diff --git a/ArduCAM/ArduCAM.cpp b/ArduCAM/ArduCAM.cpp index c88c33d1..434ab7c7 100644 --- a/ArduCAM/ArduCAM.cpp +++ b/ArduCAM/ArduCAM.cpp @@ -7,33 +7,33 @@ http://www.ArduCAM.com Now supported controllers: - - OV7670 - - MT9D111 - - OV7675 - - OV2640 - - OV3640 - - OV5642 - - OV7660 - - OV7725 - - MT9M112 - - MT9V111 - - OV5640 - - MT9M001 - - MT9T112 - - MT9D112 + - OV7670 + - MT9D111 + - OV7675 + - OV2640 + - OV3640 + - OV5642 + - OV7660 + - OV7725 + - MT9M112 + - MT9V111 + - OV5640 + - MT9M001 + - MT9T112 + - MT9D112 We will add support for many other sensors in next release. Supported MCU platform - - Theoretically support all Arduino families - - Arduino UNO R3 (Tested) - - Arduino MEGA2560 R3 (Tested) - - Arduino Leonardo R3 (Tested) - - Arduino Nano (Tested) - - Arduino DUE (Tested) - - Arduino Yun (Tested) - - Raspberry Pi (Tested) - - ESP8266-12 (Tested) + - Theoretically support all Arduino families + - Arduino UNO R3 (Tested) + - Arduino MEGA2560 R3 (Tested) + - Arduino Leonardo R3 (Tested) + - Arduino Nano (Tested) + - Arduino DUE (Tested) + - Arduino Yun (Tested) + - Raspberry Pi (Tested) + - ESP8266-12 (Tested) If you make any modifications or improvements to the code, I would appreciate that you share the code with me so that I might include it in the next release. @@ -62,15 +62,15 @@ 2012/12/13 V1.2.0 by Lee Add support for OV7675 sensor 2012/12/28 V1.3.0 by Lee Add support for OV2640,OV3640,OV5642 sensors 2013/02/26 V2.0.0 by Lee New Rev.B shield hardware, add support for FIFO control - and support Mega1280/2560 boards + and support Mega1280/2560 boards 2013/05/28 V2.1.0 by Lee Add support all drawing functions derived from UTFT library 2013/08/24 V3.0.0 by Lee Support ArudCAM shield Rev.C hardware, features SPI interface and low power mode. - Support almost all series of Arduino boards including DUE. + Support almost all series of Arduino boards including DUE. 2014/02/06 V3.0.1 by Lee Minor change to the library, fixed some bugs, add self test code to the sketches for easy debugging. 2014/03/09 V3.1.0 by Lee Add the more impressive example sketches. - Optimise the OV5642 settings, improve image quality. - Add live preview before JPEG capture. - Add play back photos one by one after BMP capture. + Optimise the OV5642 settings, improve image quality. + Add live preview before JPEG capture. + Add play back photos one by one after BMP capture. 2014/05/01 V3.1.1 by Lee Minor changes to add support Arduino IDE for linux distributions. 2014/09/30 V3.2.0 by Lee Improvement on OV5642 camera dirver. 2014/10/06 V3.3.0 by Lee Add OV7660,OV7725 camera support. @@ -87,582 +87,583 @@ 2016/06/07 V3.5.0 by Lee Add support for OV5642_CAM_BIT_ROTATION_FIXED. 2016/06/14 V3.5.1 by Lee Add support for ArduCAM-Mini-5MP-Plus OV5640_CAM. 2016/09/29 V3.5.2 by Lee Optimize the OV5642 register settings - 2016/10/05 V4.0.0 by Lee Add support for second generation hardware platforms like ArduCAM shield V2, ArduCAM-Mini-5MP-Plus(OV5642/OV5640). + 2016/10/05 V4.0.0 by Lee Add support for second generation hardware platforms like ArduCAM shield V2, ArduCAM-Mini-5MP-Plus(OV5642/OV5640). 2016/10/28 V4.0.1 by Lee Add support for Raspberry Pi 2017/04/27 V4.1.0 by Lee Add support for OV2640/OV5640/OV5642 functions. 2017/07/07 V4.1.0 by Lee Add support for ArduCAM_ESP32 paltform 2017/07/25 V4.1.1 by Lee Add support for MT9V034 --------------------------------------*/ #include "memorysaver.h" -#if defined ( RASPBERRY_PI ) - #include - #include - #include - #include - #include - #include - #include - #include - #include "ArduCAM.h" - #include "arducam_arch_raspberrypi.h" +#if defined(RASPBERRY_PI) +#include +#include +#include +#include +#include +#include +#include +#include +#include "ArduCAM.h" +#include "arducam_arch_raspberrypi.h" #else - #include "Arduino.h" - #include "ArduCAM.h" - #include - #include - #include "HardwareSerial.h" - #if defined(__SAM3X8E__) - #define Wire Wire1 - #endif +#include "Arduino.h" +#include "ArduCAM.h" +#include +#include +#include "HardwareSerial.h" +#if defined(__SAM3X8E__) +#define Wire Wire1 +#endif #endif - ArduCAM::ArduCAM() { - sensor_model = OV7670; - sensor_addr = 0x42; + sensor_model = OV7670; + sensor_addr = 0x42; } -ArduCAM::ArduCAM(byte model ,int CS) +ArduCAM::ArduCAM(byte model, int CS) { - #if defined (RASPBERRY_PI) - if(CS>=0) - { - B_CS = CS; - } - #else - #if (defined(ESP8266)||defined(ESP32)||defined(TEENSYDUINO) ||defined(NRF52840_XXAA)) - B_CS = CS; - #else - P_CS = portOutputRegister(digitalPinToPort(CS)); - B_CS = digitalPinToBitMask(CS); - #endif - #endif - #if defined (RASPBERRY_PI) - // pinMode(CS, OUTPUT); - #else - pinMode(CS, OUTPUT); - sbi(P_CS, B_CS); - #endif +#if defined(RASPBERRY_PI) + if (CS >= 0) + { + B_CS = CS; + } +#else +#if (defined(ESP8266) || defined(ESP32) || defined(TEENSYDUINO) || defined(NRF52840_XXAA)) + B_CS = CS; +#else + P_CS = portOutputRegister(digitalPinToPort(CS)); + B_CS = digitalPinToBitMask(CS); +#endif +#endif +#if defined(RASPBERRY_PI) + // pinMode(CS, OUTPUT); +#else + pinMode(CS, OUTPUT); + sbi(P_CS, B_CS); +#endif sensor_model = model; switch (sensor_model) { - case OV7660: - case OV7670: - case OV7675: - case OV7725: - #if defined (RASPBERRY_PI) - sensor_addr = 0x21; - #else - sensor_addr = 0x42; - #endif - break; - case MT9D111_A: //Standard MT9D111 module - sensor_addr = 0xba; - break; - case MT9D111_B: //Flex MT9D111 AF module - sensor_addr = 0x90; - break; - case MT9M112: - #if defined (RASPBERRY_PI) - sensor_addr = 0x5d; - #else - sensor_addr = 0x90; - #endif - break; - case MT9M001: - sensor_addr = 0xba; - break; - case MT9V034: - sensor_addr = 0x90; - break; - case MT9M034: - sensor_addr = 0x20;// 7 bits - break; - case OV3640: - case OV5640: - case OV5642: - case MT9T112: - case MT9D112: - #if defined (RASPBERRY_PI) - sensor_addr = 0x3c; - #else - sensor_addr = 0x78; - #endif - break; - case OV2640: - case OV9650: - case OV9655: - #if defined (RASPBERRY_PI) - sensor_addr = 0x30; - #else - sensor_addr = 0x60; - #endif - break; - default: - #if defined (RASPBERRY_PI) - sensor_addr = 0x21; - #else - sensor_addr = 0x42; - #endif - break; - } - #if defined (RASPBERRY_PI) - // initialize i2c: - if (!arducam_i2c_init(sensor_addr)) { + case OV7660: + case OV7670: + case OV7675: + case OV7725: +#if defined(RASPBERRY_PI) + sensor_addr = 0x21; +#else + sensor_addr = 0x42; +#endif + break; + case MT9D111_A: // Standard MT9D111 module + sensor_addr = 0xba; + break; + case MT9D111_B: // Flex MT9D111 AF module + sensor_addr = 0x90; + break; + case MT9M112: +#if defined(RASPBERRY_PI) + sensor_addr = 0x5d; +#else + sensor_addr = 0x90; +#endif + break; + case MT9M001: + sensor_addr = 0xba; + break; + case MT9V034: + sensor_addr = 0x90; + break; + case MT9M034: + sensor_addr = 0x20; // 7 bits + break; + case OV3640: + case OV5640: + case OV5642: + case MT9T112: + case MT9D112: +#if defined(RASPBERRY_PI) + sensor_addr = 0x3c; +#else + sensor_addr = 0x78; +#endif + break; + case OV2640: + case OV9650: + case OV9655: +#if defined(RASPBERRY_PI) + sensor_addr = 0x30; +#else + sensor_addr = 0x60; +#endif + break; + default: +#if defined(RASPBERRY_PI) + sensor_addr = 0x21; +#else + sensor_addr = 0x42; +#endif + break; + } +#if defined(RASPBERRY_PI) + // initialize i2c: + if (!arducam_i2c_init(sensor_addr)) + { printf("ERROR: I2C init failed\n"); } - #endif +#endif } void ArduCAM::InitCAM() { - - switch (sensor_model) - { - case OV7660: - { + + switch (sensor_model) + { + case OV7660: + { #if defined OV7660_CAM - wrSensorReg8_8(0x12, 0x80); - delay(100); - wrSensorRegs8_8(OV7660_QVGA); -#endif - break; - } - case OV7725: - { + wrSensorReg8_8(0x12, 0x80); + delay(100); + wrSensorRegs8_8(OV7660_QVGA); +#endif + break; + } + case OV7725: + { #if defined OV7725_CAM - byte reg_val; - wrSensorReg8_8(0x12, 0x80); - delay(100); - wrSensorRegs8_8(OV7725_QVGA); - rdSensorReg8_8(0x15, ®_val); - wrSensorReg8_8(0x15, (reg_val | 0x02)); -#endif - break; - } - case OV7670: - { + byte reg_val; + wrSensorReg8_8(0x12, 0x80); + delay(100); + wrSensorRegs8_8(OV7725_QVGA); + rdSensorReg8_8(0x15, ®_val); + wrSensorReg8_8(0x15, (reg_val | 0x02)); +#endif + break; + } + case OV7670: + { #if defined OV7670_CAM - wrSensorReg8_8(0x12, 0x80); - delay(100); - wrSensorRegs8_8(OV7670_QVGA); -#endif - break; - } - case OV7675: - { + wrSensorReg8_8(0x12, 0x80); + delay(100); + wrSensorRegs8_8(OV7670_QVGA); +#endif + break; + } + case OV7675: + { #if defined OV7675_CAM - wrSensorReg8_8(0x12, 0x80); - delay(100); - wrSensorRegs8_8(OV7675_QVGA); + wrSensorReg8_8(0x12, 0x80); + delay(100); + wrSensorRegs8_8(OV7675_QVGA); #endif - break; - } - case MT9D111_A: - { + break; + } + case MT9D111_A: + { #if defined MT9D111A_CAM - wrSensorRegs8_16(MT9D111_QVGA_30fps); - delay(1000); - wrSensorReg8_16(0x97, 0x0020); - wrSensorReg8_16(0xf0, 0x00); - wrSensorReg8_16(0x21, 0x8403); //Mirror Column - wrSensorReg8_16(0xC6, 0xA103);//SEQ_CMD - wrSensorReg8_16(0xC8, 0x0005); //SEQ_CMD -#endif - break; - - } - case MT9D111_B: - { - #if defined MT9D111B_CAM - wrSensorRegs8_16(MT9D111_QVGA_30fps); - delay(1000); - wrSensorReg8_16(0x97, 0x0020); - wrSensorReg8_16(0xf0, 0x00); - wrSensorReg8_16(0x21, 0x8403); //Mirror Column - wrSensorReg8_16(0xC6, 0xA103);//SEQ_CMD - wrSensorReg8_16(0xC8, 0x0005); //SEQ_CMD - #endif - break; - - } - case OV5642: - { -#if ( defined(OV5642_CAM) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) ) - wrSensorReg16_8(0x3008, 0x80); - if (m_fmt == RAW){ - //Init and set 640x480; - wrSensorRegs16_8(OV5642_1280x960_RAW); - wrSensorRegs16_8(OV5642_640x480_RAW); - }else{ - wrSensorRegs16_8(OV5642_QVGA_Preview); - #if defined (RASPBERRY_PI) - arducam_delay_ms(100); - #else - delay(100); - #endif - if (m_fmt == JPEG) - { - #if defined (RASPBERRY_PI) - arducam_delay_ms(100); - #else - delay(100); - #endif - wrSensorRegs16_8(OV5642_JPEG_Capture_QSXGA); - wrSensorRegs16_8(ov5642_320x240); - #if defined (RASPBERRY_PI) - arducam_delay_ms(100); - #else - delay(100); - #endif - wrSensorReg16_8(0x3818, 0xa8); - wrSensorReg16_8(0x3621, 0x10); - wrSensorReg16_8(0x3801, 0xb0); - #if (defined(OV5642_MINI_5MP_PLUS) || (defined ARDUCAM_SHIELD_V2)) - wrSensorReg16_8(0x4407, 0x08); - #else - wrSensorReg16_8(0x4407, 0x0C); - #endif - wrSensorReg16_8(0x5888, 0x00); - wrSensorReg16_8(0x5000, 0xFF); - } - else - { - - byte reg_val; - wrSensorReg16_8(0x4740, 0x21); - wrSensorReg16_8(0x501e, 0x2a); - wrSensorReg16_8(0x5002, 0xf8); - wrSensorReg16_8(0x501f, 0x01); - wrSensorReg16_8(0x4300, 0x61); - rdSensorReg16_8(0x3818, ®_val); - wrSensorReg16_8(0x3818, (reg_val | 0x60) & 0xff); - rdSensorReg16_8(0x3621, ®_val); - wrSensorReg16_8(0x3621, reg_val & 0xdf); - } - } - -#endif - break; - } - case OV5640: - { -#if ( defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS) ) - delay(100); - if (m_fmt == JPEG) - { - wrSensorReg16_8(0x3103, 0x11); - wrSensorReg16_8(0x3008, 0x82); - delay(100); - wrSensorRegs16_8(OV5640YUV_Sensor_Dvp_Init); - delay(500); - wrSensorRegs16_8(OV5640_JPEG_QSXGA); - wrSensorRegs16_8(OV5640_QSXGA2QVGA); - #if (defined(OV5640_MINI_5MP_PLUS) || (defined ARDUCAM_SHIELD_V2)) - wrSensorReg16_8(0x4407, 0x04); - #else - wrSensorReg16_8(0x4407, 0x0C); - #endif - } - else - { - wrSensorReg16_8(0x3103, 0x11); - wrSensorReg16_8(0x3008, 0x82); - delay(500); - wrSensorRegs16_8(OV5640YUV_Sensor_Dvp_Init); - wrSensorRegs16_8(OV5640_RGB_QVGA); - } - -#endif - break; - } - case OV3640: - { + wrSensorRegs8_16(MT9D111_QVGA_30fps); + delay(1000); + wrSensorReg8_16(0x97, 0x0020); + wrSensorReg8_16(0xf0, 0x00); + wrSensorReg8_16(0x21, 0x8403); // Mirror Column + wrSensorReg8_16(0xC6, 0xA103); // SEQ_CMD + wrSensorReg8_16(0xC8, 0x0005); // SEQ_CMD +#endif + break; + } + case MT9D111_B: + { +#if defined MT9D111B_CAM + wrSensorRegs8_16(MT9D111_QVGA_30fps); + delay(1000); + wrSensorReg8_16(0x97, 0x0020); + wrSensorReg8_16(0xf0, 0x00); + wrSensorReg8_16(0x21, 0x8403); // Mirror Column + wrSensorReg8_16(0xC6, 0xA103); // SEQ_CMD + wrSensorReg8_16(0xC8, 0x0005); // SEQ_CMD +#endif + break; + } + case OV5642: + { +#if (defined(OV5642_CAM) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS)) + wrSensorReg16_8(0x3008, 0x80); + if (m_fmt == RAW) + { + // Init and set 640x480; + wrSensorRegs16_8(OV5642_1280x960_RAW); + wrSensorRegs16_8(OV5642_640x480_RAW); + } + else + { + wrSensorRegs16_8(OV5642_QVGA_Preview); +#if defined(RASPBERRY_PI) + arducam_delay_ms(100); +#else + delay(100); +#endif + if (m_fmt == JPEG) + { +#if defined(RASPBERRY_PI) + arducam_delay_ms(100); +#else + delay(100); +#endif + wrSensorRegs16_8(OV5642_JPEG_Capture_QSXGA); + wrSensorRegs16_8(ov5642_320x240); +#if defined(RASPBERRY_PI) + arducam_delay_ms(100); +#else + delay(100); +#endif + wrSensorReg16_8(0x3818, 0xa8); + wrSensorReg16_8(0x3621, 0x10); + wrSensorReg16_8(0x3801, 0xb0); +#if (defined(OV5642_MINI_5MP_PLUS) || (defined ARDUCAM_SHIELD_V2)) + wrSensorReg16_8(0x4407, 0x08); +#else + wrSensorReg16_8(0x4407, 0x0C); +#endif + wrSensorReg16_8(0x5888, 0x00); + wrSensorReg16_8(0x5000, 0xFF); + } + else + { + + byte reg_val; + wrSensorReg16_8(0x4740, 0x21); + wrSensorReg16_8(0x501e, 0x2a); + wrSensorReg16_8(0x5002, 0xf8); + wrSensorReg16_8(0x501f, 0x01); + wrSensorReg16_8(0x4300, 0x61); + rdSensorReg16_8(0x3818, ®_val); + wrSensorReg16_8(0x3818, (reg_val | 0x60) & 0xff); + rdSensorReg16_8(0x3621, ®_val); + wrSensorReg16_8(0x3621, reg_val & 0xdf); + } + } + +#endif + break; + } + case OV5640: + { +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + delay(100); + if (m_fmt == JPEG) + { + wrSensorReg16_8(0x3103, 0x11); + wrSensorReg16_8(0x3008, 0x82); + delay(100); + wrSensorRegs16_8(OV5640YUV_Sensor_Dvp_Init); + delay(500); + wrSensorRegs16_8(OV5640_JPEG_QSXGA); + wrSensorRegs16_8(OV5640_QSXGA2QVGA); +#if (defined(OV5640_MINI_5MP_PLUS) || (defined ARDUCAM_SHIELD_V2)) + wrSensorReg16_8(0x4407, 0x04); +#else + wrSensorReg16_8(0x4407, 0x0C); +#endif + } + else + { + wrSensorReg16_8(0x3103, 0x11); + wrSensorReg16_8(0x3008, 0x82); + delay(500); + wrSensorRegs16_8(OV5640YUV_Sensor_Dvp_Init); + wrSensorRegs16_8(OV5640_RGB_QVGA); + } + +#endif + break; + } + case OV3640: + { #if defined OV3640_CAM - wrSensorRegs16_8(OV3640_QVGA); + wrSensorRegs16_8(OV3640_QVGA); #endif - break; - } - case OV2640: - { + break; + } + case OV2640: + { #if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) - wrSensorReg8_8(0xff, 0x01); - wrSensorReg8_8(0x12, 0x80); - delay(100); - if (m_fmt == JPEG) - { - wrSensorRegs8_8(OV2640_JPEG_INIT); - wrSensorRegs8_8(OV2640_YUV422); - wrSensorRegs8_8(OV2640_JPEG); - wrSensorReg8_8(0xff, 0x01); - wrSensorReg8_8(0x15, 0x00); - wrSensorRegs8_8(OV2640_320x240_JPEG); - //wrSensorReg8_8(0xff, 0x00); - //wrSensorReg8_8(0x44, 0x32); - } - else - { - wrSensorRegs8_8(OV2640_QVGA); - } -#endif - break; - } - case OV9655: - { - - break; - } - case MT9M112: - { + wrSensorReg8_8(0xff, 0x01); + wrSensorReg8_8(0x12, 0x80); + delay(100); + if (m_fmt == JPEG) + { + wrSensorRegs8_8(OV2640_JPEG_INIT); + wrSensorRegs8_8(OV2640_YUV422); + wrSensorRegs8_8(OV2640_JPEG); + wrSensorReg8_8(0xff, 0x01); + wrSensorReg8_8(0x15, 0x00); + wrSensorRegs8_8(OV2640_320x240_JPEG); + // wrSensorReg8_8(0xff, 0x00); + // wrSensorReg8_8(0x44, 0x32); + } + else + { + wrSensorRegs8_8(OV2640_QVGA); + } +#endif + break; + } + case OV9655: + { + + break; + } + case MT9M112: + { #if defined MT9M112_CAM - wrSensorRegs8_16(MT9M112_QVGA); + wrSensorRegs8_16(MT9M112_QVGA); #endif - break; - } - - case MT9M034: - { + break; + } + + case MT9M034: + { #if defined MT9M034_CAM - wrSensorRegs16_16(MT9M034_RAW); + wrSensorRegs16_16(MT9M034_RAW); #endif - break; - } - - case MT9V111: - { + break; + } + + case MT9V111: + { #if defined MT9V111_CAM - //Reset sensor core - wrSensorReg8_16(0x01, 0x04); - wrSensorReg8_16(0x0D, 0x01); - wrSensorReg8_16(0x0D, 0x00); - //Reset IFP - wrSensorReg8_16(0x01, 0x01); - wrSensorReg8_16(0x07, 0x01); - wrSensorReg8_16(0x07, 0x00); - delay(100); - wrSensorRegs8_16(MT9V111_QVGA); - //delay(1000); - wrSensorReg8_16(0x97, 0x0020); - wrSensorReg8_16(0xf0, 0x00); - wrSensorReg8_16(0x21, 0x8403); //Mirror Column - wrSensorReg8_16(0xC6, 0xA103);//SEQ_CMD - wrSensorReg8_16(0xC8, 0x0005); //SEQ_CMD -#endif - break; - } - - case MT9M001: - { + // Reset sensor core + wrSensorReg8_16(0x01, 0x04); + wrSensorReg8_16(0x0D, 0x01); + wrSensorReg8_16(0x0D, 0x00); + // Reset IFP + wrSensorReg8_16(0x01, 0x01); + wrSensorReg8_16(0x07, 0x01); + wrSensorReg8_16(0x07, 0x00); + delay(100); + wrSensorRegs8_16(MT9V111_QVGA); + // delay(1000); + wrSensorReg8_16(0x97, 0x0020); + wrSensorReg8_16(0xf0, 0x00); + wrSensorReg8_16(0x21, 0x8403); // Mirror Column + wrSensorReg8_16(0xC6, 0xA103); // SEQ_CMD + wrSensorReg8_16(0xC8, 0x0005); // SEQ_CMD +#endif + break; + } + + case MT9M001: + { #if defined MT9M001_CAM - wrSensorRegs8_16(MT9M001_QVGA_30fps); + wrSensorRegs8_16(MT9M001_QVGA_30fps); #endif - break; - } - case MT9T112: - { + break; + } + case MT9T112: + { #if defined MT9T112_CAM - wrSensorReg16_16(0x001a , 0x0219 ); - wrSensorReg16_16(0x001a , 0x0018 ); - //reset camera - wrSensorReg16_16(0x0014 , 0x2425 ); - wrSensorReg16_16(0x0014 , 0x2145 ); - wrSensorReg16_16(0x0010 , 0x0110 ); - wrSensorReg16_16(0x0012 , 0x00f0 ); - wrSensorReg16_16(0x002a , 0x7f77 ); - wrSensorReg16_16(0x0014 , 0x2545 ); - wrSensorReg16_16(0x0014 , 0x2547 ); - wrSensorReg16_16(0x0014 , 0x3447 ); - wrSensorReg16_16(0x0014 , 0x3047 ); - delay(10); - wrSensorReg16_16(0x0014 , 0x3046 ); - wrSensorReg16_16(0x0022 , 0x01f4 ); - wrSensorReg16_16(0x001e , 0x0707 ); - wrSensorReg16_16(0x3b84 , 0x01f4 ); - wrSensorReg16_16(0x002e , 0x0500 ); - wrSensorReg16_16(0x0018 , 0x402b ); - wrSensorReg16_16(0x3b82 , 0x0004 ); - wrSensorReg16_16(0x0018 , 0x402f ); - wrSensorReg16_16(0x0018 , 0x402e ); - delay(50); - wrSensorReg16_16(0x0614 , 0x0001 ); - delay(1); - wrSensorReg16_16(0x0614 , 0x0001 ); - delay(1); - wrSensorReg16_16(0x0614 , 0x0001 ); - delay(1); - wrSensorReg16_16(0x0614 , 0x0001 ); - delay(1); - wrSensorReg16_16(0x0614 , 0x0001 ); - delay(1); - wrSensorReg16_16(0x0614 , 0x0001 ); - delay(1); - delay(10); - //init pll - wrSensorReg16_16(0x098e , 0x6800 ); - wrSensorReg16_16(0x0990 , 0x0140 ); - wrSensorReg16_16(0x098e , 0x6802 ); - wrSensorReg16_16(0x0990 , 0x00f0 ); - wrSensorReg16_16(0x098e , 0x68a0 ); - wrSensorReg16_16(0x098e , 0x68a0 ); - wrSensorReg16_16(0x0990 , 0x082d ); - wrSensorReg16_16(0x098e , 0x4802 ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x098e , 0x4804 ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x098e , 0x4806 ); - wrSensorReg16_16(0x0990 , 0x060d ); - wrSensorReg16_16(0x098e , 0x4808 ); - wrSensorReg16_16(0x0990 , 0x080d ); - wrSensorReg16_16(0x098e , 0x480c ); - wrSensorReg16_16(0x0990 , 0x046c ); - wrSensorReg16_16(0x098e , 0x480f ); - wrSensorReg16_16(0x0990 , 0x00cc ); - wrSensorReg16_16(0x098e , 0x4811 ); - wrSensorReg16_16(0x0990 , 0x0381 ); - wrSensorReg16_16(0x098e , 0x4813 ); - wrSensorReg16_16(0x0990 , 0x024f ); - wrSensorReg16_16(0x098e , 0x481d ); - wrSensorReg16_16(0x0990 , 0x0436 ); - wrSensorReg16_16(0x098e , 0x481f ); - wrSensorReg16_16(0x0990 , 0x05d0 ); - wrSensorReg16_16(0x098e , 0x4825 ); - wrSensorReg16_16(0x0990 , 0x1153 ); - wrSensorReg16_16(0x098e , 0x6ca0 ); - wrSensorReg16_16(0x098e , 0x6ca0 ); - wrSensorReg16_16(0x0990 , 0x082d ); - wrSensorReg16_16(0x098e , 0x484a ); - wrSensorReg16_16(0x0990 , 0x0004 ); - wrSensorReg16_16(0x098e , 0x484c ); - wrSensorReg16_16(0x0990 , 0x0004 ); - wrSensorReg16_16(0x098e , 0x484e ); - wrSensorReg16_16(0x0990 , 0x060b ); - wrSensorReg16_16(0x098e , 0x4850 ); - wrSensorReg16_16(0x0990 , 0x080b ); - wrSensorReg16_16(0x098e , 0x4857 ); - wrSensorReg16_16(0x0990 , 0x008c ); - wrSensorReg16_16(0x098e , 0x4859 ); - wrSensorReg16_16(0x0990 , 0x01f1 ); - wrSensorReg16_16(0x098e , 0x485b ); - wrSensorReg16_16(0x0990 , 0x00ff ); - wrSensorReg16_16(0x098e , 0x4865 ); - wrSensorReg16_16(0x0990 , 0x0668 ); - wrSensorReg16_16(0x098e , 0x4867 ); - wrSensorReg16_16(0x0990 , 0x0af0 ); - wrSensorReg16_16(0x098e , 0x486d ); - wrSensorReg16_16(0x0990 , 0x0af0 ); - wrSensorReg16_16(0x098e , 0xa005 ); - wrSensorReg16_16(0x0990 , 0x0001 ); - wrSensorReg16_16(0x098e , 0x6c11 ); - wrSensorReg16_16(0x0990 , 0x0003 ); - wrSensorReg16_16(0x098e , 0x6811 ); - wrSensorReg16_16(0x0990 , 0x0003 ); - wrSensorReg16_16(0x098e , 0xc8a5 ); - wrSensorReg16_16(0x0990 , 0x0025 ); - wrSensorReg16_16(0x098e , 0xc8a6 ); - wrSensorReg16_16(0x0990 , 0x0028 ); - wrSensorReg16_16(0x098e , 0xc8a7 ); - wrSensorReg16_16(0x0990 , 0x002c ); - wrSensorReg16_16(0x098e , 0xc8a8 ); - wrSensorReg16_16(0x0990 , 0x002f ); - wrSensorReg16_16(0x098e , 0xc844 ); - wrSensorReg16_16(0x0990 , 0x00ba ); - wrSensorReg16_16(0x098e , 0xc92f ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x098e , 0xc845 ); - wrSensorReg16_16(0x0990 , 0x009b ); - wrSensorReg16_16(0x098e , 0xc92d ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x098e , 0xc88c ); - wrSensorReg16_16(0x0990 , 0x0082 ); - wrSensorReg16_16(0x098e , 0xc930 ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x098e , 0xc88d ); - wrSensorReg16_16(0x0990 , 0x006d ); - wrSensorReg16_16(0x098e , 0xc92e ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x098e , 0xa002 ); - wrSensorReg16_16(0x0990 , 0x0010 ); - wrSensorReg16_16(0x098e , 0xa009 ); - wrSensorReg16_16(0x0990 , 0x0002 ); - wrSensorReg16_16(0x098e , 0xa00a ); - wrSensorReg16_16(0x0990 , 0x0003 ); - wrSensorReg16_16(0x098e , 0xa00c ); - wrSensorReg16_16(0x0990 , 0x000a ); - wrSensorReg16_16(0x098e , 0x4846 ); - wrSensorReg16_16(0x0990 , 0x0014 ); - wrSensorReg16_16(0x098e , 0x488e ); - wrSensorReg16_16(0x0990 , 0x0014 ); - wrSensorReg16_16(0x098e , 0xc844 ); - wrSensorReg16_16(0x0990 , 0x0085 ); - wrSensorReg16_16(0x098e , 0xc845 ); - wrSensorReg16_16(0x0990 , 0x006e ); - wrSensorReg16_16(0x098e , 0xc88c ); - wrSensorReg16_16(0x0990 , 0x0082 ); - wrSensorReg16_16(0x098e , 0xc88d ); - wrSensorReg16_16(0x0990 , 0x006c ); - wrSensorReg16_16(0x098e , 0xc8a5 ); - wrSensorReg16_16(0x0990 , 0x001b ); - wrSensorReg16_16(0x098e , 0xc8a6 ); - wrSensorReg16_16(0x0990 , 0x001e ); - wrSensorReg16_16(0x098e , 0xc8a7 ); - wrSensorReg16_16(0x0990 , 0x0020 ); - wrSensorReg16_16(0x098e , 0xc8a8 ); - wrSensorReg16_16(0x0990 , 0x0023 ); - //init setting - wrSensorReg16_16(0x0018 , 0x002a ); - wrSensorReg16_16(0x3084 , 0x2409 ); - wrSensorReg16_16(0x3092 , 0x0a49 ); - wrSensorReg16_16(0x3094 , 0x4949 ); - wrSensorReg16_16(0x3096 , 0x4950 ); - wrSensorReg16_16(0x098e , 0x68a0 ); - wrSensorReg16_16(0x0990 , 0x0a2e ); - wrSensorReg16_16(0x098e , 0x6ca0 ); - wrSensorReg16_16(0x0990 , 0x0a2e ); - wrSensorReg16_16(0x098e , 0x6c90 ); - wrSensorReg16_16(0x0990 , 0x0cb4 ); - wrSensorReg16_16(0x098e , 0x6807 ); - wrSensorReg16_16(0x0990 , 0x0004 ); - wrSensorReg16_16(0x098e , 0xe88e ); - wrSensorReg16_16(0x0990 , 0x0000 ); - wrSensorReg16_16(0x316c , 0x350f ); - wrSensorReg16_16(0x001e , 0x0777 ); - wrSensorReg16_16(0x098e , 0x8400 ); - wrSensorReg16_16(0x0990 , 0x0001 ); - delay(100); - wrSensorReg16_16(0x098e , 0x8400 ); - wrSensorReg16_16(0x0990 , 0x0006 ); - //Serial.println("MT9T112 init done"); -#endif - break; - } - case MT9D112: - { + wrSensorReg16_16(0x001a, 0x0219); + wrSensorReg16_16(0x001a, 0x0018); + // reset camera + wrSensorReg16_16(0x0014, 0x2425); + wrSensorReg16_16(0x0014, 0x2145); + wrSensorReg16_16(0x0010, 0x0110); + wrSensorReg16_16(0x0012, 0x00f0); + wrSensorReg16_16(0x002a, 0x7f77); + wrSensorReg16_16(0x0014, 0x2545); + wrSensorReg16_16(0x0014, 0x2547); + wrSensorReg16_16(0x0014, 0x3447); + wrSensorReg16_16(0x0014, 0x3047); + delay(10); + wrSensorReg16_16(0x0014, 0x3046); + wrSensorReg16_16(0x0022, 0x01f4); + wrSensorReg16_16(0x001e, 0x0707); + wrSensorReg16_16(0x3b84, 0x01f4); + wrSensorReg16_16(0x002e, 0x0500); + wrSensorReg16_16(0x0018, 0x402b); + wrSensorReg16_16(0x3b82, 0x0004); + wrSensorReg16_16(0x0018, 0x402f); + wrSensorReg16_16(0x0018, 0x402e); + delay(50); + wrSensorReg16_16(0x0614, 0x0001); + delay(1); + wrSensorReg16_16(0x0614, 0x0001); + delay(1); + wrSensorReg16_16(0x0614, 0x0001); + delay(1); + wrSensorReg16_16(0x0614, 0x0001); + delay(1); + wrSensorReg16_16(0x0614, 0x0001); + delay(1); + wrSensorReg16_16(0x0614, 0x0001); + delay(1); + delay(10); + // init pll + wrSensorReg16_16(0x098e, 0x6800); + wrSensorReg16_16(0x0990, 0x0140); + wrSensorReg16_16(0x098e, 0x6802); + wrSensorReg16_16(0x0990, 0x00f0); + wrSensorReg16_16(0x098e, 0x68a0); + wrSensorReg16_16(0x098e, 0x68a0); + wrSensorReg16_16(0x0990, 0x082d); + wrSensorReg16_16(0x098e, 0x4802); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x098e, 0x4804); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x098e, 0x4806); + wrSensorReg16_16(0x0990, 0x060d); + wrSensorReg16_16(0x098e, 0x4808); + wrSensorReg16_16(0x0990, 0x080d); + wrSensorReg16_16(0x098e, 0x480c); + wrSensorReg16_16(0x0990, 0x046c); + wrSensorReg16_16(0x098e, 0x480f); + wrSensorReg16_16(0x0990, 0x00cc); + wrSensorReg16_16(0x098e, 0x4811); + wrSensorReg16_16(0x0990, 0x0381); + wrSensorReg16_16(0x098e, 0x4813); + wrSensorReg16_16(0x0990, 0x024f); + wrSensorReg16_16(0x098e, 0x481d); + wrSensorReg16_16(0x0990, 0x0436); + wrSensorReg16_16(0x098e, 0x481f); + wrSensorReg16_16(0x0990, 0x05d0); + wrSensorReg16_16(0x098e, 0x4825); + wrSensorReg16_16(0x0990, 0x1153); + wrSensorReg16_16(0x098e, 0x6ca0); + wrSensorReg16_16(0x098e, 0x6ca0); + wrSensorReg16_16(0x0990, 0x082d); + wrSensorReg16_16(0x098e, 0x484a); + wrSensorReg16_16(0x0990, 0x0004); + wrSensorReg16_16(0x098e, 0x484c); + wrSensorReg16_16(0x0990, 0x0004); + wrSensorReg16_16(0x098e, 0x484e); + wrSensorReg16_16(0x0990, 0x060b); + wrSensorReg16_16(0x098e, 0x4850); + wrSensorReg16_16(0x0990, 0x080b); + wrSensorReg16_16(0x098e, 0x4857); + wrSensorReg16_16(0x0990, 0x008c); + wrSensorReg16_16(0x098e, 0x4859); + wrSensorReg16_16(0x0990, 0x01f1); + wrSensorReg16_16(0x098e, 0x485b); + wrSensorReg16_16(0x0990, 0x00ff); + wrSensorReg16_16(0x098e, 0x4865); + wrSensorReg16_16(0x0990, 0x0668); + wrSensorReg16_16(0x098e, 0x4867); + wrSensorReg16_16(0x0990, 0x0af0); + wrSensorReg16_16(0x098e, 0x486d); + wrSensorReg16_16(0x0990, 0x0af0); + wrSensorReg16_16(0x098e, 0xa005); + wrSensorReg16_16(0x0990, 0x0001); + wrSensorReg16_16(0x098e, 0x6c11); + wrSensorReg16_16(0x0990, 0x0003); + wrSensorReg16_16(0x098e, 0x6811); + wrSensorReg16_16(0x0990, 0x0003); + wrSensorReg16_16(0x098e, 0xc8a5); + wrSensorReg16_16(0x0990, 0x0025); + wrSensorReg16_16(0x098e, 0xc8a6); + wrSensorReg16_16(0x0990, 0x0028); + wrSensorReg16_16(0x098e, 0xc8a7); + wrSensorReg16_16(0x0990, 0x002c); + wrSensorReg16_16(0x098e, 0xc8a8); + wrSensorReg16_16(0x0990, 0x002f); + wrSensorReg16_16(0x098e, 0xc844); + wrSensorReg16_16(0x0990, 0x00ba); + wrSensorReg16_16(0x098e, 0xc92f); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x098e, 0xc845); + wrSensorReg16_16(0x0990, 0x009b); + wrSensorReg16_16(0x098e, 0xc92d); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x098e, 0xc88c); + wrSensorReg16_16(0x0990, 0x0082); + wrSensorReg16_16(0x098e, 0xc930); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x098e, 0xc88d); + wrSensorReg16_16(0x0990, 0x006d); + wrSensorReg16_16(0x098e, 0xc92e); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x098e, 0xa002); + wrSensorReg16_16(0x0990, 0x0010); + wrSensorReg16_16(0x098e, 0xa009); + wrSensorReg16_16(0x0990, 0x0002); + wrSensorReg16_16(0x098e, 0xa00a); + wrSensorReg16_16(0x0990, 0x0003); + wrSensorReg16_16(0x098e, 0xa00c); + wrSensorReg16_16(0x0990, 0x000a); + wrSensorReg16_16(0x098e, 0x4846); + wrSensorReg16_16(0x0990, 0x0014); + wrSensorReg16_16(0x098e, 0x488e); + wrSensorReg16_16(0x0990, 0x0014); + wrSensorReg16_16(0x098e, 0xc844); + wrSensorReg16_16(0x0990, 0x0085); + wrSensorReg16_16(0x098e, 0xc845); + wrSensorReg16_16(0x0990, 0x006e); + wrSensorReg16_16(0x098e, 0xc88c); + wrSensorReg16_16(0x0990, 0x0082); + wrSensorReg16_16(0x098e, 0xc88d); + wrSensorReg16_16(0x0990, 0x006c); + wrSensorReg16_16(0x098e, 0xc8a5); + wrSensorReg16_16(0x0990, 0x001b); + wrSensorReg16_16(0x098e, 0xc8a6); + wrSensorReg16_16(0x0990, 0x001e); + wrSensorReg16_16(0x098e, 0xc8a7); + wrSensorReg16_16(0x0990, 0x0020); + wrSensorReg16_16(0x098e, 0xc8a8); + wrSensorReg16_16(0x0990, 0x0023); + // init setting + wrSensorReg16_16(0x0018, 0x002a); + wrSensorReg16_16(0x3084, 0x2409); + wrSensorReg16_16(0x3092, 0x0a49); + wrSensorReg16_16(0x3094, 0x4949); + wrSensorReg16_16(0x3096, 0x4950); + wrSensorReg16_16(0x098e, 0x68a0); + wrSensorReg16_16(0x0990, 0x0a2e); + wrSensorReg16_16(0x098e, 0x6ca0); + wrSensorReg16_16(0x0990, 0x0a2e); + wrSensorReg16_16(0x098e, 0x6c90); + wrSensorReg16_16(0x0990, 0x0cb4); + wrSensorReg16_16(0x098e, 0x6807); + wrSensorReg16_16(0x0990, 0x0004); + wrSensorReg16_16(0x098e, 0xe88e); + wrSensorReg16_16(0x0990, 0x0000); + wrSensorReg16_16(0x316c, 0x350f); + wrSensorReg16_16(0x001e, 0x0777); + wrSensorReg16_16(0x098e, 0x8400); + wrSensorReg16_16(0x0990, 0x0001); + delay(100); + wrSensorReg16_16(0x098e, 0x8400); + wrSensorReg16_16(0x0990, 0x0006); + // Serial.println("MT9T112 init done"); +#endif + break; + } + case MT9D112: + { #if defined MT9D112_CAM - wrSensorReg16_16(0x301a , 0x0acc ); - wrSensorReg16_16(0x3202 , 0x0008 ); - delay(100 ); - wrSensorReg16_16(0x341e , 0x8f09 ); - wrSensorReg16_16(0x341c , 0x020c ); - delay(100 ); - wrSensorRegs16_16(MT9D112_default_setting); - wrSensorReg16_16(0x338c , 0xa103 ); - wrSensorReg16_16(0x3390 , 0x0006 ); - delay(100 ); - wrSensorReg16_16(0x338c , 0xa103 ); - wrSensorReg16_16(0x3390 , 0x0005 ); - delay(100 ); - wrSensorRegs16_16(MT9D112_soc_init); - delay(200); - wrSensorReg16_16(0x332E, 0x0020); //RGB565 - -#endif - } - default: - - break; - } + wrSensorReg16_16(0x301a, 0x0acc); + wrSensorReg16_16(0x3202, 0x0008); + delay(100); + wrSensorReg16_16(0x341e, 0x8f09); + wrSensorReg16_16(0x341c, 0x020c); + delay(100); + wrSensorRegs16_16(MT9D112_default_setting); + wrSensorReg16_16(0x338c, 0xa103); + wrSensorReg16_16(0x3390, 0x0006); + delay(100); + wrSensorReg16_16(0x338c, 0xa103); + wrSensorReg16_16(0x3390, 0x0005); + delay(100); + wrSensorRegs16_16(MT9D112_soc_init); + delay(200); + wrSensorReg16_16(0x332E, 0x0020); // RGB565 + +#endif + } + default: + + break; + } } void ArduCAM::flush_fifo(void) @@ -675,27 +676,27 @@ void ArduCAM::start_capture(void) write_reg(ARDUCHIP_FIFO, FIFO_START_MASK); } -void ArduCAM::clear_fifo_flag(void ) +void ArduCAM::clear_fifo_flag(void) { write_reg(ARDUCHIP_FIFO, FIFO_CLEAR_MASK); } uint32_t ArduCAM::read_fifo_length(void) { - uint32_t len1,len2,len3,length=0; + uint32_t len1, len2, len3, length = 0; len1 = read_reg(FIFO_SIZE1); - len2 = read_reg(FIFO_SIZE2); - len3 = read_reg(FIFO_SIZE3) & 0x7f; - length = ((len3 << 16) | (len2 << 8) | len1) & 0x07fffff; - return length; + len2 = read_reg(FIFO_SIZE2); + len3 = read_reg(FIFO_SIZE3) & 0x7f; + length = ((len3 << 16) | (len2 << 8) | len1) & 0x07fffff; + return length; } -#if defined (RASPBERRY_PI) +#if defined(RASPBERRY_PI) uint8_t ArduCAM::transfer(uint8_t data) { - uint8_t temp; - temp = arducam_spi_transfer(data); - return temp; + uint8_t temp; + temp = arducam_spi_transfer(data); + return temp; } void ArduCAM::transfers(uint8_t *buf, uint32_t size) @@ -707,21 +708,20 @@ void ArduCAM::transfers(uint8_t *buf, uint32_t size) void ArduCAM::set_fifo_burst() { - #if defined (RASPBERRY_PI) +#if defined(RASPBERRY_PI) transfer(BURST_FIFO_READ); - #else - SPI.transfer(BURST_FIFO_READ); - #endif - +#else + SPI.transfer(BURST_FIFO_READ); +#endif } void ArduCAM::CS_HIGH(void) { - sbi(P_CS, B_CS); + sbi(P_CS, B_CS); } void ArduCAM::CS_LOW(void) { - cbi(P_CS, B_CS); + cbi(P_CS, B_CS); } uint8_t ArduCAM::read_fifo(void) @@ -734,31 +734,31 @@ uint8_t ArduCAM::read_fifo(void) uint8_t ArduCAM::read_reg(uint8_t addr) { uint8_t data; - #if defined (RASPBERRY_PI) - data = bus_read(addr); - #else - data = bus_read(addr & 0x7F); - #endif +#if defined(RASPBERRY_PI) + data = bus_read(addr); +#else + data = bus_read(addr & 0x7F); +#endif return data; } void ArduCAM::write_reg(uint8_t addr, uint8_t data) { - #if defined (RASPBERRY_PI) - bus_write(addr , data); - #else - bus_write(addr | 0x80, data); - #endif +#if defined(RASPBERRY_PI) + bus_write(addr, data); +#else + bus_write(addr | 0x80, data); +#endif } -//Set corresponding bit +// Set corresponding bit void ArduCAM::set_bit(uint8_t addr, uint8_t bit) { uint8_t temp; temp = read_reg(addr); write_reg(addr, temp | bit); } -//Clear corresponding bit +// Clear corresponding bit void ArduCAM::clear_bit(uint8_t addr, uint8_t bit) { uint8_t temp; @@ -766,2508 +766,2483 @@ void ArduCAM::clear_bit(uint8_t addr, uint8_t bit) write_reg(addr, temp & (~bit)); } -//Get corresponding bit status +// Get corresponding bit status uint8_t ArduCAM::get_bit(uint8_t addr, uint8_t bit) { - uint8_t temp; - temp = read_reg(addr); - temp = temp & bit; - return temp; + uint8_t temp; + temp = read_reg(addr); + temp = temp & bit; + return temp; } -//Set ArduCAM working mode -//MCU2LCD_MODE: MCU writes the LCD screen GRAM -//CAM2LCD_MODE: Camera takes control of the LCD screen -//LCD2MCU_MODE: MCU read the LCD screen GRAM +// Set ArduCAM working mode +// MCU2LCD_MODE: MCU writes the LCD screen GRAM +// CAM2LCD_MODE: Camera takes control of the LCD screen +// LCD2MCU_MODE: MCU read the LCD screen GRAM void ArduCAM::set_mode(uint8_t mode) { - switch (mode) - { - case MCU2LCD_MODE: - write_reg(ARDUCHIP_MODE, MCU2LCD_MODE); - break; - case CAM2LCD_MODE: - write_reg(ARDUCHIP_MODE, CAM2LCD_MODE); - break; - case LCD2MCU_MODE: - write_reg(ARDUCHIP_MODE, LCD2MCU_MODE); - break; - default: - write_reg(ARDUCHIP_MODE, MCU2LCD_MODE); - break; - } -} - -uint8_t ArduCAM::bus_write(int address,int value) -{ + switch (mode) + { + case MCU2LCD_MODE: + write_reg(ARDUCHIP_MODE, MCU2LCD_MODE); + break; + case CAM2LCD_MODE: + write_reg(ARDUCHIP_MODE, CAM2LCD_MODE); + break; + case LCD2MCU_MODE: + write_reg(ARDUCHIP_MODE, LCD2MCU_MODE); + break; + default: + write_reg(ARDUCHIP_MODE, MCU2LCD_MODE); + break; + } +} + +uint8_t ArduCAM::bus_write(int address, int value) +{ cbi(P_CS, B_CS); - #if defined (RASPBERRY_PI) - arducam_spi_write(address | 0x80, value); - #else - SPI.transfer(address); - SPI.transfer(value); - #endif +#if defined(RASPBERRY_PI) + arducam_spi_write(address | 0x80, value); +#else + SPI.transfer(address); + SPI.transfer(value); +#endif sbi(P_CS, B_CS); return 1; } -uint8_t ArduCAM:: bus_read(int address) +uint8_t ArduCAM::bus_read(int address) { uint8_t value; cbi(P_CS, B_CS); - #if defined (RASPBERRY_PI) - value = arducam_spi_read(address & 0x7F); - sbi(P_CS, B_CS); - return value; - #else - #if (defined(ESP8266) || defined(__arm__) ||defined(TEENSYDUINO)) - #if defined(OV5642_MINI_5MP) - SPI.transfer(address); - value = SPI.transfer(0x00); - // correction for bit rotation from readback - value = (byte)(value >> 1) | (value << 7); - // take the SS pin high to de-select the chip: - sbi(P_CS, B_CS); - return value; - #else - SPI.transfer(address); - value = SPI.transfer(0x00); - // take the SS pin high to de-select the chip: - sbi(P_CS, B_CS); - return value; - #endif - #else - SPI.transfer(address); - value = SPI.transfer(0x00); - // take the SS pin high to de-select the chip: - sbi(P_CS, B_CS); - return value; - #endif -#endif -} - -void ArduCAM:: OV3640_set_JPEG_size(uint8_t size) -{ -#if (defined (OV3640_CAM)||defined (OV3640_MINI_2MP)) - switch(size) - { - case OV3640_176x144: - wrSensorRegs8_8(OV3640_176x144_JPEG); - break; - case OV3640_320x240: - wrSensorRegs16_8(OV3640_320x240_JPEG); - break; - case OV3640_352x288: - wrSensorRegs16_8(OV3640_352x288_JPEG); - break; - case OV3640_640x480: - wrSensorRegs16_8(OV3640_640x480_JPEG); - break; - case OV3640_800x600: - wrSensorRegs16_8(OV3640_800x600_JPEG); - break; - case OV3640_1024x768: - wrSensorRegs16_8(OV3640_1024x768_JPEG); - break; - case OV3640_1280x960: - wrSensorRegs16_8(OV3640_1280x960_JPEG); - break; - case OV3640_1600x1200: - wrSensorRegs16_8(OV3640_1600x1200_JPEG); - break; - case OV3640_2048x1536: - wrSensorRegs16_8(OV3640_2048x1536_JPEG); - break; - default: - wrSensorRegs16_8(OV3640_320x240_JPEG); - break; +#if defined(RASPBERRY_PI) + value = arducam_spi_read(address & 0x7F); + sbi(P_CS, B_CS); + return value; +#else +#if (defined(ESP8266) || defined(__arm__) || defined(TEENSYDUINO)) +#if defined(OV5642_MINI_5MP) + SPI.transfer(address); + value = SPI.transfer(0x00); + // correction for bit rotation from readback + value = (byte)(value >> 1) | (value << 7); + // take the SS pin high to de-select the chip: + sbi(P_CS, B_CS); + return value; +#else + SPI.transfer(address); + value = SPI.transfer(0x00); + // take the SS pin high to de-select the chip: + sbi(P_CS, B_CS); + return value; +#endif +#else + SPI.transfer(address); + value = SPI.transfer(0x00); + // take the SS pin high to de-select the chip: + sbi(P_CS, B_CS); + return value; +#endif +#endif +} + +void ArduCAM::OV3640_set_JPEG_size(uint8_t size) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_2MP)) + switch (size) + { + case OV3640_176x144: + wrSensorRegs8_8(OV3640_176x144_JPEG); + break; + case OV3640_320x240: + wrSensorRegs16_8(OV3640_320x240_JPEG); + break; + case OV3640_352x288: + wrSensorRegs16_8(OV3640_352x288_JPEG); + break; + case OV3640_640x480: + wrSensorRegs16_8(OV3640_640x480_JPEG); + break; + case OV3640_800x600: + wrSensorRegs16_8(OV3640_800x600_JPEG); + break; + case OV3640_1024x768: + wrSensorRegs16_8(OV3640_1024x768_JPEG); + break; + case OV3640_1280x960: + wrSensorRegs16_8(OV3640_1280x960_JPEG); + break; + case OV3640_1600x1200: + wrSensorRegs16_8(OV3640_1600x1200_JPEG); + break; + case OV3640_2048x1536: + wrSensorRegs16_8(OV3640_2048x1536_JPEG); + break; + default: + wrSensorRegs16_8(OV3640_320x240_JPEG); + break; } #endif } void ArduCAM::OV2640_set_JPEG_size(uint8_t size) { - #if (defined (OV2640_CAM)||defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS)) - switch(size) +#if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) + switch (size) { - case OV2640_160x120: - wrSensorRegs8_8(OV2640_160x120_JPEG); - break; - case OV2640_176x144: - wrSensorRegs8_8(OV2640_176x144_JPEG); - break; - case OV2640_320x240: - wrSensorRegs8_8(OV2640_320x240_JPEG); - break; - case OV2640_352x288: - wrSensorRegs8_8(OV2640_352x288_JPEG); - break; - case OV2640_640x480: - wrSensorRegs8_8(OV2640_640x480_JPEG); - break; - case OV2640_800x600: - wrSensorRegs8_8(OV2640_800x600_JPEG); - break; - case OV2640_1024x768: - wrSensorRegs8_8(OV2640_1024x768_JPEG); - break; - case OV2640_1280x1024: - wrSensorRegs8_8(OV2640_1280x1024_JPEG); - break; - case OV2640_1600x1200: - wrSensorRegs8_8(OV2640_1600x1200_JPEG); - break; - default: - wrSensorRegs8_8(OV2640_320x240_JPEG); - break; + case OV2640_160x120: + wrSensorRegs8_8(OV2640_160x120_JPEG); + break; + case OV2640_176x144: + wrSensorRegs8_8(OV2640_176x144_JPEG); + break; + case OV2640_320x240: + wrSensorRegs8_8(OV2640_320x240_JPEG); + break; + case OV2640_352x288: + wrSensorRegs8_8(OV2640_352x288_JPEG); + break; + case OV2640_640x480: + wrSensorRegs8_8(OV2640_640x480_JPEG); + break; + case OV2640_800x600: + wrSensorRegs8_8(OV2640_800x600_JPEG); + break; + case OV2640_1024x768: + wrSensorRegs8_8(OV2640_1024x768_JPEG); + break; + case OV2640_1280x1024: + wrSensorRegs8_8(OV2640_1280x1024_JPEG); + break; + case OV2640_1600x1200: + wrSensorRegs8_8(OV2640_1600x1200_JPEG); + break; + default: + wrSensorRegs8_8(OV2640_320x240_JPEG); + break; } #endif } void ArduCAM::OV5642_set_RAW_size(uint8_t size) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (size) { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch (size) - { - case OV5642_640x480: - wrSensorRegs16_8(OV5642_1280x960_RAW); - wrSensorRegs16_8(OV5642_640x480_RAW); - break; - case OV5642_1280x960: - wrSensorRegs16_8(OV5642_1280x960_RAW); - break; - case OV5642_1920x1080: - wrSensorRegs16_8(ov5642_RAW); - wrSensorRegs16_8(OV5642_1920x1080_RAW); - break; - case OV5642_2592x1944: - wrSensorRegs16_8(ov5642_RAW); - break; - } - #endif + case OV5642_640x480: + wrSensorRegs16_8(OV5642_1280x960_RAW); + wrSensorRegs16_8(OV5642_640x480_RAW); + break; + case OV5642_1280x960: + wrSensorRegs16_8(OV5642_1280x960_RAW); + break; + case OV5642_1920x1080: + wrSensorRegs16_8(ov5642_RAW); + wrSensorRegs16_8(OV5642_1920x1080_RAW); + break; + case OV5642_2592x1944: + wrSensorRegs16_8(ov5642_RAW); + break; } +#endif +} void ArduCAM::OV5642_set_JPEG_size(uint8_t size) { -#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - uint8_t reg_val; - - switch (size) - { - case OV5642_320x240: - wrSensorRegs16_8(ov5642_320x240); - break; - case OV5642_640x480: - wrSensorRegs16_8(ov5642_640x480); - break; - case OV5642_1024x768: - wrSensorRegs16_8(ov5642_1024x768); - break; - case OV5642_1280x960: - wrSensorRegs16_8(ov5642_1280x960); - break; - case OV5642_1600x1200: - wrSensorRegs16_8(ov5642_1600x1200); - break; - case OV5642_2048x1536: - wrSensorRegs16_8(ov5642_2048x1536); - break; - case OV5642_2592x1944: - wrSensorRegs16_8(ov5642_2592x1944); - break; - default: - wrSensorRegs16_8(ov5642_320x240); - break; - } +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + uint8_t reg_val; + + switch (size) + { + case OV5642_320x240: + wrSensorRegs16_8(ov5642_320x240); + break; + case OV5642_640x480: + wrSensorRegs16_8(ov5642_640x480); + break; + case OV5642_1024x768: + wrSensorRegs16_8(ov5642_1024x768); + break; + case OV5642_1280x960: + wrSensorRegs16_8(ov5642_1280x960); + break; + case OV5642_1600x1200: + wrSensorRegs16_8(ov5642_1600x1200); + break; + case OV5642_2048x1536: + wrSensorRegs16_8(ov5642_2048x1536); + break; + case OV5642_2592x1944: + wrSensorRegs16_8(ov5642_2592x1944); + break; + default: + wrSensorRegs16_8(ov5642_320x240); + break; + } #endif } - void ArduCAM::OV5640_set_JPEG_size(uint8_t size) { -#if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch (size) - { - case OV5640_320x240: - wrSensorRegs16_8(OV5640_QSXGA2QVGA); - break; - case OV5640_352x288: - wrSensorRegs16_8(OV5640_QSXGA2CIF); - break; - case OV5640_640x480: - wrSensorRegs16_8(OV5640_QSXGA2VGA); - break; - case OV5640_800x480: - wrSensorRegs16_8(OV5640_QSXGA2WVGA); - break; - case OV5640_1024x768: - wrSensorRegs16_8(OV5640_QSXGA2XGA); - break; - case OV5640_1280x960: - wrSensorRegs16_8(OV5640_QSXGA2SXGA); - break; - case OV5640_1600x1200: - wrSensorRegs16_8(OV5640_QSXGA2UXGA); - break; - case OV5640_2048x1536: - wrSensorRegs16_8(OV5640_QSXGA2QXGA); - break; - case OV5640_2592x1944: - wrSensorRegs16_8(OV5640_JPEG_QSXGA); - break; - default: - //320x240 - wrSensorRegs16_8(OV5640_QSXGA2QVGA); - break; - } +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (size) + { + case OV5640_320x240: + wrSensorRegs16_8(OV5640_QSXGA2QVGA); + break; + case OV5640_352x288: + wrSensorRegs16_8(OV5640_QSXGA2CIF); + break; + case OV5640_640x480: + wrSensorRegs16_8(OV5640_QSXGA2VGA); + break; + case OV5640_800x480: + wrSensorRegs16_8(OV5640_QSXGA2WVGA); + break; + case OV5640_1024x768: + wrSensorRegs16_8(OV5640_QSXGA2XGA); + break; + case OV5640_1280x960: + wrSensorRegs16_8(OV5640_QSXGA2SXGA); + break; + case OV5640_1600x1200: + wrSensorRegs16_8(OV5640_QSXGA2UXGA); + break; + case OV5640_2048x1536: + wrSensorRegs16_8(OV5640_QSXGA2QXGA); + break; + case OV5640_2592x1944: + wrSensorRegs16_8(OV5640_JPEG_QSXGA); + break; + default: + // 320x240 + wrSensorRegs16_8(OV5640_QSXGA2QVGA); + break; + } #endif - } void ArduCAM::set_format(byte fmt) { - if (fmt == BMP) - m_fmt = BMP; - else if(fmt == RAW) - m_fmt = RAW; - else - m_fmt = JPEG; -} - - void ArduCAM::OV2640_set_Light_Mode(uint8_t Light_Mode) - { - #if (defined (OV2640_CAM)||defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS)) - switch(Light_Mode) - { - - case Auto: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0xc7, 0x00); //AWB on - break; - case Sunny: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0xc7, 0x40); //AWB off - wrSensorReg8_8(0xcc, 0x5e); - wrSensorReg8_8(0xcd, 0x41); - wrSensorReg8_8(0xce, 0x54); - break; - case Cloudy: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0xc7, 0x40); //AWB off - wrSensorReg8_8(0xcc, 0x65); - wrSensorReg8_8(0xcd, 0x41); - wrSensorReg8_8(0xce, 0x4f); - break; - case Office: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0xc7, 0x40); //AWB off - wrSensorReg8_8(0xcc, 0x52); - wrSensorReg8_8(0xcd, 0x41); - wrSensorReg8_8(0xce, 0x66); - break; - case Home: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0xc7, 0x40); //AWB off - wrSensorReg8_8(0xcc, 0x42); - wrSensorReg8_8(0xcd, 0x3f); - wrSensorReg8_8(0xce, 0x71); - break; - default : - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0xc7, 0x00); //AWB on - break; - } -#endif - } - void ArduCAM:: OV3640_set_Light_Mode(uint8_t Light_Mode) - { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Light_Mode) - { - - case Auto: - wrSensorReg16_8(0x332b, 0x00);//AWB auto, bit[3]:0,auto - break; - case Sunny: - wrSensorReg16_8(0x332b, 0x08); //AWB off - wrSensorReg16_8(0x33a7, 0x5e); - wrSensorReg16_8(0x33a8, 0x40); - wrSensorReg16_8(0x33a9, 0x46); - break; - case Cloudy: - wrSensorReg16_8(0x332b, 0x08); - wrSensorReg16_8(0x33a7, 0x68); - wrSensorReg16_8(0x33a8, 0x40); - wrSensorReg16_8(0x33a9, 0x4e); - break; - case Office: - wrSensorReg16_8(0x332b, 0x08); - wrSensorReg16_8(0x33a7, 0x52); - wrSensorReg16_8(0x33a8, 0x40); - wrSensorReg16_8(0x33a9, 0x58); - break; - case Home: - wrSensorReg16_8(0x332b, 0x08); - wrSensorReg16_8(0x33a7, 0x44); - wrSensorReg16_8(0x33a8, 0x40); - wrSensorReg16_8(0x33a9, 0x70); - break; - } -#endif - - } - - - void ArduCAM::OV5642_set_Light_Mode(uint8_t Light_Mode) - { -#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(Light_Mode) - { - - case Advanced_AWB: - wrSensorReg16_8(0x3406 ,0x0 ); - wrSensorReg16_8(0x5192 ,0x04); - wrSensorReg16_8(0x5191 ,0xf8); - wrSensorReg16_8(0x518d ,0x26); - wrSensorReg16_8(0x518f ,0x42); - wrSensorReg16_8(0x518e ,0x2b); - wrSensorReg16_8(0x5190 ,0x42); - wrSensorReg16_8(0x518b ,0xd0); - wrSensorReg16_8(0x518c ,0xbd); - wrSensorReg16_8(0x5187 ,0x18); - wrSensorReg16_8(0x5188 ,0x18); - wrSensorReg16_8(0x5189 ,0x56); - wrSensorReg16_8(0x518a ,0x5c); - wrSensorReg16_8(0x5186 ,0x1c); - wrSensorReg16_8(0x5181 ,0x50); - wrSensorReg16_8(0x5184 ,0x20); - wrSensorReg16_8(0x5182 ,0x11); - wrSensorReg16_8(0x5183 ,0x0 ); - break; - case Simple_AWB: - wrSensorReg16_8(0x3406 ,0x00); - wrSensorReg16_8(0x5183 ,0x80); - wrSensorReg16_8(0x5191 ,0xff); - wrSensorReg16_8(0x5192 ,0x00); - break; - case Manual_day: - wrSensorReg16_8(0x3406 ,0x1 ); - wrSensorReg16_8(0x3400 ,0x7 ); - wrSensorReg16_8(0x3401 ,0x32); - wrSensorReg16_8(0x3402 ,0x4 ); - wrSensorReg16_8(0x3403 ,0x0 ); - wrSensorReg16_8(0x3404 ,0x5 ); - wrSensorReg16_8(0x3405 ,0x36); - break; - case Manual_A: - wrSensorReg16_8(0x3406 ,0x1 ); - wrSensorReg16_8(0x3400 ,0x4 ); - wrSensorReg16_8(0x3401 ,0x88); - wrSensorReg16_8(0x3402 ,0x4 ); - wrSensorReg16_8(0x3403 ,0x0 ); - wrSensorReg16_8(0x3404 ,0x8 ); - wrSensorReg16_8(0x3405 ,0xb6); - break; - case Manual_cwf: - wrSensorReg16_8(0x3406 ,0x1 ); - wrSensorReg16_8(0x3400 ,0x6 ); - wrSensorReg16_8(0x3401 ,0x13); - wrSensorReg16_8(0x3402 ,0x4 ); - wrSensorReg16_8(0x3403 ,0x0 ); - wrSensorReg16_8(0x3404 ,0x7 ); - wrSensorReg16_8(0x3405 ,0xe2); - break; - case Manual_cloudy: - wrSensorReg16_8(0x3406 ,0x1 ); - wrSensorReg16_8(0x3400 ,0x7 ); - wrSensorReg16_8(0x3401 ,0x88); - wrSensorReg16_8(0x3402 ,0x4 ); - wrSensorReg16_8(0x3403 ,0x0 ); - wrSensorReg16_8(0x3404 ,0x5 ); - wrSensorReg16_8(0x3405 ,0x0); - break; - default : - break; - } -#endif - } - - void ArduCAM::OV5640_set_Light_Mode(uint8_t Light_Mode) - { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch(Light_Mode) - { - case Auto: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3406, 0x00); - wrSensorReg16_8(0x3400, 0x04); - wrSensorReg16_8(0x3401, 0x00); - wrSensorReg16_8(0x3402, 0x04); - wrSensorReg16_8(0x3403, 0x00); - wrSensorReg16_8(0x3404, 0x04); - wrSensorReg16_8(0x3405, 0x00); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 - wrSensorReg16_8(0x5183 ,0x0 ); - break; - case Sunny: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3406, 0x01); - wrSensorReg16_8(0x3400, 0x06); - wrSensorReg16_8(0x3401, 0x1c); - wrSensorReg16_8(0x3402, 0x04); - wrSensorReg16_8(0x3403, 0x00); - wrSensorReg16_8(0x3404, 0x04); - wrSensorReg16_8(0x3405, 0xf3); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 - break; - case Office: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3406, 0x01); - wrSensorReg16_8(0x3400, 0x05); - wrSensorReg16_8(0x3401, 0x48); - wrSensorReg16_8(0x3402, 0x04); - wrSensorReg16_8(0x3403, 0x00); - wrSensorReg16_8(0x3404, 0x07); - wrSensorReg16_8(0x3405, 0xcf); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3406, 0x01); - wrSensorReg16_8(0x3400, 0x06); - wrSensorReg16_8(0x3401, 0x48); - wrSensorReg16_8(0x3402, 0x04); - wrSensorReg16_8(0x3403, 0x00); - wrSensorReg16_8(0x3404, 0x04); - wrSensorReg16_8(0x3405, 0xd3); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 - break; - case Cloudy: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3406, 0x01); - wrSensorReg16_8(0x3400, 0x06); - wrSensorReg16_8(0x3401, 0x48); - wrSensorReg16_8(0x3402, 0x04); - wrSensorReg16_8(0x3403, 0x00); - wrSensorReg16_8(0x3404, 0x04); - wrSensorReg16_8(0x3405, 0xd3); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 - break; - case Home: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3406, 0x01); - wrSensorReg16_8(0x3400, 0x04); - wrSensorReg16_8(0x3401, 0x10); - wrSensorReg16_8(0x3402, 0x04); - wrSensorReg16_8(0x3403, 0x00); - wrSensorReg16_8(0x3404, 0x08); - wrSensorReg16_8(0x3405, 0x40); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 - break; - default : - break; - } - #endif + if (fmt == BMP) + m_fmt = BMP; + else if (fmt == RAW) + m_fmt = RAW; + else + m_fmt = JPEG; +} + +void ArduCAM::OV2640_set_Light_Mode(uint8_t Light_Mode) +{ +#if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) + switch (Light_Mode) + { + + case Auto: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0xc7, 0x00); // AWB on + break; + case Sunny: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0xc7, 0x40); // AWB off + wrSensorReg8_8(0xcc, 0x5e); + wrSensorReg8_8(0xcd, 0x41); + wrSensorReg8_8(0xce, 0x54); + break; + case Cloudy: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0xc7, 0x40); // AWB off + wrSensorReg8_8(0xcc, 0x65); + wrSensorReg8_8(0xcd, 0x41); + wrSensorReg8_8(0xce, 0x4f); + break; + case Office: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0xc7, 0x40); // AWB off + wrSensorReg8_8(0xcc, 0x52); + wrSensorReg8_8(0xcd, 0x41); + wrSensorReg8_8(0xce, 0x66); + break; + case Home: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0xc7, 0x40); // AWB off + wrSensorReg8_8(0xcc, 0x42); + wrSensorReg8_8(0xcd, 0x3f); + wrSensorReg8_8(0xce, 0x71); + break; + default: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0xc7, 0x00); // AWB on + break; } - - - - - void ArduCAM::OV2640_set_Color_Saturation(uint8_t Color_Saturation) +#endif +} +void ArduCAM::OV3640_set_Light_Mode(uint8_t Light_Mode) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Light_Mode) { - #if (defined (OV2640_CAM)||defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS)) - switch(Color_Saturation) - { - case Saturation2: - - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x02); - wrSensorReg8_8(0x7c, 0x03); - wrSensorReg8_8(0x7d, 0x68); - wrSensorReg8_8(0x7d, 0x68); - break; - case Saturation1: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x02); - wrSensorReg8_8(0x7c, 0x03); - wrSensorReg8_8(0x7d, 0x58); - wrSensorReg8_8(0x7d, 0x58); - break; - case Saturation0: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x02); - wrSensorReg8_8(0x7c, 0x03); - wrSensorReg8_8(0x7d, 0x48); - wrSensorReg8_8(0x7d, 0x48); - break; - case Saturation_1: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x02); - wrSensorReg8_8(0x7c, 0x03); - wrSensorReg8_8(0x7d, 0x38); - wrSensorReg8_8(0x7d, 0x38); - break; - case Saturation_2: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x02); - wrSensorReg8_8(0x7c, 0x03); - wrSensorReg8_8(0x7d, 0x28); - wrSensorReg8_8(0x7d, 0x28); - break; - } -#endif + + case Auto: + wrSensorReg16_8(0x332b, 0x00); // AWB auto, bit[3]:0,auto + break; + case Sunny: + wrSensorReg16_8(0x332b, 0x08); // AWB off + wrSensorReg16_8(0x33a7, 0x5e); + wrSensorReg16_8(0x33a8, 0x40); + wrSensorReg16_8(0x33a9, 0x46); + break; + case Cloudy: + wrSensorReg16_8(0x332b, 0x08); + wrSensorReg16_8(0x33a7, 0x68); + wrSensorReg16_8(0x33a8, 0x40); + wrSensorReg16_8(0x33a9, 0x4e); + break; + case Office: + wrSensorReg16_8(0x332b, 0x08); + wrSensorReg16_8(0x33a7, 0x52); + wrSensorReg16_8(0x33a8, 0x40); + wrSensorReg16_8(0x33a9, 0x58); + break; + case Home: + wrSensorReg16_8(0x332b, 0x08); + wrSensorReg16_8(0x33a7, 0x44); + wrSensorReg16_8(0x33a8, 0x40); + wrSensorReg16_8(0x33a9, 0x70); + break; } - void ArduCAM::OV3640_set_Color_Saturation(uint8_t Color_Saturation) - { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Color_Saturation) - { - case Saturation2: - wrSensorReg16_8(0x3302, 0xef);//bit[7]:1, enable SDE - wrSensorReg16_8(0x3355, 0x02); //enable color saturation - wrSensorReg16_8(0x3358, 0x70); - wrSensorReg16_8(0x3359, 0x70); - break; - case Saturation1: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x02); - wrSensorReg16_8(0x3358, 0x50); - wrSensorReg16_8(0x3359, 0x50); - break; - case Saturation0: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x02); - wrSensorReg16_8(0x3358, 0x40); - wrSensorReg16_8(0x3359, 0x40); - break; - case Saturation_1: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x02); - wrSensorReg16_8(0x3358, 0x30); - wrSensorReg16_8(0x3359, 0x30); - break; - case Saturation_2: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x02); - wrSensorReg16_8(0x3358, 0x20); - wrSensorReg16_8(0x3359, 0x20); - break; - } - - #endif - } - - - void ArduCAM::OV5640_set_Color_Saturation(uint8_t Color_Saturation) - { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch(Color_Saturation) - { - case Saturation3: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x2b); - wrSensorReg16_8(0x5385, 0xab); - wrSensorReg16_8(0x5386, 0xd6); - wrSensorReg16_8(0x5387, 0xda); - wrSensorReg16_8(0x5388, 0xd6); - wrSensorReg16_8(0x5389, 0x04); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Saturation2: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x24); - wrSensorReg16_8(0x5385, 0x8f); - wrSensorReg16_8(0x5386, 0xb3); - wrSensorReg16_8(0x5387, 0xb6); - wrSensorReg16_8(0x5388, 0xb3); - wrSensorReg16_8(0x5389, 0x03); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Saturation1: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x1f); - wrSensorReg16_8(0x5385, 0x7a); - wrSensorReg16_8(0x5386, 0x9a); - wrSensorReg16_8(0x5387, 0x9c); - wrSensorReg16_8(0x5388, 0x9a); - wrSensorReg16_8(0x5389, 0x02); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Saturation0: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x1a); - wrSensorReg16_8(0x5385, 0x66); - wrSensorReg16_8(0x5386, 0x80); - wrSensorReg16_8(0x5387, 0x82); - wrSensorReg16_8(0x5388, 0x80); - wrSensorReg16_8(0x5389, 0x02); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Saturation_1: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x15); - wrSensorReg16_8(0x5385, 0x52); - wrSensorReg16_8(0x5386, 0x66); - wrSensorReg16_8(0x5387, 0x68); - wrSensorReg16_8(0x5388, 0x66); - wrSensorReg16_8(0x5389, 0x02); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Saturation_2: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x10); - wrSensorReg16_8(0x5385, 0x3d); - wrSensorReg16_8(0x5386, 0x4d); - wrSensorReg16_8(0x5387, 0x4e); - wrSensorReg16_8(0x5388, 0x4d); - wrSensorReg16_8(0x5389, 0x01); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Saturation_3: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5381, 0x1c); - wrSensorReg16_8(0x5382, 0x5a); - wrSensorReg16_8(0x5383, 0x06); - wrSensorReg16_8(0x5384, 0x0c); - wrSensorReg16_8(0x5385, 0x30); - wrSensorReg16_8(0x5386, 0x3d); - wrSensorReg16_8(0x5387, 0x3e); - wrSensorReg16_8(0x5388, 0x3d); - wrSensorReg16_8(0x5389, 0x01); - wrSensorReg16_8(0x538b, 0x98); - wrSensorReg16_8(0x538a, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - } - - #endif - } - - void ArduCAM::OV5642_set_Color_Saturation(uint8_t Color_Saturation) +#endif +} + +void ArduCAM::OV5642_set_Light_Mode(uint8_t Light_Mode) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (Light_Mode) { -#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - - switch(Color_Saturation) - { - case Saturation4: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x80); - wrSensorReg16_8(0x5584 ,0x80); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation3: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x70); - wrSensorReg16_8(0x5584 ,0x70); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation2: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x60); - wrSensorReg16_8(0x5584 ,0x60); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation1: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x50); - wrSensorReg16_8(0x5584 ,0x50); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation0: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x40); - wrSensorReg16_8(0x5584 ,0x40); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation_1: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x30); - wrSensorReg16_8(0x5584 ,0x30); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation_2: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x20); - wrSensorReg16_8(0x5584 ,0x20); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation_3: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x10); - wrSensorReg16_8(0x5584 ,0x10); - wrSensorReg16_8(0x5580 ,0x02); - break; - case Saturation_4: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5583 ,0x00); - wrSensorReg16_8(0x5584 ,0x00); - wrSensorReg16_8(0x5580 ,0x02); - break; - } -#endif + + case Advanced_AWB: + wrSensorReg16_8(0x3406, 0x0); + wrSensorReg16_8(0x5192, 0x04); + wrSensorReg16_8(0x5191, 0xf8); + wrSensorReg16_8(0x518d, 0x26); + wrSensorReg16_8(0x518f, 0x42); + wrSensorReg16_8(0x518e, 0x2b); + wrSensorReg16_8(0x5190, 0x42); + wrSensorReg16_8(0x518b, 0xd0); + wrSensorReg16_8(0x518c, 0xbd); + wrSensorReg16_8(0x5187, 0x18); + wrSensorReg16_8(0x5188, 0x18); + wrSensorReg16_8(0x5189, 0x56); + wrSensorReg16_8(0x518a, 0x5c); + wrSensorReg16_8(0x5186, 0x1c); + wrSensorReg16_8(0x5181, 0x50); + wrSensorReg16_8(0x5184, 0x20); + wrSensorReg16_8(0x5182, 0x11); + wrSensorReg16_8(0x5183, 0x0); + break; + case Simple_AWB: + wrSensorReg16_8(0x3406, 0x00); + wrSensorReg16_8(0x5183, 0x80); + wrSensorReg16_8(0x5191, 0xff); + wrSensorReg16_8(0x5192, 0x00); + break; + case Manual_day: + wrSensorReg16_8(0x3406, 0x1); + wrSensorReg16_8(0x3400, 0x7); + wrSensorReg16_8(0x3401, 0x32); + wrSensorReg16_8(0x3402, 0x4); + wrSensorReg16_8(0x3403, 0x0); + wrSensorReg16_8(0x3404, 0x5); + wrSensorReg16_8(0x3405, 0x36); + break; + case Manual_A: + wrSensorReg16_8(0x3406, 0x1); + wrSensorReg16_8(0x3400, 0x4); + wrSensorReg16_8(0x3401, 0x88); + wrSensorReg16_8(0x3402, 0x4); + wrSensorReg16_8(0x3403, 0x0); + wrSensorReg16_8(0x3404, 0x8); + wrSensorReg16_8(0x3405, 0xb6); + break; + case Manual_cwf: + wrSensorReg16_8(0x3406, 0x1); + wrSensorReg16_8(0x3400, 0x6); + wrSensorReg16_8(0x3401, 0x13); + wrSensorReg16_8(0x3402, 0x4); + wrSensorReg16_8(0x3403, 0x0); + wrSensorReg16_8(0x3404, 0x7); + wrSensorReg16_8(0x3405, 0xe2); + break; + case Manual_cloudy: + wrSensorReg16_8(0x3406, 0x1); + wrSensorReg16_8(0x3400, 0x7); + wrSensorReg16_8(0x3401, 0x88); + wrSensorReg16_8(0x3402, 0x4); + wrSensorReg16_8(0x3403, 0x0); + wrSensorReg16_8(0x3404, 0x5); + wrSensorReg16_8(0x3405, 0x0); + break; + default: + break; } - - - - - - void ArduCAM::OV2640_set_Brightness(uint8_t Brightness) +#endif +} + +void ArduCAM::OV5640_set_Light_Mode(uint8_t Light_Mode) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (Light_Mode) { - #if (defined (OV2640_CAM)||defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS)) - switch(Brightness) - { - case Brightness2: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x09); - wrSensorReg8_8(0x7d, 0x40); - wrSensorReg8_8(0x7d, 0x00); - break; - case Brightness1: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x09); - wrSensorReg8_8(0x7d, 0x30); - wrSensorReg8_8(0x7d, 0x00); - break; - case Brightness0: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x09); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x00); - break; - case Brightness_1: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x09); - wrSensorReg8_8(0x7d, 0x10); - wrSensorReg8_8(0x7d, 0x00); - break; - case Brightness_2: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x09); - wrSensorReg8_8(0x7d, 0x00); - wrSensorReg8_8(0x7d, 0x00); - break; - } -#endif - + case Auto: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3406, 0x00); + wrSensorReg16_8(0x3400, 0x04); + wrSensorReg16_8(0x3401, 0x00); + wrSensorReg16_8(0x3402, 0x04); + wrSensorReg16_8(0x3403, 0x00); + wrSensorReg16_8(0x3404, 0x04); + wrSensorReg16_8(0x3405, 0x00); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 + wrSensorReg16_8(0x5183, 0x0); + break; + case Sunny: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3406, 0x01); + wrSensorReg16_8(0x3400, 0x06); + wrSensorReg16_8(0x3401, 0x1c); + wrSensorReg16_8(0x3402, 0x04); + wrSensorReg16_8(0x3403, 0x00); + wrSensorReg16_8(0x3404, 0x04); + wrSensorReg16_8(0x3405, 0xf3); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 + break; + case Office: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3406, 0x01); + wrSensorReg16_8(0x3400, 0x05); + wrSensorReg16_8(0x3401, 0x48); + wrSensorReg16_8(0x3402, 0x04); + wrSensorReg16_8(0x3403, 0x00); + wrSensorReg16_8(0x3404, 0x07); + wrSensorReg16_8(0x3405, 0xcf); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3406, 0x01); + wrSensorReg16_8(0x3400, 0x06); + wrSensorReg16_8(0x3401, 0x48); + wrSensorReg16_8(0x3402, 0x04); + wrSensorReg16_8(0x3403, 0x00); + wrSensorReg16_8(0x3404, 0x04); + wrSensorReg16_8(0x3405, 0xd3); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 + break; + case Cloudy: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3406, 0x01); + wrSensorReg16_8(0x3400, 0x06); + wrSensorReg16_8(0x3401, 0x48); + wrSensorReg16_8(0x3402, 0x04); + wrSensorReg16_8(0x3403, 0x00); + wrSensorReg16_8(0x3404, 0x04); + wrSensorReg16_8(0x3405, 0xd3); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 + break; + case Home: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3406, 0x01); + wrSensorReg16_8(0x3400, 0x04); + wrSensorReg16_8(0x3401, 0x10); + wrSensorReg16_8(0x3402, 0x04); + wrSensorReg16_8(0x3403, 0x00); + wrSensorReg16_8(0x3404, 0x08); + wrSensorReg16_8(0x3405, 0x40); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // lanuch group 3 + break; + default: + break; } - void ArduCAM::OV3640_set_Brightness(uint8_t Brightness) +#endif +} + +void ArduCAM::OV2640_set_Color_Saturation(uint8_t Color_Saturation) +{ +#if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) + switch (Color_Saturation) { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Brightness) - { - case Brightness3: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); //bit[2] enable - wrSensorReg16_8(0x3354, 0x01); //bit[3] sign of brightness - wrSensorReg16_8(0x335e, 0x30); - break; - case Brightness2: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335e, 0x20); - break; - case Brightness1: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335e, 0x10); - break; - case Brightness0: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335e, 0x00); - break; - case Brightness_1: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x09); - wrSensorReg16_8(0x335e, 0x10); - break; - case Brightness_2: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x09); - wrSensorReg16_8(0x335e, 0x20); - break; - case Brightness_3: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x09); - wrSensorReg16_8(0x335e, 0x30); - break; - } - #endif - } - - - void ArduCAM::OV5642_set_Brightness(uint8_t Brightness) - { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - - switch(Brightness) - { - case Brightness4: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x40); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x00); - break; - case Brightness3: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x30); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x00); - break; - case Brightness2: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x20); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x00); - break; - case Brightness1: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x10); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x00); - break; - case Brightness0: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x00); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x00); - break; - case Brightness_1: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x10); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x08); - break; - case Brightness_2: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x20); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x08); - break; - case Brightness_3: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x30); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x08); - break; - case Brightness_4: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5589 ,0x40); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x558a ,0x08); - break; - } -#endif - + case Saturation2: + + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x02); + wrSensorReg8_8(0x7c, 0x03); + wrSensorReg8_8(0x7d, 0x68); + wrSensorReg8_8(0x7d, 0x68); + break; + case Saturation1: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x02); + wrSensorReg8_8(0x7c, 0x03); + wrSensorReg8_8(0x7d, 0x58); + wrSensorReg8_8(0x7d, 0x58); + break; + case Saturation0: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x02); + wrSensorReg8_8(0x7c, 0x03); + wrSensorReg8_8(0x7d, 0x48); + wrSensorReg8_8(0x7d, 0x48); + break; + case Saturation_1: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x02); + wrSensorReg8_8(0x7c, 0x03); + wrSensorReg8_8(0x7d, 0x38); + wrSensorReg8_8(0x7d, 0x38); + break; + case Saturation_2: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x02); + wrSensorReg8_8(0x7c, 0x03); + wrSensorReg8_8(0x7d, 0x28); + wrSensorReg8_8(0x7d, 0x28); + break; } - - void ArduCAM::OV5640_set_Brightness(uint8_t Brightness) +#endif +} +void ArduCAM::OV3640_set_Color_Saturation(uint8_t Color_Saturation) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Color_Saturation) { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch(Brightness) - { - case Brightness4: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x40); - wrSensorReg16_8(0x5588, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness3: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x30); - wrSensorReg16_8(0x5588, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness2: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x20); - wrSensorReg16_8(0x5588, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness1: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x10); - wrSensorReg16_8(0x5588, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness0: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x00); - wrSensorReg16_8(0x5588, 0x01); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness_1: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x10); - wrSensorReg16_8(0x5588, 0x09); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness_2: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x20); - wrSensorReg16_8(0x5588, 0x09); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness_3: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x30); - wrSensorReg16_8(0x5588, 0x09); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Brightness_4: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5587, 0x40); - wrSensorReg16_8(0x5588, 0x09); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - } - #endif - } - - - - - void ArduCAM::OV2640_set_Contrast(uint8_t Contrast) - { - #if (defined (OV2640_CAM)||defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS)) - switch(Contrast) - { - case Contrast2: - - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x07); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x28); - wrSensorReg8_8(0x7d, 0x0c); - wrSensorReg8_8(0x7d, 0x06); - break; - case Contrast1: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x07); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x24); - wrSensorReg8_8(0x7d, 0x16); - wrSensorReg8_8(0x7d, 0x06); - break; - case Contrast0: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x07); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x06); - break; - case Contrast_1: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x07); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x2a); - wrSensorReg8_8(0x7d, 0x06); - break; - case Contrast_2: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x04); - wrSensorReg8_8(0x7c, 0x07); - wrSensorReg8_8(0x7d, 0x20); - wrSensorReg8_8(0x7d, 0x18); - wrSensorReg8_8(0x7d, 0x34); - wrSensorReg8_8(0x7d, 0x06); - break; - } -#endif + case Saturation2: + wrSensorReg16_8(0x3302, 0xef); // bit[7]:1, enable SDE + wrSensorReg16_8(0x3355, 0x02); // enable color saturation + wrSensorReg16_8(0x3358, 0x70); + wrSensorReg16_8(0x3359, 0x70); + break; + case Saturation1: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x02); + wrSensorReg16_8(0x3358, 0x50); + wrSensorReg16_8(0x3359, 0x50); + break; + case Saturation0: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x02); + wrSensorReg16_8(0x3358, 0x40); + wrSensorReg16_8(0x3359, 0x40); + break; + case Saturation_1: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x02); + wrSensorReg16_8(0x3358, 0x30); + wrSensorReg16_8(0x3359, 0x30); + break; + case Saturation_2: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x02); + wrSensorReg16_8(0x3358, 0x20); + wrSensorReg16_8(0x3359, 0x20); + break; } - - void ArduCAM::OV3640_set_Contrast(uint8_t Contrast) + +#endif +} + +void ArduCAM::OV5640_set_Color_Saturation(uint8_t Color_Saturation) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (Color_Saturation) { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Contrast) - { - case Contrast3: - - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); //bit[2] enable contrast/brightness - wrSensorReg16_8(0x3354, 0x01); //bit[2] Yoffset sign - wrSensorReg16_8(0x335c, 0x2c); - wrSensorReg16_8(0x335d, 0x2c); - break; - case Contrast2: - - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335c, 0x28); - wrSensorReg16_8(0x335d, 0x28); - break; - case Contrast1: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335c, 0x24); - wrSensorReg16_8(0x335d, 0x24); - break; - case Contrast0: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335c, 0x20); - wrSensorReg16_8(0x335d, 0x20); - break; - case Contrast_1: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335c, 0x1c); - wrSensorReg16_8(0x335d, 0x1c); - break; - case Contrast_2: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335c, 0x18); - wrSensorReg16_8(0x335d, 0x18); - break; - case Contrast_3: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x04); - wrSensorReg16_8(0x3354, 0x01); - wrSensorReg16_8(0x335c, 0x14); - wrSensorReg16_8(0x335d, 0x14); - break; - } -#endif + case Saturation3: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x2b); + wrSensorReg16_8(0x5385, 0xab); + wrSensorReg16_8(0x5386, 0xd6); + wrSensorReg16_8(0x5387, 0xda); + wrSensorReg16_8(0x5388, 0xd6); + wrSensorReg16_8(0x5389, 0x04); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Saturation2: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x24); + wrSensorReg16_8(0x5385, 0x8f); + wrSensorReg16_8(0x5386, 0xb3); + wrSensorReg16_8(0x5387, 0xb6); + wrSensorReg16_8(0x5388, 0xb3); + wrSensorReg16_8(0x5389, 0x03); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Saturation1: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x1f); + wrSensorReg16_8(0x5385, 0x7a); + wrSensorReg16_8(0x5386, 0x9a); + wrSensorReg16_8(0x5387, 0x9c); + wrSensorReg16_8(0x5388, 0x9a); + wrSensorReg16_8(0x5389, 0x02); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Saturation0: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x1a); + wrSensorReg16_8(0x5385, 0x66); + wrSensorReg16_8(0x5386, 0x80); + wrSensorReg16_8(0x5387, 0x82); + wrSensorReg16_8(0x5388, 0x80); + wrSensorReg16_8(0x5389, 0x02); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Saturation_1: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x15); + wrSensorReg16_8(0x5385, 0x52); + wrSensorReg16_8(0x5386, 0x66); + wrSensorReg16_8(0x5387, 0x68); + wrSensorReg16_8(0x5388, 0x66); + wrSensorReg16_8(0x5389, 0x02); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Saturation_2: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x10); + wrSensorReg16_8(0x5385, 0x3d); + wrSensorReg16_8(0x5386, 0x4d); + wrSensorReg16_8(0x5387, 0x4e); + wrSensorReg16_8(0x5388, 0x4d); + wrSensorReg16_8(0x5389, 0x01); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Saturation_3: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5381, 0x1c); + wrSensorReg16_8(0x5382, 0x5a); + wrSensorReg16_8(0x5383, 0x06); + wrSensorReg16_8(0x5384, 0x0c); + wrSensorReg16_8(0x5385, 0x30); + wrSensorReg16_8(0x5386, 0x3d); + wrSensorReg16_8(0x5387, 0x3e); + wrSensorReg16_8(0x5388, 0x3d); + wrSensorReg16_8(0x5389, 0x01); + wrSensorReg16_8(0x538b, 0x98); + wrSensorReg16_8(0x538a, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; } - - - - - void ArduCAM::OV5642_set_Contrast(uint8_t Contrast) + +#endif +} + +void ArduCAM::OV5642_set_Color_Saturation(uint8_t Color_Saturation) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + + switch (Color_Saturation) { -#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(Contrast) - { - case Contrast4: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x30); - wrSensorReg16_8(0x5588 ,0x30); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast3: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x2c); - wrSensorReg16_8(0x5588 ,0x2c); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast2: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x28); - wrSensorReg16_8(0x5588 ,0x28); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast1: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x24); - wrSensorReg16_8(0x5588 ,0x24); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast0: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x20); - wrSensorReg16_8(0x5588 ,0x20); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast_1: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x1C); - wrSensorReg16_8(0x5588 ,0x1C); - wrSensorReg16_8(0x558a ,0x1C); - break; - case Contrast_2: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x18); - wrSensorReg16_8(0x5588 ,0x18); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast_3: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x14); - wrSensorReg16_8(0x5588 ,0x14); - wrSensorReg16_8(0x558a ,0x00); - break; - case Contrast_4: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x04); - wrSensorReg16_8(0x5587 ,0x10); - wrSensorReg16_8(0x5588 ,0x10); - wrSensorReg16_8(0x558a ,0x00); - break; - } -#endif + case Saturation4: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x80); + wrSensorReg16_8(0x5584, 0x80); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation3: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x70); + wrSensorReg16_8(0x5584, 0x70); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation2: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x60); + wrSensorReg16_8(0x5584, 0x60); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation1: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x50); + wrSensorReg16_8(0x5584, 0x50); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation0: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x40); + wrSensorReg16_8(0x5584, 0x40); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation_1: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x30); + wrSensorReg16_8(0x5584, 0x30); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation_2: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x20); + wrSensorReg16_8(0x5584, 0x20); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation_3: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x10); + wrSensorReg16_8(0x5584, 0x10); + wrSensorReg16_8(0x5580, 0x02); + break; + case Saturation_4: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5583, 0x00); + wrSensorReg16_8(0x5584, 0x00); + wrSensorReg16_8(0x5580, 0x02); + break; + } +#endif +} + +void ArduCAM::OV2640_set_Brightness(uint8_t Brightness) +{ +#if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) + switch (Brightness) + { + case Brightness2: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x09); + wrSensorReg8_8(0x7d, 0x40); + wrSensorReg8_8(0x7d, 0x00); + break; + case Brightness1: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x09); + wrSensorReg8_8(0x7d, 0x30); + wrSensorReg8_8(0x7d, 0x00); + break; + case Brightness0: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x09); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x00); + break; + case Brightness_1: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x09); + wrSensorReg8_8(0x7d, 0x10); + wrSensorReg8_8(0x7d, 0x00); + break; + case Brightness_2: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x09); + wrSensorReg8_8(0x7d, 0x00); + wrSensorReg8_8(0x7d, 0x00); + break; } - void ArduCAM::OV5640_set_Contrast(uint8_t Contrast) +#endif +} +void ArduCAM::OV3640_set_Brightness(uint8_t Brightness) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Brightness) { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch(Contrast) - { - case Contrast3: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x2c); - wrSensorReg16_8(0x5585, 0x1c); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Contrast2: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x28); - wrSensorReg16_8(0x5585, 0x18); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Contrast1: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x24); - wrSensorReg16_8(0x5585, 0x10); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Contrast0: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x20); - wrSensorReg16_8(0x5585, 0x00); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Contrast_1: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x1c); - wrSensorReg16_8(0x5585, 0x1c); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Contrast_2: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x18); - wrSensorReg16_8(0x5585, 0x18); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Contrast_3: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5586, 0x14); - wrSensorReg16_8(0x5585, 0x14); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - } - #endif - + case Brightness3: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); // bit[2] enable + wrSensorReg16_8(0x3354, 0x01); // bit[3] sign of brightness + wrSensorReg16_8(0x335e, 0x30); + break; + case Brightness2: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335e, 0x20); + break; + case Brightness1: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335e, 0x10); + break; + case Brightness0: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335e, 0x00); + break; + case Brightness_1: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x09); + wrSensorReg16_8(0x335e, 0x10); + break; + case Brightness_2: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x09); + wrSensorReg16_8(0x335e, 0x20); + break; + case Brightness_3: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x09); + wrSensorReg16_8(0x335e, 0x30); + break; + } +#endif +} + +void ArduCAM::OV5642_set_Brightness(uint8_t Brightness) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + + switch (Brightness) + { + case Brightness4: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x40); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x00); + break; + case Brightness3: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x30); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x00); + break; + case Brightness2: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x20); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x00); + break; + case Brightness1: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x10); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x00); + break; + case Brightness0: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x00); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x00); + break; + case Brightness_1: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x10); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x08); + break; + case Brightness_2: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x20); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x08); + break; + case Brightness_3: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x30); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x08); + break; + case Brightness_4: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5589, 0x40); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x558a, 0x08); + break; + } +#endif +} + +void ArduCAM::OV5640_set_Brightness(uint8_t Brightness) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (Brightness) + { + case Brightness4: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x40); + wrSensorReg16_8(0x5588, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness3: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x30); + wrSensorReg16_8(0x5588, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness2: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x20); + wrSensorReg16_8(0x5588, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness1: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x10); + wrSensorReg16_8(0x5588, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness0: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x00); + wrSensorReg16_8(0x5588, 0x01); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness_1: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x10); + wrSensorReg16_8(0x5588, 0x09); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness_2: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x20); + wrSensorReg16_8(0x5588, 0x09); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness_3: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x30); + wrSensorReg16_8(0x5588, 0x09); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Brightness_4: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5587, 0x40); + wrSensorReg16_8(0x5588, 0x09); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + } +#endif +} + +void ArduCAM::OV2640_set_Contrast(uint8_t Contrast) +{ +#if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) + switch (Contrast) + { + case Contrast2: + + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x07); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x28); + wrSensorReg8_8(0x7d, 0x0c); + wrSensorReg8_8(0x7d, 0x06); + break; + case Contrast1: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x07); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x24); + wrSensorReg8_8(0x7d, 0x16); + wrSensorReg8_8(0x7d, 0x06); + break; + case Contrast0: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x07); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x06); + break; + case Contrast_1: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x07); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x2a); + wrSensorReg8_8(0x7d, 0x06); + break; + case Contrast_2: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x04); + wrSensorReg8_8(0x7c, 0x07); + wrSensorReg8_8(0x7d, 0x20); + wrSensorReg8_8(0x7d, 0x18); + wrSensorReg8_8(0x7d, 0x34); + wrSensorReg8_8(0x7d, 0x06); + break; + } +#endif +} + +void ArduCAM::OV3640_set_Contrast(uint8_t Contrast) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Contrast) + { + case Contrast3: + + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); // bit[2] enable contrast/brightness + wrSensorReg16_8(0x3354, 0x01); // bit[2] Yoffset sign + wrSensorReg16_8(0x335c, 0x2c); + wrSensorReg16_8(0x335d, 0x2c); + break; + case Contrast2: + + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335c, 0x28); + wrSensorReg16_8(0x335d, 0x28); + break; + case Contrast1: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335c, 0x24); + wrSensorReg16_8(0x335d, 0x24); + break; + case Contrast0: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335c, 0x20); + wrSensorReg16_8(0x335d, 0x20); + break; + case Contrast_1: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335c, 0x1c); + wrSensorReg16_8(0x335d, 0x1c); + break; + case Contrast_2: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335c, 0x18); + wrSensorReg16_8(0x335d, 0x18); + break; + case Contrast_3: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x04); + wrSensorReg16_8(0x3354, 0x01); + wrSensorReg16_8(0x335c, 0x14); + wrSensorReg16_8(0x335d, 0x14); + break; + } +#endif +} + +void ArduCAM::OV5642_set_Contrast(uint8_t Contrast) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (Contrast) + { + case Contrast4: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x30); + wrSensorReg16_8(0x5588, 0x30); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast3: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x2c); + wrSensorReg16_8(0x5588, 0x2c); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast2: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x28); + wrSensorReg16_8(0x5588, 0x28); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast1: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x24); + wrSensorReg16_8(0x5588, 0x24); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast0: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x20); + wrSensorReg16_8(0x5588, 0x20); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast_1: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x1C); + wrSensorReg16_8(0x5588, 0x1C); + wrSensorReg16_8(0x558a, 0x1C); + break; + case Contrast_2: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x18); + wrSensorReg16_8(0x5588, 0x18); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast_3: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x14); + wrSensorReg16_8(0x5588, 0x14); + wrSensorReg16_8(0x558a, 0x00); + break; + case Contrast_4: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x04); + wrSensorReg16_8(0x5587, 0x10); + wrSensorReg16_8(0x5588, 0x10); + wrSensorReg16_8(0x558a, 0x00); + break; + } +#endif +} +void ArduCAM::OV5640_set_Contrast(uint8_t Contrast) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (Contrast) + { + case Contrast3: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x2c); + wrSensorReg16_8(0x5585, 0x1c); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Contrast2: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x28); + wrSensorReg16_8(0x5585, 0x18); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Contrast1: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x24); + wrSensorReg16_8(0x5585, 0x10); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Contrast0: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x20); + wrSensorReg16_8(0x5585, 0x00); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Contrast_1: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x1c); + wrSensorReg16_8(0x5585, 0x1c); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Contrast_2: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x18); + wrSensorReg16_8(0x5585, 0x18); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Contrast_3: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5586, 0x14); + wrSensorReg16_8(0x5585, 0x14); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + } +#endif +} + +void ArduCAM::OV5642_set_hue(uint8_t degree) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (degree) + { + case degree_180: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x80); + wrSensorReg16_8(0x5582, 0x00); + wrSensorReg16_8(0x558a, 0x32); + break; + case degree_150: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x6f); + wrSensorReg16_8(0x5582, 0x40); + wrSensorReg16_8(0x558a, 0x32); + break; + case degree_120: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x40); + wrSensorReg16_8(0x5582, 0x6f); + wrSensorReg16_8(0x558a, 0x32); + break; + case degree_90: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x00); + wrSensorReg16_8(0x5582, 0x80); + wrSensorReg16_8(0x558a, 0x02); + break; + case degree_60: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x40); + wrSensorReg16_8(0x5582, 0x6f); + wrSensorReg16_8(0x558a, 0x02); + break; + case degree_30: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x6f); + wrSensorReg16_8(0x5582, 0x40); + wrSensorReg16_8(0x558a, 0x02); + break; + case degree_0: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x80); + wrSensorReg16_8(0x5582, 0x00); + wrSensorReg16_8(0x558a, 0x01); + break; + case degree30: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x6f); + wrSensorReg16_8(0x5582, 0x40); + wrSensorReg16_8(0x558a, 0x01); + break; + case degree60: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x40); + wrSensorReg16_8(0x5582, 0x6f); + wrSensorReg16_8(0x558a, 0x01); + break; + case degree90: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x00); + wrSensorReg16_8(0x5582, 0x80); + wrSensorReg16_8(0x558a, 0x31); + break; + case degree120: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x40); + wrSensorReg16_8(0x5582, 0x6f); + wrSensorReg16_8(0x558a, 0x31); + break; + case degree150: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x01); + wrSensorReg16_8(0x5581, 0x6f); + wrSensorReg16_8(0x5582, 0x40); + wrSensorReg16_8(0x558a, 0x31); + break; + } +#endif +} + +void ArduCAM::OV2640_set_Special_effects(uint8_t Special_effect) +{ +#if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) + switch (Special_effect) + { + case Antique: + + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x18); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x40); + wrSensorReg8_8(0x7d, 0xa6); + break; + case Bluish: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x18); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0xa0); + wrSensorReg8_8(0x7d, 0x40); + break; + case Greenish: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x18); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x40); + wrSensorReg8_8(0x7d, 0x40); + break; + case Reddish: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x18); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x40); + wrSensorReg8_8(0x7d, 0xc0); + break; + case BW: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x18); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x80); + wrSensorReg8_8(0x7d, 0x80); + break; + case Negative: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x40); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x80); + wrSensorReg8_8(0x7d, 0x80); + break; + case BWnegative: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x58); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x80); + wrSensorReg8_8(0x7d, 0x80); + + break; + case Normal: + + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x00); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x80); + wrSensorReg8_8(0x7d, 0x80); + + break; + } +#endif +} + +void ArduCAM::OV3640_set_Special_effects(uint8_t Special_effect) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Special_effect) + { + case Antique: + + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x18); + wrSensorReg16_8(0x335a, 0x40); + wrSensorReg16_8(0x335b, 0xa6); + break; + case Bluish: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x18); + wrSensorReg16_8(0x335a, 0xa0); + wrSensorReg16_8(0x335b, 0x40); + break; + case Greenish: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x18); + wrSensorReg16_8(0x335a, 0x60); + wrSensorReg16_8(0x335b, 0x60); + break; + case Reddish: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x18); + wrSensorReg16_8(0x335a, 0x80); + wrSensorReg16_8(0x335b, 0xc0); + break; + case Yellowish: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x18); + wrSensorReg16_8(0x335a, 0x30); + wrSensorReg16_8(0x335b, 0x90); + break; + case BW: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x18); // bit[4]fix u enable, bit[3]fix v enable + wrSensorReg16_8(0x335a, 0x80); + wrSensorReg16_8(0x335b, 0x80); + break; + case Negative: + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x40); // bit[6] negative + break; + case BWnegative: + wrSensorReg8_8(0xff, 0x00); + wrSensorReg8_8(0x7c, 0x00); + wrSensorReg8_8(0x7d, 0x58); + wrSensorReg8_8(0x7c, 0x05); + wrSensorReg8_8(0x7d, 0x80); + wrSensorReg8_8(0x7d, 0x80); + + break; + case Normal: + + wrSensorReg16_8(0x3302, 0xef); + wrSensorReg16_8(0x3355, 0x00); + + break; + } +#endif +} + +void ArduCAM::OV5642_set_Special_effects(uint8_t Special_effect) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (Special_effect) + { + case Bluish: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x18); + wrSensorReg16_8(0x5585, 0xa0); + wrSensorReg16_8(0x5586, 0x40); + break; + case Greenish: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x18); + wrSensorReg16_8(0x5585, 0x60); + wrSensorReg16_8(0x5586, 0x60); + break; + case Reddish: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x18); + wrSensorReg16_8(0x5585, 0x80); + wrSensorReg16_8(0x5586, 0xc0); + break; + case BW: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x18); + wrSensorReg16_8(0x5585, 0x80); + wrSensorReg16_8(0x5586, 0x80); + break; + case Negative: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x40); + break; + + case Sepia: + wrSensorReg16_8(0x5001, 0xff); + wrSensorReg16_8(0x5580, 0x18); + wrSensorReg16_8(0x5585, 0x40); + wrSensorReg16_8(0x5586, 0xa0); + break; + case Normal: + wrSensorReg16_8(0x5001, 0x7f); + wrSensorReg16_8(0x5580, 0x00); + break; + } +#endif +} + +void ArduCAM::OV5640_set_Special_effects(uint8_t Special_effect) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (Special_effect) + { + case Normal: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x06); + wrSensorReg16_8(0x5583, 0x40); // sat U + wrSensorReg16_8(0x5584, 0x10); // sat V + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group + break; + case Blueish: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x1e); + wrSensorReg16_8(0x5583, 0xa0); + wrSensorReg16_8(0x5584, 0x40); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Reddish: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x1e); + wrSensorReg16_8(0x5583, 0x80); + wrSensorReg16_8(0x5584, 0xc0); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case BW: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x1e); + wrSensorReg16_8(0x5583, 0x80); + wrSensorReg16_8(0x5584, 0x80); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Sepia: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x1e); + wrSensorReg16_8(0x5583, 0x40); + wrSensorReg16_8(0x5584, 0xa0); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + + case Negative: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x40); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x5583, 0x40); // sat U + wrSensorReg16_8(0x5584, 0x10); // sat V + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Greenish: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x1e); + wrSensorReg16_8(0x5583, 0x60); + wrSensorReg16_8(0x5584, 0x60); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Overexposure: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x1e); + wrSensorReg16_8(0x5583, 0xf0); + wrSensorReg16_8(0x5584, 0xf0); + wrSensorReg16_8(0x5003, 0x08); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + case Solarize: + wrSensorReg16_8(0x3212, 0x03); // start group 3 + wrSensorReg16_8(0x5580, 0x06); + wrSensorReg16_8(0x5583, 0x40); // sat U + wrSensorReg16_8(0x5584, 0x10); // sat V + wrSensorReg16_8(0x5003, 0x09); + wrSensorReg16_8(0x3212, 0x13); // end group 3 + wrSensorReg16_8(0x3212, 0xa3); // launch group 3 + break; + } +#endif +} + +void ArduCAM::OV3640_set_Exposure_level(uint8_t level) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (level) + { + case Exposure_17_EV: + wrSensorReg16_8(0x3018, 0x10); + wrSensorReg16_8(0x3019, 0x08); + wrSensorReg16_8(0x301a, 0x21); + break; + case Exposure_13_EV: + wrSensorReg16_8(0x3018, 0x18); + wrSensorReg16_8(0x3019, 0x10); + wrSensorReg16_8(0x301a, 0x31); + break; + case Exposure_10_EV: + wrSensorReg16_8(0x3018, 0x20); + wrSensorReg16_8(0x3019, 0x18); + wrSensorReg16_8(0x301a, 0x41); + break; + case Exposure_07_EV: + wrSensorReg16_8(0x3018, 0x28); + wrSensorReg16_8(0x3019, 0x20); + wrSensorReg16_8(0x301a, 0x51); + break; + case Exposure_03_EV: + wrSensorReg16_8(0x3018, 0x30); + wrSensorReg16_8(0x3019, 0x28); + wrSensorReg16_8(0x301a, 0x61); + break; + case Exposure_default: + wrSensorReg16_8(0x3018, 0x38); + wrSensorReg16_8(0x3019, 0x30); + wrSensorReg16_8(0x301a, 0x61); + break; + case Exposure03_EV: + wrSensorReg16_8(0x3018, 0x40); + wrSensorReg16_8(0x3019, 0x38); + wrSensorReg16_8(0x301a, 0x71); + break; + case Exposure07_EV: + wrSensorReg16_8(0x3018, 0x48); + wrSensorReg16_8(0x3019, 0x40); + wrSensorReg16_8(0x301a, 0x81); + break; + case Exposure10_EV: + wrSensorReg16_8(0x3018, 0x50); + wrSensorReg16_8(0x3019, 0x48); + wrSensorReg16_8(0x301a, 0x91); + break; + case Exposure13_EV: + wrSensorReg16_8(0x3018, 0x58); + wrSensorReg16_8(0x3019, 0x50); + wrSensorReg16_8(0x301a, 0x91); + break; + case Exposure17_EV: + wrSensorReg16_8(0x3018, 0x60); + wrSensorReg16_8(0x3019, 0x58); + wrSensorReg16_8(0x301a, 0xa1); + break; } - - - - - void ArduCAM::OV5642_set_hue(uint8_t degree) +#endif +} + +void ArduCAM::OV5642_set_Exposure_level(uint8_t level) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (level) { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(degree) - { - case degree_180: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x80); - wrSensorReg16_8(0x5582 ,0x00); - wrSensorReg16_8(0x558a ,0x32); - break; - case degree_150: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x6f); - wrSensorReg16_8(0x5582 ,0x40); - wrSensorReg16_8(0x558a ,0x32); - break; - case degree_120: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x40); - wrSensorReg16_8(0x5582 ,0x6f); - wrSensorReg16_8(0x558a ,0x32); - break; - case degree_90: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x00); - wrSensorReg16_8(0x5582 ,0x80); - wrSensorReg16_8(0x558a ,0x02); - break; - case degree_60: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x40); - wrSensorReg16_8(0x5582 ,0x6f); - wrSensorReg16_8(0x558a ,0x02); - break; - case degree_30: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x6f); - wrSensorReg16_8(0x5582 ,0x40); - wrSensorReg16_8(0x558a ,0x02); - break; - case degree_0: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x80); - wrSensorReg16_8(0x5582 ,0x00); - wrSensorReg16_8(0x558a ,0x01); - break; - case degree30: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x6f); - wrSensorReg16_8(0x5582 ,0x40); - wrSensorReg16_8(0x558a ,0x01); - break; - case degree60: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x40); - wrSensorReg16_8(0x5582 ,0x6f); - wrSensorReg16_8(0x558a ,0x01); - break; - case degree90: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x00); - wrSensorReg16_8(0x5582 ,0x80); - wrSensorReg16_8(0x558a ,0x31); - break; - case degree120: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x40); - wrSensorReg16_8(0x5582 ,0x6f); - wrSensorReg16_8(0x558a ,0x31); - break; - case degree150: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x01); - wrSensorReg16_8(0x5581 ,0x6f); - wrSensorReg16_8(0x5582 ,0x40); - wrSensorReg16_8(0x558a ,0x31); - break; - } -#endif - + case Exposure_17_EV: + wrSensorReg16_8(0x3a0f, 0x10); + wrSensorReg16_8(0x3a10, 0x08); + wrSensorReg16_8(0x3a1b, 0x10); + wrSensorReg16_8(0x3a1e, 0x08); + wrSensorReg16_8(0x3a11, 0x20); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure_13_EV: + wrSensorReg16_8(0x3a0f, 0x18); + wrSensorReg16_8(0x3a10, 0x10); + wrSensorReg16_8(0x3a1b, 0x18); + wrSensorReg16_8(0x3a1e, 0x10); + wrSensorReg16_8(0x3a11, 0x30); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure_10_EV: + wrSensorReg16_8(0x3a0f, 0x20); + wrSensorReg16_8(0x3a10, 0x18); + wrSensorReg16_8(0x3a11, 0x41); + wrSensorReg16_8(0x3a1b, 0x20); + wrSensorReg16_8(0x3a1e, 0x18); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure_07_EV: + wrSensorReg16_8(0x3a0f, 0x28); + wrSensorReg16_8(0x3a10, 0x20); + wrSensorReg16_8(0x3a11, 0x51); + wrSensorReg16_8(0x3a1b, 0x28); + wrSensorReg16_8(0x3a1e, 0x20); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure_03_EV: + wrSensorReg16_8(0x3a0f, 0x30); + wrSensorReg16_8(0x3a10, 0x28); + wrSensorReg16_8(0x3a11, 0x61); + wrSensorReg16_8(0x3a1b, 0x30); + wrSensorReg16_8(0x3a1e, 0x28); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure_default: + wrSensorReg16_8(0x3a0f, 0x38); + wrSensorReg16_8(0x3a10, 0x30); + wrSensorReg16_8(0x3a11, 0x61); + wrSensorReg16_8(0x3a1b, 0x38); + wrSensorReg16_8(0x3a1e, 0x30); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure03_EV: + wrSensorReg16_8(0x3a0f, 0x40); + wrSensorReg16_8(0x3a10, 0x38); + wrSensorReg16_8(0x3a11, 0x71); + wrSensorReg16_8(0x3a1b, 0x40); + wrSensorReg16_8(0x3a1e, 0x38); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case Exposure07_EV: + wrSensorReg16_8(0x3a0f, 0x48); + wrSensorReg16_8(0x3a10, 0x40); + wrSensorReg16_8(0x3a11, 0x80); + wrSensorReg16_8(0x3a1b, 0x48); + wrSensorReg16_8(0x3a1e, 0x40); + wrSensorReg16_8(0x3a1f, 0x20); + break; + case Exposure10_EV: + wrSensorReg16_8(0x3a0f, 0x50); + wrSensorReg16_8(0x3a10, 0x48); + wrSensorReg16_8(0x3a11, 0x90); + wrSensorReg16_8(0x3a1b, 0x50); + wrSensorReg16_8(0x3a1e, 0x48); + wrSensorReg16_8(0x3a1f, 0x20); + break; + case Exposure13_EV: + wrSensorReg16_8(0x3a0f, 0x58); + wrSensorReg16_8(0x3a10, 0x50); + wrSensorReg16_8(0x3a11, 0x91); + wrSensorReg16_8(0x3a1b, 0x58); + wrSensorReg16_8(0x3a1e, 0x50); + wrSensorReg16_8(0x3a1f, 0x20); + break; + case Exposure17_EV: + wrSensorReg16_8(0x3a0f, 0x60); + wrSensorReg16_8(0x3a10, 0x58); + wrSensorReg16_8(0x3a11, 0xa0); + wrSensorReg16_8(0x3a1b, 0x60); + wrSensorReg16_8(0x3a1e, 0x58); + wrSensorReg16_8(0x3a1f, 0x20); + break; } - - void ArduCAM::OV2640_set_Special_effects(uint8_t Special_effect) +#endif +} + +void ArduCAM::OV3640_set_Sharpness(uint8_t Sharpness) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Sharpness) { -#if (defined (OV2640_CAM)||defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS)) - switch(Special_effect) - { - case Antique: - - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x18); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x40); - wrSensorReg8_8(0x7d, 0xa6); - break; - case Bluish: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x18); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0xa0); - wrSensorReg8_8(0x7d, 0x40); - break; - case Greenish: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x18); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x40); - wrSensorReg8_8(0x7d, 0x40); - break; - case Reddish: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x18); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x40); - wrSensorReg8_8(0x7d, 0xc0); - break; - case BW: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x18); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x80); - wrSensorReg8_8(0x7d, 0x80); - break; - case Negative: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x40); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x80); - wrSensorReg8_8(0x7d, 0x80); - break; - case BWnegative: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x58); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x80); - wrSensorReg8_8(0x7d, 0x80); - - break; - case Normal: - - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x00); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x80); - wrSensorReg8_8(0x7d, 0x80); - - break; - - } - #endif + case Sharpness1: + wrSensorReg16_8(0x332d, 0x41); + break; + case Sharpness2: + wrSensorReg16_8(0x332d, 0x42); + break; + case Sharpness3: + wrSensorReg16_8(0x332d, 0x43); + break; + case Sharpness4: + wrSensorReg16_8(0x332d, 0x44); + break; + case Sharpness5: + wrSensorReg16_8(0x332d, 0x45); + break; + case Sharpness6: + wrSensorReg16_8(0x332d, 0x46); + break; + case Sharpness7: + wrSensorReg16_8(0x332d, 0x47); + break; + case Sharpness8: + wrSensorReg16_8(0x332d, 0x48); + break; + case Sharpness_auto: + wrSensorReg16_8(0x332d, 0x60); + wrSensorReg16_8(0x332f, 0x03); + break; } - - void ArduCAM::OV3640_set_Special_effects(uint8_t Special_effect) +#endif +} + +void ArduCAM::OV3640_set_Mirror_Flip(uint8_t Mirror_Flip) +{ +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) + switch (Mirror_Flip) { -#if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Special_effect) - { - case Antique: - - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x18); - wrSensorReg16_8(0x335a, 0x40); - wrSensorReg16_8(0x335b, 0xa6); - break; - case Bluish: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x18); - wrSensorReg16_8(0x335a, 0xa0); - wrSensorReg16_8(0x335b, 0x40); - break; - case Greenish: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x18); - wrSensorReg16_8(0x335a, 0x60); - wrSensorReg16_8(0x335b, 0x60); - break; - case Reddish: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x18); - wrSensorReg16_8(0x335a, 0x80); - wrSensorReg16_8(0x335b, 0xc0); - break; - case Yellowish: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x18); - wrSensorReg16_8(0x335a, 0x30); - wrSensorReg16_8(0x335b, 0x90); - break; - case BW: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x18);//bit[4]fix u enable, bit[3]fix v enable - wrSensorReg16_8(0x335a, 0x80); - wrSensorReg16_8(0x335b, 0x80); - break; - case Negative: - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x40);//bit[6] negative - break; - case BWnegative: - wrSensorReg8_8(0xff, 0x00); - wrSensorReg8_8(0x7c, 0x00); - wrSensorReg8_8(0x7d, 0x58); - wrSensorReg8_8(0x7c, 0x05); - wrSensorReg8_8(0x7d, 0x80); - wrSensorReg8_8(0x7d, 0x80); - - break; - case Normal: - - wrSensorReg16_8(0x3302, 0xef); - wrSensorReg16_8(0x3355, 0x00); - - break; - - } - #endif + case MIRROR: + wrSensorReg16_8(0x307c, 0x12); // mirror + wrSensorReg16_8(0x3090, 0xc8); + wrSensorReg16_8(0x3023, 0x0a); + + break; + case FLIP: + wrSensorReg16_8(0x307c, 0x11); // flip + wrSensorReg16_8(0x3023, 0x09); + wrSensorReg16_8(0x3090, 0xc0); + break; + case MIRROR_FLIP: + wrSensorReg16_8(0x307c, 0x13); // flip/mirror + wrSensorReg16_8(0x3023, 0x09); + wrSensorReg16_8(0x3090, 0xc8); + break; + case Normal: + wrSensorReg16_8(0x307c, 0x10); // no mirror/flip + wrSensorReg16_8(0x3090, 0xc0); + wrSensorReg16_8(0x3023, 0x0a); + break; } - - - void ArduCAM::OV5642_set_Special_effects(uint8_t Special_effect) +#endif +} + +void ArduCAM::OV5642_set_Sharpness(uint8_t Sharpness) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (Sharpness) { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(Special_effect) - { - case Bluish: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x18); - wrSensorReg16_8(0x5585 ,0xa0); - wrSensorReg16_8(0x5586 ,0x40); - break; - case Greenish: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x18); - wrSensorReg16_8(0x5585 ,0x60); - wrSensorReg16_8(0x5586 ,0x60); - break; - case Reddish: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x18); - wrSensorReg16_8(0x5585 ,0x80); - wrSensorReg16_8(0x5586 ,0xc0); - break; - case BW: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x18); - wrSensorReg16_8(0x5585 ,0x80); - wrSensorReg16_8(0x5586 ,0x80); - break; - case Negative: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x40); - break; - - case Sepia: - wrSensorReg16_8(0x5001 ,0xff); - wrSensorReg16_8(0x5580 ,0x18); - wrSensorReg16_8(0x5585 ,0x40); - wrSensorReg16_8(0x5586 ,0xa0); - break; - case Normal: - wrSensorReg16_8(0x5001 ,0x7f); - wrSensorReg16_8(0x5580 ,0x00); - break; - } - #endif + case Auto_Sharpness_default: + wrSensorReg16_8(0x530A, 0x00); + wrSensorReg16_8(0x530c, 0x0); + wrSensorReg16_8(0x530d, 0xc); + wrSensorReg16_8(0x5312, 0x40); + break; + case Auto_Sharpness1: + wrSensorReg16_8(0x530A, 0x00); + wrSensorReg16_8(0x530c, 0x4); + wrSensorReg16_8(0x530d, 0x18); + wrSensorReg16_8(0x5312, 0x20); + break; + case Auto_Sharpness2: + wrSensorReg16_8(0x530A, 0x00); + wrSensorReg16_8(0x530c, 0x8); + wrSensorReg16_8(0x530d, 0x30); + wrSensorReg16_8(0x5312, 0x10); + break; + case Manual_Sharpnessoff: + wrSensorReg16_8(0x530A, 0x08); + wrSensorReg16_8(0x531e, 0x00); + wrSensorReg16_8(0x531f, 0x00); + break; + case Manual_Sharpness1: + wrSensorReg16_8(0x530A, 0x08); + wrSensorReg16_8(0x531e, 0x04); + wrSensorReg16_8(0x531f, 0x04); + break; + case Manual_Sharpness2: + wrSensorReg16_8(0x530A, 0x08); + wrSensorReg16_8(0x531e, 0x08); + wrSensorReg16_8(0x531f, 0x08); + break; + case Manual_Sharpness3: + wrSensorReg16_8(0x530A, 0x08); + wrSensorReg16_8(0x531e, 0x0c); + wrSensorReg16_8(0x531f, 0x0c); + break; + case Manual_Sharpness4: + wrSensorReg16_8(0x530A, 0x08); + wrSensorReg16_8(0x531e, 0x0f); + wrSensorReg16_8(0x531f, 0x0f); + break; + case Manual_Sharpness5: + wrSensorReg16_8(0x530A, 0x08); + wrSensorReg16_8(0x531e, 0x1f); + wrSensorReg16_8(0x531f, 0x1f); + break; } - - void ArduCAM::OV5640_set_Special_effects(uint8_t Special_effect) +#endif +} + +void ArduCAM::OV5642_set_Mirror_Flip(uint8_t Mirror_Flip) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + uint8_t reg_val; + switch (Mirror_Flip) { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch(Special_effect) - { - case Normal: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x06); - wrSensorReg16_8(0x5583, 0x40); // sat U - wrSensorReg16_8(0x5584, 0x10); // sat V - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group - break; - case Blueish: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x1e); - wrSensorReg16_8(0x5583, 0xa0); - wrSensorReg16_8(0x5584, 0x40); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Reddish: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x1e); - wrSensorReg16_8(0x5583, 0x80); - wrSensorReg16_8(0x5584, 0xc0); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case BW: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x1e); - wrSensorReg16_8(0x5583, 0x80); - wrSensorReg16_8(0x5584, 0x80); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Sepia: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x1e); - wrSensorReg16_8(0x5583, 0x40); - wrSensorReg16_8(0x5584, 0xa0); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - - case Negative: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x40); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x5583, 0x40); // sat U - wrSensorReg16_8(0x5584, 0x10); // sat V - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Greenish: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x1e); - wrSensorReg16_8(0x5583, 0x60); - wrSensorReg16_8(0x5584, 0x60); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Overexposure: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x1e); - wrSensorReg16_8(0x5583, 0xf0); - wrSensorReg16_8(0x5584, 0xf0); - wrSensorReg16_8(0x5003, 0x08); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - case Solarize: - wrSensorReg16_8(0x3212, 0x03); // start group 3 - wrSensorReg16_8(0x5580, 0x06); - wrSensorReg16_8(0x5583, 0x40); // sat U - wrSensorReg16_8(0x5584, 0x10); // sat V - wrSensorReg16_8(0x5003, 0x09); - wrSensorReg16_8(0x3212, 0x13); // end group 3 - wrSensorReg16_8(0x3212, 0xa3); // launch group 3 - break; - } - #endif + case MIRROR: + rdSensorReg16_8(0x3818, ®_val); + reg_val = reg_val | 0x00; + reg_val = reg_val & 0x9F; + wrSensorReg16_8(0x3818, reg_val); + rdSensorReg16_8(0x3621, ®_val); + reg_val = reg_val | 0x20; + wrSensorReg16_8(0x3621, reg_val); + + break; + case FLIP: + rdSensorReg16_8(0x3818, ®_val); + reg_val = reg_val | 0x20; + reg_val = reg_val & 0xbF; + wrSensorReg16_8(0x3818, reg_val); + rdSensorReg16_8(0x3621, ®_val); + reg_val = reg_val | 0x20; + wrSensorReg16_8(0x3621, reg_val); + break; + case MIRROR_FLIP: + rdSensorReg16_8(0x3818, ®_val); + reg_val = reg_val | 0x60; + reg_val = reg_val & 0xFF; + wrSensorReg16_8(0x3818, reg_val); + rdSensorReg16_8(0x3621, ®_val); + reg_val = reg_val & 0xdf; + wrSensorReg16_8(0x3621, reg_val); + break; + case Normal: + rdSensorReg16_8(0x3818, ®_val); + reg_val = reg_val | 0x40; + reg_val = reg_val & 0xdF; + wrSensorReg16_8(0x3818, reg_val); + rdSensorReg16_8(0x3621, ®_val); + reg_val = reg_val & 0xdf; + wrSensorReg16_8(0x3621, reg_val); + break; } - - - void ArduCAM::OV3640_set_Exposure_level(uint8_t level) +#endif +} + +void ArduCAM::OV5642_set_Compress_quality(uint8_t quality) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (quality) { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(level) - { - case Exposure_17_EV: - wrSensorReg16_8(0x3018, 0x10); - wrSensorReg16_8(0x3019, 0x08); - wrSensorReg16_8(0x301a, 0x21); - break; - case Exposure_13_EV: - wrSensorReg16_8(0x3018, 0x18); - wrSensorReg16_8(0x3019, 0x10); - wrSensorReg16_8(0x301a, 0x31); - break; - case Exposure_10_EV: - wrSensorReg16_8(0x3018, 0x20); - wrSensorReg16_8(0x3019, 0x18); - wrSensorReg16_8(0x301a, 0x41); - break; - case Exposure_07_EV: - wrSensorReg16_8(0x3018, 0x28); - wrSensorReg16_8(0x3019, 0x20); - wrSensorReg16_8(0x301a, 0x51); - break; - case Exposure_03_EV: - wrSensorReg16_8(0x3018, 0x30); - wrSensorReg16_8(0x3019, 0x28); - wrSensorReg16_8(0x301a, 0x61); - break; - case Exposure_default: - wrSensorReg16_8(0x3018, 0x38); - wrSensorReg16_8(0x3019, 0x30); - wrSensorReg16_8(0x301a, 0x61); - break; - case Exposure03_EV: - wrSensorReg16_8(0x3018, 0x40); - wrSensorReg16_8(0x3019, 0x38); - wrSensorReg16_8(0x301a, 0x71); - break; - case Exposure07_EV: - wrSensorReg16_8(0x3018, 0x48); - wrSensorReg16_8(0x3019, 0x40); - wrSensorReg16_8(0x301a, 0x81); - break; - case Exposure10_EV: - wrSensorReg16_8(0x3018, 0x50); - wrSensorReg16_8(0x3019, 0x48); - wrSensorReg16_8(0x301a, 0x91); - break; - case Exposure13_EV: - wrSensorReg16_8(0x3018, 0x58); - wrSensorReg16_8(0x3019, 0x50); - wrSensorReg16_8(0x301a, 0x91); - break; - case Exposure17_EV: - wrSensorReg16_8(0x3018, 0x60); - wrSensorReg16_8(0x3019, 0x58); - wrSensorReg16_8(0x301a, 0xa1); - break; - } - #endif - + case high_quality: + wrSensorReg16_8(0x4407, 0x02); + break; + case default_quality: + wrSensorReg16_8(0x4407, 0x04); + break; + case low_quality: + wrSensorReg16_8(0x4407, 0x08); + break; } - - - - void ArduCAM::OV5642_set_Exposure_level(uint8_t level) - { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(level) - { - case Exposure_17_EV: - wrSensorReg16_8(0x3a0f ,0x10); - wrSensorReg16_8(0x3a10 ,0x08); - wrSensorReg16_8(0x3a1b ,0x10); - wrSensorReg16_8(0x3a1e ,0x08); - wrSensorReg16_8(0x3a11 ,0x20); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure_13_EV: - wrSensorReg16_8(0x3a0f ,0x18); - wrSensorReg16_8(0x3a10 ,0x10); - wrSensorReg16_8(0x3a1b ,0x18); - wrSensorReg16_8(0x3a1e ,0x10); - wrSensorReg16_8(0x3a11 ,0x30); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure_10_EV: - wrSensorReg16_8(0x3a0f ,0x20); - wrSensorReg16_8(0x3a10 ,0x18); - wrSensorReg16_8(0x3a11 ,0x41); - wrSensorReg16_8(0x3a1b ,0x20); - wrSensorReg16_8(0x3a1e ,0x18); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure_07_EV: - wrSensorReg16_8(0x3a0f ,0x28); - wrSensorReg16_8(0x3a10 ,0x20); - wrSensorReg16_8(0x3a11 ,0x51); - wrSensorReg16_8(0x3a1b ,0x28); - wrSensorReg16_8(0x3a1e ,0x20); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure_03_EV: - wrSensorReg16_8(0x3a0f ,0x30); - wrSensorReg16_8(0x3a10 ,0x28); - wrSensorReg16_8(0x3a11 ,0x61); - wrSensorReg16_8(0x3a1b ,0x30); - wrSensorReg16_8(0x3a1e ,0x28); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure_default: - wrSensorReg16_8(0x3a0f ,0x38); - wrSensorReg16_8(0x3a10 ,0x30); - wrSensorReg16_8(0x3a11 ,0x61); - wrSensorReg16_8(0x3a1b ,0x38); - wrSensorReg16_8(0x3a1e ,0x30); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure03_EV: - wrSensorReg16_8(0x3a0f ,0x40); - wrSensorReg16_8(0x3a10 ,0x38); - wrSensorReg16_8(0x3a11 ,0x71); - wrSensorReg16_8(0x3a1b ,0x40); - wrSensorReg16_8(0x3a1e ,0x38); - wrSensorReg16_8(0x3a1f ,0x10); - break; - case Exposure07_EV: - wrSensorReg16_8(0x3a0f ,0x48); - wrSensorReg16_8(0x3a10 ,0x40); - wrSensorReg16_8(0x3a11 ,0x80); - wrSensorReg16_8(0x3a1b ,0x48); - wrSensorReg16_8(0x3a1e ,0x40); - wrSensorReg16_8(0x3a1f ,0x20); - break; - case Exposure10_EV: - wrSensorReg16_8(0x3a0f ,0x50); - wrSensorReg16_8(0x3a10 ,0x48); - wrSensorReg16_8(0x3a11 ,0x90); - wrSensorReg16_8(0x3a1b ,0x50); - wrSensorReg16_8(0x3a1e ,0x48); - wrSensorReg16_8(0x3a1f ,0x20); - break; - case Exposure13_EV: - wrSensorReg16_8(0x3a0f ,0x58); - wrSensorReg16_8(0x3a10 ,0x50); - wrSensorReg16_8(0x3a11 ,0x91); - wrSensorReg16_8(0x3a1b ,0x58); - wrSensorReg16_8(0x3a1e ,0x50); - wrSensorReg16_8(0x3a1f ,0x20); - break; - case Exposure17_EV: - wrSensorReg16_8(0x3a0f ,0x60); - wrSensorReg16_8(0x3a10 ,0x58); - wrSensorReg16_8(0x3a11 ,0xa0); - wrSensorReg16_8(0x3a1b ,0x60); - wrSensorReg16_8(0x3a1e ,0x58); - wrSensorReg16_8(0x3a1f ,0x20); - break; - } -#endif - } - - - void ArduCAM::OV3640_set_Sharpness(uint8_t Sharpness) - { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Sharpness) - { - case Sharpness1: - wrSensorReg16_8(0x332d, 0x41); - break; - case Sharpness2: - wrSensorReg16_8(0x332d, 0x42); - break; - case Sharpness3: - wrSensorReg16_8(0x332d, 0x43); - break; - case Sharpness4: - wrSensorReg16_8(0x332d, 0x44); - break; - case Sharpness5: - wrSensorReg16_8(0x332d, 0x45); - break; - case Sharpness6: - wrSensorReg16_8(0x332d, 0x46); - break; - case Sharpness7: - wrSensorReg16_8(0x332d, 0x47); - break; - case Sharpness8: - wrSensorReg16_8(0x332d, 0x48); - break; - case Sharpness_auto: - wrSensorReg16_8(0x332d, 0x60); - wrSensorReg16_8(0x332f, 0x03); - break; - } #endif - } - - void ArduCAM::OV3640_set_Mirror_Flip(uint8_t Mirror_Flip) +} + +void ArduCAM::OV5642_Test_Pattern(uint8_t Pattern) +{ +#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_PLUS) + switch (Pattern) { - #if (defined (OV3640_CAM)||defined (OV3640_MINI_3MP)) - switch(Mirror_Flip) - { - case MIRROR: - wrSensorReg16_8(0x307c, 0x12);//mirror - wrSensorReg16_8(0x3090, 0xc8); - wrSensorReg16_8(0x3023, 0x0a); - - break; - case FLIP: - wrSensorReg16_8(0x307c, 0x11);//flip - wrSensorReg16_8(0x3023, 0x09); - wrSensorReg16_8(0x3090, 0xc0); - break; - case MIRROR_FLIP: - wrSensorReg16_8(0x307c, 0x13);//flip/mirror - wrSensorReg16_8(0x3023, 0x09); - wrSensorReg16_8(0x3090, 0xc8); - break; - case Normal: - wrSensorReg16_8(0x307c, 0x10);//no mirror/flip - wrSensorReg16_8(0x3090, 0xc0); - wrSensorReg16_8(0x3023, 0x0a); - break; - } - #endif + case Color_bar: + wrSensorReg16_8(0x503d, 0x80); + wrSensorReg16_8(0x503e, 0x00); + break; + case Color_square: + wrSensorReg16_8(0x503d, 0x85); + wrSensorReg16_8(0x503e, 0x12); + break; + case BW_square: + wrSensorReg16_8(0x503d, 0x85); + wrSensorReg16_8(0x503e, 0x1a); + break; + case DLI: + wrSensorReg16_8(0x4741, 0x4); + break; } - - void ArduCAM::OV5642_set_Sharpness(uint8_t Sharpness) - { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(Sharpness) - { - case Auto_Sharpness_default: - wrSensorReg16_8(0x530A ,0x00); - wrSensorReg16_8(0x530c ,0x0 ); - wrSensorReg16_8(0x530d ,0xc ); - wrSensorReg16_8(0x5312 ,0x40); - break; - case Auto_Sharpness1: - wrSensorReg16_8(0x530A ,0x00); - wrSensorReg16_8(0x530c ,0x4 ); - wrSensorReg16_8(0x530d ,0x18); - wrSensorReg16_8(0x5312 ,0x20); - break; - case Auto_Sharpness2: - wrSensorReg16_8(0x530A ,0x00); - wrSensorReg16_8(0x530c ,0x8 ); - wrSensorReg16_8(0x530d ,0x30); - wrSensorReg16_8(0x5312 ,0x10); - break; - case Manual_Sharpnessoff: - wrSensorReg16_8(0x530A ,0x08); - wrSensorReg16_8(0x531e ,0x00); - wrSensorReg16_8(0x531f ,0x00); - break; - case Manual_Sharpness1: - wrSensorReg16_8(0x530A ,0x08); - wrSensorReg16_8(0x531e ,0x04); - wrSensorReg16_8(0x531f ,0x04); - break; - case Manual_Sharpness2: - wrSensorReg16_8(0x530A ,0x08); - wrSensorReg16_8(0x531e ,0x08); - wrSensorReg16_8(0x531f ,0x08); - break; - case Manual_Sharpness3: - wrSensorReg16_8(0x530A ,0x08); - wrSensorReg16_8(0x531e ,0x0c); - wrSensorReg16_8(0x531f ,0x0c); - break; - case Manual_Sharpness4: - wrSensorReg16_8(0x530A ,0x08); - wrSensorReg16_8(0x531e ,0x0f); - wrSensorReg16_8(0x531f ,0x0f); - break; - case Manual_Sharpness5: - wrSensorReg16_8(0x530A ,0x08); - wrSensorReg16_8(0x531e ,0x1f); - wrSensorReg16_8(0x531f ,0x1f); - break; - } #endif - } - - void ArduCAM::OV5642_set_Mirror_Flip(uint8_t Mirror_Flip) +} + +void ArduCAM::OV5640_set_Night_Mode(uint8_t Night_mode) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + uint8_t reg_val; + switch (Night_mode) { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - uint8_t reg_val; - switch(Mirror_Flip) - { - case MIRROR: - rdSensorReg16_8(0x3818,®_val); - reg_val = reg_val|0x00; - reg_val = reg_val&0x9F; - wrSensorReg16_8(0x3818 ,reg_val); - rdSensorReg16_8(0x3621,®_val); - reg_val = reg_val|0x20; - wrSensorReg16_8(0x3621, reg_val ); - - break; - case FLIP: - rdSensorReg16_8(0x3818,®_val); - reg_val = reg_val|0x20; - reg_val = reg_val&0xbF; - wrSensorReg16_8(0x3818 ,reg_val); - rdSensorReg16_8(0x3621,®_val); - reg_val = reg_val|0x20; - wrSensorReg16_8(0x3621, reg_val ); - break; - case MIRROR_FLIP: - rdSensorReg16_8(0x3818,®_val); - reg_val = reg_val|0x60; - reg_val = reg_val&0xFF; - wrSensorReg16_8(0x3818 ,reg_val); - rdSensorReg16_8(0x3621,®_val); - reg_val = reg_val&0xdf; - wrSensorReg16_8(0x3621, reg_val ); - break; - case Normal: - rdSensorReg16_8(0x3818,®_val); - reg_val = reg_val|0x40; - reg_val = reg_val&0xdF; - wrSensorReg16_8(0x3818 ,reg_val); - rdSensorReg16_8(0x3621,®_val); - reg_val = reg_val&0xdf; - wrSensorReg16_8(0x3621, reg_val ); - break; - } - #endif + case Night_Mode_On: + rdSensorReg16_8(0x3a00, ®_val); + reg_val = reg_val | 0x04; + wrSensorReg16_8(0x3a00, reg_val); + break; + case Night_Mode_Off: + rdSensorReg16_8(0x3a00, ®_val); + reg_val = reg_val & 0xfb; + wrSensorReg16_8(0x3a00, reg_val); + break; } - - - void ArduCAM::OV5642_set_Compress_quality(uint8_t quality) - { -#if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(quality) - { - case high_quality: - wrSensorReg16_8(0x4407, 0x02); - break; - case default_quality: - wrSensorReg16_8(0x4407, 0x04); - break; - case low_quality: - wrSensorReg16_8(0x4407, 0x08); - break; - } #endif - } - - void ArduCAM::OV5642_Test_Pattern(uint8_t Pattern) +} + +void ArduCAM::OV5640_set_Banding_Filter(uint8_t Banding_Filter) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + uint8_t reg_val; + switch (Banding_Filter) { - #if defined(OV5642_CAM) || defined(OV5642_CAM_BIT_ROTATION_FIXED)|| defined(OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_PLUS) - switch(Pattern) - { - case Color_bar: - wrSensorReg16_8(0x503d , 0x80); - wrSensorReg16_8(0x503e, 0x00); - break; - case Color_square: - wrSensorReg16_8(0x503d , 0x85); - wrSensorReg16_8(0x503e, 0x12); - break; - case BW_square: - wrSensorReg16_8(0x503d , 0x85); - wrSensorReg16_8(0x503e, 0x1a); - break; - case DLI: - wrSensorReg16_8(0x4741 , 0x4); - break; - } -#endif + case Off: + rdSensorReg16_8(0x3a00, ®_val); + reg_val = reg_val & 0xdf; // turn off banding filter + wrSensorReg16_8(0x3a00, reg_val); + break; + case Manual_50HZ: + wrSensorReg16_8(0x3c00, 04); // set to 50Hz + wrSensorReg16_8(0x3c01, 80); // manual banding filter + rdSensorReg16_8(0x3a00, ®_val); + reg_val = reg_val | 0x20; // turn on banding filter + wrSensorReg16_8(0x3a00, reg_val); + break; + case Manual_60HZ: + wrSensorReg16_8(0x3c00, 00); // set to 60Hz + wrSensorReg16_8(0x3c01, 80); // manual banding filter + rdSensorReg16_8(0x3a00, ®_val); + reg_val = reg_val | 0x20; // turn on banding filter + wrSensorReg16_8(0x3a00, reg_val); + break; + case Auto_Detection: + wrSensorReg16_8(0x3c01, 00); // auto banding filter + rdSensorReg16_8(0x3a00, ®_val); + reg_val = reg_val & 0xdf; // turn off banding filter + wrSensorReg16_8(0x3a00, reg_val); + break; } - - void ArduCAM::OV5640_set_Night_Mode(uint8_t Night_mode) +#endif +} + +void ArduCAM::OV5640_set_EV(uint8_t EV) +{ +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) + switch (EV) { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - uint8_t reg_val; - switch(Night_mode) - { - case Night_Mode_On: - rdSensorReg16_8(0x3a00,®_val); - reg_val = reg_val| 0x04; - wrSensorReg16_8(0x3a00, reg_val); - break; - case Night_Mode_Off: - rdSensorReg16_8(0x3a00,®_val); - reg_val = reg_val& 0xfb; - wrSensorReg16_8(0x3a00, reg_val); - break; - } - #endif - - } - - void ArduCAM::OV5640_set_Banding_Filter(uint8_t Banding_Filter) - { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - uint8_t reg_val; - switch(Banding_Filter) - { - case Off: - rdSensorReg16_8(0x3a00,®_val); - reg_val = reg_val & 0xdf; // turn off banding filter - wrSensorReg16_8(0x3a00, reg_val); - break; - case Manual_50HZ: - wrSensorReg16_8(0x3c00, 04); // set to 50Hz - wrSensorReg16_8(0x3c01, 80); // manual banding filter - rdSensorReg16_8(0x3a00,®_val); - reg_val = reg_val | 0x20; // turn on banding filter - wrSensorReg16_8(0x3a00, reg_val); - break; - case Manual_60HZ: - wrSensorReg16_8(0x3c00, 00); // set to 60Hz - wrSensorReg16_8(0x3c01, 80); // manual banding filter - rdSensorReg16_8(0x3a00, ®_val); - reg_val = reg_val | 0x20; // turn on banding filter - wrSensorReg16_8(0x3a00, reg_val); - break; - case Auto_Detection: - wrSensorReg16_8(0x3c01, 00); // auto banding filter - rdSensorReg16_8(0x3a00, ®_val); - reg_val = reg_val & 0xdf; // turn off banding filter - wrSensorReg16_8(0x3a00, reg_val); - break; - } - #endif - } - - void ArduCAM::OV5640_set_EV(uint8_t EV) - { - #if (defined (OV5640_CAM)||defined (OV5640_MINI_5MP_PLUS)) - switch(EV) - { - case EV3: - wrSensorReg16_8(0x3a0f, 0x60); - wrSensorReg16_8(0x3a10, 0x58); - wrSensorReg16_8(0x3a11, 0xa0); - wrSensorReg16_8(0x3a1b, 0x60); - wrSensorReg16_8(0x3a1e, 0x58); - wrSensorReg16_8(0x3a1f, 0x20); - break; - case EV2: - wrSensorReg16_8(0x3a0f, 0x50); - wrSensorReg16_8(0x3a10, 0x48); - wrSensorReg16_8(0x3a11, 0x90); - wrSensorReg16_8(0x3a1b, 0x50); - wrSensorReg16_8(0x3a1e, 0x48); - wrSensorReg16_8(0x3a1f, 0x20); - break; - case EV1: - wrSensorReg16_8(0x3a0f, 0x40); - wrSensorReg16_8(0x3a10, 0x38); - wrSensorReg16_8(0x3a11, 0x71); - wrSensorReg16_8(0x3a1b, 0x40); - wrSensorReg16_8(0x3a1e, 0x38); - wrSensorReg16_8(0x3a1f, 0x10); - break; - case EV0: - wrSensorReg16_8(0x3a0f, 0x38); - wrSensorReg16_8(0x3a10, 0x30); - wrSensorReg16_8(0x3a11, 0x61); - wrSensorReg16_8(0x3a1b, 0x38); - wrSensorReg16_8(0x3a1e, 0x30); - wrSensorReg16_8(0x3a1f, 0x10); - break; - case EV_1: - wrSensorReg16_8(0x3a0f, 0x30); - wrSensorReg16_8(0x3a10, 0x28); - wrSensorReg16_8(0x3a11, 0x61); - wrSensorReg16_8(0x3a1b, 0x30); - wrSensorReg16_8(0x3a1e, 0x28); - wrSensorReg16_8(0x3a1f, 0x10); - break; - case EV_2: - wrSensorReg16_8(0x3a0f, 0x20); - wrSensorReg16_8(0x3a10, 0x18); - wrSensorReg16_8(0x3a11, 0x41); - wrSensorReg16_8(0x3a1b, 0x20); - wrSensorReg16_8(0x3a1e, 0x18); - wrSensorReg16_8(0x3a1f, 0x10); - break; - case EV_3: - wrSensorReg16_8(0x3a0f, 0x10); - wrSensorReg16_8(0x3a10, 0x08); - wrSensorReg16_8(0x3a1b, 0x10); - wrSensorReg16_8(0x3a1e, 0x08); - wrSensorReg16_8(0x3a11, 0x20); - wrSensorReg16_8(0x3a1f, 0x10); - break; - } - #endif - + case EV3: + wrSensorReg16_8(0x3a0f, 0x60); + wrSensorReg16_8(0x3a10, 0x58); + wrSensorReg16_8(0x3a11, 0xa0); + wrSensorReg16_8(0x3a1b, 0x60); + wrSensorReg16_8(0x3a1e, 0x58); + wrSensorReg16_8(0x3a1f, 0x20); + break; + case EV2: + wrSensorReg16_8(0x3a0f, 0x50); + wrSensorReg16_8(0x3a10, 0x48); + wrSensorReg16_8(0x3a11, 0x90); + wrSensorReg16_8(0x3a1b, 0x50); + wrSensorReg16_8(0x3a1e, 0x48); + wrSensorReg16_8(0x3a1f, 0x20); + break; + case EV1: + wrSensorReg16_8(0x3a0f, 0x40); + wrSensorReg16_8(0x3a10, 0x38); + wrSensorReg16_8(0x3a11, 0x71); + wrSensorReg16_8(0x3a1b, 0x40); + wrSensorReg16_8(0x3a1e, 0x38); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case EV0: + wrSensorReg16_8(0x3a0f, 0x38); + wrSensorReg16_8(0x3a10, 0x30); + wrSensorReg16_8(0x3a11, 0x61); + wrSensorReg16_8(0x3a1b, 0x38); + wrSensorReg16_8(0x3a1e, 0x30); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case EV_1: + wrSensorReg16_8(0x3a0f, 0x30); + wrSensorReg16_8(0x3a10, 0x28); + wrSensorReg16_8(0x3a11, 0x61); + wrSensorReg16_8(0x3a1b, 0x30); + wrSensorReg16_8(0x3a1e, 0x28); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case EV_2: + wrSensorReg16_8(0x3a0f, 0x20); + wrSensorReg16_8(0x3a10, 0x18); + wrSensorReg16_8(0x3a11, 0x41); + wrSensorReg16_8(0x3a1b, 0x20); + wrSensorReg16_8(0x3a1e, 0x18); + wrSensorReg16_8(0x3a1f, 0x10); + break; + case EV_3: + wrSensorReg16_8(0x3a0f, 0x10); + wrSensorReg16_8(0x3a10, 0x08); + wrSensorReg16_8(0x3a1b, 0x10); + wrSensorReg16_8(0x3a1e, 0x08); + wrSensorReg16_8(0x3a11, 0x20); + wrSensorReg16_8(0x3a1f, 0x10); + break; } +#endif +} - - - - - // Write 8 bit values to 8 bit register address +// Write 8 bit values to 8 bit register address int ArduCAM::wrSensorRegs8_8(const struct sensor_reg reglist[]) { - #if defined (RASPBERRY_PI) - arducam_i2c_write_regs(reglist); - #else - int err = 0; - uint16_t reg_addr = 0; - uint16_t reg_val = 0; - const struct sensor_reg *next = reglist; - while ((reg_addr != 0xff) | (reg_val != 0xff)) - { - reg_addr = pgm_read_word(&next->reg); - reg_val = pgm_read_word(&next->val); - err = wrSensorReg8_8(reg_addr, reg_val); - next++; - #if (defined(ESP8266)||defined(ESP32)||defined(TEENSYDUINO)) - yield(); - #endif - } - #endif +#if defined(RASPBERRY_PI) + arducam_i2c_write_regs(reglist); +#else + int err = 0; + uint16_t reg_addr = 0; + uint16_t reg_val = 0; + const struct sensor_reg *next = reglist; + while ((reg_addr != 0xff) | (reg_val != 0xff)) + { + reg_addr = pgm_read_word(&next->reg); + reg_val = pgm_read_word(&next->val); + err = wrSensorReg8_8(reg_addr, reg_val); + next++; +#if (defined(ESP8266) || defined(ESP32) || defined(TEENSYDUINO)) + yield(); +#endif + } +#endif return 1; } - // Write 16 bit values to 8 bit register address +// Write 16 bit values to 8 bit register address int ArduCAM::wrSensorRegs8_16(const struct sensor_reg reglist[]) { - #if defined (RASPBERRY_PI) - arducam_i2c_write_regs16(reglist); - #else - int err = 0; - unsigned int reg_addr, reg_val; - const struct sensor_reg *next = reglist; - - while ((reg_addr != 0xff) | (reg_val != 0xffff)) - { - #if defined (RASPBERRY_PI) - reg_addr =next->reg; - reg_val = next->val; - #else - reg_addr = pgm_read_word(&next->reg); - reg_val = pgm_read_word(&next->val); - #endif - err = wrSensorReg8_16(reg_addr, reg_val); - // if (!err) - //return err; - next++; - #if (defined(ESP8266)||defined(ESP32)||defined(TEENSYDUINO)) - yield(); - #endif - } - #endif +#if defined(RASPBERRY_PI) + arducam_i2c_write_regs16(reglist); +#else + int err = 0; + unsigned int reg_addr, reg_val; + const struct sensor_reg *next = reglist; + + while ((reg_addr != 0xff) | (reg_val != 0xffff)) + { +#if defined(RASPBERRY_PI) + reg_addr = next->reg; + reg_val = next->val; +#else + reg_addr = pgm_read_word(&next->reg); + reg_val = pgm_read_word(&next->val); +#endif + err = wrSensorReg8_16(reg_addr, reg_val); + // if (!err) + // return err; + next++; +#if (defined(ESP8266) || defined(ESP32) || defined(TEENSYDUINO)) + yield(); +#endif + } +#endif return 1; } // Write 8 bit values to 16 bit register address int ArduCAM::wrSensorRegs16_8(const struct sensor_reg reglist[]) { - #if defined (RASPBERRY_PI) - arducam_i2c_write_word_regs(reglist); - #else - int err = 0; - unsigned int reg_addr; - unsigned char reg_val; - const struct sensor_reg *next = reglist; - - while ((reg_addr != 0xffff) | (reg_val != 0xff)) - { - - #if defined (RASPBERRY_PI) - reg_addr =next->reg; - reg_val = next->val; - #else - reg_addr = pgm_read_word(&next->reg); - reg_val = pgm_read_word(&next->val); - #endif - err = wrSensorReg16_8(reg_addr, reg_val); - //if (!err) - //return err; - next++; - #if (defined(ESP8266)||defined(ESP32)||defined(TEENSYDUINO)) - yield(); - #endif - } - #endif +#if defined(RASPBERRY_PI) + arducam_i2c_write_word_regs(reglist); +#else + int err = 0; + unsigned int reg_addr; + unsigned char reg_val; + const struct sensor_reg *next = reglist; + + while ((reg_addr != 0xffff) | (reg_val != 0xff)) + { + +#if defined(RASPBERRY_PI) + reg_addr = next->reg; + reg_val = next->val; +#else + reg_addr = pgm_read_word(&next->reg); + reg_val = pgm_read_word(&next->val); +#endif + err = wrSensorReg16_8(reg_addr, reg_val); + // if (!err) + // return err; + next++; +#if (defined(ESP8266) || defined(ESP32) || defined(TEENSYDUINO)) + yield(); +#endif + } +#endif return 1; } -//I2C Array Write 16bit address, 16bit data +// I2C Array Write 16bit address, 16bit data int ArduCAM::wrSensorRegs16_16(const struct sensor_reg reglist[]) { - #if defined (RASPBERRY_PI) - #else - int err = 0; - unsigned int reg_addr, reg_val; - const struct sensor_reg *next = reglist; - reg_addr = pgm_read_word(&next->reg); - reg_val = pgm_read_word(&next->val); - while ((reg_addr != 0xffff) | (reg_val != 0xffff)) - { - err = wrSensorReg16_16(reg_addr, reg_val); - //if (!err) - // return err; - next++; - reg_addr = pgm_read_word(&next->reg); - reg_val = pgm_read_word(&next->val); - #if (defined(ESP8266)||defined(ESP32)||defined(TEENSYDUINO)) - yield(); - #endif - } - #endif - return 1; -} - - - -// Read/write 8 bit value to/from 8 bit register address +#if defined(RASPBERRY_PI) +#else + int err = 0; + unsigned int reg_addr, reg_val; + const struct sensor_reg *next = reglist; + reg_addr = pgm_read_word(&next->reg); + reg_val = pgm_read_word(&next->val); + while ((reg_addr != 0xffff) | (reg_val != 0xffff)) + { + err = wrSensorReg16_16(reg_addr, reg_val); + // if (!err) + // return err; + next++; + reg_addr = pgm_read_word(&next->reg); + reg_val = pgm_read_word(&next->val); +#if (defined(ESP8266) || defined(ESP32) || defined(TEENSYDUINO)) + yield(); +#endif + } +#endif + return 1; +} + +// Read/write 8 bit value to/from 8 bit register address byte ArduCAM::wrSensorReg8_8(int regID, int regDat) { - #if defined (RASPBERRY_PI) - arducam_i2c_write( regID , regDat ); - #else - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID & 0x00FF); - Wire.write(regDat & 0x00FF); - if (Wire.endTransmission()) - { - return 0; - } - delay(1); - #endif +#if defined(RASPBERRY_PI) + arducam_i2c_write(regID, regDat); +#else + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID & 0x00FF); + Wire.write(regDat & 0x00FF); + if (Wire.endTransmission()) + { + return 0; + } + delay(1); +#endif return 1; - -} -byte ArduCAM::rdSensorReg8_8(uint8_t regID, uint8_t* regDat) -{ - #if defined (RASPBERRY_PI) - arducam_i2c_read(regID,regDat); - #else - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID & 0x00FF); - Wire.endTransmission(); - - Wire.requestFrom((sensor_addr >> 1), 1); - if (Wire.available()) - *regDat = Wire.read(); - delay(1); - #endif +} +byte ArduCAM::rdSensorReg8_8(uint8_t regID, uint8_t *regDat) +{ +#if defined(RASPBERRY_PI) + arducam_i2c_read(regID, regDat); +#else + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID & 0x00FF); + Wire.endTransmission(); + + Wire.requestFrom((sensor_addr >> 1), 1); + if (Wire.available()) + *regDat = Wire.read(); + delay(1); +#endif return 1; - } // Read/write 16 bit value to/from 8 bit register address byte ArduCAM::wrSensorReg8_16(int regID, int regDat) { - #if defined (RASPBERRY_PI) - arducam_i2c_write16(regID, regDat ); - #else - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID & 0x00FF); - - Wire.write(regDat >> 8); // sends data byte, MSB first - Wire.write(regDat & 0x00FF); - if (Wire.endTransmission()) - { - return 0; - } - delay(1); - #endif +#if defined(RASPBERRY_PI) + arducam_i2c_write16(regID, regDat); +#else + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID & 0x00FF); + + Wire.write(regDat >> 8); // sends data byte, MSB first + Wire.write(regDat & 0x00FF); + if (Wire.endTransmission()) + { + return 0; + } + delay(1); +#endif return 1; } -byte ArduCAM::rdSensorReg8_16(uint8_t regID, uint16_t* regDat) -{ - #if defined (RASPBERRY_PI) - arducam_i2c_read16(regID, regDat); - #else - uint8_t temp; - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID); - Wire.endTransmission(); - - Wire.requestFrom((sensor_addr >> 1), 2); - if (Wire.available()) - { - temp = Wire.read(); - *regDat = (temp << 8) | Wire.read(); - } - delay(1); - #endif - return 1; +byte ArduCAM::rdSensorReg8_16(uint8_t regID, uint16_t *regDat) +{ +#if defined(RASPBERRY_PI) + arducam_i2c_read16(regID, regDat); +#else + uint8_t temp; + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID); + Wire.endTransmission(); + + Wire.requestFrom((sensor_addr >> 1), 2); + if (Wire.available()) + { + temp = Wire.read(); + *regDat = (temp << 8) | Wire.read(); + } + delay(1); +#endif + return 1; } // Read/write 8 bit value to/from 16 bit register address byte ArduCAM::wrSensorReg16_8(int regID, int regDat) { - #if defined (RASPBERRY_PI) - arducam_i2c_word_write(regID, regDat); - arducam_delay_ms(1); - #else - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID >> 8); // sends instruction byte, MSB first - Wire.write(regID & 0x00FF); - Wire.write(regDat & 0x00FF); - if (Wire.endTransmission()) - { - return 0; - } - delay(1); - #endif +#if defined(RASPBERRY_PI) + arducam_i2c_word_write(regID, regDat); + arducam_delay_ms(1); +#else + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID >> 8); // sends instruction byte, MSB first + Wire.write(regID & 0x00FF); + Wire.write(regDat & 0x00FF); + if (Wire.endTransmission()) + { + return 0; + } + delay(1); +#endif return 1; } -byte ArduCAM::rdSensorReg16_8(uint16_t regID, uint8_t* regDat) -{ - #if defined (RASPBERRY_PI) - arducam_i2c_word_read(regID, regDat ); - #else - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID >> 8); - Wire.write(regID & 0x00FF); - Wire.endTransmission(); - Wire.requestFrom((sensor_addr >> 1), 1); - if (Wire.available()) - { - *regDat = Wire.read(); - } - delay(1); - #endif +byte ArduCAM::rdSensorReg16_8(uint16_t regID, uint8_t *regDat) +{ +#if defined(RASPBERRY_PI) + arducam_i2c_word_read(regID, regDat); +#else + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID >> 8); + Wire.write(regID & 0x00FF); + Wire.endTransmission(); + Wire.requestFrom((sensor_addr >> 1), 1); + if (Wire.available()) + { + *regDat = Wire.read(); + } + delay(1); +#endif return 1; } -//I2C Write 16bit address, 16bit data +// I2C Write 16bit address, 16bit data byte ArduCAM::wrSensorReg16_16(int regID, int regDat) { - #if defined (RASPBERRY_PI) - #else - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID >> 8); // sends instruction byte, MSB first - Wire.write(regID & 0x00FF); - Wire.write(regDat >> 8); // sends data byte, MSB first - Wire.write(regDat & 0x00FF); - if (Wire.endTransmission()) - { - return 0; - } - delay(1); - #endif - return (1); -} - -//I2C Read 16bit address, 16bit data -byte ArduCAM::rdSensorReg16_16(uint16_t regID, uint16_t* regDat) -{ - #if defined (RASPBERRY_PI) - #else - uint16_t temp; - Wire.beginTransmission(sensor_addr >> 1); - Wire.write(regID >> 8); - Wire.write(regID & 0x00FF); - Wire.endTransmission(); - Wire.requestFrom((sensor_addr >> 1), 2); - if (Wire.available()) - { - temp = Wire.read(); - *regDat = (temp << 8) | Wire.read(); - } - delay(1); - #endif - return (1); +#if defined(RASPBERRY_PI) +#else + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID >> 8); // sends instruction byte, MSB first + Wire.write(regID & 0x00FF); + Wire.write(regDat >> 8); // sends data byte, MSB first + Wire.write(regDat & 0x00FF); + if (Wire.endTransmission()) + { + return 0; + } + delay(1); +#endif + return (1); +} + +// I2C Read 16bit address, 16bit data +byte ArduCAM::rdSensorReg16_16(uint16_t regID, uint16_t *regDat) +{ +#if defined(RASPBERRY_PI) +#else + uint16_t temp; + Wire.beginTransmission(sensor_addr >> 1); + Wire.write(regID >> 8); + Wire.write(regID & 0x00FF); + Wire.endTransmission(); + Wire.requestFrom((sensor_addr >> 1), 2); + if (Wire.available()) + { + temp = Wire.read(); + *regDat = (temp << 8) | Wire.read(); + } + delay(1); +#endif + return (1); } #if defined(ESP8266) -inline void ArduCAM::setDataBits(uint16_t bits) { - const uint32_t mask = ~((SPIMMOSI << SPILMOSI) | (SPIMMISO << SPILMISO)); - bits--; - SPI1U1 = ((SPI1U1 & mask) | ((bits << SPILMOSI) | (bits << SPILMISO))); -} - -void ArduCAM::transferBytes_(uint8_t * out, uint8_t * in, uint8_t size) { - while (SPI1CMD & SPIBUSY) {} - // Set in/out Bits to transfer - - setDataBits(size * 8); - - volatile uint32_t * fifoPtr = &SPI1W0; - uint8_t dataSize = ((size + 3) / 4); - - if (out) { - uint32_t * dataPtr = (uint32_t*) out; - while (dataSize--) { - *fifoPtr = *dataPtr; - dataPtr++; - fifoPtr++; - } - } else { - // no out data only read fill with dummy data! - while (dataSize--) { - *fifoPtr = 0xFFFFFFFF; - fifoPtr++; - } - } - - SPI1CMD |= SPIBUSY; - while (SPI1CMD & SPIBUSY) {} - - if (in) { - volatile uint8_t * fifoPtr8 = (volatile uint8_t *) &SPI1W0; - dataSize = size; - while (dataSize--) { +inline void ArduCAM::setDataBits(uint16_t bits) +{ + const uint32_t mask = ~((SPIMMOSI << SPILMOSI) | (SPIMMISO << SPILMISO)); + bits--; + SPI1U1 = ((SPI1U1 & mask) | ((bits << SPILMOSI) | (bits << SPILMISO))); +} + +void ArduCAM::transferBytes_(uint8_t *out, uint8_t *in, uint8_t size) +{ + while (SPI1CMD & SPIBUSY) + { + } + // Set in/out Bits to transfer + + setDataBits(size * 8); + + volatile uint32_t *fifoPtr = &SPI1W0; + uint8_t dataSize = ((size + 3) / 4); + + if (out) + { + uint32_t *dataPtr = (uint32_t *)out; + while (dataSize--) + { + *fifoPtr = *dataPtr; + dataPtr++; + fifoPtr++; + } + } + else + { + // no out data only read fill with dummy data! + while (dataSize--) + { + *fifoPtr = 0xFFFFFFFF; + fifoPtr++; + } + } + + SPI1CMD |= SPIBUSY; + while (SPI1CMD & SPIBUSY) + { + } + + if (in) + { + volatile uint8_t *fifoPtr8 = (volatile uint8_t *)&SPI1W0; + dataSize = size; + while (dataSize--) + { #if defined(OV5642_MINI_5MP) - *in = *fifoPtr8; - *in = (byte)(*in >> 1) | (*in << 7); + *in = *fifoPtr8; + *in = (byte)(*in >> 1) | (*in << 7); #else - *in = *fifoPtr8; -#endif - in++; - fifoPtr8++; - } - } -} - -void ArduCAM::transferBytes(uint8_t * out, uint8_t * in, uint32_t size) { - while (size) { - if (size > 64) { - transferBytes_(out, in, 64); - size -= 64; - if (out) out += 64; - if (in) in += 64; - } else { - transferBytes_(out, in, size); - size = 0; - } - } + *in = *fifoPtr8; +#endif + in++; + fifoPtr8++; + } + } +} + +void ArduCAM::transferBytes(uint8_t *out, uint8_t *in, uint32_t size) +{ + while (size) + { + if (size > 64) + { + transferBytes_(out, in, 64); + size -= 64; + if (out) + out += 64; + if (in) + in += 64; + } + else + { + transferBytes_(out, in, size); + size = 0; + } + } } #endif diff --git a/ArduCAM/ArduCAM.h b/ArduCAM/ArduCAM.h index 0c6059d8..4e213632 100644 --- a/ArduCAM/ArduCAM.h +++ b/ArduCAM/ArduCAM.h @@ -1,7 +1,7 @@ /* ArduCAM.h - Arduino library support for CMOS Image Sensor Copyright (C)2011-2015 ArduCAM.com. All right reserved - + Basic functionality of this library are based on the demo-code provided by ArduCAM.com. You can find the latest version of the library at http://www.ArduCAM.com @@ -16,25 +16,25 @@ - OV5640 - OV7660 - OV7725 - - MT9M112 + - MT9M112 - MT9V111 - - OV5640 - - MT9M001 + - OV5640 + - MT9M001 - MT9T112 - MT9D112 - + We will add support for many other sensors in next release. - + Supported MCU platform - - Theoretically support all Arduino families - - Arduino UNO R3 (Tested) - - Arduino MEGA2560 R3 (Tested) - - Arduino Leonardo R3 (Tested) - - Arduino Nano (Tested) - - Arduino DUE (Tested) - - Arduino Yun (Tested) - - Raspberry Pi (Tested) - - ESP8266-12 (Tested) + - Theoretically support all Arduino families + - Arduino UNO R3 (Tested) + - Arduino MEGA2560 R3 (Tested) + - Arduino Leonardo R3 (Tested) + - Arduino Nano (Tested) + - Arduino DUE (Tested) + - Arduino Yun (Tested) + - Raspberry Pi (Tested) + - ESP8266-12 (Tested) * Feather M0 (Tested with OV5642) If you make any modifications or improvements to the code, I would appreciate @@ -58,37 +58,37 @@ /*------------------------------------ Revision History: - 2012/09/20 V1.0.0 by Lee first release - 2012/10/23 V1.0.1 by Lee Resolved some timing issue for the Read/Write Register + 2012/09/20 V1.0.0 by Lee first release + 2012/10/23 V1.0.1 by Lee Resolved some timing issue for the Read/Write Register 2012/11/29 V1.1.0 by Lee Add support for MT9D111 sensor 2012/12/13 V1.2.0 by Lee Add support for OV7675 sensor 2012/12/28 V1.3.0 by Lee Add support for OV2640,OV3640,OV5642 sensors - 2013/02/26 V2.0.0 by Lee New Rev.B shield hardware, add support for FIFO control - and support Mega1280/2560 boards - 2013/05/28 V2.1.0 by Lee Add support all drawing functions derived from UTFT library + 2013/02/26 V2.0.0 by Lee New Rev.B shield hardware, add support for FIFO control + and support Mega1280/2560 boards + 2013/05/28 V2.1.0 by Lee Add support all drawing functions derived from UTFT library 2013/08/24 V3.0.0 by Lee Support ArudCAM shield Rev.C hardware, features SPI interface and low power mode. - Support almost all series of Arduino boards including DUE. - 2014/03/09 V3.1.0 by Lee Add the more impressive example sketches. + Support almost all series of Arduino boards including DUE. + 2014/03/09 V3.1.0 by Lee Add the more impressive example sketches. Optimise the OV5642 settings, improve image quality. Add live preview before JPEG capture. Add play back photos one by one after BMP capture. - 2014/05/01 V3.1.1 by Lee Minor changes to add support Arduino IDE for linux distributions. - 2014/09/30 V3.2.0 by Lee Improvement on OV5642 camera dirver. - 2014/10/06 V3.3.0 by Lee Add OV7660,OV7725 camera support. - 2015/02/27 V3.4.0 by Lee Add the support for Arduino Yun board, update the latest UTFT library for ArduCAM. - 2015/06/09 V3.4.1 by Lee Minor changes and add some comments - 2015/06/19 V3.4.2 by Lee Add support for MT9M112 camera. - 2015/06/20 V3.4.3 by Lee Add support for MT9V111 camera. - 2015/06/22 V3.4.4 by Lee Add support for OV5640 camera. - 2015/06/22 V3.4.5 by Lee Add support for MT9M001 camera. - 2015/08/05 V3.4.6 by Lee Add support for MT9T112 camera. - 2015/08/08 V3.4.7 by Lee Add support for MT9D112 camera. - 2015/09/20 V3.4.8 by Lee Add support for ESP8266 processor. + 2014/05/01 V3.1.1 by Lee Minor changes to add support Arduino IDE for linux distributions. + 2014/09/30 V3.2.0 by Lee Improvement on OV5642 camera dirver. + 2014/10/06 V3.3.0 by Lee Add OV7660,OV7725 camera support. + 2015/02/27 V3.4.0 by Lee Add the support for Arduino Yun board, update the latest UTFT library for ArduCAM. + 2015/06/09 V3.4.1 by Lee Minor changes and add some comments + 2015/06/19 V3.4.2 by Lee Add support for MT9M112 camera. + 2015/06/20 V3.4.3 by Lee Add support for MT9V111 camera. + 2015/06/22 V3.4.4 by Lee Add support for OV5640 camera. + 2015/06/22 V3.4.5 by Lee Add support for MT9M001 camera. + 2015/08/05 V3.4.6 by Lee Add support for MT9T112 camera. + 2015/08/08 V3.4.7 by Lee Add support for MT9D112 camera. + 2015/09/20 V3.4.8 by Lee Add support for ESP8266 processor. 2016/02/03 V3.4.9 by Lee Add support for Arduino ZERO board. 2016/06/07 V3.5.0 by Lee Add support for OV5642_CAM_BIT_ROTATION_FIXED. - 2016/06/14 V3.5.1 by Lee Add support for ArduCAM-Mini-5MP-Plus OV5640_CAM. - 2016/09/29 V3.5.2 by Lee Optimize the OV5642 register settings - 2016/10/05 V4.0.0 by Lee Add support for second generation of ArduCAM shield V2, ArduCAM-Mini-5MP-Plus(OV5642/OV5640). + 2016/06/14 V3.5.1 by Lee Add support for ArduCAM-Mini-5MP-Plus OV5640_CAM. + 2016/09/29 V3.5.2 by Lee Optimize the OV5642 register settings + 2016/10/05 V4.0.0 by Lee Add support for second generation of ArduCAM shield V2, ArduCAM-Mini-5MP-Plus(OV5642/OV5640). 2016/10/28 V4.0.1 by Lee Add support for Raspberry Pi 2017/04/27 V4.1.0 by Lee Add support for OV2640/OV5640/OV5642 functions. 2017/07/07 V4.1.0 by Lee Add support for ArduCAM_ESP32 paltform @@ -101,22 +101,31 @@ #ifndef ArduCAM_H #define ArduCAM_H #include "memorysaver.h" -#if defined ( RASPBERRY_PI ) +#if defined(RASPBERRY_PI) #else - #include "Arduino.h" - #include - #include "memorysaver.h" +#include "Arduino.h" +#include +#include "memorysaver.h" #endif -#if defined (__AVR__) +#if defined(__AVR__) #define cbi(reg, bitmask) *reg &= ~bitmask #define sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} -#define fontbyte(x) pgm_read_byte(&cfont.font[x]) +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } +#define fontbyte(x) pgm_read_byte(&cfont.font[x]) #define regtype volatile uint8_t #define regsize uint8_t #endif @@ -126,158 +135,230 @@ #define cbi(reg, bitmask) *reg &= ~bitmask #define sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} -#define fontbyte(x) cfont.font[x] +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } +#define fontbyte(x) cfont.font[x] #define regtype volatile uint32_t #define regsize uint32_t #define PROGMEM -#define pgm_read_byte(x) (*((char *)x)) -#define pgm_read_word(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) -#define pgm_read_byte_near(x) (*((char *)x)) -#define pgm_read_byte_far(x) (*((char *)x)) -#define pgm_read_word_near(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) +#define pgm_read_byte(x) (*((char *)x)) +#define pgm_read_word(x) (((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) +#define pgm_read_byte_near(x) (*((char *)x)) +#define pgm_read_byte_far(x) (*((char *)x)) +#define pgm_read_word_near(x) (((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x))) #define pgm_read_word_far(x) ( ((*((unsigned char *)x + 1)) << 8) + (*((unsigned char *)x)))) -#define PSTR(x) x +#define PSTR(x) x #if defined F - #undef F +#undef F +#endif +#define F(X) (X) #endif -#define F(X) (X) -#endif #if defined(ESP8266) - #define cbi(reg, bitmask) digitalWrite(bitmask, LOW) - #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) - #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); - #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - - #define cport(port, data) port &= data - #define sport(port, data) port |= data - - #define swap(type, i, j) {type t = i; i = j; j = t;} - - #define fontbyte(x) cfont.font[x] - - #define regtype volatile uint32_t - #define regsize uint32_t -#endif +#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } + +#define fontbyte(x) cfont.font[x] + +#define regtype volatile uint32_t +#define regsize uint32_t +#endif #if defined(__SAMD51__) || defined(__SAMD21G18A__) - #define Serial SERIAL_PORT_USBVIRTUAL +#define Serial SERIAL_PORT_USBVIRTUAL - #define cbi(reg, bitmask) *reg &= ~bitmask - #define sbi(reg, bitmask) *reg |= bitmask +#define cbi(reg, bitmask) *reg &= ~bitmask +#define sbi(reg, bitmask) *reg |= bitmask - #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); - #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); - #define cport(port, data) port &= data - #define sport(port, data) port |= data +#define cport(port, data) port &= data +#define sport(port, data) port |= data - #define swap(type, i, j) {type t = i; i = j; j = t;} - #define fontbyte(x) cfont.font[x] +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } +#define fontbyte(x) cfont.font[x] - #define regtype volatile uint32_t - #define regsize uint32_t +#define regtype volatile uint32_t +#define regsize uint32_t #endif #if defined(ESP32) - #define cbi(reg, bitmask) digitalWrite(bitmask, LOW) - #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) - #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); - #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - - #define cport(port, data) port &= data - #define sport(port, data) port |= data - - #define swap(type, i, j) {type t = i; i = j; j = t;} - - #define fontbyte(x) cfont.font[x] - - #define regtype volatile uint32_t - #define regsize uint32_t +#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } + +#define fontbyte(x) cfont.font[x] + +#define regtype volatile uint32_t +#define regsize uint32_t #endif #if defined(__CPU_ARC__) - #define cbi(reg, bitmask) *reg &= ~bitmask - #define sbi(reg, bitmask) *reg |= bitmask - #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); - #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - #define cport(port, data) port &= data - #define sport(port, data) port |= data - #define swap(type, i, j) {type t = i; i = j; j = t;} - #define fontbyte(x) pgm_read_byte(&cfont.font[x]) - #define regtype volatile uint32_t - #define regsize uint32_t -#endif - -#if defined (RASPBERRY_PI) - #define regtype volatile uint32_t - #define regsize uint32_t - #define byte uint8_t - #define cbi(reg, bitmask) digitalWrite(bitmask, LOW) - #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) - #define PROGMEM - - #define PSTR(x) x - #if defined F - #undef F - #endif - #define F(X) (X) +#define cbi(reg, bitmask) *reg &= ~bitmask +#define sbi(reg, bitmask) *reg |= bitmask +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); +#define cport(port, data) port &= data +#define sport(port, data) port |= data +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } +#define fontbyte(x) pgm_read_byte(&cfont.font[x]) +#define regtype volatile uint32_t +#define regsize uint32_t +#endif + +#if defined(RASPBERRY_PI) +#define regtype volatile uint32_t +#define regsize uint32_t +#define byte uint8_t +#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) +#define PROGMEM + +#define PSTR(x) x +#if defined F +#undef F +#endif +#define F(X) (X) #endif #if defined(ARDUINO_ARCH_NRF52) - #define cbi(reg, bitmask) digitalWrite(bitmask, LOW) - #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) - #define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); - #define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - - #define cport(port, data) port &= data - #define sport(port, data) port |= data - - #define swap(type, i, j) {type t = i; i = j; j = t;} - - #define fontbyte(x) cfont.font[x] - - #define regtype volatile uint32_t - #define regsize uint32_t +#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); + +#define cport(port, data) port &= data +#define sport(port, data) port |= data + +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } + +#define fontbyte(x) cfont.font[x] + +#define regtype volatile uint32_t +#define regsize uint32_t #endif #if defined(TEENSYDUINO) - #define cbi(reg, bitmask) digitalWriteFast(bitmask, LOW) - #define sbi(reg, bitmask) digitalWriteFast(bitmask, HIGH) -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); - #define cport(port, data) port &= data +#define cbi(reg, bitmask) digitalWriteFast(bitmask, LOW) +#define sbi(reg, bitmask) digitalWriteFast(bitmask, HIGH) +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); +#define cport(port, data) port &= data #define sport(port, data) port |= data - #define swap(type, i, j) {type t = i; i = j; j = t;} - #define fontbyte(x) cfont.font[x] - #define regtype volatile uint8_t +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } +#define fontbyte(x) cfont.font[x] +#define regtype volatile uint8_t #define regsize uint8_t - #endif +#endif #if defined(NRF52840_XXAA) - #define cbi(reg, bitmask) digitalWrite(bitmask, LOW) - #define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) +#define cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define sbi(reg, bitmask) digitalWrite(bitmask, HIGH) -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} -#define fontbyte(x) cfont.font[x] +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } +#define fontbyte(x) cfont.font[x] #define regtype volatile uint32_t #define regsize uint32_t @@ -285,256 +366,242 @@ #define PROGMEM #if defined F - #undef F +#undef F #endif #define F(X) (X) #endif -#if defined (ARDUINO_ARCH_STM32) +#if defined(ARDUINO_ARCH_STM32) #define cbi(reg, bitmask) *reg &= ~bitmask #define sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) sbi(reg, bitmask); cbi(reg, bitmask); -#define pulse_low(reg, bitmask) cbi(reg, bitmask); sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + cbi(reg, bitmask); \ + sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } #define fontbyte(x) cfont.font[x] #define regtype volatile uint32_t #define regsize uint32_t #endif - /****************************************************/ /* Sensor related definition */ /****************************************************/ -#define BMP 0 -#define JPEG 1 -#define RAW 2 - -#define OV7670 0 -#define MT9D111_A 1 -#define OV7675 2 -#define OV5642 3 -#define OV3640 4 -#define OV2640 5 -#define OV9655 6 -#define MT9M112 7 -#define OV7725 8 -#define OV7660 9 -#define MT9M001 10 -#define OV5640 11 -#define MT9D111_B 12 -#define OV9650 13 -#define MT9V111 14 -#define MT9T112 15 -#define MT9D112 16 -#define MT9V034 17 -#define MT9M034 18 - -#define OV2640_160x120 0 //160x120 -#define OV2640_176x144 1 //176x144 -#define OV2640_320x240 2 //320x240 -#define OV2640_352x288 3 //352x288 -#define OV2640_640x480 4 //640x480 -#define OV2640_800x600 5 //800x600 -#define OV2640_1024x768 6 //1024x768 -#define OV2640_1280x1024 7 //1280x1024 -#define OV2640_1600x1200 8 //1600x1200 - - - -#define OV3640_176x144 0 //176x144 -#define OV3640_320x240 1 //320x240 -#define OV3640_352x288 2 //352x288 -#define OV3640_640x480 3 //640x480 -#define OV3640_800x600 4 //800x600 -#define OV3640_1024x768 5 //1024x768 -#define OV3640_1280x960 6 //1280x960 -#define OV3640_1600x1200 7 //1600x1200 -#define OV3640_2048x1536 8 //2048x1536 - - -#define OV5642_320x240 0 //320x240 -#define OV5642_640x480 1 //640x480 -#define OV5642_1024x768 2 //1024x768 -#define OV5642_1280x960 3 //1280x960 -#define OV5642_1600x1200 4 //1600x1200 -#define OV5642_2048x1536 5 //2048x1536 -#define OV5642_2592x1944 6 //2592x1944 -#define OV5642_1920x1080 7 - - -#define OV5640_320x240 0 //320x240 -#define OV5640_352x288 1 //352x288 -#define OV5640_640x480 2 //640x480 -#define OV5640_800x480 3 //800x480 -#define OV5640_1024x768 4 //1024x768 -#define OV5640_1280x960 5 //1280x960 -#define OV5640_1600x1200 6 //1600x1200 -#define OV5640_2048x1536 7 //2048x1536 -#define OV5640_2592x1944 8 //2592x1944 - - - -//Light Mode - -#define Auto 0 -#define Sunny 1 -#define Cloudy 2 -#define Office 3 -#define Home 4 - -#define Advanced_AWB 0 -#define Simple_AWB 1 -#define Manual_day 2 -#define Manual_A 3 -#define Manual_cwf 4 -#define Manual_cloudy 5 - - - -//Color Saturation - -#define Saturation4 0 -#define Saturation3 1 -#define Saturation2 2 -#define Saturation1 3 -#define Saturation0 4 -#define Saturation_1 5 -#define Saturation_2 6 -#define Saturation_3 7 -#define Saturation_4 8 - -//Brightness - -#define Brightness4 0 -#define Brightness3 1 -#define Brightness2 2 -#define Brightness1 3 -#define Brightness0 4 -#define Brightness_1 5 -#define Brightness_2 6 -#define Brightness_3 7 -#define Brightness_4 8 - - -//Contrast - -#define Contrast4 0 -#define Contrast3 1 -#define Contrast2 2 -#define Contrast1 3 -#define Contrast0 4 -#define Contrast_1 5 -#define Contrast_2 6 -#define Contrast_3 7 -#define Contrast_4 8 - - - -#define degree_180 0 -#define degree_150 1 -#define degree_120 2 -#define degree_90 3 -#define degree_60 4 -#define degree_30 5 -#define degree_0 6 -#define degree30 7 -#define degree60 8 -#define degree90 9 -#define degree120 10 -#define degree150 11 - - - -//Special effects - -#define Antique 0 -#define Bluish 1 -#define Greenish 2 -#define Reddish 3 -#define BW 4 -#define Negative 5 -#define BWnegative 6 -#define Normal 7 -#define Sepia 8 -#define Overexposure 9 -#define Solarize 10 -#define Blueish 11 -#define Yellowish 12 - -#define Exposure_17_EV 0 -#define Exposure_13_EV 1 -#define Exposure_10_EV 2 -#define Exposure_07_EV 3 -#define Exposure_03_EV 4 -#define Exposure_default 5 -#define Exposure03_EV 6 -#define Exposure07_EV 7 -#define Exposure10_EV 8 -#define Exposure13_EV 9 -#define Exposure17_EV 10 - -#define Auto_Sharpness_default 0 -#define Auto_Sharpness1 1 -#define Auto_Sharpness2 2 -#define Manual_Sharpnessoff 3 -#define Manual_Sharpness1 4 -#define Manual_Sharpness2 5 -#define Manual_Sharpness3 6 -#define Manual_Sharpness4 7 -#define Manual_Sharpness5 8 - - - -#define Sharpness1 0 -#define Sharpness2 1 -#define Sharpness3 2 -#define Sharpness4 3 -#define Sharpness5 4 -#define Sharpness6 5 -#define Sharpness7 6 -#define Sharpness8 7 -#define Sharpness_auto 8 - - - - -#define EV3 0 -#define EV2 1 -#define EV1 2 -#define EV0 3 -#define EV_1 4 -#define EV_2 5 -#define EV_3 6 - -#define MIRROR 0 -#define FLIP 1 -#define MIRROR_FLIP 2 - - - - -#define high_quality 0 -#define default_quality 1 -#define low_quality 2 - -#define Color_bar 0 -#define Color_square 1 -#define BW_square 2 -#define DLI 3 - - -#define Night_Mode_On 0 -#define Night_Mode_Off 1 - -#define Off 0 -#define Manual_50HZ 1 -#define Manual_60HZ 2 -#define Auto_Detection 3 +#define BMP 0 +#define JPEG 1 +#define RAW 2 + +#define OV7670 0 +#define MT9D111_A 1 +#define OV7675 2 +#define OV5642 3 +#define OV3640 4 +#define OV2640 5 +#define OV9655 6 +#define MT9M112 7 +#define OV7725 8 +#define OV7660 9 +#define MT9M001 10 +#define OV5640 11 +#define MT9D111_B 12 +#define OV9650 13 +#define MT9V111 14 +#define MT9T112 15 +#define MT9D112 16 +#define MT9V034 17 +#define MT9M034 18 + +#define OV2640_160x120 0 // 160x120 +#define OV2640_176x144 1 // 176x144 +#define OV2640_320x240 2 // 320x240 +#define OV2640_352x288 3 // 352x288 +#define OV2640_640x480 4 // 640x480 +#define OV2640_800x600 5 // 800x600 +#define OV2640_1024x768 6 // 1024x768 +#define OV2640_1280x1024 7 // 1280x1024 +#define OV2640_1600x1200 8 // 1600x1200 + +#define OV3640_176x144 0 // 176x144 +#define OV3640_320x240 1 // 320x240 +#define OV3640_352x288 2 // 352x288 +#define OV3640_640x480 3 // 640x480 +#define OV3640_800x600 4 // 800x600 +#define OV3640_1024x768 5 // 1024x768 +#define OV3640_1280x960 6 // 1280x960 +#define OV3640_1600x1200 7 // 1600x1200 +#define OV3640_2048x1536 8 // 2048x1536 + +#define OV5642_320x240 0 // 320x240 +#define OV5642_640x480 1 // 640x480 +#define OV5642_1024x768 2 // 1024x768 +#define OV5642_1280x960 3 // 1280x960 +#define OV5642_1600x1200 4 // 1600x1200 +#define OV5642_2048x1536 5 // 2048x1536 +#define OV5642_2592x1944 6 // 2592x1944 +#define OV5642_1920x1080 7 + +#define OV5640_320x240 0 // 320x240 +#define OV5640_352x288 1 // 352x288 +#define OV5640_640x480 2 // 640x480 +#define OV5640_800x480 3 // 800x480 +#define OV5640_1024x768 4 // 1024x768 +#define OV5640_1280x960 5 // 1280x960 +#define OV5640_1600x1200 6 // 1600x1200 +#define OV5640_2048x1536 7 // 2048x1536 +#define OV5640_2592x1944 8 // 2592x1944 + +// Light Mode + +#define Auto 0 +#define Sunny 1 +#define Cloudy 2 +#define Office 3 +#define Home 4 + +#define Advanced_AWB 0 +#define Simple_AWB 1 +#define Manual_day 2 +#define Manual_A 3 +#define Manual_cwf 4 +#define Manual_cloudy 5 + +// Color Saturation + +#define Saturation4 0 +#define Saturation3 1 +#define Saturation2 2 +#define Saturation1 3 +#define Saturation0 4 +#define Saturation_1 5 +#define Saturation_2 6 +#define Saturation_3 7 +#define Saturation_4 8 + +// Brightness + +#define Brightness4 0 +#define Brightness3 1 +#define Brightness2 2 +#define Brightness1 3 +#define Brightness0 4 +#define Brightness_1 5 +#define Brightness_2 6 +#define Brightness_3 7 +#define Brightness_4 8 + +// Contrast + +#define Contrast4 0 +#define Contrast3 1 +#define Contrast2 2 +#define Contrast1 3 +#define Contrast0 4 +#define Contrast_1 5 +#define Contrast_2 6 +#define Contrast_3 7 +#define Contrast_4 8 + +#define degree_180 0 +#define degree_150 1 +#define degree_120 2 +#define degree_90 3 +#define degree_60 4 +#define degree_30 5 +#define degree_0 6 +#define degree30 7 +#define degree60 8 +#define degree90 9 +#define degree120 10 +#define degree150 11 + +// Special effects + +#define Antique 0 +#define Bluish 1 +#define Greenish 2 +#define Reddish 3 +#define BW 4 +#define Negative 5 +#define BWnegative 6 +#define Normal 7 +#define Sepia 8 +#define Overexposure 9 +#define Solarize 10 +#define Blueish 11 +#define Yellowish 12 + +#define Exposure_17_EV 0 +#define Exposure_13_EV 1 +#define Exposure_10_EV 2 +#define Exposure_07_EV 3 +#define Exposure_03_EV 4 +#define Exposure_default 5 +#define Exposure03_EV 6 +#define Exposure07_EV 7 +#define Exposure10_EV 8 +#define Exposure13_EV 9 +#define Exposure17_EV 10 + +#define Auto_Sharpness_default 0 +#define Auto_Sharpness1 1 +#define Auto_Sharpness2 2 +#define Manual_Sharpnessoff 3 +#define Manual_Sharpness1 4 +#define Manual_Sharpness2 5 +#define Manual_Sharpness3 6 +#define Manual_Sharpness4 7 +#define Manual_Sharpness5 8 + +#define Sharpness1 0 +#define Sharpness2 1 +#define Sharpness3 2 +#define Sharpness4 3 +#define Sharpness5 4 +#define Sharpness6 5 +#define Sharpness7 6 +#define Sharpness8 7 +#define Sharpness_auto 8 + +#define EV3 0 +#define EV2 1 +#define EV1 2 +#define EV0 3 +#define EV_1 4 +#define EV_2 5 +#define EV_3 6 + +#define MIRROR 0 +#define FLIP 1 +#define MIRROR_FLIP 2 + +#define high_quality 0 +#define default_quality 1 +#define low_quality 2 + +#define Color_bar 0 +#define Color_square 1 +#define BW_square 2 +#define DLI 3 + +#define Night_Mode_On 0 +#define Night_Mode_Off 1 + +#define Off 0 +#define Manual_50HZ 1 +#define Manual_60HZ 2 +#define Auto_Detection 3 /****************************************************/ /* I2C Control Definition */ @@ -548,223 +615,212 @@ /* Register initialization tables for SENSORs */ /* Terminating list entry for reg */ -#define SENSOR_REG_TERM_8BIT 0xFF -#define SENSOR_REG_TERM_16BIT 0xFFFF +#define SENSOR_REG_TERM_8BIT 0xFF +#define SENSOR_REG_TERM_16BIT 0xFFFF /* Terminating list entry for val */ -#define SENSOR_VAL_TERM_8BIT 0xFF -#define SENSOR_VAL_TERM_16BIT 0xFFFF +#define SENSOR_VAL_TERM_8BIT 0xFF +#define SENSOR_VAL_TERM_16BIT 0xFFFF -//Define maximum frame buffer size +// Define maximum frame buffer size #if (defined OV2640_MINI_2MP) -#define MAX_FIFO_SIZE 0x5FFFF //384KByte +#define MAX_FIFO_SIZE 0x5FFFF // 384KByte #elif (defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined ARDUCAM_SHIELD_REVC) -#define MAX_FIFO_SIZE 0x7FFFF //512KByte +#define MAX_FIFO_SIZE 0x7FFFF // 512KByte #else -#define MAX_FIFO_SIZE 0x7FFFFF //8MByte -#endif +#define MAX_FIFO_SIZE 0x7FFFFF // 8MByte +#endif /****************************************************/ /* ArduChip registers definition */ /****************************************************/ -#define RWBIT 0x80 //READ AND WRITE BIT IS BIT[7] +#define RWBIT 0x80 // READ AND WRITE BIT IS BIT[7] -#define ARDUCHIP_TEST1 0x00 //TEST register +#define ARDUCHIP_TEST1 0x00 // TEST register #if !(defined OV2640_MINI_2MP) - #define ARDUCHIP_FRAMES 0x01 //FRAME control register, Bit[2:0] = Number of frames to be captured //On 5MP_Plus platforms bit[2:0] = 7 means continuous capture until frame buffer is full +#define ARDUCHIP_FRAMES 0x01 // FRAME control register, Bit[2:0] = Number of frames to be captured //On 5MP_Plus platforms bit[2:0] = 7 means continuous capture until frame buffer is full #endif -#define ARDUCHIP_MODE 0x02 //Mode register -#define MCU2LCD_MODE 0x00 -#define CAM2LCD_MODE 0x01 -#define LCD2MCU_MODE 0x02 +#define ARDUCHIP_MODE 0x02 // Mode register +#define MCU2LCD_MODE 0x00 +#define CAM2LCD_MODE 0x01 +#define LCD2MCU_MODE 0x02 -#define ARDUCHIP_TIM 0x03 //Timming control +#define ARDUCHIP_TIM 0x03 // Timming control #if !(defined OV2640_MINI_2MP) - #define HREF_LEVEL_MASK 0x01 //0 = High active , 1 = Low active - #define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active - #define LCD_BKEN_MASK 0x04 //0 = Enable, 1 = Disable - #if (defined ARDUCAM_SHIELD_V2) - #define PCLK_REVERSE_MASK 0x08 //0 = Normal PCLK, 1 = REVERSED PCLK - #else - #define PCLK_DELAY_MASK 0x08 //0 = data no delay, 1 = data delayed one PCLK - #endif - //#define MODE_MASK 0x10 //0 = LCD mode, 1 = FIFO mode +#define HREF_LEVEL_MASK 0x01 // 0 = High active , 1 = Low active +#define VSYNC_LEVEL_MASK 0x02 // 0 = High active , 1 = Low active +#define LCD_BKEN_MASK 0x04 // 0 = Enable, 1 = Disable +#if (defined ARDUCAM_SHIELD_V2) +#define PCLK_REVERSE_MASK 0x08 // 0 = Normal PCLK, 1 = REVERSED PCLK +#else +#define PCLK_DELAY_MASK 0x08 // 0 = data no delay, 1 = data delayed one PCLK #endif -//#define FIFO_PWRDN_MASK 0x20 //0 = Normal operation, 1 = FIFO power down -//#define LOW_POWER_MODE 0x40 //0 = Normal mode, 1 = Low power mode - -#define ARDUCHIP_FIFO 0x04 //FIFO and I2C control -#define FIFO_CLEAR_MASK 0x01 -#define FIFO_START_MASK 0x02 -#define FIFO_RDPTR_RST_MASK 0x10 -#define FIFO_WRPTR_RST_MASK 0x20 - -#define ARDUCHIP_GPIO 0x06 //GPIO Write Register -#if !(defined (ARDUCAM_SHIELD_V2) || defined (ARDUCAM_SHIELD_REVC)) -#define GPIO_RESET_MASK 0x01 //0 = Sensor reset, 1 = Sensor normal operation -#define GPIO_PWDN_MASK 0x02 //0 = Sensor normal operation, 1 = Sensor standby -#define GPIO_PWREN_MASK 0x04 //0 = Sensor LDO disable, 1 = sensor LDO enable +// #define MODE_MASK 0x10 //0 = LCD mode, 1 = FIFO mode +#endif +// #define FIFO_PWRDN_MASK 0x20 //0 = Normal operation, 1 = FIFO power down +// #define LOW_POWER_MODE 0x40 //0 = Normal mode, 1 = Low power mode + +#define ARDUCHIP_FIFO 0x04 // FIFO and I2C control +#define FIFO_CLEAR_MASK 0x01 +#define FIFO_START_MASK 0x02 +#define FIFO_RDPTR_RST_MASK 0x10 +#define FIFO_WRPTR_RST_MASK 0x20 + +#define ARDUCHIP_GPIO 0x06 // GPIO Write Register +#if !(defined(ARDUCAM_SHIELD_V2) || defined(ARDUCAM_SHIELD_REVC)) +#define GPIO_RESET_MASK 0x01 // 0 = Sensor reset, 1 = Sensor normal operation +#define GPIO_PWDN_MASK 0x02 // 0 = Sensor normal operation, 1 = Sensor standby +#define GPIO_PWREN_MASK 0x04 // 0 = Sensor LDO disable, 1 = sensor LDO enable #endif -#define BURST_FIFO_READ 0x3C //Burst FIFO read operation -#define SINGLE_FIFO_READ 0x3D //Single FIFO read operation - -#define ARDUCHIP_REV 0x40 //ArduCHIP revision -#define VER_LOW_MASK 0x3F -#define VER_HIGH_MASK 0xC0 +#define BURST_FIFO_READ 0x3C // Burst FIFO read operation +#define SINGLE_FIFO_READ 0x3D // Single FIFO read operation -#define ARDUCHIP_TRIG 0x41 //Trigger source -#define VSYNC_MASK 0x01 -#define SHUTTER_MASK 0x02 -#define CAP_DONE_MASK 0x08 +#define ARDUCHIP_REV 0x40 // ArduCHIP revision +#define VER_LOW_MASK 0x3F +#define VER_HIGH_MASK 0xC0 -#define FIFO_SIZE1 0x42 //Camera write FIFO size[7:0] for burst to read -#define FIFO_SIZE2 0x43 //Camera write FIFO size[15:8] -#define FIFO_SIZE3 0x44 //Camera write FIFO size[18:16] +#define ARDUCHIP_TRIG 0x41 // Trigger source +#define VSYNC_MASK 0x01 +#define SHUTTER_MASK 0x02 +#define CAP_DONE_MASK 0x08 +#define FIFO_SIZE1 0x42 // Camera write FIFO size[7:0] for burst to read +#define FIFO_SIZE2 0x43 // Camera write FIFO size[15:8] +#define FIFO_SIZE3 0x44 // Camera write FIFO size[18:16] /****************************************************/ - /****************************************************************/ /* define a structure for sensor register initialization values */ /****************************************************************/ -struct sensor_reg { +struct sensor_reg +{ uint16_t reg; uint16_t val; }; - - /****************************************************************/ /* define a structure for sensor register initialization values */ /****************************************************************/ -class ArduCAM +class ArduCAM { - public: - ArduCAM( void ); - ArduCAM(byte model ,int CS); - void InitCAM( void ); - +public: + ArduCAM(void); + ArduCAM(byte model, int CS); + void InitCAM(void); + void CS_HIGH(void); void CS_LOW(void); - + void flush_fifo(void); void start_capture(void); void clear_fifo_flag(void); uint8_t read_fifo(void); - + uint8_t read_reg(uint8_t addr); - void write_reg(uint8_t addr, uint8_t data); - + void write_reg(uint8_t addr, uint8_t data); + uint32_t read_fifo_length(void); void set_fifo_burst(void); - + void set_bit(uint8_t addr, uint8_t bit); void clear_bit(uint8_t addr, uint8_t bit); uint8_t get_bit(uint8_t addr, uint8_t bit); void set_mode(uint8_t mode); - - uint8_t bus_write(int address, int value); - uint8_t bus_read(int address); - + + uint8_t bus_write(int address, int value); + uint8_t bus_read(int address); + // Write 8 bit values to 8 bit register address - int wrSensorRegs8_8(const struct sensor_reg*); - + int wrSensorRegs8_8(const struct sensor_reg *); + // Write 16 bit values to 8 bit register address - int wrSensorRegs8_16(const struct sensor_reg*); - + int wrSensorRegs8_16(const struct sensor_reg *); + // Write 8 bit values to 16 bit register address - int wrSensorRegs16_8(const struct sensor_reg*); - - // Write 16 bit values to 16 bit register address - int wrSensorRegs16_16(const struct sensor_reg*); - - // Read/write 8 bit value to/from 8 bit register address + int wrSensorRegs16_8(const struct sensor_reg *); + + // Write 16 bit values to 16 bit register address + int wrSensorRegs16_16(const struct sensor_reg *); + + // Read/write 8 bit value to/from 8 bit register address byte wrSensorReg8_8(int regID, int regDat); - byte rdSensorReg8_8(uint8_t regID, uint8_t* regDat); - + byte rdSensorReg8_8(uint8_t regID, uint8_t *regDat); + // Read/write 16 bit value to/from 8 bit register address byte wrSensorReg8_16(int regID, int regDat); - byte rdSensorReg8_16(uint8_t regID, uint16_t* regDat); - + byte rdSensorReg8_16(uint8_t regID, uint16_t *regDat); + // Read/write 8 bit value to/from 16 bit register address byte wrSensorReg16_8(int regID, int regDat); - byte rdSensorReg16_8(uint16_t regID, uint8_t* regDat); - + byte rdSensorReg16_8(uint16_t regID, uint8_t *regDat); + // Read/write 16 bit value to/from 16 bit register address byte wrSensorReg16_16(int regID, int regDat); - byte rdSensorReg16_16(uint16_t regID, uint16_t* regDat); + byte rdSensorReg16_16(uint16_t regID, uint16_t *regDat); void OV2640_set_JPEG_size(uint8_t size); void OV3640_set_JPEG_size(uint8_t size); void OV5642_set_JPEG_size(uint8_t size); void OV5640_set_JPEG_size(uint8_t size); - - void OV5642_set_RAW_size (uint8_t size); - - + + void OV5642_set_RAW_size(uint8_t size); + void OV2640_set_Light_Mode(uint8_t Light_Mode); - void OV3640_set_Light_Mode(uint8_t Light_Mode); + void OV3640_set_Light_Mode(uint8_t Light_Mode); void OV5642_set_Light_Mode(uint8_t Light_Mode); void OV5640_set_Light_Mode(uint8_t Light_Mode); - + void OV2640_set_Color_Saturation(uint8_t Color_Saturation); void OV3640_set_Color_Saturation(uint8_t Color_Saturation); void OV5642_set_Color_Saturation(uint8_t Color_Saturation); void OV5640_set_Color_Saturation(uint8_t Color_Saturation); - - + void OV2640_set_Brightness(uint8_t Brightness); void OV3640_set_Brightness(uint8_t Brightness); - void OV5642_set_Brightness(uint8_t Brightness); - void OV5640_set_Brightness(uint8_t Brightness); - + void OV5642_set_Brightness(uint8_t Brightness); + void OV5640_set_Brightness(uint8_t Brightness); + void OV2640_set_Contrast(uint8_t Contrast); void OV3640_set_Contrast(uint8_t Contrast); void OV5642_set_Contrast(uint8_t Contrast); void OV5640_set_Contrast(uint8_t Contrast); - + void OV2640_set_Special_effects(uint8_t Special_effect); void OV3640_set_Special_effects(uint8_t Special_effect); void OV5642_set_Special_effects(uint8_t Special_effect); void OV5640_set_Special_effects(uint8_t Special_effect); - - + void OV3640_set_Exposure_level(uint8_t level); void OV3640_set_Sharpness(uint8_t Sharpness); void OV3640_set_Mirror_Flip(uint8_t Mirror_Flip); - - + void OV5642_set_hue(uint8_t degree); void OV5642_set_Exposure_level(uint8_t level); void OV5642_set_Sharpness(uint8_t Sharpness); - void OV5642_set_Mirror_Flip(uint8_t Mirror_Flip); - void OV5642_set_Compress_quality(uint8_t quality); - void OV5642_Test_Pattern(uint8_t Pattern); - - - void OV5640_set_EV(uint8_t EV); - void OV5640_set_Night_Mode(uint8_t Night_mode); - void OV5640_set_Banding_Filter(uint8_t Banding_Filter); - - - - + void OV5642_set_Mirror_Flip(uint8_t Mirror_Flip); + void OV5642_set_Compress_quality(uint8_t quality); + void OV5642_Test_Pattern(uint8_t Pattern); + + void OV5640_set_EV(uint8_t EV); + void OV5640_set_Night_Mode(uint8_t Night_mode); + void OV5640_set_Banding_Filter(uint8_t Banding_Filter); + void set_format(byte fmt); - - #if defined (RASPBERRY_PI) - uint8_t transfer(uint8_t data); + +#if defined(RASPBERRY_PI) + uint8_t transfer(uint8_t data); void transfers(uint8_t *buf, uint32_t size); - #endif +#endif - void transferBytes_(uint8_t * out, uint8_t * in, uint8_t size); - void transferBytes(uint8_t * out, uint8_t * in, uint32_t size); + void transferBytes_(uint8_t *out, uint8_t *in, uint8_t size); + void transferBytes(uint8_t *out, uint8_t *in, uint32_t size); inline void setDataBits(uint16_t bits); - - protected: + +protected: regtype *P_CS; regsize B_CS; byte m_fmt; @@ -772,66 +828,64 @@ class ArduCAM byte sensor_addr; }; -#if defined OV7660_CAM - #include "ov7660_regs.h" +#if defined OV7660_CAM +#include "ov7660_regs.h" #endif -#if defined OV7725_CAM - #include "ov7725_regs.h" +#if defined OV7725_CAM +#include "ov7725_regs.h" #endif -#if defined OV7670_CAM - #include "ov7670_regs.h" +#if defined OV7670_CAM +#include "ov7670_regs.h" #endif #if defined OV7675_CAM - #include "ov7675_regs.h" +#include "ov7675_regs.h" #endif -#if ( defined(OV5642_CAM) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) ) - #include "ov5642_regs.h" +#if (defined(OV5642_CAM) || defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS)) +#include "ov5642_regs.h" #endif -#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) - #include "ov3640_regs.h" +#if (defined(OV3640_CAM) || defined(OV3640_MINI_3MP)) +#include "ov3640_regs.h" #endif #if (defined(OV2640_CAM) || defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS)) - #include "ov2640_regs.h" +#include "ov2640_regs.h" #endif -#if defined MT9D111A_CAM || defined MT9D111B_CAM - #include "mt9d111_regs.h" +#if defined MT9D111A_CAM || defined MT9D111B_CAM +#include "mt9d111_regs.h" #endif -#if defined MT9M112_CAM - #include "mt9m112_regs.h" +#if defined MT9M112_CAM +#include "mt9m112_regs.h" #endif -#if defined MT9V111_CAM - #include "mt9v111_regs.h" +#if defined MT9V111_CAM +#include "mt9v111_regs.h" #endif -#if ( defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS) ) - #include "ov5640_regs.h" +#if (defined(OV5640_CAM) || defined(OV5640_MINI_5MP_PLUS)) +#include "ov5640_regs.h" #endif -#if defined MT9M001_CAM - #include "mt9m001_regs.h" +#if defined MT9M001_CAM +#include "mt9m001_regs.h" #endif -#if defined MT9T112_CAM - #include "mt9t112_regs.h" +#if defined MT9T112_CAM +#include "mt9t112_regs.h" #endif -#if defined MT9D112_CAM - #include "mt9d112_regs.h" +#if defined MT9D112_CAM +#include "mt9d112_regs.h" #endif -#if defined MT9M034_CAM - #include "mt9m034_regs.h" +#if defined MT9M034_CAM +#include "mt9m034_regs.h" #endif - - #endif diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_2CAM_VideoStreaming/ArduCAM_ESP8266_2CAM_VideoStreaming.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_2CAM_VideoStreaming/ArduCAM_ESP8266_2CAM_VideoStreaming.ino index 232571cf..9c9aacc6 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_2CAM_VideoStreaming/ArduCAM_ESP8266_2CAM_VideoStreaming.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_2CAM_VideoStreaming/ArduCAM_ESP8266_2CAM_VideoStreaming.ino @@ -9,7 +9,7 @@ // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. -// 4. If receive 0x15,cameras will capture and buffer the image to FIFO. +// 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above @@ -18,12 +18,12 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. #if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif @@ -31,14 +31,14 @@ const int CS1 = 16; const int CS2 = 0; -//the falgs of camera modules -bool cam1=true,cam2=true,cam3=true,cam4=true; -//the flag of JEPG data header +// the falgs of camera modules +bool cam1 = true, cam2 = true, cam3 = true, cam4 = true; +// the flag of JEPG data header bool is_header; -//the falg data of 4 cameras' data -byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; +// the falg data of 4 cameras' data +byte flag[5] = {0xFF, 0xAA, 0x01, 0xFF, 0x55}; int count = 0; -#if defined (OV2640_MINI_2MP) +#if defined(OV2640_MINI_2MP) ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2); #else @@ -46,252 +46,294 @@ ArduCAM myCAM1(OV5642, CS1); ArduCAM myCAM2(OV5642, CS2); #endif -void setup() { -// put your setup code here, to run once: -uint8_t vid,pid; -uint8_t temp; -Wire.begin(); -Serial.begin(921600); -Serial.println("ArduCAM Start!"); -// set the CS output: -pinMode(CS1, OUTPUT); -pinMode(CS2, OUTPUT); +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(921600); + Serial.println("ArduCAM Start!"); + // set the CS output: + pinMode(CS1, OUTPUT); + pinMode(CS2, OUTPUT); -// initialize SPI: -SPI.begin(); -while(1){ - //Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // initialize SPI: + SPI.begin(); + while (1) { - Serial.println(F("ACK CMD SPI1 interface Error!")); - cam1 = false; - } - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // Check if the 2 ArduCAM Mini 2MP Cameras' SPI bus is OK + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI1 interface Error!")); + cam1 = false; + } + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI2 interface Error!")); + cam2 = false; + } + if (!(cam1 || cam2)) + { + delay(1000); + continue; + } + else + break; + } +#if defined(OV2640_MINI_2MP) + while (1) { - Serial.println(F("ACK CMD SPI2 interface Error!")); - cam2 = false; + // Check if the camera module type is OV2640 + myCAM1.wrSensorReg8_8(0xff, 0x01); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + Serial.println(F("ACK CMD Can't find OV2640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected.")); + break; + } } - if(!(cam1||cam2)){ - delay(1000);continue; - }else - break; -} -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 - myCAM1.wrSensorReg8_8(0xff, 0x01); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - Serial.println(F("ACK CMD Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV2640 detected."));break; - } -} #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("ACK CMD Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5642 detected."));break; - } - } -#endif -myCAM1.set_format(JPEG); -myCAM1.InitCAM(); -#if defined (OV2640_MINI_2MP) -myCAM1.OV2640_set_JPEG_size(OV2640_320x240); -#else -myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM1.OV5642_set_JPEG_size(OV5642_320x240); -#endif -delay(1000); -myCAM1.clear_fifo_flag(); -myCAM2.clear_fifo_flag(); -} - -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -uint8_t start_capture = 0; -uint8_t finish_count; -if (Serial.available()){ -temp = Serial.read(); -switch(temp) -{ - case 0: - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_160x120")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_320x240")); - #endif - temp = 0xff; - break; - case 1: - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_176x144")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_640x480")); - #endif - temp = 0xff; - break; - case 2: - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_320x240")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1024x768")); - #endif - temp = 0xff; - break; - case 3: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_352x288")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1280x960")); - #endif - break; - case 4: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_640x480")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1600x1200")); - #endif - break; - case 5: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_800x600")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_2048x1536")); - #endif - break; - case 6: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1024x768")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_2592x1944")); - #endif - break; - #if defined (OV2640_MINI_2MP) - case 7: - temp = 0xff; - myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024")); - break; - case 8: - temp = 0xff; - myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200")); - break; - #endif - case 0x10: - if(cam1){ - flag[2]=0x01;//flag of cam1 - for(int m=0;m<5;m++) + if ((vid != 0x56) || (pid != 0x42)) { - Serial.write(flag[m]); + Serial.println(F("ACK CMD Can't find OV5642 module!")); + delay(1000); + continue; } - read_fifo_burst(myCAM1); - } - if(cam2){ - flag[2]=0x02;//flag of cam1 - for(int m=0;m<5;m++) + else { - Serial.write(flag[m]); + Serial.println(F("ACK CMD OV5642 detected.")); + break; } - read_fifo_burst(myCAM2); } - break; - case 0x20: - while(1){ - if (Serial.available()){ - temp = Serial.read(); - if (temp == 0x21)break; +#endif + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_320x240); +#else + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); +#endif + delay(1000); + myCAM1.clear_fifo_flag(); + myCAM2.clear_fifo_flag(); } - if(cam1){ - flag[2]=0x01;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM1); - } - if(cam2){ - flag[2]=0x02;//flag of cam1 - for(int m=0;m<5;m++) + +void loop() +{ + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + uint8_t start_capture = 0; + uint8_t finish_count; + if (Serial.available()) + { + temp = Serial.read(); + switch (temp) { - Serial.write(flag[m]); + case 0: +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_160x120")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_320x240")); +#endif + temp = 0xff; + break; + case 1: +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_176x144")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_640x480")); +#endif + temp = 0xff; + break; + case 2: +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_320x240")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1024x768")); +#endif + temp = 0xff; + break; + case 3: + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_352x288")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1280x960")); +#endif + break; + case 4: + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_640x480")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1600x1200")); +#endif + break; + case 5: + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_800x600")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_2048x1536")); +#endif + break; + case 6: + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1024x768")); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_2592x1944")); +#endif + break; +#if defined(OV2640_MINI_2MP) + case 7: + temp = 0xff; + myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024")); + break; + case 8: + temp = 0xff; + myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200")); + break; +#endif + case 0x10: + if (cam1) + { + flag[2] = 0x01; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM1); + } + if (cam2) + { + flag[2] = 0x02; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM2); + } + break; + case 0x20: + while (1) + { + if (Serial.available()) + { + temp = Serial.read(); + if (temp == 0x21) + break; + } + if (cam1) + { + flag[2] = 0x01; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM1); + } + if (cam2) + { + flag[2] = 0x02; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM2); + } + } + break; } - read_fifo_burst(myCAM2); - } } - break; - - } -} } uint8_t read_fifo_burst(ArduCAM myCAM) { -uint8_t temp,temp_last; -uint32_t length; + uint8_t temp, temp_last; + uint32_t length; -myCAM.flush_fifo(); -myCAM.clear_fifo_flag(); -myCAM.start_capture(); -while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -length = myCAM.read_fifo_length(); -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -length--; -while( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00);//read a byte from spi - if(is_header == true) + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + length--; + while (length--) { - Serial.write(temp); - } - else if((temp == 0xD8) & (temp_last == 0xFF)) - { - Serial.println(F("ACK IMG")); - is_header = true; - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); // read a byte from spi + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + Serial.println(F("ACK IMG")); + is_header = true; + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) + break; + delayMicroseconds(15); } - if( (temp == 0xD9) && (temp_last == 0xFF) ) - break; - delayMicroseconds(15); -} -myCAM.CS_HIGH(); -is_header = false; -//Clear the capture done flag -myCAM.clear_fifo_flag(); + myCAM.CS_HIGH(); + is_header = false; + // Clear the capture done flag + myCAM.clear_fifo_flag(); } diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV2640_Capture/ArduCAM_ESP8266_OV2640_Capture.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV2640_Capture/ArduCAM_ESP8266_OV2640_Capture.ino index 106570c0..46e3fcf4 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV2640_Capture/ArduCAM_ESP8266_OV2640_Capture.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV2640_Capture/ArduCAM_ESP8266_OV2640_Capture.ino @@ -8,8 +8,8 @@ // The demo sketch will do the following tasks: // 1. Set the camera to JEPG output mode. // 2. if server.on("/capture", HTTP_GET, serverCapture),it can take photo and send to the Web. -// 3.if server.on("/stream", HTTP_GET, serverStream),it can take photo continuously as video -//streaming and send to the Web. +// 3.if server.on("/stream", HTTP_GET, serverStream),it can take photo continuously as video +// streaming and send to the Web. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 2MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -22,92 +22,101 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV2640_MINI_2MP)||(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))) +// This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV2640_MINI_2MP) || (defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : const int CS = 16; -//you can change the value of wifiType to select Station or AP mode. -//Default is AP mode. +// you can change the value of wifiType to select Station or AP mode. +// Default is AP mode. int wifiType = 1; // 0:Station 1:AP -//AP mode configuration -//Default is arducam_esp8266.If you want,you can change the AP_aaid to your favorite name -const char *AP_ssid = "arducam_esp8266"; -//Default is no password.If you want to set password,put your password here +// AP mode configuration +// Default is arducam_esp8266.If you want,you can change the AP_aaid to your favorite name +const char *AP_ssid = "arducam_esp8266"; +// Default is no password.If you want to set password,put your password here const char *AP_password = ""; -//Station mode you should put your ssid and password -const char *ssid = "SSID"; // Put your SSID here +// Station mode you should put your ssid and password +const char *ssid = "SSID"; // Put your SSID here const char *password = "PASSWORD"; // Put your PASSWORD here ESP8266WebServer server(80); ArduCAM myCAM(OV2640, CS); - -void start_capture(){ +void start_capture() +{ myCAM.clear_fifo_flag(); myCAM.start_capture(); } -void camCapture(ArduCAM myCAM){ +void camCapture(ArduCAM myCAM) +{ WiFiClient client = server.client(); - + size_t len = myCAM.read_fifo_length(); - if (len >= 0x07ffff){ + if (len >= 0x07ffff) + { Serial.println("Over size."); return; - }else if (len == 0 ){ + } + else if (len == 0) + { Serial.println("Size is 0."); return; } - + myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM)) +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM)) SPI.transfer(0xFF); - #endif - if (!client.connected()) return; +#endif + if (!client.connected()) + return; String response = "HTTP/1.1 200 OK\r\n"; response += "Content-Type: image/jpeg\r\n"; response += "Content-Length: " + String(len) + "\r\n\r\n"; server.sendContent(response); - + static const size_t bufferSize = 4096; static uint8_t buffer[bufferSize] = {0xFF}; - - while (len) { - size_t will_copy = (len < bufferSize) ? len : bufferSize; - SPI.transferBytes(&buffer[0], &buffer[0], will_copy); - if (!client.connected()) break; - client.write(&buffer[0], will_copy); - len -= will_copy; + + while (len) + { + size_t will_copy = (len < bufferSize) ? len : bufferSize; + SPI.transferBytes(&buffer[0], &buffer[0], will_copy); + if (!client.connected()) + break; + client.write(&buffer[0], will_copy); + len -= will_copy; } - + myCAM.CS_HIGH(); } -void serverCapture(){ +void serverCapture() +{ start_capture(); Serial.println("CAM Capturing"); int total_time = 0; total_time = millis(); - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; total_time = millis() - total_time; Serial.print("capture total_time used (in miliseconds):"); Serial.println(total_time, DEC); - + total_time = 0; - + Serial.println("CAM Capture Done!"); total_time = millis(); camCapture(myCAM); @@ -117,72 +126,86 @@ void serverCapture(){ Serial.println("CAM send Done!"); } -void serverStream(){ +void serverStream() +{ WiFiClient client = server.client(); - + String response = "HTTP/1.1 200 OK\r\n"; response += "Content-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n"; server.sendContent(response); - - while (1){ + + while (1) + { start_capture(); - - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); - + + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + size_t len = myCAM.read_fifo_length(); - if (len >= 0x07ffff){ + if (len >= 0x07ffff) + { Serial.println("Over size."); continue; - }else if (len == 0 ){ + } + else if (len == 0) + { Serial.println("Size is 0."); continue; } - + myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM)) - SPI.transfer(0xFF); - #endif - if (!client.connected()) break; - response = "--frame\r\n"; - response += "Content-Type: image/jpeg\r\n\r\n"; - server.sendContent(response); - +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM)) + SPI.transfer(0xFF); +#endif + if (!client.connected()) + break; + response = "--frame\r\n"; + response += "Content-Type: image/jpeg\r\n\r\n"; + server.sendContent(response); + static const size_t bufferSize = 4096; static uint8_t buffer[bufferSize] = {0xFF}; - - while (len) { + + while (len) + { size_t will_copy = (len < bufferSize) ? len : bufferSize; SPI.transferBytes(&buffer[0], &buffer[0], will_copy); - if (!client.connected()) break; + if (!client.connected()) + break; client.write(&buffer[0], will_copy); len -= will_copy; } myCAM.CS_HIGH(); - - if (!client.connected()) break; + + if (!client.connected()) + break; } } -void handleNotFound(){ +void handleNotFound() +{ String message = "Server is running!\n\n"; message += "URI: "; message += server.uri(); message += "\nMethod: "; - message += (server.method() == HTTP_GET)?"GET":"POST"; + message += (server.method() == HTTP_GET) ? "GET" : "POST"; message += "\nArguments: "; message += server.args(); message += "\n"; server.send(200, "text/plain", message); - - if (server.hasArg("ql")){ + + if (server.hasArg("ql")) + { int ql = server.arg("ql").toInt(); - myCAM.OV2640_set_JPEG_size(ql);delay(1000); + myCAM.OV2640_set_JPEG_size(ql); + delay(1000); Serial.println("QL change to: " + server.arg("ql")); } } -void setup() { +void setup() +{ uint8_t vid, pid; uint8_t temp; #if defined(__SAM3X8E__) @@ -198,70 +221,79 @@ void setup() { // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - while(1); + while (1) + ; } - //Check if the camera module type is OV2640 + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) Serial.println("Can't find OV2640 module!"); - else + else Serial.println("OV2640 detected."); - - //Change to JPEG capture mode and initialize the OV2640 module + // Change to JPEG capture mode and initialize the OV2640 module myCAM.set_format(JPEG); myCAM.InitCAM(); myCAM.OV2640_set_JPEG_size(OV2640_320x240); myCAM.clear_fifo_flag(); - if (wifiType == 0){ - if(!strcmp(ssid,"SSID")){ - Serial.println("Please set your SSID"); - while(1); + if (wifiType == 0) + { + if (!strcmp(ssid, "SSID")) + { + Serial.println("Please set your SSID"); + while (1) + ; } - if(!strcmp(password,"PASSWORD")){ - Serial.println("Please set your PASSWORD"); - while(1); + if (!strcmp(password, "PASSWORD")) + { + Serial.println("Please set your PASSWORD"); + while (1) + ; } // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); - + WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); - while (WiFi.status() != WL_CONNECTED) { + while (WiFi.status() != WL_CONNECTED) + { delay(500); Serial.print("."); } Serial.println("WiFi connected"); Serial.println(""); Serial.println(WiFi.localIP()); - }else if (wifiType == 1){ + } + else if (wifiType == 1) + { Serial.println(); Serial.println(); Serial.print("Share AP: "); Serial.println(AP_ssid); Serial.print("The password is: "); Serial.println(AP_password); - + WiFi.mode(WIFI_AP); WiFi.softAP(AP_ssid, AP_password); Serial.println(""); Serial.println(WiFi.softAPIP()); } - + // Start the server server.on("/capture", HTTP_GET, serverCapture); server.on("/stream", HTTP_GET, serverStream); @@ -270,7 +302,7 @@ void setup() { Serial.println("Server started"); } -void loop() { +void loop() +{ server.handleClient(); } - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5640_Capture/ArduCAM_ESP8266_OV5640_Capture.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5640_Capture/ArduCAM_ESP8266_OV5640_Capture.ino index 698a76c5..1a6e085b 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5640_Capture/ArduCAM_ESP8266_OV5640_Capture.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5640_Capture/ArduCAM_ESP8266_OV5640_Capture.ino @@ -8,8 +8,8 @@ // The demo sketch will do the following tasks: // 1. Set the camera to JEPG output mode. // 2. if server.on("/capture", HTTP_GET, serverCapture),it can take photo and send to the Web. -// 3.if server.on("/stream", HTTP_GET, serverStream),it can take photo continuously as video -//streaming and send to the Web. +// 3.if server.on("/stream", HTTP_GET, serverStream),it can take photo continuously as video +// streaming and send to the Web. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -21,84 +21,94 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM))) +// This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : const int CS = 16; -//you can change the value of wifiType to select Station or AP mode. -//Default is AP mode. +// you can change the value of wifiType to select Station or AP mode. +// Default is AP mode. int wifiType = 1; // 0:Station 1:AP -//AP mode configuration -//Default is arducam_esp8266.If you want,you can change the AP_aaid to your favorite name -const char *AP_ssid = "arducam_esp8266"; -//Default is no password.If you want to set password,put your password here +// AP mode configuration +// Default is arducam_esp8266.If you want,you can change the AP_aaid to your favorite name +const char *AP_ssid = "arducam_esp8266"; +// Default is no password.If you want to set password,put your password here const char *AP_password = ""; -//Station mode you should put your ssid and password -const char* ssid = "SSID"; // Put your SSID here -const char* password = "PASSWORD"; // Put your PASSWORD here +// Station mode you should put your ssid and password +const char *ssid = "SSID"; // Put your SSID here +const char *password = "PASSWORD"; // Put your PASSWORD here ESP8266WebServer server(80); ArduCAM myCAM(OV5640, CS); -void start_capture(){ +void start_capture() +{ myCAM.clear_fifo_flag(); myCAM.start_capture(); } -void camCapture(ArduCAM myCAM){ +void camCapture(ArduCAM myCAM) +{ WiFiClient client = server.client(); - + size_t len = myCAM.read_fifo_length(); - if (len >= MAX_FIFO_SIZE){ + if (len >= MAX_FIFO_SIZE) + { Serial.println("Over size."); return; - }else if (len == 0 ){ + } + else if (len == 0) + { Serial.println("Size is 0."); return; } - + myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM)) +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM)) SPI.transfer(0xFF); - #endif - if (!client.connected()) return; +#endif + if (!client.connected()) + return; String response = "HTTP/1.1 200 OK\r\n"; response += "Content-Type: image/jpeg\r\n"; response += "Content-Length: " + String(len) + "\r\n\r\n"; server.sendContent(response); - + static const size_t bufferSize = 4096; static uint8_t buffer[bufferSize] = {0xFF}; - - while (len) { - size_t will_copy = (len < bufferSize) ? len : bufferSize; - SPI.transferBytes(&buffer[0], &buffer[0], will_copy); - if (!client.connected()) break; - client.write(&buffer[0], will_copy); - len -= will_copy; + + while (len) + { + size_t will_copy = (len < bufferSize) ? len : bufferSize; + SPI.transferBytes(&buffer[0], &buffer[0], will_copy); + if (!client.connected()) + break; + client.write(&buffer[0], will_copy); + len -= will_copy; } - + myCAM.CS_HIGH(); } -void serverCapture(){ +void serverCapture() +{ start_capture(); Serial.println("CAM Capturing"); int total_time = 0; total_time = millis(); - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; total_time = millis() - total_time; Serial.print("capture total_time used (in miliseconds):"); Serial.println(total_time, DEC); @@ -112,62 +122,74 @@ void serverCapture(){ Serial.println("CAM send Done!"); } -void serverStream(){ +void serverStream() +{ WiFiClient client = server.client(); - + String response = "HTTP/1.1 200 OK\r\n"; response += "Content-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n"; server.sendContent(response); - - while (1){ - start_capture(); - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + + while (1) + { + start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; size_t len = myCAM.read_fifo_length(); - if (len >= MAX_FIFO_SIZE){ + if (len >= MAX_FIFO_SIZE) + { Serial.println("Over size."); continue; - }else if (len == 0 ){ + } + else if (len == 0) + { Serial.println("Size is 0."); continue; } - + myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM)) + myCAM.set_fifo_burst(); +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM)) SPI.transfer(0xFF); - #endif - if (!client.connected()) break; +#endif + if (!client.connected()) + break; response = "--frame\r\n"; response += "Content-Type: image/jpeg\r\n\r\n"; server.sendContent(response); - + static const size_t bufferSize = 4096; static uint8_t buffer[bufferSize] = {0xFF}; - - while (len) { + + while (len) + { size_t will_copy = (len < bufferSize) ? len : bufferSize; SPI.transferBytes(&buffer[0], &buffer[0], will_copy); - if (!client.connected()) break; + if (!client.connected()) + break; client.write(&buffer[0], will_copy); len -= will_copy; } myCAM.CS_HIGH(); - if (!client.connected()) break; + if (!client.connected()) + break; } } -void handleNotFound(){ +void handleNotFound() +{ String message = "Server is running!\n\n"; message += "URI: "; message += server.uri(); message += "\nMethod: "; - message += (server.method() == HTTP_GET)?"GET":"POST"; + message += (server.method() == HTTP_GET) ? "GET" : "POST"; message += "\nArguments: "; message += server.args(); message += "\n"; server.send(200, "text/plain", message); - - if (server.hasArg("ql")){ + + if (server.hasArg("ql")) + { int ql = server.arg("ql").toInt(); myCAM.OV5640_set_JPEG_size(ql); delay(1000); @@ -175,7 +197,8 @@ void handleNotFound(){ } } -void setup() { +void setup() +{ uint8_t vid, pid; uint8_t temp; #if defined(__SAM3X8E__) @@ -191,71 +214,83 @@ void setup() { // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - while(1); + while (1) + ; } - //Check if the camera module type is OV5640 + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ - Serial.println("Can't find OV5640 module!"); - while(1); - } - else - Serial.println("OV5640 detected."); - - - //Change to JPEG capture mode and initialize the OV5642 module + if ((vid != 0x56) || (pid != 0x40)) + { + Serial.println("Can't find OV5640 module!"); + while (1) + ; + } + else + Serial.println("OV5640 detected."); + + // Change to JPEG capture mode and initialize the OV5642 module myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5640_320x240);delay(1000); - - if (wifiType == 0){ - if(!strcmp(ssid,"SSID")){ - Serial.println("Please set your SSID"); - while(1); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5640_320x240); + delay(1000); + + if (wifiType == 0) + { + if (!strcmp(ssid, "SSID")) + { + Serial.println("Please set your SSID"); + while (1) + ; } - if(!strcmp(password,"PASSWORD")){ - Serial.println("Please set your PASSWORD"); - while(1); + if (!strcmp(password, "PASSWORD")) + { + Serial.println("Please set your PASSWORD"); + while (1) + ; } // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); - + WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); - while (WiFi.status() != WL_CONNECTED) { + while (WiFi.status() != WL_CONNECTED) + { delay(500); Serial.print("."); } Serial.println("WiFi connected"); Serial.println(""); Serial.println(WiFi.localIP()); - }else if (wifiType == 1){ + } + else if (wifiType == 1) + { Serial.println(); Serial.println(); Serial.print("Share AP: "); Serial.println(AP_ssid); Serial.print("The password is: "); Serial.println(AP_password); - + WiFi.mode(WIFI_AP); WiFi.softAP(AP_ssid, AP_password); Serial.println(""); Serial.println(WiFi.softAPIP()); } - + // Start the server server.on("/capture", HTTP_GET, serverCapture); server.on("/stream", HTTP_GET, serverStream); @@ -263,8 +298,8 @@ void setup() { server.begin(); Serial.println("Server started"); } -void loop() { +void loop() +{ server.handleClient(); } - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5642_Capture/ArduCAM_ESP8266_OV5642_Capture.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5642_Capture/ArduCAM_ESP8266_OV5642_Capture.ino index f3b783e4..928a4f08 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5642_Capture/ArduCAM_ESP8266_OV5642_Capture.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_OV5642_Capture/ArduCAM_ESP8266_OV5642_Capture.ino @@ -8,8 +8,8 @@ // The demo sketch will do the following tasks: // 1. Set the camera to JEPG output mode. // 2. if server.on("/capture", HTTP_GET, serverCapture),it can take photo and send to the Web. -// 3.if server.on("/stream", HTTP_GET, serverStream),it can take photo continuously as video -//streaming and send to the Web. +// 3.if server.on("/stream", HTTP_GET, serverStream),it can take photo continuously as video +// streaming and send to the Web. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -22,83 +22,93 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED -//or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) +// This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED +// or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : const int CS = 16; -//you can change the value of wifiType to select Station or AP mode. -//Default is AP mode. +// you can change the value of wifiType to select Station or AP mode. +// Default is AP mode. int wifiType = 1; // 0:Station 1:AP -//AP mode configuration -//Default is arducam_esp8266.If you want,you can change the AP_aaid to your favorite name -const char *AP_ssid = "arducam_esp8266"; -//Default is no password.If you want to set password,put your password here +// AP mode configuration +// Default is arducam_esp8266.If you want,you can change the AP_aaid to your favorite name +const char *AP_ssid = "arducam_esp8266"; +// Default is no password.If you want to set password,put your password here const char *AP_password = ""; -//Station mode you should put your ssid and password -const char* ssid = "SSID"; // Put your SSID here -const char* password = "PASSWORD"; // Put your PASSWORD here +// Station mode you should put your ssid and password +const char *ssid = "SSID"; // Put your SSID here +const char *password = "PASSWORD"; // Put your PASSWORD here ESP8266WebServer server(80); ArduCAM myCAM(OV5642, CS); -void start_capture(){ +void start_capture() +{ myCAM.clear_fifo_flag(); myCAM.start_capture(); } -void camCapture(ArduCAM myCAM){ +void camCapture(ArduCAM myCAM) +{ WiFiClient client = server.client(); - + size_t len = myCAM.read_fifo_length(); - if (len >= MAX_FIFO_SIZE){ + if (len >= MAX_FIFO_SIZE) + { Serial.println("Over size."); return; - }else if (len == 0 ){ + } + else if (len == 0) + { Serial.println("Size is 0."); return; } - + myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) +#if !(defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) SPI.transfer(0xFF); - #endif - if (!client.connected()) return; +#endif + if (!client.connected()) + return; String response = "HTTP/1.1 200 OK\r\n"; response += "Content-Type: image/jpeg\r\n"; response += "Content-Length: " + String(len) + "\r\n\r\n"; server.sendContent(response); static const size_t bufferSize = 4096; static uint8_t buffer[bufferSize] = {0xFF}; - while (len) { - size_t will_copy = (len < bufferSize) ? len : bufferSize; - myCAM.transferBytes(&buffer[0], &buffer[0], will_copy); - if (!client.connected()) break; - client.write(&buffer[0], will_copy); - len -= will_copy; + while (len) + { + size_t will_copy = (len < bufferSize) ? len : bufferSize; + myCAM.transferBytes(&buffer[0], &buffer[0], will_copy); + if (!client.connected()) + break; + client.write(&buffer[0], will_copy); + len -= will_copy; } - + myCAM.CS_HIGH(); } -void serverCapture(){ +void serverCapture() +{ start_capture(); Serial.println("CAM Capturing"); int total_time = 0; total_time = millis(); - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; total_time = millis() - total_time; Serial.print("capture total_time used (in miliseconds):"); Serial.println(total_time, DEC); @@ -112,63 +122,75 @@ void serverCapture(){ Serial.println("CAM send Done!"); } -void serverStream(){ +void serverStream() +{ WiFiClient client = server.client(); - + String response = "HTTP/1.1 200 OK\r\n"; response += "Content-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n"; server.sendContent(response); - - while (1){ - start_capture(); - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + + while (1) + { + start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; size_t len = myCAM.read_fifo_length(); - if (len >= MAX_FIFO_SIZE){ + if (len >= MAX_FIFO_SIZE) + { Serial.println("Over size."); continue; - }else if (len == 0 ){ + } + else if (len == 0) + { Serial.println("Size is 0."); continue; } myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - #if !(defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) + myCAM.set_fifo_burst(); +#if !(defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) SPI.transfer(0xFF); - #endif - if (!client.connected()) break; +#endif + if (!client.connected()) + break; response = "--frame\r\n"; response += "Content-Type: image/jpeg\r\n\r\n"; server.sendContent(response); - + static const size_t bufferSize = 4096; static uint8_t buffer[bufferSize] = {0xFF}; - - while (len) { + + while (len) + { size_t will_copy = (len < bufferSize) ? len : bufferSize; myCAM.transferBytes(&buffer[0], &buffer[0], will_copy); - if (!client.connected()) break; + if (!client.connected()) + break; client.write(&buffer[0], will_copy); len -= will_copy; } myCAM.CS_HIGH(); - if (!client.connected()) break; + if (!client.connected()) + break; } } -void handleNotFound(){ +void handleNotFound() +{ String message = "Server is running!\n\n"; message += "URI: "; message += server.uri(); message += "\nMethod: "; - message += (server.method() == HTTP_GET)?"GET":"POST"; + message += (server.method() == HTTP_GET) ? "GET" : "POST"; message += "\nArguments: "; message += server.args(); message += "\n"; server.send(200, "text/plain", message); - - if (server.hasArg("ql")){ + + if (server.hasArg("ql")) + { int ql = server.arg("ql").toInt(); myCAM.OV5642_set_JPEG_size(ql); delay(1000); @@ -176,7 +198,8 @@ void handleNotFound(){ } } -void setup() { +void setup() +{ uint8_t vid, pid; uint8_t temp; #if defined(__SAM3X8E__) @@ -192,58 +215,69 @@ void setup() { // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - while(1); + while (1) + ; } - //Check if the camera module type is OV5642 + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ - Serial.println("Can't find OV5642 module!"); - while(1); - } - else - Serial.println("OV5642 detected."); - - - //Change to JPEG capture mode and initialize the OV5642 module + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println("Can't find OV5642 module!"); + while (1) + ; + } + else + Serial.println("OV5642 detected."); + + // Change to JPEG capture mode and initialize the OV5642 module myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240); - delay(1000); - if (wifiType == 0){ - if(!strcmp(ssid,"SSID")){ - Serial.println("Please set your SSID"); - while(1); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + if (wifiType == 0) + { + if (!strcmp(ssid, "SSID")) + { + Serial.println("Please set your SSID"); + while (1) + ; } - if(!strcmp(password,"PASSWORD")){ - Serial.println("Please set your PASSWORD"); - while(1); + if (!strcmp(password, "PASSWORD")) + { + Serial.println("Please set your PASSWORD"); + while (1) + ; } // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); - + WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); - while (WiFi.status() != WL_CONNECTED) { + while (WiFi.status() != WL_CONNECTED) + { delay(500); Serial.print("."); } Serial.println("WiFi connected"); Serial.println(""); Serial.println(WiFi.localIP()); - }else if (wifiType == 1){ + } + else if (wifiType == 1) + { Serial.println(); Serial.println(); Serial.print("Share AP: "); @@ -255,7 +289,7 @@ void setup() { Serial.println(""); Serial.println(WiFi.softAPIP()); } - + // Start the server server.on("/capture", HTTP_GET, serverCapture); server.on("/stream", HTTP_GET, serverStream); @@ -263,8 +297,8 @@ void setup() { server.begin(); Serial.println("Server started"); } -void loop() { +void loop() +{ server.handleClient(); } - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Capture2SD/ArduCAM_ESP8266_V1_OV2640_Capture2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Capture2SD/ArduCAM_ESP8266_V1_OV2640_Capture2SD.ino index 71ee1e12..c49c9eff 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Capture2SD/ArduCAM_ESP8266_V1_OV2640_Capture2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Capture2SD/ArduCAM_ESP8266_V1_OV2640_Capture2SD.ino @@ -6,7 +6,7 @@ // It will run the ArduCAM ESP8266 2MP as a real 2MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 2MP shield @@ -16,21 +16,22 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV2640_MINI_2MP)||(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))) +// This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV2640_MINI_2MP) || (defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : const int CS = 16; -//Version 1,set GPIO1 as the slave select : +// Version 1,set GPIO1 as the slave select : const int SD_CS = 1; ArduCAM myCAM(OV2640, CS); -void myCAMSaveToSDFile(){ +void myCAMSaveToSDFile() +{ char str[8]; byte buf[256]; static int i = 0; @@ -38,109 +39,115 @@ void myCAMSaveToSDFile(){ static int n = 0; uint8_t temp, temp_last; File file; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("star Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println("Capture Done!"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println("Capture Done!"); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(! file){ - Serial.println("open file faild"); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); -#if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM)) -SPI.transfer(0xFF); + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!file) + { + Serial.println("open file faild"); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM)) + SPI.transfer(0xFF); #endif - //Read JPEG data from FIFO - while ( (temp !=0xD9) | (temp_last !=0xFF)){ - temp_last = temp; - temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = SPI.transfer(0x00); + + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + file.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + delay(0); + } - //Write image data to buffer if not full - if( i < 256) - buf[i++] = temp; - else{ - //Write 256 bytes image data to file + // Write the remain bytes in the buffer + if (i > 0) + { myCAM.CS_HIGH(); - file.write(buf ,256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - delay(0); - } - - //Write the remain bytes in the buffer - if(i > 0){ - myCAM.CS_HIGH(); - file.write(buf,i); - } - //Close the file - file.close(); + file.write(buf, i); + } + // Close the file + file.close(); Serial.println("CAM Save Done!"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); Serial.begin(115200); Serial.println("ArduCAM Start!"); - //set the CS as an output: - pinMode(CS,OUTPUT); + // set the CS as an output: + pinMode(CS, OUTPUT); - //initialize SPI: + // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHZ + SPI.setFrequency(4000000); // 4MHZ delay(1000); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - while(1); + while (1) + ; } - - //Initialize SD Card - if(!SD.begin(SD_CS)){ + + // Initialize SD Card + if (!SD.begin(SD_CS)) + { Serial.println("SD Card Error"); } else - Serial.println("SD Card detected!"); - + Serial.println("SD Card detected!"); - -//Check if the camera module type is OV2640 + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( !pid != 0x41 ) || ( pid != 0x42 ))) - Serial.println("Can't find OV2640 module!"); - else - Serial.println("OV2640 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); + if ((vid != 0x26) && ((!pid != 0x41) || (pid != 0x42))) + Serial.println("Can't find OV2640 module!"); + else + Serial.println("OV2640 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); } -void loop(){ +void loop() +{ delay(5000); myCAMSaveToSDFile(); } - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Video2SD/ArduCAM_ESP8266_V1_OV2640_Video2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Video2SD/ArduCAM_ESP8266_V1_OV2640_Video2SD.ino index dd506013..b195362f 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Video2SD/ArduCAM_ESP8266_V1_OV2640_Video2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV2640_Video2SD/ArduCAM_ESP8266_V1_OV2640_Video2SD.ino @@ -11,16 +11,16 @@ // 4.Write the video data to the SD card // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 2MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -30,117 +30,349 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV2640_MINI_2MP)||(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))) +// This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV2640_MINI_2MP) || (defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // Version 1, set pin 1 as the slave select for SD: #define SD_CS 1 #define pic_mun 200 #define rate 0x05 -//set pin 16 as the slave select for SPI: +// set pin 16 as the slave select for SPI: const int SPI_CS = 16; #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const char avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const char avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -ArduCAM myCAM( OV2640, SPI_CS ); -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +ArduCAM myCAM(OV2640, SPI_CS); +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -void Video2SD(){ +void Video2SD() +{ char quad_buf[4] = {}; char str[8]; File outFile; byte buf[256]; - + static int i = 0; static int k = 0; - uint8_t temp=0, temp_last=0; + uint8_t temp = 0, temp_last = 0; unsigned long position = 0; uint16_t frame_cnt = 0; uint8_t remnant = 0; movi_size = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println("open file failed"); - while (1); + while (1) + ; return; } - //Write AVI Header + // Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); - //Write video data + // Write video data Serial.println("Recording video, please wait..."); - for ( frame_cnt = 0; frame_cnt < pic_mun; frame_cnt ++) + for (frame_cnt = 0; frame_cnt < pic_mun; frame_cnt++) { - yield(); - //Capture a frame - //Flush the FIFO + yield(); + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - //Serial.println("Start Capture"); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - //Serial.println("Capture Done!"); + // Serial.println("Start Capture"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + // Serial.println("Capture Done!"); outFile.write("00dc"); outFile.write(zero_buf, 4); i = 0; jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM)) - SPI.transfer(0xFF); - #endif - //Read JPEG data from FIFO - while ( (temp != 0xD9) | (temp_last != 0xFF)) +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM)) + SPI.transfer(0xFF); +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = SPI.transfer(0x00); - //Write image data to buffer if not full + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -150,21 +382,22 @@ void Video2SD(){ jpeg_size += 256; } } - //Write the remain bytes in the buffer + // Write the remain bytes in the buffer if (i > 0) { myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; } - temp_last = 0;temp = 0; + temp_last = 0; + temp = 0; remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; jpeg_size = jpeg_size + remnant; movi_size = movi_size + jpeg_size; if (remnant > 0) outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); - + // Serial.println(movi_size, HEX); + position = outFile.position(); outFile.seek(position - 4 - jpeg_size); print_quartet(jpeg_size, outFile); @@ -174,33 +407,34 @@ void Video2SD(){ position = outFile.position(); outFile.seek(position + jpeg_size - 10); } - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 0xd8, outFile);//riff file size - //Serial.println(movi_size, HEX); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // Serial.println(movi_size, HEX); - //overwrite hdrl + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(max_bytes_per_sec, outFile); - //unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(max_bytes_per_sec, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again + print_quartet(movi_size, outFile); // size again myCAM.CS_HIGH(); - //Close the file - outFile.close(); - Serial.println("Record video OK"); + // Close the file + outFile.close(); + Serial.println("Record video OK"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); @@ -208,50 +442,44 @@ void setup(){ Serial.println("ArduCAM Start!"); // set the SPI_CS as an output: pinMode(SPI_CS, OUTPUT); - delay(1000); + delay(1000); // initialize SPI: SPI.begin(); - - //Check if the ArduCAM SPI bus is OK + + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println("SPI interface Error!"); - while (1); + while (1) + ; } - //Check if the camera module type is OV2640 + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) Serial.println("Can't find OV2640 module!"); - else + else Serial.println("OV2640 detected."); - //Change to BMP capture mode and initialize the OV2640 module + // Change to BMP capture mode and initialize the OV2640 module myCAM.set_format(JPEG); myCAM.InitCAM(); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD Card Error"); } else Serial.println("SD Card detected!"); } -void loop(){ - - Video2SD(); +void loop() +{ + + Video2SD(); delay(3000); - - } - - - - - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Capture2SD/ArduCAM_ESP8266_V1_OV5640_Capture2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Capture2SD/ArduCAM_ESP8266_V1_OV5640_Capture2SD.ino index 452f0a6f..0b610c59 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Capture2SD/ArduCAM_ESP8266_V1_OV5640_Capture2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Capture2SD/ArduCAM_ESP8266_V1_OV5640_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM ESP8266 5MP as a real 2MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP shield @@ -17,12 +17,12 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM))) +// This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : @@ -31,7 +31,8 @@ const int CS = 16; const int SD_CS = 1; ArduCAM myCAM(OV5640, CS); -void myCAMSaveToSDFile(){ +void myCAMSaveToSDFile() +{ char str[8]; byte buf[256]; static int i = 0; @@ -39,62 +40,68 @@ void myCAMSaveToSDFile(){ static int n = 0; uint8_t temp, temp_last; File file; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("star Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println("Capture Done!"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println("Capture Done!"); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(! file){ - Serial.println("open file faild"); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM)) + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!file) + { + Serial.println("open file faild"); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM)) SPI.transfer(0xFF); - #endif - //Read JPEG data from FIFO - while ( (temp !=0xD9) | (temp_last !=0xFF)){ - temp_last = temp; - temp = SPI.transfer(0x00); - //Write image data to buffer if not full - if( i < 256) - buf[i++] = temp; - else{ - //Write 256 bytes image data to file +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + file.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + delay(0); + } + + // Write the remain bytes in the buffer + if (i > 0) + { myCAM.CS_HIGH(); - file.write(buf ,256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - delay(0); - } - - //Write the remain bytes in the buffer - if(i > 0){ - myCAM.CS_HIGH(); - file.write(buf,i); - } - //Close the file - file.close(); + file.write(buf, i); + } + // Close the file + file.close(); Serial.println("CAM Save Done!"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; @@ -102,53 +109,52 @@ void setup(){ Serial.begin(115200); Serial.println("ArduCAM Start!"); - //set the CS as an output: - pinMode(CS,OUTPUT); + // set the CS as an output: + pinMode(CS, OUTPUT); // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz delay(1000); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - - if (temp != 0x55){ + + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - //while(1); + // while(1); } - //Initialize SD Card - if(!SD.begin(SD_CS)){ + // Initialize SD Card + if (!SD.begin(SD_CS)) + { Serial.println("SD Card Error"); } else - Serial.println("SD Card detected!"); - - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power + Serial.println("SD Card detected!"); + + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power delay(100); -//Check if the camera module type is OV5640 + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)) - Serial.println("Can't find OV5640 module!"); - else - Serial.println("OV5640 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5640_set_JPEG_size(OV5640_320x240); - delay(1000); + if ((vid != 0x56) || (pid != 0x40)) + Serial.println("Can't find OV5640 module!"); + else + Serial.println("OV5640 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); } -void loop(){ +void loop() +{ myCAMSaveToSDFile(); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //enable low power + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enable low power delay(3000); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power - delay(2000); - - + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power + delay(2000); } - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Video2SD/ArduCAM_ESP8266_V1_OV5640_Video2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Video2SD/ArduCAM_ESP8266_V1_OV5640_Video2SD.ino index 5166ef89..ccdf381c 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Video2SD/ArduCAM_ESP8266_V1_OV5640_Video2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5640_Video2SD/ArduCAM_ESP8266_V1_OV5640_Video2SD.ino @@ -12,16 +12,16 @@ // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -31,118 +31,350 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM))) +// This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -//Version 1, set pin 1 as the slave select for SD: +// Version 1, set pin 1 as the slave select for SD: #define SD_CS 1 // set the num of picture #define pic_num 200 #define rate 0x05 -//set pin 16 as the slave select for SPI: +// set pin 16 as the slave select for SPI: const int SPI_CS = 16; #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const char avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const char avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -ArduCAM myCAM( OV5640, SPI_CS ); -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +ArduCAM myCAM(OV5640, SPI_CS); +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -void Video2SD(){ - char quad_buf[4] = {}; +void Video2SD() +{ + char quad_buf[4] = {}; char str[8]; File outFile; byte buf[256]; - + static int i = 0; static int k = 0; uint8_t temp = 0, temp_last = 0; unsigned long position = 0; uint16_t frame_cnt = 0; uint8_t remnant = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println("open file failed"); - while (1); + while (1) + ; return; } - //Write AVI Header + // Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); - //Write video data - Serial.println("Recording video, please wait..."); - for ( frame_cnt = 0; frame_cnt < pic_num; frame_cnt ++) + // Write video data + Serial.println("Recording video, please wait..."); + for (frame_cnt = 0; frame_cnt < pic_num; frame_cnt++) { - yield(); - //Capture a frame - //Flush the FIFO + yield(); + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - //Serial.println("Start Capture"); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - //Serial.println("Capture Done!"); + // Serial.println("Start Capture"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + // Serial.println("Capture Done!"); outFile.write("00dc"); outFile.write(zero_buf, 4); i = 0; jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM)) +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM)) SPI.transfer(0xFF); - #endif - //Read JPEG data from FIFO - while ( (temp != 0xD9) | (temp_last != 0xFF)) +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = SPI.transfer(0x00); - - //Write image data to buffer if not full + + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -152,21 +384,22 @@ void Video2SD(){ jpeg_size += 256; } } - - //Write the remain bytes in the buffer + + // Write the remain bytes in the buffer if (i > 0) { myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; } - temp = 0;temp_last =0; + temp = 0; + temp_last = 0; remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; jpeg_size = jpeg_size + remnant; movi_size = movi_size + jpeg_size; if (remnant > 0) outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); + // Serial.println(movi_size, HEX); position = outFile.position(); outFile.seek(position - 4 - jpeg_size); @@ -178,33 +411,34 @@ void Video2SD(){ outFile.seek(position + jpeg_size - 10); } - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 0xd8, outFile);//riff file size - //Serial.println(movi_size, HEX); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // Serial.println(movi_size, HEX); - //overwrite hdrl + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(max_bytes_per_sec, outFile); - //unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(max_bytes_per_sec, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again - myCAM.CS_HIGH(); - //Close the file + print_quartet(movi_size, outFile); // size again + myCAM.CS_HIGH(); + // Close the file outFile.close(); - Serial.println("Record video OK"); + Serial.println("Record video OK"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); @@ -215,50 +449,46 @@ void setup(){ delay(1000); // initialize SPI: SPI.begin(); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println("SPI interface Error!"); - while (1); + while (1) + ; } - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power - delay(100); -//Check if the camera module type is OV5640 + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power + delay(100); + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)) - Serial.println("Can't find OV5640 module!"); - else - Serial.println("OV5640 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5640_set_JPEG_size(OV5640_320x240); + if ((vid != 0x56) || (pid != 0x40)) + Serial.println("Can't find OV5640 module!"); + else + Serial.println("OV5640 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD Card Error"); } else Serial.println("SD Card detected!"); } -void loop(){ - +void loop() +{ + Video2SD(); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //enable low power + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enable low power delay(3000); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power delay(2000); } - - - - - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Capture2SD/ArduCAM_ESP8266_V1_OV5642_Capture2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Capture2SD/ArduCAM_ESP8266_V1_OV5642_Capture2SD.ino index 43566a4f..7ea52c06 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Capture2SD/ArduCAM_ESP8266_V1_OV5642_Capture2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Capture2SD/ArduCAM_ESP8266_V1_OV5642_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM ESP8266 5MP as a real 2MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP shield @@ -17,13 +17,13 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED -//or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) +// This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED +// or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : @@ -32,7 +32,8 @@ const int CS = 16; const int SD_CS = 1; ArduCAM myCAM(OV5642, CS); -void myCAMSaveToSDFile(){ +void myCAMSaveToSDFile() +{ char str[8]; byte buf[256]; static int i = 0; @@ -40,68 +41,74 @@ void myCAMSaveToSDFile(){ static int n = 0; uint8_t temp, temp_last; File file; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("star Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println("Capture Done!"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println("Capture Done!"); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(! file){ - Serial.println("open file faild"); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); -#if !( defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) - temp=SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) - temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - #endif - //Read JPEG data from FIFO - while ( (temp !=0xD9) | (temp_last !=0xFF)){ - temp_last = temp; + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!file) + { + Serial.println("open file faild"); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); +#if !(defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) temp = SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) +#if defined(OV5642_MINI_5MP) temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - //Write image data to buffer if not full - if( i < 256) - buf[i++] = temp; - else{ - //Write 256 bytes image data to file +#endif +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = SPI.transfer(0x00); +#if defined(OV5642_MINI_5MP) + temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback +#endif + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + file.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + delay(0); + } + + // Write the remain bytes in the buffer + if (i > 0) + { myCAM.CS_HIGH(); - file.write(buf ,256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - delay(0); - } - - //Write the remain bytes in the buffer - if(i > 0){ - myCAM.CS_HIGH(); - file.write(buf,i); - } - //Close the file - file.close(); + file.write(buf, i); + } + // Close the file + file.close(); Serial.println("CAM Save Done!"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; @@ -109,53 +116,52 @@ void setup(){ Serial.begin(115200); Serial.println("ArduCAM Start!"); - //set the CS as an output: - pinMode(CS,OUTPUT); + // set the CS as an output: + pinMode(CS, OUTPUT); // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz delay(1000); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - - if (temp != 0x55){ + + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - //while(1); + // while(1); } - //Initialize SD Card - if(!SD.begin(SD_CS)){ + // Initialize SD Card + if (!SD.begin(SD_CS)) + { Serial.println("SD Card Error"); } else - Serial.println("SD Card detected!"); - - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power + Serial.println("SD Card detected!"); + + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power delay(100); -//Check if the camera module type is OV5642 + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)) - Serial.println("Can't find OV5642 module!"); - else - Serial.println("OV5642 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240); - delay(1000); + if ((vid != 0x56) || (pid != 0x42)) + Serial.println("Can't find OV5642 module!"); + else + Serial.println("OV5642 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); } -void loop(){ +void loop() +{ myCAMSaveToSDFile(); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //enable low power + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enable low power delay(3000); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power - delay(2000); - - + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power + delay(2000); } - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Video2SD/ArduCAM_ESP8266_V1_OV5642_Video2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Video2SD/ArduCAM_ESP8266_V1_OV5642_Video2SD.ino index 3693686e..cf22a6bf 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Video2SD/ArduCAM_ESP8266_V1_OV5642_Video2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V1_OV5642_Video2SD/ArduCAM_ESP8266_V1_OV5642_Video2SD.ino @@ -12,16 +12,16 @@ // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -31,128 +31,360 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED -//or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) +// This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED +// or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -//Version 1, set pin 1 as the slave select for SD: +// Version 1, set pin 1 as the slave select for SD: #define SD_CS 1 #define rate 0x05 // set the num of picture #define pic_num 200 -//set pin 16 as the slave select for SPI: +// set pin 16 as the slave select for SPI: const int SPI_CS = 16; #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const char avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const char avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -ArduCAM myCAM( OV5642, SPI_CS ); -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +ArduCAM myCAM(OV5642, SPI_CS); +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -void Video2SD(){ - char quad_buf[4] = {}; +void Video2SD() +{ + char quad_buf[4] = {}; char str[8]; File outFile; byte buf[256]; - + static int i = 0; static int k = 0; uint8_t temp = 0, temp_last = 0; unsigned long position = 0; uint16_t frame_cnt = 0; uint8_t remnant = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println("open file failed"); - while (1); + while (1) + ; return; } - //Write AVI Header + // Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); - //Write video data - Serial.println("Recording video, please wait..."); - for ( frame_cnt = 0; frame_cnt < pic_num; frame_cnt ++) + // Write video data + Serial.println("Recording video, please wait..."); + for (frame_cnt = 0; frame_cnt < pic_num; frame_cnt++) { - yield(); - //Capture a frame - //Flush the FIFO + yield(); + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - //Serial.println("Start Capture"); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - //Serial.println("Capture Done!"); + // Serial.println("Start Capture"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + // Serial.println("Capture Done!"); outFile.write("00dc"); outFile.write(zero_buf, 4); i = 0; jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !( defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) - temp=SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) - temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - #endif - //Read JPEG data from FIFO - - while ( (temp != 0xD9) | (temp_last != 0xFF)) +#if !(defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) + temp = SPI.transfer(0x00); +#if defined(OV5642_MINI_5MP) + temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback +#endif +#endif + // Read JPEG data from FIFO + + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) - temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - - //Write image data to buffer if not full +#if defined(OV5642_MINI_5MP) + temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback +#endif + + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -162,20 +394,21 @@ void Video2SD(){ jpeg_size += 256; } } - //Write the remain bytes in the buffer + // Write the remain bytes in the buffer if (i > 0) { myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; } - temp=0;temp_last=0; + temp = 0; + temp_last = 0; remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; jpeg_size = jpeg_size + remnant; movi_size = movi_size + jpeg_size; if (remnant > 0) outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); + // Serial.println(movi_size, HEX); position = outFile.position(); outFile.seek(position - 4 - jpeg_size); @@ -187,33 +420,34 @@ void Video2SD(){ outFile.seek(position + jpeg_size - 10); } - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 0xd8, outFile);//riff file size - //Serial.println(movi_size, HEX); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // Serial.println(movi_size, HEX); - //overwrite hdrl + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(max_bytes_per_sec, outFile); - //unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(max_bytes_per_sec, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again + print_quartet(movi_size, outFile); // size again myCAM.CS_HIGH(); - //Close the file + // Close the file outFile.close(); Serial.println("Record video OK"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); @@ -224,46 +458,41 @@ void setup(){ delay(1000); // initialize SPI: SPI.begin(); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println("SPI interface Error!"); - while (1); + while (1) + ; } -//Check if the camera module type is OV5642 + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)) - Serial.println("Can't find OV5642 module!"); - else - Serial.println("OV5642 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240); - delay(1000); + if ((vid != 0x56) || (pid != 0x42)) + Serial.println("Can't find OV5642 module!"); + else + Serial.println("OV5642 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD Card Error"); } else Serial.println("SD Card detected!"); } -void loop(){ - +void loop() +{ + Video2SD(); delay(5000); - } - - - - - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Capture2SD/ArduCAM_ESP8266_V2_OV2640_Capture2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Capture2SD/ArduCAM_ESP8266_V2_OV2640_Capture2SD.ino index 664533e6..3f580017 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Capture2SD/ArduCAM_ESP8266_V2_OV2640_Capture2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Capture2SD/ArduCAM_ESP8266_V2_OV2640_Capture2SD.ino @@ -6,7 +6,7 @@ // It will run the ArduCAM ESP8266 2MP as a real 2MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 2MP shield @@ -16,21 +16,22 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV2640_MINI_2MP)||(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))) +// This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV2640_MINI_2MP) || (defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : const int CS = 16; -//Version 2,set GPIO0 as the slave select : +// Version 2,set GPIO0 as the slave select : const int SD_CS = 0; ArduCAM myCAM(OV2640, CS); -void myCAMSaveToSDFile(){ +void myCAMSaveToSDFile() +{ char str[8]; byte buf[256]; static int i = 0; @@ -38,109 +39,115 @@ void myCAMSaveToSDFile(){ static int n = 0; uint8_t temp, temp_last; File file; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("star Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println("Capture Done!"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println("Capture Done!"); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(! file){ - Serial.println("open file faild"); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); -#if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM)) -SPI.transfer(0xFF); + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!file) + { + Serial.println("open file faild"); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM)) + SPI.transfer(0xFF); #endif - //Read JPEG data from FIFO - while ( (temp !=0xD9) | (temp_last !=0xFF)){ - temp_last = temp; - temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = SPI.transfer(0x00); + + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + file.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + delay(0); + } - //Write image data to buffer if not full - if( i < 256) - buf[i++] = temp; - else{ - //Write 256 bytes image data to file + // Write the remain bytes in the buffer + if (i > 0) + { myCAM.CS_HIGH(); - file.write(buf ,256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - delay(0); - } - - //Write the remain bytes in the buffer - if(i > 0){ - myCAM.CS_HIGH(); - file.write(buf,i); - } - //Close the file - file.close(); + file.write(buf, i); + } + // Close the file + file.close(); Serial.println("CAM Save Done!"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); Serial.begin(115200); Serial.println("ArduCAM Start!"); - //set the CS as an output: - pinMode(CS,OUTPUT); + // set the CS as an output: + pinMode(CS, OUTPUT); - //initialize SPI: + // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHZ + SPI.setFrequency(4000000); // 4MHZ delay(1000); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - while(1); + while (1) + ; } - - //Initialize SD Card - if(!SD.begin(SD_CS)){ + + // Initialize SD Card + if (!SD.begin(SD_CS)) + { Serial.println("SD Card Error"); } else - Serial.println("SD Card detected!"); - + Serial.println("SD Card detected!"); - -//Check if the camera module type is OV2640 + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( !pid != 0x41 ) || ( pid != 0x42 ))) - Serial.println("Can't find OV2640 module!"); - else - Serial.println("OV2640 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); + if ((vid != 0x26) && ((!pid != 0x41) || (pid != 0x42))) + Serial.println("Can't find OV2640 module!"); + else + Serial.println("OV2640 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); } -void loop(){ +void loop() +{ delay(5000); myCAMSaveToSDFile(); } - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Video2SD/ArduCAM_ESP8266_V2_OV2640_Video2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Video2SD/ArduCAM_ESP8266_V2_OV2640_Video2SD.ino index 6c3880ca..55fffce7 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Video2SD/ArduCAM_ESP8266_V2_OV2640_Video2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV2640_Video2SD/ArduCAM_ESP8266_V2_OV2640_Video2SD.ino @@ -11,16 +11,16 @@ // 4.Write the video data to the SD card // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 2MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -30,117 +30,349 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV2640_MINI_2MP)||(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM))) +// This demo can only work on OV2640_MINI_2MP or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV2640_MINI_2MP) || (defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // Version 2, set pin 0 as the slave select for SD: #define SD_CS 0 #define pic_mun 200 #define rate 0x05 -//set pin 16 as the slave select for SPI: +// set pin 16 as the slave select for SPI: const int SPI_CS = 16; #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const char avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const char avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -ArduCAM myCAM( OV2640, SPI_CS ); -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +ArduCAM myCAM(OV2640, SPI_CS); +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -void Video2SD(){ +void Video2SD() +{ char quad_buf[4] = {}; char str[8]; File outFile; byte buf[256]; - + static int i = 0; static int k = 0; - uint8_t temp=0, temp_last=0; + uint8_t temp = 0, temp_last = 0; unsigned long position = 0; uint16_t frame_cnt = 0; uint8_t remnant = 0; movi_size = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println("open file failed"); - while (1); + while (1) + ; return; } - //Write AVI Header + // Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); - //Write video data + // Write video data Serial.println("Recording video, please wait..."); - for ( frame_cnt = 0; frame_cnt < pic_mun; frame_cnt ++) + for (frame_cnt = 0; frame_cnt < pic_mun; frame_cnt++) { - yield(); - //Capture a frame - //Flush the FIFO + yield(); + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - //Serial.println("Start Capture"); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - //Serial.println("Capture Done!"); + // Serial.println("Start Capture"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + // Serial.println("Capture Done!"); outFile.write("00dc"); outFile.write(zero_buf, 4); i = 0; jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV2640_CAM)) - SPI.transfer(0xFF); - #endif - //Read JPEG data from FIFO - while ( (temp != 0xD9) | (temp_last != 0xFF)) +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV2640_CAM)) + SPI.transfer(0xFF); +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = SPI.transfer(0x00); - //Write image data to buffer if not full + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -150,21 +382,22 @@ void Video2SD(){ jpeg_size += 256; } } - //Write the remain bytes in the buffer + // Write the remain bytes in the buffer if (i > 0) { myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; } - temp_last = 0;temp = 0; + temp_last = 0; + temp = 0; remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; jpeg_size = jpeg_size + remnant; movi_size = movi_size + jpeg_size; if (remnant > 0) outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); - + // Serial.println(movi_size, HEX); + position = outFile.position(); outFile.seek(position - 4 - jpeg_size); print_quartet(jpeg_size, outFile); @@ -174,33 +407,34 @@ void Video2SD(){ position = outFile.position(); outFile.seek(position + jpeg_size - 10); } - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 0xd8, outFile);//riff file size - //Serial.println(movi_size, HEX); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // Serial.println(movi_size, HEX); - //overwrite hdrl + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(max_bytes_per_sec, outFile); - //unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(max_bytes_per_sec, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again + print_quartet(movi_size, outFile); // size again myCAM.CS_HIGH(); - //Close the file - outFile.close(); - Serial.println("Record video OK"); + // Close the file + outFile.close(); + Serial.println("Record video OK"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); @@ -208,50 +442,44 @@ void setup(){ Serial.println("ArduCAM Start!"); // set the SPI_CS as an output: pinMode(SPI_CS, OUTPUT); - delay(1000); + delay(1000); // initialize SPI: SPI.begin(); - - //Check if the ArduCAM SPI bus is OK + + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println("SPI interface Error!"); - while (1); + while (1) + ; } - //Check if the camera module type is OV2640 + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) Serial.println("Can't find OV2640 module!"); - else + else Serial.println("OV2640 detected."); - //Change to BMP capture mode and initialize the OV2640 module + // Change to BMP capture mode and initialize the OV2640 module myCAM.set_format(JPEG); myCAM.InitCAM(); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD Card Error"); } else Serial.println("SD Card detected!"); } -void loop(){ - - Video2SD(); +void loop() +{ + + Video2SD(); delay(3000); - - } - - - - - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Capture2SD/ArduCAM_ESP8266_V2_OV5640_Capture2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Capture2SD/ArduCAM_ESP8266_V2_OV5640_Capture2SD.ino index 9fa9d4a3..321f1884 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Capture2SD/ArduCAM_ESP8266_V2_OV5640_Capture2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Capture2SD/ArduCAM_ESP8266_V2_OV5640_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM ESP8266 5MP as a real 2MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP shield @@ -17,12 +17,12 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM))) +// This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : @@ -31,7 +31,8 @@ const int CS = 16; const int SD_CS = 0; ArduCAM myCAM(OV5640, CS); -void myCAMSaveToSDFile(){ +void myCAMSaveToSDFile() +{ char str[8]; byte buf[256]; static int i = 0; @@ -39,62 +40,68 @@ void myCAMSaveToSDFile(){ static int n = 0; uint8_t temp, temp_last; File file; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("star Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println("Capture Done!"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println("Capture Done!"); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(! file){ - Serial.println("open file faild"); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM)) + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!file) + { + Serial.println("open file faild"); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM)) SPI.transfer(0xFF); - #endif - //Read JPEG data from FIFO - while ( (temp !=0xD9) | (temp_last !=0xFF)){ - temp_last = temp; - temp = SPI.transfer(0x00); - //Write image data to buffer if not full - if( i < 256) - buf[i++] = temp; - else{ - //Write 256 bytes image data to file +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + file.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + delay(0); + } + + // Write the remain bytes in the buffer + if (i > 0) + { myCAM.CS_HIGH(); - file.write(buf ,256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - delay(0); - } - - //Write the remain bytes in the buffer - if(i > 0){ - myCAM.CS_HIGH(); - file.write(buf,i); - } - //Close the file - file.close(); + file.write(buf, i); + } + // Close the file + file.close(); Serial.println("CAM Save Done!"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; @@ -102,53 +109,52 @@ void setup(){ Serial.begin(115200); Serial.println("ArduCAM Start!"); - //set the CS as an output: - pinMode(CS,OUTPUT); + // set the CS as an output: + pinMode(CS, OUTPUT); // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz delay(1000); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - - if (temp != 0x55){ + + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - //while(1); + // while(1); } - //Initialize SD Card - if(!SD.begin(SD_CS)){ + // Initialize SD Card + if (!SD.begin(SD_CS)) + { Serial.println("SD Card Error"); } else - Serial.println("SD Card detected!"); - - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power + Serial.println("SD Card detected!"); + + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power delay(100); -//Check if the camera module type is OV5640 + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)) - Serial.println("Can't find OV5640 module!"); - else - Serial.println("OV5640 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5640_set_JPEG_size(OV5640_320x240); - delay(1000); + if ((vid != 0x56) || (pid != 0x40)) + Serial.println("Can't find OV5640 module!"); + else + Serial.println("OV5640 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); } -void loop(){ +void loop() +{ myCAMSaveToSDFile(); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //enable low power + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enable low power delay(3000); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power - delay(2000); - - + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power + delay(2000); } - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Video2SD/ArduCAM_ESP8266_V2_OV5640_Video2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Video2SD/ArduCAM_ESP8266_V2_OV5640_Video2SD.ino index ae3f31c0..a12a793e 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Video2SD/ArduCAM_ESP8266_V2_OV5640_Video2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5640_Video2SD/ArduCAM_ESP8266_V2_OV5640_Video2SD.ino @@ -12,16 +12,16 @@ // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0(or later) library and ArduCAM ESP8266 5MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -31,118 +31,350 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM))) +// This demo can only work on OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -//Vwesion 2, set pin 0 as the slave select for SD: +// Vwesion 2, set pin 0 as the slave select for SD: #define SD_CS 0 // set the num of picture #define pic_num 200 #define rate 0x05 -//set pin 16 as the slave select for SPI: +// set pin 16 as the slave select for SPI: const int SPI_CS = 16; #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const char avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const char avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -ArduCAM myCAM( OV5640, SPI_CS ); -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +ArduCAM myCAM(OV5640, SPI_CS); +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -void Video2SD(){ - char quad_buf[4] = {}; +void Video2SD() +{ + char quad_buf[4] = {}; char str[8]; File outFile; byte buf[256]; - + static int i = 0; static int k = 0; uint8_t temp = 0, temp_last = 0; unsigned long position = 0; uint16_t frame_cnt = 0; uint8_t remnant = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println("open file failed"); - while (1); + while (1) + ; return; } - //Write AVI Header + // Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); - //Write video data - Serial.println("Recording video, please wait..."); - for ( frame_cnt = 0; frame_cnt < pic_num; frame_cnt ++) + // Write video data + Serial.println("Recording video, please wait..."); + for (frame_cnt = 0; frame_cnt < pic_num; frame_cnt++) { - yield(); - //Capture a frame - //Flush the FIFO + yield(); + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - //Serial.println("Start Capture"); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - //Serial.println("Capture Done!"); + // Serial.println("Start Capture"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + // Serial.println("Capture Done!"); outFile.write("00dc"); outFile.write(zero_buf, 4); i = 0; jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !(defined (ARDUCAM_SHIELD_V2) && defined (OV5640_CAM)) +#if !(defined(ARDUCAM_SHIELD_V2) && defined(OV5640_CAM)) SPI.transfer(0xFF); - #endif - //Read JPEG data from FIFO - while ( (temp != 0xD9) | (temp_last != 0xFF)) +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = SPI.transfer(0x00); - - //Write image data to buffer if not full + + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -152,21 +384,22 @@ void Video2SD(){ jpeg_size += 256; } } - - //Write the remain bytes in the buffer + + // Write the remain bytes in the buffer if (i > 0) { myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; } - temp = 0;temp_last =0; + temp = 0; + temp_last = 0; remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; jpeg_size = jpeg_size + remnant; movi_size = movi_size + jpeg_size; if (remnant > 0) outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); + // Serial.println(movi_size, HEX); position = outFile.position(); outFile.seek(position - 4 - jpeg_size); @@ -178,33 +411,34 @@ void Video2SD(){ outFile.seek(position + jpeg_size - 10); } - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 0xd8, outFile);//riff file size - //Serial.println(movi_size, HEX); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // Serial.println(movi_size, HEX); - //overwrite hdrl + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(max_bytes_per_sec, outFile); - //unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(max_bytes_per_sec, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again - myCAM.CS_HIGH(); - //Close the file + print_quartet(movi_size, outFile); // size again + myCAM.CS_HIGH(); + // Close the file outFile.close(); - Serial.println("Record video OK"); + Serial.println("Record video OK"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); @@ -215,50 +449,46 @@ void setup(){ delay(1000); // initialize SPI: SPI.begin(); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println("SPI interface Error!"); - while (1); + while (1) + ; } - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power - delay(100); -//Check if the camera module type is OV5640 + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power + delay(100); + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)) - Serial.println("Can't find OV5640 module!"); - else - Serial.println("OV5640 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5640_set_JPEG_size(OV5640_320x240); + if ((vid != 0x56) || (pid != 0x40)) + Serial.println("Can't find OV5640 module!"); + else + Serial.println("OV5640 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD Card Error"); } else Serial.println("SD Card detected!"); } -void loop(){ - +void loop() +{ + Video2SD(); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //enable low power + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enable low power delay(3000); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power delay(2000); } - - - - - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Capture2SD/ArduCAM_ESP8266_V2_OV5642_Capture2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Capture2SD/ArduCAM_ESP8266_V2_OV5642_Capture2SD.ino index 0825278e..d8ac8eee 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Capture2SD/ArduCAM_ESP8266_V2_OV5642_Capture2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Capture2SD/ArduCAM_ESP8266_V2_OV5642_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM ESP8266 5MP as a real 2MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP shield @@ -17,13 +17,13 @@ #include #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED -//or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) +// This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED +// or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set GPIO16 as the slave select : @@ -32,7 +32,8 @@ const int CS = 16; const int SD_CS = 0; ArduCAM myCAM(OV5642, CS); -void myCAMSaveToSDFile(){ +void myCAMSaveToSDFile() +{ char str[8]; byte buf[256]; static int i = 0; @@ -40,68 +41,74 @@ void myCAMSaveToSDFile(){ static int n = 0; uint8_t temp, temp_last; File file; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("star Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println("Capture Done!"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println("Capture Done!"); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(! file){ - Serial.println("open file faild"); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); -#if !( defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) - temp=SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) - temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - #endif - //Read JPEG data from FIFO - while ( (temp !=0xD9) | (temp_last !=0xFF)){ - temp_last = temp; + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + file = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!file) + { + Serial.println("open file faild"); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); +#if !(defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) temp = SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) +#if defined(OV5642_MINI_5MP) temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - //Write image data to buffer if not full - if( i < 256) - buf[i++] = temp; - else{ - //Write 256 bytes image data to file +#endif +#endif + // Read JPEG data from FIFO + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = SPI.transfer(0x00); +#if defined(OV5642_MINI_5MP) + temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback +#endif + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + file.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + delay(0); + } + + // Write the remain bytes in the buffer + if (i > 0) + { myCAM.CS_HIGH(); - file.write(buf ,256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - delay(0); - } - - //Write the remain bytes in the buffer - if(i > 0){ - myCAM.CS_HIGH(); - file.write(buf,i); - } - //Close the file - file.close(); + file.write(buf, i); + } + // Close the file + file.close(); Serial.println("CAM Save Done!"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; @@ -109,53 +116,52 @@ void setup(){ Serial.begin(115200); Serial.println("ArduCAM Start!"); - //set the CS as an output: - pinMode(CS,OUTPUT); + // set the CS as an output: + pinMode(CS, OUTPUT); // initialize SPI: SPI.begin(); - SPI.setFrequency(4000000); //4MHz + SPI.setFrequency(4000000); // 4MHz delay(1000); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - - if (temp != 0x55){ + + if (temp != 0x55) + { Serial.println("SPI1 interface Error!"); - //while(1); + // while(1); } - //Initialize SD Card - if(!SD.begin(SD_CS)){ + // Initialize SD Card + if (!SD.begin(SD_CS)) + { Serial.println("SD Card Error"); } else - Serial.println("SD Card detected!"); - - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power + Serial.println("SD Card detected!"); + + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power delay(100); -//Check if the camera module type is OV5642 + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)) - Serial.println("Can't find OV5642 module!"); - else - Serial.println("OV5642 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240); - delay(1000); + if ((vid != 0x56) || (pid != 0x42)) + Serial.println("Can't find OV5642 module!"); + else + Serial.println("OV5642 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); } -void loop(){ +void loop() +{ myCAMSaveToSDFile(); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //enable low power + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // enable low power delay(3000); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); //disable low power - delay(2000); - - + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); // disable low power + delay(2000); } - - diff --git a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Video2SD/ArduCAM_ESP8266_V2_OV5642_Video2SD.ino b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Video2SD/ArduCAM_ESP8266_V2_OV5642_Video2SD.ino index efe3c224..6dc3ed85 100644 --- a/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Video2SD/ArduCAM_ESP8266_V2_OV5642_Video2SD.ino +++ b/ArduCAM/examples/ESP8266/ArduCAM_ESP8266_V2_OV5642_Video2SD/ArduCAM_ESP8266_V2_OV5642_Video2SD.ino @@ -12,16 +12,16 @@ // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM ESP8266 5MP camera // and use Arduino IDE 1.5.8 compiler or above @@ -32,128 +32,360 @@ #include #include "memorysaver.h" -#if !(defined ESP8266 ) +#if !(defined ESP8266) #error Please select the ArduCAM ESP8266 UNO board in the Tools/Board #endif -//This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED -//or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. -#if !(defined (OV5642_MINI_5MP) || defined (OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) +// This demo can only work on OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED +// or OV5640_MINI_5MP_PLUS or ARDUCAM_SHIELD_V2 platform. +#if !(defined(OV5642_MINI_5MP) || defined(OV5642_MINI_5MP_BIT_ROTATION_FIXED) || defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -//Vwesion 2, set pin 0 as the slave select for SD: +// Vwesion 2, set pin 0 as the slave select for SD: #define SD_CS 0 #define rate 0x05 // set the num of picture #define pic_num 200 -//set pin 16 as the slave select for SPI: +// set pin 16 as the slave select for SPI: const int SPI_CS = 16; #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const char avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const char avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -ArduCAM myCAM( OV5642, SPI_CS ); -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +ArduCAM myCAM(OV5642, SPI_CS); +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -void Video2SD(){ - char quad_buf[4] = {}; +void Video2SD() +{ + char quad_buf[4] = {}; char str[8]; File outFile; byte buf[256]; - + static int i = 0; static int k = 0; uint8_t temp = 0, temp_last = 0; unsigned long position = 0; uint16_t frame_cnt = 0; uint8_t remnant = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println("open file failed"); - while (1); + while (1) + ; return; } - //Write AVI Header + // Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); - //Write video data - Serial.println("Recording video, please wait..."); - for ( frame_cnt = 0; frame_cnt < pic_num; frame_cnt ++) + // Write video data + Serial.println("Recording video, please wait..."); + for (frame_cnt = 0; frame_cnt < pic_num; frame_cnt++) { - yield(); - //Capture a frame - //Flush the FIFO + yield(); + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - //Serial.println("Start Capture"); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - //Serial.println("Capture Done!"); + // Serial.println("Start Capture"); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + // Serial.println("Capture Done!"); outFile.write("00dc"); outFile.write(zero_buf, 4); i = 0; jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - #if !( defined (OV5642_MINI_5MP_PLUS) ||(defined (ARDUCAM_SHIELD_V2) && defined (OV5642_CAM))) - temp=SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) - temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - #endif - //Read JPEG data from FIFO - - while ( (temp != 0xD9) | (temp_last != 0xFF)) +#if !(defined(OV5642_MINI_5MP_PLUS) || (defined(ARDUCAM_SHIELD_V2) && defined(OV5642_CAM))) + temp = SPI.transfer(0x00); +#if defined(OV5642_MINI_5MP) + temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback +#endif +#endif + // Read JPEG data from FIFO + + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = SPI.transfer(0x00); - #if defined (OV5642_MINI_5MP) - temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback - #endif - - //Write image data to buffer if not full +#if defined(OV5642_MINI_5MP) + temp = (byte)(temp >> 1) | (temp << 7); // correction for bit rotation from readback +#endif + + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -163,20 +395,21 @@ void Video2SD(){ jpeg_size += 256; } } - //Write the remain bytes in the buffer + // Write the remain bytes in the buffer if (i > 0) { myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; } - temp=0;temp_last=0; + temp = 0; + temp_last = 0; remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; jpeg_size = jpeg_size + remnant; movi_size = movi_size + jpeg_size; if (remnant > 0) outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); + // Serial.println(movi_size, HEX); position = outFile.position(); outFile.seek(position - 4 - jpeg_size); @@ -188,33 +421,34 @@ void Video2SD(){ outFile.seek(position + jpeg_size - 10); } - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 0xd8, outFile);//riff file size - //Serial.println(movi_size, HEX); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // Serial.println(movi_size, HEX); - //overwrite hdrl + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(max_bytes_per_sec, outFile); - //unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(max_bytes_per_sec, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again + print_quartet(movi_size, outFile); // size again myCAM.CS_HIGH(); - //Close the file + // Close the file outFile.close(); Serial.println("Record video OK"); } -void setup(){ +void setup() +{ uint8_t vid, pid; uint8_t temp; Wire.begin(); @@ -225,46 +459,41 @@ void setup(){ delay(1000); // initialize SPI: SPI.begin(); - //Check if the ArduCAM SPI bus is OK + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println("SPI interface Error!"); - while (1); + while (1) + ; } -//Check if the camera module type is OV5642 + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)) - Serial.println("Can't find OV5642 module!"); - else - Serial.println("OV5642 detected."); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240); - delay(1000); + if ((vid != 0x56) || (pid != 0x42)) + Serial.println("Can't find OV5642 module!"); + else + Serial.println("OV5642 detected."); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD Card Error"); } else Serial.println("SD Card detected!"); } -void loop(){ - +void loop() +{ + Video2SD(); delay(5000); - } - - - - - - diff --git a/ArduCAM/examples/REVC/ArduCAM_REVC_Camera_Playback/ArduCAM_REVC_Camera_Playback.ino b/ArduCAM/examples/REVC/ArduCAM_REVC_Camera_Playback/ArduCAM_REVC_Camera_Playback.ino index 1656a2c6..11e7caba 100644 --- a/ArduCAM/examples/REVC/ArduCAM_REVC_Camera_Playback/ArduCAM_REVC_Camera_Playback.ino +++ b/ArduCAM/examples/REVC/ArduCAM_REVC_Camera_Playback/ArduCAM_REVC_Camera_Playback.ino @@ -2,8 +2,8 @@ // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with a supported camera modules. -//This demo can only work on ARDUCAM_SHIELD_REVC platform. -//This demo is compatible with ESP8266 +// This demo can only work on ARDUCAM_SHIELD_REVC platform. +// This demo is compatible with ESP8266 // This demo was made for Omnivision OV2640/OV5640/OV5642/ sensor. // It will turn the ArduCAM into a real digital camera with capture and playback functions. // 1. Preview the live video on LCD Screen. @@ -20,14 +20,10 @@ #include #include "memorysaver.h" -//This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ -// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ -// OV7725/OV2640/OV5640/OV5642 sensor. -#if !(defined (ARDUCAM_SHIELD_REVC) && (defined MT9D111A_CAM|| defined MT9D111B_CAM || defined MT9M112_CAM \ - || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM \ - || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM \ - || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM \ - || defined OV5642_CAM)) +// This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ +// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ +// OV7725/OV2640/OV5640/OV5642 sensor. +#if !(defined(ARDUCAM_SHIELD_REVC) && (defined MT9D111A_CAM || defined MT9D111B_CAM || defined MT9M112_CAM || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM || defined OV5642_CAM)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif @@ -35,270 +31,296 @@ #include #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif #define BMPIMAGEOFFSET 66 const int bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; -#if defined (MT9D111A_CAM) - ArduCAM myCAM(MT9D111_A, SPI_CS); -#elif defined (MT9D111B_CAM) - ArduCAM myCAM(MT9D111_B, SPI_CS); -#elif defined (MT9M112_CAM) - ArduCAM myCAM(MT9M112, SPI_CS); -#elif defined (MT9V111_CAM) - ArduCAM myCAM(MT9V111, SPI_CS); -#elif defined (MT9M001_CAM) - ArduCAM myCAM(MT9M001, SPI_CS); -#elif defined (MT9T112_CAM) - ArduCAM myCAM(MT9T112, SPI_CS); -#elif defined (MT9D112_CAM) - ArduCAM myCAM(MT9D112, SPI_CS); -#elif defined (OV7670_CAM) - ArduCAM myCAM(OV7670, SPI_CS); -#elif defined (OV7675_CAM) - ArduCAM myCAM(OV7675, SPI_CS); -#elif defined (OV7725_CAM) - ArduCAM myCAM(OV7725, SPI_CS); -#elif defined (OV2640_CAM) + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; +#if defined(MT9D111A_CAM) +ArduCAM myCAM(MT9D111_A, SPI_CS); +#elif defined(MT9D111B_CAM) +ArduCAM myCAM(MT9D111_B, SPI_CS); +#elif defined(MT9M112_CAM) +ArduCAM myCAM(MT9M112, SPI_CS); +#elif defined(MT9V111_CAM) +ArduCAM myCAM(MT9V111, SPI_CS); +#elif defined(MT9M001_CAM) +ArduCAM myCAM(MT9M001, SPI_CS); +#elif defined(MT9T112_CAM) +ArduCAM myCAM(MT9T112, SPI_CS); +#elif defined(MT9D112_CAM) +ArduCAM myCAM(MT9D112, SPI_CS); +#elif defined(OV7670_CAM) +ArduCAM myCAM(OV7670, SPI_CS); +#elif defined(OV7675_CAM) +ArduCAM myCAM(OV7675, SPI_CS); +#elif defined(OV7725_CAM) +ArduCAM myCAM(OV7725, SPI_CS); +#elif defined(OV2640_CAM) ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif UTFT myGLCD(SPI_CS); void setup() { -uint8_t vid = 0, pid = 0; -uint8_t temp = 0; + uint8_t vid = 0, pid = 0; + uint8_t temp = 0; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -// initialize SPI: -SPI.begin(); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + // initialize SPI: + SPI.begin(); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + delay(1000); + continue; } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -//Initialize the LCD Module -myGLCD.InitLCD(); -myCAM.InitCAM(); + // Change MCU mode + myCAM.set_mode(MCU2LCD_MODE); + // Initialize the LCD Module + myGLCD.InitLCD(); + myCAM.InitCAM(); } void loop() { -char str[8]; -unsigned long previous_time = 0; -static int k = 0; -myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM -while (1) -{ - #if defined(ESP8266) - yield(); - #endif - if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) //New Frame is coming - { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)); //Wait for VSYNC is gone - } - else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + char str[8]; + unsigned long previous_time = 0; + static int k = 0; + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (1) { - previous_time = millis(); - while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) +#if defined(ESP8266) + yield(); +#endif + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming { - if ((millis() - previous_time) > 1500) - { - Playback(); - } + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone } - if ((millis() - previous_time) < 1500) + else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { - k = k + 1; - itoa(k, str, 10); - strcat(str, ".bmp"); //Generate file name - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU, freeze the screen - GrabImage(str); + previous_time = millis(); + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + { + if ((millis() - previous_time) > 1500) + { + Playback(); + } + } + if ((millis() - previous_time) < 1500) + { + k = k + 1; + itoa(k, str, 10); + strcat(str, ".bmp"); // Generate file name + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU, freeze the screen + GrabImage(str); + } } } } -} -void GrabImage(char* str) -{ -File outFile; -char VH = 0, VL = 0; -byte buf[256]; -static int k = 0; -int i, j = 0; -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("Open File Error")); - return; -} -//Flush the FIFO -myCAM.flush_fifo(); -//Start capture -myCAM.start_capture(); -Serial.println(F("Start Capture")); -//Polling the capture done flag -while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -Serial.println(F("Capture Done!")); -k = 0; -//Write the BMP header -for ( i = 0; i < BMPIMAGEOFFSET; i++) -{ - char ch = pgm_read_byte(&bmp_header[i]); - buf[k++] = ch; -} -outFile.write(buf, k); -//Read the first dummy byte -myCAM.read_fifo(); -k = 0; -//Read 320x240x2 byte from FIFO -//Save as RGB565 bmp format -for (i = 0; i < 240; i++) -for (j = 0; j < 320; j++) +void GrabImage(char *str) { - VH = myCAM.read_fifo(); - VL = myCAM.read_fifo(); - buf[k++] = VL; - buf[k++] = VH; - #if defined(ESP8266) - yield(); - #endif - //Write image data to bufer if not full - if (k >= 256) + File outFile; + char VH = 0, VL = 0; + byte buf[256]; + static int k = 0; + int i, j = 0; + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) { - //Write 256 bytes image data to file from buffer - outFile.write(buf, 256); - k = 0; + Serial.println(F("Open File Error")); + return; } -} -//Close the file -outFile.close(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Switch to LCD Mode -myCAM.write_reg(ARDUCHIP_TIM, 0); -return; + // Flush the FIFO + myCAM.flush_fifo(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); + // Polling the capture done flag + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done!")); + k = 0; + // Write the BMP header + for (i = 0; i < BMPIMAGEOFFSET; i++) + { + char ch = pgm_read_byte(&bmp_header[i]); + buf[k++] = ch; + } + outFile.write(buf, k); + // Read the first dummy byte + myCAM.read_fifo(); + k = 0; + // Read 320x240x2 byte from FIFO + // Save as RGB565 bmp format + for (i = 0; i < 240; i++) + for (j = 0; j < 320; j++) + { + VH = myCAM.read_fifo(); + VL = myCAM.read_fifo(); + buf[k++] = VL; + buf[k++] = VH; +#if defined(ESP8266) + yield(); +#endif + // Write image data to bufer if not full + if (k >= 256) + { + // Write 256 bytes image data to file from buffer + outFile.write(buf, 256); + k = 0; + } + } + // Close the file + outFile.close(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Switch to LCD Mode + myCAM.write_reg(ARDUCHIP_TIM, 0); + return; } void Playback() { -File inFile; -char str[8]; -int k = 0; -myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU -myGLCD.InitLCD(PORTRAIT); -while (1) -{ - k = k + 1; - itoa(k, str, 10); - strcat(str, ".bmp"); - inFile = SD.open(str, FILE_READ); - if (! inFile) - return; - myGLCD.clrScr(); - //myGLCD.resetXY(); - dispBitmap(inFile); - inFile.close(); - delay(2000); -} + File inFile; + char str[8]; + int k = 0; + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.InitLCD(PORTRAIT); + while (1) + { + k = k + 1; + itoa(k, str, 10); + strcat(str, ".bmp"); + inFile = SD.open(str, FILE_READ); + if (!inFile) + return; + myGLCD.clrScr(); + // myGLCD.resetXY(); + dispBitmap(inFile); + inFile.close(); + delay(2000); + } } -//Only support RGB565 bmp format +// Only support RGB565 bmp format void dispBitmap(File inFile) { char VH = 0, VL = 0; int i = 0, j = 0; - for (i = 0 ; i < BMPIMAGEOFFSET; i++) - inFile.read(); + for (i = 0; i < BMPIMAGEOFFSET; i++) + inFile.read(); for (i = 0; i < 320; i++) - for (j = 0; j < 240; j++) - { - VL = inFile.read(); - //Serial.write(VL); - VH = inFile.read(); - //Serial.write(VH); - #if defined(ESP8266) - yield(); - #endif - myGLCD.LCD_Write_DATA(VH, VL); - } + for (j = 0; j < 240; j++) + { + VL = inFile.read(); + // Serial.write(VL); + VH = inFile.read(); +// Serial.write(VH); +#if defined(ESP8266) + yield(); +#endif + myGLCD.LCD_Write_DATA(VH, VL); + } myGLCD.clrXY(); } - diff --git a/ArduCAM/examples/REVC/ArduCAM_REVC_Capture2SD/ArduCAM_REVC_Capture2SD.ino b/ArduCAM/examples/REVC/ArduCAM_REVC_Capture2SD/ArduCAM_REVC_Capture2SD.ino index cb6f7d9b..5b177e1d 100644 --- a/ArduCAM/examples/REVC/ArduCAM_REVC_Capture2SD/ArduCAM_REVC_Capture2SD.ino +++ b/ArduCAM/examples/REVC/ArduCAM_REVC_Capture2SD/ArduCAM_REVC_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM 2MP/5MP as a real 2MP/5MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_REVC @@ -17,191 +17,221 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_REVC platform. -#if !(defined (ARDUCAM_SHIELD_REVC)&&(defined (OV5642_CAM)||defined (OV2640_CAM)||defined (OV5640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_REVC platform. +#if !(defined(ARDUCAM_SHIELD_REVC) && (defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h outFile #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif -#if defined (OV2640_CAM) - ArduCAM myCAM( OV2640, SPI_CS ); -#elif defined (OV5640_CAM) - ArduCAM myCAM( OV5640, SPI_CS ); -#elif defined (OV5642_CAM) - ArduCAM myCAM( OV5642, SPI_CS ); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif -void myCAMSaveToSDFile(){ -char str[8]; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -bool is_header = false; -File outFile; -//Flush the FIFO -myCAM.flush_fifo(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Start capture -myCAM.start_capture(); -Serial.println(F("start Capture.")); -while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) +void myCAMSaveToSDFile() { - Serial.println(F("Over size.")); - return ; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return ; -} -//Construct a outFile name -k = k + 1; -itoa(k, str, 10); -strcat(str, ".jpg"); -//Open the new outFile -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if(! outFile){ - Serial.println(F("File open faild")); - return; -} -i = 0; -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -//Read JPEG data from FIFO -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + char str[8]; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + bool is_header = false; + File outFile; + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("start Capture.")); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image Save Done!")); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return; + } + // Construct a outFile name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new outFile + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open faild")); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + // Read JPEG data from FIFO + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image Save Done!")); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } } -} -void setup(){ -uint8_t vid = 0, pid = 0; -uint8_t temp = 0; -Wire.begin(); -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -//set the CS as an output: -pinMode(SPI_CS,OUTPUT); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) +void setup() +{ + uint8_t vid = 0, pid = 0; + uint8_t temp = 0; + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + while (1) { - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); -#if defined (OV2640_CAM) -while(1){ - //Check if the camera module type is OV2640 - myCAM.wrSensorReg8_8(0xff, 0x01); - myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 + myCAM.wrSensorReg8_8(0xff, 0x01); + myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + Serial.println(F("Can't find OV2640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } } -} -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!"); delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_CAM) -myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); -#elif defined (OV5640_CAM) -myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); -#elif defined (OV5642_CAM) -myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); +#elif defined(OV5642_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -delay(1000); + delay(1000); } -void loop(){ -myCAMSaveToSDFile(); -delay(5000); +void loop() +{ + myCAMSaveToSDFile(); + delay(5000); } - - diff --git a/ArduCAM/examples/REVC/ArduCAM_REVC_Digital_Camera/ArduCAM_REVC_Digital_Camera.ino b/ArduCAM/examples/REVC/ArduCAM_REVC_Digital_Camera/ArduCAM_REVC_Digital_Camera.ino index 64549492..94df08dd 100644 --- a/ArduCAM/examples/REVC/ArduCAM_REVC_Digital_Camera/ArduCAM_REVC_Digital_Camera.ino +++ b/ArduCAM/examples/REVC/ArduCAM_REVC_Digital_Camera/ArduCAM_REVC_Digital_Camera.ino @@ -2,12 +2,12 @@ // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with a supported camera modules//This demo can only work on ARDUCAM_SHIELD_REVC platform. -//This demo is compatible with ESP8266 +// This demo is compatible with ESP8266 // It will run the ArduCAM as a real 2MP/5MP digital camera, provide both preview and JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to BMP preview output mode. // 2. Switch to JPEG mode when shutter buttom pressed. -// 3. Capture and buffer the image to FIFO. +// 3. Capture and buffer the image to FIFO. // 4. Store the image to Micro SD/TF card with JPEG format. // 5. Resolution can be changed by myCAM.OV5642_set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_REVC @@ -19,260 +19,283 @@ #include #include #include "memorysaver.h" -//This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ -// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ -// OV7725/OV2640/OV5640/OV5642 sensor. -#if !(defined (ARDUCAM_SHIELD_REVC) && (defined MT9D111A_CAM|| defined MT9D111B_CAM || defined MT9M112_CAM \ - || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM \ - || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM \ - || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM \ - || defined OV5642_CAM)) +// This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ +// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ +// OV7725/OV2640/OV5640/OV5642 sensor. +#if !(defined(ARDUCAM_SHIELD_REVC) && (defined MT9D111A_CAM || defined MT9D111B_CAM || defined MT9M112_CAM || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM || defined OV5642_CAM)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(__arm__) - #include +#include #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif -#if defined (MT9D111A_CAM) - ArduCAM myCAM(MT9D111_A, SPI_CS); -#elif defined (MT9D111B_CAM) - ArduCAM myCAM(MT9D111_B, SPI_CS); -#elif defined (MT9M112_CAM) - ArduCAM myCAM(MT9M112, SPI_CS); -#elif defined (MT9V111_CAM) - ArduCAM myCAM(MT9V111, SPI_CS); -#elif defined (MT9M001_CAM) - ArduCAM myCAM(MT9M001, SPI_CS); -#elif defined (MT9T112_CAM) - ArduCAM myCAM(MT9T112, SPI_CS); -#elif defined (MT9D112_CAM) - ArduCAM myCAM(MT9D112, SPI_CS); -#elif defined (OV7670_CAM) - ArduCAM myCAM(OV7670, SPI_CS); -#elif defined (OV7675_CAM) - ArduCAM myCAM(OV7675, SPI_CS); -#elif defined (OV7725_CAM) - ArduCAM myCAM(OV7725, SPI_CS); -#elif defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(MT9D111A_CAM) +ArduCAM myCAM(MT9D111_A, SPI_CS); +#elif defined(MT9D111B_CAM) +ArduCAM myCAM(MT9D111_B, SPI_CS); +#elif defined(MT9M112_CAM) +ArduCAM myCAM(MT9M112, SPI_CS); +#elif defined(MT9V111_CAM) +ArduCAM myCAM(MT9V111, SPI_CS); +#elif defined(MT9M001_CAM) +ArduCAM myCAM(MT9M001, SPI_CS); +#elif defined(MT9T112_CAM) +ArduCAM myCAM(MT9T112, SPI_CS); +#elif defined(MT9D112_CAM) +ArduCAM myCAM(MT9D112, SPI_CS); +#elif defined(OV7670_CAM) +ArduCAM myCAM(OV7670, SPI_CS); +#elif defined(OV7675_CAM) +ArduCAM myCAM(OV7675, SPI_CS); +#elif defined(OV7725_CAM) +ArduCAM myCAM(OV7725, SPI_CS); +#elif defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif UTFT myGLCD(SPI_CS); boolean isShowFlag = true; bool is_header = false; void setup() { -uint8_t vid = 0, pid = 0; -uint8_t temp = 0; + uint8_t vid = 0, pid = 0; + uint8_t temp = 0; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -// initialize SPI: -SPI.begin(); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + // initialize SPI: + SPI.begin(); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -myGLCD.InitLCD(); -//Change to BMP capture mode and initialize the OV5642 module -myCAM.set_format(BMP); -myCAM.InitCAM(); -} -void loop() -{ -char str[8]; -File outFile; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0,temp_last = 0; -uint8_t start_capture = 0; -uint32_t length = 0; -int total_time = 0; -//Wait trigger from shutter buttom -if(myCAM.get_bit(ARDUCHIP_TRIG , SHUTTER_MASK)) -{ - isShowFlag = false; + // Change MCU mode myCAM.set_mode(MCU2LCD_MODE); - myCAM.set_format(JPEG); + myGLCD.InitLCD(); + // Change to BMP capture mode and initialize the OV5642 module + myCAM.set_format(BMP); myCAM.InitCAM(); - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - #elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - #endif - //Wait until buttom released - while(myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)); - delay(1000); - start_capture = 1; } -else +void loop() { - if(isShowFlag ) + char str[8]; + File outFile; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint8_t start_capture = 0; + uint32_t length = 0; + int total_time = 0; + // Wait trigger from shutter buttom + if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { - if(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)) //New Frame is coming + isShowFlag = false; + myCAM.set_mode(MCU2LCD_MODE); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#endif + // Wait until buttom released + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + ; + delay(1000); + start_capture = 1; + } + else + { + if (isShowFlag) { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)); //Wait for VSYNC is gone + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming + { + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone + } } } -} -if(start_capture) -{ - //Flush the FIFO - myCAM.flush_fifo(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - Serial.println(F("Start Capture")); -} -if(myCAM.get_bit(ARDUCHIP_TRIG ,CAP_DONE_MASK)) -{ - Serial.println(F("Capture Done.")); - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str,".jpg"); - //Open the new file - outFile = SD.open(str,O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) - { - Serial.println(F("File open failed")); - return; - } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - while ( length-- ) + if (start_capture) { - #if defined (ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + Serial.println(F("Capture Done.")); + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open failed")); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - //Clear the capture done flag - myCAM.clear_fifo_flag(); - //Clear the start capture flag - start_capture = 0; - myCAM.set_format(BMP); - myCAM.InitCAM(); - isShowFlag = true; -} + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Clear the start capture flag + start_capture = 0; + myCAM.set_format(BMP); + myCAM.InitCAM(); + isShowFlag = true; + } } - - - - diff --git a/ArduCAM/examples/REVC/ArduCAM_REVC_Video2SD/ArduCAM_REVC_Video2SD.ino b/ArduCAM/examples/REVC/ArduCAM_REVC_Video2SD/ArduCAM_REVC_Video2SD.ino index 00a44dd2..27e3a05d 100644 --- a/ArduCAM/examples/REVC/ArduCAM_REVC_Video2SD/ArduCAM_REVC_Video2SD.ino +++ b/ArduCAM/examples/REVC/ArduCAM_REVC_Video2SD/ArduCAM_REVC_Video2SD.ino @@ -3,7 +3,7 @@ // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini camera, and can run on any Arduino platform. // This demo was made for ARDUCAM_SHIELD_REVC -//This demo timed 5 seconds to record video. +// This demo timed 5 seconds to record video. // It can shoot video and store it into the SD card // The demo sketch will do the following tasks // 1. Set the camera to JPEG output mode. @@ -12,16 +12,16 @@ // 4.Write the video data to the SD card // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_REVC // and use Arduino IDE 1.6.8 compiler or above @@ -31,8 +31,8 @@ #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_REVC platform. -#if !(defined (ARDUCAM_SHIELD_REVC)&&(defined (OV5642_CAM)||defined (OV2640_CAM)||defined (OV5640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_REVC platform. +#if !(defined(ARDUCAM_SHIELD_REVC) && (defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif @@ -42,260 +42,517 @@ const int SPI_CS = 10; // set the num of picture #define pic_num 200 -#if defined (OV2640_CAM) - ArduCAM myCAM( OV2640, SPI_CS ); -#elif defined (OV5640_CAM) - ArduCAM myCAM( OV5640, SPI_CS ); -#elif defined (OV5642_CAM) - ArduCAM myCAM( OV5642, SPI_CS ); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif #define AVIOFFSET 240 unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const int avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const int avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); -} -void Video2SD(){ -char str[8]; -File outFile; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0, temp_last = 0; -unsigned long position = 0; -uint16_t frame_cnt = 0; -uint8_t remnant = 0; -uint32_t length = 0; -bool is_header = false; -//Create a avi file -k = k + 1; -itoa(k, str, 10); -strcat(str, ".avi"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("File open failed")); - while (1); - return; -} -//Write AVI Header -for ( i = 0; i < AVIOFFSET; i++) +void print_quartet(unsigned long i, File fd) { - char ch = pgm_read_byte(&avi_header[i]); - buf[i] = ch; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); } -outFile.write(buf, AVIOFFSET); -//Write video data -Serial.println(F("Recording video, please wait...")); -for ( frame_cnt = 0; frame_cnt < pic_num; frame_cnt ++) +void Video2SD() { - #if defined (ESP8266) - yield(); - #endif - temp_last = 0;temp = 0; - //Capture a frame - //Flush the FIFO - myCAM.flush_fifo(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - length = myCAM.read_fifo_length(); - outFile.write("00dc"); - outFile.write(zero_buf, 4); - i = 0; - jpeg_size = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - while ( length-- ) + char str[8]; + File outFile; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + unsigned long position = 0; + uint16_t frame_cnt = 0; + uint8_t remnant = 0; + uint32_t length = 0; + bool is_header = false; + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".avi"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) { - #if defined (ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + Serial.println(F("File open failed")); + while (1) + ; + return; + } + // Write AVI Header + for (i = 0; i < AVIOFFSET; i++) + { + char ch = pgm_read_byte(&avi_header[i]); + buf[i] = ch; + } + outFile.write(buf, AVIOFFSET); + // Write video data + Serial.println(F("Recording video, please wait...")); + for (frame_cnt = 0; frame_cnt < pic_num; frame_cnt++) + { +#if defined(ESP8266) + yield(); +#endif + temp_last = 0; + temp = 0; + // Capture a frame + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + outFile.write("00dc"); + outFile.write(zero_buf, 4); + i = 0; + jpeg_size = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - is_header = false; - jpeg_size += i; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + is_header = false; + jpeg_size += i; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + jpeg_size += 256; + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - jpeg_size += 256; - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } + remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; + jpeg_size = jpeg_size + remnant; + movi_size = movi_size + jpeg_size; + if (remnant > 0) + outFile.write(zero_buf, remnant); + position = outFile.position(); + outFile.seek(position - 4 - jpeg_size); + print_quartet(jpeg_size, outFile); + position = outFile.position(); + outFile.seek(position + 6); + outFile.write("AVI1", 4); + position = outFile.position(); + outFile.seek(position + jpeg_size - 10); } - remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; - jpeg_size = jpeg_size + remnant; - movi_size = movi_size + jpeg_size; - if (remnant > 0) - outFile.write(zero_buf, remnant); - position = outFile.position(); - outFile.seek(position - 4 - jpeg_size); - print_quartet(jpeg_size, outFile); - position = outFile.position(); - outFile.seek(position + 6); - outFile.write("AVI1", 4); - position = outFile.position(); - outFile.seek(position + jpeg_size - 10); -} -//Modify the MJPEG header from the beginning of the file -outFile.seek(4); -print_quartet(movi_size + 0xd8, outFile);//riff file size -//overwrite hdrl -unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame -outFile.seek(0x20); -print_quartet(us_per_frame, outFile); -unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec -outFile.seek(0x24); -print_quartet(max_bytes_per_sec, outFile); -//unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames -outFile.seek(0x30); -print_quartet(max_bytes_per_sec, outFile); -//unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames -outFile.seek(0xe0); -print_quartet(max_bytes_per_sec, outFile); -outFile.seek(0xe8); -print_quartet(movi_size, outFile);// size again -myCAM.CS_HIGH(); -//Close the file -outFile.close(); -Serial.println(F("Record video OK")); + // Modify the MJPEG header from the beginning of the file + outFile.seek(4); + print_quartet(movi_size + 0xd8, outFile); // riff file size + // overwrite hdrl + unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame + outFile.seek(0x20); + print_quartet(us_per_frame, outFile); + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec + outFile.seek(0x24); + print_quartet(max_bytes_per_sec, outFile); + // unsigned long tot_frames = framecnt; //hdrl.avih.tot_frames + outFile.seek(0x30); + print_quartet(max_bytes_per_sec, outFile); + // unsigned long frames =framecnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames + outFile.seek(0xe0); + print_quartet(max_bytes_per_sec, outFile); + outFile.seek(0xe8); + print_quartet(movi_size, outFile); // size again + myCAM.CS_HIGH(); + // Close the file + outFile.close(); + Serial.println(F("Record video OK")); } -void setup(){ -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -delay(1000); -// initialize SPI: -SPI.begin(); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + delay(1000); + // initialize SPI: + SPI.begin(); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); -#if defined (OV2640_CAM) -while(1){ - //Check if the camera module type is OV2640 - myCAM.wrSensorReg8_8(0xff, 0x01); - myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); } -} -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 + Serial.println(F("SD Card detected.")); +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 + myCAM.wrSensorReg8_8(0xff, 0x01); + myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + Serial.println(F("Can't find OV2640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!"); delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_CAM) -myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); -#elif defined (OV5640_CAM) -myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); -#elif defined (OV5642_CAM) -myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); +#elif defined(OV5642_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -delay(1000); + delay(1000); } -void loop(){ +void loop() +{ Video2SD(); delay(5000); } - - - - - - diff --git a/ArduCAM/examples/REVC/ArduCAM_REVC_Video_Streaming/ArduCAM_REVC_Video_Streaming.ino b/ArduCAM/examples/REVC/ArduCAM_REVC_Video_Streaming/ArduCAM_REVC_Video_Streaming.ino index 4504ef3a..0972ebad 100644 --- a/ArduCAM/examples/REVC/ArduCAM_REVC_Video_Streaming/ArduCAM_REVC_Video_Streaming.ino +++ b/ArduCAM/examples/REVC/ArduCAM_REVC_Video_Streaming/ArduCAM_REVC_Video_Streaming.ino @@ -21,32 +21,33 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_REVC platform. -#if !(defined (ARDUCAM_SHIELD_REVC)&&(defined (OV5642_CAM)||defined (OV2640_CAM)||defined (OV5640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_REVC platform. +#if !(defined(ARDUCAM_SHIELD_REVC) && (defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV5640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 #if defined(ESP8266) - const int SPI_CS = 16; -#else - const int SPI_CS =10; +const int SPI_CS = 16; +#else +const int SPI_CS = 10; #endif bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -54,337 +55,380 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start!")); -// set the CS as an output: -pinMode(SPI_CS, OUTPUT); -// initialize SPI: -SPI.begin(); -//Check if the ArduCAM SPI bus is OK -while(1){ - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55) + Serial.println(F("ACK CMD ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + // initialize SPI: + SPI.begin(); + // Check if the ArduCAM SPI bus is OK + while (1) { - Serial.println(F("ACK CMD SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK.")); break; + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error!")); + delay(1000); + continue; } -} -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 + else + { + Serial.println(F("ACK CMD SPI interface OK.")); + break; + } + } +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV2640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected.")); + break; } } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5640 +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5640 myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module!")); - delay(1000); continue; - }else{ - Serial.println(F("ACK CMD OV5642 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected.")); + break; + } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV5642_CAM) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV5642_CAM) yCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); #endif -#if defined (OV5640_CAM) +#if defined(OV5640_CAM) myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); #endif -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp =0xff, temp_last =0x00; -bool is_header = false; -if (Serial.available()) +void loop() { - #if defined(ESP8266) - yield(); - #endif - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0x00; + bool is_header = false; + if (Serial.available()) { +#if defined(ESP8266) + yield(); +#endif + temp = Serial.read(); + switch (temp) + { case 0: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_320x240")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_320x240); Serial.println(F("ACK CMD switch to OV5642_320x240")); - #endif - break; +#endif + break; case 1: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_352x288);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_352x288")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_640x480); Serial.println(F("ACK CMD switch to OV5642_640x480")); - #endif - break; +#endif + break; case 2: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_640x480);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_640x480")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_1280x960); Serial.println(F("ACK CMD switch to OV5642_1280x960")); - #endif - break; +#endif + break; case 3: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_800x480);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_800x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_800x480")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); Serial.println(F("ACK CMD switch to OV5642_1600x1200")); - #endif - break; +#endif + break; case 4: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_1024x768);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1024x768")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); Serial.println(F("ACK CMD switch to OV5642_2048x1536")); - #endif - break; +#endif + break; case 5: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_1280x960);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1280x960")); - #elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944")); - #endif - break; - #if (defined (OV5640_CAM)||defined (OV2640_CAM)) +#endif + break; +#if (defined(OV5640_CAM) || defined(OV2640_CAM)) case 6: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768")); - #else - myCAM.OV5640_set_JPEG_size(OV5640_1600x1200);delay(1000); +#else + myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1600x1200")); - #endif - break; +#endif + break; case 7: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024")); - #else - myCAM.OV5640_set_JPEG_size(OV5640_2048x1536);delay(1000); +#else + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2048x1536")) - #endif - break; +#endif + break; case 8: - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200")); - #else - myCAM.OV5640_set_JPEG_size(OV5640_2592x1944);delay(1000); +#else + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2592x1944")) - #endif - break; - #endif +#endif + break; +#endif case 0x10: - mode = 1; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot.")); - break; + mode = 1; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot.")); + break; case 0x11: - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - break; + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + break; case 0x20: - mode = 2; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming.")); - break; + mode = 2; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming.")); + break; case 0x30: - mode = 3; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot.")); - break; + mode = 3; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot.")); + break; default: - break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done!")); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - #if defined(ESP8266) - yield(); - #endif - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming!")); break; } - if (start_capture == 2) + } + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) - { + Serial.println(F("ACK CMD CAM Capture Done!")); + read_fifo_burst(myCAM); + // Clear the capture done flag myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + } + } + else if (mode == 2) + { + while (1) + { +#if defined(ESP8266) + yield(); +#endif + temp = Serial.read(); + if (temp == 0x21) + { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming!")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - #if defined(ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.write(temp_last); - Serial.write(temp); +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { -uint8_t temp, temp_last; -uint32_t length = 0; -length = myCAM.read_fifo_length(); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //512 kb -{ - Serial.println(F("Over size.")); - return 0; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return 0; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -temp = SPI.transfer(0x00); -length --; -while ( length-- ) -{ - #if defined(ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 512 kb { - Serial.write(temp); + Serial.println(F("Over size.")); + return 0; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + if (length == 0) // 0 kb { - is_header = true; - Serial.println(F("ACK IMG")); - Serial.write(temp_last); - Serial.write(temp); + Serial.println(F("Size is 0.")); + return 0; } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); -} -myCAM.CS_HIGH(); -is_header = false; -return 1; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) + { +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); + } + myCAM.CS_HIGH(); + is_header = false; + return 1; } diff --git a/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.c b/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.c index 6fc5f1b1..a93bd9b7 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.c +++ b/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.c @@ -18,16 +18,15 @@ #include #include "arducam_arch_raspberrypi.h" - -#define SPI_ARDUCAM_SPEED 1000000 -#define SPI_ARDUCAM 0 +#define SPI_ARDUCAM_SPEED 1000000 +#define SPI_ARDUCAM 0 static int FD; bool wiring_init(void) { wiringPiSetup(); - int spi = wiringPiSPISetup(SPI_ARDUCAM, SPI_ARDUCAM_SPEED); + int spi = wiringPiSPISetup(SPI_ARDUCAM, SPI_ARDUCAM_SPEED); return spi != -1; } bool arducam_i2c_init(uint8_t sensor_addr) @@ -37,111 +36,109 @@ bool arducam_i2c_init(uint8_t sensor_addr) } void arducam_delay_ms(uint32_t delay) { - usleep(1000*delay); + usleep(1000 * delay); } void arducam_spi_write(uint8_t address, uint8_t value) { - uint8_t spiData [2] ; - spiData [0] = address ; - spiData [1] = value ; - wiringPiSPIDataRW (SPI_ARDUCAM, spiData, 2) ; + uint8_t spiData[2]; + spiData[0] = address; + spiData[1] = value; + wiringPiSPIDataRW(SPI_ARDUCAM, spiData, 2); } - uint8_t arducam_spi_read(uint8_t address) { uint8_t spiData[2]; - spiData[0] = address ; - spiData[1] = 0x00 ; - wiringPiSPIDataRW (SPI_ARDUCAM, spiData, 2) ; - return spiData[1]; + spiData[0] = address; + spiData[1] = 0x00; + wiringPiSPIDataRW(SPI_ARDUCAM, spiData, 2); + return spiData[1]; } - void arducam_spi_transfers(uint8_t *buf, uint32_t size) { - wiringPiSPIDataRW (SPI_ARDUCAM, buf, size) ; + wiringPiSPIDataRW(SPI_ARDUCAM, buf, size); } uint8_t arducam_spi_transfer(uint8_t data) { - uint8_t spiData [1] ; - spiData [0] = data ; - wiringPiSPIDataRW (SPI_ARDUCAM, spiData, 1) ; - return spiData [0]; + uint8_t spiData[1]; + spiData[0] = data; + wiringPiSPIDataRW(SPI_ARDUCAM, spiData, 1); + return spiData[0]; } uint8_t arducam_i2c_write(uint8_t regID, uint8_t regDat) { - if(FD != -1) + if (FD != -1) { - wiringPiI2CWriteReg8(FD,regID,regDat); - return(1); + wiringPiI2CWriteReg8(FD, regID, regDat); + return (1); } return 0; } -uint8_t arducam_i2c_read(uint8_t regID, uint8_t* regDat) +uint8_t arducam_i2c_read(uint8_t regID, uint8_t *regDat) { - if(FD != -1) + if (FD != -1) { - *regDat = wiringPiI2CReadReg8(FD,regID); - return(1); + *regDat = wiringPiI2CReadReg8(FD, regID); + return (1); } return 0; } uint8_t arducam_i2c_write16(uint8_t regID, uint16_t regDat) { - if(FD != -1) + if (FD != -1) { - wiringPiI2CWriteReg16(FD,regID,regDat); - - return(1); + wiringPiI2CWriteReg16(FD, regID, regDat); + + return (1); } return 0; } -uint8_t arducam_i2c_read16(uint8_t regID, uint16_t* regDat) +uint8_t arducam_i2c_read16(uint8_t regID, uint16_t *regDat) { - if(FD != -1) + if (FD != -1) { - *regDat = wiringPiI2CReadReg16(FD,regID); - return(1); + *regDat = wiringPiI2CReadReg16(FD, regID); + return (1); } return 0; } uint8_t arducam_i2c_word_write(uint16_t regID, uint8_t regDat) { - uint8_t reg_H,reg_L; + uint8_t reg_H, reg_L; uint16_t value; reg_H = (regID >> 8) & 0x00ff; reg_L = regID & 0x00ff; - value = regDat << 8 | reg_L; - if(FD != -1) + value = regDat << 8 | reg_L; + if (FD != -1) { i2c_smbus_write_word_data(FD, reg_H, value); arducam_delay_ms(1); - return(1); + return (1); } return 0; } -uint8_t arducam_i2c_word_read(uint16_t regID, uint8_t* regDat) +uint8_t arducam_i2c_word_read(uint16_t regID, uint8_t *regDat) { - uint8_t reg_H,reg_L; + uint8_t reg_H, reg_L; int r; reg_H = (regID >> 8) & 0x00ff; reg_L = regID & 0x00ff; - if(FD != -1) + if (FD != -1) { - r = i2c_smbus_write_byte_data(FD,reg_H,reg_L); - if(r<0) + r = i2c_smbus_write_byte_data(FD, reg_H, reg_L); + if (r < 0) return 0; *regDat = i2c_smbus_read_byte(FD); - return(1); + return (1); } return 0; } @@ -154,36 +151,37 @@ int arducam_i2c_write_regs(const struct sensor_reg reglist[]) while ((reg_addr != 0xff) | (reg_val != 0xff)) { - //reg_addr = pgm_read_word(&next->reg); - //reg_val = pgm_read_word(&next->val); + // reg_addr = pgm_read_word(&next->reg); + // reg_val = pgm_read_word(&next->val); reg_addr = next->reg; reg_val = next->val; - if (!arducam_i2c_write(reg_addr, reg_val)) { + if (!arducam_i2c_write(reg_addr, reg_val)) + { return 0; } - next++; + next++; } return 1; } - int arducam_i2c_write_regs16(const struct sensor_reg reglist[]) { - unsigned int reg_addr,reg_val; + unsigned int reg_addr, reg_val; const struct sensor_reg *next = reglist; while ((reg_addr != 0xff) | (reg_val != 0xffff)) { - //reg_addr = pgm_read_word(&next->reg); - //reg_val = pgm_read_word(&next->val); + // reg_addr = pgm_read_word(&next->reg); + // reg_val = pgm_read_word(&next->val); reg_addr = next->reg; reg_val = next->val; - if (!arducam_i2c_write16(reg_addr, reg_val)) { + if (!arducam_i2c_write16(reg_addr, reg_val)) + { return 0; } - next++; - arducam_delay_ms(1); + next++; + arducam_delay_ms(1); } return 1; @@ -191,24 +189,24 @@ int arducam_i2c_write_regs16(const struct sensor_reg reglist[]) int arducam_i2c_write_word_regs(const struct sensor_reg reglist[]) { - unsigned int reg_addr,reg_val; + unsigned int reg_addr, reg_val; const struct sensor_reg *next = reglist; while ((reg_addr != 0xffff) | (reg_val != 0xff)) { - //reg_addr = pgm_read_word(&next->reg); - //reg_val = pgm_read_word(&next->val); - reg_addr = next->reg; - reg_val = next->val; - //if (!arducam_i2c_write16(reg_addr, reg_val)) - - //My changed + // reg_addr = pgm_read_word(&next->reg); + // reg_val = pgm_read_word(&next->val); + reg_addr = next->reg; + reg_val = next->val; + // if (!arducam_i2c_write16(reg_addr, reg_val)) + + // My changed if (!arducam_i2c_word_write(reg_addr, reg_val)) - { + { return 0; } - next++; - arducam_delay_ms(1); + next++; + arducam_delay_ms(1); } return 1; diff --git a/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.h b/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.h index 5e93d4ff..2caa2e37 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.h +++ b/ArduCAM/examples/RaspberryPi/arducam_arch_raspberrypi.h @@ -1,6 +1,5 @@ - /*----------------------------------------- //Update History: @@ -12,43 +11,43 @@ #define __ARDUCAM_ARCH_H__ #include "ArduCAM.h" #ifdef __cplusplus -extern "C" { +extern "C" +{ #endif -extern bool wiring_init(void); -extern bool arducam_i2c_init(uint8_t sensor_addr); -extern void arducam_spi_write(uint8_t address, uint8_t value); -extern uint8_t arducam_spi_read(uint8_t address); - -extern uint8_t arducam_spi_transfer(uint8_t data); -extern void arducam_spi_transfers(uint8_t *buf, uint32_t size); + extern bool wiring_init(void); + extern bool arducam_i2c_init(uint8_t sensor_addr); + extern void arducam_spi_write(uint8_t address, uint8_t value); + extern uint8_t arducam_spi_read(uint8_t address); + extern uint8_t arducam_spi_transfer(uint8_t data); + extern void arducam_spi_transfers(uint8_t *buf, uint32_t size); -// Delay execution for delay milliseconds -extern void arducam_delay_ms(uint32_t delay); + // Delay execution for delay milliseconds + extern void arducam_delay_ms(uint32_t delay); -// Read/write 8 bit value to/from 8 bit register address -extern uint8_t arducam_i2c_write(uint8_t regID, uint8_t regDat); -extern uint8_t arducam_i2c_read(uint8_t regID, uint8_t* regDat); + // Read/write 8 bit value to/from 8 bit register address + extern uint8_t arducam_i2c_write(uint8_t regID, uint8_t regDat); + extern uint8_t arducam_i2c_read(uint8_t regID, uint8_t *regDat); -// Read/write 16 bit value to/from 8 bit register address -extern uint8_t arducam_i2c_write16(uint8_t regID, uint16_t regDat); -extern uint8_t arducam_i2c_read16(uint8_t regID, uint16_t* regDat); + // Read/write 16 bit value to/from 8 bit register address + extern uint8_t arducam_i2c_write16(uint8_t regID, uint16_t regDat); + extern uint8_t arducam_i2c_read16(uint8_t regID, uint16_t *regDat); -// Read/write 8 bit value to/from 16 bit register address -extern uint8_t arducam_i2c_word_write(uint16_t regID, uint8_t regDat); -extern uint8_t arducam_i2c_word_read(uint16_t regID, uint8_t* regDat); + // Read/write 8 bit value to/from 16 bit register address + extern uint8_t arducam_i2c_word_write(uint16_t regID, uint8_t regDat); + extern uint8_t arducam_i2c_word_read(uint16_t regID, uint8_t *regDat); -// Write 8 bit values to 8 bit register address -extern int arducam_i2c_write_regs(const struct sensor_reg reglist[]); + // Write 8 bit values to 8 bit register address + extern int arducam_i2c_write_regs(const struct sensor_reg reglist[]); -// Write 16 bit values to 8 bit register address -extern int arducam_i2c_write_regs16(const struct sensor_reg reglist[]); + // Write 16 bit values to 8 bit register address + extern int arducam_i2c_write_regs16(const struct sensor_reg reglist[]); -// Write 8 bit values to 16 bit register address -extern int arducam_i2c_write_word_regs(const struct sensor_reg reglist[]); + // Write 8 bit values to 16 bit register address + extern int arducam_i2c_write_word_regs(const struct sensor_reg reglist[]); #ifdef __cplusplus } #endif -#endif +#endif diff --git a/ArduCAM/examples/RaspberryPi/arducam_ov2640_4cams_capture.cpp b/ArduCAM/examples/RaspberryPi/arducam_ov2640_4cams_capture.cpp index 25f38537..6b63306e 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_ov2640_4cams_capture.cpp +++ b/ArduCAM/examples/RaspberryPi/arducam_ov2640_4cams_capture.cpp @@ -5,7 +5,6 @@ --------------------------------------*/ - #include #include #include @@ -16,9 +15,9 @@ #include #include #include "arducam_arch_raspberrypi.h" -#define OV2640_CHIPID_HIGH 0x0A -#define OV2640_CHIPID_LOW 0x0B -#define OV2640_MAX_FIFO_SIZE 0x5FFFF //384KByte +#define OV2640_CHIPID_HIGH 0x0A +#define OV2640_CHIPID_LOW 0x0B +#define OV2640_MAX_FIFO_SIZE 0x5FFFF // 384KByte #define BUF_SIZE 4096 #define CAM1_CS 0 #define CAM2_CS 4 @@ -27,368 +26,406 @@ uint8_t buf[BUF_SIZE]; bool is_header = false; -ArduCAM myCAM1(OV2640,CAM1_CS); -ArduCAM myCAM2(OV2640,CAM2_CS); -ArduCAM myCAM3(OV2640,CAM3_CS); -ArduCAM myCAM4(OV2640,CAM4_CS); +ArduCAM myCAM1(OV2640, CAM1_CS); +ArduCAM myCAM2(OV2640, CAM2_CS); +ArduCAM myCAM3(OV2640, CAM3_CS); +ArduCAM myCAM4(OV2640, CAM4_CS); void setup() { - uint8_t vid,pid; - uint8_t temp; - wiring_init(); - pinMode(CAM1_CS, OUTPUT); - pinMode(CAM2_CS, OUTPUT); - pinMode(CAM3_CS, OUTPUT); - pinMode(CAM4_CS, OUTPUT); - // Check if the ArduCAM SPI1 bus is OK - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI1 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI2 bus is OK - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); //debug - if(temp != 0x55) { - printf("SPI2 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI3 bus is OK - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI3 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI4 bus is OK - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI4 interface error!\n"); - exit(EXIT_FAILURE); - } - - // Change MCU mode - myCAM1.write_reg(ARDUCHIP_MODE, 0x00); - myCAM2.write_reg(ARDUCHIP_MODE, 0x00); - myCAM3.write_reg(ARDUCHIP_MODE, 0x00); - myCAM4.write_reg(ARDUCHIP_MODE, 0x00); - // Check if the camera module type is OV2640 - myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - printf("Can't find OV2640 module!\n"); - exit(EXIT_FAILURE); - } else { - printf("OV2640 detected\n"); - } + uint8_t vid, pid; + uint8_t temp; + wiring_init(); + pinMode(CAM1_CS, OUTPUT); + pinMode(CAM2_CS, OUTPUT); + pinMode(CAM3_CS, OUTPUT); + pinMode(CAM4_CS, OUTPUT); + // Check if the ArduCAM SPI1 bus is OK + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI1 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI2 bus is OK + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); //debug + if (temp != 0x55) + { + printf("SPI2 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI3 bus is OK + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI3 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI4 bus is OK + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI4 interface error!\n"); + exit(EXIT_FAILURE); + } + + // Change MCU mode + myCAM1.write_reg(ARDUCHIP_MODE, 0x00); + myCAM2.write_reg(ARDUCHIP_MODE, 0x00); + myCAM3.write_reg(ARDUCHIP_MODE, 0x00); + myCAM4.write_reg(ARDUCHIP_MODE, 0x00); + // Check if the camera module type is OV2640 + myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + printf("Can't find OV2640 module!\n"); + exit(EXIT_FAILURE); + } + else + { + printf("OV2640 detected\n"); + } } int main(int argc, char *argv[]) -{ +{ uint8_t temp = 0, temp_last = 0; - if (argc == 1) { - printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); - printf(" 160x120\n"); - printf(" 176x144\n"); - printf(" 320x240\n"); - printf(" 352x288\n"); - printf(" 640x480\n"); - printf(" 800x600\n"); - printf(" 1024x768\n"); - printf(" 1280x960\n"); - printf(" 1600x1200\n"); - printf(" -c Capture image\n"); - exit(EXIT_SUCCESS); - } - - if (strcmp(argv[1], "-c") == 0 && argc == 7) { - setup(); - myCAM1.set_format(JPEG); - myCAM1.InitCAM(); - // Change to JPEG capture mode and initialize the OV2640 module - if (strcmp(argv[6], "160x120") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_160x120); - else if (strcmp(argv[6], "176x144") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_176x144); - else if (strcmp(argv[6], "320x240") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_320x240); - else if (strcmp(argv[6], "352x288") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_352x288); - else if (strcmp(argv[6], "640x480") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_640x480); - else if (strcmp(argv[6], "800x600") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_800x600); - else if (strcmp(argv[6], "1024x768") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_1024x768); - else if (strcmp(argv[6], "1280x960") == 0) myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024); - else if (strcmp(argv[6], "1600x1200")== 0) myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200); - else { - printf("Unknown resolution %s\n", argv[3]); - exit(EXIT_FAILURE); - } - sleep(1); // Let auto exposure do it's thing after changing image settings - printf("Changed resolution1 to %s\n", argv[6]); - // Flush the FIFO - myCAM1.flush_fifo(); - // Clear the capture done flag - myCAM1.clear_fifo_flag(); - // Start capture - printf("CAM1 start capture\n"); - myCAM1.start_capture(); - while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM1 Capture Done\n"); - - // Flush the FIFO - myCAM2.flush_fifo(); - // Clear the capture done flag - myCAM2.clear_fifo_flag(); - // Start capture - printf("CAM2 start capture\n"); - myCAM2.start_capture(); - while (!(myCAM2.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM2 Capture Done\n"); - - // Flush the FIFO - myCAM3.flush_fifo(); - // Clear the capture done flag - myCAM3.clear_fifo_flag(); - // Start capture - printf("CAM3 start capture\n"); - myCAM3.start_capture(); - while (!(myCAM3.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM3 Capture Done\n"); - - // Flush the FIFO - myCAM4.flush_fifo(); - // Clear the capture done flag - myCAM4.clear_fifo_flag(); - // Start capture - printf("CAM4 start capture\n"); - myCAM4.start_capture(); - while (!(myCAM4.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM4 Capture Done\n"); - - - // Open the new file - FILE *fp1 = fopen(argv[2], "w+"); - FILE *fp2 = fopen(argv[3], "w+"); - FILE *fp3 = fopen(argv[4], "w+"); - FILE *fp4 = fopen(argv[5], "w+"); - - if (!fp1) { - printf("Error: could not open %s\n", argv[2]); - exit(EXIT_FAILURE); - } - if (!fp2) { - printf("Error: could not open %s\n", argv[3]); - exit(EXIT_FAILURE); - } - if (!fp3) { - printf("Error: could not open %s\n", argv[4]); - exit(EXIT_FAILURE); - } - if (!fp4) { - printf("Error: could not open %s\n", argv[5]); - exit(EXIT_FAILURE); - } - printf("Reading FIFO and saving IMG\n"); - - size_t len1 = myCAM1.read_fifo_length(); - size_t len2 = myCAM2.read_fifo_length(); - size_t len3 = myCAM3.read_fifo_length(); - size_t len4 = myCAM4.read_fifo_length(); - printf("The len1 is %d\r\n",len1); - printf("The len2 is %d\r\n",len2); - printf("The len3 is %d\r\n",len3); - printf("The len4 is %d\r\n",len4); - if ((len1>=OV2640_MAX_FIFO_SIZE)||(len2>=OV2640_MAX_FIFO_SIZE)||(len3>=OV2640_MAX_FIFO_SIZE)||(len4>=OV2640_MAX_FIFO_SIZE)){ - printf("Over size."); - exit(EXIT_FAILURE); - } - if (len1 == 0 ) printf("Size1 is 0."); - if (len2 == 0 ) printf("Size2 is 0."); - if (len3 == 0 ) printf("Size3 is 0."); - if (len4 == 0 ) printf("Size4 is 0."); - int32_t i = 0; - myCAM1.CS_LOW(); //Set CS low - myCAM1.set_fifo_burst(); - while ( len1-- ) - { - temp_last = temp; - temp = myCAM1.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM1.CS_HIGH(); - fwrite(buf, i, 1, fp1); - //Close the file - fclose(fp1); - printf("IMG1 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM1.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp1); - i = 0; - buf[i++] = temp; - myCAM1.CS_LOW(); - myCAM1.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM2.CS_LOW(); //Set CS low - myCAM2.set_fifo_burst(); - while ( len2-- ) - { - temp_last = temp; - temp = myCAM2.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM2.CS_HIGH(); - fwrite(buf, i, 1, fp2); - //Close the file - fclose(fp2); - printf("IMG2 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM2.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp2); - i = 0; - buf[i++] = temp; - myCAM2.CS_LOW(); - myCAM2.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM3.CS_LOW(); //Set CS low - myCAM3.set_fifo_burst(); - while ( len3-- ) - { - temp_last = temp; - temp = myCAM3.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM3.CS_HIGH(); - fwrite(buf, i, 1, fp3); - //Close the file - fclose(fp3); - printf("IMG3 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM3.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp3); - i = 0; - buf[i++] = temp; - myCAM3.CS_LOW(); - myCAM3.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM4.CS_LOW(); //Set CS low - myCAM4.set_fifo_burst(); - while ( len4-- ) - { - temp_last = temp; - temp = myCAM4.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM4.CS_HIGH(); - fwrite(buf, i, 1, fp4); - //Close the file - fclose(fp4); - printf("IMG4 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM4.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp4); - i = 0; - buf[i++] = temp; - myCAM4.CS_LOW(); - myCAM4.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - } else { - printf("Error: unknown or missing argument.\n"); - exit(EXIT_FAILURE); - } - exit(EXIT_SUCCESS); + if (argc == 1) + { + printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); + printf(" 160x120\n"); + printf(" 176x144\n"); + printf(" 320x240\n"); + printf(" 352x288\n"); + printf(" 640x480\n"); + printf(" 800x600\n"); + printf(" 1024x768\n"); + printf(" 1280x960\n"); + printf(" 1600x1200\n"); + printf(" -c Capture image\n"); + exit(EXIT_SUCCESS); + } + + if (strcmp(argv[1], "-c") == 0 && argc == 7) + { + setup(); + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); + // Change to JPEG capture mode and initialize the OV2640 module + if (strcmp(argv[6], "160x120") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_160x120); + else if (strcmp(argv[6], "176x144") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_176x144); + else if (strcmp(argv[6], "320x240") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_320x240); + else if (strcmp(argv[6], "352x288") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_352x288); + else if (strcmp(argv[6], "640x480") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_640x480); + else if (strcmp(argv[6], "800x600") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_800x600); + else if (strcmp(argv[6], "1024x768") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_1024x768); + else if (strcmp(argv[6], "1280x960") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024); + else if (strcmp(argv[6], "1600x1200") == 0) + myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200); + else + { + printf("Unknown resolution %s\n", argv[3]); + exit(EXIT_FAILURE); + } + sleep(1); // Let auto exposure do it's thing after changing image settings + printf("Changed resolution1 to %s\n", argv[6]); + // Flush the FIFO + myCAM1.flush_fifo(); + // Clear the capture done flag + myCAM1.clear_fifo_flag(); + // Start capture + printf("CAM1 start capture\n"); + myCAM1.start_capture(); + while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM1 Capture Done\n"); + + // Flush the FIFO + myCAM2.flush_fifo(); + // Clear the capture done flag + myCAM2.clear_fifo_flag(); + // Start capture + printf("CAM2 start capture\n"); + myCAM2.start_capture(); + while (!(myCAM2.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM2 Capture Done\n"); + + // Flush the FIFO + myCAM3.flush_fifo(); + // Clear the capture done flag + myCAM3.clear_fifo_flag(); + // Start capture + printf("CAM3 start capture\n"); + myCAM3.start_capture(); + while (!(myCAM3.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM3 Capture Done\n"); + + // Flush the FIFO + myCAM4.flush_fifo(); + // Clear the capture done flag + myCAM4.clear_fifo_flag(); + // Start capture + printf("CAM4 start capture\n"); + myCAM4.start_capture(); + while (!(myCAM4.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM4 Capture Done\n"); + + // Open the new file + FILE *fp1 = fopen(argv[2], "w+"); + FILE *fp2 = fopen(argv[3], "w+"); + FILE *fp3 = fopen(argv[4], "w+"); + FILE *fp4 = fopen(argv[5], "w+"); + + if (!fp1) + { + printf("Error: could not open %s\n", argv[2]); + exit(EXIT_FAILURE); + } + if (!fp2) + { + printf("Error: could not open %s\n", argv[3]); + exit(EXIT_FAILURE); + } + if (!fp3) + { + printf("Error: could not open %s\n", argv[4]); + exit(EXIT_FAILURE); + } + if (!fp4) + { + printf("Error: could not open %s\n", argv[5]); + exit(EXIT_FAILURE); + } + printf("Reading FIFO and saving IMG\n"); + + size_t len1 = myCAM1.read_fifo_length(); + size_t len2 = myCAM2.read_fifo_length(); + size_t len3 = myCAM3.read_fifo_length(); + size_t len4 = myCAM4.read_fifo_length(); + printf("The len1 is %d\r\n", len1); + printf("The len2 is %d\r\n", len2); + printf("The len3 is %d\r\n", len3); + printf("The len4 is %d\r\n", len4); + if ((len1 >= OV2640_MAX_FIFO_SIZE) || (len2 >= OV2640_MAX_FIFO_SIZE) || (len3 >= OV2640_MAX_FIFO_SIZE) || (len4 >= OV2640_MAX_FIFO_SIZE)) + { + printf("Over size."); + exit(EXIT_FAILURE); + } + if (len1 == 0) + printf("Size1 is 0."); + if (len2 == 0) + printf("Size2 is 0."); + if (len3 == 0) + printf("Size3 is 0."); + if (len4 == 0) + printf("Size4 is 0."); + int32_t i = 0; + myCAM1.CS_LOW(); // Set CS low + myCAM1.set_fifo_burst(); + while (len1--) + { + temp_last = temp; + temp = myCAM1.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM1.CS_HIGH(); + fwrite(buf, i, 1, fp1); + // Close the file + fclose(fp1); + printf("IMG1 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM1.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp1); + i = 0; + buf[i++] = temp; + myCAM1.CS_LOW(); + myCAM1.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM2.CS_LOW(); // Set CS low + myCAM2.set_fifo_burst(); + while (len2--) + { + temp_last = temp; + temp = myCAM2.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM2.CS_HIGH(); + fwrite(buf, i, 1, fp2); + // Close the file + fclose(fp2); + printf("IMG2 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM2.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp2); + i = 0; + buf[i++] = temp; + myCAM2.CS_LOW(); + myCAM2.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM3.CS_LOW(); // Set CS low + myCAM3.set_fifo_burst(); + while (len3--) + { + temp_last = temp; + temp = myCAM3.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM3.CS_HIGH(); + fwrite(buf, i, 1, fp3); + // Close the file + fclose(fp3); + printf("IMG3 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM3.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp3); + i = 0; + buf[i++] = temp; + myCAM3.CS_LOW(); + myCAM3.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM4.CS_LOW(); // Set CS low + myCAM4.set_fifo_burst(); + while (len4--) + { + temp_last = temp; + temp = myCAM4.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM4.CS_HIGH(); + fwrite(buf, i, 1, fp4); + // Close the file + fclose(fp4); + printf("IMG4 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM4.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp4); + i = 0; + buf[i++] = temp; + myCAM4.CS_LOW(); + myCAM4.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + } + else + { + printf("Error: unknown or missing argument.\n"); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); } diff --git a/ArduCAM/examples/RaspberryPi/arducam_ov2640_capture.cpp b/ArduCAM/examples/RaspberryPi/arducam_ov2640_capture.cpp index 1433385f..78405a50 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_ov2640_capture.cpp +++ b/ArduCAM/examples/RaspberryPi/arducam_ov2640_capture.cpp @@ -13,156 +13,176 @@ #include #include #include "arducam_arch_raspberrypi.h" -#define OV2640_CHIPID_HIGH 0x0A -#define OV2640_CHIPID_LOW 0x0B -#define OV2640_MAX_FIFO_SIZE 0x5FFFF //384KByte +#define OV2640_CHIPID_HIGH 0x0A +#define OV2640_CHIPID_LOW 0x0B +#define OV2640_MAX_FIFO_SIZE 0x5FFFF // 384KByte #define BUF_SIZE 4096 #define CAM1_CS 5 uint8_t buf[BUF_SIZE]; bool is_header = false; -ArduCAM myCAM(OV2640,CAM1_CS); +ArduCAM myCAM(OV2640, CAM1_CS); void setup() { - uint8_t vid,pid; - uint8_t temp; - wiring_init(); - pinMode(CAM1_CS, OUTPUT); - // Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI interface error!\n"); - exit(EXIT_FAILURE); - } - // Change MCU mode - myCAM.write_reg(ARDUCHIP_MODE, 0x00); - // Check if the camera module type is OV2640 - myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - printf("Can't find OV2640 module!\n"); - exit(EXIT_FAILURE); - } else { - printf("OV2640 detected\n"); - } + uint8_t vid, pid; + uint8_t temp; + wiring_init(); + pinMode(CAM1_CS, OUTPUT); + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI interface error!\n"); + exit(EXIT_FAILURE); + } + // Change MCU mode + myCAM.write_reg(ARDUCHIP_MODE, 0x00); + // Check if the camera module type is OV2640 + myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + printf("Can't find OV2640 module!\n"); + exit(EXIT_FAILURE); + } + else + { + printf("OV2640 detected\n"); + } } int main(int argc, char *argv[]) { - uint8_t temp = 0, temp_last = 0; - if (argc == 1) + uint8_t temp = 0, temp_last = 0; + if (argc == 1) + { + printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); + printf(" 160x120\n"); + printf(" 176x144\n"); + printf(" 320x240\n"); + printf(" 352x288\n"); + printf(" 640x480\n"); + printf(" 800x600\n"); + printf(" 1024x768\n"); + printf(" 1280x1024\n"); + printf(" 1600x1200\n"); + printf(" -c Capture image\n"); + exit(EXIT_SUCCESS); + } + if (strcmp(argv[1], "-c") == 0 && argc == 4) + { + setup(); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + // Change to JPEG capture mode and initialize the OV2640 module + if (strcmp(argv[3], "160x120") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + else if (strcmp(argv[3], "176x144") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + else if (strcmp(argv[3], "320x240") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + else if (strcmp(argv[3], "352x288") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + else if (strcmp(argv[3], "640x480") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + else if (strcmp(argv[3], "800x600") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + else if (strcmp(argv[3], "1024x768") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + else if (strcmp(argv[3], "1280x960") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + else if (strcmp(argv[3], "1600x1200") == 0) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + else { - printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); - printf(" 160x120\n"); - printf(" 176x144\n"); - printf(" 320x240\n"); - printf(" 352x288\n"); - printf(" 640x480\n"); - printf(" 800x600\n"); - printf(" 1024x768\n"); - printf(" 1280x1024\n"); - printf(" 1600x1200\n"); - printf(" -c Capture image\n"); - exit(EXIT_SUCCESS); - } - if (strcmp(argv[1], "-c") == 0 && argc == 4) - { - setup(); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - // Change to JPEG capture mode and initialize the OV2640 module - if (strcmp(argv[3], "160x120") == 0) myCAM.OV2640_set_JPEG_size(OV2640_160x120); - else if (strcmp(argv[3], "176x144") == 0) myCAM.OV2640_set_JPEG_size(OV2640_176x144); - else if (strcmp(argv[3], "320x240") == 0) myCAM.OV2640_set_JPEG_size(OV2640_320x240); - else if (strcmp(argv[3], "352x288") == 0) myCAM.OV2640_set_JPEG_size(OV2640_352x288); - else if (strcmp(argv[3], "640x480") == 0) myCAM.OV2640_set_JPEG_size(OV2640_640x480); - else if (strcmp(argv[3], "800x600") == 0) myCAM.OV2640_set_JPEG_size(OV2640_800x600); - else if (strcmp(argv[3], "1024x768") == 0) myCAM.OV2640_set_JPEG_size(OV2640_1024x768); - else if (strcmp(argv[3], "1280x960") == 0) myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); - else if (strcmp(argv[3], "1600x1200")== 0) myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); - else { printf("Unknown resolution %s\n", argv[3]); exit(EXIT_FAILURE); - } - sleep(1); // Let auto exposure do it's thing after changing image settings - printf("Changed resolution1 to %s\n", argv[3]); - // Flush the FIFO - myCAM.flush_fifo(); - // Clear the capture done flag - myCAM.clear_fifo_flag(); - // Start capture - printf("Start capture\n"); - myCAM.start_capture(); - while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM Capture Done\n"); - - // Open the new file - FILE *fp1 = fopen(argv[2], "w+"); - if (!fp1) { - printf("Error: could not open %s\n", argv[2]); - exit(EXIT_FAILURE); - } - printf("Reading FIFO and saving IMG\r\n"); - size_t length = myCAM.read_fifo_length(); - printf("The length is %d\r\n", length); - if (length >= OV2640_MAX_FIFO_SIZE){ - printf("Over size."); - exit(EXIT_FAILURE); - }else if (length == 0 ){ - printf("Size is 0."); - exit(EXIT_FAILURE); - } - - int32_t i = 0; - myCAM.CS_LOW(); //Set CS low - myCAM.set_fifo_burst(); - - while ( length-- ) - { - temp_last = temp; - temp = myCAM.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - fwrite(buf, i, 1, fp1); - //Close the file - fclose(fp1); - printf("IMG save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp1); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - } - else { - printf("Error: unknown or missing argument.\n"); + } + sleep(1); // Let auto exposure do it's thing after changing image settings + printf("Changed resolution1 to %s\n", argv[3]); + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + printf("Start capture\n"); + myCAM.start_capture(); + while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM Capture Done\n"); + + // Open the new file + FILE *fp1 = fopen(argv[2], "w+"); + if (!fp1) + { + printf("Error: could not open %s\n", argv[2]); + exit(EXIT_FAILURE); + } + printf("Reading FIFO and saving IMG\r\n"); + size_t length = myCAM.read_fifo_length(); + printf("The length is %d\r\n", length); + if (length >= OV2640_MAX_FIFO_SIZE) + { + printf("Over size."); + exit(EXIT_FAILURE); + } + else if (length == 0) + { + printf("Size is 0."); exit(EXIT_FAILURE); + } + + int32_t i = 0; + myCAM.CS_LOW(); // Set CS low + myCAM.set_fifo_burst(); + + while (length--) + { + temp_last = temp; + temp = myCAM.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM.CS_HIGH(); + fwrite(buf, i, 1, fp1); + // Close the file + fclose(fp1); + printf("IMG save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp1); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + } + else + { + printf("Error: unknown or missing argument.\n"); + exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } diff --git a/ArduCAM/examples/RaspberryPi/arducam_ov5640_4cams_capture.cpp b/ArduCAM/examples/RaspberryPi/arducam_ov5640_4cams_capture.cpp index d75dc1e3..fe577fc8 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_ov5640_4cams_capture.cpp +++ b/ArduCAM/examples/RaspberryPi/arducam_ov5640_4cams_capture.cpp @@ -15,380 +15,412 @@ #include "arducam_arch_raspberrypi.h" #define OV5640_CHIPID_HIGH 0x300a #define OV5640_CHIPID_LOW 0x300b -#define OV5640_MAX_FIFO_SIZE 0x7FFFFF //8MByte +#define OV5640_MAX_FIFO_SIZE 0x7FFFFF // 8MByte #define BUF_SIZE 4096 #define CAM1_CS 0 #define CAM2_CS 4 #define CAM3_CS 3 #define CAM4_CS 5 -#define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active +#define VSYNC_LEVEL_MASK 0x02 // 0 = High active , 1 = Low active uint8_t buf[BUF_SIZE]; bool is_header = false; -ArduCAM myCAM1(OV5640,CAM1_CS); -ArduCAM myCAM2(OV5640,CAM2_CS); -ArduCAM myCAM3(OV5640,CAM3_CS); -ArduCAM myCAM4(OV5640,CAM4_CS); +ArduCAM myCAM1(OV5640, CAM1_CS); +ArduCAM myCAM2(OV5640, CAM2_CS); +ArduCAM myCAM3(OV5640, CAM3_CS); +ArduCAM myCAM4(OV5640, CAM4_CS); void setup() { - uint8_t vid,pid; - uint8_t temp; - wiring_init(); - pinMode(CAM1_CS, OUTPUT); - pinMode(CAM2_CS, OUTPUT); - pinMode(CAM3_CS, OUTPUT); - pinMode(CAM4_CS, OUTPUT); - // Check if the ArduCAM SPI1 bus is OK - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI1 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI2 bus is OK - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); //debug - if(temp != 0x55) { - printf("SPI2 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI3 bus is OK - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI3 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI4 bus is OK - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI4 interface error!\n"); - exit(EXIT_FAILURE); - } - // Change MCU mode - myCAM1.write_reg(ARDUCHIP_MODE, 0x00); - myCAM2.write_reg(ARDUCHIP_MODE, 0x00); - myCAM3.write_reg(ARDUCHIP_MODE, 0x00); - myCAM4.write_reg(ARDUCHIP_MODE, 0x00); - myCAM1.wrSensorReg16_8(0xff, 0x01); - myCAM1.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)) - printf("Can't find OV5640 module!"); - else - printf("OV5640 detected.\n"); + uint8_t vid, pid; + uint8_t temp; + wiring_init(); + pinMode(CAM1_CS, OUTPUT); + pinMode(CAM2_CS, OUTPUT); + pinMode(CAM3_CS, OUTPUT); + pinMode(CAM4_CS, OUTPUT); + // Check if the ArduCAM SPI1 bus is OK + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI1 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI2 bus is OK + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); //debug + if (temp != 0x55) + { + printf("SPI2 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI3 bus is OK + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI3 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI4 bus is OK + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI4 interface error!\n"); + exit(EXIT_FAILURE); + } + // Change MCU mode + myCAM1.write_reg(ARDUCHIP_MODE, 0x00); + myCAM2.write_reg(ARDUCHIP_MODE, 0x00); + myCAM3.write_reg(ARDUCHIP_MODE, 0x00); + myCAM4.write_reg(ARDUCHIP_MODE, 0x00); + myCAM1.wrSensorReg16_8(0xff, 0x01); + myCAM1.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x40)) + printf("Can't find OV5640 module!"); + else + printf("OV5640 detected.\n"); } int main(int argc, char *argv[]) { - uint8_t temp = 0, temp_last = 0; - if (argc == 1) - { - printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); - printf(" 320x240\n"); + uint8_t temp = 0, temp_last = 0; + if (argc == 1) + { + printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); + printf(" 320x240\n"); printf(" 352x288\n"); - printf(" 640x480\n"); - printf(" 800x480\n"); + printf(" 640x480\n"); + printf(" 800x480\n"); printf(" 1024x768\n"); - printf(" 1280x960\n"); - printf(" 1600x1200\n"); - printf(" 2048x1536\n"); - printf(" 2592x1944\n"); - printf(" -c Capture image\n"); - exit(EXIT_SUCCESS); - } - if (strcmp(argv[1], "-c") == 0 && argc == 7) - { - setup(); - myCAM1.set_format(JPEG); - myCAM1.InitCAM(); - // Change to JPEG capture mode and initialize the OV5640 module - if (strcmp(argv[6], "320x240") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_320x240); - else if (strcmp(argv[6], "352x288") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_352x288); - else if (strcmp(argv[6], "640x480") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_640x480); - else if (strcmp(argv[6], "800x480") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_800x480); - else if (strcmp(argv[6], "1024x768") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_1024x768); - else if (strcmp(argv[6], "1280x960") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_1280x960); - else if (strcmp(argv[6], "1600x1200") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_1600x1200); - else if (strcmp(argv[6], "2048x1536") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_2048x1536); - else if (strcmp(argv[6], "2592x1944") == 0) myCAM1.OV5640_set_JPEG_size(OV5640_2592x1944); - else { - printf("Unknown resolution %s\n", argv[6]); - exit(EXIT_FAILURE); - } - sleep(1); // Let auto exposure do it's thing after changing image settings - printf("Changed resolution1 to %s\n", argv[6]); - myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - // Flush the FIFO - myCAM1.flush_fifo(); - // Clear the capture done flag - myCAM1.clear_fifo_flag(); - // Start capture - printf("CAM1 start capture\n"); - myCAM1.start_capture(); - while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM1 Capture Done\n"); - - // Flush the FIFO - myCAM2.flush_fifo(); - // Clear the capture done flag - myCAM2.clear_fifo_flag(); - // Start capture - printf("CAM2 start capture\n"); - myCAM2.start_capture(); - while (!(myCAM2.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM2 Capture Done\n"); - - // Flush the FIFO - myCAM3.flush_fifo(); - // Clear the capture done flag - myCAM3.clear_fifo_flag(); - // Start capture - printf("CAM3 start capture\n"); - myCAM3.start_capture(); - while (!(myCAM3.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM3 Capture Done\n"); - - // Flush the FIFO - myCAM4.flush_fifo(); - // Clear the capture done flag - myCAM4.clear_fifo_flag(); - // Start capture - printf("CAM4 start capture\n"); - myCAM4.start_capture(); - while (!(myCAM4.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM4 Capture Done\n"); - - - // Open the new file - FILE *fp1 = fopen(argv[2], "w+"); - FILE *fp2 = fopen(argv[3], "w+"); - FILE *fp3 = fopen(argv[4], "w+"); - FILE *fp4 = fopen(argv[5], "w+"); - - if (!fp1) { - printf("Error: could not open %s\n", argv[2]); - exit(EXIT_FAILURE); - } - if (!fp2) { - printf("Error: could not open %s\n", argv[3]); - exit(EXIT_FAILURE); - } - if (!fp3) { - printf("Error: could not open %s\n", argv[4]); - exit(EXIT_FAILURE); - } - if (!fp4) { - printf("Error: could not open %s\n", argv[5]); - exit(EXIT_FAILURE); - } - printf("Reading FIFO and saving IMG\n"); - - size_t len1 = myCAM1.read_fifo_length(); - size_t len2 = myCAM2.read_fifo_length(); - size_t len3 = myCAM3.read_fifo_length(); - size_t len4 = myCAM4.read_fifo_length(); - printf("The len1 is %d\r\n",len1); - printf("The len2 is %d\r\n",len2); - printf("The len3 is %d\r\n",len3); - printf("The len4 is %d\r\n",len4); - if ((len1>=OV5640_MAX_FIFO_SIZE)||(len2>=OV5640_MAX_FIFO_SIZE)||(len3>=OV5640_MAX_FIFO_SIZE)||(len4>=OV5640_MAX_FIFO_SIZE)){ - printf("Over size."); - exit(EXIT_FAILURE); - } - if (len1 == 0 ) printf("Size1 is 0."); - if (len2 == 0 ) printf("Size2 is 0."); - if (len3 == 0 ) printf("Size3 is 0."); - if (len4 == 0 ) printf("Size4 is 0."); - int32_t i = 0; - myCAM1.CS_LOW(); //Set CS low - myCAM1.set_fifo_burst(); - while ( len1-- ) - { - temp_last = temp; - temp = myCAM1.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM1.CS_HIGH(); - fwrite(buf, i, 1, fp1); - //Close the file - fclose(fp1); - printf("IMG1 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM1.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp1); - i = 0; - buf[i++] = temp; - myCAM1.CS_LOW(); - myCAM1.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM2.CS_LOW(); //Set CS low - myCAM2.set_fifo_burst(); - while ( len2-- ) - { - temp_last = temp; - temp = myCAM2.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM2.CS_HIGH(); - fwrite(buf, i, 1, fp2); - //Close the file - fclose(fp2); - printf("IMG2 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM2.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp2); - i = 0; - buf[i++] = temp; - myCAM2.CS_LOW(); - myCAM2.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM3.CS_LOW(); //Set CS low - myCAM3.set_fifo_burst(); - while ( len3-- ) - { - temp_last = temp; - temp = myCAM3.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM3.CS_HIGH(); - fwrite(buf, i, 1, fp3); - //Close the file - fclose(fp3); - printf("IMG3 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM3.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp3); - i = 0; - buf[i++] = temp; - myCAM3.CS_LOW(); - myCAM3.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM4.CS_LOW(); //Set CS low - myCAM4.set_fifo_burst(); - while ( len4-- ) - { - temp_last = temp; - temp = myCAM4.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM4.CS_HIGH(); - fwrite(buf, i, 1, fp4); - //Close the file - fclose(fp4); - printf("IMG4 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM4.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp4); - i = 0; - buf[i++] = temp; - myCAM4.CS_LOW(); - myCAM4.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - } else { - printf("Error: unknown or missing argument.\n"); - exit(EXIT_FAILURE); - } - exit(EXIT_SUCCESS); -} + printf(" 1280x960\n"); + printf(" 1600x1200\n"); + printf(" 2048x1536\n"); + printf(" 2592x1944\n"); + printf(" -c Capture image\n"); + exit(EXIT_SUCCESS); + } + if (strcmp(argv[1], "-c") == 0 && argc == 7) + { + setup(); + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); + // Change to JPEG capture mode and initialize the OV5640 module + if (strcmp(argv[6], "320x240") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_320x240); + else if (strcmp(argv[6], "352x288") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_352x288); + else if (strcmp(argv[6], "640x480") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_640x480); + else if (strcmp(argv[6], "800x480") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_800x480); + else if (strcmp(argv[6], "1024x768") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_1024x768); + else if (strcmp(argv[6], "1280x960") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_1280x960); + else if (strcmp(argv[6], "1600x1200") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_1600x1200); + else if (strcmp(argv[6], "2048x1536") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_2048x1536); + else if (strcmp(argv[6], "2592x1944") == 0) + myCAM1.OV5640_set_JPEG_size(OV5640_2592x1944); + else + { + printf("Unknown resolution %s\n", argv[6]); + exit(EXIT_FAILURE); + } + sleep(1); // Let auto exposure do it's thing after changing image settings + printf("Changed resolution1 to %s\n", argv[6]); + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + // Flush the FIFO + myCAM1.flush_fifo(); + // Clear the capture done flag + myCAM1.clear_fifo_flag(); + // Start capture + printf("CAM1 start capture\n"); + myCAM1.start_capture(); + while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM1 Capture Done\n"); + + // Flush the FIFO + myCAM2.flush_fifo(); + // Clear the capture done flag + myCAM2.clear_fifo_flag(); + // Start capture + printf("CAM2 start capture\n"); + myCAM2.start_capture(); + while (!(myCAM2.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM2 Capture Done\n"); + + // Flush the FIFO + myCAM3.flush_fifo(); + // Clear the capture done flag + myCAM3.clear_fifo_flag(); + // Start capture + printf("CAM3 start capture\n"); + myCAM3.start_capture(); + while (!(myCAM3.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM3 Capture Done\n"); + + // Flush the FIFO + myCAM4.flush_fifo(); + // Clear the capture done flag + myCAM4.clear_fifo_flag(); + // Start capture + printf("CAM4 start capture\n"); + myCAM4.start_capture(); + while (!(myCAM4.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM4 Capture Done\n"); + + // Open the new file + FILE *fp1 = fopen(argv[2], "w+"); + FILE *fp2 = fopen(argv[3], "w+"); + FILE *fp3 = fopen(argv[4], "w+"); + FILE *fp4 = fopen(argv[5], "w+"); + if (!fp1) + { + printf("Error: could not open %s\n", argv[2]); + exit(EXIT_FAILURE); + } + if (!fp2) + { + printf("Error: could not open %s\n", argv[3]); + exit(EXIT_FAILURE); + } + if (!fp3) + { + printf("Error: could not open %s\n", argv[4]); + exit(EXIT_FAILURE); + } + if (!fp4) + { + printf("Error: could not open %s\n", argv[5]); + exit(EXIT_FAILURE); + } + printf("Reading FIFO and saving IMG\n"); + + size_t len1 = myCAM1.read_fifo_length(); + size_t len2 = myCAM2.read_fifo_length(); + size_t len3 = myCAM3.read_fifo_length(); + size_t len4 = myCAM4.read_fifo_length(); + printf("The len1 is %d\r\n", len1); + printf("The len2 is %d\r\n", len2); + printf("The len3 is %d\r\n", len3); + printf("The len4 is %d\r\n", len4); + if ((len1 >= OV5640_MAX_FIFO_SIZE) || (len2 >= OV5640_MAX_FIFO_SIZE) || (len3 >= OV5640_MAX_FIFO_SIZE) || (len4 >= OV5640_MAX_FIFO_SIZE)) + { + printf("Over size."); + exit(EXIT_FAILURE); + } + if (len1 == 0) + printf("Size1 is 0."); + if (len2 == 0) + printf("Size2 is 0."); + if (len3 == 0) + printf("Size3 is 0."); + if (len4 == 0) + printf("Size4 is 0."); + int32_t i = 0; + myCAM1.CS_LOW(); // Set CS low + myCAM1.set_fifo_burst(); + while (len1--) + { + temp_last = temp; + temp = myCAM1.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM1.CS_HIGH(); + fwrite(buf, i, 1, fp1); + // Close the file + fclose(fp1); + printf("IMG1 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM1.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp1); + i = 0; + buf[i++] = temp; + myCAM1.CS_LOW(); + myCAM1.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM2.CS_LOW(); // Set CS low + myCAM2.set_fifo_burst(); + while (len2--) + { + temp_last = temp; + temp = myCAM2.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM2.CS_HIGH(); + fwrite(buf, i, 1, fp2); + // Close the file + fclose(fp2); + printf("IMG2 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM2.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp2); + i = 0; + buf[i++] = temp; + myCAM2.CS_LOW(); + myCAM2.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM3.CS_LOW(); // Set CS low + myCAM3.set_fifo_burst(); + while (len3--) + { + temp_last = temp; + temp = myCAM3.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM3.CS_HIGH(); + fwrite(buf, i, 1, fp3); + // Close the file + fclose(fp3); + printf("IMG3 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM3.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp3); + i = 0; + buf[i++] = temp; + myCAM3.CS_LOW(); + myCAM3.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM4.CS_LOW(); // Set CS low + myCAM4.set_fifo_burst(); + while (len4--) + { + temp_last = temp; + temp = myCAM4.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM4.CS_HIGH(); + fwrite(buf, i, 1, fp4); + // Close the file + fclose(fp4); + printf("IMG4 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM4.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp4); + i = 0; + buf[i++] = temp; + myCAM4.CS_LOW(); + myCAM4.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + } + else + { + printf("Error: unknown or missing argument.\n"); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); +} diff --git a/ArduCAM/examples/RaspberryPi/arducam_ov5640_capture.cpp b/ArduCAM/examples/RaspberryPi/arducam_ov5640_capture.cpp index 22afb78b..d9b2f610 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_ov5640_capture.cpp +++ b/ArduCAM/examples/RaspberryPi/arducam_ov5640_capture.cpp @@ -15,155 +15,173 @@ #include "arducam_arch_raspberrypi.h" #define OV5640_CHIPID_HIGH 0x300a #define OV5640_CHIPID_LOW 0x300b -#define OV5640_MAX_FIFO_SIZE 0x7FFFFF //8MByte +#define OV5640_MAX_FIFO_SIZE 0x7FFFFF // 8MByte #define BUF_SIZE 4096 #define CAM1_CS 5 -#define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active +#define VSYNC_LEVEL_MASK 0x02 // 0 = High active , 1 = Low active uint8_t buf[BUF_SIZE]; bool is_header = false; -ArduCAM myCAM(OV5640,CAM1_CS); +ArduCAM myCAM(OV5640, CAM1_CS); void setup() { - uint8_t vid,pid; - uint8_t temp; - wiring_init(); - pinMode(CAM1_CS, OUTPUT); - // Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI interface error!\n"); - exit(EXIT_FAILURE); - } - // Change MCU mode - myCAM.write_reg(ARDUCHIP_MODE, 0x00); - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)) + uint8_t vid, pid; + uint8_t temp; + wiring_init(); + pinMode(CAM1_CS, OUTPUT); + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI interface error!\n"); + exit(EXIT_FAILURE); + } + // Change MCU mode + myCAM.write_reg(ARDUCHIP_MODE, 0x00); + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x40)) printf("Can't find OV5640 module!"); - else - printf("OV5640 detected.\n"); + else + printf("OV5640 detected.\n"); } int main(int argc, char *argv[]) { - uint8_t temp = 0, temp_last = 0; - if (argc == 1) + uint8_t temp = 0, temp_last = 0; + if (argc == 1) + { + printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); + printf(" 320x240\n"); + printf(" 352x288\n"); + printf(" 640x480\n"); + printf(" 800x480\n"); + printf(" 1024x768\n"); + printf(" 1280x960\n"); + printf(" 1600x1200\n"); + printf(" 2048x1536\n"); + printf(" 2592x1944\n"); + printf(" -c Capture image\n"); + exit(EXIT_SUCCESS); + } + if (strcmp(argv[1], "-c") == 0 && argc == 4) + { + setup(); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + // Change to JPEG capture mode and initialize the OV5640 module + if (strcmp(argv[3], "320x240") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + else if (strcmp(argv[3], "352x288") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_352x288); + else if (strcmp(argv[3], "640x480") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + else if (strcmp(argv[3], "800x480") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_800x480); + else if (strcmp(argv[3], "1024x768") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_1024x768); + else if (strcmp(argv[3], "1280x960") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + else if (strcmp(argv[3], "1600x1200") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); + else if (strcmp(argv[3], "2048x1536") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + else if (strcmp(argv[3], "2592x1944") == 0) + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + else { - printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); - printf(" 320x240\n"); - printf(" 352x288\n"); - printf(" 640x480\n"); - printf(" 800x480\n"); - printf(" 1024x768\n"); - printf(" 1280x960\n"); - printf(" 1600x1200\n"); - printf(" 2048x1536\n"); - printf(" 2592x1944\n"); - printf(" -c Capture image\n"); - exit(EXIT_SUCCESS); - } - if (strcmp(argv[1], "-c") == 0 && argc == 4) - { - setup(); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - // Change to JPEG capture mode and initialize the OV5640 module - if (strcmp(argv[3], "320x240") == 0) myCAM.OV5640_set_JPEG_size(OV5640_320x240); - else if (strcmp(argv[3], "352x288") == 0) myCAM.OV5640_set_JPEG_size(OV5640_352x288); - else if (strcmp(argv[3], "640x480") == 0) myCAM.OV5640_set_JPEG_size(OV5640_640x480); - else if (strcmp(argv[3], "800x480") == 0) myCAM.OV5640_set_JPEG_size(OV5640_800x480); - else if (strcmp(argv[3], "1024x768") == 0) myCAM.OV5640_set_JPEG_size(OV5640_1024x768); - else if (strcmp(argv[3], "1280x960") == 0) myCAM.OV5640_set_JPEG_size(OV5640_1280x960); - else if (strcmp(argv[3], "1600x1200") == 0) myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); - else if (strcmp(argv[3], "2048x1536") == 0) myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); - else if (strcmp(argv[3], "2592x1944") == 0) myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); - else { printf("Unknown resolution %s\n", argv[3]); exit(EXIT_FAILURE); + } + sleep(1); // Let auto exposure do it's thing after changing image settings + printf("Changed resolution1 to %s\n", argv[3]); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + printf("Start capture\n"); + myCAM.start_capture(); + while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + { + } + printf("CAM Capture Done\n"); + + // Open the new file + FILE *fp1 = fopen(argv[2], "w+"); + if (!fp1) + { + printf("Error: could not open %s\n", argv[2]); + exit(EXIT_FAILURE); + } + + printf("Reading FIFO and saving IMG\n"); + size_t length = myCAM.read_fifo_length(); + printf("The length is %d\r\n", length); + if (length >= OV5640_MAX_FIFO_SIZE) + { + printf("Over size."); + exit(EXIT_FAILURE); + } + else if (length == 0) + { + printf("Size is 0."); + exit(EXIT_FAILURE); + } + int32_t i = 0; + myCAM.CS_LOW(); // Set CS low + myCAM.set_fifo_burst(); + + while (length--) + { + temp_last = temp; + temp = myCAM.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM.CS_HIGH(); + fwrite(buf, i, 1, fp1); + // Close the file + fclose(fp1); + printf("IMG save OK !\n"); + is_header = false; + i = 0; } - sleep(1); // Let auto exposure do it's thing after changing image settings - printf("Changed resolution1 to %s\n", argv[3]); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - // Flush the FIFO - myCAM.flush_fifo(); - // Clear the capture done flag - myCAM.clear_fifo_flag(); - // Start capture - printf("Start capture\n"); - myCAM.start_capture(); - while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)){} - printf("CAM Capture Done\n"); - - // Open the new file - FILE *fp1 = fopen(argv[2], "w+"); - if (!fp1) { - printf("Error: could not open %s\n", argv[2]); - exit(EXIT_FAILURE); + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp1); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } } - - printf("Reading FIFO and saving IMG\n"); - size_t length = myCAM.read_fifo_length(); - printf("The length is %d\r\n", length); - if (length >= OV5640_MAX_FIFO_SIZE){ - printf("Over size."); - exit(EXIT_FAILURE); - }else if (length == 0 ){ - printf("Size is 0."); - exit(EXIT_FAILURE); - } - int32_t i=0; - myCAM.CS_LOW(); //Set CS low - myCAM.set_fifo_burst(); - - while ( length-- ) - { - temp_last = temp; - temp = myCAM.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - fwrite(buf, i, 1, fp1); - //Close the file - fclose(fp1); - printf("IMG save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp1); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - } - else { - printf("Error: unknown or missing argument.\n"); - exit(EXIT_FAILURE); + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + } + else + { + printf("Error: unknown or missing argument.\n"); + exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } diff --git a/ArduCAM/examples/RaspberryPi/arducam_ov5642_4cams_capture.cpp b/ArduCAM/examples/RaspberryPi/arducam_ov5642_4cams_capture.cpp index 478b4f3f..63d838af 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_ov5642_4cams_capture.cpp +++ b/ArduCAM/examples/RaspberryPi/arducam_ov5642_4cams_capture.cpp @@ -15,374 +15,403 @@ #include "arducam_arch_raspberrypi.h" #define OV5642_CHIPID_HIGH 0x300a #define OV5642_CHIPID_LOW 0x300b -#define OV5642_MAX_FIFO_SIZE 0x7FFFFF //8MByte +#define OV5642_MAX_FIFO_SIZE 0x7FFFFF // 8MByte #define BUF_SIZE 4096 #define CAM1_CS 0 #define CAM2_CS 4 #define CAM3_CS 3 #define CAM4_CS 5 -#define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active +#define VSYNC_LEVEL_MASK 0x02 // 0 = High active , 1 = Low active uint8_t buf[BUF_SIZE]; bool is_header = false; -ArduCAM myCAM1(OV5642,CAM1_CS); -ArduCAM myCAM2(OV5642,CAM2_CS); -ArduCAM myCAM3(OV5642,CAM3_CS); -ArduCAM myCAM4(OV5642,CAM4_CS); +ArduCAM myCAM1(OV5642, CAM1_CS); +ArduCAM myCAM2(OV5642, CAM2_CS); +ArduCAM myCAM3(OV5642, CAM3_CS); +ArduCAM myCAM4(OV5642, CAM4_CS); void setup() { - uint8_t vid,pid; - uint8_t temp; - wiring_init(); - pinMode(CAM1_CS, OUTPUT); - pinMode(CAM2_CS, OUTPUT); - pinMode(CAM3_CS, OUTPUT); - pinMode(CAM4_CS, OUTPUT); - // Check if the ArduCAM SPI1 bus is OK - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI1 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI2 bus is OK - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); //debug - if(temp != 0x55) { - printf("SPI2 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI3 bus is OK - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI3 interface error!\n"); - exit(EXIT_FAILURE); - } - // Check if the ArduCAM SPI4 bus is OK - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI4 interface error!\n"); - exit(EXIT_FAILURE); - } - // Change MCU mode - myCAM1.write_reg(ARDUCHIP_MODE, 0x00); - myCAM2.write_reg(ARDUCHIP_MODE, 0x00); - myCAM3.write_reg(ARDUCHIP_MODE, 0x00); - myCAM4.write_reg(ARDUCHIP_MODE, 0x00); - myCAM1.wrSensorReg16_8(0xff, 0x01); - myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)) - printf("Can't find OV5642 module!"); - else - printf("OV5642 detected.\n"); + uint8_t vid, pid; + uint8_t temp; + wiring_init(); + pinMode(CAM1_CS, OUTPUT); + pinMode(CAM2_CS, OUTPUT); + pinMode(CAM3_CS, OUTPUT); + pinMode(CAM4_CS, OUTPUT); + // Check if the ArduCAM SPI1 bus is OK + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI1 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI2 bus is OK + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); //debug + if (temp != 0x55) + { + printf("SPI2 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI3 bus is OK + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI3 interface error!\n"); + exit(EXIT_FAILURE); + } + // Check if the ArduCAM SPI4 bus is OK + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI4 interface error!\n"); + exit(EXIT_FAILURE); + } + // Change MCU mode + myCAM1.write_reg(ARDUCHIP_MODE, 0x00); + myCAM2.write_reg(ARDUCHIP_MODE, 0x00); + myCAM3.write_reg(ARDUCHIP_MODE, 0x00); + myCAM4.write_reg(ARDUCHIP_MODE, 0x00); + myCAM1.wrSensorReg16_8(0xff, 0x01); + myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + printf("Can't find OV5642 module!"); + else + printf("OV5642 detected.\n"); } int main(int argc, char *argv[]) { - uint8_t temp = 0, temp_last = 0; - if (argc == 1) - { - printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); - printf(" 320x240\n"); - printf(" 640x480\n"); - printf(" 1280x960\n"); - printf(" 1600x1200\n"); - printf(" 2048x1536\n"); - printf(" 2592x1944\n"); - printf(" -c Capture image\n"); - exit(EXIT_SUCCESS); - } - if (strcmp(argv[1], "-c") == 0 && argc == 7) - { - setup(); - myCAM1.set_format(JPEG); - myCAM1.InitCAM(); - // Change to JPEG capture mode and initialize the OV2640 module - if (strcmp(argv[6], "320x240") == 0) myCAM1.OV5642_set_JPEG_size(OV5642_320x240); - else if (strcmp(argv[6], "640x480") == 0) myCAM1.OV5642_set_JPEG_size(OV5642_640x480); - else if (strcmp(argv[6], "1280x960") == 0) myCAM1.OV5642_set_JPEG_size(OV5642_1280x960); - else if (strcmp(argv[6], "1600x1200") == 0) myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200); - else if (strcmp(argv[6], "2048x1536") == 0) myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536); - else if (strcmp(argv[6], "2592x1944") == 0) myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944); - else { - printf("Unknown resolution %s\n", argv[6]); - exit(EXIT_FAILURE); - } - sleep(1); // Let auto exposure do it's thing after changing image settings - printf("Changed resolution1 to %s\n", argv[6]); - myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - // Flush the FIFO - myCAM1.flush_fifo(); - // Clear the capture done flag - myCAM1.clear_fifo_flag(); - // Start capture - printf("CAM1 start capture\n"); - myCAM1.start_capture(); - while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM1 Capture Done\n"); - - // Flush the FIFO - myCAM2.flush_fifo(); - // Clear the capture done flag - myCAM2.clear_fifo_flag(); - // Start capture - printf("CAM2 start capture\n"); - myCAM2.start_capture(); - while (!(myCAM2.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM2 Capture Done\n"); - - // Flush the FIFO - myCAM3.flush_fifo(); - // Clear the capture done flag - myCAM3.clear_fifo_flag(); - // Start capture - printf("CAM3 start capture\n"); - myCAM3.start_capture(); - while (!(myCAM3.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM3 Capture Done\n"); - - // Flush the FIFO - myCAM4.flush_fifo(); - // Clear the capture done flag - myCAM4.clear_fifo_flag(); - // Start capture - printf("CAM4 start capture\n"); - myCAM4.start_capture(); - while (!(myCAM4.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) ; - printf("CAM4 Capture Done\n"); - - - // Open the new file - FILE *fp1 = fopen(argv[2], "w+"); - FILE *fp2 = fopen(argv[3], "w+"); - FILE *fp3 = fopen(argv[4], "w+"); - FILE *fp4 = fopen(argv[5], "w+"); - - if (!fp1) { - printf("Error: could not open %s\n", argv[2]); - exit(EXIT_FAILURE); - } - if (!fp2) { - printf("Error: could not open %s\n", argv[3]); - exit(EXIT_FAILURE); - } - if (!fp3) { - printf("Error: could not open %s\n", argv[4]); - exit(EXIT_FAILURE); - } - if (!fp4) { - printf("Error: could not open %s\n", argv[5]); - exit(EXIT_FAILURE); - } - printf("Reading FIFO and saving IMG\n"); - - size_t len1 = myCAM1.read_fifo_length(); - size_t len2 = myCAM2.read_fifo_length(); - size_t len3 = myCAM3.read_fifo_length(); - size_t len4 = myCAM4.read_fifo_length(); - printf("The len1 is %d\r\n",len1); - printf("The len2 is %d\r\n",len2); - printf("The len3 is %d\r\n",len3); - printf("The len4 is %d\r\n",len4); - if ((len1>=OV5642_MAX_FIFO_SIZE)||(len2>=OV5642_MAX_FIFO_SIZE)||(len3>=OV5642_MAX_FIFO_SIZE)||(len4>=OV5642_MAX_FIFO_SIZE)){ - printf("Over size."); - exit(EXIT_FAILURE); - } - if (len1 == 0 ) printf("Size1 is 0."); - if (len2 == 0 ) printf("Size2 is 0."); - if (len3 == 0 ) printf("Size3 is 0."); - if (len4 == 0 ) printf("Size4 is 0."); - int32_t i = 0; - myCAM1.CS_LOW(); //Set CS low - myCAM1.set_fifo_burst(); - while ( len1-- ) - { - temp_last = temp; - temp = myCAM1.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM1.CS_HIGH(); - fwrite(buf, i, 1, fp1); - //Close the file - fclose(fp1); - printf("IMG1 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM1.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp1); - i = 0; - buf[i++] = temp; - myCAM1.CS_LOW(); - myCAM1.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM2.CS_LOW(); //Set CS low - myCAM2.set_fifo_burst(); - while ( len2-- ) - { - temp_last = temp; - temp = myCAM2.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM2.CS_HIGH(); - fwrite(buf, i, 1, fp2); - //Close the file - fclose(fp2); - printf("IMG2 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM2.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp2); - i = 0; - buf[i++] = temp; - myCAM2.CS_LOW(); - myCAM2.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM3.CS_LOW(); //Set CS low - myCAM3.set_fifo_burst(); - while ( len3-- ) - { - temp_last = temp; - temp = myCAM3.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM3.CS_HIGH(); - fwrite(buf, i, 1, fp3); - //Close the file - fclose(fp3); - printf("IMG3 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM3.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp3); - i = 0; - buf[i++] = temp; - myCAM3.CS_LOW(); - myCAM3.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - temp = 0;temp_last = 0; i = 0; - myCAM4.CS_LOW(); //Set CS low - myCAM4.set_fifo_burst(); - while ( len4-- ) - { - temp_last = temp; - temp = myCAM4.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM4.CS_HIGH(); - fwrite(buf, i, 1, fp4); - //Close the file - fclose(fp4); - printf("IMG4 save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM4.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp4); - i = 0; - buf[i++] = temp; - myCAM4.CS_LOW(); - myCAM4.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - - } else { - printf("Error: unknown or missing argument.\n"); - exit(EXIT_FAILURE); - } - exit(EXIT_SUCCESS); -} + uint8_t temp = 0, temp_last = 0; + if (argc == 1) + { + printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); + printf(" 320x240\n"); + printf(" 640x480\n"); + printf(" 1280x960\n"); + printf(" 1600x1200\n"); + printf(" 2048x1536\n"); + printf(" 2592x1944\n"); + printf(" -c Capture image\n"); + exit(EXIT_SUCCESS); + } + if (strcmp(argv[1], "-c") == 0 && argc == 7) + { + setup(); + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); + // Change to JPEG capture mode and initialize the OV2640 module + if (strcmp(argv[6], "320x240") == 0) + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); + else if (strcmp(argv[6], "640x480") == 0) + myCAM1.OV5642_set_JPEG_size(OV5642_640x480); + else if (strcmp(argv[6], "1280x960") == 0) + myCAM1.OV5642_set_JPEG_size(OV5642_1280x960); + else if (strcmp(argv[6], "1600x1200") == 0) + myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200); + else if (strcmp(argv[6], "2048x1536") == 0) + myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536); + else if (strcmp(argv[6], "2592x1944") == 0) + myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944); + else + { + printf("Unknown resolution %s\n", argv[6]); + exit(EXIT_FAILURE); + } + sleep(1); // Let auto exposure do it's thing after changing image settings + printf("Changed resolution1 to %s\n", argv[6]); + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + // Flush the FIFO + myCAM1.flush_fifo(); + // Clear the capture done flag + myCAM1.clear_fifo_flag(); + // Start capture + printf("CAM1 start capture\n"); + myCAM1.start_capture(); + while (!(myCAM1.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM1 Capture Done\n"); + + // Flush the FIFO + myCAM2.flush_fifo(); + // Clear the capture done flag + myCAM2.clear_fifo_flag(); + // Start capture + printf("CAM2 start capture\n"); + myCAM2.start_capture(); + while (!(myCAM2.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM2 Capture Done\n"); + + // Flush the FIFO + myCAM3.flush_fifo(); + // Clear the capture done flag + myCAM3.clear_fifo_flag(); + // Start capture + printf("CAM3 start capture\n"); + myCAM3.start_capture(); + while (!(myCAM3.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM3 Capture Done\n"); + + // Flush the FIFO + myCAM4.flush_fifo(); + // Clear the capture done flag + myCAM4.clear_fifo_flag(); + // Start capture + printf("CAM4 start capture\n"); + myCAM4.start_capture(); + while (!(myCAM4.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; + printf("CAM4 Capture Done\n"); + + // Open the new file + FILE *fp1 = fopen(argv[2], "w+"); + FILE *fp2 = fopen(argv[3], "w+"); + FILE *fp3 = fopen(argv[4], "w+"); + FILE *fp4 = fopen(argv[5], "w+"); + if (!fp1) + { + printf("Error: could not open %s\n", argv[2]); + exit(EXIT_FAILURE); + } + if (!fp2) + { + printf("Error: could not open %s\n", argv[3]); + exit(EXIT_FAILURE); + } + if (!fp3) + { + printf("Error: could not open %s\n", argv[4]); + exit(EXIT_FAILURE); + } + if (!fp4) + { + printf("Error: could not open %s\n", argv[5]); + exit(EXIT_FAILURE); + } + printf("Reading FIFO and saving IMG\n"); + + size_t len1 = myCAM1.read_fifo_length(); + size_t len2 = myCAM2.read_fifo_length(); + size_t len3 = myCAM3.read_fifo_length(); + size_t len4 = myCAM4.read_fifo_length(); + printf("The len1 is %d\r\n", len1); + printf("The len2 is %d\r\n", len2); + printf("The len3 is %d\r\n", len3); + printf("The len4 is %d\r\n", len4); + if ((len1 >= OV5642_MAX_FIFO_SIZE) || (len2 >= OV5642_MAX_FIFO_SIZE) || (len3 >= OV5642_MAX_FIFO_SIZE) || (len4 >= OV5642_MAX_FIFO_SIZE)) + { + printf("Over size."); + exit(EXIT_FAILURE); + } + if (len1 == 0) + printf("Size1 is 0."); + if (len2 == 0) + printf("Size2 is 0."); + if (len3 == 0) + printf("Size3 is 0."); + if (len4 == 0) + printf("Size4 is 0."); + int32_t i = 0; + myCAM1.CS_LOW(); // Set CS low + myCAM1.set_fifo_burst(); + while (len1--) + { + temp_last = temp; + temp = myCAM1.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM1.CS_HIGH(); + fwrite(buf, i, 1, fp1); + // Close the file + fclose(fp1); + printf("IMG1 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM1.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp1); + i = 0; + buf[i++] = temp; + myCAM1.CS_LOW(); + myCAM1.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM2.CS_LOW(); // Set CS low + myCAM2.set_fifo_burst(); + while (len2--) + { + temp_last = temp; + temp = myCAM2.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM2.CS_HIGH(); + fwrite(buf, i, 1, fp2); + // Close the file + fclose(fp2); + printf("IMG2 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM2.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp2); + i = 0; + buf[i++] = temp; + myCAM2.CS_LOW(); + myCAM2.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM3.CS_LOW(); // Set CS low + myCAM3.set_fifo_burst(); + while (len3--) + { + temp_last = temp; + temp = myCAM3.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM3.CS_HIGH(); + fwrite(buf, i, 1, fp3); + // Close the file + fclose(fp3); + printf("IMG3 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM3.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp3); + i = 0; + buf[i++] = temp; + myCAM3.CS_LOW(); + myCAM3.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + + temp = 0; + temp_last = 0; + i = 0; + myCAM4.CS_LOW(); // Set CS low + myCAM4.set_fifo_burst(); + while (len4--) + { + temp_last = temp; + temp = myCAM4.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM4.CS_HIGH(); + fwrite(buf, i, 1, fp4); + // Close the file + fclose(fp4); + printf("IMG4 save OK !\n"); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM4.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp4); + i = 0; + buf[i++] = temp; + myCAM4.CS_LOW(); + myCAM4.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + } + else + { + printf("Error: unknown or missing argument.\n"); + exit(EXIT_FAILURE); + } + exit(EXIT_SUCCESS); +} diff --git a/ArduCAM/examples/RaspberryPi/arducam_ov5642_capture.cpp b/ArduCAM/examples/RaspberryPi/arducam_ov5642_capture.cpp index 04295098..63a35310 100644 --- a/ArduCAM/examples/RaspberryPi/arducam_ov5642_capture.cpp +++ b/ArduCAM/examples/RaspberryPi/arducam_ov5642_capture.cpp @@ -15,149 +15,164 @@ #include "arducam_arch_raspberrypi.h" #define OV5642_CHIPID_HIGH 0x300a #define OV5642_CHIPID_LOW 0x300b -#define OV5642_MAX_FIFO_SIZE 0x7FFFFF //8MByte +#define OV5642_MAX_FIFO_SIZE 0x7FFFFF // 8MByte #define BUF_SIZE 4096 #define CAM1_CS 5 -#define VSYNC_LEVEL_MASK 0x02 //0 = High active , 1 = Low active +#define VSYNC_LEVEL_MASK 0x02 // 0 = High active , 1 = Low active uint8_t buf[BUF_SIZE]; bool is_header = false; -ArduCAM myCAM(OV5642,CAM1_CS); +ArduCAM myCAM(OV5642, CAM1_CS); void setup() { - uint8_t vid,pid; - uint8_t temp; - wiring_init(); - pinMode(CAM1_CS, OUTPUT); - // Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - //printf("temp=%x\n",temp); - if(temp != 0x55) { - printf("SPI interface error!\n"); - exit(EXIT_FAILURE); - } - // Change MCU mode - myCAM.write_reg(ARDUCHIP_MODE, 0x00); - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)) + uint8_t vid, pid; + uint8_t temp; + wiring_init(); + pinMode(CAM1_CS, OUTPUT); + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + // printf("temp=%x\n",temp); + if (temp != 0x55) + { + printf("SPI interface error!\n"); + exit(EXIT_FAILURE); + } + // Change MCU mode + myCAM.write_reg(ARDUCHIP_MODE, 0x00); + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) printf("Can't find OV5642 module!"); - else - printf("OV5642 detected.\n"); + else + printf("OV5642 detected.\n"); } int main(int argc, char *argv[]) { - uint8_t temp = 0, temp_last = 0; - if (argc == 1) + uint8_t temp = 0, temp_last = 0; + if (argc == 1) + { + printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); + printf(" 320x240\n"); + printf(" 640x480\n"); + printf(" 1280x960\n"); + printf(" 1600x1200\n"); + printf(" 2048x1536\n"); + printf(" 2592x1944\n"); + printf(" -c Capture image\n"); + exit(EXIT_SUCCESS); + } + if (strcmp(argv[1], "-c") == 0 && argc == 4) + { + setup(); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + // Change to JPEG capture mode and initialize the OV2640 module + if (strcmp(argv[3], "320x240") == 0) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + else if (strcmp(argv[3], "640x480") == 0) + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + else if (strcmp(argv[3], "1280x960") == 0) + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + else if (strcmp(argv[3], "1600x1200") == 0) + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + else if (strcmp(argv[3], "2048x1536") == 0) + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + else if (strcmp(argv[3], "2592x1944") == 0) + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + else { - printf("Usage: %s [-s ] | [-c Set resolution, valid resolutions are:\n"); - printf(" 320x240\n"); - printf(" 640x480\n"); - printf(" 1280x960\n"); - printf(" 1600x1200\n"); - printf(" 2048x1536\n"); - printf(" 2592x1944\n"); - printf(" -c Capture image\n"); - exit(EXIT_SUCCESS); - } - if (strcmp(argv[1], "-c") == 0 && argc == 4) - { - setup(); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - // Change to JPEG capture mode and initialize the OV2640 module - if (strcmp(argv[3], "320x240") == 0) myCAM.OV5642_set_JPEG_size(OV5642_320x240); - else if (strcmp(argv[3], "640x480") == 0) myCAM.OV5642_set_JPEG_size(OV5642_640x480); - else if (strcmp(argv[3], "1280x960") == 0) myCAM.OV5642_set_JPEG_size(OV5642_1280x960); - else if (strcmp(argv[3], "1600x1200") == 0) myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); - else if (strcmp(argv[3], "2048x1536") == 0) myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); - else if (strcmp(argv[3], "2592x1944") == 0) myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); - else { printf("Unknown resolution %s\n", argv[3]); exit(EXIT_FAILURE); + } + sleep(1); // Let auto exposure do it's thing after changing image settings + printf("Changed resolution1 to %s\n", argv[3]); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + printf("Start capture\n"); + myCAM.start_capture(); + while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + { + } + printf("CAM Capture Done\n"); + + // Open the new file + FILE *fp1 = fopen(argv[2], "w+"); + if (!fp1) + { + printf("Error: could not open %s\n", argv[2]); + exit(EXIT_FAILURE); + } + + printf("Reading FIFO and saving IMG\n"); + size_t length = myCAM.read_fifo_length(); + printf("The length is %d\r\n", length); + if (length >= OV5642_MAX_FIFO_SIZE) + { + printf("Over size."); + exit(EXIT_FAILURE); + } + else if (length == 0) + { + printf("Size is 0."); + exit(EXIT_FAILURE); + } + int32_t i = 0; + myCAM.CS_LOW(); // Set CS low + myCAM.set_fifo_burst(); + + while (length--) + { + temp_last = temp; + temp = myCAM.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + { + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM.CS_HIGH(); + fwrite(buf, i, 1, fp1); + // Close the file + fclose(fp1); + printf("IMG save OK !\n"); + is_header = false; + i = 0; } - sleep(1); // Let auto exposure do it's thing after changing image settings - printf("Changed resolution1 to %s\n", argv[3]); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - // Flush the FIFO - myCAM.flush_fifo(); - // Clear the capture done flag - myCAM.clear_fifo_flag(); - // Start capture - printf("Start capture\n"); - myCAM.start_capture(); - while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)){} - printf("CAM Capture Done\n"); - - // Open the new file - FILE *fp1 = fopen(argv[2], "w+"); - if (!fp1) { - printf("Error: could not open %s\n", argv[2]); - exit(EXIT_FAILURE); + if (is_header == true) + { + // Write image data to buffer if not full + if (i < BUF_SIZE) + buf[i++] = temp; + else + { + // Write BUF_SIZE bytes image data to file + myCAM.CS_HIGH(); + fwrite(buf, BUF_SIZE, 1, fp1); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } } - - printf("Reading FIFO and saving IMG\n"); - size_t length = myCAM.read_fifo_length(); - printf("The length is %d\r\n", length); - if (length >= OV5642_MAX_FIFO_SIZE){ - printf("Over size."); - exit(EXIT_FAILURE); - }else if (length == 0 ){ - printf("Size is 0."); - exit(EXIT_FAILURE); - } - int32_t i=0; - myCAM.CS_LOW(); //Set CS low - myCAM.set_fifo_burst(); - - while ( length-- ) - { - temp_last = temp; - temp = myCAM.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - fwrite(buf, i, 1, fp1); - //Close the file - fclose(fp1); - printf("IMG save OK !\n"); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < BUF_SIZE) - buf[i++] = temp; - else - { - //Write BUF_SIZE bytes image data to file - myCAM.CS_HIGH(); - fwrite(buf, BUF_SIZE, 1, fp1); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } - } - } - else { - printf("Error: unknown or missing argument.\n"); - exit(EXIT_FAILURE); + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; + buf[i++] = temp; + } + } + } + else + { + printf("Error: unknown or missing argument.\n"); + exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Camera_Playback/ArduCAM_Shield_V2_Camera_Playback.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Camera_Playback/ArduCAM_Shield_V2_Camera_Playback.ino index 05e1e5ec..acbd9749 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Camera_Playback/ArduCAM_Shield_V2_Camera_Playback.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Camera_Playback/ArduCAM_Shield_V2_Camera_Playback.ino @@ -2,8 +2,8 @@ // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with a supported camera modules. -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -//This demo is compatible with ESP8266 +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +// This demo is compatible with ESP8266 // This demo was made for Omnivision OV2640/OV5640/OV5642/ sensor. // It will turn the ArduCAM into a real digital camera with capture and playback functions. // 1. Preview the live video on LCD Screen. @@ -18,264 +18,292 @@ #include #include #include "memorysaver.h" -//This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ -// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ -// OV7725/OV2640/OV3640/OV5640/OV5642 sensor. -#if !(defined ARDUCAM_SHIELD_V2 && (defined MT9D111A_CAM|| defined MT9D111B_CAM || defined MT9M112_CAM \ - || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM \ - || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM \ - || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM \ - || defined OV5642_CAM|| defined OV3640_CAM)) +// This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ +// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ +// OV7725/OV2640/OV3640/OV5640/OV5642 sensor. +#if !(defined ARDUCAM_SHIELD_V2 && (defined MT9D111A_CAM || defined MT9D111B_CAM || defined MT9M112_CAM || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM || defined OV5642_CAM || defined OV3640_CAM)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(__arm__) - #include +#include #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif #define BMPIMAGEOFFSET 66 const int bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; -#if defined (MT9D111A_CAM) - ArduCAM myCAM(MT9D111_A, SPI_CS); -#elif defined (MT9D111B_CAM) - ArduCAM myCAM(MT9D111_B, SPI_CS); -#elif defined (MT9M112_CAM) - ArduCAM myCAM(MT9M112, SPI_CS); -#elif defined (MT9V111_CAM) - ArduCAM myCAM(MT9V111, SPI_CS); -#elif defined (MT9M001_CAM) - ArduCAM myCAM(MT9M001, SPI_CS); -#elif defined (MT9T112_CAM) - ArduCAM myCAM(MT9T112, SPI_CS); -#elif defined (MT9D112_CAM) - ArduCAM myCAM(MT9D112, SPI_CS); -#elif defined (OV7670_CAM) - ArduCAM myCAM(OV7670, SPI_CS); -#elif defined (OV7675_CAM) - ArduCAM myCAM(OV7675, SPI_CS); -#elif defined (OV7725_CAM) - ArduCAM myCAM(OV7725, SPI_CS); -#elif defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; +#if defined(MT9D111A_CAM) +ArduCAM myCAM(MT9D111_A, SPI_CS); +#elif defined(MT9D111B_CAM) +ArduCAM myCAM(MT9D111_B, SPI_CS); +#elif defined(MT9M112_CAM) +ArduCAM myCAM(MT9M112, SPI_CS); +#elif defined(MT9V111_CAM) +ArduCAM myCAM(MT9V111, SPI_CS); +#elif defined(MT9M001_CAM) +ArduCAM myCAM(MT9M001, SPI_CS); +#elif defined(MT9T112_CAM) +ArduCAM myCAM(MT9T112, SPI_CS); +#elif defined(MT9D112_CAM) +ArduCAM myCAM(MT9D112, SPI_CS); +#elif defined(OV7670_CAM) +ArduCAM myCAM(OV7670, SPI_CS); +#elif defined(OV7675_CAM) +ArduCAM myCAM(OV7675, SPI_CS); +#elif defined(OV7725_CAM) +ArduCAM myCAM(OV7725, SPI_CS); +#elif defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif UTFT myGLCD(SPI_CS); void setup() { -uint8_t vid, pid; -uint8_t temp; + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -//initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55) + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) { - Serial.println(F("SPI interface Error!")); - delay(1000); continue; - } else{ - Serial.println(F("SPI interface OK"));break; - } -} -#if defined (OV2640_CAM) -while(1){ - //Check if the camera module type is OV2640 - myCAM.wrSensorReg8_8(0xff, 0x01); - myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV2640 detected."));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK")); + break; + } } -} -#elif defined (OV3640_CAM) - while(1){ - //Check if the camera module type is OV3640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 + myCAM.wrSensorReg8_8(0xff, 0x01); + myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + Serial.println(F("Can't find OV2640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; + delay(1000); + continue; } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5640 + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5640 myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } + } +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } - } -#elif defined (OV5642_CAM) -while(1){ - //Check if the camera module type is OV5642 - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5642 detected."));break; } -} #endif -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -//Initialize the LCD Module -myGLCD.InitLCD(); -myCAM.InitCAM(); -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} - Serial.println(F("SD Card detected!")); + // Change MCU mode + myCAM.set_mode(MCU2LCD_MODE); + // Initialize the LCD Module + myGLCD.InitLCD(); + myCAM.InitCAM(); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); + } + Serial.println(F("SD Card detected!")); } void loop() { -char str[8]; -unsigned long previous_time = 0; -static int k = 0; -myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM -while (1) -{ - #if defined(ESP8266) - yield(); - #endif - if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) //New Frame is coming - { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)); //Wait for VSYNC is gone - } - else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + char str[8]; + unsigned long previous_time = 0; + static int k = 0; + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (1) { - previous_time = millis(); - while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) +#if defined(ESP8266) + yield(); +#endif + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming { - if ((millis() - previous_time) > 1500) - { - Playback(); - } + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone } - if ((millis() - previous_time) < 1500) + else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { - k = k + 1; - itoa(k, str, 10); - strcat(str, ".bmp"); //Generate file name - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU, freeze the screen - GrabImage(str); + previous_time = millis(); + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + { + if ((millis() - previous_time) > 1500) + { + Playback(); + } + } + if ((millis() - previous_time) < 1500) + { + k = k + 1; + itoa(k, str, 10); + strcat(str, ".bmp"); // Generate file name + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU, freeze the screen + GrabImage(str); + } } } } -} -void GrabImage(char* str) -{ -File outFile; -char VH, VL; -byte buf[256]; -static int k = 0; -int i, j = 0; -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("File open error")); - return; -} -//Flush the FIFO -myCAM.flush_fifo(); -//Start capture -myCAM.start_capture(); -Serial.println(F("Start Capture")); -//Polling the capture done flag -while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -k = 0; -//Write the BMP header -for ( i = 0; i < BMPIMAGEOFFSET; i++) -{ - char ch = pgm_read_byte(&bmp_header[i]); - buf[k++] = ch; -} -outFile.write(buf, k); -k = 0; -//Read 320x240x2 byte from FIFO -//Save as RGB565 bmp format -for (i = 0; i < 240; i++) -for (j = 0; j < 320; j++) +void GrabImage(char *str) { - VH = myCAM.read_fifo(); - VL = myCAM.read_fifo(); - buf[k++] = VL; - buf[k++] = VH; - #if defined(ESP8266) - yield(); - #endif - //Write image data to bufer if not full - if (k >= 256) + File outFile; + char VH, VL; + byte buf[256]; + static int k = 0; + int i, j = 0; + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) { - //Write 256 bytes image data to file from buffer - outFile.write(buf, 256); - k = 0; + Serial.println(F("File open error")); + return; } -} -//Close the file -outFile.close(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Switch to LCD Mode -myCAM.write_reg(ARDUCHIP_TIM, 0); -return; + // Flush the FIFO + myCAM.flush_fifo(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); + // Polling the capture done flag + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + k = 0; + // Write the BMP header + for (i = 0; i < BMPIMAGEOFFSET; i++) + { + char ch = pgm_read_byte(&bmp_header[i]); + buf[k++] = ch; + } + outFile.write(buf, k); + k = 0; + // Read 320x240x2 byte from FIFO + // Save as RGB565 bmp format + for (i = 0; i < 240; i++) + for (j = 0; j < 320; j++) + { + VH = myCAM.read_fifo(); + VL = myCAM.read_fifo(); + buf[k++] = VL; + buf[k++] = VH; +#if defined(ESP8266) + yield(); +#endif + // Write image data to bufer if not full + if (k >= 256) + { + // Write 256 bytes image data to file from buffer + outFile.write(buf, 256); + k = 0; + } + } + // Close the file + outFile.close(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Switch to LCD Mode + myCAM.write_reg(ARDUCHIP_TIM, 0); + return; } void Playback() { File inFile; char str[8]; int k = 0; - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU myGLCD.InitLCD(PORTRAIT); while (1) { @@ -283,33 +311,33 @@ void Playback() itoa(k, str, 10); strcat(str, ".bmp"); inFile = SD.open(str, FILE_READ); - if (! inFile) - return; + if (!inFile) + return; myGLCD.clrScr(); - //myGLCD.resetXY(); + // myGLCD.resetXY(); dispBitmap(inFile); inFile.close(); delay(2000); } } -//Only support RGB565 bmp format +// Only support RGB565 bmp format void dispBitmap(File inFile) -{ +{ char VH = 0, VL = 0; int i, j = 0; - for (i = 0 ; i < BMPIMAGEOFFSET; i++) - inFile.read(); + for (i = 0; i < BMPIMAGEOFFSET; i++) + inFile.read(); for (i = 0; i < 320; i++) - for (j = 0; j < 240; j++) - { - VL = inFile.read(); - //Serial.write(VL); - VH = inFile.read(); - //Serial.write(VH); - #if defined(ESP8266) + for (j = 0; j < 240; j++) + { + VL = inFile.read(); + // Serial.write(VL); + VH = inFile.read(); +// Serial.write(VH); +#if defined(ESP8266) yield(); - #endif - myGLCD.LCD_Write_DATA(VH, VL); - } +#endif + myGLCD.LCD_Write_DATA(VH, VL); + } myGLCD.clrXY(); } diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Capture2SD/ArduCAM_Shield_V2_Capture2SD.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Capture2SD/ArduCAM_Shield_V2_Capture2SD.ino index 5a774e56..f814edd8 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Capture2SD/ArduCAM_Shield_V2_Capture2SD.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Capture2SD/ArduCAM_Shield_V2_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM ESP8266 2MP/3MP/5MP as a real 2MP/3MP/5MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_REVC @@ -17,216 +17,255 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -#if !(defined (ARDUCAM_SHIELD_V2)&&(defined (OV5640_CAM) ||defined (OV5642_CAM)||defined (OV2640_CAM)||defined (OV3640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +#if !(defined(ARDUCAM_SHIELD_V2) && (defined(OV5640_CAM) || defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV3640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif -#if defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif -void myCAMSaveToSDFile(){ -char str[8]; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -bool is_header = false; -File outFile; -//Flush the FIFO -myCAM.flush_fifo(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Start capture -myCAM.start_capture(); -Serial.println(F("Start Capture")); -while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //8M +void myCAMSaveToSDFile() { - Serial.println(F("Over size.")); - return ; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return ; -} -//Construct a file name -k = k + 1; -itoa(k, str, 10); -strcat(str, ".jpg"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if(! outFile){ - Serial.println(F("File open faild")); - return; -} -i = 0; -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + char str[8]; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + bool is_header = false; + File outFile; + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image save OK!")); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return; + } + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open faild")); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image save OK!")); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } -} } -void setup(){ -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -//set the CS as an output: -pinMode(SPI_CS,OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} -Serial.println(F("SD Card detected.")); -#if defined (OV2640_CAM) -while(1){ - //Check if the camera module type is OV2640 + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); + } + Serial.println(F("SD Card detected.")); +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; } - } -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } -#elif defined (OV5640_CAM) -while(1){ - //Check if the camera module type is OV5640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ - Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } } -#elif defined (OV5642_CAM) -while(1){ - //Check if the camera module type is OV5642 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("Can't find OV3640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x40)) + { + Serial.println(F("Can't find OV5640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } + } +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; + } } -} #endif -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); -#elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); -#elif defined (OV5640_CAM) - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); -#elif defined (OV5642_CAM) - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); +#elif defined(OV5642_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -delay(1000); + delay(1000); } -void loop(){ +void loop() +{ myCAMSaveToSDFile(); delay(5000); } - - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera/ArduCAM_Shield_V2_Digital_Camera.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera/ArduCAM_Shield_V2_Digital_Camera.ino index ffeb557d..35df1b11 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera/ArduCAM_Shield_V2_Digital_Camera.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera/ArduCAM_Shield_V2_Digital_Camera.ino @@ -2,12 +2,12 @@ // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with a supported camera modules//This demo can only work on ARDUCAM_SHIELD_V2 platform. -//This demo is compatible with ESP8266 +// This demo is compatible with ESP8266 // It will run the ArduCAM as a real 2MP/3MP/5MP digital camera, provide both preview and JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to BMP preview output mode. // 2. Switch to JPEG mode when shutter buttom pressed. -// 3. Capture and buffer the image to FIFO. +// 3. Capture and buffer the image to FIFO. // 4. Store the image to Micro SD/TF card with JPEG format. // 5. Resolution can be changed by myCAM.OV5642_set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM shield V2 @@ -19,298 +19,329 @@ #include #include #include "memorysaver.h" -//This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ -// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ -// OV7725/OV2640/OV5640/OV5642 sensor. -#if !(defined ARDUCAM_SHIELD_V2 && (defined MT9D111A_CAM|| defined MT9D111B_CAM || defined MT9M112_CAM \ - || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM \ - || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM \ - || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM \ - || defined OV5642_CAM || defined OV3640_CAM)) +// This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ +// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ +// OV7725/OV2640/OV5640/OV5642 sensor. +#if !(defined ARDUCAM_SHIELD_V2 && (defined MT9D111A_CAM || defined MT9D111B_CAM || defined MT9M112_CAM || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM || defined OV5642_CAM || defined OV3640_CAM)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(__arm__) - #include +#include #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif -#if defined (MT9D111A_CAM) - ArduCAM myCAM(MT9D111_A, SPI_CS); -#elif defined (MT9D111B_CAM) - ArduCAM myCAM(MT9D111_B, SPI_CS); -#elif defined (MT9M112_CAM) - ArduCAM myCAM(MT9M112, SPI_CS); -#elif defined (MT9V111_CAM) - ArduCAM myCAM(MT9V111, SPI_CS); -#elif defined (MT9M001_CAM) - ArduCAM myCAM(MT9M001, SPI_CS); -#elif defined (MT9T112_CAM) - ArduCAM myCAM(MT9T112, SPI_CS); -#elif defined (MT9D112_CAM) - ArduCAM myCAM(MT9D112, SPI_CS); -#elif defined (OV7670_CAM) - ArduCAM myCAM(OV7670, SPI_CS); -#elif defined (OV7675_CAM) - ArduCAM myCAM(OV7675, SPI_CS); -#elif defined (OV7725_CAM) - ArduCAM myCAM(OV7725, SPI_CS); -#elif defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(MT9D111A_CAM) +ArduCAM myCAM(MT9D111_A, SPI_CS); +#elif defined(MT9D111B_CAM) +ArduCAM myCAM(MT9D111_B, SPI_CS); +#elif defined(MT9M112_CAM) +ArduCAM myCAM(MT9M112, SPI_CS); +#elif defined(MT9V111_CAM) +ArduCAM myCAM(MT9V111, SPI_CS); +#elif defined(MT9M001_CAM) +ArduCAM myCAM(MT9M001, SPI_CS); +#elif defined(MT9T112_CAM) +ArduCAM myCAM(MT9T112, SPI_CS); +#elif defined(MT9D112_CAM) +ArduCAM myCAM(MT9D112, SPI_CS); +#elif defined(OV7670_CAM) +ArduCAM myCAM(OV7670, SPI_CS); +#elif defined(OV7675_CAM) +ArduCAM myCAM(OV7675, SPI_CS); +#elif defined(OV7725_CAM) +ArduCAM myCAM(OV7725, SPI_CS); +#elif defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif UTFT myGLCD(SPI_CS); boolean isShowFlag = true; bool is_header = false; void setup() { -uint8_t vid,pid; -uint8_t temp; + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -myGLCD.InitLCD(); -#if defined (OV2640_CAM) -while(1){ - //Check if the camera module type is OV2640 - myCAM.wrSensorReg8_8(0xff, 0x01); - myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + // Change MCU mode + myCAM.set_mode(MCU2LCD_MODE); + myGLCD.InitLCD(); +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 + myCAM.wrSensorReg8_8(0xff, 0x01); + myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + Serial.println(F("Can't find OV2640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("Can't find OV3640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; + } } -} -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5640 +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} -Serial.println(F("SD Card detected!")); -//Change to BMP capture mode and initialize the OV5642 module -myCAM.set_format(BMP); -myCAM.InitCAM(); -} -void loop() -{ -char str[8]; -File outFile; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp=0,temp_last =0; -uint32_t length = 0; -uint8_t start_capture = 0; -int total_time = 0; -//Wait trigger from shutter buttom -if(myCAM.get_bit(ARDUCHIP_TRIG , SHUTTER_MASK)) -{ - isShowFlag = false; - myCAM.set_mode(MCU2LCD_MODE); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); - #elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - #elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - #endif - //Wait until buttom released - while(myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)); - delay(1000); - start_capture = 1; -} -else -{ - if(isShowFlag ) + // Initialize SD Card + while (!SD.begin(SD_CS)) { - if(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)) //New Frame is coming - { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)); //Wait for VSYNC is gone - } + Serial.println(F("SD Card Error")); + delay(1000); } + Serial.println(F("SD Card detected!")); + // Change to BMP capture mode and initialize the OV5642 module + myCAM.set_format(BMP); + myCAM.InitCAM(); } -if(start_capture) -{ - //Flush the FIFO - myCAM.flush_fifo(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - Serial.println(F("Start Capture")); -} -if(myCAM.get_bit(ARDUCHIP_TRIG ,CAP_DONE_MASK)) +void loop() { - Serial.println(F("Capture Done.")); - length = myCAM.read_fifo_length(); - Serial.print(F("The fifo length is :")); - Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //8M + char str[8]; + File outFile; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + uint8_t start_capture = 0; + int total_time = 0; + // Wait trigger from shutter buttom + if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { - Serial.println(F("Over size.")); - return ; + isShowFlag = false; + myCAM.set_mode(MCU2LCD_MODE); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#endif + // Wait until buttom released + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + ; + delay(1000); + start_capture = 1; } - if (length == 0 ) //0 kb + else { - Serial.println(F("Size is 0.")); - return; + if (isShowFlag) + { + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming + { + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone + } + } } - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str,".jpg"); - //Open the new file - outFile = SD.open(str,O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) - { - Serial.println(F("File open failed")); - return; + if (start_capture) + { + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); } - i = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - #if defined (ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image save OK.")); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return; + } + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open failed")); + return; + } + i = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) + { +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image save OK.")); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Clear the start capture flag + start_capture = 0; + myCAM.set_format(BMP); + myCAM.InitCAM(); + isShowFlag = true; } - //Clear the capture done flag - myCAM.clear_fifo_flag(); - //Clear the start capture flag - start_capture = 0; - myCAM.set_format(BMP); - myCAM.InitCAM(); - isShowFlag = true; } -} - - - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera_2560/ArduCAM_Shield_V2_Digital_Camera_2560.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera_2560/ArduCAM_Shield_V2_Digital_Camera_2560.ino index fd9f06c5..e654a0d3 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera_2560/ArduCAM_Shield_V2_Digital_Camera_2560.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Digital_Camera_2560/ArduCAM_Shield_V2_Digital_Camera_2560.ino @@ -2,7 +2,7 @@ // Web: http://www.ArduCAM.com // This program is a demo of how to use most of the functions // of the library with a supported camera modules//This demo can only work on ARDUCAM_SHIELD_V2 platform. -//This demo is compatible with ESP8266 +// This demo is compatible with ESP8266 // It will run the ArduCAM as a real 2MP/3MP/5MP digital camera, provide both preview and JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to BMP preview output mode. @@ -20,14 +20,10 @@ #include #include #include "memorysaver.h" -//This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ -// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ -// OV7725/OV2640/OV5640/OV5642 sensor. -#if !(defined ARDUCAM_SHIELD_V2 && (defined MT9D111A_CAM|| defined MT9D111B_CAM || defined MT9M112_CAM \ - || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM \ - || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM \ - || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM \ - || defined OV5642_CAM || defined OV3640_CAM)) +// This demo was made for Omnivision MT9D111A/MT9D111B/MT9M112/MT9V111_CAM/ +// MT9M001/MT9T112/MT9D112/OV7670/OV7675/ +// OV7725/OV2640/OV5640/OV5642 sensor. +#if !(defined ARDUCAM_SHIELD_V2 && (defined MT9D111A_CAM || defined MT9D111B_CAM || defined MT9M112_CAM || defined MT9V111_CAM || defined MT9M001_CAM || defined MT9T112_CAM || defined MT9D112_CAM || defined OV7670_CAM || defined OV7675_CAM || defined OV7725_CAM || defined OV2640_CAM || defined OV5640_CAM || defined OV5642_CAM || defined OV3640_CAM)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(__arm__) @@ -42,12 +38,10 @@ const int SPI_CS = 16; const int SPI_CS = 10; #endif -#define FRAMES_NUM 0x07 -#define rate 0x0a +#define FRAMES_NUM 0x07 +#define rate 0x0a #define AVIOFFSET 240 - - boolean isShowFlag = true; bool is_header = false; unsigned long previous_time = 0; @@ -66,56 +60,285 @@ unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; const int avi_header[AVIOFFSET] PROGMEM = { - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xf0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xf0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -void print_quartet(unsigned long i, File fd) { - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -#if defined (MT9D111A_CAM) +#if defined(MT9D111A_CAM) ArduCAM myCAM(MT9D111_A, SPI_CS); -#elif defined (MT9D111B_CAM) +#elif defined(MT9D111B_CAM) ArduCAM myCAM(MT9D111_B, SPI_CS); -#elif defined (MT9M112_CAM) +#elif defined(MT9M112_CAM) ArduCAM myCAM(MT9M112, SPI_CS); -#elif defined (MT9V111_CAM) +#elif defined(MT9V111_CAM) ArduCAM myCAM(MT9V111, SPI_CS); -#elif defined (MT9M001_CAM) +#elif defined(MT9M001_CAM) ArduCAM myCAM(MT9M001, SPI_CS); -#elif defined (MT9T112_CAM) +#elif defined(MT9T112_CAM) ArduCAM myCAM(MT9T112, SPI_CS); -#elif defined (MT9D112_CAM) +#elif defined(MT9D112_CAM) ArduCAM myCAM(MT9D112, SPI_CS); -#elif defined (OV7670_CAM) +#elif defined(OV7670_CAM) ArduCAM myCAM(OV7670, SPI_CS); -#elif defined (OV7675_CAM) +#elif defined(OV7675_CAM) ArduCAM myCAM(OV7675, SPI_CS); -#elif defined (OV7725_CAM) +#elif defined(OV7725_CAM) ArduCAM myCAM(OV7725, SPI_CS); -#elif defined (OV2640_CAM) +#elif defined(OV2640_CAM) ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) +#elif defined(OV3640_CAM) ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5640_CAM) +#elif defined(OV5640_CAM) ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) ArduCAM myCAM(OV5642, SPI_CS); #endif UTFT myGLCD(SPI_CS); @@ -136,101 +359,135 @@ void setup() digitalWrite(SPI_CS, HIGH); // initialize SPI: SPI.begin(); - - //Reset the CPLD + + // Reset the CPLD myCAM.write_reg(0x07, 0x80); delay(100); myCAM.write_reg(0x07, 0x00); delay(100); - - while (1) { - //Check if the ArduCAM SPI bus is OK + + while (1) + { + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55) { + if (temp != 0x55) + { Serial.println(F("SPI interface Error!")); - delay(1000); continue; - } else { - Serial.println(F("SPI interface OK!")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; } } - //Change MCU mode + // Change MCU mode myCAM.set_mode(MCU2LCD_MODE); myGLCD.InitLCD(); -#if defined (OV2640_CAM) - while (1) { - //Check if the camera module type is OV2640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) { + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000); continue; - } else { - Serial.println(F("OV2640 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; } } -#elif defined (OV3640_CAM) - while (1) { - //Check if the camera module type is OV3640 +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)) { + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module!")); - delay(1000); continue; - } else { - Serial.println(F("OV3640 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; } } -#elif defined (OV5640_CAM) - while (1) { - //Check if the camera module type is OV5640 +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5640 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)) { + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000); continue; - } else { - Serial.println(F("OV5640 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; } } -#elif defined (OV5642_CAM) - while (1) { - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)) { + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000); continue; - } else { - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif - //Initialize SD Card - while (!SD.begin(SD_CS)) { - Serial.println(F("SD Card Error")); delay(1000); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); } Serial.println(F("SD Card detected!")); - //Change to BMP capture mode and initialize the OV5642 module + // Change to BMP capture mode and initialize the OV5642 module myCAM.set_format(BMP); myCAM.InitCAM(); } void loop() { - while (1) { + while (1) + { #if defined(ESP8266) yield(); #endif - if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) //New Frame is coming + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)); //Wait for VSYNC is gone + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone } else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { @@ -240,7 +497,7 @@ void loop() if ((millis() - previous_time) > 1500) { saveShortMovie(); - //Serial.println("Save video Streaming "); + // Serial.println("Save video Streaming "); } } if ((millis() - previous_time) < 1500) @@ -249,57 +506,59 @@ void loop() } } } - } - - - -void saveImageJPEG() { +void saveImageJPEG() +{ myCAM.set_mode(MCU2LCD_MODE); myCAM.set_format(JPEG); myCAM.InitCAM(); -#if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_640x480); delay(1000); -#elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_320x240); delay(1000); -#elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240); delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -#elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_320x240); delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH #endif myCAM.write_reg(ARDUCHIP_FRAMES, 0); - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println(F("Start Capture")); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; Serial.println(F("Capture Done.")); length = myCAM.read_fifo_length(); Serial.print(F("The fifo length is :")); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //8M + if (length >= MAX_FIFO_SIZE) // 8M { Serial.println(F("Over size.")); - return ; + return; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("Size is 0.")); return; } - //Construct a file name + // Construct a file name k = k + 1; itoa(k, str, 10); strcat(str, ".jpg"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println(F("File open failed")); return; @@ -307,21 +566,21 @@ void saveImageJPEG() { i = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - while ( length-- ) + while (length--) { -#if defined (ESP8266) +#if defined(ESP8266) yield(); #endif temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); outFile.write(buf, i); - //Close the file + // Close the file outFile.close(); Serial.println(F("Image save OK.")); is_header = false; @@ -329,12 +588,12 @@ void saveImageJPEG() { } if (is_header == true) { - //Write image data to buffer if not full + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -350,16 +609,14 @@ void saveImageJPEG() { buf[i++] = temp; } } - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Clear the start capture flag + // Clear the start capture flag start_capture = 0; myCAM.set_format(BMP); myCAM.InitCAM(); - } - uint8_t saveShortMovie() { uint8_t temp = 0, temp_last = 0; @@ -372,90 +629,102 @@ uint8_t saveShortMovie() char str[8]; byte buf[256]; - myCAM.set_mode(MCU2LCD_MODE); + myCAM.set_mode(MCU2LCD_MODE); myCAM.set_format(JPEG); myCAM.InitCAM(); -#if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_640x480); delay(1000); -#elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_320x240); delay(1000); -#elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240); delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -#elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_320x240); delay(1000); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH #endif - //Flush the FIFO + // Flush the FIFO myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); - //Start capture + // Start capture myCAM.start_capture(); Serial.println(F("Start recording video...")); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)){;} + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + ; + } length = myCAM.read_fifo_length(); - if ( length < 0x3FFFFF) { + if (length < 0x3FFFFF) + { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { -#if defined (ESP8266) + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { +#if defined(ESP8266) yield(); #endif } Serial.println(F("Record video finish.")); total_time = millis() - total_time; - } else { + } + else + { Serial.println(F("Record video finish")); total_time = millis() - total_time; } Serial.print(F("The fifo length is :")); Serial.println(length, DEC); Serial.println("Writing the video data to the SD card..."); - if (length >= MAX_FIFO_SIZE) //8M + if (length >= MAX_FIFO_SIZE) // 8M { Serial.println(F("Over size.")); - return 0 ; + return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("Size is 0.")); return 0; } movi_size = 0; - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".avi"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println(F("File open failed")); - while (1); + while (1) + ; } - //Write AVI Header - for ( i = 0; i < AVIOFFSET; i++) + // Write AVI Header + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; } outFile.write(buf, AVIOFFSET); myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode + myCAM.set_fifo_burst(); // Set fifo burst mode i = 0; - while ( length-- ) + while (length--) { -#if defined (ESP8266) +#if defined(ESP8266) yield(); #endif temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); outFile.write(buf, i); jpeg_size += i; @@ -479,12 +748,12 @@ uint8_t saveShortMovie() } if (is_header == true) { - //Write image data to buffer if not full + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -509,25 +778,25 @@ uint8_t saveShortMovie() } } myCAM.CS_HIGH(); - //Modify the MJPEG header from the beginning of the file + // Modify the MJPEG header from the beginning of the file outFile.seek(4); - print_quartet(movi_size + 12 * frame_cnt + 4, outFile); //riff file size - //overwrite hdrl + print_quartet(movi_size + 12 * frame_cnt + 4, outFile); // riff file size + // overwrite hdrl unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - unsigned long tot_frames = frame_cnt; //hdrl.avih.tot_frames + unsigned long tot_frames = frame_cnt; // hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(tot_frames, outFile); unsigned long frames = frame_cnt; // (TOTALFRAMES); //hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(frames, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again - //Close the file + print_quartet(movi_size, outFile); // size again + // Close the file outFile.close(); is_header = false; Serial.println(F("Movie save OK.")); @@ -535,5 +804,3 @@ uint8_t saveShortMovie() myCAM.InitCAM(); return 1; } - - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9D111_Camera_JPEG/ArduCAM_Shield_V2_MT9D111_Camera_JPEG.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9D111_Camera_JPEG/ArduCAM_Shield_V2_MT9D111_Camera_JPEG.ino index e79e1608..72e48345 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9D111_Camera_JPEG/ArduCAM_Shield_V2_MT9D111_Camera_JPEG.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9D111_Camera_JPEG/ArduCAM_Shield_V2_MT9D111_Camera_JPEG.ino @@ -5,7 +5,7 @@ // This demo will run the MT9D111 with JPEG mode, it is compatible with autofocus and non-autofocus. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG output mode. -// 2. Capture and buffer the image to FIFO. +// 2. Capture and buffer the image to FIFO. // 3. Store the image to Micro SD/TF card with JPEG format. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM shield V2 // and use Arduino IDE 1.8.9 compiler or above. @@ -22,102 +22,101 @@ #define SD_CS 9 #define JPEGIMAGEOFFSET 625 - // w1 = 0x0140; 320 - // h1 = 0x00f0; 240 - // w2 = 0x0320; 800 - // h2 = 0x0258; 600 - // w2 = 0x0640; 1600 - // h2 = 0x04B0; 1200 - +// w1 = 0x0140; 320 +// h1 = 0x00f0; 240 +// w2 = 0x0320; 800 +// h2 = 0x0258; 600 +// w2 = 0x0640; 1600 +// h2 = 0x04B0; 1200 + int jpeg = 1; unsigned long jpeg_length = 0; // Set the offset to adjust the error data at the end of the image. int16_t OFFSET = 50; -//set resolution +// set resolution const uint16_t width = 1600; const uint16_t height = 1200; // set pin 10 as the slave select for the ArduCAM shiel: const int slaveSelectPin = 10; const char JPEG_header[625] PROGMEM = -{ - 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, - 0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, - 0x03, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x05, 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x09, 0x07, - 0x07, 0x05, 0x08, 0x0b, 0x0a, 0x0b, 0x0b, 0x0b, 0x0a, 0x0b, 0x0a, 0x0c, 0x0e, 0x11, 0x0f, 0x0c, - 0x0d, 0x10, 0x0d, 0x0a, 0x0b, 0x0f, 0x14, 0x0f, 0x10, 0x12, 0x12, 0x13, 0x14, 0x13, 0x0c, 0x0e, - 0x15, 0x17, 0x15, 0x13, 0x17, 0x11, 0x13, 0x13, 0x13, 0x01, 0x03, 0x03, 0x03, 0x05, 0x04, 0x05, - 0x09, 0x05, 0x05, 0x09, 0x13, 0x0c, 0x0b, 0x0c, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, - 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x04, - 0x80, 0x06, 0x40, 0x03, 0x00, 0x21, 0x00, 0x01, 0x11, 0x01, 0x02, 0x11, 0x01, 0xff, 0xc4, 0x00, - 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, - 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, - 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, - 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, - 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, - 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, - 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, - 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, - 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, - 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, - 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, - 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, - 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, - 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, - 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, - 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, - 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, - 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, - 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, - 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, - 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, - 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, - 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, - 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, - 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xdd, 0x00, - 0x04, 0x00, 0x20, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3f, - 0x00 -}; + { + 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, + 0x00, 0x01, 0x00, 0x00, 0xff, 0xdb, 0x00, 0x84, 0x00, 0x03, 0x02, 0x02, 0x03, 0x02, 0x02, 0x03, + 0x03, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x05, 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x09, 0x07, + 0x07, 0x05, 0x08, 0x0b, 0x0a, 0x0b, 0x0b, 0x0b, 0x0a, 0x0b, 0x0a, 0x0c, 0x0e, 0x11, 0x0f, 0x0c, + 0x0d, 0x10, 0x0d, 0x0a, 0x0b, 0x0f, 0x14, 0x0f, 0x10, 0x12, 0x12, 0x13, 0x14, 0x13, 0x0c, 0x0e, + 0x15, 0x17, 0x15, 0x13, 0x17, 0x11, 0x13, 0x13, 0x13, 0x01, 0x03, 0x03, 0x03, 0x05, 0x04, 0x05, + 0x09, 0x05, 0x05, 0x09, 0x13, 0x0c, 0x0b, 0x0c, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x04, + 0x80, 0x06, 0x40, 0x03, 0x00, 0x21, 0x00, 0x01, 0x11, 0x01, 0x02, 0x11, 0x01, 0xff, 0xc4, 0x00, + 0x1f, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, + 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, + 0x00, 0x01, 0x7d, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, + 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, + 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, + 0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, + 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, + 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, + 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, + 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, + 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, + 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, + 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, + 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04, + 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, + 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, + 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, + 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, + 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, + 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, + 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, + 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, + 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, + 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, + 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xdd, 0x00, + 0x04, 0x00, 0x20, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x01, 0x11, 0x02, 0x11, 0x00, 0x3f, + 0x00}; const uint16_t patch_addr_0400[206] PROGMEM = { - 0x0400, - 0x00cc, - 0xce06, 0x10ed, 0x0230, 0xec00, 0xce06, 0x10ed, 0x00ce, 0x0610, - 0xec04, 0xc300, 0x01ed, 0x04ce, 0x1070, 0xc603, 0xe70f, 0xc611, - 0xe740, 0xc680, 0xe742, 0xc603, 0xe701, 0xc6fe, 0xe74c, 0xc600, - 0xe71a, 0xe71b, 0xe710, 0xe712, 0xc680, 0xe711, 0xc680, 0xe713, - 0xc601, 0xe744, 0xc6fe, 0xe746, 0x39ce, 0x0620, 0xed02, 0x30ec, - 0x00ce, 0x0620, 0xed00, 0xce06, 0x20e6, 0x05cb, 0x01c4, 0x7fe7, - 0x05ce, 0x0720, 0x3a18, 0xce06, 0x2018, 0xe603, 0xe700, 0x3c34, - 0xce01, 0x0de6, 0x03e7, 0x04ce, 0x0620, 0xe603, 0xce01, 0x0de7, - 0x03ce, 0x1070, 0xc602, 0xe703, 0xc6ff, 0xe746, 0xc601, 0xe745, - 0x18ce, 0x010d, 0x18e6, 0x034f, 0xc300, 0x0105, 0xed10, 0x18e6, - 0x034f, 0x1830, 0x18ed, 0x01cc, 0x0101, 0x18a3, 0x0105, 0xed12, - 0xc600, 0xe745, 0xc6fe, 0xe746, 0xc602, 0xe703, 0x4fcc, 0x0050, // 50 is time needed for lens setling - 0xbd9b, 0x1118, 0xce01, 0x0d18, 0xe605, 0xca02, 0x18e7, 0x0530, - 0xc603, 0x3a35, 0x39ce, 0x0630, 0xed02, 0x30ec, 0x00ce, 0x0630, - 0xed00, 0xce06, 0x30ec, 0x08c3, 0x0001, 0xed08, 0x39ce, 0x0640, - 0xed02, 0x30ec, 0x00ce, 0x0640, 0xed00, 0xcc06, 0x40ec, 0x08c3, - 0x0001, 0xed08, 0xbd9c, 0x43c1, 0x0126, 0x1218, 0xce01, 0x0d18, - 0xe605, 0xf400, 0xfd18, 0xe705, 0xce06, 0x40e7, 0x04ce, 0x0640, - 0xe704, 0x18ce, 0x010d, 0x18e6, 0x0539, 0x3c3c, 0x3c3c, 0x34cc, - 0x02c4, 0x30ed, 0x06fe, 0x1050, 0xec0c, 0xfd02, 0xc0fe, 0x02c0, - 0xec00, 0xfd02, 0xc230, 0x6f08, 0xe608, 0x4f05, 0xf302, 0xc28f, - 0xec00, 0x30ed, 0x00e6, 0x084f, 0x05e3, 0x0618, 0x8fec, 0x0018, - 0xed00, 0x6c08, 0xe608, 0xc104, 0x25de, 0x30ee, 0x06cc, 0x0400, - 0xed00, 0x30ee, 0x06cc, 0x0449, 0xed02, 0x30ee, 0x06cc, 0x04d5, - 0xed04, 0x30ee, 0x06cc, 0x04ed, 0xed06, 0xcc02, 0xc4fe, 0x010d, - 0xed00, 0x30c6, 0x093a, 0x3539 -}; + 0x0400, + 0x00cc, + 0xce06, 0x10ed, 0x0230, 0xec00, 0xce06, 0x10ed, 0x00ce, 0x0610, + 0xec04, 0xc300, 0x01ed, 0x04ce, 0x1070, 0xc603, 0xe70f, 0xc611, + 0xe740, 0xc680, 0xe742, 0xc603, 0xe701, 0xc6fe, 0xe74c, 0xc600, + 0xe71a, 0xe71b, 0xe710, 0xe712, 0xc680, 0xe711, 0xc680, 0xe713, + 0xc601, 0xe744, 0xc6fe, 0xe746, 0x39ce, 0x0620, 0xed02, 0x30ec, + 0x00ce, 0x0620, 0xed00, 0xce06, 0x20e6, 0x05cb, 0x01c4, 0x7fe7, + 0x05ce, 0x0720, 0x3a18, 0xce06, 0x2018, 0xe603, 0xe700, 0x3c34, + 0xce01, 0x0de6, 0x03e7, 0x04ce, 0x0620, 0xe603, 0xce01, 0x0de7, + 0x03ce, 0x1070, 0xc602, 0xe703, 0xc6ff, 0xe746, 0xc601, 0xe745, + 0x18ce, 0x010d, 0x18e6, 0x034f, 0xc300, 0x0105, 0xed10, 0x18e6, + 0x034f, 0x1830, 0x18ed, 0x01cc, 0x0101, 0x18a3, 0x0105, 0xed12, + 0xc600, 0xe745, 0xc6fe, 0xe746, 0xc602, 0xe703, 0x4fcc, 0x0050, // 50 is time needed for lens setling + 0xbd9b, 0x1118, 0xce01, 0x0d18, 0xe605, 0xca02, 0x18e7, 0x0530, + 0xc603, 0x3a35, 0x39ce, 0x0630, 0xed02, 0x30ec, 0x00ce, 0x0630, + 0xed00, 0xce06, 0x30ec, 0x08c3, 0x0001, 0xed08, 0x39ce, 0x0640, + 0xed02, 0x30ec, 0x00ce, 0x0640, 0xed00, 0xcc06, 0x40ec, 0x08c3, + 0x0001, 0xed08, 0xbd9c, 0x43c1, 0x0126, 0x1218, 0xce01, 0x0d18, + 0xe605, 0xf400, 0xfd18, 0xe705, 0xce06, 0x40e7, 0x04ce, 0x0640, + 0xe704, 0x18ce, 0x010d, 0x18e6, 0x0539, 0x3c3c, 0x3c3c, 0x34cc, + 0x02c4, 0x30ed, 0x06fe, 0x1050, 0xec0c, 0xfd02, 0xc0fe, 0x02c0, + 0xec00, 0xfd02, 0xc230, 0x6f08, 0xe608, 0x4f05, 0xf302, 0xc28f, + 0xec00, 0x30ed, 0x00e6, 0x084f, 0x05e3, 0x0618, 0x8fec, 0x0018, + 0xed00, 0x6c08, 0xe608, 0xc104, 0x25de, 0x30ee, 0x06cc, 0x0400, + 0xed00, 0x30ee, 0x06cc, 0x0449, 0xed02, 0x30ee, 0x06cc, 0x04d5, + 0xed04, 0x30ee, 0x06cc, 0x04ed, 0xed06, 0xcc02, 0xc4fe, 0x010d, + 0xed00, 0x30c6, 0x093a, 0x3539}; ArduCAM myCAM(MT9D111_B, slaveSelectPin); UTFT myGLCD(slaveSelectPin); -void AF_refocus() { +void AF_refocus() +{ Serial.println("af_refocus"); myCAM.wrSensorReg8_16(0xF0, 0x01); myCAM.wrSensorReg8_16(0xC6, 0xA102); @@ -126,10 +125,11 @@ void AF_refocus() { myCAM.wrSensorReg8_16(0xC8, 0x01); } -void AF_mode() { +void AF_mode() +{ uint16_t value, v; - myCAM.wrSensorReg8_16( 0xF0, 0x02); + myCAM.wrSensorReg8_16(0xF0, 0x02); myCAM.rdSensorReg8_16(0x4C, &v); v |= 0x000B; myCAM.wrSensorReg8_16(0x4C, v); @@ -137,35 +137,33 @@ void AF_mode() { v |= 0x000B; myCAM.wrSensorReg8_16(0x56, v); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA102); - myCAM.rdSensorReg8_16( 0xC8, &value); - value |= 0x0010; // enable AF driver - myCAM.wrSensorReg8_16( 0xC6, 0xA102); - myCAM.wrSensorReg8_16( 0xC8, value); - myCAM.wrSensorReg8_16( 0xC6, 0xA102); - myCAM.rdSensorReg8_16( 0xC8, &value); - - + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA102); + myCAM.rdSensorReg8_16(0xC8, &value); + value |= 0x0010; // enable AF driver + myCAM.wrSensorReg8_16(0xC6, 0xA102); + myCAM.wrSensorReg8_16(0xC8, value); + myCAM.wrSensorReg8_16(0xC6, 0xA102); + myCAM.rdSensorReg8_16(0xC8, &value); - if (jpeg == 1 ) { + if (jpeg == 1) + { value = 0x01; - myCAM.wrSensorReg8_16( 0xC6, 0xA12C); - myCAM.wrSensorReg8_16( 0xC8, value); + myCAM.wrSensorReg8_16(0xC6, 0xA12C); + myCAM.wrSensorReg8_16(0xC8, value); refresh(); value = 0x00; - myCAM.wrSensorReg8_16( 0xC6, 0xA12C); - myCAM.wrSensorReg8_16( 0xC8, value); + myCAM.wrSensorReg8_16(0xC6, 0xA12C); + myCAM.wrSensorReg8_16(0xC8, value); value = 0x01; - myCAM.wrSensorReg8_16( 0xC6, 0xA13A); - myCAM.wrSensorReg8_16( 0xC8, value); - - myCAM.wrSensorReg8_16( 0xC6, 0xA504); - myCAM.wrSensorReg8_16( 0xC8, 0X00); + myCAM.wrSensorReg8_16(0xC6, 0xA13A); + myCAM.wrSensorReg8_16(0xC8, value); + myCAM.wrSensorReg8_16(0xC6, 0xA504); + myCAM.wrSensorReg8_16(0xC8, 0X00); // myCAM.wrSensorReg8_16( 0xC6, 0xA505); // myCAM.wrSensorReg8_16( 0xC8, 0x80); @@ -175,11 +173,11 @@ void AF_mode() { // myCAM.wrSensorReg8_16( 0xC6, 0xA503); // myCAM.wrSensorReg8_16( 0xC8, 0x11); } - else { + else + { value = 0x01; - myCAM.wrSensorReg8_16( 0xC6, 0xA12C); - myCAM.wrSensorReg8_16( 0xC8, value); - + myCAM.wrSensorReg8_16(0xC6, 0xA12C); + myCAM.wrSensorReg8_16(0xC8, value); // myCAM.wrSensorReg8_16( 0xC6, 0xA504); // myCAM.wrSensorReg8_16( 0xC8, 0X00); @@ -199,35 +197,35 @@ void AF_mode() { void load_patch_segment() { - uint16_t start, size, data, offreg; - uint16_t pdata; + uint16_t start, size, data, offreg; + uint16_t pdata; int offset; - //start = patch[0]; // start MCU_ADDRESS + // start = patch[0]; // start MCU_ADDRESS start = pgm_read_word(&patch_addr_0400[0]); - //size = patch[1]; // data size + // size = patch[1]; // data size size = pgm_read_word(&patch_addr_0400[1]); - pdata = 2; // data pointer - offset = 0; // MCU_DATA_0,7 + pdata = 2; // data pointer + offset = 0; // MCU_DATA_0,7 - myCAM.wrSensorReg8_16( 0xF0, 0x01); + myCAM.wrSensorReg8_16(0xF0, 0x01); while (size > 0) { if (offset == 0) { - //mi2010soc_reg_write(0x1C6, start); // write MCU_ADDRESS - myCAM.wrSensorReg8_16( 0xC6, start); - //printk(KERN_INFO "REG=1, 0xC6, 0x%04X t// MCU_ADDRESSn", start); + // mi2010soc_reg_write(0x1C6, start); // write MCU_ADDRESS + myCAM.wrSensorReg8_16(0xC6, start); + // printk(KERN_INFO "REG=1, 0xC6, 0x%04X t// MCU_ADDRESSn", start); } - //data = *pdata++; + // data = *pdata++; data = pgm_read_word(&patch_addr_0400[pdata++]); - //offreg = 0x1C8 + offset; - //mi2010soc_reg_write(offreg, data); // write MCU_ADDRESS + // offreg = 0x1C8 + offset; + // mi2010soc_reg_write(offreg, data); // write MCU_ADDRESS - //addr = 0x2003; - //myCAM.wrSensorReg8_16( 0xC6, addr); - myCAM.wrSensorReg8_16( 0xC8 + offset, data); - //printk(KERN_INFO "REG=1, 0x%02X, 0x%04X t// MCU_DATA_%dn", offreg&0xff, data, offset); + // addr = 0x2003; + // myCAM.wrSensorReg8_16( 0xC6, addr); + myCAM.wrSensorReg8_16(0xC8 + offset, data); + // printk(KERN_INFO "REG=1, 0x%02X, 0x%04X t// MCU_DATA_%dn", offreg&0xff, data, offset); start += 2; size--; offset++; @@ -237,108 +235,109 @@ void load_patch_segment() return; } -void call_vmt(uint16_t base) { +void call_vmt(uint16_t base) +{ uint16_t value, addr, v; - myCAM.wrSensorReg8_16( 0xF0, 0x01); + myCAM.wrSensorReg8_16(0xF0, 0x01); addr = 0x2003; value = base; - myCAM.wrSensorReg8_16( 0xC6, addr); - myCAM.wrSensorReg8_16( 0xC8, value); + myCAM.wrSensorReg8_16(0xC6, addr); + myCAM.wrSensorReg8_16(0xC8, value); - myCAM.wrSensorReg8_16( 0xF0, 0x01); + myCAM.wrSensorReg8_16(0xF0, 0x01); addr = 0xA002; value = 0x0001; - myCAM.wrSensorReg8_16( 0xC6, addr); - myCAM.wrSensorReg8_16( 0xC8, value); + myCAM.wrSensorReg8_16(0xC6, addr); + myCAM.wrSensorReg8_16(0xC8, value); addr = 0xA002; myCAM.wrSensorReg8_16(0xC6, addr); myCAM.rdSensorReg8_16(0xC8, &v); - while ( v != 0) { + while (v != 0) + { addr = 0xA002; myCAM.wrSensorReg8_16(0xC6, addr); myCAM.rdSensorReg8_16(0xC8, &v); } } -void call_init(uint16_t base) { +void call_init(uint16_t base) +{ uint16_t value, v, addr; - myCAM.wrSensorReg8_16( 0xF0, 0x01); + myCAM.wrSensorReg8_16(0xF0, 0x01); addr = 0x2003; value = base; - myCAM.wrSensorReg8_16( 0xC6, addr); - myCAM.wrSensorReg8_16( 0xC8, value); + myCAM.wrSensorReg8_16(0xC6, addr); + myCAM.wrSensorReg8_16(0xC8, value); - myCAM.wrSensorReg8_16( 0xF0, 0x01); + myCAM.wrSensorReg8_16(0xF0, 0x01); addr = 0xA002; value = 0x0001; - myCAM.wrSensorReg8_16( 0xC6, addr); - myCAM.wrSensorReg8_16( 0xC8, value); + myCAM.wrSensorReg8_16(0xC6, addr); + myCAM.wrSensorReg8_16(0xC8, value); addr = 0xA002; myCAM.wrSensorReg8_16(0xC6, addr); myCAM.rdSensorReg8_16(0xC8, &v); - while ( v != 0) { + while (v != 0) + { addr = 0xA002; myCAM.wrSensorReg8_16(0xC6, addr); myCAM.rdSensorReg8_16(0xC8, &v); } } -void resetCAM() { +void resetCAM() +{ uint16_t state; Serial.println("reset CAM"); - myCAM.wrSensorReg8_16( 0xF0, 0x00); - myCAM.wrSensorReg8_16( 0x65, 0xA000); - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC3, 0x0501); + myCAM.wrSensorReg8_16(0xF0, 0x00); + myCAM.wrSensorReg8_16(0x65, 0xA000); - myCAM.wrSensorReg8_16( 0xF0, 0x00); - myCAM.wrSensorReg8_16( 0x0D, 0x0021); - myCAM.wrSensorReg8_16( 0x0D, 0x0000); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC3, 0x0501); + myCAM.wrSensorReg8_16(0xF0, 0x00); + myCAM.wrSensorReg8_16(0x0D, 0x0021); + myCAM.wrSensorReg8_16(0x0D, 0x0000); delayMicroseconds(10000); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA104); - myCAM.rdSensorReg8_16( 0xC8, &state); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA104); + myCAM.rdSensorReg8_16(0xC8, &state); Serial.print("mod.state : "); Serial.println(state); - - delayMicroseconds(200000); - myCAM.wrSensorReg8_16( 0xF0, 0x00); - myCAM.wrSensorReg8_16( 0x65, 0xA000); - myCAM.wrSensorReg8_16( 0x66, 0x1001); - myCAM.wrSensorReg8_16( 0x67, 0x0503); + myCAM.wrSensorReg8_16(0xF0, 0x00); + myCAM.wrSensorReg8_16(0x65, 0xA000); + myCAM.wrSensorReg8_16(0x66, 0x1001); + myCAM.wrSensorReg8_16(0x67, 0x0503); delayMicroseconds(15000); - myCAM.wrSensorReg8_16( 0xF0, 0x00); - myCAM.wrSensorReg8_16( 0x65, 0x2000); + myCAM.wrSensorReg8_16(0xF0, 0x00); + myCAM.wrSensorReg8_16(0x65, 0x2000); delayMicroseconds(15000); - - if (state != 3) { - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.wrSensorReg8_16( 0xC8, 0X0001); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.wrSensorReg8_16(0xC8, 0X0001); // Waiting state to standby mode unsigned int count = 500000; - while (state != 3 && count > 0) { - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA104); - myCAM.rdSensorReg8_16( 0xC8, &state); + while (state != 3 && count > 0) + { + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA104); + myCAM.rdSensorReg8_16(0xC8, &state); count--; } Serial.print("mod.state : "); @@ -358,18 +357,18 @@ void refresh() { uint16_t cmd; int i; - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.wrSensorReg8_16( 0xC8, 0X05); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.rdSensorReg8_16( 0xC8, &cmd); - while (( cmd != 0) && (i < 65535)) + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.wrSensorReg8_16(0xC8, 0X05); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.rdSensorReg8_16(0xC8, &cmd); + while ((cmd != 0) && (i < 65535)) { - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.rdSensorReg8_16( 0xC8, &cmd); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.rdSensorReg8_16(0xC8, &cmd); i++; } - if ( i == 65535) + if (i == 65535) Serial.println("refresh time out"); } @@ -377,20 +376,21 @@ void refreshMode() { uint16_t cmd; int i; - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.wrSensorReg8_16( 0xC8, 0X06); - while (( cmd != 0) && (i < 65535)) + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.wrSensorReg8_16(0xC8, 0X06); + while ((cmd != 0) && (i < 65535)) { - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.rdSensorReg8_16( 0xC8, &cmd); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.rdSensorReg8_16(0xC8, &cmd); i++; } - if ( i == 65535) + if (i == 65535) Serial.println("refreshMode time out"); } -void setSizes(uint16_t w1, uint16_t h1, uint16_t w2, uint16_t h2 ) { +void setSizes(uint16_t w1, uint16_t h1, uint16_t w2, uint16_t h2) +{ // uint16_t w1,h1; // uint16_t w2,h2; @@ -400,172 +400,164 @@ void setSizes(uint16_t w1, uint16_t h1, uint16_t w2, uint16_t h2 ) { // h2 = 0x0258; 600 // w2 = 0x0640; 1600 // h2 = 0x04B0; 1200 - //msg("setSizes"); + // msg("setSizes"); // A context - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2703); - myCAM.wrSensorReg8_16( 0xC8, w1); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2705); - myCAM.wrSensorReg8_16( 0xC8, h1); - + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2703); + myCAM.wrSensorReg8_16(0xC8, w1); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2705); + myCAM.wrSensorReg8_16(0xC8, h1); // B context - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2707); - myCAM.wrSensorReg8_16( 0xC8, w2); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2707); + myCAM.wrSensorReg8_16(0xC8, w2); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2709); - myCAM.wrSensorReg8_16( 0xC8, h2); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2709); + myCAM.wrSensorReg8_16(0xC8, h2); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2779); - myCAM.wrSensorReg8_16( 0xC8, w2); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2779); + myCAM.wrSensorReg8_16(0xC8, w2); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x277B); - myCAM.wrSensorReg8_16( 0xC8, h2); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x277B); + myCAM.wrSensorReg8_16(0xC8, h2); refreshMode(); refresh(); } -void setFormats() { +void setFormats() +{ Serial.println("setFormat"); // A context - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA77D); - myCAM.wrSensorReg8_16( 0xC8, 0X00020); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA77D); + myCAM.wrSensorReg8_16(0xC8, 0X00020); // B context - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA77E); - myCAM.wrSensorReg8_16( 0xC8, 0X0000); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA77E); + myCAM.wrSensorReg8_16(0xC8, 0X0000); // Refresh Sequencer // refreshMode(); // refresh(); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.wrSensorReg8_16(0xC8, 0X0006); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.wrSensorReg8_16( 0xC8, 0X0006); - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.wrSensorReg8_16( 0xC8, 0X0005); - + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.wrSensorReg8_16(0xC8, 0X0005); } -void doCapture(unsigned short restart_int) { +void doCapture(unsigned short restart_int) +{ Serial.println("doCapture"); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0x48, 0X0000); - myCAM.wrSensorReg8_16( 0x49, 0X0000); - myCAM.wrSensorReg8_16( 0x4A, 0X007f); - myCAM.wrSensorReg8_16( 0x4B, 0X0000); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0x48, 0X0000); + myCAM.wrSensorReg8_16(0x49, 0X0000); + myCAM.wrSensorReg8_16(0x4A, 0X007f); + myCAM.wrSensorReg8_16(0x4B, 0X0000); - myCAM.wrSensorReg8_16( 0xF0, 0x02); - myCAM.wrSensorReg8_16( 0x00, 0X0001); + myCAM.wrSensorReg8_16(0xF0, 0x02); + myCAM.wrSensorReg8_16(0x00, 0X0001); // // myCAM.wrSensorReg8_16( 0xF0, 0x01); // set format B // myCAM.wrSensorReg8_16( 0xC6, 0xA77E); // myCAM.wrSensorReg8_16( 0xC8, 0X0000); + myCAM.wrSensorReg8_16(0xF0, 0x01); // switch to JPEG settings + myCAM.wrSensorReg8_16(0xC6, 0x270B); + myCAM.wrSensorReg8_16(0xC8, 0X0010); - myCAM.wrSensorReg8_16( 0xF0, 0x01); // switch to JPEG settings - myCAM.wrSensorReg8_16( 0xC6, 0x270B); - myCAM.wrSensorReg8_16( 0xC8, 0X0010); - - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2772); - myCAM.wrSensorReg8_16( 0xC8, 0X0067); - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2774); - myCAM.wrSensorReg8_16( 0xC8, 0X0406); - - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA776); - myCAM.wrSensorReg8_16( 0xC8, 0X0002); - - + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2772); + myCAM.wrSensorReg8_16(0xC8, 0X0067); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2908); - myCAM.wrSensorReg8_16( 0xC8, restart_int); // set restart interval + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2774); + myCAM.wrSensorReg8_16(0xC8, 0X0406); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA776); + myCAM.wrSensorReg8_16(0xC8, 0X0002); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA907); - myCAM.wrSensorReg8_16( 0xC8, 0X0010); // enable scaled quantization + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2908); + myCAM.wrSensorReg8_16(0xC8, restart_int); // set restart interval + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA907); + myCAM.wrSensorReg8_16(0xC8, 0X0010); // enable scaled quantization refreshMode(); refresh(); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA120); - myCAM.wrSensorReg8_16( 0xC8, 0X0002); - - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA103); - myCAM.wrSensorReg8_16( 0xC8, 0X0002); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA120); + myCAM.wrSensorReg8_16(0xC8, 0X0002); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA103); + myCAM.wrSensorReg8_16(0xC8, 0X0002); } -void mirror() { +void mirror() +{ uint16_t value; Serial.println("Mirror"); - myCAM.wrSensorReg8_16( 0xF0, 0x00); - myCAM.rdSensorReg8_16( 0x20, &value); + myCAM.wrSensorReg8_16(0xF0, 0x00); + myCAM.rdSensorReg8_16(0x20, &value); value |= 0x0001; - myCAM.wrSensorReg8_16( 0x20, value); + myCAM.wrSensorReg8_16(0x20, value); refresh(); } - -void toggleTestpattern() { +void toggleTestpattern() +{ uint16_t value; Serial.println("Toggle testpattern"); - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.rdSensorReg8_16( 0x48, &value); + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.rdSensorReg8_16(0x48, &value); Serial.print("setting : "); Serial.println(value, HEX); - if ( value == 0x0000) { - myCAM.wrSensorReg8_16( 0x48, 0x0003); + if (value == 0x0000) + { + myCAM.wrSensorReg8_16(0x48, 0x0003); } - else { - myCAM.wrSensorReg8_16( 0x48, 0x0000); + else + { + myCAM.wrSensorReg8_16(0x48, 0x0000); } - myCAM.rdSensorReg8_16( 0x48, &value); + myCAM.rdSensorReg8_16(0x48, &value); Serial.print("setting : "); Serial.println(value, HEX); refresh(); } - void setup() { -#if defined (__AVR__) +#if defined(__AVR__) Wire.begin(); #endif #if defined(__arm__) @@ -586,12 +578,11 @@ void setup() resetCAM(); setFormats(); - //setSizes(0x140, 0x0f0, width, height); + // setSizes(0x140, 0x0f0, width, height); setSizes(width, height, width, height + OFFSET); load_patch_segment(); call_vmt(0x52a); - // int mclk = 25000000; // int scale = 65536; uint16_t addr, v; @@ -606,8 +597,8 @@ void setup() myCAM.rdSensorReg8_16(0xC8, &v); Serial.println(v, HEX); - - delayMicroseconds(600000);; //minimum delay 600 msec + delayMicroseconds(600000); + ; // minimum delay 600 msec AF_mode(); @@ -617,17 +608,16 @@ void setup() myCAM.wrSensorReg8_16(0xc6, 0x810E); myCAM.wrSensorReg8_16(0xc8, 0x00c4); - call_init(0x400); Serial.println("end patch loading"); doCapture(0x20); - //Initialize SD Card + // Initialize SD Card if (!SD.begin(SD_CS)) { - //while (1); //If failed, stop here + // while (1); //If failed, stop here Serial.println("SD card failed"); } Serial.println("init done"); @@ -641,16 +631,19 @@ void loop() uint16_t value, length_low, length_high; uint32_t length; int time = 0; - myCAM.write_reg(ARDUCHIP_MODE, 0x01); //Switch to CAM + myCAM.write_reg(ARDUCHIP_MODE, 0x01); // Switch to CAM while (1) { - if (Serial.available()) { + if (Serial.available()) + { temp = Serial.read(); - if (temp == 't') { + if (temp == 't') + { toggleTestpattern(); } - if (temp == 'f') { + if (temp == 'f') + { AF_refocus(); Serial.println("AF refocus"); } @@ -658,17 +651,18 @@ void loop() temp = myCAM.read_reg(ARDUCHIP_TRIG); time++; - if (!(temp & VSYNC_MASK)) //New Frame is coming + if (!(temp & VSYNC_MASK)) // New Frame is coming { // Serial.print("VSYNC "); // Serial.println(time); time = 0; - myCAM.write_reg(ARDUCHIP_MODE, 0x00); //Switch to MCU + myCAM.write_reg(ARDUCHIP_MODE, 0x00); // Switch to MCU myGLCD.resetXY(); - myCAM.write_reg(ARDUCHIP_MODE, 0x01); //Switch to CAM - while (!(myCAM.read_reg(ARDUCHIP_TRIG) & 0x01)) { + myCAM.write_reg(ARDUCHIP_MODE, 0x01); // Switch to CAM + while (!(myCAM.read_reg(ARDUCHIP_TRIG) & 0x01)) + { time++; - } //Wait for VSYNC is gone + } // Wait for VSYNC is gone // Serial.print("VSYNC gone "); // Serial.println(time); time = 0; @@ -681,8 +675,8 @@ void loop() k = k + 1; strcat(str, "mt9d111"); itoa(k, str, 10); - strcat(str, ".jpg"); //Generate file name - myCAM.write_reg(ARDUCHIP_MODE, 0x00); //Switch to MCU, freeze the screen + strcat(str, ".jpg"); // Generate file name + myCAM.write_reg(ARDUCHIP_MODE, 0x00); // Switch to MCU, freeze the screen GrabImage(str); Serial.println("grab done"); @@ -690,8 +684,7 @@ void loop() } } - -void GrabImage(char* str) +void GrabImage(char *str) { File outFile; int i; @@ -700,90 +693,93 @@ void GrabImage(char* str) uint16_t length_high1; uint16_t length_low1; char ch; - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0xA90f); - myCAM.rdSensorReg8_16( 0xC8, &length_high1); - //Serial.print("jpeg image length high "); - //Serial.println(length_high1, HEX); - - myCAM.wrSensorReg8_16( 0xF0, 0x01); - myCAM.wrSensorReg8_16( 0xC6, 0x2910); - myCAM.rdSensorReg8_16( 0xC8, &length_low1); - //Serial.print("jpeg image length low "); - //Serial.println(length_low1, HEX); - + + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0xA90f); + myCAM.rdSensorReg8_16(0xC8, &length_high1); + // Serial.print("jpeg image length high "); + // Serial.println(length_high1, HEX); + + myCAM.wrSensorReg8_16(0xF0, 0x01); + myCAM.wrSensorReg8_16(0xC6, 0x2910); + myCAM.rdSensorReg8_16(0xC8, &length_low1); + // Serial.print("jpeg image length low "); + // Serial.println(length_low1, HEX); + Serial.println(str); - outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC ); // overwrite if file exists - if (! outFile) + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); // overwrite if file exists + if (!outFile) { Serial.println("Open File Error"); return; } - //Switch to FIFO Mode + // Switch to FIFO Mode myCAM.write_reg(ARDUCHIP_TIM, 0x10); - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Start capture + // Start capture myCAM.start_capture(); - //Polling the capture done flag - while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)); + // Polling the capture done flag + while (!(myCAM.read_reg(ARDUCHIP_TRIG) & CAP_DONE_MASK)) + ; - //Write the JPEG header - for ( i = 0; i < 0x9f; i++) + // Write the JPEG header + for (i = 0; i < 0x9f; i++) { ch = pgm_read_byte(&JPEG_header[i]); - outFile.write((uint8_t*)&ch, 1); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); } - ch = (uint8_t) (height >> 8); - outFile.write((uint8_t*)&ch, 1); + ch = (uint8_t)(height >> 8); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); - ch = (uint8_t) (height & 0xFF); - outFile.write((uint8_t*)&ch, 1); + ch = (uint8_t)(height & 0xFF); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); - ch = (uint8_t) (width >> 8); - outFile.write((uint8_t*)&ch, 1); + ch = (uint8_t)(width >> 8); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); - ch = (uint8_t) (width & 0xFF); - outFile.write((uint8_t*)&ch, 1); + ch = (uint8_t)(width & 0xFF); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); - for ( i = 0xA3; i < JPEGIMAGEOFFSET; i++) + for (i = 0xA3; i < JPEGIMAGEOFFSET; i++) { ch = pgm_read_byte(&JPEG_header[i]); - outFile.write((uint8_t*)&ch, 1); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); } - for ( k2 = 0; k2 < length_high1; k2++) + for (k2 = 0; k2 < length_high1; k2++) { - for ( k1 = 0; k1 < 0xffff; k1++) { + for (k1 = 0; k1 < 0xffff; k1++) + { ch = myCAM.read_fifo(); - outFile.write((uint8_t*)&ch, 1); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); } } - for ( k1 = 0; k1 < length_low1; k1++) { + for (k1 = 0; k1 < length_low1; k1++) + { ch = myCAM.read_fifo(); - outFile.write((uint8_t*)&ch, 1); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); } - ch = (uint8_t) (0xFF); - outFile.write((uint8_t*)&ch, 1); + ch = (uint8_t)(0xFF); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); - ch = (uint8_t) (0xD9); - outFile.write((uint8_t*)&ch, 1); + ch = (uint8_t)(0xD9); + outFile.write((uint8_t *)&ch, 1); Serial.write(ch); - //Close the file + // Close the file outFile.close(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Switch to LCD Mode + // Switch to LCD Mode myCAM.write_reg(ARDUCHIP_TIM, 0); Serial.println("file written"); return; diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M001_Camera_RAW/ArduCAM_Shield_V2_MT9M001_Camera_RAW.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M001_Camera_RAW/ArduCAM_Shield_V2_MT9M001_Camera_RAW.ino index 6f363a4d..8a3d304a 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M001_Camera_RAW/ArduCAM_Shield_V2_MT9M001_Camera_RAW.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M001_Camera_RAW/ArduCAM_Shield_V2_MT9M001_Camera_RAW.ino @@ -3,14 +3,14 @@ // This program is a demo of how to use most of the functions // of the library with a supported camera modules. // -//This demo is compatible with ESP8266 +// This demo is compatible with ESP8266 // // This demo was made for Aptina MT9M001 sensor. // It will turn the ArduCAM into a real digital camera with capture and playback functions. -// +// // 1. Capture and buffer the image to FIFO when shutter pressed quickly. // 2. Store the image to Micro SD/TF card with RAW format. -// +// // This program requires the ArduCAM V4.0.0 (or above) library and ArduCAM shield V2 // and use Arduino IDE 1.6.8 compiler or above @@ -21,164 +21,177 @@ #include #include "memorysaver.h" -#if !(defined (MT9M001_CAM)) +#if !(defined(MT9M001_CAM)) #error This demo can only support MT9M001_CAM. #endif -#if !(defined ARDUCAM_SHIELD_V2 && defined MT9M001_CAM ) +#if !(defined ARDUCAM_SHIELD_V2 && defined MT9M001_CAM) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(__arm__) - #include +#include #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif ArduCAM myCAM(MT9M001, SPI_CS); UTFT myGLCD(SPI_CS); void setup() { -uint16_t vid; -uint8_t temp = 0; + uint16_t vid; + uint8_t temp = 0; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -while(1){ - //Check if the camera module type is MT9M001 - myCAM.rdSensorReg8_16(0x00, &vid); - if (vid != 0x8431) + while (1) { - Serial.println(F("Can't find MT9M001 module!")); - delay(1000);continue; + // Check if the camera module type is MT9M001 + myCAM.rdSensorReg8_16(0x00, &vid); + if (vid != 0x8431) + { + Serial.println(F("Can't find MT9M001 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("MT9M001 detected")); + break; + } } - else{ - Serial.println(F("MT9M001 detected"));break; + // Change MCU mode + myCAM.set_mode(MCU2LCD_MODE); + // Initialize the LCD Module + myGLCD.InitLCD(); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); + myCAM.wrSensorReg8_16(0x03, 240); + myCAM.wrSensorReg8_16(0x04, 639); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); } -} -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -//Initialize the LCD Module -myGLCD.InitLCD(); -myCAM.InitCAM(); -myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); -myCAM.wrSensorReg8_16(0x03, 240); -myCAM.wrSensorReg8_16(0x04, 639); -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} -Serial.println(F("SD Card detected!")); + Serial.println(F("SD Card detected!")); } void loop() { -char str[8]; -static int k = 0; -myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM -while(1) -{ - #if defined(ESP8266) - yield(); - #endif - if(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)) //New Frame is coming - { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)); //Wait for VSYNC is gone - } - else if(myCAM.get_bit(ARDUCHIP_TRIG,SHUTTER_MASK)) + char str[8]; + static int k = 0; + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (1) { - k = k + 1; - itoa(k, str, 10); - strcat(str,".raw"); //Generate file name - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU, freeze the screen - GrabImage(str); +#if defined(ESP8266) + yield(); +#endif + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming + { + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone + } + else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + { + k = k + 1; + itoa(k, str, 10); + strcat(str, ".raw"); // Generate file name + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU, freeze the screen + GrabImage(str); + } } } -} -void GrabImage(char* str) +void GrabImage(char *str) { -File outFile; -char VL; -byte buf[256]; -static int k = 0; -int i,j = 0; -outFile = SD.open(str,O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("File open error")); - return; -} -myCAM.wrSensorReg8_16(0x03, 1023); -myCAM.wrSensorReg8_16(0x04, 1279); -//Flush the FIFO -myCAM.flush_fifo(); -//Start capture -myCAM.start_capture(); -Serial.println(F("Start Capture")); -//Polling the capture done flag -while(!myCAM.get_bit(ARDUCHIP_TRIG,CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -k = 0; -//Read 1280x1024 byte from FIFO -//Save as RAW format -for(i = 0; i < 1280; i++) -for(j = 0; j < 1024; j++) -{ - VL = myCAM.read_fifo(); - buf[k++] = VL; - #if defined(ESP8266) - yield(); - #endif - //Write image data to bufer if not full - if(k >= 256) + File outFile; + char VL; + byte buf[256]; + static int k = 0; + int i, j = 0; + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) { - //Write 256 bytes image data to file from buffer - outFile.write(buf,256); - k = 0; + Serial.println(F("File open error")); + return; } + myCAM.wrSensorReg8_16(0x03, 1023); + myCAM.wrSensorReg8_16(0x04, 1279); + // Flush the FIFO + myCAM.flush_fifo(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); + // Polling the capture done flag + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + k = 0; + // Read 1280x1024 byte from FIFO + // Save as RAW format + for (i = 0; i < 1280; i++) + for (j = 0; j < 1024; j++) + { + VL = myCAM.read_fifo(); + buf[k++] = VL; +#if defined(ESP8266) + yield(); +#endif + // Write image data to bufer if not full + if (k >= 256) + { + // Write 256 bytes image data to file from buffer + outFile.write(buf, 256); + k = 0; + } + } + // Close the file + outFile.close(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + myCAM.wrSensorReg8_16(0x03, 240); + myCAM.wrSensorReg8_16(0x04, 639); + // Switch to LCD Mode + myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); + return; } -//Close the file -outFile.close(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -myCAM.wrSensorReg8_16(0x03, 240); -myCAM.wrSensorReg8_16(0x04, 639); -//Switch to LCD Mode -myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); -return; -} - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M034_Camera_RAW/ArduCAM_Shield_V2_MT9M034_Camera_RAW.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M034_Camera_RAW/ArduCAM_Shield_V2_MT9M034_Camera_RAW.ino index 7f543d26..16ae4662 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M034_Camera_RAW/ArduCAM_Shield_V2_MT9M034_Camera_RAW.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9M034_Camera_RAW/ArduCAM_Shield_V2_MT9M034_Camera_RAW.ino @@ -5,27 +5,27 @@ // This demo was made for MT9M034 sensor. // It will turn the ArduCAM into a real digital camera with capture and playback functions. // 1.Continuous shooting and store the image to Micro SD/TF card with RAW format. -//IF the FRAMES_NUM is 0X00, take one photos -//IF the FRAMES_NUM is 0X01, take two photos -//IF the FRAMES_NUM is 0X02, take three photos -//IF the FRAMES_NUM is 0X03, take four photos -//IF the FRAMES_NUM is 0X04, take five photos -//IF the FRAMES_NUM is 0X05, take six photos -//IF the FRAMES_NUM is 0X06, take seven photos -//IF the FRAMES_NUM is 0X07, continue shooting until the FIFO is full +// IF the FRAMES_NUM is 0X00, take one photos +// IF the FRAMES_NUM is 0X01, take two photos +// IF the FRAMES_NUM is 0X02, take three photos +// IF the FRAMES_NUM is 0X03, take four photos +// IF the FRAMES_NUM is 0X04, take five photos +// IF the FRAMES_NUM is 0X05, take six photos +// IF the FRAMES_NUM is 0X06, take seven photos +// IF the FRAMES_NUM is 0X07, continue shooting until the FIFO is full // This program requires the ArduCAM V4.0.0 (or above) library and ArduCAM shield V2 // and use Arduino IDE 1.6.8 compiler or above -#define FRAMES_NUM 0x07 +#define FRAMES_NUM 0x07 #include #include #include #include -#if !(defined (MT9M034_CAM)) +#if !(defined(MT9M034_CAM)) #error This demo can only support MT9M034_CAM. #endif -#if !(defined ARDUCAM_SHIELD_V2 && defined MT9M034_CAM ) +#if !(defined ARDUCAM_SHIELD_V2 && defined MT9M034_CAM) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif @@ -47,29 +47,37 @@ void setup() digitalWrite(SPI_CS, HIGH); // initialize SPI: SPI.begin(); - - //Reset the CPLD + + // Reset the CPLD myCAM.write_reg(0x07, 0x80); delay(100); myCAM.write_reg(0x07, 0x00); delay(100); - - while (1) { - //Check if the ArduCAM SPI bus is OK + + while (1) + { + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55) { + if (temp != 0x55) + { Serial.println(F("SPI interface Error!")); - delay(1000); continue; - } else { - Serial.println(F("SPI interface OK!")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; } } myCAM.InitCAM(); myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); - //Initialize SD Card - while (!SD.begin(SD_CS)) { - Serial.println(F("SD Card Error")); delay(1000); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); } Serial.println(F("SD Card detected!")); } @@ -77,60 +85,61 @@ void loop() { GrabImage(str); } -void GrabImage(char* str) +void GrabImage(char *str) { File outFile; char VL; byte buf[256]; static int k = 0; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println(F("Start Capture")); - //Polling the capture done flag - while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + // Polling the capture done flag + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; length = myCAM.read_fifo_length(); Serial.print(F("The fifo length is :")); Serial.println(length, DEC); - int PIC_CNT = length / 1233920; //1233920 = 1280*960 + int PIC_CNT = length / 1233920; // 1233920 = 1280*960 Serial.println(PIC_CNT, DEC); Serial.println(F("Capture Done.")); - while (PIC_CNT--) { + while (PIC_CNT--) + { k = k + 1; itoa(k, str, 10); - strcat(str, ".raw"); //Generate file name + strcat(str, ".raw"); // Generate file name static int k = 0; int i, j = 0; outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println(F("File open error")); return; } Serial.println("Writting the image data in RAW format..."); k = 0; - //Read 1280x960 byte from FIFO - //Save as RAW format + // Read 1280x960 byte from FIFO + // Save as RAW format for (i = 0; i < 1280; i++) for (j = 0; j < 964; j++) { VL = myCAM.read_fifo(); buf[k++] = VL; - //Write image data to bufer if not full + // Write image data to bufer if not full if (k >= 256) { - //Write 256 bytes image data to file from buffer + // Write 256 bytes image data to file from buffer outFile.write(buf, 256); k = 0; } } - //Close the file + // Close the file outFile.close(); } - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); Serial.println("Image save OK!"); return; } - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9V034_Camera_RAW/ArduCAM_Shield_V2_MT9V034_Camera_RAW.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9V034_Camera_RAW/ArduCAM_Shield_V2_MT9V034_Camera_RAW.ino index 768c4f5c..6b1b61a9 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9V034_Camera_RAW/ArduCAM_Shield_V2_MT9V034_Camera_RAW.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_MT9V034_Camera_RAW/ArduCAM_Shield_V2_MT9V034_Camera_RAW.ino @@ -3,14 +3,14 @@ // This program is a demo of how to use most of the functions // of the library with a supported camera modules. // -//This demo is compatible with ESP8266 +// This demo is compatible with ESP8266 // // This demo was made for Aptina MT9V sensor. // It will turn the ArduCAM into a real digital camera with capture and playback functions. -// +// // 1. Capture and buffer the image to FIFO when shutter pressed quickly. // 2. Store the image to Micro SD/TF card with RAW format. -// +// // This program requires the ArduCAM V4.0.0 (or above) library and ArduCAM shield V2 // and use Arduino IDE 1.6.8 compiler or above @@ -21,167 +21,180 @@ #include #include "memorysaver.h" -#if !(defined (MT9V034_CAM)) +#if !(defined(MT9V034_CAM)) #error This demo can only support MT9V034_CAM. #endif -#if !(defined ARDUCAM_SHIELD_V2 && defined MT9V034_CAM ) +#if !(defined ARDUCAM_SHIELD_V2 && defined MT9V034_CAM) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(__arm__) - #include +#include #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif ArduCAM myCAM(MT9V034, SPI_CS); UTFT myGLCD(SPI_CS); void setup() { -uint16_t vid; -uint8_t temp = 0; + uint16_t vid; + uint8_t temp = 0; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -while(1){ - //Check if the camera module type is MT9M001 - myCAM.rdSensorReg8_16(0x00, &vid); - - //Serial.println(vid,HEX); - - if (vid != 0x1324) + while (1) { - Serial.println(F("Can't find MT9V034 module!")); - delay(1000);continue; + // Check if the camera module type is MT9M001 + myCAM.rdSensorReg8_16(0x00, &vid); + + // Serial.println(vid,HEX); + + if (vid != 0x1324) + { + Serial.println(F("Can't find MT9V034 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("MT9V034 detected")); + break; + } } - else{ - Serial.println(F("MT9V034 detected"));break; + // Change MCU mode + myCAM.set_mode(MCU2LCD_MODE); + // Initialize the LCD Module + myGLCD.InitLCD(); + myCAM.InitCAM(); + // myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); + myCAM.wrSensorReg8_16(0x03, 240); + myCAM.wrSensorReg8_16(0x04, 639); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); } -} -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -//Initialize the LCD Module -myGLCD.InitLCD(); -myCAM.InitCAM(); -//myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); -myCAM.wrSensorReg8_16(0x03, 240); -myCAM.wrSensorReg8_16(0x04, 639); -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} -Serial.println(F("SD Card detected!")); + Serial.println(F("SD Card detected!")); } void loop() { -char str[8]; -static int k = 0; -myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM -while(1) -{ - #if defined(ESP8266) - yield(); - #endif - if(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)) //New Frame is coming - { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)); //Wait for VSYNC is gone - } - else if(myCAM.get_bit(ARDUCHIP_TRIG,SHUTTER_MASK)) + char str[8]; + static int k = 0; + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (1) { - k = k + 1; - itoa(k, str, 10); - strcat(str,".raw"); //Generate file name - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU, freeze the screen - GrabImage(str); +#if defined(ESP8266) + yield(); +#endif + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming + { + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone + } + else if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + { + k = k + 1; + itoa(k, str, 10); + strcat(str, ".raw"); // Generate file name + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU, freeze the screen + GrabImage(str); + } } } -} -void GrabImage(char* str) +void GrabImage(char *str) { -File outFile; -char VL; -byte buf[256]; -static int k = 0; -int i,j = 0; -outFile = SD.open(str,O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("File open error")); - return; -} -myCAM.wrSensorReg8_16(0x03, 1023); -myCAM.wrSensorReg8_16(0x04, 1279); -//Flush the FIFO -myCAM.flush_fifo(); -//Start capture -myCAM.start_capture(); -Serial.println(F("Start Capture")); -//Polling the capture done flag -while(!myCAM.get_bit(ARDUCHIP_TRIG,CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -k = 0; -//Read 752x480 byte from FIFO -//Save as RAW format -for(i = 0; i < 752; i++) -for(j = 0; j < 480; j++) -{ - VL = myCAM.read_fifo(); - buf[k++] = VL; - #if defined(ESP8266) - yield(); - #endif - //Write image data to bufer if not full - if(k >= 256) + File outFile; + char VL; + byte buf[256]; + static int k = 0; + int i, j = 0; + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) { - //Write 256 bytes image data to file from buffer - outFile.write(buf,256); - k = 0; + Serial.println(F("File open error")); + return; } + myCAM.wrSensorReg8_16(0x03, 1023); + myCAM.wrSensorReg8_16(0x04, 1279); + // Flush the FIFO + myCAM.flush_fifo(); + // Start capture + myCAM.start_capture(); + Serial.println(F("Start Capture")); + // Polling the capture done flag + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + k = 0; + // Read 752x480 byte from FIFO + // Save as RAW format + for (i = 0; i < 752; i++) + for (j = 0; j < 480; j++) + { + VL = myCAM.read_fifo(); + buf[k++] = VL; +#if defined(ESP8266) + yield(); +#endif + // Write image data to bufer if not full + if (k >= 256) + { + // Write 256 bytes image data to file from buffer + outFile.write(buf, 256); + k = 0; + } + } + // Close the file + outFile.close(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + myCAM.wrSensorReg8_16(0x03, 240); + myCAM.wrSensorReg8_16(0x04, 639); + // Switch to LCD Mode + // myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); + return; } -//Close the file -outFile.close(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -myCAM.wrSensorReg8_16(0x03, 240); -myCAM.wrSensorReg8_16(0x04, 639); -//Switch to LCD Mode -//myCAM.write_reg(ARDUCHIP_TIM, PCLK_REVERSE_MASK); -return; -} - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Multi_Capture2SD/ArduCAM_Shield_V2_Multi_Capture2SD.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Multi_Capture2SD/ArduCAM_Shield_V2_Multi_Capture2SD.ino index 5b8d1b24..6a4b8c35 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Multi_Capture2SD/ArduCAM_Shield_V2_Multi_Capture2SD.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Multi_Capture2SD/ArduCAM_Shield_V2_Multi_Capture2SD.ino @@ -8,264 +8,304 @@ // 2. Capture a JPEG photo and buffer the image to FIFO // 3.Write the picture data to the SD card // 5.close the file -//You can change the FRAMES_NUM count to change the number of the picture. -//IF the FRAMES_NUM is 0X00, take one photos -//IF the FRAMES_NUM is 0X01, take two photos -//IF the FRAMES_NUM is 0X02, take three photos -//IF the FRAMES_NUM is 0X03, take four photos -//IF the FRAMES_NUM is 0X04, take five photos -//IF the FRAMES_NUM is 0X05, take six photos -//IF the FRAMES_NUM is 0X06, take seven photos -//IF the FRAMES_NUM is 0X07, continue shooting until the FIFO is full -//You can see the picture in the SD card. -//This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_V2 -//and use Arduino IDE 1.6.8 compiler or above +// You can change the FRAMES_NUM count to change the number of the picture. +// IF the FRAMES_NUM is 0X00, take one photos +// IF the FRAMES_NUM is 0X01, take two photos +// IF the FRAMES_NUM is 0X02, take three photos +// IF the FRAMES_NUM is 0X03, take four photos +// IF the FRAMES_NUM is 0X04, take five photos +// IF the FRAMES_NUM is 0X05, take six photos +// IF the FRAMES_NUM is 0X06, take seven photos +// IF the FRAMES_NUM is 0X07, continue shooting until the FIFO is full +// You can see the picture in the SD card. +// This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_V2 +// and use Arduino IDE 1.6.8 compiler or above #include #include #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -#if !(defined (ARDUCAM_SHIELD_V2)&&(defined (OV5640_CAM) ||defined (OV5642_CAM) ||defined (OV2640_CAM) ||defined (OV3640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +#if !(defined(ARDUCAM_SHIELD_V2) && (defined(OV5640_CAM) || defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV3640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x06 +#define FRAMES_NUM 0x06 #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif bool is_header = false; int total_time = 0; -#if defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); -#elif defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); +#if defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); +#elif defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("Can't find OV3640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; } } -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} -Serial.println(F("SD Card detected.")); -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if !(defined (OV2640_CAM) || defined (OV3640_CAM)) + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); + } + Serial.println(F("SD Card detected.")); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_CAM) || defined(OV3640_CAM)) myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); #endif -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); } -void loop() { -// put your main code here, to run repeatedly: -myCAM.flush_fifo(); -myCAM.clear_fifo_flag(); -#if defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); -#elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); -#elif defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); -#elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); +void loop() +{ + // put your main code here, to run repeatedly: + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); +#if defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); +#elif defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); #endif -//Start capture -myCAM.start_capture(); -Serial.println(F("start capture!")); -total_time = millis(); -while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)){ -#if defined (ESP8266) - yield(); + // Start capture + myCAM.start_capture(); + Serial.println(F("start capture!")); + total_time = millis(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { +#if defined(ESP8266) + yield(); #endif -} ; -Serial.println(F("CAM Capture Done.")); -total_time = millis() - total_time; -Serial.print(F("capture total_time used (in miliseconds):")); -Serial.println(total_time, DEC); -total_time = millis(); -read_fifo_burst(myCAM); -total_time = millis() - total_time; -Serial.print(F("Save capture total_time used (in miliseconds):")); -Serial.println(total_time, DEC); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -delay(5000); + }; + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; + Serial.print(F("capture total_time used (in miliseconds):")); + Serial.println(total_time, DEC); + total_time = millis(); + read_fifo_burst(myCAM); + total_time = millis() - total_time; + Serial.print(F("Save capture total_time used (in miliseconds):")); + Serial.println(total_time, DEC); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + delay(5000); } uint8_t read_fifo_burst(ArduCAM myCAM) { -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -static int i = 0; -static int k = 0; -char str[8]; -File outFile; -byte buf[256]; -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //8M -{ - Serial.println(F("Over size.")); - return 0 ; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return 0; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -i = 0; -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + static int i = 0; + static int k = 0; + char str[8]; + File outFile; + byte buf[256]; + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("OK")); - is_header = false; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else - { - //Write 256 bytes image data to file - myCAM.CS_HIGH(); - outFile.write(buf, 256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + Serial.println(F("Over size.")); + return 0; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return 0; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + i = 0; + while (length--) { - is_header = true; - myCAM.CS_HIGH(); - //Create a avi file - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - Serial.println(F("File open failed")); - while (1); + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM.CS_HIGH(); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("OK")); + is_header = false; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + i = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - buf[i++] = temp_last; - buf[i++] = temp; - } -} -myCAM.CS_HIGH(); -return 1; + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + myCAM.CS_HIGH(); + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open failed")); + while (1) + ; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + buf[i++] = temp_last; + buf[i++] = temp; + } + } + myCAM.CS_HIGH(); + return 1; } diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Touch/ArduCAM_Shield_V2_Touch.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Touch/ArduCAM_Shield_V2_Touch.ino index 2eddcaf3..9cc683ea 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Touch/ArduCAM_Shield_V2_Touch.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Touch/ArduCAM_Shield_V2_Touch.ino @@ -3,7 +3,7 @@ // This program is a demo of how to use most of the functions // of the library with a supported camera modules, and can run on any Arduino platform. // When you touch the 'Start Capture',It will preview the live video on LCD Screen. -//When you touch the ‘touch paint’,It will begin test the touch。 +// When you touch the ‘touch paint’,It will begin test the touch。 // This program requires the ArduCAM V4.0.0 (or later)ã€ArduCAM_Touch and UTFT4ArduCAM_SPI library and ARDUCAM_SHIELD_REVC // and use Arduino IDE 1.6.8 compiler or above @@ -14,133 +14,197 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -#if !(defined (ARDUCAM_SHIELD_V2)&&(defined (OV5640_CAM) ||defined (OV5642_CAM)||defined (OV2640_CAM) || defined (OV3640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +#if !(defined(ARDUCAM_SHIELD_V2) && (defined(OV5640_CAM) || defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV3640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define SPI_CS 10 +#define SPI_CS 10 int mode = 0; boolean isShowFlag = false; boolean TouchtestFlag = false; uint32_t previous_time; char currentPage = 0; UTFT myGLCD(SPI_CS); -#if defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif extern uint8_t SmallFont[]; extern uint8_t BigFont[]; -ArduCAM_Touch myTouch(8, 2); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(921600); -Serial.println(F("ACK CMD ArduCAM Start!")); -// set the CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; +ArduCAM_Touch myTouch(8, 2); +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(921600); + Serial.println(F("ACK CMD ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -//Change MCU mode -myCAM.set_mode(MCU2LCD_MODE); -myGLCD.InitLCD(); -myTouch.InitTouch(); -temp = EEPROM.read(16); -if (temp!= 0x0A) - myTouch.TP_Adjust(); -else{ - myTouch.TP_Get_Adjdata(); -} -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 + // Change MCU mode + myCAM.set_mode(MCU2LCD_MODE); + myGLCD.InitLCD(); + myTouch.InitTouch(); + temp = EEPROM.read(16); + if (temp != 0x0A) + myTouch.TP_Adjust(); + else + { + myTouch.TP_Get_Adjdata(); + } +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("Can't find OV3640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x40)) + { + Serial.println(F("Can't find OV5640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } + } +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } - } -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } -#elif defined (OV5640_CAM) -while(1){ - //Check if the camera module type is OV5642 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ - Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } -} -#elif defined (OV5642_CAM) -while(1){ - //Check if the camera module type is OV5642 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; } -} #endif -drawHomeScreen(); + drawHomeScreen(); } -void loop() { -if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) +void loop() { - previous_time = millis(); - while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { - if ((millis() - previous_time) > 30) + previous_time = millis(); + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { - myGLCD.clrScr(); - myTouch.TP_Adjust(); - if(TouchtestFlag){ + if ((millis() - previous_time) > 30) + { + myGLCD.clrScr(); + myTouch.TP_Adjust(); + if (TouchtestFlag) + { + myTouch.Drow_menu(); + myGLCD.setColor(100, 155, 203); + myGLCD.fillRoundRect(10, 10, 60, 36); + myGLCD.setColor(255, 255, 255); + myGLCD.drawRoundRect(10, 10, 60, 36); + myGLCD.setFont(BigFont); + myGLCD.setBackColor(100, 155, 203); + myGLCD.print("<-", 18, 15); + } + else + { + drawHomeScreen(); + } + } + } + } + + // put your main code here, to run repeatedly: + if (currentPage == 0) + { + myTouch.sta = myTouch.TP_Scan(0); + if (myTouch.sta & TP_PRES_DOWN) + { + if ((myTouch.x[0] >= 35) && (myTouch.x[0] <= 285) && (myTouch.y[0] >= 90) && (myTouch.y[0] <= 130)) + { + drawFrame(35, 90, 285, 130); // Custom Function -Highlighs the buttons when it's pressed + currentPage = 1; // Indicates that we are the first example + isShowFlag = false; + TouchtestFlag = 1; + myGLCD.clrScr(); // Clears the screen myTouch.Drow_menu(); myGLCD.setColor(100, 155, 203); myGLCD.fillRoundRect(10, 10, 60, 36); @@ -148,74 +212,15 @@ if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) myGLCD.drawRoundRect(10, 10, 60, 36); myGLCD.setFont(BigFont); myGLCD.setBackColor(100, 155, 203); - myGLCD.print("<-", 18, 15); - }else{ - drawHomeScreen(); + myGLCD.print("<-", 18, 15); } - } - } -} - -// put your main code here, to run repeatedly: -if (currentPage == 0){ - myTouch.sta = myTouch.TP_Scan(0); - if(myTouch.sta&TP_PRES_DOWN){ - if ((myTouch.x[0]>=35) && (myTouch.x[0]<=285) && (myTouch.y[0]>=90) && (myTouch.y[0]<=130)) { - drawFrame(35, 90, 285, 130); // Custom Function -Highlighs the buttons when it's pressed - currentPage = 1; // Indicates that we are the first example - isShowFlag = false; - TouchtestFlag = 1; - myGLCD.clrScr(); // Clears the screen - myTouch.Drow_menu(); - myGLCD.setColor(100, 155, 203); - myGLCD.fillRoundRect(10, 10, 60, 36); - myGLCD.setColor(255, 255, 255); - myGLCD.drawRoundRect(10, 10, 60, 36); - myGLCD.setFont(BigFont); - myGLCD.setBackColor(100, 155, 203); - myGLCD.print("<-", 18, 15); - } - if ((myTouch.x[0]>=35) && (myTouch.x[0]<=285) && (myTouch.y[0]>=190) && (myTouch.y[0]<=230)) { - drawFrame(35, 190, 285, 230); - currentPage = 2; - myGLCD.clrScr(); - isShowFlag = true; - TouchtestFlag = 0; - myGLCD.setColor(100, 155, 203); - myGLCD.fillRoundRect(10, 10, 60, 36); - myGLCD.setColor(255, 255, 255); - myGLCD.drawRoundRect(10, 10, 60, 36); - myGLCD.setFont(BigFont); - myGLCD.setBackColor(100, 155, 203); - myGLCD.print("<-", 18, 15); - } - } -} -if(currentPage == 1){ - if(TouchtestFlag){ - myTouch.sta = myTouch.TP_Scan(0); - if(myTouch.sta&TP_PRES_DOWN) { - if ((myTouch.x[0]>=10) && (myTouch.x[0]<=60) &&(myTouch.y[0]>=10) && (myTouch.y[0]<=36)) { - TouchtestFlag = false; - drawFrame(10, 10, 60, 36); - currentPage = 0; - myGLCD.clrScr(); - drawHomeScreen(); - } - if(myTouch.x[0]>275&&(myTouch.y[0]>=0&&myTouch.y[0]<=BOXSIZE)) - { - myTouch.TP_fillRect(280, BOXSIZE*0, 320, BOXSIZE*1, VGA_RED); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE&&myTouch.y[0]<=BOXSIZE*2)){ - myTouch.TP_fillRect(280, BOXSIZE*1, 320, BOXSIZE*2, VGA_YELLOW); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*2&&myTouch.y[0]<=BOXSIZE*3)){ - myTouch.TP_fillRect(280, BOXSIZE*2, 320, BOXSIZE*3, VGA_GREEN); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*3&&myTouch.y[0]<=BOXSIZE*4)){ - myTouch.TP_fillRect(280, BOXSIZE*3, 320, BOXSIZE*4, VGA_MAROON); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*4&&myTouch.y[0]<=BOXSIZE*5)){ - myTouch.TP_fillRect(280, BOXSIZE*4, 320, BOXSIZE*5, VGA_BLUE); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*5&&myTouch.y[0]<=BOXSIZE*6)){ + if ((myTouch.x[0] >= 35) && (myTouch.x[0] <= 285) && (myTouch.y[0] >= 190) && (myTouch.y[0] <= 230)) + { + drawFrame(35, 190, 285, 230); + currentPage = 2; myGLCD.clrScr(); - myTouch.Drow_menu(); + isShowFlag = true; + TouchtestFlag = 0; myGLCD.setColor(100, 155, 203); myGLCD.fillRoundRect(10, 10, 60, 36); myGLCD.setColor(255, 255, 255); @@ -223,80 +228,136 @@ if(currentPage == 1){ myGLCD.setFont(BigFont); myGLCD.setBackColor(100, 155, 203); myGLCD.print("<-", 18, 15); - } else{ - myTouch.TP_Draw_Big_Point(myTouch.x[0],myTouch.y[0]); - } + } } } -} -if (currentPage == 2) { - if(isShowFlag){ - myCAM.set_mode(MCU2LCD_MODE); - myCAM.set_format(BMP); - myCAM.InitCAM(); - #if !(defined (OV2640_CAM)||defined (OV3640_CAM)) - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - #endif - while(1){ + if (currentPage == 1) + { + if (TouchtestFlag) + { myTouch.sta = myTouch.TP_Scan(0); - if(myTouch.sta&TP_PRES_DOWN) { - isShowFlag = false; - currentPage = 0; - isShowFlag=false; - myCAM.set_mode(MCU2LCD_MODE); - myGLCD.clrScr(); - drawHomeScreen(); - break; - } - if(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)) //New Frame is coming - { - myCAM.set_mode(MCU2LCD_MODE); //Switch to MCU - myGLCD.resetXY(); - myCAM.set_mode(CAM2LCD_MODE); //Switch to CAM - while(!myCAM.get_bit(ARDUCHIP_TRIG,VSYNC_MASK)); //Wait for VSYNC is gone + if (myTouch.sta & TP_PRES_DOWN) + { + if ((myTouch.x[0] >= 10) && (myTouch.x[0] <= 60) && (myTouch.y[0] >= 10) && (myTouch.y[0] <= 36)) + { + TouchtestFlag = false; + drawFrame(10, 10, 60, 36); + currentPage = 0; + myGLCD.clrScr(); + drawHomeScreen(); + } + if (myTouch.x[0] > 275 && (myTouch.y[0] >= 0 && myTouch.y[0] <= BOXSIZE)) + { + myTouch.TP_fillRect(280, BOXSIZE * 0, 320, BOXSIZE * 1, VGA_RED); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE && myTouch.y[0] <= BOXSIZE * 2)) + { + myTouch.TP_fillRect(280, BOXSIZE * 1, 320, BOXSIZE * 2, VGA_YELLOW); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 2 && myTouch.y[0] <= BOXSIZE * 3)) + { + myTouch.TP_fillRect(280, BOXSIZE * 2, 320, BOXSIZE * 3, VGA_GREEN); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 3 && myTouch.y[0] <= BOXSIZE * 4)) + { + myTouch.TP_fillRect(280, BOXSIZE * 3, 320, BOXSIZE * 4, VGA_MAROON); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 4 && myTouch.y[0] <= BOXSIZE * 5)) + { + myTouch.TP_fillRect(280, BOXSIZE * 4, 320, BOXSIZE * 5, VGA_BLUE); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 5 && myTouch.y[0] <= BOXSIZE * 6)) + { + myGLCD.clrScr(); + myTouch.Drow_menu(); + myGLCD.setColor(100, 155, 203); + myGLCD.fillRoundRect(10, 10, 60, 36); + myGLCD.setColor(255, 255, 255); + myGLCD.drawRoundRect(10, 10, 60, 36); + myGLCD.setFont(BigFont); + myGLCD.setBackColor(100, 155, 203); + myGLCD.print("<-", 18, 15); + } + else + { + myTouch.TP_Draw_Big_Point(myTouch.x[0], myTouch.y[0]); + } } } - } -} + } + if (currentPage == 2) + { + if (isShowFlag) + { + myCAM.set_mode(MCU2LCD_MODE); + myCAM.set_format(BMP); + myCAM.InitCAM(); +#if !(defined(OV2640_CAM) || defined(OV3640_CAM)) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH +#endif + while (1) + { + myTouch.sta = myTouch.TP_Scan(0); + if (myTouch.sta & TP_PRES_DOWN) + { + isShowFlag = false; + currentPage = 0; + isShowFlag = false; + myCAM.set_mode(MCU2LCD_MODE); + myGLCD.clrScr(); + drawHomeScreen(); + break; + } + if (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) // New Frame is coming + { + myCAM.set_mode(MCU2LCD_MODE); // Switch to MCU + myGLCD.resetXY(); + myCAM.set_mode(CAM2LCD_MODE); // Switch to CAM + while (!myCAM.get_bit(ARDUCHIP_TRIG, VSYNC_MASK)) + ; // Wait for VSYNC is gone + } + } + } + } } // Highlights the button when pressed -void drawFrame(int x1, int y1, int x2, int y2) { +void drawFrame(int x1, int y1, int x2, int y2) +{ myGLCD.setColor(255, 0, 0); - myGLCD.drawRoundRect (x1, y1, x2, y2); + myGLCD.drawRoundRect(x1, y1, x2, y2); while (myTouch.dataAvailable()) - myTouch.read(); + myTouch.read(); myGLCD.setColor(255, 255, 255); - myGLCD.drawRoundRect (x1, y1, x2, y2); + myGLCD.drawRoundRect(x1, y1, x2, y2); } -void drawHomeScreen() { +void drawHomeScreen() +{ // Title - myGLCD.setBackColor(0,0,0); // Sets the background color of the area where the text will be printed to black - myGLCD.setColor(255, 255, 255); // Sets color to white - myGLCD.setFont(BigFont); // Sets font to big - myGLCD.print("ArduCAM", CENTER, 10); // Prints the string on the screen - myGLCD.setColor(255, 255, 0); // Sets color to red - myGLCD.drawLine(0,32,319,32); // Draws the red line CHANGED TO LIME GREEN - myGLCD.setColor(255, 255, 255); // Sets color to white - myGLCD.setFont(BigFont); // Sets the font to small + myGLCD.setBackColor(0, 0, 0); // Sets the background color of the area where the text will be printed to black + myGLCD.setColor(255, 255, 255); // Sets color to white + myGLCD.setFont(BigFont); // Sets font to big + myGLCD.print("ArduCAM", CENTER, 10); // Prints the string on the screen + myGLCD.setColor(255, 255, 0); // Sets color to red + myGLCD.drawLine(0, 32, 319, 32); // Draws the red line CHANGED TO LIME GREEN + myGLCD.setColor(255, 255, 255); // Sets color to white + myGLCD.setFont(BigFont); // Sets the font to small myGLCD.print("Shield V2 Demo", CENTER, 41); // Prints the string // Button - Rear View Camera - myGLCD.setColor(16, 167, 103); // Sets green color - myGLCD.fillRoundRect (35, 90, 285, 130); // Draws filled rounded rectangle - myGLCD.setColor(255, 255, 255); // Sets color to white - myGLCD.drawRoundRect (35, 90, 285, 130); // Draws rounded rectangle without a fill, so the overall appearance of the button looks like it has a frame - myGLCD.setFont(BigFont); // Sets the font to big - myGLCD.setBackColor(16, 167, 103); // Sets the background color of the area where the text will be printed to green, same as the button + myGLCD.setColor(16, 167, 103); // Sets green color + myGLCD.fillRoundRect(35, 90, 285, 130); // Draws filled rounded rectangle + myGLCD.setColor(255, 255, 255); // Sets color to white + myGLCD.drawRoundRect(35, 90, 285, 130); // Draws rounded rectangle without a fill, so the overall appearance of the button looks like it has a frame + myGLCD.setFont(BigFont); // Sets the font to big + myGLCD.setBackColor(16, 167, 103); // Sets the background color of the area where the text will be printed to green, same as the button myGLCD.print("Touch Paint", CENTER, 102); // Prints the string // Show camera myGLCD.setColor(16, 167, 103); - myGLCD.fillRoundRect (35, 190, 285, 230); + myGLCD.fillRoundRect(35, 190, 285, 230); myGLCD.setColor(255, 255, 255); - myGLCD.drawRoundRect (35, 190, 285, 230); + myGLCD.drawRoundRect(35, 190, 285, 230); myGLCD.setFont(BigFont); myGLCD.setBackColor(16, 167, 103); myGLCD.print("Start Capture", CENTER, 202); } - - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video2SD/ArduCAM_Shield_V2_Video2SD.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video2SD/ArduCAM_Shield_V2_Video2SD.ino index 9910dbef..0e3c53ca 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video2SD/ArduCAM_Shield_V2_Video2SD.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video2SD/ArduCAM_Shield_V2_Video2SD.ino @@ -3,7 +3,7 @@ // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini camera, and can run on any Arduino platform. // This demo was made for ARDUCAM_SHIELD_REVC -//This demo timed 5 seconds to record video. +// This demo timed 5 seconds to record video. // It can shoot video and store it into the SD card // The demo sketch will do the following tasks // 1. Set the camera to JPEG output mode. @@ -12,16 +12,16 @@ // 4.Write the video data to the SD card // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_REVC // and use Arduino IDE 1.6.8 compiler or above @@ -30,300 +30,565 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -#if !(defined (ARDUCAM_SHIELD_V2)&&(defined (OV5640_CAM) ||defined (OV5642_CAM)||defined (OV2640_CAM)||defined (OV3640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +#if !(defined(ARDUCAM_SHIELD_V2) && (defined(OV5640_CAM) || defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV3640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif #define rate 0x05 // set the num of picture #define pic_num 200 -#if defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif #define AVIOFFSET 240 - bool is_header = false; +bool is_header = false; unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const int avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const int avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xF0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); -} -void Video2SD(){ -char str[8]; -File outFile; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0, temp_last = 0; -unsigned long position = 0; -uint32_t length = 0; -uint16_t frame_cnt = 0; -uint8_t remnant = 0; -bool is_header = false; -//Create a avi file -k = k + 1; -itoa(k, str, 10); -strcat(str, ".avi"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) +void print_quartet(unsigned long i, File fd) { - Serial.println("File open failed"); - while (1); - return; -} -//Write AVI Header -for ( i = 0; i < AVIOFFSET; i++) -{ - char ch = pgm_read_byte(&avi_header[i]); - buf[i] = ch; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); } -outFile.write(buf, AVIOFFSET); -//Write video data -Serial.println("Recording video, please wait..."); -for ( frame_cnt = 0; frame_cnt < pic_num; frame_cnt ++) +void Video2SD() { - #if defined (ESP8266) - yield(); - #endif - temp_last = 0;temp = 0; - //Capture a frame - //Flush the FIFO - myCAM.flush_fifo(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - length = myCAM.read_fifo_length(); - outFile.write("00dc"); - outFile.write(zero_buf, 4); - i = 0; - jpeg_size = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - while ( length-- ) + char str[8]; + File outFile; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + unsigned long position = 0; + uint32_t length = 0; + uint16_t frame_cnt = 0; + uint8_t remnant = 0; + bool is_header = false; + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".avi"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println("File open failed"); + while (1) + ; + return; + } + // Write AVI Header + for (i = 0; i < AVIOFFSET; i++) + { + char ch = pgm_read_byte(&avi_header[i]); + buf[i] = ch; + } + outFile.write(buf, AVIOFFSET); + // Write video data + Serial.println("Recording video, please wait..."); + for (frame_cnt = 0; frame_cnt < pic_num; frame_cnt++) { - #if defined (ESP8266) +#if defined(ESP8266) yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, +#endif + temp_last = 0; + temp = 0; + // Capture a frame + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + outFile.write("00dc"); + outFile.write(zero_buf, 4); + i = 0; + jpeg_size = 0; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - is_header = false; - jpeg_size += i; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + is_header = false; + jpeg_size += i; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + jpeg_size += 256; + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - jpeg_size += 256; - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } + remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; + jpeg_size = jpeg_size + remnant; + movi_size = movi_size + jpeg_size; + if (remnant > 0) + outFile.write(zero_buf, remnant); + // Serial.println(movi_size, HEX); + position = outFile.position(); + outFile.seek(position - 4 - jpeg_size); + print_quartet(jpeg_size, outFile); + position = outFile.position(); + outFile.seek(position + 6); + outFile.write("AVI1", 4); + position = outFile.position(); + outFile.seek(position + jpeg_size - 10); } - remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; - jpeg_size = jpeg_size + remnant; - movi_size = movi_size + jpeg_size; - if (remnant > 0) - outFile.write(zero_buf, remnant); - //Serial.println(movi_size, HEX); - position = outFile.position(); - outFile.seek(position - 4 - jpeg_size); - print_quartet(jpeg_size, outFile); - position = outFile.position(); - outFile.seek(position + 6); - outFile.write("AVI1", 4); - position = outFile.position(); - outFile.seek(position + jpeg_size - 10); + // Modify the MJPEG header from the beginning of the file + outFile.seek(4); + print_quartet(movi_size + 12 * frame_cnt + 4, outFile); // riff file size + // overwrite hdrl + unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame + outFile.seek(0x20); + print_quartet(us_per_frame, outFile); + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec + outFile.seek(0x24); + print_quartet(max_bytes_per_sec, outFile); + unsigned long tot_frames = frame_cnt; // hdrl.avih.tot_frames + outFile.seek(0x30); + print_quartet(frame_cnt, outFile); + unsigned long frames = frame_cnt; // (TOTALFRAMES); //hdrl.strl.list_odml.frames + outFile.seek(0xe0); + print_quartet(frames, outFile); + outFile.seek(0xe8); + print_quartet(movi_size, outFile); // size again + myCAM.CS_HIGH(); + // Close the file + outFile.close(); + Serial.println("Record video OK"); } -//Modify the MJPEG header from the beginning of the file -outFile.seek(4); -print_quartet(movi_size +12*frame_cnt+4, outFile);//riff file size -//overwrite hdrl -unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame -outFile.seek(0x20); -print_quartet(us_per_frame, outFile); -unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec -outFile.seek(0x24); -print_quartet(max_bytes_per_sec, outFile); -unsigned long tot_frames = frame_cnt; //hdrl.avih.tot_frames -outFile.seek(0x30); -print_quartet(frame_cnt, outFile); -unsigned long frames =frame_cnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames -outFile.seek(0xe0); -print_quartet(frames, outFile); -outFile.seek(0xe8); -print_quartet(movi_size, outFile);// size again -myCAM.CS_HIGH(); -//Close the file -outFile.close(); -Serial.println("Record video OK"); -} -void setup(){ -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(115200); -Serial.println("ArduCAM Start!"); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -delay(1000); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println("SPI interface Error!"); - delay(1000);continue; - }else{ - Serial.println("SPI interface OK!");break; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(115200); + Serial.println("ArduCAM Start!"); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + delay(1000); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println("SPI interface Error!"); + delay(1000); + continue; + } + else + { + Serial.println("SPI interface OK!"); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println("SD Card Error");delay(1000); -} -Serial.println("SD Card detected."); -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println("SD Card Error"); + delay(1000); + } + Serial.println("SD Card detected."); +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println("Can't find OV2640 module!"); - delay(1000);continue; - }else{ - Serial.println("OV2640 detected.");break; + delay(1000); + continue; } - } -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 + else + { + Serial.println("OV2640 detected."); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("Can't find OV3640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println("Can't find OV5640 module!"); - delay(1000);continue; - }else{ - Serial.println("OV5640 detected.");break; - } + delay(1000); + continue; + } + else + { + Serial.println("OV5640 detected."); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println("Can't find OV5642 module!"); - delay(1000);continue; - } else{ - Serial.println("OV5642 detected."); break; + delay(1000); + continue; + } + else + { + Serial.println("OV5642 detected."); + break; } } #endif -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); -#elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); -#elif defined (OV5640_CAM) - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); -#elif defined (OV5642_CAM) - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); +#elif defined(OV5640_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); +#elif defined(OV5642_CAM) + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -delay(1000); + delay(1000); } -void loop(){ +void loop() +{ Video2SD(); delay(5000); } - - - - - - diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video_Streaming/ArduCAM_Shield_V2_Video_Streaming.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video_Streaming/ArduCAM_Shield_V2_Video_Streaming.ino index 3170d999..447699b8 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video_Streaming/ArduCAM_Shield_V2_Video_Streaming.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_Video_Streaming/ArduCAM_Shield_V2_Video_Streaming.ino @@ -21,41 +21,41 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -#if !(defined (ARDUCAM_SHIELD_V2)&&(defined (OV5640_CAM) ||defined (OV5642_CAM)||defined (OV2640_CAM) ||defined (OV3640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +#if !(defined(ARDUCAM_SHIELD_V2) && (defined(OV5640_CAM) || defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV3640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; #if defined(ESP8266) - const int SPI_CS = 16; -#else - const int SPI_CS =10; +const int SPI_CS = 16; +#else +const int SPI_CS = 10; #endif bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); -#elif defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); +#if defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); +#elif defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -63,461 +63,523 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(SPI_CS, OUTPUT); - digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("ACK CMD Can't find OV3640 module! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV3640 detected. END")); + break; } - } -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("ACK CMD Can't find OV3640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV3640 detected. END"));break; - } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 + } +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5640 detected. END"));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected. END")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; - } else{ - Serial.println(F("ACK CMD OV5642 detected. END")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if !(defined (OV2640_CAM)||defined (OV3640_CAM)) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_CAM) || defined(OV3640_CAM)) myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); #endif myCAM.clear_fifo_flag(); - } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -if (Serial.available()) +void loop() { - #if defined (ESP8266) - yield(); - #endif - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + if (Serial.available()) { +#if defined(ESP8266) + yield(); +#endif + temp = Serial.read(); + switch (temp) + { case 0: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_176x144);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_320x240 END")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_320x240); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - break; +#endif + break; case 1: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_320x240 END")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_352x288);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_352x288 END")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_640x480); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - break; +#endif + break; case 2: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_352x288);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_352x288 END")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_640x480);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_640x480 END")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_1280x960); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - break; +#endif + break; case 3: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_640x480);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_640x480 END")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_800x480);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_800x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_800x480 END")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - break; +#endif + break; case 4: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_800x600);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_800x600 END")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_1024x768);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1024x768 END")); - #elif defined (OV5642_CAM) +#elif defined(OV5642_CAM) myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - break; +#endif + break; case 5: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1024x768 END")); - #elif defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_1280x960);delay(1000); +#elif defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1280x960 END")); - #elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - break; - #if (defined (OV5640_CAM)||defined (OV2640_CAM)) +#endif + break; +#if (defined(OV5640_CAM) || defined(OV2640_CAM)) case 6: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1280x960 END")); - #else - myCAM.OV5640_set_JPEG_size(OV5640_1600x1200);delay(1000); +#else + myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1600x1200 END")); - #endif - break; +#endif + break; case 7: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - #elif defined(OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1600x1200 END")); - #else - myCAM.OV5640_set_JPEG_size(OV5640_2048x1536);delay(1000); +#else + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); - #endif - break; +#endif + break; case 8: - temp = 0xff; - #if defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); + temp = 0xff; +#if defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); - #elif defined (OV3640_CAM) - myCAM.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); - #else - myCAM.OV5640_set_JPEG_size(OV5640_2592x1944);delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); +#else + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); - #endif - break; - #endif +#endif + break; +#endif case 0x10: - temp = 0xff; - mode = 1; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + temp = 0xff; + mode = 1; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if !(defined (OV2640_CAM)||defined (OV3640_CAM)) + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_CAM) || defined(OV3640_CAM)) myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - break; +#endif + break; case 0x20: - temp = 0xff; - mode = 2; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + temp = 0xff; + mode = 2; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - temp = 0xff; - mode = 3; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + temp = 0xff; + mode = 3; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - #if !(defined (OV2640_CAM)) - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); +#if !(defined(OV2640_CAM)) + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; default: - break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; + break; + } } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + if (mode == 1) { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); + if (start_capture == 1) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + start_capture = 0; + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } } -} -else if (mode == 2) -{ - while (1) + else if (mode == 2) { - #if defined (ESP8266) - yield(); - #endif - temp = Serial.read(); - if (temp == 0x21) + while (1) { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); - break; +#if defined(ESP8266) + yield(); +#endif + temp = Serial.read(); + if (temp == 0x21) + { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + start_capture = 0; + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) + { + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + while (length--) + { +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + Serial.println(F("ACK IMG END")); + is_header = true; + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); + } + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; + } } - if (start_capture == 2) + } + else if (mode == 3) + { + if (start_capture == 3) { + // Flush the FIFO myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; uint32_t length = 0; length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + if (length >= MAX_FIFO_SIZE) { + Serial.println(F("ACK CMD Over size. END")); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) { - #if defined (ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) - { - Serial.write(temp); - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + Serial.write(pgm_read_byte(&bmp_header[temp])); + } + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) { - Serial.println(F("ACK IMG END")); - is_header = true; - Serial.write(temp_last); - Serial.write(temp); + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); } + Serial.write(0xBB); + Serial.write(0xCC); myCAM.CS_HIGH(); + // Clear the capture done flag myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } } -else if (mode == 3) +uint8_t read_fifo_burst(ArduCAM myCAM) { - if (start_capture == 3) + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 512 kb { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; + Serial.println(F("ACK CMD Over size. END")); + return 0; } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + if (length == 0) // 0 kb { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) - { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0. END")); - myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + Serial.println(F("ACK CMD Size is 0. END")); + return 0; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + while (length--) + { +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) { - Serial.write(pgm_read_byte(&bmp_header[temp])); + Serial.write(temp); } - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + else if ((temp == 0xD8) & (temp_last == 0xFF)) { - for (j = 0; j < 320; j++) - { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); - } + Serial.println(F("ACK IMG END")); + is_header = true; + Serial.write(temp_last); + Serial.write(temp); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -} -uint8_t read_fifo_burst(ArduCAM myCAM) -{ -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -length = myCAM.read_fifo_length(); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //512 kb -{ - Serial.println(F("ACK CMD Over size. END")); - return 0; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("ACK CMD Size is 0. END")); - return 0; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -while ( length-- ) -{ - #if defined (ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) - { - Serial.write(temp); - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - Serial.println(F("ACK IMG END")); - is_header = true; - Serial.write(temp_last); - Serial.write(temp); + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); -} -myCAM.CS_HIGH(); -is_header = false; -return 1; + myCAM.CS_HIGH(); + is_header = false; + return 1; } diff --git a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_short_movie_clip/ArduCAM_Shield_V2_short_movie_clip.ino b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_short_movie_clip/ArduCAM_Shield_V2_short_movie_clip.ino index 774150fa..5758f299 100644 --- a/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_short_movie_clip/ArduCAM_Shield_V2_short_movie_clip.ino +++ b/ArduCAM/examples/Shield_V2/ArduCAM_Shield_V2_short_movie_clip/ArduCAM_Shield_V2_short_movie_clip.ino @@ -3,23 +3,23 @@ // This demo was made for ARDUCAM_SHIELD_V2. // It can continue shooting and store it into the SD card in AVI format // The demo sketch will do the following tasks -// 1.Shoot video button, began to shoot video +// 1.Shoot video button, began to shoot video // 2. Set the camera to JPEG output mode. // 3. Capture a JPEG photo and buffer the image to FIFO // 4.Write AVI Header // 5.Write the video data to the SD card // 6.More updates AVI file header // 7.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ARDUCAM_SHIELD_V2 // and use Arduino IDE 1.6.8 compiler or above #include @@ -27,342 +27,617 @@ #include #include #include "memorysaver.h" -//This demo can only work on ARDUCAM_SHIELD_V2 platform. -#if !(defined (ARDUCAM_SHIELD_V2)&&(defined (OV5640_CAM) ||defined (OV5642_CAM) ||defined (OV2640_CAM) ||defined (OV3640_CAM))) +// This demo can only work on ARDUCAM_SHIELD_V2 platform. +#if !(defined(ARDUCAM_SHIELD_V2) && (defined(OV5640_CAM) || defined(OV5642_CAM) || defined(OV2640_CAM) || defined(OV3640_CAM))) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x07 -#define rate 0x0a +#define FRAMES_NUM 0x07 +#define rate 0x0a #define AVIOFFSET 240 #if defined(ESP8266) - #define SD_CS 0 - const int SPI_CS = 16; -#else - #define SD_CS 9 - const int SPI_CS =10; +#define SD_CS 0 +const int SPI_CS = 16; +#else +#define SD_CS 9 +const int SPI_CS = 10; #endif bool is_header = false; uint32_t total_time = 0; unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const int avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x40, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const int avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xf0, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x40, + 0x01, + 0x00, + 0x00, + 0xf0, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -#if defined (OV5640_CAM) - ArduCAM myCAM(OV5640, SPI_CS); -#elif defined (OV5642_CAM) - ArduCAM myCAM(OV5642, SPI_CS); -#elif defined (OV2640_CAM) - ArduCAM myCAM(OV2640, SPI_CS); -#elif defined (OV3640_CAM) - ArduCAM myCAM(OV3640, SPI_CS); +#if defined(OV5640_CAM) +ArduCAM myCAM(OV5640, SPI_CS); +#elif defined(OV5642_CAM) +ArduCAM myCAM(OV5642, SPI_CS); +#elif defined(OV2640_CAM) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_CAM) +ArduCAM myCAM(OV3640, SPI_CS); #endif uint8_t read_fifo_burst(); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the CS as an output: -pinMode(SD_CS, OUTPUT); -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK!"));break; + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(SD_CS, OUTPUT); + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK!")); + break; + } } -} -#if defined (OV2640_CAM) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_CAM) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV3640_CAM) + while (1) + { + // Check if the camera module type is OV3640 + myCAM.wrSensorReg16_8(0xff, 0x01); + myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) || (pid != 0x4C)) + { + Serial.println(F("Can't find OV3640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; } } -#elif defined (OV3640_CAM) -while(1){ - //Check if the camera module type is OV3640 - myCAM.wrSensorReg16_8(0xff, 0x01); - myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if((vid != 0x36) || (pid != 0x4C)){ - Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } -#elif defined (OV5640_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5640_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -#elif defined (OV5642_CAM) - while(1){ - //Check if the camera module type is OV5642 +#elif defined(OV5642_CAM) + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - } else{ - Serial.println(F("OV5642 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if !(defined (OV2640_CAM)||defined (OV3640_CAM) ) + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_CAM) || defined(OV3640_CAM)) myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); #endif -#if defined (OV5640_CAM) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); -#elif defined (OV5642_CAM) - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); -#elif defined (OV2640_CAM) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); -#elif defined (OV3640_CAM) - myCAM.OV2640_set_JPEG_size(OV3640_320x240);delay(1000); +#if defined(OV5640_CAM) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); +#elif defined(OV5642_CAM) + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); +#elif defined(OV2640_CAM) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); +#elif defined(OV3640_CAM) + myCAM.OV2640_set_JPEG_size(OV3640_320x240); + delay(1000); #endif -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); } boolean isCaptureFlag = false; uint32_t length = 0; -void loop() { -if(myCAM.get_bit(ARDUCHIP_TRIG , SHUTTER_MASK)) +void loop() { - isCaptureFlag = true; - while(myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)); -} -if(isCaptureFlag){ - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - Serial.println(F("Start capture!")); - total_time = millis(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); - length = myCAM.read_fifo_length(); - if( length < 0x3FFFFF){ + if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + { + isCaptureFlag = true; + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + ; + } + if (isCaptureFlag) + { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)){ - #if defined (ESP8266) - yield(); - #endif + Serial.println(F("Start capture!")); + total_time = millis(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + if (length < 0x3FFFFF) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { +#if defined(ESP8266) + yield(); +#endif + } + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; } - Serial.println(F("CAM Capture Done.")); - total_time = millis() - total_time; - }else{ - Serial.println(F("CAM Capture Done.")); + else + { + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; + } + total_time = millis(); + read_fifo_burst(); total_time = millis() - total_time; + // Clear the capture done flag + myCAM.clear_fifo_flag(); + isCaptureFlag = false; } - total_time = millis(); - read_fifo_burst(); - total_time = millis() - total_time; - //Clear the capture done flag - myCAM.clear_fifo_flag(); - isCaptureFlag = false; -} } uint8_t read_fifo_burst() -{ -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -static int i = 0; -static int k = 0; -unsigned long position = 0; -uint16_t frame_cnt = 0; -uint8_t remnant = 0; -File outFile; -char str[8]; -byte buf[256]; -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //8M -{ - Serial.println(F("Over size.")); - return 0 ; -} -if (length == 0 ) //0 kb -{ -Serial.println(F("Size is 0.")); -return 0; -} -movi_size = 0; -//Create a avi file -k = k + 1; -itoa(k, str, 10); -strcat(str, ".avi"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("File open failed")); - while (1); -} -//Write AVI Header -for ( i = 0; i < AVIOFFSET; i++) -{ - char ch = pgm_read_byte(&avi_header[i]); - buf[i] = ch; -} -outFile.write(buf, AVIOFFSET); -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -i = 0; -while ( length-- ) { - #if defined (ESP8266) - yield(); - #endif - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + static int i = 0; + static int k = 0; + unsigned long position = 0; + uint16_t frame_cnt = 0; + uint8_t remnant = 0; + File outFile; + char str[8]; + byte buf[256]; + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - jpeg_size += i; - remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; - jpeg_size = jpeg_size + remnant; - movi_size = movi_size + jpeg_size; - if (remnant > 0) - outFile.write(zero_buf, remnant); - position = outFile.position(); - outFile.seek(position - 4 - jpeg_size); - print_quartet(jpeg_size, outFile); - position = outFile.position(); - outFile.seek(position + 6); - outFile.write("AVI1", 4); - position = outFile.position(); - outFile.seek(position + jpeg_size - 10); - is_header = false; - frame_cnt++; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return 0; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return 0; + } + movi_size = 0; + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".avi"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open failed")); + while (1) + ; + } + // Write AVI Header + for (i = 0; i < AVIOFFSET; i++) + { + char ch = pgm_read_byte(&avi_header[i]); + buf[i] = ch; + } + outFile.write(buf, AVIOFFSET); + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + i = 0; + while (length--) + { +#if defined(ESP8266) + yield(); +#endif + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + jpeg_size += i; + remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; + jpeg_size = jpeg_size + remnant; + movi_size = movi_size + jpeg_size; + if (remnant > 0) + outFile.write(zero_buf, remnant); + position = outFile.position(); + outFile.seek(position - 4 - jpeg_size); + print_quartet(jpeg_size, outFile); + position = outFile.position(); + outFile.seek(position + 6); + outFile.write("AVI1", 4); + position = outFile.position(); + outFile.seek(position + jpeg_size - 10); + is_header = false; + frame_cnt++; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + jpeg_size += 256; + } + } + else if ((temp == 0xD8) && (temp_last == 0xFF)) + { + is_header = true; + myCAM.CS_HIGH(); + outFile.write("00dc"); + outFile.write(zero_buf, 4); i = 0; - buf[i++] = temp; + jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - jpeg_size += 256; - } - } - else if ((temp == 0xD8) && (temp_last == 0xFF)) - { - is_header = true; - myCAM.CS_HIGH(); - outFile.write("00dc"); - outFile.write(zero_buf, 4); - i = 0; - jpeg_size = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - buf[i++] = temp_last; - buf[i++] = temp; + buf[i++] = temp_last; + buf[i++] = temp; + } } -} -myCAM.CS_HIGH(); -//Modify the MJPEG header from the beginning of the file -outFile.seek(4); -print_quartet(movi_size +12*frame_cnt+4, outFile);//riff file size -//overwrite hdrl -unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame -outFile.seek(0x20); -print_quartet(us_per_frame, outFile); -unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec -outFile.seek(0x24); -print_quartet(max_bytes_per_sec, outFile); -unsigned long tot_frames = frame_cnt; //hdrl.avih.tot_frames -outFile.seek(0x30); -print_quartet(tot_frames, outFile); -unsigned long frames =frame_cnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames -outFile.seek(0xe0); -print_quartet(frames, outFile); -outFile.seek(0xe8); -print_quartet(movi_size, outFile);// size again -//Close the file -outFile.close(); -is_header = false; -Serial.println(F("Movie save OK.")); -return 1; + myCAM.CS_HIGH(); + // Modify the MJPEG header from the beginning of the file + outFile.seek(4); + print_quartet(movi_size + 12 * frame_cnt + 4, outFile); // riff file size + // overwrite hdrl + unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame + outFile.seek(0x20); + print_quartet(us_per_frame, outFile); + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec + outFile.seek(0x24); + print_quartet(max_bytes_per_sec, outFile); + unsigned long tot_frames = frame_cnt; // hdrl.avih.tot_frames + outFile.seek(0x30); + print_quartet(tot_frames, outFile); + unsigned long frames = frame_cnt; // (TOTALFRAMES); //hdrl.strl.list_odml.frames + outFile.seek(0xe0); + print_quartet(frames, outFile); + outFile.seek(0xe8); + print_quartet(movi_size, outFile); // size again + // Close the file + outFile.close(); + is_header = false; + Serial.println(F("Movie save OK.")); + return 1; } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_OV2640_functions/ArduCAM_Mini_2MP_OV2640_functions.ino b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_OV2640_functions/ArduCAM_Mini_2MP_OV2640_functions.ino index 1ac33874..b7d85041 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_OV2640_functions/ArduCAM_Mini_2MP_OV2640_functions.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_OV2640_functions/ArduCAM_Mini_2MP_OV2640_functions.ino @@ -11,34 +11,34 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP platform. +// This demo can only work on OV2640_MINI_2MP platform. #if !(defined OV2640_MINI_2MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_MINI_2MP) - ArduCAM myCAM( OV2640, CS ); +#if defined(OV2640_MINI_2MP) +ArduCAM myCAM(OV2640, CS); #else - ArduCAM myCAM( OV5642, CS ); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -46,500 +46,642 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); - //Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; - } } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP) myCAM.OV2640_set_JPEG_size(OV2640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); -myCAM.clear_fifo_flag(); -#if !(defined (OV2640_MINI_2MP)) -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + delay(1000); + myCAM.clear_fifo_flag(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); #endif } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 1: - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - temp = 0xff; - break; - case 2: - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); + temp = 0xff; + break; + case 2: + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 3: - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_352x288 END")); + temp = 0xff; + break; case 4: - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 5: - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_800x600 END")); + temp = 0xff; + break; case 6: - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); + temp = 0xff; + break; case 7: - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); + temp = 0xff; + break; case 8: - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); + temp = 0xff; + break; case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - break; + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; case 0x40: - myCAM.OV2640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto END"));break; - case 0x41: - myCAM.OV2640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny END"));break; - case 0x42: - myCAM.OV2640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy END"));break; - case 0x43: - myCAM.OV2640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office END"));break; - case 0x44: - myCAM.OV2640_set_Light_Mode(Home); temp = 0xff; - Serial.println(F("ACK CMD Set to Home END"));break; - case 0x50: - myCAM.OV2640_set_Color_Saturation(Saturation2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x51: - myCAM.OV2640_set_Color_Saturation(Saturation1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x52: - myCAM.OV2640_set_Color_Saturation(Saturation0); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; + myCAM.OV2640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto END")); + break; + case 0x41: + myCAM.OV2640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny END")); + break; + case 0x42: + myCAM.OV2640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy END")); + break; + case 0x43: + myCAM.OV2640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office END")); + break; + case 0x44: + myCAM.OV2640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home END")); + break; + case 0x50: + myCAM.OV2640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x51: + myCAM.OV2640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x52: + myCAM.OV2640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; case 0x53: - myCAM. OV2640_set_Color_Saturation(Saturation_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; + myCAM.OV2640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; case 0x54: - myCAM.OV2640_set_Color_Saturation(Saturation_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; - case 0x60: - myCAM.OV2640_set_Brightness(Brightness2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x61: - myCAM.OV2640_set_Brightness(Brightness1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x62: - myCAM.OV2640_set_Brightness(Brightness0); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; + myCAM.OV2640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; + case 0x60: + myCAM.OV2640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x61: + myCAM.OV2640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x62: + myCAM.OV2640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; case 0x63: - myCAM. OV2640_set_Brightness(Brightness_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; + myCAM.OV2640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; case 0x64: - myCAM.OV2640_set_Brightness(Brightness_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; + myCAM.OV2640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; case 0x70: - myCAM.OV2640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; + myCAM.OV2640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; case 0x71: - myCAM.OV2640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x72: - myCAM.OV2640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; + myCAM.OV2640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x72: + myCAM.OV2640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; case 0x73: - myCAM.OV2640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x74: - myCAM.OV2640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; - case 0x80: - myCAM.OV2640_set_Special_effects(Antique);temp = 0xff; - Serial.println(F("ACK CMD Set to Antique END"));break; - case 0x81: - myCAM.OV2640_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish END"));break; - case 0x82: - myCAM.OV2640_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break; - case 0x83: - myCAM.OV2640_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break; - case 0x84: - myCAM.OV2640_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break; - case 0x85: - myCAM.OV2640_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break; - case 0x86: - myCAM.OV2640_set_Special_effects(BWnegative);temp = 0xff; - Serial.println(F("ACK CMD Set to BWnegative END"));break; - case 0x87: - myCAM.OV2640_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); + myCAM.OV2640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x74: + myCAM.OV2640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; + case 0x80: + myCAM.OV2640_set_Special_effects(Antique); + temp = 0xff; + Serial.println(F("ACK CMD Set to Antique END")); + break; + case 0x81: + myCAM.OV2640_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish END")); + break; + case 0x82: + myCAM.OV2640_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x83: + myCAM.OV2640_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x84: + myCAM.OV2640_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x85: + myCAM.OV2640_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0x86: + myCAM.OV2640_set_Special_effects(BWnegative); + temp = 0xff; + Serial.println(F("ACK CMD Set to BWnegative END")); + break; + case 0x87: + myCAM.OV2640_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); break; } - switch (temp) - { - case 0x40: - myCAM.OV2640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto END"));break; - case 0x41: - myCAM.OV2640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny END"));break; - case 0x42: - myCAM.OV2640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy END"));break; - case 0x43: - myCAM.OV2640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office END"));break; - case 0x44: - myCAM.OV2640_set_Light_Mode(Home); temp = 0xff; - Serial.println(F("ACK CMD Set to Home END"));break; - case 0x50: - myCAM.OV2640_set_Color_Saturation(Saturation2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x51: - myCAM.OV2640_set_Color_Saturation(Saturation1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x52: - myCAM.OV2640_set_Color_Saturation(Saturation0); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; - case 0x53: - myCAM. OV2640_set_Color_Saturation(Saturation_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; - case 0x54: - myCAM.OV2640_set_Color_Saturation(Saturation_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; - case 0x60: - myCAM.OV2640_set_Brightness(Brightness2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x61: - myCAM.OV2640_set_Brightness(Brightness1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x62: - myCAM.OV2640_set_Brightness(Brightness0); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; - case 0x63: - myCAM. OV2640_set_Brightness(Brightness_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; - case 0x64: - myCAM.OV2640_set_Brightness(Brightness_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; - case 0x70: - myCAM.OV2640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; - case 0x71: - myCAM.OV2640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x72: - myCAM.OV2640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; - case 0x73: - myCAM.OV2640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x74: - myCAM.OV2640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; - case 0x80: - myCAM.OV2640_set_Special_effects(Antique);temp = 0xff; - Serial.println(F("ACK CMD Set to Antique END"));break; - case 0x81: - myCAM.OV2640_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish END"));break; - case 0x82: - myCAM.OV2640_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break; - case 0x83: - myCAM.OV2640_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break; - case 0x84: - myCAM.OV2640_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break; - case 0x85: - myCAM.OV2640_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break; - case 0x86: - myCAM.OV2640_set_Special_effects(BWnegative);temp = 0xff; - Serial.println(F("ACK CMD Set to BWnegative END"));break; - case 0x87: - myCAM.OV2640_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break; } - if (start_capture == 2) + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + switch (temp) + { + case 0x40: + myCAM.OV2640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto END")); + break; + case 0x41: + myCAM.OV2640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny END")); + break; + case 0x42: + myCAM.OV2640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy END")); + break; + case 0x43: + myCAM.OV2640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office END")); + break; + case 0x44: + myCAM.OV2640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home END")); + break; + case 0x50: + myCAM.OV2640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x51: + myCAM.OV2640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x52: + myCAM.OV2640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; + case 0x53: + myCAM.OV2640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; + case 0x54: + myCAM.OV2640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; + case 0x60: + myCAM.OV2640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x61: + myCAM.OV2640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x62: + myCAM.OV2640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; + case 0x63: + myCAM.OV2640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; + case 0x64: + myCAM.OV2640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; + case 0x70: + myCAM.OV2640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; + case 0x71: + myCAM.OV2640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x72: + myCAM.OV2640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; + case 0x73: + myCAM.OV2640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x74: + myCAM.OV2640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; + case 0x80: + myCAM.OV2640_set_Special_effects(Antique); + temp = 0xff; + Serial.println(F("ACK CMD Set to Antique END")); + break; + case 0x81: + myCAM.OV2640_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish END")); + break; + case 0x82: + myCAM.OV2640_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x83: + myCAM.OV2640_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x84: + myCAM.OV2640_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x85: + myCAM.OV2640_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0x86: + myCAM.OV2640_set_Special_effects(BWnegative); + temp = 0xff; + Serial.println(F("ACK CMD Set to BWnegative END")); + break; + case 0x87: + myCAM.OV2640_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) - { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + else if (mode == 3) { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (start_capture == 3) { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0. END")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - //for old version, enable it else disable - // SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.println(F("ACK CMD Over size. END")); + myCAM.clear_fifo_flag(); + return; } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + { + Serial.write(pgm_read_byte(&bmp_header[temp])); + } + // for old version, enable it else disable + // SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size. END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0. END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -551,8 +693,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD.ino index bf212ead..02c4cc3f 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD/ArduCAM_Mini_2MP_Plus_Multi_Capture2SD.ino @@ -8,16 +8,16 @@ // 2. Capture a JPEG photo and buffer the image to FIFO // 3.Write the picture data to the SD card // 5.close the file -//You can change the FRAMES_NUM count to change the number of the picture. -//IF the FRAMES_NUM is 0X00, take one photos -//IF the FRAMES_NUM is 0X01, take two photos -//IF the FRAMES_NUM is 0X02, take three photos -//IF the FRAMES_NUM is 0X03, take four photos -//IF the FRAMES_NUM is 0X04, take five photos -//IF the FRAMES_NUM is 0X05, take six photos -//IF the FRAMES_NUM is 0X06, take seven photos -//IF the FRAMES_NUM is 0XFF, continue shooting until the FIFO is full -//You can see the picture in the SD card. +// You can change the FRAMES_NUM count to change the number of the picture. +// IF the FRAMES_NUM is 0X00, take one photos +// IF the FRAMES_NUM is 0X01, take two photos +// IF the FRAMES_NUM is 0X02, take three photos +// IF the FRAMES_NUM is 0X03, take four photos +// IF the FRAMES_NUM is 0X04, take five photos +// IF the FRAMES_NUM is 0X05, take six photos +// IF the FRAMES_NUM is 0X06, take seven photos +// IF the FRAMES_NUM is 0XFF, continue shooting until the FIFO is full +// You can see the picture in the SD card. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM_Mini_2MP_Plus // and use Arduino IDE 1.6.8 compiler or above @@ -26,21 +26,22 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV2640_MINI_2MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV2640_MINI_2MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x06 +#define FRAMES_NUM 0x06 // set pin 7 as the slave select for the digital pot: const int CS = 7; #define SD_CS 9 bool is_header = false; int total_time = 0; -#if defined (OV2640_MINI_2MP_PLUS) -ArduCAM myCAM( OV2640, CS ); +#if defined(OV2640_MINI_2MP_PLUS) +ArduCAM myCAM(OV2640, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { +void setup() +{ // put your setup code here, to run once: uint8_t vid, pid; uint8_t temp; @@ -56,63 +57,76 @@ void setup() { digitalWrite(CS, HIGH); // initialize SPI: SPI.begin(); - //Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - while (1) { - //Check if the ArduCAM SPI bus is OK + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println(F("SPI interface Error!")); - delay(1000); continue; - } else { - Serial.println(F("SPI interface OK.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; } } -#if defined (OV2640_MINI_2MP_PLUS) - while (1) { - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP_PLUS) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) { + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module!")); - delay(1000); continue; + delay(1000); + continue; } - else { - Serial.println(F("ACK CMD OV2640 detected.")); break; + else + { + Serial.println(F("ACK CMD OV2640 detected.")); + break; } } #endif - //Initialize SD Card + // Initialize SD Card while (!SD.begin(SD_CS)) { - Serial.println(F("SD Card Error!")); delay(1000); + Serial.println(F("SD Card Error!")); + delay(1000); } Serial.println(F("SD Card detected.")); - //Change to JPEG capture mode and initialize the OV5640 module + // Change to JPEG capture mode and initialize the OV5640 module myCAM.set_format(JPEG); myCAM.InitCAM(); myCAM.clear_fifo_flag(); myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); } -void loop() { +void loop() +{ // put your main code here, to run repeatedly: myCAM.flush_fifo(); myCAM.clear_fifo_flag(); -#if defined (OV2640_MINI_2MP_PLUS) +#if defined(OV2640_MINI_2MP_PLUS) myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); #endif - //Start capture + // Start capture myCAM.start_capture(); Serial.println(F("start capture.")); total_time = millis(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; Serial.println(F("CAM Capture Done.")); total_time = millis() - total_time; Serial.print(F("capture total_time used (in miliseconds):")); @@ -122,7 +136,7 @@ void loop() { total_time = millis() - total_time; Serial.print(F("save capture total_time used (in miliseconds):")); Serial.println(total_time, DEC); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); delay(5000); } @@ -138,31 +152,31 @@ uint8_t read_fifo_burst(ArduCAM myCAM) length = myCAM.read_fifo_length(); Serial.print(F("The fifo length is :")); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //8M + if (length >= MAX_FIFO_SIZE) // 8M { Serial.println("Over size."); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("Size is 0.")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode + myCAM.set_fifo_burst(); // Set fifo burst mode i = 0; - while ( length-- ) + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); outFile.write(buf, i); - //Close the file + // Close the file outFile.close(); Serial.println(F("OK")); is_header = false; @@ -172,12 +186,12 @@ uint8_t read_fifo_burst(ArduCAM myCAM) } if (is_header == true) { - //Write image data to buffer if not full + // Write image data to buffer if not full if (i < 256) buf[i++] = temp; else { - //Write 256 bytes image data to file + // Write 256 bytes image data to file myCAM.CS_HIGH(); outFile.write(buf, 256); i = 0; @@ -190,16 +204,17 @@ uint8_t read_fifo_burst(ArduCAM myCAM) { is_header = true; myCAM.CS_HIGH(); - //Create a avi file + // Create a avi file k = k + 1; itoa(k, str, 10); strcat(str, ".jpg"); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println(F("File open failed")); - while (1); + while (1) + ; } myCAM.CS_LOW(); myCAM.set_fifo_burst(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_VideoStreaming/ArduCAM_Mini_2MP_Plus_VideoStreaming.ino b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_VideoStreaming/ArduCAM_Mini_2MP_Plus_VideoStreaming.ino index 545591f3..f0201218 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_VideoStreaming/ArduCAM_Mini_2MP_Plus_VideoStreaming.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_VideoStreaming/ArduCAM_Mini_2MP_Plus_VideoStreaming.ino @@ -21,29 +21,29 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. -#if !( defined OV2640_MINI_2MP_PLUS) +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +#if !(defined OV2640_MINI_2MP_PLUS) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_MINI_2MP_PLUS) -ArduCAM myCAM( OV2640, CS ); +#if defined(OV2640_MINI_2MP_PLUS) +ArduCAM myCAM(OV2640, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { +void setup() +{ // put your setup code here, to run once: uint8_t vid, pid; uint8_t temp; @@ -60,49 +60,61 @@ void setup() { digitalWrite(CS, HIGH); // initialize SPI: SPI.begin(); - //Reset the CPLD + // Reset the CPLD myCAM.write_reg(0x07, 0x80); delay(100); myCAM.write_reg(0x07, 0x00); delay(100); - - while (1) { - //Check if the ArduCAM SPI bus is OK + + while (1) + { + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55) { + if (temp != 0x55) + { Serial.println(F("ACK CMD SPI interface Error!END")); - delay(1000); continue; - } else { - Serial.println(F("ACK CMD SPI interface OK.END")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK.END")); + break; } } -#if defined (OV2640_MINI_2MP_PLUS) - while (1) { - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP_PLUS) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) { + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module!")); - delay(1000); continue; + delay(1000); + continue; } - else { - Serial.println(F("ACK CMD OV2640 detected.END")); break; + else + { + Serial.println(F("ACK CMD OV2640 detected.END")); + break; } } #endif - //Change to JPEG capture mode and initialize the OV5642 module + // Change to JPEG capture mode and initialize the OV5642 module myCAM.set_format(JPEG); myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP_PLUS) +#if defined(OV2640_MINI_2MP_PLUS) myCAM.OV2640_set_JPEG_size(OV2640_320x240); #endif delay(1000); myCAM.clear_fifo_flag(); } -void loop() { +void loop() +{ // put your main code here, to run repeatedly: uint8_t temp = 0xff, temp_last = 0; bool is_header = false; @@ -111,149 +123,174 @@ void loop() { temp = Serial.read(); switch (temp) { - case 0: -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_160x120); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_160x120END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_176x144); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_160x120END")); + case 0: +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_160x120END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_160x120END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_320x240END")); + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_320x240END")); #endif - temp = 0xff; - break; - case 1: -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_176x144); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_176x144END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_320x240); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_320x240END")); + temp = 0xff; + break; + case 1: +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_176x144END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_320x240END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_640x480); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_640x480END")); + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_640x480END")); #endif - temp = 0xff; - break; - case 2: -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_320x240); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_320x240END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_352x288); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_352x288END")); + temp = 0xff; + break; + case 2: +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_320x240END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_352x288END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_1024x768); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1024x768END")); + myCAM.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1024x768END")); #endif - temp = 0xff; - break; - case 3: - temp = 0xff; -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_352x288); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_352x288END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_640x480); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_640x480END")); + temp = 0xff; + break; + case 3: + temp = 0xff; +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_352x288END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_640x480END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_1280x960); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1280x960END")); + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1280x960END")); #endif - break; - case 4: - temp = 0xff; -#if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_640x480); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_640x480END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_800x600); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_800x600END")); + break; + case 4: + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_640x480END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_800x600END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1600x1200END")); + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1600x1200END")); #endif - break; - case 5: - temp = 0xff; -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_800x600); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_800x600END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1024x768); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_1024x768END")); + break; + case 5: + temp = 0xff; +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_800x600END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_1024x768END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_2048x1536END")); + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_2048x1536END")); #endif - break; - case 6: - temp = 0xff; -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_1024x768); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1024x768END")); -#elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1280x960); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_1280x960END")); + break; + case 6: + temp = 0xff; +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1024x768END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_1280x960END")); #else - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); delay(1000); - Serial.println(F("ACK CMD switch to OV5642_2592x1944END")); + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_2592x1944END")); #endif - break; - case 7: - temp = 0xff; -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024END")); + break; + case 7: + temp = 0xff; +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024END")); #else - myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_1600x1200END")); + myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_1600x1200END")); #endif - break; - case 8: - temp = 0xff; -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200END")); + break; + case 8: + temp = 0xff; +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200END")); #else - myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536END")); + myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536END")); #endif - break; - case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot.END")); - break; - case 0x11: - temp = 0xff; - Serial.println(F("ACK CMD Change OK.END")); - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.OV2640_set_JPEG_size(OV2640_320x240); - break; - case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming.END")); - break; - case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot.END")); - break; - case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - break; - default: - break; + break; + case 0x10: + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot.END")); + break; + case 0x11: + temp = 0xff; + Serial.println(F("ACK CMD Change OK.END")); + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + break; + case 0x20: + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming.END")); + break; + case 0x30: + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot.END")); + break; + case 0x31: + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); + break; + default: + break; } } if (mode == 1) @@ -262,7 +299,7 @@ void loop() { { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } @@ -271,7 +308,7 @@ void loop() { Serial.println(F("ACK CMD CAM Capture Done.END")); delay(50); read_fifo_burst(myCAM); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); } } @@ -291,7 +328,7 @@ void loop() { { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } @@ -306,13 +343,13 @@ void loop() { continue; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -324,7 +361,7 @@ void loop() { Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, break; delayMicroseconds(15); } @@ -339,10 +376,10 @@ void loop() { { if (start_capture == 3) { - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } @@ -353,20 +390,20 @@ void loop() { uint8_t temp, temp_last; uint32_t length = 0; length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (length >= MAX_FIFO_SIZE) { Serial.println(F("ACK CMD Over size.END")); myCAM.clear_fifo_flag(); return; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0.END")); myCAM.clear_fifo_flag(); return; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode + myCAM.set_fifo_burst(); // Set fifo burst mode Serial.write(0xFF); Serial.write(0xAA); @@ -380,8 +417,10 @@ void loop() { { for (j = 0; j < 320; j++) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; Serial.write(VL); delayMicroseconds(12); Serial.write(VH); @@ -391,7 +430,7 @@ void loop() { Serial.write(0xBB); Serial.write(0xCC); myCAM.CS_HIGH(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); } } @@ -402,24 +441,24 @@ uint8_t read_fifo_burst(ArduCAM myCAM) uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size.END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0.END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -431,7 +470,7 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, break; delayMicroseconds(15); } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_functions/ArduCAM_Mini_2MP_Plus_functions.ino b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_functions/ArduCAM_Mini_2MP_Plus_functions.ino index 0176b685..1b74f729 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_functions/ArduCAM_Mini_2MP_Plus_functions.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_functions/ArduCAM_Mini_2MP_Plus_functions.ino @@ -11,34 +11,34 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP_PLUS platform. +// This demo can only work on OV2640_MINI_2MP_PLUS platform. #if !(defined OV2640_MINI_2MP_PLUS) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_MINI_2MP_PLUS) - ArduCAM myCAM( OV2640, CS ); +#if defined(OV2640_MINI_2MP_PLUS) +ArduCAM myCAM(OV2640, CS); #else - ArduCAM myCAM( OV5642, CS ); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -46,498 +46,640 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); - //Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV2640_MINI_2MP_PLUS) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP_PLUS) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; - } } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP_PLUS) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP_PLUS) myCAM.OV2640_set_JPEG_size(OV2640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); -myCAM.clear_fifo_flag(); -#if !(defined (OV2640_MINI_2MP_PLUS)) -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + delay(1000); + myCAM.clear_fifo_flag(); +#if !(defined(OV2640_MINI_2MP_PLUS)) + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); #endif } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 1: - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - temp = 0xff; - break; - case 2: - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); + temp = 0xff; + break; + case 2: + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 3: - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_352x288 END")); + temp = 0xff; + break; case 4: - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 5: - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_800x600 END")); + temp = 0xff; + break; case 6: - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); + temp = 0xff; + break; case 7: - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); + temp = 0xff; + break; case 8: - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); - temp = 0xff; - break; + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); + temp = 0xff; + break; case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP_PLUS)) - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - break; + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP_PLUS)) + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP_PLUS)) - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP_PLUS)) + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; case 0x40: - myCAM.OV2640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto END"));break; - case 0x41: - myCAM.OV2640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny END"));break; - case 0x42: - myCAM.OV2640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy END"));break; - case 0x43: - myCAM.OV2640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office END"));break; - case 0x44: - myCAM.OV2640_set_Light_Mode(Home); temp = 0xff; - Serial.println(F("ACK CMD Set to Home END"));break; - case 0x50: - myCAM.OV2640_set_Color_Saturation(Saturation2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x51: - myCAM.OV2640_set_Color_Saturation(Saturation1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x52: - myCAM.OV2640_set_Color_Saturation(Saturation0); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; + myCAM.OV2640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto END")); + break; + case 0x41: + myCAM.OV2640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny END")); + break; + case 0x42: + myCAM.OV2640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy END")); + break; + case 0x43: + myCAM.OV2640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office END")); + break; + case 0x44: + myCAM.OV2640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home END")); + break; + case 0x50: + myCAM.OV2640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x51: + myCAM.OV2640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x52: + myCAM.OV2640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; case 0x53: - myCAM. OV2640_set_Color_Saturation(Saturation_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; + myCAM.OV2640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; case 0x54: - myCAM.OV2640_set_Color_Saturation(Saturation_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; - case 0x60: - myCAM.OV2640_set_Brightness(Brightness2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x61: - myCAM.OV2640_set_Brightness(Brightness1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x62: - myCAM.OV2640_set_Brightness(Brightness0); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; + myCAM.OV2640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; + case 0x60: + myCAM.OV2640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x61: + myCAM.OV2640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x62: + myCAM.OV2640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; case 0x63: - myCAM. OV2640_set_Brightness(Brightness_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; + myCAM.OV2640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; case 0x64: - myCAM.OV2640_set_Brightness(Brightness_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; + myCAM.OV2640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; case 0x70: - myCAM.OV2640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; + myCAM.OV2640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; case 0x71: - myCAM.OV2640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x72: - myCAM.OV2640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; + myCAM.OV2640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x72: + myCAM.OV2640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; case 0x73: - myCAM.OV2640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x74: - myCAM.OV2640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; - case 0x80: - myCAM.OV2640_set_Special_effects(Antique);temp = 0xff; - Serial.println(F("ACK CMD Set to Antique END"));break; - case 0x81: - myCAM.OV2640_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish END"));break; - case 0x82: - myCAM.OV2640_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break; - case 0x83: - myCAM.OV2640_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break; - case 0x84: - myCAM.OV2640_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break; - case 0x85: - myCAM.OV2640_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break; - case 0x86: - myCAM.OV2640_set_Special_effects(BWnegative);temp = 0xff; - Serial.println(F("ACK CMD Set to BWnegative END"));break; - case 0x87: - myCAM.OV2640_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); + myCAM.OV2640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x74: + myCAM.OV2640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; + case 0x80: + myCAM.OV2640_set_Special_effects(Antique); + temp = 0xff; + Serial.println(F("ACK CMD Set to Antique END")); + break; + case 0x81: + myCAM.OV2640_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish END")); + break; + case 0x82: + myCAM.OV2640_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x83: + myCAM.OV2640_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x84: + myCAM.OV2640_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x85: + myCAM.OV2640_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0x86: + myCAM.OV2640_set_Special_effects(BWnegative); + temp = 0xff; + Serial.println(F("ACK CMD Set to BWnegative END")); + break; + case 0x87: + myCAM.OV2640_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); break; } - switch (temp) - { - case 0x40: - myCAM.OV2640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto END"));break; - case 0x41: - myCAM.OV2640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny END"));break; - case 0x42: - myCAM.OV2640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy END"));break; - case 0x43: - myCAM.OV2640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office END"));break; - case 0x44: - myCAM.OV2640_set_Light_Mode(Home); temp = 0xff; - Serial.println(F("ACK CMD Set to Home END"));break; - case 0x50: - myCAM.OV2640_set_Color_Saturation(Saturation2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x51: - myCAM.OV2640_set_Color_Saturation(Saturation1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x52: - myCAM.OV2640_set_Color_Saturation(Saturation0); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; - case 0x53: - myCAM. OV2640_set_Color_Saturation(Saturation_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; - case 0x54: - myCAM.OV2640_set_Color_Saturation(Saturation_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; - case 0x60: - myCAM.OV2640_set_Brightness(Brightness2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x61: - myCAM.OV2640_set_Brightness(Brightness1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x62: - myCAM.OV2640_set_Brightness(Brightness0); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; - case 0x63: - myCAM. OV2640_set_Brightness(Brightness_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; - case 0x64: - myCAM.OV2640_set_Brightness(Brightness_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; - case 0x70: - myCAM.OV2640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; - case 0x71: - myCAM.OV2640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x72: - myCAM.OV2640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; - case 0x73: - myCAM.OV2640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x74: - myCAM.OV2640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; - case 0x80: - myCAM.OV2640_set_Special_effects(Antique);temp = 0xff; - Serial.println(F("ACK CMD Set to Antique END"));break; - case 0x81: - myCAM.OV2640_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish END"));break; - case 0x82: - myCAM.OV2640_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break; - case 0x83: - myCAM.OV2640_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break; - case 0x84: - myCAM.OV2640_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break; - case 0x85: - myCAM.OV2640_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break; - case 0x86: - myCAM.OV2640_set_Special_effects(BWnegative);temp = 0xff; - Serial.println(F("ACK CMD Set to BWnegative END"));break; - case 0x87: - myCAM.OV2640_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break; } - if (start_capture == 2) + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + switch (temp) + { + case 0x40: + myCAM.OV2640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto END")); + break; + case 0x41: + myCAM.OV2640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny END")); + break; + case 0x42: + myCAM.OV2640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy END")); + break; + case 0x43: + myCAM.OV2640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office END")); + break; + case 0x44: + myCAM.OV2640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home END")); + break; + case 0x50: + myCAM.OV2640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x51: + myCAM.OV2640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x52: + myCAM.OV2640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; + case 0x53: + myCAM.OV2640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; + case 0x54: + myCAM.OV2640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; + case 0x60: + myCAM.OV2640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x61: + myCAM.OV2640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x62: + myCAM.OV2640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; + case 0x63: + myCAM.OV2640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; + case 0x64: + myCAM.OV2640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; + case 0x70: + myCAM.OV2640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; + case 0x71: + myCAM.OV2640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x72: + myCAM.OV2640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; + case 0x73: + myCAM.OV2640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x74: + myCAM.OV2640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; + case 0x80: + myCAM.OV2640_set_Special_effects(Antique); + temp = 0xff; + Serial.println(F("ACK CMD Set to Antique END")); + break; + case 0x81: + myCAM.OV2640_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish END")); + break; + case 0x82: + myCAM.OV2640_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x83: + myCAM.OV2640_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x84: + myCAM.OV2640_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x85: + myCAM.OV2640_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0x86: + myCAM.OV2640_set_Special_effects(BWnegative); + temp = 0xff; + Serial.println(F("ACK CMD Set to BWnegative END")); + break; + case 0x87: + myCAM.OV2640_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) - { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + else if (mode == 3) { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (start_capture == 3) { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0. END")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.println(F("ACK CMD Over size. END")); + myCAM.clear_fifo_flag(); + return; } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + { + Serial.write(pgm_read_byte(&bmp_header[temp])); + } + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size. END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0. END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -549,8 +691,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino index 0dced884..5b0389f7 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_2MP_Plus_short_movie_clip/ArduCAM_Mini_2MP_Plus_short_movie_clip.ino @@ -3,7 +3,7 @@ // This demo was made for ArduCAM_Mini_2MP_Plus. // It can continue shooting and store it into the SD card in AVI format // The demo sketch will do the following tasks -// 1.Shoot video button, began to shoot video +// 1.Shoot video button, began to shoot video // 2. Set the camera to JPEG output mode. // 3. Capture a JPEG photo and buffer the image to FIFO // 4.Write AVI Header @@ -17,7 +17,7 @@ // 0C-0F :The first list of identification number // 10-13 :The size of the first list // 14-17 :The hdr1 of identification -// 18-1B :Hdr1 contains avih piece of identification +// 18-1B :Hdr1 contains avih piece of identification // 1C-1F :The size of the avih // 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM_Mini_5MP_Plus @@ -27,13 +27,13 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV2640_MINI_2MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV2640_MINI_2MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0xFF -#define rate 0x0a +#define FRAMES_NUM 0xFF +#define rate 0x0a #define SD_CS 9 #define KEY 2 #define AVIOFFSET 240 @@ -44,275 +44,527 @@ uint32_t total_time = 0; unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const int avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const int avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x80, + 0x02, + 0x00, + 0x00, + 0xe0, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x80, + 0x02, + 0x00, + 0x00, + 0xe0, + 0x01, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -#if defined (OV2640_MINI_2MP_PLUS) - ArduCAM myCAM(OV2640, CS); +#if defined(OV2640_MINI_2MP_PLUS) +ArduCAM myCAM(OV2640, CS); #endif uint8_t read_fifo_burst(); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) -Wire1.begin(); + Wire1.begin(); #else -Wire.begin(); + Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ACK CMD ArduCAM Start!END")); + Serial.begin(115200); + Serial.println(F("ACK CMD ArduCAM Start!END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -pinMode(SD_CS, OUTPUT); -pinMode(KEY, INPUT); -// initialize SPI: -SPI.begin(); - //Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + pinMode(SD_CS, OUTPUT); + pinMode(KEY, INPUT); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) { - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK.END"));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK.END")); + break; + } } -} -#if defined (OV2640_MINI_2MP_PLUS) - while (1) { - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP_PLUS) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) { + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module!")); - delay(1000); continue; + delay(1000); + continue; } - else { - Serial.println(F("ACK CMD OV2640 detected.END")); break; + else + { + Serial.println(F("ACK CMD OV2640 detected.END")); + break; } } #endif -//Initialize SD Card -while(!SD.begin(SD_CS)) -{ - Serial.println(F("ACK CMD SD Card Error!END"));delay(1000); -} -Serial.println(F("ACK CMD SD Card detected.END")); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("ACK CMD SD Card Error!END")); + delay(1000); + } + Serial.println(F("ACK CMD SD Card detected.END")); -//Change to JPEG capture mode and initialize the OV5640 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP_PLUS) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); + // Change to JPEG capture mode and initialize the OV5640 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP_PLUS) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); #endif -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); } boolean isCaptureFlag = false; bool keyState; uint8_t temp, temp_last; uint32_t length = 0; uint32_t flash_time = 0; -void loop() { -// put your main code here, to run repeatedly: -keyState= digitalRead(KEY); -if(!keyState) { - isCaptureFlag = true; - while(!digitalRead(KEY)); -} -if(isCaptureFlag){ - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - Serial.println(F("ACK CMD start capture.END")); - total_time = millis(); - flash_time =millis(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); - length = myCAM.read_fifo_length(); - if( length < 0x3FFFFF){ +void loop() +{ + // put your main code here, to run repeatedly: + keyState = digitalRead(KEY); + if (!keyState) + { + isCaptureFlag = true; + while (!digitalRead(KEY)) + ; + } + if (isCaptureFlag) + { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); - Serial.println(F("ACK CMD CAM Capture Done.END")); - total_time = millis() - total_time; - }else{ - Serial.println(F("ACK CMD CAM Capture Done.END")); + Serial.println(F("ACK CMD start capture.END")); + total_time = millis(); + flash_time = millis(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + if (length < 0x3FFFFF) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("ACK CMD CAM Capture Done.END")); + total_time = millis() - total_time; + } + else + { + Serial.println(F("ACK CMD CAM Capture Done.END")); + total_time = millis() - total_time; + } + total_time = millis(); + read_fifo_burst(); total_time = millis() - total_time; + // Clear the capture done flag + myCAM.clear_fifo_flag(); + isCaptureFlag = false; } - total_time = millis(); - read_fifo_burst(); - total_time = millis() - total_time; - //Clear the capture done flag - myCAM.clear_fifo_flag(); - isCaptureFlag = false; -} } uint8_t read_fifo_burst() -{ -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -static int i = 0; -static int k = 0; -unsigned long position = 0; -uint16_t frame_cnt = 0; -uint8_t remnant = 0; -File outFile; -char str[8]; -byte buf[256]; -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -// Serial.println("writting the data to the SD !"); -if (length >= MAX_FIFO_SIZE) //8M -{ - Serial.println(F("ACK CMD Over size.END")); - return 0; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("ACK CMD Size is 0.END")); - return 0; -} -movi_size = 0; -//Create a avi file -k = k + 1; -itoa(k, str, 10); -strcat(str, ".avi"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("ACK CMD open file failed END")); - while (1); -} -//Write AVI Header -for ( i = 0; i < AVIOFFSET; i++) { - char ch = pgm_read_byte(&avi_header[i]); - buf[i] = ch; -} -outFile.write(buf, AVIOFFSET); -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -i = 0; -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + static int i = 0; + static int k = 0; + unsigned long position = 0; + uint16_t frame_cnt = 0; + uint8_t remnant = 0; + File outFile; + char str[8]; + byte buf[256]; + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + // Serial.println("writting the data to the SD !"); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - jpeg_size += i; - remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; - jpeg_size = jpeg_size + remnant; - movi_size = movi_size + jpeg_size; - if (remnant > 0) - outFile.write(zero_buf, remnant); - position = outFile.position(); - outFile.seek(position - 4 - jpeg_size); - print_quartet(jpeg_size, outFile); - position = outFile.position(); - outFile.seek(position + 6); - outFile.write("AVI1", 4); - position = outFile.position(); - outFile.seek(position + jpeg_size - 10); - is_header = false; - frame_cnt++; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("ACK CMD Over size.END")); + return 0; + } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0.END")); + return 0; + } + movi_size = 0; + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".avi"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("ACK CMD open file failed END")); + while (1) + ; + } + // Write AVI Header + for (i = 0; i < AVIOFFSET; i++) + { + char ch = pgm_read_byte(&avi_header[i]); + buf[i] = ch; + } + outFile.write(buf, AVIOFFSET); + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + i = 0; + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + jpeg_size += i; + remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; + jpeg_size = jpeg_size + remnant; + movi_size = movi_size + jpeg_size; + if (remnant > 0) + outFile.write(zero_buf, remnant); + position = outFile.position(); + outFile.seek(position - 4 - jpeg_size); + print_quartet(jpeg_size, outFile); + position = outFile.position(); + outFile.seek(position + 6); + outFile.write("AVI1", 4); + position = outFile.position(); + outFile.seek(position + jpeg_size - 10); + is_header = false; + frame_cnt++; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + jpeg_size += 256; + } + } + else if ((temp == 0xD8) && (temp_last == 0xFF)) + { + is_header = true; + myCAM.CS_HIGH(); + outFile.write("00dc"); + outFile.write(zero_buf, 4); i = 0; - buf[i++] = temp; + jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - jpeg_size += 256; - } - } - else if ((temp == 0xD8) && (temp_last == 0xFF)) - { - is_header = true; - myCAM.CS_HIGH(); - outFile.write("00dc"); - outFile.write(zero_buf, 4); - i = 0; - jpeg_size = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - buf[i++] = temp_last; - buf[i++] = temp; + buf[i++] = temp_last; + buf[i++] = temp; + } } -} -myCAM.CS_HIGH(); -//Modify the MJPEG header from the beginning of the file -outFile.seek(4); -print_quartet(movi_size +12*frame_cnt+4, outFile);//riff file size -//overwrite hdrl -unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame -outFile.seek(0x20); -print_quartet(us_per_frame, outFile); -unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec -outFile.seek(0x24); -print_quartet(max_bytes_per_sec, outFile); -unsigned long tot_frames = frame_cnt; //hdrl.avih.tot_frames -outFile.seek(0x30); -print_quartet(tot_frames, outFile); -unsigned long frames =frame_cnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames -outFile.seek(0xe0); -print_quartet(frames, outFile); -outFile.seek(0xe8); -print_quartet(movi_size, outFile);// size again -//Close the file -outFile.close(); -is_header = false; -Serial.println(F("ACK CMD Movie save OK END")); -return 1; + myCAM.CS_HIGH(); + // Modify the MJPEG header from the beginning of the file + outFile.seek(4); + print_quartet(movi_size + 12 * frame_cnt + 4, outFile); // riff file size + // overwrite hdrl + unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame + outFile.seek(0x20); + print_quartet(us_per_frame, outFile); + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec + outFile.seek(0x24); + print_quartet(max_bytes_per_sec, outFile); + unsigned long tot_frames = frame_cnt; // hdrl.avih.tot_frames + outFile.seek(0x30); + print_quartet(tot_frames, outFile); + unsigned long frames = frame_cnt; // (TOTALFRAMES); //hdrl.strl.list_odml.frames + outFile.seek(0xe0); + print_quartet(frames, outFile); + outFile.seek(0xe8); + print_quartet(movi_size, outFile); // size again + // Close the file + outFile.close(); + is_header = false; + Serial.println(F("ACK CMD Movie save OK END")); + return 1; } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_3MP_OV3640_functions/ArduCAM_Mini_3MP_OV3640_functions.ino b/ArduCAM/examples/mini/ArduCAM_Mini_3MP_OV3640_functions/ArduCAM_Mini_3MP_OV3640_functions.ino index 907aed46..45b0b212 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_3MP_OV3640_functions/ArduCAM_Mini_3MP_OV3640_functions.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_3MP_OV3640_functions/ArduCAM_Mini_3MP_OV3640_functions.ino @@ -4,37 +4,37 @@ // of the library with ArduCAM Mini camera, and can run on any Arduino platform. // This demo was made for ArduCAM_Mini_5MP_Plus. // It needs to be used in combination with PC software. -// It can test OV3640 functions +// It can test OV3640 functions // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM_Mini_5MP_Plus // and use Arduino IDE 1.6.8 compiler or above #include #include #include #include "memorysaver.h" -//This demo can only work on OV3640_MINI_3MP platform. +// This demo can only work on OV3640_MINI_3MP platform. #if !(defined OV3640_MINI_3MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -ArduCAM myCAM( OV3640, CS ); +ArduCAM myCAM(OV3640, CS); uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -42,472 +42,609 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start!")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK."));break; + Serial.println(F("ACK CMD ArduCAM Start!")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK.")); + break; + } } -} - while(1){ - //Check if the camera module type is OV3640 + while (1) + { + // Check if the camera module type is OV3640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36 ) && ( pid != 0x4C )){ + if ((vid != 0x36) && (pid != 0x4C)) + { Serial.println(F("ACK CMD Can't find OV3640 module!")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV3640 detected.")); + break; } - else{ - Serial.println(F("ACK CMD OV3640 detected."));break; - } } -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -myCAM.OV3640_set_JPEG_size(OV3640_320x240); -delay(1000); -myCAM.clear_fifo_flag(); + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); + myCAM.clear_fifo_flag(); } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { - case 0: - myCAM.OV3640_set_JPEG_size(OV3640_176x144);delay(1000); + temp = Serial.read(); + switch (temp) + { + case 0: + myCAM.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120")); temp = 0xff; - break; + break; case 1: - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_320x240")); - temp = 0xff; - break; - case 2: - myCAM.OV3640_set_JPEG_size(OV3640_352x288);delay(1000); + temp = 0xff; + break; + case 2: + myCAM.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_352x288")); - temp = 0xff; - break; + temp = 0xff; + break; case 3: - temp = 0xff; - myCAM.OV3640_set_JPEG_size(OV3640_640x480);delay(1000); + temp = 0xff; + myCAM.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_640x480")); - break; + break; case 4: - temp = 0xff; - myCAM.OV3640_set_JPEG_size(OV3640_800x600);delay(1000); + temp = 0xff; + myCAM.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_800x600")); - break; + break; case 5: - temp = 0xff; - - myCAM.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000); + temp = 0xff; + + myCAM.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1024x768")); - break; + break; case 6: - temp = 0xff; - myCAM.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000); + temp = 0xff; + myCAM.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1280x960")); - break; + break; case 7: - temp = 0xff; - myCAM.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000); + temp = 0xff; + myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1600x1200")); - break; + break; case 8: - temp = 0xff; - myCAM.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536")); - break; + temp = 0xff; + myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536")); + break; case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot.")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - break; + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot.")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming.")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming.")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("CAM start single shoot.")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("CAM start single shoot.")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; case 0x40: - myCAM.OV3640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto"));break; - case 0x41: - myCAM.OV3640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny"));break; - case 0x42: - myCAM.OV3640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy"));break; - case 0x43: - myCAM.OV3640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office"));break; - case 0x44: - myCAM.OV3640_set_Light_Mode(Home); temp = 0xff; - Serial.println(F("ACK CMD Set to Home"));break; - case 0x50: - myCAM.OV3640_set_Color_Saturation(Saturation2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2"));break; - case 0x51: - myCAM.OV3640_set_Color_Saturation(Saturation1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1"));break; - case 0x52: - myCAM.OV3640_set_Color_Saturation(Saturation0); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0"));break; + myCAM.OV3640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto")); + break; + case 0x41: + myCAM.OV3640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny")); + break; + case 0x42: + myCAM.OV3640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy")); + break; + case 0x43: + myCAM.OV3640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office")); + break; + case 0x44: + myCAM.OV3640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home")); + break; + case 0x50: + myCAM.OV3640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2")); + break; + case 0x51: + myCAM.OV3640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1")); + break; + case 0x52: + myCAM.OV3640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0")); + break; case 0x53: - myCAM. OV3640_set_Color_Saturation(Saturation_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1"));break; + myCAM.OV3640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1")); + break; case 0x54: - myCAM.OV3640_set_Color_Saturation(Saturation_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2"));break; - case 0x60: - myCAM.OV3640_set_Brightness(Brightness2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2"));break; - case 0x61: - myCAM.OV3640_set_Brightness(Brightness1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1"));break; - case 0x62: - myCAM.OV3640_set_Brightness(Brightness0); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0"));break; + myCAM.OV3640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2")); + break; + case 0x60: + myCAM.OV3640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2")); + break; + case 0x61: + myCAM.OV3640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1")); + break; + case 0x62: + myCAM.OV3640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0")); + break; case 0x63: - myCAM. OV3640_set_Brightness(Brightness_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1"));break; + myCAM.OV3640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1")); + break; case 0x64: - myCAM.OV3640_set_Brightness(Brightness_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2"));break; + myCAM.OV3640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2")); + break; case 0x70: - myCAM.OV3640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2"));break; + myCAM.OV3640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2")); + break; case 0x71: - myCAM.OV3640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1"));break; - case 0x72: - myCAM.OV3640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0"));break; + myCAM.OV3640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1")); + break; + case 0x72: + myCAM.OV3640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0")); + break; case 0x73: - myCAM.OV3640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1"));break; - case 0x74: - myCAM.OV3640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2"));break; - case 0x80: - myCAM.OV3640_set_Special_effects(Antique);temp = 0xff; - Serial.println(F("ACK CMD Set to Antique"));break; - case 0x81: - myCAM.OV3640_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish"));break; - case 0x82: - myCAM.OV3640_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish"));break; - case 0x83: - myCAM.OV3640_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish"));break; - case 0x84: - myCAM.OV3640_set_Special_effects(Yellowish);temp = 0xff; - Serial.println(F("ACK CMD Set to Yellowish"));break; + myCAM.OV3640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1")); + break; + case 0x74: + myCAM.OV3640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2")); + break; + case 0x80: + myCAM.OV3640_set_Special_effects(Antique); + temp = 0xff; + Serial.println(F("ACK CMD Set to Antique")); + break; + case 0x81: + myCAM.OV3640_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish")); + break; + case 0x82: + myCAM.OV3640_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish")); + break; + case 0x83: + myCAM.OV3640_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish")); + break; + case 0x84: + myCAM.OV3640_set_Special_effects(Yellowish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Yellowish")); + break; case 0x85: - myCAM.OV3640_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW"));break; - case 0x86: - myCAM.OV3640_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative"));break; - case 0x87: - myCAM.OV3640_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal"));break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done.")); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming.")); + myCAM.OV3640_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW")); + break; + case 0x86: + myCAM.OV3640_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative")); + break; + case 0x87: + myCAM.OV3640_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal")); break; } - switch (temp) - { - case 0x40: - myCAM.OV3640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto"));break; - case 0x41: - myCAM.OV3640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny"));break; - case 0x42: - myCAM.OV3640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy"));break; - case 0x43: - myCAM.OV3640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office"));break; - case 0x44: - myCAM.OV3640_set_Light_Mode(Home); temp = 0xff; - Serial.println(F("ACK CMD Set to Home"));break; - case 0x50: - myCAM.OV3640_set_Color_Saturation(Saturation2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2"));break; - case 0x51: - myCAM.OV3640_set_Color_Saturation(Saturation1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1"));break; - case 0x52: - myCAM.OV3640_set_Color_Saturation(Saturation0); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0"));break; - case 0x53: - myCAM. OV3640_set_Color_Saturation(Saturation_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1"));break; - case 0x54: - myCAM.OV3640_set_Color_Saturation(Saturation_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2"));break; - case 0x60: - myCAM.OV3640_set_Brightness(Brightness2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2"));break; - case 0x61: - myCAM.OV3640_set_Brightness(Brightness1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1"));break; - case 0x62: - myCAM.OV3640_set_Brightness(Brightness0); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0"));break; - case 0x63: - myCAM. OV3640_set_Brightness(Brightness_1); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1"));break; - case 0x64: - myCAM.OV3640_set_Brightness(Brightness_2); temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2"));break; - case 0x70: - myCAM.OV3640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2"));break; - case 0x71: - myCAM.OV3640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1"));break; - case 0x72: - myCAM.OV3640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0"));break; - case 0x73: - myCAM.OV3640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1"));break; - case 0x74: - myCAM.OV3640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2"));break; - case 0x80: - myCAM.OV3640_set_Special_effects(Antique);temp = 0xff; - Serial.println(F("ACK CMD Set to Antique"));break; - case 0x81: - myCAM.OV3640_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish"));break; - case 0x82: - myCAM.OV3640_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish"));break; - case 0x83: - myCAM.OV3640_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish"));break; - case 0x84: - myCAM.OV3640_set_Special_effects(Yellowish);temp = 0xff; - Serial.println(F("ACK CMD Set to Yellowish"));break; - case 0x85: - myCAM.OV3640_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW"));break; - case 0x86: - myCAM.OV3640_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative"));break; - case 0x87: - myCAM.OV3640_set_Special_effects(BWnegative);temp = 0xff; - Serial.println(F("ACK CMD Set to BWnegative"));break; - case 0x88: - myCAM.OV3640_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal"));break; } - if (start_capture == 2) + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done.")); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) + { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming.")); + break; + } + switch (temp) + { + case 0x40: + myCAM.OV3640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto")); + break; + case 0x41: + myCAM.OV3640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny")); + break; + case 0x42: + myCAM.OV3640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy")); + break; + case 0x43: + myCAM.OV3640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office")); + break; + case 0x44: + myCAM.OV3640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home")); + break; + case 0x50: + myCAM.OV3640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2")); + break; + case 0x51: + myCAM.OV3640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1")); + break; + case 0x52: + myCAM.OV3640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0")); + break; + case 0x53: + myCAM.OV3640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1")); + break; + case 0x54: + myCAM.OV3640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2")); + break; + case 0x60: + myCAM.OV3640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2")); + break; + case 0x61: + myCAM.OV3640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1")); + break; + case 0x62: + myCAM.OV3640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0")); + break; + case 0x63: + myCAM.OV3640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1")); + break; + case 0x64: + myCAM.OV3640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2")); + break; + case 0x70: + myCAM.OV3640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2")); + break; + case 0x71: + myCAM.OV3640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1")); + break; + case 0x72: + myCAM.OV3640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0")); + break; + case 0x73: + myCAM.OV3640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1")); + break; + case 0x74: + myCAM.OV3640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2")); + break; + case 0x80: + myCAM.OV3640_set_Special_effects(Antique); + temp = 0xff; + Serial.println(F("ACK CMD Set to Antique")); + break; + case 0x81: + myCAM.OV3640_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish")); + break; + case 0x82: + myCAM.OV3640_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish")); + break; + case 0x83: + myCAM.OV3640_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish")); + break; + case 0x84: + myCAM.OV3640_set_Special_effects(Yellowish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Yellowish")); + break; + case 0x85: + myCAM.OV3640_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW")); + break; + case 0x86: + myCAM.OV3640_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative")); + break; + case 0x87: + myCAM.OV3640_set_Special_effects(BWnegative); + temp = 0xff; + Serial.println(F("ACK CMD Set to BWnegative")); + break; + case 0x88: + myCAM.OV3640_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal")); + break; + } + if (start_capture == 2) { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) - { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + else if (mode == 3) { - Serial.println(F("ACK CMD CAM Capture Done.")); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (start_capture == 3) { - Serial.println(F("ACK CMD Over size.")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0.")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done.")); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) + { + Serial.println(F("ACK CMD Over size.")); + myCAM.clear_fifo_flag(); + return; + } + if (length == 0) // 0 kb { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.println(F("ACK CMD Size is 0.")); + myCAM.clear_fifo_flag(); + return; } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + { + Serial.write(pgm_read_byte(&bmp_header[temp])); + } + SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("Over size.")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("Size is 0.")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -519,8 +656,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_Capture2SD/ArduCAM_Mini_4CAM_Capture2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_Capture2SD/ArduCAM_Mini_4CAM_Capture2SD.ino index f90647e0..91ae59c4 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_Capture2SD/ArduCAM_Mini_4CAM_Capture2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_Capture2SD/ArduCAM_Mini_4CAM_Capture2SD.ino @@ -17,7 +17,7 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP and OV5642_MINI_5MP and OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +// This demo can only work on OV2640_MINI_2MP and OV5642_MINI_5MP and OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. #if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif @@ -30,18 +30,17 @@ const int CS2 = 5; const int CS3 = 6; const int CS4 = 7; -bool CAM1_EXIST = false; +bool CAM1_EXIST = false; bool CAM2_EXIST = false; bool CAM3_EXIST = false; bool CAM4_EXIST = false; - -#if defined (OV2640_MINI_2MP) +#if defined(OV2640_MINI_2MP) ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2); ArduCAM myCAM3(OV2640, CS3); ArduCAM myCAM4(OV2640, CS4); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) ArduCAM myCAM1(OV3640, CS1); ArduCAM myCAM2(OV3640, CS2); ArduCAM myCAM3(OV3640, CS3); @@ -53,241 +52,278 @@ ArduCAM myCAM3(OV5642, CS3); ArduCAM myCAM4(OV5642, CS4); #endif -void setup() { +void setup() +{ // put your setup code here, to run once: uint8_t vid, pid; uint8_t temp; - Wire.begin(); - Serial.begin(115200); - Serial.println(F("ArduCAM Start!")); -// set the CS output: -pinMode(CS1, OUTPUT); -digitalWrite(CS1, HIGH); -pinMode(CS2, OUTPUT); -digitalWrite(CS2, HIGH); -pinMode(CS3, OUTPUT); -digitalWrite(CS3, HIGH); -pinMode(CS4, OUTPUT); -digitalWrite(CS4, HIGH); -pinMode(SD_CS, OUTPUT); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM1.write_reg(0x07, 0x80); -delay(100); -myCAM1.write_reg(0x07, 0x00); -delay(100); -myCAM2.write_reg(0x07, 0x80); -delay(100); -myCAM2.write_reg(0x07, 0x00); -delay(100); -myCAM3.write_reg(0x07, 0x80); -delay(100); -myCAM3.write_reg(0x07, 0x00); -delay(100); -myCAM4.write_reg(0x07, 0x80); -delay(100); -myCAM4.write_reg(0x07, 0x00); -delay(100); - //Check if the 4 ArduCAM Mini 2MP Cameras' SPI bus is OK - while(1){ - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS output: + pinMode(CS1, OUTPUT); + digitalWrite(CS1, HIGH); + pinMode(CS2, OUTPUT); + digitalWrite(CS2, HIGH); + pinMode(CS3, OUTPUT); + digitalWrite(CS3, HIGH); + pinMode(CS4, OUTPUT); + digitalWrite(CS4, HIGH); + pinMode(SD_CS, OUTPUT); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM1.write_reg(0x07, 0x80); + delay(100); + myCAM1.write_reg(0x07, 0x00); + delay(100); + myCAM2.write_reg(0x07, 0x80); + delay(100); + myCAM2.write_reg(0x07, 0x00); + delay(100); + myCAM3.write_reg(0x07, 0x80); + delay(100); + myCAM3.write_reg(0x07, 0x00); + delay(100); + myCAM4.write_reg(0x07, 0x80); + delay(100); + myCAM4.write_reg(0x07, 0x00); + delay(100); + // Check if the 4 ArduCAM Mini 2MP Cameras' SPI bus is OK + while (1) { - Serial.println(F("SPI1 interface Error!")); - }else{ + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI1 interface Error!")); + } + else + { CAM1_EXIST = true; Serial.println(F("SPI1 interface OK.")); } - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println("SPI2 interface Error!"); - }else{ + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println("SPI2 interface Error!"); + } + else + { CAM2_EXIST = true; Serial.println(F("SPI2 interface OK.")); } - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println(F("SPI3 interface Error!")); - }else{ + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI3 interface Error!")); + } + else + { CAM3_EXIST = true; Serial.println(F("SPI3 interface OK.")); } - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println(F("SPI4 interface Error!")); - }else{ + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI4 interface Error!")); + } + else + { CAM4_EXIST = true; Serial.println(F("SPI4 interface OK.")); } - if(!(CAM1_EXIST||CAM2_EXIST||CAM3_EXIST||CAM4_EXIST)){ - delay(1000);continue; - }else - break; + if (!(CAM1_EXIST || CAM2_EXIST || CAM3_EXIST || CAM4_EXIST)) + { + delay(1000); + continue; + } + else + break; } - //Initialize SD Card - while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error")); + delay(1000); } Serial.println(F("SD Card detected.")); - - #if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 - myCAM1.wrSensorReg8_8(0xff, 0x01); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 + myCAM1.wrSensorReg8_8(0xff, 0x01); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV2640 detected."));break; - } - } -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV2640 - myCAM1.rdSensorReg8_8(OV3640_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg8_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36 ) && ( pid != 0x4C)){ + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; + } + } +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV2640 + myCAM1.rdSensorReg8_8(OV3640_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg8_8(OV3640_CHIPID_LOW, &pid); + if ((vid != 0x36) && (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; - } - } - #else - while(1){ - //Check if the camera module type is OV5642 + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } +#else + while (1) + { + // Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5642 detected."));break; - } + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; + } } - #endif - myCAM1.set_format(JPEG); - myCAM1.InitCAM(); - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_640x480); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_640x480); - #else - myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH - myCAM1.OV5642_set_JPEG_size(OV5642_320x240); - #endif +#endif + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_640x480); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_640x480); +#else + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); +#endif delay(1000); myCAM1.clear_fifo_flag(); myCAM2.clear_fifo_flag(); myCAM3.clear_fifo_flag(); myCAM4.clear_fifo_flag(); } -void loop() { - if(CAM1_EXIST) +void loop() +{ + if (CAM1_EXIST) myCAMSaveToSDFile(myCAM1); - if(CAM2_EXIST) + if (CAM2_EXIST) myCAMSaveToSDFile(myCAM2); - if(CAM3_EXIST) + if (CAM3_EXIST) myCAMSaveToSDFile(myCAM3); - if(CAM4_EXIST) + if (CAM4_EXIST) myCAMSaveToSDFile(myCAM4); - delay(5000); - } -void myCAMSaveToSDFile(ArduCAM myCAM){ + delay(5000); +} +void myCAMSaveToSDFile(ArduCAM myCAM) +{ char str[8]; byte buf[256]; static int i = 0; static int k = 0; - uint8_t temp = 0,temp_last=0; + uint8_t temp = 0, temp_last = 0; uint32_t length = 0; bool is_header = false; File outFile; - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); Serial.println("start Capture"); - while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - Serial.println(F("Capture Done.")); - length = myCAM.read_fifo_length(); - Serial.print(F("The fifo length is :")); - Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //384K + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 384K { Serial.println(F("Over size.")); - return ; + return; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("Size is 0.")); - return ; + return; } - //Construct a file name - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if(!outFile){ - Serial.println(F("File open faild")); - return; - } -myCAM.CS_LOW(); - myCAM.set_fifo_burst(); -while ( length-- ) + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open faild")); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer + myCAM.CS_HIGH(); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image save OK.")); + is_header = false; + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image save OK.")); - is_header = false; + outFile.write(buf, 256); i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) buf[i++] = temp; - else - { - //Write 256 bytes image data to file - myCAM.CS_HIGH(); - outFile.write(buf, 256); - i = 0; - buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } } else if ((temp == 0xD8) & (temp_last == 0xFF)) { is_header = true; buf[i++] = temp_last; - buf[i++] = temp; - } - } + buf[i++] = temp; + } + } } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino b/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino index f5251cc1..91cfe18c 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_4CAM_VideoStreaming/ArduCAM_Mini_4CAM_VideoStreaming.ino @@ -9,7 +9,7 @@ // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. -// 4. If receive 0x15,cameras will capture and buffer the image to FIFO. +// 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Minicamera // and use Arduino IDE 1.6.8 compiler or above @@ -18,8 +18,8 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. -#if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP|| defined OV3640_MINI_3MP) +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +#if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif @@ -29,19 +29,19 @@ const int CS2 = 5; const int CS3 = 6; const int CS4 = 7; -//the falgs of camera modules -bool cam1=true,cam2=true,cam3=true,cam4=true; -//the flag of JEPG data header +// the falgs of camera modules +bool cam1 = true, cam2 = true, cam3 = true, cam4 = true; +// the flag of JEPG data header bool is_header; -//the falg data of 4 cameras' data -byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; +// the falg data of 4 cameras' data +byte flag[5] = {0xFF, 0xAA, 0x01, 0xFF, 0x55}; int count = 0; -#if defined (OV2640_MINI_2MP) +#if defined(OV2640_MINI_2MP) ArduCAM myCAM1(OV2640, CS1); ArduCAM myCAM2(OV2640, CS2); ArduCAM myCAM3(OV2640, CS3); ArduCAM myCAM4(OV2640, CS4); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) ArduCAM myCAM1(OV3640, CS1); ArduCAM myCAM2(OV3640, CS2); ArduCAM myCAM3(OV3640, CS3); @@ -53,372 +53,433 @@ ArduCAM myCAM3(OV5642, CS3); ArduCAM myCAM4(OV5642, CS4); #endif -void setup() { -// put your setup code here, to run once: -uint8_t vid,pid; -uint8_t temp; -Wire.begin(); -Serial.begin(921600); -Serial.println("ACK CMD ArduCAM Start! END"); -// set the CS output: -pinMode(CS1, OUTPUT); -digitalWrite(CS1, HIGH); -pinMode(CS2, OUTPUT); -digitalWrite(CS2, HIGH); -pinMode(CS3, OUTPUT); -digitalWrite(CS3, HIGH); -pinMode(CS4, OUTPUT); -digitalWrite(CS4, HIGH); +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(921600); + Serial.println("ACK CMD ArduCAM Start! END"); + // set the CS output: + pinMode(CS1, OUTPUT); + digitalWrite(CS1, HIGH); + pinMode(CS2, OUTPUT); + digitalWrite(CS2, HIGH); + pinMode(CS3, OUTPUT); + digitalWrite(CS3, HIGH); + pinMode(CS4, OUTPUT); + digitalWrite(CS4, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM1.write_reg(0x07, 0x80); -delay(100); -myCAM1.write_reg(0x07, 0x00); -delay(100); -myCAM2.write_reg(0x07, 0x80); -delay(100); -myCAM2.write_reg(0x07, 0x00); -delay(100); -myCAM3.write_reg(0x07, 0x80); -delay(100); -myCAM3.write_reg(0x07, 0x00); -delay(100); -myCAM4.write_reg(0x07, 0x80); -delay(100); -myCAM4.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the 4 ArduCAM Mini 2MP Cameras' SPI bus is OK - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println(F("ACK CMD SPI1 interface Error! END")); - cam1 = false; - } - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM1.write_reg(0x07, 0x80); + delay(100); + myCAM1.write_reg(0x07, 0x00); + delay(100); + myCAM2.write_reg(0x07, 0x80); + delay(100); + myCAM2.write_reg(0x07, 0x00); + delay(100); + myCAM3.write_reg(0x07, 0x80); + delay(100); + myCAM3.write_reg(0x07, 0x00); + delay(100); + myCAM4.write_reg(0x07, 0x80); + delay(100); + myCAM4.write_reg(0x07, 0x00); + delay(100); + + while (1) { - Serial.println(F("ACK CMD SPI2 interface Error! END")); - cam2 = false; + // Check if the 4 ArduCAM Mini 2MP Cameras' SPI bus is OK + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI1 interface Error! END")); + cam1 = false; + } + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI2 interface Error! END")); + cam2 = false; + } + + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI3 interface Error! END")); + cam3 = false; + } + + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI4 interface Error! END")); + cam4 = false; + } + if (!(cam1 || cam2 || cam3 || cam4)) + { + delay(1000); + continue; + } + else + break; } - - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) +#if defined(OV2640_MINI_2MP) + while (1) { - Serial.println(F("ACK CMD SPI3 interface Error! END")); - cam3 = false; + // Check if the camera module type is OV2640 + myCAM1.wrSensorReg8_8(0xff, 0x01); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); + myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { + Serial.println(F("ACK CMD Can't find OV2640 module! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; + } } - - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) +#elif defined(OV3640_MINI_3MP) + while (1) { - Serial.println(F("ACK CMD SPI4 interface Error! END")); - cam4 = false; - } - if(!(cam1||cam2||cam3||cam4)){ - delay(1000);continue; - }else - break; -} -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 - myCAM1.wrSensorReg8_8(0xff, 0x01); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); - myCAM1.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ - Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; - } -} -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV3640 + // Check if the camera module type is OV3640 myCAM1.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV3640 detected. END"));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV3640 detected. END")); + break; } - } + } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM1.wrSensorReg16_8(0xff, 0x01); myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } - } + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("ACK CMD Can't find OV5642 module! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; + } + } #endif -myCAM1.set_format(JPEG); -myCAM1.InitCAM(); -#if defined (OV2640_MINI_2MP) -myCAM1.OV2640_set_JPEG_size(OV2640_320x240); -#elif defined (OV3640_MINI_3MP) + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_320x240); +#elif defined(OV3640_MINI_3MP) myCAM1.OV3640_set_JPEG_size(OV3640_320x240); #else -myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM1.OV5642_set_JPEG_size(OV5642_320x240); + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); -myCAM1.clear_fifo_flag(); -myCAM2.clear_fifo_flag(); -myCAM3.clear_fifo_flag(); -myCAM4.clear_fifo_flag(); + delay(1000); + myCAM1.clear_fifo_flag(); + myCAM2.clear_fifo_flag(); + myCAM3.clear_fifo_flag(); + myCAM4.clear_fifo_flag(); } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -uint8_t start_capture = 0; -uint8_t finish_count; -if (Serial.available()){ -temp = Serial.read(); -switch(temp) +void loop() { - case 0: - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + uint8_t start_capture = 0; + uint8_t finish_count; + if (Serial.available()) + { + temp = Serial.read(); + switch (temp) + { + case 0: +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_176x144);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - temp = 0xff; - break; +#endif + temp = 0xff; + break; case 1: - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_320x240 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - temp = 0xff; - break; - case 2: - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); +#endif + temp = 0xff; + break; + case 2: +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_352x288);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_352x288 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - #endif - temp = 0xff; - break; +#endif + temp = 0xff; + break; case 3: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_640x480);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_640x480 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - break; +#endif + break; case 4: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_800x600);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_800x600 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - break; +#endif + break; case 5: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1024x768 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - break; +#endif + break; case 6: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - #elif defined (OV3640_MINI_3MP) - myCAM1.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM1.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1280x960 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - break; +#endif + break; case 7: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - #else - myCAM1.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); +#else + myCAM1.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1600x1200 END")); - #endif - break; +#endif + break; case 8: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); - #else - myCAM1.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); - #endif - break; - case 0x10: - if(cam1){ - flag[2]=0x01;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM1); - } - if(cam2){ - flag[2]=0x02;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM2); - } - if(cam3){ - flag[2]=0x03;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM3); - } - if(cam4){ - flag[2]=0x04;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM4); - } - break; - case 0x20: - while(1){ - if (Serial.available()){ - temp = Serial.read(); - if (temp == 0x21)break; -} - if(cam1){ - flag[2]=0x01;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM1); - } - if(cam2){ - flag[2]=0x02;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM2); - } - if(cam3){ - flag[2]=0x03;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM3); - } - if(cam4){ - - flag[2]=0x04;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM4); - } + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM1.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); +#else + myCAM1.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); +#endif + break; + case 0x10: + if (cam1) + { + flag[2] = 0x01; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM1); + } + if (cam2) + { + flag[2] = 0x02; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM2); + } + if (cam3) + { + flag[2] = 0x03; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM3); + } + if (cam4) + { + flag[2] = 0x04; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM4); + } + break; + case 0x20: + while (1) + { + if (Serial.available()) + { + temp = Serial.read(); + if (temp == 0x21) + break; + } + if (cam1) + { + flag[2] = 0x01; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM1); + } + if (cam2) + { + flag[2] = 0x02; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM2); + } + if (cam3) + { + flag[2] = 0x03; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM3); + } + if (cam4) + { + + flag[2] = 0x04; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM4); + } + } + break; } - break; - } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { -uint8_t temp,temp_last; -uint32_t length; + uint8_t temp, temp_last; + uint32_t length; -myCAM.flush_fifo(); -myCAM.clear_fifo_flag(); -myCAM.start_capture(); -while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -length = myCAM.read_fifo_length(); -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -length--; -while( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00);//read a byte from spi - if(is_header == true) - { - Serial.write(temp); - } - else if((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + length--; + while (length--) { - Serial.println(F("ACK IMG END")); - is_header = true; - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); // read a byte from spi + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + Serial.println(F("ACK IMG END")); + is_header = true; + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) + break; + delayMicroseconds(15); } - if( (temp == 0xD9) && (temp_last == 0xFF) ) - break; - delayMicroseconds(15); -} -myCAM.CS_HIGH(); -is_header = false; -//Clear the capture done flag -myCAM.clear_fifo_flag(); + myCAM.CS_HIGH(); + is_header = false; + // Clear the capture done flag + myCAM.clear_fifo_flag(); } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_AutoFocus/ArduCAM_Mini_5MP_OV5640_AutoFocus.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_AutoFocus/ArduCAM_Mini_5MP_OV5640_AutoFocus.ino index bd971e15..8aaeee94 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_AutoFocus/ArduCAM_Mini_5MP_OV5640_AutoFocus.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_AutoFocus/ArduCAM_Mini_5MP_OV5640_AutoFocus.ino @@ -22,19 +22,18 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 10; bool is_header = false; @@ -45,8 +44,8 @@ uint8_t regX; ArduCAM myCAM(OV5640, CS); uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { - +void setup() +{ // put your setup code here, to run once: uint8_t vid, pid; @@ -64,37 +63,48 @@ void setup() { digitalWrite(CS, HIGH); // initialize SPI: SPI.begin(); - //Reset the CPLD + // Reset the CPLD myCAM.write_reg(0x07, 0x80); delay(100); myCAM.write_reg(0x07, 0x00); - delay(100); + delay(100); - while (1) { - //Check if the ArduCAM SPI bus is OK + while (1) + { + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000); continue; - } else { - Serial.println(F("ACK CMD SPI interface OK. END")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; } } - while (1) { - //Check if the camera module type is OV5640 + while (1) + { + // Check if the camera module type is OV5640 myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)) { + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module! END")); - delay(1000); continue; - } else { - Serial.println(F("ACK CMD OV5640 detected. END")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected. END")); + break; } } - //Change to JPEG capture mode and initialize the OV5642 module + // Change to JPEG capture mode and initialize the OV5642 module myCAM.set_format(JPEG); myCAM.InitCAM(); Serial.println("ACK CMD Downloading firmware... END"); @@ -104,20 +114,24 @@ void setup() { { // check status myCAM.rdSensorReg16_8(0x3029, ®X); - if (regX == 0x10) { - Serial.println("ACK CMD Auto focus completed END"); break; + if (regX == 0x10) + { + Serial.println("ACK CMD Auto focus completed END"); + break; } // focus completed - else { - Serial.println("ACK CMD Auto focusing ... END"); delay(1000); + else + { + Serial.println("ACK CMD Auto focusing ... END"); + delay(1000); } } myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); myCAM.clear_fifo_flag(); myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); - } -void loop() { +void loop() +{ uint8_t temp = 0xff, temp_last = 0; bool is_header = false; @@ -126,101 +140,114 @@ void loop() { temp = Serial.read(); switch (temp) { - case 0: - myCAM.OV5640_set_JPEG_size(OV5640_320x240); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_320x240 END")); - temp = 0xff; - break; - case 1: - myCAM.OV5640_set_JPEG_size(OV5640_352x288); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_352x288 END")); - temp = 0xff; - break; - case 2: - myCAM.OV5640_set_JPEG_size(OV5640_640x480); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_640x480 END")); + case 0: + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_320x240 END")); + temp = 0xff; + break; + case 1: + myCAM.OV5640_set_JPEG_size(OV5640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_352x288 END")); + temp = 0xff; + break; + case 2: + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_640x480 END")); - temp = 0xff; - break; - case 3: - myCAM.OV5640_set_JPEG_size(OV5640_800x480); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_800x480 END")); + temp = 0xff; + break; + case 3: + myCAM.OV5640_set_JPEG_size(OV5640_800x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_800x480 END")); - temp = 0xff; - break; - case 4: - myCAM.OV5640_set_JPEG_size(OV5640_1024x768); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_1024x768 END")); - temp = 0xff; - break; - case 5: - myCAM.OV5640_set_JPEG_size(OV5640_1280x960); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_1280x960 END")); - temp = 0xff; - break; - case 6: - myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_1600x1200 END")); - temp = 0xff; - break; - case 7: - myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); - temp = 0xff; - break; - case 8: - myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); delay(1000); - Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); - temp = 0xff; - break; - case 0x10: - mode = 1; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot.END")); - break; - case 0x11: - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - break; - case 0x20: - mode = 2; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming.END")); - break; - case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot.END")); - break; - case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - //Add support for automatic focus - myCAM.wrSensorRegs16_8(OV5640_Auto_Focus); - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; - case 0x40: - myCAM.wrSensorReg16_8(0x3022, 0x03); - while (1) + temp = 0xff; + break; + case 4: + myCAM.OV5640_set_JPEG_size(OV5640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_1024x768 END")); + temp = 0xff; + break; + case 5: + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_1280x960 END")); + temp = 0xff; + break; + case 6: + myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_1600x1200 END")); + temp = 0xff; + break; + case 7: + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); + temp = 0xff; + break; + case 8: + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); + temp = 0xff; + break; + case 0x10: + mode = 1; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot.END")); + break; + case 0x11: + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + break; + case 0x20: + mode = 2; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming.END")); + break; + case 0x30: + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot.END")); + break; + case 0x31: + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); + // Add support for automatic focus + myCAM.wrSensorRegs16_8(OV5640_Auto_Focus); + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; + case 0x40: + myCAM.wrSensorReg16_8(0x3022, 0x03); + while (1) + { + // check status + myCAM.rdSensorReg16_8(0x3029, ®X); + if (regX == 0x10) { - // check status - myCAM.rdSensorReg16_8(0x3029, ®X); - if (regX == 0x10) { - Serial.println("ACK CMD Auto focus completed END"); break; - } // focus completed - else { - Serial.println("ACK CMD Auto focusing ...END"); delay(1000); - } + Serial.println("ACK CMD Auto focus completed END"); + break; + } // focus completed + else + { + Serial.println("ACK CMD Auto focusing ...END"); + delay(1000); } + } - break; - default: - break; + break; + default: + break; } } if (mode == 1) @@ -229,7 +256,7 @@ void loop() { { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } @@ -237,7 +264,7 @@ void loop() { { Serial.println(F("ACK CMD CAM Capture Done.END")); read_fifo_burst(myCAM); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); } } @@ -255,17 +282,17 @@ void loop() { break; } - if (temp == 0x40) { + if (temp == 0x40) + { temp = 0; myCAM.wrSensorReg16_8(0x3022, 0x03); } - if (start_capture == 2) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } @@ -280,11 +307,11 @@ void loop() { continue; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -296,7 +323,7 @@ void loop() { Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, break; delayMicroseconds(15); } @@ -311,10 +338,10 @@ void loop() { { if (start_capture == 3) { - //Flush the FIFO + // Flush the FIFO myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } @@ -324,20 +351,20 @@ void loop() { uint8_t temp, temp_last; uint32_t length = 0; length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (length >= MAX_FIFO_SIZE) { Serial.println(F("ACK CMD Over size.END")); myCAM.clear_fifo_flag(); return; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0.END")); myCAM.clear_fifo_flag(); return; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode + myCAM.set_fifo_burst(); // Set fifo burst mode Serial.write(0xFF); Serial.write(0xAA); for (temp = 0; temp < BMPIMAGEOFFSET; temp++) @@ -351,8 +378,10 @@ void loop() { { for (j = 0; j < 320; j++) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; Serial.write(VL); delayMicroseconds(12); Serial.write(VH); @@ -362,7 +391,7 @@ void loop() { Serial.write(0xBB); Serial.write(0xCC); myCAM.CS_HIGH(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); } } @@ -373,22 +402,22 @@ uint8_t read_fifo_burst(ArduCAM myCAM) uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size.END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0.END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -400,7 +429,7 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, break; delayMicroseconds(15); } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_Plus_Functions/ArduCAM_Mini_5MP_OV5640_Plus_Functions.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_Plus_Functions/ArduCAM_Mini_5MP_OV5640_Plus_Functions.ino index 7449d795..3fc5cd7e 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_Plus_Functions/ArduCAM_Mini_5MP_OV5640_Plus_Functions.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5640_Plus_Functions/ArduCAM_Mini_5MP_OV5640_Plus_Functions.ino @@ -11,30 +11,30 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_Plus platform. -#if !(defined OV5640_MINI_5MP_PLUS ) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +// This demo can only work on OV5640_MINI_5MP_Plus platform. +#if !(defined OV5640_MINI_5MP_PLUS) +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; - ArduCAM myCAM( OV5640, CS ); +ArduCAM myCAM(OV5640, CS); uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -42,614 +42,840 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5640 detected. END"));break; - } } -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM.OV5640_set_JPEG_size(OV5640_320x240); -delay(1000); -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { - case 0: - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); + temp = Serial.read(); + switch (temp) + { + case 0: + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_320x240 END")); - temp=0xff; - break; + temp = 0xff; + break; case 1: - myCAM.OV5640_set_JPEG_size(OV5640_352x288);delay(1000); + myCAM.OV5640_set_JPEG_size(OV5640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_352x288 END")); - temp=0xff; - break; + temp = 0xff; + break; case 2: - myCAM.OV5640_set_JPEG_size(OV5640_640x480);delay(1000); + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_640x480 END")); - - temp=0xff; - break; + + temp = 0xff; + break; case 3: - myCAM.OV5640_set_JPEG_size(OV5640_800x480);delay(1000); + myCAM.OV5640_set_JPEG_size(OV5640_800x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_800x480 END")); - temp=0xff; - break; + temp = 0xff; + break; case 4: - myCAM.OV5640_set_JPEG_size(OV5640_1024x768);delay(1000); + myCAM.OV5640_set_JPEG_size(OV5640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1024x768 END")); - - temp=0xff; - break; + + temp = 0xff; + break; case 5: - myCAM.OV5640_set_JPEG_size(OV5640_1280x960);delay(1000); + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1280x960 END")); - - temp=0xff; - break; + + temp = 0xff; + break; case 6: - myCAM.OV5640_set_JPEG_size(OV5640_1600x1200);delay(1000); + myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1600x1200 END")); - - temp=0xff; - break; - case 7: - myCAM.OV5640_set_JPEG_size(OV5640_2048x1536);delay(1000); + + temp = 0xff; + break; + case 7: + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); - temp=0xff; + temp = 0xff; break; - case 8: - myCAM.OV5640_set_JPEG_size(OV5640_2592x1944);delay(1000); + case 8: + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); - temp=0xff; - break; - case 0x10: - mode = 1; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - break; + temp = 0xff; + break; + case 0x10: + mode = 1; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; - case 0x40: - myCAM.OV5640_set_Brightness(Brightness4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+4 END"));break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; + case 0x40: + myCAM.OV5640_set_Brightness(Brightness4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+4 END")); + break; case 0x41: - myCAM.OV5640_set_Brightness(Brightness3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+3 END"));break; - case 0x42: - myCAM.OV5640_set_Brightness(Brightness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x43: - myCAM.OV5640_set_Brightness(Brightness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x44: - myCAM.OV5640_set_Brightness(Brightness0);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; + myCAM.OV5640_set_Brightness(Brightness3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+3 END")); + break; + case 0x42: + myCAM.OV5640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x43: + myCAM.OV5640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x44: + myCAM.OV5640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; case 0x45: - myCAM.OV5640_set_Brightness(Brightness_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; - case 0x46: - myCAM.OV5640_set_Brightness(Brightness_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; + myCAM.OV5640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; + case 0x46: + myCAM.OV5640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; case 0x47: - myCAM.OV5640_set_Brightness(Brightness_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-3 END"));break; + myCAM.OV5640_set_Brightness(Brightness_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-3 END")); + break; case 0x48: - myCAM.OV5640_set_Brightness(Brightness_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-4 END"));break; - case 0x50: - myCAM.OV5640_set_Contrast(Contrast3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+3 END"));break; - case 0x51: - myCAM.OV5640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; - case 0x52: - myCAM.OV5640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x53: - myCAM.OV5640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; + myCAM.OV5640_set_Brightness(Brightness_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-4 END")); + break; + case 0x50: + myCAM.OV5640_set_Contrast(Contrast3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+3 END")); + break; + case 0x51: + myCAM.OV5640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; + case 0x52: + myCAM.OV5640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x53: + myCAM.OV5640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; case 0x54: - myCAM.OV5640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x55: - myCAM.OV5640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; + myCAM.OV5640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x55: + myCAM.OV5640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; case 0x56: - myCAM.OV5640_set_Contrast(Contrast_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-3 END"));break; - case 0x60: - myCAM.OV5640_set_Color_Saturation(Saturation3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+3 END"));break; - case 0x61: - myCAM.OV5640_set_Color_Saturation(Saturation2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x62: - myCAM.OV5640_set_Color_Saturation(Saturation1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x63: - myCAM.OV5640_set_Color_Saturation(Saturation0);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; - case 0x64: - myCAM.OV5640_set_Color_Saturation(Saturation_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; - case 0x65: - myCAM.OV5640_set_Color_Saturation(Saturation_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; + myCAM.OV5640_set_Contrast(Contrast_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-3 END")); + break; + case 0x60: + myCAM.OV5640_set_Color_Saturation(Saturation3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+3 END")); + break; + case 0x61: + myCAM.OV5640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x62: + myCAM.OV5640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x63: + myCAM.OV5640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; + case 0x64: + myCAM.OV5640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; + case 0x65: + myCAM.OV5640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; case 0x66: - myCAM.OV5640_set_Color_Saturation(Saturation_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-3 END"));break; - case 0x70: - myCAM.OV5640_set_EV(EV3);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+3 END"));break; - case 0x71: - myCAM.OV5640_set_EV(EV2);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+2 END"));break; - case 0x72: - myCAM.OV5640_set_EV(EV1);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+1 END"));break; - case 0x73: - myCAM.OV5640_set_EV(EV0);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+0 END"));break; + myCAM.OV5640_set_Color_Saturation(Saturation_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-3 END")); + break; + case 0x70: + myCAM.OV5640_set_EV(EV3); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+3 END")); + break; + case 0x71: + myCAM.OV5640_set_EV(EV2); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+2 END")); + break; + case 0x72: + myCAM.OV5640_set_EV(EV1); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+1 END")); + break; + case 0x73: + myCAM.OV5640_set_EV(EV0); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+0 END")); + break; case 0x74: - myCAM.OV5640_set_EV(EV_1);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-1 END"));break; + myCAM.OV5640_set_EV(EV_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-1 END")); + break; case 0x75: - myCAM.OV5640_set_EV(EV_2);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-2 END"));break; + myCAM.OV5640_set_EV(EV_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-2 END")); + break; case 0x76: - myCAM.OV5640_set_EV(EV_2);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-2 END"));break; + myCAM.OV5640_set_EV(EV_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-2 END")); + break; case 0x77: - myCAM.OV5640_set_EV(EV_3);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-3 END"));break; - + myCAM.OV5640_set_EV(EV_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-3 END")); + break; + case 0x80: - myCAM.OV5640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto END"));break; + myCAM.OV5640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto END")); + break; case 0x81: - myCAM.OV5640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny END"));break; + myCAM.OV5640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny END")); + break; case 0x82: - myCAM.OV5640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office END"));break; - case 0x83: - myCAM.OV5640_set_Light_Mode(Cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Cloudy END"));break; + myCAM.OV5640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office END")); + break; + case 0x83: + myCAM.OV5640_set_Light_Mode(Cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Cloudy END")); + break; case 0x84: - myCAM.OV5640_set_Light_Mode(Home);temp = 0xff; - Serial.println(F("ACK CMD Set to Home END"));break; - case 0x90: - myCAM.OV5640_set_Light_Mode(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break ; - case 0x91: - myCAM.OV5640_set_Light_Mode(Blueish);temp = 0xff; - Serial.println(F("ACK CMD Set to Blueish END"));break ; - case 0x92: - myCAM.OV5640_set_Light_Mode(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break ; - case 0x93: - myCAM.OV5640_set_Light_Mode(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break ; - case 0x94: - myCAM.OV5640_set_Light_Mode(Sepia);temp = 0xff; - Serial.println(F("ACK CMD Set to Sepia END"));break ; - case 0x95: - myCAM.OV5640_set_Light_Mode(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break ; - case 0x96: - myCAM.OV5640_set_Light_Mode(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break ; - case 0x97: - myCAM.OV5640_set_Light_Mode(Overexposure);temp = 0xff; - Serial.println(F("ACK CMD Set to Overexposure END"));break ; - case 0x98: - myCAM.OV5640_set_Light_Mode(Solarize);temp = 0xff; - Serial.println(F("ACK CMD Set to Solarize END"));break ; - case 0xA0: - myCAM.OV5640_set_Night_Mode(Night_Mode_On);temp = 0xff; - Serial.println(F("ACK CMD Set to Night_Mode_On END"));break ; - case 0xA1: - myCAM.OV5640_set_Night_Mode(Night_Mode_Off);temp = 0xff; - Serial.println(F("ACK CMD Set to Night_Mode_Off END"));break ; - case 0xB0: - myCAM.OV5640_set_Banding_Filter(Off);temp = 0xff; - Serial.println(F("ACK CMD Set to Off END"));break ; - case 0xB1: - myCAM.OV5640_set_Banding_Filter(Manual_50HZ);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual 50HZ END"));break ; - case 0xB2: - myCAM.OV5640_set_Banding_Filter(Manual_60HZ);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual 60HZ END"));break ; - case 0xB3: - myCAM.OV5640_set_Banding_Filter(Auto_Detection);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto_Detection END"));break ; - default: + myCAM.OV5640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home END")); break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END")); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); + case 0x90: + myCAM.OV5640_set_Light_Mode(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + case 0x91: + myCAM.OV5640_set_Light_Mode(Blueish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Blueish END")); + break; + case 0x92: + myCAM.OV5640_set_Light_Mode(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x93: + myCAM.OV5640_set_Light_Mode(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x94: + myCAM.OV5640_set_Light_Mode(Sepia); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sepia END")); + break; + case 0x95: + myCAM.OV5640_set_Light_Mode(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0x96: + myCAM.OV5640_set_Light_Mode(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x97: + myCAM.OV5640_set_Light_Mode(Overexposure); + temp = 0xff; + Serial.println(F("ACK CMD Set to Overexposure END")); + break; + case 0x98: + myCAM.OV5640_set_Light_Mode(Solarize); + temp = 0xff; + Serial.println(F("ACK CMD Set to Solarize END")); + break; + case 0xA0: + myCAM.OV5640_set_Night_Mode(Night_Mode_On); + temp = 0xff; + Serial.println(F("ACK CMD Set to Night_Mode_On END")); + break; + case 0xA1: + myCAM.OV5640_set_Night_Mode(Night_Mode_Off); + temp = 0xff; + Serial.println(F("ACK CMD Set to Night_Mode_Off END")); + break; + case 0xB0: + myCAM.OV5640_set_Banding_Filter(Off); + temp = 0xff; + Serial.println(F("ACK CMD Set to Off END")); + break; + case 0xB1: + myCAM.OV5640_set_Banding_Filter(Manual_50HZ); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual 50HZ END")); + break; + case 0xB2: + myCAM.OV5640_set_Banding_Filter(Manual_60HZ); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual 60HZ END")); + break; + case 0xB3: + myCAM.OV5640_set_Banding_Filter(Auto_Detection); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto_Detection END")); + break; + default: break; } - switch(temp){ - case 0x40: - myCAM.OV5640_set_Brightness(Brightness4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+4 END"));break; - case 0x41: - myCAM.OV5640_set_Brightness(Brightness3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+3 END"));break; - case 0x42: - myCAM.OV5640_set_Brightness(Brightness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x43: - myCAM.OV5640_set_Brightness(Brightness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x44: - myCAM.OV5640_set_Brightness(Brightness0);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; - case 0x45: - myCAM.OV5640_set_Brightness(Brightness_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; - case 0x46: - myCAM.OV5640_set_Brightness(Brightness_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; - case 0x47: - myCAM.OV5640_set_Brightness(Brightness_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-3 END"));break; - case 0x48: - myCAM.OV5640_set_Brightness(Brightness_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-4 END"));break; - case 0x50: - myCAM.OV5640_set_Contrast(Contrast3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+3 END"));break; - case 0x51: - myCAM.OV5640_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; - case 0x52: - myCAM.OV5640_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x53: - myCAM.OV5640_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; - case 0x54: - myCAM.OV5640_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x55: - myCAM.OV5640_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; - case 0x56: - myCAM.OV5640_set_Contrast(Contrast_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-3 END"));break; - case 0x60: - myCAM.OV5640_set_Color_Saturation(Saturation3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+3 END"));break; - case 0x61: - myCAM.OV5640_set_Color_Saturation(Saturation2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x62: - myCAM.OV5640_set_Color_Saturation(Saturation1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x63: - myCAM.OV5640_set_Color_Saturation(Saturation0);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; - case 0x64: - myCAM.OV5640_set_Color_Saturation(Saturation_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; - case 0x65: - myCAM.OV5640_set_Color_Saturation(Saturation_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; - case 0x66: - myCAM.OV5640_set_Color_Saturation(Saturation_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-3 END"));break; - case 0x70: - myCAM.OV5640_set_EV(EV3);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+3 END"));break; - case 0x71: - myCAM.OV5640_set_EV(EV2);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+2 END"));break; - case 0x72: - myCAM.OV5640_set_EV(EV1);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+1 END"));break; - case 0x73: - myCAM.OV5640_set_EV(EV0);temp = 0xff; - Serial.println(F("ACK CMD Set to EV+0 END"));break; - case 0x74: - myCAM.OV5640_set_EV(EV_1);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-1 END"));break; - case 0x75: - myCAM.OV5640_set_EV(EV_2);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-2 END"));break; - case 0x76: - myCAM.OV5640_set_EV(EV_2);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-2 END"));break; - case 0x77: - myCAM.OV5640_set_EV(EV_3);temp = 0xff; - Serial.println(F("ACK CMD Set to EV-3 END"));break; - - case 0x80: - myCAM.OV5640_set_Light_Mode(Auto);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto END"));break; - case 0x81: - myCAM.OV5640_set_Light_Mode(Sunny);temp = 0xff; - Serial.println(F("ACK CMD Set to Sunny END"));break; - case 0x82: - myCAM.OV5640_set_Light_Mode(Office);temp = 0xff; - Serial.println(F("ACK CMD Set to Office END"));break; - case 0x83: - myCAM.OV5640_set_Light_Mode(Home);temp = 0xff; - Serial.println(F("ACK CMD Set to Home END"));break; - case 0x90: - myCAM.OV5640_set_Light_Mode(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break ; - case 0x91: - myCAM.OV5640_set_Light_Mode(Blueish);temp = 0xff; - Serial.println(F("ACK CMD Set to Blueish END"));break ; - case 0x92: - myCAM.OV5640_set_Light_Mode(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break ; - case 0x93: - myCAM.OV5640_set_Light_Mode(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break ; - case 0x94: - myCAM.OV5640_set_Light_Mode(Sepia);temp = 0xff; - Serial.println(F("ACK CMD Set to Sepia END"));break ; - case 0x95: - myCAM.OV5640_set_Light_Mode(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break ; - case 0x96: - myCAM.OV5640_set_Light_Mode(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break ; - case 0x97: - myCAM.OV5640_set_Light_Mode(Overexposure);temp = 0xff; - Serial.println(F("ACK CMD Set to Overexposure END"));break ; - case 0x98: - myCAM.OV5640_set_Light_Mode(Solarize);temp = 0xff; - Serial.println(F("ACK CMD Set to Solarize END"));break ; - case 0xA0: - myCAM.OV5640_set_Night_Mode(Night_Mode_On);temp = 0xff; - Serial.println(F("ACK CMD Set to Night_Mode_On END"));break ; - case 0xA1: - myCAM.OV5640_set_Night_Mode(Night_Mode_Off);temp = 0xff; - Serial.println(F("ACK CMD Set to Night_Mode_Off END"));break ; - case 0xB0: - myCAM.OV5640_set_Banding_Filter(Off);temp = 0xff; - Serial.println(F("ACK CMD Set to Off END"));break ; - case 0xB1: - myCAM.OV5640_set_Banding_Filter(Manual_50HZ);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual 50HZ END"));break ; - case 0xB2: - myCAM.OV5640_set_Banding_Filter(Manual_60HZ);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual 60HZ END"));break ; - case 0xB3: - myCAM.OV5640_set_Banding_Filter(Auto_Detection);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto_Detection END"));break ; - - } - if (start_capture == 2) + } + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done. END")); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + switch (temp) + { + case 0x40: + myCAM.OV5640_set_Brightness(Brightness4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+4 END")); + break; + case 0x41: + myCAM.OV5640_set_Brightness(Brightness3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+3 END")); + break; + case 0x42: + myCAM.OV5640_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x43: + myCAM.OV5640_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x44: + myCAM.OV5640_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; + case 0x45: + myCAM.OV5640_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; + case 0x46: + myCAM.OV5640_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; + case 0x47: + myCAM.OV5640_set_Brightness(Brightness_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-3 END")); + break; + case 0x48: + myCAM.OV5640_set_Brightness(Brightness_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-4 END")); + break; + case 0x50: + myCAM.OV5640_set_Contrast(Contrast3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+3 END")); + break; + case 0x51: + myCAM.OV5640_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; + case 0x52: + myCAM.OV5640_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x53: + myCAM.OV5640_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; + case 0x54: + myCAM.OV5640_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x55: + myCAM.OV5640_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; + case 0x56: + myCAM.OV5640_set_Contrast(Contrast_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-3 END")); + break; + case 0x60: + myCAM.OV5640_set_Color_Saturation(Saturation3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+3 END")); + break; + case 0x61: + myCAM.OV5640_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x62: + myCAM.OV5640_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x63: + myCAM.OV5640_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; + case 0x64: + myCAM.OV5640_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; + case 0x65: + myCAM.OV5640_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; + case 0x66: + myCAM.OV5640_set_Color_Saturation(Saturation_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-3 END")); + break; + case 0x70: + myCAM.OV5640_set_EV(EV3); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+3 END")); + break; + case 0x71: + myCAM.OV5640_set_EV(EV2); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+2 END")); + break; + case 0x72: + myCAM.OV5640_set_EV(EV1); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+1 END")); + break; + case 0x73: + myCAM.OV5640_set_EV(EV0); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV+0 END")); + break; + case 0x74: + myCAM.OV5640_set_EV(EV_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-1 END")); + break; + case 0x75: + myCAM.OV5640_set_EV(EV_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-2 END")); + break; + case 0x76: + myCAM.OV5640_set_EV(EV_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-2 END")); + break; + case 0x77: + myCAM.OV5640_set_EV(EV_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to EV-3 END")); + break; + + case 0x80: + myCAM.OV5640_set_Light_Mode(Auto); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto END")); + break; + case 0x81: + myCAM.OV5640_set_Light_Mode(Sunny); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sunny END")); + break; + case 0x82: + myCAM.OV5640_set_Light_Mode(Office); + temp = 0xff; + Serial.println(F("ACK CMD Set to Office END")); + break; + case 0x83: + myCAM.OV5640_set_Light_Mode(Home); + temp = 0xff; + Serial.println(F("ACK CMD Set to Home END")); + break; + case 0x90: + myCAM.OV5640_set_Light_Mode(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + case 0x91: + myCAM.OV5640_set_Light_Mode(Blueish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Blueish END")); + break; + case 0x92: + myCAM.OV5640_set_Light_Mode(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x93: + myCAM.OV5640_set_Light_Mode(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x94: + myCAM.OV5640_set_Light_Mode(Sepia); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sepia END")); + break; + case 0x95: + myCAM.OV5640_set_Light_Mode(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0x96: + myCAM.OV5640_set_Light_Mode(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x97: + myCAM.OV5640_set_Light_Mode(Overexposure); + temp = 0xff; + Serial.println(F("ACK CMD Set to Overexposure END")); + break; + case 0x98: + myCAM.OV5640_set_Light_Mode(Solarize); + temp = 0xff; + Serial.println(F("ACK CMD Set to Solarize END")); + break; + case 0xA0: + myCAM.OV5640_set_Night_Mode(Night_Mode_On); + temp = 0xff; + Serial.println(F("ACK CMD Set to Night_Mode_On END")); + break; + case 0xA1: + myCAM.OV5640_set_Night_Mode(Night_Mode_Off); + temp = 0xff; + Serial.println(F("ACK CMD Set to Night_Mode_Off END")); + break; + case 0xB0: + myCAM.OV5640_set_Banding_Filter(Off); + temp = 0xff; + Serial.println(F("ACK CMD Set to Off END")); + break; + case 0xB1: + myCAM.OV5640_set_Banding_Filter(Manual_50HZ); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual 50HZ END")); + break; + case 0xB2: + myCAM.OV5640_set_Banding_Filter(Manual_60HZ); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual 60HZ END")); + break; + case 0xB3: + myCAM.OV5640_set_Banding_Filter(Auto_Detection); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto_Detection END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) - { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + else if (mode == 3) { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (start_capture == 3) { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0. END")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) + { + Serial.println(F("ACK CMD Over size. END")); + myCAM.clear_fifo_flag(); + return; + } + if (length == 0) // 0 kb { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + { + Serial.write(pgm_read_byte(&bmp_header[temp])); + } + SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size. END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("Size is 0.")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -661,8 +887,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5642_Plus_Functions/ArduCAM_Mini_5MP_OV5642_Plus_Functions.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5642_Plus_Functions/ArduCAM_Mini_5MP_OV5642_Plus_Functions.ino index 9e488b73..046e2bc0 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5642_Plus_Functions/ArduCAM_Mini_5MP_OV5642_Plus_Functions.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_OV5642_Plus_Functions/ArduCAM_Mini_5MP_OV5642_Plus_Functions.ino @@ -13,30 +13,30 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5642_MINI_5MP_Plus platform. -//#if !(defined OV5642_MINI_5MP_PLUS) -// #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file -//#endif +// This demo can only work on OV5642_MINI_5MP_Plus platform. +// #if !(defined OV5642_MINI_5MP_PLUS) +// #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +// #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; - ArduCAM myCAM( OV5642, CS ); +ArduCAM myCAM(OV5642, CS); uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -44,793 +44,1144 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); - //Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } } -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); -delay(1000); -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + delay(1000); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 1: - myCAM.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - temp = 0xff; - break; - case 2: - myCAM.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); + temp = 0xff; + break; + case 2: + myCAM.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - temp = 0xff; - break; + temp = 0xff; + break; case 3: - temp = 0xff; - myCAM.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); + temp = 0xff; + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - break; + break; case 4: - temp = 0xff; - myCAM.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); + temp = 0xff; + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - break; + break; case 5: - temp = 0xff; - myCAM.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); + temp = 0xff; + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - break; + break; case 6: - temp = 0xff; - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); + temp = 0xff; + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - break; + break; case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - break; + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; case 0x40: - myCAM.OV5642_set_Light_Mode(Advanced_AWB);temp = 0xff; - Serial.println(F("ACK CMD Set to Advanced_AWB END"));break; + myCAM.OV5642_set_Light_Mode(Advanced_AWB); + temp = 0xff; + Serial.println(F("ACK CMD Set to Advanced_AWB END")); + break; case 0x41: - myCAM.OV5642_set_Light_Mode(Simple_AWB);temp = 0xff; - Serial.println(F("ACK CMD Set to Simple_AWB END"));break; - case 0x42: - myCAM.OV5642_set_Light_Mode(Manual_day);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_day END"));break; - case 0x43: - myCAM.OV5642_set_Light_Mode(Manual_A);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_A END"));break; - case 0x44: - myCAM.OV5642_set_Light_Mode(Manual_cwf);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_cwf END"));break; - case 0x45: - myCAM.OV5642_set_Light_Mode(Manual_cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_cloudy END"));break; - case 0x50: - myCAM.OV5642_set_Color_Saturation(Saturation4);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+4 END"));break; - case 0x51: - myCAM.OV5642_set_Color_Saturation(Saturation3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+3 END"));break; - case 0x52: - myCAM.OV5642_set_Color_Saturation(Saturation2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x53: - myCAM.OV5642_set_Color_Saturation(Saturation1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x54: - myCAM.OV5642_set_Color_Saturation(Saturation0);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; - case 0x55: - myCAM.OV5642_set_Color_Saturation(Saturation_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; - case 0x56: - myCAM.OV5642_set_Color_Saturation(Saturation_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2"));break; + myCAM.OV5642_set_Light_Mode(Simple_AWB); + temp = 0xff; + Serial.println(F("ACK CMD Set to Simple_AWB END")); + break; + case 0x42: + myCAM.OV5642_set_Light_Mode(Manual_day); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_day END")); + break; + case 0x43: + myCAM.OV5642_set_Light_Mode(Manual_A); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_A END")); + break; + case 0x44: + myCAM.OV5642_set_Light_Mode(Manual_cwf); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_cwf END")); + break; + case 0x45: + myCAM.OV5642_set_Light_Mode(Manual_cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_cloudy END")); + break; + case 0x50: + myCAM.OV5642_set_Color_Saturation(Saturation4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+4 END")); + break; + case 0x51: + myCAM.OV5642_set_Color_Saturation(Saturation3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+3 END")); + break; + case 0x52: + myCAM.OV5642_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x53: + myCAM.OV5642_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x54: + myCAM.OV5642_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; + case 0x55: + myCAM.OV5642_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; + case 0x56: + myCAM.OV5642_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2")); + break; case 0x57: - myCAM.OV5642_set_Color_Saturation(Saturation_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-3 END"));break; - case 0x58: - myCAM.OV5642_set_Light_Mode(Saturation_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-4 END"));break; - case 0x60: - myCAM.OV5642_set_Brightness(Brightness4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+4 END"));break; - case 0x61: - myCAM.OV5642_set_Brightness(Brightness3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+3 END"));break; - case 0x62: - myCAM.OV5642_set_Brightness(Brightness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x63: - myCAM.OV5642_set_Brightness(Brightness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x64: - myCAM.OV5642_set_Brightness(Brightness0);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; + myCAM.OV5642_set_Color_Saturation(Saturation_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-3 END")); + break; + case 0x58: + myCAM.OV5642_set_Light_Mode(Saturation_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-4 END")); + break; + case 0x60: + myCAM.OV5642_set_Brightness(Brightness4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+4 END")); + break; + case 0x61: + myCAM.OV5642_set_Brightness(Brightness3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+3 END")); + break; + case 0x62: + myCAM.OV5642_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x63: + myCAM.OV5642_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x64: + myCAM.OV5642_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; case 0x65: - myCAM.OV5642_set_Brightness(Brightness_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; - case 0x66: - myCAM.OV5642_set_Brightness(Brightness_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; + myCAM.OV5642_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; + case 0x66: + myCAM.OV5642_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; case 0x67: - myCAM.OV5642_set_Brightness(Brightness_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-3 END"));break; + myCAM.OV5642_set_Brightness(Brightness_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-3 END")); + break; case 0x68: - myCAM.OV5642_set_Brightness(Brightness_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-4 END"));break; -case 0x70: - myCAM.OV5642_set_Contrast(Contrast4);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+4 END"));break; - case 0x71: - myCAM.OV5642_set_Contrast(Contrast3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+3 END"));break; - case 0x72: - myCAM.OV5642_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; - case 0x73: - myCAM.OV5642_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x74: - myCAM.OV5642_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; + myCAM.OV5642_set_Brightness(Brightness_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-4 END")); + break; + case 0x70: + myCAM.OV5642_set_Contrast(Contrast4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+4 END")); + break; + case 0x71: + myCAM.OV5642_set_Contrast(Contrast3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+3 END")); + break; + case 0x72: + myCAM.OV5642_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; + case 0x73: + myCAM.OV5642_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x74: + myCAM.OV5642_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; case 0x75: - myCAM.OV5642_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x76: - myCAM.OV5642_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; + myCAM.OV5642_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x76: + myCAM.OV5642_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; case 0x77: - myCAM.OV5642_set_Contrast(Contrast_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-3 END"));break; + myCAM.OV5642_set_Contrast(Contrast_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-3 END")); + break; case 0x78: - myCAM.OV5642_set_Contrast(Contrast_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-4 END"));break; - case 0x80: - myCAM.OV5642_set_hue(degree_180);temp = 0xff; - Serial.println(F("ACK CMD Set to -180 degree END"));break; - case 0x81: - myCAM.OV5642_set_hue(degree_150);temp = 0xff; - Serial.println(F("ACK CMD Set to -150 degree END"));break; - case 0x82: - myCAM.OV5642_set_hue(degree_120);temp = 0xff; - Serial.println(F("ACK CMD Set to -120 degree END"));break; - case 0x83: - myCAM.OV5642_set_hue(degree_90);temp = 0xff; - Serial.println(F("ACK CMD Set to -90 degree END"));break; - case 0x84: - myCAM.OV5642_set_hue(degree_60);temp = 0xff; - Serial.println(F("ACK CMD Set to -60 degree END"));break; - case 0x85: - myCAM.OV5642_set_hue(degree_30);temp = 0xff; - Serial.println(F("ACK CMD Set to -30 degree END"));break; - case 0x86: - myCAM.OV5642_set_hue(degree_0);temp = 0xff; - Serial.println(F("ACK CMD Set to 0 degree END"));break; - case 0x87: - myCAM.OV5642_set_hue(degree30);temp = 0xff; - Serial.println(F("ACK CMD Set to 30 degree END"));break; - case 0x88: - myCAM.OV5642_set_hue(degree60);temp = 0xff; - Serial.println(F("ACK CMD Set to 60 degree END"));break; - case 0x89: - myCAM.OV5642_set_hue(degree90);temp = 0xff; - Serial.println(F("ACK CMD Set to 90 degree END"));break; - case 0x8a: - myCAM.OV5642_set_hue(degree120);temp = 0xff; - Serial.println(F("ACK CMD Set to 120 degree END"));break ; - case 0x8b: - myCAM.OV5642_set_hue(degree150);temp = 0xff; - Serial.println(F("ACK CMD Set to 150 degree END"));break ; - case 0x90: - myCAM.OV5642_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break ; - case 0x91: - myCAM.OV5642_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break ; - case 0x92: - myCAM.OV5642_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish END"));break ; - case 0x93: - myCAM.OV5642_set_Special_effects(Sepia);temp = 0xff; - Serial.println(F("ACK CMD Set to Sepia END"));break ; - case 0x94: - myCAM.OV5642_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break ; - case 0x95: - myCAM.OV5642_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break ; - case 0x96: - myCAM.OV5642_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break ; - case 0xA0: - myCAM.OV5642_set_Exposure_level(Exposure_17_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -1.7EV"));break ; - case 0xA1: - myCAM.OV5642_set_Exposure_level(Exposure_13_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -1.3EV END"));break ; - case 0xA2: - myCAM.OV5642_set_Exposure_level(Exposure_10_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -1.0EV END"));break ; - case 0xA3: - myCAM.OV5642_set_Exposure_level(Exposure_07_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -0.7EV END"));break ; - case 0xA4: - myCAM.OV5642_set_Exposure_level(Exposure_03_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -0.3EV END"));break ; - case 0xA5: - myCAM.OV5642_set_Exposure_level(Exposure_default);temp = 0xff; - Serial.println(F("ACK CMD Set to -Exposure_default END"));break ; - case 0xA6: - myCAM.OV5642_set_Exposure_level(Exposure07_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 0.7EV END"));break ; - case 0xA7: - myCAM.OV5642_set_Exposure_level(Exposure10_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 1.0EV END"));break ; - case 0xA8: - myCAM.OV5642_set_Exposure_level(Exposure13_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 1.3EV END"));break ; - case 0xA9: - myCAM.OV5642_set_Exposure_level(Exposure17_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 1.7EV END"));break ; - case 0xB0: - myCAM.OV5642_set_Sharpness(Auto_Sharpness_default);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Sharpness default END"));break ; - case 0xB1: - myCAM.OV5642_set_Sharpness(Auto_Sharpness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Sharpness +1 END"));break ; - case 0xB2: - myCAM.OV5642_set_Sharpness(Auto_Sharpness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Sharpness +2 END"));break ; - case 0xB3: - myCAM.OV5642_set_Sharpness(Manual_Sharpnessoff);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness off END"));break ; - case 0xB4: - myCAM.OV5642_set_Sharpness(Manual_Sharpness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +1 END"));break ; - case 0xB5: - myCAM.OV5642_set_Sharpness(Manual_Sharpness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +2 END"));break ; - case 0xB6: - myCAM.OV5642_set_Sharpness(Manual_Sharpness3);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +3 END"));break ; - case 0xB7: - myCAM.OV5642_set_Sharpness(Manual_Sharpness4);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +4 END"));break ; - case 0xB8: - myCAM.OV5642_set_Sharpness(Manual_Sharpness5);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +5 END"));break ; - case 0xC0: - myCAM.OV5642_set_Mirror_Flip(MIRROR);temp = 0xff; - Serial.println(F("ACK CMD Set to MIRROR END"));break ; - case 0xC1: - myCAM.OV5642_set_Mirror_Flip(FLIP);temp = 0xff; - Serial.println(F("ACK CMD Set to FLIP END"));break ; - case 0xC2: - myCAM.OV5642_set_Mirror_Flip(MIRROR_FLIP);temp = 0xff; - Serial.println(F("ACK CMD Set to MIRROR&FLIP END"));break ; - case 0xC3: - myCAM.OV5642_set_Mirror_Flip(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break ; - case 0xD0: - myCAM.OV5642_set_Compress_quality(high_quality);temp = 0xff; - Serial.println(F("ACK CMD Set to high quality END"));break ; - case 0xD1: - myCAM.OV5642_set_Compress_quality(default_quality);temp = 0xff; - Serial.println(F("ACK CMD Set to default quality END"));break ; - case 0xD2: - myCAM.OV5642_set_Compress_quality(low_quality);temp = 0xff; - Serial.println(F("ACK CMD Set to low quality END"));break ; + myCAM.OV5642_set_Contrast(Contrast_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-4 END")); + break; + case 0x80: + myCAM.OV5642_set_hue(degree_180); + temp = 0xff; + Serial.println(F("ACK CMD Set to -180 degree END")); + break; + case 0x81: + myCAM.OV5642_set_hue(degree_150); + temp = 0xff; + Serial.println(F("ACK CMD Set to -150 degree END")); + break; + case 0x82: + myCAM.OV5642_set_hue(degree_120); + temp = 0xff; + Serial.println(F("ACK CMD Set to -120 degree END")); + break; + case 0x83: + myCAM.OV5642_set_hue(degree_90); + temp = 0xff; + Serial.println(F("ACK CMD Set to -90 degree END")); + break; + case 0x84: + myCAM.OV5642_set_hue(degree_60); + temp = 0xff; + Serial.println(F("ACK CMD Set to -60 degree END")); + break; + case 0x85: + myCAM.OV5642_set_hue(degree_30); + temp = 0xff; + Serial.println(F("ACK CMD Set to -30 degree END")); + break; + case 0x86: + myCAM.OV5642_set_hue(degree_0); + temp = 0xff; + Serial.println(F("ACK CMD Set to 0 degree END")); + break; + case 0x87: + myCAM.OV5642_set_hue(degree30); + temp = 0xff; + Serial.println(F("ACK CMD Set to 30 degree END")); + break; + case 0x88: + myCAM.OV5642_set_hue(degree60); + temp = 0xff; + Serial.println(F("ACK CMD Set to 60 degree END")); + break; + case 0x89: + myCAM.OV5642_set_hue(degree90); + temp = 0xff; + Serial.println(F("ACK CMD Set to 90 degree END")); + break; + case 0x8a: + myCAM.OV5642_set_hue(degree120); + temp = 0xff; + Serial.println(F("ACK CMD Set to 120 degree END")); + break; + case 0x8b: + myCAM.OV5642_set_hue(degree150); + temp = 0xff; + Serial.println(F("ACK CMD Set to 150 degree END")); + break; + case 0x90: + myCAM.OV5642_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + case 0x91: + myCAM.OV5642_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x92: + myCAM.OV5642_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish END")); + break; + case 0x93: + myCAM.OV5642_set_Special_effects(Sepia); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sepia END")); + break; + case 0x94: + myCAM.OV5642_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x95: + myCAM.OV5642_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x96: + myCAM.OV5642_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0xA0: + myCAM.OV5642_set_Exposure_level(Exposure_17_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -1.7EV")); + break; + case 0xA1: + myCAM.OV5642_set_Exposure_level(Exposure_13_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -1.3EV END")); + break; + case 0xA2: + myCAM.OV5642_set_Exposure_level(Exposure_10_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -1.0EV END")); + break; + case 0xA3: + myCAM.OV5642_set_Exposure_level(Exposure_07_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -0.7EV END")); + break; + case 0xA4: + myCAM.OV5642_set_Exposure_level(Exposure_03_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -0.3EV END")); + break; + case 0xA5: + myCAM.OV5642_set_Exposure_level(Exposure_default); + temp = 0xff; + Serial.println(F("ACK CMD Set to -Exposure_default END")); + break; + case 0xA6: + myCAM.OV5642_set_Exposure_level(Exposure07_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 0.7EV END")); + break; + case 0xA7: + myCAM.OV5642_set_Exposure_level(Exposure10_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 1.0EV END")); + break; + case 0xA8: + myCAM.OV5642_set_Exposure_level(Exposure13_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 1.3EV END")); + break; + case 0xA9: + myCAM.OV5642_set_Exposure_level(Exposure17_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 1.7EV END")); + break; + case 0xB0: + myCAM.OV5642_set_Sharpness(Auto_Sharpness_default); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Sharpness default END")); + break; + case 0xB1: + myCAM.OV5642_set_Sharpness(Auto_Sharpness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Sharpness +1 END")); + break; + case 0xB2: + myCAM.OV5642_set_Sharpness(Auto_Sharpness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Sharpness +2 END")); + break; + case 0xB3: + myCAM.OV5642_set_Sharpness(Manual_Sharpnessoff); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness off END")); + break; + case 0xB4: + myCAM.OV5642_set_Sharpness(Manual_Sharpness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +1 END")); + break; + case 0xB5: + myCAM.OV5642_set_Sharpness(Manual_Sharpness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +2 END")); + break; + case 0xB6: + myCAM.OV5642_set_Sharpness(Manual_Sharpness3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +3 END")); + break; + case 0xB7: + myCAM.OV5642_set_Sharpness(Manual_Sharpness4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +4 END")); + break; + case 0xB8: + myCAM.OV5642_set_Sharpness(Manual_Sharpness5); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +5 END")); + break; + case 0xC0: + myCAM.OV5642_set_Mirror_Flip(MIRROR); + temp = 0xff; + Serial.println(F("ACK CMD Set to MIRROR END")); + break; + case 0xC1: + myCAM.OV5642_set_Mirror_Flip(FLIP); + temp = 0xff; + Serial.println(F("ACK CMD Set to FLIP END")); + break; + case 0xC2: + myCAM.OV5642_set_Mirror_Flip(MIRROR_FLIP); + temp = 0xff; + Serial.println(F("ACK CMD Set to MIRROR&FLIP END")); + break; + case 0xC3: + myCAM.OV5642_set_Mirror_Flip(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + case 0xD0: + myCAM.OV5642_set_Compress_quality(high_quality); + temp = 0xff; + Serial.println(F("ACK CMD Set to high quality END")); + break; + case 0xD1: + myCAM.OV5642_set_Compress_quality(default_quality); + temp = 0xff; + Serial.println(F("ACK CMD Set to default quality END")); + break; + case 0xD2: + myCAM.OV5642_set_Compress_quality(low_quality); + temp = 0xff; + Serial.println(F("ACK CMD Set to low quality END")); + break; - case 0xE0: - myCAM.OV5642_Test_Pattern(Color_bar);temp = 0xff; - Serial.println(F("ACK CMD Set to Color bar END"));break ; - case 0xE1: - myCAM.OV5642_Test_Pattern(Color_square);temp = 0xff; - Serial.println(F("ACK CMD Set to Color square END"));break ; - case 0xE2: - myCAM.OV5642_Test_Pattern(BW_square);temp = 0xff; - Serial.println(F("ACK CMD Set to BW square END"));break ; - case 0xE3: - myCAM.OV5642_Test_Pattern(DLI);temp = 0xff; - Serial.println(F("ACK CMD Set to DLI END"));break ; - default: + case 0xE0: + myCAM.OV5642_Test_Pattern(Color_bar); + temp = 0xff; + Serial.println(F("ACK CMD Set to Color bar END")); break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); + case 0xE1: + myCAM.OV5642_Test_Pattern(Color_square); + temp = 0xff; + Serial.println(F("ACK CMD Set to Color square END")); + break; + case 0xE2: + myCAM.OV5642_Test_Pattern(BW_square); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW square END")); + break; + case 0xE3: + myCAM.OV5642_Test_Pattern(DLI); + temp = 0xff; + Serial.println(F("ACK CMD Set to DLI END")); + break; + default: break; } - switch(temp){ - case 0x40: - myCAM.OV5642_set_Light_Mode(Advanced_AWB);temp = 0xff; - Serial.println(F("ACK CMD Set to Advanced_AWB END"));break; - case 0x41: - myCAM.OV5642_set_Light_Mode(Simple_AWB);temp = 0xff; - Serial.println(F("ACK CMD Set to Simple_AWB END"));break; - case 0x42: - myCAM.OV5642_set_Light_Mode(Manual_day);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_day END"));break; - case 0x43: - myCAM.OV5642_set_Light_Mode(Manual_A);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_A END"));break; - case 0x44: - myCAM.OV5642_set_Light_Mode(Manual_cwf);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_cwf END"));break; - case 0x45: - myCAM.OV5642_set_Light_Mode(Manual_cloudy);temp = 0xff; - Serial.println(F("ACK CMD Set to Manual_cloudy END"));break; - case 0x50: - myCAM.OV5642_set_Color_Saturation(Saturation4);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+4 END"));break; - case 0x51: - myCAM.OV5642_set_Color_Saturation(Saturation3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+3 END"));break; - case 0x52: - myCAM.OV5642_set_Color_Saturation(Saturation2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+2 END"));break; - case 0x53: - myCAM.OV5642_set_Color_Saturation(Saturation1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+1 END"));break; - case 0x54: - myCAM.OV5642_set_Color_Saturation(Saturation0);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation+0 END"));break; - case 0x55: - myCAM.OV5642_set_Color_Saturation(Saturation_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-1 END"));break; - case 0x56: - myCAM.OV5642_set_Color_Saturation(Saturation_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-2 END"));break; - case 0x57: - myCAM.OV5642_set_Color_Saturation(Saturation_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-3 END"));break; - case 0x58: - myCAM.OV5642_set_Light_Mode(Saturation_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Saturation-4 END"));break; - case 0x60: - myCAM.OV5642_set_Brightness(Brightness4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+4 END"));break; - case 0x61: - myCAM.OV5642_set_Brightness(Brightness3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+3 END"));break; - case 0x62: - myCAM.OV5642_set_Brightness(Brightness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+2 END"));break; - case 0x63: - myCAM.OV5642_set_Brightness(Brightness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+1 END"));break; - case 0x64: - myCAM.OV5642_set_Brightness(Brightness0);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness+0 END"));break; - case 0x65: - myCAM.OV5642_set_Brightness(Brightness_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-1 END"));break; - case 0x66: - myCAM.OV5642_set_Brightness(Brightness_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-2 END"));break; - case 0x67: - myCAM.OV5642_set_Brightness(Brightness_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-3 END"));break; - case 0x68: - myCAM.OV5642_set_Brightness(Brightness_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Brightness-4 END"));break; -case 0x70: - myCAM.OV5642_set_Contrast(Contrast4);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+4 END"));break; - case 0x71: - myCAM.OV5642_set_Contrast(Contrast3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+3 END"));break; - case 0x72: - myCAM.OV5642_set_Contrast(Contrast2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+2 END"));break; - case 0x73: - myCAM.OV5642_set_Contrast(Contrast1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+1 END"));break; - case 0x74: - myCAM.OV5642_set_Contrast(Contrast0);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast+0 END"));break; - case 0x75: - myCAM.OV5642_set_Contrast(Contrast_1);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-1 END"));break; - case 0x76: - myCAM.OV5642_set_Contrast(Contrast_2);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-2 END"));break; - case 0x77: - myCAM.OV5642_set_Contrast(Contrast_3);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-3 END"));break; - case 0x78: - myCAM.OV5642_set_Contrast(Contrast_4);temp = 0xff; - Serial.println(F("ACK CMD Set to Contrast-4 END"));break; - case 0x80: - myCAM.OV5642_set_hue(degree_180);temp = 0xff; - Serial.println(F("ACK CMD Set to -180 degree END"));break; - case 0x81: - myCAM.OV5642_set_hue(degree_150);temp = 0xff; - Serial.println(F("ACK CMD Set to -150 degree END"));break; - case 0x82: - myCAM.OV5642_set_hue(degree_120);temp = 0xff; - Serial.println(F("ACK CMD Set to -120 degree END"));break; - case 0x83: - myCAM.OV5642_set_hue(degree_90);temp = 0xff; - Serial.println(F("ACK CMD Set to -90 degree END"));break; - case 0x84: - myCAM.OV5642_set_hue(degree_60);temp = 0xff; - Serial.println(F("ACK CMD Set to -60 degree END"));break; - case 0x85: - myCAM.OV5642_set_hue(degree_30);temp = 0xff; - Serial.println(F("ACK CMD Set to -30 degree END"));break; - case 0x86: - myCAM.OV5642_set_hue(degree_0);temp = 0xff; - Serial.println(F("ACK CMD Set to 0 degree END"));break; - case 0x87: - myCAM.OV5642_set_hue(degree30);temp = 0xff; - Serial.println(F("ACK CMD Set to 30 degree END"));break; - case 0x88: - myCAM.OV5642_set_hue(degree60);temp = 0xff; - Serial.println(F("ACK CMD Set to 60 degree END"));break; - case 0x89: - myCAM.OV5642_set_hue(degree90);temp = 0xff; - Serial.println(F("ACK CMD Set to 90 degree END"));break; - case 0x8a: - myCAM.OV5642_set_hue(degree120);temp = 0xff; - Serial.println(F("ACK CMD Set to 120 degree END"));break ; - case 0x8b: - myCAM.OV5642_set_hue(degree150);temp = 0xff; - Serial.println(F("ACK CMD Set to 150 degree END"));break ; - case 0x90: - myCAM.OV5642_set_Special_effects(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break ; - case 0x91: - myCAM.OV5642_set_Special_effects(BW);temp = 0xff; - Serial.println(F("ACK CMD Set to BW END"));break ; - case 0x92: - myCAM.OV5642_set_Special_effects(Bluish);temp = 0xff; - Serial.println(F("ACK CMD Set to Bluish END"));break ; - case 0x93: - myCAM.OV5642_set_Special_effects(Sepia);temp = 0xff; - Serial.println(F("ACK CMD Set to Sepia END"));break ; - case 0x94: - myCAM.OV5642_set_Special_effects(Reddish);temp = 0xff; - Serial.println(F("ACK CMD Set to Reddish END"));break ; - case 0x95: - myCAM.OV5642_set_Special_effects(Greenish);temp = 0xff; - Serial.println(F("ACK CMD Set to Greenish END"));break ; - case 0x96: - myCAM.OV5642_set_Special_effects(Negative);temp = 0xff; - Serial.println(F("ACK CMD Set to Negative END"));break ; - case 0xA0: - myCAM.OV5642_set_Exposure_level(Exposure_17_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -1.7EV END"));break ; - case 0xA1: - myCAM.OV5642_set_Exposure_level(Exposure_13_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -1.3EV END"));break ; - case 0xA2: - myCAM.OV5642_set_Exposure_level(Exposure_10_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -1.0EV END"));break ; - case 0xA3: - myCAM.OV5642_set_Exposure_level(Exposure_07_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -0.7EV END"));break ; - case 0xA4: - myCAM.OV5642_set_Exposure_level(Exposure_03_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to -0.3EV END"));break ; - case 0xA5: - myCAM.OV5642_set_Exposure_level(Exposure_default);temp = 0xff; - Serial.println(F("ACK CMD Set to -Exposure_default END"));break ; - case 0xA6: - myCAM.OV5642_set_Exposure_level(Exposure07_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 0.7EV END"));break ; - case 0xA7: - myCAM.OV5642_set_Exposure_level(Exposure10_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 1.0EV END"));break ; - case 0xA8: - myCAM.OV5642_set_Exposure_level(Exposure13_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 1.3EV END"));break ; - case 0xA9: - myCAM.OV5642_set_Exposure_level(Exposure17_EV);temp = 0xff; - Serial.println(F("ACK CMD Set to 1.7EV END"));break ; - case 0xB0: - myCAM.OV5642_set_Sharpness(Auto_Sharpness_default);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Sharpness default END"));break ; - case 0xB1: - myCAM.OV5642_set_Sharpness(Auto_Sharpness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Sharpness +1 END"));break ; - case 0xB2: - myCAM.OV5642_set_Sharpness(Auto_Sharpness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Sharpness +2 END"));break ; - case 0xB3: - myCAM.OV5642_set_Sharpness(Manual_Sharpnessoff);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness off END"));break ; - case 0xB4: - myCAM.OV5642_set_Sharpness(Manual_Sharpness1);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +1 END"));break ; - case 0xB5: - myCAM.OV5642_set_Sharpness(Manual_Sharpness2);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +2 END"));break ; - case 0xB6: - myCAM.OV5642_set_Sharpness(Manual_Sharpness3);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +3 END"));break ; - case 0xB7: - myCAM.OV5642_set_Sharpness(Manual_Sharpness4);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +4 END"));break ; - case 0xB8: - myCAM.OV5642_set_Sharpness(Manual_Sharpness5);temp = 0xff; - Serial.println(F("ACK CMD Set to Auto Manual Sharpness +5 END"));break ; - case 0xC0: - myCAM.OV5642_set_Mirror_Flip(MIRROR);temp = 0xff; - Serial.println(F("ACK CMD Set to MIRROR END"));break ; - case 0xC1: - myCAM.OV5642_set_Mirror_Flip(FLIP);temp = 0xff; - Serial.println(F("ACK CMD Set to FLIP END"));break ; - case 0xC2: - myCAM.OV5642_set_Mirror_Flip(MIRROR_FLIP);temp = 0xff; - Serial.println(F("ACK CMD Set to MIRROR&FLIP END"));break ; - case 0xC3: - myCAM.OV5642_set_Mirror_Flip(Normal);temp = 0xff; - Serial.println(F("ACK CMD Set to Normal END"));break ; - case 0xD0: - myCAM.OV5642_set_Compress_quality(high_quality);temp = 0xff; - Serial.println(F("ACK CMD Set to high quality END"));break ; - case 0xD1: - myCAM.OV5642_set_Compress_quality(default_quality);temp = 0xff; - Serial.println(F("ACK CMD Set to default quality END"));break ; - case 0xD2: - myCAM.OV5642_set_Compress_quality(low_quality);temp = 0xff; - Serial.println(F("ACK CMD Set to low quality END"));break ; - - case 0xE0: - myCAM.OV5642_Test_Pattern(Color_bar);temp = 0xff; - Serial.println(F("ACK CMD Set to Color bar END"));break ; - case 0xE1: - myCAM.OV5642_Test_Pattern(Color_square);temp = 0xff; - Serial.println(F("ACK CMD Set to Color square END"));break ; - case 0xE2: - myCAM.OV5642_Test_Pattern(BW_square);temp = 0xff; - Serial.println(F("ACK CMD Set to BW square END"));break ; - case 0xE3: - myCAM.OV5642_Test_Pattern(DLI);temp = 0xff; - Serial.println(F("ACK CMD Set to DLI END"));break ; - - } - if (start_capture == 2) + } + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) + { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + switch (temp) { + case 0x40: + myCAM.OV5642_set_Light_Mode(Advanced_AWB); + temp = 0xff; + Serial.println(F("ACK CMD Set to Advanced_AWB END")); + break; + case 0x41: + myCAM.OV5642_set_Light_Mode(Simple_AWB); + temp = 0xff; + Serial.println(F("ACK CMD Set to Simple_AWB END")); + break; + case 0x42: + myCAM.OV5642_set_Light_Mode(Manual_day); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_day END")); + break; + case 0x43: + myCAM.OV5642_set_Light_Mode(Manual_A); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_A END")); + break; + case 0x44: + myCAM.OV5642_set_Light_Mode(Manual_cwf); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_cwf END")); + break; + case 0x45: + myCAM.OV5642_set_Light_Mode(Manual_cloudy); + temp = 0xff; + Serial.println(F("ACK CMD Set to Manual_cloudy END")); + break; + case 0x50: + myCAM.OV5642_set_Color_Saturation(Saturation4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+4 END")); + break; + case 0x51: + myCAM.OV5642_set_Color_Saturation(Saturation3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+3 END")); + break; + case 0x52: + myCAM.OV5642_set_Color_Saturation(Saturation2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+2 END")); + break; + case 0x53: + myCAM.OV5642_set_Color_Saturation(Saturation1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+1 END")); + break; + case 0x54: + myCAM.OV5642_set_Color_Saturation(Saturation0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation+0 END")); + break; + case 0x55: + myCAM.OV5642_set_Color_Saturation(Saturation_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-1 END")); + break; + case 0x56: + myCAM.OV5642_set_Color_Saturation(Saturation_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-2 END")); + break; + case 0x57: + myCAM.OV5642_set_Color_Saturation(Saturation_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-3 END")); + break; + case 0x58: + myCAM.OV5642_set_Light_Mode(Saturation_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Saturation-4 END")); + break; + case 0x60: + myCAM.OV5642_set_Brightness(Brightness4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+4 END")); + break; + case 0x61: + myCAM.OV5642_set_Brightness(Brightness3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+3 END")); + break; + case 0x62: + myCAM.OV5642_set_Brightness(Brightness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+2 END")); + break; + case 0x63: + myCAM.OV5642_set_Brightness(Brightness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+1 END")); + break; + case 0x64: + myCAM.OV5642_set_Brightness(Brightness0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness+0 END")); + break; + case 0x65: + myCAM.OV5642_set_Brightness(Brightness_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-1 END")); + break; + case 0x66: + myCAM.OV5642_set_Brightness(Brightness_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-2 END")); + break; + case 0x67: + myCAM.OV5642_set_Brightness(Brightness_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-3 END")); + break; + case 0x68: + myCAM.OV5642_set_Brightness(Brightness_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Brightness-4 END")); + break; + case 0x70: + myCAM.OV5642_set_Contrast(Contrast4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+4 END")); + break; + case 0x71: + myCAM.OV5642_set_Contrast(Contrast3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+3 END")); + break; + case 0x72: + myCAM.OV5642_set_Contrast(Contrast2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+2 END")); + break; + case 0x73: + myCAM.OV5642_set_Contrast(Contrast1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+1 END")); + break; + case 0x74: + myCAM.OV5642_set_Contrast(Contrast0); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast+0 END")); + break; + case 0x75: + myCAM.OV5642_set_Contrast(Contrast_1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-1 END")); + break; + case 0x76: + myCAM.OV5642_set_Contrast(Contrast_2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-2 END")); + break; + case 0x77: + myCAM.OV5642_set_Contrast(Contrast_3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-3 END")); + break; + case 0x78: + myCAM.OV5642_set_Contrast(Contrast_4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Contrast-4 END")); + break; + case 0x80: + myCAM.OV5642_set_hue(degree_180); + temp = 0xff; + Serial.println(F("ACK CMD Set to -180 degree END")); + break; + case 0x81: + myCAM.OV5642_set_hue(degree_150); + temp = 0xff; + Serial.println(F("ACK CMD Set to -150 degree END")); + break; + case 0x82: + myCAM.OV5642_set_hue(degree_120); + temp = 0xff; + Serial.println(F("ACK CMD Set to -120 degree END")); + break; + case 0x83: + myCAM.OV5642_set_hue(degree_90); + temp = 0xff; + Serial.println(F("ACK CMD Set to -90 degree END")); + break; + case 0x84: + myCAM.OV5642_set_hue(degree_60); + temp = 0xff; + Serial.println(F("ACK CMD Set to -60 degree END")); + break; + case 0x85: + myCAM.OV5642_set_hue(degree_30); + temp = 0xff; + Serial.println(F("ACK CMD Set to -30 degree END")); + break; + case 0x86: + myCAM.OV5642_set_hue(degree_0); + temp = 0xff; + Serial.println(F("ACK CMD Set to 0 degree END")); + break; + case 0x87: + myCAM.OV5642_set_hue(degree30); + temp = 0xff; + Serial.println(F("ACK CMD Set to 30 degree END")); + break; + case 0x88: + myCAM.OV5642_set_hue(degree60); + temp = 0xff; + Serial.println(F("ACK CMD Set to 60 degree END")); + break; + case 0x89: + myCAM.OV5642_set_hue(degree90); + temp = 0xff; + Serial.println(F("ACK CMD Set to 90 degree END")); + break; + case 0x8a: + myCAM.OV5642_set_hue(degree120); + temp = 0xff; + Serial.println(F("ACK CMD Set to 120 degree END")); + break; + case 0x8b: + myCAM.OV5642_set_hue(degree150); + temp = 0xff; + Serial.println(F("ACK CMD Set to 150 degree END")); + break; + case 0x90: + myCAM.OV5642_set_Special_effects(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + case 0x91: + myCAM.OV5642_set_Special_effects(BW); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW END")); + break; + case 0x92: + myCAM.OV5642_set_Special_effects(Bluish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Bluish END")); + break; + case 0x93: + myCAM.OV5642_set_Special_effects(Sepia); + temp = 0xff; + Serial.println(F("ACK CMD Set to Sepia END")); + break; + case 0x94: + myCAM.OV5642_set_Special_effects(Reddish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Reddish END")); + break; + case 0x95: + myCAM.OV5642_set_Special_effects(Greenish); + temp = 0xff; + Serial.println(F("ACK CMD Set to Greenish END")); + break; + case 0x96: + myCAM.OV5642_set_Special_effects(Negative); + temp = 0xff; + Serial.println(F("ACK CMD Set to Negative END")); + break; + case 0xA0: + myCAM.OV5642_set_Exposure_level(Exposure_17_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -1.7EV END")); + break; + case 0xA1: + myCAM.OV5642_set_Exposure_level(Exposure_13_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -1.3EV END")); + break; + case 0xA2: + myCAM.OV5642_set_Exposure_level(Exposure_10_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -1.0EV END")); + break; + case 0xA3: + myCAM.OV5642_set_Exposure_level(Exposure_07_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -0.7EV END")); + break; + case 0xA4: + myCAM.OV5642_set_Exposure_level(Exposure_03_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to -0.3EV END")); + break; + case 0xA5: + myCAM.OV5642_set_Exposure_level(Exposure_default); + temp = 0xff; + Serial.println(F("ACK CMD Set to -Exposure_default END")); + break; + case 0xA6: + myCAM.OV5642_set_Exposure_level(Exposure07_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 0.7EV END")); + break; + case 0xA7: + myCAM.OV5642_set_Exposure_level(Exposure10_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 1.0EV END")); + break; + case 0xA8: + myCAM.OV5642_set_Exposure_level(Exposure13_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 1.3EV END")); + break; + case 0xA9: + myCAM.OV5642_set_Exposure_level(Exposure17_EV); + temp = 0xff; + Serial.println(F("ACK CMD Set to 1.7EV END")); + break; + case 0xB0: + myCAM.OV5642_set_Sharpness(Auto_Sharpness_default); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Sharpness default END")); + break; + case 0xB1: + myCAM.OV5642_set_Sharpness(Auto_Sharpness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Sharpness +1 END")); + break; + case 0xB2: + myCAM.OV5642_set_Sharpness(Auto_Sharpness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Sharpness +2 END")); + break; + case 0xB3: + myCAM.OV5642_set_Sharpness(Manual_Sharpnessoff); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness off END")); + break; + case 0xB4: + myCAM.OV5642_set_Sharpness(Manual_Sharpness1); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +1 END")); + break; + case 0xB5: + myCAM.OV5642_set_Sharpness(Manual_Sharpness2); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +2 END")); + break; + case 0xB6: + myCAM.OV5642_set_Sharpness(Manual_Sharpness3); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +3 END")); + break; + case 0xB7: + myCAM.OV5642_set_Sharpness(Manual_Sharpness4); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +4 END")); + break; + case 0xB8: + myCAM.OV5642_set_Sharpness(Manual_Sharpness5); + temp = 0xff; + Serial.println(F("ACK CMD Set to Auto Manual Sharpness +5 END")); + break; + case 0xC0: + myCAM.OV5642_set_Mirror_Flip(MIRROR); + temp = 0xff; + Serial.println(F("ACK CMD Set to MIRROR END")); + break; + case 0xC1: + myCAM.OV5642_set_Mirror_Flip(FLIP); + temp = 0xff; + Serial.println(F("ACK CMD Set to FLIP END")); + break; + case 0xC2: + myCAM.OV5642_set_Mirror_Flip(MIRROR_FLIP); + temp = 0xff; + Serial.println(F("ACK CMD Set to MIRROR&FLIP END")); + break; + case 0xC3: + myCAM.OV5642_set_Mirror_Flip(Normal); + temp = 0xff; + Serial.println(F("ACK CMD Set to Normal END")); + break; + case 0xD0: + myCAM.OV5642_set_Compress_quality(high_quality); + temp = 0xff; + Serial.println(F("ACK CMD Set to high quality END")); + break; + case 0xD1: + myCAM.OV5642_set_Compress_quality(default_quality); + temp = 0xff; + Serial.println(F("ACK CMD Set to default quality END")); + break; + case 0xD2: + myCAM.OV5642_set_Compress_quality(low_quality); + temp = 0xff; + Serial.println(F("ACK CMD Set to low quality END")); + break; + + case 0xE0: + myCAM.OV5642_Test_Pattern(Color_bar); + temp = 0xff; + Serial.println(F("ACK CMD Set to Color bar END")); + break; + case 0xE1: + myCAM.OV5642_Test_Pattern(Color_square); + temp = 0xff; + Serial.println(F("ACK CMD Set to Color square END")); + break; + case 0xE2: + myCAM.OV5642_Test_Pattern(BW_square); + temp = 0xff; + Serial.println(F("ACK CMD Set to BW square END")); + break; + case 0xE3: + myCAM.OV5642_Test_Pattern(DLI); + temp = 0xff; + Serial.println(F("ACK CMD Set to DLI END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(4); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(4); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) + else if (mode == 3) { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) + if (start_capture == 3) { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0. END")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - //SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) + { + Serial.println(F("ACK CMD Over size. END")); + myCAM.clear_fifo_flag(); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.write(pgm_read_byte(&bmp_header[temp])); } + // SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size. END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0. END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -842,8 +1193,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD.ino index 2dac1199..9a75546b 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD/ArduCAM_Mini_5MP_Plus_4CAM_Capture2SD.ino @@ -17,11 +17,11 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x00 +#define FRAMES_NUM 0x00 #define SD_CS 9 // set pin 4,5,6,7 as the slave select for SPI: @@ -29,248 +29,281 @@ const int CS1 = 4; const int CS2 = 5; const int CS3 = 6; const int CS4 = 7; -bool CAM1_EXIST = false; +bool CAM1_EXIST = false; bool CAM2_EXIST = false; bool CAM3_EXIST = false; bool CAM4_EXIST = false; -#if defined (OV5640_MINI_5MP_PLUS) - ArduCAM myCAM1(OV5640, CS1); - ArduCAM myCAM2(OV5640, CS2); - ArduCAM myCAM3(OV5640, CS3); - ArduCAM myCAM4(OV5640, CS4); +#if defined(OV5640_MINI_5MP_PLUS) +ArduCAM myCAM1(OV5640, CS1); +ArduCAM myCAM2(OV5640, CS2); +ArduCAM myCAM3(OV5640, CS3); +ArduCAM myCAM4(OV5640, CS4); #else - ArduCAM myCAM1(OV5642, CS1); - ArduCAM myCAM2(OV5642, CS2); - ArduCAM myCAM3(OV5642, CS3); - ArduCAM myCAM4(OV5642, CS4); +ArduCAM myCAM1(OV5642, CS1); +ArduCAM myCAM2(OV5642, CS2); +ArduCAM myCAM3(OV5642, CS3); +ArduCAM myCAM4(OV5642, CS4); #endif -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the CS output: -pinMode(CS1, OUTPUT); -digitalWrite(CS1, HIGH); -pinMode(CS2, OUTPUT); -digitalWrite(CS2, HIGH); -pinMode(CS3, OUTPUT); -digitalWrite(CS3, HIGH); -pinMode(CS4, OUTPUT); -digitalWrite(CS4, HIGH); -pinMode(SD_CS, OUTPUT); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM1.write_reg(0x07, 0x80); -delay(100); -myCAM1.write_reg(0x07, 0x00); -delay(100); -myCAM2.write_reg(0x07, 0x80); -delay(100); -myCAM2.write_reg(0x07, 0x00); -delay(100); -myCAM3.write_reg(0x07, 0x80); -delay(100); -myCAM3.write_reg(0x07, 0x00); -delay(100); -myCAM4.write_reg(0x07, 0x80); -delay(100); -myCAM4.write_reg(0x07, 0x00); -delay(100); +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS output: + pinMode(CS1, OUTPUT); + digitalWrite(CS1, HIGH); + pinMode(CS2, OUTPUT); + digitalWrite(CS2, HIGH); + pinMode(CS3, OUTPUT); + digitalWrite(CS3, HIGH); + pinMode(CS4, OUTPUT); + digitalWrite(CS4, HIGH); + pinMode(SD_CS, OUTPUT); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM1.write_reg(0x07, 0x80); + delay(100); + myCAM1.write_reg(0x07, 0x00); + delay(100); + myCAM2.write_reg(0x07, 0x80); + delay(100); + myCAM2.write_reg(0x07, 0x00); + delay(100); + myCAM3.write_reg(0x07, 0x80); + delay(100); + myCAM3.write_reg(0x07, 0x00); + delay(100); + myCAM4.write_reg(0x07, 0x80); + delay(100); + myCAM4.write_reg(0x07, 0x00); + delay(100); -//Check if the 4 ArduCAM Mini 5MP PLus Cameras' SPI bus is OK -while(1){ - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println(F("SPI1 interface Error!")); - }else{ - CAM1_EXIST = true; - Serial.println(F("SPI1 interface OK.")); - } - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // Check if the 4 ArduCAM Mini 5MP PLus Cameras' SPI bus is OK + while (1) { - Serial.println(F("SPI2 interface Error!")); - }else{ - CAM2_EXIST = true; - Serial.println(F("SPI2 interface OK.")); + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI1 interface Error!")); + } + else + { + CAM1_EXIST = true; + Serial.println(F("SPI1 interface OK.")); + } + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI2 interface Error!")); + } + else + { + CAM2_EXIST = true; + Serial.println(F("SPI2 interface OK.")); + } + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI3 interface Error!")); + } + else + { + CAM3_EXIST = true; + Serial.println(F("SPI3 interface OK.")); + } + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI4 interface Error!")); + } + else + { + CAM4_EXIST = true; + Serial.println(F("SPI4 interface OK.")); + } + if (!(CAM1_EXIST || CAM2_EXIST || CAM3_EXIST || CAM4_EXIST)) + { + delay(1000); + continue; + } + else + break; } - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // Initialize SD Card + while (!SD.begin(SD_CS)) { - Serial.println(F("SPI3 interface Error!")); - }else{ - CAM3_EXIST = true; - Serial.println(F("SPI3 interface OK.")); + Serial.println(F("SD Card Error")); + delay(1000); } - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + Serial.println(F("SD Card detected.")); +#if defined(OV5640_MINI_5MP_PLUS) + while (1) { - Serial.println(F("SPI4 interface Error!")); - }else{ - CAM4_EXIST = true; - Serial.println(F("SPI4 interface OK.")); - } - if(!(CAM1_EXIST||CAM2_EXIST||CAM3_EXIST||CAM4_EXIST)){ - delay(1000);continue; - }else - break; -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error"));delay(1000); -} -Serial.println(F("SD Card detected.")); -#if defined (OV5640_MINI_5MP_PLUS) - while(1){ - //Check if the camera module type is OV5640 + // Check if the camera module type is OV5640 myCAM1.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("Can't find OV5640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5640 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5642 detected."));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; + } } #endif -//Change to JPEG capture mode and initialize the OV5640 module -myCAM1.set_format(JPEG); -myCAM1.InitCAM(); -myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM1.clear_fifo_flag(); -myCAM1.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM2.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM3.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM4.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -#if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); + // Change to JPEG capture mode and initialize the OV5640 module + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM1.clear_fifo_flag(); + myCAM1.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM2.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM3.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM4.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); #else - myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -delay(1000); -myCAM1.clear_fifo_flag(); -myCAM2.clear_fifo_flag(); -myCAM3.clear_fifo_flag(); -myCAM4.clear_fifo_flag(); + delay(1000); + myCAM1.clear_fifo_flag(); + myCAM2.clear_fifo_flag(); + myCAM3.clear_fifo_flag(); + myCAM4.clear_fifo_flag(); } -void loop() { - if(CAM1_EXIST) +void loop() +{ + if (CAM1_EXIST) myCAMSaveToSDFile(myCAM1); - if(CAM2_EXIST) + if (CAM2_EXIST) myCAMSaveToSDFile(myCAM2); - if(CAM3_EXIST) + if (CAM3_EXIST) myCAMSaveToSDFile(myCAM3); - if(CAM4_EXIST) + if (CAM4_EXIST) myCAMSaveToSDFile(myCAM4); delay(5000); } -void myCAMSaveToSDFile(ArduCAM myCAM){ -char str[8]; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0,temp_last=0; -uint32_t length = 0; -bool is_header = false; -File outFile; -//Flush the FIFO -myCAM.flush_fifo(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Start capture -myCAM.start_capture(); -Serial.println(F("start Capture")); -while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //8M -{ - Serial.println(F("Over size.")); - return ; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return ; -} -//Construct a file name -k = k + 1; -itoa(k, str, 10); -strcat(str, ".jpg"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if(!outFile){ - Serial.println(F("File open faild")); - return; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -while ( length-- ) +void myCAMSaveToSDFile(ArduCAM myCAM) { - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + char str[8]; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + bool is_header = false; + File outFile; + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("start Capture")); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image save OK.")); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return; + } + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open faild")); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image save OK.")); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } -} } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming.ino index d96a84e4..c15292b6 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming/ArduCAM_Mini_5MP_Plus_4CAM_VideoStreaming.ino @@ -9,7 +9,7 @@ // 1. Set the 4 cameras to JPEG output mode. // 2. Read data from Serial port and deal with it // 3. If receive 0x00-0x08,the resolution will be changed. -// 4. If receive 0x15,cameras will capture and buffer the image to FIFO. +// 4. If receive 0x15,cameras will capture and buffer the image to FIFO. // 5. Check the CAP_DONE_MASK bit and write datas to Serial port. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Mini 5MP Plus camera // and use Arduino IDE 1.6.8 compiler or above @@ -18,11 +18,11 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x00 +#define FRAMES_NUM 0x00 // set pin 4,5,6,7 as the slave select for SPI: const int CS1 = 4; @@ -30,343 +30,388 @@ const int CS2 = 5; const int CS3 = 6; const int CS4 = 7; -//the falgs of camera modules -bool cam1=true, cam2=true, cam3=true, cam4=true; -//the flag of JEPG data header +// the falgs of camera modules +bool cam1 = true, cam2 = true, cam3 = true, cam4 = true; +// the flag of JEPG data header bool is_header; -//the falg data of 4 cameras' data -byte flag[5]={0xFF,0xAA,0x01,0xFF,0x55}; +// the falg data of 4 cameras' data +byte flag[5] = {0xFF, 0xAA, 0x01, 0xFF, 0x55}; int count = 0; -#if defined (OV5640_MINI_5MP_PLUS) - ArduCAM myCAM1(OV5640,CS1); - ArduCAM myCAM2(OV5640,CS2); - ArduCAM myCAM3(OV5640,CS3); - ArduCAM myCAM4(OV5640,CS4); +#if defined(OV5640_MINI_5MP_PLUS) +ArduCAM myCAM1(OV5640, CS1); +ArduCAM myCAM2(OV5640, CS2); +ArduCAM myCAM3(OV5640, CS3); +ArduCAM myCAM4(OV5640, CS4); #else - ArduCAM myCAM1(OV5642,CS1); - ArduCAM myCAM2(OV5642,CS2); - ArduCAM myCAM3(OV5642,CS3); - ArduCAM myCAM4(OV5642,CS4); +ArduCAM myCAM1(OV5642, CS1); +ArduCAM myCAM2(OV5642, CS2); +ArduCAM myCAM3(OV5642, CS3); +ArduCAM myCAM4(OV5642, CS4); #endif -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(921600); -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS output: -pinMode(CS1, OUTPUT); -digitalWrite(CS1, HIGH); -pinMode(CS2, OUTPUT); -digitalWrite(CS2, HIGH); -pinMode(CS3, OUTPUT); -digitalWrite(CS3, HIGH); -pinMode(CS4, OUTPUT); -digitalWrite(CS4, HIGH); +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(921600); + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS output: + pinMode(CS1, OUTPUT); + digitalWrite(CS1, HIGH); + pinMode(CS2, OUTPUT); + digitalWrite(CS2, HIGH); + pinMode(CS3, OUTPUT); + digitalWrite(CS3, HIGH); + pinMode(CS4, OUTPUT); + digitalWrite(CS4, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM1.write_reg(0x07, 0x80); -delay(100); -myCAM1.write_reg(0x07, 0x00); -delay(100); -myCAM2.write_reg(0x07, 0x80); -delay(100); -myCAM2.write_reg(0x07, 0x00); -delay(100); -myCAM3.write_reg(0x07, 0x80); -delay(100); -myCAM3.write_reg(0x07, 0x00); -delay(100); -myCAM4.write_reg(0x07, 0x80); -delay(100); -myCAM4.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the 4 ArduCAM Mini 5MP Plus Cameras' SPI bus is OK - myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM1.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println(F("ACK CMD SPI1 interface Error! END")); - cam1 = false; - } - myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM2.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM1.write_reg(0x07, 0x80); + delay(100); + myCAM1.write_reg(0x07, 0x00); + delay(100); + myCAM2.write_reg(0x07, 0x80); + delay(100); + myCAM2.write_reg(0x07, 0x00); + delay(100); + myCAM3.write_reg(0x07, 0x80); + delay(100); + myCAM3.write_reg(0x07, 0x00); + delay(100); + myCAM4.write_reg(0x07, 0x80); + delay(100); + myCAM4.write_reg(0x07, 0x00); + delay(100); + + while (1) { - Serial.println(F("ACK CMD SPI2 interface Error! END")); - cam2 = false; + // Check if the 4 ArduCAM Mini 5MP Plus Cameras' SPI bus is OK + myCAM1.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM1.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI1 interface Error! END")); + cam1 = false; + } + myCAM2.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM2.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI2 interface Error! END")); + cam2 = false; + } + myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM3.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI3 interface Error! END")); + cam3 = false; + } + myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM4.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI4 interface Error! END")); + cam4 = false; + } + if (!(cam1 || cam2 || cam3 || cam4)) + { + delay(1000); + continue; + } + else + break; } - myCAM3.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM3.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) - { - Serial.println(F("ACK CMD SPI3 interface Error! END")); - cam3 = false; - } - myCAM4.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM4.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) +#if defined(OV5640_MINI_5MP_PLUS) + while (1) { - Serial.println(F("ACK CMD SPI4 interface Error! END")); - cam4 = false; - } - if(!(cam1||cam2||cam3||cam4)){ - delay(1000);continue; - }else - break; -} -#if defined (OV5640_MINI_5MP_PLUS) - while(1){ - //Check if the camera module type is OV5640 + // Check if the camera module type is OV5640 myCAM1.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5640 detected. END"));break; - } + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected. END")); + break; + } } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM1.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM1.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } - } + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; + } + } #endif -//Change to JPEG capture mode and initialize the OV5640 module -myCAM1.set_format(JPEG); -myCAM1.InitCAM(); -myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH -myCAM1.clear_fifo_flag(); -myCAM1.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM2.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM3.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM4.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); -myCAM1.clear_fifo_flag(); -myCAM2.clear_fifo_flag(); -myCAM3.clear_fifo_flag(); -myCAM4.clear_fifo_flag(); + // Change to JPEG capture mode and initialize the OV5640 module + myCAM1.set_format(JPEG); + myCAM1.InitCAM(); + myCAM1.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM2.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM3.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM4.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH + myCAM1.clear_fifo_flag(); + myCAM1.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM2.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM3.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM4.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM1.clear_fifo_flag(); + myCAM2.clear_fifo_flag(); + myCAM3.clear_fifo_flag(); + myCAM4.clear_fifo_flag(); } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff,temp_last = 0; -uint8_t start_capture = 0; -uint8_t finish_count; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch(temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + uint8_t start_capture = 0; + uint8_t finish_count; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_320x240 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 1: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_352x288);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_352x288 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 2: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_640x480);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_640x480 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 3: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_800x480);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_800x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_800x480 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 4: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_1024x768);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1024x768 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 5: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_1280x960);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1280x960 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 6: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM1.OV5640_set_JPEG_size(OV5640_1600x1200);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM1.OV5640_set_JPEG_size(OV5640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1600x1200 END")); - #else - myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#else + myCAM1.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - temp=0xff; - break; - #if defined (OV5640_MINI_5MP_PLUS) +#endif + temp = 0xff; + break; +#if defined(OV5640_MINI_5MP_PLUS) case 7: - myCAM1.OV5640_set_JPEG_size(OV5640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); - temp=0xff; - break; + myCAM1.OV5640_set_JPEG_size(OV5640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); + temp = 0xff; + break; case 8: - myCAM1.OV5640_set_JPEG_size(OV5640_2592x1944);delay(1000); - Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); - temp=0xff; - break; - #endif - case 0x10: - if(cam1){ - flag[2]=0x01;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM1); - } - if(cam2){ - flag[2]=0x02;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); + myCAM1.OV5640_set_JPEG_size(OV5640_2592x1944); + delay(1000); + Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); + temp = 0xff; + break; +#endif + case 0x10: + if (cam1) + { + flag[2] = 0x01; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM1); + } + if (cam2) + { + flag[2] = 0x02; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM2); + } + if (cam3) + { + flag[2] = 0x03; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM3); + } + if (cam4) + { + flag[2] = 0x04; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM4); + } + break; + case 0x20: + while (1) + { + if (Serial.available()) + { + temp = Serial.read(); + if (temp == 0x21) + break; + } + if (cam1) + { + flag[2] = 0x01; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM1); + } + if (cam2) + { + flag[2] = 0x02; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM2); + } + if (cam3) + { + flag[2] = 0x03; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM3); + } + if (cam4) + { + + flag[2] = 0x04; // flag of cam1 + for (int m = 0; m < 5; m++) + { + Serial.write(flag[m]); + } + read_fifo_burst(myCAM4); + } + } + break; } - read_fifo_burst(myCAM2); } - if(cam3){ - flag[2]=0x03;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM3); - } - if(cam4){ - flag[2]=0x04;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM4); - } - break; - case 0x20: - while(1){ - if (Serial.available()){ - temp = Serial.read(); - if (temp == 0x21)break; } - if(cam1){ - flag[2]=0x01;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM1); - } - if(cam2){ - flag[2]=0x02;//flag of cam1 - for(int m=0;m<5;m++) - { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM2); - } - if(cam3){ - flag[2]=0x03;//flag of cam1 - for(int m=0;m<5;m++) +uint8_t read_fifo_burst(ArduCAM myCAM) +{ + uint8_t temp, temp_last; + uint32_t length = 0; + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + length--; + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); // read a byte from spi + if (is_header == true) { - Serial.write(flag[m]); + Serial.write(temp); } - read_fifo_burst(myCAM3); - } - if(cam4){ - - flag[2]=0x04;//flag of cam1 - for(int m=0;m<5;m++) + else if ((temp == 0xD8) & (temp_last == 0xFF)) { - Serial.write(flag[m]); - } - read_fifo_burst(myCAM4); - } + Serial.println(F("ACK IMG END")); + is_header = true; + Serial.write(temp_last); + Serial.write(temp); } - break; - + if ((temp == 0xD9) && (temp_last == 0xFF)) + break; + delayMicroseconds(15); } -} -} -uint8_t read_fifo_burst(ArduCAM myCAM) -{ -uint8_t temp,temp_last; -uint32_t length = 0; -myCAM.flush_fifo(); -myCAM.clear_fifo_flag(); -myCAM.start_capture(); -while(!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -length = myCAM.read_fifo_length(); -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -length--; -while( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00);//read a byte from spi - if(is_header == true) - { - Serial.write(temp); - } - else if((temp == 0xD8) & (temp_last == 0xFF)) - { - Serial.println(F("ACK IMG END")); - is_header = true; - Serial.write(temp_last); - Serial.write(temp); - } - if( (temp == 0xD9) && (temp_last == 0xFF) ) - break; - delayMicroseconds(15); -} -myCAM.CS_HIGH(); -is_header = false; -//Clear the capture done flag -myCAM.clear_fifo_flag(); + myCAM.CS_HIGH(); + is_header = false; + // Clear the capture done flag + myCAM.clear_fifo_flag(); } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_LowPowerMode/ArduCAM_Mini_5MP_Plus_LowPowerMode.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_LowPowerMode/ArduCAM_Mini_5MP_Plus_LowPowerMode.ino index 4da75d2c..033902f4 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_LowPowerMode/ArduCAM_Mini_5MP_Plus_LowPowerMode.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_LowPowerMode/ArduCAM_Mini_5MP_Plus_LowPowerMode.ino @@ -16,21 +16,22 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif // set pin 7 as the slave select for the digital pot: const int CS = 7; static uint8_t resolution = 0; -#if defined (OV5640_MINI_5MP_PLUS) - ArduCAM myCAM(OV5640, CS); +#if defined(OV5640_MINI_5MP_PLUS) +ArduCAM myCAM(OV5640, CS); #else - ArduCAM myCAM(OV5642, CS); +ArduCAM myCAM(OV5642, CS); #endif -void setup() { -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -38,202 +39,235 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start!")); -// set the SPI_CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); + Serial.println(F("ACK CMD ArduCAM Start!")); + // set the SPI_CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + while (1) { - Serial.println(F("ACK CMD SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK."));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK.")); + break; + } } -} -#if defined (OV5640_MINI_5MP_PLUS) - while(1){ - //Check if the camera module type is OV5640 +#if defined(OV5640_MINI_5MP_PLUS) + while (1) + { + // Check if the camera module type is OV5640 myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module!")); - delay(1000); continue; - }else{ - Serial.println(F("ACK CMD OV5640 detected.");break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected.");break; } } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5642 detected."));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected.")); + break; } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); -myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); -delay(800); + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + delay(800); } -void loop() { -uint8_t temp = 0xff, temp_last = 0; -uint8_t start_capture = 0; -temp = Serial.read(); -switch(temp) +void loop() { + uint8_t temp = 0xff, temp_last = 0; + uint8_t start_capture = 0; + temp = Serial.read(); + switch (temp) + { case 0: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_320x240); - Serial.println(F("ACK CMD switch to OV5640_320x240"));delay(1000); - #else + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + Serial.println(F("ACK CMD switch to OV5640_320x240")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_320x240); - Serial.println(F("ACK CMD switch to OV5642_320x240"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; + Serial.println(F("ACK CMD switch to OV5642_320x240")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 1: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV5640_MINI_5MP_PLUS) + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV5640_MINI_5MP_PLUS) myCAM.OV5640_set_JPEG_size(OV5640_352x288); - Serial.println(F("ACK CMD switch to OV5640_352x288"));delay(1000); - #else + Serial.println(F("ACK CMD switch to OV5640_352x288")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_640x480); - Serial.println(F("ACK CMD switch to OV5642_640x480"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; + Serial.println(F("ACK CMD switch to OV5642_640x480")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 2: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_640x480); - Serial.println(F("ACK CMD switch to OV5640_640x480"));delay(1000); - #else + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + Serial.println(F("ACK CMD switch to OV5640_640x480")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_1024x768); - Serial.println(F("ACK CMD switch to OV5642_1024x768"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; - case 3: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV5640_MINI_5MP_PLUS) + Serial.println(F("ACK CMD switch to OV5642_1024x768")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; + case 3: + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV5640_MINI_5MP_PLUS) myCAM.OV5640_set_JPEG_size(OV5640_800x480); - Serial.println(F("ACK CMD switch to OV5640_800x480"));delay(1000); - #else + Serial.println(F("ACK CMD switch to OV5640_800x480")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_1280x960); - Serial.println(F("ACK CMD switch to OV5642_1280x960"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; + Serial.println(F("ACK CMD switch to OV5642_1280x960")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 4: - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - temp = 0xff; - #if defined (OV5640_MINI_5MP_PLUS) + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + temp = 0xff; +#if defined(OV5640_MINI_5MP_PLUS) myCAM.OV5640_set_JPEG_size(OV5640_1024x768); - Serial.println(F("ACK CMD switch to OV5640_1024x768"));delay(1000); - #else + Serial.println(F("ACK CMD switch to OV5640_1024x768")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); - Serial.println(F("ACK CMD switch to OV5642_1600x1200"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; + Serial.println(F("ACK CMD switch to OV5642_1600x1200")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 5: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_1280x960); - Serial.println(F("ACK CMD switch to OV5640_1280x960"));delay(1000); - #else + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + Serial.println(F("ACK CMD switch to OV5640_1280x960")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); - Serial.println(F("ACK CMD switch to OV5642_2048x1536"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; + Serial.println(F("ACK CMD switch to OV5642_2048x1536")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 6: - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - temp = 0xff; - #if defined (OV5640_MINI_5MP_PLUS) + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + temp = 0xff; +#if defined(OV5640_MINI_5MP_PLUS) myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); - Serial.println(F("ACK CMD switch to OV5640_1600x1200"));delay(1000); - #else + Serial.println(F("ACK CMD switch to OV5640_1600x1200")); + delay(1000); +#else myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); - Serial.println(F("ACK CMD switch to OV5642_2592x1944"));delay(1000); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; - #if defined (OV5640_MINI_5MP_PLUS) + Serial.println(F("ACK CMD switch to OV5642_2592x1944")); + delay(1000); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; +#if defined(OV5640_MINI_5MP_PLUS) case 7: - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - temp = 0xff; - myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - Serial.println(F("ACK CMD switch to OV5640_2048x1536"));delay(1000); - break; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + temp = 0xff; + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + Serial.println(F("ACK CMD switch to OV5640_2048x1536")); + delay(1000); + break; case 8: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); - Serial.println(F("ACK CMD switch to OV5640_2592x1944")); - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK);delay(1000); - break; - #endif + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + Serial.println(F("ACK CMD switch to OV5640_2592x1944")); + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + delay(1000); + break; +#endif case 0x10: - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shot.")); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - delay(800); - break; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shot.")); + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + delay(800); + break; default: - break; -} -if(start_capture == 1) -{ - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - myCAM.start_capture(); - start_capture = 0; -} - if(myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + break; + } + if (start_capture == 1) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + myCAM.start_capture(); + start_capture = 0; + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { Serial.println(F("ACK CMD CAM Capture Done.")); temp = 0; Serial.println(F("ACK IMG")); - while( (temp != 0xD9) | (temp_last != 0xFF) ) + while ((temp != 0xD9) | (temp_last != 0xFF)) { temp_last = temp; temp = myCAM.read_fifo(); Serial.write(temp); delayMicroseconds(15); } - //Clear the capture done flag - myCAM.clear_fifo_flag(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino index 1a9a00d5..9f7f932f 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD/ArduCAM_Mini_5MP_Plus_Multi_Capture2SD.ino @@ -8,16 +8,16 @@ // 2. Capture a JPEG photo and buffer the image to FIFO // 3.Write the picture data to the SD card // 5.close the file -//You can change the FRAMES_NUM count to change the number of the picture. -//IF the FRAMES_NUM is 0X00, take one photos -//IF the FRAMES_NUM is 0X01, take two photos -//IF the FRAMES_NUM is 0X02, take three photos -//IF the FRAMES_NUM is 0X03, take four photos -//IF the FRAMES_NUM is 0X04, take five photos -//IF the FRAMES_NUM is 0X05, take six photos -//IF the FRAMES_NUM is 0X06, take seven photos -//IF the FRAMES_NUM is 0XFF, continue shooting until the FIFO is full -//You can see the picture in the SD card. +// You can change the FRAMES_NUM count to change the number of the picture. +// IF the FRAMES_NUM is 0X00, take one photos +// IF the FRAMES_NUM is 0X01, take two photos +// IF the FRAMES_NUM is 0X02, take three photos +// IF the FRAMES_NUM is 0X03, take four photos +// IF the FRAMES_NUM is 0X04, take five photos +// IF the FRAMES_NUM is 0X05, take six photos +// IF the FRAMES_NUM is 0X06, take seven photos +// IF the FRAMES_NUM is 0XFF, continue shooting until the FIFO is full +// You can see the picture in the SD card. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM_Mini_5MP_Plus // and use Arduino IDE 1.6.8 compiler or above @@ -26,205 +26,229 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x06 +#define FRAMES_NUM 0x06 // set pin 7 as the slave select for the digital pot: const int CS = 7; #define SD_CS 9 bool is_header = false; int total_time = 0; -#if defined (OV5640_MINI_5MP_PLUS) - ArduCAM myCAM(OV5640, CS); +#if defined(OV5640_MINI_5MP_PLUS) +ArduCAM myCAM(OV5640, CS); #else - ArduCAM myCAM(OV5642, CS); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + while (1) { - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -#if defined (OV5640_MINI_5MP_PLUS) -while(1){ - //Check if the camera module type is OV5640 - myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ - Serial.println(F("Can't find OV5640 module!")); - delay(1000); continue; - }else{ - Serial.println(F("OV5640 detected."));break; +#if defined(OV5640_MINI_5MP_PLUS) + while (1) + { + // Check if the camera module type is OV5640 + myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x40)) + { + Serial.println(F("Can't find OV5640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -} #else -while(1){ - //Check if the camera module type is OV5642 - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5642 detected."));break; + while (1) + { + // Check if the camera module type is OV5642 + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; + } } -} #endif -//Initialize SD Card -while(!SD.begin(SD_CS)) -{ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); -//Change to JPEG capture mode and initialize the OV5640 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); + // Change to JPEG capture mode and initialize the OV5640 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); } -void loop() { -// put your main code here, to run repeatedly: -myCAM.flush_fifo(); -myCAM.clear_fifo_flag(); -#if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); +void loop() +{ + // put your main code here, to run repeatedly: + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -//Start capture -myCAM.start_capture(); -Serial.println(F("start capture.")); -total_time = millis(); -while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -Serial.println(F("CAM Capture Done.")); -total_time = millis() - total_time; -Serial.print(F("capture total_time used (in miliseconds):")); -Serial.println(total_time, DEC); -total_time = millis(); -read_fifo_burst(myCAM); -total_time = millis() - total_time; -Serial.print(F("save capture total_time used (in miliseconds):")); -Serial.println(total_time, DEC); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -delay(5000); + // Start capture + myCAM.start_capture(); + Serial.println(F("start capture.")); + total_time = millis(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; + Serial.print(F("capture total_time used (in miliseconds):")); + Serial.println(total_time, DEC); + total_time = millis(); + read_fifo_burst(myCAM); + total_time = millis() - total_time; + Serial.print(F("save capture total_time used (in miliseconds):")); + Serial.println(total_time, DEC); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + delay(5000); } uint8_t read_fifo_burst(ArduCAM myCAM) { -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -static int i = 0; -static int k = 0; -char str[8]; -File outFile; -byte buf[256]; -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //8M -{ - Serial.println("Over size."); - return 0; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return 0; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -i = 0; -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + static int i = 0; + static int k = 0; + char str[8]; + File outFile; + byte buf[256]; + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("OK")); - is_header = false; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println("Over size."); + return 0; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return 0; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + i = 0; + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); - i = 0; - buf[i++] = temp; + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("OK")); + is_header = false; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - } - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - myCAM.CS_HIGH(); - //Create a avi file - k = k + 1; - itoa(k, str, 10); - strcat(str, ".jpg"); - //Open the new file - outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) { - Serial.println(F("File open failed")); - while (1); + is_header = true; + myCAM.CS_HIGH(); + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open failed")); + while (1) + ; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + buf[i++] = temp_last; + buf[i++] = temp; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - buf[i++] = temp_last; - buf[i++] = temp; } -} myCAM.CS_HIGH(); return 1; } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_OV5642_RAW/ArduCAM_Mini_5MP_Plus_OV5642_RAW.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_OV5642_RAW/ArduCAM_Mini_5MP_Plus_OV5642_RAW.ino index 4a7cb10d..758abb16 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_OV5642_RAW/ArduCAM_Mini_5MP_Plus_OV5642_RAW.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_OV5642_RAW/ArduCAM_Mini_5MP_Plus_OV5642_RAW.ino @@ -1,9 +1,9 @@ // ArduCAM demo (C)2017 Lee // Web: http://www.ArduCAM.com // This program is a demo of how to capture image in RAW format -// 1. Capture and buffer the image to FIFO every 5 seconds +// 1. Capture and buffer the image to FIFO every 5 seconds // 2. Store the image to Micro SD/TF card with RAW format. -//3. You can change the resolution by change the "resolution = OV5642_640x480" +// 3. You can change the resolution by change the "resolution = OV5642_640x480" // This program requires the ArduCAM V4.0.0 (or above) library and ArduCAM shield V2 // and use Arduino IDE 1.6.8 compiler or above #include @@ -11,139 +11,167 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -#define FRAMES_NUM 0x00 +#define FRAMES_NUM 0x00 // set pin 7 as the slave select for the digital pot: const int CS = 7; #define SD_CS 9 bool is_header = false; int total_time = 0; uint8_t resolution = OV5642_2592x1944; -uint32_t line,column; - ArduCAM myCAM(OV5642, CS); +uint32_t line, column; +ArduCAM myCAM(OV5642, CS); uint8_t saveRAW(void); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp ; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); #else Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) { - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -while(1){ - //Check if the camera module type is OV5642 - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5642 detected."));break; + while (1) + { + // Check if the camera module type is OV5642 + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)) -{ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); -//Change to JPEG capture mode and initialize the OV5640 module -myCAM.set_format(RAW); -myCAM.InitCAM(); -myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); + // Change to JPEG capture mode and initialize the OV5640 module + myCAM.set_format(RAW); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); } -void loop() { - File outFile; - char VL; - char str[8]; - byte buf[256]; - static int k = 0,m = 0; - int i,j = 0; -// put your main code here, to run repeatedly: +void loop() +{ + File outFile; + char VL; + char str[8]; + byte buf[256]; + static int k = 0, m = 0; + int i, j = 0; + // put your main code here, to run repeatedly: myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - myCAM.OV5642_set_RAW_size(resolution);delay(1000); -//Start capture -myCAM.start_capture(); -Serial.println(F("start capture.")); -total_time = millis(); -while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); -Serial.println(F("CAM Capture Done.")); -total_time = millis() - total_time; -Serial.print(F("capture total_time used (in miliseconds):")); -Serial.println(total_time, DEC); -Serial.println("Saving the image,please waitting..."); -total_time = millis(); - k = k + 1; - itoa(k, str, 10); - strcat(str,".raw"); //Generate file name - outFile = SD.open(str,O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) - { - Serial.println(F("File open error")); - return; - } - if(resolution == OV5642_640x480 ){ - line = 640;column = 480; - }else if( resolution == OV5642_1280x960 ){ - line = 1280;column = 960; - }else if( resolution == OV5642_1920x1080 ){ - line = 1920;column = 1080; - }else if( resolution == OV5642_2592x1944 ){ - line = 2592;column = 1944; - } - //Save as RAW format - for(i = 0; i < line; i++) - for(j = 0; j < column; j++) + myCAM.OV5642_set_RAW_size(resolution); + delay(1000); + // Start capture + myCAM.start_capture(); + Serial.println(F("start capture.")); + total_time = millis(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; + Serial.print(F("capture total_time used (in miliseconds):")); + Serial.println(total_time, DEC); + Serial.println("Saving the image,please waitting..."); + total_time = millis(); + k = k + 1; + itoa(k, str, 10); + strcat(str, ".raw"); // Generate file name + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open error")); + return; + } + if (resolution == OV5642_640x480) + { + line = 640; + column = 480; + } + else if (resolution == OV5642_1280x960) + { + line = 1280; + column = 960; + } + else if (resolution == OV5642_1920x1080) + { + line = 1920; + column = 1080; + } + else if (resolution == OV5642_2592x1944) + { + line = 2592; + column = 1944; + } + // Save as RAW format + for (i = 0; i < line; i++) + for (j = 0; j < column; j++) { VL = myCAM.read_fifo(); buf[m++] = VL; - if(m >= 256) + if (m >= 256) { - //Write 256 bytes image data to file from buffer - outFile.write(buf,256); + // Write 256 bytes image data to file from buffer + outFile.write(buf, 256); m = 0; } } - if(m > 0 )//Write the left image data to file from buffer - outFile.write( buf, m );m = 0; - //Close the file - outFile.close(); - Serial.println("Image save OK."); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -delay(5000); + if (m > 0) // Write the left image data to file from buffer + outFile.write(buf, m); + m = 0; + // Close the file + outFile.close(); + Serial.println("Image save OK."); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + delay(5000); } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Video_Streaming/ArduCAM_Mini_5MP_Plus_Video_Streaming.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Video_Streaming/ArduCAM_Mini_5MP_Plus_Video_Streaming.ino index 1d7ef761..08cd02a9 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Video_Streaming/ArduCAM_Mini_5MP_Plus_Video_Streaming.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_Video_Streaming/ArduCAM_Mini_5MP_Plus_Video_Streaming.ino @@ -21,35 +21,35 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV5640_MINI_5MP_PLUS) - ArduCAM myCAM(OV5640, CS); +#if defined(OV5640_MINI_5MP_PLUS) +ArduCAM myCAM(OV5640, CS); #else - ArduCAM myCAM(OV5642, CS); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -57,362 +57,398 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) { - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV5640_MINI_5MP_PLUS) - while(1){ - //Check if the camera module type is OV5640 +#if defined(OV5640_MINI_5MP_PLUS) + while (1) + { + // Check if the camera module type is OV5640 myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ + if ((vid != 0x56) || (pid != 0x40)) + { Serial.println(F("ACK CMD Can't find OV5640 module! END")); - delay(1000); continue; - }else{ - Serial.println(F("ACK CMD OV5640 detected. END"));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5640 detected. END")); + break; } } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); -myCAM.clear_fifo_flag(); -myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.clear_fifo_flag(); + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); } -void loop() { -uint8_t temp= 0xff, temp_last =0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_320x240 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 1: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_352x288);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_352x288 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 2: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_640x480);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_640x480 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 3: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_800x480);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_800x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_800x480 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 4: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_1024x768);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1024x768 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 5: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_1280x960);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1280x960 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - temp=0xff; - break; +#endif + temp = 0xff; + break; case 6: - #if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_1600x1200);delay(1000); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_1600x1200 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - temp=0xff; - break; - #if defined (OV5640_MINI_5MP_PLUS) - case 7: - myCAM.OV5640_set_JPEG_size(OV5640_2048x1536);delay(1000); +#endif + temp = 0xff; + break; +#if defined(OV5640_MINI_5MP_PLUS) + case 7: + myCAM.OV5640_set_JPEG_size(OV5640_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2048x1536 END")); - temp=0xff; + temp = 0xff; break; - case 8: - myCAM.OV5640_set_JPEG_size(OV5640_2592x1944);delay(1000); + case 8: + myCAM.OV5640_set_JPEG_size(OV5640_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5640_2592x1944 END")); - temp=0xff; + temp = 0xff; break; - #endif +#endif case 0x10: - mode = 1; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 1; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x11: - myCAM.set_format(JPEG); - myCAM.InitCAM(); - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - break; + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + break; case 0x20: - mode = 2; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + mode = 2; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; default: - break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; + break; + } } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + if (mode == 1) { - Serial.println(F("ACK CMD CAM Capture Done. END")); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); + if (start_capture == 1) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + start_capture = 0; + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + Serial.println(F("ACK CMD CAM Capture Done. END")); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } } -} -else if (mode == 2) -{ - while (1) + else if (mode == 2) { - temp = Serial.read(); - if (temp == 0x21) + while (1) { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); - break; + temp = Serial.read(); + if (temp == 0x21) + { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + start_capture = 0; + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) + { + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); + } + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; + } } - if (start_capture == 2) + } + else if (mode == 3) + { + if (start_capture == 3) { + // Flush the FIFO myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; uint32_t length = 0; length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + if (length >= MAX_FIFO_SIZE) { + Serial.println(F("ACK CMD Over size. END")); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) - { - Serial.write(temp); - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + Serial.write(pgm_read_byte(&bmp_header[temp])); + } + // SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) { - is_header = true; - Serial.println(F("ACK IMG")); - Serial.write(temp_last); - Serial.write(temp); + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); } + Serial.write(0xBB); + Serial.write(0xCC); myCAM.CS_HIGH(); + // Clear the capture done flag myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } } -else if (mode == 3) +uint8_t read_fifo_burst(ArduCAM myCAM) { - if (start_capture == 3) + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 512 kb { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; + Serial.println(F("ACK CMD Over size. END")); + return 0; } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + if (length == 0) // 0 kb { - Serial.println(F("ACK CMD CAM Capture Done. END")); - delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) - { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb - { - Serial.println(F("ACK CMD Size is 0. END")); - myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + Serial.println(F("ACK CMD Size is 0.")); + return 0; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) { - Serial.write(pgm_read_byte(&bmp_header[temp])); + Serial.write(temp); } - // SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + else if ((temp == 0xD8) & (temp_last == 0xFF)) { - for (j = 0; j < 320; j++) - { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); - } - } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(5); } -} -uint8_t read_fifo_burst(ArduCAM myCAM) -{ -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -length = myCAM.read_fifo_length(); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //512 kb -{ - Serial.println(F("ACK CMD Over size. END")); - return 0; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("ACK CMD Size is 0.")); - return 0; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) - { - Serial.write(temp); - } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); - } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(5); -} -myCAM.CS_HIGH(); -is_header = false; -return 1; + myCAM.CS_HIGH(); + is_header = false; + return 1; } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_short_movie_clip/ArduCAM_Mini_5MP_Plus_short_movie_clip.ino b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_short_movie_clip/ArduCAM_Mini_5MP_Plus_short_movie_clip.ino index dc836217..1432b32e 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_short_movie_clip/ArduCAM_Mini_5MP_Plus_short_movie_clip.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_5MP_Plus_short_movie_clip/ArduCAM_Mini_5MP_Plus_short_movie_clip.ino @@ -3,7 +3,7 @@ // This demo was made for ArduCAM_Mini_5MP_Plus. // It can continue shooting and store it into the SD card in AVI format // The demo sketch will do the following tasks -// 1.Shoot video button, began to shoot video +// 1.Shoot video button, began to shoot video // 2. Set the camera to JPEG output mode. // 3. Capture a JPEG photo and buffer the image to FIFO // 4.Write AVI Header @@ -17,7 +17,7 @@ // 0C-0F :The first list of identification number // 10-13 :The size of the first list // 14-17 :The hdr1 of identification -// 18-1B :Hdr1 contains avih piece of identification +// 18-1B :Hdr1 contains avih piece of identification // 1C-1F :The size of the avih // 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM_Mini_5MP_Plus @@ -27,319 +27,581 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. -#if !(defined (OV5640_MINI_5MP_PLUS)||defined (OV5642_MINI_5MP_PLUS)) +// This demo can only work on OV5640_MINI_5MP_PLUS or OV5642_MINI_5MP_PLUS platform. +#if !(defined(OV5640_MINI_5MP_PLUS) || defined(OV5642_MINI_5MP_PLUS)) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif - -#define rate 0x0a +#define rate 0x0a #define SD_CS 9 #define KEY 2 #define AVIOFFSET 240 // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; -uint8_t FRAMES_NUM = 0x07; +uint8_t FRAMES_NUM = 0x07; uint8_t cameraVersion = 0; uint32_t total_time = 0; unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; -const int avi_header[AVIOFFSET] PROGMEM ={ - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, rate, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, +const int avi_header[AVIOFFSET] PROGMEM = { + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x80, + 0x02, + 0x00, + 0x00, + 0xe0, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + rate, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + 0x80, + 0x02, + 0x00, + 0x00, + 0xe0, + 0x01, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -void print_quartet(unsigned long i,File fd){ - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; +void print_quartet(unsigned long i, File fd) +{ + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } -#if defined (OV5640_MINI_5MP_PLUS) - ArduCAM myCAM(OV5640, CS); +#if defined(OV5640_MINI_5MP_PLUS) +ArduCAM myCAM(OV5640, CS); #else - ArduCAM myCAM(OV5642, CS); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) -Wire1.begin(); + Wire1.begin(); #else -Wire.begin(); + Wire.begin(); #endif -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -pinMode(SD_CS, OUTPUT); -pinMode(KEY, INPUT); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + pinMode(SD_CS, OUTPUT); + pinMode(KEY, INPUT); + // initialize SPI: + SPI.begin(); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if(temp != 0x55) + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) { - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -#if defined (OV5640_MINI_5MP_PLUS) -while(1){ - //Check if the camera module type is OV5640 - myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x40)){ - Serial.println(F("Can't find OV5640 module!")); - delay(1000); continue; - }else{ - Serial.println(F("OV5640 detected."));break; +#if defined(OV5640_MINI_5MP_PLUS) + while (1) + { + // Check if the camera module type is OV5640 + myCAM.rdSensorReg16_8(OV5640_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5640_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x40)) + { + Serial.println(F("Can't find OV5640 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5640 detected.")); + break; + } } -} #else -while(1){ - //Check if the camera module type is OV5642 - myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); - myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)){ - Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV5642 detected."));break; + while (1) + { + // Check if the camera module type is OV5642 + myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); + myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); + if ((vid != 0x56) || (pid != 0x42)) + { + Serial.println(F("Can't find OV5642 module!")); + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; + } } -} #endif -//Initialize SD Card -while(!SD.begin(SD_CS)) -{ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); -//Change to JPEG capture mode and initialize the OV5640 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); -#if defined (OV5640_MINI_5MP_PLUS) - myCAM.OV5640_set_JPEG_size(OV5640_320x240);delay(1000); + // Change to JPEG capture mode and initialize the OV5640 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#if defined(OV5640_MINI_5MP_PLUS) + myCAM.OV5640_set_JPEG_size(OV5640_320x240); + delay(1000); #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); #endif -myCAM.clear_fifo_flag(); -cameraVersion = myCAM.read_reg(0x40); -Serial.print("The camera version is :"); -Serial.println(cameraVersion, HEX); -if(cameraVersion &&0x70){ - FRAMES_NUM = 0xFF; - }else{ + myCAM.clear_fifo_flag(); + cameraVersion = myCAM.read_reg(0x40); + Serial.print("The camera version is :"); + Serial.println(cameraVersion, HEX); + if (cameraVersion && 0x70) + { + FRAMES_NUM = 0xFF; + } + else + { FRAMES_NUM = 0x07; - } + } -myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); + myCAM.write_reg(ARDUCHIP_FRAMES, FRAMES_NUM); } boolean isCaptureFlag = false; bool keyState; uint8_t temp, temp_last; uint32_t length = 0; uint32_t flash_time = 0; -void loop() { -// put your main code here, to run repeatedly: -keyState= digitalRead(KEY); -if(!keyState) { - isCaptureFlag = true; - while(!digitalRead(KEY)); -} -if(isCaptureFlag){ - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - Serial.println(F("start capture.")); - total_time = millis(); - flash_time =millis(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); - length = myCAM.read_fifo_length(); - if( length < 0x3FFFFF){ +void loop() +{ + // put your main code here, to run repeatedly: + keyState = digitalRead(KEY); + if (!keyState) + { + isCaptureFlag = true; + while (!digitalRead(KEY)) + ; + } + if (isCaptureFlag) + { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); - while ( !myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)); - Serial.println(F("CAM Capture Done.")); - total_time = millis() - total_time; - }else{ - Serial.println(F("CAM Capture Done.")); + Serial.println(F("start capture.")); + total_time = millis(); + flash_time = millis(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); + if (length < 0x3FFFFF) + { + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; + } + else + { + Serial.println(F("CAM Capture Done.")); + total_time = millis() - total_time; + } + total_time = millis(); + read_fifo_burst(); total_time = millis() - total_time; + // Clear the capture done flag + myCAM.clear_fifo_flag(); + isCaptureFlag = false; } - total_time = millis(); - read_fifo_burst(); - total_time = millis() - total_time; - //Clear the capture done flag - myCAM.clear_fifo_flag(); - isCaptureFlag = false; -} } uint8_t read_fifo_burst() -{ -uint8_t temp = 0, temp_last = 0; -uint32_t length = 0; -static int i = 0; -static int k = 0; -unsigned long position = 0; -uint16_t frame_cnt = 0; -uint8_t remnant = 0; -File outFile; -char str[8]; -byte buf[256]; -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -// Serial.println("writting the data to the SD !"); -if (length >= MAX_FIFO_SIZE) //8M { - Serial.println(F("Over size.")); - return 0; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return 0; -} -movi_size = 0; -//Create a avi file -k = k + 1; -itoa(k, str, 10); -strcat(str, ".avi"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if (! outFile) -{ - Serial.println(F("open file failed")); - while (1); -} -//Write AVI Header -for ( i = 0; i < AVIOFFSET; i++) -{ - char ch = pgm_read_byte(&avi_header[i]); - buf[i] = ch; -} -outFile.write(buf, AVIOFFSET); -myCAM.CS_LOW(); -myCAM.set_fifo_burst();//Set fifo burst mode -i = 0; -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + static int i = 0; + static int k = 0; + unsigned long position = 0; + uint16_t frame_cnt = 0; + uint8_t remnant = 0; + File outFile; + char str[8]; + byte buf[256]; + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + // Serial.println("writting the data to the SD !"); + if (length >= MAX_FIFO_SIZE) // 8M { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - jpeg_size += i; - remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; - jpeg_size = jpeg_size + remnant; - movi_size = movi_size + jpeg_size; - if (remnant > 0) - outFile.write(zero_buf, remnant); - position = outFile.position(); - outFile.seek(position - 4 - jpeg_size); - print_quartet(jpeg_size, outFile); - position = outFile.position(); - outFile.seek(position + 6); - outFile.write("AVI1", 4); - position = outFile.position(); - outFile.seek(position + jpeg_size - 10); - is_header = false; - frame_cnt++; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return 0; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return 0; + } + movi_size = 0; + // Create a avi file + k = k + 1; + itoa(k, str, 10); + strcat(str, ".avi"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("open file failed")); + while (1) + ; + } + // Write AVI Header + for (i = 0; i < AVIOFFSET; i++) + { + char ch = pgm_read_byte(&avi_header[i]); + buf[i] = ch; + } + outFile.write(buf, AVIOFFSET); + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + i = 0; + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + jpeg_size += i; + remnant = (4 - (jpeg_size & 0x00000003)) & 0x00000003; + jpeg_size = jpeg_size + remnant; + movi_size = movi_size + jpeg_size; + if (remnant > 0) + outFile.write(zero_buf, remnant); + position = outFile.position(); + outFile.seek(position - 4 - jpeg_size); + print_quartet(jpeg_size, outFile); + position = outFile.position(); + outFile.seek(position + 6); + outFile.write("AVI1", 4); + position = outFile.position(); + outFile.seek(position + jpeg_size - 10); + is_header = false; + frame_cnt++; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + jpeg_size += 256; + } + } + else if ((temp == 0xD8) && (temp_last == 0xFF)) + { + is_header = true; + myCAM.CS_HIGH(); + outFile.write("00dc"); + outFile.write(zero_buf, 4); i = 0; - buf[i++] = temp; + jpeg_size = 0; myCAM.CS_LOW(); myCAM.set_fifo_burst(); - jpeg_size += 256; - } - } - else if ((temp == 0xD8) && (temp_last == 0xFF)) - { - is_header = true; - myCAM.CS_HIGH(); - outFile.write("00dc"); - outFile.write(zero_buf, 4); - i = 0; - jpeg_size = 0; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - buf[i++] = temp_last; - buf[i++] = temp; + buf[i++] = temp_last; + buf[i++] = temp; + } } -} -myCAM.CS_HIGH(); -//Modify the MJPEG header from the beginning of the file -outFile.seek(4); -print_quartet(movi_size +12*frame_cnt+4, outFile);//riff file size -//overwrite hdrl -unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame -outFile.seek(0x20); -print_quartet(us_per_frame, outFile); -unsigned long max_bytes_per_sec = movi_size * rate/ frame_cnt; //hdrl.avih.max_bytes_per_sec -outFile.seek(0x24); -print_quartet(max_bytes_per_sec, outFile); -unsigned long tot_frames = frame_cnt; //hdrl.avih.tot_frames -outFile.seek(0x30); -print_quartet(tot_frames, outFile); -unsigned long frames =frame_cnt;// (TOTALFRAMES); //hdrl.strl.list_odml.frames -outFile.seek(0xe0); -print_quartet(frames, outFile); -outFile.seek(0xe8); -print_quartet(movi_size, outFile);// size again -//Close the file -outFile.close(); -is_header = false; -Serial.println(F("Movie save OK")); -return 1; + myCAM.CS_HIGH(); + // Modify the MJPEG header from the beginning of the file + outFile.seek(4); + print_quartet(movi_size + 12 * frame_cnt + 4, outFile); // riff file size + // overwrite hdrl + unsigned long us_per_frame = 1000000 / rate; //(per_usec); //hdrl.avih.us_per_frame + outFile.seek(0x20); + print_quartet(us_per_frame, outFile); + unsigned long max_bytes_per_sec = movi_size * rate / frame_cnt; // hdrl.avih.max_bytes_per_sec + outFile.seek(0x24); + print_quartet(max_bytes_per_sec, outFile); + unsigned long tot_frames = frame_cnt; // hdrl.avih.tot_frames + outFile.seek(0x30); + print_quartet(tot_frames, outFile); + unsigned long frames = frame_cnt; // (TOTALFRAMES); //hdrl.strl.list_odml.frames + outFile.seek(0xe0); + print_quartet(frames, outFile); + outFile.seek(0xe8); + print_quartet(movi_size, outFile); // size again + // Close the file + outFile.close(); + is_header = false; + Serial.println(F("Movie save OK")); + return 1; } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD/ArduCAM_Mini_Capture2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD/ArduCAM_Mini_Capture2SD.ino index a2c71580..455d1c41 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD/ArduCAM_Mini_Capture2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_Capture2SD/ArduCAM_Mini_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM 2MP/5MP as a real 2MP/5MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO every 5 seconds +// 2. Capture and buffer the image to FIFO every 5 seconds // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM 2MP/5MP shield @@ -17,197 +17,224 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. #if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define SD_CS 9 const int SPI_CS = 7; -#if defined (OV2640_MINI_2MP) - ArduCAM myCAM( OV2640, SPI_CS ); -#elif defined (OV3640_MINI_3MP) - ArduCAM myCAM( OV3640, SPI_CS ); +#if defined(OV2640_MINI_2MP) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_MINI_3MP) +ArduCAM myCAM(OV3640, SPI_CS); #else - ArduCAM myCAM( OV5642, SPI_CS ); +ArduCAM myCAM(OV5642, SPI_CS); #endif -void myCAMSaveToSDFile(){ -char str[8]; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0,temp_last=0; -uint32_t length = 0; -bool is_header = false; -File outFile; -//Flush the FIFO -myCAM.flush_fifo(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Start capture -myCAM.start_capture(); -Serial.println(F("start Capture")); -while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //384K +void myCAMSaveToSDFile() { - Serial.println(F("Over size.")); - return ; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return ; -} -//Construct a file name -k = k + 1; -itoa(k, str, 10); -strcat(str, ".jpg"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if(!outFile){ - Serial.println(F("File open faild")); - return; -} -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -while ( length-- ) -{ - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + char str[8]; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + bool is_header = false; + File outFile; + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("start Capture")); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 384K { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image save OK.")); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return; + } + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open faild")); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image save OK.")); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } -} } -void setup(){ -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -//set the CS as an output: -pinMode(SPI_CS,OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; } - else{ - Serial.println(F("OV2640 detected."));break; - } } -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV3640 +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; + delay(1000); + continue; } - } + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } - else{ - Serial.println(F("OV5642 detected."));break; - } } #endif -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP) + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP) myCAM.OV2640_set_JPEG_size(OV2640_320x240); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) myCAM.OV3640_set_JPEG_size(OV3640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); + delay(1000); } -void loop(){ -myCAMSaveToSDFile(); -delay(5000); +void loop() +{ + myCAMSaveToSDFile(); + delay(5000); } - - diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_LowPowerMode/ArduCAM_Mini_LowPowerMode.ino b/ArduCAM/examples/mini/ArduCAM_Mini_LowPowerMode/ArduCAM_Mini_LowPowerMode.ino index 96e8f0dd..6ceccd52 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_LowPowerMode/ArduCAM_Mini_LowPowerMode.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_LowPowerMode/ArduCAM_Mini_LowPowerMode.ino @@ -17,21 +17,22 @@ #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. -#if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP|| defined OV3640_MINI_3MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +#if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif const int SPI_CS = 7; -#if defined (OV2640_MINI_2MP) - ArduCAM myCAM( OV2640, SPI_CS ); -#elif defined (OV3640_MINI_3MP) - ArduCAM myCAM( OV3640, SPI_CS ); +#if defined(OV2640_MINI_2MP) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_MINI_3MP) +ArduCAM myCAM(OV3640, SPI_CS); #else - ArduCAM myCAM( OV5642, SPI_CS ); +ArduCAM myCAM(OV5642, SPI_CS); #endif -void setup() { -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -39,259 +40,308 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the SPI_CS as an output: -pinMode(SPI_CS, OUTPUT); -digitalWrite(SPI_CS, HIGH); -// initialize SPI: -SPI.begin(); - -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); - -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the SPI_CS as an output: + pinMode(SPI_CS, OUTPUT); + digitalWrite(SPI_CS, HIGH); + // initialize SPI: + SPI.begin(); + + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; - } } -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV3640 +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("ACK CMD Can't find OV3640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV3640 detected. END"));break; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV3640 detected. END")); + break; } - } + } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP) myCAM.OV2640_set_JPEG_size(OV2640_320x240); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) myCAM.OV3640_set_JPEG_size(OV3640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -myCAM.clear_fifo_flag(); -#if !(defined (OV2640_MINI_2MP)) - myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + myCAM.clear_fifo_flag(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); #endif -myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); } -void loop() { -uint8_t temp = 0xff, temp_last = 0; -uint8_t start_capture = 0; -temp = Serial.read(); -switch(temp) +void loop() { + uint8_t temp = 0xff, temp_last = 0; + uint8_t start_capture = 0; + temp = Serial.read(); + switch (temp) + { case 0: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_176x144);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_160x120 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 1: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_320x240 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_320x240 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; - +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; + case 2: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_352x288);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_352x288 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; - + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_320x240 END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_352x288 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; + case 3: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_640x480);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_640x480 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_352x288 END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_640x480 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; - +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; + case 4: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_800x600);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_800x600 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_800x600 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 5: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_1024x768 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_800x600 END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_1024x768 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; - +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; + case 6: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_1280x960 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_1280x960 END")); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 7: - temp = 0xff; - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); + temp = 0xff; + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - #else - myCAM.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000); +#else + myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1600x1200 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 8: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200")); - #else - myCAM.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); - #endif - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - break; + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200")); +#else + myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); +#endif + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + break; case 0x10: - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shot. END")); - myCAM.clear_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - delay(800); - break; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shot. END")); + myCAM.clear_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + delay(800); + break; default: - break; -} -if(start_capture == 1) -{ - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; -} -if(myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) -{ - myCAM.set_bit(ARDUCHIP_GPIO,GPIO_PWDN_MASK); - Serial.println(F("ACK CMD CAM Capture Done. END"));delay(50); - temp = 0; - Serial.println(F("ACK IMG END")); - while( (temp != 0xD9) | (temp_last != 0xFF) ) + break; + } + if (start_capture == 1) { - temp_last = temp; - temp = myCAM.read_fifo(); - Serial.write(temp); - delayMicroseconds(10); + myCAM.flush_fifo(); + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + start_capture = 0; + } + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + { + myCAM.set_bit(ARDUCHIP_GPIO, GPIO_PWDN_MASK); + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + temp = 0; + Serial.println(F("ACK IMG END")); + while ((temp != 0xD9) | (temp_last != 0xFF)) + { + temp_last = temp; + temp = myCAM.read_fifo(); + Serial.write(temp); + delayMicroseconds(10); + } + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - //Clear the capture done flag - myCAM.clear_fifo_flag(); -} } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_PIR_Trig_Capture2SD/ArduCAM_Mini_PIR_Trig_Capture2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_PIR_Trig_Capture2SD/ArduCAM_Mini_PIR_Trig_Capture2SD.ino index ea028db9..ca07b3ff 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_PIR_Trig_Capture2SD/ArduCAM_Mini_PIR_Trig_Capture2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_PIR_Trig_Capture2SD/ArduCAM_Mini_PIR_Trig_Capture2SD.ino @@ -7,7 +7,7 @@ // It will run the ArduCAM 2MP/5MP as a real 2MP/5MP digital camera, provide both JPEG capture. // The demo sketch will do the following tasks: // 1. Set the sensor to JPEG mode. -// 2. Capture and buffer the image to FIFO When the PIR sensor detects the rising edge signal +// 2. Capture and buffer the image to FIFO When the PIR sensor detects the rising edge signal // 3. Store the image to Micro SD/TF card with JPEG format in sequential. // 4. Resolution can be changed by myCAM.set_JPEG_size() function. // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM 2MP/5MP shield @@ -15,218 +15,244 @@ /***************Hardware Connection******************/ /* - UNO PIR - VCC VCC - 4 S - GND GND + UNO PIR + VCC VCC + 4 S + GND GND ***************************************************/ - #include #include #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. #if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define SD_CS 9 #define HCSR 4 const int SPI_CS = 7; -#if defined (OV2640_MINI_2MP) - ArduCAM myCAM( OV2640, SPI_CS ); -#elif defined (OV3640_MINI_3MP) - ArduCAM myCAM( OV3640, SPI_CS ); +#if defined(OV2640_MINI_2MP) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_MINI_3MP) +ArduCAM myCAM(OV3640, SPI_CS); #else - ArduCAM myCAM( OV5642, SPI_CS ); +ArduCAM myCAM(OV5642, SPI_CS); #endif int read_HCSR501() { - static int val; - pinMode(HCSR, INPUT); - return( digitalRead(HCSR)); -} -void myCAMSaveToSDFile(){ -char str[8]; -byte buf[256]; -static int i = 0; -static int k = 0; -uint8_t temp = 0,temp_last=0; -uint32_t length = 0; -bool is_header = false; -File outFile; -//Flush the FIFO -myCAM.flush_fifo(); -//Clear the capture done flag -myCAM.clear_fifo_flag(); -//Start capture -myCAM.start_capture(); -Serial.println(F("start Capture")); -while(!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); -Serial.println(F("Capture Done.")); -length = myCAM.read_fifo_length(); -Serial.print(F("The fifo length is :")); -Serial.println(length, DEC); -if (length >= MAX_FIFO_SIZE) //384K -{ - Serial.println(F("Over size.")); - return ; -} -if (length == 0 ) //0 kb -{ - Serial.println(F("Size is 0.")); - return ; -} -//Construct a file name -k = k + 1; -itoa(k, str, 10); -strcat(str, ".jpg"); -//Open the new file -outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); -if(!outFile){ - Serial.println(F("File open faild")); - return; + static int val; + pinMode(HCSR, INPUT); + return (digitalRead(HCSR)); } -myCAM.CS_LOW(); -myCAM.set_fifo_burst(); -while ( length-- ) +void myCAMSaveToSDFile() { - temp_last = temp; - temp = SPI.transfer(0x00); - //Read JPEG data from FIFO - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, + char str[8]; + byte buf[256]; + static int i = 0; + static int k = 0; + uint8_t temp = 0, temp_last = 0; + uint32_t length = 0; + bool is_header = false; + File outFile; + // Flush the FIFO + myCAM.flush_fifo(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + // Start capture + myCAM.start_capture(); + Serial.println(F("start Capture")); + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + Serial.println(F("Capture Done.")); + length = myCAM.read_fifo_length(); + Serial.print(F("The fifo length is :")); + Serial.println(length, DEC); + if (length >= MAX_FIFO_SIZE) // 384K { - buf[i++] = temp; //save the last 0XD9 - //Write the remain bytes in the buffer - myCAM.CS_HIGH(); - outFile.write(buf, i); - //Close the file - outFile.close(); - Serial.println(F("Image save OK.")); - is_header = false; - i = 0; - } - if (is_header == true) - { - //Write image data to buffer if not full - if (i < 256) - buf[i++] = temp; - else + Serial.println(F("Over size.")); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("Size is 0.")); + return; + } + // Construct a file name + k = k + 1; + itoa(k, str, 10); + strcat(str, ".jpg"); + // Open the new file + outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); + if (!outFile) + { + Serial.println(F("File open faild")); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + while (length--) + { + temp_last = temp; + temp = SPI.transfer(0x00); + // Read JPEG data from FIFO + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, { - //Write 256 bytes image data to file + buf[i++] = temp; // save the last 0XD9 + // Write the remain bytes in the buffer myCAM.CS_HIGH(); - outFile.write(buf, 256); + outFile.write(buf, i); + // Close the file + outFile.close(); + Serial.println(F("Image save OK.")); + is_header = false; i = 0; + } + if (is_header == true) + { + // Write image data to buffer if not full + if (i < 256) + buf[i++] = temp; + else + { + // Write 256 bytes image data to file + myCAM.CS_HIGH(); + outFile.write(buf, 256); + i = 0; + buf[i++] = temp; + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); + } + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + buf[i++] = temp_last; buf[i++] = temp; - myCAM.CS_LOW(); - myCAM.set_fifo_burst(); - } + } } - else if ((temp == 0xD8) & (temp_last == 0xFF)) - { - is_header = true; - buf[i++] = temp_last; - buf[i++] = temp; - } -} } -void setup(){ -uint8_t vid, pid; -uint8_t temp; -Wire.begin(); -Serial.begin(115200); -Serial.println(F("ArduCAM Start!")); -//set the CS as an output: -pinMode(SPI_CS,OUTPUT); -// initialize SPI: -SPI.begin(); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - - if (temp != 0x55){ - Serial.println(F("SPI interface Error!")); - delay(1000);continue; - }else{ - Serial.println(F("SPI interface OK."));break; +void setup() +{ + uint8_t vid, pid; + uint8_t temp; + Wire.begin(); + Serial.begin(115200); + Serial.println(F("ArduCAM Start!")); + // set the CS as an output: + pinMode(SPI_CS, OUTPUT); + // initialize SPI: + SPI.begin(); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + + if (temp != 0x55) + { + Serial.println(F("SPI interface Error!")); + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; + } } -} -//Initialize SD Card -while(!SD.begin(SD_CS)){ - Serial.println(F("SD Card Error!"));delay(1000); -} -Serial.println(F("SD Card detected.")); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); + } + Serial.println(F("SD Card detected.")); -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("Can't find OV2640 module!")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("OV2640 detected.")); + break; } - else{ - Serial.println(F("OV2640 detected."));break; - } } -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV3640 +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module!")); - delay(1000);continue; - }else{ - Serial.println(F("OV3640 detected."));break; + delay(1000); + continue; } - } + else + { + Serial.println(F("OV3640 detected.")); + break; + } + } #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("OV5642 detected.")); + break; } - else{ - Serial.println(F("OV5642 detected."));break; - } } #endif -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP) + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP) myCAM.OV2640_set_JPEG_size(OV2640_320x240); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) myCAM.OV3640_set_JPEG_size(OV3640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); -Serial.println("Detecting..."); + delay(1000); + Serial.println("Detecting..."); } -void loop(){ - int now_val = read_HCSR501(); - if(now_val == 1) - { - Serial.println("Rising edge is detected!"); - Serial.println(F("Start snapping...")); - myCAMSaveToSDFile(); - Serial.println("Detecting..."); - } - while(now_val) - { - now_val = read_HCSR501(); - } +void loop() +{ + int now_val = read_HCSR501(); + if (now_val == 1) + { + Serial.println("Rising edge is detected!"); + Serial.println(F("Start snapping...")); + myCAMSaveToSDFile(); + Serial.println("Detecting..."); + } + while (now_val) + { + now_val = read_HCSR501(); + } } - - diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_Video2SD/ArduCAM_Mini_Video2SD.ino b/ArduCAM/examples/mini/ArduCAM_Mini_Video2SD/ArduCAM_Mini_Video2SD.ino index 57198f6f..e1aee48f 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_Video2SD/ArduCAM_Mini_Video2SD.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_Video2SD/ArduCAM_Mini_Video2SD.ino @@ -3,7 +3,7 @@ // This program is a demo of how to use most of the functions // of the library with ArduCAM Mini camera, and can run on any Arduino platform. // This demo was made for ArduCAM Mini Camera. -//This demo timed 5 seconds to record video. +// This demo timed 5 seconds to record video. // It can shoot video and store it into the SD card // The demo sketch will do the following tasks // 1. Set the camera to JPEG output mode. @@ -12,16 +12,16 @@ // 4.Write the video data to the SD card // 5.More updates AVI file header // 6.close the file -//The file header introduction -//00-03 :RIFF -//04-07 :The size of the data -//08-0B :File identifier -//0C-0F :The first list of identification number -//10-13 :The size of the first list -//14-17 :The hdr1 of identification -//18-1B :Hdr1 contains avih piece of identification -//1C-1F :The size of the avih -//20-23 :Maintain time per frame picture +// The file header introduction +// 00-03 :RIFF +// 04-07 :The size of the data +// 08-0B :File identifier +// 0C-0F :The first list of identification number +// 10-13 :The size of the first list +// 14-17 :The hdr1 of identification +// 18-1B :Hdr1 contains avih piece of identification +// 1C-1F :The size of the avih +// 20-23 :Maintain time per frame picture // This program requires the ArduCAM V4.0.0 (or later) library and ArduCAM Mini camera // and use Arduino IDE 1.6.8 compiler or above @@ -40,69 +40,296 @@ #include "memorysaver.h" // DEFINES -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. -#if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED|| defined OV2640_MINI_2MP_PLUS || defined OV2640_MINI_2MP|| defined OV3640_MINI_3MP) +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +#if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP_PLUS || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif -//#define FISHINO_UNO // Nice UNO board with integrated RTC, microSD, WiFi +// #define FISHINO_UNO // Nice UNO board with integrated RTC, microSD, WiFi #define SERIAL_SPEED 115200 -#define BUFFSIZE 512 // 512 is a good buffer size for SD writing. 4096 would be better, on boards with enough RAM (not Arduino Uno of course) +#define BUFFSIZE 512 // 512 is a good buffer size for SD writing. 4096 would be better, on boards with enough RAM (not Arduino Uno of course) #define FRAME_SIZE OV2640_320x240 -#define WIDTH_1 0x40 // Video width in pixel, hex. Here we set 320 (Big Endian: 320 = 0x01 0x40 -> 0x40 0x01). For 640: 0x80 -#define WIDTH_2 0x01 // For 640: 0x02 -#define HEIGHT_1 0xF0 // 240 pixels height (0x00 0xF0 -> 0xF0 0x00). For 480: 0xE0 -#define HEIGHT_2 0x00 // For 480: 0x01 -#define FPS 0x0F // 15 FPS. Placeholder: will be overwritten at runtime based upon real FPS attained -#define TOTAL_FRAMES 200 // Number of frames to be recorded. If < 256, easier to recognize in header (for manual hex debug) -//set pin 7 as the slave select for SPI: -#define SPI_CS 7 +#define WIDTH_1 0x40 // Video width in pixel, hex. Here we set 320 (Big Endian: 320 = 0x01 0x40 -> 0x40 0x01). For 640: 0x80 +#define WIDTH_2 0x01 // For 640: 0x02 +#define HEIGHT_1 0xF0 // 240 pixels height (0x00 0xF0 -> 0xF0 0x00). For 480: 0xE0 +#define HEIGHT_2 0x00 // For 480: 0x01 +#define FPS 0x0F // 15 FPS. Placeholder: will be overwritten at runtime based upon real FPS attained +#define TOTAL_FRAMES 200 // Number of frames to be recorded. If < 256, easier to recognize in header (for manual hex debug) +// set pin 7 as the slave select for SPI: +#define SPI_CS 7 // SD card Select pin: -#define SD_CS 9 // 9 on Arducam adapter Uno and SD shields +#define SD_CS 9 // 9 on Arducam adapter Uno and SD shields #ifdef FISHINO_UNO -#define SD_AUX 10 // Needs to be Output on Fishino Uno for the integrated SD card to work +#define SD_AUX 10 // Needs to be Output on Fishino Uno for the integrated SD card to work #endif #define AVIOFFSET 240 // AVI main header length -//#define DISABLE_SD +// #define DISABLE_SD // GLOBALS unsigned long movi_size = 0; unsigned long jpeg_size = 0; const char zero_buf[4] = {0x00, 0x00, 0x00, 0x00}; const int avi_header[AVIOFFSET] PROGMEM = { - 0x52, 0x49, 0x46, 0x46, 0xD8, 0x01, 0x0E, 0x00, 0x41, 0x56, 0x49, 0x20, 0x4C, 0x49, 0x53, 0x54, - 0xD0, 0x00, 0x00, 0x00, 0x68, 0x64, 0x72, 0x6C, 0x61, 0x76, 0x69, 0x68, 0x38, 0x00, 0x00, 0x00, - 0xA0, 0x86, 0x01, 0x00, 0x80, 0x66, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - WIDTH_1, WIDTH_2, 0x00, 0x00, HEIGHT_1, HEIGHT_2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x84, 0x00, 0x00, 0x00, - 0x73, 0x74, 0x72, 0x6C, 0x73, 0x74, 0x72, 0x68, 0x30, 0x00, 0x00, 0x00, 0x76, 0x69, 0x64, 0x73, - 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, FPS, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x74, 0x72, 0x66, - 0x28, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, WIDTH_1, WIDTH_2, 0x00, 0x00, HEIGHT_1, HEIGHT_2, 0x00, 0x00, - 0x01, 0x00, 0x18, 0x00, 0x4D, 0x4A, 0x50, 0x47, 0x00, 0x84, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, - 0x10, 0x00, 0x00, 0x00, 0x6F, 0x64, 0x6D, 0x6C, 0x64, 0x6D, 0x6C, 0x68, 0x04, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x4C, 0x49, 0x53, 0x54, 0x00, 0x01, 0x0E, 0x00, 0x6D, 0x6F, 0x76, 0x69, + 0x52, + 0x49, + 0x46, + 0x46, + 0xD8, + 0x01, + 0x0E, + 0x00, + 0x41, + 0x56, + 0x49, + 0x20, + 0x4C, + 0x49, + 0x53, + 0x54, + 0xD0, + 0x00, + 0x00, + 0x00, + 0x68, + 0x64, + 0x72, + 0x6C, + 0x61, + 0x76, + 0x69, + 0x68, + 0x38, + 0x00, + 0x00, + 0x00, + 0xA0, + 0x86, + 0x01, + 0x00, + 0x80, + 0x66, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x10, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + WIDTH_1, + WIDTH_2, + 0x00, + 0x00, + HEIGHT_1, + HEIGHT_2, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x84, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x6C, + 0x73, + 0x74, + 0x72, + 0x68, + 0x30, + 0x00, + 0x00, + 0x00, + 0x76, + 0x69, + 0x64, + 0x73, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x01, + 0x00, + 0x00, + 0x00, + FPS, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x0A, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x73, + 0x74, + 0x72, + 0x66, + 0x28, + 0x00, + 0x00, + 0x00, + 0x28, + 0x00, + 0x00, + 0x00, + WIDTH_1, + WIDTH_2, + 0x00, + 0x00, + HEIGHT_1, + HEIGHT_2, + 0x00, + 0x00, + 0x01, + 0x00, + 0x18, + 0x00, + 0x4D, + 0x4A, + 0x50, + 0x47, + 0x00, + 0x84, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x10, + 0x00, + 0x00, + 0x00, + 0x6F, + 0x64, + 0x6D, + 0x6C, + 0x64, + 0x6D, + 0x6C, + 0x68, + 0x04, + 0x00, + 0x00, + 0x00, + 0x64, + 0x00, + 0x00, + 0x00, + 0x4C, + 0x49, + 0x53, + 0x54, + 0x00, + 0x01, + 0x0E, + 0x00, + 0x6D, + 0x6F, + 0x76, + 0x69, }; -#if defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS) -ArduCAM myCAM( OV2640, SPI_CS ); -#elif defined (OV3640_MINI_3MP) -ArduCAM myCAM( OV3640, SPI_CS ); +#if defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS) +ArduCAM myCAM(OV2640, SPI_CS); +#elif defined(OV3640_MINI_3MP) +ArduCAM myCAM(OV3640, SPI_CS); #else -ArduCAM myCAM( OV5642, SPI_CS ); +ArduCAM myCAM(OV5642, SPI_CS); #endif // END GLOBALS - static void inline print_quartet(unsigned long i, File fd) { // Writes an uint32_t in Big Endian at current file position - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; - fd.write(i % 0x100); i = i >> 8; //i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; + fd.write(i % 0x100); + i = i >> 8; // i /= 0x100; fd.write(i % 0x100); } @@ -129,24 +356,26 @@ static void Video2SD() digitalWrite(SD_CS, HIGH); randomSeed(analogRead(0) * millis()); - n = (random(2, 999)); // Don't use 1.avi: was the default in old code, we don't want to overwrite old recordings + n = (random(2, 999)); // Don't use 1.avi: was the default in old code, we don't want to overwrite old recordings itoa(n, str, 10); strcat(str, ".avi"); - Serial.print("\nFile name will be "); Serial.println(str); + Serial.print("\nFile name will be "); + Serial.println(str); - //Open the new file + // Open the new file outFile = SD.open(str, O_WRITE | O_CREAT | O_TRUNC); - if (! outFile) + if (!outFile) { Serial.println(F("File open failed")); - while (1); + while (1) + ; return; } #endif - //Write AVI Main Header - // Some entries will be overwritten later - for ( i = 0; i < AVIOFFSET; i++) + // Write AVI Main Header + // Some entries will be overwritten later + for (i = 0; i < AVIOFFSET; i++) { char ch = pgm_read_byte(&avi_header[i]); buf[i] = ch; @@ -161,32 +390,34 @@ static void Video2SD() startms = millis(); - //Write video data, frame by frame - for ( frame_cnt = 0; frame_cnt < TOTAL_FRAMES; frame_cnt++) + // Write video data, frame by frame + for (frame_cnt = 0; frame_cnt < TOTAL_FRAMES; frame_cnt++) { -#if defined (ESP8266) +#if defined(ESP8266) yield(); #endif - temp_last = 0; temp = 0; - //Capture a frame - //Flush the FIFO + temp_last = 0; + temp = 0; + // Capture a frame + // Flush the FIFO myCAM.flush_fifo(); - //Clear the capture done flag + // Clear the capture done flag myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); // Wait for frame ready - while (!myCAM.get_bit(ARDUCHIP_TRIG , CAP_DONE_MASK)); - length = myCAM.read_fifo_length(); // Length of FIFO buffer. In general, it contains more than 1 JPEG frame; - // so we'll have to check JPEG markers to save a single JPEG frame + while (!myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) + ; + length = myCAM.read_fifo_length(); // Length of FIFO buffer. In general, it contains more than 1 JPEG frame; + // so we'll have to check JPEG markers to save a single JPEG frame #if defined(SPI_HAS_TRANSACTION) SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); #endif #ifndef DISABLE_SD // Write segment. We store 1 frame for each segment (video chunk) - outFile.write("00dc"); // "start of video data chunk" (00 = data stream #0, d = video, c = "compressed") - outFile.write(zero_buf, 4); // Placeholder for actual JPEG frame size, to be overwritten later + outFile.write("00dc"); // "start of video data chunk" (00 = data stream #0, d = video, c = "compressed") + outFile.write(zero_buf, 4); // Placeholder for actual JPEG frame size, to be overwritten later #endif i = 0; jpeg_size = 0; @@ -196,114 +427,114 @@ static void Video2SD() // Set FIFO to burst read mode myCAM.set_fifo_burst(); // Transfer data, a byte at a time - while ( length-- ) + while (length--) { // For every byte in the FIFO... -#if defined (ESP8266) +#if defined(ESP8266) yield(); #endif // We always need the last 2 bytes, to check for JPEG begin/end markers - temp_last = temp; // Save current temp value - temp = SPI.transfer(0x00); // Overwrite temp with 1 byte from FIFO (0x00 is dummy byte for the slave: we are reading, the slave will ignore it) + temp_last = temp; // Save current temp value + temp = SPI.transfer(0x00); // Overwrite temp with 1 byte from FIFO (0x00 is dummy byte for the slave: we are reading, the slave will ignore it) #if defined(SPI_HAS_TRANSACTION) SPI.endTransaction(); #endif // a JPEG ends with the two bytes 0xFF, 0xD9 - if ( (temp == 0xD9) && (temp_last == 0xFF) ) // End of the image + if ((temp == 0xD9) && (temp_last == 0xFF)) // End of the image { - buf[i++] = temp; // Add this last byte to the buffer - myCAM.CS_HIGH(); // End of transfer: re-assert Slave Select + buf[i++] = temp; // Add this last byte to the buffer + myCAM.CS_HIGH(); // End of transfer: re-assert Slave Select #ifndef DISABLE_SD // Write the buffer to file outFile.write(buf, i); #endif - is_header = false; // We are at the last byte of the JPEG: sure is not the header :) - jpeg_size += i; // Update total jpeg size with this last buffer size - i = 0; // Reset byte counter (restart writing from the first element of the buffer) + is_header = false; // We are at the last byte of the JPEG: sure is not the header :) + jpeg_size += i; // Update total jpeg size with this last buffer size + i = 0; // Reset byte counter (restart writing from the first element of the buffer) } - if (is_header == true) // Not at end of JPEG, yet + if (is_header == true) // Not at end of JPEG, yet { - //Write image data to buffer if not full + // Write image data to buffer if not full if (i < BUFFSIZE) buf[i++] = temp; else - { // Buffer is full: transfer to file - myCAM.CS_HIGH(); // End SPI transfer + { // Buffer is full: transfer to file + myCAM.CS_HIGH(); // End SPI transfer #ifndef DISABLE_SD - //Write BUFFSIZE bytes image data to file + // Write BUFFSIZE bytes image data to file outFile.write(buf, BUFFSIZE); #endif - i = 0; // Restart writing from the first element - buf[i++] = temp; // Save current byte as first in "new" buffer - myCAM.CS_LOW(); // Re-enable SPI transfer - myCAM.set_fifo_burst(); // Set FIFO to burst read mode + i = 0; // Restart writing from the first element + buf[i++] = temp; // Save current byte as first in "new" buffer + myCAM.CS_LOW(); // Re-enable SPI transfer + myCAM.set_fifo_burst(); // Set FIFO to burst read mode jpeg_size += BUFFSIZE; } } else if ((temp == 0xD8) & (temp_last == 0xFF)) { // A JPEG starts with the two bytes 0xFF, 0XD8; so here we are at the beginning of the JPEG is_header = true; - buf[i++] = temp_last; // Save the first two bytes (off-cycle) + buf[i++] = temp_last; // Save the first two bytes (off-cycle) buf[i++] = temp; } - } // end loop over each byte in the FIFO: JPEG is complete + } // end loop over each byte in the FIFO: JPEG is complete // Padding - remnant = jpeg_size & 0x00000001; // Align to 16 bit: add 0 or 1 "0x00" bytes + remnant = jpeg_size & 0x00000001; // Align to 16 bit: add 0 or 1 "0x00" bytes #ifndef DISABLE_SD if (remnant > 0) { outFile.write(zero_buf, remnant); // see https://docs.microsoft.com/en-us/windows/desktop/directshow/avi-riff-file-reference } #endif - movi_size += jpeg_size; // Update totals - uVideoLen += jpeg_size; // <- This is for statistics only + movi_size += jpeg_size; // Update totals + uVideoLen += jpeg_size; // <- This is for statistics only // Now we have the real frame size in bytes. Time to overwrite the placeholder #ifndef DISABLE_SD - fileposition = outFile.position(); // Here, we are at end of chunk (after padding) + fileposition = outFile.position(); // Here, we are at end of chunk (after padding) outFile.seek(fileposition - jpeg_size - remnant - 4); // Here we are the the 4-bytes blank placeholder - print_quartet(jpeg_size, outFile); // Overwrite placeholder with actual frame size (without padding) + print_quartet(jpeg_size, outFile); // Overwrite placeholder with actual frame size (without padding) outFile.seek(fileposition - jpeg_size - remnant + 2); // Here is the FOURCC "JFIF" (JPEG header) - outFile.write("AVI1", 4); // Overwrite "JFIF" (still images) with more appropriate "AVI1" + outFile.write("AVI1", 4); // Overwrite "JFIF" (still images) with more appropriate "AVI1" // Return to end of JPEG, ready for next chunk outFile.seek(fileposition); #endif - } // End cycle for all frames + } // End cycle for all frames // END CAPTURE // Compute statistics elapsedms = millis() - startms; float fRealFPS = (1000.0f * (float)frame_cnt) / ((float)elapsedms); float fmicroseconds_per_frame = 1000000.0f / fRealFPS; - uint8_t iAttainedFPS = round(fRealFPS); // Will overwrite AVI header placeholder + uint8_t iAttainedFPS = round(fRealFPS); // Will overwrite AVI header placeholder uint32_t us_per_frame = round(fmicroseconds_per_frame); // Will overwrite AVI header placeholder #ifndef DISABLE_SD - //Modify the MJPEG header from the beginning of the file, overwriting various placeholders + // Modify the MJPEG header from the beginning of the file, overwriting various placeholders outFile.seek(4); print_quartet(movi_size + 12 * frame_cnt + 4, outFile); // riff file size - //overwrite hdrl - //hdrl.avih.us_per_frame: + // overwrite hdrl + // hdrl.avih.us_per_frame: outFile.seek(0x20); print_quartet(us_per_frame, outFile); - unsigned long max_bytes_per_sec = movi_size * iAttainedFPS / frame_cnt; //hdrl.avih.max_bytes_per_sec + unsigned long max_bytes_per_sec = movi_size * iAttainedFPS / frame_cnt; // hdrl.avih.max_bytes_per_sec outFile.seek(0x24); print_quartet(max_bytes_per_sec, outFile); - //hdrl.avih.tot_frames + // hdrl.avih.tot_frames outFile.seek(0x30); print_quartet(frame_cnt, outFile); outFile.seek(0x84); print_quartet((int)iAttainedFPS, outFile); - //hdrl.strl.list_odml.frames + // hdrl.strl.list_odml.frames outFile.seek(0xe0); print_quartet(frame_cnt, outFile); outFile.seek(0xe8); - print_quartet(movi_size, outFile);// size again + print_quartet(movi_size, outFile); // size again myCAM.CS_HIGH(); - //Close the file + // Close the file outFile.close(); #endif @@ -339,11 +570,12 @@ void setup() Wire.begin(); Serial.begin(SERIAL_SPEED); - while (!Serial); + while (!Serial) + ; delay(200); Serial.println(F("ArduCAM Start!\n")); - delay(5000); // Gain time to start logic analyzer + delay(5000); // Gain time to start logic analyzer #ifndef DISABLE_SD // set the SPI_CS as an output: @@ -360,95 +592,114 @@ void setup() SPI.begin(); #ifndef DISABLE_SD - //Initialize SD Card - while (!SD.begin(SD_CS)) { - Serial.println(F("SD Card Error!")); delay(1000); + // Initialize SD Card + while (!SD.begin(SD_CS)) + { + Serial.println(F("SD Card Error!")); + delay(1000); } Serial.println(F("SD Card detected.")); delay(200); #endif - - //Reset the CPLD + // Reset the CPLD myCAM.write_reg(0x07, 0x80); delay(100); myCAM.write_reg(0x07, 0x00); delay(200); - while (1) { - //Check if the ArduCAM SPI bus is OK + while (1) + { + // Check if the ArduCAM SPI bus is OK myCAM.write_reg(ARDUCHIP_TEST1, 0x55); temp = myCAM.read_reg(ARDUCHIP_TEST1); if (temp != 0x55) { Serial.println(F("SPI interface Error!")); - delay(1000); continue; - } else { - Serial.println(F("SPI interface OK.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("SPI interface OK.")); + break; } } delay(100); -#if defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS) +#if defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS) while (1) { - //Check if the camera module type is OV2640 + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))) + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) { Serial.println(F("Can't find OV2640 module!")); - delay(1000); continue; + delay(1000); + continue; } - else { - Serial.println(F("OV2640 detected.")); break; + else + { + Serial.println(F("OV2640 detected.")); + break; } } -#elif defined (OV3640_MINI_3MP) - while (1) { - //Check if the camera module type is OV3640 +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)) { + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("Can't find OV3640 module!")); - delay(1000); continue; - } else { - Serial.println(F("OV3640 detected.")); break; + delay(1000); + continue; + } + else + { + Serial.println(F("OV3640 detected.")); + break; } } #else - while (1) { - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if ((vid != 0x56) || (pid != 0x42)) { + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("Can't find OV5642 module!")); - delay(1000); continue; + delay(1000); + continue; } - else { - Serial.println(F("OV5642 detected.")); break; + else + { + Serial.println(F("OV5642 detected.")); + break; } } #endif delay(1000); myCAM.set_format(JPEG); myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP)||defined (OV2640_MINI_2MP_PLUS) +#if defined(OV2640_MINI_2MP) || defined(OV2640_MINI_2MP_PLUS) myCAM.OV2640_set_JPEG_size(FRAME_SIZE); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) myCAM.OV3640_set_JPEG_size(OV3640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif - - - Video2SD(); + Video2SD(); delay(30000); } -void loop() { +void loop() +{ delay(500000); } diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming/ArduCAM_Mini_Video_Streaming.ino b/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming/ArduCAM_Mini_Video_Streaming.ino index 6329636e..87629740 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming/ArduCAM_Mini_Video_Streaming.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming/ArduCAM_Mini_Video_Streaming.ino @@ -21,36 +21,36 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. #if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_MINI_2MP) - ArduCAM myCAM( OV2640, CS ); -#elif defined (OV3640_MINI_3MP) -ArduCAM myCAM( OV3640, CS ); +#if defined(OV2640_MINI_2MP) +ArduCAM myCAM(OV2640, CS); +#elif defined(OV3640_MINI_3MP) +ArduCAM myCAM(OV3640, CS); #else - ArduCAM myCAM( OV5642, CS ); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -58,413 +58,464 @@ uint8_t temp; Wire.begin(); Serial.begin(921600); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; - } } -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV3640 +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("ACK CMD Can't find OV3640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV3640 detected. END"));break; + delay(1000); + continue; } - } - + else + { + Serial.println(F("ACK CMD OV3640 detected. END")); + break; + } + } + #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP) myCAM.OV2640_set_JPEG_size(OV2640_320x240); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) myCAM.OV3640_set_JPEG_size(OV3640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); -myCAM.clear_fifo_flag(); -#if !(defined (OV2640_MINI_2MP)) -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + delay(1000); + myCAM.clear_fifo_flag(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); #endif } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_176x144);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - temp = 0xff; - break; +#endif + temp = 0xff; + break; case 1: - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_320x240 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - temp = 0xff; - break; - case 2: - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); +#endif + temp = 0xff; + break; + case 2: +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_352x288);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_352x288 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - #endif - temp = 0xff; - break; +#endif + temp = 0xff; + break; case 3: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_640x480);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_640x480 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - break; +#endif + break; case 4: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_800x600);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_800x600 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - break; +#endif + break; case 5: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1024x768 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - break; +#endif + break; case 6: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1280x960 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - break; +#endif + break; case 7: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - #else - myCAM.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); +#else + myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1600x1200 END")); - #endif - break; +#endif + break; case 8: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); - #else - myCAM.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); - #endif - break; + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); +#else + myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); +#endif + break; case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - break; + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); Serial.println(F("ACK IMG END")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + Serial.println(F("ACK IMG END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; default: - break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END")); - delay(50); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); break; } - if (start_capture == 2) + } + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) + else if (mode == 3) { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END")); - delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) - { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb + if (start_capture == 3) { - Serial.println(F("ACK CMD Size is 0. END")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.println(F("ACK CMD Over size. END")); + myCAM.clear_fifo_flag(); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + { + Serial.write(pgm_read_byte(&bmp_header[temp])); } + SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size. END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0. END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -476,8 +527,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming_Bluetooth/ArduCAM_Mini_Video_Streaming_Bluetooth.ino b/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming_Bluetooth/ArduCAM_Mini_Video_Streaming_Bluetooth.ino index 38d59abd..16cdbf09 100644 --- a/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming_Bluetooth/ArduCAM_Mini_Video_Streaming_Bluetooth.ino +++ b/ArduCAM/examples/mini/ArduCAM_Mini_Video_Streaming_Bluetooth/ArduCAM_Mini_Video_Streaming_Bluetooth.ino @@ -4,7 +4,7 @@ // of the library with ArduCAM Mini camera, and can run on any Arduino platform. // This demo was made for ArduCAM_Mini_2MP. // It needs to be used in combination with PC software. -//It supports Bluetooth module +// It supports Bluetooth module // It can take photo continuously as video streaming. // // The demo sketch will do the following tasks: @@ -22,36 +22,36 @@ #include #include #include "memorysaver.h" -//This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. +// This demo can only work on OV2640_MINI_2MP or OV5642_MINI_5MP or OV5642_MINI_5MP_BIT_ROTATION_FIXED platform. #if !(defined OV5642_MINI_5MP || defined OV5642_MINI_5MP_BIT_ROTATION_FIXED || defined OV2640_MINI_2MP || defined OV3640_MINI_3MP) - #error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file +#error Please select the hardware platform and camera module in the ../libraries/ArduCAM/memorysaver.h file #endif #define BMPIMAGEOFFSET 66 const char bmp_header[BMPIMAGEOFFSET] PROGMEM = -{ - 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, - 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, - 0x00, 0x00 -}; + { + 0x42, 0x4D, 0x36, 0x58, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x01, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x00, 0x00, 0x00, 0x58, 0x02, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0xC4, 0x0E, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xE0, 0x07, 0x00, 0x00, 0x1F, 0x00, + 0x00, 0x00}; // set pin 7 as the slave select for the digital pot: const int CS = 7; bool is_header = false; int mode = 0; uint8_t start_capture = 0; -#if defined (OV2640_MINI_2MP) - ArduCAM myCAM( OV2640, CS ); -#elif defined (OV3640_MINI_3MP) -ArduCAM myCAM( OV3640, CS ); +#if defined(OV2640_MINI_2MP) +ArduCAM myCAM(OV2640, CS); +#elif defined(OV3640_MINI_3MP) +ArduCAM myCAM(OV3640, CS); #else - ArduCAM myCAM( OV5642, CS ); +ArduCAM myCAM(OV5642, CS); #endif uint8_t read_fifo_burst(ArduCAM myCAM); -void setup() { -// put your setup code here, to run once: -uint8_t vid, pid; -uint8_t temp; +void setup() +{ + // put your setup code here, to run once: + uint8_t vid, pid; + uint8_t temp; #if defined(__SAM3X8E__) Wire1.begin(); Serial.begin(115200); @@ -59,413 +59,463 @@ uint8_t temp; Wire.begin(); Serial.begin(115200); #endif -Serial.println(F("ACK CMD ArduCAM Start! END")); -// set the CS as an output: -pinMode(CS, OUTPUT); -digitalWrite(CS, HIGH); -// initialize SPI: -SPI.begin(); -//Reset the CPLD -myCAM.write_reg(0x07, 0x80); -delay(100); -myCAM.write_reg(0x07, 0x00); -delay(100); -while(1){ - //Check if the ArduCAM SPI bus is OK - myCAM.write_reg(ARDUCHIP_TEST1, 0x55); - temp = myCAM.read_reg(ARDUCHIP_TEST1); - if (temp != 0x55){ - Serial.println(F("ACK CMD SPI interface Error! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD SPI interface OK. END"));break; + Serial.println(F("ACK CMD ArduCAM Start! END")); + // set the CS as an output: + pinMode(CS, OUTPUT); + digitalWrite(CS, HIGH); + // initialize SPI: + SPI.begin(); + // Reset the CPLD + myCAM.write_reg(0x07, 0x80); + delay(100); + myCAM.write_reg(0x07, 0x00); + delay(100); + while (1) + { + // Check if the ArduCAM SPI bus is OK + myCAM.write_reg(ARDUCHIP_TEST1, 0x55); + temp = myCAM.read_reg(ARDUCHIP_TEST1); + if (temp != 0x55) + { + Serial.println(F("ACK CMD SPI interface Error! END")); + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD SPI interface OK. END")); + break; + } } -} -#if defined (OV2640_MINI_2MP) - while(1){ - //Check if the camera module type is OV2640 +#if defined(OV2640_MINI_2MP) + while (1) + { + // Check if the camera module type is OV2640 myCAM.wrSensorReg8_8(0xff, 0x01); myCAM.rdSensorReg8_8(OV2640_CHIPID_HIGH, &vid); myCAM.rdSensorReg8_8(OV2640_CHIPID_LOW, &pid); - if ((vid != 0x26 ) && (( pid != 0x41 ) || ( pid != 0x42 ))){ + if ((vid != 0x26) && ((pid != 0x41) || (pid != 0x42))) + { Serial.println(F("ACK CMD Can't find OV2640 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV2640 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV2640 detected. END"));break; - } } -#elif defined (OV3640_MINI_3MP) - while(1){ - //Check if the camera module type is OV3640 +#elif defined(OV3640_MINI_3MP) + while (1) + { + // Check if the camera module type is OV3640 myCAM.rdSensorReg16_8(OV3640_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV3640_CHIPID_LOW, &pid); - if ((vid != 0x36) || (pid != 0x4C)){ + if ((vid != 0x36) || (pid != 0x4C)) + { Serial.println(F("ACK CMD Can't find OV3640 module! END")); - delay(1000);continue; - }else{ - Serial.println(F("ACK CMD OV3640 detected. END"));break; + delay(1000); + continue; } - } - + else + { + Serial.println(F("ACK CMD OV3640 detected. END")); + break; + } + } + #else - while(1){ - //Check if the camera module type is OV5642 + while (1) + { + // Check if the camera module type is OV5642 myCAM.wrSensorReg16_8(0xff, 0x01); myCAM.rdSensorReg16_8(OV5642_CHIPID_HIGH, &vid); myCAM.rdSensorReg16_8(OV5642_CHIPID_LOW, &pid); - if((vid != 0x56) || (pid != 0x42)){ + if ((vid != 0x56) || (pid != 0x42)) + { Serial.println(F("ACK CMD Can't find OV5642 module! END")); - delay(1000);continue; + delay(1000); + continue; + } + else + { + Serial.println(F("ACK CMD OV5642 detected. END")); + break; } - else{ - Serial.println(F("ACK CMD OV5642 detected. END"));break; - } } #endif -//Change to JPEG capture mode and initialize the OV5642 module -myCAM.set_format(JPEG); -myCAM.InitCAM(); -#if defined (OV2640_MINI_2MP) + // Change to JPEG capture mode and initialize the OV5642 module + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if defined(OV2640_MINI_2MP) myCAM.OV2640_set_JPEG_size(OV2640_320x240); -#elif defined (OV3640_MINI_3MP) +#elif defined(OV3640_MINI_3MP) myCAM.OV3640_set_JPEG_size(OV3640_320x240); #else - myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); //VSYNC is active HIGH + myCAM.write_reg(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); // VSYNC is active HIGH myCAM.OV5642_set_JPEG_size(OV5642_320x240); #endif -delay(1000); -myCAM.clear_fifo_flag(); -#if !(defined (OV2640_MINI_2MP)) -myCAM.write_reg(ARDUCHIP_FRAMES,0x00); + delay(1000); + myCAM.clear_fifo_flag(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.write_reg(ARDUCHIP_FRAMES, 0x00); #endif } -void loop() { -// put your main code here, to run repeatedly: -uint8_t temp = 0xff, temp_last = 0; -bool is_header = false; -if (Serial.available()) +void loop() { - temp = Serial.read(); - switch (temp) + // put your main code here, to run repeatedly: + uint8_t temp = 0xff, temp_last = 0; + bool is_header = false; + if (Serial.available()) { + temp = Serial.read(); + switch (temp) + { case 0: - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_160x120);delay(1000); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_160x120); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_176x144);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_160x120 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_320x240);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_320x240 END")); - #endif - temp = 0xff; - break; +#endif + temp = 0xff; + break; case 1: - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_176x144);delay(1000); +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_176x144); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_176x144 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_320x240);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_320x240 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_640x480);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_640x480 END")); - #endif - temp = 0xff; - break; - case 2: - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_320x240);delay(1000); +#endif + temp = 0xff; + break; + case 2: +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_320x240); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_320x240 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_352x288);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_352x288 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1024x768);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1024x768 END")); - #endif - temp = 0xff; - break; +#endif + temp = 0xff; + break; case 3: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_352x288);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_352x288); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_352x288 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_640x480);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_640x480 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1280x960);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1280x960 END")); - #endif - break; +#endif + break; case 4: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_640x480);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_640x480); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_640x480 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_800x600);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_800x600 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_1600x1200);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_1600x1200 END")); - #endif - break; +#endif + break; case 5: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_800x600);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_800x600); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_800x600 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1024x768);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1024x768 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2048x1536);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2048x1536); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2048x1536 END")); - #endif - break; +#endif + break; case 6: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1024x768);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1024x768); + delay(1000); Serial.println(F("ACK CMD switch to OV2640_1024x768 END")); - #elif defined (OV3640_MINI_3MP) - myCAM.OV3640_set_JPEG_size(OV3640_1280x960);delay(1000); +#elif defined(OV3640_MINI_3MP) + myCAM.OV3640_set_JPEG_size(OV3640_1280x960); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1280x960 END")); - #else - myCAM.OV5642_set_JPEG_size(OV5642_2592x1944);delay(1000); +#else + myCAM.OV5642_set_JPEG_size(OV5642_2592x1944); + delay(1000); Serial.println(F("ACK CMD switch to OV5642_2592x1944 END")); - #endif - break; +#endif + break; case 7: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1280x1024);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); - #else - myCAM.OV3640_set_JPEG_size(OV3640_1600x1200);delay(1000); + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1280x1024); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1280x1024 END")); +#else + myCAM.OV3640_set_JPEG_size(OV3640_1600x1200); + delay(1000); Serial.println(F("ACK CMD switch to OV3640_1600x1200 END")); - #endif - break; +#endif + break; case 8: - temp = 0xff; - #if defined (OV2640_MINI_2MP) - myCAM.OV2640_set_JPEG_size(OV2640_1600x1200);delay(1000); - Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); - #else - myCAM.OV3640_set_JPEG_size(OV3640_2048x1536);delay(1000); - Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); - #endif - break; + temp = 0xff; +#if defined(OV2640_MINI_2MP) + myCAM.OV2640_set_JPEG_size(OV2640_1600x1200); + delay(1000); + Serial.println(F("ACK CMD switch to OV2640_1600x1200 END")); +#else + myCAM.OV3640_set_JPEG_size(OV3640_2048x1536); + delay(1000); + Serial.println(F("ACK CMD switch to OV3640_2048x1536 END")); +#endif + break; case 0x10: - mode = 1; - temp = 0xff; - start_capture = 1; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; - case 0x11: - temp = 0xff; - myCAM.set_format(JPEG); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - break; + mode = 1; + temp = 0xff; + start_capture = 1; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; + case 0x11: + temp = 0xff; + myCAM.set_format(JPEG); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.set_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + break; case 0x20: - mode = 2; - temp = 0xff; - start_capture = 2; - Serial.println(F("ACK CMD CAM start video streaming. END")); - break; + mode = 2; + temp = 0xff; + start_capture = 2; + Serial.println(F("ACK CMD CAM start video streaming. END")); + break; case 0x30: - mode = 3; - temp = 0xff; - start_capture = 3; - Serial.println(F("ACK CMD CAM start single shoot. END")); - break; + mode = 3; + temp = 0xff; + start_capture = 3; + Serial.println(F("ACK CMD CAM start single shoot. END")); + break; case 0x31: - temp = 0xff; - myCAM.set_format(BMP); - myCAM.InitCAM(); - #if !(defined (OV2640_MINI_2MP)) - myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); - #endif - myCAM.wrSensorReg16_8(0x3818, 0x81); - myCAM.wrSensorReg16_8(0x3621, 0xA7); - break; + temp = 0xff; + myCAM.set_format(BMP); + myCAM.InitCAM(); +#if !(defined(OV2640_MINI_2MP)) + myCAM.clear_bit(ARDUCHIP_TIM, VSYNC_LEVEL_MASK); +#endif + myCAM.wrSensorReg16_8(0x3818, 0x81); + myCAM.wrSensorReg16_8(0x3621, 0xA7); + break; default: - break; - } -} -if (mode == 1) -{ - if (start_capture == 1) - { - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END")); - delay(50); - read_fifo_burst(myCAM); - //Clear the capture done flag - myCAM.clear_fifo_flag(); - } -} -else if (mode == 2) -{ - while (1) - { - temp = Serial.read(); - if (temp == 0x21) - { - start_capture = 0; - mode = 0; - Serial.println(F("ACK CMD CAM stop video streaming. END")); break; } - if (start_capture == 2) + } + if (mode == 1) + { + if (start_capture == 1) { myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - //Start capture + // Start capture myCAM.start_capture(); start_capture = 0; } if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if ((length >= MAX_FIFO_SIZE) | (length == 0)) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + read_fifo_burst(myCAM); + // Clear the capture done flag + myCAM.clear_fifo_flag(); + } + } + else if (mode == 2) + { + while (1) + { + temp = Serial.read(); + if (temp == 0x21) { + start_capture = 0; + mode = 0; + Serial.println(F("ACK CMD CAM stop video streaming. END")); + break; + } + if (start_capture == 2) + { + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - start_capture = 2; - continue; + // Start capture + myCAM.start_capture(); + start_capture = 0; } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - temp_last = temp; - temp = SPI.transfer(0x00); - if (is_header == true) + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if ((length >= MAX_FIFO_SIZE) | (length == 0)) { - Serial.write(temp); + myCAM.clear_fifo_flag(); + start_capture = 2; + continue; } - else if ((temp == 0xD8) & (temp_last == 0xFF)) + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { - is_header = true; - Serial.println(F("ACK IMG END")); - Serial.write(temp_last); - Serial.write(temp); + temp_last = temp; + temp = SPI.transfer(0x00); + if (is_header == true) + { + Serial.write(temp); + } + else if ((temp == 0xD8) & (temp_last == 0xFF)) + { + is_header = true; + Serial.println(F("ACK IMG END")); + Serial.write(temp_last); + Serial.write(temp); + } + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; + delayMicroseconds(15); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; - delayMicroseconds(15); + myCAM.CS_HIGH(); + myCAM.clear_fifo_flag(); + start_capture = 2; + is_header = false; } - myCAM.CS_HIGH(); - myCAM.clear_fifo_flag(); - start_capture = 2; - is_header = false; } } -} -else if (mode == 3) -{ - if (start_capture == 3) + else if (mode == 3) { - //Flush the FIFO - myCAM.flush_fifo(); - myCAM.clear_fifo_flag(); - //Start capture - myCAM.start_capture(); - start_capture = 0; - } - if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) - { - Serial.println(F("ACK CMD CAM Capture Done. END")); - delay(50); - uint8_t temp, temp_last; - uint32_t length = 0; - length = myCAM.read_fifo_length(); - if (length >= MAX_FIFO_SIZE ) - { - Serial.println(F("ACK CMD Over size. END")); - myCAM.clear_fifo_flag(); - return; - } - if (length == 0 ) //0 kb + if (start_capture == 3) { - Serial.println(F("ACK CMD Size is 0. END")); + // Flush the FIFO + myCAM.flush_fifo(); myCAM.clear_fifo_flag(); - return; - } - myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - - Serial.write(0xFF); - Serial.write(0xAA); - for (temp = 0; temp < BMPIMAGEOFFSET; temp++) - { - Serial.write(pgm_read_byte(&bmp_header[temp])); + // Start capture + myCAM.start_capture(); + start_capture = 0; } - SPI.transfer(0x00); - char VH, VL; - int i = 0, j = 0; - for (i = 0; i < 240; i++) + if (myCAM.get_bit(ARDUCHIP_TRIG, CAP_DONE_MASK)) { - for (j = 0; j < 320; j++) + Serial.println(F("ACK CMD CAM Capture Done. END")); + delay(50); + uint8_t temp, temp_last; + uint32_t length = 0; + length = myCAM.read_fifo_length(); + if (length >= MAX_FIFO_SIZE) { - VH = SPI.transfer(0x00);; - VL = SPI.transfer(0x00);; - Serial.write(VL); - delayMicroseconds(12); - Serial.write(VH); - delayMicroseconds(12); + Serial.println(F("ACK CMD Over size. END")); + myCAM.clear_fifo_flag(); + return; + } + if (length == 0) // 0 kb + { + Serial.println(F("ACK CMD Size is 0. END")); + myCAM.clear_fifo_flag(); + return; + } + myCAM.CS_LOW(); + myCAM.set_fifo_burst(); // Set fifo burst mode + + Serial.write(0xFF); + Serial.write(0xAA); + for (temp = 0; temp < BMPIMAGEOFFSET; temp++) + { + Serial.write(pgm_read_byte(&bmp_header[temp])); } + SPI.transfer(0x00); + char VH, VL; + int i = 0, j = 0; + for (i = 0; i < 240; i++) + { + for (j = 0; j < 320; j++) + { + VH = SPI.transfer(0x00); + ; + VL = SPI.transfer(0x00); + ; + Serial.write(VL); + delayMicroseconds(12); + Serial.write(VH); + delayMicroseconds(12); + } + } + Serial.write(0xBB); + Serial.write(0xCC); + myCAM.CS_HIGH(); + // Clear the capture done flag + myCAM.clear_fifo_flag(); } - Serial.write(0xBB); - Serial.write(0xCC); - myCAM.CS_HIGH(); - //Clear the capture done flag - myCAM.clear_fifo_flag(); } } -} uint8_t read_fifo_burst(ArduCAM myCAM) { uint8_t temp = 0, temp_last = 0; uint32_t length = 0; length = myCAM.read_fifo_length(); Serial.println(length, DEC); - if (length >= MAX_FIFO_SIZE) //512 kb + if (length >= MAX_FIFO_SIZE) // 512 kb { Serial.println(F("ACK CMD Over size. END")); return 0; } - if (length == 0 ) //0 kb + if (length == 0) // 0 kb { Serial.println(F("ACK CMD Size is 0. END")); return 0; } myCAM.CS_LOW(); - myCAM.set_fifo_burst();//Set fifo burst mode - temp = SPI.transfer(0x00); - length --; - while ( length-- ) + myCAM.set_fifo_burst(); // Set fifo burst mode + temp = SPI.transfer(0x00); + length--; + while (length--) { temp_last = temp; - temp = SPI.transfer(0x00); + temp = SPI.transfer(0x00); if (is_header == true) { Serial.write(temp); @@ -477,8 +527,8 @@ uint8_t read_fifo_burst(ArduCAM myCAM) Serial.write(temp_last); Serial.write(temp); } - if ( (temp == 0xD9) && (temp_last == 0xFF) ) //If find the end ,break while, - break; + if ((temp == 0xD9) && (temp_last == 0xFF)) // If find the end ,break while, + break; delayMicroseconds(15); } myCAM.CS_HIGH(); diff --git a/ArduCAM/library.json b/ArduCAM/library.json index 293f6906..9f051cdc 100644 --- a/ArduCAM/library.json +++ b/ArduCAM/library.json @@ -1,15 +1,15 @@ { - "name": "ArduCAM", - "keywords": "cam, camera, video", - "description": "This is a opensource library for taking high resolution still images and short video clip on Arduino based platforms using ArduCAM's camera moduels", - "repository": { - "type": "git", - "url": "https://github.com/ArduCAM/Arduino.git" - }, - "version": "1.0.0", - "export": { - "include": "ArduCAM" - }, - "frameworks": "arduino", - "platforms": "*" -} + "name": "ArduCAM", + "keywords": "cam, camera, video", + "description": "This is a opensource library for taking high resolution still images and short video clip on Arduino based platforms using ArduCAM's camera moduels", + "repository": { + "type": "git", + "url": "https://github.com/ArduCAM/Arduino.git" + }, + "version": "1.0.0", + "export": { + "include": "ArduCAM" + }, + "frameworks": "arduino", + "platforms": "*" +} \ No newline at end of file diff --git a/ArduCAM/memorysaver.h b/ArduCAM/memorysaver.h index 86fccc61..5f8253c4 100644 --- a/ArduCAM/memorysaver.h +++ b/ArduCAM/memorysaver.h @@ -1,46 +1,44 @@ #ifndef _MEMORYSAVER_ #define _MEMORYSAVER_ -//Only when using raspberry,enable it -//#define RASPBERRY_PI - -//There are two steps you need to modify in this file before normal compilation -//Only ArduCAM Shield series platform need to select camera module, ArduCAM-Mini series platform doesn't - -//Step 1: select the hardware platform, only one at a time -//#define OV2640_MINI_2MP -//#define OV3640_MINI_3MP -//#define OV5642_MINI_5MP -//#define OV5642_MINI_5MP_BIT_ROTATION_FIXED -//#define OV2640_MINI_2MP_PLUS +// Only when using raspberry,enable it +// #define RASPBERRY_PI + +// There are two steps you need to modify in this file before normal compilation +// Only ArduCAM Shield series platform need to select camera module, ArduCAM-Mini series platform doesn't + +// Step 1: select the hardware platform, only one at a time +// #define OV2640_MINI_2MP +// #define OV3640_MINI_3MP +// #define OV5642_MINI_5MP +// #define OV5642_MINI_5MP_BIT_ROTATION_FIXED +// #define OV2640_MINI_2MP_PLUS #define OV5642_MINI_5MP_PLUS -//#define OV5640_MINI_5MP_PLUS - +// #define OV5640_MINI_5MP_PLUS -//#define ARDUCAM_SHIELD_REVC -//#define ARDUCAM_SHIELD_V2 +// #define ARDUCAM_SHIELD_REVC +// #define ARDUCAM_SHIELD_V2 - -//Step 2: Select one of the camera module, only one at a time +// Step 2: Select one of the camera module, only one at a time #if (defined(ARDUCAM_SHIELD_REVC) || defined(ARDUCAM_SHIELD_V2)) - //#define OV7660_CAM - //#define OV7725_CAM - //#define OV7670_CAM - //#define OV7675_CAM - //#define OV2640_CAM - //#define OV3640_CAM - //#define OV5642_CAM - //#define OV5640_CAM - - //#define MT9D111A_CAM - //#define MT9D111B_CAM - //#define MT9M112_CAM - //#define MT9V111_CAM - //#define MT9M001_CAM - //#define MT9V034_CAM - //#define MT9M034_CAM - //#define MT9T112_CAM - //#define MT9D112_CAM -#endif - -#endif //_MEMORYSAVER_ \ No newline at end of file +// #define OV7660_CAM +// #define OV7725_CAM +// #define OV7670_CAM +// #define OV7675_CAM +// #define OV2640_CAM +// #define OV3640_CAM +// #define OV5642_CAM +// #define OV5640_CAM + +// #define MT9D111A_CAM +// #define MT9D111B_CAM +// #define MT9M112_CAM +// #define MT9V111_CAM +// #define MT9M001_CAM +// #define MT9V034_CAM +// #define MT9M034_CAM +// #define MT9T112_CAM +// #define MT9D112_CAM +#endif + +#endif //_MEMORYSAVER_ \ No newline at end of file diff --git a/ArduCAM/mt9d111_regs.h b/ArduCAM/mt9d111_regs.h index c7750542..5b76e989 100644 --- a/ArduCAM/mt9d111_regs.h +++ b/ArduCAM/mt9d111_regs.h @@ -1,592 +1,582 @@ #ifndef MT9D111_REGS_H #define MT9D111_REGS_H #include "ArduCAM.h" -//#include +// #include /******************************************************************************************* # Display resolution standards # - QCIF : 176 x 144 - CIF : 352 x 288 - QVGA : 320 x 240 - VGA : 640 x 480 - SVGA : 800 x 600 - XGA : 1024 x 768 - WXGA : 1280 x 800 - QVGA : 1280 x 960 - SXGA : 1280 x 1024 - SXGA+ : 1400 x 1050 - WSXGA+ : 1680 x 1050 - UXGA : 1600 x 1200 - WUXGA : 1920 x 1200 - QXGA : 2048 x 1536 + QCIF : 176 x 144 + CIF : 352 x 288 + QVGA : 320 x 240 + VGA : 640 x 480 + SVGA : 800 x 600 + XGA : 1024 x 768 + WXGA : 1280 x 800 + QVGA : 1280 x 960 + SXGA : 1280 x 1024 + SXGA+ : 1400 x 1050 + WSXGA+ : 1680 x 1050 + UXGA : 1600 x 1200 + WUXGA : 1920 x 1200 + QXGA : 2048 x 1536 ********************************************************************************************/ -const struct sensor_reg MT9D111_QVGA_30fps[] PROGMEM= -{ +const struct sensor_reg MT9D111_QVGA_30fps[] PROGMEM = + { - {0xf0, 0x0}, - {0x33, 0x0343 }, // RESERVED_CORE_33 - {0xf0, 0x1}, - {0xC6, 0xA115 }, //SEQ_LLMODE - {0xC8, 0x0020 }, //SEQ_LLMODE - {0xf0, 0x0}, - {0x38, 0x0866 }, // RESERVED_CORE_38 + {0xf0, 0x0}, + {0x33, 0x0343}, // RESERVED_CORE_33 + {0xf0, 0x1}, + {0xC6, 0xA115}, // SEQ_LLMODE + {0xC8, 0x0020}, // SEQ_LLMODE + {0xf0, 0x0}, + {0x38, 0x0866}, // RESERVED_CORE_38 - //{MT9D111_DELAY, 0x00, 0x0064 }, // Delay =100ms + //{MT9D111_DELAY, 0x00, 0x0064 }, // Delay =100ms - {0xf0, 0x2}, - {0x80, 0x0168 }, // LENS_CORRECTION_CONTROL - {0x81, 0x6432 }, // ZONE_BOUNDS_X1_X2 - {0x82, 0x3296 }, // ZONE_BOUNDS_X0_X3 - {0x83, 0x9664 }, // ZONE_BOUNDS_X4_X5 - {0x84, 0x5028 }, // ZONE_BOUNDS_Y1_Y2 - {0x85, 0x2878 }, // ZONE_BOUNDS_Y0_Y3 - {0x86, 0x7850 }, // ZONE_BOUNDS_Y4_Y5 - {0x87, 0x0000 }, // CENTER_OFFSET - {0x88, 0x0152 }, // FX_RED - {0x89, 0x015C }, // FX_GREEN - {0x8A, 0x00F4 }, // FX_BLUE - {0x8B, 0x0108 }, // FY_RED - {0x8C, 0x00FA }, // FY_GREEN - {0x8D, 0x00CF }, // FY_BLUE - {0x8E, 0x09AD }, // DF_DX_RED - {0x8F, 0x091E }, // DF_DX_GREEN - {0x90, 0x0B3F }, // DF_DX_BLUE - {0x91, 0x0C85 }, // DF_DY_RED - {0x92, 0x0CFF }, // DF_DY_GREEN - {0x93, 0x0D86 }, // DF_DY_BLUE - {0x94, 0x163A }, // SECOND_DERIV_ZONE_0_RED - {0x95, 0x0E47 }, // SECOND_DERIV_ZONE_0_GREEN - {0x96, 0x103C }, // SECOND_DERIV_ZONE_0_BLUE - {0x97, 0x1D35 }, // SECOND_DERIV_ZONE_1_RED - {0x98, 0x173E }, // SECOND_DERIV_ZONE_1_GREEN - {0x99, 0x1119 }, // SECOND_DERIV_ZONE_1_BLUE - {0x9A, 0x1663 }, // SECOND_DERIV_ZONE_2_RED - {0x9B, 0x1569 }, // SECOND_DERIV_ZONE_2_GREEN - {0x9C, 0x104C }, // SECOND_DERIV_ZONE_2_BLUE - {0x9D, 0x1015 }, // SECOND_DERIV_ZONE_3_RED - {0x9E, 0x1010 }, // SECOND_DERIV_ZONE_3_GREEN - {0x9F, 0x0B0A }, // SECOND_DERIV_ZONE_3_BLUE - {0xA0, 0x0D53 }, // SECOND_DERIV_ZONE_4_RED - {0xA1, 0x0D51 }, // SECOND_DERIV_ZONE_4_GREEN - {0xA2, 0x0A44 }, // SECOND_DERIV_ZONE_4_BLUE - {0xA3, 0x1545 }, // SECOND_DERIV_ZONE_5_RED - {0xA4, 0x1643 }, // SECOND_DERIV_ZONE_5_GREEN - {0xA5, 0x1231 }, // SECOND_DERIV_ZONE_5_BLUE - {0xA6, 0x0047 }, // SECOND_DERIV_ZONE_6_RED - {0xA7, 0x035C }, // SECOND_DERIV_ZONE_6_GREEN - {0xA8, 0xFE30 }, // SECOND_DERIV_ZONE_6_BLUE - {0xA9, 0x4625 }, // SECOND_DERIV_ZONE_7_RED - {0xAA, 0x47F3 }, // SECOND_DERIV_ZONE_7_GREEN - {0xAB, 0x5859 }, // SECOND_DERIV_ZONE_7_BLUE - {0xAC, 0x0000 }, // X2_FACTORS - {0xAD, 0x0000 }, // GLOBAL_OFFSET_FXY_FUNCTION - {0xAE, 0x0000 }, // K_FACTOR_IN_K_FX_FY - - {0xf0, 0x1}, - {0x08, 0x01FC }, // COLOR_PIPELINE_CONTROL - //{MT9D111_DELAY, 0x00, 0x0064 }, // Delay =100ms - {0xf0, 0x1}, - {0xBE, 0x0004 }, // YUV_YCBCR_CONTROL - {0xf0, 0x0}, - {0x65, 0xA000 }, // CLOCK_ENABLING - //{MT9D111_DELAY, 0x00, 0x0064 }, // Delay =100ms - - {0xf0, 0x1}, - {0xC6, 0xA102 }, //SEQ_MODE - {0xC8, 0x001F }, //SEQ_MODE - {0x08, 0x01FC }, // COLOR_PIPELINE_CONTROL - {0x08, 0x01EC }, // COLOR_PIPELINE_CONTROL - {0x08, 0x01FC }, // COLOR_PIPELINE_CONTROL - {0x36, 0x0F08 }, // APERTURE_PARAMETERS - {0xC6, 0x270B }, //MODE_CONFIG - {0xC8, 0x0030 }, //MODE_CONFIG, JPEG disabled for A and B - {0xC6, 0xA121 }, //SEQ_CAP_MODE - {0xC8, 0x007f }, //SEQ_CAP_MODE (127 frames before switching to Preview) + {0xf0, 0x2}, + {0x80, 0x0168}, // LENS_CORRECTION_CONTROL + {0x81, 0x6432}, // ZONE_BOUNDS_X1_X2 + {0x82, 0x3296}, // ZONE_BOUNDS_X0_X3 + {0x83, 0x9664}, // ZONE_BOUNDS_X4_X5 + {0x84, 0x5028}, // ZONE_BOUNDS_Y1_Y2 + {0x85, 0x2878}, // ZONE_BOUNDS_Y0_Y3 + {0x86, 0x7850}, // ZONE_BOUNDS_Y4_Y5 + {0x87, 0x0000}, // CENTER_OFFSET + {0x88, 0x0152}, // FX_RED + {0x89, 0x015C}, // FX_GREEN + {0x8A, 0x00F4}, // FX_BLUE + {0x8B, 0x0108}, // FY_RED + {0x8C, 0x00FA}, // FY_GREEN + {0x8D, 0x00CF}, // FY_BLUE + {0x8E, 0x09AD}, // DF_DX_RED + {0x8F, 0x091E}, // DF_DX_GREEN + {0x90, 0x0B3F}, // DF_DX_BLUE + {0x91, 0x0C85}, // DF_DY_RED + {0x92, 0x0CFF}, // DF_DY_GREEN + {0x93, 0x0D86}, // DF_DY_BLUE + {0x94, 0x163A}, // SECOND_DERIV_ZONE_0_RED + {0x95, 0x0E47}, // SECOND_DERIV_ZONE_0_GREEN + {0x96, 0x103C}, // SECOND_DERIV_ZONE_0_BLUE + {0x97, 0x1D35}, // SECOND_DERIV_ZONE_1_RED + {0x98, 0x173E}, // SECOND_DERIV_ZONE_1_GREEN + {0x99, 0x1119}, // SECOND_DERIV_ZONE_1_BLUE + {0x9A, 0x1663}, // SECOND_DERIV_ZONE_2_RED + {0x9B, 0x1569}, // SECOND_DERIV_ZONE_2_GREEN + {0x9C, 0x104C}, // SECOND_DERIV_ZONE_2_BLUE + {0x9D, 0x1015}, // SECOND_DERIV_ZONE_3_RED + {0x9E, 0x1010}, // SECOND_DERIV_ZONE_3_GREEN + {0x9F, 0x0B0A}, // SECOND_DERIV_ZONE_3_BLUE + {0xA0, 0x0D53}, // SECOND_DERIV_ZONE_4_RED + {0xA1, 0x0D51}, // SECOND_DERIV_ZONE_4_GREEN + {0xA2, 0x0A44}, // SECOND_DERIV_ZONE_4_BLUE + {0xA3, 0x1545}, // SECOND_DERIV_ZONE_5_RED + {0xA4, 0x1643}, // SECOND_DERIV_ZONE_5_GREEN + {0xA5, 0x1231}, // SECOND_DERIV_ZONE_5_BLUE + {0xA6, 0x0047}, // SECOND_DERIV_ZONE_6_RED + {0xA7, 0x035C}, // SECOND_DERIV_ZONE_6_GREEN + {0xA8, 0xFE30}, // SECOND_DERIV_ZONE_6_BLUE + {0xA9, 0x4625}, // SECOND_DERIV_ZONE_7_RED + {0xAA, 0x47F3}, // SECOND_DERIV_ZONE_7_GREEN + {0xAB, 0x5859}, // SECOND_DERIV_ZONE_7_BLUE + {0xAC, 0x0000}, // X2_FACTORS + {0xAD, 0x0000}, // GLOBAL_OFFSET_FXY_FUNCTION + {0xAE, 0x0000}, // K_FACTOR_IN_K_FX_FY - {0xf0, 0x0}, - {0x05, 0x011E }, // HORZ_BLANK_B - {0x06, 0x006F }, // VERT_BLANK_B - {0x07, 0xFE }, // HORZ_BLANK_A - {0x08, 19 }, // VERT_BLANK_A - {0x20, 0x0302 }, // READ_MODE_B (Image flip settings) - {0x21, 0x8400 }, // READ_MODE_A (1ADC) + {0xf0, 0x1}, + {0x08, 0x01FC}, // COLOR_PIPELINE_CONTROL + //{MT9D111_DELAY, 0x00, 0x0064 }, // Delay =100ms + {0xf0, 0x1}, + {0xBE, 0x0004}, // YUV_YCBCR_CONTROL + {0xf0, 0x0}, + {0x65, 0xA000}, // CLOCK_ENABLING + //{MT9D111_DELAY, 0x00, 0x0064 }, // Delay =100ms - {0xf0, 0x1}, - {0xC6, 0x2717 }, //MODE_SENSOR_X_DELAY_A - {0xC8, 792 }, //MODE_SENSOR_X_DELAY_A - {0xC6, 0x270F }, //MODE_SENSOR_ROW_START_A - {0xC8, 0x001C }, //MODE_SENSOR_ROW_START_A - {0xC6, 0x2711 }, //MODE_SENSOR_COL_START_A - {0xC8, 0x003C }, //MODE_SENSOR_COL_START_A - {0xC6, 0x2713 }, //MODE_SENSOR_ROW_HEIGHT_A - {0xC8, 0x04B0 }, //MODE_SENSOR_ROW_HEIGHT_A - {0xC6, 0x2715 }, //MODE_SENSOR_COL_WIDTH_A - {0xC8, 0x0640 }, //MODE_SENSOR_COL_WIDTH_A - {0xC6, 0x2719 }, //MODE_SENSOR_ROW_SPEED_A - {0xC8, 0x0011 }, //MODE_SENSOR_ROW_SPEED_A - {0xC6, 0x2707 }, //MODE_OUTPUT_WIDTH_B - {0xC8, 0x0640 }, //MODE_OUTPUT_WIDTH_B - {0xC6, 0x2709 }, //MODE_OUTPUT_HEIGHT_B - {0xC8, 0x04B0 }, //MODE_OUTPUT_HEIGHT_B - {0xC6, 0x271B }, //MODE_SENSOR_ROW_START_B - {0xC8, 0x001C }, //MODE_SENSOR_ROW_START_B - {0xC6, 0x271D }, //MODE_SENSOR_COL_START_B - {0xC8, 0x003C }, //MODE_SENSOR_COL_START_B - {0xC6, 0x271F }, //MODE_SENSOR_ROW_HEIGHT_B - {0xC8, 0x04B0 }, //MODE_SENSOR_ROW_HEIGHT_B - {0xC6, 0x2721 }, //MODE_SENSOR_COL_WIDTH_B - {0xC8, 0x0640 }, //MODE_SENSOR_COL_WIDTH_B - {0xC6, 0x2723 }, //MODE_SENSOR_X_DELAY_B - {0xC8, 0x0716 }, //MODE_SENSOR_X_DELAY_B - {0xC6, 0x2725 }, //MODE_SENSOR_ROW_SPEED_B - {0xC8, 0x0011 }, //MODE_SENSOR_ROW_SPEED_B + {0xf0, 0x1}, + {0xC6, 0xA102}, // SEQ_MODE + {0xC8, 0x001F}, // SEQ_MODE + {0x08, 0x01FC}, // COLOR_PIPELINE_CONTROL + {0x08, 0x01EC}, // COLOR_PIPELINE_CONTROL + {0x08, 0x01FC}, // COLOR_PIPELINE_CONTROL + {0x36, 0x0F08}, // APERTURE_PARAMETERS + {0xC6, 0x270B}, // MODE_CONFIG + {0xC8, 0x0030}, // MODE_CONFIG, JPEG disabled for A and B + {0xC6, 0xA121}, // SEQ_CAP_MODE + {0xC8, 0x007f}, // SEQ_CAP_MODE (127 frames before switching to Preview) + {0xf0, 0x0}, + {0x05, 0x011E}, // HORZ_BLANK_B + {0x06, 0x006F}, // VERT_BLANK_B + {0x07, 0xFE}, // HORZ_BLANK_A + {0x08, 19}, // VERT_BLANK_A + {0x20, 0x0302}, // READ_MODE_B (Image flip settings) + {0x21, 0x8400}, // READ_MODE_A (1ADC) -// HANI tmp -//////////////////////////////////////////////////////////// + {0xf0, 0x1}, + {0xC6, 0x2717}, // MODE_SENSOR_X_DELAY_A + {0xC8, 792}, // MODE_SENSOR_X_DELAY_A + {0xC6, 0x270F}, // MODE_SENSOR_ROW_START_A + {0xC8, 0x001C}, // MODE_SENSOR_ROW_START_A + {0xC6, 0x2711}, // MODE_SENSOR_COL_START_A + {0xC8, 0x003C}, // MODE_SENSOR_COL_START_A + {0xC6, 0x2713}, // MODE_SENSOR_ROW_HEIGHT_A + {0xC8, 0x04B0}, // MODE_SENSOR_ROW_HEIGHT_A + {0xC6, 0x2715}, // MODE_SENSOR_COL_WIDTH_A + {0xC8, 0x0640}, // MODE_SENSOR_COL_WIDTH_A + {0xC6, 0x2719}, // MODE_SENSOR_ROW_SPEED_A + {0xC8, 0x0011}, // MODE_SENSOR_ROW_SPEED_A + {0xC6, 0x2707}, // MODE_OUTPUT_WIDTH_B + {0xC8, 0x0640}, // MODE_OUTPUT_WIDTH_B + {0xC6, 0x2709}, // MODE_OUTPUT_HEIGHT_B + {0xC8, 0x04B0}, // MODE_OUTPUT_HEIGHT_B + {0xC6, 0x271B}, // MODE_SENSOR_ROW_START_B + {0xC8, 0x001C}, // MODE_SENSOR_ROW_START_B + {0xC6, 0x271D}, // MODE_SENSOR_COL_START_B + {0xC8, 0x003C}, // MODE_SENSOR_COL_START_B + {0xC6, 0x271F}, // MODE_SENSOR_ROW_HEIGHT_B + {0xC8, 0x04B0}, // MODE_SENSOR_ROW_HEIGHT_B + {0xC6, 0x2721}, // MODE_SENSOR_COL_WIDTH_B + {0xC8, 0x0640}, // MODE_SENSOR_COL_WIDTH_B + {0xC6, 0x2723}, // MODE_SENSOR_X_DELAY_B + {0xC8, 0x0716}, // MODE_SENSOR_X_DELAY_B + {0xC6, 0x2725}, // MODE_SENSOR_ROW_SPEED_B + {0xC8, 0x0011}, // MODE_SENSOR_ROW_SPEED_B - {0xC6, 0x2703 }, //MODE_OUTPUT_WIDTH_A - {0xC8, 0x0280 }, //MODE_OUTPUT_WIDTH_A - {0xC6, 0x2705 }, //MODE_OUTPUT_HEIGHT_A - {0xC8, 0x01E0 }, //MODE_OUTPUT_HEIGHT_A - {0xC6, 0x2707 }, //MODE_OUTPUT_WIDTH_B - {0xC8, 0x0280 }, //MODE_OUTPUT_WIDTH_B - {0xC6, 0x2709 }, //MODE_OUTPUT_HEIGHT_B - {0xC8, 0x01E0 }, //MODE_OUTPUT_HEIGHT_B - {0xC6, 0x2779 }, //Spoof Frame Width - {0xC8, 0x0280 }, //Spoof Frame Width - {0xC6, 0x277B }, //Spoof Frame Height - {0xC8, 0x01E0 }, //Spoof Frame Height - {0xC6, 0xA103 }, //SEQ_CMD - {0xC8, 0x0005 }, //SEQ_CMD + // HANI tmp + //////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////// + {0xC6, 0x2703}, // MODE_OUTPUT_WIDTH_A + {0xC8, 0x0280}, // MODE_OUTPUT_WIDTH_A + {0xC6, 0x2705}, // MODE_OUTPUT_HEIGHT_A + {0xC8, 0x01E0}, // MODE_OUTPUT_HEIGHT_A + {0xC6, 0x2707}, // MODE_OUTPUT_WIDTH_B + {0xC8, 0x0280}, // MODE_OUTPUT_WIDTH_B + {0xC6, 0x2709}, // MODE_OUTPUT_HEIGHT_B + {0xC8, 0x01E0}, // MODE_OUTPUT_HEIGHT_B + {0xC6, 0x2779}, // Spoof Frame Width + {0xC8, 0x0280}, // Spoof Frame Width + {0xC6, 0x277B}, // Spoof Frame Height + {0xC8, 0x01E0}, // Spoof Frame Height + {0xC6, 0xA103}, // SEQ_CMD + {0xC8, 0x0005}, // SEQ_CMD - //Maximum Slew-Rate on IO-Pads (for Mode A) - {0xC6, 0x276B }, //MODE_FIFO_CONF0_A - {0xC8, 0x0027 }, //MODE_FIFO_CONF0_A - {0xC6, 0x276D }, //MODE_FIFO_CONF1_A - {0xC8, 0xE1E1 }, //MODE_FIFO_CONF1_A - {0xC6, 0xA76F }, //MODE_FIFO_CONF2_A - {0xC8, 0x00E1 }, //MODE_FIFO_CONF2_A + //////////////////////////////////////////////////////////// + // Maximum Slew-Rate on IO-Pads (for Mode A) + {0xC6, 0x276B}, // MODE_FIFO_CONF0_A + {0xC8, 0x0027}, // MODE_FIFO_CONF0_A + {0xC6, 0x276D}, // MODE_FIFO_CONF1_A + {0xC8, 0xE1E1}, // MODE_FIFO_CONF1_A + {0xC6, 0xA76F}, // MODE_FIFO_CONF2_A + {0xC8, 0x00E1}, // MODE_FIFO_CONF2_A - //Maximum Slew-Rate on IO-Pads (for Mode B) - {0xC6, 0x2772 }, //MODE_FIFO_CONF0_B - {0xC8, 0x0027 }, //MODE_FIFO_CONF0_B - {0xC6, 0x2774 }, //MODE_FIFO_CONF1_B - {0xC8, 0xE1E1 }, //MODE_FIFO_CONF1_B - {0xC6, 0xA776 }, //MODE_FIFO_CONF2_B - {0xC8, 0x00E1 }, //MODE_FIFO_CONF2_B + // Maximum Slew-Rate on IO-Pads (for Mode B) + {0xC6, 0x2772}, // MODE_FIFO_CONF0_B + {0xC8, 0x0027}, // MODE_FIFO_CONF0_B + {0xC6, 0x2774}, // MODE_FIFO_CONF1_B + {0xC8, 0xE1E1}, // MODE_FIFO_CONF1_B + {0xC6, 0xA776}, // MODE_FIFO_CONF2_B + {0xC8, 0x00E1}, // MODE_FIFO_CONF2_B - //Set maximum integration time to get a minimum of 15 fps at 45MHz - {0xC6, 0xA20E }, //AE_MAX_INDEX - {0xC8, 0x0004 }, //AE_MAX_INDEX - //Set minimum integration time to get a maximum of 15 fps at 45MHz - {0xC6, 0xA20D }, //AE_MAX_INDEX - {0xC8, 0x0004 }, //AE_MAX_INDEX - // Configue all GPIO for output and set low to save power - {0xC6, 0x9078 }, - {0xC8, 0x0000 }, - {0xC6, 0x9079 }, - {0xC8, 0x0000 }, - {0xC6, 0x9070 }, - {0xC8, 0x0000 }, - {0xC6, 0x9071 }, - {0xC8, 0x0000 }, - // gamma and contrast - {0xC6, 0xA743 }, // MODE_GAM_CONT_A - {0xC8, 0x0003 }, // MODE_GAM_CONT_A - {0xC6, 0xA744 }, // MODE_GAM_CONT_B - {0xC8, 0x0003 }, // MODE_GAM_CONT_B - //{MT9D111_DELAY, 0x00, 0x01F4 }, // Delay =500m + // Set maximum integration time to get a minimum of 15 fps at 45MHz + {0xC6, 0xA20E}, // AE_MAX_INDEX + {0xC8, 0x0004}, // AE_MAX_INDEX + // Set minimum integration time to get a maximum of 15 fps at 45MHz + {0xC6, 0xA20D}, // AE_MAX_INDEX + {0xC8, 0x0004}, // AE_MAX_INDEX + // Configue all GPIO for output and set low to save power + {0xC6, 0x9078}, + {0xC8, 0x0000}, + {0xC6, 0x9079}, + {0xC8, 0x0000}, + {0xC6, 0x9070}, + {0xC8, 0x0000}, + {0xC6, 0x9071}, + {0xC8, 0x0000}, + // gamma and contrast + {0xC6, 0xA743}, // MODE_GAM_CONT_A + {0xC8, 0x0003}, // MODE_GAM_CONT_A + {0xC6, 0xA744}, // MODE_GAM_CONT_B + {0xC8, 0x0003}, // MODE_GAM_CONT_B + //{MT9D111_DELAY, 0x00, 0x01F4 }, // Delay =500m + // Set PLL + // Mclk = 19MHz , Pclk = 79MHz + {0xf0, 0x0}, + {0xF2, 0x0000}, + {0x65, 0xE000}, + {0x66, 0x1001}, // PLL Control 1 = 4097 + {0x67, 0x503}, // PLL Control 2 = 1283 + {0x65, 0xA000}, // Clock CNTRL: PLL ON = 40960 + //{MT9D111_DELAY, 0x00, 0x01F4 }, // Delay =500ms + {0xf0, 0x0}, + {0x65, 0x2000}, // CLOCK_ENABLING + {0xf0, 0x0}, + //{MT9D111_DELAY, 0x00, 0x01F4 }, // Delay =500ms -// Set PLL -// Mclk = 19MHz , Pclk = 79MHz - {0xf0, 0x0}, - {0xF2, 0x0000 }, - {0x65, 0xE000 }, - {0x66, 0x1001}, //PLL Control 1 = 4097 - {0x67, 0x503 }, //PLL Control 2 = 1283 - {0x65, 0xA000}, //Clock CNTRL: PLL ON = 40960 - //{MT9D111_DELAY, 0x00, 0x01F4 }, // Delay =500ms - {0xf0, 0x0}, - {0x65, 0x2000 }, // CLOCK_ENABLING - {0xf0, 0x0}, - //{MT9D111_DELAY, 0x00, 0x01F4 }, // Delay =500ms - - {0xf0, 0x1}, - {0xC6, 0x2703 }, //MODE_OUTPUT_WIDTH_A - {0xC8, 0x0140 }, //MODE_OUTPUT_WIDTH_A - {0xC6, 0x2705 }, //MODE_OUTPUT_HEIGHT_A - {0xC8, 0x00F0 }, //MODE_OUTPUT_HEIGHT_A - {0xC6, 0x2707 }, //MODE_OUTPUT_WIDTH_B - {0xC8, 0x0280 }, //MODE_OUTPUT_WIDTH_B - {0xC6, 0x2709 }, //MODE_OUTPUT_HEIGHT_B - {0xC8, 0x01E0 }, //MODE_OUTPUT_HEIGHT_B - {0xC6, 0x2779 }, //Spoof Frame Width - {0xC8, 0x0140 }, //Spoof Frame Width - {0xC6, 0x277B }, //Spoof Frame Height - {0xC8, 0x00F0 }, //Spoof Frame Height - {0xC6, 0xA103 }, //SEQ_CMD - {0xC8, 0x0005 }, //SEQ_CMD - - - {0xff, 0xffff } -}; + {0xf0, 0x1}, + {0xC6, 0x2703}, // MODE_OUTPUT_WIDTH_A + {0xC8, 0x0140}, // MODE_OUTPUT_WIDTH_A + {0xC6, 0x2705}, // MODE_OUTPUT_HEIGHT_A + {0xC8, 0x00F0}, // MODE_OUTPUT_HEIGHT_A + {0xC6, 0x2707}, // MODE_OUTPUT_WIDTH_B + {0xC8, 0x0280}, // MODE_OUTPUT_WIDTH_B + {0xC6, 0x2709}, // MODE_OUTPUT_HEIGHT_B + {0xC8, 0x01E0}, // MODE_OUTPUT_HEIGHT_B + {0xC6, 0x2779}, // Spoof Frame Width + {0xC8, 0x0140}, // Spoof Frame Width + {0xC6, 0x277B}, // Spoof Frame Height + {0xC8, 0x00F0}, // Spoof Frame Height + {0xC6, 0xA103}, // SEQ_CMD + {0xC8, 0x0005}, // SEQ_CMD + {0xff, 0xffff}}; - -const struct sensor_reg MT9D111_QVGA_15fps[] PROGMEM= -{ - {0xf0, 0x0}, - {0x5, 0x11e}, - {0x6, 0xb}, - {0x7, 0xfe}, - {0x8, 0xb}, - {0x20, 0x300}, - {0x21, 0x8400}, - {0x66, 0x1000}, - {0x67, 0x503}, - {0x65, 0xa000}, - {0x65, 0x2000}, - {0xf0, 0x1}, - {0xc6, 0xa122}, - {0xc8, 0x1}, - {0xc6, 0xa123}, - {0xc8, 0x0}, - {0xc6, 0xa124}, - {0xc8, 0x1}, - {0xc6, 0xa125}, - {0xc8, 0x0}, - {0xc6, 0xa126}, - {0xc8, 0x1}, - {0xc6, 0xa127}, - {0xc8, 0x0}, - {0xc6, 0xa128}, - {0xc8, 0x0}, - {0xc6, 0xa129}, - {0xc8, 0x3}, - {0xc6, 0xa12a}, - {0xc8, 0x2}, - {0xc6, 0xa12b}, - {0xc8, 0x3}, - {0xc6, 0xa12c}, - {0xc8, 0x0}, - {0xc6, 0xa12d}, - {0xc8, 0x3}, - {0xc6, 0xa12e}, - {0xc8, 0x0}, - {0xc6, 0xa12f}, - {0xc8, 0x0}, - {0xc6, 0xa130}, - {0xc8, 0x4}, - {0xc6, 0xa131}, - {0xc8, 0x0}, - {0xc6, 0xa132}, - {0xc8, 0x1}, - {0xc6, 0xa133}, - {0xc8, 0x0}, - {0xc6, 0xa134}, - {0xc8, 0x1}, - {0xc6, 0xa135}, - {0xc8, 0x0}, - {0xc6, 0xa136}, - {0xc8, 0x0}, - {0xc6, 0xa137}, - {0xc8, 0x0}, - {0xc6, 0xa138}, - {0xc8, 0x0}, - {0xc6, 0xa139}, - {0xc8, 0x0}, - {0xc6, 0xa13a}, - {0xc8, 0x0}, - {0xc6, 0xa13b}, - {0xc8, 0x0}, - {0xc6, 0xa13c}, - {0xc8, 0x0}, - {0xc6, 0xa13d}, - {0xc8, 0x0}, - {0xc6, 0x2703}, - {0xc8, 0x140}, - {0xc6, 0x2705}, - {0xc8, 0xf0}, - {0xc6, 0x2707}, - {0xc8, 0x140}, - {0xc6, 0x2709}, - {0xc8, 0xf0}, - {0xc6, 0x270b}, - {0xc8, 0x30}, - {0xc6, 0x270f}, - {0xc8, 0x1c}, - {0xc6, 0x2711}, - {0xc8, 0x3c}, - {0xc6, 0x2713}, - {0xc8, 0x4b0}, - {0xc6, 0x2715}, - {0xc8, 0x640}, - {0xc6, 0x2717}, - {0xc8, 0x0}, - {0xc6, 0x2719}, - {0xc8, 0x11}, - {0xc6, 0x271b}, - {0xc8, 0x1c}, - {0xc6, 0x271d}, - {0xc8, 0x3c}, - {0xc6, 0x271f}, - {0xc8, 0x4b0}, - {0xc6, 0x2721}, - {0xc8, 0x640}, - {0xc6, 0x2723}, - {0xc8, 0x53c}, - {0xc6, 0x2725}, - {0xc8, 0x11}, - {0xc6, 0x2727}, - {0xc8, 0x0}, - {0xc6, 0x2729}, - {0xc8, 0x320}, - {0xc6, 0x272b}, - {0xc8, 0x0}, - {0xc6, 0x272d}, - {0xc8, 0x258}, - {0xc6, 0x2735}, - {0xc8, 0x0}, - {0xc6, 0x2737}, - {0xc8, 0x640}, - {0xc6, 0x2739}, - {0xc8, 0x0}, - {0xc6, 0x273b}, - {0xc8, 0x4b0}, - {0xc6, 0xa743}, - {0xc8, 0x42}, - {0xc6, 0xa744}, - {0xc8, 0x42}, - {0xc6, 0xa745}, - {0xc8, 0x0}, - {0xc6, 0xa746}, - {0xc8, 0x14}, - {0xc6, 0xa747}, - {0xc8, 0x23}, - {0xc6, 0xa748}, - {0xc8, 0x3a}, - {0xc6, 0xa749}, - {0xc8, 0x5e}, - {0xc6, 0xa74a}, - {0xc8, 0x76}, - {0xc6, 0xa74b}, - {0xc8, 0x88}, - {0xc6, 0xa74c}, - {0xc8, 0x96}, - {0xc6, 0xa74d}, - {0xc8, 0xa3}, - {0xc6, 0xa74e}, - {0xc8, 0xaf}, - {0xc6, 0xa74f}, - {0xc8, 0xba}, - {0xc6, 0xa750}, - {0xc8, 0xc4}, - {0xc6, 0xa751}, - {0xc8, 0xce}, - {0xc6, 0xa752}, - {0xc8, 0xd7}, - {0xc6, 0xa753}, - {0xc8, 0xe0}, - {0xc6, 0xa754}, - {0xc8, 0xe8}, - {0xc6, 0xa755}, - {0xc8, 0xf0}, - {0xc6, 0xa756}, - {0xc8, 0xf8}, - {0xc6, 0xa757}, - {0xc8, 0xff}, - {0xc6, 0xa758}, - {0xc8, 0x0}, - {0xc6, 0xa759}, - {0xc8, 0x14}, - {0xc6, 0xa75a}, - {0xc8, 0x23}, - {0xc6, 0xa75b}, - {0xc8, 0x3a}, - {0xc6, 0xa75c}, - {0xc8, 0x5e}, - {0xc6, 0xa75d}, - {0xc8, 0x76}, - {0xc6, 0xa75e}, - {0xc8, 0x88}, - {0xc6, 0xa75f}, - {0xc8, 0x96}, - {0xc6, 0xa760}, - {0xc8, 0xa3}, - {0xc6, 0xa761}, - {0xc8, 0xaf}, - {0xc6, 0xa762}, - {0xc8, 0xba}, - {0xc6, 0xa763}, - {0xc8, 0xc4}, - {0xc6, 0xa764}, - {0xc8, 0xce}, - {0xc6, 0xa765}, - {0xc8, 0xd7}, - {0xc6, 0xa766}, - {0xc8, 0xe0}, - {0xc6, 0xa767}, - {0xc8, 0xe8}, - {0xc6, 0xa768}, - {0xc8, 0xf0}, - {0xc6, 0xa769}, - {0xc8, 0xf8}, - {0xc6, 0xa76a}, - {0xc8, 0xff}, - {0xc6, 0x276d}, - {0xc8, 0xe0e2}, - {0xc6, 0xa76f}, - {0xc8, 0xe1}, - {0xc6, 0x2774}, - {0xc8, 0xe0e1}, - {0xc6, 0xa776}, - {0xc8, 0xe1}, - {0xc6, 0x220b}, - {0xc8, 0x192}, - {0xc6, 0xa217}, - {0xc8, 0x8}, - {0xc6, 0x2228}, - {0xc8, 0x20f}, - {0xc6, 0x222f}, - {0xc8, 0x0}, - {0xc6, 0xa408}, - {0xc8, 0xff}, - {0xc6, 0xa409}, - {0xc8, 0x1}, - {0xc6, 0xa40a}, - {0xc8, 0xff}, - {0xc6, 0xa40b}, - {0xc8, 0x1}, - {0xc6, 0x2411}, - {0xc8, 0x0}, - {0xc6, 0x2413}, - {0xc8, 0x0}, - {0xf0, 0x1}, - {0xc6, 0xa103}, - {0xc8, 0x6}, - {0xf0, 0x1}, - {0xc6, 0xa103}, - {0xc8, 0x5}, - {0xf0, 0x1}, - {0x97, 0x20}, - {0xff, 0xffff}, +const struct sensor_reg MT9D111_QVGA_15fps[] PROGMEM = + { + {0xf0, 0x0}, + {0x5, 0x11e}, + {0x6, 0xb}, + {0x7, 0xfe}, + {0x8, 0xb}, + {0x20, 0x300}, + {0x21, 0x8400}, + {0x66, 0x1000}, + {0x67, 0x503}, + {0x65, 0xa000}, + {0x65, 0x2000}, + {0xf0, 0x1}, + {0xc6, 0xa122}, + {0xc8, 0x1}, + {0xc6, 0xa123}, + {0xc8, 0x0}, + {0xc6, 0xa124}, + {0xc8, 0x1}, + {0xc6, 0xa125}, + {0xc8, 0x0}, + {0xc6, 0xa126}, + {0xc8, 0x1}, + {0xc6, 0xa127}, + {0xc8, 0x0}, + {0xc6, 0xa128}, + {0xc8, 0x0}, + {0xc6, 0xa129}, + {0xc8, 0x3}, + {0xc6, 0xa12a}, + {0xc8, 0x2}, + {0xc6, 0xa12b}, + {0xc8, 0x3}, + {0xc6, 0xa12c}, + {0xc8, 0x0}, + {0xc6, 0xa12d}, + {0xc8, 0x3}, + {0xc6, 0xa12e}, + {0xc8, 0x0}, + {0xc6, 0xa12f}, + {0xc8, 0x0}, + {0xc6, 0xa130}, + {0xc8, 0x4}, + {0xc6, 0xa131}, + {0xc8, 0x0}, + {0xc6, 0xa132}, + {0xc8, 0x1}, + {0xc6, 0xa133}, + {0xc8, 0x0}, + {0xc6, 0xa134}, + {0xc8, 0x1}, + {0xc6, 0xa135}, + {0xc8, 0x0}, + {0xc6, 0xa136}, + {0xc8, 0x0}, + {0xc6, 0xa137}, + {0xc8, 0x0}, + {0xc6, 0xa138}, + {0xc8, 0x0}, + {0xc6, 0xa139}, + {0xc8, 0x0}, + {0xc6, 0xa13a}, + {0xc8, 0x0}, + {0xc6, 0xa13b}, + {0xc8, 0x0}, + {0xc6, 0xa13c}, + {0xc8, 0x0}, + {0xc6, 0xa13d}, + {0xc8, 0x0}, + {0xc6, 0x2703}, + {0xc8, 0x140}, + {0xc6, 0x2705}, + {0xc8, 0xf0}, + {0xc6, 0x2707}, + {0xc8, 0x140}, + {0xc6, 0x2709}, + {0xc8, 0xf0}, + {0xc6, 0x270b}, + {0xc8, 0x30}, + {0xc6, 0x270f}, + {0xc8, 0x1c}, + {0xc6, 0x2711}, + {0xc8, 0x3c}, + {0xc6, 0x2713}, + {0xc8, 0x4b0}, + {0xc6, 0x2715}, + {0xc8, 0x640}, + {0xc6, 0x2717}, + {0xc8, 0x0}, + {0xc6, 0x2719}, + {0xc8, 0x11}, + {0xc6, 0x271b}, + {0xc8, 0x1c}, + {0xc6, 0x271d}, + {0xc8, 0x3c}, + {0xc6, 0x271f}, + {0xc8, 0x4b0}, + {0xc6, 0x2721}, + {0xc8, 0x640}, + {0xc6, 0x2723}, + {0xc8, 0x53c}, + {0xc6, 0x2725}, + {0xc8, 0x11}, + {0xc6, 0x2727}, + {0xc8, 0x0}, + {0xc6, 0x2729}, + {0xc8, 0x320}, + {0xc6, 0x272b}, + {0xc8, 0x0}, + {0xc6, 0x272d}, + {0xc8, 0x258}, + {0xc6, 0x2735}, + {0xc8, 0x0}, + {0xc6, 0x2737}, + {0xc8, 0x640}, + {0xc6, 0x2739}, + {0xc8, 0x0}, + {0xc6, 0x273b}, + {0xc8, 0x4b0}, + {0xc6, 0xa743}, + {0xc8, 0x42}, + {0xc6, 0xa744}, + {0xc8, 0x42}, + {0xc6, 0xa745}, + {0xc8, 0x0}, + {0xc6, 0xa746}, + {0xc8, 0x14}, + {0xc6, 0xa747}, + {0xc8, 0x23}, + {0xc6, 0xa748}, + {0xc8, 0x3a}, + {0xc6, 0xa749}, + {0xc8, 0x5e}, + {0xc6, 0xa74a}, + {0xc8, 0x76}, + {0xc6, 0xa74b}, + {0xc8, 0x88}, + {0xc6, 0xa74c}, + {0xc8, 0x96}, + {0xc6, 0xa74d}, + {0xc8, 0xa3}, + {0xc6, 0xa74e}, + {0xc8, 0xaf}, + {0xc6, 0xa74f}, + {0xc8, 0xba}, + {0xc6, 0xa750}, + {0xc8, 0xc4}, + {0xc6, 0xa751}, + {0xc8, 0xce}, + {0xc6, 0xa752}, + {0xc8, 0xd7}, + {0xc6, 0xa753}, + {0xc8, 0xe0}, + {0xc6, 0xa754}, + {0xc8, 0xe8}, + {0xc6, 0xa755}, + {0xc8, 0xf0}, + {0xc6, 0xa756}, + {0xc8, 0xf8}, + {0xc6, 0xa757}, + {0xc8, 0xff}, + {0xc6, 0xa758}, + {0xc8, 0x0}, + {0xc6, 0xa759}, + {0xc8, 0x14}, + {0xc6, 0xa75a}, + {0xc8, 0x23}, + {0xc6, 0xa75b}, + {0xc8, 0x3a}, + {0xc6, 0xa75c}, + {0xc8, 0x5e}, + {0xc6, 0xa75d}, + {0xc8, 0x76}, + {0xc6, 0xa75e}, + {0xc8, 0x88}, + {0xc6, 0xa75f}, + {0xc8, 0x96}, + {0xc6, 0xa760}, + {0xc8, 0xa3}, + {0xc6, 0xa761}, + {0xc8, 0xaf}, + {0xc6, 0xa762}, + {0xc8, 0xba}, + {0xc6, 0xa763}, + {0xc8, 0xc4}, + {0xc6, 0xa764}, + {0xc8, 0xce}, + {0xc6, 0xa765}, + {0xc8, 0xd7}, + {0xc6, 0xa766}, + {0xc8, 0xe0}, + {0xc6, 0xa767}, + {0xc8, 0xe8}, + {0xc6, 0xa768}, + {0xc8, 0xf0}, + {0xc6, 0xa769}, + {0xc8, 0xf8}, + {0xc6, 0xa76a}, + {0xc8, 0xff}, + {0xc6, 0x276d}, + {0xc8, 0xe0e2}, + {0xc6, 0xa76f}, + {0xc8, 0xe1}, + {0xc6, 0x2774}, + {0xc8, 0xe0e1}, + {0xc6, 0xa776}, + {0xc8, 0xe1}, + {0xc6, 0x220b}, + {0xc8, 0x192}, + {0xc6, 0xa217}, + {0xc8, 0x8}, + {0xc6, 0x2228}, + {0xc8, 0x20f}, + {0xc6, 0x222f}, + {0xc8, 0x0}, + {0xc6, 0xa408}, + {0xc8, 0xff}, + {0xc6, 0xa409}, + {0xc8, 0x1}, + {0xc6, 0xa40a}, + {0xc8, 0xff}, + {0xc6, 0xa40b}, + {0xc8, 0x1}, + {0xc6, 0x2411}, + {0xc8, 0x0}, + {0xc6, 0x2413}, + {0xc8, 0x0}, + {0xf0, 0x1}, + {0xc6, 0xa103}, + {0xc8, 0x6}, + {0xf0, 0x1}, + {0xc6, 0xa103}, + {0xc8, 0x5}, + {0xf0, 0x1}, + {0x97, 0x20}, + {0xff, 0xffff}, }; - -const struct sensor_reg MT9D111_QVGA_3fps[] PROGMEM= -{ - {0xf0, 0x0}, - - - //{0x65, 0xA000}, - //{0x65, 0x2000}, - - {0x33, 0x343}, - {0xf0, 0x1}, - {0xc6, 0xa115}, - {0xc8, 0x20}, - {0xf0, 0x0}, - {0x38, 0x866}, - {0xf0, 0x1}, - {0xc6, 0x2703}, - {0xc8, 0x640}, - {0xc6, 0x2705}, - {0xc8, 0x4b0}, - {0xf0, 0x0}, - {0x21, 0x402}, //Mirror Column - {0xf0, 0x1}, - {0xc6, 0x2729}, - {0xc8, 0x640}, - {0xc6, 0x272d}, - {0xc8, 0x4b0}, - {0xc6, 0xa103}, - {0xc8, 0x5}, - {0xf0, 0x0}, - {0xf2, 0x0}, - {0x3, 0x4b0}, - {0x4, 0x640}, - {0x65, 0xe000}, - {0x66, 0x1902}, - {0x67, 0x500}, - {0x65, 0xa000}, - {0xf0, 0x1}, - {0x97, 0x20}, - {0x98, 0x0}, - {0xf0, 0x1}, - {0x97, 0x20}, - {0xf0, 0x0}, - {0x33, 0x343}, - {0xf0, 0x1}, - {0xc6, 0xa115}, - {0xc8, 0x20}, - {0xf0, 0x0}, - {0x38, 0x866}, - {0xf0, 0x1}, - {0xc6, 0x2703}, - {0xc8, 0x640}, - {0xc6, 0x2705}, - {0xc8, 0x4b0}, - {0xf0, 0x0}, - {0x21, 0x402}, - {0x20, 0x7b6}, - {0xf0, 0x1}, - {0xc6, 0x2729}, - {0xc8, 0x640}, - {0xc6, 0x272d}, - {0xc8, 0x4b0}, - {0xc6, 0xa103}, - {0xc8, 0x5}, - {0xf0, 0x0}, - /* - {0x05, 0x00A2}, - {0x06, 0x0022}, - {0x07, 0x00A2}, - {0x08, 0x000B}, - {0x20, 0x07B4}, - {0x21, 0x04B4}, - {0x66, 0x5008}, - {0x67, 0x506 }, - */ - {0xf2, 0x0}, - {0x3, 0x4b0}, - {0x4, 0x640}, - {0x65, 0xe000}, - {0x66, 0x1902}, - {0x67, 0x500}, - {0x65, 0xa000}, - {0xf0, 0x1}, - {0x97, 0x20}, - {0x98, 0x0}, - {0xf0, 0x1}, - {0xc6, 0x2703}, - {0xc8, 0x140}, - {0xc6, 0x2705}, - {0xc8, 0xf0}, - {0xc6, 0x2707}, - {0xc8, 0x140}, - {0xc6, 0x2709}, - {0xc8, 0xf0}, - {0xc6, 0x2779}, - {0xc8, 0x140}, - {0xc6, 0x277b}, - {0xc8, 0xf0}, - {0xc6, 0xa103}, - {0xc8, 0x5}, - /* - {0xc6, 0x2120}, - {0xc8, 0x0}, - - {0xc6, 0x2103}, - {0xc8, 0x1}, - */ - {0xff, 0xffff}, -}; +const struct sensor_reg MT9D111_QVGA_3fps[] PROGMEM = + { + {0xf0, 0x0}, + + //{0x65, 0xA000}, + //{0x65, 0x2000}, + {0x33, 0x343}, + {0xf0, 0x1}, + {0xc6, 0xa115}, + {0xc8, 0x20}, + {0xf0, 0x0}, + {0x38, 0x866}, + {0xf0, 0x1}, + {0xc6, 0x2703}, + {0xc8, 0x640}, + {0xc6, 0x2705}, + {0xc8, 0x4b0}, + {0xf0, 0x0}, + {0x21, 0x402}, // Mirror Column + {0xf0, 0x1}, + {0xc6, 0x2729}, + {0xc8, 0x640}, + {0xc6, 0x272d}, + {0xc8, 0x4b0}, + {0xc6, 0xa103}, + {0xc8, 0x5}, + {0xf0, 0x0}, + {0xf2, 0x0}, + {0x3, 0x4b0}, + {0x4, 0x640}, + {0x65, 0xe000}, + {0x66, 0x1902}, + {0x67, 0x500}, + {0x65, 0xa000}, + {0xf0, 0x1}, + {0x97, 0x20}, + {0x98, 0x0}, + {0xf0, 0x1}, + {0x97, 0x20}, + {0xf0, 0x0}, + {0x33, 0x343}, + {0xf0, 0x1}, + {0xc6, 0xa115}, + {0xc8, 0x20}, + {0xf0, 0x0}, + {0x38, 0x866}, + {0xf0, 0x1}, + {0xc6, 0x2703}, + {0xc8, 0x640}, + {0xc6, 0x2705}, + {0xc8, 0x4b0}, + {0xf0, 0x0}, + {0x21, 0x402}, + {0x20, 0x7b6}, + {0xf0, 0x1}, + {0xc6, 0x2729}, + {0xc8, 0x640}, + {0xc6, 0x272d}, + {0xc8, 0x4b0}, + {0xc6, 0xa103}, + {0xc8, 0x5}, + {0xf0, 0x0}, + /* + {0x05, 0x00A2}, + {0x06, 0x0022}, + {0x07, 0x00A2}, + {0x08, 0x000B}, + {0x20, 0x07B4}, + {0x21, 0x04B4}, + {0x66, 0x5008}, + {0x67, 0x506 }, + */ + {0xf2, 0x0}, + {0x3, 0x4b0}, + {0x4, 0x640}, + {0x65, 0xe000}, + {0x66, 0x1902}, + {0x67, 0x500}, + {0x65, 0xa000}, + {0xf0, 0x1}, + {0x97, 0x20}, + {0x98, 0x0}, + {0xf0, 0x1}, + {0xc6, 0x2703}, + {0xc8, 0x140}, + {0xc6, 0x2705}, + {0xc8, 0xf0}, + {0xc6, 0x2707}, + {0xc8, 0x140}, + {0xc6, 0x2709}, + {0xc8, 0xf0}, + {0xc6, 0x2779}, + {0xc8, 0x140}, + {0xc6, 0x277b}, + {0xc8, 0xf0}, + {0xc6, 0xa103}, + {0xc8, 0x5}, + /* + {0xc6, 0x2120}, + {0xc8, 0x0}, + + {0xc6, 0x2103}, + {0xc8, 0x1}, + */ + {0xff, 0xffff}, +}; -#endif //MT9D111_REGS_H \ No newline at end of file +#endif // MT9D111_REGS_H \ No newline at end of file diff --git a/ArduCAM/mt9d112_regs.h b/ArduCAM/mt9d112_regs.h index b5b35887..19fe069d 100644 --- a/ArduCAM/mt9d112_regs.h +++ b/ArduCAM/mt9d112_regs.h @@ -3,472 +3,469 @@ #include "ArduCAM.h" #include -const struct sensor_reg MT9T112_QVGA[] PROGMEM= -{ - +const struct sensor_reg MT9T112_QVGA[] PROGMEM = + { - - {0xffff, 0xffff}, + {0xffff, 0xffff}, }; -const struct sensor_reg MT9D112_soc_init[] PROGMEM= -{ - {0x34ce , 0x01a0 }, - {0x34d0 , 0x6532 }, - {0x34d2 , 0x3297 }, - {0x34d4 , 0x9664 }, - {0x34d6 , 0x4b25 }, - {0x34d8 , 0x2670 }, - {0x34da , 0x724c }, - {0x34dc , 0xff01 }, - {0x34de , 0x011f }, - {0x34e6 , 0x00b3 }, - {0x34ee , 0x0d8f }, - {0x34f6 , 0x0d6e }, - {0x3500 , 0xf51c }, - {0x3508 , 0xfef8 }, - {0x3510 , 0x212d }, - {0x3518 , 0x212b }, - {0x3520 , 0x1f2a }, - {0x3528 , 0x2934 }, - {0x3530 , 0x17db }, - {0x3538 , 0xe7d6 }, - {0x354c , 0x07c6 }, - {0x3544 , 0x07ff }, - {0x355c , 0x051c }, - {0x3554 , 0x07ff }, - {0x34e0 , 0x0137 }, - {0x34e8 , 0x00a8 }, - {0x34f0 , 0x0e3e }, - {0x34f8 , 0x0dcb }, - {0x3502 , 0xf20a }, - {0x350a , 0xfbe1 }, - {0x3512 , 0x1c26 }, - {0x351a , 0x232b }, - {0x3522 , 0x312e }, - {0x352a , 0x2121 }, - {0x3532 , 0xf106 }, - {0x353a , 0x0c0d }, - {0x354e , 0x07ff }, - {0x3546 , 0x0638 }, - {0x355e , 0x07ff }, - {0x3556 , 0x0155 }, - {0x34e4 , 0x0107 }, - {0x34ec , 0x0079 }, - {0x34f4 , 0x0e19 }, - {0x34fc , 0x0d35 }, - {0x3506 , 0x111c }, - {0x350e , 0x02e6 }, - {0x3516 , 0x2521 }, - {0x351e , 0x2620 }, - {0x3526 , 0x1a25 }, - {0x352e , 0x0b1d }, - {0x3536 , 0xfd03 }, - {0x353e , 0xb315 }, - {0x3552 , 0x06d0 }, - {0x354a , 0x03ff }, - {0x3562 , 0x07ff }, - {0x355a , 0x057b }, - {0x34e2 , 0x011e }, - {0x34ea , 0x008a }, - {0x34f2 , 0x0d6e }, - {0x34fa , 0x0d7f }, - {0x3504 , 0xf822 }, - {0x350c , 0x0dfc }, - {0x3514 , 0x1f25 }, - {0x351c , 0x3032 }, - {0x3524 , 0x2628 }, - {0x352c , 0x1523 }, - {0x3534 , 0xfadf }, - {0x353c , 0xdef7 }, - {0x3550 , 0x0109 }, - {0x3548 , 0x0638 }, - {0x3560 , 0x0638 }, - {0x3558 , 0x07ff }, - {0x3540 , 0x0000 }, - {0x3542 , 0x0000 }, - {0x3210 , 0x01fc }, - {0x338c , 0xa364 }, - {0x3390 , 0x0080 }, - {0x338c , 0xa364 }, - {0x3390 , 0x0080 }, - {0x338c , 0xa365 }, - {0x3390 , 0x008c }, - {0x338c , 0xa365 }, - {0x3390 , 0x008c }, - {0x338c , 0xa366 }, - {0x3390 , 0x0082 }, - {0x338c , 0xa366 }, - {0x3390 , 0x0082 }, - {0x338c , 0x2306 }, - {0x3390 , 0x0619 }, - {0x338c , 0x2308 }, - {0x3390 , 0xfc80 }, - {0x338c , 0x230a }, - {0x3390 , 0xfefb }, - {0x338c , 0x230c }, - {0x3390 , 0xfeee }, - {0x338c , 0x230e }, - {0x3390 , 0x0571 }, - {0x338c , 0x2310 }, - {0x3390 , 0xfe26 }, - {0x338c , 0x2312 }, - {0x3390 , 0xff0c }, - {0x338c , 0x2314 }, - {0x3390 , 0xfe48 }, - {0x338c , 0x2316 }, - {0x3390 , 0x04a2 }, - {0x338c , 0x2318 }, - {0x3390 , 0x0024 }, - {0x338c , 0x231a }, - {0x3390 , 0x003f }, - {0x338c , 0x231c }, - {0x3390 , 0xfda7 }, - {0x338c , 0x231e }, - {0x3390 , 0x0158 }, - {0x338c , 0x2320 }, - {0x3390 , 0x00ee }, - {0x338c , 0x2322 }, - {0x3390 , 0x00d3 }, - {0x338c , 0x2324 }, - {0x3390 , 0xfc74 }, - {0x338c , 0x2326 }, - {0x3390 , 0x01a9 }, - {0x338c , 0x2328 }, - {0x3390 , 0x014b }, - {0x338c , 0x232a }, - {0x3390 , 0xfe9d }, - {0x338c , 0x232c }, - {0x3390 , 0xff69 }, - {0x338c , 0x232e }, - {0x3390 , 0x0018 }, - {0x338c , 0x2330 }, - {0x3390 , 0xffec }, - {0x338c , 0xa348 }, - {0x3390 , 0x0008 }, - {0x338c , 0xa349 }, - {0x3390 , 0x0002 }, - {0x338c , 0xa34a }, - {0x3390 , 0x0059 }, - {0x338c , 0xa34b }, - {0x3390 , 0x00a6 }, - {0x338c , 0xa34f }, - {0x3390 , 0x0000 }, - {0x338c , 0xa350 }, - {0x3390 , 0x007f }, - {0x338c , 0xa353 }, - {0x3390 , 0x0002 }, - {0x338c , 0xa35b }, - {0x3390 , 0x0078 }, - {0x338c , 0xa35c }, - {0x3390 , 0x0086 }, - {0x338c , 0xa35d }, - {0x3390 , 0x007e }, - {0x338c , 0xa35e }, - {0x3390 , 0x0082 }, - {0x338c , 0x235f }, - {0x3390 , 0x0040 }, - {0x338c , 0xa361 }, - {0x3390 , 0x00c8 }, - {0x338c , 0xa362 }, - {0x3390 , 0x00e1 }, - {0x338c , 0xa302 }, - {0x3390 , 0x0000 }, - {0x338c , 0xa303 }, - {0x3390 , 0x00ef }, - {0x338c , 0xa352 }, - {0x3390 , 0x001e }, - {0x338c , 0xa118 }, - {0x3390 , 0x001e }, - {0x338c , 0xa103 }, - {0x3390 , 0x0005 }, - {0x338c , 0xa76d }, - {0x3390 , 0x0003 }, - {0x338c , 0xa76f }, - {0x3390 , 0x0000 }, - {0x338c , 0xa770 }, - {0x3390 , 0x000b }, - {0x338c , 0xa771 }, - {0x3390 , 0x0023 }, - {0x338c , 0xa772 }, - {0x3390 , 0x0043 }, - {0x338c , 0xa773 }, - {0x3390 , 0x006e }, - {0x338c , 0xa774 }, - {0x3390 , 0x0090 }, - {0x338c , 0xa775 }, - {0x3390 , 0x00a8 }, - {0x338c , 0xa776 }, - {0x3390 , 0x00b9 }, - {0x338c , 0xa777 }, - {0x3390 , 0x00c6 }, - {0x338c , 0xa778 }, - {0x3390 , 0x00d0 }, - {0x338c , 0xa779 }, - {0x3390 , 0x00d9 }, - {0x338c , 0xa77a }, - {0x3390 , 0x00e0 }, - {0x338c , 0xa77b }, - {0x3390 , 0x00e6 }, - {0x338c , 0xa77c }, - {0x3390 , 0x00eb }, - {0x338c , 0xa77d }, - {0x3390 , 0x00f0 }, - {0x338c , 0xa77e }, - {0x3390 , 0x00f4 }, - {0x338c , 0xa77f }, - {0x3390 , 0x00f8 }, - {0x338c , 0xa780 }, - {0x3390 , 0x00fc }, - {0x338c , 0xa781 }, - {0x3390 , 0x00ff }, - {0x338c , 0xa102 }, - {0x3390 , 0x002f }, - {0x338c , 0xa114 }, - {0x3390 , 0x0005 }, +const struct sensor_reg MT9D112_soc_init[] PROGMEM = + { + {0x34ce, 0x01a0}, + {0x34d0, 0x6532}, + {0x34d2, 0x3297}, + {0x34d4, 0x9664}, + {0x34d6, 0x4b25}, + {0x34d8, 0x2670}, + {0x34da, 0x724c}, + {0x34dc, 0xff01}, + {0x34de, 0x011f}, + {0x34e6, 0x00b3}, + {0x34ee, 0x0d8f}, + {0x34f6, 0x0d6e}, + {0x3500, 0xf51c}, + {0x3508, 0xfef8}, + {0x3510, 0x212d}, + {0x3518, 0x212b}, + {0x3520, 0x1f2a}, + {0x3528, 0x2934}, + {0x3530, 0x17db}, + {0x3538, 0xe7d6}, + {0x354c, 0x07c6}, + {0x3544, 0x07ff}, + {0x355c, 0x051c}, + {0x3554, 0x07ff}, + {0x34e0, 0x0137}, + {0x34e8, 0x00a8}, + {0x34f0, 0x0e3e}, + {0x34f8, 0x0dcb}, + {0x3502, 0xf20a}, + {0x350a, 0xfbe1}, + {0x3512, 0x1c26}, + {0x351a, 0x232b}, + {0x3522, 0x312e}, + {0x352a, 0x2121}, + {0x3532, 0xf106}, + {0x353a, 0x0c0d}, + {0x354e, 0x07ff}, + {0x3546, 0x0638}, + {0x355e, 0x07ff}, + {0x3556, 0x0155}, + {0x34e4, 0x0107}, + {0x34ec, 0x0079}, + {0x34f4, 0x0e19}, + {0x34fc, 0x0d35}, + {0x3506, 0x111c}, + {0x350e, 0x02e6}, + {0x3516, 0x2521}, + {0x351e, 0x2620}, + {0x3526, 0x1a25}, + {0x352e, 0x0b1d}, + {0x3536, 0xfd03}, + {0x353e, 0xb315}, + {0x3552, 0x06d0}, + {0x354a, 0x03ff}, + {0x3562, 0x07ff}, + {0x355a, 0x057b}, + {0x34e2, 0x011e}, + {0x34ea, 0x008a}, + {0x34f2, 0x0d6e}, + {0x34fa, 0x0d7f}, + {0x3504, 0xf822}, + {0x350c, 0x0dfc}, + {0x3514, 0x1f25}, + {0x351c, 0x3032}, + {0x3524, 0x2628}, + {0x352c, 0x1523}, + {0x3534, 0xfadf}, + {0x353c, 0xdef7}, + {0x3550, 0x0109}, + {0x3548, 0x0638}, + {0x3560, 0x0638}, + {0x3558, 0x07ff}, + {0x3540, 0x0000}, + {0x3542, 0x0000}, + {0x3210, 0x01fc}, + {0x338c, 0xa364}, + {0x3390, 0x0080}, + {0x338c, 0xa364}, + {0x3390, 0x0080}, + {0x338c, 0xa365}, + {0x3390, 0x008c}, + {0x338c, 0xa365}, + {0x3390, 0x008c}, + {0x338c, 0xa366}, + {0x3390, 0x0082}, + {0x338c, 0xa366}, + {0x3390, 0x0082}, + {0x338c, 0x2306}, + {0x3390, 0x0619}, + {0x338c, 0x2308}, + {0x3390, 0xfc80}, + {0x338c, 0x230a}, + {0x3390, 0xfefb}, + {0x338c, 0x230c}, + {0x3390, 0xfeee}, + {0x338c, 0x230e}, + {0x3390, 0x0571}, + {0x338c, 0x2310}, + {0x3390, 0xfe26}, + {0x338c, 0x2312}, + {0x3390, 0xff0c}, + {0x338c, 0x2314}, + {0x3390, 0xfe48}, + {0x338c, 0x2316}, + {0x3390, 0x04a2}, + {0x338c, 0x2318}, + {0x3390, 0x0024}, + {0x338c, 0x231a}, + {0x3390, 0x003f}, + {0x338c, 0x231c}, + {0x3390, 0xfda7}, + {0x338c, 0x231e}, + {0x3390, 0x0158}, + {0x338c, 0x2320}, + {0x3390, 0x00ee}, + {0x338c, 0x2322}, + {0x3390, 0x00d3}, + {0x338c, 0x2324}, + {0x3390, 0xfc74}, + {0x338c, 0x2326}, + {0x3390, 0x01a9}, + {0x338c, 0x2328}, + {0x3390, 0x014b}, + {0x338c, 0x232a}, + {0x3390, 0xfe9d}, + {0x338c, 0x232c}, + {0x3390, 0xff69}, + {0x338c, 0x232e}, + {0x3390, 0x0018}, + {0x338c, 0x2330}, + {0x3390, 0xffec}, + {0x338c, 0xa348}, + {0x3390, 0x0008}, + {0x338c, 0xa349}, + {0x3390, 0x0002}, + {0x338c, 0xa34a}, + {0x3390, 0x0059}, + {0x338c, 0xa34b}, + {0x3390, 0x00a6}, + {0x338c, 0xa34f}, + {0x3390, 0x0000}, + {0x338c, 0xa350}, + {0x3390, 0x007f}, + {0x338c, 0xa353}, + {0x3390, 0x0002}, + {0x338c, 0xa35b}, + {0x3390, 0x0078}, + {0x338c, 0xa35c}, + {0x3390, 0x0086}, + {0x338c, 0xa35d}, + {0x3390, 0x007e}, + {0x338c, 0xa35e}, + {0x3390, 0x0082}, + {0x338c, 0x235f}, + {0x3390, 0x0040}, + {0x338c, 0xa361}, + {0x3390, 0x00c8}, + {0x338c, 0xa362}, + {0x3390, 0x00e1}, + {0x338c, 0xa302}, + {0x3390, 0x0000}, + {0x338c, 0xa303}, + {0x3390, 0x00ef}, + {0x338c, 0xa352}, + {0x3390, 0x001e}, + {0x338c, 0xa118}, + {0x3390, 0x001e}, + {0x338c, 0xa103}, + {0x3390, 0x0005}, + {0x338c, 0xa76d}, + {0x3390, 0x0003}, + {0x338c, 0xa76f}, + {0x3390, 0x0000}, + {0x338c, 0xa770}, + {0x3390, 0x000b}, + {0x338c, 0xa771}, + {0x3390, 0x0023}, + {0x338c, 0xa772}, + {0x3390, 0x0043}, + {0x338c, 0xa773}, + {0x3390, 0x006e}, + {0x338c, 0xa774}, + {0x3390, 0x0090}, + {0x338c, 0xa775}, + {0x3390, 0x00a8}, + {0x338c, 0xa776}, + {0x3390, 0x00b9}, + {0x338c, 0xa777}, + {0x3390, 0x00c6}, + {0x338c, 0xa778}, + {0x3390, 0x00d0}, + {0x338c, 0xa779}, + {0x3390, 0x00d9}, + {0x338c, 0xa77a}, + {0x3390, 0x00e0}, + {0x338c, 0xa77b}, + {0x3390, 0x00e6}, + {0x338c, 0xa77c}, + {0x3390, 0x00eb}, + {0x338c, 0xa77d}, + {0x3390, 0x00f0}, + {0x338c, 0xa77e}, + {0x3390, 0x00f4}, + {0x338c, 0xa77f}, + {0x3390, 0x00f8}, + {0x338c, 0xa780}, + {0x3390, 0x00fc}, + {0x338c, 0xa781}, + {0x3390, 0x00ff}, + {0x338c, 0xa102}, + {0x3390, 0x002f}, + {0x338c, 0xa114}, + {0x3390, 0x0005}, - {0x338c , 0xa103 }, - {0x3390 , 0x0005 }, + {0x338c, 0xa103}, + {0x3390, 0x0005}, - {0x338c , 0xa206 }, - {0x3390 , 0x003c }, - {0xffff,0xffff}, -}; + {0x338c, 0xa206}, + {0x3390, 0x003c}, + {0xffff, 0xffff}, +}; const struct sensor_reg MT9D112_default_setting[] PROGMEM = -{ - {0x341e , 0x8f09 }, - {0x341e , 0x8f08 }, - {0x3044 , 0x0540 }, - {0x3216 , 0x02cf }, - {0x321c , 0x0402 }, - {0x3212 , 0x0001 }, - {0x341e , 0x8f09 }, - {0x341c , 0x0114 }, - {0x341e , 0x8f09 }, - {0x341e , 0x8f08 }, - {0x3044 , 0x0540 }, - {0x3216 , 0x02cf }, - {0x321c , 0x0402 }, - {0x3212 , 0x0001 }, - {0x338c , 0x2703 }, - {0x3390 , 0x0140 }, - {0x338c , 0x2705 }, - {0x3390 , 0x00f0 }, - {0x338c , 0x2707 }, - {0x3390 , 0x0640 }, - {0x338c , 0x2709 }, - {0x3390 , 0x04b0 }, - {0x338c , 0x270d }, - {0x3390 , 0x0000 }, - {0x338c , 0x270f }, - {0x3390 , 0x0000 }, - {0x338c , 0x2711 }, - {0x3390 , 0x04bd }, - {0x338c , 0x2713 }, - {0x3390 , 0x064d }, - {0x338c , 0x2715 }, - {0x3390 , 0x0022 }, - {0x338c , 0x2717 }, - {0x3390 , 0x2111 }, - {0x338c , 0x2719 }, - {0x3390 , 0x046c }, - {0x338c , 0x271b }, - {0x3390 , 0x024f }, - {0x338c , 0x271d }, - {0x3390 , 0x0102 }, - {0x338c , 0x271f }, - {0x3390 , 0x0279 }, - {0x338c , 0x2721 }, - {0x3390 , 0x0155 }, - {0x338c , 0x2723 }, - {0x3390 , 0x0293 }, - {0x338c , 0x2725 }, - {0x3390 , 0x0824 }, - {0x338c , 0x2727 }, - {0x3390 , 0x2020 }, - {0x338c , 0x2729 }, - {0x3390 , 0x2020 }, - {0x338c , 0x272b }, - {0x3390 , 0x1020 }, - {0x338c , 0x272d }, - {0x3390 , 0x2007 }, - {0x338c , 0x272f }, - {0x3390 , 0x0004 }, - {0x338c , 0x2731 }, - {0x3390 , 0x0004 }, - {0x338c , 0x2733 }, - {0x3390 , 0x04bb }, - {0x338c , 0x2735 }, - {0x3390 , 0x064b }, - {0x338c , 0x2737 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2739 }, - {0x3390 , 0x2111 }, - {0x338c , 0x273b }, - {0x3390 , 0x0024 }, - {0x338c , 0x273d }, - {0x3390 , 0x0120 }, - {0x338c , 0x273f }, - {0x3390 , 0x00a4 }, - {0x338c , 0x2741 }, - {0x3390 , 0x0169 }, - {0x338c , 0x2743 }, - {0x3390 , 0x00a4 }, - {0x338c , 0x2745 }, - {0x3390 , 0x04ed }, - {0x338c , 0x2747 }, - {0x3390 , 0x0824 }, - {0x338c , 0x2751 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2753 }, - {0x3390 , 0x0320 }, - {0x338c , 0x2755 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2757 }, - {0x3390 , 0x0258 }, - {0x338c , 0x275f }, - {0x3390 , 0x0000 }, - {0x338c , 0x2761 }, - {0x3390 , 0x0640 }, - {0x338c , 0x2763 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2765 }, - {0x3390 , 0x04b0 }, - {0x338c , 0x222e }, - {0x3390 , 0x0060 }, - {0x338c , 0xa408 }, - {0x3390 , 0x0017 }, - {0x338c , 0xa409 }, - {0x3390 , 0x001a }, - {0x338c , 0xa40a }, - {0x3390 , 0x001b }, - {0x338c , 0xa40b }, - {0x3390 , 0x001e }, - {0x338c , 0x2411 }, - {0x3390 , 0x0060 }, - {0x338c , 0x2413 }, - {0x3390 , 0x0073 }, - {0x338c , 0x2415 }, - {0x3390 , 0x0060 }, - {0x338c , 0x2417 }, - {0x3390 , 0x0073 }, - {0x338c , 0xa40d }, - {0x3390 , 0x0002 }, - {0x338c , 0xa410 }, - {0x3390 , 0x0001 }, - {0x338c , 0xa103 }, - {0x3390 , 0x0006 }, - {0x338c , 0xa103 }, - {0x3390 , 0x0005 }, - {0x338c , 0x2703 }, - {0x3390 , 0x0140 }, - {0x338c , 0x2705 }, - {0x3390 , 0x00f0 }, - {0x338c , 0x2707 }, - {0x3390 , 0x0640 }, - {0x338c , 0x2709 }, - {0x3390 , 0x04b0 }, - {0x338c , 0x270d }, - {0x3390 , 0x0000 }, - {0x338c , 0x270f }, - {0x3390 , 0x0000 }, - {0x338c , 0x2711 }, - {0x3390 , 0x04bd }, - {0x338c , 0x2713 }, - {0x3390 , 0x064d }, - {0x338c , 0x2715 }, - {0x3390 , 0x0022 }, - {0x338c , 0x2717 }, - {0x3390 , 0x2111 }, - {0x338c , 0x2719 }, - {0x3390 , 0x046c }, - {0x338c , 0x271b }, - {0x3390 , 0x024f }, - {0x338c , 0x271d }, - {0x3390 , 0x0102 }, - {0x338c , 0x271f }, - {0x3390 , 0x0279 }, - {0x338c , 0x2721 }, - {0x3390 , 0x0155 }, - {0x338c , 0x2723 }, - {0x3390 , 0x0293 }, - {0x338c , 0x2725 }, - {0x3390 , 0x0824 }, - {0x338c , 0x2727 }, - {0x3390 , 0x2020 }, - {0x338c , 0x2729 }, - {0x3390 , 0x2020 }, - {0x338c , 0x272b }, - {0x3390 , 0x1020 }, - {0x338c , 0x272d }, - {0x3390 , 0x2007 }, - {0x338c , 0x272f }, - {0x3390 , 0x0004 }, - {0x338c , 0x2731 }, - {0x3390 , 0x0004 }, - {0x338c , 0x2733 }, - {0x3390 , 0x04bb }, - {0x338c , 0x2735 }, - {0x3390 , 0x064b }, - {0x338c , 0x2737 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2739 }, - {0x3390 , 0x2111 }, - {0x338c , 0x273b }, - {0x3390 , 0x0024 }, - {0x338c , 0x273d }, - {0x3390 , 0x0120 }, - {0x338c , 0x273f }, - {0x3390 , 0x00a4 }, - {0x338c , 0x2741 }, - {0x3390 , 0x0169 }, - {0x338c , 0x2743 }, - {0x3390 , 0x00a4 }, - {0x338c , 0x2745 }, - {0x3390 , 0x04ed }, - {0x338c , 0x2747 }, - {0x3390 , 0x0824 }, - {0x338c , 0x2751 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2753 }, - {0x3390 , 0x0320 }, - {0x338c , 0x2755 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2757 }, - {0x3390 , 0x0258 }, - {0x338c , 0x275f }, - {0x3390 , 0x0000 }, - {0x338c , 0x2761 }, - {0x3390 , 0x0640 }, - {0x338c , 0x2763 }, - {0x3390 , 0x0000 }, - {0x338c , 0x2765 }, - {0x3390 , 0x04b0 }, - {0x338c , 0x222e }, - {0x3390 , 0x0060 }, - {0x338c , 0xa408 }, - {0x3390 , 0x0017 }, - {0x338c , 0xa409 }, - {0x3390 , 0x001a }, - {0x338c , 0xa40a }, - {0x3390 , 0x001b }, - {0x338c , 0xa40b }, - {0x3390 , 0x001e }, - {0x338c , 0x2411 }, - {0x3390 , 0x0060 }, - {0x338c , 0x2413 }, - {0x3390 , 0x0073 }, - {0x338c , 0x2415 }, - {0x3390 , 0x0060 }, - {0x338c , 0x2417 }, - {0x3390 , 0x0073 }, - {0x338c , 0xa40d }, - {0x3390 , 0x0002 }, - {0x338c , 0xa410 }, - {0x3390 , 0x0001 }, - - {0xffff,0xffff}, -}; -#endif + { + {0x341e, 0x8f09}, + {0x341e, 0x8f08}, + {0x3044, 0x0540}, + {0x3216, 0x02cf}, + {0x321c, 0x0402}, + {0x3212, 0x0001}, + {0x341e, 0x8f09}, + {0x341c, 0x0114}, + {0x341e, 0x8f09}, + {0x341e, 0x8f08}, + {0x3044, 0x0540}, + {0x3216, 0x02cf}, + {0x321c, 0x0402}, + {0x3212, 0x0001}, + {0x338c, 0x2703}, + {0x3390, 0x0140}, + {0x338c, 0x2705}, + {0x3390, 0x00f0}, + {0x338c, 0x2707}, + {0x3390, 0x0640}, + {0x338c, 0x2709}, + {0x3390, 0x04b0}, + {0x338c, 0x270d}, + {0x3390, 0x0000}, + {0x338c, 0x270f}, + {0x3390, 0x0000}, + {0x338c, 0x2711}, + {0x3390, 0x04bd}, + {0x338c, 0x2713}, + {0x3390, 0x064d}, + {0x338c, 0x2715}, + {0x3390, 0x0022}, + {0x338c, 0x2717}, + {0x3390, 0x2111}, + {0x338c, 0x2719}, + {0x3390, 0x046c}, + {0x338c, 0x271b}, + {0x3390, 0x024f}, + {0x338c, 0x271d}, + {0x3390, 0x0102}, + {0x338c, 0x271f}, + {0x3390, 0x0279}, + {0x338c, 0x2721}, + {0x3390, 0x0155}, + {0x338c, 0x2723}, + {0x3390, 0x0293}, + {0x338c, 0x2725}, + {0x3390, 0x0824}, + {0x338c, 0x2727}, + {0x3390, 0x2020}, + {0x338c, 0x2729}, + {0x3390, 0x2020}, + {0x338c, 0x272b}, + {0x3390, 0x1020}, + {0x338c, 0x272d}, + {0x3390, 0x2007}, + {0x338c, 0x272f}, + {0x3390, 0x0004}, + {0x338c, 0x2731}, + {0x3390, 0x0004}, + {0x338c, 0x2733}, + {0x3390, 0x04bb}, + {0x338c, 0x2735}, + {0x3390, 0x064b}, + {0x338c, 0x2737}, + {0x3390, 0x0000}, + {0x338c, 0x2739}, + {0x3390, 0x2111}, + {0x338c, 0x273b}, + {0x3390, 0x0024}, + {0x338c, 0x273d}, + {0x3390, 0x0120}, + {0x338c, 0x273f}, + {0x3390, 0x00a4}, + {0x338c, 0x2741}, + {0x3390, 0x0169}, + {0x338c, 0x2743}, + {0x3390, 0x00a4}, + {0x338c, 0x2745}, + {0x3390, 0x04ed}, + {0x338c, 0x2747}, + {0x3390, 0x0824}, + {0x338c, 0x2751}, + {0x3390, 0x0000}, + {0x338c, 0x2753}, + {0x3390, 0x0320}, + {0x338c, 0x2755}, + {0x3390, 0x0000}, + {0x338c, 0x2757}, + {0x3390, 0x0258}, + {0x338c, 0x275f}, + {0x3390, 0x0000}, + {0x338c, 0x2761}, + {0x3390, 0x0640}, + {0x338c, 0x2763}, + {0x3390, 0x0000}, + {0x338c, 0x2765}, + {0x3390, 0x04b0}, + {0x338c, 0x222e}, + {0x3390, 0x0060}, + {0x338c, 0xa408}, + {0x3390, 0x0017}, + {0x338c, 0xa409}, + {0x3390, 0x001a}, + {0x338c, 0xa40a}, + {0x3390, 0x001b}, + {0x338c, 0xa40b}, + {0x3390, 0x001e}, + {0x338c, 0x2411}, + {0x3390, 0x0060}, + {0x338c, 0x2413}, + {0x3390, 0x0073}, + {0x338c, 0x2415}, + {0x3390, 0x0060}, + {0x338c, 0x2417}, + {0x3390, 0x0073}, + {0x338c, 0xa40d}, + {0x3390, 0x0002}, + {0x338c, 0xa410}, + {0x3390, 0x0001}, + {0x338c, 0xa103}, + {0x3390, 0x0006}, + {0x338c, 0xa103}, + {0x3390, 0x0005}, + {0x338c, 0x2703}, + {0x3390, 0x0140}, + {0x338c, 0x2705}, + {0x3390, 0x00f0}, + {0x338c, 0x2707}, + {0x3390, 0x0640}, + {0x338c, 0x2709}, + {0x3390, 0x04b0}, + {0x338c, 0x270d}, + {0x3390, 0x0000}, + {0x338c, 0x270f}, + {0x3390, 0x0000}, + {0x338c, 0x2711}, + {0x3390, 0x04bd}, + {0x338c, 0x2713}, + {0x3390, 0x064d}, + {0x338c, 0x2715}, + {0x3390, 0x0022}, + {0x338c, 0x2717}, + {0x3390, 0x2111}, + {0x338c, 0x2719}, + {0x3390, 0x046c}, + {0x338c, 0x271b}, + {0x3390, 0x024f}, + {0x338c, 0x271d}, + {0x3390, 0x0102}, + {0x338c, 0x271f}, + {0x3390, 0x0279}, + {0x338c, 0x2721}, + {0x3390, 0x0155}, + {0x338c, 0x2723}, + {0x3390, 0x0293}, + {0x338c, 0x2725}, + {0x3390, 0x0824}, + {0x338c, 0x2727}, + {0x3390, 0x2020}, + {0x338c, 0x2729}, + {0x3390, 0x2020}, + {0x338c, 0x272b}, + {0x3390, 0x1020}, + {0x338c, 0x272d}, + {0x3390, 0x2007}, + {0x338c, 0x272f}, + {0x3390, 0x0004}, + {0x338c, 0x2731}, + {0x3390, 0x0004}, + {0x338c, 0x2733}, + {0x3390, 0x04bb}, + {0x338c, 0x2735}, + {0x3390, 0x064b}, + {0x338c, 0x2737}, + {0x3390, 0x0000}, + {0x338c, 0x2739}, + {0x3390, 0x2111}, + {0x338c, 0x273b}, + {0x3390, 0x0024}, + {0x338c, 0x273d}, + {0x3390, 0x0120}, + {0x338c, 0x273f}, + {0x3390, 0x00a4}, + {0x338c, 0x2741}, + {0x3390, 0x0169}, + {0x338c, 0x2743}, + {0x3390, 0x00a4}, + {0x338c, 0x2745}, + {0x3390, 0x04ed}, + {0x338c, 0x2747}, + {0x3390, 0x0824}, + {0x338c, 0x2751}, + {0x3390, 0x0000}, + {0x338c, 0x2753}, + {0x3390, 0x0320}, + {0x338c, 0x2755}, + {0x3390, 0x0000}, + {0x338c, 0x2757}, + {0x3390, 0x0258}, + {0x338c, 0x275f}, + {0x3390, 0x0000}, + {0x338c, 0x2761}, + {0x3390, 0x0640}, + {0x338c, 0x2763}, + {0x3390, 0x0000}, + {0x338c, 0x2765}, + {0x3390, 0x04b0}, + {0x338c, 0x222e}, + {0x3390, 0x0060}, + {0x338c, 0xa408}, + {0x3390, 0x0017}, + {0x338c, 0xa409}, + {0x3390, 0x001a}, + {0x338c, 0xa40a}, + {0x3390, 0x001b}, + {0x338c, 0xa40b}, + {0x3390, 0x001e}, + {0x338c, 0x2411}, + {0x3390, 0x0060}, + {0x338c, 0x2413}, + {0x3390, 0x0073}, + {0x338c, 0x2415}, + {0x3390, 0x0060}, + {0x338c, 0x2417}, + {0x3390, 0x0073}, + {0x338c, 0xa40d}, + {0x3390, 0x0002}, + {0x338c, 0xa410}, + {0x3390, 0x0001}, + {0xffff, 0xffff}, +}; +#endif diff --git a/ArduCAM/mt9m001_regs.h b/ArduCAM/mt9m001_regs.h index fd1a689f..ffa4947f 100644 --- a/ArduCAM/mt9m001_regs.h +++ b/ArduCAM/mt9m001_regs.h @@ -1,18 +1,14 @@ #ifndef MT9M001_REGS_H #define MT9M001_REGS_H #include "ArduCAM.h" -//#include +// #include -const struct sensor_reg MT9M001_QVGA_30fps[] PROGMEM= -{ - - {0x03, 240},//Row Size - {0x04, 639},//Col Size +const struct sensor_reg MT9M001_QVGA_30fps[] PROGMEM = + { - {0xff, 0xffff } -}; + {0x03, 240}, // Row Size + {0x04, 639}, // Col Size + {0xff, 0xffff}}; - - -#endif //MT9M001_REGS_H \ No newline at end of file +#endif // MT9M001_REGS_H \ No newline at end of file diff --git a/ArduCAM/mt9m034_regs.h b/ArduCAM/mt9m034_regs.h index 5ca8013d..fc311f0d 100644 --- a/ArduCAM/mt9m034_regs.h +++ b/ArduCAM/mt9m034_regs.h @@ -3,7 +3,7 @@ #include "ArduCAM.h" #include -//const struct sensor_reg MT9M034_RAW PROGMEM = +// const struct sensor_reg MT9M034_RAW PROGMEM = //{ //{0x3028, 0x0010}, // ROW_SPEED = 16 //{0x302E, 0x0002}, // PRE_PLL_CLK_DIV = 2 (N) @@ -39,9 +39,8 @@ //{0x3064, 0x1982}, // EMBEDDED_DATA_CTRL = 6530 //{0x31C6, 0x8000}, // HISPI_CONTROL_STATUS = 32768 (DEFAULT) //{0xffff, 0xffff}, -//}; -//#endif - +// }; +// #endif //{0x3056, 33 } //{0x3058, 50 } @@ -49,42 +48,41 @@ //{0x305c, 33 } //{ - -const struct sensor_reg MT9M034_RAW[] PROGMEM= -{ - {0x3028, 0x0010}, // ROW_SPEED = 16 -{0x302E, 0x0002}, // PRE_PLL_CLK_DIV = 2 (N) -{0x3030, 0x0028}, // PLL_MULTIPLIER = 40 (M) -{0x302C, 0x0001}, // VT_SYS_CLK_DIV = 1 (P1) -{0x302A, 0x0010}, // VT_PIX_CLK_DIV = 16 (P2) -{0x302E, 0x0002}, // PRE_PLL_CLK_DIV = 2 (N) -{0x3030, 0x002C}, // PLL_MULTIPLIER = 44 (M) -{0x302C, 0x0001}, // VT_SYS_CLK_DIV = 1 (P1) -{0x302A, 0x0010}, // VT_PIX_CLK_DIV = 16 (P2) -{0x3032, 0x0000}, // DIGITAL_BINNING = 0 -{0x30B0, 0x0080}, // DIGITAL_TEST = 128 -{0x301A, 0x10DC}, // RESET_REGISTER = 4312 -{0x301A, 0x1980}, // R0x301A[12] = 1, R0x301A[11] = 1, R0x301A[8] = 1, R0x301A[7] = 1, R0x301A[2] = 0 -{0x300C, 0x0672}, // LINE_LENGTH_PCK = 1650 -{0x3002, 0x0000}, // Y_ADDR_START = 0 -{0x3004, 0x0000}, // X_ADDR_START = 0 -{0x3006, 0x03BF}, // Y_ADDR_END = 959 -{0x3008, 0x04FF}, // X_ADDR_END = 1279 -{0x300A, 0x03DE}, // FRAME_LENGTH_LINES = 990 -{0x3012, 0x1000}, // COARSE_INTEGRATION_TIME = 100 -{0x3014, 0x00C0}, // FINE_INTEGRATION_TIME = 192 -{0x30A6, 0x0001}, // Y_ODD_INC = 1 -{0x308C, 0x0000}, // Y_ADDR_START_CB = 0 -{0x308A, 0x0000}, // X_ADDR_START_CB = 0 -{0x3090, 0x03BF}, // Y_ADDR_END_CB = 959 -{0x308E, 0x04FF}, // X_ADDR_END_CB = 1279 -{0x30AA, 0x03DE}, // FRAME_LENGTH_LINES_CB = 990 -{0x3016, 0x0064}, // COARSE_INTEGRATION_TIME_CB = 100 -{0x3018, 0x00C0}, // FINE_INTEGRATION_TIME_CB = 192 -{0x30A8, 0x0001}, // Y_ODD_INC_CB = 1 -{0x3040, 0x0000}, // READ_MODE = 0 -{0x3064, 0x1982}, // EMBEDDED_DATA_CTRL = 6530 -{0x31C6, 0x8000}, // HISPI_CONTROL_STATUS = 32768 (DEFAULT) -{0xffff, 0xffff}, -}; -#endif \ No newline at end of file +const struct sensor_reg MT9M034_RAW[] PROGMEM = + { + {0x3028, 0x0010}, // ROW_SPEED = 16 + {0x302E, 0x0002}, // PRE_PLL_CLK_DIV = 2 (N) + {0x3030, 0x0028}, // PLL_MULTIPLIER = 40 (M) + {0x302C, 0x0001}, // VT_SYS_CLK_DIV = 1 (P1) + {0x302A, 0x0010}, // VT_PIX_CLK_DIV = 16 (P2) + {0x302E, 0x0002}, // PRE_PLL_CLK_DIV = 2 (N) + {0x3030, 0x002C}, // PLL_MULTIPLIER = 44 (M) + {0x302C, 0x0001}, // VT_SYS_CLK_DIV = 1 (P1) + {0x302A, 0x0010}, // VT_PIX_CLK_DIV = 16 (P2) + {0x3032, 0x0000}, // DIGITAL_BINNING = 0 + {0x30B0, 0x0080}, // DIGITAL_TEST = 128 + {0x301A, 0x10DC}, // RESET_REGISTER = 4312 + {0x301A, 0x1980}, // R0x301A[12] = 1, R0x301A[11] = 1, R0x301A[8] = 1, R0x301A[7] = 1, R0x301A[2] = 0 + {0x300C, 0x0672}, // LINE_LENGTH_PCK = 1650 + {0x3002, 0x0000}, // Y_ADDR_START = 0 + {0x3004, 0x0000}, // X_ADDR_START = 0 + {0x3006, 0x03BF}, // Y_ADDR_END = 959 + {0x3008, 0x04FF}, // X_ADDR_END = 1279 + {0x300A, 0x03DE}, // FRAME_LENGTH_LINES = 990 + {0x3012, 0x1000}, // COARSE_INTEGRATION_TIME = 100 + {0x3014, 0x00C0}, // FINE_INTEGRATION_TIME = 192 + {0x30A6, 0x0001}, // Y_ODD_INC = 1 + {0x308C, 0x0000}, // Y_ADDR_START_CB = 0 + {0x308A, 0x0000}, // X_ADDR_START_CB = 0 + {0x3090, 0x03BF}, // Y_ADDR_END_CB = 959 + {0x308E, 0x04FF}, // X_ADDR_END_CB = 1279 + {0x30AA, 0x03DE}, // FRAME_LENGTH_LINES_CB = 990 + {0x3016, 0x0064}, // COARSE_INTEGRATION_TIME_CB = 100 + {0x3018, 0x00C0}, // FINE_INTEGRATION_TIME_CB = 192 + {0x30A8, 0x0001}, // Y_ODD_INC_CB = 1 + {0x3040, 0x0000}, // READ_MODE = 0 + {0x3064, 0x1982}, // EMBEDDED_DATA_CTRL = 6530 + {0x31C6, 0x8000}, // HISPI_CONTROL_STATUS = 32768 (DEFAULT) + {0xffff, 0xffff}, +}; +#endif \ No newline at end of file diff --git a/ArduCAM/mt9m112_regs.h b/ArduCAM/mt9m112_regs.h index 5bc5a06c..e3ab0a1b 100644 --- a/ArduCAM/mt9m112_regs.h +++ b/ArduCAM/mt9m112_regs.h @@ -3,167 +3,166 @@ #include "ArduCAM.h" #include -const struct sensor_reg MT9M112_QVGA[] PROGMEM= -{ - - #if 1 //MCLK == 24M - {0xf0,0x0000}, - {0x66,0x1001}, - {0x67,0x0501}, - {0x65,0xa000}, - {0xff,0x0064}, - {0x65,0x2000}, - {0xff,0x0064}, - #endif - {0xf0,0x0000}, - {0x0d,0x0009}, - {0xff,0x0020}, - {0x0d,0x0008}, - {0xf0,0x0000}, - {0x01,0x0024}, - {0x03,0x0400},// default value - {0x04,0x0500}, - {0x30,0x042a}, - {0xf0,0x0001}, - {0x05,0x000f}, - {0x25,0x004d},// saturation adjustment, default value 0x4d - {0x3b,0x0430},//0x0436 - {0x3c,0x0400}, - {0x47,0x322e}, - {0x9d,0x3ce0}, - - {0xf0,0x0002}, - {0x28,0xef02},//0xef3e - {0x06,0x748e}, - {0x02,0x00ee},// base matrix signs - {0x15,0x00d9},// delta coefficients signs - {0x09,0x0067},//k1 - {0x0a,0x009a},//k2 - {0x0b,0x0028},//k3 - {0x0c,0x0030},//k4 - {0x0d,0x00ca},//k5 - {0x0e,0x0037},//k6 - {0x0f,0x001a},//k7 - {0x10,0x0065},//k8 - {0x11,0x0086},//k9 - {0x16,0x005e},//d1 0x0062 - {0x17,0x0084},//d2 - {0x18,0x004d},//d3 - {0x19,0x0024},//d4 - {0x1a,0x001f},//d5 - {0x1b,0x002f},//d6 - {0x1c,0x0004},//d7 - {0x1d,0x0023},//d8 - {0x1e,0x0010},//d9 - {0x03,0x3922},// base matrix scale k1-k5 - {0x04,0x0524},// base matrix scale k6-k9 0x04e4 - {0xf0,0x0002}, - {0x1f,0x0180}, - {0x20,0xc814},//0xdc0c - {0x21,0x8080}, - {0x22,0x9080}, - {0x23,0x8878}, - {0x26,0x8000}, - {0x27,0x8008}, - {0x2e,0x0c44},// 0x0d20 - {0x3e,0x1cff}, - {0x46,0x00b0}, - {0x5b,0x8002}, - {0x5c,0x110c}, - {0x5d,0x1510}, - {0x5e,0x534c}, - {0x5f,0x2b21}, - {0x24,0x7f40}, - {0x60,0x0002}, - {0x62,0x1010}, - {0x65,0x0000}, - {0xdc,0x0ff8}, - {0xdd,0x0ce0}, - {0xf0,0x0001}, - {0x47,0x202e}, - {0x80,0x0006},// lens correction control - {0x81,0x0000},// vertical red knee 0 and initial value 0x0009 - {0x82,0xfe05},// vertical red knees 2 and 1 - {0x83,0x0000},// vertical red knees 4 and 30x00ff - {0x84,0x0c00},// vertical green knee 0 and initial value - {0x85,0xfe02},// vertical green knees 2 and 1 - {0x86,0x00ff},// vertical green knees 4 and 3 - {0x87,0x0701},// vertical blue knee 0 and initial value 1003 - {0x88,0xfc06},// vertical blue knees 2 and 1 - {0x89,0x00ff},// vertical blue knees 4 and 3 - {0x8a,0x0801},// horizontal red knee 0 and initial value - {0x8b,0x030e},// horizontal red knees 2 and 1 - {0x8c,0xfefd},// horizontal red knees 4 and 3 - {0x8d,0x00ff},// horizontal red knee 5 - {0x8e,0x0601},// horizontal green knee 0 and initial value - {0x8f,0x040b},// horizontal green knees 2 and 1 - {0x90,0xfefb},// horizontal green knees 4 and 3 - {0x91,0x00fe},// horizontal green knee 5 - {0x92,0x0600},// horizontal blue knee 0 and initial value - {0x93,0x040b},// horizontal blue knees 2 and 1 - {0x94,0xfefd},// horizontal blue knees 4 and 3 - {0x95,0x00ff},// horizontal blue knees 5 - {0xb6,0x0204},// lens vertical red knees 6 and 5 - {0xb7,0xfbfa},// lens vertical red knees 8 and 7 - {0xb8,0x0503},// lens vertical green knees 6 and 5 - {0xb9,0xfaf8},// lens vertical green knees 8 and 7 - {0xba,0x0401},// lens vertical blue knees 6 and 5 - {0xbb,0xfef8},// lens vertical blue knees 8 and 7 - {0xbc,0xff01},// lens horizontal red knees 7 and 6 - {0xbd,0xf4ff},// lens horizontal red knees 9 and 8 - {0xbe,0x00fb},// lens horizontal red knee 10 - {0xbf,0x0000},// lens horizontal green knees 7 and 6 - {0xc0,0xf8fd},// lens horizontal green knees 9 and 8 - {0xc1,0x00f7},// lens horizontal green knee 10 - {0xc2,0x01ff},// lens horizontal blue knees 7 and 6 - {0xc3,0xf5fc},// lens horizontal blue knees 9 and 8 - {0xc4,0x00fa},// lens horizontal blue knee 10 - {0x06,0x748e}, - {0x9d,0x3ce0},// defect correction control - {0xf0,0x0002}, - {0x2e,0x0d3a},// 0x0d32 - {0x37,0x0081}, - {0x36,0x7810}, - {0xf0,0x0001}, - {0x06,0xf48e}, - {0xf0,0x0001}, - {0x06,0x648e}, - {0xf0,0x0002}, - {0x5b,0x0001},//0x0003 - - {0xf0,0x0000}, - {0x20,0x0102}, - {0x21,0x8000}, - {0x22,0x090d}, - - {0xf0,0x0000}, - {0x07,0x0374}, //horizontal blank - {0x08,0x0009}, - {0xf0,0x0002}, - {0xc8,0x0000}, - {0x2f,0xd100},// auto exposure speed A - {0x57,0x0271}, - {0x58,0x0271}, - {0xf0,0x0000}, - {0x21,0x8400}, - {0x22,0x090d}, - {0x68,0x0070}, - {0xf0,0x0001}, - {0xa6,0x0500},// horizontal zoom size A - {0xa7,0x0140},// horizontal output size A - {0xa9,0x0400},// vertical zoom size A - {0xaa,0x00f0},// vertical output size A - {0x3a,0x0100},// [7:6]:RGB565 - {0x53,0x1105},// gamma start A - {0x54,0x5d33}, - {0x55,0xad8d}, - {0x56,0xd6c4}, - {0x57,0xf3e6}, - {0x58,0xff00},// gamma end A - {0xf0,0x0000}, +const struct sensor_reg MT9M112_QVGA[] PROGMEM = + { - {0xff, 0xffff}, +#if 1 // MCLK == 24M + {0xf0, 0x0000}, + {0x66, 0x1001}, + {0x67, 0x0501}, + {0x65, 0xa000}, + {0xff, 0x0064}, + {0x65, 0x2000}, + {0xff, 0x0064}, +#endif + {0xf0, 0x0000}, + {0x0d, 0x0009}, + {0xff, 0x0020}, + {0x0d, 0x0008}, + {0xf0, 0x0000}, + {0x01, 0x0024}, + {0x03, 0x0400}, // default value + {0x04, 0x0500}, + {0x30, 0x042a}, + {0xf0, 0x0001}, + {0x05, 0x000f}, + {0x25, 0x004d}, // saturation adjustment, default value 0x4d + {0x3b, 0x0430}, // 0x0436 + {0x3c, 0x0400}, + {0x47, 0x322e}, + {0x9d, 0x3ce0}, + + {0xf0, 0x0002}, + {0x28, 0xef02}, // 0xef3e + {0x06, 0x748e}, + {0x02, 0x00ee}, // base matrix signs + {0x15, 0x00d9}, // delta coefficients signs + {0x09, 0x0067}, // k1 + {0x0a, 0x009a}, // k2 + {0x0b, 0x0028}, // k3 + {0x0c, 0x0030}, // k4 + {0x0d, 0x00ca}, // k5 + {0x0e, 0x0037}, // k6 + {0x0f, 0x001a}, // k7 + {0x10, 0x0065}, // k8 + {0x11, 0x0086}, // k9 + {0x16, 0x005e}, // d1 0x0062 + {0x17, 0x0084}, // d2 + {0x18, 0x004d}, // d3 + {0x19, 0x0024}, // d4 + {0x1a, 0x001f}, // d5 + {0x1b, 0x002f}, // d6 + {0x1c, 0x0004}, // d7 + {0x1d, 0x0023}, // d8 + {0x1e, 0x0010}, // d9 + {0x03, 0x3922}, // base matrix scale k1-k5 + {0x04, 0x0524}, // base matrix scale k6-k9 0x04e4 + {0xf0, 0x0002}, + {0x1f, 0x0180}, + {0x20, 0xc814}, // 0xdc0c + {0x21, 0x8080}, + {0x22, 0x9080}, + {0x23, 0x8878}, + {0x26, 0x8000}, + {0x27, 0x8008}, + {0x2e, 0x0c44}, // 0x0d20 + {0x3e, 0x1cff}, + {0x46, 0x00b0}, + {0x5b, 0x8002}, + {0x5c, 0x110c}, + {0x5d, 0x1510}, + {0x5e, 0x534c}, + {0x5f, 0x2b21}, + {0x24, 0x7f40}, + {0x60, 0x0002}, + {0x62, 0x1010}, + {0x65, 0x0000}, + {0xdc, 0x0ff8}, + {0xdd, 0x0ce0}, + {0xf0, 0x0001}, + {0x47, 0x202e}, + {0x80, 0x0006}, // lens correction control + {0x81, 0x0000}, // vertical red knee 0 and initial value 0x0009 + {0x82, 0xfe05}, // vertical red knees 2 and 1 + {0x83, 0x0000}, // vertical red knees 4 and 30x00ff + {0x84, 0x0c00}, // vertical green knee 0 and initial value + {0x85, 0xfe02}, // vertical green knees 2 and 1 + {0x86, 0x00ff}, // vertical green knees 4 and 3 + {0x87, 0x0701}, // vertical blue knee 0 and initial value 1003 + {0x88, 0xfc06}, // vertical blue knees 2 and 1 + {0x89, 0x00ff}, // vertical blue knees 4 and 3 + {0x8a, 0x0801}, // horizontal red knee 0 and initial value + {0x8b, 0x030e}, // horizontal red knees 2 and 1 + {0x8c, 0xfefd}, // horizontal red knees 4 and 3 + {0x8d, 0x00ff}, // horizontal red knee 5 + {0x8e, 0x0601}, // horizontal green knee 0 and initial value + {0x8f, 0x040b}, // horizontal green knees 2 and 1 + {0x90, 0xfefb}, // horizontal green knees 4 and 3 + {0x91, 0x00fe}, // horizontal green knee 5 + {0x92, 0x0600}, // horizontal blue knee 0 and initial value + {0x93, 0x040b}, // horizontal blue knees 2 and 1 + {0x94, 0xfefd}, // horizontal blue knees 4 and 3 + {0x95, 0x00ff}, // horizontal blue knees 5 + {0xb6, 0x0204}, // lens vertical red knees 6 and 5 + {0xb7, 0xfbfa}, // lens vertical red knees 8 and 7 + {0xb8, 0x0503}, // lens vertical green knees 6 and 5 + {0xb9, 0xfaf8}, // lens vertical green knees 8 and 7 + {0xba, 0x0401}, // lens vertical blue knees 6 and 5 + {0xbb, 0xfef8}, // lens vertical blue knees 8 and 7 + {0xbc, 0xff01}, // lens horizontal red knees 7 and 6 + {0xbd, 0xf4ff}, // lens horizontal red knees 9 and 8 + {0xbe, 0x00fb}, // lens horizontal red knee 10 + {0xbf, 0x0000}, // lens horizontal green knees 7 and 6 + {0xc0, 0xf8fd}, // lens horizontal green knees 9 and 8 + {0xc1, 0x00f7}, // lens horizontal green knee 10 + {0xc2, 0x01ff}, // lens horizontal blue knees 7 and 6 + {0xc3, 0xf5fc}, // lens horizontal blue knees 9 and 8 + {0xc4, 0x00fa}, // lens horizontal blue knee 10 + {0x06, 0x748e}, + {0x9d, 0x3ce0}, // defect correction control + {0xf0, 0x0002}, + {0x2e, 0x0d3a}, // 0x0d32 + {0x37, 0x0081}, + {0x36, 0x7810}, + {0xf0, 0x0001}, + {0x06, 0xf48e}, + {0xf0, 0x0001}, + {0x06, 0x648e}, + {0xf0, 0x0002}, + {0x5b, 0x0001}, // 0x0003 + + {0xf0, 0x0000}, + {0x20, 0x0102}, + {0x21, 0x8000}, + {0x22, 0x090d}, + + {0xf0, 0x0000}, + {0x07, 0x0374}, // horizontal blank + {0x08, 0x0009}, + {0xf0, 0x0002}, + {0xc8, 0x0000}, + {0x2f, 0xd100}, // auto exposure speed A + {0x57, 0x0271}, + {0x58, 0x0271}, + {0xf0, 0x0000}, + {0x21, 0x8400}, + {0x22, 0x090d}, + {0x68, 0x0070}, + {0xf0, 0x0001}, + {0xa6, 0x0500}, // horizontal zoom size A + {0xa7, 0x0140}, // horizontal output size A + {0xa9, 0x0400}, // vertical zoom size A + {0xaa, 0x00f0}, // vertical output size A + {0x3a, 0x0100}, // [7:6]:RGB565 + {0x53, 0x1105}, // gamma start A + {0x54, 0x5d33}, + {0x55, 0xad8d}, + {0x56, 0xd6c4}, + {0x57, 0xf3e6}, + {0x58, 0xff00}, // gamma end A + {0xf0, 0x0000}, + + {0xff, 0xffff}, }; #endif - diff --git a/ArduCAM/mt9t112_regs.h b/ArduCAM/mt9t112_regs.h index 5dd0e760..db6e3d15 100644 --- a/ArduCAM/mt9t112_regs.h +++ b/ArduCAM/mt9t112_regs.h @@ -3,13 +3,10 @@ #include "ArduCAM.h" #include -const struct sensor_reg MT9T112_QVGA[] PROGMEM= -{ - +const struct sensor_reg MT9T112_QVGA[] PROGMEM = + { - - {0xffff, 0xffff}, + {0xffff, 0xffff}, }; #endif - diff --git a/ArduCAM/mt9v111_regs.h b/ArduCAM/mt9v111_regs.h index 20d5bdc2..4b9a5b8f 100644 --- a/ArduCAM/mt9v111_regs.h +++ b/ArduCAM/mt9v111_regs.h @@ -5,68 +5,66 @@ #define I2C_SLAVE_ADDRESS 0xB8 +const struct sensor_reg MT9V111_QVGA[] PROGMEM = + { + {0x01, 0x04}, // REG=4 Sensor Core Register Access + {64, 488}, // anti-eclipse Vref + {47, 63408}, // set for Fmclk>13.5MHz + {2, 11}, + {3, 487}, + {4, 646}, + {0x06, 70}, // vertical blank, + {32, 0x4000}, -const struct sensor_reg MT9V111_QVGA[] PROGMEM= -{ - {0x01, 0x04}, //REG=4 Sensor Core Register Access - {64, 488 }, // anti-eclipse Vref - {47, 63408}, //set for Fmclk>13.5MHz - {2, 11}, - {3, 487}, - {4, 646}, - {0x06, 70 }, //vertical blank, - {32, 0x4000}, - - {0x01, 1}, //REG=1 IFP Register Access - {0x08, 0xd802}, //RGB mode - {58, 0x0001}, - {165, 0x8000}, // [QVGA 1:1 zoom] - {166, 0x8280}, // - {167, 0x8140}, // - {168, 0x8000}, // - {169, 0x81e0}, // - {170, 0x00f0}, // - - //[Auto Lens Correction Setup] - {0x2B, 0x0022}, //(36) GREEN1_GAIN_REG - {0x2C, 0x003E}, //(48) BLUE_GAIN_REG - {0x2D, 0x0020}, //(53) RED_GAIN_REG - {0x2E, 0x0066}, //(36) GREEN2_GAIN_REG - {0x02, 0x0000}, //(18) BASE_MATRIX_SIGNS - {0x03, 0x3923}, //(11) BASE_MATRIX_SCALE_K1_K5 - {0x04, 0x0724}, //(10) BASE_MATRIX_SCALE_K6_K9 - {0x06, 0xF00C}, //(14) MODE_CONTROL R6[14]:enable AEs - {0x09, 0x0080}, //(3) BASE_MATRIX_COEF_K1 - {0x0A, 0x0000}, //(2) BASE_MATRIX_COEF_K2 - {0x0B, 0x0000}, //(2) BASE_MATRIX_COEF_K3 - {0x0C, 0x0000}, //(1) BASE_MATRIX_COEF_K4 - {0x0D, 0x0080}, //(3) BASE_MATRIX_COEF_K5 - {0x0E, 0x0000}, //(2) BASE_MATRIX_COEF_K6 - {0x0F, 0x0000}, //(2) BASE_MATRIX_COEF_K7 - {0x10, 0x0000}, //(2) BASE_MATRIX_COEF_K8 - {0x11, 0x0080}, //(3) BASE_MATRIX_COEF_K9 - {0x15, 0x0000}, //(21) DELTA_COEFS_SIGNS - {0x16, 0x0000}, //(3) DELTA_MATRIX_COEF_D1 - {0x17, 0x0000}, //(2) DELTA_MATRIX_COEF_D2 - {0x18, 0x0000}, //(2) DELTA_MATRIX_COEF_D3 - {0x19, 0x0000}, //(1) DELTA_MATRIX_COEF_D4 - {0x1A, 0x0000}, //(3) DELTA_MATRIX_COEF_D5 - {0x1B, 0x0000}, //(2) DELTA_MATRIX_COEF_D6 - {0x1C, 0x0000}, //(2) DELTA_MATRIX_COEF_D7 - {0x1D, 0x0000}, //(2) DELTA_MATRIX_COEF_D8 - {0x1E, 0x0000}, //(4) DELTA_MATRIX_COEF_D9 - {0x25, 0x0514}, //(1) AWB_SPEED_SATURATION - {0x34, 0x0010}, //(5) LUMA_OFFSET - {0x35, 0xF010}, //(10) CLIPPING_LIM_OUT_LUMA - {0x48, 0x0080}, //(1) TEST_PATTERN_GEN - {0x53, 0x0804}, //(10) GAMMA_Y1_Y2 - {0x54, 0x2010}, //(10) GAMMA_Y3_Y4 - {0x55, 0x6040}, //(10) GAMMA_Y5_Y6 - {0x56, 0xA080}, //(10) GAMMA_Y7_Y8 - {0x57, 0xE0C0}, //(10) GAMMA_Y9_Y10 + {0x01, 1}, // REG=1 IFP Register Access + {0x08, 0xd802}, // RGB mode + {58, 0x0001}, + {165, 0x8000}, // [QVGA 1:1 zoom] + {166, 0x8280}, // + {167, 0x8140}, // + {168, 0x8000}, // + {169, 0x81e0}, // + {170, 0x00f0}, // - {0xff, 0xffff}, + //[Auto Lens Correction Setup] + {0x2B, 0x0022}, //(36) GREEN1_GAIN_REG + {0x2C, 0x003E}, //(48) BLUE_GAIN_REG + {0x2D, 0x0020}, //(53) RED_GAIN_REG + {0x2E, 0x0066}, //(36) GREEN2_GAIN_REG + {0x02, 0x0000}, //(18) BASE_MATRIX_SIGNS + {0x03, 0x3923}, //(11) BASE_MATRIX_SCALE_K1_K5 + {0x04, 0x0724}, //(10) BASE_MATRIX_SCALE_K6_K9 + {0x06, 0xF00C}, //(14) MODE_CONTROL R6[14]:enable AEs + {0x09, 0x0080}, //(3) BASE_MATRIX_COEF_K1 + {0x0A, 0x0000}, //(2) BASE_MATRIX_COEF_K2 + {0x0B, 0x0000}, //(2) BASE_MATRIX_COEF_K3 + {0x0C, 0x0000}, //(1) BASE_MATRIX_COEF_K4 + {0x0D, 0x0080}, //(3) BASE_MATRIX_COEF_K5 + {0x0E, 0x0000}, //(2) BASE_MATRIX_COEF_K6 + {0x0F, 0x0000}, //(2) BASE_MATRIX_COEF_K7 + {0x10, 0x0000}, //(2) BASE_MATRIX_COEF_K8 + {0x11, 0x0080}, //(3) BASE_MATRIX_COEF_K9 + {0x15, 0x0000}, //(21) DELTA_COEFS_SIGNS + {0x16, 0x0000}, //(3) DELTA_MATRIX_COEF_D1 + {0x17, 0x0000}, //(2) DELTA_MATRIX_COEF_D2 + {0x18, 0x0000}, //(2) DELTA_MATRIX_COEF_D3 + {0x19, 0x0000}, //(1) DELTA_MATRIX_COEF_D4 + {0x1A, 0x0000}, //(3) DELTA_MATRIX_COEF_D5 + {0x1B, 0x0000}, //(2) DELTA_MATRIX_COEF_D6 + {0x1C, 0x0000}, //(2) DELTA_MATRIX_COEF_D7 + {0x1D, 0x0000}, //(2) DELTA_MATRIX_COEF_D8 + {0x1E, 0x0000}, //(4) DELTA_MATRIX_COEF_D9 + {0x25, 0x0514}, //(1) AWB_SPEED_SATURATION + {0x34, 0x0010}, //(5) LUMA_OFFSET + {0x35, 0xF010}, //(10) CLIPPING_LIM_OUT_LUMA + {0x48, 0x0080}, //(1) TEST_PATTERN_GEN + {0x53, 0x0804}, //(10) GAMMA_Y1_Y2 + {0x54, 0x2010}, //(10) GAMMA_Y3_Y4 + {0x55, 0x6040}, //(10) GAMMA_Y5_Y6 + {0x56, 0xA080}, //(10) GAMMA_Y7_Y8 + {0x57, 0xE0C0}, //(10) GAMMA_Y9_Y10 + + {0xff, 0xffff}, }; #endif - diff --git a/ArduCAM/ov2640_regs.h b/ArduCAM/ov2640_regs.h index c2dd305a..b0c88caa 100644 --- a/ArduCAM/ov2640_regs.h +++ b/ArduCAM/ov2640_regs.h @@ -1,1089 +1,1085 @@ #ifndef OV2640_REGS_H #define OV2640_REGS_H #include "ArduCAM.h" -//#include +// #include -#define OV2640_CHIPID_HIGH 0x0A -#define OV2640_CHIPID_LOW 0x0B +#define OV2640_CHIPID_HIGH 0x0A +#define OV2640_CHIPID_LOW 0x0B const struct sensor_reg OV2640_QVGA[] PROGMEM = -{ - {0xff, 0x0}, - {0x2c, 0xff}, - {0x2e, 0xdf}, - {0xff, 0x1}, - {0x3c, 0x32}, - {0x11, 0x0}, - {0x9, 0x2}, - {0x4, 0xa8}, - {0x13, 0xe5}, - {0x14, 0x48}, - {0x2c, 0xc}, - {0x33, 0x78}, - {0x3a, 0x33}, - {0x3b, 0xfb}, - {0x3e, 0x0}, - {0x43, 0x11}, - {0x16, 0x10}, - {0x39, 0x2}, - {0x35, 0x88}, + { + {0xff, 0x0}, + {0x2c, 0xff}, + {0x2e, 0xdf}, + {0xff, 0x1}, + {0x3c, 0x32}, + {0x11, 0x0}, + {0x9, 0x2}, + {0x4, 0xa8}, + {0x13, 0xe5}, + {0x14, 0x48}, + {0x2c, 0xc}, + {0x33, 0x78}, + {0x3a, 0x33}, + {0x3b, 0xfb}, + {0x3e, 0x0}, + {0x43, 0x11}, + {0x16, 0x10}, + {0x39, 0x2}, + {0x35, 0x88}, + + {0x22, 0xa}, + {0x37, 0x40}, + {0x23, 0x0}, + {0x34, 0xa0}, + {0x6, 0x2}, + {0x6, 0x88}, + {0x7, 0xc0}, + {0xd, 0xb7}, + {0xe, 0x1}, + {0x4c, 0x0}, + {0x4a, 0x81}, + {0x21, 0x99}, + {0x24, 0x40}, + {0x25, 0x38}, + {0x26, 0x82}, + {0x5c, 0x0}, + {0x63, 0x0}, + {0x46, 0x22}, + {0xc, 0x3a}, + {0x5d, 0x55}, + {0x5e, 0x7d}, + {0x5f, 0x7d}, + {0x60, 0x55}, + {0x61, 0x70}, + {0x62, 0x80}, + {0x7c, 0x5}, + {0x20, 0x80}, + {0x28, 0x30}, + {0x6c, 0x0}, + {0x6d, 0x80}, + {0x6e, 0x0}, + {0x70, 0x2}, + {0x71, 0x94}, + {0x73, 0xc1}, + {0x3d, 0x34}, + {0x12, 0x4}, + {0x5a, 0x57}, + {0x4f, 0xbb}, + {0x50, 0x9c}, + {0xff, 0x0}, + {0xe5, 0x7f}, + {0xf9, 0xc0}, + {0x41, 0x24}, + {0xe0, 0x14}, + {0x76, 0xff}, + {0x33, 0xa0}, + {0x42, 0x20}, + {0x43, 0x18}, + {0x4c, 0x0}, + {0x87, 0xd0}, + {0x88, 0x3f}, + {0xd7, 0x3}, + {0xd9, 0x10}, + {0xd3, 0x82}, + {0xc8, 0x8}, + {0xc9, 0x80}, + {0x7c, 0x0}, + {0x7d, 0x0}, + {0x7c, 0x3}, + {0x7d, 0x48}, + {0x7d, 0x48}, + {0x7c, 0x8}, + {0x7d, 0x20}, + {0x7d, 0x10}, + {0x7d, 0xe}, + {0x90, 0x0}, + {0x91, 0xe}, + {0x91, 0x1a}, + {0x91, 0x31}, + {0x91, 0x5a}, + {0x91, 0x69}, + {0x91, 0x75}, + {0x91, 0x7e}, + {0x91, 0x88}, + {0x91, 0x8f}, + {0x91, 0x96}, + {0x91, 0xa3}, + {0x91, 0xaf}, + {0x91, 0xc4}, + {0x91, 0xd7}, + {0x91, 0xe8}, + {0x91, 0x20}, + {0x92, 0x0}, + + {0x93, 0x6}, + {0x93, 0xe3}, + {0x93, 0x3}, + {0x93, 0x3}, + {0x93, 0x0}, + {0x93, 0x2}, + {0x93, 0x0}, + {0x93, 0x0}, + {0x93, 0x0}, + {0x93, 0x0}, + {0x93, 0x0}, + {0x93, 0x0}, + {0x93, 0x0}, + {0x96, 0x0}, + {0x97, 0x8}, + {0x97, 0x19}, + {0x97, 0x2}, + {0x97, 0xc}, + {0x97, 0x24}, + {0x97, 0x30}, + {0x97, 0x28}, + {0x97, 0x26}, + {0x97, 0x2}, + {0x97, 0x98}, + {0x97, 0x80}, + {0x97, 0x0}, + {0x97, 0x0}, + {0xa4, 0x0}, + {0xa8, 0x0}, + {0xc5, 0x11}, + {0xc6, 0x51}, + {0xbf, 0x80}, + {0xc7, 0x10}, + {0xb6, 0x66}, + {0xb8, 0xa5}, + {0xb7, 0x64}, + {0xb9, 0x7c}, + {0xb3, 0xaf}, + {0xb4, 0x97}, + {0xb5, 0xff}, + {0xb0, 0xc5}, + {0xb1, 0x94}, + {0xb2, 0xf}, + {0xc4, 0x5c}, + {0xa6, 0x0}, + {0xa7, 0x20}, + {0xa7, 0xd8}, + {0xa7, 0x1b}, + {0xa7, 0x31}, + {0xa7, 0x0}, + {0xa7, 0x18}, + {0xa7, 0x20}, + {0xa7, 0xd8}, + {0xa7, 0x19}, + {0xa7, 0x31}, + {0xa7, 0x0}, + {0xa7, 0x18}, + {0xa7, 0x20}, + {0xa7, 0xd8}, + {0xa7, 0x19}, + {0xa7, 0x31}, + {0xa7, 0x0}, + {0xa7, 0x18}, + {0x7f, 0x0}, + {0xe5, 0x1f}, + {0xe1, 0x77}, + {0xdd, 0x7f}, + {0xc2, 0xe}, + + {0xff, 0x0}, + {0xe0, 0x4}, + {0xc0, 0xc8}, + {0xc1, 0x96}, + {0x86, 0x3d}, + {0x51, 0x90}, + {0x52, 0x2c}, + {0x53, 0x0}, + {0x54, 0x0}, + {0x55, 0x88}, + {0x57, 0x0}, + + {0x50, 0x92}, + {0x5a, 0x50}, + {0x5b, 0x3c}, + {0x5c, 0x0}, + {0xd3, 0x4}, + {0xe0, 0x0}, + + {0xff, 0x0}, + {0x5, 0x0}, - {0x22, 0xa}, - {0x37, 0x40}, - {0x23, 0x0}, - {0x34, 0xa0}, - {0x6, 0x2}, - {0x6, 0x88}, - {0x7, 0xc0}, - {0xd, 0xb7}, - {0xe, 0x1}, - {0x4c, 0x0}, - {0x4a, 0x81}, - {0x21, 0x99}, - {0x24, 0x40}, - {0x25, 0x38}, - {0x26, 0x82}, - {0x5c, 0x0}, - {0x63, 0x0}, - {0x46, 0x22}, - {0xc, 0x3a}, - {0x5d, 0x55}, - {0x5e, 0x7d}, - {0x5f, 0x7d}, - {0x60, 0x55}, - {0x61, 0x70}, - {0x62, 0x80}, - {0x7c, 0x5}, - {0x20, 0x80}, - {0x28, 0x30}, - {0x6c, 0x0}, - {0x6d, 0x80}, - {0x6e, 0x0}, - {0x70, 0x2}, - {0x71, 0x94}, - {0x73, 0xc1}, - {0x3d, 0x34}, - {0x12, 0x4}, - {0x5a, 0x57}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0xff, 0x0}, - {0xe5, 0x7f}, - {0xf9, 0xc0}, - {0x41, 0x24}, - {0xe0, 0x14}, - {0x76, 0xff}, - {0x33, 0xa0}, - {0x42, 0x20}, - {0x43, 0x18}, - {0x4c, 0x0}, - {0x87, 0xd0}, - {0x88, 0x3f}, - {0xd7, 0x3}, - {0xd9, 0x10}, - {0xd3, 0x82}, - {0xc8, 0x8}, - {0xc9, 0x80}, - {0x7c, 0x0}, - {0x7d, 0x0}, - {0x7c, 0x3}, - {0x7d, 0x48}, - {0x7d, 0x48}, - {0x7c, 0x8}, - {0x7d, 0x20}, - {0x7d, 0x10}, - {0x7d, 0xe}, - {0x90, 0x0}, - {0x91, 0xe}, - {0x91, 0x1a}, - {0x91, 0x31}, - {0x91, 0x5a}, - {0x91, 0x69}, - {0x91, 0x75}, - {0x91, 0x7e}, - {0x91, 0x88}, - {0x91, 0x8f}, - {0x91, 0x96}, - {0x91, 0xa3}, - {0x91, 0xaf}, - {0x91, 0xc4}, - {0x91, 0xd7}, - {0x91, 0xe8}, - {0x91, 0x20}, - {0x92, 0x0}, + {0xda, 0x8}, + {0xd7, 0x3}, + {0xe0, 0x0}, - {0x93, 0x6}, - {0x93, 0xe3}, - {0x93, 0x3}, - {0x93, 0x3}, - {0x93, 0x0}, - {0x93, 0x2}, - {0x93, 0x0}, - {0x93, 0x0}, - {0x93, 0x0}, - {0x93, 0x0}, - {0x93, 0x0}, - {0x93, 0x0}, - {0x93, 0x0}, - {0x96, 0x0}, - {0x97, 0x8}, - {0x97, 0x19}, - {0x97, 0x2}, - {0x97, 0xc}, - {0x97, 0x24}, - {0x97, 0x30}, - {0x97, 0x28}, - {0x97, 0x26}, - {0x97, 0x2}, - {0x97, 0x98}, - {0x97, 0x80}, - {0x97, 0x0}, - {0x97, 0x0}, - {0xa4, 0x0}, - {0xa8, 0x0}, - {0xc5, 0x11}, - {0xc6, 0x51}, - {0xbf, 0x80}, - {0xc7, 0x10}, - {0xb6, 0x66}, - {0xb8, 0xa5}, - {0xb7, 0x64}, - {0xb9, 0x7c}, - {0xb3, 0xaf}, - {0xb4, 0x97}, - {0xb5, 0xff}, - {0xb0, 0xc5}, - {0xb1, 0x94}, - {0xb2, 0xf}, - {0xc4, 0x5c}, - {0xa6, 0x0}, - {0xa7, 0x20}, - {0xa7, 0xd8}, - {0xa7, 0x1b}, - {0xa7, 0x31}, - {0xa7, 0x0}, - {0xa7, 0x18}, - {0xa7, 0x20}, - {0xa7, 0xd8}, - {0xa7, 0x19}, - {0xa7, 0x31}, - {0xa7, 0x0}, - {0xa7, 0x18}, - {0xa7, 0x20}, - {0xa7, 0xd8}, - {0xa7, 0x19}, - {0xa7, 0x31}, - {0xa7, 0x0}, - {0xa7, 0x18}, - {0x7f, 0x0}, - {0xe5, 0x1f}, - {0xe1, 0x77}, - {0xdd, 0x7f}, - {0xc2, 0xe}, - - {0xff, 0x0}, - {0xe0, 0x4}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x0}, - {0x54, 0x0}, - {0x55, 0x88}, - {0x57, 0x0}, - - {0x50, 0x92}, - {0x5a, 0x50}, - {0x5b, 0x3c}, - {0x5c, 0x0}, - {0xd3, 0x4}, - {0xe0, 0x0}, - - {0xff, 0x0}, - {0x5, 0x0}, - - {0xda, 0x8}, - {0xd7, 0x3}, - {0xe0, 0x0}, - - {0x5, 0x0}, + {0x5, 0x0}, - - {0xff,0xff}, -}; + {0xff, 0xff}, +}; const struct sensor_reg OV2640_JPEG_INIT[] PROGMEM = -{ - { 0xff, 0x00 }, - { 0x2c, 0xff }, - { 0x2e, 0xdf }, - { 0xff, 0x01 }, - { 0x3c, 0x32 }, - { 0x11, 0x00 }, - { 0x09, 0x02 }, - { 0x04, 0x28 }, - { 0x13, 0xe5 }, - { 0x14, 0x48 }, - { 0x2c, 0x0c }, - { 0x33, 0x78 }, - { 0x3a, 0x33 }, - { 0x3b, 0xfB }, - { 0x3e, 0x00 }, - { 0x43, 0x11 }, - { 0x16, 0x10 }, - { 0x39, 0x92 }, - { 0x35, 0xda }, - { 0x22, 0x1a }, - { 0x37, 0xc3 }, - { 0x23, 0x00 }, - { 0x34, 0xc0 }, - { 0x36, 0x1a }, - { 0x06, 0x88 }, - { 0x07, 0xc0 }, - { 0x0d, 0x87 }, - { 0x0e, 0x41 }, - { 0x4c, 0x00 }, - { 0x48, 0x00 }, - { 0x5B, 0x00 }, - { 0x42, 0x03 }, - { 0x4a, 0x81 }, - { 0x21, 0x99 }, - { 0x24, 0x40 }, - { 0x25, 0x38 }, - { 0x26, 0x82 }, - { 0x5c, 0x00 }, - { 0x63, 0x00 }, - { 0x61, 0x70 }, - { 0x62, 0x80 }, - { 0x7c, 0x05 }, - { 0x20, 0x80 }, - { 0x28, 0x30 }, - { 0x6c, 0x00 }, - { 0x6d, 0x80 }, - { 0x6e, 0x00 }, - { 0x70, 0x02 }, - { 0x71, 0x94 }, - { 0x73, 0xc1 }, - { 0x12, 0x40 }, - { 0x17, 0x11 }, - { 0x18, 0x43 }, - { 0x19, 0x00 }, - { 0x1a, 0x4b }, - { 0x32, 0x09 }, - { 0x37, 0xc0 }, - { 0x4f, 0x60 }, - { 0x50, 0xa8 }, - { 0x6d, 0x00 }, - { 0x3d, 0x38 }, - { 0x46, 0x3f }, - { 0x4f, 0x60 }, - { 0x0c, 0x3c }, - { 0xff, 0x00 }, - { 0xe5, 0x7f }, - { 0xf9, 0xc0 }, - { 0x41, 0x24 }, - { 0xe0, 0x14 }, - { 0x76, 0xff }, - { 0x33, 0xa0 }, - { 0x42, 0x20 }, - { 0x43, 0x18 }, - { 0x4c, 0x00 }, - { 0x87, 0xd5 }, - { 0x88, 0x3f }, - { 0xd7, 0x03 }, - { 0xd9, 0x10 }, - { 0xd3, 0x82 }, - { 0xc8, 0x08 }, - { 0xc9, 0x80 }, - { 0x7c, 0x00 }, - { 0x7d, 0x00 }, - { 0x7c, 0x03 }, - { 0x7d, 0x48 }, - { 0x7d, 0x48 }, - { 0x7c, 0x08 }, - { 0x7d, 0x20 }, - { 0x7d, 0x10 }, - { 0x7d, 0x0e }, - { 0x90, 0x00 }, - { 0x91, 0x0e }, - { 0x91, 0x1a }, - { 0x91, 0x31 }, - { 0x91, 0x5a }, - { 0x91, 0x69 }, - { 0x91, 0x75 }, - { 0x91, 0x7e }, - { 0x91, 0x88 }, - { 0x91, 0x8f }, - { 0x91, 0x96 }, - { 0x91, 0xa3 }, - { 0x91, 0xaf }, - { 0x91, 0xc4 }, - { 0x91, 0xd7 }, - { 0x91, 0xe8 }, - { 0x91, 0x20 }, - { 0x92, 0x00 }, - { 0x93, 0x06 }, - { 0x93, 0xe3 }, - { 0x93, 0x05 }, - { 0x93, 0x05 }, - { 0x93, 0x00 }, - { 0x93, 0x04 }, - { 0x93, 0x00 }, - { 0x93, 0x00 }, - { 0x93, 0x00 }, - { 0x93, 0x00 }, - { 0x93, 0x00 }, - { 0x93, 0x00 }, - { 0x93, 0x00 }, - { 0x96, 0x00 }, - { 0x97, 0x08 }, - { 0x97, 0x19 }, - { 0x97, 0x02 }, - { 0x97, 0x0c }, - { 0x97, 0x24 }, - { 0x97, 0x30 }, - { 0x97, 0x28 }, - { 0x97, 0x26 }, - { 0x97, 0x02 }, - { 0x97, 0x98 }, - { 0x97, 0x80 }, - { 0x97, 0x00 }, - { 0x97, 0x00 }, - { 0xc3, 0xed }, - { 0xa4, 0x00 }, - { 0xa8, 0x00 }, - { 0xc5, 0x11 }, - { 0xc6, 0x51 }, - { 0xbf, 0x80 }, - { 0xc7, 0x10 }, - { 0xb6, 0x66 }, - { 0xb8, 0xA5 }, - { 0xb7, 0x64 }, - { 0xb9, 0x7C }, - { 0xb3, 0xaf }, - { 0xb4, 0x97 }, - { 0xb5, 0xFF }, - { 0xb0, 0xC5 }, - { 0xb1, 0x94 }, - { 0xb2, 0x0f }, - { 0xc4, 0x5c }, - { 0xc0, 0x64 }, - { 0xc1, 0x4B }, - { 0x8c, 0x00 }, - { 0x86, 0x3D }, - { 0x50, 0x00 }, - { 0x51, 0xC8 }, - { 0x52, 0x96 }, - { 0x53, 0x00 }, - { 0x54, 0x00 }, - { 0x55, 0x00 }, - { 0x5a, 0xC8 }, - { 0x5b, 0x96 }, - { 0x5c, 0x00 }, - { 0xd3, 0x00 }, //{ 0xd3, 0x7f }, - { 0xc3, 0xed }, - { 0x7f, 0x00 }, - { 0xda, 0x00 }, - { 0xe5, 0x1f }, - { 0xe1, 0x67 }, - { 0xe0, 0x00 }, - { 0xdd, 0x7f }, - { 0x05, 0x00 }, - - { 0x12, 0x40 }, - { 0xd3, 0x04 }, //{ 0xd3, 0x7f }, - { 0xc0, 0x16 }, - { 0xC1, 0x12 }, - { 0x8c, 0x00 }, - { 0x86, 0x3d }, - { 0x50, 0x00 }, - { 0x51, 0x2C }, - { 0x52, 0x24 }, - { 0x53, 0x00 }, - { 0x54, 0x00 }, - { 0x55, 0x00 }, - { 0x5A, 0x2c }, - { 0x5b, 0x24 }, - { 0x5c, 0x00 }, - { 0xff, 0xff }, -}; + { + {0xff, 0x00}, + {0x2c, 0xff}, + {0x2e, 0xdf}, + {0xff, 0x01}, + {0x3c, 0x32}, + {0x11, 0x00}, + {0x09, 0x02}, + {0x04, 0x28}, + {0x13, 0xe5}, + {0x14, 0x48}, + {0x2c, 0x0c}, + {0x33, 0x78}, + {0x3a, 0x33}, + {0x3b, 0xfB}, + {0x3e, 0x00}, + {0x43, 0x11}, + {0x16, 0x10}, + {0x39, 0x92}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0x48, 0x00}, + {0x5B, 0x00}, + {0x42, 0x03}, + {0x4a, 0x81}, + {0x21, 0x99}, + {0x24, 0x40}, + {0x25, 0x38}, + {0x26, 0x82}, + {0x5c, 0x00}, + {0x63, 0x00}, + {0x61, 0x70}, + {0x62, 0x80}, + {0x7c, 0x05}, + {0x20, 0x80}, + {0x28, 0x30}, + {0x6c, 0x00}, + {0x6d, 0x80}, + {0x6e, 0x00}, + {0x70, 0x02}, + {0x71, 0x94}, + {0x73, 0xc1}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x4b}, + {0x32, 0x09}, + {0x37, 0xc0}, + {0x4f, 0x60}, + {0x50, 0xa8}, + {0x6d, 0x00}, + {0x3d, 0x38}, + {0x46, 0x3f}, + {0x4f, 0x60}, + {0x0c, 0x3c}, + {0xff, 0x00}, + {0xe5, 0x7f}, + {0xf9, 0xc0}, + {0x41, 0x24}, + {0xe0, 0x14}, + {0x76, 0xff}, + {0x33, 0xa0}, + {0x42, 0x20}, + {0x43, 0x18}, + {0x4c, 0x00}, + {0x87, 0xd5}, + {0x88, 0x3f}, + {0xd7, 0x03}, + {0xd9, 0x10}, + {0xd3, 0x82}, + {0xc8, 0x08}, + {0xc9, 0x80}, + {0x7c, 0x00}, + {0x7d, 0x00}, + {0x7c, 0x03}, + {0x7d, 0x48}, + {0x7d, 0x48}, + {0x7c, 0x08}, + {0x7d, 0x20}, + {0x7d, 0x10}, + {0x7d, 0x0e}, + {0x90, 0x00}, + {0x91, 0x0e}, + {0x91, 0x1a}, + {0x91, 0x31}, + {0x91, 0x5a}, + {0x91, 0x69}, + {0x91, 0x75}, + {0x91, 0x7e}, + {0x91, 0x88}, + {0x91, 0x8f}, + {0x91, 0x96}, + {0x91, 0xa3}, + {0x91, 0xaf}, + {0x91, 0xc4}, + {0x91, 0xd7}, + {0x91, 0xe8}, + {0x91, 0x20}, + {0x92, 0x00}, + {0x93, 0x06}, + {0x93, 0xe3}, + {0x93, 0x05}, + {0x93, 0x05}, + {0x93, 0x00}, + {0x93, 0x04}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x96, 0x00}, + {0x97, 0x08}, + {0x97, 0x19}, + {0x97, 0x02}, + {0x97, 0x0c}, + {0x97, 0x24}, + {0x97, 0x30}, + {0x97, 0x28}, + {0x97, 0x26}, + {0x97, 0x02}, + {0x97, 0x98}, + {0x97, 0x80}, + {0x97, 0x00}, + {0x97, 0x00}, + {0xc3, 0xed}, + {0xa4, 0x00}, + {0xa8, 0x00}, + {0xc5, 0x11}, + {0xc6, 0x51}, + {0xbf, 0x80}, + {0xc7, 0x10}, + {0xb6, 0x66}, + {0xb8, 0xA5}, + {0xb7, 0x64}, + {0xb9, 0x7C}, + {0xb3, 0xaf}, + {0xb4, 0x97}, + {0xb5, 0xFF}, + {0xb0, 0xC5}, + {0xb1, 0x94}, + {0xb2, 0x0f}, + {0xc4, 0x5c}, + {0xc0, 0x64}, + {0xc1, 0x4B}, + {0x8c, 0x00}, + {0x86, 0x3D}, + {0x50, 0x00}, + {0x51, 0xC8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x5a, 0xC8}, + {0x5b, 0x96}, + {0x5c, 0x00}, + {0xd3, 0x00}, //{ 0xd3, 0x7f }, + {0xc3, 0xed}, + {0x7f, 0x00}, + {0xda, 0x00}, + {0xe5, 0x1f}, + {0xe1, 0x67}, + {0xe0, 0x00}, + {0xdd, 0x7f}, + {0x05, 0x00}, + + {0x12, 0x40}, + {0xd3, 0x04}, //{ 0xd3, 0x7f }, + {0xc0, 0x16}, + {0xC1, 0x12}, + {0x8c, 0x00}, + {0x86, 0x3d}, + {0x50, 0x00}, + {0x51, 0x2C}, + {0x52, 0x24}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x5A, 0x2c}, + {0x5b, 0x24}, + {0x5c, 0x00}, + {0xff, 0xff}, +}; const struct sensor_reg OV2640_YUV422[] PROGMEM = -{ - { 0xFF, 0x00 }, - { 0x05, 0x00 }, - { 0xDA, 0x10 }, - { 0xD7, 0x03 }, - { 0xDF, 0x00 }, - { 0x33, 0x80 }, - { 0x3C, 0x40 }, - { 0xe1, 0x77 }, - { 0x00, 0x00 }, - { 0xff, 0xff }, + { + {0xFF, 0x00}, + {0x05, 0x00}, + {0xDA, 0x10}, + {0xD7, 0x03}, + {0xDF, 0x00}, + {0x33, 0x80}, + {0x3C, 0x40}, + {0xe1, 0x77}, + {0x00, 0x00}, + {0xff, 0xff}, }; -const struct sensor_reg OV2640_JPEG[] PROGMEM = -{ - { 0xe0, 0x14 }, - { 0xe1, 0x77 }, - { 0xe5, 0x1f }, - { 0xd7, 0x03 }, - { 0xda, 0x10 }, - { 0xe0, 0x00 }, - { 0xFF, 0x01 }, - { 0x04, 0x08 }, - { 0xff, 0xff }, -}; +const struct sensor_reg OV2640_JPEG[] PROGMEM = + { + {0xe0, 0x14}, + {0xe1, 0x77}, + {0xe5, 0x1f}, + {0xd7, 0x03}, + {0xda, 0x10}, + {0xe0, 0x00}, + {0xFF, 0x01}, + {0x04, 0x08}, + {0xff, 0xff}, +}; /* JPG 160x120 */ -const struct sensor_reg OV2640_160x120_JPEG[] PROGMEM = -{ - { 0xff, 0x01 }, - { 0x12, 0x40 }, - { 0x17, 0x11 }, - { 0x18, 0x43 }, - { 0x19, 0x00 }, - { 0x1a, 0x4b }, - { 0x32, 0x09 }, - { 0x4f, 0xca }, - { 0x50, 0xa8 }, - { 0x5a, 0x23 }, - { 0x6d, 0x00 }, - { 0x39, 0x12 }, - { 0x35, 0xda }, - { 0x22, 0x1a }, - { 0x37, 0xc3 }, - { 0x23, 0x00 }, - { 0x34, 0xc0 }, - { 0x36, 0x1a }, - { 0x06, 0x88 }, - { 0x07, 0xc0 }, - { 0x0d, 0x87 }, - { 0x0e, 0x41 }, - { 0x4c, 0x00 }, - { 0xff, 0x00 }, - { 0xe0, 0x04 }, - { 0xc0, 0x64 }, - { 0xc1, 0x4b }, - { 0x86, 0x35 }, - { 0x50, 0x92 }, - { 0x51, 0xc8 }, - { 0x52, 0x96 }, - { 0x53, 0x00 }, - { 0x54, 0x00 }, - { 0x55, 0x00 }, - { 0x57, 0x00 }, - { 0x5a, 0x28 }, - { 0x5b, 0x1e }, - { 0x5c, 0x00 }, - { 0xe0, 0x00 }, - { 0xff, 0xff }, +const struct sensor_reg OV2640_160x120_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x4b}, + {0x32, 0x09}, + {0x4f, 0xca}, + {0x50, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x39, 0x12}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0x64}, + {0xc1, 0x4b}, + {0x86, 0x35}, + {0x50, 0x92}, + {0x51, 0xc8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x57, 0x00}, + {0x5a, 0x28}, + {0x5b, 0x1e}, + {0x5c, 0x00}, + {0xe0, 0x00}, + {0xff, 0xff}, }; /* JPG, 0x176x144 */ -const struct sensor_reg OV2640_176x144_JPEG[] PROGMEM = -{ - { 0xff, 0x01 }, - { 0x12, 0x40 }, - { 0x17, 0x11 }, - { 0x18, 0x43 }, - { 0x19, 0x00 }, - { 0x1a, 0x4b }, - { 0x32, 0x09 }, - { 0x4f, 0xca }, - { 0x50, 0xa8 }, - { 0x5a, 0x23 }, - { 0x6d, 0x00 }, - { 0x39, 0x12 }, - { 0x35, 0xda }, - { 0x22, 0x1a }, - { 0x37, 0xc3 }, - { 0x23, 0x00 }, - { 0x34, 0xc0 }, - { 0x36, 0x1a }, - { 0x06, 0x88 }, - { 0x07, 0xc0 }, - { 0x0d, 0x87 }, - { 0x0e, 0x41 }, - { 0x4c, 0x00 }, - { 0xff, 0x00 }, - { 0xe0, 0x04 }, - { 0xc0, 0x64 }, - { 0xc1, 0x4b }, - { 0x86, 0x35 }, - { 0x50, 0x92 }, - { 0x51, 0xc8 }, - { 0x52, 0x96 }, - { 0x53, 0x00 }, - { 0x54, 0x00 }, - { 0x55, 0x00 }, - { 0x57, 0x00 }, - { 0x5a, 0x2c }, - { 0x5b, 0x24 }, - { 0x5c, 0x00 }, - { 0xe0, 0x00 }, - { 0xff, 0xff }, +const struct sensor_reg OV2640_176x144_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x4b}, + {0x32, 0x09}, + {0x4f, 0xca}, + {0x50, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x39, 0x12}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0x64}, + {0xc1, 0x4b}, + {0x86, 0x35}, + {0x50, 0x92}, + {0x51, 0xc8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x57, 0x00}, + {0x5a, 0x2c}, + {0x5b, 0x24}, + {0x5c, 0x00}, + {0xe0, 0x00}, + {0xff, 0xff}, }; /* JPG 320x240 */ -const struct sensor_reg OV2640_320x240_JPEG[] PROGMEM = -{ - { 0xff, 0x01 }, - { 0x12, 0x40 }, - { 0x17, 0x11 }, - { 0x18, 0x43 }, - { 0x19, 0x00 }, - { 0x1a, 0x4b }, - { 0x32, 0x09 }, - { 0x4f, 0xca }, - { 0x50, 0xa8 }, - { 0x5a, 0x23 }, - { 0x6d, 0x00 }, - { 0x39, 0x12 }, - { 0x35, 0xda }, - { 0x22, 0x1a }, - { 0x37, 0xc3 }, - { 0x23, 0x00 }, - { 0x34, 0xc0 }, - { 0x36, 0x1a }, - { 0x06, 0x88 }, - { 0x07, 0xc0 }, - { 0x0d, 0x87 }, - { 0x0e, 0x41 }, - { 0x4c, 0x00 }, - { 0xff, 0x00 }, - { 0xe0, 0x04 }, - { 0xc0, 0x64 }, - { 0xc1, 0x4b }, - { 0x86, 0x35 }, - { 0x50, 0x89 }, - { 0x51, 0xc8 }, - { 0x52, 0x96 }, - { 0x53, 0x00 }, - { 0x54, 0x00 }, - { 0x55, 0x00 }, - { 0x57, 0x00 }, - { 0x5a, 0x50 }, - { 0x5b, 0x3c }, - { 0x5c, 0x00 }, - { 0xe0, 0x00 }, - { 0xff, 0xff }, +const struct sensor_reg OV2640_320x240_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x4b}, + {0x32, 0x09}, + {0x4f, 0xca}, + {0x50, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x39, 0x12}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0x64}, + {0xc1, 0x4b}, + {0x86, 0x35}, + {0x50, 0x89}, + {0x51, 0xc8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x57, 0x00}, + {0x5a, 0x50}, + {0x5b, 0x3c}, + {0x5c, 0x00}, + {0xe0, 0x00}, + {0xff, 0xff}, }; /* JPG 352x288 */ -const struct sensor_reg OV2640_352x288_JPEG[] PROGMEM = +const struct sensor_reg OV2640_352x288_JPEG[] PROGMEM = -{ - { 0xff, 0x01 }, - { 0x12, 0x40 }, - { 0x17, 0x11 }, - { 0x18, 0x43 }, - { 0x19, 0x00 }, - { 0x1a, 0x4b }, - { 0x32, 0x09 }, - { 0x4f, 0xca }, - { 0x50, 0xa8 }, - { 0x5a, 0x23 }, - { 0x6d, 0x00 }, - { 0x39, 0x12 }, - { 0x35, 0xda }, - { 0x22, 0x1a }, - { 0x37, 0xc3 }, - { 0x23, 0x00 }, - { 0x34, 0xc0 }, - { 0x36, 0x1a }, - { 0x06, 0x88 }, - { 0x07, 0xc0 }, - { 0x0d, 0x87 }, - { 0x0e, 0x41 }, - { 0x4c, 0x00 }, - { 0xff, 0x00 }, - { 0xe0, 0x04 }, - { 0xc0, 0x64 }, - { 0xc1, 0x4b }, - { 0x86, 0x35 }, - { 0x50, 0x89 }, - { 0x51, 0xc8 }, - { 0x52, 0x96 }, - { 0x53, 0x00 }, - { 0x54, 0x00 }, - { 0x55, 0x00 }, - { 0x57, 0x00 }, - { 0x5a, 0x58 }, - { 0x5b, 0x48 }, - { 0x5c, 0x00 }, - { 0xe0, 0x00 }, - { 0xff, 0xff }, + { + {0xff, 0x01}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x4b}, + {0x32, 0x09}, + {0x4f, 0xca}, + {0x50, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x39, 0x12}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0x64}, + {0xc1, 0x4b}, + {0x86, 0x35}, + {0x50, 0x89}, + {0x51, 0xc8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x57, 0x00}, + {0x5a, 0x58}, + {0x5b, 0x48}, + {0x5c, 0x00}, + {0xe0, 0x00}, + {0xff, 0xff}, }; /* JPG 640x480 */ -const struct sensor_reg OV2640_640x480_JPEG[] PROGMEM = -{ - {0xff, 0x01}, - {0x11, 0x01}, - {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02Ϊ²ÊÌõ - {0x17, 0x11}, // HREFST[10:3] - {0x18, 0x75}, // HREFEND[10:3] - {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] - {0x19, 0x01}, // VSTRT[9:2] - {0x1a, 0x97}, // VEND[9:2] - {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x3d, 0x34}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x34, 0xa0}, - {0x06, 0x02}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x89}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0xa0}, - {0x5b, 0x78}, - {0x5c, 0x00}, - {0xd3, 0x04}, - {0xe0, 0x00}, - - {0xff, 0xff}, -}; - +const struct sensor_reg OV2640_640x480_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x11, 0x01}, + {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02���� + {0x17, 0x11}, // HREFST[10:3] + {0x18, 0x75}, // HREFEND[10:3] + {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] + {0x19, 0x01}, // VSTRT[9:2] + {0x1a, 0x97}, // VEND[9:2] + {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] + {0x37, 0x40}, + {0x4f, 0xbb}, + {0x50, 0x9c}, + {0x5a, 0x57}, + {0x6d, 0x80}, + {0x3d, 0x34}, + {0x39, 0x02}, + {0x35, 0x88}, + {0x22, 0x0a}, + {0x37, 0x40}, + {0x34, 0xa0}, + {0x06, 0x02}, + {0x0d, 0xb7}, + {0x0e, 0x01}, + + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0xc8}, + {0xc1, 0x96}, + {0x86, 0x3d}, + {0x50, 0x89}, + {0x51, 0x90}, + {0x52, 0x2c}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x88}, + {0x57, 0x00}, + {0x5a, 0xa0}, + {0x5b, 0x78}, + {0x5c, 0x00}, + {0xd3, 0x04}, + {0xe0, 0x00}, + + {0xff, 0xff}, +}; + /* JPG 800x600 */ -const struct sensor_reg OV2640_800x600_JPEG[] PROGMEM = -{ - {0xff, 0x01}, - {0x11, 0x01}, - {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02Ϊ²ÊÌõ - {0x17, 0x11}, // HREFST[10:3] - {0x18, 0x75}, // HREFEND[10:3] - {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] - {0x19, 0x01}, // VSTRT[9:2] - {0x1a, 0x97}, // VEND[9:2] - {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x3d, 0x34}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x34, 0xa0}, - {0x06, 0x02}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x35}, - {0x50, 0x89}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0xc8}, - {0x5b, 0x96}, - {0x5c, 0x00}, - {0xd3, 0x02}, - {0xe0, 0x00}, - - {0xff, 0xff}, -}; - +const struct sensor_reg OV2640_800x600_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x11, 0x01}, + {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02���� + {0x17, 0x11}, // HREFST[10:3] + {0x18, 0x75}, // HREFEND[10:3] + {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] + {0x19, 0x01}, // VSTRT[9:2] + {0x1a, 0x97}, // VEND[9:2] + {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] + {0x37, 0x40}, + {0x4f, 0xbb}, + {0x50, 0x9c}, + {0x5a, 0x57}, + {0x6d, 0x80}, + {0x3d, 0x34}, + {0x39, 0x02}, + {0x35, 0x88}, + {0x22, 0x0a}, + {0x37, 0x40}, + {0x34, 0xa0}, + {0x06, 0x02}, + {0x0d, 0xb7}, + {0x0e, 0x01}, + + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0xc8}, + {0xc1, 0x96}, + {0x86, 0x35}, + {0x50, 0x89}, + {0x51, 0x90}, + {0x52, 0x2c}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x88}, + {0x57, 0x00}, + {0x5a, 0xc8}, + {0x5b, 0x96}, + {0x5c, 0x00}, + {0xd3, 0x02}, + {0xe0, 0x00}, + + {0xff, 0xff}, +}; + /* JPG 1024x768 */ -const struct sensor_reg OV2640_1024x768_JPEG[] PROGMEM = -{ - {0xff, 0x01}, - {0x11, 0x01}, - {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02Ϊ²ÊÌõ - {0x17, 0x11}, // HREFST[10:3] - {0x18, 0x75}, // HREFEND[10:3] - {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] - {0x19, 0x01}, // VSTRT[9:2] - {0x1a, 0x97}, // VEND[9:2] - {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x3d, 0x34}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x34, 0xa0}, - {0x06, 0x02}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - - {0xff, 0x00}, - {0xc0, 0xC8}, - {0xc1, 0x96}, - {0x8c, 0x00}, - {0x86, 0x3D}, - {0x50, 0x00}, - {0x51, 0x90}, - {0x52, 0x2C}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x5a, 0x00}, - {0x5b, 0xC0}, - {0x5c, 0x01}, - {0xd3, 0x02}, +const struct sensor_reg OV2640_1024x768_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x11, 0x01}, + {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02���� + {0x17, 0x11}, // HREFST[10:3] + {0x18, 0x75}, // HREFEND[10:3] + {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] + {0x19, 0x01}, // VSTRT[9:2] + {0x1a, 0x97}, // VEND[9:2] + {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] + {0x37, 0x40}, + {0x4f, 0xbb}, + {0x50, 0x9c}, + {0x5a, 0x57}, + {0x6d, 0x80}, + {0x3d, 0x34}, + {0x39, 0x02}, + {0x35, 0x88}, + {0x22, 0x0a}, + {0x37, 0x40}, + {0x34, 0xa0}, + {0x06, 0x02}, + {0x0d, 0xb7}, + {0x0e, 0x01}, - - {0xff, 0xff}, -}; + {0xff, 0x00}, + {0xc0, 0xC8}, + {0xc1, 0x96}, + {0x8c, 0x00}, + {0x86, 0x3D}, + {0x50, 0x00}, + {0x51, 0x90}, + {0x52, 0x2C}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x88}, + {0x5a, 0x00}, + {0x5b, 0xC0}, + {0x5c, 0x01}, + {0xd3, 0x02}, - /* JPG 1280x1024 */ -const struct sensor_reg OV2640_1280x1024_JPEG[] PROGMEM = -{ - {0xff, 0x01}, - {0x11, 0x01}, - {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02Ϊ²ÊÌõ - {0x17, 0x11}, // HREFST[10:3] - {0x18, 0x75}, // HREFEND[10:3] - {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] - {0x19, 0x01}, // VSTRT[9:2] - {0x1a, 0x97}, // VEND[9:2] - {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x3d, 0x34}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x34, 0xa0}, - {0x06, 0x02}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x00}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x40}, - {0x5b, 0xf0}, - {0x5c, 0x01}, - {0xd3, 0x02}, - {0xe0, 0x00}, - - {0xff, 0xff}, -}; - - /* JPG 1600x1200 */ -const struct sensor_reg OV2640_1600x1200_JPEG[] PROGMEM = -{ - {0xff, 0x01}, - {0x11, 0x01}, - {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02Ϊ²ÊÌõ - {0x17, 0x11}, // HREFST[10:3] - {0x18, 0x75}, // HREFEND[10:3] - {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] - {0x19, 0x01}, // VSTRT[9:2] - {0x1a, 0x97}, // VEND[9:2] - {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] - {0x37, 0x40}, - {0x4f, 0xbb}, - {0x50, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x3d, 0x34}, - {0x39, 0x02}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {0x34, 0xa0}, - {0x06, 0x02}, - {0x0d, 0xb7}, - {0x0e, 0x01}, - - {0xff, 0x00}, - {0xe0, 0x04}, - {0xc0, 0xc8}, - {0xc1, 0x96}, - {0x86, 0x3d}, - {0x50, 0x00}, - {0x51, 0x90}, - {0x52, 0x2c}, - {0x53, 0x00}, - {0x54, 0x00}, - {0x55, 0x88}, - {0x57, 0x00}, - {0x5a, 0x90}, - {0x5b, 0x2C}, - {0x5c, 0x05}, //bit2->1;bit[1:0]->1 - {0xd3, 0x02}, - {0xe0, 0x00}, - - {0xff, 0xff}, - -}; -#endif + {0xff, 0xff}, +}; + +/* JPG 1280x1024 */ +const struct sensor_reg OV2640_1280x1024_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x11, 0x01}, + {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02���� + {0x17, 0x11}, // HREFST[10:3] + {0x18, 0x75}, // HREFEND[10:3] + {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] + {0x19, 0x01}, // VSTRT[9:2] + {0x1a, 0x97}, // VEND[9:2] + {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] + {0x37, 0x40}, + {0x4f, 0xbb}, + {0x50, 0x9c}, + {0x5a, 0x57}, + {0x6d, 0x80}, + {0x3d, 0x34}, + {0x39, 0x02}, + {0x35, 0x88}, + {0x22, 0x0a}, + {0x37, 0x40}, + {0x34, 0xa0}, + {0x06, 0x02}, + {0x0d, 0xb7}, + {0x0e, 0x01}, + + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0xc8}, + {0xc1, 0x96}, + {0x86, 0x3d}, + {0x50, 0x00}, + {0x51, 0x90}, + {0x52, 0x2c}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x88}, + {0x57, 0x00}, + {0x5a, 0x40}, + {0x5b, 0xf0}, + {0x5c, 0x01}, + {0xd3, 0x02}, + {0xe0, 0x00}, + + {0xff, 0xff}, +}; +/* JPG 1600x1200 */ +const struct sensor_reg OV2640_1600x1200_JPEG[] PROGMEM = + { + {0xff, 0x01}, + {0x11, 0x01}, + {0x12, 0x00}, // Bit[6:4]: Resolution selection//0x02���� + {0x17, 0x11}, // HREFST[10:3] + {0x18, 0x75}, // HREFEND[10:3] + {0x32, 0x36}, // Bit[5:3]: HREFEND[2:0]; Bit[2:0]: HREFST[2:0] + {0x19, 0x01}, // VSTRT[9:2] + {0x1a, 0x97}, // VEND[9:2] + {0x03, 0x0f}, // Bit[3:2]: VEND[1:0]; Bit[1:0]: VSTRT[1:0] + {0x37, 0x40}, + {0x4f, 0xbb}, + {0x50, 0x9c}, + {0x5a, 0x57}, + {0x6d, 0x80}, + {0x3d, 0x34}, + {0x39, 0x02}, + {0x35, 0x88}, + {0x22, 0x0a}, + {0x37, 0x40}, + {0x34, 0xa0}, + {0x06, 0x02}, + {0x0d, 0xb7}, + {0x0e, 0x01}, + {0xff, 0x00}, + {0xe0, 0x04}, + {0xc0, 0xc8}, + {0xc1, 0x96}, + {0x86, 0x3d}, + {0x50, 0x00}, + {0x51, 0x90}, + {0x52, 0x2c}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x88}, + {0x57, 0x00}, + {0x5a, 0x90}, + {0x5b, 0x2C}, + {0x5c, 0x05}, // bit2->1;bit[1:0]->1 + {0xd3, 0x02}, + {0xe0, 0x00}, + + {0xff, 0xff}, + +}; +#endif const struct sensor_reg OV2640_SVGA[] { {0xff, 0x01}, -{0x12, 0x80}, -{0xff, 0x00}, -{0x2c, 0xff}, -{0x2e, 0xdf}, -{0xff, 0x01}, -{0x3c, 0x32}, -{0x11, 0x01}, -{0x09, 0x02}, -{0x04, 0x28}, -{0x13, 0xe5}, -{0x14, 0x48}, -{0x2c, 0x0c}, -{0x33, 0x78}, -{0x3a, 0x33}, -{0x3b, 0xfB}, -{0x3e, 0x00}, -{0x43, 0x11}, -{0x16, 0x10}, -{0x39, 0x92}, -{0x35, 0xda}, -{0x22, 0x1a}, -{0x37, 0xc3}, -{0x23, 0x00}, -{0x34, 0xc0}, -{0x36, 0x1a}, -{0x06, 0x88}, -{0x07, 0xc0}, -{0x0d, 0x87}, -{0x0e, 0x41}, -{0x4c, 0x00}, -{0x48, 0x00}, -{0x5B, 0x00}, -{0x42, 0x03}, -{0x4a, 0x81}, -{0x21, 0x99}, -{0x24, 0x40}, -{0x25, 0x38}, -{0x26, 0x82}, -{0x5c, 0x00}, -{0x63, 0x00}, -{0x61, 0x70}, -{0x62, 0x80}, -{0x7c, 0x05}, -{0x20, 0x80}, -{0x28, 0x30}, -{0x6c, 0x00}, -{0x6d, 0x80}, -{0x6e, 0x00}, -{0x70, 0x02}, -{0x71, 0x94}, -{0x73, 0xc1}, -{0x12, 0x40}, -{0x17, 0x11}, -{0x18, 0x43}, -{0x19, 0x00}, -{0x1a, 0x4b}, -{0x32, 0x09}, -{0x37, 0xc0}, -{0x4f, 0x60}, -{0x50, 0xa8}, -{0x6d, 0x00}, -{0x3d, 0x38}, -{0x46, 0x3f}, -{0x4f, 0x60}, -{0x0c, 0x3c}, -{0xff, 0x00}, -{0xe5, 0x7f}, -{0xf9, 0xc0}, -{0x41, 0x24}, -{0xe0, 0x14}, -{0x76, 0xff}, -{0x33, 0xa0}, -{0x42, 0x20}, -{0x43, 0x18}, -{0x4c, 0x00}, -{0x87, 0xd5}, -{0x88, 0x3f}, -{0xd7, 0x03}, -{0xd9, 0x10}, -{0xd3, 0x82}, -{0xc8, 0x08}, -{0xc9, 0x80}, -{0x7c, 0x00}, -{0x7d, 0x00}, -{0x7c, 0x03}, -{0x7d, 0x48}, -{0x7d, 0x48}, -{0x7c, 0x08}, -{0x7d, 0x20}, -{0x7d, 0x10}, -{0x7d, 0x0e}, -{0x90, 0x00}, -{0x91, 0x0e}, -{0x91, 0x1a}, -{0x91, 0x31}, -{0x91, 0x5a}, -{0x91, 0x69}, -{0x91, 0x75}, -{0x91, 0x7e}, -{0x91, 0x88}, -{0x91, 0x8f}, -{0x91, 0x96}, -{0x91, 0xa3}, -{0x91, 0xaf}, -{0x91, 0xc4}, -{0x91, 0xd7}, -{0x91, 0xe8}, -{0x91, 0x20}, -{0x92, 0x00}, -{0x93, 0x06}, -{0x93, 0xe3}, -{0x93, 0x05}, -{0x93, 0x05}, -{0x93, 0x00}, -{0x93, 0x04}, -{0x93, 0x00}, -{0x93, 0x00}, -{0x93, 0x00}, -{0x93, 0x00}, -{0x93, 0x00}, -{0x93, 0x00}, -{0x93, 0x00}, -{0x96, 0x00}, -{0x97, 0x08}, -{0x97, 0x19}, -{0x97, 0x02}, -{0x97, 0x0c}, -{0x97, 0x24}, -{0x97, 0x30}, -{0x97, 0x28}, -{0x97, 0x26}, -{0x97, 0x02}, -{0x97, 0x98}, -{0x97, 0x80}, -{0x97, 0x00}, -{0x97, 0x00}, -{0xc3, 0xed}, -{0xa4, 0x00}, -{0xa8, 0x00}, -{0xc5, 0x11}, -{0xc6, 0x51}, -{0xbf, 0x80}, -{0xc7, 0x10}, -{0xb6, 0x66}, -{0xb8, 0xA5}, -{0xb7, 0x64}, -{0xb9, 0x7C}, -{0xb3, 0xaf}, -{0xb4, 0x97}, -{0xb5, 0xFF}, -{0xb0, 0xC5}, -{0xb1, 0x94}, -{0xb2, 0x0f}, -{0xc4, 0x5c}, -{0xc0, 0x64}, -{0xc1, 0x4B}, -{0x8c, 0x00}, -{0x86, 0x3D}, -{0x50, 0x00}, -{0x51, 0xC8}, -{0x52, 0x96}, -{0x53, 0x00}, -{0x54, 0x00}, -{0x55, 0x00}, -{0x5a, 0xC8}, -{0x5b, 0x96}, -{0x5c, 0x00}, -{0xd3, 0x82}, -{0xc3, 0xed}, -{0x7f, 0x00}, -{0xda, 0x00}, -{0xe5, 0x1f}, -{0xe1, 0x67}, -{0xe0, 0x00}, -{0xdd, 0x7f}, -{0x05, 0x00}, -{0xff, 0xff}, + {0x12, 0x80}, + {0xff, 0x00}, + {0x2c, 0xff}, + {0x2e, 0xdf}, + {0xff, 0x01}, + {0x3c, 0x32}, + {0x11, 0x01}, + {0x09, 0x02}, + {0x04, 0x28}, + {0x13, 0xe5}, + {0x14, 0x48}, + {0x2c, 0x0c}, + {0x33, 0x78}, + {0x3a, 0x33}, + {0x3b, 0xfB}, + {0x3e, 0x00}, + {0x43, 0x11}, + {0x16, 0x10}, + {0x39, 0x92}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {0x34, 0xc0}, + {0x36, 0x1a}, + {0x06, 0x88}, + {0x07, 0xc0}, + {0x0d, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0x48, 0x00}, + {0x5B, 0x00}, + {0x42, 0x03}, + {0x4a, 0x81}, + {0x21, 0x99}, + {0x24, 0x40}, + {0x25, 0x38}, + {0x26, 0x82}, + {0x5c, 0x00}, + {0x63, 0x00}, + {0x61, 0x70}, + {0x62, 0x80}, + {0x7c, 0x05}, + {0x20, 0x80}, + {0x28, 0x30}, + {0x6c, 0x00}, + {0x6d, 0x80}, + {0x6e, 0x00}, + {0x70, 0x02}, + {0x71, 0x94}, + {0x73, 0xc1}, + {0x12, 0x40}, + {0x17, 0x11}, + {0x18, 0x43}, + {0x19, 0x00}, + {0x1a, 0x4b}, + {0x32, 0x09}, + {0x37, 0xc0}, + {0x4f, 0x60}, + {0x50, 0xa8}, + {0x6d, 0x00}, + {0x3d, 0x38}, + {0x46, 0x3f}, + {0x4f, 0x60}, + {0x0c, 0x3c}, + {0xff, 0x00}, + {0xe5, 0x7f}, + {0xf9, 0xc0}, + {0x41, 0x24}, + {0xe0, 0x14}, + {0x76, 0xff}, + {0x33, 0xa0}, + {0x42, 0x20}, + {0x43, 0x18}, + {0x4c, 0x00}, + {0x87, 0xd5}, + {0x88, 0x3f}, + {0xd7, 0x03}, + {0xd9, 0x10}, + {0xd3, 0x82}, + {0xc8, 0x08}, + {0xc9, 0x80}, + {0x7c, 0x00}, + {0x7d, 0x00}, + {0x7c, 0x03}, + {0x7d, 0x48}, + {0x7d, 0x48}, + {0x7c, 0x08}, + {0x7d, 0x20}, + {0x7d, 0x10}, + {0x7d, 0x0e}, + {0x90, 0x00}, + {0x91, 0x0e}, + {0x91, 0x1a}, + {0x91, 0x31}, + {0x91, 0x5a}, + {0x91, 0x69}, + {0x91, 0x75}, + {0x91, 0x7e}, + {0x91, 0x88}, + {0x91, 0x8f}, + {0x91, 0x96}, + {0x91, 0xa3}, + {0x91, 0xaf}, + {0x91, 0xc4}, + {0x91, 0xd7}, + {0x91, 0xe8}, + {0x91, 0x20}, + {0x92, 0x00}, + {0x93, 0x06}, + {0x93, 0xe3}, + {0x93, 0x05}, + {0x93, 0x05}, + {0x93, 0x00}, + {0x93, 0x04}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x93, 0x00}, + {0x96, 0x00}, + {0x97, 0x08}, + {0x97, 0x19}, + {0x97, 0x02}, + {0x97, 0x0c}, + {0x97, 0x24}, + {0x97, 0x30}, + {0x97, 0x28}, + {0x97, 0x26}, + {0x97, 0x02}, + {0x97, 0x98}, + {0x97, 0x80}, + {0x97, 0x00}, + {0x97, 0x00}, + {0xc3, 0xed}, + {0xa4, 0x00}, + {0xa8, 0x00}, + {0xc5, 0x11}, + {0xc6, 0x51}, + {0xbf, 0x80}, + {0xc7, 0x10}, + {0xb6, 0x66}, + {0xb8, 0xA5}, + {0xb7, 0x64}, + {0xb9, 0x7C}, + {0xb3, 0xaf}, + {0xb4, 0x97}, + {0xb5, 0xFF}, + {0xb0, 0xC5}, + {0xb1, 0x94}, + {0xb2, 0x0f}, + {0xc4, 0x5c}, + {0xc0, 0x64}, + {0xc1, 0x4B}, + {0x8c, 0x00}, + {0x86, 0x3D}, + {0x50, 0x00}, + {0x51, 0xC8}, + {0x52, 0x96}, + {0x53, 0x00}, + {0x54, 0x00}, + {0x55, 0x00}, + {0x5a, 0xC8}, + {0x5b, 0x96}, + {0x5c, 0x00}, + {0xd3, 0x82}, + {0xc3, 0xed}, + {0x7f, 0x00}, + {0xda, 0x00}, + {0xe5, 0x1f}, + {0xe1, 0x67}, + {0xe0, 0x00}, + {0xdd, 0x7f}, + {0x05, 0x00}, + {0xff, 0xff}, }; const struct sensor_reg OV2640_640x480_JPEG2[] = -{ - {0xff,0x01}, //001 - {0x11,0x01}, //002 - {0x12,0x00}, //003 - {0x17,0x11}, //004 - {0x18,0x75}, //005 - {0x32,0x36}, //006 - {0x19,0x01}, //007 - {0x1a,0x97}, //008 - {0x03,0x0f}, //009 - {0x37,0x40}, //010 - {0x4f,0xbb}, //011 - {0x50,0x9c}, //012 - {0x5a,0x57}, //013 - {0x6d,0x80}, //014 - {0x3d,0x34}, //015 - {0x39,0x02}, //016 - {0x35,0x88}, //017 - {0x22,0x0a}, //018 - {0x37,0x40}, //019 - {0x34,0xa0}, //020 - {0x06,0x02}, //021 - {0x0d,0xb7}, //022 - {0x0e,0x01}, //023 - {0xff,0x00}, //024 - {0xe0,0x04}, //025 - {0xc0,0xc8}, //026 - {0xc1,0x96}, //027 - {0x86,0x3d}, //028 - {0x50,0x89}, //029 - {0x51,0x90}, //030 - {0x52,0x2c}, //031 - {0x53,0x00}, //032 - {0x54,0x00}, //033 - {0x55,0x88}, //034 - {0x57,0x00}, //035 - {0x5a,0xa0}, //036 - {0x5b,0x78}, //037 - {0x5c,0x00}, //038 - {0xd3,0x04}, //039 - {0xe0,0x00}, //040 + { + {0xff, 0x01}, // 001 + {0x11, 0x01}, // 002 + {0x12, 0x00}, // 003 + {0x17, 0x11}, // 004 + {0x18, 0x75}, // 005 + {0x32, 0x36}, // 006 + {0x19, 0x01}, // 007 + {0x1a, 0x97}, // 008 + {0x03, 0x0f}, // 009 + {0x37, 0x40}, // 010 + {0x4f, 0xbb}, // 011 + {0x50, 0x9c}, // 012 + {0x5a, 0x57}, // 013 + {0x6d, 0x80}, // 014 + {0x3d, 0x34}, // 015 + {0x39, 0x02}, // 016 + {0x35, 0x88}, // 017 + {0x22, 0x0a}, // 018 + {0x37, 0x40}, // 019 + {0x34, 0xa0}, // 020 + {0x06, 0x02}, // 021 + {0x0d, 0xb7}, // 022 + {0x0e, 0x01}, // 023 + {0xff, 0x00}, // 024 + {0xe0, 0x04}, // 025 + {0xc0, 0xc8}, // 026 + {0xc1, 0x96}, // 027 + {0x86, 0x3d}, // 028 + {0x50, 0x89}, // 029 + {0x51, 0x90}, // 030 + {0x52, 0x2c}, // 031 + {0x53, 0x00}, // 032 + {0x54, 0x00}, // 033 + {0x55, 0x88}, // 034 + {0x57, 0x00}, // 035 + {0x5a, 0xa0}, // 036 + {0x5b, 0x78}, // 037 + {0x5c, 0x00}, // 038 + {0xd3, 0x04}, // 039 + {0xe0, 0x00}, // 040 }; \ No newline at end of file diff --git a/ArduCAM/ov3640_regs.h b/ArduCAM/ov3640_regs.h index abdf3b71..514cf4f7 100644 --- a/ArduCAM/ov3640_regs.h +++ b/ArduCAM/ov3640_regs.h @@ -2,393 +2,387 @@ #define OV3640_REGS_H #include "ArduCAM.h" -#define OV3640_CHIPID_HIGH 0x300a -#define OV3640_CHIPID_LOW 0x300b +#define OV3640_CHIPID_HIGH 0x300a +#define OV3640_CHIPID_LOW 0x300b -//#include +// #include const struct sensor_reg OV3640_VGA[] PROGMEM = -{ - {0x3012, 0x80}, - {0x3012, 0x80}, - {0x304d, 0x45}, - {0x3087, 0x16}, - {0x30aa, 0x45}, - {0x30b0, 0xff}, - {0x30b1, 0xff}, - {0x30b2, 0x10}, - {0x30d7, 0x10}, - {0x309e, 0x00}, - {0x3602, 0x26}, - {0x3603, 0x4D}, - {0x364c, 0x04}, - {0x360c, 0x12}, - {0x361e, 0x00}, - {0x361f, 0x11}, - {0x3633, 0x32}, - {0x3629, 0x3c}, - {0x300e, 0x32}, - {0x300f, 0x21}, - {0x3010, 0x21}, - {0x3011, 0x00}, - {0x304c, 0x81}, - {0x3018, 0x58}, - {0x3019, 0x59}, - {0x301a, 0x61}, - {0x307d, 0x00}, - {0x3087, 0x02}, - {0x3082, 0x20}, - {0x303c, 0x08}, - {0x303d, 0x18}, - {0x303e, 0x06}, - {0x303F, 0x0c}, - {0x3030, 0x62}, - {0x3031, 0x26}, - {0x3032, 0xe6}, - {0x3033, 0x6e}, - {0x3034, 0xea}, - {0x3035, 0xae}, - {0x3036, 0xa6}, - {0x3037, 0x6a}, - {0x3015, 0x12}, - {0x3014, 0x84}, - {0x3013, 0xf7}, - {0x3104, 0x02}, - {0x3105, 0xfd}, - {0x3106, 0x00}, - {0x3107, 0xff}, - {0x3308, 0xa5}, - {0x3316, 0xff}, - {0x3317, 0x00}, - {0x3087, 0x02}, - {0x3082, 0x20}, - {0x3300, 0x13}, - {0x3301, 0xd6}, - {0x3302, 0xef}, - {0x30b8, 0x20}, - {0x30b9, 0x17}, - {0x30ba, 0x04}, - {0x30bb, 0x08}, - {0x3100, 0x02}, - {0x3304, 0xfc}, - {0x3400, 0x00}, - {0x3404, 0x00}, - {0x3020, 0x01}, - {0x3021, 0x1d}, - {0x3022, 0x00}, - {0x3023, 0x0a}, - {0x3024, 0x08}, - {0x3025, 0x18}, - {0x3026, 0x06}, - {0x3027, 0x0c}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x68}, - {0x3363, 0x08}, - {0x3364, 0x04}, - {0x3403, 0x42}, - {0x3088, 0x08}, - {0x3089, 0x00}, - {0x308a, 0x06}, - {0x308b, 0x00}, - {0x3507, 0x06}, - {0x350a, 0x4f}, - {0x3600, 0xc4}, - {0x3011, 0x01}, - {0xffff, 0xff}, - + { + {0x3012, 0x80}, + {0x3012, 0x80}, + {0x304d, 0x45}, + {0x3087, 0x16}, + {0x30aa, 0x45}, + {0x30b0, 0xff}, + {0x30b1, 0xff}, + {0x30b2, 0x10}, + {0x30d7, 0x10}, + {0x309e, 0x00}, + {0x3602, 0x26}, + {0x3603, 0x4D}, + {0x364c, 0x04}, + {0x360c, 0x12}, + {0x361e, 0x00}, + {0x361f, 0x11}, + {0x3633, 0x32}, + {0x3629, 0x3c}, + {0x300e, 0x32}, + {0x300f, 0x21}, + {0x3010, 0x21}, + {0x3011, 0x00}, + {0x304c, 0x81}, + {0x3018, 0x58}, + {0x3019, 0x59}, + {0x301a, 0x61}, + {0x307d, 0x00}, + {0x3087, 0x02}, + {0x3082, 0x20}, + {0x303c, 0x08}, + {0x303d, 0x18}, + {0x303e, 0x06}, + {0x303F, 0x0c}, + {0x3030, 0x62}, + {0x3031, 0x26}, + {0x3032, 0xe6}, + {0x3033, 0x6e}, + {0x3034, 0xea}, + {0x3035, 0xae}, + {0x3036, 0xa6}, + {0x3037, 0x6a}, + {0x3015, 0x12}, + {0x3014, 0x84}, + {0x3013, 0xf7}, + {0x3104, 0x02}, + {0x3105, 0xfd}, + {0x3106, 0x00}, + {0x3107, 0xff}, + {0x3308, 0xa5}, + {0x3316, 0xff}, + {0x3317, 0x00}, + {0x3087, 0x02}, + {0x3082, 0x20}, + {0x3300, 0x13}, + {0x3301, 0xd6}, + {0x3302, 0xef}, + {0x30b8, 0x20}, + {0x30b9, 0x17}, + {0x30ba, 0x04}, + {0x30bb, 0x08}, + {0x3100, 0x02}, + {0x3304, 0xfc}, + {0x3400, 0x00}, + {0x3404, 0x00}, + {0x3020, 0x01}, + {0x3021, 0x1d}, + {0x3022, 0x00}, + {0x3023, 0x0a}, + {0x3024, 0x08}, + {0x3025, 0x18}, + {0x3026, 0x06}, + {0x3027, 0x0c}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x68}, + {0x3363, 0x08}, + {0x3364, 0x04}, + {0x3403, 0x42}, + {0x3088, 0x08}, + {0x3089, 0x00}, + {0x308a, 0x06}, + {0x308b, 0x00}, + {0x3507, 0x06}, + {0x350a, 0x4f}, + {0x3600, 0xc4}, + {0x3011, 0x01}, + {0xffff, 0xff}, + }; +const struct sensor_reg OV3640_QVGA[] PROGMEM = + { + {0x3012, 0x80}, + {0x304d, 0x45}, + {0x30a7, 0x5e}, + {0x3087, 0x16}, + {0x309c, 0x1a}, + {0x30a2, 0xe4}, + {0x30aa, 0x42}, + {0x30b0, 0xff}, + {0x30b1, 0xff}, + {0x30b2, 0x10}, + {0x300e, 0x32}, + {0x300f, 0x21}, + {0x3010, 0x20}, + {0x3011, 0x04}, + {0x304c, 0x81}, + {0x30d7, 0x10}, + {0x30d9, 0x0d}, + {0x30db, 0x08}, + {0x3016, 0x82}, + {0x3018, 0x58}, + {0x3019, 0x59}, + {0x301a, 0x61}, + {0x307d, 0x00}, + {0x3087, 0x02}, + {0x3082, 0x20}, + {0x3015, 0x12}, + {0x3014, 0x84}, + {0x3013, 0xf7}, + {0x303c, 0x08}, + {0x303d, 0x18}, + {0x303e, 0x06}, + {0x303f, 0x0c}, + {0x3030, 0x62}, + {0x3031, 0x26}, + {0x3032, 0xe6}, + {0x3033, 0x6e}, + {0x3034, 0xea}, + {0x3035, 0xae}, + {0x3036, 0xa6}, + {0x3037, 0x6a}, + {0x3104, 0x02}, + {0x3105, 0xfd}, + {0x3106, 0x00}, + {0x3107, 0xff}, + {0x3300, 0x12}, + {0x3301, 0xde}, + {0x3302, 0xef}, + {0x3316, 0xff}, + {0x3317, 0x00}, + {0x3312, 0x26}, + {0x3314, 0x42}, + {0x3313, 0x2b}, + {0x3315, 0x42}, + {0x3310, 0xd0}, + {0x3311, 0xbd}, + {0x330c, 0x18}, + {0x330d, 0x18}, + {0x330e, 0x56}, + {0x330f, 0x5c}, + {0x330b, 0x1c}, + {0x3306, 0x5c}, + {0x3307, 0x11}, + {0x336a, 0x52}, + {0x3370, 0x46}, + {0x3376, 0x38}, + {0x3300, 0x13}, + {0x30b8, 0x20}, + {0x30b9, 0x17}, + {0x30ba, 0x4}, + {0x30bb, 0x8}, + {0x3507, 0x06}, + {0x350a, 0x4f}, + {0x3100, 0x02}, + {0x3301, 0xde}, + {0x3304, 0x00}, + {0x3400, 0x01}, + {0x3404, 0x11}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0xc}, + {0x3362, 0x12}, + {0x3363, 0x88}, + {0x3364, 0xe4}, + {0x3403, 0x42}, + {0x3088, 0x2}, + {0x3089, 0x80}, + {0x308a, 0x1}, + {0x308b, 0xe0}, + {0x308d, 0x4}, + {0x3086, 0x3}, + {0x3086, 0x0}, + {0x3011, 0x0}, + {0x304c, 0x85}, + {0x3600, 0xd0}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0xc}, + {0x3362, 0x1}, + {0x3363, 0x48}, + {0x3364, 0xf4}, + {0x3403, 0x42}, + {0x3088, 0x1}, + {0x3089, 0x40}, + {0x308a, 0x0}, + {0x308b, 0xf0}, -const struct sensor_reg OV3640_QVGA[] PROGMEM = -{ - {0x3012, 0x80}, - {0x304d, 0x45}, - {0x30a7, 0x5e}, - {0x3087, 0x16}, - {0x309c, 0x1a}, - {0x30a2, 0xe4}, - {0x30aa, 0x42}, - {0x30b0, 0xff}, - {0x30b1, 0xff}, - {0x30b2, 0x10}, - {0x300e, 0x32}, - {0x300f, 0x21}, - {0x3010, 0x20}, - {0x3011, 0x04}, - {0x304c, 0x81}, - {0x30d7, 0x10}, - {0x30d9, 0x0d}, - {0x30db, 0x08}, - {0x3016, 0x82}, - {0x3018, 0x58}, - {0x3019, 0x59}, - {0x301a, 0x61}, - {0x307d, 0x00}, - {0x3087, 0x02}, - {0x3082, 0x20}, - {0x3015, 0x12}, - {0x3014, 0x84}, - {0x3013, 0xf7}, - {0x303c, 0x08}, - {0x303d, 0x18}, + {0x307c, 0x12}, + {0x3090, 0xc8}, - {0x303e, 0x06}, - {0x303f, 0x0c}, - {0x3030, 0x62}, - {0x3031, 0x26}, - {0x3032, 0xe6}, - {0x3033, 0x6e}, - {0x3034, 0xea}, - {0x3035, 0xae}, - {0x3036, 0xa6}, - {0x3037, 0x6a}, - {0x3104, 0x02}, - {0x3105, 0xfd}, - {0x3106, 0x00}, - {0x3107, 0xff}, - {0x3300, 0x12}, - {0x3301, 0xde}, - {0x3302, 0xef}, - {0x3316, 0xff}, - {0x3317, 0x00}, - {0x3312, 0x26}, - {0x3314, 0x42}, - {0x3313, 0x2b}, - {0x3315, 0x42}, - {0x3310, 0xd0}, - {0x3311, 0xbd}, - {0x330c, 0x18}, - {0x330d, 0x18}, - {0x330e, 0x56}, - {0x330f, 0x5c}, - {0x330b, 0x1c}, - {0x3306, 0x5c}, - {0x3307, 0x11}, - {0x336a, 0x52}, - {0x3370, 0x46}, - {0x3376, 0x38}, - {0x3300, 0x13}, - {0x30b8, 0x20}, - {0x30b9, 0x17}, - {0x30ba, 0x4}, - {0x30bb, 0x8}, + //{0x3080, 0x02}, + //{0x307D, 0x80}, + //{0x306C, 0x10}, - {0x3507, 0x06}, - {0x350a, 0x4f}, - {0x3100, 0x02}, - {0x3301, 0xde}, - {0x3304, 0x00}, - {0x3400, 0x01}, - {0x3404, 0x11}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0xc}, - {0x3362, 0x12}, - {0x3363, 0x88}, - {0x3364, 0xe4}, - {0x3403, 0x42}, - {0x3088, 0x2}, - {0x3089, 0x80}, - {0x308a, 0x1}, - {0x308b, 0xe0}, - {0x308d, 0x4}, - {0x3086, 0x3}, - {0x3086, 0x0}, - {0x3011, 0x0}, - {0x304c, 0x85}, - {0x3600, 0xd0}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0xc}, - {0x3362, 0x1}, - {0x3363, 0x48}, - {0x3364, 0xf4}, - {0x3403, 0x42}, - {0x3088, 0x1}, - {0x3089, 0x40}, - {0x308a, 0x0}, - {0x308b, 0xf0}, - - {0x307c, 0x12}, - {0x3090, 0xc8}, - - //{0x3080, 0x02}, - //{0x307D, 0x80}, - //{0x306C, 0x10}, - - {0x3600, 0xc4}, - {0xffff,0xff}, + {0x3600, 0xc4}, + {0xffff, 0xff}, }; -const struct sensor_reg OV3640_176x144_JPEG[] PROGMEM = -{ - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x00}, - {0x3363, 0xb8}, - {0x3364, 0x94}, - {0x3403, 0x42}, - {0x3088, 0x00}, - {0x3089, 0xb0}, - {0x308a, 0x00}, - {0x308b, 0x90}, - {0x304c, 0x84}, +const struct sensor_reg OV3640_176x144_JPEG[] PROGMEM = + { + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x00}, + {0x3363, 0xb8}, + {0x3364, 0x94}, + {0x3403, 0x42}, + {0x3088, 0x00}, + {0x3089, 0xb0}, + {0x308a, 0x00}, + {0x308b, 0x90}, + {0x304c, 0x84}, - {0xffff, 0xff}, + {0xffff, 0xff}, }; const struct sensor_reg OV3640_320x240_JPEG[] PROGMEM = -{ - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x01}, - {0x3363, 0x48}, - {0x3364, 0xf4}, - {0x3403, 0x42}, - {0x3088, 0x01}, - {0x3089, 0x40}, - {0x308a, 0x00}, - {0x308b, 0xf0}, - - {0xffff,0xff}, -}; + { + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x01}, + {0x3363, 0x48}, + {0x3364, 0xf4}, + {0x3403, 0x42}, + {0x3088, 0x01}, + {0x3089, 0x40}, + {0x308a, 0x00}, + {0x308b, 0xf0}, + + {0xffff, 0xff}, +}; const struct sensor_reg OV3640_352x288_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x11}, - {0x3363, 0x68}, - {0x3364, 0x24}, - {0x3403, 0x42}, - {0x3088, 0x01}, - {0x3089, 0x60}, - {0x308a, 0x01}, - {0x308b, 0x20}, - - {0xffff,0xff}, + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x11}, + {0x3363, 0x68}, + {0x3364, 0x24}, + {0x3403, 0x42}, + {0x3088, 0x01}, + {0x3089, 0x60}, + {0x308a, 0x01}, + {0x308b, 0x20}, + + {0xffff, 0xff}, }; +const struct sensor_reg OV3640_640x480_JPEG[] PROGMEM = + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x12}, + {0x3363, 0x88}, + {0x3364, 0xe4}, + {0x3403, 0x42}, + {0x3088, 0x02}, + {0x3089, 0x80}, + {0x308a, 0x01}, + {0x308b, 0xe0}, + {0x304c, 0x84}, -const struct sensor_reg OV3640_640x480_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x12}, - {0x3363, 0x88}, - {0x3364, 0xe4}, - {0x3403, 0x42}, - {0x3088, 0x02}, - {0x3089, 0x80}, - {0x308a, 0x01}, - {0x308b, 0xe0}, - {0x304c, 0x84}, - - {0xffff, 0xff}, + {0xffff, 0xff}, }; - const struct sensor_reg OV3640_800x600_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x23}, - {0x3363, 0x28}, - {0x3364, 0x5c}, - {0x3403, 0x42}, - {0x3088, 0x03}, - {0x3089, 0x20}, - {0x308a, 0x02}, - {0x308b, 0x58}, - {0x304c, 0x82}, - - {0xffff, 0xff}, +const struct sensor_reg OV3640_800x600_JPEG[] PROGMEM = + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x23}, + {0x3363, 0x28}, + {0x3364, 0x5c}, + {0x3403, 0x42}, + {0x3088, 0x03}, + {0x3089, 0x20}, + {0x308a, 0x02}, + {0x308b, 0x58}, + {0x304c, 0x82}, + + {0xffff, 0xff}, }; - const struct sensor_reg OV3640_1024x768_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x34}, - {0x3363, 0x08}, - {0x3364, 0x06}, - {0x3403, 0x42}, - {0x3088, 0x04}, - {0x3089, 0x00}, - {0x308a, 0x03}, - {0x308b, 0x00}, - {0x304c, 0x82}, - - {0xffff, 0xff}, +const struct sensor_reg OV3640_1024x768_JPEG[] PROGMEM = + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x34}, + {0x3363, 0x08}, + {0x3364, 0x06}, + {0x3403, 0x42}, + {0x3088, 0x04}, + {0x3089, 0x00}, + {0x308a, 0x03}, + {0x308b, 0x00}, + {0x304c, 0x82}, + + {0xffff, 0xff}, }; - - const struct sensor_reg OV3640_1600x1200_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0C}, - {0x3362, 0x46}, - {0x3363, 0x48}, - {0x3364, 0xb4}, - {0x3403, 0x42}, - {0x3088, 0x06}, - {0x3089, 0x40}, - {0x308a, 0x04}, - {0x308b, 0xb0}, - {0x304c, 0x85}, - - - {0xffff, 0xff}, - -}; - const struct sensor_reg OV3640_1280x960_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x35}, - {0x3363, 0x08}, - {0x3364, 0xc4}, - {0x3403, 0x42}, - {0x3088, 0x05}, - {0x3089, 0x00}, - {0x308a, 0x03}, - {0x308b, 0xc0}, - {0x304c, 0x81}, - - {0xffff, 0xff}, + +const struct sensor_reg OV3640_1600x1200_JPEG[] PROGMEM = + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0C}, + {0x3362, 0x46}, + {0x3363, 0x48}, + {0x3364, 0xb4}, + {0x3403, 0x42}, + {0x3088, 0x06}, + {0x3089, 0x40}, + {0x308a, 0x04}, + {0x308b, 0xb0}, + {0x304c, 0x85}, + + {0xffff, 0xff}, + +}; +const struct sensor_reg OV3640_1280x960_JPEG[] PROGMEM = + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x35}, + {0x3363, 0x08}, + {0x3364, 0xc4}, + {0x3403, 0x42}, + {0x3088, 0x05}, + {0x3089, 0x00}, + {0x308a, 0x03}, + {0x308b, 0xc0}, + {0x304c, 0x81}, + + {0xffff, 0xff}, }; const struct sensor_reg OV3640_2048x1536_JPEG[] PROGMEM = -{ - {0x3302, 0xef}, - {0x335f, 0x68}, - {0x3360, 0x18}, - {0x3361, 0x0c}, - {0x3362, 0x68}, - {0x3363, 0x08}, - {0x3364, 0x04}, - {0x3403, 0x42}, - {0x3088, 0x08}, - {0x3089, 0x00}, - {0x308a, 0x06}, - {0x308b, 0x00}, - - {0xffff,0xff}, + { + {0x3302, 0xef}, + {0x335f, 0x68}, + {0x3360, 0x18}, + {0x3361, 0x0c}, + {0x3362, 0x68}, + {0x3363, 0x08}, + {0x3364, 0x04}, + {0x3403, 0x42}, + {0x3088, 0x08}, + {0x3089, 0x00}, + {0x308a, 0x06}, + {0x308b, 0x00}, + + {0xffff, 0xff}, }; #endif - diff --git a/ArduCAM/ov5640_regs.h b/ArduCAM/ov5640_regs.h index 0cbe953c..672c8dab 100644 --- a/ArduCAM/ov5640_regs.h +++ b/ArduCAM/ov5640_regs.h @@ -1,4477 +1,4466 @@ #ifndef OV5640_REGS_H #define OV5640_REGS_H #include "ArduCAM.h" -//#include +// #include #define OV5640_CHIPID_HIGH 0x300a #define OV5640_CHIPID_LOW 0x300b -const struct sensor_reg OV5640_Auto_Focus[] PROGMEM= -{ -{0x3000,0x20}, -{0x8000,0x02}, -{0x8001,0x0f}, -{0x8002,0xd6}, -{0x8003,0x02}, -{0x8004,0x0a}, -{0x8005,0x39}, -{0x8006,0xc2}, -{0x8007,0x01}, -{0x8008,0x22}, -{0x8009,0x22}, -{0x800a,0x00}, -{0x800b,0x02}, -{0x800c,0x0f}, -{0x800d,0xb2}, -{0x800e,0xe5}, -{0x800f,0x1f}, -{0x8010,0x70}, -{0x8011,0x72}, -{0x8012,0xf5}, -{0x8013,0x1e}, -{0x8014,0xd2}, -{0x8015,0x35}, -{0x8016,0xff}, -{0x8017,0xef}, -{0x8018,0x25}, -{0x8019,0xe0}, -{0x801a,0x24}, -{0x801b,0x4e}, -{0x801c,0xf8}, -{0x801d,0xe4}, -{0x801e,0xf6}, -{0x801f,0x08}, -{0x8020,0xf6}, -{0x8021,0x0f}, -{0x8022,0xbf}, -{0x8023,0x34}, -{0x8024,0xf2}, -{0x8025,0x90}, -{0x8026,0x0e}, -{0x8027,0x93}, -{0x8028,0xe4}, -{0x8029,0x93}, -{0x802a,0xff}, -{0x802b,0xe5}, -{0x802c,0x4b}, -{0x802d,0xc3}, -{0x802e,0x9f}, -{0x802f,0x50}, -{0x8030,0x04}, -{0x8031,0x7f}, -{0x8032,0x05}, -{0x8033,0x80}, -{0x8034,0x02}, -{0x8035,0x7f}, -{0x8036,0xfb}, -{0x8037,0x78}, -{0x8038,0xbd}, -{0x8039,0xa6}, -{0x803a,0x07}, -{0x803b,0x12}, -{0x803c,0x0f}, -{0x803d,0x04}, -{0x803e,0x40}, -{0x803f,0x04}, -{0x8040,0x7f}, -{0x8041,0x03}, -{0x8042,0x80}, -{0x8043,0x02}, -{0x8044,0x7f}, -{0x8045,0x30}, -{0x8046,0x78}, -{0x8047,0xbc}, -{0x8048,0xa6}, -{0x8049,0x07}, -{0x804a,0xe6}, -{0x804b,0x18}, -{0x804c,0xf6}, -{0x804d,0x08}, -{0x804e,0xe6}, -{0x804f,0x78}, -{0x8050,0xb9}, -{0x8051,0xf6}, -{0x8052,0x78}, -{0x8053,0xbc}, -{0x8054,0xe6}, -{0x8055,0x78}, -{0x8056,0xba}, -{0x8057,0xf6}, -{0x8058,0x78}, -{0x8059,0xbf}, -{0x805a,0x76}, -{0x805b,0x33}, -{0x805c,0xe4}, -{0x805d,0x08}, -{0x805e,0xf6}, -{0x805f,0x78}, -{0x8060,0xb8}, -{0x8061,0x76}, -{0x8062,0x01}, -{0x8063,0x75}, -{0x8064,0x4a}, -{0x8065,0x02}, -{0x8066,0x78}, -{0x8067,0xb6}, -{0x8068,0xf6}, -{0x8069,0x08}, -{0x806a,0xf6}, -{0x806b,0x74}, -{0x806c,0xff}, -{0x806d,0x78}, -{0x806e,0xc1}, -{0x806f,0xf6}, -{0x8070,0x08}, -{0x8071,0xf6}, -{0x8072,0x75}, -{0x8073,0x1f}, -{0x8074,0x01}, -{0x8075,0x78}, -{0x8076,0xbc}, -{0x8077,0xe6}, -{0x8078,0x75}, -{0x8079,0xf0}, -{0x807a,0x05}, -{0x807b,0xa4}, -{0x807c,0xf5}, -{0x807d,0x4b}, -{0x807e,0x12}, -{0x807f,0x0a}, -{0x8080,0xff}, -{0x8081,0xc2}, -{0x8082,0x37}, -{0x8083,0x22}, -{0x8084,0x78}, -{0x8085,0xb8}, -{0x8086,0xe6}, -{0x8087,0xd3}, -{0x8088,0x94}, -{0x8089,0x00}, -{0x808a,0x40}, -{0x808b,0x02}, -{0x808c,0x16}, -{0x808d,0x22}, -{0x808e,0xe5}, -{0x808f,0x1f}, -{0x8090,0xb4}, -{0x8091,0x05}, -{0x8092,0x23}, -{0x8093,0xe4}, -{0x8094,0xf5}, -{0x8095,0x1f}, -{0x8096,0xc2}, -{0x8097,0x01}, -{0x8098,0x78}, -{0x8099,0xb6}, -{0x809a,0xe6}, -{0x809b,0xfe}, -{0x809c,0x08}, -{0x809d,0xe6}, -{0x809e,0xff}, -{0x809f,0x78}, -{0x80a0,0x4e}, -{0x80a1,0xa6}, -{0x80a2,0x06}, -{0x80a3,0x08}, -{0x80a4,0xa6}, -{0x80a5,0x07}, -{0x80a6,0xa2}, -{0x80a7,0x37}, -{0x80a8,0xe4}, -{0x80a9,0x33}, -{0x80aa,0xf5}, -{0x80ab,0x3c}, -{0x80ac,0x90}, -{0x80ad,0x30}, -{0x80ae,0x28}, -{0x80af,0xf0}, -{0x80b0,0x75}, -{0x80b1,0x1e}, -{0x80b2,0x10}, -{0x80b3,0xd2}, -{0x80b4,0x35}, -{0x80b5,0x22}, -{0x80b6,0xe5}, -{0x80b7,0x4b}, -{0x80b8,0x75}, -{0x80b9,0xf0}, -{0x80ba,0x05}, -{0x80bb,0x84}, -{0x80bc,0x78}, -{0x80bd,0xbc}, -{0x80be,0xf6}, -{0x80bf,0x90}, -{0x80c0,0x0e}, -{0x80c1,0x8c}, -{0x80c2,0xe4}, -{0x80c3,0x93}, -{0x80c4,0xff}, -{0x80c5,0x25}, -{0x80c6,0xe0}, -{0x80c7,0x24}, -{0x80c8,0x0a}, -{0x80c9,0xf8}, -{0x80ca,0xe6}, -{0x80cb,0xfc}, -{0x80cc,0x08}, -{0x80cd,0xe6}, -{0x80ce,0xfd}, -{0x80cf,0x78}, -{0x80d0,0xbc}, -{0x80d1,0xe6}, -{0x80d2,0x25}, -{0x80d3,0xe0}, -{0x80d4,0x24}, -{0x80d5,0x4e}, -{0x80d6,0xf8}, -{0x80d7,0xa6}, -{0x80d8,0x04}, -{0x80d9,0x08}, -{0x80da,0xa6}, -{0x80db,0x05}, -{0x80dc,0xef}, -{0x80dd,0x12}, -{0x80de,0x0f}, -{0x80df,0x0b}, -{0x80e0,0xd3}, -{0x80e1,0x78}, -{0x80e2,0xb7}, -{0x80e3,0x96}, -{0x80e4,0xee}, -{0x80e5,0x18}, -{0x80e6,0x96}, -{0x80e7,0x40}, -{0x80e8,0x0d}, -{0x80e9,0x78}, -{0x80ea,0xbc}, -{0x80eb,0xe6}, -{0x80ec,0x78}, -{0x80ed,0xb9}, -{0x80ee,0xf6}, -{0x80ef,0x78}, -{0x80f0,0xb6}, -{0x80f1,0xa6}, -{0x80f2,0x06}, -{0x80f3,0x08}, -{0x80f4,0xa6}, -{0x80f5,0x07}, -{0x80f6,0x90}, -{0x80f7,0x0e}, -{0x80f8,0x8c}, -{0x80f9,0xe4}, -{0x80fa,0x93}, -{0x80fb,0x12}, -{0x80fc,0x0f}, -{0x80fd,0x0b}, -{0x80fe,0xc3}, -{0x80ff,0x78}, -{0x8100,0xc2}, -{0x8101,0x96}, -{0x8102,0xee}, -{0x8103,0x18}, -{0x8104,0x96}, -{0x8105,0x50}, -{0x8106,0x0d}, -{0x8107,0x78}, -{0x8108,0xbc}, -{0x8109,0xe6}, -{0x810a,0x78}, -{0x810b,0xba}, -{0x810c,0xf6}, -{0x810d,0x78}, -{0x810e,0xc1}, -{0x810f,0xa6}, -{0x8110,0x06}, -{0x8111,0x08}, -{0x8112,0xa6}, -{0x8113,0x07}, -{0x8114,0x78}, -{0x8115,0xb6}, -{0x8116,0xe6}, -{0x8117,0xfe}, -{0x8118,0x08}, -{0x8119,0xe6}, -{0x811a,0xc3}, -{0x811b,0x78}, -{0x811c,0xc2}, -{0x811d,0x96}, -{0x811e,0xff}, -{0x811f,0xee}, -{0x8120,0x18}, -{0x8121,0x96}, -{0x8122,0x78}, -{0x8123,0xc3}, -{0x8124,0xf6}, -{0x8125,0x08}, -{0x8126,0xa6}, -{0x8127,0x07}, -{0x8128,0x90}, -{0x8129,0x0e}, -{0x812a,0x95}, -{0x812b,0xe4}, -{0x812c,0x18}, -{0x812d,0x12}, -{0x812e,0x0e}, -{0x812f,0xe9}, -{0x8130,0x40}, -{0x8131,0x02}, -{0x8132,0xd2}, -{0x8133,0x37}, -{0x8134,0x78}, -{0x8135,0xbc}, -{0x8136,0xe6}, -{0x8137,0x08}, -{0x8138,0x26}, -{0x8139,0x08}, -{0x813a,0xf6}, -{0x813b,0xe5}, -{0x813c,0x1f}, -{0x813d,0x64}, -{0x813e,0x01}, -{0x813f,0x70}, -{0x8140,0x4a}, -{0x8141,0xe6}, -{0x8142,0xc3}, -{0x8143,0x78}, -{0x8144,0xc0}, -{0x8145,0x12}, -{0x8146,0x0e}, -{0x8147,0xdf}, -{0x8148,0x40}, -{0x8149,0x05}, -{0x814a,0x12}, -{0x814b,0x0e}, -{0x814c,0xda}, -{0x814d,0x40}, -{0x814e,0x39}, -{0x814f,0x12}, -{0x8150,0x0f}, -{0x8151,0x02}, -{0x8152,0x40}, -{0x8153,0x04}, -{0x8154,0x7f}, -{0x8155,0xfe}, -{0x8156,0x80}, -{0x8157,0x02}, -{0x8158,0x7f}, -{0x8159,0x02}, -{0x815a,0x78}, -{0x815b,0xbd}, -{0x815c,0xa6}, -{0x815d,0x07}, -{0x815e,0x78}, -{0x815f,0xb9}, -{0x8160,0xe6}, -{0x8161,0x24}, -{0x8162,0x03}, -{0x8163,0x78}, -{0x8164,0xbf}, -{0x8165,0xf6}, -{0x8166,0x78}, -{0x8167,0xb9}, -{0x8168,0xe6}, -{0x8169,0x24}, -{0x816a,0xfd}, -{0x816b,0x78}, -{0x816c,0xc0}, -{0x816d,0xf6}, -{0x816e,0x12}, -{0x816f,0x0f}, -{0x8170,0x02}, -{0x8171,0x40}, -{0x8172,0x06}, -{0x8173,0x78}, -{0x8174,0xc0}, -{0x8175,0xe6}, -{0x8176,0xff}, -{0x8177,0x80}, -{0x8178,0x04}, -{0x8179,0x78}, -{0x817a,0xbf}, -{0x817b,0xe6}, -{0x817c,0xff}, -{0x817d,0x78}, -{0x817e,0xbe}, -{0x817f,0xa6}, -{0x8180,0x07}, -{0x8181,0x75}, -{0x8182,0x1f}, -{0x8183,0x02}, -{0x8184,0x78}, -{0x8185,0xb8}, -{0x8186,0x76}, -{0x8187,0x01}, -{0x8188,0x02}, -{0x8189,0x02}, -{0x818a,0x4a}, -{0x818b,0xe5}, -{0x818c,0x1f}, -{0x818d,0x64}, -{0x818e,0x02}, -{0x818f,0x60}, -{0x8190,0x03}, -{0x8191,0x02}, -{0x8192,0x02}, -{0x8193,0x2a}, -{0x8194,0x78}, -{0x8195,0xbe}, -{0x8196,0xe6}, -{0x8197,0xff}, -{0x8198,0xc3}, -{0x8199,0x78}, -{0x819a,0xc0}, -{0x819b,0x12}, -{0x819c,0x0e}, -{0x819d,0xe0}, -{0x819e,0x40}, -{0x819f,0x08}, -{0x81a0,0x12}, -{0x81a1,0x0e}, -{0x81a2,0xda}, -{0x81a3,0x50}, -{0x81a4,0x03}, -{0x81a5,0x02}, -{0x81a6,0x02}, -{0x81a7,0x28}, -{0x81a8,0x12}, -{0x81a9,0x0f}, -{0x81aa,0x02}, -{0x81ab,0x40}, -{0x81ac,0x04}, -{0x81ad,0x7f}, -{0x81ae,0xff}, -{0x81af,0x80}, -{0x81b0,0x02}, -{0x81b1,0x7f}, -{0x81b2,0x01}, -{0x81b3,0x78}, -{0x81b4,0xbd}, -{0x81b5,0xa6}, -{0x81b6,0x07}, -{0x81b7,0x78}, -{0x81b8,0xb9}, -{0x81b9,0xe6}, -{0x81ba,0x04}, -{0x81bb,0x78}, -{0x81bc,0xbf}, -{0x81bd,0xf6}, -{0x81be,0x78}, -{0x81bf,0xb9}, -{0x81c0,0xe6}, -{0x81c1,0x14}, -{0x81c2,0x78}, -{0x81c3,0xc0}, -{0x81c4,0xf6}, -{0x81c5,0x18}, -{0x81c6,0x12}, -{0x81c7,0x0f}, -{0x81c8,0x04}, -{0x81c9,0x40}, -{0x81ca,0x04}, -{0x81cb,0xe6}, -{0x81cc,0xff}, -{0x81cd,0x80}, -{0x81ce,0x02}, -{0x81cf,0x7f}, -{0x81d0,0x00}, -{0x81d1,0x78}, -{0x81d2,0xbf}, -{0x81d3,0xa6}, -{0x81d4,0x07}, -{0x81d5,0xd3}, -{0x81d6,0x08}, -{0x81d7,0xe6}, -{0x81d8,0x64}, -{0x81d9,0x80}, -{0x81da,0x94}, -{0x81db,0x80}, -{0x81dc,0x40}, -{0x81dd,0x04}, -{0x81de,0xe6}, -{0x81df,0xff}, -{0x81e0,0x80}, -{0x81e1,0x02}, -{0x81e2,0x7f}, -{0x81e3,0x00}, -{0x81e4,0x78}, -{0x81e5,0xc0}, -{0x81e6,0xa6}, -{0x81e7,0x07}, -{0x81e8,0xc3}, -{0x81e9,0x18}, -{0x81ea,0xe6}, -{0x81eb,0x64}, -{0x81ec,0x80}, -{0x81ed,0x94}, -{0x81ee,0xb3}, -{0x81ef,0x50}, -{0x81f0,0x04}, -{0x81f1,0xe6}, -{0x81f2,0xff}, -{0x81f3,0x80}, -{0x81f4,0x02}, -{0x81f5,0x7f}, -{0x81f6,0x33}, -{0x81f7,0x78}, -{0x81f8,0xbf}, -{0x81f9,0xa6}, -{0x81fa,0x07}, -{0x81fb,0xc3}, -{0x81fc,0x08}, -{0x81fd,0xe6}, -{0x81fe,0x64}, -{0x81ff,0x80}, -{0x8200,0x94}, -{0x8201,0xb3}, -{0x8202,0x50}, -{0x8203,0x04}, -{0x8204,0xe6}, -{0x8205,0xff}, -{0x8206,0x80}, -{0x8207,0x02}, -{0x8208,0x7f}, -{0x8209,0x33}, -{0x820a,0x78}, -{0x820b,0xc0}, -{0x820c,0xa6}, -{0x820d,0x07}, -{0x820e,0x12}, -{0x820f,0x0f}, -{0x8210,0x02}, -{0x8211,0x40}, -{0x8212,0x06}, -{0x8213,0x78}, -{0x8214,0xc0}, -{0x8215,0xe6}, -{0x8216,0xff}, -{0x8217,0x80}, -{0x8218,0x04}, -{0x8219,0x78}, -{0x821a,0xbf}, -{0x821b,0xe6}, -{0x821c,0xff}, -{0x821d,0x78}, -{0x821e,0xbe}, -{0x821f,0xa6}, -{0x8220,0x07}, -{0x8221,0x75}, -{0x8222,0x1f}, -{0x8223,0x03}, -{0x8224,0x78}, -{0x8225,0xb8}, -{0x8226,0x76}, -{0x8227,0x01}, -{0x8228,0x80}, -{0x8229,0x20}, -{0x822a,0xe5}, -{0x822b,0x1f}, -{0x822c,0x64}, -{0x822d,0x03}, -{0x822e,0x70}, -{0x822f,0x26}, -{0x8230,0x78}, -{0x8231,0xbe}, -{0x8232,0xe6}, -{0x8233,0xff}, -{0x8234,0xc3}, -{0x8235,0x78}, -{0x8236,0xc0}, -{0x8237,0x12}, -{0x8238,0x0e}, -{0x8239,0xe0}, -{0x823a,0x40}, -{0x823b,0x05}, -{0x823c,0x12}, -{0x823d,0x0e}, -{0x823e,0xda}, -{0x823f,0x40}, -{0x8240,0x09}, -{0x8241,0x78}, -{0x8242,0xb9}, -{0x8243,0xe6}, -{0x8244,0x78}, -{0x8245,0xbe}, -{0x8246,0xf6}, -{0x8247,0x75}, -{0x8248,0x1f}, -{0x8249,0x04}, -{0x824a,0x78}, -{0x824b,0xbe}, -{0x824c,0xe6}, -{0x824d,0x75}, -{0x824e,0xf0}, -{0x824f,0x05}, -{0x8250,0xa4}, -{0x8251,0xf5}, -{0x8252,0x4b}, -{0x8253,0x02}, -{0x8254,0x0a}, -{0x8255,0xff}, -{0x8256,0xe5}, -{0x8257,0x1f}, -{0x8258,0xb4}, -{0x8259,0x04}, -{0x825a,0x10}, -{0x825b,0x90}, -{0x825c,0x0e}, -{0x825d,0x94}, -{0x825e,0xe4}, -{0x825f,0x78}, -{0x8260,0xc3}, -{0x8261,0x12}, -{0x8262,0x0e}, -{0x8263,0xe9}, -{0x8264,0x40}, -{0x8265,0x02}, -{0x8266,0xd2}, -{0x8267,0x37}, -{0x8268,0x75}, -{0x8269,0x1f}, -{0x826a,0x05}, -{0x826b,0x22}, -{0x826c,0x30}, -{0x826d,0x01}, -{0x826e,0x03}, -{0x826f,0x02}, -{0x8270,0x04}, -{0x8271,0xc0}, -{0x8272,0x30}, -{0x8273,0x02}, -{0x8274,0x03}, -{0x8275,0x02}, -{0x8276,0x04}, -{0x8277,0xc0}, -{0x8278,0x90}, -{0x8279,0x51}, -{0x827a,0xa5}, -{0x827b,0xe0}, -{0x827c,0x78}, -{0x827d,0x93}, -{0x827e,0xf6}, -{0x827f,0xa3}, -{0x8280,0xe0}, -{0x8281,0x08}, -{0x8282,0xf6}, -{0x8283,0xa3}, -{0x8284,0xe0}, -{0x8285,0x08}, -{0x8286,0xf6}, -{0x8287,0xe5}, -{0x8288,0x1f}, -{0x8289,0x70}, -{0x828a,0x3c}, -{0x828b,0x75}, -{0x828c,0x1e}, -{0x828d,0x20}, -{0x828e,0xd2}, -{0x828f,0x35}, -{0x8290,0x12}, -{0x8291,0x0c}, -{0x8292,0x7a}, -{0x8293,0x78}, -{0x8294,0x7e}, -{0x8295,0xa6}, -{0x8296,0x06}, -{0x8297,0x08}, -{0x8298,0xa6}, -{0x8299,0x07}, -{0x829a,0x78}, -{0x829b,0x8b}, -{0x829c,0xa6}, -{0x829d,0x09}, -{0x829e,0x18}, -{0x829f,0x76}, -{0x82a0,0x01}, -{0x82a1,0x12}, -{0x82a2,0x0c}, -{0x82a3,0x5b}, -{0x82a4,0x78}, -{0x82a5,0x4e}, -{0x82a6,0xa6}, -{0x82a7,0x06}, -{0x82a8,0x08}, -{0x82a9,0xa6}, -{0x82aa,0x07}, -{0x82ab,0x78}, -{0x82ac,0x8b}, -{0x82ad,0xe6}, -{0x82ae,0x78}, -{0x82af,0x6e}, -{0x82b0,0xf6}, -{0x82b1,0x75}, -{0x82b2,0x1f}, -{0x82b3,0x01}, -{0x82b4,0x78}, -{0x82b5,0x93}, -{0x82b6,0xe6}, -{0x82b7,0x78}, -{0x82b8,0x90}, -{0x82b9,0xf6}, -{0x82ba,0x78}, -{0x82bb,0x94}, -{0x82bc,0xe6}, -{0x82bd,0x78}, -{0x82be,0x91}, -{0x82bf,0xf6}, -{0x82c0,0x78}, -{0x82c1,0x95}, -{0x82c2,0xe6}, -{0x82c3,0x78}, -{0x82c4,0x92}, -{0x82c5,0xf6}, -{0x82c6,0x22}, -{0x82c7,0x79}, -{0x82c8,0x90}, -{0x82c9,0xe7}, -{0x82ca,0xd3}, -{0x82cb,0x78}, -{0x82cc,0x93}, -{0x82cd,0x96}, -{0x82ce,0x40}, -{0x82cf,0x05}, -{0x82d0,0xe7}, -{0x82d1,0x96}, -{0x82d2,0xff}, -{0x82d3,0x80}, -{0x82d4,0x08}, -{0x82d5,0xc3}, -{0x82d6,0x79}, -{0x82d7,0x93}, -{0x82d8,0xe7}, -{0x82d9,0x78}, -{0x82da,0x90}, -{0x82db,0x96}, -{0x82dc,0xff}, -{0x82dd,0x78}, -{0x82de,0x88}, -{0x82df,0x76}, -{0x82e0,0x00}, -{0x82e1,0x08}, -{0x82e2,0xa6}, -{0x82e3,0x07}, -{0x82e4,0x79}, -{0x82e5,0x91}, -{0x82e6,0xe7}, -{0x82e7,0xd3}, -{0x82e8,0x78}, -{0x82e9,0x94}, -{0x82ea,0x96}, -{0x82eb,0x40}, -{0x82ec,0x05}, -{0x82ed,0xe7}, -{0x82ee,0x96}, -{0x82ef,0xff}, -{0x82f0,0x80}, -{0x82f1,0x08}, -{0x82f2,0xc3}, -{0x82f3,0x79}, -{0x82f4,0x94}, -{0x82f5,0xe7}, -{0x82f6,0x78}, -{0x82f7,0x91}, -{0x82f8,0x96}, -{0x82f9,0xff}, -{0x82fa,0x12}, -{0x82fb,0x0c}, -{0x82fc,0x8e}, -{0x82fd,0x79}, -{0x82fe,0x92}, -{0x82ff,0xe7}, -{0x8300,0xd3}, -{0x8301,0x78}, -{0x8302,0x95}, -{0x8303,0x96}, -{0x8304,0x40}, -{0x8305,0x05}, -{0x8306,0xe7}, -{0x8307,0x96}, -{0x8308,0xff}, -{0x8309,0x80}, -{0x830a,0x08}, -{0x830b,0xc3}, -{0x830c,0x79}, -{0x830d,0x95}, -{0x830e,0xe7}, -{0x830f,0x78}, -{0x8310,0x92}, -{0x8311,0x96}, -{0x8312,0xff}, -{0x8313,0x12}, -{0x8314,0x0c}, -{0x8315,0x8e}, -{0x8316,0x12}, -{0x8317,0x0c}, -{0x8318,0x5b}, -{0x8319,0x78}, -{0x831a,0x8a}, -{0x831b,0xe6}, -{0x831c,0x25}, -{0x831d,0xe0}, -{0x831e,0x24}, -{0x831f,0x4e}, -{0x8320,0xf8}, -{0x8321,0xa6}, -{0x8322,0x06}, -{0x8323,0x08}, -{0x8324,0xa6}, -{0x8325,0x07}, -{0x8326,0x78}, -{0x8327,0x8a}, -{0x8328,0xe6}, -{0x8329,0x24}, -{0x832a,0x6e}, -{0x832b,0xf8}, -{0x832c,0xa6}, -{0x832d,0x09}, -{0x832e,0x78}, -{0x832f,0x8a}, -{0x8330,0xe6}, -{0x8331,0x24}, -{0x8332,0x01}, -{0x8333,0xff}, -{0x8334,0xe4}, -{0x8335,0x33}, -{0x8336,0xfe}, -{0x8337,0xd3}, -{0x8338,0xef}, -{0x8339,0x94}, -{0x833a,0x0f}, -{0x833b,0xee}, -{0x833c,0x64}, -{0x833d,0x80}, -{0x833e,0x94}, -{0x833f,0x80}, -{0x8340,0x40}, -{0x8341,0x04}, -{0x8342,0x7f}, -{0x8343,0x00}, -{0x8344,0x80}, -{0x8345,0x05}, -{0x8346,0x78}, -{0x8347,0x8a}, -{0x8348,0xe6}, -{0x8349,0x04}, -{0x834a,0xff}, -{0x834b,0x78}, -{0x834c,0x8a}, -{0x834d,0xa6}, -{0x834e,0x07}, -{0x834f,0xe5}, -{0x8350,0x1f}, -{0x8351,0xb4}, -{0x8352,0x01}, -{0x8353,0x0a}, -{0x8354,0xe6}, -{0x8355,0x60}, -{0x8356,0x03}, -{0x8357,0x02}, -{0x8358,0x04}, -{0x8359,0xc0}, -{0x835a,0x75}, -{0x835b,0x1f}, -{0x835c,0x02}, -{0x835d,0x22}, -{0x835e,0x12}, -{0x835f,0x0c}, -{0x8360,0x7a}, -{0x8361,0x78}, -{0x8362,0x80}, -{0x8363,0xa6}, -{0x8364,0x06}, -{0x8365,0x08}, -{0x8366,0xa6}, -{0x8367,0x07}, -{0x8368,0x12}, -{0x8369,0x0c}, -{0x836a,0x7a}, -{0x836b,0x78}, -{0x836c,0x82}, -{0x836d,0xa6}, -{0x836e,0x06}, -{0x836f,0x08}, -{0x8370,0xa6}, -{0x8371,0x07}, -{0x8372,0x78}, -{0x8373,0x6e}, -{0x8374,0xe6}, -{0x8375,0x78}, -{0x8376,0x8c}, -{0x8377,0xf6}, -{0x8378,0x78}, -{0x8379,0x6e}, -{0x837a,0xe6}, -{0x837b,0x78}, -{0x837c,0x8d}, -{0x837d,0xf6}, -{0x837e,0x7f}, -{0x837f,0x01}, -{0x8380,0xef}, -{0x8381,0x25}, -{0x8382,0xe0}, -{0x8383,0x24}, -{0x8384,0x4f}, -{0x8385,0xf9}, -{0x8386,0xc3}, -{0x8387,0x78}, -{0x8388,0x81}, -{0x8389,0xe6}, -{0x838a,0x97}, -{0x838b,0x18}, -{0x838c,0xe6}, -{0x838d,0x19}, -{0x838e,0x97}, -{0x838f,0x50}, -{0x8390,0x0a}, -{0x8391,0x12}, -{0x8392,0x0c}, -{0x8393,0x82}, -{0x8394,0x78}, -{0x8395,0x80}, -{0x8396,0xa6}, -{0x8397,0x04}, -{0x8398,0x08}, -{0x8399,0xa6}, -{0x839a,0x05}, -{0x839b,0x74}, -{0x839c,0x6e}, -{0x839d,0x2f}, -{0x839e,0xf9}, -{0x839f,0x78}, -{0x83a0,0x8c}, -{0x83a1,0xe6}, -{0x83a2,0xc3}, -{0x83a3,0x97}, -{0x83a4,0x50}, -{0x83a5,0x08}, -{0x83a6,0x74}, -{0x83a7,0x6e}, -{0x83a8,0x2f}, -{0x83a9,0xf8}, -{0x83aa,0xe6}, -{0x83ab,0x78}, -{0x83ac,0x8c}, -{0x83ad,0xf6}, -{0x83ae,0xef}, -{0x83af,0x25}, -{0x83b0,0xe0}, -{0x83b1,0x24}, -{0x83b2,0x4f}, -{0x83b3,0xf9}, -{0x83b4,0xd3}, -{0x83b5,0x78}, -{0x83b6,0x83}, -{0x83b7,0xe6}, -{0x83b8,0x97}, -{0x83b9,0x18}, -{0x83ba,0xe6}, -{0x83bb,0x19}, -{0x83bc,0x97}, -{0x83bd,0x40}, -{0x83be,0x0a}, -{0x83bf,0x12}, -{0x83c0,0x0c}, -{0x83c1,0x82}, -{0x83c2,0x78}, -{0x83c3,0x82}, -{0x83c4,0xa6}, -{0x83c5,0x04}, -{0x83c6,0x08}, -{0x83c7,0xa6}, -{0x83c8,0x05}, -{0x83c9,0x74}, -{0x83ca,0x6e}, -{0x83cb,0x2f}, -{0x83cc,0xf9}, -{0x83cd,0x78}, -{0x83ce,0x8d}, -{0x83cf,0xe6}, -{0x83d0,0xd3}, -{0x83d1,0x97}, -{0x83d2,0x40}, -{0x83d3,0x08}, -{0x83d4,0x74}, -{0x83d5,0x6e}, -{0x83d6,0x2f}, -{0x83d7,0xf8}, -{0x83d8,0xe6}, -{0x83d9,0x78}, -{0x83da,0x8d}, -{0x83db,0xf6}, -{0x83dc,0x0f}, -{0x83dd,0xef}, -{0x83de,0x64}, -{0x83df,0x10}, -{0x83e0,0x70}, -{0x83e1,0x9e}, -{0x83e2,0xc3}, -{0x83e3,0x79}, -{0x83e4,0x81}, -{0x83e5,0xe7}, -{0x83e6,0x78}, -{0x83e7,0x83}, -{0x83e8,0x96}, -{0x83e9,0xff}, -{0x83ea,0x19}, -{0x83eb,0xe7}, -{0x83ec,0x18}, -{0x83ed,0x96}, -{0x83ee,0x78}, -{0x83ef,0x84}, -{0x83f0,0xf6}, -{0x83f1,0x08}, -{0x83f2,0xa6}, -{0x83f3,0x07}, -{0x83f4,0xc3}, -{0x83f5,0x79}, -{0x83f6,0x8c}, -{0x83f7,0xe7}, -{0x83f8,0x78}, -{0x83f9,0x8d}, -{0x83fa,0x96}, -{0x83fb,0x08}, -{0x83fc,0xf6}, -{0x83fd,0xd3}, -{0x83fe,0x79}, -{0x83ff,0x81}, -{0x8400,0xe7}, -{0x8401,0x78}, -{0x8402,0x7f}, -{0x8403,0x96}, -{0x8404,0x19}, -{0x8405,0xe7}, -{0x8406,0x18}, -{0x8407,0x96}, -{0x8408,0x40}, -{0x8409,0x05}, -{0x840a,0x09}, -{0x840b,0xe7}, -{0x840c,0x08}, -{0x840d,0x80}, -{0x840e,0x06}, -{0x840f,0xc3}, -{0x8410,0x79}, -{0x8411,0x7f}, -{0x8412,0xe7}, -{0x8413,0x78}, -{0x8414,0x81}, -{0x8415,0x96}, -{0x8416,0xff}, -{0x8417,0x19}, -{0x8418,0xe7}, -{0x8419,0x18}, -{0x841a,0x96}, -{0x841b,0xfe}, -{0x841c,0x78}, -{0x841d,0x86}, -{0x841e,0xa6}, -{0x841f,0x06}, -{0x8420,0x08}, -{0x8421,0xa6}, -{0x8422,0x07}, -{0x8423,0x79}, -{0x8424,0x8c}, -{0x8425,0xe7}, -{0x8426,0xd3}, -{0x8427,0x78}, -{0x8428,0x8b}, -{0x8429,0x96}, -{0x842a,0x40}, -{0x842b,0x05}, -{0x842c,0xe7}, -{0x842d,0x96}, -{0x842e,0xff}, -{0x842f,0x80}, -{0x8430,0x08}, -{0x8431,0xc3}, -{0x8432,0x79}, -{0x8433,0x8b}, -{0x8434,0xe7}, -{0x8435,0x78}, -{0x8436,0x8c}, -{0x8437,0x96}, -{0x8438,0xff}, -{0x8439,0x78}, -{0x843a,0x8f}, -{0x843b,0xa6}, -{0x843c,0x07}, -{0x843d,0xe5}, -{0x843e,0x1f}, -{0x843f,0x64}, -{0x8440,0x02}, -{0x8441,0x70}, -{0x8442,0x69}, -{0x8443,0x90}, -{0x8444,0x0e}, -{0x8445,0x91}, -{0x8446,0x93}, -{0x8447,0xff}, -{0x8448,0x18}, -{0x8449,0xe6}, -{0x844a,0xc3}, -{0x844b,0x9f}, -{0x844c,0x50}, -{0x844d,0x72}, -{0x844e,0x12}, -{0x844f,0x0c}, -{0x8450,0x4a}, -{0x8451,0x12}, -{0x8452,0x0c}, -{0x8453,0x2f}, -{0x8454,0x90}, -{0x8455,0x0e}, -{0x8456,0x8e}, -{0x8457,0x12}, -{0x8458,0x0c}, -{0x8459,0x38}, -{0x845a,0x78}, -{0x845b,0x80}, -{0x845c,0x12}, -{0x845d,0x0c}, -{0x845e,0x6b}, -{0x845f,0x7b}, -{0x8460,0x04}, -{0x8461,0x12}, -{0x8462,0x0c}, -{0x8463,0x1d}, -{0x8464,0xc3}, -{0x8465,0x12}, -{0x8466,0x06}, -{0x8467,0x45}, -{0x8468,0x50}, -{0x8469,0x56}, -{0x846a,0x90}, -{0x846b,0x0e}, -{0x846c,0x92}, -{0x846d,0xe4}, -{0x846e,0x93}, -{0x846f,0xff}, -{0x8470,0x78}, -{0x8471,0x8f}, -{0x8472,0xe6}, -{0x8473,0x9f}, -{0x8474,0x40}, -{0x8475,0x02}, -{0x8476,0x80}, -{0x8477,0x11}, -{0x8478,0x90}, -{0x8479,0x0e}, -{0x847a,0x90}, -{0x847b,0xe4}, -{0x847c,0x93}, -{0x847d,0xff}, -{0x847e,0xd3}, -{0x847f,0x78}, -{0x8480,0x89}, -{0x8481,0xe6}, -{0x8482,0x9f}, -{0x8483,0x18}, -{0x8484,0xe6}, -{0x8485,0x94}, -{0x8486,0x00}, -{0x8487,0x40}, -{0x8488,0x03}, -{0x8489,0x75}, -{0x848a,0x1f}, -{0x848b,0x05}, -{0x848c,0x12}, -{0x848d,0x0c}, -{0x848e,0x4a}, -{0x848f,0x12}, -{0x8490,0x0c}, -{0x8491,0x2f}, -{0x8492,0x90}, -{0x8493,0x0e}, -{0x8494,0x8f}, -{0x8495,0x12}, -{0x8496,0x0c}, -{0x8497,0x38}, -{0x8498,0x78}, -{0x8499,0x7e}, -{0x849a,0x12}, -{0x849b,0x0c}, -{0x849c,0x6b}, -{0x849d,0x7b}, -{0x849e,0x40}, -{0x849f,0x12}, -{0x84a0,0x0c}, -{0x84a1,0x1d}, -{0x84a2,0xd3}, -{0x84a3,0x12}, -{0x84a4,0x06}, -{0x84a5,0x45}, -{0x84a6,0x40}, -{0x84a7,0x18}, -{0x84a8,0x75}, -{0x84a9,0x1f}, -{0x84aa,0x05}, -{0x84ab,0x22}, -{0x84ac,0xe5}, -{0x84ad,0x1f}, -{0x84ae,0xb4}, -{0x84af,0x05}, -{0x84b0,0x0f}, -{0x84b1,0xd2}, -{0x84b2,0x01}, -{0x84b3,0xc2}, -{0x84b4,0x02}, -{0x84b5,0xe4}, -{0x84b6,0xf5}, -{0x84b7,0x1f}, -{0x84b8,0xf5}, -{0x84b9,0x1e}, -{0x84ba,0xd2}, -{0x84bb,0x35}, -{0x84bc,0xd2}, -{0x84bd,0x33}, -{0x84be,0xd2}, -{0x84bf,0x36}, -{0x84c0,0x22}, -{0x84c1,0xef}, -{0x84c2,0x8d}, -{0x84c3,0xf0}, -{0x84c4,0xa4}, -{0x84c5,0xa8}, -{0x84c6,0xf0}, -{0x84c7,0xcf}, -{0x84c8,0x8c}, -{0x84c9,0xf0}, -{0x84ca,0xa4}, -{0x84cb,0x28}, -{0x84cc,0xce}, -{0x84cd,0x8d}, -{0x84ce,0xf0}, -{0x84cf,0xa4}, -{0x84d0,0x2e}, -{0x84d1,0xfe}, -{0x84d2,0x22}, -{0x84d3,0xbc}, -{0x84d4,0x00}, -{0x84d5,0x0b}, -{0x84d6,0xbe}, -{0x84d7,0x00}, -{0x84d8,0x29}, -{0x84d9,0xef}, -{0x84da,0x8d}, -{0x84db,0xf0}, -{0x84dc,0x84}, -{0x84dd,0xff}, -{0x84de,0xad}, -{0x84df,0xf0}, -{0x84e0,0x22}, -{0x84e1,0xe4}, -{0x84e2,0xcc}, -{0x84e3,0xf8}, -{0x84e4,0x75}, -{0x84e5,0xf0}, -{0x84e6,0x08}, -{0x84e7,0xef}, -{0x84e8,0x2f}, -{0x84e9,0xff}, -{0x84ea,0xee}, -{0x84eb,0x33}, -{0x84ec,0xfe}, -{0x84ed,0xec}, -{0x84ee,0x33}, -{0x84ef,0xfc}, -{0x84f0,0xee}, -{0x84f1,0x9d}, -{0x84f2,0xec}, -{0x84f3,0x98}, -{0x84f4,0x40}, -{0x84f5,0x05}, -{0x84f6,0xfc}, -{0x84f7,0xee}, -{0x84f8,0x9d}, -{0x84f9,0xfe}, -{0x84fa,0x0f}, -{0x84fb,0xd5}, -{0x84fc,0xf0}, -{0x84fd,0xe9}, -{0x84fe,0xe4}, -{0x84ff,0xce}, -{0x8500,0xfd}, -{0x8501,0x22}, -{0x8502,0xed}, -{0x8503,0xf8}, -{0x8504,0xf5}, -{0x8505,0xf0}, -{0x8506,0xee}, -{0x8507,0x84}, -{0x8508,0x20}, -{0x8509,0xd2}, -{0x850a,0x1c}, -{0x850b,0xfe}, -{0x850c,0xad}, -{0x850d,0xf0}, -{0x850e,0x75}, -{0x850f,0xf0}, -{0x8510,0x08}, -{0x8511,0xef}, -{0x8512,0x2f}, -{0x8513,0xff}, -{0x8514,0xed}, -{0x8515,0x33}, -{0x8516,0xfd}, -{0x8517,0x40}, -{0x8518,0x07}, -{0x8519,0x98}, -{0x851a,0x50}, -{0x851b,0x06}, -{0x851c,0xd5}, -{0x851d,0xf0}, -{0x851e,0xf2}, -{0x851f,0x22}, -{0x8520,0xc3}, -{0x8521,0x98}, -{0x8522,0xfd}, -{0x8523,0x0f}, -{0x8524,0xd5}, -{0x8525,0xf0}, -{0x8526,0xea}, -{0x8527,0x22}, -{0x8528,0xe8}, -{0x8529,0x8f}, -{0x852a,0xf0}, -{0x852b,0xa4}, -{0x852c,0xcc}, -{0x852d,0x8b}, -{0x852e,0xf0}, -{0x852f,0xa4}, -{0x8530,0x2c}, -{0x8531,0xfc}, -{0x8532,0xe9}, -{0x8533,0x8e}, -{0x8534,0xf0}, -{0x8535,0xa4}, -{0x8536,0x2c}, -{0x8537,0xfc}, -{0x8538,0x8a}, -{0x8539,0xf0}, -{0x853a,0xed}, -{0x853b,0xa4}, -{0x853c,0x2c}, -{0x853d,0xfc}, -{0x853e,0xea}, -{0x853f,0x8e}, -{0x8540,0xf0}, -{0x8541,0xa4}, -{0x8542,0xcd}, -{0x8543,0xa8}, -{0x8544,0xf0}, -{0x8545,0x8b}, -{0x8546,0xf0}, -{0x8547,0xa4}, -{0x8548,0x2d}, -{0x8549,0xcc}, -{0x854a,0x38}, -{0x854b,0x25}, -{0x854c,0xf0}, -{0x854d,0xfd}, -{0x854e,0xe9}, -{0x854f,0x8f}, -{0x8550,0xf0}, -{0x8551,0xa4}, -{0x8552,0x2c}, -{0x8553,0xcd}, -{0x8554,0x35}, -{0x8555,0xf0}, -{0x8556,0xfc}, -{0x8557,0xeb}, -{0x8558,0x8e}, -{0x8559,0xf0}, -{0x855a,0xa4}, -{0x855b,0xfe}, -{0x855c,0xa9}, -{0x855d,0xf0}, -{0x855e,0xeb}, -{0x855f,0x8f}, -{0x8560,0xf0}, -{0x8561,0xa4}, -{0x8562,0xcf}, -{0x8563,0xc5}, -{0x8564,0xf0}, -{0x8565,0x2e}, -{0x8566,0xcd}, -{0x8567,0x39}, -{0x8568,0xfe}, -{0x8569,0xe4}, -{0x856a,0x3c}, -{0x856b,0xfc}, -{0x856c,0xea}, -{0x856d,0xa4}, -{0x856e,0x2d}, -{0x856f,0xce}, -{0x8570,0x35}, -{0x8571,0xf0}, -{0x8572,0xfd}, -{0x8573,0xe4}, -{0x8574,0x3c}, -{0x8575,0xfc}, -{0x8576,0x22}, -{0x8577,0x75}, -{0x8578,0xf0}, -{0x8579,0x08}, -{0x857a,0x75}, -{0x857b,0x82}, -{0x857c,0x00}, -{0x857d,0xef}, -{0x857e,0x2f}, -{0x857f,0xff}, -{0x8580,0xee}, -{0x8581,0x33}, -{0x8582,0xfe}, -{0x8583,0xcd}, -{0x8584,0x33}, -{0x8585,0xcd}, -{0x8586,0xcc}, -{0x8587,0x33}, -{0x8588,0xcc}, -{0x8589,0xc5}, -{0x858a,0x82}, -{0x858b,0x33}, -{0x858c,0xc5}, -{0x858d,0x82}, -{0x858e,0x9b}, -{0x858f,0xed}, -{0x8590,0x9a}, -{0x8591,0xec}, -{0x8592,0x99}, -{0x8593,0xe5}, -{0x8594,0x82}, -{0x8595,0x98}, -{0x8596,0x40}, -{0x8597,0x0c}, -{0x8598,0xf5}, -{0x8599,0x82}, -{0x859a,0xee}, -{0x859b,0x9b}, -{0x859c,0xfe}, -{0x859d,0xed}, -{0x859e,0x9a}, -{0x859f,0xfd}, -{0x85a0,0xec}, -{0x85a1,0x99}, -{0x85a2,0xfc}, -{0x85a3,0x0f}, -{0x85a4,0xd5}, -{0x85a5,0xf0}, -{0x85a6,0xd6}, -{0x85a7,0xe4}, -{0x85a8,0xce}, -{0x85a9,0xfb}, -{0x85aa,0xe4}, -{0x85ab,0xcd}, -{0x85ac,0xfa}, -{0x85ad,0xe4}, -{0x85ae,0xcc}, -{0x85af,0xf9}, -{0x85b0,0xa8}, -{0x85b1,0x82}, -{0x85b2,0x22}, -{0x85b3,0xb8}, -{0x85b4,0x00}, -{0x85b5,0xc1}, -{0x85b6,0xb9}, -{0x85b7,0x00}, -{0x85b8,0x59}, -{0x85b9,0xba}, -{0x85ba,0x00}, -{0x85bb,0x2d}, -{0x85bc,0xec}, -{0x85bd,0x8b}, -{0x85be,0xf0}, -{0x85bf,0x84}, -{0x85c0,0xcf}, -{0x85c1,0xce}, -{0x85c2,0xcd}, -{0x85c3,0xfc}, -{0x85c4,0xe5}, -{0x85c5,0xf0}, -{0x85c6,0xcb}, -{0x85c7,0xf9}, -{0x85c8,0x78}, -{0x85c9,0x18}, -{0x85ca,0xef}, -{0x85cb,0x2f}, -{0x85cc,0xff}, -{0x85cd,0xee}, -{0x85ce,0x33}, -{0x85cf,0xfe}, -{0x85d0,0xed}, -{0x85d1,0x33}, -{0x85d2,0xfd}, -{0x85d3,0xec}, -{0x85d4,0x33}, -{0x85d5,0xfc}, -{0x85d6,0xeb}, -{0x85d7,0x33}, -{0x85d8,0xfb}, -{0x85d9,0x10}, -{0x85da,0xd7}, -{0x85db,0x03}, -{0x85dc,0x99}, -{0x85dd,0x40}, -{0x85de,0x04}, -{0x85df,0xeb}, -{0x85e0,0x99}, -{0x85e1,0xfb}, -{0x85e2,0x0f}, -{0x85e3,0xd8}, -{0x85e4,0xe5}, -{0x85e5,0xe4}, -{0x85e6,0xf9}, -{0x85e7,0xfa}, -{0x85e8,0x22}, -{0x85e9,0x78}, -{0x85ea,0x18}, -{0x85eb,0xef}, -{0x85ec,0x2f}, -{0x85ed,0xff}, -{0x85ee,0xee}, -{0x85ef,0x33}, -{0x85f0,0xfe}, -{0x85f1,0xed}, -{0x85f2,0x33}, -{0x85f3,0xfd}, -{0x85f4,0xec}, -{0x85f5,0x33}, -{0x85f6,0xfc}, -{0x85f7,0xc9}, -{0x85f8,0x33}, -{0x85f9,0xc9}, -{0x85fa,0x10}, -{0x85fb,0xd7}, -{0x85fc,0x05}, -{0x85fd,0x9b}, -{0x85fe,0xe9}, -{0x85ff,0x9a}, -{0x8600,0x40}, -{0x8601,0x07}, -{0x8602,0xec}, -{0x8603,0x9b}, -{0x8604,0xfc}, -{0x8605,0xe9}, -{0x8606,0x9a}, -{0x8607,0xf9}, -{0x8608,0x0f}, -{0x8609,0xd8}, -{0x860a,0xe0}, -{0x860b,0xe4}, -{0x860c,0xc9}, -{0x860d,0xfa}, -{0x860e,0xe4}, -{0x860f,0xcc}, -{0x8610,0xfb}, -{0x8611,0x22}, -{0x8612,0x75}, -{0x8613,0xf0}, -{0x8614,0x10}, -{0x8615,0xef}, -{0x8616,0x2f}, -{0x8617,0xff}, -{0x8618,0xee}, -{0x8619,0x33}, -{0x861a,0xfe}, -{0x861b,0xed}, -{0x861c,0x33}, -{0x861d,0xfd}, -{0x861e,0xcc}, -{0x861f,0x33}, -{0x8620,0xcc}, -{0x8621,0xc8}, -{0x8622,0x33}, -{0x8623,0xc8}, -{0x8624,0x10}, -{0x8625,0xd7}, -{0x8626,0x07}, -{0x8627,0x9b}, -{0x8628,0xec}, -{0x8629,0x9a}, -{0x862a,0xe8}, -{0x862b,0x99}, -{0x862c,0x40}, -{0x862d,0x0a}, -{0x862e,0xed}, -{0x862f,0x9b}, -{0x8630,0xfd}, -{0x8631,0xec}, -{0x8632,0x9a}, -{0x8633,0xfc}, -{0x8634,0xe8}, -{0x8635,0x99}, -{0x8636,0xf8}, -{0x8637,0x0f}, -{0x8638,0xd5}, -{0x8639,0xf0}, -{0x863a,0xda}, -{0x863b,0xe4}, -{0x863c,0xcd}, -{0x863d,0xfb}, -{0x863e,0xe4}, -{0x863f,0xcc}, -{0x8640,0xfa}, -{0x8641,0xe4}, -{0x8642,0xc8}, -{0x8643,0xf9}, -{0x8644,0x22}, -{0x8645,0xeb}, -{0x8646,0x9f}, -{0x8647,0xf5}, -{0x8648,0xf0}, -{0x8649,0xea}, -{0x864a,0x9e}, -{0x864b,0x42}, -{0x864c,0xf0}, -{0x864d,0xe9}, -{0x864e,0x9d}, -{0x864f,0x42}, -{0x8650,0xf0}, -{0x8651,0xe8}, -{0x8652,0x9c}, -{0x8653,0x45}, -{0x8654,0xf0}, -{0x8655,0x22}, -{0x8656,0xe8}, -{0x8657,0x60}, -{0x8658,0x0f}, -{0x8659,0xec}, -{0x865a,0xc3}, -{0x865b,0x13}, -{0x865c,0xfc}, -{0x865d,0xed}, -{0x865e,0x13}, -{0x865f,0xfd}, -{0x8660,0xee}, -{0x8661,0x13}, -{0x8662,0xfe}, -{0x8663,0xef}, -{0x8664,0x13}, -{0x8665,0xff}, -{0x8666,0xd8}, -{0x8667,0xf1}, -{0x8668,0x22}, -{0x8669,0xe8}, -{0x866a,0x60}, -{0x866b,0x0f}, -{0x866c,0xef}, -{0x866d,0xc3}, -{0x866e,0x33}, -{0x866f,0xff}, -{0x8670,0xee}, -{0x8671,0x33}, -{0x8672,0xfe}, -{0x8673,0xed}, -{0x8674,0x33}, -{0x8675,0xfd}, -{0x8676,0xec}, -{0x8677,0x33}, -{0x8678,0xfc}, -{0x8679,0xd8}, -{0x867a,0xf1}, -{0x867b,0x22}, -{0x867c,0xe4}, -{0x867d,0x93}, -{0x867e,0xfc}, -{0x867f,0x74}, -{0x8680,0x01}, -{0x8681,0x93}, -{0x8682,0xfd}, -{0x8683,0x74}, -{0x8684,0x02}, -{0x8685,0x93}, -{0x8686,0xfe}, -{0x8687,0x74}, -{0x8688,0x03}, -{0x8689,0x93}, -{0x868a,0xff}, -{0x868b,0x22}, -{0x868c,0xe6}, -{0x868d,0xfb}, -{0x868e,0x08}, -{0x868f,0xe6}, -{0x8690,0xf9}, -{0x8691,0x08}, -{0x8692,0xe6}, -{0x8693,0xfa}, -{0x8694,0x08}, -{0x8695,0xe6}, -{0x8696,0xcb}, -{0x8697,0xf8}, -{0x8698,0x22}, -{0x8699,0xec}, -{0x869a,0xf6}, -{0x869b,0x08}, -{0x869c,0xed}, -{0x869d,0xf6}, -{0x869e,0x08}, -{0x869f,0xee}, -{0x86a0,0xf6}, -{0x86a1,0x08}, -{0x86a2,0xef}, -{0x86a3,0xf6}, -{0x86a4,0x22}, -{0x86a5,0xa4}, -{0x86a6,0x25}, -{0x86a7,0x82}, -{0x86a8,0xf5}, -{0x86a9,0x82}, -{0x86aa,0xe5}, -{0x86ab,0xf0}, -{0x86ac,0x35}, -{0x86ad,0x83}, -{0x86ae,0xf5}, -{0x86af,0x83}, -{0x86b0,0x22}, -{0x86b1,0xd0}, -{0x86b2,0x83}, -{0x86b3,0xd0}, -{0x86b4,0x82}, -{0x86b5,0xf8}, -{0x86b6,0xe4}, -{0x86b7,0x93}, -{0x86b8,0x70}, -{0x86b9,0x12}, -{0x86ba,0x74}, -{0x86bb,0x01}, -{0x86bc,0x93}, -{0x86bd,0x70}, -{0x86be,0x0d}, -{0x86bf,0xa3}, -{0x86c0,0xa3}, -{0x86c1,0x93}, -{0x86c2,0xf8}, -{0x86c3,0x74}, -{0x86c4,0x01}, -{0x86c5,0x93}, -{0x86c6,0xf5}, -{0x86c7,0x82}, -{0x86c8,0x88}, -{0x86c9,0x83}, -{0x86ca,0xe4}, -{0x86cb,0x73}, -{0x86cc,0x74}, -{0x86cd,0x02}, -{0x86ce,0x93}, -{0x86cf,0x68}, -{0x86d0,0x60}, -{0x86d1,0xef}, -{0x86d2,0xa3}, -{0x86d3,0xa3}, -{0x86d4,0xa3}, -{0x86d5,0x80}, -{0x86d6,0xdf}, -{0x86d7,0x90}, -{0x86d8,0x38}, -{0x86d9,0x04}, -{0x86da,0x78}, -{0x86db,0x52}, -{0x86dc,0x12}, -{0x86dd,0x0b}, -{0x86de,0xfd}, -{0x86df,0x90}, -{0x86e0,0x38}, -{0x86e1,0x00}, -{0x86e2,0xe0}, -{0x86e3,0xfe}, -{0x86e4,0xa3}, -{0x86e5,0xe0}, -{0x86e6,0xfd}, -{0x86e7,0xed}, -{0x86e8,0xff}, -{0x86e9,0xc3}, -{0x86ea,0x12}, -{0x86eb,0x0b}, -{0x86ec,0x9e}, -{0x86ed,0x90}, -{0x86ee,0x38}, -{0x86ef,0x10}, -{0x86f0,0x12}, -{0x86f1,0x0b}, -{0x86f2,0x92}, -{0x86f3,0x90}, -{0x86f4,0x38}, -{0x86f5,0x06}, -{0x86f6,0x78}, -{0x86f7,0x54}, -{0x86f8,0x12}, -{0x86f9,0x0b}, -{0x86fa,0xfd}, -{0x86fb,0x90}, -{0x86fc,0x38}, -{0x86fd,0x02}, -{0x86fe,0xe0}, -{0x86ff,0xfe}, -{0x8700,0xa3}, -{0x8701,0xe0}, -{0x8702,0xfd}, -{0x8703,0xed}, -{0x8704,0xff}, -{0x8705,0xc3}, -{0x8706,0x12}, -{0x8707,0x0b}, -{0x8708,0x9e}, -{0x8709,0x90}, -{0x870a,0x38}, -{0x870b,0x12}, -{0x870c,0x12}, -{0x870d,0x0b}, -{0x870e,0x92}, -{0x870f,0xa3}, -{0x8710,0xe0}, -{0x8711,0xb4}, -{0x8712,0x31}, -{0x8713,0x07}, -{0x8714,0x78}, -{0x8715,0x52}, -{0x8716,0x79}, -{0x8717,0x52}, -{0x8718,0x12}, -{0x8719,0x0c}, -{0x871a,0x13}, -{0x871b,0x90}, -{0x871c,0x38}, -{0x871d,0x14}, -{0x871e,0xe0}, -{0x871f,0xb4}, -{0x8720,0x71}, -{0x8721,0x15}, -{0x8722,0x78}, -{0x8723,0x52}, -{0x8724,0xe6}, -{0x8725,0xfe}, -{0x8726,0x08}, -{0x8727,0xe6}, -{0x8728,0x78}, -{0x8729,0x02}, -{0x872a,0xce}, -{0x872b,0xc3}, -{0x872c,0x13}, -{0x872d,0xce}, -{0x872e,0x13}, -{0x872f,0xd8}, -{0x8730,0xf9}, -{0x8731,0x79}, -{0x8732,0x53}, -{0x8733,0xf7}, -{0x8734,0xee}, -{0x8735,0x19}, -{0x8736,0xf7}, -{0x8737,0x90}, -{0x8738,0x38}, -{0x8739,0x15}, -{0x873a,0xe0}, -{0x873b,0xb4}, -{0x873c,0x31}, -{0x873d,0x07}, -{0x873e,0x78}, -{0x873f,0x54}, -{0x8740,0x79}, -{0x8741,0x54}, -{0x8742,0x12}, -{0x8743,0x0c}, -{0x8744,0x13}, -{0x8745,0x90}, -{0x8746,0x38}, -{0x8747,0x15}, -{0x8748,0xe0}, -{0x8749,0xb4}, -{0x874a,0x71}, -{0x874b,0x15}, -{0x874c,0x78}, -{0x874d,0x54}, -{0x874e,0xe6}, -{0x874f,0xfe}, -{0x8750,0x08}, -{0x8751,0xe6}, -{0x8752,0x78}, -{0x8753,0x02}, -{0x8754,0xce}, -{0x8755,0xc3}, -{0x8756,0x13}, -{0x8757,0xce}, -{0x8758,0x13}, -{0x8759,0xd8}, -{0x875a,0xf9}, -{0x875b,0x79}, -{0x875c,0x55}, -{0x875d,0xf7}, -{0x875e,0xee}, -{0x875f,0x19}, -{0x8760,0xf7}, -{0x8761,0x79}, -{0x8762,0x52}, -{0x8763,0x12}, -{0x8764,0x0b}, -{0x8765,0xd9}, -{0x8766,0x09}, -{0x8767,0x12}, -{0x8768,0x0b}, -{0x8769,0xd9}, -{0x876a,0xaf}, -{0x876b,0x47}, -{0x876c,0x12}, -{0x876d,0x0b}, -{0x876e,0xb2}, -{0x876f,0xe5}, -{0x8770,0x44}, -{0x8771,0xfb}, -{0x8772,0x7a}, -{0x8773,0x00}, -{0x8774,0xfd}, -{0x8775,0x7c}, -{0x8776,0x00}, -{0x8777,0x12}, -{0x8778,0x04}, -{0x8779,0xd3}, -{0x877a,0x78}, -{0x877b,0x5a}, -{0x877c,0xa6}, -{0x877d,0x06}, -{0x877e,0x08}, -{0x877f,0xa6}, -{0x8780,0x07}, -{0x8781,0xaf}, -{0x8782,0x45}, -{0x8783,0x12}, -{0x8784,0x0b}, -{0x8785,0xb2}, -{0x8786,0xad}, -{0x8787,0x03}, -{0x8788,0x7c}, -{0x8789,0x00}, -{0x878a,0x12}, -{0x878b,0x04}, -{0x878c,0xd3}, -{0x878d,0x78}, -{0x878e,0x56}, -{0x878f,0xa6}, -{0x8790,0x06}, -{0x8791,0x08}, -{0x8792,0xa6}, -{0x8793,0x07}, -{0x8794,0xaf}, -{0x8795,0x48}, -{0x8796,0x78}, -{0x8797,0x54}, -{0x8798,0x12}, -{0x8799,0x0b}, -{0x879a,0xb4}, -{0x879b,0xe5}, -{0x879c,0x43}, -{0x879d,0xfb}, -{0x879e,0xfd}, -{0x879f,0x7c}, -{0x87a0,0x00}, -{0x87a1,0x12}, -{0x87a2,0x04}, -{0x87a3,0xd3}, -{0x87a4,0x78}, -{0x87a5,0x5c}, -{0x87a6,0xa6}, -{0x87a7,0x06}, -{0x87a8,0x08}, -{0x87a9,0xa6}, -{0x87aa,0x07}, -{0x87ab,0xaf}, -{0x87ac,0x46}, -{0x87ad,0x7e}, -{0x87ae,0x00}, -{0x87af,0x78}, -{0x87b0,0x54}, -{0x87b1,0x12}, -{0x87b2,0x0b}, -{0x87b3,0xb6}, -{0x87b4,0xad}, -{0x87b5,0x03}, -{0x87b6,0x7c}, -{0x87b7,0x00}, -{0x87b8,0x12}, -{0x87b9,0x04}, -{0x87ba,0xd3}, -{0x87bb,0x78}, -{0x87bc,0x58}, -{0x87bd,0xa6}, -{0x87be,0x06}, -{0x87bf,0x08}, -{0x87c0,0xa6}, -{0x87c1,0x07}, -{0x87c2,0xc3}, -{0x87c3,0x78}, -{0x87c4,0x5b}, -{0x87c5,0xe6}, -{0x87c6,0x94}, -{0x87c7,0x08}, -{0x87c8,0x18}, -{0x87c9,0xe6}, -{0x87ca,0x94}, -{0x87cb,0x00}, -{0x87cc,0x50}, -{0x87cd,0x05}, -{0x87ce,0x76}, -{0x87cf,0x00}, -{0x87d0,0x08}, -{0x87d1,0x76}, -{0x87d2,0x08}, -{0x87d3,0xc3}, -{0x87d4,0x78}, -{0x87d5,0x5d}, -{0x87d6,0xe6}, -{0x87d7,0x94}, -{0x87d8,0x08}, -{0x87d9,0x18}, -{0x87da,0xe6}, -{0x87db,0x94}, -{0x87dc,0x00}, -{0x87dd,0x50}, -{0x87de,0x05}, -{0x87df,0x76}, -{0x87e0,0x00}, -{0x87e1,0x08}, -{0x87e2,0x76}, -{0x87e3,0x08}, -{0x87e4,0x78}, -{0x87e5,0x5a}, -{0x87e6,0x12}, -{0x87e7,0x0b}, -{0x87e8,0xc6}, -{0x87e9,0xff}, -{0x87ea,0xd3}, -{0x87eb,0x78}, -{0x87ec,0x57}, -{0x87ed,0xe6}, -{0x87ee,0x9f}, -{0x87ef,0x18}, -{0x87f0,0xe6}, -{0x87f1,0x9e}, -{0x87f2,0x40}, -{0x87f3,0x0e}, -{0x87f4,0x78}, -{0x87f5,0x5a}, -{0x87f6,0xe6}, -{0x87f7,0x13}, -{0x87f8,0xfe}, -{0x87f9,0x08}, -{0x87fa,0xe6}, -{0x87fb,0x78}, -{0x87fc,0x57}, -{0x87fd,0x12}, -{0x87fe,0x0c}, -{0x87ff,0x08}, -{0x8800,0x80}, -{0x8801,0x04}, -{0x8802,0x7e}, -{0x8803,0x00}, -{0x8804,0x7f}, -{0x8805,0x00}, -{0x8806,0x78}, -{0x8807,0x5e}, -{0x8808,0x12}, -{0x8809,0x0b}, -{0x880a,0xbe}, -{0x880b,0xff}, -{0x880c,0xd3}, -{0x880d,0x78}, -{0x880e,0x59}, -{0x880f,0xe6}, -{0x8810,0x9f}, -{0x8811,0x18}, -{0x8812,0xe6}, -{0x8813,0x9e}, -{0x8814,0x40}, -{0x8815,0x0e}, -{0x8816,0x78}, -{0x8817,0x5c}, -{0x8818,0xe6}, -{0x8819,0x13}, -{0x881a,0xfe}, -{0x881b,0x08}, -{0x881c,0xe6}, -{0x881d,0x78}, -{0x881e,0x59}, -{0x881f,0x12}, -{0x8820,0x0c}, -{0x8821,0x08}, -{0x8822,0x80}, -{0x8823,0x04}, -{0x8824,0x7e}, -{0x8825,0x00}, -{0x8826,0x7f}, -{0x8827,0x00}, -{0x8828,0xe4}, -{0x8829,0xfc}, -{0x882a,0xfd}, -{0x882b,0x78}, -{0x882c,0x62}, -{0x882d,0x12}, -{0x882e,0x06}, -{0x882f,0x99}, -{0x8830,0x78}, -{0x8831,0x5a}, -{0x8832,0x12}, -{0x8833,0x0b}, -{0x8834,0xc6}, -{0x8835,0x78}, -{0x8836,0x57}, -{0x8837,0x26}, -{0x8838,0xff}, -{0x8839,0xee}, -{0x883a,0x18}, -{0x883b,0x36}, -{0x883c,0xfe}, -{0x883d,0x78}, -{0x883e,0x66}, -{0x883f,0x12}, -{0x8840,0x0b}, -{0x8841,0xbe}, -{0x8842,0x78}, -{0x8843,0x59}, -{0x8844,0x26}, -{0x8845,0xff}, -{0x8846,0xee}, -{0x8847,0x18}, -{0x8848,0x36}, -{0x8849,0xfe}, -{0x884a,0xe4}, -{0x884b,0xfc}, -{0x884c,0xfd}, -{0x884d,0x78}, -{0x884e,0x6a}, -{0x884f,0x12}, -{0x8850,0x06}, -{0x8851,0x99}, -{0x8852,0x12}, -{0x8853,0x0b}, -{0x8854,0xce}, -{0x8855,0x78}, -{0x8856,0x66}, -{0x8857,0x12}, -{0x8858,0x06}, -{0x8859,0x8c}, -{0x885a,0xd3}, -{0x885b,0x12}, -{0x885c,0x06}, -{0x885d,0x45}, -{0x885e,0x40}, -{0x885f,0x08}, -{0x8860,0x12}, -{0x8861,0x0b}, -{0x8862,0xce}, -{0x8863,0x78}, -{0x8864,0x66}, -{0x8865,0x12}, -{0x8866,0x06}, -{0x8867,0x99}, -{0x8868,0x78}, -{0x8869,0x54}, -{0x886a,0x12}, -{0x886b,0x0b}, -{0x886c,0xd0}, -{0x886d,0x78}, -{0x886e,0x6a}, -{0x886f,0x12}, -{0x8870,0x06}, -{0x8871,0x8c}, -{0x8872,0xd3}, -{0x8873,0x12}, -{0x8874,0x06}, -{0x8875,0x45}, -{0x8876,0x40}, -{0x8877,0x0a}, -{0x8878,0x78}, -{0x8879,0x54}, -{0x887a,0x12}, -{0x887b,0x0b}, -{0x887c,0xd0}, -{0x887d,0x78}, -{0x887e,0x6a}, -{0x887f,0x12}, -{0x8880,0x06}, -{0x8881,0x99}, -{0x8882,0x78}, -{0x8883,0x61}, -{0x8884,0xe6}, -{0x8885,0x90}, -{0x8886,0x60}, -{0x8887,0x01}, -{0x8888,0xf0}, -{0x8889,0x78}, -{0x888a,0x65}, -{0x888b,0xe6}, -{0x888c,0xa3}, -{0x888d,0xf0}, -{0x888e,0x78}, -{0x888f,0x69}, -{0x8890,0xe6}, -{0x8891,0xa3}, -{0x8892,0xf0}, -{0x8893,0x78}, -{0x8894,0x55}, -{0x8895,0xe6}, -{0x8896,0xa3}, -{0x8897,0xf0}, -{0x8898,0x7d}, -{0x8899,0x01}, -{0x889a,0x78}, -{0x889b,0x61}, -{0x889c,0x12}, -{0x889d,0x0b}, -{0x889e,0xe9}, -{0x889f,0x24}, -{0x88a0,0x01}, -{0x88a1,0x12}, -{0x88a2,0x0b}, -{0x88a3,0xa6}, -{0x88a4,0x78}, -{0x88a5,0x65}, -{0x88a6,0x12}, -{0x88a7,0x0b}, -{0x88a8,0xe9}, -{0x88a9,0x24}, -{0x88aa,0x02}, -{0x88ab,0x12}, -{0x88ac,0x0b}, -{0x88ad,0xa6}, -{0x88ae,0x78}, -{0x88af,0x69}, -{0x88b0,0x12}, -{0x88b1,0x0b}, -{0x88b2,0xe9}, -{0x88b3,0x24}, -{0x88b4,0x03}, -{0x88b5,0x12}, -{0x88b6,0x0b}, -{0x88b7,0xa6}, -{0x88b8,0x78}, -{0x88b9,0x6d}, -{0x88ba,0x12}, -{0x88bb,0x0b}, -{0x88bc,0xe9}, -{0x88bd,0x24}, -{0x88be,0x04}, -{0x88bf,0x12}, -{0x88c0,0x0b}, -{0x88c1,0xa6}, -{0x88c2,0x0d}, -{0x88c3,0xbd}, -{0x88c4,0x05}, -{0x88c5,0xd4}, -{0x88c6,0xc2}, -{0x88c7,0x0e}, -{0x88c8,0xc2}, -{0x88c9,0x06}, -{0x88ca,0x22}, -{0x88cb,0x85}, -{0x88cc,0x08}, -{0x88cd,0x41}, -{0x88ce,0x90}, -{0x88cf,0x30}, -{0x88d0,0x24}, -{0x88d1,0xe0}, -{0x88d2,0xf5}, -{0x88d3,0x3d}, -{0x88d4,0xa3}, -{0x88d5,0xe0}, -{0x88d6,0xf5}, -{0x88d7,0x3e}, -{0x88d8,0xa3}, -{0x88d9,0xe0}, -{0x88da,0xf5}, -{0x88db,0x3f}, -{0x88dc,0xa3}, -{0x88dd,0xe0}, -{0x88de,0xf5}, -{0x88df,0x40}, -{0x88e0,0xa3}, -{0x88e1,0xe0}, -{0x88e2,0xf5}, -{0x88e3,0x3c}, -{0x88e4,0xd2}, -{0x88e5,0x34}, -{0x88e6,0xe5}, -{0x88e7,0x41}, -{0x88e8,0x12}, -{0x88e9,0x06}, -{0x88ea,0xb1}, -{0x88eb,0x09}, -{0x88ec,0x31}, -{0x88ed,0x03}, -{0x88ee,0x09}, -{0x88ef,0x35}, -{0x88f0,0x04}, -{0x88f1,0x09}, -{0x88f2,0x3b}, -{0x88f3,0x05}, -{0x88f4,0x09}, -{0x88f5,0x3e}, -{0x88f6,0x06}, -{0x88f7,0x09}, -{0x88f8,0x41}, -{0x88f9,0x07}, -{0x88fa,0x09}, -{0x88fb,0x4a}, -{0x88fc,0x08}, -{0x88fd,0x09}, -{0x88fe,0x5b}, -{0x88ff,0x12}, -{0x8900,0x09}, -{0x8901,0x73}, -{0x8902,0x18}, -{0x8903,0x09}, -{0x8904,0x89}, -{0x8905,0x19}, -{0x8906,0x09}, -{0x8907,0x5e}, -{0x8908,0x1a}, -{0x8909,0x09}, -{0x890a,0x6a}, -{0x890b,0x1b}, -{0x890c,0x09}, -{0x890d,0xad}, -{0x890e,0x80}, -{0x890f,0x09}, -{0x8910,0xb2}, -{0x8911,0x81}, -{0x8912,0x0a}, -{0x8913,0x1d}, -{0x8914,0x8f}, -{0x8915,0x0a}, -{0x8916,0x09}, -{0x8917,0x90}, -{0x8918,0x0a}, -{0x8919,0x1d}, -{0x891a,0x91}, -{0x891b,0x0a}, -{0x891c,0x1d}, -{0x891d,0x92}, -{0x891e,0x0a}, -{0x891f,0x1d}, -{0x8920,0x93}, -{0x8921,0x0a}, -{0x8922,0x1d}, -{0x8923,0x94}, -{0x8924,0x0a}, -{0x8925,0x1d}, -{0x8926,0x98}, -{0x8927,0x0a}, -{0x8928,0x17}, -{0x8929,0x9f}, -{0x892a,0x0a}, -{0x892b,0x1a}, -{0x892c,0xec}, -{0x892d,0x00}, -{0x892e,0x00}, -{0x892f,0x0a}, -{0x8930,0x38}, -{0x8931,0x12}, -{0x8932,0x0f}, -{0x8933,0x74}, -{0x8934,0x22}, -{0x8935,0x12}, -{0x8936,0x0f}, -{0x8937,0x74}, -{0x8938,0xd2}, -{0x8939,0x03}, -{0x893a,0x22}, -{0x893b,0xd2}, -{0x893c,0x03}, -{0x893d,0x22}, -{0x893e,0xc2}, -{0x893f,0x03}, -{0x8940,0x22}, -{0x8941,0xa2}, -{0x8942,0x37}, -{0x8943,0xe4}, -{0x8944,0x33}, -{0x8945,0xf5}, -{0x8946,0x3c}, -{0x8947,0x02}, -{0x8948,0x0a}, -{0x8949,0x1d}, -{0x894a,0xc2}, -{0x894b,0x01}, -{0x894c,0xc2}, -{0x894d,0x02}, -{0x894e,0xc2}, -{0x894f,0x03}, -{0x8950,0x12}, -{0x8951,0x0d}, -{0x8952,0x0d}, -{0x8953,0x75}, -{0x8954,0x1e}, -{0x8955,0x70}, -{0x8956,0xd2}, -{0x8957,0x35}, -{0x8958,0x02}, -{0x8959,0x0a}, -{0x895a,0x1d}, -{0x895b,0x02}, -{0x895c,0x0a}, -{0x895d,0x04}, -{0x895e,0x85}, -{0x895f,0x40}, -{0x8960,0x4a}, -{0x8961,0x85}, -{0x8962,0x3c}, -{0x8963,0x4b}, -{0x8964,0x12}, -{0x8965,0x0a}, -{0x8966,0xff}, -{0x8967,0x02}, -{0x8968,0x0a}, -{0x8969,0x1d}, -{0x896a,0x85}, -{0x896b,0x4a}, -{0x896c,0x40}, -{0x896d,0x85}, -{0x896e,0x4b}, -{0x896f,0x3c}, -{0x8970,0x02}, -{0x8971,0x0a}, -{0x8972,0x1d}, -{0x8973,0xe4}, -{0x8974,0xf5}, -{0x8975,0x22}, -{0x8976,0xf5}, -{0x8977,0x23}, -{0x8978,0x85}, -{0x8979,0x40}, -{0x897a,0x31}, -{0x897b,0x85}, -{0x897c,0x3f}, -{0x897d,0x30}, -{0x897e,0x85}, -{0x897f,0x3e}, -{0x8980,0x2f}, -{0x8981,0x85}, -{0x8982,0x3d}, -{0x8983,0x2e}, -{0x8984,0x12}, -{0x8985,0x0f}, -{0x8986,0x46}, -{0x8987,0x80}, -{0x8988,0x1f}, -{0x8989,0x75}, -{0x898a,0x22}, -{0x898b,0x00}, -{0x898c,0x75}, -{0x898d,0x23}, -{0x898e,0x01}, -{0x898f,0x74}, -{0x8990,0xff}, -{0x8991,0xf5}, -{0x8992,0x2d}, -{0x8993,0xf5}, -{0x8994,0x2c}, -{0x8995,0xf5}, -{0x8996,0x2b}, -{0x8997,0xf5}, -{0x8998,0x2a}, -{0x8999,0x12}, -{0x899a,0x0f}, -{0x899b,0x46}, -{0x899c,0x85}, -{0x899d,0x2d}, -{0x899e,0x40}, -{0x899f,0x85}, -{0x89a0,0x2c}, -{0x89a1,0x3f}, -{0x89a2,0x85}, -{0x89a3,0x2b}, -{0x89a4,0x3e}, -{0x89a5,0x85}, -{0x89a6,0x2a}, -{0x89a7,0x3d}, -{0x89a8,0xe4}, -{0x89a9,0xf5}, -{0x89aa,0x3c}, -{0x89ab,0x80}, -{0x89ac,0x70}, -{0x89ad,0x12}, -{0x89ae,0x0f}, -{0x89af,0x16}, -{0x89b0,0x80}, -{0x89b1,0x6b}, -{0x89b2,0x85}, -{0x89b3,0x3d}, -{0x89b4,0x45}, -{0x89b5,0x85}, -{0x89b6,0x3e}, -{0x89b7,0x46}, -{0x89b8,0xe5}, -{0x89b9,0x47}, -{0x89ba,0xc3}, -{0x89bb,0x13}, -{0x89bc,0xff}, -{0x89bd,0xe5}, -{0x89be,0x45}, -{0x89bf,0xc3}, -{0x89c0,0x9f}, -{0x89c1,0x50}, -{0x89c2,0x02}, -{0x89c3,0x8f}, -{0x89c4,0x45}, -{0x89c5,0xe5}, -{0x89c6,0x48}, -{0x89c7,0xc3}, -{0x89c8,0x13}, -{0x89c9,0xff}, -{0x89ca,0xe5}, -{0x89cb,0x46}, -{0x89cc,0xc3}, -{0x89cd,0x9f}, -{0x89ce,0x50}, -{0x89cf,0x02}, -{0x89d0,0x8f}, -{0x89d1,0x46}, -{0x89d2,0xe5}, -{0x89d3,0x47}, -{0x89d4,0xc3}, -{0x89d5,0x13}, -{0x89d6,0xff}, -{0x89d7,0xfd}, -{0x89d8,0xe5}, -{0x89d9,0x45}, -{0x89da,0x2d}, -{0x89db,0xfd}, -{0x89dc,0xe4}, -{0x89dd,0x33}, -{0x89de,0xfc}, -{0x89df,0xe5}, -{0x89e0,0x44}, -{0x89e1,0x12}, -{0x89e2,0x0f}, -{0x89e3,0x90}, -{0x89e4,0x40}, -{0x89e5,0x05}, -{0x89e6,0xe5}, -{0x89e7,0x44}, -{0x89e8,0x9f}, -{0x89e9,0xf5}, -{0x89ea,0x45}, -{0x89eb,0xe5}, -{0x89ec,0x48}, -{0x89ed,0xc3}, -{0x89ee,0x13}, -{0x89ef,0xff}, -{0x89f0,0xfd}, -{0x89f1,0xe5}, -{0x89f2,0x46}, -{0x89f3,0x2d}, -{0x89f4,0xfd}, -{0x89f5,0xe4}, -{0x89f6,0x33}, -{0x89f7,0xfc}, -{0x89f8,0xe5}, -{0x89f9,0x43}, -{0x89fa,0x12}, -{0x89fb,0x0f}, -{0x89fc,0x90}, -{0x89fd,0x40}, -{0x89fe,0x05}, -{0x89ff,0xe5}, -{0x8a00,0x43}, -{0x8a01,0x9f}, -{0x8a02,0xf5}, -{0x8a03,0x46}, -{0x8a04,0x12}, -{0x8a05,0x06}, -{0x8a06,0xd7}, -{0x8a07,0x80}, -{0x8a08,0x14}, -{0x8a09,0x85}, -{0x8a0a,0x40}, -{0x8a0b,0x48}, -{0x8a0c,0x85}, -{0x8a0d,0x3f}, -{0x8a0e,0x47}, -{0x8a0f,0x85}, -{0x8a10,0x3e}, -{0x8a11,0x46}, -{0x8a12,0x85}, -{0x8a13,0x3d}, -{0x8a14,0x45}, -{0x8a15,0x80}, -{0x8a16,0x06}, -{0x8a17,0x02}, -{0x8a18,0x06}, -{0x8a19,0xd7}, -{0x8a1a,0x12}, -{0x8a1b,0x0d}, -{0x8a1c,0x7e}, -{0x8a1d,0x90}, -{0x8a1e,0x30}, -{0x8a1f,0x24}, -{0x8a20,0xe5}, -{0x8a21,0x3d}, -{0x8a22,0xf0}, -{0x8a23,0xa3}, -{0x8a24,0xe5}, -{0x8a25,0x3e}, -{0x8a26,0xf0}, -{0x8a27,0xa3}, -{0x8a28,0xe5}, -{0x8a29,0x3f}, -{0x8a2a,0xf0}, -{0x8a2b,0xa3}, -{0x8a2c,0xe5}, -{0x8a2d,0x40}, -{0x8a2e,0xf0}, -{0x8a2f,0xa3}, -{0x8a30,0xe5}, -{0x8a31,0x3c}, -{0x8a32,0xf0}, -{0x8a33,0x90}, -{0x8a34,0x30}, -{0x8a35,0x23}, -{0x8a36,0xe4}, -{0x8a37,0xf0}, -{0x8a38,0x22}, -{0x8a39,0xc0}, -{0x8a3a,0xe0}, -{0x8a3b,0xc0}, -{0x8a3c,0x83}, -{0x8a3d,0xc0}, -{0x8a3e,0x82}, -{0x8a3f,0xc0}, -{0x8a40,0xd0}, -{0x8a41,0x90}, -{0x8a42,0x3f}, -{0x8a43,0x0c}, -{0x8a44,0xe0}, -{0x8a45,0xf5}, -{0x8a46,0x32}, -{0x8a47,0xe5}, -{0x8a48,0x32}, -{0x8a49,0x30}, -{0x8a4a,0xe3}, -{0x8a4b,0x74}, -{0x8a4c,0x30}, -{0x8a4d,0x36}, -{0x8a4e,0x66}, -{0x8a4f,0x90}, -{0x8a50,0x60}, -{0x8a51,0x19}, -{0x8a52,0xe0}, -{0x8a53,0xf5}, -{0x8a54,0x0a}, -{0x8a55,0xa3}, -{0x8a56,0xe0}, -{0x8a57,0xf5}, -{0x8a58,0x0b}, -{0x8a59,0x90}, -{0x8a5a,0x60}, -{0x8a5b,0x1d}, -{0x8a5c,0xe0}, -{0x8a5d,0xf5}, -{0x8a5e,0x14}, -{0x8a5f,0xa3}, -{0x8a60,0xe0}, -{0x8a61,0xf5}, -{0x8a62,0x15}, -{0x8a63,0x90}, -{0x8a64,0x60}, -{0x8a65,0x21}, -{0x8a66,0xe0}, -{0x8a67,0xf5}, -{0x8a68,0x0c}, -{0x8a69,0xa3}, -{0x8a6a,0xe0}, -{0x8a6b,0xf5}, -{0x8a6c,0x0d}, -{0x8a6d,0x90}, -{0x8a6e,0x60}, -{0x8a6f,0x29}, -{0x8a70,0xe0}, -{0x8a71,0xf5}, -{0x8a72,0x0e}, -{0x8a73,0xa3}, -{0x8a74,0xe0}, -{0x8a75,0xf5}, -{0x8a76,0x0f}, -{0x8a77,0x90}, -{0x8a78,0x60}, -{0x8a79,0x31}, -{0x8a7a,0xe0}, -{0x8a7b,0xf5}, -{0x8a7c,0x10}, -{0x8a7d,0xa3}, -{0x8a7e,0xe0}, -{0x8a7f,0xf5}, -{0x8a80,0x11}, -{0x8a81,0x90}, -{0x8a82,0x60}, -{0x8a83,0x39}, -{0x8a84,0xe0}, -{0x8a85,0xf5}, -{0x8a86,0x12}, -{0x8a87,0xa3}, -{0x8a88,0xe0}, -{0x8a89,0xf5}, -{0x8a8a,0x13}, -{0x8a8b,0x30}, -{0x8a8c,0x01}, -{0x8a8d,0x06}, -{0x8a8e,0x30}, -{0x8a8f,0x33}, -{0x8a90,0x03}, -{0x8a91,0xd3}, -{0x8a92,0x80}, -{0x8a93,0x01}, -{0x8a94,0xc3}, -{0x8a95,0x92}, -{0x8a96,0x09}, -{0x8a97,0x30}, -{0x8a98,0x02}, -{0x8a99,0x06}, -{0x8a9a,0x30}, -{0x8a9b,0x33}, -{0x8a9c,0x03}, -{0x8a9d,0xd3}, -{0x8a9e,0x80}, -{0x8a9f,0x01}, -{0x8aa0,0xc3}, -{0x8aa1,0x92}, -{0x8aa2,0x0a}, -{0x8aa3,0x30}, -{0x8aa4,0x33}, -{0x8aa5,0x0c}, -{0x8aa6,0x30}, -{0x8aa7,0x03}, -{0x8aa8,0x09}, -{0x8aa9,0x20}, -{0x8aaa,0x02}, -{0x8aab,0x06}, -{0x8aac,0x20}, -{0x8aad,0x01}, -{0x8aae,0x03}, -{0x8aaf,0xd3}, -{0x8ab0,0x80}, -{0x8ab1,0x01}, -{0x8ab2,0xc3}, -{0x8ab3,0x92}, -{0x8ab4,0x0b}, -{0x8ab5,0x90}, -{0x8ab6,0x30}, -{0x8ab7,0x01}, -{0x8ab8,0xe0}, -{0x8ab9,0x44}, -{0x8aba,0x40}, -{0x8abb,0xf0}, -{0x8abc,0xe0}, -{0x8abd,0x54}, -{0x8abe,0xbf}, -{0x8abf,0xf0}, -{0x8ac0,0xe5}, -{0x8ac1,0x32}, -{0x8ac2,0x30}, -{0x8ac3,0xe1}, -{0x8ac4,0x14}, -{0x8ac5,0x30}, -{0x8ac6,0x34}, -{0x8ac7,0x11}, -{0x8ac8,0x90}, -{0x8ac9,0x30}, -{0x8aca,0x22}, -{0x8acb,0xe0}, -{0x8acc,0xf5}, -{0x8acd,0x08}, -{0x8ace,0xe4}, -{0x8acf,0xf0}, -{0x8ad0,0x30}, -{0x8ad1,0x00}, -{0x8ad2,0x03}, -{0x8ad3,0xd3}, -{0x8ad4,0x80}, -{0x8ad5,0x01}, -{0x8ad6,0xc3}, -{0x8ad7,0x92}, -{0x8ad8,0x08}, -{0x8ad9,0xe5}, -{0x8ada,0x32}, -{0x8adb,0x30}, -{0x8adc,0xe5}, -{0x8add,0x12}, -{0x8ade,0x90}, -{0x8adf,0x56}, -{0x8ae0,0xa1}, -{0x8ae1,0xe0}, -{0x8ae2,0xf5}, -{0x8ae3,0x09}, -{0x8ae4,0x30}, -{0x8ae5,0x31}, -{0x8ae6,0x09}, -{0x8ae7,0x30}, -{0x8ae8,0x05}, -{0x8ae9,0x03}, -{0x8aea,0xd3}, -{0x8aeb,0x80}, -{0x8aec,0x01}, -{0x8aed,0xc3}, -{0x8aee,0x92}, -{0x8aef,0x0d}, -{0x8af0,0x90}, -{0x8af1,0x3f}, -{0x8af2,0x0c}, -{0x8af3,0xe5}, -{0x8af4,0x32}, -{0x8af5,0xf0}, -{0x8af6,0xd0}, -{0x8af7,0xd0}, -{0x8af8,0xd0}, -{0x8af9,0x82}, -{0x8afa,0xd0}, -{0x8afb,0x83}, -{0x8afc,0xd0}, -{0x8afd,0xe0}, -{0x8afe,0x32}, -{0x8aff,0x90}, -{0x8b00,0x0e}, -{0x8b01,0x7e}, -{0x8b02,0xe4}, -{0x8b03,0x93}, -{0x8b04,0xfe}, -{0x8b05,0x74}, -{0x8b06,0x01}, -{0x8b07,0x93}, -{0x8b08,0xff}, -{0x8b09,0xc3}, -{0x8b0a,0x90}, -{0x8b0b,0x0e}, -{0x8b0c,0x7c}, -{0x8b0d,0x74}, -{0x8b0e,0x01}, -{0x8b0f,0x93}, -{0x8b10,0x9f}, -{0x8b11,0xff}, -{0x8b12,0xe4}, -{0x8b13,0x93}, -{0x8b14,0x9e}, -{0x8b15,0xfe}, -{0x8b16,0xe4}, -{0x8b17,0x8f}, -{0x8b18,0x3b}, -{0x8b19,0x8e}, -{0x8b1a,0x3a}, -{0x8b1b,0xf5}, -{0x8b1c,0x39}, -{0x8b1d,0xf5}, -{0x8b1e,0x38}, -{0x8b1f,0xab}, -{0x8b20,0x3b}, -{0x8b21,0xaa}, -{0x8b22,0x3a}, -{0x8b23,0xa9}, -{0x8b24,0x39}, -{0x8b25,0xa8}, -{0x8b26,0x38}, -{0x8b27,0xaf}, -{0x8b28,0x4b}, -{0x8b29,0xfc}, -{0x8b2a,0xfd}, -{0x8b2b,0xfe}, -{0x8b2c,0x12}, -{0x8b2d,0x05}, -{0x8b2e,0x28}, -{0x8b2f,0x12}, -{0x8b30,0x0d}, -{0x8b31,0xe1}, -{0x8b32,0xe4}, -{0x8b33,0x7b}, -{0x8b34,0xff}, -{0x8b35,0xfa}, -{0x8b36,0xf9}, -{0x8b37,0xf8}, -{0x8b38,0x12}, -{0x8b39,0x05}, -{0x8b3a,0xb3}, -{0x8b3b,0x12}, -{0x8b3c,0x0d}, -{0x8b3d,0xe1}, -{0x8b3e,0x90}, -{0x8b3f,0x0e}, -{0x8b40,0x69}, -{0x8b41,0xe4}, -{0x8b42,0x12}, -{0x8b43,0x0d}, -{0x8b44,0xf6}, -{0x8b45,0x12}, -{0x8b46,0x0d}, -{0x8b47,0xe1}, -{0x8b48,0xe4}, -{0x8b49,0x85}, -{0x8b4a,0x4a}, -{0x8b4b,0x37}, -{0x8b4c,0xf5}, -{0x8b4d,0x36}, -{0x8b4e,0xf5}, -{0x8b4f,0x35}, -{0x8b50,0xf5}, -{0x8b51,0x34}, -{0x8b52,0xaf}, -{0x8b53,0x37}, -{0x8b54,0xae}, -{0x8b55,0x36}, -{0x8b56,0xad}, -{0x8b57,0x35}, -{0x8b58,0xac}, -{0x8b59,0x34}, -{0x8b5a,0xa3}, -{0x8b5b,0x12}, -{0x8b5c,0x0d}, -{0x8b5d,0xf6}, -{0x8b5e,0x8f}, -{0x8b5f,0x37}, -{0x8b60,0x8e}, -{0x8b61,0x36}, -{0x8b62,0x8d}, -{0x8b63,0x35}, -{0x8b64,0x8c}, -{0x8b65,0x34}, -{0x8b66,0xe5}, -{0x8b67,0x3b}, -{0x8b68,0x45}, -{0x8b69,0x37}, -{0x8b6a,0xf5}, -{0x8b6b,0x3b}, -{0x8b6c,0xe5}, -{0x8b6d,0x3a}, -{0x8b6e,0x45}, -{0x8b6f,0x36}, -{0x8b70,0xf5}, -{0x8b71,0x3a}, -{0x8b72,0xe5}, -{0x8b73,0x39}, -{0x8b74,0x45}, -{0x8b75,0x35}, -{0x8b76,0xf5}, -{0x8b77,0x39}, -{0x8b78,0xe5}, -{0x8b79,0x38}, -{0x8b7a,0x45}, -{0x8b7b,0x34}, -{0x8b7c,0xf5}, -{0x8b7d,0x38}, -{0x8b7e,0xe4}, -{0x8b7f,0xf5}, -{0x8b80,0x22}, -{0x8b81,0xf5}, -{0x8b82,0x23}, -{0x8b83,0x85}, -{0x8b84,0x3b}, -{0x8b85,0x31}, -{0x8b86,0x85}, -{0x8b87,0x3a}, -{0x8b88,0x30}, -{0x8b89,0x85}, -{0x8b8a,0x39}, -{0x8b8b,0x2f}, -{0x8b8c,0x85}, -{0x8b8d,0x38}, -{0x8b8e,0x2e}, -{0x8b8f,0x02}, -{0x8b90,0x0f}, -{0x8b91,0x46}, -{0x8b92,0xe0}, -{0x8b93,0xa3}, -{0x8b94,0xe0}, -{0x8b95,0x75}, -{0x8b96,0xf0}, -{0x8b97,0x02}, -{0x8b98,0xa4}, -{0x8b99,0xff}, -{0x8b9a,0xae}, -{0x8b9b,0xf0}, -{0x8b9c,0xc3}, -{0x8b9d,0x08}, -{0x8b9e,0xe6}, -{0x8b9f,0x9f}, -{0x8ba0,0xf6}, -{0x8ba1,0x18}, -{0x8ba2,0xe6}, -{0x8ba3,0x9e}, -{0x8ba4,0xf6}, -{0x8ba5,0x22}, -{0x8ba6,0xff}, -{0x8ba7,0xe5}, -{0x8ba8,0xf0}, -{0x8ba9,0x34}, -{0x8baa,0x60}, -{0x8bab,0x8f}, -{0x8bac,0x82}, -{0x8bad,0xf5}, -{0x8bae,0x83}, -{0x8baf,0xec}, -{0x8bb0,0xf0}, -{0x8bb1,0x22}, -{0x8bb2,0x78}, -{0x8bb3,0x52}, -{0x8bb4,0x7e}, -{0x8bb5,0x00}, -{0x8bb6,0xe6}, -{0x8bb7,0xfc}, -{0x8bb8,0x08}, -{0x8bb9,0xe6}, -{0x8bba,0xfd}, -{0x8bbb,0x02}, -{0x8bbc,0x04}, -{0x8bbd,0xc1}, -{0x8bbe,0xe4}, -{0x8bbf,0xfc}, -{0x8bc0,0xfd}, -{0x8bc1,0x12}, -{0x8bc2,0x06}, -{0x8bc3,0x99}, -{0x8bc4,0x78}, -{0x8bc5,0x5c}, -{0x8bc6,0xe6}, -{0x8bc7,0xc3}, -{0x8bc8,0x13}, -{0x8bc9,0xfe}, -{0x8bca,0x08}, -{0x8bcb,0xe6}, -{0x8bcc,0x13}, -{0x8bcd,0x22}, -{0x8bce,0x78}, -{0x8bcf,0x52}, -{0x8bd0,0xe6}, -{0x8bd1,0xfe}, -{0x8bd2,0x08}, -{0x8bd3,0xe6}, -{0x8bd4,0xff}, -{0x8bd5,0xe4}, -{0x8bd6,0xfc}, -{0x8bd7,0xfd}, -{0x8bd8,0x22}, -{0x8bd9,0xe7}, -{0x8bda,0xc4}, -{0x8bdb,0xf8}, -{0x8bdc,0x54}, -{0x8bdd,0xf0}, -{0x8bde,0xc8}, -{0x8bdf,0x68}, -{0x8be0,0xf7}, -{0x8be1,0x09}, -{0x8be2,0xe7}, -{0x8be3,0xc4}, -{0x8be4,0x54}, -{0x8be5,0x0f}, -{0x8be6,0x48}, -{0x8be7,0xf7}, -{0x8be8,0x22}, -{0x8be9,0xe6}, -{0x8bea,0xfc}, -{0x8beb,0xed}, -{0x8bec,0x75}, -{0x8bed,0xf0}, -{0x8bee,0x04}, -{0x8bef,0xa4}, -{0x8bf0,0x22}, -{0x8bf1,0x12}, -{0x8bf2,0x06}, -{0x8bf3,0x7c}, -{0x8bf4,0x8f}, -{0x8bf5,0x48}, -{0x8bf6,0x8e}, -{0x8bf7,0x47}, -{0x8bf8,0x8d}, -{0x8bf9,0x46}, -{0x8bfa,0x8c}, -{0x8bfb,0x45}, -{0x8bfc,0x22}, -{0x8bfd,0xe0}, -{0x8bfe,0xfe}, -{0x8bff,0xa3}, -{0x8c00,0xe0}, -{0x8c01,0xfd}, -{0x8c02,0xee}, -{0x8c03,0xf6}, -{0x8c04,0xed}, -{0x8c05,0x08}, -{0x8c06,0xf6}, -{0x8c07,0x22}, -{0x8c08,0x13}, -{0x8c09,0xff}, -{0x8c0a,0xc3}, -{0x8c0b,0xe6}, -{0x8c0c,0x9f}, -{0x8c0d,0xff}, -{0x8c0e,0x18}, -{0x8c0f,0xe6}, -{0x8c10,0x9e}, -{0x8c11,0xfe}, -{0x8c12,0x22}, -{0x8c13,0xe6}, -{0x8c14,0xc3}, -{0x8c15,0x13}, -{0x8c16,0xf7}, -{0x8c17,0x08}, -{0x8c18,0xe6}, -{0x8c19,0x13}, -{0x8c1a,0x09}, -{0x8c1b,0xf7}, -{0x8c1c,0x22}, -{0x8c1d,0xad}, -{0x8c1e,0x39}, -{0x8c1f,0xac}, -{0x8c20,0x38}, -{0x8c21,0xfa}, -{0x8c22,0xf9}, -{0x8c23,0xf8}, -{0x8c24,0x12}, -{0x8c25,0x05}, -{0x8c26,0x28}, -{0x8c27,0x8f}, -{0x8c28,0x3b}, -{0x8c29,0x8e}, -{0x8c2a,0x3a}, -{0x8c2b,0x8d}, -{0x8c2c,0x39}, -{0x8c2d,0x8c}, -{0x8c2e,0x38}, -{0x8c2f,0xab}, -{0x8c30,0x37}, -{0x8c31,0xaa}, -{0x8c32,0x36}, -{0x8c33,0xa9}, -{0x8c34,0x35}, -{0x8c35,0xa8}, -{0x8c36,0x34}, -{0x8c37,0x22}, -{0x8c38,0x93}, -{0x8c39,0xff}, -{0x8c3a,0xe4}, -{0x8c3b,0xfc}, -{0x8c3c,0xfd}, -{0x8c3d,0xfe}, -{0x8c3e,0x12}, -{0x8c3f,0x05}, -{0x8c40,0x28}, -{0x8c41,0x8f}, -{0x8c42,0x37}, -{0x8c43,0x8e}, -{0x8c44,0x36}, -{0x8c45,0x8d}, -{0x8c46,0x35}, -{0x8c47,0x8c}, -{0x8c48,0x34}, -{0x8c49,0x22}, -{0x8c4a,0x78}, -{0x8c4b,0x84}, -{0x8c4c,0xe6}, -{0x8c4d,0xfe}, -{0x8c4e,0x08}, -{0x8c4f,0xe6}, -{0x8c50,0xff}, -{0x8c51,0xe4}, -{0x8c52,0x8f}, -{0x8c53,0x37}, -{0x8c54,0x8e}, -{0x8c55,0x36}, -{0x8c56,0xf5}, -{0x8c57,0x35}, -{0x8c58,0xf5}, -{0x8c59,0x34}, -{0x8c5a,0x22}, -{0x8c5b,0x90}, -{0x8c5c,0x0e}, -{0x8c5d,0x8c}, -{0x8c5e,0xe4}, -{0x8c5f,0x93}, -{0x8c60,0x25}, -{0x8c61,0xe0}, -{0x8c62,0x24}, -{0x8c63,0x0a}, -{0x8c64,0xf8}, -{0x8c65,0xe6}, -{0x8c66,0xfe}, -{0x8c67,0x08}, -{0x8c68,0xe6}, -{0x8c69,0xff}, -{0x8c6a,0x22}, -{0x8c6b,0xe6}, -{0x8c6c,0xfe}, -{0x8c6d,0x08}, -{0x8c6e,0xe6}, -{0x8c6f,0xff}, -{0x8c70,0xe4}, -{0x8c71,0x8f}, -{0x8c72,0x3b}, -{0x8c73,0x8e}, -{0x8c74,0x3a}, -{0x8c75,0xf5}, -{0x8c76,0x39}, -{0x8c77,0xf5}, -{0x8c78,0x38}, -{0x8c79,0x22}, -{0x8c7a,0x78}, -{0x8c7b,0x4e}, -{0x8c7c,0xe6}, -{0x8c7d,0xfe}, -{0x8c7e,0x08}, -{0x8c7f,0xe6}, -{0x8c80,0xff}, -{0x8c81,0x22}, -{0x8c82,0xef}, -{0x8c83,0x25}, -{0x8c84,0xe0}, -{0x8c85,0x24}, -{0x8c86,0x4e}, -{0x8c87,0xf8}, -{0x8c88,0xe6}, -{0x8c89,0xfc}, -{0x8c8a,0x08}, -{0x8c8b,0xe6}, -{0x8c8c,0xfd}, -{0x8c8d,0x22}, -{0x8c8e,0x78}, -{0x8c8f,0x89}, -{0x8c90,0xef}, -{0x8c91,0x26}, -{0x8c92,0xf6}, -{0x8c93,0x18}, -{0x8c94,0xe4}, -{0x8c95,0x36}, -{0x8c96,0xf6}, -{0x8c97,0x22}, -{0x8c98,0x75}, -{0x8c99,0x89}, -{0x8c9a,0x03}, -{0x8c9b,0x75}, -{0x8c9c,0xa8}, -{0x8c9d,0x01}, -{0x8c9e,0x75}, -{0x8c9f,0xb8}, -{0x8ca0,0x04}, -{0x8ca1,0x75}, -{0x8ca2,0x34}, -{0x8ca3,0xff}, -{0x8ca4,0x75}, -{0x8ca5,0x35}, -{0x8ca6,0x0e}, -{0x8ca7,0x75}, -{0x8ca8,0x36}, -{0x8ca9,0x15}, -{0x8caa,0x75}, -{0x8cab,0x37}, -{0x8cac,0x0d}, -{0x8cad,0x12}, -{0x8cae,0x0e}, -{0x8caf,0x9a}, -{0x8cb0,0x12}, -{0x8cb1,0x00}, -{0x8cb2,0x09}, -{0x8cb3,0x12}, -{0x8cb4,0x0f}, -{0x8cb5,0x16}, -{0x8cb6,0x12}, -{0x8cb7,0x00}, -{0x8cb8,0x06}, -{0x8cb9,0xd2}, -{0x8cba,0x00}, -{0x8cbb,0xd2}, -{0x8cbc,0x34}, -{0x8cbd,0xd2}, -{0x8cbe,0xaf}, -{0x8cbf,0x75}, -{0x8cc0,0x34}, -{0x8cc1,0xff}, -{0x8cc2,0x75}, -{0x8cc3,0x35}, -{0x8cc4,0x0e}, -{0x8cc5,0x75}, -{0x8cc6,0x36}, -{0x8cc7,0x49}, -{0x8cc8,0x75}, -{0x8cc9,0x37}, -{0x8cca,0x03}, -{0x8ccb,0x12}, -{0x8ccc,0x0e}, -{0x8ccd,0x9a}, -{0x8cce,0x30}, -{0x8ccf,0x08}, -{0x8cd0,0x09}, -{0x8cd1,0xc2}, -{0x8cd2,0x34}, -{0x8cd3,0x12}, -{0x8cd4,0x08}, -{0x8cd5,0xcb}, -{0x8cd6,0xc2}, -{0x8cd7,0x08}, -{0x8cd8,0xd2}, -{0x8cd9,0x34}, -{0x8cda,0x30}, -{0x8cdb,0x0b}, -{0x8cdc,0x09}, -{0x8cdd,0xc2}, -{0x8cde,0x36}, -{0x8cdf,0x12}, -{0x8ce0,0x02}, -{0x8ce1,0x6c}, -{0x8ce2,0xc2}, -{0x8ce3,0x0b}, -{0x8ce4,0xd2}, -{0x8ce5,0x36}, -{0x8ce6,0x30}, -{0x8ce7,0x09}, -{0x8ce8,0x09}, -{0x8ce9,0xc2}, -{0x8cea,0x36}, -{0x8ceb,0x12}, -{0x8cec,0x00}, -{0x8ced,0x0e}, -{0x8cee,0xc2}, -{0x8cef,0x09}, -{0x8cf0,0xd2}, -{0x8cf1,0x36}, -{0x8cf2,0x30}, -{0x8cf3,0x0e}, -{0x8cf4,0x03}, -{0x8cf5,0x12}, -{0x8cf6,0x06}, -{0x8cf7,0xd7}, -{0x8cf8,0x30}, -{0x8cf9,0x35}, -{0x8cfa,0xd3}, -{0x8cfb,0x90}, -{0x8cfc,0x30}, -{0x8cfd,0x29}, -{0x8cfe,0xe5}, -{0x8cff,0x1e}, -{0x8d00,0xf0}, -{0x8d01,0xb4}, -{0x8d02,0x10}, -{0x8d03,0x05}, -{0x8d04,0x90}, -{0x8d05,0x30}, -{0x8d06,0x23}, -{0x8d07,0xe4}, -{0x8d08,0xf0}, -{0x8d09,0xc2}, -{0x8d0a,0x35}, -{0x8d0b,0x80}, -{0x8d0c,0xc1}, -{0x8d0d,0xe4}, -{0x8d0e,0xf5}, -{0x8d0f,0x4b}, -{0x8d10,0x90}, -{0x8d11,0x0e}, -{0x8d12,0x7a}, -{0x8d13,0x93}, -{0x8d14,0xff}, -{0x8d15,0xe4}, -{0x8d16,0x8f}, -{0x8d17,0x37}, -{0x8d18,0xf5}, -{0x8d19,0x36}, -{0x8d1a,0xf5}, -{0x8d1b,0x35}, -{0x8d1c,0xf5}, -{0x8d1d,0x34}, -{0x8d1e,0xaf}, -{0x8d1f,0x37}, -{0x8d20,0xae}, -{0x8d21,0x36}, -{0x8d22,0xad}, -{0x8d23,0x35}, -{0x8d24,0xac}, -{0x8d25,0x34}, -{0x8d26,0x90}, -{0x8d27,0x0e}, -{0x8d28,0x6a}, -{0x8d29,0x12}, -{0x8d2a,0x0d}, -{0x8d2b,0xf6}, -{0x8d2c,0x8f}, -{0x8d2d,0x37}, -{0x8d2e,0x8e}, -{0x8d2f,0x36}, -{0x8d30,0x8d}, -{0x8d31,0x35}, -{0x8d32,0x8c}, -{0x8d33,0x34}, -{0x8d34,0x90}, -{0x8d35,0x0e}, -{0x8d36,0x72}, -{0x8d37,0x12}, -{0x8d38,0x06}, -{0x8d39,0x7c}, -{0x8d3a,0xef}, -{0x8d3b,0x45}, -{0x8d3c,0x37}, -{0x8d3d,0xf5}, -{0x8d3e,0x37}, -{0x8d3f,0xee}, -{0x8d40,0x45}, -{0x8d41,0x36}, -{0x8d42,0xf5}, -{0x8d43,0x36}, -{0x8d44,0xed}, -{0x8d45,0x45}, -{0x8d46,0x35}, -{0x8d47,0xf5}, -{0x8d48,0x35}, -{0x8d49,0xec}, -{0x8d4a,0x45}, -{0x8d4b,0x34}, -{0x8d4c,0xf5}, -{0x8d4d,0x34}, -{0x8d4e,0xe4}, -{0x8d4f,0xf5}, -{0x8d50,0x22}, -{0x8d51,0xf5}, -{0x8d52,0x23}, -{0x8d53,0x85}, -{0x8d54,0x37}, -{0x8d55,0x31}, -{0x8d56,0x85}, -{0x8d57,0x36}, -{0x8d58,0x30}, -{0x8d59,0x85}, -{0x8d5a,0x35}, -{0x8d5b,0x2f}, -{0x8d5c,0x85}, -{0x8d5d,0x34}, -{0x8d5e,0x2e}, -{0x8d5f,0x12}, -{0x8d60,0x0f}, -{0x8d61,0x46}, -{0x8d62,0xe4}, -{0x8d63,0xf5}, -{0x8d64,0x22}, -{0x8d65,0xf5}, -{0x8d66,0x23}, -{0x8d67,0x90}, -{0x8d68,0x0e}, -{0x8d69,0x72}, -{0x8d6a,0x12}, -{0x8d6b,0x0d}, -{0x8d6c,0xea}, -{0x8d6d,0x12}, -{0x8d6e,0x0f}, -{0x8d6f,0x46}, -{0x8d70,0xe4}, -{0x8d71,0xf5}, -{0x8d72,0x22}, -{0x8d73,0xf5}, -{0x8d74,0x23}, -{0x8d75,0x90}, -{0x8d76,0x0e}, -{0x8d77,0x6e}, -{0x8d78,0x12}, -{0x8d79,0x0d}, -{0x8d7a,0xea}, -{0x8d7b,0x02}, -{0x8d7c,0x0f}, -{0x8d7d,0x46}, -{0x8d7e,0xe5}, -{0x8d7f,0x40}, -{0x8d80,0x24}, -{0x8d81,0xf2}, -{0x8d82,0xf5}, -{0x8d83,0x37}, -{0x8d84,0xe5}, -{0x8d85,0x3f}, -{0x8d86,0x34}, -{0x8d87,0x43}, -{0x8d88,0xf5}, -{0x8d89,0x36}, -{0x8d8a,0xe5}, -{0x8d8b,0x3e}, -{0x8d8c,0x34}, -{0x8d8d,0xa2}, -{0x8d8e,0xf5}, -{0x8d8f,0x35}, -{0x8d90,0xe5}, -{0x8d91,0x3d}, -{0x8d92,0x34}, -{0x8d93,0x28}, -{0x8d94,0xf5}, -{0x8d95,0x34}, -{0x8d96,0xe5}, -{0x8d97,0x37}, -{0x8d98,0xff}, -{0x8d99,0xe4}, -{0x8d9a,0xfe}, -{0x8d9b,0xfd}, -{0x8d9c,0xfc}, -{0x8d9d,0x78}, -{0x8d9e,0x18}, -{0x8d9f,0x12}, -{0x8da0,0x06}, -{0x8da1,0x69}, -{0x8da2,0x8f}, -{0x8da3,0x40}, -{0x8da4,0x8e}, -{0x8da5,0x3f}, -{0x8da6,0x8d}, -{0x8da7,0x3e}, -{0x8da8,0x8c}, -{0x8da9,0x3d}, -{0x8daa,0xe5}, -{0x8dab,0x37}, -{0x8dac,0x54}, -{0x8dad,0xa0}, -{0x8dae,0xff}, -{0x8daf,0xe5}, -{0x8db0,0x36}, -{0x8db1,0xfe}, -{0x8db2,0xe4}, -{0x8db3,0xfd}, -{0x8db4,0xfc}, -{0x8db5,0x78}, -{0x8db6,0x07}, -{0x8db7,0x12}, -{0x8db8,0x06}, -{0x8db9,0x56}, -{0x8dba,0x78}, -{0x8dbb,0x10}, -{0x8dbc,0x12}, -{0x8dbd,0x0f}, -{0x8dbe,0x9a}, -{0x8dbf,0xe4}, -{0x8dc0,0xff}, -{0x8dc1,0xfe}, -{0x8dc2,0xe5}, -{0x8dc3,0x35}, -{0x8dc4,0xfd}, -{0x8dc5,0xe4}, -{0x8dc6,0xfc}, -{0x8dc7,0x78}, -{0x8dc8,0x0e}, -{0x8dc9,0x12}, -{0x8dca,0x06}, -{0x8dcb,0x56}, -{0x8dcc,0x12}, -{0x8dcd,0x0f}, -{0x8dce,0x9d}, -{0x8dcf,0xe4}, -{0x8dd0,0xff}, -{0x8dd1,0xfe}, -{0x8dd2,0xfd}, -{0x8dd3,0xe5}, -{0x8dd4,0x34}, -{0x8dd5,0xfc}, -{0x8dd6,0x78}, -{0x8dd7,0x18}, -{0x8dd8,0x12}, -{0x8dd9,0x06}, -{0x8dda,0x56}, -{0x8ddb,0x78}, -{0x8ddc,0x08}, -{0x8ddd,0x12}, -{0x8dde,0x0f}, -{0x8ddf,0x9a}, -{0x8de0,0x22}, -{0x8de1,0x8f}, -{0x8de2,0x3b}, -{0x8de3,0x8e}, -{0x8de4,0x3a}, -{0x8de5,0x8d}, -{0x8de6,0x39}, -{0x8de7,0x8c}, -{0x8de8,0x38}, -{0x8de9,0x22}, -{0x8dea,0x12}, -{0x8deb,0x06}, -{0x8dec,0x7c}, -{0x8ded,0x8f}, -{0x8dee,0x31}, -{0x8def,0x8e}, -{0x8df0,0x30}, -{0x8df1,0x8d}, -{0x8df2,0x2f}, -{0x8df3,0x8c}, -{0x8df4,0x2e}, -{0x8df5,0x22}, -{0x8df6,0x93}, -{0x8df7,0xf9}, -{0x8df8,0xf8}, -{0x8df9,0x02}, -{0x8dfa,0x06}, -{0x8dfb,0x69}, -{0x8dfc,0x00}, -{0x8dfd,0x00}, -{0x8dfe,0x00}, -{0x8dff,0x00}, -{0x8e00,0x12}, -{0x8e01,0x01}, -{0x8e02,0x17}, -{0x8e03,0x08}, -{0x8e04,0x31}, -{0x8e05,0x15}, -{0x8e06,0x53}, -{0x8e07,0x54}, -{0x8e08,0x44}, -{0x8e09,0x20}, -{0x8e0a,0x20}, -{0x8e0b,0x20}, -{0x8e0c,0x20}, -{0x8e0d,0x20}, -{0x8e0e,0x13}, -{0x8e0f,0x01}, -{0x8e10,0x10}, -{0x8e11,0x01}, -{0x8e12,0x56}, -{0x8e13,0x40}, -{0x8e14,0x1a}, -{0x8e15,0x30}, -{0x8e16,0x29}, -{0x8e17,0x7e}, -{0x8e18,0x00}, -{0x8e19,0x30}, -{0x8e1a,0x04}, -{0x8e1b,0x20}, -{0x8e1c,0xdf}, -{0x8e1d,0x30}, -{0x8e1e,0x05}, -{0x8e1f,0x40}, -{0x8e20,0xbf}, -{0x8e21,0x50}, -{0x8e22,0x03}, -{0x8e23,0x00}, -{0x8e24,0xfd}, -{0x8e25,0x50}, -{0x8e26,0x27}, -{0x8e27,0x01}, -{0x8e28,0xfe}, -{0x8e29,0x60}, -{0x8e2a,0x00}, -{0x8e2b,0x11}, -{0x8e2c,0x00}, -{0x8e2d,0x3f}, -{0x8e2e,0x05}, -{0x8e2f,0x30}, -{0x8e30,0x00}, -{0x8e31,0x3f}, -{0x8e32,0x06}, -{0x8e33,0x22}, -{0x8e34,0x00}, -{0x8e35,0x3f}, -{0x8e36,0x01}, -{0x8e37,0x2a}, -{0x8e38,0x00}, -{0x8e39,0x3f}, -{0x8e3a,0x02}, -{0x8e3b,0x00}, -{0x8e3c,0x00}, -{0x8e3d,0x36}, -{0x8e3e,0x06}, -{0x8e3f,0x07}, -{0x8e40,0x00}, -{0x8e41,0x3f}, -{0x8e42,0x0b}, -{0x8e43,0x0f}, -{0x8e44,0xf0}, -{0x8e45,0x00}, -{0x8e46,0x00}, -{0x8e47,0x00}, -{0x8e48,0x00}, -{0x8e49,0x30}, -{0x8e4a,0x01}, -{0x8e4b,0x40}, -{0x8e4c,0xbf}, -{0x8e4d,0x30}, -{0x8e4e,0x01}, -{0x8e4f,0x00}, -{0x8e50,0xbf}, -{0x8e51,0x30}, -{0x8e52,0x29}, -{0x8e53,0x70}, -{0x8e54,0x00}, -{0x8e55,0x3a}, -{0x8e56,0x00}, -{0x8e57,0x00}, -{0x8e58,0xff}, -{0x8e59,0x3a}, -{0x8e5a,0x00}, -{0x8e5b,0x00}, -{0x8e5c,0xff}, -{0x8e5d,0x36}, -{0x8e5e,0x03}, -{0x8e5f,0x36}, -{0x8e60,0x02}, -{0x8e61,0x41}, -{0x8e62,0x44}, -{0x8e63,0x58}, -{0x8e64,0x20}, -{0x8e65,0x18}, -{0x8e66,0x10}, -{0x8e67,0x0a}, -{0x8e68,0x04}, -{0x8e69,0x04}, -{0x8e6a,0x00}, -{0x8e6b,0x03}, -{0x8e6c,0xff}, -{0x8e6d,0x64}, -{0x8e6e,0x00}, -{0x8e6f,0x00}, -{0x8e70,0x80}, -{0x8e71,0x00}, -{0x8e72,0x00}, -{0x8e73,0x00}, -{0x8e74,0x00}, -{0x8e75,0x00}, -{0x8e76,0x00}, -{0x8e77,0x02}, -{0x8e78,0x04}, -{0x8e79,0x06}, -{0x8e7a,0x06}, -{0x8e7b,0x00}, -{0x8e7c,0x03}, -{0x8e7d,0x51}, -{0x8e7e,0x00}, -{0x8e7f,0x7a}, -{0x8e80,0x50}, -{0x8e81,0x3c}, -{0x8e82,0x28}, -{0x8e83,0x1e}, -{0x8e84,0x10}, -{0x8e85,0x10}, -{0x8e86,0x50}, -{0x8e87,0x2d}, -{0x8e88,0x28}, -{0x8e89,0x16}, -{0x8e8a,0x10}, -{0x8e8b,0x10}, -{0x8e8c,0x02}, -{0x8e8d,0x00}, -{0x8e8e,0x10}, -{0x8e8f,0x0c}, -{0x8e90,0x10}, -{0x8e91,0x04}, -{0x8e92,0x0c}, -{0x8e93,0x6e}, -{0x8e94,0x06}, -{0x8e95,0x05}, -{0x8e96,0x00}, -{0x8e97,0xa5}, -{0x8e98,0x5a}, -{0x8e99,0x00}, -{0x8e9a,0xae}, -{0x8e9b,0x35}, -{0x8e9c,0xaf}, -{0x8e9d,0x36}, -{0x8e9e,0xe4}, -{0x8e9f,0xfd}, -{0x8ea0,0xed}, -{0x8ea1,0xc3}, -{0x8ea2,0x95}, -{0x8ea3,0x37}, -{0x8ea4,0x50}, -{0x8ea5,0x33}, -{0x8ea6,0x12}, -{0x8ea7,0x0f}, -{0x8ea8,0xe2}, -{0x8ea9,0xe4}, -{0x8eaa,0x93}, -{0x8eab,0xf5}, -{0x8eac,0x38}, -{0x8ead,0x74}, -{0x8eae,0x01}, -{0x8eaf,0x93}, -{0x8eb0,0xf5}, -{0x8eb1,0x39}, -{0x8eb2,0x45}, -{0x8eb3,0x38}, -{0x8eb4,0x60}, -{0x8eb5,0x23}, -{0x8eb6,0x85}, -{0x8eb7,0x39}, -{0x8eb8,0x82}, -{0x8eb9,0x85}, -{0x8eba,0x38}, -{0x8ebb,0x83}, -{0x8ebc,0xe0}, -{0x8ebd,0xfc}, -{0x8ebe,0x12}, -{0x8ebf,0x0f}, -{0x8ec0,0xe2}, -{0x8ec1,0x74}, -{0x8ec2,0x03}, -{0x8ec3,0x93}, -{0x8ec4,0x52}, -{0x8ec5,0x04}, -{0x8ec6,0x12}, -{0x8ec7,0x0f}, -{0x8ec8,0xe2}, -{0x8ec9,0x74}, -{0x8eca,0x02}, -{0x8ecb,0x93}, -{0x8ecc,0x42}, -{0x8ecd,0x04}, -{0x8ece,0x85}, -{0x8ecf,0x39}, -{0x8ed0,0x82}, -{0x8ed1,0x85}, -{0x8ed2,0x38}, -{0x8ed3,0x83}, -{0x8ed4,0xec}, -{0x8ed5,0xf0}, -{0x8ed6,0x0d}, -{0x8ed7,0x80}, -{0x8ed8,0xc7}, -{0x8ed9,0x22}, -{0x8eda,0x78}, -{0x8edb,0xbe}, -{0x8edc,0xe6}, -{0x8edd,0xd3}, -{0x8ede,0x08}, -{0x8edf,0xff}, -{0x8ee0,0xe6}, -{0x8ee1,0x64}, -{0x8ee2,0x80}, -{0x8ee3,0xf8}, -{0x8ee4,0xef}, -{0x8ee5,0x64}, -{0x8ee6,0x80}, -{0x8ee7,0x98}, -{0x8ee8,0x22}, -{0x8ee9,0x93}, -{0x8eea,0xff}, -{0x8eeb,0x7e}, -{0x8eec,0x00}, -{0x8eed,0xe6}, -{0x8eee,0xfc}, -{0x8eef,0x08}, -{0x8ef0,0xe6}, -{0x8ef1,0xfd}, -{0x8ef2,0x12}, -{0x8ef3,0x04}, -{0x8ef4,0xc1}, -{0x8ef5,0x78}, -{0x8ef6,0xc1}, -{0x8ef7,0xe6}, -{0x8ef8,0xfc}, -{0x8ef9,0x08}, -{0x8efa,0xe6}, -{0x8efb,0xfd}, -{0x8efc,0xd3}, -{0x8efd,0xef}, -{0x8efe,0x9d}, -{0x8eff,0xee}, -{0x8f00,0x9c}, -{0x8f01,0x22}, -{0x8f02,0x78}, -{0x8f03,0xbd}, -{0x8f04,0xd3}, -{0x8f05,0xe6}, -{0x8f06,0x64}, -{0x8f07,0x80}, -{0x8f08,0x94}, -{0x8f09,0x80}, -{0x8f0a,0x22}, -{0x8f0b,0x25}, -{0x8f0c,0xe0}, -{0x8f0d,0x24}, -{0x8f0e,0x0a}, -{0x8f0f,0xf8}, -{0x8f10,0xe6}, -{0x8f11,0xfe}, -{0x8f12,0x08}, -{0x8f13,0xe6}, -{0x8f14,0xff}, -{0x8f15,0x22}, -{0x8f16,0xe5}, -{0x8f17,0x3c}, -{0x8f18,0xd3}, -{0x8f19,0x94}, -{0x8f1a,0x00}, -{0x8f1b,0x40}, -{0x8f1c,0x0b}, -{0x8f1d,0x90}, -{0x8f1e,0x0e}, -{0x8f1f,0x88}, -{0x8f20,0x12}, -{0x8f21,0x0b}, -{0x8f22,0xf1}, -{0x8f23,0x90}, -{0x8f24,0x0e}, -{0x8f25,0x86}, -{0x8f26,0x80}, -{0x8f27,0x09}, -{0x8f28,0x90}, -{0x8f29,0x0e}, -{0x8f2a,0x82}, -{0x8f2b,0x12}, -{0x8f2c,0x0b}, -{0x8f2d,0xf1}, -{0x8f2e,0x90}, -{0x8f2f,0x0e}, -{0x8f30,0x80}, -{0x8f31,0xe4}, -{0x8f32,0x93}, -{0x8f33,0xf5}, -{0x8f34,0x44}, -{0x8f35,0xa3}, -{0x8f36,0xe4}, -{0x8f37,0x93}, -{0x8f38,0xf5}, -{0x8f39,0x43}, -{0x8f3a,0xd2}, -{0x8f3b,0x06}, -{0x8f3c,0x30}, -{0x8f3d,0x06}, -{0x8f3e,0x03}, -{0x8f3f,0xd3}, -{0x8f40,0x80}, -{0x8f41,0x01}, -{0x8f42,0xc3}, -{0x8f43,0x92}, -{0x8f44,0x0e}, -{0x8f45,0x22}, -{0x8f46,0xa2}, -{0x8f47,0xaf}, -{0x8f48,0x92}, -{0x8f49,0x32}, -{0x8f4a,0xc2}, -{0x8f4b,0xaf}, -{0x8f4c,0xe5}, -{0x8f4d,0x23}, -{0x8f4e,0x45}, -{0x8f4f,0x22}, -{0x8f50,0x90}, -{0x8f51,0x0e}, -{0x8f52,0x5d}, -{0x8f53,0x60}, -{0x8f54,0x0e}, -{0x8f55,0x12}, -{0x8f56,0x0f}, -{0x8f57,0xcb}, -{0x8f58,0xe0}, -{0x8f59,0xf5}, -{0x8f5a,0x2c}, -{0x8f5b,0x12}, -{0x8f5c,0x0f}, -{0x8f5d,0xc8}, -{0x8f5e,0xe0}, -{0x8f5f,0xf5}, -{0x8f60,0x2d}, -{0x8f61,0x80}, -{0x8f62,0x0c}, -{0x8f63,0x12}, -{0x8f64,0x0f}, -{0x8f65,0xcb}, -{0x8f66,0xe5}, -{0x8f67,0x30}, -{0x8f68,0xf0}, -{0x8f69,0x12}, -{0x8f6a,0x0f}, -{0x8f6b,0xc8}, -{0x8f6c,0xe5}, -{0x8f6d,0x31}, -{0x8f6e,0xf0}, -{0x8f6f,0xa2}, -{0x8f70,0x32}, -{0x8f71,0x92}, -{0x8f72,0xaf}, -{0x8f73,0x22}, -{0x8f74,0xd2}, -{0x8f75,0x01}, -{0x8f76,0xc2}, -{0x8f77,0x02}, -{0x8f78,0xe4}, -{0x8f79,0xf5}, -{0x8f7a,0x1f}, -{0x8f7b,0xf5}, -{0x8f7c,0x1e}, -{0x8f7d,0xd2}, -{0x8f7e,0x35}, -{0x8f7f,0xd2}, -{0x8f80,0x33}, -{0x8f81,0xd2}, -{0x8f82,0x36}, -{0x8f83,0xd2}, -{0x8f84,0x01}, -{0x8f85,0xc2}, -{0x8f86,0x02}, -{0x8f87,0xf5}, -{0x8f88,0x1f}, -{0x8f89,0xf5}, -{0x8f8a,0x1e}, -{0x8f8b,0xd2}, -{0x8f8c,0x35}, -{0x8f8d,0xd2}, -{0x8f8e,0x33}, -{0x8f8f,0x22}, -{0x8f90,0xfb}, -{0x8f91,0xd3}, -{0x8f92,0xed}, -{0x8f93,0x9b}, -{0x8f94,0x74}, -{0x8f95,0x80}, -{0x8f96,0xf8}, -{0x8f97,0x6c}, -{0x8f98,0x98}, -{0x8f99,0x22}, -{0x8f9a,0x12}, -{0x8f9b,0x06}, -{0x8f9c,0x69}, -{0x8f9d,0xe5}, -{0x8f9e,0x40}, -{0x8f9f,0x2f}, -{0x8fa0,0xf5}, -{0x8fa1,0x40}, -{0x8fa2,0xe5}, -{0x8fa3,0x3f}, -{0x8fa4,0x3e}, -{0x8fa5,0xf5}, -{0x8fa6,0x3f}, -{0x8fa7,0xe5}, -{0x8fa8,0x3e}, -{0x8fa9,0x3d}, -{0x8faa,0xf5}, -{0x8fab,0x3e}, -{0x8fac,0xe5}, -{0x8fad,0x3d}, -{0x8fae,0x3c}, -{0x8faf,0xf5}, -{0x8fb0,0x3d}, -{0x8fb1,0x22}, -{0x8fb2,0xc0}, -{0x8fb3,0xe0}, -{0x8fb4,0xc0}, -{0x8fb5,0x83}, -{0x8fb6,0xc0}, -{0x8fb7,0x82}, -{0x8fb8,0x90}, -{0x8fb9,0x3f}, -{0x8fba,0x0d}, -{0x8fbb,0xe0}, -{0x8fbc,0xf5}, -{0x8fbd,0x33}, -{0x8fbe,0xe5}, -{0x8fbf,0x33}, -{0x8fc0,0xf0}, -{0x8fc1,0xd0}, -{0x8fc2,0x82}, -{0x8fc3,0xd0}, -{0x8fc4,0x83}, -{0x8fc5,0xd0}, -{0x8fc6,0xe0}, -{0x8fc7,0x32}, -{0x8fc8,0x90}, -{0x8fc9,0x0e}, -{0x8fca,0x5f}, -{0x8fcb,0xe4}, -{0x8fcc,0x93}, -{0x8fcd,0xfe}, -{0x8fce,0x74}, -{0x8fcf,0x01}, -{0x8fd0,0x93}, -{0x8fd1,0xf5}, -{0x8fd2,0x82}, -{0x8fd3,0x8e}, -{0x8fd4,0x83}, -{0x8fd5,0x22}, -{0x8fd6,0x78}, -{0x8fd7,0x7f}, -{0x8fd8,0xe4}, -{0x8fd9,0xf6}, -{0x8fda,0xd8}, -{0x8fdb,0xfd}, -{0x8fdc,0x75}, -{0x8fdd,0x81}, -{0x8fde,0xcd}, -{0x8fdf,0x02}, -{0x8fe0,0x0c}, -{0x8fe1,0x98}, -{0x8fe2,0x8f}, -{0x8fe3,0x82}, -{0x8fe4,0x8e}, -{0x8fe5,0x83}, -{0x8fe6,0x75}, -{0x8fe7,0xf0}, -{0x8fe8,0x04}, -{0x8fe9,0xed}, -{0x8fea,0x02}, -{0x8feb,0x06}, -{0x8fec,0xa5}, - -{0x3022,0x03}, -{0x3023,0x00}, -{0x3024,0x00}, -{0x3025,0x00}, -{0x3026,0x00}, -{0x3027,0x00}, -{0x3028,0x00}, -{0x3029,0x7f}, -{0x3000,0x00}, - -{0xffff,0xff}, -}; - - - - - - - +const struct sensor_reg OV5640_Auto_Focus[] PROGMEM = + { + {0x3000, 0x20}, + {0x8000, 0x02}, + {0x8001, 0x0f}, + {0x8002, 0xd6}, + {0x8003, 0x02}, + {0x8004, 0x0a}, + {0x8005, 0x39}, + {0x8006, 0xc2}, + {0x8007, 0x01}, + {0x8008, 0x22}, + {0x8009, 0x22}, + {0x800a, 0x00}, + {0x800b, 0x02}, + {0x800c, 0x0f}, + {0x800d, 0xb2}, + {0x800e, 0xe5}, + {0x800f, 0x1f}, + {0x8010, 0x70}, + {0x8011, 0x72}, + {0x8012, 0xf5}, + {0x8013, 0x1e}, + {0x8014, 0xd2}, + {0x8015, 0x35}, + {0x8016, 0xff}, + {0x8017, 0xef}, + {0x8018, 0x25}, + {0x8019, 0xe0}, + {0x801a, 0x24}, + {0x801b, 0x4e}, + {0x801c, 0xf8}, + {0x801d, 0xe4}, + {0x801e, 0xf6}, + {0x801f, 0x08}, + {0x8020, 0xf6}, + {0x8021, 0x0f}, + {0x8022, 0xbf}, + {0x8023, 0x34}, + {0x8024, 0xf2}, + {0x8025, 0x90}, + {0x8026, 0x0e}, + {0x8027, 0x93}, + {0x8028, 0xe4}, + {0x8029, 0x93}, + {0x802a, 0xff}, + {0x802b, 0xe5}, + {0x802c, 0x4b}, + {0x802d, 0xc3}, + {0x802e, 0x9f}, + {0x802f, 0x50}, + {0x8030, 0x04}, + {0x8031, 0x7f}, + {0x8032, 0x05}, + {0x8033, 0x80}, + {0x8034, 0x02}, + {0x8035, 0x7f}, + {0x8036, 0xfb}, + {0x8037, 0x78}, + {0x8038, 0xbd}, + {0x8039, 0xa6}, + {0x803a, 0x07}, + {0x803b, 0x12}, + {0x803c, 0x0f}, + {0x803d, 0x04}, + {0x803e, 0x40}, + {0x803f, 0x04}, + {0x8040, 0x7f}, + {0x8041, 0x03}, + {0x8042, 0x80}, + {0x8043, 0x02}, + {0x8044, 0x7f}, + {0x8045, 0x30}, + {0x8046, 0x78}, + {0x8047, 0xbc}, + {0x8048, 0xa6}, + {0x8049, 0x07}, + {0x804a, 0xe6}, + {0x804b, 0x18}, + {0x804c, 0xf6}, + {0x804d, 0x08}, + {0x804e, 0xe6}, + {0x804f, 0x78}, + {0x8050, 0xb9}, + {0x8051, 0xf6}, + {0x8052, 0x78}, + {0x8053, 0xbc}, + {0x8054, 0xe6}, + {0x8055, 0x78}, + {0x8056, 0xba}, + {0x8057, 0xf6}, + {0x8058, 0x78}, + {0x8059, 0xbf}, + {0x805a, 0x76}, + {0x805b, 0x33}, + {0x805c, 0xe4}, + {0x805d, 0x08}, + {0x805e, 0xf6}, + {0x805f, 0x78}, + {0x8060, 0xb8}, + {0x8061, 0x76}, + {0x8062, 0x01}, + {0x8063, 0x75}, + {0x8064, 0x4a}, + {0x8065, 0x02}, + {0x8066, 0x78}, + {0x8067, 0xb6}, + {0x8068, 0xf6}, + {0x8069, 0x08}, + {0x806a, 0xf6}, + {0x806b, 0x74}, + {0x806c, 0xff}, + {0x806d, 0x78}, + {0x806e, 0xc1}, + {0x806f, 0xf6}, + {0x8070, 0x08}, + {0x8071, 0xf6}, + {0x8072, 0x75}, + {0x8073, 0x1f}, + {0x8074, 0x01}, + {0x8075, 0x78}, + {0x8076, 0xbc}, + {0x8077, 0xe6}, + {0x8078, 0x75}, + {0x8079, 0xf0}, + {0x807a, 0x05}, + {0x807b, 0xa4}, + {0x807c, 0xf5}, + {0x807d, 0x4b}, + {0x807e, 0x12}, + {0x807f, 0x0a}, + {0x8080, 0xff}, + {0x8081, 0xc2}, + {0x8082, 0x37}, + {0x8083, 0x22}, + {0x8084, 0x78}, + {0x8085, 0xb8}, + {0x8086, 0xe6}, + {0x8087, 0xd3}, + {0x8088, 0x94}, + {0x8089, 0x00}, + {0x808a, 0x40}, + {0x808b, 0x02}, + {0x808c, 0x16}, + {0x808d, 0x22}, + {0x808e, 0xe5}, + {0x808f, 0x1f}, + {0x8090, 0xb4}, + {0x8091, 0x05}, + {0x8092, 0x23}, + {0x8093, 0xe4}, + {0x8094, 0xf5}, + {0x8095, 0x1f}, + {0x8096, 0xc2}, + {0x8097, 0x01}, + {0x8098, 0x78}, + {0x8099, 0xb6}, + {0x809a, 0xe6}, + {0x809b, 0xfe}, + {0x809c, 0x08}, + {0x809d, 0xe6}, + {0x809e, 0xff}, + {0x809f, 0x78}, + {0x80a0, 0x4e}, + {0x80a1, 0xa6}, + {0x80a2, 0x06}, + {0x80a3, 0x08}, + {0x80a4, 0xa6}, + {0x80a5, 0x07}, + {0x80a6, 0xa2}, + {0x80a7, 0x37}, + {0x80a8, 0xe4}, + {0x80a9, 0x33}, + {0x80aa, 0xf5}, + {0x80ab, 0x3c}, + {0x80ac, 0x90}, + {0x80ad, 0x30}, + {0x80ae, 0x28}, + {0x80af, 0xf0}, + {0x80b0, 0x75}, + {0x80b1, 0x1e}, + {0x80b2, 0x10}, + {0x80b3, 0xd2}, + {0x80b4, 0x35}, + {0x80b5, 0x22}, + {0x80b6, 0xe5}, + {0x80b7, 0x4b}, + {0x80b8, 0x75}, + {0x80b9, 0xf0}, + {0x80ba, 0x05}, + {0x80bb, 0x84}, + {0x80bc, 0x78}, + {0x80bd, 0xbc}, + {0x80be, 0xf6}, + {0x80bf, 0x90}, + {0x80c0, 0x0e}, + {0x80c1, 0x8c}, + {0x80c2, 0xe4}, + {0x80c3, 0x93}, + {0x80c4, 0xff}, + {0x80c5, 0x25}, + {0x80c6, 0xe0}, + {0x80c7, 0x24}, + {0x80c8, 0x0a}, + {0x80c9, 0xf8}, + {0x80ca, 0xe6}, + {0x80cb, 0xfc}, + {0x80cc, 0x08}, + {0x80cd, 0xe6}, + {0x80ce, 0xfd}, + {0x80cf, 0x78}, + {0x80d0, 0xbc}, + {0x80d1, 0xe6}, + {0x80d2, 0x25}, + {0x80d3, 0xe0}, + {0x80d4, 0x24}, + {0x80d5, 0x4e}, + {0x80d6, 0xf8}, + {0x80d7, 0xa6}, + {0x80d8, 0x04}, + {0x80d9, 0x08}, + {0x80da, 0xa6}, + {0x80db, 0x05}, + {0x80dc, 0xef}, + {0x80dd, 0x12}, + {0x80de, 0x0f}, + {0x80df, 0x0b}, + {0x80e0, 0xd3}, + {0x80e1, 0x78}, + {0x80e2, 0xb7}, + {0x80e3, 0x96}, + {0x80e4, 0xee}, + {0x80e5, 0x18}, + {0x80e6, 0x96}, + {0x80e7, 0x40}, + {0x80e8, 0x0d}, + {0x80e9, 0x78}, + {0x80ea, 0xbc}, + {0x80eb, 0xe6}, + {0x80ec, 0x78}, + {0x80ed, 0xb9}, + {0x80ee, 0xf6}, + {0x80ef, 0x78}, + {0x80f0, 0xb6}, + {0x80f1, 0xa6}, + {0x80f2, 0x06}, + {0x80f3, 0x08}, + {0x80f4, 0xa6}, + {0x80f5, 0x07}, + {0x80f6, 0x90}, + {0x80f7, 0x0e}, + {0x80f8, 0x8c}, + {0x80f9, 0xe4}, + {0x80fa, 0x93}, + {0x80fb, 0x12}, + {0x80fc, 0x0f}, + {0x80fd, 0x0b}, + {0x80fe, 0xc3}, + {0x80ff, 0x78}, + {0x8100, 0xc2}, + {0x8101, 0x96}, + {0x8102, 0xee}, + {0x8103, 0x18}, + {0x8104, 0x96}, + {0x8105, 0x50}, + {0x8106, 0x0d}, + {0x8107, 0x78}, + {0x8108, 0xbc}, + {0x8109, 0xe6}, + {0x810a, 0x78}, + {0x810b, 0xba}, + {0x810c, 0xf6}, + {0x810d, 0x78}, + {0x810e, 0xc1}, + {0x810f, 0xa6}, + {0x8110, 0x06}, + {0x8111, 0x08}, + {0x8112, 0xa6}, + {0x8113, 0x07}, + {0x8114, 0x78}, + {0x8115, 0xb6}, + {0x8116, 0xe6}, + {0x8117, 0xfe}, + {0x8118, 0x08}, + {0x8119, 0xe6}, + {0x811a, 0xc3}, + {0x811b, 0x78}, + {0x811c, 0xc2}, + {0x811d, 0x96}, + {0x811e, 0xff}, + {0x811f, 0xee}, + {0x8120, 0x18}, + {0x8121, 0x96}, + {0x8122, 0x78}, + {0x8123, 0xc3}, + {0x8124, 0xf6}, + {0x8125, 0x08}, + {0x8126, 0xa6}, + {0x8127, 0x07}, + {0x8128, 0x90}, + {0x8129, 0x0e}, + {0x812a, 0x95}, + {0x812b, 0xe4}, + {0x812c, 0x18}, + {0x812d, 0x12}, + {0x812e, 0x0e}, + {0x812f, 0xe9}, + {0x8130, 0x40}, + {0x8131, 0x02}, + {0x8132, 0xd2}, + {0x8133, 0x37}, + {0x8134, 0x78}, + {0x8135, 0xbc}, + {0x8136, 0xe6}, + {0x8137, 0x08}, + {0x8138, 0x26}, + {0x8139, 0x08}, + {0x813a, 0xf6}, + {0x813b, 0xe5}, + {0x813c, 0x1f}, + {0x813d, 0x64}, + {0x813e, 0x01}, + {0x813f, 0x70}, + {0x8140, 0x4a}, + {0x8141, 0xe6}, + {0x8142, 0xc3}, + {0x8143, 0x78}, + {0x8144, 0xc0}, + {0x8145, 0x12}, + {0x8146, 0x0e}, + {0x8147, 0xdf}, + {0x8148, 0x40}, + {0x8149, 0x05}, + {0x814a, 0x12}, + {0x814b, 0x0e}, + {0x814c, 0xda}, + {0x814d, 0x40}, + {0x814e, 0x39}, + {0x814f, 0x12}, + {0x8150, 0x0f}, + {0x8151, 0x02}, + {0x8152, 0x40}, + {0x8153, 0x04}, + {0x8154, 0x7f}, + {0x8155, 0xfe}, + {0x8156, 0x80}, + {0x8157, 0x02}, + {0x8158, 0x7f}, + {0x8159, 0x02}, + {0x815a, 0x78}, + {0x815b, 0xbd}, + {0x815c, 0xa6}, + {0x815d, 0x07}, + {0x815e, 0x78}, + {0x815f, 0xb9}, + {0x8160, 0xe6}, + {0x8161, 0x24}, + {0x8162, 0x03}, + {0x8163, 0x78}, + {0x8164, 0xbf}, + {0x8165, 0xf6}, + {0x8166, 0x78}, + {0x8167, 0xb9}, + {0x8168, 0xe6}, + {0x8169, 0x24}, + {0x816a, 0xfd}, + {0x816b, 0x78}, + {0x816c, 0xc0}, + {0x816d, 0xf6}, + {0x816e, 0x12}, + {0x816f, 0x0f}, + {0x8170, 0x02}, + {0x8171, 0x40}, + {0x8172, 0x06}, + {0x8173, 0x78}, + {0x8174, 0xc0}, + {0x8175, 0xe6}, + {0x8176, 0xff}, + {0x8177, 0x80}, + {0x8178, 0x04}, + {0x8179, 0x78}, + {0x817a, 0xbf}, + {0x817b, 0xe6}, + {0x817c, 0xff}, + {0x817d, 0x78}, + {0x817e, 0xbe}, + {0x817f, 0xa6}, + {0x8180, 0x07}, + {0x8181, 0x75}, + {0x8182, 0x1f}, + {0x8183, 0x02}, + {0x8184, 0x78}, + {0x8185, 0xb8}, + {0x8186, 0x76}, + {0x8187, 0x01}, + {0x8188, 0x02}, + {0x8189, 0x02}, + {0x818a, 0x4a}, + {0x818b, 0xe5}, + {0x818c, 0x1f}, + {0x818d, 0x64}, + {0x818e, 0x02}, + {0x818f, 0x60}, + {0x8190, 0x03}, + {0x8191, 0x02}, + {0x8192, 0x02}, + {0x8193, 0x2a}, + {0x8194, 0x78}, + {0x8195, 0xbe}, + {0x8196, 0xe6}, + {0x8197, 0xff}, + {0x8198, 0xc3}, + {0x8199, 0x78}, + {0x819a, 0xc0}, + {0x819b, 0x12}, + {0x819c, 0x0e}, + {0x819d, 0xe0}, + {0x819e, 0x40}, + {0x819f, 0x08}, + {0x81a0, 0x12}, + {0x81a1, 0x0e}, + {0x81a2, 0xda}, + {0x81a3, 0x50}, + {0x81a4, 0x03}, + {0x81a5, 0x02}, + {0x81a6, 0x02}, + {0x81a7, 0x28}, + {0x81a8, 0x12}, + {0x81a9, 0x0f}, + {0x81aa, 0x02}, + {0x81ab, 0x40}, + {0x81ac, 0x04}, + {0x81ad, 0x7f}, + {0x81ae, 0xff}, + {0x81af, 0x80}, + {0x81b0, 0x02}, + {0x81b1, 0x7f}, + {0x81b2, 0x01}, + {0x81b3, 0x78}, + {0x81b4, 0xbd}, + {0x81b5, 0xa6}, + {0x81b6, 0x07}, + {0x81b7, 0x78}, + {0x81b8, 0xb9}, + {0x81b9, 0xe6}, + {0x81ba, 0x04}, + {0x81bb, 0x78}, + {0x81bc, 0xbf}, + {0x81bd, 0xf6}, + {0x81be, 0x78}, + {0x81bf, 0xb9}, + {0x81c0, 0xe6}, + {0x81c1, 0x14}, + {0x81c2, 0x78}, + {0x81c3, 0xc0}, + {0x81c4, 0xf6}, + {0x81c5, 0x18}, + {0x81c6, 0x12}, + {0x81c7, 0x0f}, + {0x81c8, 0x04}, + {0x81c9, 0x40}, + {0x81ca, 0x04}, + {0x81cb, 0xe6}, + {0x81cc, 0xff}, + {0x81cd, 0x80}, + {0x81ce, 0x02}, + {0x81cf, 0x7f}, + {0x81d0, 0x00}, + {0x81d1, 0x78}, + {0x81d2, 0xbf}, + {0x81d3, 0xa6}, + {0x81d4, 0x07}, + {0x81d5, 0xd3}, + {0x81d6, 0x08}, + {0x81d7, 0xe6}, + {0x81d8, 0x64}, + {0x81d9, 0x80}, + {0x81da, 0x94}, + {0x81db, 0x80}, + {0x81dc, 0x40}, + {0x81dd, 0x04}, + {0x81de, 0xe6}, + {0x81df, 0xff}, + {0x81e0, 0x80}, + {0x81e1, 0x02}, + {0x81e2, 0x7f}, + {0x81e3, 0x00}, + {0x81e4, 0x78}, + {0x81e5, 0xc0}, + {0x81e6, 0xa6}, + {0x81e7, 0x07}, + {0x81e8, 0xc3}, + {0x81e9, 0x18}, + {0x81ea, 0xe6}, + {0x81eb, 0x64}, + {0x81ec, 0x80}, + {0x81ed, 0x94}, + {0x81ee, 0xb3}, + {0x81ef, 0x50}, + {0x81f0, 0x04}, + {0x81f1, 0xe6}, + {0x81f2, 0xff}, + {0x81f3, 0x80}, + {0x81f4, 0x02}, + {0x81f5, 0x7f}, + {0x81f6, 0x33}, + {0x81f7, 0x78}, + {0x81f8, 0xbf}, + {0x81f9, 0xa6}, + {0x81fa, 0x07}, + {0x81fb, 0xc3}, + {0x81fc, 0x08}, + {0x81fd, 0xe6}, + {0x81fe, 0x64}, + {0x81ff, 0x80}, + {0x8200, 0x94}, + {0x8201, 0xb3}, + {0x8202, 0x50}, + {0x8203, 0x04}, + {0x8204, 0xe6}, + {0x8205, 0xff}, + {0x8206, 0x80}, + {0x8207, 0x02}, + {0x8208, 0x7f}, + {0x8209, 0x33}, + {0x820a, 0x78}, + {0x820b, 0xc0}, + {0x820c, 0xa6}, + {0x820d, 0x07}, + {0x820e, 0x12}, + {0x820f, 0x0f}, + {0x8210, 0x02}, + {0x8211, 0x40}, + {0x8212, 0x06}, + {0x8213, 0x78}, + {0x8214, 0xc0}, + {0x8215, 0xe6}, + {0x8216, 0xff}, + {0x8217, 0x80}, + {0x8218, 0x04}, + {0x8219, 0x78}, + {0x821a, 0xbf}, + {0x821b, 0xe6}, + {0x821c, 0xff}, + {0x821d, 0x78}, + {0x821e, 0xbe}, + {0x821f, 0xa6}, + {0x8220, 0x07}, + {0x8221, 0x75}, + {0x8222, 0x1f}, + {0x8223, 0x03}, + {0x8224, 0x78}, + {0x8225, 0xb8}, + {0x8226, 0x76}, + {0x8227, 0x01}, + {0x8228, 0x80}, + {0x8229, 0x20}, + {0x822a, 0xe5}, + {0x822b, 0x1f}, + {0x822c, 0x64}, + {0x822d, 0x03}, + {0x822e, 0x70}, + {0x822f, 0x26}, + {0x8230, 0x78}, + {0x8231, 0xbe}, + {0x8232, 0xe6}, + {0x8233, 0xff}, + {0x8234, 0xc3}, + {0x8235, 0x78}, + {0x8236, 0xc0}, + {0x8237, 0x12}, + {0x8238, 0x0e}, + {0x8239, 0xe0}, + {0x823a, 0x40}, + {0x823b, 0x05}, + {0x823c, 0x12}, + {0x823d, 0x0e}, + {0x823e, 0xda}, + {0x823f, 0x40}, + {0x8240, 0x09}, + {0x8241, 0x78}, + {0x8242, 0xb9}, + {0x8243, 0xe6}, + {0x8244, 0x78}, + {0x8245, 0xbe}, + {0x8246, 0xf6}, + {0x8247, 0x75}, + {0x8248, 0x1f}, + {0x8249, 0x04}, + {0x824a, 0x78}, + {0x824b, 0xbe}, + {0x824c, 0xe6}, + {0x824d, 0x75}, + {0x824e, 0xf0}, + {0x824f, 0x05}, + {0x8250, 0xa4}, + {0x8251, 0xf5}, + {0x8252, 0x4b}, + {0x8253, 0x02}, + {0x8254, 0x0a}, + {0x8255, 0xff}, + {0x8256, 0xe5}, + {0x8257, 0x1f}, + {0x8258, 0xb4}, + {0x8259, 0x04}, + {0x825a, 0x10}, + {0x825b, 0x90}, + {0x825c, 0x0e}, + {0x825d, 0x94}, + {0x825e, 0xe4}, + {0x825f, 0x78}, + {0x8260, 0xc3}, + {0x8261, 0x12}, + {0x8262, 0x0e}, + {0x8263, 0xe9}, + {0x8264, 0x40}, + {0x8265, 0x02}, + {0x8266, 0xd2}, + {0x8267, 0x37}, + {0x8268, 0x75}, + {0x8269, 0x1f}, + {0x826a, 0x05}, + {0x826b, 0x22}, + {0x826c, 0x30}, + {0x826d, 0x01}, + {0x826e, 0x03}, + {0x826f, 0x02}, + {0x8270, 0x04}, + {0x8271, 0xc0}, + {0x8272, 0x30}, + {0x8273, 0x02}, + {0x8274, 0x03}, + {0x8275, 0x02}, + {0x8276, 0x04}, + {0x8277, 0xc0}, + {0x8278, 0x90}, + {0x8279, 0x51}, + {0x827a, 0xa5}, + {0x827b, 0xe0}, + {0x827c, 0x78}, + {0x827d, 0x93}, + {0x827e, 0xf6}, + {0x827f, 0xa3}, + {0x8280, 0xe0}, + {0x8281, 0x08}, + {0x8282, 0xf6}, + {0x8283, 0xa3}, + {0x8284, 0xe0}, + {0x8285, 0x08}, + {0x8286, 0xf6}, + {0x8287, 0xe5}, + {0x8288, 0x1f}, + {0x8289, 0x70}, + {0x828a, 0x3c}, + {0x828b, 0x75}, + {0x828c, 0x1e}, + {0x828d, 0x20}, + {0x828e, 0xd2}, + {0x828f, 0x35}, + {0x8290, 0x12}, + {0x8291, 0x0c}, + {0x8292, 0x7a}, + {0x8293, 0x78}, + {0x8294, 0x7e}, + {0x8295, 0xa6}, + {0x8296, 0x06}, + {0x8297, 0x08}, + {0x8298, 0xa6}, + {0x8299, 0x07}, + {0x829a, 0x78}, + {0x829b, 0x8b}, + {0x829c, 0xa6}, + {0x829d, 0x09}, + {0x829e, 0x18}, + {0x829f, 0x76}, + {0x82a0, 0x01}, + {0x82a1, 0x12}, + {0x82a2, 0x0c}, + {0x82a3, 0x5b}, + {0x82a4, 0x78}, + {0x82a5, 0x4e}, + {0x82a6, 0xa6}, + {0x82a7, 0x06}, + {0x82a8, 0x08}, + {0x82a9, 0xa6}, + {0x82aa, 0x07}, + {0x82ab, 0x78}, + {0x82ac, 0x8b}, + {0x82ad, 0xe6}, + {0x82ae, 0x78}, + {0x82af, 0x6e}, + {0x82b0, 0xf6}, + {0x82b1, 0x75}, + {0x82b2, 0x1f}, + {0x82b3, 0x01}, + {0x82b4, 0x78}, + {0x82b5, 0x93}, + {0x82b6, 0xe6}, + {0x82b7, 0x78}, + {0x82b8, 0x90}, + {0x82b9, 0xf6}, + {0x82ba, 0x78}, + {0x82bb, 0x94}, + {0x82bc, 0xe6}, + {0x82bd, 0x78}, + {0x82be, 0x91}, + {0x82bf, 0xf6}, + {0x82c0, 0x78}, + {0x82c1, 0x95}, + {0x82c2, 0xe6}, + {0x82c3, 0x78}, + {0x82c4, 0x92}, + {0x82c5, 0xf6}, + {0x82c6, 0x22}, + {0x82c7, 0x79}, + {0x82c8, 0x90}, + {0x82c9, 0xe7}, + {0x82ca, 0xd3}, + {0x82cb, 0x78}, + {0x82cc, 0x93}, + {0x82cd, 0x96}, + {0x82ce, 0x40}, + {0x82cf, 0x05}, + {0x82d0, 0xe7}, + {0x82d1, 0x96}, + {0x82d2, 0xff}, + {0x82d3, 0x80}, + {0x82d4, 0x08}, + {0x82d5, 0xc3}, + {0x82d6, 0x79}, + {0x82d7, 0x93}, + {0x82d8, 0xe7}, + {0x82d9, 0x78}, + {0x82da, 0x90}, + {0x82db, 0x96}, + {0x82dc, 0xff}, + {0x82dd, 0x78}, + {0x82de, 0x88}, + {0x82df, 0x76}, + {0x82e0, 0x00}, + {0x82e1, 0x08}, + {0x82e2, 0xa6}, + {0x82e3, 0x07}, + {0x82e4, 0x79}, + {0x82e5, 0x91}, + {0x82e6, 0xe7}, + {0x82e7, 0xd3}, + {0x82e8, 0x78}, + {0x82e9, 0x94}, + {0x82ea, 0x96}, + {0x82eb, 0x40}, + {0x82ec, 0x05}, + {0x82ed, 0xe7}, + {0x82ee, 0x96}, + {0x82ef, 0xff}, + {0x82f0, 0x80}, + {0x82f1, 0x08}, + {0x82f2, 0xc3}, + {0x82f3, 0x79}, + {0x82f4, 0x94}, + {0x82f5, 0xe7}, + {0x82f6, 0x78}, + {0x82f7, 0x91}, + {0x82f8, 0x96}, + {0x82f9, 0xff}, + {0x82fa, 0x12}, + {0x82fb, 0x0c}, + {0x82fc, 0x8e}, + {0x82fd, 0x79}, + {0x82fe, 0x92}, + {0x82ff, 0xe7}, + {0x8300, 0xd3}, + {0x8301, 0x78}, + {0x8302, 0x95}, + {0x8303, 0x96}, + {0x8304, 0x40}, + {0x8305, 0x05}, + {0x8306, 0xe7}, + {0x8307, 0x96}, + {0x8308, 0xff}, + {0x8309, 0x80}, + {0x830a, 0x08}, + {0x830b, 0xc3}, + {0x830c, 0x79}, + {0x830d, 0x95}, + {0x830e, 0xe7}, + {0x830f, 0x78}, + {0x8310, 0x92}, + {0x8311, 0x96}, + {0x8312, 0xff}, + {0x8313, 0x12}, + {0x8314, 0x0c}, + {0x8315, 0x8e}, + {0x8316, 0x12}, + {0x8317, 0x0c}, + {0x8318, 0x5b}, + {0x8319, 0x78}, + {0x831a, 0x8a}, + {0x831b, 0xe6}, + {0x831c, 0x25}, + {0x831d, 0xe0}, + {0x831e, 0x24}, + {0x831f, 0x4e}, + {0x8320, 0xf8}, + {0x8321, 0xa6}, + {0x8322, 0x06}, + {0x8323, 0x08}, + {0x8324, 0xa6}, + {0x8325, 0x07}, + {0x8326, 0x78}, + {0x8327, 0x8a}, + {0x8328, 0xe6}, + {0x8329, 0x24}, + {0x832a, 0x6e}, + {0x832b, 0xf8}, + {0x832c, 0xa6}, + {0x832d, 0x09}, + {0x832e, 0x78}, + {0x832f, 0x8a}, + {0x8330, 0xe6}, + {0x8331, 0x24}, + {0x8332, 0x01}, + {0x8333, 0xff}, + {0x8334, 0xe4}, + {0x8335, 0x33}, + {0x8336, 0xfe}, + {0x8337, 0xd3}, + {0x8338, 0xef}, + {0x8339, 0x94}, + {0x833a, 0x0f}, + {0x833b, 0xee}, + {0x833c, 0x64}, + {0x833d, 0x80}, + {0x833e, 0x94}, + {0x833f, 0x80}, + {0x8340, 0x40}, + {0x8341, 0x04}, + {0x8342, 0x7f}, + {0x8343, 0x00}, + {0x8344, 0x80}, + {0x8345, 0x05}, + {0x8346, 0x78}, + {0x8347, 0x8a}, + {0x8348, 0xe6}, + {0x8349, 0x04}, + {0x834a, 0xff}, + {0x834b, 0x78}, + {0x834c, 0x8a}, + {0x834d, 0xa6}, + {0x834e, 0x07}, + {0x834f, 0xe5}, + {0x8350, 0x1f}, + {0x8351, 0xb4}, + {0x8352, 0x01}, + {0x8353, 0x0a}, + {0x8354, 0xe6}, + {0x8355, 0x60}, + {0x8356, 0x03}, + {0x8357, 0x02}, + {0x8358, 0x04}, + {0x8359, 0xc0}, + {0x835a, 0x75}, + {0x835b, 0x1f}, + {0x835c, 0x02}, + {0x835d, 0x22}, + {0x835e, 0x12}, + {0x835f, 0x0c}, + {0x8360, 0x7a}, + {0x8361, 0x78}, + {0x8362, 0x80}, + {0x8363, 0xa6}, + {0x8364, 0x06}, + {0x8365, 0x08}, + {0x8366, 0xa6}, + {0x8367, 0x07}, + {0x8368, 0x12}, + {0x8369, 0x0c}, + {0x836a, 0x7a}, + {0x836b, 0x78}, + {0x836c, 0x82}, + {0x836d, 0xa6}, + {0x836e, 0x06}, + {0x836f, 0x08}, + {0x8370, 0xa6}, + {0x8371, 0x07}, + {0x8372, 0x78}, + {0x8373, 0x6e}, + {0x8374, 0xe6}, + {0x8375, 0x78}, + {0x8376, 0x8c}, + {0x8377, 0xf6}, + {0x8378, 0x78}, + {0x8379, 0x6e}, + {0x837a, 0xe6}, + {0x837b, 0x78}, + {0x837c, 0x8d}, + {0x837d, 0xf6}, + {0x837e, 0x7f}, + {0x837f, 0x01}, + {0x8380, 0xef}, + {0x8381, 0x25}, + {0x8382, 0xe0}, + {0x8383, 0x24}, + {0x8384, 0x4f}, + {0x8385, 0xf9}, + {0x8386, 0xc3}, + {0x8387, 0x78}, + {0x8388, 0x81}, + {0x8389, 0xe6}, + {0x838a, 0x97}, + {0x838b, 0x18}, + {0x838c, 0xe6}, + {0x838d, 0x19}, + {0x838e, 0x97}, + {0x838f, 0x50}, + {0x8390, 0x0a}, + {0x8391, 0x12}, + {0x8392, 0x0c}, + {0x8393, 0x82}, + {0x8394, 0x78}, + {0x8395, 0x80}, + {0x8396, 0xa6}, + {0x8397, 0x04}, + {0x8398, 0x08}, + {0x8399, 0xa6}, + {0x839a, 0x05}, + {0x839b, 0x74}, + {0x839c, 0x6e}, + {0x839d, 0x2f}, + {0x839e, 0xf9}, + {0x839f, 0x78}, + {0x83a0, 0x8c}, + {0x83a1, 0xe6}, + {0x83a2, 0xc3}, + {0x83a3, 0x97}, + {0x83a4, 0x50}, + {0x83a5, 0x08}, + {0x83a6, 0x74}, + {0x83a7, 0x6e}, + {0x83a8, 0x2f}, + {0x83a9, 0xf8}, + {0x83aa, 0xe6}, + {0x83ab, 0x78}, + {0x83ac, 0x8c}, + {0x83ad, 0xf6}, + {0x83ae, 0xef}, + {0x83af, 0x25}, + {0x83b0, 0xe0}, + {0x83b1, 0x24}, + {0x83b2, 0x4f}, + {0x83b3, 0xf9}, + {0x83b4, 0xd3}, + {0x83b5, 0x78}, + {0x83b6, 0x83}, + {0x83b7, 0xe6}, + {0x83b8, 0x97}, + {0x83b9, 0x18}, + {0x83ba, 0xe6}, + {0x83bb, 0x19}, + {0x83bc, 0x97}, + {0x83bd, 0x40}, + {0x83be, 0x0a}, + {0x83bf, 0x12}, + {0x83c0, 0x0c}, + {0x83c1, 0x82}, + {0x83c2, 0x78}, + {0x83c3, 0x82}, + {0x83c4, 0xa6}, + {0x83c5, 0x04}, + {0x83c6, 0x08}, + {0x83c7, 0xa6}, + {0x83c8, 0x05}, + {0x83c9, 0x74}, + {0x83ca, 0x6e}, + {0x83cb, 0x2f}, + {0x83cc, 0xf9}, + {0x83cd, 0x78}, + {0x83ce, 0x8d}, + {0x83cf, 0xe6}, + {0x83d0, 0xd3}, + {0x83d1, 0x97}, + {0x83d2, 0x40}, + {0x83d3, 0x08}, + {0x83d4, 0x74}, + {0x83d5, 0x6e}, + {0x83d6, 0x2f}, + {0x83d7, 0xf8}, + {0x83d8, 0xe6}, + {0x83d9, 0x78}, + {0x83da, 0x8d}, + {0x83db, 0xf6}, + {0x83dc, 0x0f}, + {0x83dd, 0xef}, + {0x83de, 0x64}, + {0x83df, 0x10}, + {0x83e0, 0x70}, + {0x83e1, 0x9e}, + {0x83e2, 0xc3}, + {0x83e3, 0x79}, + {0x83e4, 0x81}, + {0x83e5, 0xe7}, + {0x83e6, 0x78}, + {0x83e7, 0x83}, + {0x83e8, 0x96}, + {0x83e9, 0xff}, + {0x83ea, 0x19}, + {0x83eb, 0xe7}, + {0x83ec, 0x18}, + {0x83ed, 0x96}, + {0x83ee, 0x78}, + {0x83ef, 0x84}, + {0x83f0, 0xf6}, + {0x83f1, 0x08}, + {0x83f2, 0xa6}, + {0x83f3, 0x07}, + {0x83f4, 0xc3}, + {0x83f5, 0x79}, + {0x83f6, 0x8c}, + {0x83f7, 0xe7}, + {0x83f8, 0x78}, + {0x83f9, 0x8d}, + {0x83fa, 0x96}, + {0x83fb, 0x08}, + {0x83fc, 0xf6}, + {0x83fd, 0xd3}, + {0x83fe, 0x79}, + {0x83ff, 0x81}, + {0x8400, 0xe7}, + {0x8401, 0x78}, + {0x8402, 0x7f}, + {0x8403, 0x96}, + {0x8404, 0x19}, + {0x8405, 0xe7}, + {0x8406, 0x18}, + {0x8407, 0x96}, + {0x8408, 0x40}, + {0x8409, 0x05}, + {0x840a, 0x09}, + {0x840b, 0xe7}, + {0x840c, 0x08}, + {0x840d, 0x80}, + {0x840e, 0x06}, + {0x840f, 0xc3}, + {0x8410, 0x79}, + {0x8411, 0x7f}, + {0x8412, 0xe7}, + {0x8413, 0x78}, + {0x8414, 0x81}, + {0x8415, 0x96}, + {0x8416, 0xff}, + {0x8417, 0x19}, + {0x8418, 0xe7}, + {0x8419, 0x18}, + {0x841a, 0x96}, + {0x841b, 0xfe}, + {0x841c, 0x78}, + {0x841d, 0x86}, + {0x841e, 0xa6}, + {0x841f, 0x06}, + {0x8420, 0x08}, + {0x8421, 0xa6}, + {0x8422, 0x07}, + {0x8423, 0x79}, + {0x8424, 0x8c}, + {0x8425, 0xe7}, + {0x8426, 0xd3}, + {0x8427, 0x78}, + {0x8428, 0x8b}, + {0x8429, 0x96}, + {0x842a, 0x40}, + {0x842b, 0x05}, + {0x842c, 0xe7}, + {0x842d, 0x96}, + {0x842e, 0xff}, + {0x842f, 0x80}, + {0x8430, 0x08}, + {0x8431, 0xc3}, + {0x8432, 0x79}, + {0x8433, 0x8b}, + {0x8434, 0xe7}, + {0x8435, 0x78}, + {0x8436, 0x8c}, + {0x8437, 0x96}, + {0x8438, 0xff}, + {0x8439, 0x78}, + {0x843a, 0x8f}, + {0x843b, 0xa6}, + {0x843c, 0x07}, + {0x843d, 0xe5}, + {0x843e, 0x1f}, + {0x843f, 0x64}, + {0x8440, 0x02}, + {0x8441, 0x70}, + {0x8442, 0x69}, + {0x8443, 0x90}, + {0x8444, 0x0e}, + {0x8445, 0x91}, + {0x8446, 0x93}, + {0x8447, 0xff}, + {0x8448, 0x18}, + {0x8449, 0xe6}, + {0x844a, 0xc3}, + {0x844b, 0x9f}, + {0x844c, 0x50}, + {0x844d, 0x72}, + {0x844e, 0x12}, + {0x844f, 0x0c}, + {0x8450, 0x4a}, + {0x8451, 0x12}, + {0x8452, 0x0c}, + {0x8453, 0x2f}, + {0x8454, 0x90}, + {0x8455, 0x0e}, + {0x8456, 0x8e}, + {0x8457, 0x12}, + {0x8458, 0x0c}, + {0x8459, 0x38}, + {0x845a, 0x78}, + {0x845b, 0x80}, + {0x845c, 0x12}, + {0x845d, 0x0c}, + {0x845e, 0x6b}, + {0x845f, 0x7b}, + {0x8460, 0x04}, + {0x8461, 0x12}, + {0x8462, 0x0c}, + {0x8463, 0x1d}, + {0x8464, 0xc3}, + {0x8465, 0x12}, + {0x8466, 0x06}, + {0x8467, 0x45}, + {0x8468, 0x50}, + {0x8469, 0x56}, + {0x846a, 0x90}, + {0x846b, 0x0e}, + {0x846c, 0x92}, + {0x846d, 0xe4}, + {0x846e, 0x93}, + {0x846f, 0xff}, + {0x8470, 0x78}, + {0x8471, 0x8f}, + {0x8472, 0xe6}, + {0x8473, 0x9f}, + {0x8474, 0x40}, + {0x8475, 0x02}, + {0x8476, 0x80}, + {0x8477, 0x11}, + {0x8478, 0x90}, + {0x8479, 0x0e}, + {0x847a, 0x90}, + {0x847b, 0xe4}, + {0x847c, 0x93}, + {0x847d, 0xff}, + {0x847e, 0xd3}, + {0x847f, 0x78}, + {0x8480, 0x89}, + {0x8481, 0xe6}, + {0x8482, 0x9f}, + {0x8483, 0x18}, + {0x8484, 0xe6}, + {0x8485, 0x94}, + {0x8486, 0x00}, + {0x8487, 0x40}, + {0x8488, 0x03}, + {0x8489, 0x75}, + {0x848a, 0x1f}, + {0x848b, 0x05}, + {0x848c, 0x12}, + {0x848d, 0x0c}, + {0x848e, 0x4a}, + {0x848f, 0x12}, + {0x8490, 0x0c}, + {0x8491, 0x2f}, + {0x8492, 0x90}, + {0x8493, 0x0e}, + {0x8494, 0x8f}, + {0x8495, 0x12}, + {0x8496, 0x0c}, + {0x8497, 0x38}, + {0x8498, 0x78}, + {0x8499, 0x7e}, + {0x849a, 0x12}, + {0x849b, 0x0c}, + {0x849c, 0x6b}, + {0x849d, 0x7b}, + {0x849e, 0x40}, + {0x849f, 0x12}, + {0x84a0, 0x0c}, + {0x84a1, 0x1d}, + {0x84a2, 0xd3}, + {0x84a3, 0x12}, + {0x84a4, 0x06}, + {0x84a5, 0x45}, + {0x84a6, 0x40}, + {0x84a7, 0x18}, + {0x84a8, 0x75}, + {0x84a9, 0x1f}, + {0x84aa, 0x05}, + {0x84ab, 0x22}, + {0x84ac, 0xe5}, + {0x84ad, 0x1f}, + {0x84ae, 0xb4}, + {0x84af, 0x05}, + {0x84b0, 0x0f}, + {0x84b1, 0xd2}, + {0x84b2, 0x01}, + {0x84b3, 0xc2}, + {0x84b4, 0x02}, + {0x84b5, 0xe4}, + {0x84b6, 0xf5}, + {0x84b7, 0x1f}, + {0x84b8, 0xf5}, + {0x84b9, 0x1e}, + {0x84ba, 0xd2}, + {0x84bb, 0x35}, + {0x84bc, 0xd2}, + {0x84bd, 0x33}, + {0x84be, 0xd2}, + {0x84bf, 0x36}, + {0x84c0, 0x22}, + {0x84c1, 0xef}, + {0x84c2, 0x8d}, + {0x84c3, 0xf0}, + {0x84c4, 0xa4}, + {0x84c5, 0xa8}, + {0x84c6, 0xf0}, + {0x84c7, 0xcf}, + {0x84c8, 0x8c}, + {0x84c9, 0xf0}, + {0x84ca, 0xa4}, + {0x84cb, 0x28}, + {0x84cc, 0xce}, + {0x84cd, 0x8d}, + {0x84ce, 0xf0}, + {0x84cf, 0xa4}, + {0x84d0, 0x2e}, + {0x84d1, 0xfe}, + {0x84d2, 0x22}, + {0x84d3, 0xbc}, + {0x84d4, 0x00}, + {0x84d5, 0x0b}, + {0x84d6, 0xbe}, + {0x84d7, 0x00}, + {0x84d8, 0x29}, + {0x84d9, 0xef}, + {0x84da, 0x8d}, + {0x84db, 0xf0}, + {0x84dc, 0x84}, + {0x84dd, 0xff}, + {0x84de, 0xad}, + {0x84df, 0xf0}, + {0x84e0, 0x22}, + {0x84e1, 0xe4}, + {0x84e2, 0xcc}, + {0x84e3, 0xf8}, + {0x84e4, 0x75}, + {0x84e5, 0xf0}, + {0x84e6, 0x08}, + {0x84e7, 0xef}, + {0x84e8, 0x2f}, + {0x84e9, 0xff}, + {0x84ea, 0xee}, + {0x84eb, 0x33}, + {0x84ec, 0xfe}, + {0x84ed, 0xec}, + {0x84ee, 0x33}, + {0x84ef, 0xfc}, + {0x84f0, 0xee}, + {0x84f1, 0x9d}, + {0x84f2, 0xec}, + {0x84f3, 0x98}, + {0x84f4, 0x40}, + {0x84f5, 0x05}, + {0x84f6, 0xfc}, + {0x84f7, 0xee}, + {0x84f8, 0x9d}, + {0x84f9, 0xfe}, + {0x84fa, 0x0f}, + {0x84fb, 0xd5}, + {0x84fc, 0xf0}, + {0x84fd, 0xe9}, + {0x84fe, 0xe4}, + {0x84ff, 0xce}, + {0x8500, 0xfd}, + {0x8501, 0x22}, + {0x8502, 0xed}, + {0x8503, 0xf8}, + {0x8504, 0xf5}, + {0x8505, 0xf0}, + {0x8506, 0xee}, + {0x8507, 0x84}, + {0x8508, 0x20}, + {0x8509, 0xd2}, + {0x850a, 0x1c}, + {0x850b, 0xfe}, + {0x850c, 0xad}, + {0x850d, 0xf0}, + {0x850e, 0x75}, + {0x850f, 0xf0}, + {0x8510, 0x08}, + {0x8511, 0xef}, + {0x8512, 0x2f}, + {0x8513, 0xff}, + {0x8514, 0xed}, + {0x8515, 0x33}, + {0x8516, 0xfd}, + {0x8517, 0x40}, + {0x8518, 0x07}, + {0x8519, 0x98}, + {0x851a, 0x50}, + {0x851b, 0x06}, + {0x851c, 0xd5}, + {0x851d, 0xf0}, + {0x851e, 0xf2}, + {0x851f, 0x22}, + {0x8520, 0xc3}, + {0x8521, 0x98}, + {0x8522, 0xfd}, + {0x8523, 0x0f}, + {0x8524, 0xd5}, + {0x8525, 0xf0}, + {0x8526, 0xea}, + {0x8527, 0x22}, + {0x8528, 0xe8}, + {0x8529, 0x8f}, + {0x852a, 0xf0}, + {0x852b, 0xa4}, + {0x852c, 0xcc}, + {0x852d, 0x8b}, + {0x852e, 0xf0}, + {0x852f, 0xa4}, + {0x8530, 0x2c}, + {0x8531, 0xfc}, + {0x8532, 0xe9}, + {0x8533, 0x8e}, + {0x8534, 0xf0}, + {0x8535, 0xa4}, + {0x8536, 0x2c}, + {0x8537, 0xfc}, + {0x8538, 0x8a}, + {0x8539, 0xf0}, + {0x853a, 0xed}, + {0x853b, 0xa4}, + {0x853c, 0x2c}, + {0x853d, 0xfc}, + {0x853e, 0xea}, + {0x853f, 0x8e}, + {0x8540, 0xf0}, + {0x8541, 0xa4}, + {0x8542, 0xcd}, + {0x8543, 0xa8}, + {0x8544, 0xf0}, + {0x8545, 0x8b}, + {0x8546, 0xf0}, + {0x8547, 0xa4}, + {0x8548, 0x2d}, + {0x8549, 0xcc}, + {0x854a, 0x38}, + {0x854b, 0x25}, + {0x854c, 0xf0}, + {0x854d, 0xfd}, + {0x854e, 0xe9}, + {0x854f, 0x8f}, + {0x8550, 0xf0}, + {0x8551, 0xa4}, + {0x8552, 0x2c}, + {0x8553, 0xcd}, + {0x8554, 0x35}, + {0x8555, 0xf0}, + {0x8556, 0xfc}, + {0x8557, 0xeb}, + {0x8558, 0x8e}, + {0x8559, 0xf0}, + {0x855a, 0xa4}, + {0x855b, 0xfe}, + {0x855c, 0xa9}, + {0x855d, 0xf0}, + {0x855e, 0xeb}, + {0x855f, 0x8f}, + {0x8560, 0xf0}, + {0x8561, 0xa4}, + {0x8562, 0xcf}, + {0x8563, 0xc5}, + {0x8564, 0xf0}, + {0x8565, 0x2e}, + {0x8566, 0xcd}, + {0x8567, 0x39}, + {0x8568, 0xfe}, + {0x8569, 0xe4}, + {0x856a, 0x3c}, + {0x856b, 0xfc}, + {0x856c, 0xea}, + {0x856d, 0xa4}, + {0x856e, 0x2d}, + {0x856f, 0xce}, + {0x8570, 0x35}, + {0x8571, 0xf0}, + {0x8572, 0xfd}, + {0x8573, 0xe4}, + {0x8574, 0x3c}, + {0x8575, 0xfc}, + {0x8576, 0x22}, + {0x8577, 0x75}, + {0x8578, 0xf0}, + {0x8579, 0x08}, + {0x857a, 0x75}, + {0x857b, 0x82}, + {0x857c, 0x00}, + {0x857d, 0xef}, + {0x857e, 0x2f}, + {0x857f, 0xff}, + {0x8580, 0xee}, + {0x8581, 0x33}, + {0x8582, 0xfe}, + {0x8583, 0xcd}, + {0x8584, 0x33}, + {0x8585, 0xcd}, + {0x8586, 0xcc}, + {0x8587, 0x33}, + {0x8588, 0xcc}, + {0x8589, 0xc5}, + {0x858a, 0x82}, + {0x858b, 0x33}, + {0x858c, 0xc5}, + {0x858d, 0x82}, + {0x858e, 0x9b}, + {0x858f, 0xed}, + {0x8590, 0x9a}, + {0x8591, 0xec}, + {0x8592, 0x99}, + {0x8593, 0xe5}, + {0x8594, 0x82}, + {0x8595, 0x98}, + {0x8596, 0x40}, + {0x8597, 0x0c}, + {0x8598, 0xf5}, + {0x8599, 0x82}, + {0x859a, 0xee}, + {0x859b, 0x9b}, + {0x859c, 0xfe}, + {0x859d, 0xed}, + {0x859e, 0x9a}, + {0x859f, 0xfd}, + {0x85a0, 0xec}, + {0x85a1, 0x99}, + {0x85a2, 0xfc}, + {0x85a3, 0x0f}, + {0x85a4, 0xd5}, + {0x85a5, 0xf0}, + {0x85a6, 0xd6}, + {0x85a7, 0xe4}, + {0x85a8, 0xce}, + {0x85a9, 0xfb}, + {0x85aa, 0xe4}, + {0x85ab, 0xcd}, + {0x85ac, 0xfa}, + {0x85ad, 0xe4}, + {0x85ae, 0xcc}, + {0x85af, 0xf9}, + {0x85b0, 0xa8}, + {0x85b1, 0x82}, + {0x85b2, 0x22}, + {0x85b3, 0xb8}, + {0x85b4, 0x00}, + {0x85b5, 0xc1}, + {0x85b6, 0xb9}, + {0x85b7, 0x00}, + {0x85b8, 0x59}, + {0x85b9, 0xba}, + {0x85ba, 0x00}, + {0x85bb, 0x2d}, + {0x85bc, 0xec}, + {0x85bd, 0x8b}, + {0x85be, 0xf0}, + {0x85bf, 0x84}, + {0x85c0, 0xcf}, + {0x85c1, 0xce}, + {0x85c2, 0xcd}, + {0x85c3, 0xfc}, + {0x85c4, 0xe5}, + {0x85c5, 0xf0}, + {0x85c6, 0xcb}, + {0x85c7, 0xf9}, + {0x85c8, 0x78}, + {0x85c9, 0x18}, + {0x85ca, 0xef}, + {0x85cb, 0x2f}, + {0x85cc, 0xff}, + {0x85cd, 0xee}, + {0x85ce, 0x33}, + {0x85cf, 0xfe}, + {0x85d0, 0xed}, + {0x85d1, 0x33}, + {0x85d2, 0xfd}, + {0x85d3, 0xec}, + {0x85d4, 0x33}, + {0x85d5, 0xfc}, + {0x85d6, 0xeb}, + {0x85d7, 0x33}, + {0x85d8, 0xfb}, + {0x85d9, 0x10}, + {0x85da, 0xd7}, + {0x85db, 0x03}, + {0x85dc, 0x99}, + {0x85dd, 0x40}, + {0x85de, 0x04}, + {0x85df, 0xeb}, + {0x85e0, 0x99}, + {0x85e1, 0xfb}, + {0x85e2, 0x0f}, + {0x85e3, 0xd8}, + {0x85e4, 0xe5}, + {0x85e5, 0xe4}, + {0x85e6, 0xf9}, + {0x85e7, 0xfa}, + {0x85e8, 0x22}, + {0x85e9, 0x78}, + {0x85ea, 0x18}, + {0x85eb, 0xef}, + {0x85ec, 0x2f}, + {0x85ed, 0xff}, + {0x85ee, 0xee}, + {0x85ef, 0x33}, + {0x85f0, 0xfe}, + {0x85f1, 0xed}, + {0x85f2, 0x33}, + {0x85f3, 0xfd}, + {0x85f4, 0xec}, + {0x85f5, 0x33}, + {0x85f6, 0xfc}, + {0x85f7, 0xc9}, + {0x85f8, 0x33}, + {0x85f9, 0xc9}, + {0x85fa, 0x10}, + {0x85fb, 0xd7}, + {0x85fc, 0x05}, + {0x85fd, 0x9b}, + {0x85fe, 0xe9}, + {0x85ff, 0x9a}, + {0x8600, 0x40}, + {0x8601, 0x07}, + {0x8602, 0xec}, + {0x8603, 0x9b}, + {0x8604, 0xfc}, + {0x8605, 0xe9}, + {0x8606, 0x9a}, + {0x8607, 0xf9}, + {0x8608, 0x0f}, + {0x8609, 0xd8}, + {0x860a, 0xe0}, + {0x860b, 0xe4}, + {0x860c, 0xc9}, + {0x860d, 0xfa}, + {0x860e, 0xe4}, + {0x860f, 0xcc}, + {0x8610, 0xfb}, + {0x8611, 0x22}, + {0x8612, 0x75}, + {0x8613, 0xf0}, + {0x8614, 0x10}, + {0x8615, 0xef}, + {0x8616, 0x2f}, + {0x8617, 0xff}, + {0x8618, 0xee}, + {0x8619, 0x33}, + {0x861a, 0xfe}, + {0x861b, 0xed}, + {0x861c, 0x33}, + {0x861d, 0xfd}, + {0x861e, 0xcc}, + {0x861f, 0x33}, + {0x8620, 0xcc}, + {0x8621, 0xc8}, + {0x8622, 0x33}, + {0x8623, 0xc8}, + {0x8624, 0x10}, + {0x8625, 0xd7}, + {0x8626, 0x07}, + {0x8627, 0x9b}, + {0x8628, 0xec}, + {0x8629, 0x9a}, + {0x862a, 0xe8}, + {0x862b, 0x99}, + {0x862c, 0x40}, + {0x862d, 0x0a}, + {0x862e, 0xed}, + {0x862f, 0x9b}, + {0x8630, 0xfd}, + {0x8631, 0xec}, + {0x8632, 0x9a}, + {0x8633, 0xfc}, + {0x8634, 0xe8}, + {0x8635, 0x99}, + {0x8636, 0xf8}, + {0x8637, 0x0f}, + {0x8638, 0xd5}, + {0x8639, 0xf0}, + {0x863a, 0xda}, + {0x863b, 0xe4}, + {0x863c, 0xcd}, + {0x863d, 0xfb}, + {0x863e, 0xe4}, + {0x863f, 0xcc}, + {0x8640, 0xfa}, + {0x8641, 0xe4}, + {0x8642, 0xc8}, + {0x8643, 0xf9}, + {0x8644, 0x22}, + {0x8645, 0xeb}, + {0x8646, 0x9f}, + {0x8647, 0xf5}, + {0x8648, 0xf0}, + {0x8649, 0xea}, + {0x864a, 0x9e}, + {0x864b, 0x42}, + {0x864c, 0xf0}, + {0x864d, 0xe9}, + {0x864e, 0x9d}, + {0x864f, 0x42}, + {0x8650, 0xf0}, + {0x8651, 0xe8}, + {0x8652, 0x9c}, + {0x8653, 0x45}, + {0x8654, 0xf0}, + {0x8655, 0x22}, + {0x8656, 0xe8}, + {0x8657, 0x60}, + {0x8658, 0x0f}, + {0x8659, 0xec}, + {0x865a, 0xc3}, + {0x865b, 0x13}, + {0x865c, 0xfc}, + {0x865d, 0xed}, + {0x865e, 0x13}, + {0x865f, 0xfd}, + {0x8660, 0xee}, + {0x8661, 0x13}, + {0x8662, 0xfe}, + {0x8663, 0xef}, + {0x8664, 0x13}, + {0x8665, 0xff}, + {0x8666, 0xd8}, + {0x8667, 0xf1}, + {0x8668, 0x22}, + {0x8669, 0xe8}, + {0x866a, 0x60}, + {0x866b, 0x0f}, + {0x866c, 0xef}, + {0x866d, 0xc3}, + {0x866e, 0x33}, + {0x866f, 0xff}, + {0x8670, 0xee}, + {0x8671, 0x33}, + {0x8672, 0xfe}, + {0x8673, 0xed}, + {0x8674, 0x33}, + {0x8675, 0xfd}, + {0x8676, 0xec}, + {0x8677, 0x33}, + {0x8678, 0xfc}, + {0x8679, 0xd8}, + {0x867a, 0xf1}, + {0x867b, 0x22}, + {0x867c, 0xe4}, + {0x867d, 0x93}, + {0x867e, 0xfc}, + {0x867f, 0x74}, + {0x8680, 0x01}, + {0x8681, 0x93}, + {0x8682, 0xfd}, + {0x8683, 0x74}, + {0x8684, 0x02}, + {0x8685, 0x93}, + {0x8686, 0xfe}, + {0x8687, 0x74}, + {0x8688, 0x03}, + {0x8689, 0x93}, + {0x868a, 0xff}, + {0x868b, 0x22}, + {0x868c, 0xe6}, + {0x868d, 0xfb}, + {0x868e, 0x08}, + {0x868f, 0xe6}, + {0x8690, 0xf9}, + {0x8691, 0x08}, + {0x8692, 0xe6}, + {0x8693, 0xfa}, + {0x8694, 0x08}, + {0x8695, 0xe6}, + {0x8696, 0xcb}, + {0x8697, 0xf8}, + {0x8698, 0x22}, + {0x8699, 0xec}, + {0x869a, 0xf6}, + {0x869b, 0x08}, + {0x869c, 0xed}, + {0x869d, 0xf6}, + {0x869e, 0x08}, + {0x869f, 0xee}, + {0x86a0, 0xf6}, + {0x86a1, 0x08}, + {0x86a2, 0xef}, + {0x86a3, 0xf6}, + {0x86a4, 0x22}, + {0x86a5, 0xa4}, + {0x86a6, 0x25}, + {0x86a7, 0x82}, + {0x86a8, 0xf5}, + {0x86a9, 0x82}, + {0x86aa, 0xe5}, + {0x86ab, 0xf0}, + {0x86ac, 0x35}, + {0x86ad, 0x83}, + {0x86ae, 0xf5}, + {0x86af, 0x83}, + {0x86b0, 0x22}, + {0x86b1, 0xd0}, + {0x86b2, 0x83}, + {0x86b3, 0xd0}, + {0x86b4, 0x82}, + {0x86b5, 0xf8}, + {0x86b6, 0xe4}, + {0x86b7, 0x93}, + {0x86b8, 0x70}, + {0x86b9, 0x12}, + {0x86ba, 0x74}, + {0x86bb, 0x01}, + {0x86bc, 0x93}, + {0x86bd, 0x70}, + {0x86be, 0x0d}, + {0x86bf, 0xa3}, + {0x86c0, 0xa3}, + {0x86c1, 0x93}, + {0x86c2, 0xf8}, + {0x86c3, 0x74}, + {0x86c4, 0x01}, + {0x86c5, 0x93}, + {0x86c6, 0xf5}, + {0x86c7, 0x82}, + {0x86c8, 0x88}, + {0x86c9, 0x83}, + {0x86ca, 0xe4}, + {0x86cb, 0x73}, + {0x86cc, 0x74}, + {0x86cd, 0x02}, + {0x86ce, 0x93}, + {0x86cf, 0x68}, + {0x86d0, 0x60}, + {0x86d1, 0xef}, + {0x86d2, 0xa3}, + {0x86d3, 0xa3}, + {0x86d4, 0xa3}, + {0x86d5, 0x80}, + {0x86d6, 0xdf}, + {0x86d7, 0x90}, + {0x86d8, 0x38}, + {0x86d9, 0x04}, + {0x86da, 0x78}, + {0x86db, 0x52}, + {0x86dc, 0x12}, + {0x86dd, 0x0b}, + {0x86de, 0xfd}, + {0x86df, 0x90}, + {0x86e0, 0x38}, + {0x86e1, 0x00}, + {0x86e2, 0xe0}, + {0x86e3, 0xfe}, + {0x86e4, 0xa3}, + {0x86e5, 0xe0}, + {0x86e6, 0xfd}, + {0x86e7, 0xed}, + {0x86e8, 0xff}, + {0x86e9, 0xc3}, + {0x86ea, 0x12}, + {0x86eb, 0x0b}, + {0x86ec, 0x9e}, + {0x86ed, 0x90}, + {0x86ee, 0x38}, + {0x86ef, 0x10}, + {0x86f0, 0x12}, + {0x86f1, 0x0b}, + {0x86f2, 0x92}, + {0x86f3, 0x90}, + {0x86f4, 0x38}, + {0x86f5, 0x06}, + {0x86f6, 0x78}, + {0x86f7, 0x54}, + {0x86f8, 0x12}, + {0x86f9, 0x0b}, + {0x86fa, 0xfd}, + {0x86fb, 0x90}, + {0x86fc, 0x38}, + {0x86fd, 0x02}, + {0x86fe, 0xe0}, + {0x86ff, 0xfe}, + {0x8700, 0xa3}, + {0x8701, 0xe0}, + {0x8702, 0xfd}, + {0x8703, 0xed}, + {0x8704, 0xff}, + {0x8705, 0xc3}, + {0x8706, 0x12}, + {0x8707, 0x0b}, + {0x8708, 0x9e}, + {0x8709, 0x90}, + {0x870a, 0x38}, + {0x870b, 0x12}, + {0x870c, 0x12}, + {0x870d, 0x0b}, + {0x870e, 0x92}, + {0x870f, 0xa3}, + {0x8710, 0xe0}, + {0x8711, 0xb4}, + {0x8712, 0x31}, + {0x8713, 0x07}, + {0x8714, 0x78}, + {0x8715, 0x52}, + {0x8716, 0x79}, + {0x8717, 0x52}, + {0x8718, 0x12}, + {0x8719, 0x0c}, + {0x871a, 0x13}, + {0x871b, 0x90}, + {0x871c, 0x38}, + {0x871d, 0x14}, + {0x871e, 0xe0}, + {0x871f, 0xb4}, + {0x8720, 0x71}, + {0x8721, 0x15}, + {0x8722, 0x78}, + {0x8723, 0x52}, + {0x8724, 0xe6}, + {0x8725, 0xfe}, + {0x8726, 0x08}, + {0x8727, 0xe6}, + {0x8728, 0x78}, + {0x8729, 0x02}, + {0x872a, 0xce}, + {0x872b, 0xc3}, + {0x872c, 0x13}, + {0x872d, 0xce}, + {0x872e, 0x13}, + {0x872f, 0xd8}, + {0x8730, 0xf9}, + {0x8731, 0x79}, + {0x8732, 0x53}, + {0x8733, 0xf7}, + {0x8734, 0xee}, + {0x8735, 0x19}, + {0x8736, 0xf7}, + {0x8737, 0x90}, + {0x8738, 0x38}, + {0x8739, 0x15}, + {0x873a, 0xe0}, + {0x873b, 0xb4}, + {0x873c, 0x31}, + {0x873d, 0x07}, + {0x873e, 0x78}, + {0x873f, 0x54}, + {0x8740, 0x79}, + {0x8741, 0x54}, + {0x8742, 0x12}, + {0x8743, 0x0c}, + {0x8744, 0x13}, + {0x8745, 0x90}, + {0x8746, 0x38}, + {0x8747, 0x15}, + {0x8748, 0xe0}, + {0x8749, 0xb4}, + {0x874a, 0x71}, + {0x874b, 0x15}, + {0x874c, 0x78}, + {0x874d, 0x54}, + {0x874e, 0xe6}, + {0x874f, 0xfe}, + {0x8750, 0x08}, + {0x8751, 0xe6}, + {0x8752, 0x78}, + {0x8753, 0x02}, + {0x8754, 0xce}, + {0x8755, 0xc3}, + {0x8756, 0x13}, + {0x8757, 0xce}, + {0x8758, 0x13}, + {0x8759, 0xd8}, + {0x875a, 0xf9}, + {0x875b, 0x79}, + {0x875c, 0x55}, + {0x875d, 0xf7}, + {0x875e, 0xee}, + {0x875f, 0x19}, + {0x8760, 0xf7}, + {0x8761, 0x79}, + {0x8762, 0x52}, + {0x8763, 0x12}, + {0x8764, 0x0b}, + {0x8765, 0xd9}, + {0x8766, 0x09}, + {0x8767, 0x12}, + {0x8768, 0x0b}, + {0x8769, 0xd9}, + {0x876a, 0xaf}, + {0x876b, 0x47}, + {0x876c, 0x12}, + {0x876d, 0x0b}, + {0x876e, 0xb2}, + {0x876f, 0xe5}, + {0x8770, 0x44}, + {0x8771, 0xfb}, + {0x8772, 0x7a}, + {0x8773, 0x00}, + {0x8774, 0xfd}, + {0x8775, 0x7c}, + {0x8776, 0x00}, + {0x8777, 0x12}, + {0x8778, 0x04}, + {0x8779, 0xd3}, + {0x877a, 0x78}, + {0x877b, 0x5a}, + {0x877c, 0xa6}, + {0x877d, 0x06}, + {0x877e, 0x08}, + {0x877f, 0xa6}, + {0x8780, 0x07}, + {0x8781, 0xaf}, + {0x8782, 0x45}, + {0x8783, 0x12}, + {0x8784, 0x0b}, + {0x8785, 0xb2}, + {0x8786, 0xad}, + {0x8787, 0x03}, + {0x8788, 0x7c}, + {0x8789, 0x00}, + {0x878a, 0x12}, + {0x878b, 0x04}, + {0x878c, 0xd3}, + {0x878d, 0x78}, + {0x878e, 0x56}, + {0x878f, 0xa6}, + {0x8790, 0x06}, + {0x8791, 0x08}, + {0x8792, 0xa6}, + {0x8793, 0x07}, + {0x8794, 0xaf}, + {0x8795, 0x48}, + {0x8796, 0x78}, + {0x8797, 0x54}, + {0x8798, 0x12}, + {0x8799, 0x0b}, + {0x879a, 0xb4}, + {0x879b, 0xe5}, + {0x879c, 0x43}, + {0x879d, 0xfb}, + {0x879e, 0xfd}, + {0x879f, 0x7c}, + {0x87a0, 0x00}, + {0x87a1, 0x12}, + {0x87a2, 0x04}, + {0x87a3, 0xd3}, + {0x87a4, 0x78}, + {0x87a5, 0x5c}, + {0x87a6, 0xa6}, + {0x87a7, 0x06}, + {0x87a8, 0x08}, + {0x87a9, 0xa6}, + {0x87aa, 0x07}, + {0x87ab, 0xaf}, + {0x87ac, 0x46}, + {0x87ad, 0x7e}, + {0x87ae, 0x00}, + {0x87af, 0x78}, + {0x87b0, 0x54}, + {0x87b1, 0x12}, + {0x87b2, 0x0b}, + {0x87b3, 0xb6}, + {0x87b4, 0xad}, + {0x87b5, 0x03}, + {0x87b6, 0x7c}, + {0x87b7, 0x00}, + {0x87b8, 0x12}, + {0x87b9, 0x04}, + {0x87ba, 0xd3}, + {0x87bb, 0x78}, + {0x87bc, 0x58}, + {0x87bd, 0xa6}, + {0x87be, 0x06}, + {0x87bf, 0x08}, + {0x87c0, 0xa6}, + {0x87c1, 0x07}, + {0x87c2, 0xc3}, + {0x87c3, 0x78}, + {0x87c4, 0x5b}, + {0x87c5, 0xe6}, + {0x87c6, 0x94}, + {0x87c7, 0x08}, + {0x87c8, 0x18}, + {0x87c9, 0xe6}, + {0x87ca, 0x94}, + {0x87cb, 0x00}, + {0x87cc, 0x50}, + {0x87cd, 0x05}, + {0x87ce, 0x76}, + {0x87cf, 0x00}, + {0x87d0, 0x08}, + {0x87d1, 0x76}, + {0x87d2, 0x08}, + {0x87d3, 0xc3}, + {0x87d4, 0x78}, + {0x87d5, 0x5d}, + {0x87d6, 0xe6}, + {0x87d7, 0x94}, + {0x87d8, 0x08}, + {0x87d9, 0x18}, + {0x87da, 0xe6}, + {0x87db, 0x94}, + {0x87dc, 0x00}, + {0x87dd, 0x50}, + {0x87de, 0x05}, + {0x87df, 0x76}, + {0x87e0, 0x00}, + {0x87e1, 0x08}, + {0x87e2, 0x76}, + {0x87e3, 0x08}, + {0x87e4, 0x78}, + {0x87e5, 0x5a}, + {0x87e6, 0x12}, + {0x87e7, 0x0b}, + {0x87e8, 0xc6}, + {0x87e9, 0xff}, + {0x87ea, 0xd3}, + {0x87eb, 0x78}, + {0x87ec, 0x57}, + {0x87ed, 0xe6}, + {0x87ee, 0x9f}, + {0x87ef, 0x18}, + {0x87f0, 0xe6}, + {0x87f1, 0x9e}, + {0x87f2, 0x40}, + {0x87f3, 0x0e}, + {0x87f4, 0x78}, + {0x87f5, 0x5a}, + {0x87f6, 0xe6}, + {0x87f7, 0x13}, + {0x87f8, 0xfe}, + {0x87f9, 0x08}, + {0x87fa, 0xe6}, + {0x87fb, 0x78}, + {0x87fc, 0x57}, + {0x87fd, 0x12}, + {0x87fe, 0x0c}, + {0x87ff, 0x08}, + {0x8800, 0x80}, + {0x8801, 0x04}, + {0x8802, 0x7e}, + {0x8803, 0x00}, + {0x8804, 0x7f}, + {0x8805, 0x00}, + {0x8806, 0x78}, + {0x8807, 0x5e}, + {0x8808, 0x12}, + {0x8809, 0x0b}, + {0x880a, 0xbe}, + {0x880b, 0xff}, + {0x880c, 0xd3}, + {0x880d, 0x78}, + {0x880e, 0x59}, + {0x880f, 0xe6}, + {0x8810, 0x9f}, + {0x8811, 0x18}, + {0x8812, 0xe6}, + {0x8813, 0x9e}, + {0x8814, 0x40}, + {0x8815, 0x0e}, + {0x8816, 0x78}, + {0x8817, 0x5c}, + {0x8818, 0xe6}, + {0x8819, 0x13}, + {0x881a, 0xfe}, + {0x881b, 0x08}, + {0x881c, 0xe6}, + {0x881d, 0x78}, + {0x881e, 0x59}, + {0x881f, 0x12}, + {0x8820, 0x0c}, + {0x8821, 0x08}, + {0x8822, 0x80}, + {0x8823, 0x04}, + {0x8824, 0x7e}, + {0x8825, 0x00}, + {0x8826, 0x7f}, + {0x8827, 0x00}, + {0x8828, 0xe4}, + {0x8829, 0xfc}, + {0x882a, 0xfd}, + {0x882b, 0x78}, + {0x882c, 0x62}, + {0x882d, 0x12}, + {0x882e, 0x06}, + {0x882f, 0x99}, + {0x8830, 0x78}, + {0x8831, 0x5a}, + {0x8832, 0x12}, + {0x8833, 0x0b}, + {0x8834, 0xc6}, + {0x8835, 0x78}, + {0x8836, 0x57}, + {0x8837, 0x26}, + {0x8838, 0xff}, + {0x8839, 0xee}, + {0x883a, 0x18}, + {0x883b, 0x36}, + {0x883c, 0xfe}, + {0x883d, 0x78}, + {0x883e, 0x66}, + {0x883f, 0x12}, + {0x8840, 0x0b}, + {0x8841, 0xbe}, + {0x8842, 0x78}, + {0x8843, 0x59}, + {0x8844, 0x26}, + {0x8845, 0xff}, + {0x8846, 0xee}, + {0x8847, 0x18}, + {0x8848, 0x36}, + {0x8849, 0xfe}, + {0x884a, 0xe4}, + {0x884b, 0xfc}, + {0x884c, 0xfd}, + {0x884d, 0x78}, + {0x884e, 0x6a}, + {0x884f, 0x12}, + {0x8850, 0x06}, + {0x8851, 0x99}, + {0x8852, 0x12}, + {0x8853, 0x0b}, + {0x8854, 0xce}, + {0x8855, 0x78}, + {0x8856, 0x66}, + {0x8857, 0x12}, + {0x8858, 0x06}, + {0x8859, 0x8c}, + {0x885a, 0xd3}, + {0x885b, 0x12}, + {0x885c, 0x06}, + {0x885d, 0x45}, + {0x885e, 0x40}, + {0x885f, 0x08}, + {0x8860, 0x12}, + {0x8861, 0x0b}, + {0x8862, 0xce}, + {0x8863, 0x78}, + {0x8864, 0x66}, + {0x8865, 0x12}, + {0x8866, 0x06}, + {0x8867, 0x99}, + {0x8868, 0x78}, + {0x8869, 0x54}, + {0x886a, 0x12}, + {0x886b, 0x0b}, + {0x886c, 0xd0}, + {0x886d, 0x78}, + {0x886e, 0x6a}, + {0x886f, 0x12}, + {0x8870, 0x06}, + {0x8871, 0x8c}, + {0x8872, 0xd3}, + {0x8873, 0x12}, + {0x8874, 0x06}, + {0x8875, 0x45}, + {0x8876, 0x40}, + {0x8877, 0x0a}, + {0x8878, 0x78}, + {0x8879, 0x54}, + {0x887a, 0x12}, + {0x887b, 0x0b}, + {0x887c, 0xd0}, + {0x887d, 0x78}, + {0x887e, 0x6a}, + {0x887f, 0x12}, + {0x8880, 0x06}, + {0x8881, 0x99}, + {0x8882, 0x78}, + {0x8883, 0x61}, + {0x8884, 0xe6}, + {0x8885, 0x90}, + {0x8886, 0x60}, + {0x8887, 0x01}, + {0x8888, 0xf0}, + {0x8889, 0x78}, + {0x888a, 0x65}, + {0x888b, 0xe6}, + {0x888c, 0xa3}, + {0x888d, 0xf0}, + {0x888e, 0x78}, + {0x888f, 0x69}, + {0x8890, 0xe6}, + {0x8891, 0xa3}, + {0x8892, 0xf0}, + {0x8893, 0x78}, + {0x8894, 0x55}, + {0x8895, 0xe6}, + {0x8896, 0xa3}, + {0x8897, 0xf0}, + {0x8898, 0x7d}, + {0x8899, 0x01}, + {0x889a, 0x78}, + {0x889b, 0x61}, + {0x889c, 0x12}, + {0x889d, 0x0b}, + {0x889e, 0xe9}, + {0x889f, 0x24}, + {0x88a0, 0x01}, + {0x88a1, 0x12}, + {0x88a2, 0x0b}, + {0x88a3, 0xa6}, + {0x88a4, 0x78}, + {0x88a5, 0x65}, + {0x88a6, 0x12}, + {0x88a7, 0x0b}, + {0x88a8, 0xe9}, + {0x88a9, 0x24}, + {0x88aa, 0x02}, + {0x88ab, 0x12}, + {0x88ac, 0x0b}, + {0x88ad, 0xa6}, + {0x88ae, 0x78}, + {0x88af, 0x69}, + {0x88b0, 0x12}, + {0x88b1, 0x0b}, + {0x88b2, 0xe9}, + {0x88b3, 0x24}, + {0x88b4, 0x03}, + {0x88b5, 0x12}, + {0x88b6, 0x0b}, + {0x88b7, 0xa6}, + {0x88b8, 0x78}, + {0x88b9, 0x6d}, + {0x88ba, 0x12}, + {0x88bb, 0x0b}, + {0x88bc, 0xe9}, + {0x88bd, 0x24}, + {0x88be, 0x04}, + {0x88bf, 0x12}, + {0x88c0, 0x0b}, + {0x88c1, 0xa6}, + {0x88c2, 0x0d}, + {0x88c3, 0xbd}, + {0x88c4, 0x05}, + {0x88c5, 0xd4}, + {0x88c6, 0xc2}, + {0x88c7, 0x0e}, + {0x88c8, 0xc2}, + {0x88c9, 0x06}, + {0x88ca, 0x22}, + {0x88cb, 0x85}, + {0x88cc, 0x08}, + {0x88cd, 0x41}, + {0x88ce, 0x90}, + {0x88cf, 0x30}, + {0x88d0, 0x24}, + {0x88d1, 0xe0}, + {0x88d2, 0xf5}, + {0x88d3, 0x3d}, + {0x88d4, 0xa3}, + {0x88d5, 0xe0}, + {0x88d6, 0xf5}, + {0x88d7, 0x3e}, + {0x88d8, 0xa3}, + {0x88d9, 0xe0}, + {0x88da, 0xf5}, + {0x88db, 0x3f}, + {0x88dc, 0xa3}, + {0x88dd, 0xe0}, + {0x88de, 0xf5}, + {0x88df, 0x40}, + {0x88e0, 0xa3}, + {0x88e1, 0xe0}, + {0x88e2, 0xf5}, + {0x88e3, 0x3c}, + {0x88e4, 0xd2}, + {0x88e5, 0x34}, + {0x88e6, 0xe5}, + {0x88e7, 0x41}, + {0x88e8, 0x12}, + {0x88e9, 0x06}, + {0x88ea, 0xb1}, + {0x88eb, 0x09}, + {0x88ec, 0x31}, + {0x88ed, 0x03}, + {0x88ee, 0x09}, + {0x88ef, 0x35}, + {0x88f0, 0x04}, + {0x88f1, 0x09}, + {0x88f2, 0x3b}, + {0x88f3, 0x05}, + {0x88f4, 0x09}, + {0x88f5, 0x3e}, + {0x88f6, 0x06}, + {0x88f7, 0x09}, + {0x88f8, 0x41}, + {0x88f9, 0x07}, + {0x88fa, 0x09}, + {0x88fb, 0x4a}, + {0x88fc, 0x08}, + {0x88fd, 0x09}, + {0x88fe, 0x5b}, + {0x88ff, 0x12}, + {0x8900, 0x09}, + {0x8901, 0x73}, + {0x8902, 0x18}, + {0x8903, 0x09}, + {0x8904, 0x89}, + {0x8905, 0x19}, + {0x8906, 0x09}, + {0x8907, 0x5e}, + {0x8908, 0x1a}, + {0x8909, 0x09}, + {0x890a, 0x6a}, + {0x890b, 0x1b}, + {0x890c, 0x09}, + {0x890d, 0xad}, + {0x890e, 0x80}, + {0x890f, 0x09}, + {0x8910, 0xb2}, + {0x8911, 0x81}, + {0x8912, 0x0a}, + {0x8913, 0x1d}, + {0x8914, 0x8f}, + {0x8915, 0x0a}, + {0x8916, 0x09}, + {0x8917, 0x90}, + {0x8918, 0x0a}, + {0x8919, 0x1d}, + {0x891a, 0x91}, + {0x891b, 0x0a}, + {0x891c, 0x1d}, + {0x891d, 0x92}, + {0x891e, 0x0a}, + {0x891f, 0x1d}, + {0x8920, 0x93}, + {0x8921, 0x0a}, + {0x8922, 0x1d}, + {0x8923, 0x94}, + {0x8924, 0x0a}, + {0x8925, 0x1d}, + {0x8926, 0x98}, + {0x8927, 0x0a}, + {0x8928, 0x17}, + {0x8929, 0x9f}, + {0x892a, 0x0a}, + {0x892b, 0x1a}, + {0x892c, 0xec}, + {0x892d, 0x00}, + {0x892e, 0x00}, + {0x892f, 0x0a}, + {0x8930, 0x38}, + {0x8931, 0x12}, + {0x8932, 0x0f}, + {0x8933, 0x74}, + {0x8934, 0x22}, + {0x8935, 0x12}, + {0x8936, 0x0f}, + {0x8937, 0x74}, + {0x8938, 0xd2}, + {0x8939, 0x03}, + {0x893a, 0x22}, + {0x893b, 0xd2}, + {0x893c, 0x03}, + {0x893d, 0x22}, + {0x893e, 0xc2}, + {0x893f, 0x03}, + {0x8940, 0x22}, + {0x8941, 0xa2}, + {0x8942, 0x37}, + {0x8943, 0xe4}, + {0x8944, 0x33}, + {0x8945, 0xf5}, + {0x8946, 0x3c}, + {0x8947, 0x02}, + {0x8948, 0x0a}, + {0x8949, 0x1d}, + {0x894a, 0xc2}, + {0x894b, 0x01}, + {0x894c, 0xc2}, + {0x894d, 0x02}, + {0x894e, 0xc2}, + {0x894f, 0x03}, + {0x8950, 0x12}, + {0x8951, 0x0d}, + {0x8952, 0x0d}, + {0x8953, 0x75}, + {0x8954, 0x1e}, + {0x8955, 0x70}, + {0x8956, 0xd2}, + {0x8957, 0x35}, + {0x8958, 0x02}, + {0x8959, 0x0a}, + {0x895a, 0x1d}, + {0x895b, 0x02}, + {0x895c, 0x0a}, + {0x895d, 0x04}, + {0x895e, 0x85}, + {0x895f, 0x40}, + {0x8960, 0x4a}, + {0x8961, 0x85}, + {0x8962, 0x3c}, + {0x8963, 0x4b}, + {0x8964, 0x12}, + {0x8965, 0x0a}, + {0x8966, 0xff}, + {0x8967, 0x02}, + {0x8968, 0x0a}, + {0x8969, 0x1d}, + {0x896a, 0x85}, + {0x896b, 0x4a}, + {0x896c, 0x40}, + {0x896d, 0x85}, + {0x896e, 0x4b}, + {0x896f, 0x3c}, + {0x8970, 0x02}, + {0x8971, 0x0a}, + {0x8972, 0x1d}, + {0x8973, 0xe4}, + {0x8974, 0xf5}, + {0x8975, 0x22}, + {0x8976, 0xf5}, + {0x8977, 0x23}, + {0x8978, 0x85}, + {0x8979, 0x40}, + {0x897a, 0x31}, + {0x897b, 0x85}, + {0x897c, 0x3f}, + {0x897d, 0x30}, + {0x897e, 0x85}, + {0x897f, 0x3e}, + {0x8980, 0x2f}, + {0x8981, 0x85}, + {0x8982, 0x3d}, + {0x8983, 0x2e}, + {0x8984, 0x12}, + {0x8985, 0x0f}, + {0x8986, 0x46}, + {0x8987, 0x80}, + {0x8988, 0x1f}, + {0x8989, 0x75}, + {0x898a, 0x22}, + {0x898b, 0x00}, + {0x898c, 0x75}, + {0x898d, 0x23}, + {0x898e, 0x01}, + {0x898f, 0x74}, + {0x8990, 0xff}, + {0x8991, 0xf5}, + {0x8992, 0x2d}, + {0x8993, 0xf5}, + {0x8994, 0x2c}, + {0x8995, 0xf5}, + {0x8996, 0x2b}, + {0x8997, 0xf5}, + {0x8998, 0x2a}, + {0x8999, 0x12}, + {0x899a, 0x0f}, + {0x899b, 0x46}, + {0x899c, 0x85}, + {0x899d, 0x2d}, + {0x899e, 0x40}, + {0x899f, 0x85}, + {0x89a0, 0x2c}, + {0x89a1, 0x3f}, + {0x89a2, 0x85}, + {0x89a3, 0x2b}, + {0x89a4, 0x3e}, + {0x89a5, 0x85}, + {0x89a6, 0x2a}, + {0x89a7, 0x3d}, + {0x89a8, 0xe4}, + {0x89a9, 0xf5}, + {0x89aa, 0x3c}, + {0x89ab, 0x80}, + {0x89ac, 0x70}, + {0x89ad, 0x12}, + {0x89ae, 0x0f}, + {0x89af, 0x16}, + {0x89b0, 0x80}, + {0x89b1, 0x6b}, + {0x89b2, 0x85}, + {0x89b3, 0x3d}, + {0x89b4, 0x45}, + {0x89b5, 0x85}, + {0x89b6, 0x3e}, + {0x89b7, 0x46}, + {0x89b8, 0xe5}, + {0x89b9, 0x47}, + {0x89ba, 0xc3}, + {0x89bb, 0x13}, + {0x89bc, 0xff}, + {0x89bd, 0xe5}, + {0x89be, 0x45}, + {0x89bf, 0xc3}, + {0x89c0, 0x9f}, + {0x89c1, 0x50}, + {0x89c2, 0x02}, + {0x89c3, 0x8f}, + {0x89c4, 0x45}, + {0x89c5, 0xe5}, + {0x89c6, 0x48}, + {0x89c7, 0xc3}, + {0x89c8, 0x13}, + {0x89c9, 0xff}, + {0x89ca, 0xe5}, + {0x89cb, 0x46}, + {0x89cc, 0xc3}, + {0x89cd, 0x9f}, + {0x89ce, 0x50}, + {0x89cf, 0x02}, + {0x89d0, 0x8f}, + {0x89d1, 0x46}, + {0x89d2, 0xe5}, + {0x89d3, 0x47}, + {0x89d4, 0xc3}, + {0x89d5, 0x13}, + {0x89d6, 0xff}, + {0x89d7, 0xfd}, + {0x89d8, 0xe5}, + {0x89d9, 0x45}, + {0x89da, 0x2d}, + {0x89db, 0xfd}, + {0x89dc, 0xe4}, + {0x89dd, 0x33}, + {0x89de, 0xfc}, + {0x89df, 0xe5}, + {0x89e0, 0x44}, + {0x89e1, 0x12}, + {0x89e2, 0x0f}, + {0x89e3, 0x90}, + {0x89e4, 0x40}, + {0x89e5, 0x05}, + {0x89e6, 0xe5}, + {0x89e7, 0x44}, + {0x89e8, 0x9f}, + {0x89e9, 0xf5}, + {0x89ea, 0x45}, + {0x89eb, 0xe5}, + {0x89ec, 0x48}, + {0x89ed, 0xc3}, + {0x89ee, 0x13}, + {0x89ef, 0xff}, + {0x89f0, 0xfd}, + {0x89f1, 0xe5}, + {0x89f2, 0x46}, + {0x89f3, 0x2d}, + {0x89f4, 0xfd}, + {0x89f5, 0xe4}, + {0x89f6, 0x33}, + {0x89f7, 0xfc}, + {0x89f8, 0xe5}, + {0x89f9, 0x43}, + {0x89fa, 0x12}, + {0x89fb, 0x0f}, + {0x89fc, 0x90}, + {0x89fd, 0x40}, + {0x89fe, 0x05}, + {0x89ff, 0xe5}, + {0x8a00, 0x43}, + {0x8a01, 0x9f}, + {0x8a02, 0xf5}, + {0x8a03, 0x46}, + {0x8a04, 0x12}, + {0x8a05, 0x06}, + {0x8a06, 0xd7}, + {0x8a07, 0x80}, + {0x8a08, 0x14}, + {0x8a09, 0x85}, + {0x8a0a, 0x40}, + {0x8a0b, 0x48}, + {0x8a0c, 0x85}, + {0x8a0d, 0x3f}, + {0x8a0e, 0x47}, + {0x8a0f, 0x85}, + {0x8a10, 0x3e}, + {0x8a11, 0x46}, + {0x8a12, 0x85}, + {0x8a13, 0x3d}, + {0x8a14, 0x45}, + {0x8a15, 0x80}, + {0x8a16, 0x06}, + {0x8a17, 0x02}, + {0x8a18, 0x06}, + {0x8a19, 0xd7}, + {0x8a1a, 0x12}, + {0x8a1b, 0x0d}, + {0x8a1c, 0x7e}, + {0x8a1d, 0x90}, + {0x8a1e, 0x30}, + {0x8a1f, 0x24}, + {0x8a20, 0xe5}, + {0x8a21, 0x3d}, + {0x8a22, 0xf0}, + {0x8a23, 0xa3}, + {0x8a24, 0xe5}, + {0x8a25, 0x3e}, + {0x8a26, 0xf0}, + {0x8a27, 0xa3}, + {0x8a28, 0xe5}, + {0x8a29, 0x3f}, + {0x8a2a, 0xf0}, + {0x8a2b, 0xa3}, + {0x8a2c, 0xe5}, + {0x8a2d, 0x40}, + {0x8a2e, 0xf0}, + {0x8a2f, 0xa3}, + {0x8a30, 0xe5}, + {0x8a31, 0x3c}, + {0x8a32, 0xf0}, + {0x8a33, 0x90}, + {0x8a34, 0x30}, + {0x8a35, 0x23}, + {0x8a36, 0xe4}, + {0x8a37, 0xf0}, + {0x8a38, 0x22}, + {0x8a39, 0xc0}, + {0x8a3a, 0xe0}, + {0x8a3b, 0xc0}, + {0x8a3c, 0x83}, + {0x8a3d, 0xc0}, + {0x8a3e, 0x82}, + {0x8a3f, 0xc0}, + {0x8a40, 0xd0}, + {0x8a41, 0x90}, + {0x8a42, 0x3f}, + {0x8a43, 0x0c}, + {0x8a44, 0xe0}, + {0x8a45, 0xf5}, + {0x8a46, 0x32}, + {0x8a47, 0xe5}, + {0x8a48, 0x32}, + {0x8a49, 0x30}, + {0x8a4a, 0xe3}, + {0x8a4b, 0x74}, + {0x8a4c, 0x30}, + {0x8a4d, 0x36}, + {0x8a4e, 0x66}, + {0x8a4f, 0x90}, + {0x8a50, 0x60}, + {0x8a51, 0x19}, + {0x8a52, 0xe0}, + {0x8a53, 0xf5}, + {0x8a54, 0x0a}, + {0x8a55, 0xa3}, + {0x8a56, 0xe0}, + {0x8a57, 0xf5}, + {0x8a58, 0x0b}, + {0x8a59, 0x90}, + {0x8a5a, 0x60}, + {0x8a5b, 0x1d}, + {0x8a5c, 0xe0}, + {0x8a5d, 0xf5}, + {0x8a5e, 0x14}, + {0x8a5f, 0xa3}, + {0x8a60, 0xe0}, + {0x8a61, 0xf5}, + {0x8a62, 0x15}, + {0x8a63, 0x90}, + {0x8a64, 0x60}, + {0x8a65, 0x21}, + {0x8a66, 0xe0}, + {0x8a67, 0xf5}, + {0x8a68, 0x0c}, + {0x8a69, 0xa3}, + {0x8a6a, 0xe0}, + {0x8a6b, 0xf5}, + {0x8a6c, 0x0d}, + {0x8a6d, 0x90}, + {0x8a6e, 0x60}, + {0x8a6f, 0x29}, + {0x8a70, 0xe0}, + {0x8a71, 0xf5}, + {0x8a72, 0x0e}, + {0x8a73, 0xa3}, + {0x8a74, 0xe0}, + {0x8a75, 0xf5}, + {0x8a76, 0x0f}, + {0x8a77, 0x90}, + {0x8a78, 0x60}, + {0x8a79, 0x31}, + {0x8a7a, 0xe0}, + {0x8a7b, 0xf5}, + {0x8a7c, 0x10}, + {0x8a7d, 0xa3}, + {0x8a7e, 0xe0}, + {0x8a7f, 0xf5}, + {0x8a80, 0x11}, + {0x8a81, 0x90}, + {0x8a82, 0x60}, + {0x8a83, 0x39}, + {0x8a84, 0xe0}, + {0x8a85, 0xf5}, + {0x8a86, 0x12}, + {0x8a87, 0xa3}, + {0x8a88, 0xe0}, + {0x8a89, 0xf5}, + {0x8a8a, 0x13}, + {0x8a8b, 0x30}, + {0x8a8c, 0x01}, + {0x8a8d, 0x06}, + {0x8a8e, 0x30}, + {0x8a8f, 0x33}, + {0x8a90, 0x03}, + {0x8a91, 0xd3}, + {0x8a92, 0x80}, + {0x8a93, 0x01}, + {0x8a94, 0xc3}, + {0x8a95, 0x92}, + {0x8a96, 0x09}, + {0x8a97, 0x30}, + {0x8a98, 0x02}, + {0x8a99, 0x06}, + {0x8a9a, 0x30}, + {0x8a9b, 0x33}, + {0x8a9c, 0x03}, + {0x8a9d, 0xd3}, + {0x8a9e, 0x80}, + {0x8a9f, 0x01}, + {0x8aa0, 0xc3}, + {0x8aa1, 0x92}, + {0x8aa2, 0x0a}, + {0x8aa3, 0x30}, + {0x8aa4, 0x33}, + {0x8aa5, 0x0c}, + {0x8aa6, 0x30}, + {0x8aa7, 0x03}, + {0x8aa8, 0x09}, + {0x8aa9, 0x20}, + {0x8aaa, 0x02}, + {0x8aab, 0x06}, + {0x8aac, 0x20}, + {0x8aad, 0x01}, + {0x8aae, 0x03}, + {0x8aaf, 0xd3}, + {0x8ab0, 0x80}, + {0x8ab1, 0x01}, + {0x8ab2, 0xc3}, + {0x8ab3, 0x92}, + {0x8ab4, 0x0b}, + {0x8ab5, 0x90}, + {0x8ab6, 0x30}, + {0x8ab7, 0x01}, + {0x8ab8, 0xe0}, + {0x8ab9, 0x44}, + {0x8aba, 0x40}, + {0x8abb, 0xf0}, + {0x8abc, 0xe0}, + {0x8abd, 0x54}, + {0x8abe, 0xbf}, + {0x8abf, 0xf0}, + {0x8ac0, 0xe5}, + {0x8ac1, 0x32}, + {0x8ac2, 0x30}, + {0x8ac3, 0xe1}, + {0x8ac4, 0x14}, + {0x8ac5, 0x30}, + {0x8ac6, 0x34}, + {0x8ac7, 0x11}, + {0x8ac8, 0x90}, + {0x8ac9, 0x30}, + {0x8aca, 0x22}, + {0x8acb, 0xe0}, + {0x8acc, 0xf5}, + {0x8acd, 0x08}, + {0x8ace, 0xe4}, + {0x8acf, 0xf0}, + {0x8ad0, 0x30}, + {0x8ad1, 0x00}, + {0x8ad2, 0x03}, + {0x8ad3, 0xd3}, + {0x8ad4, 0x80}, + {0x8ad5, 0x01}, + {0x8ad6, 0xc3}, + {0x8ad7, 0x92}, + {0x8ad8, 0x08}, + {0x8ad9, 0xe5}, + {0x8ada, 0x32}, + {0x8adb, 0x30}, + {0x8adc, 0xe5}, + {0x8add, 0x12}, + {0x8ade, 0x90}, + {0x8adf, 0x56}, + {0x8ae0, 0xa1}, + {0x8ae1, 0xe0}, + {0x8ae2, 0xf5}, + {0x8ae3, 0x09}, + {0x8ae4, 0x30}, + {0x8ae5, 0x31}, + {0x8ae6, 0x09}, + {0x8ae7, 0x30}, + {0x8ae8, 0x05}, + {0x8ae9, 0x03}, + {0x8aea, 0xd3}, + {0x8aeb, 0x80}, + {0x8aec, 0x01}, + {0x8aed, 0xc3}, + {0x8aee, 0x92}, + {0x8aef, 0x0d}, + {0x8af0, 0x90}, + {0x8af1, 0x3f}, + {0x8af2, 0x0c}, + {0x8af3, 0xe5}, + {0x8af4, 0x32}, + {0x8af5, 0xf0}, + {0x8af6, 0xd0}, + {0x8af7, 0xd0}, + {0x8af8, 0xd0}, + {0x8af9, 0x82}, + {0x8afa, 0xd0}, + {0x8afb, 0x83}, + {0x8afc, 0xd0}, + {0x8afd, 0xe0}, + {0x8afe, 0x32}, + {0x8aff, 0x90}, + {0x8b00, 0x0e}, + {0x8b01, 0x7e}, + {0x8b02, 0xe4}, + {0x8b03, 0x93}, + {0x8b04, 0xfe}, + {0x8b05, 0x74}, + {0x8b06, 0x01}, + {0x8b07, 0x93}, + {0x8b08, 0xff}, + {0x8b09, 0xc3}, + {0x8b0a, 0x90}, + {0x8b0b, 0x0e}, + {0x8b0c, 0x7c}, + {0x8b0d, 0x74}, + {0x8b0e, 0x01}, + {0x8b0f, 0x93}, + {0x8b10, 0x9f}, + {0x8b11, 0xff}, + {0x8b12, 0xe4}, + {0x8b13, 0x93}, + {0x8b14, 0x9e}, + {0x8b15, 0xfe}, + {0x8b16, 0xe4}, + {0x8b17, 0x8f}, + {0x8b18, 0x3b}, + {0x8b19, 0x8e}, + {0x8b1a, 0x3a}, + {0x8b1b, 0xf5}, + {0x8b1c, 0x39}, + {0x8b1d, 0xf5}, + {0x8b1e, 0x38}, + {0x8b1f, 0xab}, + {0x8b20, 0x3b}, + {0x8b21, 0xaa}, + {0x8b22, 0x3a}, + {0x8b23, 0xa9}, + {0x8b24, 0x39}, + {0x8b25, 0xa8}, + {0x8b26, 0x38}, + {0x8b27, 0xaf}, + {0x8b28, 0x4b}, + {0x8b29, 0xfc}, + {0x8b2a, 0xfd}, + {0x8b2b, 0xfe}, + {0x8b2c, 0x12}, + {0x8b2d, 0x05}, + {0x8b2e, 0x28}, + {0x8b2f, 0x12}, + {0x8b30, 0x0d}, + {0x8b31, 0xe1}, + {0x8b32, 0xe4}, + {0x8b33, 0x7b}, + {0x8b34, 0xff}, + {0x8b35, 0xfa}, + {0x8b36, 0xf9}, + {0x8b37, 0xf8}, + {0x8b38, 0x12}, + {0x8b39, 0x05}, + {0x8b3a, 0xb3}, + {0x8b3b, 0x12}, + {0x8b3c, 0x0d}, + {0x8b3d, 0xe1}, + {0x8b3e, 0x90}, + {0x8b3f, 0x0e}, + {0x8b40, 0x69}, + {0x8b41, 0xe4}, + {0x8b42, 0x12}, + {0x8b43, 0x0d}, + {0x8b44, 0xf6}, + {0x8b45, 0x12}, + {0x8b46, 0x0d}, + {0x8b47, 0xe1}, + {0x8b48, 0xe4}, + {0x8b49, 0x85}, + {0x8b4a, 0x4a}, + {0x8b4b, 0x37}, + {0x8b4c, 0xf5}, + {0x8b4d, 0x36}, + {0x8b4e, 0xf5}, + {0x8b4f, 0x35}, + {0x8b50, 0xf5}, + {0x8b51, 0x34}, + {0x8b52, 0xaf}, + {0x8b53, 0x37}, + {0x8b54, 0xae}, + {0x8b55, 0x36}, + {0x8b56, 0xad}, + {0x8b57, 0x35}, + {0x8b58, 0xac}, + {0x8b59, 0x34}, + {0x8b5a, 0xa3}, + {0x8b5b, 0x12}, + {0x8b5c, 0x0d}, + {0x8b5d, 0xf6}, + {0x8b5e, 0x8f}, + {0x8b5f, 0x37}, + {0x8b60, 0x8e}, + {0x8b61, 0x36}, + {0x8b62, 0x8d}, + {0x8b63, 0x35}, + {0x8b64, 0x8c}, + {0x8b65, 0x34}, + {0x8b66, 0xe5}, + {0x8b67, 0x3b}, + {0x8b68, 0x45}, + {0x8b69, 0x37}, + {0x8b6a, 0xf5}, + {0x8b6b, 0x3b}, + {0x8b6c, 0xe5}, + {0x8b6d, 0x3a}, + {0x8b6e, 0x45}, + {0x8b6f, 0x36}, + {0x8b70, 0xf5}, + {0x8b71, 0x3a}, + {0x8b72, 0xe5}, + {0x8b73, 0x39}, + {0x8b74, 0x45}, + {0x8b75, 0x35}, + {0x8b76, 0xf5}, + {0x8b77, 0x39}, + {0x8b78, 0xe5}, + {0x8b79, 0x38}, + {0x8b7a, 0x45}, + {0x8b7b, 0x34}, + {0x8b7c, 0xf5}, + {0x8b7d, 0x38}, + {0x8b7e, 0xe4}, + {0x8b7f, 0xf5}, + {0x8b80, 0x22}, + {0x8b81, 0xf5}, + {0x8b82, 0x23}, + {0x8b83, 0x85}, + {0x8b84, 0x3b}, + {0x8b85, 0x31}, + {0x8b86, 0x85}, + {0x8b87, 0x3a}, + {0x8b88, 0x30}, + {0x8b89, 0x85}, + {0x8b8a, 0x39}, + {0x8b8b, 0x2f}, + {0x8b8c, 0x85}, + {0x8b8d, 0x38}, + {0x8b8e, 0x2e}, + {0x8b8f, 0x02}, + {0x8b90, 0x0f}, + {0x8b91, 0x46}, + {0x8b92, 0xe0}, + {0x8b93, 0xa3}, + {0x8b94, 0xe0}, + {0x8b95, 0x75}, + {0x8b96, 0xf0}, + {0x8b97, 0x02}, + {0x8b98, 0xa4}, + {0x8b99, 0xff}, + {0x8b9a, 0xae}, + {0x8b9b, 0xf0}, + {0x8b9c, 0xc3}, + {0x8b9d, 0x08}, + {0x8b9e, 0xe6}, + {0x8b9f, 0x9f}, + {0x8ba0, 0xf6}, + {0x8ba1, 0x18}, + {0x8ba2, 0xe6}, + {0x8ba3, 0x9e}, + {0x8ba4, 0xf6}, + {0x8ba5, 0x22}, + {0x8ba6, 0xff}, + {0x8ba7, 0xe5}, + {0x8ba8, 0xf0}, + {0x8ba9, 0x34}, + {0x8baa, 0x60}, + {0x8bab, 0x8f}, + {0x8bac, 0x82}, + {0x8bad, 0xf5}, + {0x8bae, 0x83}, + {0x8baf, 0xec}, + {0x8bb0, 0xf0}, + {0x8bb1, 0x22}, + {0x8bb2, 0x78}, + {0x8bb3, 0x52}, + {0x8bb4, 0x7e}, + {0x8bb5, 0x00}, + {0x8bb6, 0xe6}, + {0x8bb7, 0xfc}, + {0x8bb8, 0x08}, + {0x8bb9, 0xe6}, + {0x8bba, 0xfd}, + {0x8bbb, 0x02}, + {0x8bbc, 0x04}, + {0x8bbd, 0xc1}, + {0x8bbe, 0xe4}, + {0x8bbf, 0xfc}, + {0x8bc0, 0xfd}, + {0x8bc1, 0x12}, + {0x8bc2, 0x06}, + {0x8bc3, 0x99}, + {0x8bc4, 0x78}, + {0x8bc5, 0x5c}, + {0x8bc6, 0xe6}, + {0x8bc7, 0xc3}, + {0x8bc8, 0x13}, + {0x8bc9, 0xfe}, + {0x8bca, 0x08}, + {0x8bcb, 0xe6}, + {0x8bcc, 0x13}, + {0x8bcd, 0x22}, + {0x8bce, 0x78}, + {0x8bcf, 0x52}, + {0x8bd0, 0xe6}, + {0x8bd1, 0xfe}, + {0x8bd2, 0x08}, + {0x8bd3, 0xe6}, + {0x8bd4, 0xff}, + {0x8bd5, 0xe4}, + {0x8bd6, 0xfc}, + {0x8bd7, 0xfd}, + {0x8bd8, 0x22}, + {0x8bd9, 0xe7}, + {0x8bda, 0xc4}, + {0x8bdb, 0xf8}, + {0x8bdc, 0x54}, + {0x8bdd, 0xf0}, + {0x8bde, 0xc8}, + {0x8bdf, 0x68}, + {0x8be0, 0xf7}, + {0x8be1, 0x09}, + {0x8be2, 0xe7}, + {0x8be3, 0xc4}, + {0x8be4, 0x54}, + {0x8be5, 0x0f}, + {0x8be6, 0x48}, + {0x8be7, 0xf7}, + {0x8be8, 0x22}, + {0x8be9, 0xe6}, + {0x8bea, 0xfc}, + {0x8beb, 0xed}, + {0x8bec, 0x75}, + {0x8bed, 0xf0}, + {0x8bee, 0x04}, + {0x8bef, 0xa4}, + {0x8bf0, 0x22}, + {0x8bf1, 0x12}, + {0x8bf2, 0x06}, + {0x8bf3, 0x7c}, + {0x8bf4, 0x8f}, + {0x8bf5, 0x48}, + {0x8bf6, 0x8e}, + {0x8bf7, 0x47}, + {0x8bf8, 0x8d}, + {0x8bf9, 0x46}, + {0x8bfa, 0x8c}, + {0x8bfb, 0x45}, + {0x8bfc, 0x22}, + {0x8bfd, 0xe0}, + {0x8bfe, 0xfe}, + {0x8bff, 0xa3}, + {0x8c00, 0xe0}, + {0x8c01, 0xfd}, + {0x8c02, 0xee}, + {0x8c03, 0xf6}, + {0x8c04, 0xed}, + {0x8c05, 0x08}, + {0x8c06, 0xf6}, + {0x8c07, 0x22}, + {0x8c08, 0x13}, + {0x8c09, 0xff}, + {0x8c0a, 0xc3}, + {0x8c0b, 0xe6}, + {0x8c0c, 0x9f}, + {0x8c0d, 0xff}, + {0x8c0e, 0x18}, + {0x8c0f, 0xe6}, + {0x8c10, 0x9e}, + {0x8c11, 0xfe}, + {0x8c12, 0x22}, + {0x8c13, 0xe6}, + {0x8c14, 0xc3}, + {0x8c15, 0x13}, + {0x8c16, 0xf7}, + {0x8c17, 0x08}, + {0x8c18, 0xe6}, + {0x8c19, 0x13}, + {0x8c1a, 0x09}, + {0x8c1b, 0xf7}, + {0x8c1c, 0x22}, + {0x8c1d, 0xad}, + {0x8c1e, 0x39}, + {0x8c1f, 0xac}, + {0x8c20, 0x38}, + {0x8c21, 0xfa}, + {0x8c22, 0xf9}, + {0x8c23, 0xf8}, + {0x8c24, 0x12}, + {0x8c25, 0x05}, + {0x8c26, 0x28}, + {0x8c27, 0x8f}, + {0x8c28, 0x3b}, + {0x8c29, 0x8e}, + {0x8c2a, 0x3a}, + {0x8c2b, 0x8d}, + {0x8c2c, 0x39}, + {0x8c2d, 0x8c}, + {0x8c2e, 0x38}, + {0x8c2f, 0xab}, + {0x8c30, 0x37}, + {0x8c31, 0xaa}, + {0x8c32, 0x36}, + {0x8c33, 0xa9}, + {0x8c34, 0x35}, + {0x8c35, 0xa8}, + {0x8c36, 0x34}, + {0x8c37, 0x22}, + {0x8c38, 0x93}, + {0x8c39, 0xff}, + {0x8c3a, 0xe4}, + {0x8c3b, 0xfc}, + {0x8c3c, 0xfd}, + {0x8c3d, 0xfe}, + {0x8c3e, 0x12}, + {0x8c3f, 0x05}, + {0x8c40, 0x28}, + {0x8c41, 0x8f}, + {0x8c42, 0x37}, + {0x8c43, 0x8e}, + {0x8c44, 0x36}, + {0x8c45, 0x8d}, + {0x8c46, 0x35}, + {0x8c47, 0x8c}, + {0x8c48, 0x34}, + {0x8c49, 0x22}, + {0x8c4a, 0x78}, + {0x8c4b, 0x84}, + {0x8c4c, 0xe6}, + {0x8c4d, 0xfe}, + {0x8c4e, 0x08}, + {0x8c4f, 0xe6}, + {0x8c50, 0xff}, + {0x8c51, 0xe4}, + {0x8c52, 0x8f}, + {0x8c53, 0x37}, + {0x8c54, 0x8e}, + {0x8c55, 0x36}, + {0x8c56, 0xf5}, + {0x8c57, 0x35}, + {0x8c58, 0xf5}, + {0x8c59, 0x34}, + {0x8c5a, 0x22}, + {0x8c5b, 0x90}, + {0x8c5c, 0x0e}, + {0x8c5d, 0x8c}, + {0x8c5e, 0xe4}, + {0x8c5f, 0x93}, + {0x8c60, 0x25}, + {0x8c61, 0xe0}, + {0x8c62, 0x24}, + {0x8c63, 0x0a}, + {0x8c64, 0xf8}, + {0x8c65, 0xe6}, + {0x8c66, 0xfe}, + {0x8c67, 0x08}, + {0x8c68, 0xe6}, + {0x8c69, 0xff}, + {0x8c6a, 0x22}, + {0x8c6b, 0xe6}, + {0x8c6c, 0xfe}, + {0x8c6d, 0x08}, + {0x8c6e, 0xe6}, + {0x8c6f, 0xff}, + {0x8c70, 0xe4}, + {0x8c71, 0x8f}, + {0x8c72, 0x3b}, + {0x8c73, 0x8e}, + {0x8c74, 0x3a}, + {0x8c75, 0xf5}, + {0x8c76, 0x39}, + {0x8c77, 0xf5}, + {0x8c78, 0x38}, + {0x8c79, 0x22}, + {0x8c7a, 0x78}, + {0x8c7b, 0x4e}, + {0x8c7c, 0xe6}, + {0x8c7d, 0xfe}, + {0x8c7e, 0x08}, + {0x8c7f, 0xe6}, + {0x8c80, 0xff}, + {0x8c81, 0x22}, + {0x8c82, 0xef}, + {0x8c83, 0x25}, + {0x8c84, 0xe0}, + {0x8c85, 0x24}, + {0x8c86, 0x4e}, + {0x8c87, 0xf8}, + {0x8c88, 0xe6}, + {0x8c89, 0xfc}, + {0x8c8a, 0x08}, + {0x8c8b, 0xe6}, + {0x8c8c, 0xfd}, + {0x8c8d, 0x22}, + {0x8c8e, 0x78}, + {0x8c8f, 0x89}, + {0x8c90, 0xef}, + {0x8c91, 0x26}, + {0x8c92, 0xf6}, + {0x8c93, 0x18}, + {0x8c94, 0xe4}, + {0x8c95, 0x36}, + {0x8c96, 0xf6}, + {0x8c97, 0x22}, + {0x8c98, 0x75}, + {0x8c99, 0x89}, + {0x8c9a, 0x03}, + {0x8c9b, 0x75}, + {0x8c9c, 0xa8}, + {0x8c9d, 0x01}, + {0x8c9e, 0x75}, + {0x8c9f, 0xb8}, + {0x8ca0, 0x04}, + {0x8ca1, 0x75}, + {0x8ca2, 0x34}, + {0x8ca3, 0xff}, + {0x8ca4, 0x75}, + {0x8ca5, 0x35}, + {0x8ca6, 0x0e}, + {0x8ca7, 0x75}, + {0x8ca8, 0x36}, + {0x8ca9, 0x15}, + {0x8caa, 0x75}, + {0x8cab, 0x37}, + {0x8cac, 0x0d}, + {0x8cad, 0x12}, + {0x8cae, 0x0e}, + {0x8caf, 0x9a}, + {0x8cb0, 0x12}, + {0x8cb1, 0x00}, + {0x8cb2, 0x09}, + {0x8cb3, 0x12}, + {0x8cb4, 0x0f}, + {0x8cb5, 0x16}, + {0x8cb6, 0x12}, + {0x8cb7, 0x00}, + {0x8cb8, 0x06}, + {0x8cb9, 0xd2}, + {0x8cba, 0x00}, + {0x8cbb, 0xd2}, + {0x8cbc, 0x34}, + {0x8cbd, 0xd2}, + {0x8cbe, 0xaf}, + {0x8cbf, 0x75}, + {0x8cc0, 0x34}, + {0x8cc1, 0xff}, + {0x8cc2, 0x75}, + {0x8cc3, 0x35}, + {0x8cc4, 0x0e}, + {0x8cc5, 0x75}, + {0x8cc6, 0x36}, + {0x8cc7, 0x49}, + {0x8cc8, 0x75}, + {0x8cc9, 0x37}, + {0x8cca, 0x03}, + {0x8ccb, 0x12}, + {0x8ccc, 0x0e}, + {0x8ccd, 0x9a}, + {0x8cce, 0x30}, + {0x8ccf, 0x08}, + {0x8cd0, 0x09}, + {0x8cd1, 0xc2}, + {0x8cd2, 0x34}, + {0x8cd3, 0x12}, + {0x8cd4, 0x08}, + {0x8cd5, 0xcb}, + {0x8cd6, 0xc2}, + {0x8cd7, 0x08}, + {0x8cd8, 0xd2}, + {0x8cd9, 0x34}, + {0x8cda, 0x30}, + {0x8cdb, 0x0b}, + {0x8cdc, 0x09}, + {0x8cdd, 0xc2}, + {0x8cde, 0x36}, + {0x8cdf, 0x12}, + {0x8ce0, 0x02}, + {0x8ce1, 0x6c}, + {0x8ce2, 0xc2}, + {0x8ce3, 0x0b}, + {0x8ce4, 0xd2}, + {0x8ce5, 0x36}, + {0x8ce6, 0x30}, + {0x8ce7, 0x09}, + {0x8ce8, 0x09}, + {0x8ce9, 0xc2}, + {0x8cea, 0x36}, + {0x8ceb, 0x12}, + {0x8cec, 0x00}, + {0x8ced, 0x0e}, + {0x8cee, 0xc2}, + {0x8cef, 0x09}, + {0x8cf0, 0xd2}, + {0x8cf1, 0x36}, + {0x8cf2, 0x30}, + {0x8cf3, 0x0e}, + {0x8cf4, 0x03}, + {0x8cf5, 0x12}, + {0x8cf6, 0x06}, + {0x8cf7, 0xd7}, + {0x8cf8, 0x30}, + {0x8cf9, 0x35}, + {0x8cfa, 0xd3}, + {0x8cfb, 0x90}, + {0x8cfc, 0x30}, + {0x8cfd, 0x29}, + {0x8cfe, 0xe5}, + {0x8cff, 0x1e}, + {0x8d00, 0xf0}, + {0x8d01, 0xb4}, + {0x8d02, 0x10}, + {0x8d03, 0x05}, + {0x8d04, 0x90}, + {0x8d05, 0x30}, + {0x8d06, 0x23}, + {0x8d07, 0xe4}, + {0x8d08, 0xf0}, + {0x8d09, 0xc2}, + {0x8d0a, 0x35}, + {0x8d0b, 0x80}, + {0x8d0c, 0xc1}, + {0x8d0d, 0xe4}, + {0x8d0e, 0xf5}, + {0x8d0f, 0x4b}, + {0x8d10, 0x90}, + {0x8d11, 0x0e}, + {0x8d12, 0x7a}, + {0x8d13, 0x93}, + {0x8d14, 0xff}, + {0x8d15, 0xe4}, + {0x8d16, 0x8f}, + {0x8d17, 0x37}, + {0x8d18, 0xf5}, + {0x8d19, 0x36}, + {0x8d1a, 0xf5}, + {0x8d1b, 0x35}, + {0x8d1c, 0xf5}, + {0x8d1d, 0x34}, + {0x8d1e, 0xaf}, + {0x8d1f, 0x37}, + {0x8d20, 0xae}, + {0x8d21, 0x36}, + {0x8d22, 0xad}, + {0x8d23, 0x35}, + {0x8d24, 0xac}, + {0x8d25, 0x34}, + {0x8d26, 0x90}, + {0x8d27, 0x0e}, + {0x8d28, 0x6a}, + {0x8d29, 0x12}, + {0x8d2a, 0x0d}, + {0x8d2b, 0xf6}, + {0x8d2c, 0x8f}, + {0x8d2d, 0x37}, + {0x8d2e, 0x8e}, + {0x8d2f, 0x36}, + {0x8d30, 0x8d}, + {0x8d31, 0x35}, + {0x8d32, 0x8c}, + {0x8d33, 0x34}, + {0x8d34, 0x90}, + {0x8d35, 0x0e}, + {0x8d36, 0x72}, + {0x8d37, 0x12}, + {0x8d38, 0x06}, + {0x8d39, 0x7c}, + {0x8d3a, 0xef}, + {0x8d3b, 0x45}, + {0x8d3c, 0x37}, + {0x8d3d, 0xf5}, + {0x8d3e, 0x37}, + {0x8d3f, 0xee}, + {0x8d40, 0x45}, + {0x8d41, 0x36}, + {0x8d42, 0xf5}, + {0x8d43, 0x36}, + {0x8d44, 0xed}, + {0x8d45, 0x45}, + {0x8d46, 0x35}, + {0x8d47, 0xf5}, + {0x8d48, 0x35}, + {0x8d49, 0xec}, + {0x8d4a, 0x45}, + {0x8d4b, 0x34}, + {0x8d4c, 0xf5}, + {0x8d4d, 0x34}, + {0x8d4e, 0xe4}, + {0x8d4f, 0xf5}, + {0x8d50, 0x22}, + {0x8d51, 0xf5}, + {0x8d52, 0x23}, + {0x8d53, 0x85}, + {0x8d54, 0x37}, + {0x8d55, 0x31}, + {0x8d56, 0x85}, + {0x8d57, 0x36}, + {0x8d58, 0x30}, + {0x8d59, 0x85}, + {0x8d5a, 0x35}, + {0x8d5b, 0x2f}, + {0x8d5c, 0x85}, + {0x8d5d, 0x34}, + {0x8d5e, 0x2e}, + {0x8d5f, 0x12}, + {0x8d60, 0x0f}, + {0x8d61, 0x46}, + {0x8d62, 0xe4}, + {0x8d63, 0xf5}, + {0x8d64, 0x22}, + {0x8d65, 0xf5}, + {0x8d66, 0x23}, + {0x8d67, 0x90}, + {0x8d68, 0x0e}, + {0x8d69, 0x72}, + {0x8d6a, 0x12}, + {0x8d6b, 0x0d}, + {0x8d6c, 0xea}, + {0x8d6d, 0x12}, + {0x8d6e, 0x0f}, + {0x8d6f, 0x46}, + {0x8d70, 0xe4}, + {0x8d71, 0xf5}, + {0x8d72, 0x22}, + {0x8d73, 0xf5}, + {0x8d74, 0x23}, + {0x8d75, 0x90}, + {0x8d76, 0x0e}, + {0x8d77, 0x6e}, + {0x8d78, 0x12}, + {0x8d79, 0x0d}, + {0x8d7a, 0xea}, + {0x8d7b, 0x02}, + {0x8d7c, 0x0f}, + {0x8d7d, 0x46}, + {0x8d7e, 0xe5}, + {0x8d7f, 0x40}, + {0x8d80, 0x24}, + {0x8d81, 0xf2}, + {0x8d82, 0xf5}, + {0x8d83, 0x37}, + {0x8d84, 0xe5}, + {0x8d85, 0x3f}, + {0x8d86, 0x34}, + {0x8d87, 0x43}, + {0x8d88, 0xf5}, + {0x8d89, 0x36}, + {0x8d8a, 0xe5}, + {0x8d8b, 0x3e}, + {0x8d8c, 0x34}, + {0x8d8d, 0xa2}, + {0x8d8e, 0xf5}, + {0x8d8f, 0x35}, + {0x8d90, 0xe5}, + {0x8d91, 0x3d}, + {0x8d92, 0x34}, + {0x8d93, 0x28}, + {0x8d94, 0xf5}, + {0x8d95, 0x34}, + {0x8d96, 0xe5}, + {0x8d97, 0x37}, + {0x8d98, 0xff}, + {0x8d99, 0xe4}, + {0x8d9a, 0xfe}, + {0x8d9b, 0xfd}, + {0x8d9c, 0xfc}, + {0x8d9d, 0x78}, + {0x8d9e, 0x18}, + {0x8d9f, 0x12}, + {0x8da0, 0x06}, + {0x8da1, 0x69}, + {0x8da2, 0x8f}, + {0x8da3, 0x40}, + {0x8da4, 0x8e}, + {0x8da5, 0x3f}, + {0x8da6, 0x8d}, + {0x8da7, 0x3e}, + {0x8da8, 0x8c}, + {0x8da9, 0x3d}, + {0x8daa, 0xe5}, + {0x8dab, 0x37}, + {0x8dac, 0x54}, + {0x8dad, 0xa0}, + {0x8dae, 0xff}, + {0x8daf, 0xe5}, + {0x8db0, 0x36}, + {0x8db1, 0xfe}, + {0x8db2, 0xe4}, + {0x8db3, 0xfd}, + {0x8db4, 0xfc}, + {0x8db5, 0x78}, + {0x8db6, 0x07}, + {0x8db7, 0x12}, + {0x8db8, 0x06}, + {0x8db9, 0x56}, + {0x8dba, 0x78}, + {0x8dbb, 0x10}, + {0x8dbc, 0x12}, + {0x8dbd, 0x0f}, + {0x8dbe, 0x9a}, + {0x8dbf, 0xe4}, + {0x8dc0, 0xff}, + {0x8dc1, 0xfe}, + {0x8dc2, 0xe5}, + {0x8dc3, 0x35}, + {0x8dc4, 0xfd}, + {0x8dc5, 0xe4}, + {0x8dc6, 0xfc}, + {0x8dc7, 0x78}, + {0x8dc8, 0x0e}, + {0x8dc9, 0x12}, + {0x8dca, 0x06}, + {0x8dcb, 0x56}, + {0x8dcc, 0x12}, + {0x8dcd, 0x0f}, + {0x8dce, 0x9d}, + {0x8dcf, 0xe4}, + {0x8dd0, 0xff}, + {0x8dd1, 0xfe}, + {0x8dd2, 0xfd}, + {0x8dd3, 0xe5}, + {0x8dd4, 0x34}, + {0x8dd5, 0xfc}, + {0x8dd6, 0x78}, + {0x8dd7, 0x18}, + {0x8dd8, 0x12}, + {0x8dd9, 0x06}, + {0x8dda, 0x56}, + {0x8ddb, 0x78}, + {0x8ddc, 0x08}, + {0x8ddd, 0x12}, + {0x8dde, 0x0f}, + {0x8ddf, 0x9a}, + {0x8de0, 0x22}, + {0x8de1, 0x8f}, + {0x8de2, 0x3b}, + {0x8de3, 0x8e}, + {0x8de4, 0x3a}, + {0x8de5, 0x8d}, + {0x8de6, 0x39}, + {0x8de7, 0x8c}, + {0x8de8, 0x38}, + {0x8de9, 0x22}, + {0x8dea, 0x12}, + {0x8deb, 0x06}, + {0x8dec, 0x7c}, + {0x8ded, 0x8f}, + {0x8dee, 0x31}, + {0x8def, 0x8e}, + {0x8df0, 0x30}, + {0x8df1, 0x8d}, + {0x8df2, 0x2f}, + {0x8df3, 0x8c}, + {0x8df4, 0x2e}, + {0x8df5, 0x22}, + {0x8df6, 0x93}, + {0x8df7, 0xf9}, + {0x8df8, 0xf8}, + {0x8df9, 0x02}, + {0x8dfa, 0x06}, + {0x8dfb, 0x69}, + {0x8dfc, 0x00}, + {0x8dfd, 0x00}, + {0x8dfe, 0x00}, + {0x8dff, 0x00}, + {0x8e00, 0x12}, + {0x8e01, 0x01}, + {0x8e02, 0x17}, + {0x8e03, 0x08}, + {0x8e04, 0x31}, + {0x8e05, 0x15}, + {0x8e06, 0x53}, + {0x8e07, 0x54}, + {0x8e08, 0x44}, + {0x8e09, 0x20}, + {0x8e0a, 0x20}, + {0x8e0b, 0x20}, + {0x8e0c, 0x20}, + {0x8e0d, 0x20}, + {0x8e0e, 0x13}, + {0x8e0f, 0x01}, + {0x8e10, 0x10}, + {0x8e11, 0x01}, + {0x8e12, 0x56}, + {0x8e13, 0x40}, + {0x8e14, 0x1a}, + {0x8e15, 0x30}, + {0x8e16, 0x29}, + {0x8e17, 0x7e}, + {0x8e18, 0x00}, + {0x8e19, 0x30}, + {0x8e1a, 0x04}, + {0x8e1b, 0x20}, + {0x8e1c, 0xdf}, + {0x8e1d, 0x30}, + {0x8e1e, 0x05}, + {0x8e1f, 0x40}, + {0x8e20, 0xbf}, + {0x8e21, 0x50}, + {0x8e22, 0x03}, + {0x8e23, 0x00}, + {0x8e24, 0xfd}, + {0x8e25, 0x50}, + {0x8e26, 0x27}, + {0x8e27, 0x01}, + {0x8e28, 0xfe}, + {0x8e29, 0x60}, + {0x8e2a, 0x00}, + {0x8e2b, 0x11}, + {0x8e2c, 0x00}, + {0x8e2d, 0x3f}, + {0x8e2e, 0x05}, + {0x8e2f, 0x30}, + {0x8e30, 0x00}, + {0x8e31, 0x3f}, + {0x8e32, 0x06}, + {0x8e33, 0x22}, + {0x8e34, 0x00}, + {0x8e35, 0x3f}, + {0x8e36, 0x01}, + {0x8e37, 0x2a}, + {0x8e38, 0x00}, + {0x8e39, 0x3f}, + {0x8e3a, 0x02}, + {0x8e3b, 0x00}, + {0x8e3c, 0x00}, + {0x8e3d, 0x36}, + {0x8e3e, 0x06}, + {0x8e3f, 0x07}, + {0x8e40, 0x00}, + {0x8e41, 0x3f}, + {0x8e42, 0x0b}, + {0x8e43, 0x0f}, + {0x8e44, 0xf0}, + {0x8e45, 0x00}, + {0x8e46, 0x00}, + {0x8e47, 0x00}, + {0x8e48, 0x00}, + {0x8e49, 0x30}, + {0x8e4a, 0x01}, + {0x8e4b, 0x40}, + {0x8e4c, 0xbf}, + {0x8e4d, 0x30}, + {0x8e4e, 0x01}, + {0x8e4f, 0x00}, + {0x8e50, 0xbf}, + {0x8e51, 0x30}, + {0x8e52, 0x29}, + {0x8e53, 0x70}, + {0x8e54, 0x00}, + {0x8e55, 0x3a}, + {0x8e56, 0x00}, + {0x8e57, 0x00}, + {0x8e58, 0xff}, + {0x8e59, 0x3a}, + {0x8e5a, 0x00}, + {0x8e5b, 0x00}, + {0x8e5c, 0xff}, + {0x8e5d, 0x36}, + {0x8e5e, 0x03}, + {0x8e5f, 0x36}, + {0x8e60, 0x02}, + {0x8e61, 0x41}, + {0x8e62, 0x44}, + {0x8e63, 0x58}, + {0x8e64, 0x20}, + {0x8e65, 0x18}, + {0x8e66, 0x10}, + {0x8e67, 0x0a}, + {0x8e68, 0x04}, + {0x8e69, 0x04}, + {0x8e6a, 0x00}, + {0x8e6b, 0x03}, + {0x8e6c, 0xff}, + {0x8e6d, 0x64}, + {0x8e6e, 0x00}, + {0x8e6f, 0x00}, + {0x8e70, 0x80}, + {0x8e71, 0x00}, + {0x8e72, 0x00}, + {0x8e73, 0x00}, + {0x8e74, 0x00}, + {0x8e75, 0x00}, + {0x8e76, 0x00}, + {0x8e77, 0x02}, + {0x8e78, 0x04}, + {0x8e79, 0x06}, + {0x8e7a, 0x06}, + {0x8e7b, 0x00}, + {0x8e7c, 0x03}, + {0x8e7d, 0x51}, + {0x8e7e, 0x00}, + {0x8e7f, 0x7a}, + {0x8e80, 0x50}, + {0x8e81, 0x3c}, + {0x8e82, 0x28}, + {0x8e83, 0x1e}, + {0x8e84, 0x10}, + {0x8e85, 0x10}, + {0x8e86, 0x50}, + {0x8e87, 0x2d}, + {0x8e88, 0x28}, + {0x8e89, 0x16}, + {0x8e8a, 0x10}, + {0x8e8b, 0x10}, + {0x8e8c, 0x02}, + {0x8e8d, 0x00}, + {0x8e8e, 0x10}, + {0x8e8f, 0x0c}, + {0x8e90, 0x10}, + {0x8e91, 0x04}, + {0x8e92, 0x0c}, + {0x8e93, 0x6e}, + {0x8e94, 0x06}, + {0x8e95, 0x05}, + {0x8e96, 0x00}, + {0x8e97, 0xa5}, + {0x8e98, 0x5a}, + {0x8e99, 0x00}, + {0x8e9a, 0xae}, + {0x8e9b, 0x35}, + {0x8e9c, 0xaf}, + {0x8e9d, 0x36}, + {0x8e9e, 0xe4}, + {0x8e9f, 0xfd}, + {0x8ea0, 0xed}, + {0x8ea1, 0xc3}, + {0x8ea2, 0x95}, + {0x8ea3, 0x37}, + {0x8ea4, 0x50}, + {0x8ea5, 0x33}, + {0x8ea6, 0x12}, + {0x8ea7, 0x0f}, + {0x8ea8, 0xe2}, + {0x8ea9, 0xe4}, + {0x8eaa, 0x93}, + {0x8eab, 0xf5}, + {0x8eac, 0x38}, + {0x8ead, 0x74}, + {0x8eae, 0x01}, + {0x8eaf, 0x93}, + {0x8eb0, 0xf5}, + {0x8eb1, 0x39}, + {0x8eb2, 0x45}, + {0x8eb3, 0x38}, + {0x8eb4, 0x60}, + {0x8eb5, 0x23}, + {0x8eb6, 0x85}, + {0x8eb7, 0x39}, + {0x8eb8, 0x82}, + {0x8eb9, 0x85}, + {0x8eba, 0x38}, + {0x8ebb, 0x83}, + {0x8ebc, 0xe0}, + {0x8ebd, 0xfc}, + {0x8ebe, 0x12}, + {0x8ebf, 0x0f}, + {0x8ec0, 0xe2}, + {0x8ec1, 0x74}, + {0x8ec2, 0x03}, + {0x8ec3, 0x93}, + {0x8ec4, 0x52}, + {0x8ec5, 0x04}, + {0x8ec6, 0x12}, + {0x8ec7, 0x0f}, + {0x8ec8, 0xe2}, + {0x8ec9, 0x74}, + {0x8eca, 0x02}, + {0x8ecb, 0x93}, + {0x8ecc, 0x42}, + {0x8ecd, 0x04}, + {0x8ece, 0x85}, + {0x8ecf, 0x39}, + {0x8ed0, 0x82}, + {0x8ed1, 0x85}, + {0x8ed2, 0x38}, + {0x8ed3, 0x83}, + {0x8ed4, 0xec}, + {0x8ed5, 0xf0}, + {0x8ed6, 0x0d}, + {0x8ed7, 0x80}, + {0x8ed8, 0xc7}, + {0x8ed9, 0x22}, + {0x8eda, 0x78}, + {0x8edb, 0xbe}, + {0x8edc, 0xe6}, + {0x8edd, 0xd3}, + {0x8ede, 0x08}, + {0x8edf, 0xff}, + {0x8ee0, 0xe6}, + {0x8ee1, 0x64}, + {0x8ee2, 0x80}, + {0x8ee3, 0xf8}, + {0x8ee4, 0xef}, + {0x8ee5, 0x64}, + {0x8ee6, 0x80}, + {0x8ee7, 0x98}, + {0x8ee8, 0x22}, + {0x8ee9, 0x93}, + {0x8eea, 0xff}, + {0x8eeb, 0x7e}, + {0x8eec, 0x00}, + {0x8eed, 0xe6}, + {0x8eee, 0xfc}, + {0x8eef, 0x08}, + {0x8ef0, 0xe6}, + {0x8ef1, 0xfd}, + {0x8ef2, 0x12}, + {0x8ef3, 0x04}, + {0x8ef4, 0xc1}, + {0x8ef5, 0x78}, + {0x8ef6, 0xc1}, + {0x8ef7, 0xe6}, + {0x8ef8, 0xfc}, + {0x8ef9, 0x08}, + {0x8efa, 0xe6}, + {0x8efb, 0xfd}, + {0x8efc, 0xd3}, + {0x8efd, 0xef}, + {0x8efe, 0x9d}, + {0x8eff, 0xee}, + {0x8f00, 0x9c}, + {0x8f01, 0x22}, + {0x8f02, 0x78}, + {0x8f03, 0xbd}, + {0x8f04, 0xd3}, + {0x8f05, 0xe6}, + {0x8f06, 0x64}, + {0x8f07, 0x80}, + {0x8f08, 0x94}, + {0x8f09, 0x80}, + {0x8f0a, 0x22}, + {0x8f0b, 0x25}, + {0x8f0c, 0xe0}, + {0x8f0d, 0x24}, + {0x8f0e, 0x0a}, + {0x8f0f, 0xf8}, + {0x8f10, 0xe6}, + {0x8f11, 0xfe}, + {0x8f12, 0x08}, + {0x8f13, 0xe6}, + {0x8f14, 0xff}, + {0x8f15, 0x22}, + {0x8f16, 0xe5}, + {0x8f17, 0x3c}, + {0x8f18, 0xd3}, + {0x8f19, 0x94}, + {0x8f1a, 0x00}, + {0x8f1b, 0x40}, + {0x8f1c, 0x0b}, + {0x8f1d, 0x90}, + {0x8f1e, 0x0e}, + {0x8f1f, 0x88}, + {0x8f20, 0x12}, + {0x8f21, 0x0b}, + {0x8f22, 0xf1}, + {0x8f23, 0x90}, + {0x8f24, 0x0e}, + {0x8f25, 0x86}, + {0x8f26, 0x80}, + {0x8f27, 0x09}, + {0x8f28, 0x90}, + {0x8f29, 0x0e}, + {0x8f2a, 0x82}, + {0x8f2b, 0x12}, + {0x8f2c, 0x0b}, + {0x8f2d, 0xf1}, + {0x8f2e, 0x90}, + {0x8f2f, 0x0e}, + {0x8f30, 0x80}, + {0x8f31, 0xe4}, + {0x8f32, 0x93}, + {0x8f33, 0xf5}, + {0x8f34, 0x44}, + {0x8f35, 0xa3}, + {0x8f36, 0xe4}, + {0x8f37, 0x93}, + {0x8f38, 0xf5}, + {0x8f39, 0x43}, + {0x8f3a, 0xd2}, + {0x8f3b, 0x06}, + {0x8f3c, 0x30}, + {0x8f3d, 0x06}, + {0x8f3e, 0x03}, + {0x8f3f, 0xd3}, + {0x8f40, 0x80}, + {0x8f41, 0x01}, + {0x8f42, 0xc3}, + {0x8f43, 0x92}, + {0x8f44, 0x0e}, + {0x8f45, 0x22}, + {0x8f46, 0xa2}, + {0x8f47, 0xaf}, + {0x8f48, 0x92}, + {0x8f49, 0x32}, + {0x8f4a, 0xc2}, + {0x8f4b, 0xaf}, + {0x8f4c, 0xe5}, + {0x8f4d, 0x23}, + {0x8f4e, 0x45}, + {0x8f4f, 0x22}, + {0x8f50, 0x90}, + {0x8f51, 0x0e}, + {0x8f52, 0x5d}, + {0x8f53, 0x60}, + {0x8f54, 0x0e}, + {0x8f55, 0x12}, + {0x8f56, 0x0f}, + {0x8f57, 0xcb}, + {0x8f58, 0xe0}, + {0x8f59, 0xf5}, + {0x8f5a, 0x2c}, + {0x8f5b, 0x12}, + {0x8f5c, 0x0f}, + {0x8f5d, 0xc8}, + {0x8f5e, 0xe0}, + {0x8f5f, 0xf5}, + {0x8f60, 0x2d}, + {0x8f61, 0x80}, + {0x8f62, 0x0c}, + {0x8f63, 0x12}, + {0x8f64, 0x0f}, + {0x8f65, 0xcb}, + {0x8f66, 0xe5}, + {0x8f67, 0x30}, + {0x8f68, 0xf0}, + {0x8f69, 0x12}, + {0x8f6a, 0x0f}, + {0x8f6b, 0xc8}, + {0x8f6c, 0xe5}, + {0x8f6d, 0x31}, + {0x8f6e, 0xf0}, + {0x8f6f, 0xa2}, + {0x8f70, 0x32}, + {0x8f71, 0x92}, + {0x8f72, 0xaf}, + {0x8f73, 0x22}, + {0x8f74, 0xd2}, + {0x8f75, 0x01}, + {0x8f76, 0xc2}, + {0x8f77, 0x02}, + {0x8f78, 0xe4}, + {0x8f79, 0xf5}, + {0x8f7a, 0x1f}, + {0x8f7b, 0xf5}, + {0x8f7c, 0x1e}, + {0x8f7d, 0xd2}, + {0x8f7e, 0x35}, + {0x8f7f, 0xd2}, + {0x8f80, 0x33}, + {0x8f81, 0xd2}, + {0x8f82, 0x36}, + {0x8f83, 0xd2}, + {0x8f84, 0x01}, + {0x8f85, 0xc2}, + {0x8f86, 0x02}, + {0x8f87, 0xf5}, + {0x8f88, 0x1f}, + {0x8f89, 0xf5}, + {0x8f8a, 0x1e}, + {0x8f8b, 0xd2}, + {0x8f8c, 0x35}, + {0x8f8d, 0xd2}, + {0x8f8e, 0x33}, + {0x8f8f, 0x22}, + {0x8f90, 0xfb}, + {0x8f91, 0xd3}, + {0x8f92, 0xed}, + {0x8f93, 0x9b}, + {0x8f94, 0x74}, + {0x8f95, 0x80}, + {0x8f96, 0xf8}, + {0x8f97, 0x6c}, + {0x8f98, 0x98}, + {0x8f99, 0x22}, + {0x8f9a, 0x12}, + {0x8f9b, 0x06}, + {0x8f9c, 0x69}, + {0x8f9d, 0xe5}, + {0x8f9e, 0x40}, + {0x8f9f, 0x2f}, + {0x8fa0, 0xf5}, + {0x8fa1, 0x40}, + {0x8fa2, 0xe5}, + {0x8fa3, 0x3f}, + {0x8fa4, 0x3e}, + {0x8fa5, 0xf5}, + {0x8fa6, 0x3f}, + {0x8fa7, 0xe5}, + {0x8fa8, 0x3e}, + {0x8fa9, 0x3d}, + {0x8faa, 0xf5}, + {0x8fab, 0x3e}, + {0x8fac, 0xe5}, + {0x8fad, 0x3d}, + {0x8fae, 0x3c}, + {0x8faf, 0xf5}, + {0x8fb0, 0x3d}, + {0x8fb1, 0x22}, + {0x8fb2, 0xc0}, + {0x8fb3, 0xe0}, + {0x8fb4, 0xc0}, + {0x8fb5, 0x83}, + {0x8fb6, 0xc0}, + {0x8fb7, 0x82}, + {0x8fb8, 0x90}, + {0x8fb9, 0x3f}, + {0x8fba, 0x0d}, + {0x8fbb, 0xe0}, + {0x8fbc, 0xf5}, + {0x8fbd, 0x33}, + {0x8fbe, 0xe5}, + {0x8fbf, 0x33}, + {0x8fc0, 0xf0}, + {0x8fc1, 0xd0}, + {0x8fc2, 0x82}, + {0x8fc3, 0xd0}, + {0x8fc4, 0x83}, + {0x8fc5, 0xd0}, + {0x8fc6, 0xe0}, + {0x8fc7, 0x32}, + {0x8fc8, 0x90}, + {0x8fc9, 0x0e}, + {0x8fca, 0x5f}, + {0x8fcb, 0xe4}, + {0x8fcc, 0x93}, + {0x8fcd, 0xfe}, + {0x8fce, 0x74}, + {0x8fcf, 0x01}, + {0x8fd0, 0x93}, + {0x8fd1, 0xf5}, + {0x8fd2, 0x82}, + {0x8fd3, 0x8e}, + {0x8fd4, 0x83}, + {0x8fd5, 0x22}, + {0x8fd6, 0x78}, + {0x8fd7, 0x7f}, + {0x8fd8, 0xe4}, + {0x8fd9, 0xf6}, + {0x8fda, 0xd8}, + {0x8fdb, 0xfd}, + {0x8fdc, 0x75}, + {0x8fdd, 0x81}, + {0x8fde, 0xcd}, + {0x8fdf, 0x02}, + {0x8fe0, 0x0c}, + {0x8fe1, 0x98}, + {0x8fe2, 0x8f}, + {0x8fe3, 0x82}, + {0x8fe4, 0x8e}, + {0x8fe5, 0x83}, + {0x8fe6, 0x75}, + {0x8fe7, 0xf0}, + {0x8fe8, 0x04}, + {0x8fe9, 0xed}, + {0x8fea, 0x02}, + {0x8feb, 0x06}, + {0x8fec, 0xa5}, + {0x3022, 0x03}, + {0x3023, 0x00}, + {0x3024, 0x00}, + {0x3025, 0x00}, + {0x3026, 0x00}, + {0x3027, 0x00}, + {0x3028, 0x00}, + {0x3029, 0x7f}, + {0x3000, 0x00}, + {0xffff, 0xff}, +}; -const struct sensor_reg OV5640YUV_Sensor_Dvp_Init[] PROGMEM= -{ - { 0x4740, 0x20 }, +const struct sensor_reg OV5640YUV_Sensor_Dvp_Init[] PROGMEM = + { + {0x4740, 0x20}, - { 0x4050, 0x6e }, - { 0x4051, 0x8f }, + {0x4050, 0x6e}, + {0x4051, 0x8f}, - { 0x3008, 0x42 }, - { 0x3103, 0x03 }, - { 0x3017, 0x7f }, - { 0x3018, 0xff }, - { 0x302c, 0x02 }, - { 0x3108, 0x01 }, - { 0x3630, 0x2e },//2e - { 0x3632, 0xe2 }, - { 0x3633, 0x23 },//23 - { 0x3621, 0xe0 }, - { 0x3704, 0xa0 }, - { 0x3703, 0x5a }, - { 0x3715, 0x78 }, - { 0x3717, 0x01 }, - { 0x370b, 0x60 }, - { 0x3705, 0x1a }, - { 0x3905, 0x02 }, - { 0x3906, 0x10 }, - { 0x3901, 0x0a }, - { 0x3731, 0x12 }, - { 0x3600, 0x08 }, - { 0x3601, 0x33 }, - { 0x302d, 0x60 }, - { 0x3620, 0x52 }, - { 0x371b, 0x20 }, - { 0x471c, 0x50 }, + {0x3008, 0x42}, + {0x3103, 0x03}, + {0x3017, 0x7f}, + {0x3018, 0xff}, + {0x302c, 0x02}, + {0x3108, 0x01}, + {0x3630, 0x2e}, // 2e + {0x3632, 0xe2}, + {0x3633, 0x23}, // 23 + {0x3621, 0xe0}, + {0x3704, 0xa0}, + {0x3703, 0x5a}, + {0x3715, 0x78}, + {0x3717, 0x01}, + {0x370b, 0x60}, + {0x3705, 0x1a}, + {0x3905, 0x02}, + {0x3906, 0x10}, + {0x3901, 0x0a}, + {0x3731, 0x12}, + {0x3600, 0x08}, + {0x3601, 0x33}, + {0x302d, 0x60}, + {0x3620, 0x52}, + {0x371b, 0x20}, + {0x471c, 0x50}, - { 0x3a18, 0x00 }, - { 0x3a19, 0xf8 }, + {0x3a18, 0x00}, + {0x3a19, 0xf8}, - { 0x3635, 0x1c },//1c - { 0x3634, 0x40 }, - { 0x3622, 0x01 }, + {0x3635, 0x1c}, // 1c + {0x3634, 0x40}, + {0x3622, 0x01}, - { 0x3c04, 0x28 }, - { 0x3c05, 0x98 }, - { 0x3c06, 0x00 }, - { 0x3c07, 0x08 }, - { 0x3c08, 0x00 }, - { 0x3c09, 0x1c }, - { 0x3c0a, 0x9c }, - { 0x3c0b, 0x40 }, + {0x3c04, 0x28}, + {0x3c05, 0x98}, + {0x3c06, 0x00}, + {0x3c07, 0x08}, + {0x3c08, 0x00}, + {0x3c09, 0x1c}, + {0x3c0a, 0x9c}, + {0x3c0b, 0x40}, - { 0x3820, 0x41 }, - { 0x3821, 0x01 }, //07 + {0x3820, 0x41}, + {0x3821, 0x01}, // 07 - //windows setup - { 0x3800, 0x00 }, - { 0x3801, 0x00 }, - { 0x3802, 0x00 }, - { 0x3803, 0x04 }, - { 0x3804, 0x0a }, - { 0x3805, 0x3f }, - { 0x3806, 0x07 }, - { 0x3807, 0x9b }, - { 0x3808, 0x05 }, - { 0x3809, 0x00 }, - { 0x380a, 0x03 }, - { 0x380b, 0xc0 }, - { 0x3810, 0x00 }, - { 0x3811, 0x10 }, - { 0x3812, 0x00 }, - { 0x3813, 0x06 }, - { 0x3814, 0x31 }, - { 0x3815, 0x31 }, + // windows setup + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x04}, + {0x3804, 0x0a}, + {0x3805, 0x3f}, + {0x3806, 0x07}, + {0x3807, 0x9b}, + {0x3808, 0x05}, + {0x3809, 0x00}, + {0x380a, 0x03}, + {0x380b, 0xc0}, + {0x3810, 0x00}, + {0x3811, 0x10}, + {0x3812, 0x00}, + {0x3813, 0x06}, + {0x3814, 0x31}, + {0x3815, 0x31}, - { 0x3034, 0x1a }, - { 0x3035, 0x21 }, //15fps - { 0x3036, 0x46 }, - { 0x3037, 0x13 }, - { 0x3038, 0x00 }, - { 0x3039, 0x00 }, + {0x3034, 0x1a}, + {0x3035, 0x21}, // 15fps + {0x3036, 0x46}, + {0x3037, 0x13}, + {0x3038, 0x00}, + {0x3039, 0x00}, - { 0x380c, 0x07 }, - { 0x380d, 0x68 }, - { 0x380e, 0x03 }, //03 - { 0x380f, 0xd8 }, //d8 + {0x380c, 0x07}, + {0x380d, 0x68}, + {0x380e, 0x03}, // 03 + {0x380f, 0xd8}, // d8 - { 0x3c01, 0xb4 }, - { 0x3c00, 0x04 }, - { 0x3a08, 0x00 }, - { 0x3a09, 0x93 }, - { 0x3a0e, 0x06 }, - { 0x3a0a, 0x00 }, - { 0x3a0b, 0x7b }, - { 0x3a0d, 0x08 }, + {0x3c01, 0xb4}, + {0x3c00, 0x04}, + {0x3a08, 0x00}, + {0x3a09, 0x93}, + {0x3a0e, 0x06}, + {0x3a0a, 0x00}, + {0x3a0b, 0x7b}, + {0x3a0d, 0x08}, - { 0x3a00, 0x3c }, //15fps-10fps - { 0x3a02, 0x05 }, - { 0x3a03, 0xc4 }, - { 0x3a14, 0x05 }, - { 0x3a15, 0xc4 }, + {0x3a00, 0x3c}, // 15fps-10fps + {0x3a02, 0x05}, + {0x3a03, 0xc4}, + {0x3a14, 0x05}, + {0x3a15, 0xc4}, - { 0x3618, 0x00 }, - { 0x3612, 0x29 }, - { 0x3708, 0x64 }, - { 0x3709, 0x52 }, - { 0x370c, 0x03 }, + {0x3618, 0x00}, + {0x3612, 0x29}, + {0x3708, 0x64}, + {0x3709, 0x52}, + {0x370c, 0x03}, - { 0x4001, 0x02 }, - { 0x4004, 0x02 }, - { 0x3000, 0x00 }, - { 0x3002, 0x1c }, - { 0x3004, 0xff }, - { 0x3006, 0xc3 }, - { 0x300e, 0x58 }, - { 0x302e, 0x00 }, - { 0x4300, 0x30 }, - { 0x501f, 0x00 }, - { 0x4713, 0x03 }, - { 0x4407, 0x04 }, - { 0x460b, 0x35 }, - { 0x460c, 0x22 },//add by bright - { 0x3824, 0x01 },//add by bright - { 0x5001, 0xa3 }, + {0x4001, 0x02}, + {0x4004, 0x02}, + {0x3000, 0x00}, + {0x3002, 0x1c}, + {0x3004, 0xff}, + {0x3006, 0xc3}, + {0x300e, 0x58}, + {0x302e, 0x00}, + {0x4300, 0x30}, + {0x501f, 0x00}, + {0x4713, 0x03}, + {0x4407, 0x04}, + {0x460b, 0x35}, + {0x460c, 0x22}, // add by bright + {0x3824, 0x01}, // add by bright + {0x5001, 0xa3}, - { 0x3406, 0x01 },//awbinit - { 0x3400, 0x06 }, - { 0x3401, 0x80 }, - { 0x3402, 0x04 }, - { 0x3403, 0x00 }, - { 0x3404, 0x06 }, - { 0x3405, 0x00 }, - //awb - { 0x5180, 0xff }, - { 0x5181, 0xf2 }, - { 0x5182, 0x00 }, - { 0x5183, 0x14 }, - { 0x5184, 0x25 }, - { 0x5185, 0x24 }, - { 0x5186, 0x16 }, - { 0x5187, 0x16 }, - { 0x5188, 0x16 }, - { 0x5189, 0x62 }, - { 0x518a, 0x62 }, - { 0x518b, 0xf0 }, - { 0x518c, 0xb2 }, - { 0x518d, 0x50 }, - { 0x518e, 0x30 }, - { 0x518f, 0x30 }, - { 0x5190, 0x50 }, - { 0x5191, 0xf8 }, - { 0x5192, 0x04 }, - { 0x5193, 0x70 }, - { 0x5194, 0xf0 }, - { 0x5195, 0xf0 }, - { 0x5196, 0x03 }, - { 0x5197, 0x01 }, - { 0x5198, 0x04 }, - { 0x5199, 0x12 }, - { 0x519a, 0x04 }, - { 0x519b, 0x00 }, - { 0x519c, 0x06 }, - { 0x519d, 0x82 }, - { 0x519e, 0x38 }, - //color matrix - { 0x5381, 0x1e }, - { 0x5382, 0x5b }, - { 0x5383, 0x14 }, - { 0x5384, 0x06 }, - { 0x5385, 0x82 }, - { 0x5386, 0x88 }, - { 0x5387, 0x7c }, - { 0x5388, 0x60 }, - { 0x5389, 0x1c }, - { 0x538a, 0x01 }, - { 0x538b, 0x98 }, - //sharp&noise - { 0x5300, 0x08 }, - { 0x5301, 0x30 }, - { 0x5302, 0x3f }, - { 0x5303, 0x10 }, - { 0x5304, 0x08 }, - { 0x5305, 0x30 }, - { 0x5306, 0x18 }, - { 0x5307, 0x28 }, - { 0x5309, 0x08 }, - { 0x530a, 0x30 }, - { 0x530b, 0x04 }, - { 0x530c, 0x06 }, - //gamma - { 0x5480, 0x01 }, - { 0x5481, 0x06 }, - { 0x5482, 0x12 }, - { 0x5483, 0x24 }, - { 0x5484, 0x4a }, - { 0x5485, 0x58 }, - { 0x5486, 0x65 }, - { 0x5487, 0x72 }, - { 0x5488, 0x7d }, - { 0x5489, 0x88 }, - { 0x548a, 0x92 }, - { 0x548b, 0xa3 }, - { 0x548c, 0xb2 }, - { 0x548d, 0xc8 }, - { 0x548e, 0xdd }, - { 0x548f, 0xf0 }, - { 0x5490, 0x15 }, - //UV adjust - { 0x5580, 0x06 }, - { 0x5583, 0x40 }, - { 0x5584, 0x20 }, - { 0x5589, 0x10 }, - { 0x558a, 0x00 }, - { 0x558b, 0xf8 }, - //lens shading - { 0x5000, 0xa7 }, - { 0x5800, 0x20 }, - { 0x5801, 0x19 }, - { 0x5802, 0x17 }, - { 0x5803, 0x16 }, - { 0x5804, 0x18 }, - { 0x5805, 0x21 }, - { 0x5806, 0x0F }, - { 0x5807, 0x0A }, - { 0x5808, 0x07 }, - { 0x5809, 0x07 }, - { 0x580a, 0x0A }, - { 0x580b, 0x0C }, - { 0x580c, 0x0A }, - { 0x580d, 0x03 }, - { 0x580e, 0x01 }, - { 0x580f, 0x01 }, - { 0x5810, 0x03 }, - { 0x5811, 0x09 }, - { 0x5812, 0x0A }, - { 0x5813, 0x03 }, - { 0x5814, 0x01 }, - { 0x5815, 0x01 }, - { 0x5816, 0x03 }, - { 0x5817, 0x08 }, - { 0x5818, 0x10 }, - { 0x5819, 0x0A }, - { 0x581a, 0x06 }, - { 0x581b, 0x06 }, - { 0x581c, 0x08 }, - { 0x581d, 0x0E }, - { 0x581e, 0x22 }, - { 0x581f, 0x18 }, - { 0x5820, 0x13 }, - { 0x5821, 0x12 }, - { 0x5822, 0x16 }, - { 0x5823, 0x1E }, - { 0x5824, 0x64 }, - { 0x5825, 0x2A }, - { 0x5826, 0x2C }, - { 0x5827, 0x2A }, - { 0x5828, 0x46 }, - { 0x5829, 0x2A }, - { 0x582a, 0x26 }, - { 0x582b, 0x24 }, - { 0x582c, 0x26 }, - { 0x582d, 0x2A }, - { 0x582e, 0x28 }, - { 0x582f, 0x42 }, - { 0x5830, 0x40 }, - { 0x5831, 0x42 }, - { 0x5832, 0x08 }, - { 0x5833, 0x28 }, - { 0x5834, 0x26 }, - { 0x5835, 0x24 }, - { 0x5836, 0x26 }, - { 0x5837, 0x2A }, - { 0x5838, 0x44 }, - { 0x5839, 0x4A }, - { 0x583a, 0x2C }, - { 0x583b, 0x2a }, - { 0x583c, 0x46 }, - { 0x583d, 0xCE }, + {0x3406, 0x01}, // awbinit + {0x3400, 0x06}, + {0x3401, 0x80}, + {0x3402, 0x04}, + {0x3403, 0x00}, + {0x3404, 0x06}, + {0x3405, 0x00}, + // awb + {0x5180, 0xff}, + {0x5181, 0xf2}, + {0x5182, 0x00}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x16}, + {0x5187, 0x16}, + {0x5188, 0x16}, + {0x5189, 0x62}, + {0x518a, 0x62}, + {0x518b, 0xf0}, + {0x518c, 0xb2}, + {0x518d, 0x50}, + {0x518e, 0x30}, + {0x518f, 0x30}, + {0x5190, 0x50}, + {0x5191, 0xf8}, + {0x5192, 0x04}, + {0x5193, 0x70}, + {0x5194, 0xf0}, + {0x5195, 0xf0}, + {0x5196, 0x03}, + {0x5197, 0x01}, + {0x5198, 0x04}, + {0x5199, 0x12}, + {0x519a, 0x04}, + {0x519b, 0x00}, + {0x519c, 0x06}, + {0x519d, 0x82}, + {0x519e, 0x38}, + // color matrix + {0x5381, 0x1e}, + {0x5382, 0x5b}, + {0x5383, 0x14}, + {0x5384, 0x06}, + {0x5385, 0x82}, + {0x5386, 0x88}, + {0x5387, 0x7c}, + {0x5388, 0x60}, + {0x5389, 0x1c}, + {0x538a, 0x01}, + {0x538b, 0x98}, + // sharp&noise + {0x5300, 0x08}, + {0x5301, 0x30}, + {0x5302, 0x3f}, + {0x5303, 0x10}, + {0x5304, 0x08}, + {0x5305, 0x30}, + {0x5306, 0x18}, + {0x5307, 0x28}, + {0x5309, 0x08}, + {0x530a, 0x30}, + {0x530b, 0x04}, + {0x530c, 0x06}, + // gamma + {0x5480, 0x01}, + {0x5481, 0x06}, + {0x5482, 0x12}, + {0x5483, 0x24}, + {0x5484, 0x4a}, + {0x5485, 0x58}, + {0x5486, 0x65}, + {0x5487, 0x72}, + {0x5488, 0x7d}, + {0x5489, 0x88}, + {0x548a, 0x92}, + {0x548b, 0xa3}, + {0x548c, 0xb2}, + {0x548d, 0xc8}, + {0x548e, 0xdd}, + {0x548f, 0xf0}, + {0x5490, 0x15}, + // UV adjust + {0x5580, 0x06}, + {0x5583, 0x40}, + {0x5584, 0x20}, + {0x5589, 0x10}, + {0x558a, 0x00}, + {0x558b, 0xf8}, + // lens shading + {0x5000, 0xa7}, + {0x5800, 0x20}, + {0x5801, 0x19}, + {0x5802, 0x17}, + {0x5803, 0x16}, + {0x5804, 0x18}, + {0x5805, 0x21}, + {0x5806, 0x0F}, + {0x5807, 0x0A}, + {0x5808, 0x07}, + {0x5809, 0x07}, + {0x580a, 0x0A}, + {0x580b, 0x0C}, + {0x580c, 0x0A}, + {0x580d, 0x03}, + {0x580e, 0x01}, + {0x580f, 0x01}, + {0x5810, 0x03}, + {0x5811, 0x09}, + {0x5812, 0x0A}, + {0x5813, 0x03}, + {0x5814, 0x01}, + {0x5815, 0x01}, + {0x5816, 0x03}, + {0x5817, 0x08}, + {0x5818, 0x10}, + {0x5819, 0x0A}, + {0x581a, 0x06}, + {0x581b, 0x06}, + {0x581c, 0x08}, + {0x581d, 0x0E}, + {0x581e, 0x22}, + {0x581f, 0x18}, + {0x5820, 0x13}, + {0x5821, 0x12}, + {0x5822, 0x16}, + {0x5823, 0x1E}, + {0x5824, 0x64}, + {0x5825, 0x2A}, + {0x5826, 0x2C}, + {0x5827, 0x2A}, + {0x5828, 0x46}, + {0x5829, 0x2A}, + {0x582a, 0x26}, + {0x582b, 0x24}, + {0x582c, 0x26}, + {0x582d, 0x2A}, + {0x582e, 0x28}, + {0x582f, 0x42}, + {0x5830, 0x40}, + {0x5831, 0x42}, + {0x5832, 0x08}, + {0x5833, 0x28}, + {0x5834, 0x26}, + {0x5835, 0x24}, + {0x5836, 0x26}, + {0x5837, 0x2A}, + {0x5838, 0x44}, + {0x5839, 0x4A}, + {0x583a, 0x2C}, + {0x583b, 0x2a}, + {0x583c, 0x46}, + {0x583d, 0xCE}, - { 0x5688, 0x22 }, - { 0x5689, 0x22 }, - { 0x568a, 0x42 }, - { 0x568b, 0x24 }, - { 0x568c, 0x42 }, - { 0x568d, 0x24 }, - { 0x568e, 0x22 }, - { 0x568f, 0x22 }, + {0x5688, 0x22}, + {0x5689, 0x22}, + {0x568a, 0x42}, + {0x568b, 0x24}, + {0x568c, 0x42}, + {0x568d, 0x24}, + {0x568e, 0x22}, + {0x568f, 0x22}, - { 0x5025, 0x00 }, + {0x5025, 0x00}, - { 0x3a0f, 0x30 }, - { 0x3a10, 0x28 }, - { 0x3a1b, 0x30 }, - { 0x3a1e, 0x28 }, - { 0x3a11, 0x61 }, - { 0x3a1f, 0x10 }, + {0x3a0f, 0x30}, + {0x3a10, 0x28}, + {0x3a1b, 0x30}, + {0x3a1e, 0x28}, + {0x3a11, 0x61}, + {0x3a1f, 0x10}, - { 0x4005, 0x1a }, - { 0x3406, 0x00 },//awbinit - { 0x3503, 0x00 },//awbinit - { 0x3008, 0x02 }, - { 0xffff, 0xff }, + {0x4005, 0x1a}, + {0x3406, 0x00}, // awbinit + {0x3503, 0x00}, // awbinit + {0x3008, 0x02}, + {0xffff, 0xff}, }; - - -const struct sensor_reg ov5640_vga_preview[] PROGMEM= -{ +const struct sensor_reg ov5640_vga_preview[] PROGMEM = + { // YUV VGA 30fps, night mode 5fps // Input Clock = 24Mhz, PCLK = 56MHz - { 0x3035, 0x11 }, // PLL - { 0x3036, 0x46 }, // PLL - { 0x3c07, 0x08 }, // light meter 1 threshold [7:0] - { 0x3820, 0x41 }, // Sensor flip off, ISP flip on - { 0x3821, 0x01 }, // Sensor mirror on, ISP mirror on, H binning on - { 0x3814, 0x31 }, // X INC - { 0x3815, 0x31 }, // Y INC - { 0x3800, 0x00 }, // HS - { 0x3801, 0x00 }, // HS - { 0x3802, 0x00 }, // VS - { 0x3803, 0x04 }, // VS - { 0x3804, 0x0a }, // HW (HE) - { 0x3805, 0x3f }, // HW (HE) - { 0x3806, 0x07 }, // VH (VE) - { 0x3807, 0x9b }, // VH (VE) - { 0x3808, 0x02 }, // DVPHO - { 0x3809, 0x80 }, // DVPHO - { 0x380a, 0x01 }, // DVPVO - { 0x380b, 0xe0 }, // DVPVO - { 0x380c, 0x07 }, // HTS - { 0x380d, 0x68 }, // HTS - { 0x380e, 0x03 }, // VTS - { 0x380f, 0xd8 }, // VTS - { 0x3813, 0x06 }, // Timing Voffset - { 0x3618, 0x00 }, - { 0x3612, 0x29 }, - { 0x3709, 0x52 }, - { 0x370c, 0x03 }, - { 0x3a02, 0x17 }, // 60Hz max exposure, night mode 5fps - { 0x3a03, 0x10 }, // 60Hz max exposure - // banding filters are calculated automatically in camera driver - //{ 0x3a08, 0x01 }, // B50 step - //{ 0x3a09, 0x27 }, // B50 step - //{ 0x3a0a, 0x00 }, // B60 step - //{ 0x3a0b, 0xf6 }, // B60 step - //{ 0x3a0e, 0x03 }, // 50Hz max band - //{ 0x3a0d, 0x04 }, // 60Hz max band - { 0x3a14, 0x17 }, // 50Hz max exposure, night mode 5fps - { 0x3a15, 0x10 }, // 50Hz max exposure - { 0x4004, 0x02 }, // BLC 2 lines - { 0x3002, 0x1c }, // reset JFIFO, SFIFO, JPEG - { 0x3006, 0xc3 }, // disable clock of JPEG2x, JPEG - { 0x4713, 0x03 }, // JPEG mode 3 - { 0x4407, 0x04 }, // Quantization scale - { 0x460b, 0x35 }, - { 0x460c, 0x22 }, - { 0x4837, 0x22 }, // DVP CLK divider - { 0x3824, 0x02 }, // DVP CLK divider - { 0x5001, 0xa3 }, // SDE on, scale on, UV average off, color matrix on, AWB on - { 0x3503, 0x00 }, // AEC/AGC on + {0x3035, 0x11}, // PLL + {0x3036, 0x46}, // PLL + {0x3c07, 0x08}, // light meter 1 threshold [7:0] + {0x3820, 0x41}, // Sensor flip off, ISP flip on + {0x3821, 0x01}, // Sensor mirror on, ISP mirror on, H binning on + {0x3814, 0x31}, // X INC + {0x3815, 0x31}, // Y INC + {0x3800, 0x00}, // HS + {0x3801, 0x00}, // HS + {0x3802, 0x00}, // VS + {0x3803, 0x04}, // VS + {0x3804, 0x0a}, // HW (HE) + {0x3805, 0x3f}, // HW (HE) + {0x3806, 0x07}, // VH (VE) + {0x3807, 0x9b}, // VH (VE) + {0x3808, 0x02}, // DVPHO + {0x3809, 0x80}, // DVPHO + {0x380a, 0x01}, // DVPVO + {0x380b, 0xe0}, // DVPVO + {0x380c, 0x07}, // HTS + {0x380d, 0x68}, // HTS + {0x380e, 0x03}, // VTS + {0x380f, 0xd8}, // VTS + {0x3813, 0x06}, // Timing Voffset + {0x3618, 0x00}, + {0x3612, 0x29}, + {0x3709, 0x52}, + {0x370c, 0x03}, + {0x3a02, 0x17}, // 60Hz max exposure, night mode 5fps + {0x3a03, 0x10}, // 60Hz max exposure + // banding filters are calculated automatically in camera driver + //{ 0x3a08, 0x01 }, // B50 step + //{ 0x3a09, 0x27 }, // B50 step + //{ 0x3a0a, 0x00 }, // B60 step + //{ 0x3a0b, 0xf6 }, // B60 step + //{ 0x3a0e, 0x03 }, // 50Hz max band + //{ 0x3a0d, 0x04 }, // 60Hz max band + {0x3a14, 0x17}, // 50Hz max exposure, night mode 5fps + {0x3a15, 0x10}, // 50Hz max exposure + {0x4004, 0x02}, // BLC 2 lines + {0x3002, 0x1c}, // reset JFIFO, SFIFO, JPEG + {0x3006, 0xc3}, // disable clock of JPEG2x, JPEG + {0x4713, 0x03}, // JPEG mode 3 + {0x4407, 0x04}, // Quantization scale + {0x460b, 0x35}, + {0x460c, 0x22}, + {0x4837, 0x22}, // DVP CLK divider + {0x3824, 0x02}, // DVP CLK divider + {0x5001, 0xa3}, // SDE on, scale on, UV average off, color matrix on, AWB on + {0x3503, 0x00}, // AEC/AGC on }; const struct sensor_reg OV5640_RGB_QVGA[] PROGMEM = -{ + { {0x3008, 0x02}, {0x3035, 0x41}, {0x4740, 0x21}, @@ -4484,336 +4473,333 @@ const struct sensor_reg OV5640_RGB_QVGA[] PROGMEM = {0xffff, 0xff}, }; -//2592x1944 QSXGA +// 2592x1944 QSXGA const struct sensor_reg OV5640_JPEG_QSXGA[] PROGMEM = -{ - {0x3820 ,0x40}, - {0x3821 ,0x26}, - {0x3814 ,0x11}, - {0x3815 ,0x11}, - {0x3803 ,0x00}, - {0x3807 ,0x9f}, - {0x3808 ,0x0a}, - {0x3809 ,0x20}, - {0x380a ,0x07}, - {0x380b ,0x98}, - {0x380c ,0x0b}, - {0x380d ,0x1c}, - {0x380e ,0x07}, - {0x380f ,0xb0}, - {0x3813 ,0x04}, - {0x3618 ,0x04}, - {0x3612 ,0x4b}, - {0x3708 ,0x64}, - {0x3709 ,0x12}, - {0x370c ,0x00}, - {0x3a02 ,0x07}, - {0x3a03 ,0xb0}, - {0x3a0e ,0x06}, - {0x3a0d ,0x08}, - {0x3a14 ,0x07}, - {0x3a15 ,0xb0}, - {0x4001 ,0x02}, - {0x4004 ,0x06}, - {0x3002 ,0x00}, - {0x3006 ,0xff}, - {0x3824 ,0x04}, - {0x5001 ,0x83}, - {0x3036 ,0x69}, - {0x3035 ,0x31}, - {0x4005 ,0x1A}, + { + {0x3820, 0x40}, + {0x3821, 0x26}, + {0x3814, 0x11}, + {0x3815, 0x11}, + {0x3803, 0x00}, + {0x3807, 0x9f}, + {0x3808, 0x0a}, + {0x3809, 0x20}, + {0x380a, 0x07}, + {0x380b, 0x98}, + {0x380c, 0x0b}, + {0x380d, 0x1c}, + {0x380e, 0x07}, + {0x380f, 0xb0}, + {0x3813, 0x04}, + {0x3618, 0x04}, + {0x3612, 0x4b}, + {0x3708, 0x64}, + {0x3709, 0x12}, + {0x370c, 0x00}, + {0x3a02, 0x07}, + {0x3a03, 0xb0}, + {0x3a0e, 0x06}, + {0x3a0d, 0x08}, + {0x3a14, 0x07}, + {0x3a15, 0xb0}, + {0x4001, 0x02}, + {0x4004, 0x06}, + {0x3002, 0x00}, + {0x3006, 0xff}, + {0x3824, 0x04}, + {0x5001, 0x83}, + {0x3036, 0x69}, + {0x3035, 0x31}, + {0x4005, 0x1A}, {0xffff, 0xff}, }; -//5MP +// 5MP const struct sensor_reg OV5640_5MP_JPEG[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0xA }, - {0x3809 ,0x20}, - {0x380a ,0x7 }, - {0x380b ,0x98}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0xA}, + {0x3809, 0x20}, + {0x380a, 0x7}, + {0x380b, 0x98}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//320x240 QVGA +// 320x240 QVGA const struct sensor_reg OV5640_QSXGA2QVGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x1 }, - {0x3809 ,0x40}, - {0x380a ,0x0 }, - {0x380b ,0xf0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x1}, + {0x3809, 0x40}, + {0x380a, 0x0}, + {0x380b, 0xf0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//640x480 VGA +// 640x480 VGA const struct sensor_reg OV5640_QSXGA2VGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x2 }, - {0x3809 ,0x80}, - {0x380a ,0x1 }, - {0x380b ,0xe0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x2}, + {0x3809, 0x80}, + {0x380a, 0x1}, + {0x380b, 0xe0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//800x480 WVGA +// 800x480 WVGA const struct sensor_reg OV5640_QSXGA2WVGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x3 }, - {0x3809 ,0x20}, - {0x380a ,0x1 }, - {0x380b ,0xe0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x3810, 0x00}, - {0x3811, 0x10}, - {0x3812, 0x01}, - {0x3813, 0x48}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x3}, + {0x3809, 0x20}, + {0x380a, 0x1}, + {0x380b, 0xe0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x3810, 0x00}, + {0x3811, 0x10}, + {0x3812, 0x01}, + {0x3813, 0x48}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//352x288 CIF +// 352x288 CIF const struct sensor_reg OV5640_QSXGA2CIF[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x1 }, - {0x3809 ,0x60}, - {0x380a ,0x1 }, - {0x380b ,0x20}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x3810, 0x00}, - {0x3811, 0x10}, - {0x3812, 0x00}, - {0x3813, 0x70}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x1}, + {0x3809, 0x60}, + {0x380a, 0x1}, + {0x380b, 0x20}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x3810, 0x00}, + {0x3811, 0x10}, + {0x3812, 0x00}, + {0x3813, 0x70}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//1280x960 SXGA +// 1280x960 SXGA const struct sensor_reg OV5640_QSXGA2SXGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x5 }, - {0x3809 ,0x0 }, - {0x380a ,0x3 }, - {0x380b ,0xc0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x5}, + {0x3809, 0x0}, + {0x380a, 0x3}, + {0x380b, 0xc0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//2048x1536 QXGA +// 2048x1536 QXGA const struct sensor_reg OV5640_QSXGA2QXGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x8 }, - {0x3809 ,0x0 }, - {0x380a ,0x6 }, - {0x380b ,0x0 }, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x8}, + {0x3809, 0x0}, + {0x380a, 0x6}, + {0x380b, 0x0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; - -//1600x1200 UXGA +// 1600x1200 UXGA const struct sensor_reg OV5640_QSXGA2UXGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x6 }, - {0x3809 ,0x40}, - {0x380a ,0x4 }, - {0x380b ,0xb0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x6}, + {0x3809, 0x40}, + {0x380a, 0x4}, + {0x380b, 0xb0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; -//1024x768 XGA +// 1024x768 XGA const struct sensor_reg OV5640_QSXGA2XGA[] PROGMEM = -{ - {0x3800 ,0x00}, - {0x3801 ,0x00}, - {0x3802 ,0x00}, - {0x3803 ,0x00}, - {0x3804 ,0xA }, - {0x3805 ,0x3f}, - {0x3806 ,0x7 }, - {0x3807 ,0x9f}, - {0x3808 ,0x4 }, - {0x3809 ,0x0 }, - {0x380a ,0x3 }, - {0x380b ,0x0 }, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0xa3}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, + { + {0x3800, 0x00}, + {0x3801, 0x00}, + {0x3802, 0x00}, + {0x3803, 0x00}, + {0x3804, 0xA}, + {0x3805, 0x3f}, + {0x3806, 0x7}, + {0x3807, 0x9f}, + {0x3808, 0x4}, + {0x3809, 0x0}, + {0x380a, 0x3}, + {0x380b, 0x0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0xa3}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, {0xffff, 0xff}, }; - #endif - diff --git a/ArduCAM/ov5642_regs.h b/ArduCAM/ov5642_regs.h index 30501658..c658d818 100644 --- a/ArduCAM/ov5642_regs.h +++ b/ArduCAM/ov5642_regs.h @@ -1,2528 +1,2493 @@ #ifndef OV5642_REGS_H #define OV5642_REGS_H #include "ArduCAM.h" -//#include +// #include #define OV5642_CHIPID_HIGH 0x300a #define OV5642_CHIPID_LOW 0x300b const struct sensor_reg ov5642_RAW[] PROGMEM = -{ -{0x3103,0x03}, -{0x3008,0x82}, -{0x3017,0x7f}, -{0x3018,0xfc}, -{0x3810,0xc2}, -{0x3615,0xf0}, -{0x3000,0x00}, -{0x3001,0x00}, -{0x3002,0x00}, -{0x3003,0x00}, -{0x3011,0x08}, -{0x3010,0x30}, -{0x3604,0x60}, -{0x3622,0x08}, -{0x3621,0x17}, -{0x3709,0x00}, -{0x4000,0x21}, -{0x401d,0x02}, -{0x3600,0x54}, -{0x3605,0x04}, -{0x3606,0x3f}, -{0x3c01,0x80}, -{0x300d,0x21}, -{0x3623,0x22}, -{0x5000,0xcf}, -{0x5001,0xFF}, -{0x5020,0x04}, -{0x5181,0x79}, -{0x5182,0x00}, -{0x5185,0x22}, -{0x5197,0x01}, -{0x5500,0x0a}, -{0x5504,0x00}, -{0x5505,0x7f}, -{0x5080,0x08}, -{0x300e,0x18}, -{0x4610,0x00}, -{0x471d,0x05}, -{0x4708,0x06}, -{0x3710,0x10}, -{0x370d,0x06}, -{0x3632,0x41}, -{0x3702,0x40}, -{0x3620,0x37}, -{0x3631,0x01}, -{0x370c,0xa0}, -{0x3808,0x0a}, -{0x3809,0x20}, -{0x380a,0x07}, -{0x380b,0x98}, -{0x380c,0x0c}, -{0x380d,0x80}, -{0x380e,0x07}, -{0x380f,0xd0}, -{0x5000,0x06}, -{0x501f,0x03}, -{0x3503,0x07}, -{0x3501,0x73}, -{0x3502,0x80}, -{0x350b,0x00}, -{0x3818,0xc0}, -{0x3621,0x27}, -{0x3801,0x8a}, -{0x3a00,0x78}, -{0x3a1a,0x04}, -{0x3a13,0x30}, -{0x3a18,0x00}, -{0x3a19,0x7c}, -{0x3a08,0x12}, -{0x3a09,0xc0}, -{0x3a0a,0x0f}, -{0x3a0b,0xa0}, -{0x3004,0xff}, -{0x350c,0x07}, -{0x350d,0xd0}, -{0x3a0d,0x08}, -{0x3a0e,0x06}, -{0x3500,0x00}, -{0x3501,0x00}, -{0x3502,0x00}, -{0x350a,0x00}, -{0x350b,0x00}, -{0x3503,0x00}, -{0x3030,0x2b}, -{0x3a02,0x00}, -{0x3a03,0x7d}, -{0x3a04,0x00}, -{0x3a14,0x00}, -{0x3a15,0x7d}, -{0x3a16,0x00}, -{0x3a00,0x78}, -{0x3a08,0x09}, -{0x3a09,0x60}, -{0x3a0a,0x07}, -{0x3a0b,0xd0}, -{0x3a0d,0x10}, -{0x3a0e,0x0d}, -{0x3620,0x57}, -{0x3703,0x98}, -{0x3704,0x1c}, -{0x589b,0x00}, -{0x589a,0xc0}, -{0x3633,0x07}, -{0x3702,0x10}, -{0x3703,0xb2}, -{0x3704,0x18}, -{0x370b,0x40}, -{0x370d,0x02}, -{0x3620,0x52}, -{0x5000,0x06}, -{0x5001,0xff}, -{0x5005,0x00}, -{0x3818,0x80}, -{0x3621,0x17}, -{0x3801,0xb4}, -{0x3001,0x40}, -{0x3002,0x1c}, -{0x3810,0x00}, -{0x3818,0x00}, -{0x460c,0x20}, -{0x501f,0x03}, -{0x4300,0xf8}, - -{0xffff,0xff}, + { + {0x3103, 0x03}, + {0x3008, 0x82}, + {0x3017, 0x7f}, + {0x3018, 0xfc}, + {0x3810, 0xc2}, + {0x3615, 0xf0}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3003, 0x00}, + {0x3011, 0x08}, + {0x3010, 0x30}, + {0x3604, 0x60}, + {0x3622, 0x08}, + {0x3621, 0x17}, + {0x3709, 0x00}, + {0x4000, 0x21}, + {0x401d, 0x02}, + {0x3600, 0x54}, + {0x3605, 0x04}, + {0x3606, 0x3f}, + {0x3c01, 0x80}, + {0x300d, 0x21}, + {0x3623, 0x22}, + {0x5000, 0xcf}, + {0x5001, 0xFF}, + {0x5020, 0x04}, + {0x5181, 0x79}, + {0x5182, 0x00}, + {0x5185, 0x22}, + {0x5197, 0x01}, + {0x5500, 0x0a}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + {0x5080, 0x08}, + {0x300e, 0x18}, + {0x4610, 0x00}, + {0x471d, 0x05}, + {0x4708, 0x06}, + {0x3710, 0x10}, + {0x370d, 0x06}, + {0x3632, 0x41}, + {0x3702, 0x40}, + {0x3620, 0x37}, + {0x3631, 0x01}, + {0x370c, 0xa0}, + {0x3808, 0x0a}, + {0x3809, 0x20}, + {0x380a, 0x07}, + {0x380b, 0x98}, + {0x380c, 0x0c}, + {0x380d, 0x80}, + {0x380e, 0x07}, + {0x380f, 0xd0}, + {0x5000, 0x06}, + {0x501f, 0x03}, + {0x3503, 0x07}, + {0x3501, 0x73}, + {0x3502, 0x80}, + {0x350b, 0x00}, + {0x3818, 0xc0}, + {0x3621, 0x27}, + {0x3801, 0x8a}, + {0x3a00, 0x78}, + {0x3a1a, 0x04}, + {0x3a13, 0x30}, + {0x3a18, 0x00}, + {0x3a19, 0x7c}, + {0x3a08, 0x12}, + {0x3a09, 0xc0}, + {0x3a0a, 0x0f}, + {0x3a0b, 0xa0}, + {0x3004, 0xff}, + {0x350c, 0x07}, + {0x350d, 0xd0}, + {0x3a0d, 0x08}, + {0x3a0e, 0x06}, + {0x3500, 0x00}, + {0x3501, 0x00}, + {0x3502, 0x00}, + {0x350a, 0x00}, + {0x350b, 0x00}, + {0x3503, 0x00}, + {0x3030, 0x2b}, + {0x3a02, 0x00}, + {0x3a03, 0x7d}, + {0x3a04, 0x00}, + {0x3a14, 0x00}, + {0x3a15, 0x7d}, + {0x3a16, 0x00}, + {0x3a00, 0x78}, + {0x3a08, 0x09}, + {0x3a09, 0x60}, + {0x3a0a, 0x07}, + {0x3a0b, 0xd0}, + {0x3a0d, 0x10}, + {0x3a0e, 0x0d}, + {0x3620, 0x57}, + {0x3703, 0x98}, + {0x3704, 0x1c}, + {0x589b, 0x00}, + {0x589a, 0xc0}, + {0x3633, 0x07}, + {0x3702, 0x10}, + {0x3703, 0xb2}, + {0x3704, 0x18}, + {0x370b, 0x40}, + {0x370d, 0x02}, + {0x3620, 0x52}, + {0x5000, 0x06}, + {0x5001, 0xff}, + {0x5005, 0x00}, + {0x3818, 0x80}, + {0x3621, 0x17}, + {0x3801, 0xb4}, + {0x3001, 0x40}, + {0x3002, 0x1c}, + {0x3810, 0x00}, + {0x3818, 0x00}, + {0x460c, 0x20}, + {0x501f, 0x03}, + {0x4300, 0xf8}, + + {0xffff, 0xff}, }; - - const struct sensor_reg OV5642_1280x960_RAW[] PROGMEM = -{ -{0x3103,0x93}, -{0x3008,0x02}, -{0x3017,0x7f}, -{0x3018,0xf0}, -{0x3615,0xf0}, -{0x3000,0xF8}, -{0x3001,0x48}, -{0x3002,0x5c}, -{0x3003,0x02}, -{0x3005,0xB7}, -{0x3006,0x43}, -{0x3007,0x37}, -{0x300f,0x06}, -{0x3011,0x08}, -{0x3010,0x20}, -{0x3012,0x00}, -{0x460c,0x22}, -{0x3815,0x04}, -{0x370c,0xA0}, -{0x3602,0xFC}, -{0x3612,0xFF}, -{0x3634,0xC0}, -{0x3613,0x00}, -{0x3622,0x00}, -{0x3603,0x27}, -{0x4000,0x21}, -{0x401D,0x02}, -{0x3600,0x54}, -{0x3605,0x04}, -{0x3606,0x3F}, -{0x5020,0x04}, -{0x5197,0x01}, -{0x5001,0xFF}, -{0x5500,0x10}, -{0x5502,0x00}, -{0x5503,0x04}, -{0x5504,0x00}, -{0x5505,0x7F}, -{0x5080,0x08}, -{0x300E,0x18}, -{0x4610,0x00}, -{0x471D,0x05}, -{0x4708,0x06}, -{0x3710,0x10}, -{0x3632,0x41}, -{0x3631,0x01}, -{0x501F,0x03}, -{0x3604,0x40}, -{0x4300,0x00}, -{0x3824,0x11}, -{0x5000,0x4F}, -{0x3818,0xC1}, -{0x3705,0xDB}, -{0x370A,0x81}, -{0x3621,0xC7}, -{0x3800,0x03}, -{0x3801,0xE8}, -{0x3802,0x03}, -{0x3803,0xE8}, -{0x3804,0x38}, -{0x3805,0x00}, -{0x3806,0x03}, -{0x3807,0xC0}, -{0x3808,0x05}, -{0x3809,0x00}, -{0x380A,0x03}, -{0x380B,0xC0}, -{0x380C,0x0A}, -{0x380D,0xF0}, -{0x380E,0x03}, -{0x380F,0xE8}, -{0x3827,0x08}, -{0x3810,0xC0}, -{0x5683,0x00}, -{0x5686,0x03}, -{0x5687,0xC0}, -{0x3A1A,0x04}, -{0x3A13,0x30}, -{0x3004,0xDF}, -{0x350C,0x07}, -{0x350D,0xD0}, -{0x3500,0x35}, -{0x3501,0x00}, -{0x3502,0x00}, -{0x350A,0x00}, -{0x350B,0x00}, -{0x3503,0x00}, -{0x5682,0x05}, -{0x3A0F,0x78}, -{0x3A11,0xD0}, -{0x3A1B,0x7A}, -{0x3A1E,0x66}, -{0x3A1F,0x40}, -{0x3A10,0x68}, -{0x3030,0x0B}, -{0x3A01,0x04}, -{0x3A02,0x00}, -{0x3A03,0x78}, -{0x3A04,0x00}, -{0x3A05,0x30}, -{0x3A14,0x00}, -{0x3A15,0x64}, -{0x3A16,0x00}, -{0x3A17,0x89}, -{0x3A18,0x00}, -{0x3A19,0x70}, -{0x3A00,0x78}, -{0x3A08,0x12}, -{0x3A09,0xC0}, -{0x3A0A,0x0F}, -{0x3A0B,0xA0}, -{0x3A0D,0x04}, -{0x3A0E,0x03}, -{0x3C00,0x04}, -{0x3C01,0xB4}, -{0x5688,0xFD}, -{0x5689,0xDF}, -{0x568A,0xFE}, -{0x568B,0xEF}, -{0x568C,0xFE}, -{0x568D,0xEF}, -{0x568E,0xAA}, -{0x568F,0xAA}, -{0x589B,0x04}, -{0x589A,0xC5}, -{0x528A,0x00}, -{0x528B,0x02}, -{0x528C,0x08}, -{0x528D,0x10}, -{0x528E,0x20}, -{0x528F,0x28}, -{0x5290,0x30}, -{0x5292,0x00}, -{0x5293,0x00}, -{0x5294,0x00}, -{0x5295,0x02}, -{0x5296,0x00}, -{0x5297,0x08}, -{0x5298,0x00}, -{0x5299,0x10}, -{0x529A,0x00}, -{0x529B,0x20}, -{0x529C,0x00}, -{0x529D,0x28}, -{0x529E,0x00}, -{0x5282,0x00}, -{0x529F,0x30}, -{0x5300,0x00}, -{0x5302,0x00}, -{0x5303,0x7C}, -{0x530C,0x00}, -{0x530D,0x0C}, -{0x530E,0x20}, -{0x530F,0x80}, -{0x5310,0x20}, -{0x5311,0x80}, -{0x5308,0x20}, -{0x5309,0x40}, -{0x5304,0x00}, -{0x5305,0x30}, -{0x5306,0x00}, -{0x5307,0x80}, -{0x5314,0x08}, -{0x5315,0x20}, -{0x5319,0x30}, -{0x5316,0x10}, -{0x5317,0x08}, -{0x5318,0x02}, -{0x5380,0x01}, -{0x5381,0x20}, -{0x5382,0x00}, -{0x5383,0x4E}, -{0x5384,0x00}, -{0x5385,0x0F}, -{0x5386,0x00}, -{0x5387,0x00}, -{0x5388,0x01}, -{0x5389,0x15}, -{0x538A,0x00}, -{0x538B,0x31}, -{0x538C,0x00}, -{0x538D,0x00}, -{0x538E,0x00}, -{0x538F,0x0F}, -{0x5390,0x00}, -{0x5391,0xAB}, -{0x5392,0x00}, -{0x5393,0xA2}, -{0x5394,0x08}, -{0x5301,0x20}, -{0x5480,0x14}, -{0x5482,0x03}, -{0x5483,0x57}, -{0x5484,0x65}, -{0x5485,0x71}, -{0x5481,0x21}, -{0x5486,0x7D}, -{0x5487,0x87}, -{0x5488,0x91}, -{0x5489,0x9A}, -{0x548A,0xAA}, -{0x548B,0xB8}, -{0x548C,0xCD}, -{0x548D,0xDD}, -{0x548E,0xEA}, -{0x548F,0x10}, -{0x5490,0x05}, -{0x5491,0x00}, -{0x5492,0x04}, -{0x5493,0x20}, -{0x5494,0x03}, -{0x5495,0x60}, -{0x5496,0x02}, -{0x5497,0xB8}, -{0x5498,0x02}, -{0x5499,0x86}, -{0x549A,0x02}, -{0x549B,0x5B}, -{0x549C,0x02}, -{0x549D,0x3B}, -{0x549E,0x02}, -{0x549F,0x1C}, -{0x54A0,0x02}, -{0x54A1,0x04}, -{0x54A2,0x01}, -{0x54A3,0xED}, -{0x54A4,0x01}, -{0x54A5,0xC5}, -{0x54A6,0x01}, -{0x54A7,0xA5}, -{0x54A8,0x01}, -{0x54A9,0x6C}, -{0x54AA,0x01}, -{0x54AB,0x41}, -{0x54AC,0x01}, -{0x54AD,0x20}, -{0x54AE,0x00}, -{0x54AF,0x16}, -{0x3406,0x00}, -{0x5192,0x04}, -{0x5191,0xF8}, -{0x5193,0x70}, -{0x5194,0xF0}, -{0x5195,0xF0}, -{0x518D,0x3D}, -{0x518F,0x54}, -{0x518E,0x3D}, -{0x5190,0x54}, -{0x518B,0xC0}, -{0x518C,0xBD}, -{0x5187,0x18}, -{0x5188,0x18}, -{0x5189,0x6E}, -{0x518A,0x68}, -{0x5186,0x1C}, -{0x5181,0x50}, -{0x5182,0x11}, -{0x5183,0x14}, -{0x5184,0x25}, -{0x5185,0x24}, -{0x5025,0x82}, -{0x5583,0x40}, -{0x5584,0x40}, -{0x5580,0x02}, -{0x3633,0x07}, -{0x3702,0x10}, -{0x3703,0xB2}, -{0x3704,0x18}, -{0x370B,0x40}, -{0x370D,0x02}, -{0x3620,0x52}, - -{0xffff,0xff}, + { + {0x3103, 0x93}, + {0x3008, 0x02}, + {0x3017, 0x7f}, + {0x3018, 0xf0}, + {0x3615, 0xf0}, + {0x3000, 0xF8}, + {0x3001, 0x48}, + {0x3002, 0x5c}, + {0x3003, 0x02}, + {0x3005, 0xB7}, + {0x3006, 0x43}, + {0x3007, 0x37}, + {0x300f, 0x06}, + {0x3011, 0x08}, + {0x3010, 0x20}, + {0x3012, 0x00}, + {0x460c, 0x22}, + {0x3815, 0x04}, + {0x370c, 0xA0}, + {0x3602, 0xFC}, + {0x3612, 0xFF}, + {0x3634, 0xC0}, + {0x3613, 0x00}, + {0x3622, 0x00}, + {0x3603, 0x27}, + {0x4000, 0x21}, + {0x401D, 0x02}, + {0x3600, 0x54}, + {0x3605, 0x04}, + {0x3606, 0x3F}, + {0x5020, 0x04}, + {0x5197, 0x01}, + {0x5001, 0xFF}, + {0x5500, 0x10}, + {0x5502, 0x00}, + {0x5503, 0x04}, + {0x5504, 0x00}, + {0x5505, 0x7F}, + {0x5080, 0x08}, + {0x300E, 0x18}, + {0x4610, 0x00}, + {0x471D, 0x05}, + {0x4708, 0x06}, + {0x3710, 0x10}, + {0x3632, 0x41}, + {0x3631, 0x01}, + {0x501F, 0x03}, + {0x3604, 0x40}, + {0x4300, 0x00}, + {0x3824, 0x11}, + {0x5000, 0x4F}, + {0x3818, 0xC1}, + {0x3705, 0xDB}, + {0x370A, 0x81}, + {0x3621, 0xC7}, + {0x3800, 0x03}, + {0x3801, 0xE8}, + {0x3802, 0x03}, + {0x3803, 0xE8}, + {0x3804, 0x38}, + {0x3805, 0x00}, + {0x3806, 0x03}, + {0x3807, 0xC0}, + {0x3808, 0x05}, + {0x3809, 0x00}, + {0x380A, 0x03}, + {0x380B, 0xC0}, + {0x380C, 0x0A}, + {0x380D, 0xF0}, + {0x380E, 0x03}, + {0x380F, 0xE8}, + {0x3827, 0x08}, + {0x3810, 0xC0}, + {0x5683, 0x00}, + {0x5686, 0x03}, + {0x5687, 0xC0}, + {0x3A1A, 0x04}, + {0x3A13, 0x30}, + {0x3004, 0xDF}, + {0x350C, 0x07}, + {0x350D, 0xD0}, + {0x3500, 0x35}, + {0x3501, 0x00}, + {0x3502, 0x00}, + {0x350A, 0x00}, + {0x350B, 0x00}, + {0x3503, 0x00}, + {0x5682, 0x05}, + {0x3A0F, 0x78}, + {0x3A11, 0xD0}, + {0x3A1B, 0x7A}, + {0x3A1E, 0x66}, + {0x3A1F, 0x40}, + {0x3A10, 0x68}, + {0x3030, 0x0B}, + {0x3A01, 0x04}, + {0x3A02, 0x00}, + {0x3A03, 0x78}, + {0x3A04, 0x00}, + {0x3A05, 0x30}, + {0x3A14, 0x00}, + {0x3A15, 0x64}, + {0x3A16, 0x00}, + {0x3A17, 0x89}, + {0x3A18, 0x00}, + {0x3A19, 0x70}, + {0x3A00, 0x78}, + {0x3A08, 0x12}, + {0x3A09, 0xC0}, + {0x3A0A, 0x0F}, + {0x3A0B, 0xA0}, + {0x3A0D, 0x04}, + {0x3A0E, 0x03}, + {0x3C00, 0x04}, + {0x3C01, 0xB4}, + {0x5688, 0xFD}, + {0x5689, 0xDF}, + {0x568A, 0xFE}, + {0x568B, 0xEF}, + {0x568C, 0xFE}, + {0x568D, 0xEF}, + {0x568E, 0xAA}, + {0x568F, 0xAA}, + {0x589B, 0x04}, + {0x589A, 0xC5}, + {0x528A, 0x00}, + {0x528B, 0x02}, + {0x528C, 0x08}, + {0x528D, 0x10}, + {0x528E, 0x20}, + {0x528F, 0x28}, + {0x5290, 0x30}, + {0x5292, 0x00}, + {0x5293, 0x00}, + {0x5294, 0x00}, + {0x5295, 0x02}, + {0x5296, 0x00}, + {0x5297, 0x08}, + {0x5298, 0x00}, + {0x5299, 0x10}, + {0x529A, 0x00}, + {0x529B, 0x20}, + {0x529C, 0x00}, + {0x529D, 0x28}, + {0x529E, 0x00}, + {0x5282, 0x00}, + {0x529F, 0x30}, + {0x5300, 0x00}, + {0x5302, 0x00}, + {0x5303, 0x7C}, + {0x530C, 0x00}, + {0x530D, 0x0C}, + {0x530E, 0x20}, + {0x530F, 0x80}, + {0x5310, 0x20}, + {0x5311, 0x80}, + {0x5308, 0x20}, + {0x5309, 0x40}, + {0x5304, 0x00}, + {0x5305, 0x30}, + {0x5306, 0x00}, + {0x5307, 0x80}, + {0x5314, 0x08}, + {0x5315, 0x20}, + {0x5319, 0x30}, + {0x5316, 0x10}, + {0x5317, 0x08}, + {0x5318, 0x02}, + {0x5380, 0x01}, + {0x5381, 0x20}, + {0x5382, 0x00}, + {0x5383, 0x4E}, + {0x5384, 0x00}, + {0x5385, 0x0F}, + {0x5386, 0x00}, + {0x5387, 0x00}, + {0x5388, 0x01}, + {0x5389, 0x15}, + {0x538A, 0x00}, + {0x538B, 0x31}, + {0x538C, 0x00}, + {0x538D, 0x00}, + {0x538E, 0x00}, + {0x538F, 0x0F}, + {0x5390, 0x00}, + {0x5391, 0xAB}, + {0x5392, 0x00}, + {0x5393, 0xA2}, + {0x5394, 0x08}, + {0x5301, 0x20}, + {0x5480, 0x14}, + {0x5482, 0x03}, + {0x5483, 0x57}, + {0x5484, 0x65}, + {0x5485, 0x71}, + {0x5481, 0x21}, + {0x5486, 0x7D}, + {0x5487, 0x87}, + {0x5488, 0x91}, + {0x5489, 0x9A}, + {0x548A, 0xAA}, + {0x548B, 0xB8}, + {0x548C, 0xCD}, + {0x548D, 0xDD}, + {0x548E, 0xEA}, + {0x548F, 0x10}, + {0x5490, 0x05}, + {0x5491, 0x00}, + {0x5492, 0x04}, + {0x5493, 0x20}, + {0x5494, 0x03}, + {0x5495, 0x60}, + {0x5496, 0x02}, + {0x5497, 0xB8}, + {0x5498, 0x02}, + {0x5499, 0x86}, + {0x549A, 0x02}, + {0x549B, 0x5B}, + {0x549C, 0x02}, + {0x549D, 0x3B}, + {0x549E, 0x02}, + {0x549F, 0x1C}, + {0x54A0, 0x02}, + {0x54A1, 0x04}, + {0x54A2, 0x01}, + {0x54A3, 0xED}, + {0x54A4, 0x01}, + {0x54A5, 0xC5}, + {0x54A6, 0x01}, + {0x54A7, 0xA5}, + {0x54A8, 0x01}, + {0x54A9, 0x6C}, + {0x54AA, 0x01}, + {0x54AB, 0x41}, + {0x54AC, 0x01}, + {0x54AD, 0x20}, + {0x54AE, 0x00}, + {0x54AF, 0x16}, + {0x3406, 0x00}, + {0x5192, 0x04}, + {0x5191, 0xF8}, + {0x5193, 0x70}, + {0x5194, 0xF0}, + {0x5195, 0xF0}, + {0x518D, 0x3D}, + {0x518F, 0x54}, + {0x518E, 0x3D}, + {0x5190, 0x54}, + {0x518B, 0xC0}, + {0x518C, 0xBD}, + {0x5187, 0x18}, + {0x5188, 0x18}, + {0x5189, 0x6E}, + {0x518A, 0x68}, + {0x5186, 0x1C}, + {0x5181, 0x50}, + {0x5182, 0x11}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5025, 0x82}, + {0x5583, 0x40}, + {0x5584, 0x40}, + {0x5580, 0x02}, + {0x3633, 0x07}, + {0x3702, 0x10}, + {0x3703, 0xB2}, + {0x3704, 0x18}, + {0x370B, 0x40}, + {0x370D, 0x02}, + {0x3620, 0x52}, + + {0xffff, 0xff}, }; const struct sensor_reg OV5642_1920x1080_RAW[] PROGMEM = -{ + { -{0x3808,0x07}, -{0x3809,0x80}, -{0x380A,0x04}, -{0x380B,0x38}, -{0xffff,0xff}, + {0x3808, 0x07}, + {0x3809, 0x80}, + {0x380A, 0x04}, + {0x380B, 0x38}, + {0xffff, 0xff}, }; const struct sensor_reg OV5642_640x480_RAW[] PROGMEM = -{ - /* -{0x3800,0x03}, -{0x3801,0xE8}, -{0x3802,0x03}, -{0x3803,0xE8}, -{0x3804,0x38}, -{0x3805,0x00}, -{0x3806,0x03}, -{0x3807,0xC0}, -*/ -{0x3808,0x02}, -{0x3809,0x80}, -{0x380A,0x01}, -{0x380B,0xe0}, -{0xffff,0xff}, + { + /* + {0x3800,0x03}, + {0x3801,0xE8}, + {0x3802,0x03}, + {0x3803,0xE8}, + {0x3804,0x38}, + {0x3805,0x00}, + {0x3806,0x03}, + {0x3807,0xC0}, + */ + {0x3808, 0x02}, + {0x3809, 0x80}, + {0x380A, 0x01}, + {0x380B, 0xe0}, + {0xffff, 0xff}, }; - - - - - - - - - - - - - - - - - - - - - - - - - - - const struct sensor_reg ov5642_320x240[] PROGMEM = -{ - {0x3800 ,0x1 }, - {0x3801 ,0xa8}, - {0x3802 ,0x0 }, - {0x3803 ,0xA }, - {0x3804 ,0xA }, - {0x3805 ,0x20}, - {0x3806 ,0x7 }, - {0x3807 ,0x98}, - {0x3808 ,0x1 }, - {0x3809 ,0x40}, - {0x380a ,0x0 }, - {0x380b ,0xF0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, - {0x3801, 0xb0}, - {0xffff, 0xff}, + { + {0x3800, 0x1}, + {0x3801, 0xa8}, + {0x3802, 0x0}, + {0x3803, 0xA}, + {0x3804, 0xA}, + {0x3805, 0x20}, + {0x3806, 0x7}, + {0x3807, 0x98}, + {0x3808, 0x1}, + {0x3809, 0x40}, + {0x380a, 0x0}, + {0x380b, 0xF0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, + {0x3801, 0xb0}, + {0xffff, 0xff}, }; const struct sensor_reg ov5642_640x480[] PROGMEM = -{ - {0x3800 ,0x1 }, - {0x3801 ,0xa8}, - {0x3802 ,0x0 }, - {0x3803 ,0xA }, - {0x3804 ,0xA }, - {0x3805 ,0x20}, - {0x3806 ,0x7 }, - {0x3807 ,0x98}, - {0x3808 ,0x2 }, - {0x3809 ,0x80}, - {0x380a ,0x1 }, - {0x380b ,0xe0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, - {0x3801, 0xb0}, - {0xffff, 0xff}, + { + {0x3800, 0x1}, + {0x3801, 0xa8}, + {0x3802, 0x0}, + {0x3803, 0xA}, + {0x3804, 0xA}, + {0x3805, 0x20}, + {0x3806, 0x7}, + {0x3807, 0x98}, + {0x3808, 0x2}, + {0x3809, 0x80}, + {0x380a, 0x1}, + {0x380b, 0xe0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, + {0x3801, 0xb0}, + {0xffff, 0xff}, }; const struct sensor_reg ov5642_1280x960[] PROGMEM = -{ - {0x3800 ,0x1 }, - {0x3801 ,0xB0}, - {0x3802 ,0x0 }, - {0x3803 ,0xA }, - {0x3804 ,0xA }, - {0x3805 ,0x20}, - {0x3806 ,0x7 }, - {0x3807 ,0x98}, - {0x3808 ,0x5 }, - {0x3809 ,0x00}, - {0x380a ,0x3 }, - {0x380b ,0xC0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, - {0xffff, 0xff}, + { + {0x3800, 0x1}, + {0x3801, 0xB0}, + {0x3802, 0x0}, + {0x3803, 0xA}, + {0x3804, 0xA}, + {0x3805, 0x20}, + {0x3806, 0x7}, + {0x3807, 0x98}, + {0x3808, 0x5}, + {0x3809, 0x00}, + {0x380a, 0x3}, + {0x380b, 0xC0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, + {0xffff, 0xff}, }; const struct sensor_reg ov5642_1600x1200[] PROGMEM = -{ - {0x3800 ,0x1 }, - {0x3801 ,0xB0}, - {0x3802 ,0x0 }, - {0x3803 ,0xA }, - {0x3804 ,0xA }, - {0x3805 ,0x20}, - {0x3806 ,0x7 }, - {0x3807 ,0x98}, - {0x3808 ,0x6 }, - {0x3809 ,0x40}, - {0x380a ,0x4 }, - {0x380b ,0xB0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, - {0xffff, 0xff}, + { + {0x3800, 0x1}, + {0x3801, 0xB0}, + {0x3802, 0x0}, + {0x3803, 0xA}, + {0x3804, 0xA}, + {0x3805, 0x20}, + {0x3806, 0x7}, + {0x3807, 0x98}, + {0x3808, 0x6}, + {0x3809, 0x40}, + {0x380a, 0x4}, + {0x380b, 0xB0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, + {0xffff, 0xff}, }; const struct sensor_reg ov5642_1024x768[] PROGMEM = -{ - {0x3800 ,0x1 }, - {0x3801 ,0xB0}, - {0x3802 ,0x0 }, - {0x3803 ,0xA }, - {0x3804 ,0xA }, - {0x3805 ,0x20}, - {0x3806 ,0x7 }, - {0x3807 ,0x98}, - {0x3808 ,0x4 }, - {0x3809 ,0x0}, - {0x380a ,0x3 }, - {0x380b ,0x0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, - {0xffff, 0xff}, + { + {0x3800, 0x1}, + {0x3801, 0xB0}, + {0x3802, 0x0}, + {0x3803, 0xA}, + {0x3804, 0xA}, + {0x3805, 0x20}, + {0x3806, 0x7}, + {0x3807, 0x98}, + {0x3808, 0x4}, + {0x3809, 0x0}, + {0x380a, 0x3}, + {0x380b, 0x0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, + {0xffff, 0xff}, }; - - - const struct sensor_reg ov5642_2048x1536[] PROGMEM = -{ - {0x3800 ,0x01}, - {0x3801 ,0xb0}, - {0x3802 ,0x00}, - {0x3803 ,0x0a}, - {0x3804 ,0x0a}, - {0x3805 ,0x20}, - {0x3806 ,0x07}, - {0x3807 ,0x98}, - - {0x3808 ,0x08}, - {0x3809 ,0x00}, - {0x380a ,0x06}, - {0x380b ,0x00}, - - {0x380c ,0x0c}, - {0x380d ,0x80}, - {0x380e ,0x07}, - {0x380f ,0xd0}, - {0x3810 ,0xc2}, - {0x3815 ,0x44}, - {0x3818 ,0xa8}, - {0x3824 ,0x01}, - {0x3827 ,0x0a}, - {0x3a00 ,0x78}, - {0x3a0d ,0x10}, - {0x3a0e ,0x0d}, - {0x3a00 ,0x78}, - {0x460b ,0x35}, - {0x471d ,0x00}, - {0x471c ,0x50}, - {0x5682 ,0x0a}, - {0x5683 ,0x20}, - {0x5686 ,0x07}, - {0x5687 ,0x98}, - {0x589b ,0x00}, - {0x589a ,0xc0}, - {0x589b ,0x00}, - {0x589a ,0xc0}, - {0x3002 ,0x0c}, - {0x3002 ,0x00}, - {0x4300 ,0x32}, - {0x460b ,0x35}, - {0x3002 ,0x0c}, - {0x3002 ,0x00}, - {0x4713 ,0x02}, - {0x4600 ,0x80}, - {0x4721 ,0x02}, - {0x471c ,0x40}, - {0x4408 ,0x00}, - {0x460c ,0x22}, - {0x3815 ,0x04}, - {0x3818 ,0xc8}, - {0x501f ,0x00}, - {0x5002 ,0xe0}, - {0x440a ,0x01}, - {0x4402 ,0x90}, - {0x3811 ,0xf0}, - {0x3818, 0xa8}, - {0x3621, 0x10}, - {0xffff, 0xff}, + { + {0x3800, 0x01}, + {0x3801, 0xb0}, + {0x3802, 0x00}, + {0x3803, 0x0a}, + {0x3804, 0x0a}, + {0x3805, 0x20}, + {0x3806, 0x07}, + {0x3807, 0x98}, + + {0x3808, 0x08}, + {0x3809, 0x00}, + {0x380a, 0x06}, + {0x380b, 0x00}, + + {0x380c, 0x0c}, + {0x380d, 0x80}, + {0x380e, 0x07}, + {0x380f, 0xd0}, + {0x3810, 0xc2}, + {0x3815, 0x44}, + {0x3818, 0xa8}, + {0x3824, 0x01}, + {0x3827, 0x0a}, + {0x3a00, 0x78}, + {0x3a0d, 0x10}, + {0x3a0e, 0x0d}, + {0x3a00, 0x78}, + {0x460b, 0x35}, + {0x471d, 0x00}, + {0x471c, 0x50}, + {0x5682, 0x0a}, + {0x5683, 0x20}, + {0x5686, 0x07}, + {0x5687, 0x98}, + {0x589b, 0x00}, + {0x589a, 0xc0}, + {0x589b, 0x00}, + {0x589a, 0xc0}, + {0x3002, 0x0c}, + {0x3002, 0x00}, + {0x4300, 0x32}, + {0x460b, 0x35}, + {0x3002, 0x0c}, + {0x3002, 0x00}, + {0x4713, 0x02}, + {0x4600, 0x80}, + {0x4721, 0x02}, + {0x471c, 0x40}, + {0x4408, 0x00}, + {0x460c, 0x22}, + {0x3815, 0x04}, + {0x3818, 0xc8}, + {0x501f, 0x00}, + {0x5002, 0xe0}, + {0x440a, 0x01}, + {0x4402, 0x90}, + {0x3811, 0xf0}, + {0x3818, 0xa8}, + {0x3621, 0x10}, + {0xffff, 0xff}, }; const struct sensor_reg ov5642_2592x1944[] PROGMEM = -{ - {0x3800 ,0x1 }, - {0x3801 ,0xB0}, - {0x3802 ,0x0 }, - {0x3803 ,0xA }, - {0x3804 ,0xA }, - {0x3805 ,0x20}, - {0x3806 ,0x7 }, - {0x3807 ,0x98}, - {0x3808 ,0xA }, - {0x3809 ,0x20}, - {0x380a ,0x7 }, - {0x380b ,0x98}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0xA }, - {0x5683 ,0x20}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x7 }, - {0x5687 ,0x98}, - {0xffff, 0xff}, + { + {0x3800, 0x1}, + {0x3801, 0xB0}, + {0x3802, 0x0}, + {0x3803, 0xA}, + {0x3804, 0xA}, + {0x3805, 0x20}, + {0x3806, 0x7}, + {0x3807, 0x98}, + {0x3808, 0xA}, + {0x3809, 0x20}, + {0x380a, 0x7}, + {0x380b, 0x98}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0xA}, + {0x5683, 0x20}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x7}, + {0x5687, 0x98}, + {0xffff, 0xff}, }; -const struct sensor_reg ov5642_dvp_zoom8[] PROGMEM= -{ - - {0x3800 ,0x5 }, - {0x3801 ,0xf8}, - {0x3802 ,0x3 }, - {0x3803 ,0x5c}, - {0x3804 ,0x1 }, - {0x3805 ,0x44}, - {0x3806 ,0x0 }, - {0x3807 ,0xf0}, - {0x3808 ,0x1 }, - {0x3809 ,0x40}, - {0x380a ,0x0 }, - {0x380b ,0xf0}, - {0x380c ,0xc }, - {0x380d ,0x80}, - {0x380e ,0x7 }, - {0x380f ,0xd0}, - - {0x5001 ,0x7f}, - {0x5680 ,0x0 }, - {0x5681 ,0x0 }, - {0x5682 ,0x1 }, - {0x5683 ,0x44}, - {0x5684 ,0x0 }, - {0x5685 ,0x0 }, - {0x5686 ,0x0 }, - {0x5687 ,0xf3}, - /* - {0x381c ,0x21}, - {0x3524 ,0x0 }, - {0x3825 ,0x0 }, - {0x3826 ,0x0 }, - {0x3827 ,0x0 }, - {0x3010 ,0x70}, -*/ - - {0xffff, 0xff}, +const struct sensor_reg ov5642_dvp_zoom8[] PROGMEM = + { + + {0x3800, 0x5}, + {0x3801, 0xf8}, + {0x3802, 0x3}, + {0x3803, 0x5c}, + {0x3804, 0x1}, + {0x3805, 0x44}, + {0x3806, 0x0}, + {0x3807, 0xf0}, + {0x3808, 0x1}, + {0x3809, 0x40}, + {0x380a, 0x0}, + {0x380b, 0xf0}, + {0x380c, 0xc}, + {0x380d, 0x80}, + {0x380e, 0x7}, + {0x380f, 0xd0}, + + {0x5001, 0x7f}, + {0x5680, 0x0}, + {0x5681, 0x0}, + {0x5682, 0x1}, + {0x5683, 0x44}, + {0x5684, 0x0}, + {0x5685, 0x0}, + {0x5686, 0x0}, + {0x5687, 0xf3}, + /* + {0x381c ,0x21}, + {0x3524 ,0x0 }, + {0x3825 ,0x0 }, + {0x3826 ,0x0 }, + {0x3827 ,0x0 }, + {0x3010 ,0x70}, + */ + + {0xffff, 0xff}, }; const struct sensor_reg OV5642_QVGA_Preview[] PROGMEM = -{ - {0x3103 ,0x93}, - {0x3008 ,0x82}, - {0x3017 ,0x7f}, - {0x3018 ,0xfc}, - {0x3810 ,0xc2}, - {0x3615 ,0xf0}, - {0x3000 ,0x00}, - {0x3001 ,0x00}, - {0x3002 ,0x5c}, - {0x3003 ,0x00}, - {0x3004 ,0xff}, - {0x3005 ,0xff}, - {0x3006 ,0x43}, - {0x3007 ,0x37}, - {0x3011 ,0x08}, - {0x3010 ,0x10}, - {0x460c ,0x22}, - {0x3815 ,0x04}, - {0x370c ,0xa0}, - {0x3602 ,0xfc}, - {0x3612 ,0xff}, - {0x3634 ,0xc0}, - {0x3613 ,0x00}, - {0x3605 ,0x7c}, - {0x3621 ,0x09}, - {0x3622 ,0x60}, - {0x3604 ,0x40}, - {0x3603 ,0xa7}, - {0x3603 ,0x27}, - {0x4000 ,0x21}, - {0x401d ,0x22}, - {0x3600 ,0x54}, - {0x3605 ,0x04}, - {0x3606 ,0x3f}, - {0x3c01 ,0x80}, - {0x5000 ,0x4f}, - {0x5020 ,0x04}, - {0x5181 ,0x79}, - {0x5182 ,0x00}, - {0x5185 ,0x22}, - {0x5197 ,0x01}, - {0x5001 ,0xff}, - {0x5500 ,0x0a}, - {0x5504 ,0x00}, - {0x5505 ,0x7f}, - {0x5080 ,0x08}, - {0x300e ,0x18}, - {0x4610 ,0x00}, - {0x471d ,0x05}, - {0x4708 ,0x06}, - {0x3808 ,0x02}, - {0x3809 ,0x80}, - {0x380a ,0x01}, - {0x380b ,0xe0}, - {0x380e ,0x07}, - {0x380f ,0xd0}, - {0x501f ,0x00}, - {0x5000 ,0x4f}, - {0x4300 ,0x30}, - {0x3503 ,0x07}, - {0x3501 ,0x73}, - {0x3502 ,0x80}, - {0x350b ,0x00}, - {0x3503 ,0x07}, - {0x3824 ,0x11}, - {0x3501 ,0x1e}, - {0x3502 ,0x80}, - {0x350b ,0x7f}, - {0x380c ,0x0c}, - {0x380d ,0x80}, - {0x380e ,0x03}, - {0x380f ,0xe8}, - {0x3a0d ,0x04}, - {0x3a0e ,0x03}, - {0x3818 ,0xc1}, - {0x3705 ,0xdb}, - {0x370a ,0x81}, - {0x3801 ,0x80}, - {0x3621 ,0x87}, - {0x3801 ,0x50}, - {0x3803 ,0x08}, - {0x3827 ,0x08}, - {0x3810 ,0x40}, - {0x3804 ,0x05}, - {0x3805 ,0x00}, - {0x5682 ,0x05}, - {0x5683 ,0x00}, - {0x3806 ,0x03}, - {0x3807 ,0xc0}, - {0x5686 ,0x03}, - {0x5687 ,0xbc}, - {0x3a00 ,0x78}, - {0x3a1a ,0x05}, - {0x3a13 ,0x30}, - {0x3a18 ,0x00}, - {0x3a19 ,0x7c}, - {0x3a08 ,0x12}, - {0x3a09 ,0xc0}, - {0x3a0a ,0x0f}, - {0x3a0b ,0xa0}, - {0x350c ,0x07}, - {0x350d ,0xd0}, - {0x3500 ,0x00}, - {0x3501 ,0x00}, - {0x3502 ,0x00}, - {0x350a ,0x00}, - {0x350b ,0x00}, - {0x3503 ,0x00}, - {0x528a ,0x02}, - {0x528b ,0x04}, - {0x528c ,0x08}, - {0x528d ,0x08}, - {0x528e ,0x08}, - {0x528f ,0x10}, - {0x5290 ,0x10}, - {0x5292 ,0x00}, - {0x5293 ,0x02}, - {0x5294 ,0x00}, - {0x5295 ,0x02}, - {0x5296 ,0x00}, - {0x5297 ,0x02}, - {0x5298 ,0x00}, - {0x5299 ,0x02}, - {0x529a ,0x00}, - {0x529b ,0x02}, - {0x529c ,0x00}, - {0x529d ,0x02}, - {0x529e ,0x00}, - {0x529f ,0x02}, - {0x3030 ,0x0b}, - {0x3a02 ,0x00}, - {0x3a03 ,0x7d}, - {0x3a04 ,0x00}, - {0x3a14 ,0x00}, - {0x3a15 ,0x7d}, - {0x3a16 ,0x00}, - {0x3a00 ,0x78}, - {0x3a08 ,0x09}, - {0x3a09 ,0x60}, - {0x3a0a ,0x07}, - {0x3a0b ,0xd0}, - {0x3a0d ,0x08}, - {0x3a0e ,0x06}, - {0x5193 ,0x70}, - {0x589b ,0x04}, - {0x589a ,0xc5}, - {0x401e ,0x20}, - {0x4001 ,0x42}, - {0x401c ,0x04}, - {0x528a ,0x01}, - {0x528b ,0x04}, - {0x528c ,0x08}, - {0x528d ,0x10}, - {0x528e ,0x20}, - {0x528f ,0x28}, - {0x5290 ,0x30}, - {0x5292 ,0x00}, - {0x5293 ,0x01}, - {0x5294 ,0x00}, - {0x5295 ,0x04}, - {0x5296 ,0x00}, - {0x5297 ,0x08}, - {0x5298 ,0x00}, - {0x5299 ,0x10}, - {0x529a ,0x00}, - {0x529b ,0x20}, - {0x529c ,0x00}, - {0x529d ,0x28}, - {0x529e ,0x00}, - {0x529f ,0x30}, - {0x5282 ,0x00}, - {0x5300 ,0x00}, - {0x5301 ,0x20}, - {0x5302 ,0x00}, - {0x5303 ,0x7c}, - {0x530c ,0x00}, - {0x530d ,0x0c}, - {0x530e ,0x20}, - {0x530f ,0x80}, - {0x5310 ,0x20}, - {0x5311 ,0x80}, - {0x5308 ,0x20}, - {0x5309 ,0x40}, - {0x5304 ,0x00}, - {0x5305 ,0x30}, - {0x5306 ,0x00}, - {0x5307 ,0x80}, - {0x5314 ,0x08}, - {0x5315 ,0x20}, - {0x5319 ,0x30}, - {0x5316 ,0x10}, - {0x5317 ,0x00}, - {0x5318 ,0x02}, - {0x5402 ,0x3f}, - {0x5403 ,0x00}, - {0x3406 ,0x00}, - {0x5180 ,0xff}, - {0x5181 ,0x52}, - {0x5182 ,0x11}, - {0x5183 ,0x14}, - {0x5184 ,0x25}, - {0x5185 ,0x24}, - {0x5186 ,0x06}, - {0x5187 ,0x08}, - {0x5188 ,0x08}, - {0x5189 ,0x7c}, - {0x518a ,0x60}, - {0x518b ,0xb2}, - {0x518c ,0xb2}, - {0x518d ,0x44}, - {0x518e ,0x3d}, - {0x518f ,0x58}, - {0x5190 ,0x46}, - {0x5191 ,0xf8}, - {0x5192 ,0x04}, - {0x5193 ,0x70}, - {0x5194 ,0xf0}, - {0x5195 ,0xf0}, - {0x5196 ,0x03}, - {0x5197 ,0x01}, - {0x5198 ,0x04}, - {0x5199 ,0x12}, - {0x519a ,0x04}, - {0x519b ,0x00}, - {0x519c ,0x06}, - {0x519d ,0x82}, - {0x519e ,0x00}, - {0x5025 ,0x80}, - {0x5583 ,0x40}, - {0x5584 ,0x40}, - {0x5580 ,0x02}, - {0x5000 ,0xcf}, - {0x3710 ,0x10}, - {0x3632 ,0x51}, - {0x3702 ,0x10}, - {0x3703 ,0xb2}, - {0x3704 ,0x18}, - {0x370b ,0x40}, - {0x370d ,0x03}, - {0x3631 ,0x01}, - {0x3632 ,0x52}, - {0x3606 ,0x24}, - {0x3620 ,0x96}, - {0x5785 ,0x07}, - {0x3a13 ,0x30}, - {0x3600 ,0x52}, - {0x3604 ,0x48}, - {0x3606 ,0x1b}, - {0x370d ,0x0b}, - {0x370f ,0xc0}, - {0x3709 ,0x01}, - {0x3823 ,0x00}, - {0x5007 ,0x00}, - {0x5009 ,0x00}, - {0x5011 ,0x00}, - {0x5013 ,0x00}, - {0x519e ,0x00}, - {0x5086 ,0x00}, - {0x5087 ,0x00}, - {0x5088 ,0x00}, - {0x5089 ,0x00}, - {0x302b ,0x00}, - {0x3808 ,0x01}, - {0x3809 ,0x40}, - {0x380a ,0x00}, - {0x380b ,0xf0}, - {0x3a00 ,0x78}, - {0x5001 ,0xFF}, - {0x5583 ,0x50}, - {0x5584 ,0x50}, - {0x5580 ,0x02}, - {0x3c01 ,0x80}, - {0x3c00 ,0x04}, - - {0x5800 ,0x48}, - {0x5801 ,0x31}, - {0x5802 ,0x21}, - {0x5803 ,0x1b}, - {0x5804 ,0x1a}, - {0x5805 ,0x1e}, - {0x5806 ,0x29}, - {0x5807 ,0x38}, - {0x5808 ,0x26}, - {0x5809 ,0x17}, - {0x580a ,0x11}, - {0x580b ,0xe }, - {0x580c ,0xd }, - {0x580d ,0xe }, - {0x580e ,0x13}, - {0x580f ,0x1a}, - {0x5810 ,0x15}, - {0x5811 ,0xd }, - {0x5812 ,0x8 }, - {0x5813 ,0x5 }, - {0x5814 ,0x4 }, - {0x5815 ,0x5 }, - {0x5816 ,0x9 }, - {0x5817 ,0xd }, - {0x5818 ,0x11}, - {0x5819 ,0xa }, - {0x581a ,0x4 }, - {0x581b ,0x0 }, - {0x581c ,0x0 }, - {0x581d ,0x1 }, - {0x581e ,0x6 }, - {0x581f ,0x9 }, - {0x5820 ,0x12}, - {0x5821 ,0xb }, - {0x5822 ,0x4 }, - {0x5823 ,0x0 }, - {0x5824 ,0x0 }, - {0x5825 ,0x1 }, - {0x5826 ,0x6 }, - {0x5827 ,0xa }, - {0x5828 ,0x17}, - {0x5829 ,0xf }, - {0x582a ,0x9 }, - {0x582b ,0x6 }, - {0x582c ,0x5 }, - {0x582d ,0x6 }, - {0x582e ,0xa }, - {0x582f ,0xe }, - {0x5830 ,0x28}, - {0x5831 ,0x1a}, - {0x5832 ,0x11}, - {0x5833 ,0xe }, - {0x5834 ,0xe }, - {0x5835 ,0xf }, - {0x5836 ,0x15}, - {0x5837 ,0x1d}, - {0x5838 ,0x6e}, - {0x5839 ,0x39}, - {0x583a ,0x27}, - {0x583b ,0x1f}, - {0x583c ,0x1e}, - {0x583d ,0x23}, - {0x583e ,0x2f}, - {0x583f ,0x41}, - {0x5840 ,0xe }, - {0x5841 ,0xc }, - {0x5842 ,0xd }, - {0x5843 ,0xc }, - {0x5844 ,0xc }, - {0x5845 ,0xc }, - {0x5846 ,0xc }, - {0x5847 ,0xc }, - {0x5848 ,0xd }, - {0x5849 ,0xe }, - {0x584a ,0xe }, - {0x584b ,0xa }, - {0x584c ,0xe }, - {0x584d ,0xe }, - {0x584e ,0x10}, - {0x584f ,0x10}, - {0x5850 ,0x11}, - {0x5851 ,0xa }, - {0x5852 ,0xf }, - {0x5853 ,0xe }, - {0x5854 ,0x10}, - {0x5855 ,0x10}, - {0x5856 ,0x10}, - {0x5857 ,0xa }, - {0x5858 ,0xe }, - {0x5859 ,0xe }, - {0x585a ,0xf }, - {0x585b ,0xf }, - {0x585c ,0xf }, - {0x585d ,0xa }, - {0x585e ,0x9 }, - {0x585f ,0xd }, - {0x5860 ,0xc }, - {0x5861 ,0xb }, - {0x5862 ,0xd }, - {0x5863 ,0x7 }, - {0x5864 ,0x17}, - {0x5865 ,0x14}, - {0x5866 ,0x18}, - {0x5867 ,0x18}, - {0x5868 ,0x16}, - {0x5869 ,0x12}, - {0x586a ,0x1b}, - {0x586b ,0x1a}, - {0x586c ,0x16}, - {0x586d ,0x16}, - {0x586e ,0x18}, - {0x586f ,0x1f}, - {0x5870 ,0x1c}, - {0x5871 ,0x16}, - {0x5872 ,0x10}, - {0x5873 ,0xf }, - {0x5874 ,0x13}, - {0x5875 ,0x1c}, - {0x5876 ,0x1e}, - {0x5877 ,0x17}, - {0x5878 ,0x11}, - {0x5879 ,0x11}, - {0x587a ,0x14}, - {0x587b ,0x1e}, - {0x587c ,0x1c}, - {0x587d ,0x1c}, - {0x587e ,0x1a}, - {0x587f ,0x1a}, - {0x5880 ,0x1b}, - {0x5881 ,0x1f}, - {0x5882 ,0x14}, - {0x5883 ,0x1a}, - {0x5884 ,0x1d}, - {0x5885 ,0x1e}, - {0x5886 ,0x1a}, - {0x5887 ,0x1a}, - - {0x5180 ,0xff}, - {0x5181 ,0x52}, - {0x5182 ,0x11}, - {0x5183 ,0x14}, - {0x5184 ,0x25}, - {0x5185 ,0x24}, - {0x5186 ,0x14}, - {0x5187 ,0x14}, - {0x5188 ,0x14}, - {0x5189 ,0x69}, - {0x518a ,0x60}, - {0x518b ,0xa2}, - {0x518c ,0x9c}, - {0x518d ,0x36}, - {0x518e ,0x34}, - {0x518f ,0x54}, - {0x5190 ,0x4c}, - {0x5191 ,0xf8}, - {0x5192 ,0x04}, - {0x5193 ,0x70}, - {0x5194 ,0xf0}, - {0x5195 ,0xf0}, - {0x5196 ,0x03}, - {0x5197 ,0x01}, - {0x5198 ,0x05}, - {0x5199 ,0x2f}, - {0x519a ,0x04}, - {0x519b ,0x00}, - {0x519c ,0x06}, - {0x519d ,0xa0}, - {0x519e ,0xa0}, - - {0x528a ,0x00}, - {0x528b ,0x01}, - {0x528c ,0x04}, - {0x528d ,0x08}, - {0x528e ,0x10}, - {0x528f ,0x20}, - {0x5290 ,0x30}, - {0x5292 ,0x00}, - {0x5293 ,0x00}, - {0x5294 ,0x00}, - {0x5295 ,0x01}, - {0x5296 ,0x00}, - {0x5297 ,0x04}, - {0x5298 ,0x00}, - {0x5299 ,0x08}, - {0x529a ,0x00}, - {0x529b ,0x10}, - {0x529c ,0x00}, - {0x529d ,0x20}, - {0x529e ,0x00}, - {0x529f ,0x30}, - {0x5282 ,0x00}, - {0x5300 ,0x00}, - {0x5301 ,0x20}, - {0x5302 ,0x00}, - {0x5303 ,0x7c}, - {0x530c ,0x00}, - {0x530d ,0x10}, - {0x530e ,0x20}, - {0x530f ,0x80}, - {0x5310 ,0x20}, - {0x5311 ,0x80}, - {0x5308 ,0x20}, - {0x5309 ,0x40}, - {0x5304 ,0x00}, - {0x5305 ,0x30}, - {0x5306 ,0x00}, - {0x5307 ,0x80}, - {0x5314 ,0x08}, - {0x5315 ,0x20}, - {0x5319 ,0x30}, - {0x5316 ,0x10}, - {0x5317 ,0x00}, - {0x5318 ,0x02}, - - {0x5380 ,0x01}, - {0x5381 ,0x00}, - {0x5382 ,0x00}, - {0x5383 ,0x1f}, - {0x5384 ,0x00}, - {0x5385 ,0x06}, - {0x5386 ,0x00}, - {0x5387 ,0x00}, - {0x5388 ,0x00}, - {0x5389 ,0xE1}, - {0x538A ,0x00}, - {0x538B ,0x2B}, - {0x538C ,0x00}, - {0x538D ,0x00}, - {0x538E ,0x00}, - {0x538F ,0x10}, - {0x5390 ,0x00}, - {0x5391 ,0xB3}, - {0x5392 ,0x00}, - {0x5393 ,0xA6}, - {0x5394 ,0x08}, - - {0x5480 ,0x0c}, - {0x5481 ,0x18}, - {0x5482 ,0x2f}, - {0x5483 ,0x55}, - {0x5484 ,0x64}, - {0x5485 ,0x71}, - {0x5486 ,0x7d}, - {0x5487 ,0x87}, - {0x5488 ,0x91}, - {0x5489 ,0x9a}, - {0x548A ,0xaa}, - {0x548B ,0xb8}, - {0x548C ,0xcd}, - {0x548D ,0xdd}, - {0x548E ,0xea}, - {0x548F ,0x1d}, - {0x5490 ,0x05}, - {0x5491 ,0x00}, - {0x5492 ,0x04}, - {0x5493 ,0x20}, - {0x5494 ,0x03}, - {0x5495 ,0x60}, - {0x5496 ,0x02}, - {0x5497 ,0xB8}, - {0x5498 ,0x02}, - {0x5499 ,0x86}, - {0x549A ,0x02}, - {0x549B ,0x5B}, - {0x549C ,0x02}, - {0x549D ,0x3B}, - {0x549E ,0x02}, - {0x549F ,0x1C}, - {0x54A0 ,0x02}, - {0x54A1 ,0x04}, - {0x54A2 ,0x01}, - {0x54A3 ,0xED}, - {0x54A4 ,0x01}, - {0x54A5 ,0xC5}, - {0x54A6 ,0x01}, - {0x54A7 ,0xA5}, - {0x54A8 ,0x01}, - {0x54A9 ,0x6C}, - {0x54AA ,0x01}, - {0x54AB ,0x41}, - {0x54AC ,0x01}, - {0x54AD ,0x20}, - {0x54AE ,0x00}, - {0x54AF ,0x16}, - {0x54B0 ,0x01}, - {0x54B1 ,0x20}, - {0x54B2 ,0x00}, - {0x54B3 ,0x10}, - {0x54B4 ,0x00}, - {0x54B5 ,0xf0}, - {0x54B6 ,0x00}, - {0x54B7 ,0xDF}, - {0x5402 ,0x3f}, - {0x5403 ,0x00}, - - {0x5500 ,0x10}, - {0x5502 ,0x00}, - {0x5503 ,0x06}, - {0x5504 ,0x00}, - {0x5505 ,0x7f}, - - {0x5025 ,0x80}, - {0x3a0f ,0x30}, - {0x3a10 ,0x28}, - {0x3a1b ,0x30}, - {0x3a1e ,0x28}, - {0x3a11 ,0x61}, - {0x3a1f ,0x10}, - {0x5688 ,0xfd}, - {0x5689 ,0xdf}, - {0x568a ,0xfe}, - {0x568b ,0xef}, - {0x568c ,0xfe}, - {0x568d ,0xef}, - {0x568e ,0xaa}, - {0x568f ,0xaa}, - - - - {0xffff,0xff}, -}; + { + {0x3103, 0x93}, + {0x3008, 0x82}, + {0x3017, 0x7f}, + {0x3018, 0xfc}, + {0x3810, 0xc2}, + {0x3615, 0xf0}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x5c}, + {0x3003, 0x00}, + {0x3004, 0xff}, + {0x3005, 0xff}, + {0x3006, 0x43}, + {0x3007, 0x37}, + {0x3011, 0x08}, + {0x3010, 0x10}, + {0x460c, 0x22}, + {0x3815, 0x04}, + {0x370c, 0xa0}, + {0x3602, 0xfc}, + {0x3612, 0xff}, + {0x3634, 0xc0}, + {0x3613, 0x00}, + {0x3605, 0x7c}, + {0x3621, 0x09}, + {0x3622, 0x60}, + {0x3604, 0x40}, + {0x3603, 0xa7}, + {0x3603, 0x27}, + {0x4000, 0x21}, + {0x401d, 0x22}, + {0x3600, 0x54}, + {0x3605, 0x04}, + {0x3606, 0x3f}, + {0x3c01, 0x80}, + {0x5000, 0x4f}, + {0x5020, 0x04}, + {0x5181, 0x79}, + {0x5182, 0x00}, + {0x5185, 0x22}, + {0x5197, 0x01}, + {0x5001, 0xff}, + {0x5500, 0x0a}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + {0x5080, 0x08}, + {0x300e, 0x18}, + {0x4610, 0x00}, + {0x471d, 0x05}, + {0x4708, 0x06}, + {0x3808, 0x02}, + {0x3809, 0x80}, + {0x380a, 0x01}, + {0x380b, 0xe0}, + {0x380e, 0x07}, + {0x380f, 0xd0}, + {0x501f, 0x00}, + {0x5000, 0x4f}, + {0x4300, 0x30}, + {0x3503, 0x07}, + {0x3501, 0x73}, + {0x3502, 0x80}, + {0x350b, 0x00}, + {0x3503, 0x07}, + {0x3824, 0x11}, + {0x3501, 0x1e}, + {0x3502, 0x80}, + {0x350b, 0x7f}, + {0x380c, 0x0c}, + {0x380d, 0x80}, + {0x380e, 0x03}, + {0x380f, 0xe8}, + {0x3a0d, 0x04}, + {0x3a0e, 0x03}, + {0x3818, 0xc1}, + {0x3705, 0xdb}, + {0x370a, 0x81}, + {0x3801, 0x80}, + {0x3621, 0x87}, + {0x3801, 0x50}, + {0x3803, 0x08}, + {0x3827, 0x08}, + {0x3810, 0x40}, + {0x3804, 0x05}, + {0x3805, 0x00}, + {0x5682, 0x05}, + {0x5683, 0x00}, + {0x3806, 0x03}, + {0x3807, 0xc0}, + {0x5686, 0x03}, + {0x5687, 0xbc}, + {0x3a00, 0x78}, + {0x3a1a, 0x05}, + {0x3a13, 0x30}, + {0x3a18, 0x00}, + {0x3a19, 0x7c}, + {0x3a08, 0x12}, + {0x3a09, 0xc0}, + {0x3a0a, 0x0f}, + {0x3a0b, 0xa0}, + {0x350c, 0x07}, + {0x350d, 0xd0}, + {0x3500, 0x00}, + {0x3501, 0x00}, + {0x3502, 0x00}, + {0x350a, 0x00}, + {0x350b, 0x00}, + {0x3503, 0x00}, + {0x528a, 0x02}, + {0x528b, 0x04}, + {0x528c, 0x08}, + {0x528d, 0x08}, + {0x528e, 0x08}, + {0x528f, 0x10}, + {0x5290, 0x10}, + {0x5292, 0x00}, + {0x5293, 0x02}, + {0x5294, 0x00}, + {0x5295, 0x02}, + {0x5296, 0x00}, + {0x5297, 0x02}, + {0x5298, 0x00}, + {0x5299, 0x02}, + {0x529a, 0x00}, + {0x529b, 0x02}, + {0x529c, 0x00}, + {0x529d, 0x02}, + {0x529e, 0x00}, + {0x529f, 0x02}, + {0x3030, 0x0b}, + {0x3a02, 0x00}, + {0x3a03, 0x7d}, + {0x3a04, 0x00}, + {0x3a14, 0x00}, + {0x3a15, 0x7d}, + {0x3a16, 0x00}, + {0x3a00, 0x78}, + {0x3a08, 0x09}, + {0x3a09, 0x60}, + {0x3a0a, 0x07}, + {0x3a0b, 0xd0}, + {0x3a0d, 0x08}, + {0x3a0e, 0x06}, + {0x5193, 0x70}, + {0x589b, 0x04}, + {0x589a, 0xc5}, + {0x401e, 0x20}, + {0x4001, 0x42}, + {0x401c, 0x04}, + {0x528a, 0x01}, + {0x528b, 0x04}, + {0x528c, 0x08}, + {0x528d, 0x10}, + {0x528e, 0x20}, + {0x528f, 0x28}, + {0x5290, 0x30}, + {0x5292, 0x00}, + {0x5293, 0x01}, + {0x5294, 0x00}, + {0x5295, 0x04}, + {0x5296, 0x00}, + {0x5297, 0x08}, + {0x5298, 0x00}, + {0x5299, 0x10}, + {0x529a, 0x00}, + {0x529b, 0x20}, + {0x529c, 0x00}, + {0x529d, 0x28}, + {0x529e, 0x00}, + {0x529f, 0x30}, + {0x5282, 0x00}, + {0x5300, 0x00}, + {0x5301, 0x20}, + {0x5302, 0x00}, + {0x5303, 0x7c}, + {0x530c, 0x00}, + {0x530d, 0x0c}, + {0x530e, 0x20}, + {0x530f, 0x80}, + {0x5310, 0x20}, + {0x5311, 0x80}, + {0x5308, 0x20}, + {0x5309, 0x40}, + {0x5304, 0x00}, + {0x5305, 0x30}, + {0x5306, 0x00}, + {0x5307, 0x80}, + {0x5314, 0x08}, + {0x5315, 0x20}, + {0x5319, 0x30}, + {0x5316, 0x10}, + {0x5317, 0x00}, + {0x5318, 0x02}, + {0x5402, 0x3f}, + {0x5403, 0x00}, + {0x3406, 0x00}, + {0x5180, 0xff}, + {0x5181, 0x52}, + {0x5182, 0x11}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x06}, + {0x5187, 0x08}, + {0x5188, 0x08}, + {0x5189, 0x7c}, + {0x518a, 0x60}, + {0x518b, 0xb2}, + {0x518c, 0xb2}, + {0x518d, 0x44}, + {0x518e, 0x3d}, + {0x518f, 0x58}, + {0x5190, 0x46}, + {0x5191, 0xf8}, + {0x5192, 0x04}, + {0x5193, 0x70}, + {0x5194, 0xf0}, + {0x5195, 0xf0}, + {0x5196, 0x03}, + {0x5197, 0x01}, + {0x5198, 0x04}, + {0x5199, 0x12}, + {0x519a, 0x04}, + {0x519b, 0x00}, + {0x519c, 0x06}, + {0x519d, 0x82}, + {0x519e, 0x00}, + {0x5025, 0x80}, + {0x5583, 0x40}, + {0x5584, 0x40}, + {0x5580, 0x02}, + {0x5000, 0xcf}, + {0x3710, 0x10}, + {0x3632, 0x51}, + {0x3702, 0x10}, + {0x3703, 0xb2}, + {0x3704, 0x18}, + {0x370b, 0x40}, + {0x370d, 0x03}, + {0x3631, 0x01}, + {0x3632, 0x52}, + {0x3606, 0x24}, + {0x3620, 0x96}, + {0x5785, 0x07}, + {0x3a13, 0x30}, + {0x3600, 0x52}, + {0x3604, 0x48}, + {0x3606, 0x1b}, + {0x370d, 0x0b}, + {0x370f, 0xc0}, + {0x3709, 0x01}, + {0x3823, 0x00}, + {0x5007, 0x00}, + {0x5009, 0x00}, + {0x5011, 0x00}, + {0x5013, 0x00}, + {0x519e, 0x00}, + {0x5086, 0x00}, + {0x5087, 0x00}, + {0x5088, 0x00}, + {0x5089, 0x00}, + {0x302b, 0x00}, + {0x3808, 0x01}, + {0x3809, 0x40}, + {0x380a, 0x00}, + {0x380b, 0xf0}, + {0x3a00, 0x78}, + {0x5001, 0xFF}, + {0x5583, 0x50}, + {0x5584, 0x50}, + {0x5580, 0x02}, + {0x3c01, 0x80}, + {0x3c00, 0x04}, + + {0x5800, 0x48}, + {0x5801, 0x31}, + {0x5802, 0x21}, + {0x5803, 0x1b}, + {0x5804, 0x1a}, + {0x5805, 0x1e}, + {0x5806, 0x29}, + {0x5807, 0x38}, + {0x5808, 0x26}, + {0x5809, 0x17}, + {0x580a, 0x11}, + {0x580b, 0xe}, + {0x580c, 0xd}, + {0x580d, 0xe}, + {0x580e, 0x13}, + {0x580f, 0x1a}, + {0x5810, 0x15}, + {0x5811, 0xd}, + {0x5812, 0x8}, + {0x5813, 0x5}, + {0x5814, 0x4}, + {0x5815, 0x5}, + {0x5816, 0x9}, + {0x5817, 0xd}, + {0x5818, 0x11}, + {0x5819, 0xa}, + {0x581a, 0x4}, + {0x581b, 0x0}, + {0x581c, 0x0}, + {0x581d, 0x1}, + {0x581e, 0x6}, + {0x581f, 0x9}, + {0x5820, 0x12}, + {0x5821, 0xb}, + {0x5822, 0x4}, + {0x5823, 0x0}, + {0x5824, 0x0}, + {0x5825, 0x1}, + {0x5826, 0x6}, + {0x5827, 0xa}, + {0x5828, 0x17}, + {0x5829, 0xf}, + {0x582a, 0x9}, + {0x582b, 0x6}, + {0x582c, 0x5}, + {0x582d, 0x6}, + {0x582e, 0xa}, + {0x582f, 0xe}, + {0x5830, 0x28}, + {0x5831, 0x1a}, + {0x5832, 0x11}, + {0x5833, 0xe}, + {0x5834, 0xe}, + {0x5835, 0xf}, + {0x5836, 0x15}, + {0x5837, 0x1d}, + {0x5838, 0x6e}, + {0x5839, 0x39}, + {0x583a, 0x27}, + {0x583b, 0x1f}, + {0x583c, 0x1e}, + {0x583d, 0x23}, + {0x583e, 0x2f}, + {0x583f, 0x41}, + {0x5840, 0xe}, + {0x5841, 0xc}, + {0x5842, 0xd}, + {0x5843, 0xc}, + {0x5844, 0xc}, + {0x5845, 0xc}, + {0x5846, 0xc}, + {0x5847, 0xc}, + {0x5848, 0xd}, + {0x5849, 0xe}, + {0x584a, 0xe}, + {0x584b, 0xa}, + {0x584c, 0xe}, + {0x584d, 0xe}, + {0x584e, 0x10}, + {0x584f, 0x10}, + {0x5850, 0x11}, + {0x5851, 0xa}, + {0x5852, 0xf}, + {0x5853, 0xe}, + {0x5854, 0x10}, + {0x5855, 0x10}, + {0x5856, 0x10}, + {0x5857, 0xa}, + {0x5858, 0xe}, + {0x5859, 0xe}, + {0x585a, 0xf}, + {0x585b, 0xf}, + {0x585c, 0xf}, + {0x585d, 0xa}, + {0x585e, 0x9}, + {0x585f, 0xd}, + {0x5860, 0xc}, + {0x5861, 0xb}, + {0x5862, 0xd}, + {0x5863, 0x7}, + {0x5864, 0x17}, + {0x5865, 0x14}, + {0x5866, 0x18}, + {0x5867, 0x18}, + {0x5868, 0x16}, + {0x5869, 0x12}, + {0x586a, 0x1b}, + {0x586b, 0x1a}, + {0x586c, 0x16}, + {0x586d, 0x16}, + {0x586e, 0x18}, + {0x586f, 0x1f}, + {0x5870, 0x1c}, + {0x5871, 0x16}, + {0x5872, 0x10}, + {0x5873, 0xf}, + {0x5874, 0x13}, + {0x5875, 0x1c}, + {0x5876, 0x1e}, + {0x5877, 0x17}, + {0x5878, 0x11}, + {0x5879, 0x11}, + {0x587a, 0x14}, + {0x587b, 0x1e}, + {0x587c, 0x1c}, + {0x587d, 0x1c}, + {0x587e, 0x1a}, + {0x587f, 0x1a}, + {0x5880, 0x1b}, + {0x5881, 0x1f}, + {0x5882, 0x14}, + {0x5883, 0x1a}, + {0x5884, 0x1d}, + {0x5885, 0x1e}, + {0x5886, 0x1a}, + {0x5887, 0x1a}, + + {0x5180, 0xff}, + {0x5181, 0x52}, + {0x5182, 0x11}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x14}, + {0x5187, 0x14}, + {0x5188, 0x14}, + {0x5189, 0x69}, + {0x518a, 0x60}, + {0x518b, 0xa2}, + {0x518c, 0x9c}, + {0x518d, 0x36}, + {0x518e, 0x34}, + {0x518f, 0x54}, + {0x5190, 0x4c}, + {0x5191, 0xf8}, + {0x5192, 0x04}, + {0x5193, 0x70}, + {0x5194, 0xf0}, + {0x5195, 0xf0}, + {0x5196, 0x03}, + {0x5197, 0x01}, + {0x5198, 0x05}, + {0x5199, 0x2f}, + {0x519a, 0x04}, + {0x519b, 0x00}, + {0x519c, 0x06}, + {0x519d, 0xa0}, + {0x519e, 0xa0}, + + {0x528a, 0x00}, + {0x528b, 0x01}, + {0x528c, 0x04}, + {0x528d, 0x08}, + {0x528e, 0x10}, + {0x528f, 0x20}, + {0x5290, 0x30}, + {0x5292, 0x00}, + {0x5293, 0x00}, + {0x5294, 0x00}, + {0x5295, 0x01}, + {0x5296, 0x00}, + {0x5297, 0x04}, + {0x5298, 0x00}, + {0x5299, 0x08}, + {0x529a, 0x00}, + {0x529b, 0x10}, + {0x529c, 0x00}, + {0x529d, 0x20}, + {0x529e, 0x00}, + {0x529f, 0x30}, + {0x5282, 0x00}, + {0x5300, 0x00}, + {0x5301, 0x20}, + {0x5302, 0x00}, + {0x5303, 0x7c}, + {0x530c, 0x00}, + {0x530d, 0x10}, + {0x530e, 0x20}, + {0x530f, 0x80}, + {0x5310, 0x20}, + {0x5311, 0x80}, + {0x5308, 0x20}, + {0x5309, 0x40}, + {0x5304, 0x00}, + {0x5305, 0x30}, + {0x5306, 0x00}, + {0x5307, 0x80}, + {0x5314, 0x08}, + {0x5315, 0x20}, + {0x5319, 0x30}, + {0x5316, 0x10}, + {0x5317, 0x00}, + {0x5318, 0x02}, + + {0x5380, 0x01}, + {0x5381, 0x00}, + {0x5382, 0x00}, + {0x5383, 0x1f}, + {0x5384, 0x00}, + {0x5385, 0x06}, + {0x5386, 0x00}, + {0x5387, 0x00}, + {0x5388, 0x00}, + {0x5389, 0xE1}, + {0x538A, 0x00}, + {0x538B, 0x2B}, + {0x538C, 0x00}, + {0x538D, 0x00}, + {0x538E, 0x00}, + {0x538F, 0x10}, + {0x5390, 0x00}, + {0x5391, 0xB3}, + {0x5392, 0x00}, + {0x5393, 0xA6}, + {0x5394, 0x08}, + + {0x5480, 0x0c}, + {0x5481, 0x18}, + {0x5482, 0x2f}, + {0x5483, 0x55}, + {0x5484, 0x64}, + {0x5485, 0x71}, + {0x5486, 0x7d}, + {0x5487, 0x87}, + {0x5488, 0x91}, + {0x5489, 0x9a}, + {0x548A, 0xaa}, + {0x548B, 0xb8}, + {0x548C, 0xcd}, + {0x548D, 0xdd}, + {0x548E, 0xea}, + {0x548F, 0x1d}, + {0x5490, 0x05}, + {0x5491, 0x00}, + {0x5492, 0x04}, + {0x5493, 0x20}, + {0x5494, 0x03}, + {0x5495, 0x60}, + {0x5496, 0x02}, + {0x5497, 0xB8}, + {0x5498, 0x02}, + {0x5499, 0x86}, + {0x549A, 0x02}, + {0x549B, 0x5B}, + {0x549C, 0x02}, + {0x549D, 0x3B}, + {0x549E, 0x02}, + {0x549F, 0x1C}, + {0x54A0, 0x02}, + {0x54A1, 0x04}, + {0x54A2, 0x01}, + {0x54A3, 0xED}, + {0x54A4, 0x01}, + {0x54A5, 0xC5}, + {0x54A6, 0x01}, + {0x54A7, 0xA5}, + {0x54A8, 0x01}, + {0x54A9, 0x6C}, + {0x54AA, 0x01}, + {0x54AB, 0x41}, + {0x54AC, 0x01}, + {0x54AD, 0x20}, + {0x54AE, 0x00}, + {0x54AF, 0x16}, + {0x54B0, 0x01}, + {0x54B1, 0x20}, + {0x54B2, 0x00}, + {0x54B3, 0x10}, + {0x54B4, 0x00}, + {0x54B5, 0xf0}, + {0x54B6, 0x00}, + {0x54B7, 0xDF}, + {0x5402, 0x3f}, + {0x5403, 0x00}, + + {0x5500, 0x10}, + {0x5502, 0x00}, + {0x5503, 0x06}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + + {0x5025, 0x80}, + {0x3a0f, 0x30}, + {0x3a10, 0x28}, + {0x3a1b, 0x30}, + {0x3a1e, 0x28}, + {0x3a11, 0x61}, + {0x3a1f, 0x10}, + {0x5688, 0xfd}, + {0x5689, 0xdf}, + {0x568a, 0xfe}, + {0x568b, 0xef}, + {0x568c, 0xfe}, + {0x568d, 0xef}, + {0x568e, 0xaa}, + {0x568f, 0xaa}, + + {0xffff, 0xff}, +}; const struct sensor_reg OV5642_JPEG_Capture_QSXGA[] PROGMEM = -{ - // OV5642_ QSXGA _YUV7.5 fps - // 24 MHz input clock, 24Mhz pclk - // jpeg mode 7.5fps - - {0x3503 ,0x07}, //AEC Manual Mode Control - {0x3000 ,0x00}, //SYSTEM RESET00 - {0x3001 ,0x00}, //Reset for Individual Block - {0x3002 ,0x00}, //Reset for Individual Block - {0x3003 ,0x00}, //Reset for Individual Block - {0x3005 ,0xff}, //Clock Enable Control - {0x3006 ,0xff}, //Clock Enable Control - {0x3007 ,0x3f}, //Clock Enable Control - {0x350c ,0x07}, //AEC VTS Output high bits - {0x350d ,0xd0}, //AEC VTS Output low bits - {0x3602 ,0xe4}, //Analog Control Registers - {0x3612 ,0xac}, //Analog Control Registers - {0x3613 ,0x44}, //Analog Control Registers - {0x3621 ,0x27}, //Array Control 01 - {0x3622 ,0x08}, //Analog Control Registers - {0x3623 ,0x22}, //Analog Control Registers - {0x3604 ,0x60}, //Analog Control Registers - {0x3705 ,0xda}, //Analog Control Registers - {0x370a ,0x80}, //Analog Control Registers - {0x3801 ,0x8a}, //HS - {0x3803 ,0x0a}, //VS - {0x3804 ,0x0a}, //HW - {0x3805 ,0x20}, //HW - {0x3806 ,0x07}, //VH - {0x3807 ,0x98}, //VH - {0x3808 ,0x0a}, //DVPHO - {0x3809 ,0x20}, //DVPHO - {0x380a ,0x07}, //DVPVO - {0x380b ,0x98}, //DVPVO - {0x380c ,0x0c}, //HTS - {0x380d ,0x80}, //HTS - {0x380e ,0x07}, //VTS - {0x380f ,0xd0}, //VTS - {0x3810 ,0xc2}, - {0x3815 ,0x44}, - {0x3818 ,0xc8}, //Mirror NO, Compression enable - {0x3824 ,0x01}, //RSV - {0x3827 ,0x0a}, //RSV - {0x3a00 ,0x78}, //AEC System Control 0 - {0x3a0d ,0x10}, //60 Hz Max Bands in One Frame - {0x3a0e ,0x0d}, //50 Hz Max Bands in One Frame - {0x3a10 ,0x32}, //Stable Range Low Limit (enter) - {0x3a1b ,0x3c}, //Stable Range High Limit (go out) - {0x3a1e ,0x32}, //Stable Range Low Limit (go out) - {0x3a11 ,0x80}, //Step Manual Mode, Fast Zone High Limit - {0x3a1f ,0x20}, //Step Manual Mode, Fast Zone Low Limit - {0x3a00 ,0x78}, //AEC System Control 0 - {0x460b ,0x35}, //RSV VFIFO Control 0B - {0x471d ,0x00}, //DVP CONTROL 1D - {0x4713 ,0x03}, //COMPRESSION MODE SELECT mode3 - {0x471c ,0x50}, //RSV - {0x5682 ,0x0a}, //AVG X END - {0x5683 ,0x20}, //AVG X END - {0x5686 ,0x07}, //AVG Y END - {0x5687 ,0x98}, //AVG Y END - {0x5001 ,0x4f}, //ISP CONTROL 01, UV adjust/Line stretch/UV average/Color matrix/AWB enable - {0x589b ,0x00}, //RSV - {0x589a ,0xc0}, //RSV - {0x4407 ,0x08}, //COMPRESSION CTRL07 Bit[5:0]: Quantization scale 0x02 - {0x589b ,0x00}, //RSV - {0x589a ,0xc0}, //RSV - {0x3002 ,0x0c}, //Reset for Individual Block, Reset SFIFO/compression - {0x3002 ,0x00}, //Reset for Individual Block - {0x3503 ,0x00}, //AEC Manual Mode Control, Auto enable - //{0x3818, 0xa8}, - //{0x3621, 0x17}, - //{0x3801, 0xb0}, - {0x5025, 0x80}, - {0x3a0f, 0x48}, - {0x3a10, 0x40}, - {0x3a1b, 0x4a}, - {0x3a1e, 0x3e}, - {0x3a11, 0x70}, - {0x3a1f, 0x20}, - {0xffff, 0xff}, + { + // OV5642_ QSXGA _YUV7.5 fps + // 24 MHz input clock, 24Mhz pclk + // jpeg mode 7.5fps + + {0x3503, 0x07}, // AEC Manual Mode Control + {0x3000, 0x00}, // SYSTEM RESET00 + {0x3001, 0x00}, // Reset for Individual Block + {0x3002, 0x00}, // Reset for Individual Block + {0x3003, 0x00}, // Reset for Individual Block + {0x3005, 0xff}, // Clock Enable Control + {0x3006, 0xff}, // Clock Enable Control + {0x3007, 0x3f}, // Clock Enable Control + {0x350c, 0x07}, // AEC VTS Output high bits + {0x350d, 0xd0}, // AEC VTS Output low bits + {0x3602, 0xe4}, // Analog Control Registers + {0x3612, 0xac}, // Analog Control Registers + {0x3613, 0x44}, // Analog Control Registers + {0x3621, 0x27}, // Array Control 01 + {0x3622, 0x08}, // Analog Control Registers + {0x3623, 0x22}, // Analog Control Registers + {0x3604, 0x60}, // Analog Control Registers + {0x3705, 0xda}, // Analog Control Registers + {0x370a, 0x80}, // Analog Control Registers + {0x3801, 0x8a}, // HS + {0x3803, 0x0a}, // VS + {0x3804, 0x0a}, // HW + {0x3805, 0x20}, // HW + {0x3806, 0x07}, // VH + {0x3807, 0x98}, // VH + {0x3808, 0x0a}, // DVPHO + {0x3809, 0x20}, // DVPHO + {0x380a, 0x07}, // DVPVO + {0x380b, 0x98}, // DVPVO + {0x380c, 0x0c}, // HTS + {0x380d, 0x80}, // HTS + {0x380e, 0x07}, // VTS + {0x380f, 0xd0}, // VTS + {0x3810, 0xc2}, + {0x3815, 0x44}, + {0x3818, 0xc8}, // Mirror NO, Compression enable + {0x3824, 0x01}, // RSV + {0x3827, 0x0a}, // RSV + {0x3a00, 0x78}, // AEC System Control 0 + {0x3a0d, 0x10}, // 60 Hz Max Bands in One Frame + {0x3a0e, 0x0d}, // 50 Hz Max Bands in One Frame + {0x3a10, 0x32}, // Stable Range Low Limit (enter) + {0x3a1b, 0x3c}, // Stable Range High Limit (go out) + {0x3a1e, 0x32}, // Stable Range Low Limit (go out) + {0x3a11, 0x80}, // Step Manual Mode, Fast Zone High Limit + {0x3a1f, 0x20}, // Step Manual Mode, Fast Zone Low Limit + {0x3a00, 0x78}, // AEC System Control 0 + {0x460b, 0x35}, // RSV VFIFO Control 0B + {0x471d, 0x00}, // DVP CONTROL 1D + {0x4713, 0x03}, // COMPRESSION MODE SELECT mode3 + {0x471c, 0x50}, // RSV + {0x5682, 0x0a}, // AVG X END + {0x5683, 0x20}, // AVG X END + {0x5686, 0x07}, // AVG Y END + {0x5687, 0x98}, // AVG Y END + {0x5001, 0x4f}, // ISP CONTROL 01, UV adjust/Line stretch/UV average/Color matrix/AWB enable + {0x589b, 0x00}, // RSV + {0x589a, 0xc0}, // RSV + {0x4407, 0x08}, // COMPRESSION CTRL07 Bit[5:0]: Quantization scale 0x02 + {0x589b, 0x00}, // RSV + {0x589a, 0xc0}, // RSV + {0x3002, 0x0c}, // Reset for Individual Block, Reset SFIFO/compression + {0x3002, 0x00}, // Reset for Individual Block + {0x3503, 0x00}, // AEC Manual Mode Control, Auto enable + //{0x3818, 0xa8}, + //{0x3621, 0x17}, + //{0x3801, 0xb0}, + {0x5025, 0x80}, + {0x3a0f, 0x48}, + {0x3a10, 0x40}, + {0x3a1b, 0x4a}, + {0x3a1e, 0x3e}, + {0x3a11, 0x70}, + {0x3a1f, 0x20}, + {0xffff, 0xff}, }; - -const struct sensor_reg OV5642_1080P_Video_setting[] PROGMEM = -{ - {0x3103 ,0x93}, - {0x3008 ,0x82}, - {0x3017 ,0x7f}, - {0x3018 ,0xfc}, - {0x3810 ,0xc2}, - {0x3615 ,0xf0}, - {0x3000 ,0x00}, - {0x3001 ,0x00}, - {0x3002 ,0x00}, - {0x3003 ,0x00}, - {0x3004 ,0xff}, - {0x3030 ,0x0b}, - {0x3011 ,0x08}, - {0x3010 ,0x10}, - {0x3604 ,0x60}, - {0x3622 ,0x60}, - {0x3621 ,0x09}, - {0x3709 ,0x00}, - {0x4000 ,0x21}, - {0x401d ,0x22}, - {0x3600 ,0x54}, - {0x3605 ,0x04}, - {0x3606 ,0x3f}, - {0x3c01 ,0x80}, - {0x300d ,0x22}, - {0x3623 ,0x22}, - {0x5000 ,0x4f}, - {0x5020 ,0x04}, - {0x5181 ,0x79}, - {0x5182 ,0x00}, - {0x5185 ,0x22}, - {0x5197 ,0x01}, - {0x5500 ,0x0a}, - {0x5504 ,0x00}, - {0x5505 ,0x7f}, - {0x5080 ,0x08}, - {0x300e ,0x18}, - {0x4610 ,0x00}, - {0x471d ,0x05}, - {0x4708 ,0x06}, - {0x370c ,0xa0}, - {0x3808 ,0x0a}, - {0x3809 ,0x20}, - {0x380a ,0x07}, - {0x380b ,0x98}, - {0x380c ,0x0c}, - {0x380d ,0x80}, - {0x380e ,0x07}, - {0x380f ,0xd0}, - {0x5687 ,0x94}, - {0x501f ,0x00}, - {0x5000 ,0x4f}, - {0x5001 ,0xcf}, - {0x4300 ,0x30}, - {0x4300 ,0x30}, - {0x460b ,0x35}, - {0x471d ,0x00}, - {0x3002 ,0x0c}, - {0x3002 ,0x00}, - {0x4713 ,0x03}, - {0x471c ,0x50}, - {0x4721 ,0x02}, - {0x4402 ,0x90}, - {0x460c ,0x22}, - {0x3815 ,0x44}, - {0x3503 ,0x07}, - {0x3501 ,0x73}, - {0x3502 ,0x80}, - {0x350b ,0x00}, - {0x3818 ,0xc8}, - {0x3801 ,0x88}, - {0x3824 ,0x11}, - {0x3a00 ,0x78}, - {0x3a1a ,0x04}, - {0x3a13 ,0x30}, - {0x3a18 ,0x00}, - {0x3a19 ,0x7c}, - {0x3a08 ,0x12}, - {0x3a09 ,0xc0}, - {0x3a0a ,0x0f}, - {0x3a0b ,0xa0}, - {0x350c ,0x07}, - {0x350d ,0xd0}, - {0x3a0d ,0x08}, - {0x3a0e ,0x06}, - {0x3500 ,0x00}, - {0x3501 ,0x00}, - {0x3502 ,0x00}, - {0x350a ,0x00}, - {0x350b ,0x00}, - {0x3503 ,0x00}, - {0x3030 ,0x0b}, - {0x3a02 ,0x00}, - {0x3a03 ,0x7d}, - {0x3a04 ,0x00}, - {0x3a14 ,0x00}, - {0x3a15 ,0x7d}, - {0x3a16 ,0x00}, - {0x3a00 ,0x78}, - {0x3a08 ,0x09}, - {0x3a09 ,0x60}, - {0x3a0a ,0x07}, - {0x3a0b ,0xd0}, - {0x3a0d ,0x10}, - {0x3a0e ,0x0d}, - {0x4407 ,0x04}, - {0x5193 ,0x70}, - {0x589b ,0x00}, - {0x589a ,0xc0}, - {0x401e ,0x20}, - {0x4001 ,0x42}, - {0x401c ,0x06}, - {0x3825 ,0xac}, - {0x3827 ,0x0c}, - {0x5402 ,0x3f}, - {0x5403 ,0x00}, - {0x3406 ,0x00}, - {0x5180 ,0xff}, - {0x5181 ,0x52}, - {0x5182 ,0x11}, - {0x5183 ,0x14}, - {0x5184 ,0x25}, - {0x5185 ,0x24}, - {0x5186 ,0x06}, - {0x5187 ,0x08}, - {0x5188 ,0x08}, - {0x5189 ,0x7c}, - {0x518a ,0x60}, - {0x518b ,0xb2}, - {0x518c ,0xb2}, - {0x518d ,0x44}, - {0x518e ,0x3d}, - {0x518f ,0x58}, - {0x5190 ,0x46}, - {0x5191 ,0xf8}, - {0x5192 ,0x04}, - {0x5193 ,0x70}, - {0x5194 ,0xf0}, - {0x5195 ,0xf0}, - {0x5196 ,0x03}, - {0x5197 ,0x01}, - {0x5198 ,0x04}, - {0x5199 ,0x12}, - {0x519a ,0x04}, - {0x519b ,0x00}, - {0x519c ,0x06}, - {0x519d ,0x82}, - {0x519e ,0x00}, - {0x5025 ,0x80}, - {0x5583 ,0x40}, - {0x5584 ,0x40}, - {0x5580 ,0x02}, - {0x5000 ,0xcf}, - {0x3710 ,0x10}, - {0x3632 ,0x51}, - {0x3702 ,0x10}, - {0x3703 ,0xb2}, - {0x3704 ,0x18}, - {0x370b ,0x40}, - {0x370d ,0x03}, - {0x3631 ,0x01}, - {0x3632 ,0x52}, - {0x3606 ,0x24}, - {0x3620 ,0x96}, - {0x5785 ,0x07}, - {0x3a13 ,0x30}, - {0x3600 ,0x52}, - {0x3604 ,0x48}, - {0x3606 ,0x1b}, - {0x370d ,0x0b}, - {0x370f ,0xc0}, - {0x3709 ,0x01}, - {0x3823 ,0x00}, - {0x5007 ,0x00}, - {0x5009 ,0x00}, - {0x5011 ,0x00}, - {0x5013 ,0x00}, - {0x519e ,0x00}, - {0x5086 ,0x00}, - {0x5087 ,0x00}, - {0x5088 ,0x00}, - {0x5089 ,0x00}, - {0x302b ,0x00}, - {0x3503 ,0x07}, - {0x3011 ,0x07}, - {0x350c ,0x04}, - {0x350d ,0x58}, - {0x3801 ,0x8a}, - {0x3803 ,0x0a}, - {0x3804 ,0x07}, - {0x3805 ,0x80}, - {0x3806 ,0x04}, - {0x3807 ,0x38}, - {0x3808 ,0x07}, - {0x3809 ,0x80}, - {0x380a ,0x04}, - {0x380b ,0x38}, - {0x380c ,0x09}, - {0x380d ,0xd6}, - {0x380e ,0x04}, - {0x380f ,0x58}, - {0x381c ,0x11}, - {0x381d ,0xba}, - {0x381e ,0x04}, - {0x381f ,0x48}, - {0x3820 ,0x04}, - {0x3821 ,0x18}, - {0x3a08 ,0x14}, - {0x3a09 ,0xe0}, - {0x3a0a ,0x11}, - {0x3a0b ,0x60}, - {0x3a0d ,0x04}, - {0x3a0e ,0x03}, - {0x5682 ,0x07}, - {0x5683 ,0x60}, - {0x5686 ,0x04}, - {0x5687 ,0x1c}, - {0x5001 ,0x7f}, - {0x3503 ,0x00}, - {0x3010 ,0x10}, - {0x5001 ,0xFF}, - {0x5583 ,0x50}, - {0x5584 ,0x50}, - {0x5580 ,0x02}, - {0x3c01 ,0x80}, - {0x3c00 ,0x04}, - - {0x5800 ,0x48}, - {0x5801 ,0x31}, - {0x5802 ,0x21}, - {0x5803 ,0x1b}, - {0x5804 ,0x1a}, - {0x5805 ,0x1e}, - {0x5806 ,0x29}, - {0x5807 ,0x38}, - {0x5808 ,0x26}, - {0x5809 ,0x17}, - {0x580a ,0x11}, - {0x580b ,0xe }, - {0x580c ,0xd }, - {0x580d ,0xe }, - {0x580e ,0x13}, - {0x580f ,0x1a}, - {0x5810 ,0x15}, - {0x5811 ,0xd }, - {0x5812 ,0x8 }, - {0x5813 ,0x5 }, - {0x5814 ,0x4 }, - {0x5815 ,0x5 }, - {0x5816 ,0x9 }, - {0x5817 ,0xd }, - {0x5818 ,0x11}, - {0x5819 ,0xa }, - {0x581a ,0x4 }, - {0x581b ,0x0 }, - {0x581c ,0x0 }, - {0x581d ,0x1 }, - {0x581e ,0x6 }, - {0x581f ,0x9 }, - {0x5820 ,0x12}, - {0x5821 ,0xb }, - {0x5822 ,0x4 }, - {0x5823 ,0x0 }, - {0x5824 ,0x0 }, - {0x5825 ,0x1 }, - {0x5826 ,0x6 }, - {0x5827 ,0xa }, - {0x5828 ,0x17}, - {0x5829 ,0xf }, - {0x582a ,0x9 }, - {0x582b ,0x6 }, - {0x582c ,0x5 }, - {0x582d ,0x6 }, - {0x582e ,0xa }, - {0x582f ,0xe }, - {0x5830 ,0x28}, - {0x5831 ,0x1a}, - {0x5832 ,0x11}, - {0x5833 ,0xe }, - {0x5834 ,0xe }, - {0x5835 ,0xf }, - {0x5836 ,0x15}, - {0x5837 ,0x1d}, - {0x5838 ,0x6e}, - {0x5839 ,0x39}, - {0x583a ,0x27}, - {0x583b ,0x1f}, - {0x583c ,0x1e}, - {0x583d ,0x23}, - {0x583e ,0x2f}, - {0x583f ,0x41}, - {0x5840 ,0xe }, - {0x5841 ,0xc }, - {0x5842 ,0xd }, - {0x5843 ,0xc }, - {0x5844 ,0xc }, - {0x5845 ,0xc }, - {0x5846 ,0xc }, - {0x5847 ,0xc }, - {0x5848 ,0xd }, - {0x5849 ,0xe }, - {0x584a ,0xe }, - {0x584b ,0xa }, - {0x584c ,0xe }, - {0x584d ,0xe }, - {0x584e ,0x10}, - {0x584f ,0x10}, - {0x5850 ,0x11}, - {0x5851 ,0xa }, - {0x5852 ,0xf }, - {0x5853 ,0xe }, - {0x5854 ,0x10}, - {0x5855 ,0x10}, - {0x5856 ,0x10}, - {0x5857 ,0xa }, - {0x5858 ,0xe }, - {0x5859 ,0xe }, - {0x585a ,0xf }, - {0x585b ,0xf }, - {0x585c ,0xf }, - {0x585d ,0xa }, - {0x585e ,0x9 }, - {0x585f ,0xd }, - {0x5860 ,0xc }, - {0x5861 ,0xb }, - {0x5862 ,0xd }, - {0x5863 ,0x7 }, - {0x5864 ,0x17}, - {0x5865 ,0x14}, - {0x5866 ,0x18}, - {0x5867 ,0x18}, - {0x5868 ,0x16}, - {0x5869 ,0x12}, - {0x586a ,0x1b}, - {0x586b ,0x1a}, - {0x586c ,0x16}, - {0x586d ,0x16}, - {0x586e ,0x18}, - {0x586f ,0x1f}, - {0x5870 ,0x1c}, - {0x5871 ,0x16}, - {0x5872 ,0x10}, - {0x5873 ,0xf }, - {0x5874 ,0x13}, - {0x5875 ,0x1c}, - {0x5876 ,0x1e}, - {0x5877 ,0x17}, - {0x5878 ,0x11}, - {0x5879 ,0x11}, - {0x587a ,0x14}, - {0x587b ,0x1e}, - {0x587c ,0x1c}, - {0x587d ,0x1c}, - {0x587e ,0x1a}, - {0x587f ,0x1a}, - {0x5880 ,0x1b}, - {0x5881 ,0x1f}, - {0x5882 ,0x14}, - {0x5883 ,0x1a}, - {0x5884 ,0x1d}, - {0x5885 ,0x1e}, - {0x5886 ,0x1a}, - {0x5887 ,0x1a}, - - {0x5180 ,0xff}, - {0x5181 ,0x52}, - {0x5182 ,0x11}, - {0x5183 ,0x14}, - {0x5184 ,0x25}, - {0x5185 ,0x24}, - {0x5186 ,0x14}, - {0x5187 ,0x14}, - {0x5188 ,0x14}, - {0x5189 ,0x69}, - {0x518a ,0x60}, - {0x518b ,0xa2}, - {0x518c ,0x9c}, - {0x518d ,0x36}, - {0x518e ,0x34}, - {0x518f ,0x54}, - {0x5190 ,0x4c}, - {0x5191 ,0xf8}, - {0x5192 ,0x04}, - {0x5193 ,0x70}, - {0x5194 ,0xf0}, - {0x5195 ,0xf0}, - {0x5196 ,0x03}, - {0x5197 ,0x01}, - {0x5198 ,0x05}, - {0x5199 ,0x2f}, - {0x519a ,0x04}, - {0x519b ,0x00}, - {0x519c ,0x06}, - {0x519d ,0xa0}, - {0x519e ,0xa0}, - - {0x528a ,0x00}, - {0x528b ,0x01}, - {0x528c ,0x04}, - {0x528d ,0x08}, - {0x528e ,0x10}, - {0x528f ,0x20}, - {0x5290 ,0x30}, - {0x5292 ,0x00}, - {0x5293 ,0x00}, - {0x5294 ,0x00}, - {0x5295 ,0x01}, - {0x5296 ,0x00}, - {0x5297 ,0x04}, - {0x5298 ,0x00}, - {0x5299 ,0x08}, - {0x529a ,0x00}, - {0x529b ,0x10}, - {0x529c ,0x00}, - {0x529d ,0x20}, - {0x529e ,0x00}, - {0x529f ,0x30}, - {0x5282 ,0x00}, - {0x5300 ,0x00}, - {0x5301 ,0x20}, - {0x5302 ,0x00}, - {0x5303 ,0x7c}, - {0x530c ,0x00}, - {0x530d ,0x10}, - {0x530e ,0x20}, - {0x530f ,0x80}, - {0x5310 ,0x20}, - {0x5311 ,0x80}, - {0x5308 ,0x20}, - {0x5309 ,0x40}, - {0x5304 ,0x00}, - {0x5305 ,0x30}, - {0x5306 ,0x00}, - {0x5307 ,0x80}, - {0x5314 ,0x08}, - {0x5315 ,0x20}, - {0x5319 ,0x30}, - {0x5316 ,0x10}, - {0x5317 ,0x00}, - {0x5318 ,0x02}, - - {0x5380 ,0x01}, - {0x5381 ,0x00}, - {0x5382 ,0x00}, - {0x5383 ,0x1f}, - {0x5384 ,0x00}, - {0x5385 ,0x06}, - {0x5386 ,0x00}, - {0x5387 ,0x00}, - {0x5388 ,0x00}, - {0x5389 ,0xE1}, - {0x538A ,0x00}, - {0x538B ,0x2B}, - {0x538C ,0x00}, - {0x538D ,0x00}, - {0x538E ,0x00}, - {0x538F ,0x10}, - {0x5390 ,0x00}, - {0x5391 ,0xB3}, - {0x5392 ,0x00}, - {0x5393 ,0xA6}, - {0x5394 ,0x08}, - - {0x5480 ,0x0c}, - {0x5481 ,0x18}, - {0x5482 ,0x2f}, - {0x5483 ,0x55}, - {0x5484 ,0x64}, - {0x5485 ,0x71}, - {0x5486 ,0x7d}, - {0x5487 ,0x87}, - {0x5488 ,0x91}, - {0x5489 ,0x9a}, - {0x548A ,0xaa}, - {0x548B ,0xb8}, - {0x548C ,0xcd}, - {0x548D ,0xdd}, - {0x548E ,0xea}, - {0x548F ,0x1d}, - {0x5490 ,0x05}, - {0x5491 ,0x00}, - {0x5492 ,0x04}, - {0x5493 ,0x20}, - {0x5494 ,0x03}, - {0x5495 ,0x60}, - {0x5496 ,0x02}, - {0x5497 ,0xB8}, - {0x5498 ,0x02}, - {0x5499 ,0x86}, - {0x549A ,0x02}, - {0x549B ,0x5B}, - {0x549C ,0x02}, - {0x549D ,0x3B}, - {0x549E ,0x02}, - {0x549F ,0x1C}, - {0x54A0 ,0x02}, - {0x54A1 ,0x04}, - {0x54A2 ,0x01}, - {0x54A3 ,0xED}, - {0x54A4 ,0x01}, - {0x54A5 ,0xC5}, - {0x54A6 ,0x01}, - {0x54A7 ,0xA5}, - {0x54A8 ,0x01}, - {0x54A9 ,0x6C}, - {0x54AA ,0x01}, - {0x54AB ,0x41}, - {0x54AC ,0x01}, - {0x54AD ,0x20}, - {0x54AE ,0x00}, - {0x54AF ,0x16}, - {0x54B0 ,0x01}, - {0x54B1 ,0x20}, - {0x54B2 ,0x00}, - {0x54B3 ,0x10}, - {0x54B4 ,0x00}, - {0x54B5 ,0xf0}, - {0x54B6 ,0x00}, - {0x54B7 ,0xDF}, - - {0x5402 ,0x3f}, - {0x5403 ,0x00}, - - {0x5500 ,0x10}, - {0x5502 ,0x00}, - {0x5503 ,0x06}, - {0x5504 ,0x00}, - {0x5505 ,0x7f}, - - {0x5025 ,0x80}, - {0x3a0f ,0x30}, - {0x3a10 ,0x28}, - {0x3a1b ,0x30}, - {0x3a1e ,0x28}, - {0x3a11 ,0x61}, - {0x3a1f ,0x10}, - {0x5688 ,0xfd}, - {0x5689 ,0xdf}, - {0x568a ,0xfe}, - {0x568b ,0xef}, - {0x568c ,0xfe}, - {0x568d ,0xef}, - {0x568e ,0xaa}, - {0x568f ,0xaa}, - {0x3010, 0x00}, - {0x3818, 0xa8}, - {0x3621, 0x27}, - - {0xffff, 0xff}, +const struct sensor_reg OV5642_1080P_Video_setting[] PROGMEM = + { + {0x3103, 0x93}, + {0x3008, 0x82}, + {0x3017, 0x7f}, + {0x3018, 0xfc}, + {0x3810, 0xc2}, + {0x3615, 0xf0}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3003, 0x00}, + {0x3004, 0xff}, + {0x3030, 0x0b}, + {0x3011, 0x08}, + {0x3010, 0x10}, + {0x3604, 0x60}, + {0x3622, 0x60}, + {0x3621, 0x09}, + {0x3709, 0x00}, + {0x4000, 0x21}, + {0x401d, 0x22}, + {0x3600, 0x54}, + {0x3605, 0x04}, + {0x3606, 0x3f}, + {0x3c01, 0x80}, + {0x300d, 0x22}, + {0x3623, 0x22}, + {0x5000, 0x4f}, + {0x5020, 0x04}, + {0x5181, 0x79}, + {0x5182, 0x00}, + {0x5185, 0x22}, + {0x5197, 0x01}, + {0x5500, 0x0a}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + {0x5080, 0x08}, + {0x300e, 0x18}, + {0x4610, 0x00}, + {0x471d, 0x05}, + {0x4708, 0x06}, + {0x370c, 0xa0}, + {0x3808, 0x0a}, + {0x3809, 0x20}, + {0x380a, 0x07}, + {0x380b, 0x98}, + {0x380c, 0x0c}, + {0x380d, 0x80}, + {0x380e, 0x07}, + {0x380f, 0xd0}, + {0x5687, 0x94}, + {0x501f, 0x00}, + {0x5000, 0x4f}, + {0x5001, 0xcf}, + {0x4300, 0x30}, + {0x4300, 0x30}, + {0x460b, 0x35}, + {0x471d, 0x00}, + {0x3002, 0x0c}, + {0x3002, 0x00}, + {0x4713, 0x03}, + {0x471c, 0x50}, + {0x4721, 0x02}, + {0x4402, 0x90}, + {0x460c, 0x22}, + {0x3815, 0x44}, + {0x3503, 0x07}, + {0x3501, 0x73}, + {0x3502, 0x80}, + {0x350b, 0x00}, + {0x3818, 0xc8}, + {0x3801, 0x88}, + {0x3824, 0x11}, + {0x3a00, 0x78}, + {0x3a1a, 0x04}, + {0x3a13, 0x30}, + {0x3a18, 0x00}, + {0x3a19, 0x7c}, + {0x3a08, 0x12}, + {0x3a09, 0xc0}, + {0x3a0a, 0x0f}, + {0x3a0b, 0xa0}, + {0x350c, 0x07}, + {0x350d, 0xd0}, + {0x3a0d, 0x08}, + {0x3a0e, 0x06}, + {0x3500, 0x00}, + {0x3501, 0x00}, + {0x3502, 0x00}, + {0x350a, 0x00}, + {0x350b, 0x00}, + {0x3503, 0x00}, + {0x3030, 0x0b}, + {0x3a02, 0x00}, + {0x3a03, 0x7d}, + {0x3a04, 0x00}, + {0x3a14, 0x00}, + {0x3a15, 0x7d}, + {0x3a16, 0x00}, + {0x3a00, 0x78}, + {0x3a08, 0x09}, + {0x3a09, 0x60}, + {0x3a0a, 0x07}, + {0x3a0b, 0xd0}, + {0x3a0d, 0x10}, + {0x3a0e, 0x0d}, + {0x4407, 0x04}, + {0x5193, 0x70}, + {0x589b, 0x00}, + {0x589a, 0xc0}, + {0x401e, 0x20}, + {0x4001, 0x42}, + {0x401c, 0x06}, + {0x3825, 0xac}, + {0x3827, 0x0c}, + {0x5402, 0x3f}, + {0x5403, 0x00}, + {0x3406, 0x00}, + {0x5180, 0xff}, + {0x5181, 0x52}, + {0x5182, 0x11}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x06}, + {0x5187, 0x08}, + {0x5188, 0x08}, + {0x5189, 0x7c}, + {0x518a, 0x60}, + {0x518b, 0xb2}, + {0x518c, 0xb2}, + {0x518d, 0x44}, + {0x518e, 0x3d}, + {0x518f, 0x58}, + {0x5190, 0x46}, + {0x5191, 0xf8}, + {0x5192, 0x04}, + {0x5193, 0x70}, + {0x5194, 0xf0}, + {0x5195, 0xf0}, + {0x5196, 0x03}, + {0x5197, 0x01}, + {0x5198, 0x04}, + {0x5199, 0x12}, + {0x519a, 0x04}, + {0x519b, 0x00}, + {0x519c, 0x06}, + {0x519d, 0x82}, + {0x519e, 0x00}, + {0x5025, 0x80}, + {0x5583, 0x40}, + {0x5584, 0x40}, + {0x5580, 0x02}, + {0x5000, 0xcf}, + {0x3710, 0x10}, + {0x3632, 0x51}, + {0x3702, 0x10}, + {0x3703, 0xb2}, + {0x3704, 0x18}, + {0x370b, 0x40}, + {0x370d, 0x03}, + {0x3631, 0x01}, + {0x3632, 0x52}, + {0x3606, 0x24}, + {0x3620, 0x96}, + {0x5785, 0x07}, + {0x3a13, 0x30}, + {0x3600, 0x52}, + {0x3604, 0x48}, + {0x3606, 0x1b}, + {0x370d, 0x0b}, + {0x370f, 0xc0}, + {0x3709, 0x01}, + {0x3823, 0x00}, + {0x5007, 0x00}, + {0x5009, 0x00}, + {0x5011, 0x00}, + {0x5013, 0x00}, + {0x519e, 0x00}, + {0x5086, 0x00}, + {0x5087, 0x00}, + {0x5088, 0x00}, + {0x5089, 0x00}, + {0x302b, 0x00}, + {0x3503, 0x07}, + {0x3011, 0x07}, + {0x350c, 0x04}, + {0x350d, 0x58}, + {0x3801, 0x8a}, + {0x3803, 0x0a}, + {0x3804, 0x07}, + {0x3805, 0x80}, + {0x3806, 0x04}, + {0x3807, 0x38}, + {0x3808, 0x07}, + {0x3809, 0x80}, + {0x380a, 0x04}, + {0x380b, 0x38}, + {0x380c, 0x09}, + {0x380d, 0xd6}, + {0x380e, 0x04}, + {0x380f, 0x58}, + {0x381c, 0x11}, + {0x381d, 0xba}, + {0x381e, 0x04}, + {0x381f, 0x48}, + {0x3820, 0x04}, + {0x3821, 0x18}, + {0x3a08, 0x14}, + {0x3a09, 0xe0}, + {0x3a0a, 0x11}, + {0x3a0b, 0x60}, + {0x3a0d, 0x04}, + {0x3a0e, 0x03}, + {0x5682, 0x07}, + {0x5683, 0x60}, + {0x5686, 0x04}, + {0x5687, 0x1c}, + {0x5001, 0x7f}, + {0x3503, 0x00}, + {0x3010, 0x10}, + {0x5001, 0xFF}, + {0x5583, 0x50}, + {0x5584, 0x50}, + {0x5580, 0x02}, + {0x3c01, 0x80}, + {0x3c00, 0x04}, + + {0x5800, 0x48}, + {0x5801, 0x31}, + {0x5802, 0x21}, + {0x5803, 0x1b}, + {0x5804, 0x1a}, + {0x5805, 0x1e}, + {0x5806, 0x29}, + {0x5807, 0x38}, + {0x5808, 0x26}, + {0x5809, 0x17}, + {0x580a, 0x11}, + {0x580b, 0xe}, + {0x580c, 0xd}, + {0x580d, 0xe}, + {0x580e, 0x13}, + {0x580f, 0x1a}, + {0x5810, 0x15}, + {0x5811, 0xd}, + {0x5812, 0x8}, + {0x5813, 0x5}, + {0x5814, 0x4}, + {0x5815, 0x5}, + {0x5816, 0x9}, + {0x5817, 0xd}, + {0x5818, 0x11}, + {0x5819, 0xa}, + {0x581a, 0x4}, + {0x581b, 0x0}, + {0x581c, 0x0}, + {0x581d, 0x1}, + {0x581e, 0x6}, + {0x581f, 0x9}, + {0x5820, 0x12}, + {0x5821, 0xb}, + {0x5822, 0x4}, + {0x5823, 0x0}, + {0x5824, 0x0}, + {0x5825, 0x1}, + {0x5826, 0x6}, + {0x5827, 0xa}, + {0x5828, 0x17}, + {0x5829, 0xf}, + {0x582a, 0x9}, + {0x582b, 0x6}, + {0x582c, 0x5}, + {0x582d, 0x6}, + {0x582e, 0xa}, + {0x582f, 0xe}, + {0x5830, 0x28}, + {0x5831, 0x1a}, + {0x5832, 0x11}, + {0x5833, 0xe}, + {0x5834, 0xe}, + {0x5835, 0xf}, + {0x5836, 0x15}, + {0x5837, 0x1d}, + {0x5838, 0x6e}, + {0x5839, 0x39}, + {0x583a, 0x27}, + {0x583b, 0x1f}, + {0x583c, 0x1e}, + {0x583d, 0x23}, + {0x583e, 0x2f}, + {0x583f, 0x41}, + {0x5840, 0xe}, + {0x5841, 0xc}, + {0x5842, 0xd}, + {0x5843, 0xc}, + {0x5844, 0xc}, + {0x5845, 0xc}, + {0x5846, 0xc}, + {0x5847, 0xc}, + {0x5848, 0xd}, + {0x5849, 0xe}, + {0x584a, 0xe}, + {0x584b, 0xa}, + {0x584c, 0xe}, + {0x584d, 0xe}, + {0x584e, 0x10}, + {0x584f, 0x10}, + {0x5850, 0x11}, + {0x5851, 0xa}, + {0x5852, 0xf}, + {0x5853, 0xe}, + {0x5854, 0x10}, + {0x5855, 0x10}, + {0x5856, 0x10}, + {0x5857, 0xa}, + {0x5858, 0xe}, + {0x5859, 0xe}, + {0x585a, 0xf}, + {0x585b, 0xf}, + {0x585c, 0xf}, + {0x585d, 0xa}, + {0x585e, 0x9}, + {0x585f, 0xd}, + {0x5860, 0xc}, + {0x5861, 0xb}, + {0x5862, 0xd}, + {0x5863, 0x7}, + {0x5864, 0x17}, + {0x5865, 0x14}, + {0x5866, 0x18}, + {0x5867, 0x18}, + {0x5868, 0x16}, + {0x5869, 0x12}, + {0x586a, 0x1b}, + {0x586b, 0x1a}, + {0x586c, 0x16}, + {0x586d, 0x16}, + {0x586e, 0x18}, + {0x586f, 0x1f}, + {0x5870, 0x1c}, + {0x5871, 0x16}, + {0x5872, 0x10}, + {0x5873, 0xf}, + {0x5874, 0x13}, + {0x5875, 0x1c}, + {0x5876, 0x1e}, + {0x5877, 0x17}, + {0x5878, 0x11}, + {0x5879, 0x11}, + {0x587a, 0x14}, + {0x587b, 0x1e}, + {0x587c, 0x1c}, + {0x587d, 0x1c}, + {0x587e, 0x1a}, + {0x587f, 0x1a}, + {0x5880, 0x1b}, + {0x5881, 0x1f}, + {0x5882, 0x14}, + {0x5883, 0x1a}, + {0x5884, 0x1d}, + {0x5885, 0x1e}, + {0x5886, 0x1a}, + {0x5887, 0x1a}, + + {0x5180, 0xff}, + {0x5181, 0x52}, + {0x5182, 0x11}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x14}, + {0x5187, 0x14}, + {0x5188, 0x14}, + {0x5189, 0x69}, + {0x518a, 0x60}, + {0x518b, 0xa2}, + {0x518c, 0x9c}, + {0x518d, 0x36}, + {0x518e, 0x34}, + {0x518f, 0x54}, + {0x5190, 0x4c}, + {0x5191, 0xf8}, + {0x5192, 0x04}, + {0x5193, 0x70}, + {0x5194, 0xf0}, + {0x5195, 0xf0}, + {0x5196, 0x03}, + {0x5197, 0x01}, + {0x5198, 0x05}, + {0x5199, 0x2f}, + {0x519a, 0x04}, + {0x519b, 0x00}, + {0x519c, 0x06}, + {0x519d, 0xa0}, + {0x519e, 0xa0}, + + {0x528a, 0x00}, + {0x528b, 0x01}, + {0x528c, 0x04}, + {0x528d, 0x08}, + {0x528e, 0x10}, + {0x528f, 0x20}, + {0x5290, 0x30}, + {0x5292, 0x00}, + {0x5293, 0x00}, + {0x5294, 0x00}, + {0x5295, 0x01}, + {0x5296, 0x00}, + {0x5297, 0x04}, + {0x5298, 0x00}, + {0x5299, 0x08}, + {0x529a, 0x00}, + {0x529b, 0x10}, + {0x529c, 0x00}, + {0x529d, 0x20}, + {0x529e, 0x00}, + {0x529f, 0x30}, + {0x5282, 0x00}, + {0x5300, 0x00}, + {0x5301, 0x20}, + {0x5302, 0x00}, + {0x5303, 0x7c}, + {0x530c, 0x00}, + {0x530d, 0x10}, + {0x530e, 0x20}, + {0x530f, 0x80}, + {0x5310, 0x20}, + {0x5311, 0x80}, + {0x5308, 0x20}, + {0x5309, 0x40}, + {0x5304, 0x00}, + {0x5305, 0x30}, + {0x5306, 0x00}, + {0x5307, 0x80}, + {0x5314, 0x08}, + {0x5315, 0x20}, + {0x5319, 0x30}, + {0x5316, 0x10}, + {0x5317, 0x00}, + {0x5318, 0x02}, + + {0x5380, 0x01}, + {0x5381, 0x00}, + {0x5382, 0x00}, + {0x5383, 0x1f}, + {0x5384, 0x00}, + {0x5385, 0x06}, + {0x5386, 0x00}, + {0x5387, 0x00}, + {0x5388, 0x00}, + {0x5389, 0xE1}, + {0x538A, 0x00}, + {0x538B, 0x2B}, + {0x538C, 0x00}, + {0x538D, 0x00}, + {0x538E, 0x00}, + {0x538F, 0x10}, + {0x5390, 0x00}, + {0x5391, 0xB3}, + {0x5392, 0x00}, + {0x5393, 0xA6}, + {0x5394, 0x08}, + + {0x5480, 0x0c}, + {0x5481, 0x18}, + {0x5482, 0x2f}, + {0x5483, 0x55}, + {0x5484, 0x64}, + {0x5485, 0x71}, + {0x5486, 0x7d}, + {0x5487, 0x87}, + {0x5488, 0x91}, + {0x5489, 0x9a}, + {0x548A, 0xaa}, + {0x548B, 0xb8}, + {0x548C, 0xcd}, + {0x548D, 0xdd}, + {0x548E, 0xea}, + {0x548F, 0x1d}, + {0x5490, 0x05}, + {0x5491, 0x00}, + {0x5492, 0x04}, + {0x5493, 0x20}, + {0x5494, 0x03}, + {0x5495, 0x60}, + {0x5496, 0x02}, + {0x5497, 0xB8}, + {0x5498, 0x02}, + {0x5499, 0x86}, + {0x549A, 0x02}, + {0x549B, 0x5B}, + {0x549C, 0x02}, + {0x549D, 0x3B}, + {0x549E, 0x02}, + {0x549F, 0x1C}, + {0x54A0, 0x02}, + {0x54A1, 0x04}, + {0x54A2, 0x01}, + {0x54A3, 0xED}, + {0x54A4, 0x01}, + {0x54A5, 0xC5}, + {0x54A6, 0x01}, + {0x54A7, 0xA5}, + {0x54A8, 0x01}, + {0x54A9, 0x6C}, + {0x54AA, 0x01}, + {0x54AB, 0x41}, + {0x54AC, 0x01}, + {0x54AD, 0x20}, + {0x54AE, 0x00}, + {0x54AF, 0x16}, + {0x54B0, 0x01}, + {0x54B1, 0x20}, + {0x54B2, 0x00}, + {0x54B3, 0x10}, + {0x54B4, 0x00}, + {0x54B5, 0xf0}, + {0x54B6, 0x00}, + {0x54B7, 0xDF}, + + {0x5402, 0x3f}, + {0x5403, 0x00}, + + {0x5500, 0x10}, + {0x5502, 0x00}, + {0x5503, 0x06}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + + {0x5025, 0x80}, + {0x3a0f, 0x30}, + {0x3a10, 0x28}, + {0x3a1b, 0x30}, + {0x3a1e, 0x28}, + {0x3a11, 0x61}, + {0x3a1f, 0x10}, + {0x5688, 0xfd}, + {0x5689, 0xdf}, + {0x568a, 0xfe}, + {0x568b, 0xef}, + {0x568c, 0xfe}, + {0x568d, 0xef}, + {0x568e, 0xaa}, + {0x568f, 0xaa}, + {0x3010, 0x00}, + {0x3818, 0xa8}, + {0x3621, 0x27}, + + {0xffff, 0xff}, }; -const struct sensor_reg OV5642_720P_Video_setting[] PROGMEM = -{ - {0x3103 ,0x93}, - {0x3008 ,0x82}, - {0x3017 ,0x7f}, - {0x3018 ,0xfc}, - {0x3810 ,0xc2}, - {0x3615 ,0xf0}, - {0x3000 ,0x00}, - {0x3001 ,0x00}, - {0x3002 ,0x00}, - {0x3003 ,0x00}, - {0x3004 ,0xff}, - {0x3030 ,0x2b}, - {0x3011 ,0x08}, - {0x3010 ,0x10}, - {0x3604 ,0x60}, - {0x3622 ,0x60}, - {0x3621 ,0x09}, - {0x3709 ,0x00}, - {0x4000 ,0x21}, - {0x401d ,0x22}, - {0x3600 ,0x54}, - {0x3605 ,0x04}, - {0x3606 ,0x3f}, - {0x3c01 ,0x80}, - {0x300d ,0x22}, - {0x3623 ,0x22}, - {0x5000 ,0x4f}, - {0x5020 ,0x04}, - {0x5181 ,0x79}, - {0x5182 ,0x00}, - {0x5185 ,0x22}, - {0x5197 ,0x01}, - {0x5500 ,0x0a}, - {0x5504 ,0x00}, - {0x5505 ,0x7f}, - {0x5080 ,0x08}, - {0x300e ,0x18}, - {0x4610 ,0x00}, - {0x471d ,0x05}, - {0x4708 ,0x06}, - {0x370c ,0xa0}, - {0x3808 ,0x0a}, - {0x3809 ,0x20}, - {0x380a ,0x07}, - {0x380b ,0x98}, - {0x380c ,0x0c}, - {0x380d ,0x80}, - {0x380e ,0x07}, - {0x380f ,0xd0}, - {0x5687 ,0x94}, - {0x501f ,0x00}, - {0x5000 ,0x4f}, - {0x5001 ,0xcf}, - {0x4300 ,0x30}, - {0x4300 ,0x30}, - {0x460b ,0x35}, - {0x471d ,0x00}, - {0x3002 ,0x0c}, - {0x3002 ,0x00}, - {0x4713 ,0x03}, - {0x471c ,0x50}, - {0x4721 ,0x02}, - {0x4402 ,0x90}, - {0x460c ,0x22}, - {0x3815 ,0x44}, - {0x3503 ,0x07}, - {0x3501 ,0x73}, - {0x3502 ,0x80}, - {0x350b ,0x00}, - {0x3818 ,0xc8}, - {0x3801 ,0x88}, - {0x3824 ,0x11}, - {0x3a00 ,0x78}, - {0x3a1a ,0x04}, - {0x3a13 ,0x30}, - {0x3a18 ,0x00}, - {0x3a19 ,0x7c}, - {0x3a08 ,0x12}, - {0x3a09 ,0xc0}, - {0x3a0a ,0x0f}, - {0x3a0b ,0xa0}, - {0x350c ,0x07}, - {0x350d ,0xd0}, - {0x3a0d ,0x08}, - {0x3a0e ,0x06}, - {0x3500 ,0x00}, - {0x3501 ,0x00}, - {0x3502 ,0x00}, - {0x350a ,0x00}, - {0x350b ,0x00}, - {0x3503 ,0x00}, - {0x3030 ,0x2b}, - {0x3a02 ,0x00}, - {0x3a03 ,0x7d}, - {0x3a04 ,0x00}, - {0x3a14 ,0x00}, - {0x3a15 ,0x7d}, - {0x3a16 ,0x00}, - {0x3a00 ,0x78}, - {0x3a08 ,0x09}, - {0x3a09 ,0x60}, - {0x3a0a ,0x07}, - {0x3a0b ,0xd0}, - {0x3a0d ,0x10}, - {0x3a0e ,0x0d}, - {0x4407 ,0x04}, - {0x5193 ,0x70}, - {0x589b ,0x00}, - {0x589a ,0xc0}, - {0x401e ,0x20}, - {0x4001 ,0x42}, - {0x401c ,0x06}, - {0x3825 ,0xac}, - {0x3827 ,0x0c}, - {0x5402 ,0x3f}, - {0x5403 ,0x00}, - {0x3406 ,0x00}, - {0x5025 ,0x80}, - {0x5583 ,0x40}, - {0x5584 ,0x40}, - {0x5580 ,0x02}, - {0x5000 ,0xcf}, - {0x3710 ,0x10}, - {0x3632 ,0x51}, - {0x3702 ,0x10}, - {0x3703 ,0xb2}, - {0x3704 ,0x18}, - {0x370b ,0x40}, - {0x370d ,0x03}, - {0x3631 ,0x01}, - {0x3632 ,0x52}, - {0x3606 ,0x24}, - {0x3620 ,0x96}, - {0x5785 ,0x07}, - {0x3a13 ,0x30}, - {0x3600 ,0x52}, - {0x3604 ,0x48}, - {0x3606 ,0x1b}, - {0x370d ,0x0b}, - {0x370f ,0xc0}, - {0x3709 ,0x01}, - {0x3823 ,0x00}, - {0x5007 ,0x00}, - {0x5009 ,0x00}, - {0x5011 ,0x00}, - {0x5013 ,0x00}, - {0x519e ,0x00}, - {0x5086 ,0x00}, - {0x5087 ,0x00}, - {0x5088 ,0x00}, - {0x5089 ,0x00}, - {0x302b ,0x00}, - {0x3503 ,0x07}, - {0x3011 ,0x08}, - {0x350c ,0x02}, - {0x350d ,0xe4}, - {0x3621 ,0xc9}, - {0x370a ,0x81}, - {0x3803 ,0x08}, - {0x3804 ,0x05}, - {0x3805 ,0x00}, - {0x3806 ,0x02}, - {0x3807 ,0xd0}, - {0x3808 ,0x05}, - {0x3809 ,0x00}, - {0x380a ,0x02}, - {0x380b ,0xd0}, - {0x380c ,0x08}, - {0x380d ,0x72}, - {0x380e ,0x02}, - {0x380f ,0xe4}, - {0x3810 ,0xc0}, - {0x3818 ,0xc9}, - {0x381c ,0x10}, - {0x381d ,0xa0}, - {0x381e ,0x05}, - {0x381f ,0xb0}, - {0x3820 ,0x00}, - {0x3821 ,0x00}, - {0x3824 ,0x11}, - {0x3a08 ,0x1b}, - {0x3a09 ,0xc0}, - {0x3a0a ,0x17}, - {0x3a0b ,0x20}, - {0x3a0d ,0x02}, - {0x3a0e ,0x01}, - {0x401c ,0x04}, - {0x5682 ,0x05}, - {0x5683 ,0x00}, - {0x5686 ,0x02}, - {0x5687 ,0xcc}, - {0x5001 ,0x7f}, - {0x589b ,0x06}, - {0x589a ,0xc5}, - {0x3503 ,0x00}, - {0x3010 ,0x10}, - - {0x5001 ,0xFF}, - {0x5583 ,0x50}, - {0x5584 ,0x50}, - {0x5580 ,0x02}, - - {0x3c01 ,0x80}, - {0x3c00 ,0x04}, - - {0x5800 ,0x48}, - {0x5801 ,0x31}, - {0x5802 ,0x21}, - {0x5803 ,0x1b}, - {0x5804 ,0x1a}, - {0x5805 ,0x1e}, - {0x5806 ,0x29}, - {0x5807 ,0x38}, - {0x5808 ,0x26}, - {0x5809 ,0x17}, - {0x580a ,0x11}, - {0x580b ,0xe }, - {0x580c ,0xd }, - {0x580d ,0xe }, - {0x580e ,0x13}, - {0x580f ,0x1a}, - {0x5810 ,0x15}, - {0x5811 ,0xd }, - {0x5812 ,0x8 }, - {0x5813 ,0x5 }, - {0x5814 ,0x4 }, - {0x5815 ,0x5 }, - {0x5816 ,0x9 }, - {0x5817 ,0xd }, - {0x5818 ,0x11}, - {0x5819 ,0xa }, - {0x581a ,0x4 }, - {0x581b ,0x0 }, - {0x581c ,0x0 }, - {0x581d ,0x1 }, - {0x581e ,0x6 }, - {0x581f ,0x9 }, - {0x5820 ,0x12}, - {0x5821 ,0xb }, - {0x5822 ,0x4 }, - {0x5823 ,0x0 }, - {0x5824 ,0x0 }, - {0x5825 ,0x1 }, - {0x5826 ,0x6 }, - {0x5827 ,0xa }, - {0x5828 ,0x17}, - {0x5829 ,0xf }, - {0x582a ,0x9 }, - {0x582b ,0x6 }, - {0x582c ,0x5 }, - {0x582d ,0x6 }, - {0x582e ,0xa }, - {0x582f ,0xe }, - {0x5830 ,0x28}, - {0x5831 ,0x1a}, - {0x5832 ,0x11}, - {0x5833 ,0xe }, - {0x5834 ,0xe }, - {0x5835 ,0xf }, - {0x5836 ,0x15}, - {0x5837 ,0x1d}, - {0x5838 ,0x6e}, - {0x5839 ,0x39}, - {0x583a ,0x27}, - {0x583b ,0x1f}, - {0x583c ,0x1e}, - {0x583d ,0x23}, - {0x583e ,0x2f}, - {0x583f ,0x41}, - {0x5840 ,0xe }, - {0x5841 ,0xc }, - {0x5842 ,0xd }, - {0x5843 ,0xc }, - {0x5844 ,0xc }, - {0x5845 ,0xc }, - {0x5846 ,0xc }, - {0x5847 ,0xc }, - {0x5848 ,0xd }, - {0x5849 ,0xe }, - {0x584a ,0xe }, - {0x584b ,0xa }, - {0x584c ,0xe }, - {0x584d ,0xe }, - {0x584e ,0x10}, - {0x584f ,0x10}, - {0x5850 ,0x11}, - {0x5851 ,0xa }, - {0x5852 ,0xf }, - {0x5853 ,0xe }, - {0x5854 ,0x10}, - {0x5855 ,0x10}, - {0x5856 ,0x10}, - {0x5857 ,0xa }, - {0x5858 ,0xe }, - {0x5859 ,0xe }, - {0x585a ,0xf }, - {0x585b ,0xf }, - {0x585c ,0xf }, - {0x585d ,0xa }, - {0x585e ,0x9 }, - {0x585f ,0xd }, - {0x5860 ,0xc }, - {0x5861 ,0xb }, - {0x5862 ,0xd }, - {0x5863 ,0x7 }, - {0x5864 ,0x17}, - {0x5865 ,0x14}, - {0x5866 ,0x18}, - {0x5867 ,0x18}, - {0x5868 ,0x16}, - {0x5869 ,0x12}, - {0x586a ,0x1b}, - {0x586b ,0x1a}, - {0x586c ,0x16}, - {0x586d ,0x16}, - {0x586e ,0x18}, - {0x586f ,0x1f}, - {0x5870 ,0x1c}, - {0x5871 ,0x16}, - {0x5872 ,0x10}, - {0x5873 ,0xf }, - {0x5874 ,0x13}, - {0x5875 ,0x1c}, - {0x5876 ,0x1e}, - {0x5877 ,0x17}, - {0x5878 ,0x11}, - {0x5879 ,0x11}, - {0x587a ,0x14}, - {0x587b ,0x1e}, - {0x587c ,0x1c}, - {0x587d ,0x1c}, - {0x587e ,0x1a}, - {0x587f ,0x1a}, - {0x5880 ,0x1b}, - {0x5881 ,0x1f}, - {0x5882 ,0x14}, - {0x5883 ,0x1a}, - {0x5884 ,0x1d}, - {0x5885 ,0x1e}, - {0x5886 ,0x1a}, - {0x5887 ,0x1a}, - - {0x5180 ,0xff}, - {0x5181 ,0x52}, - {0x5182 ,0x11}, - {0x5183 ,0x14}, - {0x5184 ,0x25}, - {0x5185 ,0x24}, - {0x5186 ,0x14}, - {0x5187 ,0x14}, - {0x5188 ,0x14}, - {0x5189 ,0x69}, - {0x518a ,0x60}, - {0x518b ,0xa2}, - {0x518c ,0x9c}, - {0x518d ,0x36}, - {0x518e ,0x34}, - {0x518f ,0x54}, - {0x5190 ,0x4c}, - {0x5191 ,0xf8}, - {0x5192 ,0x04}, - {0x5193 ,0x70}, - {0x5194 ,0xf0}, - {0x5195 ,0xf0}, - {0x5196 ,0x03}, - {0x5197 ,0x01}, - {0x5198 ,0x05}, - {0x5199 ,0x2f}, - {0x519a ,0x04}, - {0x519b ,0x00}, - {0x519c ,0x06}, - {0x519d ,0xa0}, - {0x519e ,0xa0}, - - {0x528a ,0x00}, - {0x528b ,0x01}, - {0x528c ,0x04}, - {0x528d ,0x08}, - {0x528e ,0x10}, - {0x528f ,0x20}, - {0x5290 ,0x30}, - {0x5292 ,0x00}, - {0x5293 ,0x00}, - {0x5294 ,0x00}, - {0x5295 ,0x01}, - {0x5296 ,0x00}, - {0x5297 ,0x04}, - {0x5298 ,0x00}, - {0x5299 ,0x08}, - {0x529a ,0x00}, - {0x529b ,0x10}, - {0x529c ,0x00}, - {0x529d ,0x20}, - {0x529e ,0x00}, - {0x529f ,0x30}, - {0x5282 ,0x00}, - {0x5300 ,0x00}, - {0x5301 ,0x20}, - {0x5302 ,0x00}, - {0x5303 ,0x7c}, - {0x530c ,0x00}, - {0x530d ,0x10}, - {0x530e ,0x20}, - {0x530f ,0x80}, - {0x5310 ,0x20}, - {0x5311 ,0x80}, - {0x5308 ,0x20}, - {0x5309 ,0x40}, - {0x5304 ,0x00}, - {0x5305 ,0x30}, - {0x5306 ,0x00}, - {0x5307 ,0x80}, - {0x5314 ,0x08}, - {0x5315 ,0x20}, - {0x5319 ,0x30}, - {0x5316 ,0x10}, - {0x5317 ,0x00}, - {0x5318 ,0x02}, - - {0x5380 ,0x01}, - {0x5381 ,0x00}, - {0x5382 ,0x00}, - {0x5383 ,0x1f}, - {0x5384 ,0x00}, - {0x5385 ,0x06}, - {0x5386 ,0x00}, - {0x5387 ,0x00}, - {0x5388 ,0x00}, - {0x5389 ,0xE1}, - {0x538A ,0x00}, - {0x538B ,0x2B}, - {0x538C ,0x00}, - {0x538D ,0x00}, - {0x538E ,0x00}, - {0x538F ,0x10}, - {0x5390 ,0x00}, - {0x5391 ,0xB3}, - {0x5392 ,0x00}, - {0x5393 ,0xA6}, - {0x5394 ,0x08}, - - {0x5480 ,0x0c}, - {0x5481 ,0x18}, - {0x5482 ,0x2f}, - {0x5483 ,0x55}, - {0x5484 ,0x64}, - {0x5485 ,0x71}, - {0x5486 ,0x7d}, - {0x5487 ,0x87}, - {0x5488 ,0x91}, - {0x5489 ,0x9a}, - {0x548A ,0xaa}, - {0x548B ,0xb8}, - {0x548C ,0xcd}, - {0x548D ,0xdd}, - {0x548E ,0xea}, - {0x548F ,0x1d}, - {0x5490 ,0x05}, - {0x5491 ,0x00}, - {0x5492 ,0x04}, - {0x5493 ,0x20}, - {0x5494 ,0x03}, - - {0x5495 ,0x60}, - {0x5496 ,0x02}, - {0x5497 ,0xB8}, - {0x5498 ,0x02}, - {0x5499 ,0x86}, - {0x549A ,0x02}, - {0x549B ,0x5B}, - {0x549C ,0x02}, - {0x549D ,0x3B}, - {0x549E ,0x02}, - {0x549F ,0x1C}, - {0x54A0 ,0x02}, - {0x54A1 ,0x04}, - {0x54A2 ,0x01}, - {0x54A3 ,0xED}, - {0x54A4 ,0x01}, - {0x54A5 ,0xC5}, - {0x54A6 ,0x01}, - {0x54A7 ,0xA5}, - {0x54A8 ,0x01}, - {0x54A9 ,0x6C}, - {0x54AA ,0x01}, - {0x54AB ,0x41}, - {0x54AC ,0x01}, - {0x54AD ,0x20}, - {0x54AE ,0x00}, - {0x54AF ,0x16}, - {0x54B0 ,0x01}, - {0x54B1 ,0x20}, - {0x54B2 ,0x00}, - {0x54B3 ,0x10}, - {0x54B4 ,0x00}, - {0x54B5 ,0xf0}, - {0x54B6 ,0x00}, - {0x54B7 ,0xDF}, - - {0x5402 ,0x3f}, - {0x5403 ,0x00}, - - {0x5500 ,0x10}, - {0x5502 ,0x00}, - {0x5503 ,0x06}, - {0x5504 ,0x00}, - {0x5505 ,0x7f}, - - {0x5025 ,0x80}, - {0x3a0f ,0x30}, - {0x3a10 ,0x28}, - {0x3a1b ,0x30}, - {0x3a1e ,0x28}, - {0x3a11 ,0x61}, - {0x3a1f ,0x10}, - {0x5688 ,0xfd}, - {0x5689 ,0xdf}, - {0x568a ,0xfe}, - {0x568b ,0xef}, - {0x568c ,0xfe}, - {0x568d ,0xef}, - {0x568e ,0xaa}, - {0x568f ,0xaa}, - {0x3818, 0xa8}, - {0x3621, 0x27}, - {0xffff, 0xff}, - +const struct sensor_reg OV5642_720P_Video_setting[] PROGMEM = + { + {0x3103, 0x93}, + {0x3008, 0x82}, + {0x3017, 0x7f}, + {0x3018, 0xfc}, + {0x3810, 0xc2}, + {0x3615, 0xf0}, + {0x3000, 0x00}, + {0x3001, 0x00}, + {0x3002, 0x00}, + {0x3003, 0x00}, + {0x3004, 0xff}, + {0x3030, 0x2b}, + {0x3011, 0x08}, + {0x3010, 0x10}, + {0x3604, 0x60}, + {0x3622, 0x60}, + {0x3621, 0x09}, + {0x3709, 0x00}, + {0x4000, 0x21}, + {0x401d, 0x22}, + {0x3600, 0x54}, + {0x3605, 0x04}, + {0x3606, 0x3f}, + {0x3c01, 0x80}, + {0x300d, 0x22}, + {0x3623, 0x22}, + {0x5000, 0x4f}, + {0x5020, 0x04}, + {0x5181, 0x79}, + {0x5182, 0x00}, + {0x5185, 0x22}, + {0x5197, 0x01}, + {0x5500, 0x0a}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + {0x5080, 0x08}, + {0x300e, 0x18}, + {0x4610, 0x00}, + {0x471d, 0x05}, + {0x4708, 0x06}, + {0x370c, 0xa0}, + {0x3808, 0x0a}, + {0x3809, 0x20}, + {0x380a, 0x07}, + {0x380b, 0x98}, + {0x380c, 0x0c}, + {0x380d, 0x80}, + {0x380e, 0x07}, + {0x380f, 0xd0}, + {0x5687, 0x94}, + {0x501f, 0x00}, + {0x5000, 0x4f}, + {0x5001, 0xcf}, + {0x4300, 0x30}, + {0x4300, 0x30}, + {0x460b, 0x35}, + {0x471d, 0x00}, + {0x3002, 0x0c}, + {0x3002, 0x00}, + {0x4713, 0x03}, + {0x471c, 0x50}, + {0x4721, 0x02}, + {0x4402, 0x90}, + {0x460c, 0x22}, + {0x3815, 0x44}, + {0x3503, 0x07}, + {0x3501, 0x73}, + {0x3502, 0x80}, + {0x350b, 0x00}, + {0x3818, 0xc8}, + {0x3801, 0x88}, + {0x3824, 0x11}, + {0x3a00, 0x78}, + {0x3a1a, 0x04}, + {0x3a13, 0x30}, + {0x3a18, 0x00}, + {0x3a19, 0x7c}, + {0x3a08, 0x12}, + {0x3a09, 0xc0}, + {0x3a0a, 0x0f}, + {0x3a0b, 0xa0}, + {0x350c, 0x07}, + {0x350d, 0xd0}, + {0x3a0d, 0x08}, + {0x3a0e, 0x06}, + {0x3500, 0x00}, + {0x3501, 0x00}, + {0x3502, 0x00}, + {0x350a, 0x00}, + {0x350b, 0x00}, + {0x3503, 0x00}, + {0x3030, 0x2b}, + {0x3a02, 0x00}, + {0x3a03, 0x7d}, + {0x3a04, 0x00}, + {0x3a14, 0x00}, + {0x3a15, 0x7d}, + {0x3a16, 0x00}, + {0x3a00, 0x78}, + {0x3a08, 0x09}, + {0x3a09, 0x60}, + {0x3a0a, 0x07}, + {0x3a0b, 0xd0}, + {0x3a0d, 0x10}, + {0x3a0e, 0x0d}, + {0x4407, 0x04}, + {0x5193, 0x70}, + {0x589b, 0x00}, + {0x589a, 0xc0}, + {0x401e, 0x20}, + {0x4001, 0x42}, + {0x401c, 0x06}, + {0x3825, 0xac}, + {0x3827, 0x0c}, + {0x5402, 0x3f}, + {0x5403, 0x00}, + {0x3406, 0x00}, + {0x5025, 0x80}, + {0x5583, 0x40}, + {0x5584, 0x40}, + {0x5580, 0x02}, + {0x5000, 0xcf}, + {0x3710, 0x10}, + {0x3632, 0x51}, + {0x3702, 0x10}, + {0x3703, 0xb2}, + {0x3704, 0x18}, + {0x370b, 0x40}, + {0x370d, 0x03}, + {0x3631, 0x01}, + {0x3632, 0x52}, + {0x3606, 0x24}, + {0x3620, 0x96}, + {0x5785, 0x07}, + {0x3a13, 0x30}, + {0x3600, 0x52}, + {0x3604, 0x48}, + {0x3606, 0x1b}, + {0x370d, 0x0b}, + {0x370f, 0xc0}, + {0x3709, 0x01}, + {0x3823, 0x00}, + {0x5007, 0x00}, + {0x5009, 0x00}, + {0x5011, 0x00}, + {0x5013, 0x00}, + {0x519e, 0x00}, + {0x5086, 0x00}, + {0x5087, 0x00}, + {0x5088, 0x00}, + {0x5089, 0x00}, + {0x302b, 0x00}, + {0x3503, 0x07}, + {0x3011, 0x08}, + {0x350c, 0x02}, + {0x350d, 0xe4}, + {0x3621, 0xc9}, + {0x370a, 0x81}, + {0x3803, 0x08}, + {0x3804, 0x05}, + {0x3805, 0x00}, + {0x3806, 0x02}, + {0x3807, 0xd0}, + {0x3808, 0x05}, + {0x3809, 0x00}, + {0x380a, 0x02}, + {0x380b, 0xd0}, + {0x380c, 0x08}, + {0x380d, 0x72}, + {0x380e, 0x02}, + {0x380f, 0xe4}, + {0x3810, 0xc0}, + {0x3818, 0xc9}, + {0x381c, 0x10}, + {0x381d, 0xa0}, + {0x381e, 0x05}, + {0x381f, 0xb0}, + {0x3820, 0x00}, + {0x3821, 0x00}, + {0x3824, 0x11}, + {0x3a08, 0x1b}, + {0x3a09, 0xc0}, + {0x3a0a, 0x17}, + {0x3a0b, 0x20}, + {0x3a0d, 0x02}, + {0x3a0e, 0x01}, + {0x401c, 0x04}, + {0x5682, 0x05}, + {0x5683, 0x00}, + {0x5686, 0x02}, + {0x5687, 0xcc}, + {0x5001, 0x7f}, + {0x589b, 0x06}, + {0x589a, 0xc5}, + {0x3503, 0x00}, + {0x3010, 0x10}, + + {0x5001, 0xFF}, + {0x5583, 0x50}, + {0x5584, 0x50}, + {0x5580, 0x02}, + + {0x3c01, 0x80}, + {0x3c00, 0x04}, + + {0x5800, 0x48}, + {0x5801, 0x31}, + {0x5802, 0x21}, + {0x5803, 0x1b}, + {0x5804, 0x1a}, + {0x5805, 0x1e}, + {0x5806, 0x29}, + {0x5807, 0x38}, + {0x5808, 0x26}, + {0x5809, 0x17}, + {0x580a, 0x11}, + {0x580b, 0xe}, + {0x580c, 0xd}, + {0x580d, 0xe}, + {0x580e, 0x13}, + {0x580f, 0x1a}, + {0x5810, 0x15}, + {0x5811, 0xd}, + {0x5812, 0x8}, + {0x5813, 0x5}, + {0x5814, 0x4}, + {0x5815, 0x5}, + {0x5816, 0x9}, + {0x5817, 0xd}, + {0x5818, 0x11}, + {0x5819, 0xa}, + {0x581a, 0x4}, + {0x581b, 0x0}, + {0x581c, 0x0}, + {0x581d, 0x1}, + {0x581e, 0x6}, + {0x581f, 0x9}, + {0x5820, 0x12}, + {0x5821, 0xb}, + {0x5822, 0x4}, + {0x5823, 0x0}, + {0x5824, 0x0}, + {0x5825, 0x1}, + {0x5826, 0x6}, + {0x5827, 0xa}, + {0x5828, 0x17}, + {0x5829, 0xf}, + {0x582a, 0x9}, + {0x582b, 0x6}, + {0x582c, 0x5}, + {0x582d, 0x6}, + {0x582e, 0xa}, + {0x582f, 0xe}, + {0x5830, 0x28}, + {0x5831, 0x1a}, + {0x5832, 0x11}, + {0x5833, 0xe}, + {0x5834, 0xe}, + {0x5835, 0xf}, + {0x5836, 0x15}, + {0x5837, 0x1d}, + {0x5838, 0x6e}, + {0x5839, 0x39}, + {0x583a, 0x27}, + {0x583b, 0x1f}, + {0x583c, 0x1e}, + {0x583d, 0x23}, + {0x583e, 0x2f}, + {0x583f, 0x41}, + {0x5840, 0xe}, + {0x5841, 0xc}, + {0x5842, 0xd}, + {0x5843, 0xc}, + {0x5844, 0xc}, + {0x5845, 0xc}, + {0x5846, 0xc}, + {0x5847, 0xc}, + {0x5848, 0xd}, + {0x5849, 0xe}, + {0x584a, 0xe}, + {0x584b, 0xa}, + {0x584c, 0xe}, + {0x584d, 0xe}, + {0x584e, 0x10}, + {0x584f, 0x10}, + {0x5850, 0x11}, + {0x5851, 0xa}, + {0x5852, 0xf}, + {0x5853, 0xe}, + {0x5854, 0x10}, + {0x5855, 0x10}, + {0x5856, 0x10}, + {0x5857, 0xa}, + {0x5858, 0xe}, + {0x5859, 0xe}, + {0x585a, 0xf}, + {0x585b, 0xf}, + {0x585c, 0xf}, + {0x585d, 0xa}, + {0x585e, 0x9}, + {0x585f, 0xd}, + {0x5860, 0xc}, + {0x5861, 0xb}, + {0x5862, 0xd}, + {0x5863, 0x7}, + {0x5864, 0x17}, + {0x5865, 0x14}, + {0x5866, 0x18}, + {0x5867, 0x18}, + {0x5868, 0x16}, + {0x5869, 0x12}, + {0x586a, 0x1b}, + {0x586b, 0x1a}, + {0x586c, 0x16}, + {0x586d, 0x16}, + {0x586e, 0x18}, + {0x586f, 0x1f}, + {0x5870, 0x1c}, + {0x5871, 0x16}, + {0x5872, 0x10}, + {0x5873, 0xf}, + {0x5874, 0x13}, + {0x5875, 0x1c}, + {0x5876, 0x1e}, + {0x5877, 0x17}, + {0x5878, 0x11}, + {0x5879, 0x11}, + {0x587a, 0x14}, + {0x587b, 0x1e}, + {0x587c, 0x1c}, + {0x587d, 0x1c}, + {0x587e, 0x1a}, + {0x587f, 0x1a}, + {0x5880, 0x1b}, + {0x5881, 0x1f}, + {0x5882, 0x14}, + {0x5883, 0x1a}, + {0x5884, 0x1d}, + {0x5885, 0x1e}, + {0x5886, 0x1a}, + {0x5887, 0x1a}, + + {0x5180, 0xff}, + {0x5181, 0x52}, + {0x5182, 0x11}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x14}, + {0x5187, 0x14}, + {0x5188, 0x14}, + {0x5189, 0x69}, + {0x518a, 0x60}, + {0x518b, 0xa2}, + {0x518c, 0x9c}, + {0x518d, 0x36}, + {0x518e, 0x34}, + {0x518f, 0x54}, + {0x5190, 0x4c}, + {0x5191, 0xf8}, + {0x5192, 0x04}, + {0x5193, 0x70}, + {0x5194, 0xf0}, + {0x5195, 0xf0}, + {0x5196, 0x03}, + {0x5197, 0x01}, + {0x5198, 0x05}, + {0x5199, 0x2f}, + {0x519a, 0x04}, + {0x519b, 0x00}, + {0x519c, 0x06}, + {0x519d, 0xa0}, + {0x519e, 0xa0}, + + {0x528a, 0x00}, + {0x528b, 0x01}, + {0x528c, 0x04}, + {0x528d, 0x08}, + {0x528e, 0x10}, + {0x528f, 0x20}, + {0x5290, 0x30}, + {0x5292, 0x00}, + {0x5293, 0x00}, + {0x5294, 0x00}, + {0x5295, 0x01}, + {0x5296, 0x00}, + {0x5297, 0x04}, + {0x5298, 0x00}, + {0x5299, 0x08}, + {0x529a, 0x00}, + {0x529b, 0x10}, + {0x529c, 0x00}, + {0x529d, 0x20}, + {0x529e, 0x00}, + {0x529f, 0x30}, + {0x5282, 0x00}, + {0x5300, 0x00}, + {0x5301, 0x20}, + {0x5302, 0x00}, + {0x5303, 0x7c}, + {0x530c, 0x00}, + {0x530d, 0x10}, + {0x530e, 0x20}, + {0x530f, 0x80}, + {0x5310, 0x20}, + {0x5311, 0x80}, + {0x5308, 0x20}, + {0x5309, 0x40}, + {0x5304, 0x00}, + {0x5305, 0x30}, + {0x5306, 0x00}, + {0x5307, 0x80}, + {0x5314, 0x08}, + {0x5315, 0x20}, + {0x5319, 0x30}, + {0x5316, 0x10}, + {0x5317, 0x00}, + {0x5318, 0x02}, + + {0x5380, 0x01}, + {0x5381, 0x00}, + {0x5382, 0x00}, + {0x5383, 0x1f}, + {0x5384, 0x00}, + {0x5385, 0x06}, + {0x5386, 0x00}, + {0x5387, 0x00}, + {0x5388, 0x00}, + {0x5389, 0xE1}, + {0x538A, 0x00}, + {0x538B, 0x2B}, + {0x538C, 0x00}, + {0x538D, 0x00}, + {0x538E, 0x00}, + {0x538F, 0x10}, + {0x5390, 0x00}, + {0x5391, 0xB3}, + {0x5392, 0x00}, + {0x5393, 0xA6}, + {0x5394, 0x08}, + + {0x5480, 0x0c}, + {0x5481, 0x18}, + {0x5482, 0x2f}, + {0x5483, 0x55}, + {0x5484, 0x64}, + {0x5485, 0x71}, + {0x5486, 0x7d}, + {0x5487, 0x87}, + {0x5488, 0x91}, + {0x5489, 0x9a}, + {0x548A, 0xaa}, + {0x548B, 0xb8}, + {0x548C, 0xcd}, + {0x548D, 0xdd}, + {0x548E, 0xea}, + {0x548F, 0x1d}, + {0x5490, 0x05}, + {0x5491, 0x00}, + {0x5492, 0x04}, + {0x5493, 0x20}, + {0x5494, 0x03}, + + {0x5495, 0x60}, + {0x5496, 0x02}, + {0x5497, 0xB8}, + {0x5498, 0x02}, + {0x5499, 0x86}, + {0x549A, 0x02}, + {0x549B, 0x5B}, + {0x549C, 0x02}, + {0x549D, 0x3B}, + {0x549E, 0x02}, + {0x549F, 0x1C}, + {0x54A0, 0x02}, + {0x54A1, 0x04}, + {0x54A2, 0x01}, + {0x54A3, 0xED}, + {0x54A4, 0x01}, + {0x54A5, 0xC5}, + {0x54A6, 0x01}, + {0x54A7, 0xA5}, + {0x54A8, 0x01}, + {0x54A9, 0x6C}, + {0x54AA, 0x01}, + {0x54AB, 0x41}, + {0x54AC, 0x01}, + {0x54AD, 0x20}, + {0x54AE, 0x00}, + {0x54AF, 0x16}, + {0x54B0, 0x01}, + {0x54B1, 0x20}, + {0x54B2, 0x00}, + {0x54B3, 0x10}, + {0x54B4, 0x00}, + {0x54B5, 0xf0}, + {0x54B6, 0x00}, + {0x54B7, 0xDF}, + + {0x5402, 0x3f}, + {0x5403, 0x00}, + + {0x5500, 0x10}, + {0x5502, 0x00}, + {0x5503, 0x06}, + {0x5504, 0x00}, + {0x5505, 0x7f}, + + {0x5025, 0x80}, + {0x3a0f, 0x30}, + {0x3a10, 0x28}, + {0x3a1b, 0x30}, + {0x3a1e, 0x28}, + {0x3a11, 0x61}, + {0x3a1f, 0x10}, + {0x5688, 0xfd}, + {0x5689, 0xdf}, + {0x568a, 0xfe}, + {0x568b, 0xef}, + {0x568c, 0xfe}, + {0x568d, 0xef}, + {0x568e, 0xaa}, + {0x568f, 0xaa}, + {0x3818, 0xa8}, + {0x3621, 0x27}, + {0xffff, 0xff}, + }; #endif diff --git a/ArduCAM/ov7660_regs.h b/ArduCAM/ov7660_regs.h index c550bab2..4d6d53ae 100644 --- a/ArduCAM/ov7660_regs.h +++ b/ArduCAM/ov7660_regs.h @@ -1,118 +1,116 @@ #ifndef OV7660_REGS_H #define OV7660_REGS_H #include "ArduCAM.h" -//#include +// #include const struct sensor_reg OV7660_QVGA[] PROGMEM = -{ - {0x11, 0x83}, - {0x92, 0x48}, - {0x93, 0x00}, - {0x9d, 0x31}, - {0x9e, 0x29}, - {0x3b, 0x02}, - {0x13, 0xf2}, - {0x10, 0x00}, - {0x00, 0x00}, - {0x01, 0x80}, - {0x02, 0x80}, - {0x13, 0xf7}, - {0x12, 0x14}, - {0x04, 0x00}, - {0x18, 0x4b}, - {0x17, 0x23}, - {0x32, 0xbf}, - {0x19, 0x02}, - {0x1a, 0x7a}, - {0x03, 0x00}, - {0x0e, 0x84}, - {0x0f, 0x62}, - {0x15, 0x02}, - {0x16, 0x02}, - {0x1b, 0x01}, - {0x1e, 0x01}, - {0x29, 0x3c}, - {0x33, 0x00}, - {0x34, 0x07}, - {0x35, 0x84}, - {0x36, 0x00}, - {0x38, 0x13}, - {0x39, 0x43}, - {0x3a, 0x00}, - {0x3c, 0x6c}, - {0x3d, 0x90}, - {0x3f, 0x29}, - {0x40, 0xd1}, - {0x41, 0x20}, - {0x6b, 0x0a}, - {0xa1, 0xc8}, - {0x69, 0x80}, - {0x43, 0xf0}, - {0x44, 0x10}, - {0x45, 0x78}, - {0x46, 0xa8}, - {0x47, 0x60}, - {0x48, 0x80}, - {0x59, 0xba}, - {0x5a, 0x9a}, - {0x5b, 0x22}, - {0x5c, 0xb9}, - {0x5d, 0x9b}, - {0x5e, 0x10}, - {0x5f, 0xe0}, - {0x60, 0x85}, - {0x61, 0x60}, - {0x9f, 0x9d}, - {0xa0, 0xa0}, - {0x4f, 0xae}, - {0x50, 0x26}, - {0x51, 0x08}, - {0x52, 0x1a}, - {0x53, 0xa9}, - {0x54, 0x0f}, - {0x55, 0x05}, - {0x56, 0x46}, - {0x57, 0xcb}, - {0x58, 0x77}, - {0x8b, 0xcc}, - {0x8c, 0xcc}, - {0x8d, 0xcf}, - {0x6c, 0x40}, - {0x6d, 0x30}, - {0x6e, 0x4b}, - {0x6f, 0x60}, - {0x70, 0x70}, - {0x71, 0x70}, - {0x72, 0x70}, - {0x73, 0x70}, - {0x74, 0x60}, - {0x75, 0x60}, - {0x76, 0x50}, - {0x77, 0x48}, - {0x78, 0x3a}, - {0x79, 0x2e}, - {0x7a, 0x28}, - {0x7b, 0x22}, - {0x7c, 0x04}, - {0x7d, 0x07}, - {0x7e, 0x10}, - {0x7f, 0x28}, - {0x80, 0x36}, - {0x81, 0x44}, - {0x82, 0x52}, - {0x83, 0x60}, - {0x84, 0x6c}, - {0x85, 0x78}, - {0x86, 0x8c}, - {0x87, 0x9e}, - {0x88, 0xbb}, - {0x89, 0xd2}, - {0x8a, 0xe6}, - {0x14, 0x2e}, - {0x24, 0x68}, - {0x25, 0x58}, - {0xff, 0xff}, -}; - + { + {0x11, 0x83}, + {0x92, 0x48}, + {0x93, 0x00}, + {0x9d, 0x31}, + {0x9e, 0x29}, + {0x3b, 0x02}, + {0x13, 0xf2}, + {0x10, 0x00}, + {0x00, 0x00}, + {0x01, 0x80}, + {0x02, 0x80}, + {0x13, 0xf7}, + {0x12, 0x14}, + {0x04, 0x00}, + {0x18, 0x4b}, + {0x17, 0x23}, + {0x32, 0xbf}, + {0x19, 0x02}, + {0x1a, 0x7a}, + {0x03, 0x00}, + {0x0e, 0x84}, + {0x0f, 0x62}, + {0x15, 0x02}, + {0x16, 0x02}, + {0x1b, 0x01}, + {0x1e, 0x01}, + {0x29, 0x3c}, + {0x33, 0x00}, + {0x34, 0x07}, + {0x35, 0x84}, + {0x36, 0x00}, + {0x38, 0x13}, + {0x39, 0x43}, + {0x3a, 0x00}, + {0x3c, 0x6c}, + {0x3d, 0x90}, + {0x3f, 0x29}, + {0x40, 0xd1}, + {0x41, 0x20}, + {0x6b, 0x0a}, + {0xa1, 0xc8}, + {0x69, 0x80}, + {0x43, 0xf0}, + {0x44, 0x10}, + {0x45, 0x78}, + {0x46, 0xa8}, + {0x47, 0x60}, + {0x48, 0x80}, + {0x59, 0xba}, + {0x5a, 0x9a}, + {0x5b, 0x22}, + {0x5c, 0xb9}, + {0x5d, 0x9b}, + {0x5e, 0x10}, + {0x5f, 0xe0}, + {0x60, 0x85}, + {0x61, 0x60}, + {0x9f, 0x9d}, + {0xa0, 0xa0}, + {0x4f, 0xae}, + {0x50, 0x26}, + {0x51, 0x08}, + {0x52, 0x1a}, + {0x53, 0xa9}, + {0x54, 0x0f}, + {0x55, 0x05}, + {0x56, 0x46}, + {0x57, 0xcb}, + {0x58, 0x77}, + {0x8b, 0xcc}, + {0x8c, 0xcc}, + {0x8d, 0xcf}, + {0x6c, 0x40}, + {0x6d, 0x30}, + {0x6e, 0x4b}, + {0x6f, 0x60}, + {0x70, 0x70}, + {0x71, 0x70}, + {0x72, 0x70}, + {0x73, 0x70}, + {0x74, 0x60}, + {0x75, 0x60}, + {0x76, 0x50}, + {0x77, 0x48}, + {0x78, 0x3a}, + {0x79, 0x2e}, + {0x7a, 0x28}, + {0x7b, 0x22}, + {0x7c, 0x04}, + {0x7d, 0x07}, + {0x7e, 0x10}, + {0x7f, 0x28}, + {0x80, 0x36}, + {0x81, 0x44}, + {0x82, 0x52}, + {0x83, 0x60}, + {0x84, 0x6c}, + {0x85, 0x78}, + {0x86, 0x8c}, + {0x87, 0x9e}, + {0x88, 0xbb}, + {0x89, 0xd2}, + {0x8a, 0xe6}, + {0x14, 0x2e}, + {0x24, 0x68}, + {0x25, 0x58}, + {0xff, 0xff}, +}; #endif - diff --git a/ArduCAM/ov7670_regs.h b/ArduCAM/ov7670_regs.h index ae009d9b..150fb7a2 100644 --- a/ArduCAM/ov7670_regs.h +++ b/ArduCAM/ov7670_regs.h @@ -1,177 +1,175 @@ #ifndef OV7670_REGS_H #define OV7670_REGS_H #include "ArduCAM.h" -//#include +// #include const struct sensor_reg OV7670_QVGA[] PROGMEM = -{ - {0x3a, 0x04}, - {0x40, 0xd0}, - {0x12, 0x14}, - {0x32, 0x80}, - {0x17, 0x16}, - {0x18, 0x04}, - {0x19, 0x02}, - {0x1a, 0x7b}, - {0x03, 0x06}, - {0x0c, 0x00}, - {0x3e, 0x00}, - {0x70, 0x00}, - {0x71, 0x00}, - {0x72, 0x11}, - {0x73, 0x00}, - {0xa2, 0x02}, - {0x11, 0x81}, - {0x7a, 0x20}, - {0x7b, 0x1c}, - {0x7c, 0x28}, - {0x7d, 0x3c}, - {0x7e, 0x55}, - {0x7f, 0x68}, - {0x80, 0x76}, - {0x81, 0x80}, - {0x82, 0x88}, - {0x83, 0x8f}, - {0x84, 0x96}, - {0x85, 0xa3}, - {0x86, 0xaf}, - {0x87, 0xc4}, - {0x88, 0xd7}, - {0x89, 0xe8}, - {0x13, 0xe0}, - {0x00, 0x00}, - {0x10, 0x00}, - {0x0d, 0x00}, - {0x14, 0x28}, - {0xa5, 0x05}, - {0xab, 0x07}, - {0x24, 0x75}, - {0x25, 0x63}, - {0x26, 0xA5}, - {0x9f, 0x78}, - {0xa0, 0x68}, - {0xa1, 0x03}, - {0xa6, 0xdf}, - {0xa7, 0xdf}, - {0xa8, 0xf0}, - {0xa9, 0x90}, - {0xaa, 0x94}, - {0x13, 0xe5}, - {0x0e, 0x61}, - {0x0f, 0x4b}, - {0x16, 0x02}, - {0x1e, 0x17}, - {0x21, 0x02}, - {0x22, 0x91}, - {0x29, 0x07}, - {0x33, 0x0b}, - {0x35, 0x0b}, - {0x37, 0x1d}, - {0x38, 0x71}, - {0x39, 0x2a}, - {0x3c, 0x78}, - {0x4d, 0x40}, - {0x4e, 0x20}, - {0x69, 0x00}, - {0x6b, 0x00}, - {0x74, 0x19}, - {0x8d, 0x4f}, - {0x8e, 0x00}, - {0x8f, 0x00}, - {0x90, 0x00}, - {0x91, 0x00}, - {0x92, 0x00}, - {0x96, 0x00}, - {0x9a, 0x80}, - {0xb0, 0x84}, - {0xb1, 0x0c}, - {0xb2, 0x0e}, - {0xb3, 0x82}, - {0xb8, 0x0a}, - {0x43, 0x14}, - {0x44, 0xf0}, - {0x45, 0x34}, - {0x46, 0x58}, - {0x47, 0x28}, - {0x48, 0x3a}, - {0x59, 0x88}, - {0x5a, 0x88}, - {0x5b, 0x44}, - {0x5c, 0x67}, - {0x5d, 0x49}, - {0x5e, 0x0e}, - {0x64, 0x04}, - {0x65, 0x20}, - {0x66, 0x05}, - {0x94, 0x04}, - {0x95, 0x08}, - {0x6c, 0x0a}, - {0x6d, 0x55}, - {0x6e, 0x11}, - {0x6f, 0x9f}, - {0x6a, 0x40}, - {0x01, 0x40}, - {0x02, 0x40}, - {0x13, 0xe7}, - {0x15, 0x02}, - {0x4f, 0x80}, - {0x50, 0x80}, - {0x51, 0x00}, - {0x52, 0x22}, - {0x53, 0x5e}, - {0x54, 0x80}, - {0x58, 0x9e}, - {0x41, 0x08}, - {0x3f, 0x00}, - {0x75, 0x05}, - {0x76, 0xe1}, - {0x4c, 0x00}, - {0x77, 0x01}, - {0x3d, 0xc2}, - {0x4b, 0x09}, - {0xc9, 0x60}, - {0x41, 0x38}, - {0x56, 0x40}, - {0x34, 0x11}, - {0x3b, 0x02}, - {0xa4, 0x89}, - {0x96, 0x00}, - {0x97, 0x30}, - {0x98, 0x20}, - {0x99, 0x30}, - {0x9a, 0x84}, - {0x9b, 0x29}, - {0x9c, 0x03}, - {0x9d, 0x4c}, - {0x9e, 0x3f}, - {0x78, 0x04}, - {0x79, 0x01}, - {0xc8, 0xf0}, - {0x79, 0x0f}, - {0xc8, 0x00}, - {0x79, 0x10}, - {0xc8, 0x7e}, - {0x79, 0x0a}, - {0xc8, 0x80}, - {0x79, 0x0b}, - {0xc8, 0x01}, - {0x79, 0x0c}, - {0xc8, 0x0f}, - {0x79, 0x0d}, - {0xc8, 0x20}, - {0x79, 0x09}, - {0xc8, 0x80}, - {0x79, 0x02}, - {0xc8, 0xc0}, - {0x79, 0x03}, - {0xc8, 0x40}, - {0x79, 0x05}, - {0xc8, 0x30}, - {0x79, 0x26}, - {0x09, 0x03}, - {0x3b, 0x42}, - {0xff, 0xff}, -}; - + { + {0x3a, 0x04}, + {0x40, 0xd0}, + {0x12, 0x14}, + {0x32, 0x80}, + {0x17, 0x16}, + {0x18, 0x04}, + {0x19, 0x02}, + {0x1a, 0x7b}, + {0x03, 0x06}, + {0x0c, 0x00}, + {0x3e, 0x00}, + {0x70, 0x00}, + {0x71, 0x00}, + {0x72, 0x11}, + {0x73, 0x00}, + {0xa2, 0x02}, + {0x11, 0x81}, + {0x7a, 0x20}, + {0x7b, 0x1c}, + {0x7c, 0x28}, + {0x7d, 0x3c}, + {0x7e, 0x55}, + {0x7f, 0x68}, + {0x80, 0x76}, + {0x81, 0x80}, + {0x82, 0x88}, + {0x83, 0x8f}, + {0x84, 0x96}, + {0x85, 0xa3}, + {0x86, 0xaf}, + {0x87, 0xc4}, + {0x88, 0xd7}, + {0x89, 0xe8}, + {0x13, 0xe0}, + {0x00, 0x00}, + {0x10, 0x00}, + {0x0d, 0x00}, + {0x14, 0x28}, + {0xa5, 0x05}, + {0xab, 0x07}, + {0x24, 0x75}, + {0x25, 0x63}, + {0x26, 0xA5}, + {0x9f, 0x78}, + {0xa0, 0x68}, + {0xa1, 0x03}, + {0xa6, 0xdf}, + {0xa7, 0xdf}, + {0xa8, 0xf0}, + {0xa9, 0x90}, + {0xaa, 0x94}, + {0x13, 0xe5}, + {0x0e, 0x61}, + {0x0f, 0x4b}, + {0x16, 0x02}, + {0x1e, 0x17}, + {0x21, 0x02}, + {0x22, 0x91}, + {0x29, 0x07}, + {0x33, 0x0b}, + {0x35, 0x0b}, + {0x37, 0x1d}, + {0x38, 0x71}, + {0x39, 0x2a}, + {0x3c, 0x78}, + {0x4d, 0x40}, + {0x4e, 0x20}, + {0x69, 0x00}, + {0x6b, 0x00}, + {0x74, 0x19}, + {0x8d, 0x4f}, + {0x8e, 0x00}, + {0x8f, 0x00}, + {0x90, 0x00}, + {0x91, 0x00}, + {0x92, 0x00}, + {0x96, 0x00}, + {0x9a, 0x80}, + {0xb0, 0x84}, + {0xb1, 0x0c}, + {0xb2, 0x0e}, + {0xb3, 0x82}, + {0xb8, 0x0a}, + {0x43, 0x14}, + {0x44, 0xf0}, + {0x45, 0x34}, + {0x46, 0x58}, + {0x47, 0x28}, + {0x48, 0x3a}, + {0x59, 0x88}, + {0x5a, 0x88}, + {0x5b, 0x44}, + {0x5c, 0x67}, + {0x5d, 0x49}, + {0x5e, 0x0e}, + {0x64, 0x04}, + {0x65, 0x20}, + {0x66, 0x05}, + {0x94, 0x04}, + {0x95, 0x08}, + {0x6c, 0x0a}, + {0x6d, 0x55}, + {0x6e, 0x11}, + {0x6f, 0x9f}, + {0x6a, 0x40}, + {0x01, 0x40}, + {0x02, 0x40}, + {0x13, 0xe7}, + {0x15, 0x02}, + {0x4f, 0x80}, + {0x50, 0x80}, + {0x51, 0x00}, + {0x52, 0x22}, + {0x53, 0x5e}, + {0x54, 0x80}, + {0x58, 0x9e}, + {0x41, 0x08}, + {0x3f, 0x00}, + {0x75, 0x05}, + {0x76, 0xe1}, + {0x4c, 0x00}, + {0x77, 0x01}, + {0x3d, 0xc2}, + {0x4b, 0x09}, + {0xc9, 0x60}, + {0x41, 0x38}, + {0x56, 0x40}, + {0x34, 0x11}, + {0x3b, 0x02}, + {0xa4, 0x89}, + {0x96, 0x00}, + {0x97, 0x30}, + {0x98, 0x20}, + {0x99, 0x30}, + {0x9a, 0x84}, + {0x9b, 0x29}, + {0x9c, 0x03}, + {0x9d, 0x4c}, + {0x9e, 0x3f}, + {0x78, 0x04}, + {0x79, 0x01}, + {0xc8, 0xf0}, + {0x79, 0x0f}, + {0xc8, 0x00}, + {0x79, 0x10}, + {0xc8, 0x7e}, + {0x79, 0x0a}, + {0xc8, 0x80}, + {0x79, 0x0b}, + {0xc8, 0x01}, + {0x79, 0x0c}, + {0xc8, 0x0f}, + {0x79, 0x0d}, + {0xc8, 0x20}, + {0x79, 0x09}, + {0xc8, 0x80}, + {0x79, 0x02}, + {0xc8, 0xc0}, + {0x79, 0x03}, + {0xc8, 0x40}, + {0x79, 0x05}, + {0xc8, 0x30}, + {0x79, 0x26}, + {0x09, 0x03}, + {0x3b, 0x42}, + {0xff, 0xff}, +}; #endif - diff --git a/ArduCAM/ov7675_regs.h b/ArduCAM/ov7675_regs.h index df595b7f..bed20ae1 100644 --- a/ArduCAM/ov7675_regs.h +++ b/ArduCAM/ov7675_regs.h @@ -1,211 +1,209 @@ #ifndef OV7675_REGS_H #define OV7675_REGS_H #include "ArduCAM.h" -//#include -#define OV7675_CHIPID_HIGH 0x0A -#define OV7675_CHIPID_LOW 0x0B +// #include +#define OV7675_CHIPID_HIGH 0x0A +#define OV7675_CHIPID_LOW 0x0B const struct sensor_reg OV7675_QVGA[] PROGMEM = -{ - {0x11,0x80}, - {0x3a,0x4}, - {0x12,0x0}, - {0x17,0x13}, - {0x18,0x1}, - {0x32,0xb6}, - {0x19,63}, - {0x1a,0x7b}, - {0x03,0x01}, - {0xc,0x0}, - {0x3e,0x0}, - {0x70,0x3a}, - {0x71,0x35}, - {0x72,0x11}, - {0x73,0xf0}, - {0xa2,0x2}, - {0x15,0x0}, - {0x7a,0x18}, - {0x7b,0x4}, - {0x7c,0x9}, - {0x7d,0x18}, - {0x7e,0x38}, - {0x7f,0x47}, - {0x80,0x56}, - {0x81,0x66}, - {0x82,0x74}, - {0x83,0x7f}, - {0x84,0x89}, - {0x85,0x9a}, - {0x86,0xa9}, - {0x87,0xc4}, - {0x88,0xdb}, - {0x89,0xee}, - {0x13,0xe0}, - {0x1,0x50}, - {0x2,0x68}, - {0x0,0x0}, - {0x10,0x0}, - {0xd,0x40}, - {0x14,0x48}, - {0x15,0x07}, - {0xab,0x8}, - {0x24,0x60}, - {0x25,0x50}, - {0x26,0xe3}, - {0x9f,0x78}, - {0xa0,0x68}, - {0xa1,0x3}, - {0xa6,0xd8}, - {0xa7,0xd8}, - {0xa8,0xf0}, - {0xa9,0x90}, - {0xaa,0x14}, - {0x13,0xe5}, - {0xe,0x61}, - {0xf,0x4b}, - {0x16,0x2}, - {0x1e,0x27},//0x1e,0x17 - {0x21,0x2}, - {0x22,0x91}, - {0x29,0x07}, - {0x33,0xb}, - {0x35,0xb}, - {0x37,0x1d}, - {0x38,0x71}, - {0x39,0x2a}, - {0x3c,0x78}, - {0x4d,0x40}, - {0x4e,0x20}, - {0x69,0x0}, - {0x4e,0x20}, - {0x74,0x10}, - {0x8d,0x4f}, - {0x8e,0x0}, - {0x8f,0x0}, - {0x90,0x0}, - {0x91,0x0}, - {0x92,0x66}, - {0x96,0x0}, - {0x9a,0x80}, - {0xb0,0x84}, - {0xb1,0xc}, - {0xb2,0xe}, - {0xb3,0x82}, - {0xb8,0x0a}, - {0x43,0x14}, - {0x44,0xf0}, - {0x45,0x41}, - {0x46,0x66}, - {0x47,0x2a}, - {0x48,0x3e}, - {0x59,0x8d}, - {0x5a,0x8e}, - {0x5b,0x53}, - {0x5c,0x83}, - {0x5d,0x4f}, - {0x5e,0xe}, - {0x6c,0x0a}, - {0x6d,0x55}, - {0x6e,0x11}, - {0x6f,0x9e}, - {0x62,0x90}, - {0x63,0x30}, - {0x64,0x11}, - {0x65,0x0}, - {0x66,0x5}, - {0x94,0x11}, - {0x95,0x18}, - {0x6a,0x40}, - {0x1,0x40}, - {0x2,0x40}, - {0x13,0xe7}, - {0x4f,0x80}, - {0x50,0x80}, - {0x51,0x0}, - {0x52,0x22}, - {0x53,0x5e}, - {0x54,0x80}, - {0x58,0x9e}, - {0x41,0x8}, - {0x3f,0x0}, - {0x75,0x3}, - {0x76,0xe1}, - {0x4c,0x0}, - {0x77,0x0}, - {0x3d,0xc2}, - {0x4b,0x9}, - {0xc9,0x60}, - {0x41,0x38}, - {0x56,0x3a}, - {0x34,0x11}, - {0x3b,0x0a}, - {0xa4,0x88}, - {0x96,0x0}, - {0x97,0x30}, - {0x98,0x20}, - {0x99,0x30}, - {0x9a,0x84}, - {0x9b,0x29}, - {0x9c,0x3}, - {0x9d,0x98}, - {0x9e,0x3f}, - {0x78,0x4}, - {0x79,0x1}, - {0xc8,0xf0}, - {0x79,0xf}, - {0xc8,0x0}, - {0x79,0x10}, - {0xc8,0x7e}, - {0x79,0x0a}, - {0xc8,0x80}, - {0x79,0xb}, - {0xc8,0x1}, - {0x79,0xc}, - {0xc8,0xf}, - {0x79,0xd}, - {0xc8,0x20}, - {0x79,0x9}, - {0xc8,0x80}, - {0x79,0x2}, - {0xc8,0xc0}, - {0x79,0x3}, - {0xc8,0x40}, - {0x79,0x5}, - {0xc8,0x30}, - {0x79,0x26}, - {0x2d,0x0}, - {0x2e,0x0}, - {0x11,0x40}, - {0x6b,0x0a}, - {0x2a,0x0}, - {0x2b,0x0}, - {0x2d,0x0}, - {0x2e,0x0}, - {0xca,0x0}, - {0x92,0x66}, - {0x93,0x0}, - {0x3b,0x0a}, - {0xcf,0x8c}, - {0x9d,0x98}, - {0x9e,0x7f}, - {0xa5,0x2}, - {0xab,0x3}, - {0x15,0x2}, - {0x12,0x14}, - {0x8c,0x0}, - {0x4,0x0}, - {0x40,0x10}, - {0x14,0x48}, - {0x4f,0xb3}, - {0x50,0xb3}, - {0x51,0x0}, - {0x52,0x3d}, - {0x53,0xa7}, - {0x54,0xe4}, - {0x3d,0xc0}, - {0x15,0x2}, - {0xff, 0xff}, -}; - + { + {0x11, 0x80}, + {0x3a, 0x4}, + {0x12, 0x0}, + {0x17, 0x13}, + {0x18, 0x1}, + {0x32, 0xb6}, + {0x19, 63}, + {0x1a, 0x7b}, + {0x03, 0x01}, + {0xc, 0x0}, + {0x3e, 0x0}, + {0x70, 0x3a}, + {0x71, 0x35}, + {0x72, 0x11}, + {0x73, 0xf0}, + {0xa2, 0x2}, + {0x15, 0x0}, + {0x7a, 0x18}, + {0x7b, 0x4}, + {0x7c, 0x9}, + {0x7d, 0x18}, + {0x7e, 0x38}, + {0x7f, 0x47}, + {0x80, 0x56}, + {0x81, 0x66}, + {0x82, 0x74}, + {0x83, 0x7f}, + {0x84, 0x89}, + {0x85, 0x9a}, + {0x86, 0xa9}, + {0x87, 0xc4}, + {0x88, 0xdb}, + {0x89, 0xee}, + {0x13, 0xe0}, + {0x1, 0x50}, + {0x2, 0x68}, + {0x0, 0x0}, + {0x10, 0x0}, + {0xd, 0x40}, + {0x14, 0x48}, + {0x15, 0x07}, + {0xab, 0x8}, + {0x24, 0x60}, + {0x25, 0x50}, + {0x26, 0xe3}, + {0x9f, 0x78}, + {0xa0, 0x68}, + {0xa1, 0x3}, + {0xa6, 0xd8}, + {0xa7, 0xd8}, + {0xa8, 0xf0}, + {0xa9, 0x90}, + {0xaa, 0x14}, + {0x13, 0xe5}, + {0xe, 0x61}, + {0xf, 0x4b}, + {0x16, 0x2}, + {0x1e, 0x27}, // 0x1e,0x17 + {0x21, 0x2}, + {0x22, 0x91}, + {0x29, 0x07}, + {0x33, 0xb}, + {0x35, 0xb}, + {0x37, 0x1d}, + {0x38, 0x71}, + {0x39, 0x2a}, + {0x3c, 0x78}, + {0x4d, 0x40}, + {0x4e, 0x20}, + {0x69, 0x0}, + {0x4e, 0x20}, + {0x74, 0x10}, + {0x8d, 0x4f}, + {0x8e, 0x0}, + {0x8f, 0x0}, + {0x90, 0x0}, + {0x91, 0x0}, + {0x92, 0x66}, + {0x96, 0x0}, + {0x9a, 0x80}, + {0xb0, 0x84}, + {0xb1, 0xc}, + {0xb2, 0xe}, + {0xb3, 0x82}, + {0xb8, 0x0a}, + {0x43, 0x14}, + {0x44, 0xf0}, + {0x45, 0x41}, + {0x46, 0x66}, + {0x47, 0x2a}, + {0x48, 0x3e}, + {0x59, 0x8d}, + {0x5a, 0x8e}, + {0x5b, 0x53}, + {0x5c, 0x83}, + {0x5d, 0x4f}, + {0x5e, 0xe}, + {0x6c, 0x0a}, + {0x6d, 0x55}, + {0x6e, 0x11}, + {0x6f, 0x9e}, + {0x62, 0x90}, + {0x63, 0x30}, + {0x64, 0x11}, + {0x65, 0x0}, + {0x66, 0x5}, + {0x94, 0x11}, + {0x95, 0x18}, + {0x6a, 0x40}, + {0x1, 0x40}, + {0x2, 0x40}, + {0x13, 0xe7}, + {0x4f, 0x80}, + {0x50, 0x80}, + {0x51, 0x0}, + {0x52, 0x22}, + {0x53, 0x5e}, + {0x54, 0x80}, + {0x58, 0x9e}, + {0x41, 0x8}, + {0x3f, 0x0}, + {0x75, 0x3}, + {0x76, 0xe1}, + {0x4c, 0x0}, + {0x77, 0x0}, + {0x3d, 0xc2}, + {0x4b, 0x9}, + {0xc9, 0x60}, + {0x41, 0x38}, + {0x56, 0x3a}, + {0x34, 0x11}, + {0x3b, 0x0a}, + {0xa4, 0x88}, + {0x96, 0x0}, + {0x97, 0x30}, + {0x98, 0x20}, + {0x99, 0x30}, + {0x9a, 0x84}, + {0x9b, 0x29}, + {0x9c, 0x3}, + {0x9d, 0x98}, + {0x9e, 0x3f}, + {0x78, 0x4}, + {0x79, 0x1}, + {0xc8, 0xf0}, + {0x79, 0xf}, + {0xc8, 0x0}, + {0x79, 0x10}, + {0xc8, 0x7e}, + {0x79, 0x0a}, + {0xc8, 0x80}, + {0x79, 0xb}, + {0xc8, 0x1}, + {0x79, 0xc}, + {0xc8, 0xf}, + {0x79, 0xd}, + {0xc8, 0x20}, + {0x79, 0x9}, + {0xc8, 0x80}, + {0x79, 0x2}, + {0xc8, 0xc0}, + {0x79, 0x3}, + {0xc8, 0x40}, + {0x79, 0x5}, + {0xc8, 0x30}, + {0x79, 0x26}, + {0x2d, 0x0}, + {0x2e, 0x0}, + {0x11, 0x40}, + {0x6b, 0x0a}, + {0x2a, 0x0}, + {0x2b, 0x0}, + {0x2d, 0x0}, + {0x2e, 0x0}, + {0xca, 0x0}, + {0x92, 0x66}, + {0x93, 0x0}, + {0x3b, 0x0a}, + {0xcf, 0x8c}, + {0x9d, 0x98}, + {0x9e, 0x7f}, + {0xa5, 0x2}, + {0xab, 0x3}, + {0x15, 0x2}, + {0x12, 0x14}, + {0x8c, 0x0}, + {0x4, 0x0}, + {0x40, 0x10}, + {0x14, 0x48}, + {0x4f, 0xb3}, + {0x50, 0xb3}, + {0x51, 0x0}, + {0x52, 0x3d}, + {0x53, 0xa7}, + {0x54, 0xe4}, + {0x3d, 0xc0}, + {0x15, 0x2}, + {0xff, 0xff}, +}; #endif - diff --git a/ArduCAM/ov7725_regs.h b/ArduCAM/ov7725_regs.h index 21484e3b..f56a2278 100644 --- a/ArduCAM/ov7725_regs.h +++ b/ArduCAM/ov7725_regs.h @@ -1,96 +1,92 @@ #ifndef OV7725_REGS_H #define OV7725_REGS_H #include "ArduCAM.h" -//#include +// #include const struct sensor_reg OV7725_QVGA[] PROGMEM = -{ - {0x32,0x00}, - {0x2a,0x00}, - {0x11,0x02}, - {0x12,0x46},//QVGA RGB565 - {0x12,0x06}, + { + {0x32, 0x00}, + {0x2a, 0x00}, + {0x11, 0x02}, + {0x12, 0x46}, // QVGA RGB565 + {0x12, 0x06}, - - {0x42,0x7f}, - {0x4d,0x00},//0x09 - {0x63,0xf0}, - {0x64,0xff}, - {0x65,0x20}, - {0x66,0x00}, - {0x67,0x00}, - {0x69,0x5d}, - - - {0x13,0xff}, - {0x0d,0x81},//PLL - {0x0f,0xc5}, - {0x14,0x11}, - {0x22,0xFF},//7f - {0x23,0x01}, - {0x24,0x34}, - {0x25,0x3c}, - {0x26,0xa1}, - {0x2b,0x00}, - {0x6b,0xaa}, - {0x13,0xff}, + {0x42, 0x7f}, + {0x4d, 0x00}, // 0x09 + {0x63, 0xf0}, + {0x64, 0xff}, + {0x65, 0x20}, + {0x66, 0x00}, + {0x67, 0x00}, + {0x69, 0x5d}, - {0x90,0x0a},// - {0x91,0x01},// - {0x92,0x01},// - {0x93,0x01}, - - {0x94,0x5f}, - {0x95,0x53}, - {0x96,0x11}, - {0x97,0x1a}, - {0x98,0x3d}, - {0x99,0x5a}, - {0x9a,0x1e}, - - {0x9b,0x00},//set luma - {0x9c,0x25},//set contrast - {0xa7,0x65},//set saturation - {0xa8,0x65},//set saturation - {0xa9,0x80},//set hue - {0xaa,0x80},//set hue - - {0x9e,0x81}, - {0xa6,0x06}, + {0x13, 0xff}, + {0x0d, 0x81}, // PLL + {0x0f, 0xc5}, + {0x14, 0x11}, + {0x22, 0xFF}, // 7f + {0x23, 0x01}, + {0x24, 0x34}, + {0x25, 0x3c}, + {0x26, 0xa1}, + {0x2b, 0x00}, + {0x6b, 0xaa}, + {0x13, 0xff}, - {0x7e,0x0c}, - {0x7f,0x16}, - {0x80,0x2a}, - {0x81,0x4e}, - {0x82,0x61}, - {0x83,0x6f}, - {0x84,0x7b}, - {0x85,0x86}, - {0x86,0x8e}, - {0x87,0x97}, - {0x88,0xa4}, - {0x89,0xaf}, - {0x8a,0xc5}, - {0x8b,0xd7}, - {0x8c,0xe8}, - {0x8d,0x20}, + {0x90, 0x0a}, // + {0x91, 0x01}, // + {0x92, 0x01}, // + {0x93, 0x01}, - {0x33,0x00}, - {0x22,0x99}, - {0x23,0x03}, - {0x4a,0x00}, - {0x49,0x13}, - {0x47,0x08}, - {0x4b,0x14}, - {0x4c,0x17}, - {0x46,0x05}, - {0x0e,0x75}, - {0x0c,0x90}, - {0x00,0xf0}, - {0x29,0x50}, - {0x2C,0x78}, - {0xff, 0xff}, -}; + {0x94, 0x5f}, + {0x95, 0x53}, + {0x96, 0x11}, + {0x97, 0x1a}, + {0x98, 0x3d}, + {0x99, 0x5a}, + {0x9a, 0x1e}, + {0x9b, 0x00}, // set luma + {0x9c, 0x25}, // set contrast + {0xa7, 0x65}, // set saturation + {0xa8, 0x65}, // set saturation + {0xa9, 0x80}, // set hue + {0xaa, 0x80}, // set hue -#endif + {0x9e, 0x81}, + {0xa6, 0x06}, + + {0x7e, 0x0c}, + {0x7f, 0x16}, + {0x80, 0x2a}, + {0x81, 0x4e}, + {0x82, 0x61}, + {0x83, 0x6f}, + {0x84, 0x7b}, + {0x85, 0x86}, + {0x86, 0x8e}, + {0x87, 0x97}, + {0x88, 0xa4}, + {0x89, 0xaf}, + {0x8a, 0xc5}, + {0x8b, 0xd7}, + {0x8c, 0xe8}, + {0x8d, 0x20}, + {0x33, 0x00}, + {0x22, 0x99}, + {0x23, 0x03}, + {0x4a, 0x00}, + {0x49, 0x13}, + {0x47, 0x08}, + {0x4b, 0x14}, + {0x4c, 0x17}, + {0x46, 0x05}, + {0x0e, 0x75}, + {0x0c, 0x90}, + {0x00, 0xf0}, + {0x29, 0x50}, + {0x2C, 0x78}, + {0xff, 0xff}, +}; + +#endif diff --git a/ArduCAM_Touch/ArduCAM_Touch.cpp b/ArduCAM_Touch/ArduCAM_Touch.cpp index abbe50d3..0131ef89 100644 --- a/ArduCAM_Touch/ArduCAM_Touch.cpp +++ b/ArduCAM_Touch/ArduCAM_Touch.cpp @@ -1,12 +1,12 @@ /* ArduCAM_Touch.cpp - Arduino library support for ArduCAM Touch function Copyright (C)2010 www.ArduCAM.com. All right reserved - + Basic functionality of this library are based on the demo-code provided by ArduCAM. You can find the latest version of the library at http://www.ArduCAM.com - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -25,10 +25,10 @@ */ -#define PixSizeX 13.78 -#define PixOffsX 411 -#define PixSizeY 11.01 -#define PixOffsY 378 +#define PixSizeX 13.78 +#define PixOffsX 411 +#define PixSizeY 11.01 +#define PixOffsY 378 #include "Arduino.h" #include "ArduCAM_Touch.h" @@ -41,21 +41,19 @@ extern uint8_t SmallFont[]; extern uint8_t BigFont[]; UTFT TP_TFT(LCD_CS); - - -ArduCAM_Touch::ArduCAM_Touch(byte tcs,byte irq) +ArduCAM_Touch::ArduCAM_Touch(byte tcs, byte irq) { - T_IRQ = irq; - T_CS = tcs; - SPI.begin(); + T_IRQ = irq; + T_CS = tcs; + SPI.begin(); } void ArduCAM_Touch::InitTouch(byte orientation) { orient = orientation; - pinMode(T_CS, OUTPUT); - pinMode(T_IRQ, INPUT); - digitalWrite(T_CS, HIGH); + pinMode(T_CS, OUTPUT); + pinMode(T_IRQ, INPUT); + digitalWrite(T_CS, HIGH); } void ArduCAM_Touch::touch_WriteData(byte data) @@ -71,38 +69,36 @@ word ArduCAM_Touch::touch_ReadData() data = data << 8; data |= SPI.transfer(nop); data = data >> 4; - return(data); + return (data); } void ArduCAM_Touch::read() { - unsigned long tx=0; - unsigned long ty=0; + unsigned long tx = 0; + unsigned long ty = 0; - digitalWrite(T_CS,LOW); + digitalWrite(T_CS, LOW); - for (int i=0; i=0) + if (PixSizeX >= 0) { - value = 240-((TP_X-PixOffsX)/PixSizeX); + value = 240 - ((TP_X - PixOffsX) / PixSizeX); } else { - value = (TP_X-PixOffsX)/-(PixSizeX); + value = (TP_X - PixOffsX) / -(PixSizeX); } } else { - if (PixSizeY<0) - value = 400-((TP_Y-PixOffsY)/-PixSizeY); + if (PixSizeY < 0) + value = 400 - ((TP_Y - PixOffsY) / -PixSizeY); else - value = ((TP_Y-PixOffsY)/PixSizeY); + value = ((TP_Y - PixOffsY) / PixSizeY); } if (value < 0) @@ -139,410 +135,411 @@ int ArduCAM_Touch::getY() if (orient == PORTRAIT) { - if (PixSizeY<0) - value = ((TP_Y-PixOffsY)/-PixSizeY); + if (PixSizeY < 0) + value = ((TP_Y - PixOffsY) / -PixSizeY); else - value = 320-((TP_Y-PixOffsY)/PixSizeY); + value = 320 - ((TP_Y - PixOffsY) / PixSizeY); } else { - if (PixSizeX>=0) + if (PixSizeX >= 0) { - value = 240-((TP_X-PixOffsX)/PixSizeX); + value = 240 - ((TP_X - PixOffsX) / PixSizeX); } else { - value = (TP_X-PixOffsX)/-(PixSizeX); + value = (TP_X - PixOffsX) / -(PixSizeX); } } if (value < 0) value = 0; - return value; + return value; } void ArduCAM_Touch::setPrecision(byte precision) { switch (precision) { - case PREC_LOW: - prec=1; - break; - case PREC_MEDIUM: - prec=10; - break; - case PREC_HI: - prec=25; - break; - case PREC_EXTREME: - prec=100; - break; - default: - prec=10; - break; + case PREC_LOW: + prec = 1; + break; + case PREC_MEDIUM: + prec = 10; + break; + case PREC_HI: + prec = 25; + break; + case PREC_EXTREME: + prec = 100; + break; + default: + prec = 10; + break; } } - - void ArduCAM_Touch::TP_Write_Byte(uint8_t num) { SPI.transfer(num); } - uint16_t ArduCAM_Touch::TP_Read_AD(uint8_t CMD) { - uint16_t Num = 0; - digitalWrite(T_CS,LOW); + uint16_t Num = 0; + digitalWrite(T_CS, LOW); TP_Write_Byte(CMD); delayMicroseconds(1); - Num=touch_ReadData(); - digitalWrite(T_CS,HIGH); - return(Num); -} + Num = touch_ReadData(); + digitalWrite(T_CS, HIGH); + return (Num); +} -#define READ_TIMES 10 -#define LOST_VAL 1 +#define READ_TIMES 10 +#define LOST_VAL 1 uint16_t ArduCAM_Touch::TP_Read_XOY(uint8_t xy) { uint16_t i, j; uint16_t buf[READ_TIMES]; - uint16_t sum=0; + uint16_t sum = 0; uint16_t temp; - for(i=0;ibuf[j]) + if (buf[i] > buf[j]) { - temp=buf[i]; - buf[i]=buf[j]; - buf[j]=temp; + temp = buf[i]; + buf[i] = buf[j]; + buf[j] = temp; } } - } - sum=0; - for(i=LOST_VAL;i(1+ERROR)) + else { - cnt=0; - TP_Drow_Touch_Point(width-20,height-20,VGA_BLACK); - TP_Drow_Touch_Point(20,20,VGA_YELLOW); - continue; + CMD_RDX = 0XD0; + CMD_RDY = 0X90; } - - xfac=-(float)(width-40)/(pos_temp[0][0]-pos_temp[1][0]);//xfac - - xoff=(width-xfac*(pos_temp[1][0]+pos_temp[0][0]))/2;//xoff - - yfac=-(float)(height-40)/(pos_temp[0][1]-pos_temp[2][1]);//yfac - - yoff=(height-yfac*(pos_temp[2][1]+pos_temp[0][1]))/2;//yoff - - TP_Save_Adjdata(); - EEPROM.write(16, 0x0a); - - if(myabs(xfac)>2||myabs(yfac)>2) - { - cnt=0; - TP_Drow_Touch_Point(width-20,height-20,VGA_BLACK); - TP_Drow_Touch_Point(20,20,VGA_YELLOW); - TP_TFT.print("TP Need readjust!", LEFT, 40); - touchtype=!touchtype; - if(touchtype) - { - CMD_RDX=0X90; - CMD_RDY=0XD0; - }else - { - CMD_RDX=0XD0; - CMD_RDY=0X90; - } - continue; - } - TP_TFT.setColor(VGA_BLACK); - TP_TFT.print("Please adjust!", 60, 120); - TP_TFT.setColor(VGA_YELLOW); - TP_TFT.print("Adjust OK!", 60, 120); - TP_TFT.clrScr(); - return; + continue; + } + TP_TFT.setColor(VGA_BLACK); + TP_TFT.print("Please adjust!", 60, 120); + TP_TFT.setColor(VGA_YELLOW); + TP_TFT.print("Adjust OK!", 60, 120); + TP_TFT.clrScr(); + return; } } delay(10); outtime++; - if(outtime>1000) + if (outtime > 1000) { - TP_Get_Adjdata(); - TP_TFT.setColor(VGA_BLACK); - TP_TFT.print("Please adjust!", 60, 120); - TP_TFT.setColor(VGA_YELLOW); - TP_TFT.print("Adjust OK!", 60, 120); - TP_TFT.clrScr(); - break; - } - } + TP_Get_Adjdata(); + TP_TFT.setColor(VGA_BLACK); + TP_TFT.print("Please adjust!", 60, 120); + TP_TFT.setColor(VGA_YELLOW); + TP_TFT.print("Adjust OK!", 60, 120); + TP_TFT.clrScr(); + break; + } + } } -void ArduCAM_Touch::TP_Save_Adjdata(void){ +void ArduCAM_Touch::TP_Save_Adjdata(void) +{ uint8_t i = 0; col_xfac.val = xfac; - for(i=0;i<4;i++) - EEPROM.write(i, col_xfac.buf[i]); + for (i = 0; i < 4; i++) + EEPROM.write(i, col_xfac.buf[i]); col_yfac.val = yfac; - for(i=0;i<4;i++) - EEPROM.write(i+4, col_yfac.buf[i]); + for (i = 0; i < 4; i++) + EEPROM.write(i + 4, col_yfac.buf[i]); col_xoff.val = xoff; - for(i=0;i<4;i++) - EEPROM.write(i+8, col_xoff.buf[i]); - col_yoff.val = yoff; - for(i=0;i<4;i++) - EEPROM.write(i+12, col_yoff.buf[i]); + for (i = 0; i < 4; i++) + EEPROM.write(i + 8, col_xoff.buf[i]); + col_yoff.val = yoff; + for (i = 0; i < 4; i++) + EEPROM.write(i + 12, col_yoff.buf[i]); } uint8_t ArduCAM_Touch::TP_Get_Adjdata(void) { uint8_t i = 0; - for(i=0;i<4;i++) - col_xfac.buf[i] = EEPROM.read(i); - xfac = col_xfac.val; - for(i=0;i<4;i++) - col_yfac.buf[i] = EEPROM.read(i+4); - yfac = col_yfac.val; - for(i=0;i<4;i++) - col_xoff.buf[i] = EEPROM.read(i+8); - xoff = col_xoff.val; - for(i=0;i<4;i++) - col_yoff.buf[i] = EEPROM.read(i+12); - yoff = col_yoff.val; + for (i = 0; i < 4; i++) + col_xfac.buf[i] = EEPROM.read(i); + xfac = col_xfac.val; + for (i = 0; i < 4; i++) + col_yfac.buf[i] = EEPROM.read(i + 4); + yfac = col_yfac.val; + for (i = 0; i < 4; i++) + col_xoff.buf[i] = EEPROM.read(i + 8); + xoff = col_xoff.val; + for (i = 0; i < 4; i++) + col_yoff.buf[i] = EEPROM.read(i + 12); + yoff = col_yoff.val; return 1; } - - diff --git a/ArduCAM_Touch/ArduCAM_Touch.h b/ArduCAM_Touch/ArduCAM_Touch.h index 653494ae..9fed5fc0 100644 --- a/ArduCAM_Touch/ArduCAM_Touch.h +++ b/ArduCAM_Touch/ArduCAM_Touch.h @@ -1,12 +1,12 @@ /* ArduCAM_Touch.h - Arduino library support for ArduCAM Touch function Copyright (C)2010 www.ArduCAM.com. All right reserved - + Basic functionality of this library are based on the demo-code provided by ArduCAM. You can find the latest version of the library at http://www.ArduCAM.com - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either @@ -28,90 +28,85 @@ #ifndef ArduCAM_Touch_h #define ArduCAM_Touch_h #include "Arduino.h" -#define PORTRAIT 1 -#define LANDSCAPE 0 -#define PREC_LOW 1 -#define PREC_MEDIUM 2 -#define PREC_HI 3 -#define PREC_EXTREME 4 - +#define PORTRAIT 1 +#define LANDSCAPE 0 +#define PREC_LOW 1 +#define PREC_MEDIUM 2 +#define PREC_HI 3 +#define PREC_EXTREME 4 - -#define TP_PRES_DOWN 0x80 -#define TP_CATH_PRES 0x40 -#define CT_MAX_TOUCH 5 +#define TP_PRES_DOWN 0x80 +#define TP_CATH_PRES 0x40 +#define CT_MAX_TOUCH 5 #define ERROR 0.05 #define BOXSIZE 40 union data - { - float val; - byte buf[4]; - }; +{ + float val; + byte buf[4]; +}; class ArduCAM_Touch { - public: - word TP_X ,TP_Y; - - ArduCAM_Touch( byte tcs, byte irq); - - void InitTouch(byte orientation = PORTRAIT); - void read(); - bool dataAvailable(); - int getX(); - int getY(); - void setPrecision(byte precision); - - data col_xfac; - data col_yfac; - data col_xoff; - data col_yoff; - - - - - uint8_t CMD_RDX=0X90; - uint8_t CMD_RDY=0XD0; - - uint16_t width = 320; - uint16_t height = 240; - uint16_t x[CT_MAX_TOUCH]; - uint16_t y[CT_MAX_TOUCH]; - uint8_t sta; - float xfac; - float yfac; - short xoff; - short yoff; - uint8_t touchtype =0; - - void TP_Write_Byte(uint8_t num); - uint16_t TP_Read_AD(uint8_t CMD); - uint16_t TP_Read_XOY(uint8_t xy); - uint8_t TP_Read_XY(uint16_t *x,uint16_t *y); - uint8_t TP_Read_XY2(uint16_t *x,uint16_t *y); - void TP_Drow_Touch_Point(uint16_t x,uint16_t y,uint16_t color); - void TP_Draw_Big_Point(uint16_t x,uint16_t y); - void Load_Drow_Dialog(void); - void TP_fillRect(int x1, int y1, int x2, int y2, int color); - void TP_clrSrc(void); - void Drow_menu(void); - void TP_Save_Adjdata(void); - uint8_t TP_Get_Adjdata(void); - int myabs(int x); - void TP_Adjust(void); - void TP_Adj_Info_Show(uint16_t x0,uint16_t y0,uint16_t x1,uint16_t y1,uint16_t x2,uint16_t y2,uint16_t x3,uint16_t y3,uint16_t fac);//ÃÔʾã׼ÃÅâ - uint8_t TP_Scan(uint8_t tp); - uint8_t TP_Init(void); - - private: - byte T_CS, T_IRQ; - byte orient; - byte prec; - - void touch_WriteData(byte data); - word touch_ReadData(); +public: + word TP_X, TP_Y; + + ArduCAM_Touch(byte tcs, byte irq); + + void InitTouch(byte orientation = PORTRAIT); + void read(); + bool dataAvailable(); + int getX(); + int getY(); + void setPrecision(byte precision); + + data col_xfac; + data col_yfac; + data col_xoff; + data col_yoff; + + uint8_t CMD_RDX = 0X90; + uint8_t CMD_RDY = 0XD0; + + uint16_t width = 320; + uint16_t height = 240; + uint16_t x[CT_MAX_TOUCH]; + uint16_t y[CT_MAX_TOUCH]; + uint8_t sta; + float xfac; + float yfac; + short xoff; + short yoff; + uint8_t touchtype = 0; + + void TP_Write_Byte(uint8_t num); + uint16_t TP_Read_AD(uint8_t CMD); + uint16_t TP_Read_XOY(uint8_t xy); + uint8_t TP_Read_XY(uint16_t *x, uint16_t *y); + uint8_t TP_Read_XY2(uint16_t *x, uint16_t *y); + void TP_Drow_Touch_Point(uint16_t x, uint16_t y, uint16_t color); + void TP_Draw_Big_Point(uint16_t x, uint16_t y); + void Load_Drow_Dialog(void); + void TP_fillRect(int x1, int y1, int x2, int y2, int color); + void TP_clrSrc(void); + void Drow_menu(void); + void TP_Save_Adjdata(void); + uint8_t TP_Get_Adjdata(void); + int myabs(int x); + void TP_Adjust(void); + void TP_Adj_Info_Show(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t x3, uint16_t y3, uint16_t fac); // ÃÔʾã׼ÃÅâ + uint8_t TP_Scan(uint8_t tp); + uint8_t TP_Init(void); + +private: + byte T_CS, T_IRQ; + byte orient; + byte prec; + + void touch_WriteData(byte data); + word touch_ReadData(); }; #endif \ No newline at end of file diff --git a/ArduCAM_Touch/examples/Touch_test/Touch_test.ino b/ArduCAM_Touch/examples/Touch_test/Touch_test.ino index 2139fa98..4cc6468d 100644 --- a/ArduCAM_Touch/examples/Touch_test/Touch_test.ino +++ b/ArduCAM_Touch/examples/Touch_test/Touch_test.ino @@ -13,39 +13,43 @@ // Declare which fonts we will be using extern uint8_t SmallFont[]; // Declare the TFT CS -const int SPI_CS =10; +const int SPI_CS = 10; UTFT myGLCD(SPI_CS); -//Initialize the touch CS INT -ArduCAM_Touch myTouch(8, 2); +// Initialize the touch CS INT +ArduCAM_Touch myTouch(8, 2); void rtp_test(void) -{ - while(1) +{ + while (1) { - myTouch.sta = myTouch.TP_Scan(0); - if(myTouch.sta&TP_PRES_DOWN) - { - if(myTouch.x[0](myTouch.width-30)&&myTouch.y[0]<20) { - myGLCD.clrScr(); myTouch.Load_Drow_Dialog(); - } - else myTouch.TP_Draw_Big_Point(myTouch.x[0],myTouch.y[0],VGA_YELLOW); + myTouch.sta = myTouch.TP_Scan(0); + if (myTouch.sta & TP_PRES_DOWN) + { + if (myTouch.x[0] < myTouch.width && myTouch.y[0] < myTouch.height) + { + if (myTouch.x[0] > (myTouch.width - 30) && myTouch.y[0] < 20) + { + myGLCD.clrScr(); + myTouch.Load_Drow_Dialog(); + } + else + myTouch.TP_Draw_Big_Point(myTouch.x[0], myTouch.y[0], VGA_YELLOW); } - }else delay(20); - + } + else + delay(20); } } void setup() { Serial.begin(115200); - // set the SPI_CS as an output: + // set the SPI_CS as an output: pinMode(SPI_CS, OUTPUT); // initialize SPI: - SPI.begin(); + SPI.begin(); myGLCD.InitLCD(); myGLCD.setFont(SmallFont); myTouch.InitTouch(); - myTouch.setPrecision(PREC_MEDIUM); + myTouch.setPrecision(PREC_MEDIUM); myTouch.TP_Adjust(); myTouch.Load_Drow_Dialog(); } diff --git a/ArduCAM_Touch/examples/touchpaint/touchpaint.ino b/ArduCAM_Touch/examples/touchpaint/touchpaint.ino index 1b4e7d43..c4cdc1f2 100644 --- a/ArduCAM_Touch/examples/touchpaint/touchpaint.ino +++ b/ArduCAM_Touch/examples/touchpaint/touchpaint.ino @@ -16,53 +16,63 @@ // Declare which fonts we will be using extern uint8_t SmallFont[]; // Declare the TFT CS -const int SPI_CS =10; +const int SPI_CS = 10; UTFT myGLCD(SPI_CS); -//Initialize the touch CS INT -ArduCAM_Touch myTouch(8, 2); -ArduCAM myCAM(OV5642, SPI_CS); +// Initialize the touch CS INT +ArduCAM_Touch myTouch(8, 2); +ArduCAM myCAM(OV5642, SPI_CS); uint32_t previous_time; -long pre_color =0; +long pre_color = 0; void rtp_test(void) -{ - while(1) +{ + while (1) { - myTouch.sta = myTouch.TP_Scan(0); - if(myTouch.sta&TP_PRES_DOWN) - { - if(myTouch.x[0]>275&&(myTouch.y[0]>=0&&myTouch.y[0]<=BOXSIZE)) - { - myTouch.TP_fillRect(280, BOXSIZE*0, 320, BOXSIZE*1, VGA_RED); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE&&myTouch.y[0]<=BOXSIZE*2)){ - myTouch.TP_fillRect(280, BOXSIZE*1, 320, BOXSIZE*2, VGA_YELLOW); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*2&&myTouch.y[0]<=BOXSIZE*3)){ - myTouch.TP_fillRect(280, BOXSIZE*2, 320, BOXSIZE*3, VGA_GREEN); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*3&&myTouch.y[0]<=BOXSIZE*4)){ - myTouch.TP_fillRect(280, BOXSIZE*3, 320, BOXSIZE*4, VGA_MAROON); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*4&&myTouch.y[0]<=BOXSIZE*5)){ - myTouch.TP_fillRect(280, BOXSIZE*4, 320, BOXSIZE*5, VGA_BLUE); - }else if(myTouch.x[0]>275&&(myTouch.y[0]>=BOXSIZE*5&&myTouch.y[0]<=BOXSIZE*6)){ - pre_color = myGLCD.getColor(); - Serial.println(pre_color,HEX); - myGLCD.clrScr(); - myTouch.Drow_menu(); - myGLCD.setColor(pre_color); - } - else myTouch.TP_Draw_Big_Point(myTouch.x[0],myTouch.y[0]); - - } - if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + myTouch.sta = myTouch.TP_Scan(0); + if (myTouch.sta & TP_PRES_DOWN) + { + if (myTouch.x[0] > 275 && (myTouch.y[0] >= 0 && myTouch.y[0] <= BOXSIZE)) + { + myTouch.TP_fillRect(280, BOXSIZE * 0, 320, BOXSIZE * 1, VGA_RED); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE && myTouch.y[0] <= BOXSIZE * 2)) + { + myTouch.TP_fillRect(280, BOXSIZE * 1, 320, BOXSIZE * 2, VGA_YELLOW); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 2 && myTouch.y[0] <= BOXSIZE * 3)) + { + myTouch.TP_fillRect(280, BOXSIZE * 2, 320, BOXSIZE * 3, VGA_GREEN); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 3 && myTouch.y[0] <= BOXSIZE * 4)) + { + myTouch.TP_fillRect(280, BOXSIZE * 3, 320, BOXSIZE * 4, VGA_MAROON); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 4 && myTouch.y[0] <= BOXSIZE * 5)) + { + myTouch.TP_fillRect(280, BOXSIZE * 4, 320, BOXSIZE * 5, VGA_BLUE); + } + else if (myTouch.x[0] > 275 && (myTouch.y[0] >= BOXSIZE * 5 && myTouch.y[0] <= BOXSIZE * 6)) + { + pre_color = myGLCD.getColor(); + Serial.println(pre_color, HEX); + myGLCD.clrScr(); + myTouch.Drow_menu(); + myGLCD.setColor(pre_color); + } + else + myTouch.TP_Draw_Big_Point(myTouch.x[0], myTouch.y[0]); + } + if (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) { previous_time = millis(); - while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + while (myCAM.get_bit(ARDUCHIP_TRIG, SHUTTER_MASK)) + { + if ((millis() - previous_time) > 30) { - if ((millis() - previous_time) > 30) - { - myGLCD.clrScr(); - myTouch.TP_Adjust(); - myTouch.Drow_menu(); - } - } + myGLCD.clrScr(); + myTouch.TP_Adjust(); + myTouch.Drow_menu(); + } + } } } } @@ -70,23 +80,25 @@ void setup() { uint8_t temp = 0; Serial.begin(115200); - // set the SPI_CS as an output: + // set the SPI_CS as an output: pinMode(SPI_CS, OUTPUT); // initialize SPI: - SPI.begin(); + SPI.begin(); myGLCD.InitLCD(); myGLCD.setFont(SmallFont); - myTouch.InitTouch(); + myTouch.InitTouch(); temp = EEPROM.read(16); - if (temp!= 0x0A){ - myTouch.TP_Adjust(); - myTouch.Drow_menu(); - } - - else{ - myGLCD.clrScr(); - myTouch.TP_Get_Adjdata(); - myTouch.Drow_menu(); + if (temp != 0x0A) + { + myTouch.TP_Adjust(); + myTouch.Drow_menu(); + } + + else + { + myGLCD.clrScr(); + myTouch.TP_Get_Adjdata(); + myTouch.Drow_menu(); } } diff --git a/OV7670FIFO/OV7670FIFO.ino b/OV7670FIFO/OV7670FIFO.ino index de6996d6..ec20e56c 100644 --- a/OV7670FIFO/OV7670FIFO.ino +++ b/OV7670FIFO/OV7670FIFO.ino @@ -4,23 +4,23 @@ #include #include -const int chipSelect = 53; -const int HardwareSSPin = 53; // For Arduino Mega +const int chipSelect = 53; +const int HardwareSSPin = 53; // For Arduino Mega int PhotoTakenCount = 0; -// Serial Input +// Serial Input const int BUFFERLENGTH = 255; -char IncomingByte[BUFFERLENGTH]; // for incoming serial data +char IncomingByte[BUFFERLENGTH]; // for incoming serial data -// VGA Default -int PHOTO_WIDTH = 640; -int PHOTO_HEIGHT = 480; +// VGA Default +int PHOTO_WIDTH = 640; +int PHOTO_HEIGHT = 480; int PHOTO_BYTES_PER_PIXEL = 2; // Command and Parameter related Strings String RawCommandLine = ""; -String Command = "QVGA"; +String Command = "QVGA"; String FPSParam = "ThirtyFPS"; String AWBParam = "SAWB"; String AECParam = "HistAEC"; @@ -29,7 +29,6 @@ String DenoiseParam = "DenoiseNo"; String EdgeParam = "EdgeNo"; String ABLCParam = "AblcON"; - enum ResolutionType { VGA, @@ -39,678 +38,642 @@ enum ResolutionType None }; -ResolutionType Resolution = None; +ResolutionType Resolution = None; // Camera input/output pin connection to Arduino -#define WRST 25 // Output Write Pointer Reset -#define RRST 23 // Output Read Pointer Reset -#define WEN 24 // Output Write Enable -#define VSYNC 22 // Input Vertical Sync marking frame capture -#define RCLK 26 // Output FIFO buffer output clock +#define WRST 25 // Output Write Pointer Reset +#define RRST 23 // Output Read Pointer Reset +#define WEN 24 // Output Write Enable +#define VSYNC 22 // Input Vertical Sync marking frame capture +#define RCLK 26 // Output FIFO buffer output clock // set OE to low gnd // FIFO Ram input pins -#define DO7 28 -#define DO6 29 -#define DO5 30 -#define DO4 31 -#define DO3 32 -#define DO2 33 -#define DO1 34 -#define DO0 35 - +#define DO7 28 +#define DO6 29 +#define DO5 30 +#define DO4 31 +#define DO3 32 +#define DO2 33 +#define DO1 34 +#define DO0 35 // SDCARD -// MISO, MOSI, and SCK are also available in a consistent physical location on the ICSP header; -// this is useful, for example, in designing a shield that works on the Uno and the Mega. -// On the Arduino Mega, this is -// 50 (MISO) -// 51 (MOSI) -// 52 (SCK) -// 53 (SS) - - +// MISO, MOSI, and SCK are also available in a consistent physical location on the ICSP header; +// this is useful, for example, in designing a shield that works on the Uno and the Mega. +// On the Arduino Mega, this is +// 50 (MISO) +// 51 (MOSI) +// 52 (SCK) +// 53 (SS) // Register addresses and values -#define CLKRC 0x11 -#define CLKRC_VALUE_VGA 0x01 // Raw Bayer -#define CLKRC_VALUE_QVGA 0x01 -#define CLKRC_VALUE_QQVGA 0x01 -#define CLKRC_VALUE_NIGHTMODE_FIXED 0x03 // Fixed Frame -#define CLKRC_VALUE_NIGHTMODE_AUTO 0x80 // Auto Frame Rate Adjust - -#define COM7 0x12 -#define COM7_VALUE_VGA 0x01 // Raw Bayer -#define COM7_VALUE_VGA_COLOR_BAR 0x03 // Raw Bayer -#define COM7_VALUE_VGA_PROCESSED_BAYER 0x05 // Processed Bayer -#define COM7_VALUE_QVGA 0x00 -#define COM7_VALUE_QVGA_COLOR_BAR 0x02 -#define COM7_VALUE_QVGA_PREDEFINED_COLOR_BAR 0x12 -#define COM7_VALUE_QQVGA 0x00 -#define COM7_VALUE_QQVGA_COLOR_BAR 0x02 -#define COM7_VALUE_QCIF 0x08 // Predefined QCIF format -#define COM7_VALUE_COLOR_BAR_QCIF 0x0A // Predefined QCIF Format with ColorBar -#define COM7_VALUE_RESET 0x80 - - -#define COM3 0x0C -#define COM3_VALUE_VGA 0x00 // Raw Bayer -#define COM3_VALUE_QVGA 0x04 -#define COM3_VALUE_QQVGA 0x04 // From Docs -#define COM3_VALUE_QQVGA_SCALE_ENABLED 0x0C // Enable Scale and DCW -#define COM3_VALUE_QCIF 0x0C // Enable Scaling and enable DCW - -#define COM14 0x3E -#define COM14_VALUE_VGA 0x00 // Raw Bayer -#define COM14_VALUE_QVGA 0x19 -#define COM14_VALUE_QQVGA 0x1A -#define COM14_VALUE_MANUAL_SCALING 0x08 // Manual Scaling Enabled -#define COM14_VALUE_NO_MANUAL_SCALING 0x00 // Manual Scaling DisEnabled - -#define SCALING_XSC 0x70 -#define SCALING_XSC_VALUE_VGA 0x3A // Raw Bayer -#define SCALING_XSC_VALUE_QVGA 0x3A -#define SCALING_XSC_VALUE_QQVGA 0x3A -#define SCALING_XSC_VALUE_QQVGA_SHIFT1 0x3A -#define SCALING_XSC_VALUE_COLOR_BAR 0xBA -#define SCALING_XSC_VALUE_QCIF_COLOR_BAR_NO_SCALE 0x80 // Predefined QCIF with Color Bar and NO Scaling - -#define SCALING_YSC 0x71 -#define SCALING_YSC_VALUE_VGA 0x35 // Raw Bayer -#define SCALING_YSC_VALUE_QVGA 0x35 -#define SCALING_YSC_VALUE_QQVGA 0x35 -#define SCALING_YSC_VALUE_COLOR_BAR 0x35 // 8 bar color bar -#define SCALING_YSC_VALUE_COLOR_BAR_GREY 0xB5 // fade to grey color bar -#define SCALING_YSC_VALUE_COLOR_BAR_SHIFT1 0xB5 // fade to grey color bar -#define SCALING_YSC_VALUE_QCIF_COLOR_BAR_NO_SCALE 0x00 // Predefined QCIF with Color Bar and NO Scaling - -#define SCALING_DCWCTR 0x72 -#define SCALING_DCWCTR_VALUE_VGA 0x11 // Raw Bayer -#define SCALING_DCWCTR_VALUE_QVGA 0x11 -#define SCALING_DCWCTR_VALUE_QQVGA 0x22 - -#define SCALING_PCLK_DIV 0x73 -#define SCALING_PCLK_DIV_VALUE_VGA 0xF0 // Raw Bayer -#define SCALING_PCLK_DIV_VALUE_QVGA 0xF1 -#define SCALING_PCLK_DIV_VALUE_QQVGA 0xF2 - -#define SCALING_PCLK_DELAY 0xA2 -#define SCALING_PCLK_DELAY_VALUE_VGA 0x02 // Raw Bayer -#define SCALING_PCLK_DELAY_VALUE_QVGA 0x02 -#define SCALING_PCLK_DELAY_VALUE_QQVGA 0x02 - +#define CLKRC 0x11 +#define CLKRC_VALUE_VGA 0x01 // Raw Bayer +#define CLKRC_VALUE_QVGA 0x01 +#define CLKRC_VALUE_QQVGA 0x01 +#define CLKRC_VALUE_NIGHTMODE_FIXED 0x03 // Fixed Frame +#define CLKRC_VALUE_NIGHTMODE_AUTO 0x80 // Auto Frame Rate Adjust + +#define COM7 0x12 +#define COM7_VALUE_VGA 0x01 // Raw Bayer +#define COM7_VALUE_VGA_COLOR_BAR 0x03 // Raw Bayer +#define COM7_VALUE_VGA_PROCESSED_BAYER 0x05 // Processed Bayer +#define COM7_VALUE_QVGA 0x00 +#define COM7_VALUE_QVGA_COLOR_BAR 0x02 +#define COM7_VALUE_QVGA_PREDEFINED_COLOR_BAR 0x12 +#define COM7_VALUE_QQVGA 0x00 +#define COM7_VALUE_QQVGA_COLOR_BAR 0x02 +#define COM7_VALUE_QCIF 0x08 // Predefined QCIF format +#define COM7_VALUE_COLOR_BAR_QCIF 0x0A // Predefined QCIF Format with ColorBar +#define COM7_VALUE_RESET 0x80 + +#define COM3 0x0C +#define COM3_VALUE_VGA 0x00 // Raw Bayer +#define COM3_VALUE_QVGA 0x04 +#define COM3_VALUE_QQVGA 0x04 // From Docs +#define COM3_VALUE_QQVGA_SCALE_ENABLED 0x0C // Enable Scale and DCW +#define COM3_VALUE_QCIF 0x0C // Enable Scaling and enable DCW + +#define COM14 0x3E +#define COM14_VALUE_VGA 0x00 // Raw Bayer +#define COM14_VALUE_QVGA 0x19 +#define COM14_VALUE_QQVGA 0x1A +#define COM14_VALUE_MANUAL_SCALING 0x08 // Manual Scaling Enabled +#define COM14_VALUE_NO_MANUAL_SCALING 0x00 // Manual Scaling DisEnabled + +#define SCALING_XSC 0x70 +#define SCALING_XSC_VALUE_VGA 0x3A // Raw Bayer +#define SCALING_XSC_VALUE_QVGA 0x3A +#define SCALING_XSC_VALUE_QQVGA 0x3A +#define SCALING_XSC_VALUE_QQVGA_SHIFT1 0x3A +#define SCALING_XSC_VALUE_COLOR_BAR 0xBA +#define SCALING_XSC_VALUE_QCIF_COLOR_BAR_NO_SCALE 0x80 // Predefined QCIF with Color Bar and NO Scaling + +#define SCALING_YSC 0x71 +#define SCALING_YSC_VALUE_VGA 0x35 // Raw Bayer +#define SCALING_YSC_VALUE_QVGA 0x35 +#define SCALING_YSC_VALUE_QQVGA 0x35 +#define SCALING_YSC_VALUE_COLOR_BAR 0x35 // 8 bar color bar +#define SCALING_YSC_VALUE_COLOR_BAR_GREY 0xB5 // fade to grey color bar +#define SCALING_YSC_VALUE_COLOR_BAR_SHIFT1 0xB5 // fade to grey color bar +#define SCALING_YSC_VALUE_QCIF_COLOR_BAR_NO_SCALE 0x00 // Predefined QCIF with Color Bar and NO Scaling + +#define SCALING_DCWCTR 0x72 +#define SCALING_DCWCTR_VALUE_VGA 0x11 // Raw Bayer +#define SCALING_DCWCTR_VALUE_QVGA 0x11 +#define SCALING_DCWCTR_VALUE_QQVGA 0x22 + +#define SCALING_PCLK_DIV 0x73 +#define SCALING_PCLK_DIV_VALUE_VGA 0xF0 // Raw Bayer +#define SCALING_PCLK_DIV_VALUE_QVGA 0xF1 +#define SCALING_PCLK_DIV_VALUE_QQVGA 0xF2 + +#define SCALING_PCLK_DELAY 0xA2 +#define SCALING_PCLK_DELAY_VALUE_VGA 0x02 // Raw Bayer +#define SCALING_PCLK_DELAY_VALUE_QVGA 0x02 +#define SCALING_PCLK_DELAY_VALUE_QQVGA 0x02 // Controls YUV order Used with COM13 // Need YUYV format for Android Decoding- Default value is 0xD -#define TSLB 0x3A -#define TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_ENABLED 0x01 // No custom scaling -#define TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_DISABLED 0x00 // For adjusting HSTART, etc. YUYV format -#define TSLB_VALUE_UYVY_AUTO_OUTPUT_WINDOW_DISABLED 0x08 -#define TSLB_VALUE_TESTVALUE 0x04 // From YCbCr Reference - +#define TSLB 0x3A +#define TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_ENABLED 0x01 // No custom scaling +#define TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_DISABLED 0x00 // For adjusting HSTART, etc. YUYV format +#define TSLB_VALUE_UYVY_AUTO_OUTPUT_WINDOW_DISABLED 0x08 +#define TSLB_VALUE_TESTVALUE 0x04 // From YCbCr Reference // Default value is 0x88 // ok if you want YUYV order, no need to change -#define COM13 0x3D -#define COM13_VALUE_DEFAULT 0x88 -#define COM13_VALUE_NOGAMMA_YUYV 0x00 -#define COM13_VALUE_GAMMA_YUYV 0x80 -#define COM13_VALUE_GAMMA_YVYU 0x82 +#define COM13 0x3D +#define COM13_VALUE_DEFAULT 0x88 +#define COM13_VALUE_NOGAMMA_YUYV 0x00 +#define COM13_VALUE_GAMMA_YUYV 0x80 +#define COM13_VALUE_GAMMA_YVYU 0x82 #define COM13_VALUE_YUYV_UVSATAUTOADJ_ON 0x40 - - // Works with COM4 -#define COM17 0x42 -#define COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR 0x00 -#define COM17_VALUE_AEC_NORMAL_COLOR_BAR 0x08 // Activate Color Bar for DSP +#define COM17 0x42 +#define COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR 0x00 +#define COM17_VALUE_AEC_NORMAL_COLOR_BAR 0x08 // Activate Color Bar for DSP -#define COM4 0x0D +#define COM4 0x0D // RGB Settings and Data format -#define COM15 0x40 - +#define COM15 0x40 // Night Mode -#define COM11 0x3B -#define COM11_VALUE_NIGHTMODE_ON 0x80 // Night Mode -#define COM11_VALUE_NIGHTMODE_OFF 0x00 -#define COM11_VALUE_NIGHTMODE_ON_EIGHTH 0xE0 // Night Mode 1/8 frame rate minimum -#define COM11_VALUE_NIGHTMODE_FIXED 0x0A -#define COM11_VALUE_NIGHTMODE_AUTO 0xEA // Night Mode Auto Frame Rate Adjust - +#define COM11 0x3B +#define COM11_VALUE_NIGHTMODE_ON 0x80 // Night Mode +#define COM11_VALUE_NIGHTMODE_OFF 0x00 +#define COM11_VALUE_NIGHTMODE_ON_EIGHTH 0xE0 // Night Mode 1/8 frame rate minimum +#define COM11_VALUE_NIGHTMODE_FIXED 0x0A +#define COM11_VALUE_NIGHTMODE_AUTO 0xEA // Night Mode Auto Frame Rate Adjust // Color Matrix Control YUV -#define MTX1 0x4f -#define MTX1_VALUE 0x80 - -#define MTX2 0x50 -#define MTX2_VALUE 0x80 - -#define MTX3 0x51 -#define MTX3_VALUE 0x00 +#define MTX1 0x4f +#define MTX1_VALUE 0x80 -#define MTX4 0x52 -#define MTX4_VALUE 0x22 +#define MTX2 0x50 +#define MTX2_VALUE 0x80 -#define MTX5 0x53 -#define MTX5_VALUE 0x5e +#define MTX3 0x51 +#define MTX3_VALUE 0x00 -#define MTX6 0x54 -#define MTX6_VALUE 0x80 +#define MTX4 0x52 +#define MTX4_VALUE 0x22 -#define CONTRAS 0x56 -#define CONTRAS_VALUE 0x40 +#define MTX5 0x53 +#define MTX5_VALUE 0x5e -#define MTXS 0x58 -#define MTXS_VALUE 0x9e +#define MTX6 0x54 +#define MTX6_VALUE 0x80 +#define CONTRAS 0x56 +#define CONTRAS_VALUE 0x40 +#define MTXS 0x58 +#define MTXS_VALUE 0x9e // COM8 -#define COM8 0x13 -#define COM8_VALUE_AWB_OFF 0xE5 -#define COM8_VALUE_AWB_ON 0xE7 - - - +#define COM8 0x13 +#define COM8_VALUE_AWB_OFF 0xE5 +#define COM8_VALUE_AWB_ON 0xE7 // Automatic White Balance -#define AWBC1 0x43 -#define AWBC1_VALUE 0x14 +#define AWBC1 0x43 +#define AWBC1_VALUE 0x14 -#define AWBC2 0x44 -#define AWBC2_VALUE 0xf0 +#define AWBC2 0x44 +#define AWBC2_VALUE 0xf0 -#define AWBC3 0x45 -#define AWBC3_VALUE 0x34 +#define AWBC3 0x45 +#define AWBC3_VALUE 0x34 -#define AWBC4 0x46 -#define AWBC4_VALUE 0x58 +#define AWBC4 0x46 +#define AWBC4_VALUE 0x58 -#define AWBC5 0x47 -#define AWBC5_VALUE 0x28 +#define AWBC5 0x47 +#define AWBC5_VALUE 0x28 -#define AWBC6 0x48 -#define AWBC6_VALUE 0x3a +#define AWBC6 0x48 +#define AWBC6_VALUE 0x3a -#define AWBC7 0x59 -#define AWBC7_VALUE 0x88 +#define AWBC7 0x59 +#define AWBC7_VALUE 0x88 -#define AWBC8 0x5A -#define AWBC8_VALUE 0x88 +#define AWBC8 0x5A +#define AWBC8_VALUE 0x88 -#define AWBC9 0x5B -#define AWBC9_VALUE 0x44 +#define AWBC9 0x5B +#define AWBC9_VALUE 0x44 -#define AWBC10 0x5C -#define AWBC10_VALUE 0x67 +#define AWBC10 0x5C +#define AWBC10_VALUE 0x67 -#define AWBC11 0x5D -#define AWBC11_VALUE 0x49 +#define AWBC11 0x5D +#define AWBC11_VALUE 0x49 -#define AWBC12 0x5E -#define AWBC12_VALUE 0x0E +#define AWBC12 0x5E +#define AWBC12_VALUE 0x0E -#define AWBCTR3 0x6C -#define AWBCTR3_VALUE 0x0A +#define AWBCTR3 0x6C +#define AWBCTR3_VALUE 0x0A -#define AWBCTR2 0x6D -#define AWBCTR2_VALUE 0x55 +#define AWBCTR2 0x6D +#define AWBCTR2_VALUE 0x55 -#define AWBCTR1 0x6E -#define AWBCTR1_VALUE 0x11 +#define AWBCTR1 0x6E +#define AWBCTR1_VALUE 0x11 -#define AWBCTR0 0x6F -#define AWBCTR0_VALUE_NORMAL 0x9F +#define AWBCTR0 0x6F +#define AWBCTR0_VALUE_NORMAL 0x9F #define AWBCTR0_VALUE_ADVANCED 0x9E - // Gain -#define COM9 0x14 -#define COM9_VALUE_MAX_GAIN_128X 0x6A -#define COM9_VALUE_4XGAIN 0x10 // 0001 0000 +#define COM9 0x14 +#define COM9_VALUE_MAX_GAIN_128X 0x6A +#define COM9_VALUE_4XGAIN 0x10 // 0001 0000 -#define BLUE 0x01 // AWB Blue Channel Gain -#define BLUE_VALUE 0x40 +#define BLUE 0x01 // AWB Blue Channel Gain +#define BLUE_VALUE 0x40 -#define RED 0x02 // AWB Red Channel Gain -#define RED_VALUE 0x40 +#define RED 0x02 // AWB Red Channel Gain +#define RED_VALUE 0x40 -#define GGAIN 0x6A // AWB Green Channel Gain -#define GGAIN_VALUE 0x40 +#define GGAIN 0x6A // AWB Green Channel Gain +#define GGAIN_VALUE 0x40 -#define COM16 0x41 -#define COM16_VALUE 0x08 // AWB Gain on +#define COM16 0x41 +#define COM16_VALUE 0x08 // AWB Gain on -#define GFIX 0x69 -#define GFIX_VALUE 0x00 +#define GFIX 0x69 +#define GFIX_VALUE 0x00 // Edge Enhancement Adjustment -#define EDGE 0x3f -#define EDGE_VALUE 0x00 +#define EDGE 0x3f +#define EDGE_VALUE 0x00 -#define REG75 0x75 -#define REG75_VALUE 0x03 +#define REG75 0x75 +#define REG75_VALUE 0x03 -#define REG76 0x76 -#define REG76_VALUE 0xe1 +#define REG76 0x76 +#define REG76_VALUE 0xe1 -// DeNoise -#define DNSTH 0x4c -#define DNSTH_VALUE 0x00 +// DeNoise +#define DNSTH 0x4c +#define DNSTH_VALUE 0x00 -#define REG77 0x77 -#define REG77_VALUE 0x00 +#define REG77 0x77 +#define REG77_VALUE 0x00 // Denoise and Edge Enhancement -#define COM16_VALUE_DENOISE_OFF_EDGE_ENHANCEMENT_OFF_AWBGAIN_ON 0x08 // Denoise off, AWB Gain on -#define COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_OFF__AWBGAIN_ON 0x18 -#define COM16_VALUE_DENOISE_OFF__EDGE_ENHANCEMENT_ON__AWBGAIN_ON 0x28 -#define COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_ON__AWBGAIN_ON 0x38 // Denoise on, Edge Enhancement on, AWB Gain on - +#define COM16_VALUE_DENOISE_OFF_EDGE_ENHANCEMENT_OFF_AWBGAIN_ON 0x08 // Denoise off, AWB Gain on +#define COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_OFF__AWBGAIN_ON 0x18 +#define COM16_VALUE_DENOISE_OFF__EDGE_ENHANCEMENT_ON__AWBGAIN_ON 0x28 +#define COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_ON__AWBGAIN_ON 0x38 // Denoise on, Edge Enhancement on, AWB Gain on // 30FPS Frame Rate , PCLK = 24Mhz -#define CLKRC_VALUE_30FPS 0x80 - -#define DBLV 0x6b -#define DBLV_VALUE_30FPS 0x0A +#define CLKRC_VALUE_30FPS 0x80 -#define EXHCH 0x2A -#define EXHCH_VALUE_30FPS 0x00 +#define DBLV 0x6b +#define DBLV_VALUE_30FPS 0x0A -#define EXHCL 0x2B -#define EXHCL_VALUE_30FPS 0x00 +#define EXHCH 0x2A +#define EXHCH_VALUE_30FPS 0x00 -#define DM_LNL 0x92 -#define DM_LNL_VALUE_30FPS 0x00 +#define EXHCL 0x2B +#define EXHCL_VALUE_30FPS 0x00 -#define DM_LNH 0x93 -#define DM_LNH_VALUE_30FPS 0x00 +#define DM_LNL 0x92 +#define DM_LNL_VALUE_30FPS 0x00 -#define COM11_VALUE_30FPS 0x0A +#define DM_LNH 0x93 +#define DM_LNH_VALUE_30FPS 0x00 +#define COM11_VALUE_30FPS 0x0A // Saturation Control -#define SATCTR 0xc9 -#define SATCTR_VALUE 0x60 - +#define SATCTR 0xc9 +#define SATCTR_VALUE 0x60 // AEC/AGC - Automatic Exposure/Gain Control -#define GAIN 0x00 -#define GAIN_VALUE 0x00 - -#define AEW 0x24 -#define AEW_VALUE 0x95 +#define GAIN 0x00 +#define GAIN_VALUE 0x00 -#define AEB 0x25 -#define AEB_VALUE 0x33 +#define AEW 0x24 +#define AEW_VALUE 0x95 -#define VPT 0x26 -#define VPT_VALUE 0xe3 +#define AEB 0x25 +#define AEB_VALUE 0x33 +#define VPT 0x26 +#define VPT_VALUE 0xe3 /* // Gamma -#define SLOP 0x7a +#define SLOP 0x7a #define SLOP_VALUE 0x20 -#define GAM1 0x7b +#define GAM1 0x7b #define GAM1_VALUE 0x10 -#define GAM2 0x7c +#define GAM2 0x7c #define GAM2_VALUE 0x1e -#define GAM3 0x7d +#define GAM3 0x7d #define GAM3_VALUE 0x35 -#define GAM4 0x7e +#define GAM4 0x7e #define GAM4_VALUE 0x5a -#define GAM5 0x7f +#define GAM5 0x7f #define GAM5_VALUE 0x69 -#define GAM6 0x80 +#define GAM6 0x80 #define GAM6_VALUE 0x76 -#define GAM7 0x81 +#define GAM7 0x81 #define GAM7_VALUE 0x80 -#define GAM8 0x82 +#define GAM8 0x82 #define GAM8_VALUE 0x88 -#define GAM9 0x83 +#define GAM9 0x83 #define GAM9_VALUE 0x8f -#define GAM10 0x84 +#define GAM10 0x84 #define GAM10_VALUE 0x96 -#define GAM11 0x85 +#define GAM11 0x85 #define GAM11_VALUE 0xa3 -#define GAM12 0x86 +#define GAM12 0x86 #define GAM12_VALUE 0xaf -#define GAM13 0x87 +#define GAM13 0x87 #define GAM13_VALUE 0xc4 -#define GAM14 0x88 +#define GAM14 0x88 #define GAM14_VALUE 0xd7 -#define GAM15 0x89 +#define GAM15 0x89 #define GAM15_VALUE 0xe8 */ - - // AEC/AGC Control- Histogram -#define HAECC1 0x9f -#define HAECC1_VALUE 0x78 - -#define HAECC2 0xa0 -#define HAECC2_VALUE 0x68 - -#define HAECC3 0xa6 -#define HAECC3_VALUE 0xd8 +#define HAECC1 0x9f +#define HAECC1_VALUE 0x78 -#define HAECC4 0xa7 -#define HAECC4_VALUE 0xd8 +#define HAECC2 0xa0 +#define HAECC2_VALUE 0x68 -#define HAECC5 0xa8 -#define HAECC5_VALUE 0xf0 +#define HAECC3 0xa6 +#define HAECC3_VALUE 0xd8 -#define HAECC6 0xa9 -#define HAECC6_VALUE 0x90 +#define HAECC4 0xa7 +#define HAECC4_VALUE 0xd8 -#define HAECC7 0xaa // AEC Algorithm selection -#define HAECC7_VALUE_HISTOGRAM_AEC_ON 0x94 -#define HAECC7_VALUE_AVERAGE_AEC_ON 0x00 +#define HAECC5 0xa8 +#define HAECC5_VALUE 0xf0 +#define HAECC6 0xa9 +#define HAECC6_VALUE 0x90 +#define HAECC7 0xaa // AEC Algorithm selection +#define HAECC7_VALUE_HISTOGRAM_AEC_ON 0x94 +#define HAECC7_VALUE_AVERAGE_AEC_ON 0x00 /* // Gamma -#define SLOP 0x7a +#define SLOP 0x7a #define SLOP_VALUE 0x20 -#define GAM1 0x7b +#define GAM1 0x7b #define GAM1_VALUE 0x10 -#define GAM2 0x7c +#define GAM2 0x7c #define GAM2_VALUE 0x1e -#define GAM3 0x7d +#define GAM3 0x7d #define GAM3_VALUE 0x35 -#define GAM4 0x7e +#define GAM4 0x7e #define GAM4_VALUE 0x5a -#define GAM5 0x7f +#define GAM5 0x7f #define GAM5_VALUE 0x69 -#define GAM6 0x80 +#define GAM6 0x80 #define GAM6_VALUE 0x76 -#define GAM7 0x81 +#define GAM7 0x81 #define GAM7_VALUE 0x80 -#define GAM8 0x82 +#define GAM8 0x82 #define GAM8_VALUE 0x88 -#define GAM9 0x83 +#define GAM9 0x83 #define GAM9_VALUE 0x8f -#define GAM10 0x84 +#define GAM10 0x84 #define GAM10_VALUE 0x96 -#define GAM11 0x85 +#define GAM11 0x85 #define GAM11_VALUE 0xa3 -#define GAM12 0x86 +#define GAM12 0x86 #define GAM12_VALUE 0xaf -#define GAM13 0x87 +#define GAM13 0x87 #define GAM13_VALUE 0xc4 -#define GAM14 0x88 +#define GAM14 0x88 #define GAM14_VALUE 0xd7 -#define GAM15 0x89 +#define GAM15 0x89 #define GAM15_VALUE 0xe8 */ // Array Control -#define CHLF 0x33 -#define CHLF_VALUE 0x0b - -#define ARBLM 0x34 -#define ARBLM_VALUE 0x11 - +#define CHLF 0x33 +#define CHLF_VALUE 0x0b +#define ARBLM 0x34 +#define ARBLM_VALUE 0x11 // ADC Control -#define ADCCTR1 0x21 -#define ADCCTR1_VALUE 0x02 +#define ADCCTR1 0x21 +#define ADCCTR1_VALUE 0x02 -#define ADCCTR2 0x22 -#define ADCCTR2_VALUE 0x91 +#define ADCCTR2 0x22 +#define ADCCTR2_VALUE 0x91 -#define ADC 0x37 -#define ADC_VALUE 0x1d +#define ADC 0x37 +#define ADC_VALUE 0x1d -#define ACOM 0x38 -#define ACOM_VALUE 0x71 - -#define OFON 0x39 -#define OFON_VALUE 0x2a +#define ACOM 0x38 +#define ACOM_VALUE 0x71 +#define OFON 0x39 +#define OFON_VALUE 0x2a // Black Level Calibration -#define ABLC1 0xb1 -#define ABLC1_VALUE 0x0c - -#define THL_ST 0xb3 -#define THL_ST_VALUE 0x82 +#define ABLC1 0xb1 +#define ABLC1_VALUE 0x0c +#define THL_ST 0xb3 +#define THL_ST_VALUE 0x82 -// Window Output -#define HSTART 0x17 +// Window Output +#define HSTART 0x17 #define HSTART_VALUE_DEFAULT 0x11 -#define HSTART_VALUE_VGA 0x13 -#define HSTART_VALUE_QVGA 0x13 -#define HSTART_VALUE_QQVGA 0x13 // Works - -#define HSTOP 0x18 -#define HSTOP_VALUE_DEFAULT 0x61 -#define HSTOP_VALUE_VGA 0x01 -#define HSTOP_VALUE_QVGA 0x01 -#define HSTOP_VALUE_QQVGA 0x01 // Works - -#define HREF 0x32 -#define HREF_VALUE_DEFAULT 0x80 -#define HREF_VALUE_VGA 0xB6 -#define HREF_VALUE_QVGA 0x24 -#define HREF_VALUE_QQVGA 0xA4 - -#define VSTRT 0x19 -#define VSTRT_VALUE_DEFAULT 0x03 -#define VSTRT_VALUE_VGA 0x02 -#define VSTRT_VALUE_QVGA 0x02 -#define VSTRT_VALUE_QQVGA 0x02 - -#define VSTOP 0x1A -#define VSTOP_VALUE_DEFAULT 0x7B -#define VSTOP_VALUE_VGA 0x7A -#define VSTOP_VALUE_QVGA 0x7A -#define VSTOP_VALUE_QQVGA 0x7A - -#define VREF 0x03 -#define VREF_VALUE_DEFAULT 0x03 -#define VREF_VALUE_VGA 0x0A -#define VREF_VALUE_QVGA 0x0A -#define VREF_VALUE_QQVGA 0x0A - - -// I2C -#define OV7670_I2C_ADDRESS 0x21 -#define I2C_ERROR_WRITING_START_ADDRESS 11 -#define I2C_ERROR_WRITING_DATA 22 - -#define DATA_TOO_LONG 1 // data too long to fit in transmit buffer -#define NACK_ON_TRANSMIT_OF_ADDRESS 2 // received NACK on transmit of address -#define NACK_ON_TRANSMIT_OF_DATA 3 // received NACK on transmit of data -#define OTHER_ERROR 4 // other error - -#define I2C_READ_START_ADDRESS_ERROR 33 -#define I2C_READ_DATA_SIZE_MISMATCH_ERROR 44 - - - - +#define HSTART_VALUE_VGA 0x13 +#define HSTART_VALUE_QVGA 0x13 +#define HSTART_VALUE_QQVGA 0x13 // Works + +#define HSTOP 0x18 +#define HSTOP_VALUE_DEFAULT 0x61 +#define HSTOP_VALUE_VGA 0x01 +#define HSTOP_VALUE_QVGA 0x01 +#define HSTOP_VALUE_QQVGA 0x01 // Works + +#define HREF 0x32 +#define HREF_VALUE_DEFAULT 0x80 +#define HREF_VALUE_VGA 0xB6 +#define HREF_VALUE_QVGA 0x24 +#define HREF_VALUE_QQVGA 0xA4 + +#define VSTRT 0x19 +#define VSTRT_VALUE_DEFAULT 0x03 +#define VSTRT_VALUE_VGA 0x02 +#define VSTRT_VALUE_QVGA 0x02 +#define VSTRT_VALUE_QQVGA 0x02 + +#define VSTOP 0x1A +#define VSTOP_VALUE_DEFAULT 0x7B +#define VSTOP_VALUE_VGA 0x7A +#define VSTOP_VALUE_QVGA 0x7A +#define VSTOP_VALUE_QQVGA 0x7A + +#define VREF 0x03 +#define VREF_VALUE_DEFAULT 0x03 +#define VREF_VALUE_VGA 0x0A +#define VREF_VALUE_QVGA 0x0A +#define VREF_VALUE_QQVGA 0x0A + +// I2C +#define OV7670_I2C_ADDRESS 0x21 +#define I2C_ERROR_WRITING_START_ADDRESS 11 +#define I2C_ERROR_WRITING_DATA 22 + +#define DATA_TOO_LONG 1 // data too long to fit in transmit buffer +#define NACK_ON_TRANSMIT_OF_ADDRESS 2 // received NACK on transmit of address +#define NACK_ON_TRANSMIT_OF_DATA 3 // received NACK on transmit of data +#define OTHER_ERROR 4 // other error + +#define I2C_READ_START_ADDRESS_ERROR 33 +#define I2C_READ_DATA_SIZE_MISMATCH_ERROR 44 byte ReadRegisterValue(int RegisterAddress) { byte data = 0; - - Wire.beginTransmission(OV7670_I2C_ADDRESS); - Wire.write(RegisterAddress); + + Wire.beginTransmission(OV7670_I2C_ADDRESS); + Wire.write(RegisterAddress); Wire.endTransmission(); - Wire.requestFrom(OV7670_I2C_ADDRESS, 1); - while(Wire.available() < 1); - data = Wire.read(); + Wire.requestFrom(OV7670_I2C_ADDRESS, 1); + while (Wire.available() < 1) + ; + data = Wire.read(); - return data; + return data; } void ReadRegisters() { byte data = 0; - + data = ReadRegisterValue(CLKRC); Serial.print(F("CLKRC = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM7); Serial.print(F("COM7 = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM3); Serial.print(F("COM3 = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM14); Serial.print(F("COM14 = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(SCALING_XSC); Serial.print(F("SCALING_XSC = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(SCALING_YSC); Serial.print(F("SCALING_YSC = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(SCALING_DCWCTR); Serial.print(F("SCALING_DCWCTR = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(SCALING_PCLK_DIV); Serial.print(F("SCALING_PCLK_DIV = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(SCALING_PCLK_DELAY); Serial.print(F("SCALING_PCLK_DELAY = ")); - Serial.println(data,HEX); - - //data = ReadRegisterValue(COM10); - //Serial.print(F("COM10 (Vsync Polarity) = ")); - //Serial.println(data,HEX); - + Serial.println(data, HEX); + + // data = ReadRegisterValue(COM10); + // Serial.print(F("COM10 (Vsync Polarity) = ")); + // Serial.println(data,HEX); + // default value D data = ReadRegisterValue(TSLB); Serial.print(F("TSLB (YUV Order- Higher Bit, Bit[3]) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + // default value 88 data = ReadRegisterValue(COM13); Serial.print(F("COM13 (YUV Order - Lower Bit, Bit[1]) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM17); Serial.print(F("COM17 (DSP Color Bar Selection) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM4); Serial.print(F("COM4 (works with COM 17) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM15); Serial.print(F("COM15 (COLOR FORMAT SELECTION) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM11); Serial.print(F("COM11 (Night Mode) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(COM8); Serial.print(F("COM8 (Color Control, AWB) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(HAECC7); Serial.print(F("HAECC7 (AEC Algorithm Selection) = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(GFIX); Serial.print(F("GFIX = ")); - Serial.println(data,HEX); - - + Serial.println(data, HEX); + // Window Output data = ReadRegisterValue(HSTART); Serial.print(F("HSTART = ")); - Serial.println(data,HEX); - //Serial.print(F(", ")); - //Serial.println(data, DEC); - + Serial.println(data, HEX); + // Serial.print(F(", ")); + // Serial.println(data, DEC); + data = ReadRegisterValue(HSTOP); Serial.print(F("HSTOP = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(HREF); Serial.print(F("HREF = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(VSTRT); Serial.print(F("VSTRT = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(VSTOP); Serial.print(F("VSTOP = ")); - Serial.println(data,HEX); - + Serial.println(data, HEX); + data = ReadRegisterValue(VREF); Serial.print(F("VREF = ")); - Serial.println(data,HEX); + Serial.println(data, HEX); } - void ResetCameraRegisters() { // Reset Camera Registers // Reading needed to prevent error byte data = ReadRegisterValue(COM7); - - int result = OV7670WriteReg(COM7, COM7_VALUE_RESET ); + + int result = OV7670WriteReg(COM7, COM7_VALUE_RESET); String sresult = ParseI2CResult(result); Serial.println("RESETTING ALL REGISTERS BY SETTING COM7 REGISTER to 0x80: " + sresult); - // Delay at least 500ms + // Delay at least 500ms delay(500); } - - // Main Call to Setup the ov7670 Camera void SetupCamera() { @@ -718,763 +681,746 @@ void SetupCamera() InitializeOV7670Camera(); } - void InitializeOV7670Camera() { Serial.println(F("Initializing OV7670 Camera ...")); - - //Set WRST to 0 and RRST to 0 , 0.1ms after power on. - int DurationMicroSecs = 1; - + + // Set WRST to 0 and RRST to 0 , 0.1ms after power on. + int DurationMicroSecs = 1; + // Set mode for pins wither input or output - pinMode(WRST , OUTPUT); - pinMode(RRST , OUTPUT); - pinMode(WEN , OUTPUT); + pinMode(WRST, OUTPUT); + pinMode(RRST, OUTPUT); + pinMode(WEN, OUTPUT); pinMode(VSYNC, INPUT); - pinMode(RCLK , OUTPUT); - + pinMode(RCLK, OUTPUT); + // FIFO Ram output pins - pinMode(DO7 , INPUT); - pinMode(DO6 , INPUT); - pinMode(DO5 , INPUT); - pinMode(DO4 , INPUT); - pinMode(DO3 , INPUT); - pinMode(DO2 , INPUT); - pinMode(DO1 , INPUT); - pinMode(DO0 , INPUT); - - // Delay 1 ms - delay(1); - - PulseLowEnabledPin(WRST, DurationMicroSecs); - - //PulseLowEnabledPin(RRST, DurationMicroSecs); - // Need to clock the fifo manually to get it to reset + pinMode(DO7, INPUT); + pinMode(DO6, INPUT); + pinMode(DO5, INPUT); + pinMode(DO4, INPUT); + pinMode(DO3, INPUT); + pinMode(DO2, INPUT); + pinMode(DO1, INPUT); + pinMode(DO0, INPUT); + + // Delay 1 ms + delay(1); + + PulseLowEnabledPin(WRST, DurationMicroSecs); + + // PulseLowEnabledPin(RRST, DurationMicroSecs); + // Need to clock the fifo manually to get it to reset digitalWrite(RRST, LOW); - PulsePin(RCLK, DurationMicroSecs); - PulsePin(RCLK, DurationMicroSecs); - digitalWrite(RRST, HIGH); + PulsePin(RCLK, DurationMicroSecs); + PulsePin(RCLK, DurationMicroSecs); + digitalWrite(RRST, HIGH); } void SetupCameraAdvancedAutoWhiteBalanceConfig() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera Advanced Auto White Balance Configs ........")); - - result = OV7670WriteReg(AWBC1, AWBC1_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC1: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC2, AWBC2_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC2: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC3, AWBC3_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC3: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC4, AWBC4_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC4: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC5, AWBC5_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC5: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC6, AWBC6_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC6: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC7, AWBC7_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC7: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC8, AWBC8_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC8: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC9, AWBC9_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC9: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC10, AWBC10_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC10: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC11, AWBC11_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC11: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBC12, AWBC12_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBC12: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBCTR3, AWBCTR3_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBCTR3: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBCTR2, AWBCTR2_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBCTR2: ")); - Serial.println(sresult); - - result = OV7670WriteReg(AWBCTR1, AWBCTR1_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AWBCTR1: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera Advanced Auto White Balance Configs ........")); + + result = OV7670WriteReg(AWBC1, AWBC1_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC1: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC2, AWBC2_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC2: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC3, AWBC3_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC3: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC4, AWBC4_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC4: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC5, AWBC5_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC5: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC6, AWBC6_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC6: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC7, AWBC7_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC7: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC8, AWBC8_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC8: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC9, AWBC9_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC9: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC10, AWBC10_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC10: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC11, AWBC11_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC11: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBC12, AWBC12_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBC12: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBCTR3, AWBCTR3_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBCTR3: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBCTR2, AWBCTR2_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBCTR2: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AWBCTR1, AWBCTR1_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AWBCTR1: ")); + Serial.println(sresult); } void SetupCameraUndocumentedRegisters() -{ - // Write(0xb0,0x84); //adding this improve the color a little bit - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera Undocumented Registers ........")); - result = OV7670WriteReg(0xB0, 0x84); - sresult = ParseI2CResult(result); - Serial.print(F("Setting B0 UNDOCUMENTED register to 0x84:= ")); - Serial.println(sresult); +{ + // Write(0xb0,0x84); //adding this improve the color a little bit + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera Undocumented Registers ........")); + result = OV7670WriteReg(0xB0, 0x84); + sresult = ParseI2CResult(result); + Serial.print(F("Setting B0 UNDOCUMENTED register to 0x84:= ")); + Serial.println(sresult); } void SetupCameraFor30FPS() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera to 30 FPS ........")); - result = OV7670WriteReg(CLKRC, CLKRC_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("CLKRC: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; - result = OV7670WriteReg(DBLV, DBLV_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("DBLV: ")); - Serial.println(sresult); - - result = OV7670WriteReg(EXHCH, EXHCH_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("EXHCH: ")); - Serial.println(sresult); + Serial.println(F("........... Setting Camera to 30 FPS ........")); + result = OV7670WriteReg(CLKRC, CLKRC_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("CLKRC: ")); + Serial.println(sresult); - result = OV7670WriteReg(EXHCL, EXHCL_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("EXHCL: ")); - Serial.println(sresult); - - result = OV7670WriteReg(DM_LNL, DM_LNL_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("DM_LNL: ")); - Serial.println(sresult); + result = OV7670WriteReg(DBLV, DBLV_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("DBLV: ")); + Serial.println(sresult); - result = OV7670WriteReg(DM_LNH, DM_LNH_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("DM_LNH: ")); - Serial.println(sresult); + result = OV7670WriteReg(EXHCH, EXHCH_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("EXHCH: ")); + Serial.println(sresult); - result = OV7670WriteReg(COM11, COM11_VALUE_30FPS); - sresult = ParseI2CResult(result); - Serial.print(F("COM11: ")); - Serial.println(sresult); - + result = OV7670WriteReg(EXHCL, EXHCL_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("EXHCL: ")); + Serial.println(sresult); + + result = OV7670WriteReg(DM_LNL, DM_LNL_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("DM_LNL: ")); + Serial.println(sresult); + + result = OV7670WriteReg(DM_LNH, DM_LNH_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("DM_LNH: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM11, COM11_VALUE_30FPS); + sresult = ParseI2CResult(result); + Serial.print(F("COM11: ")); + Serial.println(sresult); } void SetupCameraABLC() { - int result = 0; - String sresult = ""; - - // If ABLC is off then return otherwise - // turn on ABLC. - if (ABLCParam == "AblcOFF") - { - return; - } - - Serial.println(F("........ Setting Camera ABLC .......")); - - result = OV7670WriteReg(ABLC1, ABLC1_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("ABLC1: ")); - Serial.println(sresult); - - result = OV7670WriteReg(THL_ST, THL_ST_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("THL_ST: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; + + // If ABLC is off then return otherwise + // turn on ABLC. + if (ABLCParam == "AblcOFF") + { + return; + } + + Serial.println(F("........ Setting Camera ABLC .......")); + + result = OV7670WriteReg(ABLC1, ABLC1_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("ABLC1: ")); + Serial.println(sresult); + + result = OV7670WriteReg(THL_ST, THL_ST_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("THL_ST: ")); + Serial.println(sresult); } void SetupOV7670ForVGARawRGB() { - int result = 0; - String sresult = ""; - - Serial.println(F("--------------------------- Setting Camera for VGA (Raw RGB) ---------------------------")); - - PHOTO_WIDTH = 640; - PHOTO_HEIGHT = 480; - PHOTO_BYTES_PER_PIXEL = 1; - - Serial.print(F("Photo Width = ")); - Serial.println(PHOTO_WIDTH); - - Serial.print(F("Photo Height = ")); - Serial.println(PHOTO_HEIGHT); - - Serial.print(F("Bytes Per Pixel = ")); - Serial.println(PHOTO_BYTES_PER_PIXEL); - - - // Basic Registers - result = OV7670WriteReg(CLKRC, CLKRC_VALUE_VGA); - sresult = ParseI2CResult(result); - Serial.print(F("CLKRC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM7, COM7_VALUE_VGA ); - //result = OV7670WriteReg(COM7, COM7_VALUE_VGA_COLOR_BAR ); - sresult = ParseI2CResult(result); - Serial.print(F("COM7: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; - result = OV7670WriteReg(COM3, COM3_VALUE_VGA); - sresult = ParseI2CResult(result); - Serial.print(F("COM3: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM14, COM14_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("COM14: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_XSC,SCALING_XSC_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_XSC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_YSC,SCALING_YSC_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_YSC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_DCWCTR, SCALING_DCWCTR_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_DCWCTR: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_PCLK_DIV, SCALING_PCLK_DIV_VALUE_VGA); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_PCLK_DIV: ")); - Serial.println (sresult); - - result = OV7670WriteReg(SCALING_PCLK_DELAY,SCALING_PCLK_DELAY_VALUE_VGA); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_PCLK_DELAY: ")); - Serial.println(sresult); - - // COM17 - DSP Color Bar Enable/Disable - // 0000 1000 => to Enable - // 0x08 - // COM17_VALUE 0x08 // Activate Color Bar for DSP - //result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_COLOR_BAR); - result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR); - sresult = ParseI2CResult(result); - Serial.print(F("COM17: ")); - Serial.println(sresult); - - - // Set Additional Parameters - - // Set Camera Frames per second - SetCameraFPSMode(); - - // Set Camera Automatic Exposure Control - SetCameraAEC(); - - // Needed Color Correction, green to red - result = OV7670WriteReg(0xB0, 0x8c); - sresult = ParseI2CResult(result); - Serial.print(F("Setting B0 UNDOCUMENTED register to 0x84:= ")); - Serial.println(sresult); - - // Set Camera Saturation - SetCameraSaturationControl(); - - // Setup Camera Array Control - SetupCameraArrayControl(); - - // Set ADC Control - SetupCameraADCControl(); - - // Set Automatic Black Level Calibration - SetupCameraABLC(); - - - - Serial.println(F("........... Setting Camera Window Output Parameters ........")); - - // Change Window Output parameters after custom scaling - result = OV7670WriteReg(HSTART, HSTART_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HSTART: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HSTOP, HSTOP_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HSTOP: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HREF, HREF_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HREF: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VSTRT, VSTRT_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VSTRT: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VSTOP, VSTOP_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VSTOP: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VREF, VREF_VALUE_VGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VREF: ")); - Serial.println(sresult); -} + Serial.println(F("--------------------------- Setting Camera for VGA (Raw RGB) ---------------------------")); + + PHOTO_WIDTH = 640; + PHOTO_HEIGHT = 480; + PHOTO_BYTES_PER_PIXEL = 1; + + Serial.print(F("Photo Width = ")); + Serial.println(PHOTO_WIDTH); + + Serial.print(F("Photo Height = ")); + Serial.println(PHOTO_HEIGHT); + + Serial.print(F("Bytes Per Pixel = ")); + Serial.println(PHOTO_BYTES_PER_PIXEL); + + // Basic Registers + result = OV7670WriteReg(CLKRC, CLKRC_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("CLKRC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM7, COM7_VALUE_VGA); + // result = OV7670WriteReg(COM7, COM7_VALUE_VGA_COLOR_BAR ); + sresult = ParseI2CResult(result); + Serial.print(F("COM7: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM3, COM3_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("COM3: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM14, COM14_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("COM14: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_XSC, SCALING_XSC_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_XSC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_YSC, SCALING_YSC_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_YSC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_DCWCTR, SCALING_DCWCTR_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_DCWCTR: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_PCLK_DIV, SCALING_PCLK_DIV_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_PCLK_DIV: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_PCLK_DELAY, SCALING_PCLK_DELAY_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_PCLK_DELAY: ")); + Serial.println(sresult); + + // COM17 - DSP Color Bar Enable/Disable + // 0000 1000 => to Enable + // 0x08 + // COM17_VALUE 0x08 // Activate Color Bar for DSP + // result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_COLOR_BAR); + result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR); + sresult = ParseI2CResult(result); + Serial.print(F("COM17: ")); + Serial.println(sresult); + + // Set Additional Parameters + + // Set Camera Frames per second + SetCameraFPSMode(); + + // Set Camera Automatic Exposure Control + SetCameraAEC(); + + // Needed Color Correction, green to red + result = OV7670WriteReg(0xB0, 0x8c); + sresult = ParseI2CResult(result); + Serial.print(F("Setting B0 UNDOCUMENTED register to 0x84:= ")); + Serial.println(sresult); + + // Set Camera Saturation + SetCameraSaturationControl(); + + // Setup Camera Array Control + SetupCameraArrayControl(); + + // Set ADC Control + SetupCameraADCControl(); + + // Set Automatic Black Level Calibration + SetupCameraABLC(); + + Serial.println(F("........... Setting Camera Window Output Parameters ........")); + + // Change Window Output parameters after custom scaling + result = OV7670WriteReg(HSTART, HSTART_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("HSTART: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HSTOP, HSTOP_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("HSTOP: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HREF, HREF_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("HREF: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VSTRT, VSTRT_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("VSTRT: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VSTOP, VSTOP_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("VSTOP: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VREF, VREF_VALUE_VGA); + sresult = ParseI2CResult(result); + Serial.print(F("VREF: ")); + Serial.println(sresult); +} void SetupOV7670ForVGAProcessedBayerRGB() { - int result = 0; - String sresult = ""; - - // Call Base for VGA Raw Bayer RGB Mode - SetupOV7670ForVGARawRGB(); - - Serial.println(F("------------- Setting Camera for VGA (Processed Bayer RGB) ----------------")); - - // Set key register for selecting processed bayer rgb output - result = OV7670WriteReg(COM7, COM7_VALUE_VGA_PROCESSED_BAYER ); - //result = OV7670WriteReg(COM7, COM7_VALUE_VGA_COLOR_BAR ); - sresult = ParseI2CResult(result); - Serial.print(F("COM7: ")); - Serial.println(sresult); - - result = OV7670WriteReg(TSLB, 0x04); - sresult = ParseI2CResult(result); - Serial.print(F("Initializing TSLB register result = ")); - Serial.println(sresult); - - // Needed Color Correction, green to red - result = OV7670WriteReg(0xB0, 0x8c); - sresult = ParseI2CResult(result); - Serial.print(F("Setting B0 UNDOCUMENTED register to 0x84:= ")); - Serial.println(sresult); - - // Set Camera Automatic White Balance - SetupCameraAWB(); - - // Denoise and Edge Enhancement - SetupCameraDenoiseEdgeEnhancement(); + int result = 0; + String sresult = ""; + + // Call Base for VGA Raw Bayer RGB Mode + SetupOV7670ForVGARawRGB(); + + Serial.println(F("------------- Setting Camera for VGA (Processed Bayer RGB) ----------------")); + + // Set key register for selecting processed bayer rgb output + result = OV7670WriteReg(COM7, COM7_VALUE_VGA_PROCESSED_BAYER); + // result = OV7670WriteReg(COM7, COM7_VALUE_VGA_COLOR_BAR ); + sresult = ParseI2CResult(result); + Serial.print(F("COM7: ")); + Serial.println(sresult); + + result = OV7670WriteReg(TSLB, 0x04); + sresult = ParseI2CResult(result); + Serial.print(F("Initializing TSLB register result = ")); + Serial.println(sresult); + + // Needed Color Correction, green to red + result = OV7670WriteReg(0xB0, 0x8c); + sresult = ParseI2CResult(result); + Serial.print(F("Setting B0 UNDOCUMENTED register to 0x84:= ")); + Serial.println(sresult); + + // Set Camera Automatic White Balance + SetupCameraAWB(); + + // Denoise and Edge Enhancement + SetupCameraDenoiseEdgeEnhancement(); } void SetupCameraAverageBasedAECAGC() { - int result = 0; - String sresult = ""; - - Serial.println(F("-------------- Setting Camera Average Based AEC/AGC Registers ---------------")); - - result = OV7670WriteReg(AEW, AEW_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AEW: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; - result = OV7670WriteReg(AEB, AEB_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AEB: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VPT, VPT_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("VPT: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC7, HAECC7_VALUE_AVERAGE_AEC_ON); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC7: ")); - Serial.println(sresult); + Serial.println(F("-------------- Setting Camera Average Based AEC/AGC Registers ---------------")); + + result = OV7670WriteReg(AEW, AEW_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AEW: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AEB, AEB_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AEB: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VPT, VPT_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("VPT: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC7, HAECC7_VALUE_AVERAGE_AEC_ON); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC7: ")); + Serial.println(sresult); } void SetCameraHistogramBasedAECAGC() { - int result = 0; - String sresult = ""; - - Serial.println(F("-------------- Setting Camera Histogram Based AEC/AGC Registers ---------------")); - - result = OV7670WriteReg(AEW, AEW_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AEW: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; - result = OV7670WriteReg(AEB, AEB_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("AEB: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC1, HAECC1_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC1: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC2, HAECC2_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC2: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC3, HAECC3_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC3: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC4, HAECC4_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC4: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC5, HAECC5_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC5: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC6, HAECC6_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC6: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HAECC7, HAECC7_VALUE_HISTOGRAM_AEC_ON); - sresult = ParseI2CResult(result); - Serial.print(F("HAECC7: ")); - Serial.println(sresult); + Serial.println(F("-------------- Setting Camera Histogram Based AEC/AGC Registers ---------------")); + + result = OV7670WriteReg(AEW, AEW_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AEW: ")); + Serial.println(sresult); + + result = OV7670WriteReg(AEB, AEB_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("AEB: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC1, HAECC1_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC1: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC2, HAECC2_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC2: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC3, HAECC3_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC3: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC4, HAECC4_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC4: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC5, HAECC5_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC5: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC6, HAECC6_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC6: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HAECC7, HAECC7_VALUE_HISTOGRAM_AEC_ON); + sresult = ParseI2CResult(result); + Serial.print(F("HAECC7: ")); + Serial.println(sresult); } void SetupOV7670ForQVGAYUV() { - int result = 0; - String sresult = ""; - - Serial.println(F("--------------------------- Setting Camera for QVGA (YUV) ---------------------------")); - - PHOTO_WIDTH = 320; - PHOTO_HEIGHT = 240; - PHOTO_BYTES_PER_PIXEL = 2; - - Serial.print(F("Photo Width = ")); - Serial.println(PHOTO_WIDTH); - - Serial.print(F("Photo Height = ")); - Serial.println(PHOTO_HEIGHT); - - Serial.print(F("Bytes Per Pixel = ")); - Serial.println(PHOTO_BYTES_PER_PIXEL); - - - // Basic Registers - result = OV7670WriteReg(CLKRC, CLKRC_VALUE_QVGA); - sresult = ParseI2CResult(result); - Serial.print(F("CLKRC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM7, COM7_VALUE_QVGA ); - //result = OV7670WriteReg(COM7, COM7_VALUE_QVGA_COLOR_BAR ); - sresult = ParseI2CResult(result); - Serial.print(F("COM7: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; - result = OV7670WriteReg(COM3, COM3_VALUE_QVGA); - sresult = ParseI2CResult(result); - Serial.print(F("COM3: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM14, COM14_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("COM14: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_XSC,SCALING_XSC_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_XSC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_YSC,SCALING_YSC_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_YSC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_DCWCTR, SCALING_DCWCTR_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_DCWCTR: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_PCLK_DIV, SCALING_PCLK_DIV_VALUE_QVGA); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_PCLK_DIV: ")); - Serial.println (sresult); - - result = OV7670WriteReg(SCALING_PCLK_DELAY,SCALING_PCLK_DELAY_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_PCLK_DELAY: ")); - Serial.println(sresult); - - // YUV order control change from default use with COM13 - //result = OV7670WriteReg(TSLB, TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_ENABLED); - //result = OV7670WriteReg(TSLB, TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_DISABLED); // Works - //result = OV7670WriteReg(TSLB, TSLB_VALUE_UYVY_AUTO_OUTPUT_WINDOW_DISABLED); - //result = OV7670WriteReg(TSLB, TSLB_VALUE_TESTVALUE); - result = OV7670WriteReg(TSLB, 0x04); - sresult = ParseI2CResult(result); - Serial.print(F("TSLB: ")); - Serial.println(sresult); - - //COM13 - //result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YUYV); - //result = OV7670WriteReg(COM13, COM13_VALUE_DEFAULT); - //result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YVYU); - //result = OV7670WriteReg(COM13, COM13_VALUE_NOGAMMA_YUYV); - //result = OV7670WriteReg(COM13, COM13_VALUE_YUYV_UVSATAUTOADJ_ON); - // { REG_COM13, /*0xc3*/0x48 } // error in datasheet bit 3 controls YUV order - //result = OV7670WriteReg(COM13, 0x48); - //result = OV7670WriteReg(COM13, 0xC8); // needed for correct color bar - result = OV7670WriteReg(COM13, 0xC2); // from YCbCr reference specs - //result = OV7670WriteReg(COM13, 0x82); - sresult = ParseI2CResult(result); - Serial.print(F("COM13: ")); - Serial.println(sresult); - - // COM17 - DSP Color Bar Enable/Disable - // 0000 1000 => to Enable - // 0x08 - // COM17_VALUE 0x08 // Activate Color Bar for DSP - //result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_COLOR_BAR); - result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR); - sresult = ParseI2CResult(result); - Serial.print(F("COM17: ")); - Serial.println(sresult); - - - - // Set Additional Parameters - - // Set Camera Frames per second - SetCameraFPSMode(); - - // Set Camera Automatic Exposure Control - SetCameraAEC(); - - // Set Camera Automatic White Balance - SetupCameraAWB(); - - // Setup Undocumented Registers - Needed Minimum - SetupCameraUndocumentedRegisters(); - - // Set Color Matrix for YUV - if (YUVMatrixParam == "YUVMatrixOn") - { - SetCameraColorMatrixYUV(); - } - - // Set Camera Saturation - SetCameraSaturationControl(); - - // Denoise and Edge Enhancement - SetupCameraDenoiseEdgeEnhancement(); - - - // Set up Camera Array Control - SetupCameraArrayControl(); - - - // Set ADC Control - SetupCameraADCControl(); - - - // Set Automatic Black Level Calibration - SetupCameraABLC(); - - - Serial.println(F("........... Setting Camera Window Output Parameters ........")); - - // Change Window Output parameters after custom scaling - result = OV7670WriteReg(HSTART, HSTART_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HSTART: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HSTOP, HSTOP_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HSTOP: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HREF, HREF_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HREF: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VSTRT, VSTRT_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VSTRT: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VSTOP, VSTOP_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VSTOP: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VREF, VREF_VALUE_QVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VREF: ")); - Serial.println(sresult); + Serial.println(F("--------------------------- Setting Camera for QVGA (YUV) ---------------------------")); + + PHOTO_WIDTH = 320; + PHOTO_HEIGHT = 240; + PHOTO_BYTES_PER_PIXEL = 2; + + Serial.print(F("Photo Width = ")); + Serial.println(PHOTO_WIDTH); + + Serial.print(F("Photo Height = ")); + Serial.println(PHOTO_HEIGHT); + + Serial.print(F("Bytes Per Pixel = ")); + Serial.println(PHOTO_BYTES_PER_PIXEL); + + // Basic Registers + result = OV7670WriteReg(CLKRC, CLKRC_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("CLKRC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM7, COM7_VALUE_QVGA); + // result = OV7670WriteReg(COM7, COM7_VALUE_QVGA_COLOR_BAR ); + sresult = ParseI2CResult(result); + Serial.print(F("COM7: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM3, COM3_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("COM3: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM14, COM14_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("COM14: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_XSC, SCALING_XSC_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_XSC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_YSC, SCALING_YSC_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_YSC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_DCWCTR, SCALING_DCWCTR_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_DCWCTR: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_PCLK_DIV, SCALING_PCLK_DIV_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_PCLK_DIV: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_PCLK_DELAY, SCALING_PCLK_DELAY_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_PCLK_DELAY: ")); + Serial.println(sresult); + + // YUV order control change from default use with COM13 + // result = OV7670WriteReg(TSLB, TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_ENABLED); + // result = OV7670WriteReg(TSLB, TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_DISABLED); // Works + // result = OV7670WriteReg(TSLB, TSLB_VALUE_UYVY_AUTO_OUTPUT_WINDOW_DISABLED); + // result = OV7670WriteReg(TSLB, TSLB_VALUE_TESTVALUE); + result = OV7670WriteReg(TSLB, 0x04); + sresult = ParseI2CResult(result); + Serial.print(F("TSLB: ")); + Serial.println(sresult); + + // COM13 + // result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YUYV); + // result = OV7670WriteReg(COM13, COM13_VALUE_DEFAULT); + // result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YVYU); + // result = OV7670WriteReg(COM13, COM13_VALUE_NOGAMMA_YUYV); + // result = OV7670WriteReg(COM13, COM13_VALUE_YUYV_UVSATAUTOADJ_ON); + // { REG_COM13, /*0xc3*/0x48 } // error in datasheet bit 3 controls YUV order + // result = OV7670WriteReg(COM13, 0x48); + // result = OV7670WriteReg(COM13, 0xC8); // needed for correct color bar + result = OV7670WriteReg(COM13, 0xC2); // from YCbCr reference specs + // result = OV7670WriteReg(COM13, 0x82); + sresult = ParseI2CResult(result); + Serial.print(F("COM13: ")); + Serial.println(sresult); + + // COM17 - DSP Color Bar Enable/Disable + // 0000 1000 => to Enable + // 0x08 + // COM17_VALUE 0x08 // Activate Color Bar for DSP + // result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_COLOR_BAR); + result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR); + sresult = ParseI2CResult(result); + Serial.print(F("COM17: ")); + Serial.println(sresult); + + // Set Additional Parameters + + // Set Camera Frames per second + SetCameraFPSMode(); + + // Set Camera Automatic Exposure Control + SetCameraAEC(); + + // Set Camera Automatic White Balance + SetupCameraAWB(); + + // Setup Undocumented Registers - Needed Minimum + SetupCameraUndocumentedRegisters(); + + // Set Color Matrix for YUV + if (YUVMatrixParam == "YUVMatrixOn") + { + SetCameraColorMatrixYUV(); + } + + // Set Camera Saturation + SetCameraSaturationControl(); + + // Denoise and Edge Enhancement + SetupCameraDenoiseEdgeEnhancement(); + + // Set up Camera Array Control + SetupCameraArrayControl(); + + // Set ADC Control + SetupCameraADCControl(); + + // Set Automatic Black Level Calibration + SetupCameraABLC(); + + Serial.println(F("........... Setting Camera Window Output Parameters ........")); + + // Change Window Output parameters after custom scaling + result = OV7670WriteReg(HSTART, HSTART_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("HSTART: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HSTOP, HSTOP_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("HSTOP: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HREF, HREF_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("HREF: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VSTRT, VSTRT_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("VSTRT: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VSTOP, VSTOP_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("VSTOP: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VREF, VREF_VALUE_QVGA); + sresult = ParseI2CResult(result); + Serial.print(F("VREF: ")); + Serial.println(sresult); } void SetupCameraNightMode() { - int result = 0; - String sresult = ""; - - Serial.println(F("......... Turning NIGHT MODE ON ........")); - result = OV7670WriteReg(CLKRC, CLKRC_VALUE_NIGHTMODE_AUTO); - sresult = ParseI2CResult(result); - Serial.print(F("CLKRC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM11, COM11_VALUE_NIGHTMODE_AUTO); - sresult = ParseI2CResult(result); - Serial.print(F("COM11: ")); - Serial.println(sresult); -} + int result = 0; + String sresult = ""; + Serial.println(F("......... Turning NIGHT MODE ON ........")); + result = OV7670WriteReg(CLKRC, CLKRC_VALUE_NIGHTMODE_AUTO); + sresult = ParseI2CResult(result); + Serial.print(F("CLKRC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM11, COM11_VALUE_NIGHTMODE_AUTO); + sresult = ParseI2CResult(result); + Serial.print(F("COM11: ")); + Serial.println(sresult); +} void SetupCameraSimpleAutomaticWhiteBalance() { - /* - i2c_salve_Address = 0x42; - write_i2c(0x13, 0xe7); //AWB on - write_i2c(0x6f, 0x9f); // Simple AWB - */ - - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera to Simple AWB ........")); - - // COM8 - //result = OV7670WriteReg(0x13, 0xE7); - result = OV7670WriteReg(COM8, COM8_VALUE_AWB_ON); - sresult = ParseI2CResult(result); - Serial.print(F("COM8(0x13): ")); - Serial.println(sresult); - - // AWBCTR0 - //result = OV7670WriteReg(0x6f, 0x9f); - result = OV7670WriteReg(AWBCTR0, AWBCTR0_VALUE_NORMAL); - sresult = ParseI2CResult(result); - Serial.print(F("AWBCTR0 Control Register 0(0x6F): ")); - Serial.println(sresult); + /* + i2c_salve_Address = 0x42; + write_i2c(0x13, 0xe7); //AWB on + write_i2c(0x6f, 0x9f); // Simple AWB + */ + + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera to Simple AWB ........")); + + // COM8 + // result = OV7670WriteReg(0x13, 0xE7); + result = OV7670WriteReg(COM8, COM8_VALUE_AWB_ON); + sresult = ParseI2CResult(result); + Serial.print(F("COM8(0x13): ")); + Serial.println(sresult); + + // AWBCTR0 + // result = OV7670WriteReg(0x6f, 0x9f); + result = OV7670WriteReg(AWBCTR0, AWBCTR0_VALUE_NORMAL); + sresult = ParseI2CResult(result); + Serial.print(F("AWBCTR0 Control Register 0(0x6F): ")); + Serial.println(sresult); } void SetupCameraAdvancedAutomaticWhiteBalance() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera to Advanced AWB ........")); - - // AGC, AWB, and AEC Enable - result = OV7670WriteReg(0x13, 0xE7); - sresult = ParseI2CResult(result); - Serial.print(F("COM8(0x13): ")); - Serial.println(sresult); - - // AWBCTR0 - result = OV7670WriteReg(0x6f, 0x9E); - sresult = ParseI2CResult(result); - Serial.print(F("AWB Control Register 0(0x6F): ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera to Advanced AWB ........")); + + // AGC, AWB, and AEC Enable + result = OV7670WriteReg(0x13, 0xE7); + sresult = ParseI2CResult(result); + Serial.print(F("COM8(0x13): ")); + Serial.println(sresult); + + // AWBCTR0 + result = OV7670WriteReg(0x6f, 0x9E); + sresult = ParseI2CResult(result); + Serial.print(F("AWB Control Register 0(0x6F): ")); + Serial.println(sresult); } void SetupCameraGain() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera Gain ........")); - - // Set Maximum Gain - //result = OV7670WriteReg(COM9, COM9_VALUE_MAX_GAIN_128X); - result = OV7670WriteReg(COM9, COM9_VALUE_4XGAIN); - //result = OV7670WriteReg(COM9, 0x18); - sresult = ParseI2CResult(result); - Serial.print(F("COM9: ")); - Serial.println(sresult); - - // Set Blue Gain - //{ REG_BLUE, 0x40 }, - result = OV7670WriteReg(BLUE, BLUE_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("BLUE GAIN: ")); - Serial.println(sresult); - - // Set Red Gain - //{ REG_RED, 0x60 }, - result = OV7670WriteReg(RED, RED_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("RED GAIN: ")); - Serial.println(sresult); - - - // Set Green Gain - //{ 0x6a, 0x40 }, - result = OV7670WriteReg(GGAIN, GGAIN_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("GREEN GAIN: ")); - Serial.println(sresult); - - - // Enable AWB Gain - // REG_COM16 0x41 /* Control 16 */ - // COM16_AWBGAIN 0x08 /* AWB gain enable */ - // { REG_COM16, COM16_AWBGAIN }, - result = OV7670WriteReg(COM16, COM16_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("COM16(ENABLE GAIN): ")); - Serial.println(sresult); - + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera Gain ........")); + + // Set Maximum Gain + // result = OV7670WriteReg(COM9, COM9_VALUE_MAX_GAIN_128X); + result = OV7670WriteReg(COM9, COM9_VALUE_4XGAIN); + // result = OV7670WriteReg(COM9, 0x18); + sresult = ParseI2CResult(result); + Serial.print(F("COM9: ")); + Serial.println(sresult); + + // Set Blue Gain + //{ REG_BLUE, 0x40 }, + result = OV7670WriteReg(BLUE, BLUE_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("BLUE GAIN: ")); + Serial.println(sresult); + + // Set Red Gain + //{ REG_RED, 0x60 }, + result = OV7670WriteReg(RED, RED_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("RED GAIN: ")); + Serial.println(sresult); + + // Set Green Gain + //{ 0x6a, 0x40 }, + result = OV7670WriteReg(GGAIN, GGAIN_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("GREEN GAIN: ")); + Serial.println(sresult); + + // Enable AWB Gain + // REG_COM16 0x41 /* Control 16 */ + // COM16_AWBGAIN 0x08 /* AWB gain enable */ + // { REG_COM16, COM16_AWBGAIN }, + result = OV7670WriteReg(COM16, COM16_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("COM16(ENABLE GAIN): ")); + Serial.println(sresult); } void SetCameraSaturationControl() { int result = 0; String sresult = ""; - + Serial.println(F("........... Setting Camera Saturation Level ........")); result = OV7670WriteReg(SATCTR, SATCTR_VALUE); sresult = ParseI2CResult(result); @@ -1486,187 +1432,177 @@ void SetCameraColorMatrixYUV() { int result = 0; String sresult = ""; - + Serial.println(F("........... Setting Camera Color Matrix for YUV ........")); - + result = OV7670WriteReg(MTX1, MTX1_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTX1: ")); Serial.println(sresult); - + result = OV7670WriteReg(MTX2, MTX2_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTX2: ")); Serial.println(sresult); - + result = OV7670WriteReg(MTX3, MTX3_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTX3: ")); Serial.println(sresult); - + result = OV7670WriteReg(MTX4, MTX4_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTX4: ")); Serial.println(sresult); - + result = OV7670WriteReg(MTX5, MTX5_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTX5: ")); Serial.println(sresult); - + result = OV7670WriteReg(MTX6, MTX6_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTX6: ")); Serial.println(sresult); - + result = OV7670WriteReg(CONTRAS, CONTRAS_VALUE); sresult = ParseI2CResult(result); Serial.print(F("CONTRAS: ")); Serial.println(sresult); - + result = OV7670WriteReg(MTXS, MTXS_VALUE); sresult = ParseI2CResult(result); Serial.print(F("MTXS: ")); - Serial.println(sresult); + Serial.println(sresult); } void SetCameraFPSMode() { - // Set FPS for Camera - if (FPSParam == "ThirtyFPS") - { - SetupCameraFor30FPS(); - } - else - if (FPSParam == "NightMode") - { - SetupCameraNightMode(); - } + // Set FPS for Camera + if (FPSParam == "ThirtyFPS") + { + SetupCameraFor30FPS(); + } + else if (FPSParam == "NightMode") + { + SetupCameraNightMode(); + } } void SetCameraAEC() { - // Process AEC - if (AECParam == "AveAEC") - { - // Set Camera's Average AEC/AGC Parameters - SetupCameraAverageBasedAECAGC(); - } - else - if (AECParam == "HistAEC") - { - // Set Camera AEC algorithim to Histogram - SetCameraHistogramBasedAECAGC(); - } + // Process AEC + if (AECParam == "AveAEC") + { + // Set Camera's Average AEC/AGC Parameters + SetupCameraAverageBasedAECAGC(); + } + else if (AECParam == "HistAEC") + { + // Set Camera AEC algorithim to Histogram + SetCameraHistogramBasedAECAGC(); + } } void SetupCameraAWB() { - // Set AWB Mode - if (AWBParam == "SAWB") - { - // Set Simple Automatic White Balance - SetupCameraSimpleAutomaticWhiteBalance(); // OK - - // Set Gain Config - SetupCameraGain(); - } - else - if (AWBParam == "AAWB") - { - // Set Advanced Automatic White Balance - SetupCameraAdvancedAutomaticWhiteBalance(); // ok - - // Set Camera Automatic White Balance Configuration - SetupCameraAdvancedAutoWhiteBalanceConfig(); // ok - - // Set Gain Config - SetupCameraGain(); - } -} + // Set AWB Mode + if (AWBParam == "SAWB") + { + // Set Simple Automatic White Balance + SetupCameraSimpleAutomaticWhiteBalance(); // OK + // Set Gain Config + SetupCameraGain(); + } + else if (AWBParam == "AAWB") + { + // Set Advanced Automatic White Balance + SetupCameraAdvancedAutomaticWhiteBalance(); // ok -void SetupCameraDenoise() -{ - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera Denoise ........")); - - result = OV7670WriteReg(DNSTH, DNSTH_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("DNSTH: ")); - Serial.println(sresult); - - result = OV7670WriteReg(REG77, REG77_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("REG77: ")); - Serial.println(sresult); + // Set Camera Automatic White Balance Configuration + SetupCameraAdvancedAutoWhiteBalanceConfig(); // ok + + // Set Gain Config + SetupCameraGain(); + } } +void SetupCameraDenoise() +{ + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera Denoise ........")); + + result = OV7670WriteReg(DNSTH, DNSTH_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("DNSTH: ")); + Serial.println(sresult); + + result = OV7670WriteReg(REG77, REG77_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("REG77: ")); + Serial.println(sresult); +} void SetupCameraEdgeEnhancement() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera Edge Enhancement ........")); - - result = OV7670WriteReg(EDGE, EDGE_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("EDGE: ")); - Serial.println(sresult); - - result = OV7670WriteReg(REG75, REG75_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("REG75: ")); - Serial.println(sresult); - - result = OV7670WriteReg(REG76, REG76_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("REG76: ")); - Serial.println(sresult); -} + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera Edge Enhancement ........")); + + result = OV7670WriteReg(EDGE, EDGE_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("EDGE: ")); + Serial.println(sresult); + result = OV7670WriteReg(REG75, REG75_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("REG75: ")); + Serial.println(sresult); + result = OV7670WriteReg(REG76, REG76_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("REG76: ")); + Serial.println(sresult); +} void SetupCameraDenoiseEdgeEnhancement() { - int result = 0; - String sresult = ""; - - if ((DenoiseParam == "DenoiseYes")&& - (EdgeParam == "EdgeYes")) - { - SetupCameraDenoise(); - SetupCameraEdgeEnhancement(); - result = OV7670WriteReg(COM16, COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_ON__AWBGAIN_ON); - sresult = ParseI2CResult(result); - Serial.print(F("COM16: ")); - Serial.println(sresult); - } - else - if ((DenoiseParam == "DenoiseYes")&& - (EdgeParam == "EdgeNo")) - { - SetupCameraDenoise(); - result = OV7670WriteReg(COM16, COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_OFF__AWBGAIN_ON); - sresult = ParseI2CResult(result); - Serial.print(F("COM16: ")); - Serial.println(sresult); - } - else - if ((DenoiseParam == "DenoiseNo")&& - (EdgeParam == "EdgeYes")) - { - SetupCameraEdgeEnhancement(); - result = OV7670WriteReg(COM16, COM16_VALUE_DENOISE_OFF__EDGE_ENHANCEMENT_ON__AWBGAIN_ON); - sresult = ParseI2CResult(result); - Serial.print(F("COM16: ")); - Serial.println(sresult); - } -} + int result = 0; + String sresult = ""; + if ((DenoiseParam == "DenoiseYes") && + (EdgeParam == "EdgeYes")) + { + SetupCameraDenoise(); + SetupCameraEdgeEnhancement(); + result = OV7670WriteReg(COM16, COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_ON__AWBGAIN_ON); + sresult = ParseI2CResult(result); + Serial.print(F("COM16: ")); + Serial.println(sresult); + } + else if ((DenoiseParam == "DenoiseYes") && + (EdgeParam == "EdgeNo")) + { + SetupCameraDenoise(); + result = OV7670WriteReg(COM16, COM16_VALUE_DENOISE_ON__EDGE_ENHANCEMENT_OFF__AWBGAIN_ON); + sresult = ParseI2CResult(result); + Serial.print(F("COM16: ")); + Serial.println(sresult); + } + else if ((DenoiseParam == "DenoiseNo") && + (EdgeParam == "EdgeYes")) + { + SetupCameraEdgeEnhancement(); + result = OV7670WriteReg(COM16, COM16_VALUE_DENOISE_OFF__EDGE_ENHANCEMENT_ON__AWBGAIN_ON); + sresult = ParseI2CResult(result); + Serial.print(F("COM16: ")); + Serial.println(sresult); + } +} /* @@ -1674,9 +1610,9 @@ void SetCameraGamma() { int result = 0; String sresult = ""; - + Serial.println(F("........... Setting Camera Gamma ........")); - + result = OV7670WriteReg(SLOP, SLOP_VALUE); sresult = ParseI2CResult(result); Serial.print(F("SLOP: ")); @@ -1686,72 +1622,72 @@ void SetCameraGamma() sresult = ParseI2CResult(result); Serial.print(F("GAM1: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM2, GAM2_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM2: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM3, GAM3_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM3: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM4, GAM4_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM4: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM5, GAM5_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM5: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM6, GAM6_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM6: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM7, GAM7_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM7: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM8, GAM8_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM8: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM9, GAM9_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM9: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM10, GAM10_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM10: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM11, GAM11_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM11: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM12, GAM12_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM12: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM13, GAM13_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM13: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM14, GAM14_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM14: ")); Serial.println(sresult); - + result = OV7670WriteReg(GAM15, GAM15_VALUE); sresult = ParseI2CResult(result); Serial.print(F("GAM15: ")); @@ -1759,305 +1695,294 @@ void SetCameraGamma() } */ +void SetupCameraArrayControl() +{ + int result = 0; + String sresult = ""; + Serial.println(F("........... Setting Camera Array Control ........")); -void SetupCameraArrayControl() + result = OV7670WriteReg(CHLF, CHLF_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("CHLF: ")); + Serial.println(sresult); + + result = OV7670WriteReg(ARBLM, ARBLM_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("ARBLM: ")); + Serial.println(sresult); +} + +void SetupCameraADCControl() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera Array Control ........")); - - result = OV7670WriteReg(CHLF, CHLF_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("CHLF: ")); - Serial.println(sresult); - - result = OV7670WriteReg(ARBLM, ARBLM_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("ARBLM: ")); - Serial.println(sresult); + int result = 0; + String sresult = ""; + + Serial.println(F("........... Setting Camera ADC Control ........")); + + result = OV7670WriteReg(ADCCTR1, ADCCTR1_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("ADCCTR1: ")); + Serial.println(sresult); + + result = OV7670WriteReg(ADCCTR2, ADCCTR2_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("ADCCTR2: ")); + Serial.println(sresult); + + result = OV7670WriteReg(ADC, ADC_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("ADC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(ACOM, ACOM_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("ACOM: ")); + Serial.println(sresult); + + result = OV7670WriteReg(OFON, OFON_VALUE); + sresult = ParseI2CResult(result); + Serial.print(F("OFON: ")); + Serial.println(sresult); } +void SetupOV7670ForQQVGAYUV() +{ + int result = 0; + String sresult = ""; + + Serial.println(F("--------------------------- Setting Camera for QQVGA YUV ---------------------------")); + PHOTO_WIDTH = 160; + PHOTO_HEIGHT = 120; + PHOTO_BYTES_PER_PIXEL = 2; -void SetupCameraADCControl() + Serial.print(F("Photo Width = ")); + Serial.println(PHOTO_WIDTH); + + Serial.print(F("Photo Height = ")); + Serial.println(PHOTO_HEIGHT); + + Serial.print(F("Bytes Per Pixel = ")); + Serial.println(PHOTO_BYTES_PER_PIXEL); + + Serial.println(F("........... Setting Basic QQVGA Parameters ........")); + + result = OV7670WriteReg(CLKRC, CLKRC_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("CLKRC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM7, COM7_VALUE_QQVGA); + // result = OV7670WriteReg(COM7, COM7_VALUE_QQVGA_COLOR_BAR ); + sresult = ParseI2CResult(result); + Serial.print(F("COM7: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM3, COM3_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("COM3: ")); + Serial.println(sresult); + + result = OV7670WriteReg(COM14, COM14_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("COM14: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_XSC, SCALING_XSC_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_XSC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_YSC, SCALING_YSC_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_YSC: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_DCWCTR, SCALING_DCWCTR_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_DCWCTR: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_PCLK_DIV, SCALING_PCLK_DIV_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_PCLK_DIV: ")); + Serial.println(sresult); + + result = OV7670WriteReg(SCALING_PCLK_DELAY, SCALING_PCLK_DELAY_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("SCALING_PCLK_DELAY: ")); + Serial.println(sresult); + + // YUV order control change from default use with COM13 + result = OV7670WriteReg(TSLB, TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_DISABLED); // Works + sresult = ParseI2CResult(result); + Serial.print(F("TSLB: ")); + Serial.println(sresult); + + // COM13 + // result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YUYV); + // result = OV7670WriteReg(COM13, COM13_VALUE_DEFAULT); + // result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YVYU); + // result = OV7670WriteReg(COM13, COM13_VALUE_NOGAMMA_YUYV); + // result = OV7670WriteReg(COM13, COM13_VALUE_YUYV_UVSATAUTOADJ_ON); + // { REG_COM13, /*0xc3*/0x48 } // error in datasheet bit 3 controls YUV order + // result = OV7670WriteReg(COM13, 0x48); + result = OV7670WriteReg(COM13, 0xC8); // Gamma Enabled, UV Auto Adj On + sresult = ParseI2CResult(result); + Serial.print(F("COM13: ")); + Serial.println(sresult); + + // COM17 - DSP Color Bar Enable/Disable + // 0000 1000 => to Enable + // 0x08 + // COM17_VALUE 0x08 // Activate Color Bar for DSP + // result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_COLOR_BAR); + result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR); + sresult = ParseI2CResult(result); + Serial.print(F("COM17: ")); + Serial.println(sresult); + + // Set Additional Parameters + // Set Camera Frames per second + SetCameraFPSMode(); + + // Set Camera Automatic Exposure Control + SetCameraAEC(); + + // Set Camera Automatic White Balance + SetupCameraAWB(); + + // Setup Undocumented Registers - Needed Minimum + SetupCameraUndocumentedRegisters(); + + // Set Color Matrix for YUV + if (YUVMatrixParam == "YUVMatrixOn") + { + SetCameraColorMatrixYUV(); + } + + // Set Camera Saturation + SetCameraSaturationControl(); + + // Denoise and Edge Enhancement + SetupCameraDenoiseEdgeEnhancement(); + + // Set New Gamma Values + // SetCameraGamma(); + + // Set Array Control + SetupCameraArrayControl(); + + // Set ADC Control + SetupCameraADCControl(); + + // Set Automatic Black Level Calibration + SetupCameraABLC(); + + Serial.println(F("........... Setting Camera Window Output Parameters ........")); + + // Change Window Output parameters after custom scaling + result = OV7670WriteReg(HSTART, HSTART_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("HSTART: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HSTOP, HSTOP_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("HSTOP: ")); + Serial.println(sresult); + + result = OV7670WriteReg(HREF, HREF_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("HREF: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VSTRT, VSTRT_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("VSTRT: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VSTOP, VSTOP_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("VSTOP: ")); + Serial.println(sresult); + + result = OV7670WriteReg(VREF, VREF_VALUE_QQVGA); + sresult = ParseI2CResult(result); + Serial.print(F("VREF: ")); + Serial.println(sresult); +} + +void CaptureOV7670Frame() { - int result = 0; - String sresult = ""; - - Serial.println(F("........... Setting Camera ADC Control ........")); - - result = OV7670WriteReg(ADCCTR1, ADCCTR1_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("ADCCTR1: ")); - Serial.println(sresult); - - result = OV7670WriteReg(ADCCTR2, ADCCTR2_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("ADCCTR2: ")); - Serial.println(sresult); - - result = OV7670WriteReg(ADC, ADC_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("ADC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(ACOM, ACOM_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("ACOM: ")); - Serial.println(sresult); + unsigned long DurationStart = 0; + unsigned long DurationStop = 0; + unsigned long TimeForCaptureStart = 0; + unsigned long TimeForCaptureEnd = 0; + unsigned long ElapsedTime = 0; - result = OV7670WriteReg(OFON, OFON_VALUE); - sresult = ParseI2CResult(result); - Serial.print(F("OFON: ")); - Serial.println(sresult); -} + // Capture one frame into FIFO memory + // 0. Initialization. + Serial.println(); + Serial.println(F("Starting Capture of Photo ...")); + TimeForCaptureStart = millis(); + // 1. Wait for VSync to pulse to indicate the start of the image + DurationStart = pulseIn(VSYNC, LOW); -void SetupOV7670ForQQVGAYUV() -{ - int result = 0; - String sresult = ""; - - Serial.println(F("--------------------------- Setting Camera for QQVGA YUV ---------------------------")); - - PHOTO_WIDTH = 160; - PHOTO_HEIGHT = 120; - PHOTO_BYTES_PER_PIXEL = 2; - - Serial.print(F("Photo Width = ")); - Serial.println(PHOTO_WIDTH); - - Serial.print(F("Photo Height = ")); - Serial.println(PHOTO_HEIGHT); - - Serial.print(F("Bytes Per Pixel = ")); - Serial.println(PHOTO_BYTES_PER_PIXEL); - - - Serial.println(F("........... Setting Basic QQVGA Parameters ........")); - - result = OV7670WriteReg(CLKRC, CLKRC_VALUE_QQVGA); - sresult = ParseI2CResult(result); - Serial.print(F("CLKRC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM7, COM7_VALUE_QQVGA ); - //result = OV7670WriteReg(COM7, COM7_VALUE_QQVGA_COLOR_BAR ); - sresult = ParseI2CResult(result); - Serial.print(F("COM7: ")); - Serial.println(sresult); + // 2. Reset Write Pointer to 0. Which is the beginning of frame + PulseLowEnabledPin(WRST, 6); // 3 microseconds + 3 microseconds for error factor on Arduino - result = OV7670WriteReg(COM3, COM3_VALUE_QQVGA); - sresult = ParseI2CResult(result); - Serial.print(F("COM3: ")); - Serial.println(sresult); - - result = OV7670WriteReg(COM14, COM14_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("COM14: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_XSC,SCALING_XSC_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_XSC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_YSC,SCALING_YSC_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_YSC: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_DCWCTR, SCALING_DCWCTR_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_DCWCTR: ")); - Serial.println(sresult); - - result = OV7670WriteReg(SCALING_PCLK_DIV, SCALING_PCLK_DIV_VALUE_QQVGA); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_PCLK_DIV: ")); - Serial.println (sresult); - - result = OV7670WriteReg(SCALING_PCLK_DELAY,SCALING_PCLK_DELAY_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("SCALING_PCLK_DELAY: ")); - Serial.println(sresult); - - // YUV order control change from default use with COM13 - result = OV7670WriteReg(TSLB, TSLB_VALUE_YUYV_AUTO_OUTPUT_WINDOW_DISABLED); // Works - sresult = ParseI2CResult(result); - Serial.print(F("TSLB: ")); - Serial.println(sresult); - - //COM13 - //result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YUYV); - //result = OV7670WriteReg(COM13, COM13_VALUE_DEFAULT); - //result = OV7670WriteReg(COM13, COM13_VALUE_GAMMA_YVYU); - //result = OV7670WriteReg(COM13, COM13_VALUE_NOGAMMA_YUYV); - //result = OV7670WriteReg(COM13, COM13_VALUE_YUYV_UVSATAUTOADJ_ON); - // { REG_COM13, /*0xc3*/0x48 } // error in datasheet bit 3 controls YUV order - //result = OV7670WriteReg(COM13, 0x48); - result = OV7670WriteReg(COM13, 0xC8); // Gamma Enabled, UV Auto Adj On - sresult = ParseI2CResult(result); - Serial.print(F("COM13: ")); - Serial.println(sresult); - - // COM17 - DSP Color Bar Enable/Disable - // 0000 1000 => to Enable - // 0x08 - // COM17_VALUE 0x08 // Activate Color Bar for DSP - //result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_COLOR_BAR); - result = OV7670WriteReg(COM17, COM17_VALUE_AEC_NORMAL_NO_COLOR_BAR); - sresult = ParseI2CResult(result); - Serial.print(F("COM17: ")); - Serial.println(sresult); - - - // Set Additional Parameters - // Set Camera Frames per second - SetCameraFPSMode(); - - // Set Camera Automatic Exposure Control - SetCameraAEC(); - - // Set Camera Automatic White Balance - SetupCameraAWB(); - - // Setup Undocumented Registers - Needed Minimum - SetupCameraUndocumentedRegisters(); - - - // Set Color Matrix for YUV - if (YUVMatrixParam == "YUVMatrixOn") - { - SetCameraColorMatrixYUV(); - } - - // Set Camera Saturation - SetCameraSaturationControl(); - - // Denoise and Edge Enhancement - SetupCameraDenoiseEdgeEnhancement(); - - // Set New Gamma Values - //SetCameraGamma(); - - // Set Array Control - SetupCameraArrayControl(); - - // Set ADC Control - SetupCameraADCControl(); - - // Set Automatic Black Level Calibration - SetupCameraABLC(); - - - Serial.println(F("........... Setting Camera Window Output Parameters ........")); - - // Change Window Output parameters after custom scaling - result = OV7670WriteReg(HSTART, HSTART_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HSTART: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HSTOP, HSTOP_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HSTOP: ")); - Serial.println(sresult); - - result = OV7670WriteReg(HREF, HREF_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("HREF: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VSTRT, VSTRT_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VSTRT: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VSTOP, VSTOP_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VSTOP: ")); - Serial.println(sresult); - - result = OV7670WriteReg(VREF, VREF_VALUE_QQVGA ); - sresult = ParseI2CResult(result); - Serial.print(F("VREF: ")); - Serial.println(sresult); -} + // 3. Set FIFO Write Enable to active (high) so that image can be written to ram + digitalWrite(WEN, HIGH); -void CaptureOV7670Frame() -{ - unsigned long DurationStart = 0; - unsigned long DurationStop = 0; - unsigned long TimeForCaptureStart = 0; - unsigned long TimeForCaptureEnd = 0; - unsigned long ElapsedTime = 0; - - //Capture one frame into FIFO memory - - // 0. Initialization. - Serial.println(); - Serial.println(F("Starting Capture of Photo ...")); - TimeForCaptureStart = millis(); - - // 1. Wait for VSync to pulse to indicate the start of the image - DurationStart = pulseIn(VSYNC, LOW); - - // 2. Reset Write Pointer to 0. Which is the beginning of frame - PulseLowEnabledPin(WRST, 6); // 3 microseconds + 3 microseconds for error factor on Arduino - - // 3. Set FIFO Write Enable to active (high) so that image can be written to ram - digitalWrite(WEN, HIGH); - - // 4. Wait for VSync to pulse again to indicate the end of the frame capture - DurationStop = pulseIn(VSYNC, LOW); - - // 5. Set FIFO Write Enable to nonactive (low) so that no more images can be written to the ram - digitalWrite(WEN, LOW); - - // 6. Print out Stats - TimeForCaptureEnd = millis(); - ElapsedTime = TimeForCaptureEnd - TimeForCaptureStart; - - Serial.print(F("Time for Frame Capture (milliseconds) = ")); - Serial.println(ElapsedTime); - - Serial.print(F("VSync beginning duration (microseconds) = ")); - Serial.println(DurationStart); - - Serial.print(F("VSync end duration (microseconds) = ")); - Serial.println(DurationStop); - - // 7. WAIT so that new data can appear on output pins Read new data. - delay(2); + // 4. Wait for VSync to pulse again to indicate the end of the frame capture + DurationStop = pulseIn(VSYNC, LOW); + + // 5. Set FIFO Write Enable to nonactive (low) so that no more images can be written to the ram + digitalWrite(WEN, LOW); + + // 6. Print out Stats + TimeForCaptureEnd = millis(); + ElapsedTime = TimeForCaptureEnd - TimeForCaptureStart; + + Serial.print(F("Time for Frame Capture (milliseconds) = ")); + Serial.println(ElapsedTime); + + Serial.print(F("VSync beginning duration (microseconds) = ")); + Serial.println(DurationStart); + + Serial.print(F("VSync end duration (microseconds) = ")); + Serial.println(DurationStop); + + // 7. WAIT so that new data can appear on output pins Read new data. + delay(2); } String CreatePhotoFilename() { String Filename = ""; String Ext = ""; - + // Creates filename that the photo will be saved under - + // Create file extension // If Command = QQVGA or QVGA then extension is .yuv if ((Command == "QQVGA") || (Command == "QVGA")) { - Ext = ".yuv"; + Ext = ".yuv"; } - else - if ((Command == "VGA") || (Command == "VGAP")) + else if ((Command == "VGA") || (Command == "VGAP")) { - Ext = ".raw"; + Ext = ".raw"; } - + // Create Filename from // Resolution + PhotoNumber + Extension - Filename = Command + PhotoTakenCount + Ext; - + Filename = Command + PhotoTakenCount + Ext; + return Filename; } @@ -2065,59 +1990,59 @@ String CreatePhotoInfoFilename() { String Filename = ""; String Ext = ""; - - // Creates filename that the information about the photo will - // be saved under. - + + // Creates filename that the information about the photo will + // be saved under. + // Create file extension Ext = ".txt"; - + // Create Filename from // Resolution + PhotoNumber + Extension - Filename = Command + PhotoTakenCount + Ext; - + Filename = Command + PhotoTakenCount + Ext; + return Filename; } String CreatePhotoInfo() { String Info = ""; - - Info = Command + " " + FPSParam + " " + AWBParam + " " + AECParam + " " + YUVMatrixParam + " " + + + Info = Command + " " + FPSParam + " " + AWBParam + " " + AECParam + " " + YUVMatrixParam + " " + DenoiseParam + " " + EdgeParam + " " + ABLCParam; - + return Info; } void CreatePhotoInfoFile() { - // Creates the photo information file based on current settings - - // .txt information File for Photo - File InfoFile; - - // Create name of Photo To save based on certain parameters - String Filename = CreatePhotoInfoFilename(); - - // Check if file already exists and remove it if it does. - CheckRemoveFile(Filename); - - // Open File - InfoFile = SD.open(Filename.c_str(), FILE_WRITE); - - // Test if file actually open - if (!InfoFile) - { - Serial.println(F("\nCritical ERROR ... Can not open Photo Info File for output ... ")); - return; - } - - // Write Info to file - String Data = CreatePhotoInfo(); - InfoFile.println(Data); - - // Close SD Card File - InfoFile.close(); + // Creates the photo information file based on current settings + + // .txt information File for Photo + File InfoFile; + + // Create name of Photo To save based on certain parameters + String Filename = CreatePhotoInfoFilename(); + + // Check if file already exists and remove it if it does. + CheckRemoveFile(Filename); + + // Open File + InfoFile = SD.open(Filename.c_str(), FILE_WRITE); + + // Test if file actually open + if (!InfoFile) + { + Serial.println(F("\nCritical ERROR ... Can not open Photo Info File for output ... ")); + return; + } + + // Write Info to file + String Data = CreatePhotoInfo(); + InfoFile.println(Data); + + // Close SD Card File + InfoFile.close(); } // Converts pin HIGH/LOW values on pins at positions 0-7 to a corresponding byte value @@ -2128,123 +2053,122 @@ byte ConvertPinValueToByteValue(int PinValue, int PinPosition) { ByteValue = 1 << PinPosition; } - + return ByteValue; } void ReadTransmitCapturedFrame() { - // Read captured frame from FIFO memory and send each byte as it is read to the Android controller - // via bluetooth. - - // Set Output Enable OE to active (low). - // * Make sure to connect the OE output to ground. - - // Reset the FIFO read pointer by setting RRST to active (low) then bringing it back to high. - // *Done from previous CaptureOV7670Frame() assuming WRST and RRST are tied together. - - // Read in the QQVGA image that is captured in the camera buffer by reading in the 38400 bytes that make up the - // YUV photo - - byte PixelData = 0; - byte PinVal7 = 0; - byte PinVal6 = 0; - byte PinVal5 = 0; - byte PinVal4 = 0; - byte PinVal3 = 0; - byte PinVal2 = 0; - byte PinVal1 = 0; - byte PinVal0 = 0; - - Serial.println(F("Starting Transmission of Photo To SDCard ...")); - - - //////////////////// Code for SD Card ///////////////////////////////// - - // Image file to write to - File ImageOutputFile; - - // Create name of Photo To save based on certain parameters - String Filename = CreatePhotoFilename(); - - // Check if file already exists and remove it if it does. - CheckRemoveFile(Filename); - - ImageOutputFile = SD.open(Filename.c_str(), FILE_WRITE); - - // Test if file actually open - if (!ImageOutputFile) - { - Serial.println(F("\nCritical ERROR ... Can not open Image Ouput File for output ... ")); - return; - } - //////////////////////////////////////////////////////////////////////// - - // Set Read Buffer Pointer to start of frame - digitalWrite(RRST, LOW); - PulsePin(RCLK, 1); - PulsePin(RCLK, 1); - PulsePin(RCLK, 1); - digitalWrite(RRST, HIGH); - - unsigned long ByteCounter = 0; - for (int height = 0; height < PHOTO_HEIGHT; height++) - { - for (int width = 0; width < PHOTO_WIDTH; width++) - { - for (int bytenumber = 0; bytenumber < PHOTO_BYTES_PER_PIXEL; bytenumber++) - { - // Pulse the read clock RCLK to bring in new byte of data. - // 7ns for RCLK High Pulse Width and Low Pulse Width .007 micro secs - PulsePin(RCLK, 1); - - // Convert Pin values to byte values for pins 0-7 of incoming pixel byte - PinVal7 = ConvertPinValueToByteValue(digitalRead(DO7), 7); - PinVal6 = ConvertPinValueToByteValue(digitalRead(DO6), 6); - PinVal5 = ConvertPinValueToByteValue(digitalRead(DO5), 5); - PinVal4 = ConvertPinValueToByteValue(digitalRead(DO4), 4); - PinVal3 = ConvertPinValueToByteValue(digitalRead(DO3), 3); - PinVal2 = ConvertPinValueToByteValue(digitalRead(DO2), 2); - PinVal1 = ConvertPinValueToByteValue(digitalRead(DO1), 1); - PinVal0 = ConvertPinValueToByteValue(digitalRead(DO0), 0); - - // Combine individual data from each pin into composite data in the form of a single byte - PixelData = PinVal7 | PinVal6 | PinVal5 | PinVal4 | PinVal3 | PinVal2 | PinVal1 | PinVal0; - - ///////////////////////////// SD Card //////////////////////////////// - ByteCounter = ByteCounter + ImageOutputFile.write(PixelData); - /////////////////////////////////////////////////////////////////////// - } - } - } - - // Close SD Card File - ImageOutputFile.close(); - - Serial.print(F("Total Bytes Saved to SDCard = ")); - Serial.println(ByteCounter); - - // Write Photo's Info File to SDCard. - Serial.println(F("Writing Photo's Info file (.txt file) to SD Card ...")); - CreatePhotoInfoFile(); + // Read captured frame from FIFO memory and send each byte as it is read to the Android controller + // via bluetooth. + + // Set Output Enable OE to active (low). + // * Make sure to connect the OE output to ground. + + // Reset the FIFO read pointer by setting RRST to active (low) then bringing it back to high. + // *Done from previous CaptureOV7670Frame() assuming WRST and RRST are tied together. + + // Read in the QQVGA image that is captured in the camera buffer by reading in the 38400 bytes that make up the + // YUV photo + + byte PixelData = 0; + byte PinVal7 = 0; + byte PinVal6 = 0; + byte PinVal5 = 0; + byte PinVal4 = 0; + byte PinVal3 = 0; + byte PinVal2 = 0; + byte PinVal1 = 0; + byte PinVal0 = 0; + + Serial.println(F("Starting Transmission of Photo To SDCard ...")); + + //////////////////// Code for SD Card ///////////////////////////////// + + // Image file to write to + File ImageOutputFile; + + // Create name of Photo To save based on certain parameters + String Filename = CreatePhotoFilename(); + + // Check if file already exists and remove it if it does. + CheckRemoveFile(Filename); + + ImageOutputFile = SD.open(Filename.c_str(), FILE_WRITE); + + // Test if file actually open + if (!ImageOutputFile) + { + Serial.println(F("\nCritical ERROR ... Can not open Image Ouput File for output ... ")); + return; + } + //////////////////////////////////////////////////////////////////////// + + // Set Read Buffer Pointer to start of frame + digitalWrite(RRST, LOW); + PulsePin(RCLK, 1); + PulsePin(RCLK, 1); + PulsePin(RCLK, 1); + digitalWrite(RRST, HIGH); + + unsigned long ByteCounter = 0; + for (int height = 0; height < PHOTO_HEIGHT; height++) + { + for (int width = 0; width < PHOTO_WIDTH; width++) + { + for (int bytenumber = 0; bytenumber < PHOTO_BYTES_PER_PIXEL; bytenumber++) + { + // Pulse the read clock RCLK to bring in new byte of data. + // 7ns for RCLK High Pulse Width and Low Pulse Width .007 micro secs + PulsePin(RCLK, 1); + + // Convert Pin values to byte values for pins 0-7 of incoming pixel byte + PinVal7 = ConvertPinValueToByteValue(digitalRead(DO7), 7); + PinVal6 = ConvertPinValueToByteValue(digitalRead(DO6), 6); + PinVal5 = ConvertPinValueToByteValue(digitalRead(DO5), 5); + PinVal4 = ConvertPinValueToByteValue(digitalRead(DO4), 4); + PinVal3 = ConvertPinValueToByteValue(digitalRead(DO3), 3); + PinVal2 = ConvertPinValueToByteValue(digitalRead(DO2), 2); + PinVal1 = ConvertPinValueToByteValue(digitalRead(DO1), 1); + PinVal0 = ConvertPinValueToByteValue(digitalRead(DO0), 0); + + // Combine individual data from each pin into composite data in the form of a single byte + PixelData = PinVal7 | PinVal6 | PinVal5 | PinVal4 | PinVal3 | PinVal2 | PinVal1 | PinVal0; + + ///////////////////////////// SD Card //////////////////////////////// + ByteCounter = ByteCounter + ImageOutputFile.write(PixelData); + /////////////////////////////////////////////////////////////////////// + } + } + } + + // Close SD Card File + ImageOutputFile.close(); + + Serial.print(F("Total Bytes Saved to SDCard = ")); + Serial.println(ByteCounter); + + // Write Photo's Info File to SDCard. + Serial.println(F("Writing Photo's Info file (.txt file) to SD Card ...")); + CreatePhotoInfoFile(); } void TakePhoto() { - // Take Photo using the ov7670 camera and transmit the image to the Android controller via + // Take Photo using the ov7670 camera and transmit the image to the Android controller via // Bluetooth - unsigned long StartTime = 0; - unsigned long EndTime = 0; + unsigned long StartTime = 0; + unsigned long EndTime = 0; unsigned long ElapsedTime = 0; - + StartTime = millis(); - - CaptureOV7670Frame(); + + CaptureOV7670Frame(); ReadTransmitCapturedFrame(); - - EndTime = millis(); - ElapsedTime = (EndTime - StartTime)/1000; // Convert to seconds - + + EndTime = millis(); + ElapsedTime = (EndTime - StartTime) / 1000; // Convert to seconds + Serial.print(F("Elapsed Time for Taking and Sending Photo(secs) = ")); Serial.println(ElapsedTime); } @@ -2252,64 +2176,63 @@ void TakePhoto() void PulseLowEnabledPin(int PinNumber, int DurationMicroSecs) { // For Low Enabled Pins , 0 = on and 1 = off - digitalWrite(PinNumber, LOW); // Sets the pin on - delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds - - digitalWrite(PinNumber, HIGH); // Sets the pin off - delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds + digitalWrite(PinNumber, LOW); // Sets the pin on + delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds + + digitalWrite(PinNumber, HIGH); // Sets the pin off + delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds } void PulsePin(int PinNumber, int DurationMicroSecs) { - digitalWrite(PinNumber, HIGH); // Sets the pin on - delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds - - digitalWrite(PinNumber, LOW); // Sets the pin off - delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds + digitalWrite(PinNumber, HIGH); // Sets the pin on + delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds + + digitalWrite(PinNumber, LOW); // Sets the pin off + delayMicroseconds(DurationMicroSecs); // Pauses for DurationMicroSecs microseconds } String ParseI2CResult(int result) { String sresult = ""; - switch(result) + switch (result) { - case 0: - sresult = "I2C Operation OK ..."; + case 0: + sresult = "I2C Operation OK ..."; + break; + + case I2C_ERROR_WRITING_START_ADDRESS: + sresult = "I2C_ERROR_WRITING_START_ADDRESS"; break; - - case I2C_ERROR_WRITING_START_ADDRESS: - sresult = "I2C_ERROR_WRITING_START_ADDRESS"; + + case I2C_ERROR_WRITING_DATA: + sresult = "I2C_ERROR_WRITING_DATA"; break; - - case I2C_ERROR_WRITING_DATA: - sresult = "I2C_ERROR_WRITING_DATA"; + + case DATA_TOO_LONG: + sresult = "DATA_TOO_LONG"; break; - - case DATA_TOO_LONG: - sresult = "DATA_TOO_LONG"; - break; - - case NACK_ON_TRANSMIT_OF_ADDRESS: - sresult = "NACK_ON_TRANSMIT_OF_ADDRESS"; + + case NACK_ON_TRANSMIT_OF_ADDRESS: + sresult = "NACK_ON_TRANSMIT_OF_ADDRESS"; break; - - case NACK_ON_TRANSMIT_OF_DATA: - sresult = "NACK_ON_TRANSMIT_OF_DATA"; + + case NACK_ON_TRANSMIT_OF_DATA: + sresult = "NACK_ON_TRANSMIT_OF_DATA"; break; - - case OTHER_ERROR: - sresult = "OTHER_ERROR"; + + case OTHER_ERROR: + sresult = "OTHER_ERROR"; break; - - default: - sresult = "I2C ERROR TYPE NOT FOUND..."; + + default: + sresult = "I2C ERROR TYPE NOT FOUND..."; break; } - + return sresult; } - // Parameters: // start : Start address, use a define for the register // pData : A pointer to the data to write. @@ -2320,27 +2243,26 @@ int OV7670Write(int start, const byte *pData, int size) int n, error; Wire.beginTransmission(OV7670_I2C_ADDRESS); - n = Wire.write(start); // write the start address + n = Wire.write(start); // write the start address if (n != 1) { return (I2C_ERROR_WRITING_START_ADDRESS); } - - n = Wire.write(pData, size); // write data bytes + + n = Wire.write(pData, size); // write data bytes if (n != size) { return (I2C_ERROR_WRITING_DATA); } - + error = Wire.endTransmission(true); // release the I2C-bus if (error != 0) { return (error); } - - return 0; // return : no error -} + return 0; // return : no error +} // // A function to write a single register @@ -2355,11 +2277,11 @@ int OV7670WriteReg(int reg, byte data) } // -// This is a common function to read multiple bytes +// This is a common function to read multiple bytes // from an I2C device. // // It uses the boolean parameter for Wire.endTransMission() -// to be able to hold or release the I2C-bus. +// to be able to hold or release the I2C-bus. // This is implemented in Arduino 1.0.1. // int OV7670Read(int start, byte *buffer, int size) @@ -2372,26 +2294,26 @@ int OV7670Read(int start, byte *buffer, int size) { return (I2C_READ_START_ADDRESS_ERROR); } - - n = Wire.endTransmission(false); // hold the I2C-bus + + n = Wire.endTransmission(false); // hold the I2C-bus if (n != 0) { return (n); } - + // Third parameter is true: relase I2C-bus after data is read. Wire.requestFrom(OV7670_I2C_ADDRESS, size, true); i = 0; - while(Wire.available() && i ")); - while (1) - { - if (Serial.available() > 0) - { - int NumberCharsRead = Serial.readBytesUntil('\n', IncomingByte, BUFFERLENGTH); - for (int i = 0; i < NumberCharsRead; i++) - { - RawCommandLine += IncomingByte[i]; - } - break; - } - } - - // Print out the command from Android - Serial.print(F("Raw Command from Serial Monitor: ")); - Serial.println(RawCommandLine); - - if ((RawCommandLine == "h")|| - (RawCommandLine == "help")) - { - DisplayHelpMenu(); - } - else - if (RawCommandLine == "help camera") - { - DisplayHelpCommandsParams(); - } - else - if (RawCommandLine == "d") - { - DisplayCurrentCommand(); - } - else - if (RawCommandLine == "t") - { - // Take Photo - Serial.println(F("\nGoing to take photo with current command:")); - DisplayCurrentCommand(); - - // Take Photo - ExecuteCommand(Command); - Serial.println(F("Photo Taken and Saved to Arduino SD CARD ...")); - - String Testfile = CreatePhotoFilename(); - Serial.print(F("Image Output Filename :")); - Serial.println(Testfile); - PhotoTakenCount++; - - } - else - if (RawCommandLine == "testread") - { - ReadPrintFile("TEST.TXT"); - } - else - if (RawCommandLine == "testwrite") - { - CheckRemoveFile("TEST.TXT"); - WriteFileTest("TEST.TXT"); - } - else - { - Serial.println(F("Changing command or parameters according to your input:")); - // Parse Command Line and Set Command Line Elements - // Parse Raw Command into Command and Parameters - ParseRawCommand(RawCommandLine); - - // Display new changed camera command with parameters - DisplayCurrentCommand(); - } - - // Reset Command Line - RawCommandLine = ""; - - Serial.println(); - Serial.println(); + // If file still exists then new image file cannot be saved to SD Card. + if (SD.exists(tempchar)) + { + Serial.println(F("Error.. Image output file cannot be created...")); + return; + } } +void loop() +{ + // Wait for Command + Serial.println(F("Ready to Accept new Command => ")); + while (1) + { + if (Serial.available() > 0) + { + int NumberCharsRead = Serial.readBytesUntil('\n', IncomingByte, BUFFERLENGTH); + for (int i = 0; i < NumberCharsRead; i++) + { + RawCommandLine += IncomingByte[i]; + } + break; + } + } + + // Print out the command from Android + Serial.print(F("Raw Command from Serial Monitor: ")); + Serial.println(RawCommandLine); + + if ((RawCommandLine == "h") || + (RawCommandLine == "help")) + { + DisplayHelpMenu(); + } + else if (RawCommandLine == "help camera") + { + DisplayHelpCommandsParams(); + } + else if (RawCommandLine == "d") + { + DisplayCurrentCommand(); + } + else if (RawCommandLine == "t") + { + // Take Photo + Serial.println(F("\nGoing to take photo with current command:")); + DisplayCurrentCommand(); + + // Take Photo + ExecuteCommand(Command); + Serial.println(F("Photo Taken and Saved to Arduino SD CARD ...")); + + String Testfile = CreatePhotoFilename(); + Serial.print(F("Image Output Filename :")); + Serial.println(Testfile); + PhotoTakenCount++; + } + else if (RawCommandLine == "testread") + { + ReadPrintFile("TEST.TXT"); + } + else if (RawCommandLine == "testwrite") + { + CheckRemoveFile("TEST.TXT"); + WriteFileTest("TEST.TXT"); + } + else + { + Serial.println(F("Changing command or parameters according to your input:")); + // Parse Command Line and Set Command Line Elements + // Parse Raw Command into Command and Parameters + ParseRawCommand(RawCommandLine); + + // Display new changed camera command with parameters + DisplayCurrentCommand(); + } + + // Reset Command Line + RawCommandLine = ""; + + Serial.println(); + Serial.println(); +} -int ParseCommand(const char* commandline, char splitcharacter, String* Result) -{ +int ParseCommand(const char *commandline, char splitcharacter, String *Result) +{ int ResultIndex = 0; int length = strlen(commandline); String temp = ""; - - for (int i = 0; i < length ; i++) - { - char tempchar = commandline[i]; - if (tempchar == splitcharacter) - { - Result[ResultIndex] += temp; - ResultIndex++; - temp = ""; - } - else - { - temp += tempchar; - } - } - + + for (int i = 0; i < length; i++) + { + char tempchar = commandline[i]; + if (tempchar == splitcharacter) + { + Result[ResultIndex] += temp; + ResultIndex++; + temp = ""; + } + else + { + temp += tempchar; + } + } + // Put in end part of string Result[ResultIndex] = temp; - + return (ResultIndex + 1); } - diff --git a/UTFT4ArduCAM_SPI/DefaultFonts_SPI.c b/UTFT4ArduCAM_SPI/DefaultFonts_SPI.c index b0e3e220..e005bfaa 100644 --- a/UTFT4ArduCAM_SPI/DefaultFonts_SPI.c +++ b/UTFT4ArduCAM_SPI/DefaultFonts_SPI.c @@ -3,244 +3,244 @@ // ------------------------------------------------------------------------------------------------ #if defined(__AVR__) - #include - #define fontdatatype const uint8_t +#include +#define fontdatatype const uint8_t #elif defined(__PIC32MX__) - #define PROGMEM - #define fontdatatype const unsigned char -#elif defined(__arm__) || defined(ESP8266)|| defined(__CPU_ARC__) - #define PROGMEM - #define fontdatatype const unsigned char +#define PROGMEM +#define fontdatatype const unsigned char +#elif defined(__arm__) || defined(ESP8266) || defined(__CPU_ARC__) +#define PROGMEM +#define fontdatatype const unsigned char #endif -// SmallFont.c +// SmallFont.c // Font Size : 8x12 // Memory usage : 1144 bytes // # characters : 95 -fontdatatype SmallFont[1144] PROGMEM={ -0x08,0x0C,0x20,0x5F, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -0x00,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x00,0x20,0x00,0x00, // ! -0x00,0x28,0x50,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // " -0x00,0x00,0x28,0x28,0xFC,0x28,0x50,0xFC,0x50,0x50,0x00,0x00, // # -0x00,0x20,0x78,0xA8,0xA0,0x60,0x30,0x28,0xA8,0xF0,0x20,0x00, // $ -0x00,0x00,0x48,0xA8,0xB0,0x50,0x28,0x34,0x54,0x48,0x00,0x00, // % -0x00,0x00,0x20,0x50,0x50,0x78,0xA8,0xA8,0x90,0x6C,0x00,0x00, // & -0x00,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ' -0x00,0x04,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x04,0x00, // ( -0x00,0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x10,0x20,0x40,0x00, // ) -0x00,0x00,0x00,0x20,0xA8,0x70,0x70,0xA8,0x20,0x00,0x00,0x00, // * -0x00,0x00,0x20,0x20,0x20,0xF8,0x20,0x20,0x20,0x00,0x00,0x00, // + -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x40,0x80, // , -0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00, // - -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,0x00, // . -0x00,0x08,0x10,0x10,0x10,0x20,0x20,0x40,0x40,0x40,0x80,0x00, // / -0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00, // 0 -0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, // 1 -0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,0x00,0x00, // 2 -0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00,0x00, // 3 -0x00,0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,0x00,0x00, // 4 -0x00,0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0x88,0x70,0x00,0x00, // 5 -0x00,0x00,0x70,0x90,0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00, // 6 -0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,0x00,0x00, // 7 -0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00, // 8 -0x00,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,0x00,0x00, // 9 -0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x20,0x00,0x00, // : -0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x20,0x20,0x00, // ; -0x00,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x00,0x00, // < -0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0xF8,0x00,0x00,0x00,0x00, // = -0x00,0x40,0x20,0x10,0x08,0x04,0x08,0x10,0x20,0x40,0x00,0x00, // > -0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x20,0x00,0x20,0x00,0x00, // ? -0x00,0x00,0x70,0x88,0x98,0xA8,0xA8,0xB8,0x80,0x78,0x00,0x00, // @ -0x00,0x00,0x20,0x20,0x30,0x50,0x50,0x78,0x48,0xCC,0x00,0x00, // A -0x00,0x00,0xF0,0x48,0x48,0x70,0x48,0x48,0x48,0xF0,0x00,0x00, // B -0x00,0x00,0x78,0x88,0x80,0x80,0x80,0x80,0x88,0x70,0x00,0x00, // C -0x00,0x00,0xF0,0x48,0x48,0x48,0x48,0x48,0x48,0xF0,0x00,0x00, // D -0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x48,0xF8,0x00,0x00, // E -0x00,0x00,0xF8,0x48,0x50,0x70,0x50,0x40,0x40,0xE0,0x00,0x00, // F -0x00,0x00,0x38,0x48,0x80,0x80,0x9C,0x88,0x48,0x30,0x00,0x00, // G -0x00,0x00,0xCC,0x48,0x48,0x78,0x48,0x48,0x48,0xCC,0x00,0x00, // H -0x00,0x00,0xF8,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00, // I -0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x90,0xE0,0x00, // J -0x00,0x00,0xEC,0x48,0x50,0x60,0x50,0x50,0x48,0xEC,0x00,0x00, // K -0x00,0x00,0xE0,0x40,0x40,0x40,0x40,0x40,0x44,0xFC,0x00,0x00, // L -0x00,0x00,0xD8,0xD8,0xD8,0xD8,0xA8,0xA8,0xA8,0xA8,0x00,0x00, // M -0x00,0x00,0xDC,0x48,0x68,0x68,0x58,0x58,0x48,0xE8,0x00,0x00, // N -0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00, // O -0x00,0x00,0xF0,0x48,0x48,0x70,0x40,0x40,0x40,0xE0,0x00,0x00, // P -0x00,0x00,0x70,0x88,0x88,0x88,0x88,0xE8,0x98,0x70,0x18,0x00, // Q -0x00,0x00,0xF0,0x48,0x48,0x70,0x50,0x48,0x48,0xEC,0x00,0x00, // R -0x00,0x00,0x78,0x88,0x80,0x60,0x10,0x08,0x88,0xF0,0x00,0x00, // S -0x00,0x00,0xF8,0xA8,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00, // T -0x00,0x00,0xCC,0x48,0x48,0x48,0x48,0x48,0x48,0x30,0x00,0x00, // U -0x00,0x00,0xCC,0x48,0x48,0x50,0x50,0x30,0x20,0x20,0x00,0x00, // V -0x00,0x00,0xA8,0xA8,0xA8,0x70,0x50,0x50,0x50,0x50,0x00,0x00, // W -0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x50,0x50,0xD8,0x00,0x00, // X -0x00,0x00,0xD8,0x50,0x50,0x20,0x20,0x20,0x20,0x70,0x00,0x00, // Y -0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x40,0x48,0xF8,0x00,0x00, // Z -0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x00, // [ -0x00,0x40,0x40,0x40,0x20,0x20,0x10,0x10,0x10,0x08,0x00,0x00, // -0x00,0x70,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x70,0x00, // ] -0x00,0x20,0x50,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^ -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFC, // _ -0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ' -0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x38,0x48,0x3C,0x00,0x00, // a -0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0x70,0x00,0x00, // b -0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x40,0x40,0x38,0x00,0x00, // c -0x00,0x00,0x18,0x08,0x08,0x38,0x48,0x48,0x48,0x3C,0x00,0x00, // d -0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x78,0x40,0x38,0x00,0x00, // e -0x00,0x00,0x1C,0x20,0x20,0x78,0x20,0x20,0x20,0x78,0x00,0x00, // f -0x00,0x00,0x00,0x00,0x00,0x3C,0x48,0x30,0x40,0x78,0x44,0x38, // g -0x00,0x00,0xC0,0x40,0x40,0x70,0x48,0x48,0x48,0xEC,0x00,0x00, // h -0x00,0x00,0x20,0x00,0x00,0x60,0x20,0x20,0x20,0x70,0x00,0x00, // i -0x00,0x00,0x10,0x00,0x00,0x30,0x10,0x10,0x10,0x10,0x10,0xE0, // j -0x00,0x00,0xC0,0x40,0x40,0x5C,0x50,0x70,0x48,0xEC,0x00,0x00, // k -0x00,0x00,0xE0,0x20,0x20,0x20,0x20,0x20,0x20,0xF8,0x00,0x00, // l -0x00,0x00,0x00,0x00,0x00,0xF0,0xA8,0xA8,0xA8,0xA8,0x00,0x00, // m -0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0xEC,0x00,0x00, // n -0x00,0x00,0x00,0x00,0x00,0x30,0x48,0x48,0x48,0x30,0x00,0x00, // o -0x00,0x00,0x00,0x00,0x00,0xF0,0x48,0x48,0x48,0x70,0x40,0xE0, // p -0x00,0x00,0x00,0x00,0x00,0x38,0x48,0x48,0x48,0x38,0x08,0x1C, // q -0x00,0x00,0x00,0x00,0x00,0xD8,0x60,0x40,0x40,0xE0,0x00,0x00, // r -0x00,0x00,0x00,0x00,0x00,0x78,0x40,0x30,0x08,0x78,0x00,0x00, // s -0x00,0x00,0x00,0x20,0x20,0x70,0x20,0x20,0x20,0x18,0x00,0x00, // t -0x00,0x00,0x00,0x00,0x00,0xD8,0x48,0x48,0x48,0x3C,0x00,0x00, // u -0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x00,0x00, // v -0x00,0x00,0x00,0x00,0x00,0xA8,0xA8,0x70,0x50,0x50,0x00,0x00, // w -0x00,0x00,0x00,0x00,0x00,0xD8,0x50,0x20,0x50,0xD8,0x00,0x00, // x -0x00,0x00,0x00,0x00,0x00,0xEC,0x48,0x50,0x30,0x20,0x20,0xC0, // y -0x00,0x00,0x00,0x00,0x00,0x78,0x10,0x20,0x20,0x78,0x00,0x00, // z -0x00,0x18,0x10,0x10,0x10,0x20,0x10,0x10,0x10,0x10,0x18,0x00, // { -0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10, // | -0x00,0x60,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x60,0x00, // } -0x40,0xA4,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ~ -}; +fontdatatype SmallFont[1144] PROGMEM = { + 0x08, 0x0C, 0x20, 0x5F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, // ! + 0x00, 0x28, 0x50, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " + 0x00, 0x00, 0x28, 0x28, 0xFC, 0x28, 0x50, 0xFC, 0x50, 0x50, 0x00, 0x00, // # + 0x00, 0x20, 0x78, 0xA8, 0xA0, 0x60, 0x30, 0x28, 0xA8, 0xF0, 0x20, 0x00, // $ + 0x00, 0x00, 0x48, 0xA8, 0xB0, 0x50, 0x28, 0x34, 0x54, 0x48, 0x00, 0x00, // % + 0x00, 0x00, 0x20, 0x50, 0x50, 0x78, 0xA8, 0xA8, 0x90, 0x6C, 0x00, 0x00, // & + 0x00, 0x40, 0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' + 0x00, 0x04, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, // ( + 0x00, 0x40, 0x20, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x20, 0x40, 0x00, // ) + 0x00, 0x00, 0x00, 0x20, 0xA8, 0x70, 0x70, 0xA8, 0x20, 0x00, 0x00, 0x00, // * + 0x00, 0x00, 0x20, 0x20, 0x20, 0xF8, 0x20, 0x20, 0x20, 0x00, 0x00, 0x00, // + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x80, // , + 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, // . + 0x00, 0x08, 0x10, 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x40, 0x80, 0x00, // / + 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, // 0 + 0x00, 0x00, 0x20, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00, // 1 + 0x00, 0x00, 0x70, 0x88, 0x88, 0x10, 0x20, 0x40, 0x80, 0xF8, 0x00, 0x00, // 2 + 0x00, 0x00, 0x70, 0x88, 0x08, 0x30, 0x08, 0x08, 0x88, 0x70, 0x00, 0x00, // 3 + 0x00, 0x00, 0x10, 0x30, 0x50, 0x50, 0x90, 0x78, 0x10, 0x18, 0x00, 0x00, // 4 + 0x00, 0x00, 0xF8, 0x80, 0x80, 0xF0, 0x08, 0x08, 0x88, 0x70, 0x00, 0x00, // 5 + 0x00, 0x00, 0x70, 0x90, 0x80, 0xF0, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, // 6 + 0x00, 0x00, 0xF8, 0x90, 0x10, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, // 7 + 0x00, 0x00, 0x70, 0x88, 0x88, 0x70, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, // 8 + 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x78, 0x08, 0x48, 0x70, 0x00, 0x00, // 9 + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, // : + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, // ; + 0x00, 0x04, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x04, 0x00, 0x00, // < + 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x00, 0xF8, 0x00, 0x00, 0x00, 0x00, // = + 0x00, 0x40, 0x20, 0x10, 0x08, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, 0x00, // > + 0x00, 0x00, 0x70, 0x88, 0x88, 0x10, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, // ? + 0x00, 0x00, 0x70, 0x88, 0x98, 0xA8, 0xA8, 0xB8, 0x80, 0x78, 0x00, 0x00, // @ + 0x00, 0x00, 0x20, 0x20, 0x30, 0x50, 0x50, 0x78, 0x48, 0xCC, 0x00, 0x00, // A + 0x00, 0x00, 0xF0, 0x48, 0x48, 0x70, 0x48, 0x48, 0x48, 0xF0, 0x00, 0x00, // B + 0x00, 0x00, 0x78, 0x88, 0x80, 0x80, 0x80, 0x80, 0x88, 0x70, 0x00, 0x00, // C + 0x00, 0x00, 0xF0, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0xF0, 0x00, 0x00, // D + 0x00, 0x00, 0xF8, 0x48, 0x50, 0x70, 0x50, 0x40, 0x48, 0xF8, 0x00, 0x00, // E + 0x00, 0x00, 0xF8, 0x48, 0x50, 0x70, 0x50, 0x40, 0x40, 0xE0, 0x00, 0x00, // F + 0x00, 0x00, 0x38, 0x48, 0x80, 0x80, 0x9C, 0x88, 0x48, 0x30, 0x00, 0x00, // G + 0x00, 0x00, 0xCC, 0x48, 0x48, 0x78, 0x48, 0x48, 0x48, 0xCC, 0x00, 0x00, // H + 0x00, 0x00, 0xF8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xF8, 0x00, 0x00, // I + 0x00, 0x00, 0x7C, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x90, 0xE0, 0x00, // J + 0x00, 0x00, 0xEC, 0x48, 0x50, 0x60, 0x50, 0x50, 0x48, 0xEC, 0x00, 0x00, // K + 0x00, 0x00, 0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x44, 0xFC, 0x00, 0x00, // L + 0x00, 0x00, 0xD8, 0xD8, 0xD8, 0xD8, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, // M + 0x00, 0x00, 0xDC, 0x48, 0x68, 0x68, 0x58, 0x58, 0x48, 0xE8, 0x00, 0x00, // N + 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x70, 0x00, 0x00, // O + 0x00, 0x00, 0xF0, 0x48, 0x48, 0x70, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00, // P + 0x00, 0x00, 0x70, 0x88, 0x88, 0x88, 0x88, 0xE8, 0x98, 0x70, 0x18, 0x00, // Q + 0x00, 0x00, 0xF0, 0x48, 0x48, 0x70, 0x50, 0x48, 0x48, 0xEC, 0x00, 0x00, // R + 0x00, 0x00, 0x78, 0x88, 0x80, 0x60, 0x10, 0x08, 0x88, 0xF0, 0x00, 0x00, // S + 0x00, 0x00, 0xF8, 0xA8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00, // T + 0x00, 0x00, 0xCC, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x30, 0x00, 0x00, // U + 0x00, 0x00, 0xCC, 0x48, 0x48, 0x50, 0x50, 0x30, 0x20, 0x20, 0x00, 0x00, // V + 0x00, 0x00, 0xA8, 0xA8, 0xA8, 0x70, 0x50, 0x50, 0x50, 0x50, 0x00, 0x00, // W + 0x00, 0x00, 0xD8, 0x50, 0x50, 0x20, 0x20, 0x50, 0x50, 0xD8, 0x00, 0x00, // X + 0x00, 0x00, 0xD8, 0x50, 0x50, 0x20, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00, // Y + 0x00, 0x00, 0xF8, 0x90, 0x10, 0x20, 0x20, 0x40, 0x48, 0xF8, 0x00, 0x00, // Z + 0x00, 0x38, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x38, 0x00, // [ + 0x00, 0x40, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x10, 0x08, 0x00, 0x00, // + 0x00, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x70, 0x00, // ] + 0x00, 0x20, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC, // _ + 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x48, 0x38, 0x48, 0x3C, 0x00, 0x00, // a + 0x00, 0x00, 0xC0, 0x40, 0x40, 0x70, 0x48, 0x48, 0x48, 0x70, 0x00, 0x00, // b + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x48, 0x40, 0x40, 0x38, 0x00, 0x00, // c + 0x00, 0x00, 0x18, 0x08, 0x08, 0x38, 0x48, 0x48, 0x48, 0x3C, 0x00, 0x00, // d + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x48, 0x78, 0x40, 0x38, 0x00, 0x00, // e + 0x00, 0x00, 0x1C, 0x20, 0x20, 0x78, 0x20, 0x20, 0x20, 0x78, 0x00, 0x00, // f + 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x48, 0x30, 0x40, 0x78, 0x44, 0x38, // g + 0x00, 0x00, 0xC0, 0x40, 0x40, 0x70, 0x48, 0x48, 0x48, 0xEC, 0x00, 0x00, // h + 0x00, 0x00, 0x20, 0x00, 0x00, 0x60, 0x20, 0x20, 0x20, 0x70, 0x00, 0x00, // i + 0x00, 0x00, 0x10, 0x00, 0x00, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0xE0, // j + 0x00, 0x00, 0xC0, 0x40, 0x40, 0x5C, 0x50, 0x70, 0x48, 0xEC, 0x00, 0x00, // k + 0x00, 0x00, 0xE0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xF8, 0x00, 0x00, // l + 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0xA8, 0xA8, 0xA8, 0xA8, 0x00, 0x00, // m + 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x48, 0x48, 0x48, 0xEC, 0x00, 0x00, // n + 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x48, 0x48, 0x48, 0x30, 0x00, 0x00, // o + 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x48, 0x48, 0x48, 0x70, 0x40, 0xE0, // p + 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x48, 0x48, 0x48, 0x38, 0x08, 0x1C, // q + 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x60, 0x40, 0x40, 0xE0, 0x00, 0x00, // r + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x40, 0x30, 0x08, 0x78, 0x00, 0x00, // s + 0x00, 0x00, 0x00, 0x20, 0x20, 0x70, 0x20, 0x20, 0x20, 0x18, 0x00, 0x00, // t + 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x48, 0x48, 0x48, 0x3C, 0x00, 0x00, // u + 0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x48, 0x50, 0x30, 0x20, 0x00, 0x00, // v + 0x00, 0x00, 0x00, 0x00, 0x00, 0xA8, 0xA8, 0x70, 0x50, 0x50, 0x00, 0x00, // w + 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x50, 0x20, 0x50, 0xD8, 0x00, 0x00, // x + 0x00, 0x00, 0x00, 0x00, 0x00, 0xEC, 0x48, 0x50, 0x30, 0x20, 0x20, 0xC0, // y + 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x10, 0x20, 0x20, 0x78, 0x00, 0x00, // z + 0x00, 0x18, 0x10, 0x10, 0x10, 0x20, 0x10, 0x10, 0x10, 0x10, 0x18, 0x00, // { + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, // | + 0x00, 0x60, 0x20, 0x20, 0x20, 0x10, 0x20, 0x20, 0x20, 0x20, 0x60, 0x00, // } + 0x40, 0xA4, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ~ +}; // BigFont.c (C)2010 by Henning Karlsen // Font Size : 16x16 // Memory usage : 3044 bytes // # characters : 95 -fontdatatype BigFont[3044] PROGMEM={ -0x10,0x10,0x20,0x5F, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // -0x00,0x00,0x00,0x00,0x07,0x00,0x0F,0x80,0x0F,0x80,0x0F,0x80,0x0F,0x80,0x0F,0x80,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00, // ! -0x00,0x00,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x06,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // " -0x00,0x00,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x7F,0xFE,0x7F,0xFE,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x7F,0xFE,0x7F,0xFE,0x0C,0x30,0x0C,0x30,0x0C,0x30,0x00,0x00, // # -0x00,0x00,0x02,0x40,0x02,0x40,0x0F,0xF8,0x1F,0xF8,0x1A,0x40,0x1A,0x40,0x1F,0xF0,0x0F,0xF8,0x02,0x58,0x02,0x58,0x1F,0xF8,0x1F,0xF0,0x02,0x40,0x02,0x40,0x00,0x00, // $ -0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x10,0x0E,0x30,0x0E,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x70,0x0C,0x70,0x08,0x70,0x00,0x00,0x00,0x00,0x00,0x00, // % -0x00,0x00,0x00,0x00,0x0F,0x00,0x19,0x80,0x19,0x80,0x19,0x80,0x0F,0x00,0x0F,0x08,0x0F,0x98,0x19,0xF8,0x18,0xF0,0x18,0xE0,0x19,0xF0,0x0F,0x98,0x00,0x00,0x00,0x00, // & -0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ' -0x00,0x00,0x00,0x00,0x00,0xF0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x07,0x00,0x03,0x80,0x01,0xC0,0x00,0xF0,0x00,0x00,0x00,0x00, // ( -0x00,0x00,0x00,0x00,0x0F,0x00,0x03,0x80,0x01,0xC0,0x00,0xE0,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x0F,0x00,0x00,0x00,0x00,0x00, // ) -0x00,0x00,0x00,0x00,0x01,0x80,0x11,0x88,0x09,0x90,0x07,0xE0,0x07,0xE0,0x3F,0xFC,0x3F,0xFC,0x07,0xE0,0x07,0xE0,0x09,0x90,0x11,0x88,0x01,0x80,0x00,0x00,0x00,0x00, // * -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x01,0x80,0x0F,0xF0,0x0F,0xF0,0x01,0x80,0x01,0x80,0x01,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // + -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x0E,0x00,0x00,0x00, // , -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // - -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00, // , -0x00,0x00,0x00,0x00,0x00,0x02,0x00,0x06,0x00,0x0E,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x00,0x1C,0x00,0x00,0x00,0x00,0x00, // / +fontdatatype BigFont[3044] PROGMEM = { + 0x10, 0x10, 0x20, 0x5F, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x0F, 0x80, 0x0F, 0x80, 0x0F, 0x80, 0x0F, 0x80, 0x0F, 0x80, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, // ! + 0x00, 0x00, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x06, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // " + 0x00, 0x00, 0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x30, 0x7F, 0xFE, 0x7F, 0xFE, 0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x30, 0x7F, 0xFE, 0x7F, 0xFE, 0x0C, 0x30, 0x0C, 0x30, 0x0C, 0x30, 0x00, 0x00, // # + 0x00, 0x00, 0x02, 0x40, 0x02, 0x40, 0x0F, 0xF8, 0x1F, 0xF8, 0x1A, 0x40, 0x1A, 0x40, 0x1F, 0xF0, 0x0F, 0xF8, 0x02, 0x58, 0x02, 0x58, 0x1F, 0xF8, 0x1F, 0xF0, 0x02, 0x40, 0x02, 0x40, 0x00, 0x00, // $ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x10, 0x0E, 0x30, 0x0E, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x70, 0x0C, 0x70, 0x08, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // % + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x19, 0x80, 0x19, 0x80, 0x19, 0x80, 0x0F, 0x00, 0x0F, 0x08, 0x0F, 0x98, 0x19, 0xF8, 0x18, 0xF0, 0x18, 0xE0, 0x19, 0xF0, 0x0F, 0x98, 0x00, 0x00, 0x00, 0x00, // & + 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' + 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x00, // ( + 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, // ) + 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x11, 0x88, 0x09, 0x90, 0x07, 0xE0, 0x07, 0xE0, 0x3F, 0xFC, 0x3F, 0xFC, 0x07, 0xE0, 0x07, 0xE0, 0x09, 0x90, 0x11, 0x88, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, // * + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x0F, 0xF0, 0x0F, 0xF0, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x0E, 0x00, 0x00, 0x00, // , + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // - + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, // , + 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00, // / -0x00,0x00,0x00,0x00,0x0F,0xF0,0x1C,0x38,0x1C,0x78,0x1C,0xF8,0x1C,0xF8,0x1D,0xB8,0x1D,0xB8,0x1F,0x38,0x1F,0x38,0x1E,0x38,0x1C,0x38,0x0F,0xF0,0x00,0x00,0x00,0x00, // 0 -0x00,0x00,0x00,0x00,0x01,0x80,0x01,0x80,0x03,0x80,0x1F,0x80,0x1F,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x1F,0xF0,0x00,0x00,0x00,0x00, // 1 -0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x70,0x1C,0x38,0x00,0x38,0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x38,0x1C,0x38,0x1F,0xF8,0x00,0x00,0x00,0x00, // 2 -0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x70,0x1C,0x38,0x00,0x38,0x00,0x70,0x03,0xC0,0x03,0xC0,0x00,0x70,0x00,0x38,0x1C,0x38,0x1C,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // 3 -0x00,0x00,0x00,0x00,0x00,0xE0,0x01,0xE0,0x03,0xE0,0x06,0xE0,0x0C,0xE0,0x18,0xE0,0x1F,0xF8,0x1F,0xF8,0x00,0xE0,0x00,0xE0,0x00,0xE0,0x03,0xF8,0x00,0x00,0x00,0x00, // 4 -0x00,0x00,0x00,0x00,0x1F,0xF8,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1F,0xE0,0x1F,0xF0,0x00,0x78,0x00,0x38,0x1C,0x38,0x1C,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // 5 -0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0x00,0x0E,0x00,0x1C,0x00,0x1C,0x00,0x1F,0xF0,0x1F,0xF8,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x0F,0xF0,0x00,0x00,0x00,0x00, // 6 -0x00,0x00,0x00,0x00,0x1F,0xFC,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x00,0x1C,0x00,0x38,0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x03,0x80,0x03,0x80,0x00,0x00,0x00,0x00, // 7 -0x00,0x00,0x00,0x00,0x0F,0xF0,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1F,0x38,0x07,0xE0,0x07,0xE0,0x1C,0xF8,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x0F,0xF0,0x00,0x00,0x00,0x00, // 8 -0x00,0x00,0x00,0x00,0x0F,0xF0,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1F,0xF8,0x0F,0xF8,0x00,0x38,0x00,0x38,0x00,0x70,0x00,0xE0,0x07,0xC0,0x00,0x00,0x00,0x00, // 9 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x03,0x80,0x03,0x80,0x00,0x00,0x00,0x00,0x03,0x80,0x03,0x80,0x03,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // : -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0x80,0x03,0x80,0x03,0x80,0x00,0x00,0x00,0x00,0x03,0x80,0x03,0x80,0x03,0x80,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ; -0x00,0x00,0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x00,0x1C,0x00,0x1C,0x00,0x0E,0x00,0x07,0x00,0x03,0x80,0x01,0xC0,0x00,0xE0,0x00,0x70,0x00,0x00, // < -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x3F,0xFC,0x3F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // = -0x00,0x00,0x1C,0x00,0x0E,0x00,0x07,0x00,0x03,0x80,0x01,0xC0,0x00,0xE0,0x00,0x70,0x00,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x00,0x1C,0x00,0x00,0x00, // > -0x00,0x00,0x03,0xC0,0x0F,0xF0,0x1E,0x78,0x18,0x38,0x00,0x38,0x00,0x70,0x00,0xE0,0x01,0xC0,0x01,0xC0,0x00,0x00,0x00,0x00,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0x00, // ? + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x1C, 0x38, 0x1C, 0x78, 0x1C, 0xF8, 0x1C, 0xF8, 0x1D, 0xB8, 0x1D, 0xB8, 0x1F, 0x38, 0x1F, 0x38, 0x1E, 0x38, 0x1C, 0x38, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, // 0 + 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x01, 0x80, 0x03, 0x80, 0x1F, 0x80, 0x1F, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, // 1 + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1C, 0x70, 0x1C, 0x38, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x38, 0x1C, 0x38, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, // 2 + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1C, 0x70, 0x1C, 0x38, 0x00, 0x38, 0x00, 0x70, 0x03, 0xC0, 0x03, 0xC0, 0x00, 0x70, 0x00, 0x38, 0x1C, 0x38, 0x1C, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // 3 + 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x01, 0xE0, 0x03, 0xE0, 0x06, 0xE0, 0x0C, 0xE0, 0x18, 0xE0, 0x1F, 0xF8, 0x1F, 0xF8, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x00, // 4 + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1F, 0xE0, 0x1F, 0xF0, 0x00, 0x78, 0x00, 0x38, 0x1C, 0x38, 0x1C, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // 5 + 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1F, 0xF0, 0x1F, 0xF8, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, // 6 + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00, 0x1C, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, // 7 + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1F, 0x38, 0x07, 0xE0, 0x07, 0xE0, 0x1C, 0xF8, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, // 8 + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1F, 0xF8, 0x0F, 0xF8, 0x00, 0x38, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x07, 0xC0, 0x00, 0x00, 0x00, 0x00, // 9 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // : + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ; + 0x00, 0x00, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x00, // < + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xFC, 0x3F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // = + 0x00, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x00, 0x1C, 0x00, 0x00, 0x00, // > + 0x00, 0x00, 0x03, 0xC0, 0x0F, 0xF0, 0x1E, 0x78, 0x18, 0x38, 0x00, 0x38, 0x00, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x01, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x00, 0x00, // ? -0x00,0x00,0x0F,0xF8,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0xFC,0x1C,0xFC,0x1C,0xFC,0x1C,0xFC,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1F,0xF0,0x07,0xF8,0x00,0x00, // @ -0x00,0x00,0x00,0x00,0x03,0xC0,0x07,0xE0,0x0E,0x70,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1F,0xF8,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x00,0x00,0x00,0x00, // A -0x00,0x00,0x00,0x00,0x1F,0xF0,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0F,0xF0,0x0F,0xF0,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1F,0xF0,0x00,0x00,0x00,0x00, // B -0x00,0x00,0x00,0x00,0x07,0xF0,0x0E,0x38,0x1C,0x38,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0x38,0x0E,0x38,0x07,0xF0,0x00,0x00,0x00,0x00, // C -0x00,0x00,0x00,0x00,0x1F,0xE0,0x0E,0x70,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x70,0x1F,0xE0,0x00,0x00,0x00,0x00, // D -0x00,0x00,0x00,0x00,0x1F,0xF8,0x0E,0x18,0x0E,0x08,0x0E,0x00,0x0E,0x30,0x0F,0xF0,0x0F,0xF0,0x0E,0x30,0x0E,0x00,0x0E,0x08,0x0E,0x18,0x1F,0xF8,0x00,0x00,0x00,0x00, // E -0x00,0x00,0x00,0x00,0x1F,0xF8,0x0E,0x18,0x0E,0x08,0x0E,0x00,0x0E,0x30,0x0F,0xF0,0x0F,0xF0,0x0E,0x30,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1F,0x00,0x00,0x00,0x00,0x00, // F -0x00,0x00,0x00,0x00,0x07,0xF0,0x0E,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x00,0x1C,0x00,0x1C,0x00,0x1C,0xF8,0x1C,0x38,0x1C,0x38,0x0E,0x38,0x07,0xF8,0x00,0x00,0x00,0x00, // G -0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1F,0xF0,0x1F,0xF0,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x00,0x00,0x00,0x00, // H -0x00,0x00,0x00,0x00,0x0F,0xE0,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x0F,0xE0,0x00,0x00,0x00,0x00, // I -0x00,0x00,0x00,0x00,0x01,0xFC,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x38,0x70,0x38,0x70,0x38,0x70,0x38,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // J -0x00,0x00,0x00,0x00,0x1E,0x38,0x0E,0x38,0x0E,0x70,0x0E,0xE0,0x0F,0xC0,0x0F,0x80,0x0F,0x80,0x0F,0xC0,0x0E,0xE0,0x0E,0x70,0x0E,0x38,0x1E,0x38,0x00,0x00,0x00,0x00, // K -0x00,0x00,0x00,0x00,0x1F,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x08,0x0E,0x18,0x0E,0x38,0x1F,0xF8,0x00,0x00,0x00,0x00, // L -0x00,0x00,0x00,0x00,0x1C,0x1C,0x1E,0x3C,0x1F,0x7C,0x1F,0xFC,0x1F,0xFC,0x1D,0xDC,0x1C,0x9C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00, // M -0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0x1E,0x1C,0x1F,0x1C,0x1F,0x9C,0x1D,0xDC,0x1C,0xFC,0x1C,0x7C,0x1C,0x3C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x00,0x00,0x00,0x00, // N -0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0xF0,0x0E,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x0E,0x38,0x07,0xF0,0x03,0xE0,0x00,0x00,0x00,0x00, // O + 0x00, 0x00, 0x0F, 0xF8, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0xFC, 0x1C, 0xFC, 0x1C, 0xFC, 0x1C, 0xFC, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1F, 0xF0, 0x07, 0xF8, 0x00, 0x00, // @ + 0x00, 0x00, 0x00, 0x00, 0x03, 0xC0, 0x07, 0xE0, 0x0E, 0x70, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1F, 0xF8, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x00, 0x00, 0x00, 0x00, // A + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0F, 0xF0, 0x0F, 0xF0, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x1F, 0xF0, 0x00, 0x00, 0x00, 0x00, // B + 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x0E, 0x38, 0x1C, 0x38, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x38, 0x0E, 0x38, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, // C + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x0E, 0x70, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x70, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, // D + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x0E, 0x18, 0x0E, 0x08, 0x0E, 0x00, 0x0E, 0x30, 0x0F, 0xF0, 0x0F, 0xF0, 0x0E, 0x30, 0x0E, 0x00, 0x0E, 0x08, 0x0E, 0x18, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, // E + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x0E, 0x18, 0x0E, 0x08, 0x0E, 0x00, 0x0E, 0x30, 0x0F, 0xF0, 0x0F, 0xF0, 0x0E, 0x30, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, // F + 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x0E, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0xF8, 0x1C, 0x38, 0x1C, 0x38, 0x0E, 0x38, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, // G + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1F, 0xF0, 0x1F, 0xF0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x00, 0x00, 0x00, 0x00, // H + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // I + 0x00, 0x00, 0x00, 0x00, 0x01, 0xFC, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x38, 0x70, 0x38, 0x70, 0x38, 0x70, 0x38, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // J + 0x00, 0x00, 0x00, 0x00, 0x1E, 0x38, 0x0E, 0x38, 0x0E, 0x70, 0x0E, 0xE0, 0x0F, 0xC0, 0x0F, 0x80, 0x0F, 0x80, 0x0F, 0xC0, 0x0E, 0xE0, 0x0E, 0x70, 0x0E, 0x38, 0x1E, 0x38, 0x00, 0x00, 0x00, 0x00, // K + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x08, 0x0E, 0x18, 0x0E, 0x38, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, // L + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1E, 0x3C, 0x1F, 0x7C, 0x1F, 0xFC, 0x1F, 0xFC, 0x1D, 0xDC, 0x1C, 0x9C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, // M + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x1C, 0x1E, 0x1C, 0x1F, 0x1C, 0x1F, 0x9C, 0x1D, 0xDC, 0x1C, 0xFC, 0x1C, 0x7C, 0x1C, 0x3C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00, 0x00, 0x00, 0x00, // N + 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x07, 0xF0, 0x0E, 0x38, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x0E, 0x38, 0x07, 0xF0, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x00, // O -0x00,0x00,0x00,0x00,0x1F,0xF0,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0F,0xF0,0x0F,0xF0,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1F,0x00,0x00,0x00,0x00,0x00, // P -0x00,0x00,0x00,0x00,0x03,0xE0,0x0F,0x78,0x0E,0x38,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x7C,0x1C,0xFC,0x0F,0xF8,0x0F,0xF8,0x00,0x38,0x00,0xFC,0x00,0x00, // Q -0x00,0x00,0x00,0x00,0x1F,0xF0,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0F,0xF0,0x0F,0xF0,0x0E,0x70,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1E,0x38,0x00,0x00,0x00,0x00, // R -0x00,0x00,0x00,0x00,0x0F,0xF0,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x00,0x0F,0xE0,0x07,0xF0,0x00,0x38,0x1C,0x38,0x1C,0x38,0x1C,0x38,0x0F,0xF0,0x00,0x00,0x00,0x00, // S -0x00,0x00,0x00,0x00,0x1F,0xFC,0x19,0xCC,0x11,0xC4,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x07,0xF0,0x00,0x00,0x00,0x00, // T -0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // U -0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0E,0xE0,0x07,0xC0,0x03,0x80,0x00,0x00,0x00,0x00, // V -0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x9C,0x1C,0x9C,0x1C,0x9C,0x0F,0xF8,0x0F,0xF8,0x07,0x70,0x07,0x70,0x00,0x00,0x00,0x00, // W -0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0E,0xE0,0x07,0xC0,0x03,0x80,0x03,0x80,0x07,0xC0,0x0E,0xE0,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x00,0x00,0x00,0x00, // X -0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0E,0xE0,0x07,0xC0,0x03,0x80,0x03,0x80,0x03,0x80,0x03,0x80,0x0F,0xE0,0x00,0x00,0x00,0x00, // Y -0x00,0x00,0x00,0x00,0x1F,0xF8,0x1C,0x38,0x18,0x38,0x10,0x70,0x00,0xE0,0x01,0xC0,0x03,0x80,0x07,0x00,0x0E,0x08,0x1C,0x18,0x1C,0x38,0x1F,0xF8,0x00,0x00,0x00,0x00, // Z -0x00,0x00,0x00,0x00,0x07,0xF0,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0xF0,0x00,0x00,0x00,0x00, // [ -0x00,0x00,0x00,0x00,0x10,0x00,0x18,0x00,0x1C,0x00,0x0E,0x00,0x07,0x00,0x03,0x80,0x01,0xC0,0x00,0xE0,0x00,0x70,0x00,0x38,0x00,0x1C,0x00,0x07,0x00,0x00,0x00,0x00, // -0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x07,0xF0,0x00,0x00,0x00,0x00, // ] -0x00,0x00,0x01,0x80,0x03,0xC0,0x07,0xE0,0x0E,0x70,0x1C,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ^ -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFF,0x7F,0xFF, // _ + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0F, 0xF0, 0x0F, 0xF0, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, // P + 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x0F, 0x78, 0x0E, 0x38, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x7C, 0x1C, 0xFC, 0x0F, 0xF8, 0x0F, 0xF8, 0x00, 0x38, 0x00, 0xFC, 0x00, 0x00, // Q + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF0, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0F, 0xF0, 0x0F, 0xF0, 0x0E, 0x70, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x1E, 0x38, 0x00, 0x00, 0x00, 0x00, // R + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xF0, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x00, 0x0F, 0xE0, 0x07, 0xF0, 0x00, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x1C, 0x38, 0x0F, 0xF0, 0x00, 0x00, 0x00, 0x00, // S + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xFC, 0x19, 0xCC, 0x11, 0xC4, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, // T + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // U + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, // V + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x9C, 0x1C, 0x9C, 0x1C, 0x9C, 0x0F, 0xF8, 0x0F, 0xF8, 0x07, 0x70, 0x07, 0x70, 0x00, 0x00, 0x00, 0x00, // W + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x03, 0x80, 0x07, 0xC0, 0x0E, 0xE0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x00, 0x00, 0x00, 0x00, // X + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // Y + 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x1C, 0x38, 0x18, 0x38, 0x10, 0x70, 0x00, 0xE0, 0x01, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x08, 0x1C, 0x18, 0x1C, 0x38, 0x1F, 0xF8, 0x00, 0x00, 0x00, 0x00, // Z + 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, // [ + 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x18, 0x00, 0x1C, 0x00, 0x0E, 0x00, 0x07, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x70, 0x00, 0x38, 0x00, 0x1C, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, // + 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x07, 0xF0, 0x00, 0x00, 0x00, 0x00, // ] + 0x00, 0x00, 0x01, 0x80, 0x03, 0xC0, 0x07, 0xE0, 0x0E, 0x70, 0x1C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ^ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xFF, 0x7F, 0xFF, // _ -0x00,0x00,0x00,0x00,0x1C,0x00,0x1C,0x00,0x07,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // ' -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x00,0x70,0x00,0x70,0x0F,0xF0,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0F,0xD8,0x00,0x00,0x00,0x00, // a -0x00,0x00,0x00,0x00,0x1E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0F,0xF0,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1B,0xF0,0x00,0x00,0x00,0x00, // b -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x70,0x1C,0x70,0x1C,0x00,0x1C,0x00,0x1C,0x70,0x1C,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // c -0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x70,0x00,0x70,0x00,0x70,0x0F,0xF0,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0F,0xD8,0x00,0x00,0x00,0x00, // d -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x70,0x1C,0x70,0x1F,0xF0,0x1C,0x00,0x1C,0x70,0x1C,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // e -0x00,0x00,0x00,0x00,0x03,0xE0,0x07,0x70,0x07,0x70,0x07,0x00,0x07,0x00,0x1F,0xE0,0x1F,0xE0,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x1F,0xC0,0x00,0x00,0x00,0x00, // f -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xD8,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0F,0xF0,0x07,0xF0,0x00,0x70,0x1C,0x70,0x0F,0xE0, // g -0x00,0x00,0x00,0x00,0x1E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0xF0,0x0F,0x38,0x0F,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x1E,0x38,0x00,0x00,0x00,0x00, // h -0x00,0x00,0x00,0x00,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0x00,0x0F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x0F,0xF8,0x00,0x00,0x00,0x00, // i -0x00,0x00,0x00,0x00,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x00,0x03,0xF0,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x00,0x70,0x1C,0x70,0x0C,0xF0,0x07,0xE0, // j -0x00,0x00,0x00,0x00,0x1E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x38,0x0E,0x70,0x0E,0xE0,0x0F,0xC0,0x0E,0xE0,0x0E,0x70,0x0E,0x38,0x1E,0x38,0x00,0x00,0x00,0x00, // k -0x00,0x00,0x00,0x00,0x0F,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x0F,0xF8,0x00,0x00,0x00,0x00, // l -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xF8,0x1C,0x9C,0x1C,0x9C,0x1C,0x9C,0x1C,0x9C,0x1C,0x9C,0x1C,0x9C,0x1C,0x9C,0x00,0x00,0x00,0x00, // m -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x00,0x00,0x00,0x00, // n -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // o + 0x00, 0x00, 0x00, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ' + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x00, 0x70, 0x00, 0x70, 0x0F, 0xF0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xD8, 0x00, 0x00, 0x00, 0x00, // a + 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0F, 0xF0, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x1B, 0xF0, 0x00, 0x00, 0x00, 0x00, // b + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x00, 0x1C, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // c + 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x0F, 0xF0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xD8, 0x00, 0x00, 0x00, 0x00, // d + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1C, 0x70, 0x1C, 0x70, 0x1F, 0xF0, 0x1C, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // e + 0x00, 0x00, 0x00, 0x00, 0x03, 0xE0, 0x07, 0x70, 0x07, 0x70, 0x07, 0x00, 0x07, 0x00, 0x1F, 0xE0, 0x1F, 0xE0, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x00, 0x00, // f + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xD8, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xF0, 0x07, 0xF0, 0x00, 0x70, 0x1C, 0x70, 0x0F, 0xE0, // g + 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0xF0, 0x0F, 0x38, 0x0F, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x1E, 0x38, 0x00, 0x00, 0x00, 0x00, // h + 0x00, 0x00, 0x00, 0x00, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x00, 0x00, 0x0F, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, // i + 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x00, 0x03, 0xF0, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x00, 0x70, 0x1C, 0x70, 0x0C, 0xF0, 0x07, 0xE0, // j + 0x00, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x38, 0x0E, 0x70, 0x0E, 0xE0, 0x0F, 0xC0, 0x0E, 0xE0, 0x0E, 0x70, 0x0E, 0x38, 0x1E, 0x38, 0x00, 0x00, 0x00, 0x00, // k + 0x00, 0x00, 0x00, 0x00, 0x0F, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x0F, 0xF8, 0x00, 0x00, 0x00, 0x00, // l + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xF8, 0x1C, 0x9C, 0x1C, 0x9C, 0x1C, 0x9C, 0x1C, 0x9C, 0x1C, 0x9C, 0x1C, 0x9C, 0x1C, 0x9C, 0x00, 0x00, 0x00, 0x00, // m + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x00, 0x00, 0x00, 0x00, // n + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // o -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0xF0,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0F,0xF0,0x0E,0x00,0x0E,0x00,0x1F,0x00, // p -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xB0,0x38,0xE0,0x38,0xE0,0x38,0xE0,0x38,0xE0,0x38,0xE0,0x1F,0xE0,0x00,0xE0,0x00,0xE0,0x01,0xF0, // q -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0xF0,0x0F,0xF8,0x0F,0x38,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x0E,0x00,0x1F,0x00,0x00,0x00,0x00,0x00, // r -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0xE0,0x1C,0x30,0x1C,0x30,0x0F,0x80,0x03,0xE0,0x18,0x70,0x18,0x70,0x0F,0xE0,0x00,0x00,0x00,0x00, // s -0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x03,0x00,0x07,0x00,0x1F,0xF0,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x00,0x07,0x70,0x07,0x70,0x03,0xE0,0x00,0x00,0x00,0x00, // t -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0F,0xD8,0x00,0x00,0x00,0x00, // u -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x1C,0x70,0x0E,0xE0,0x07,0xC0,0x03,0x80,0x00,0x00,0x00,0x00, // v -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x1C,0x9C,0x1C,0x9C,0x0F,0xF8,0x07,0x70,0x07,0x70,0x00,0x00,0x00,0x00, // w -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0xE0,0x1C,0xE0,0x0F,0xC0,0x07,0x80,0x07,0x80,0x0F,0xC0,0x1C,0xE0,0x1C,0xE0,0x00,0x00,0x00,0x00, // x -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x0E,0x38,0x07,0xF0,0x03,0xE0,0x00,0xE0,0x01,0xC0,0x1F,0x80, // y -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0xE0,0x18,0xE0,0x11,0xC0,0x03,0x80,0x07,0x00,0x0E,0x20,0x1C,0x60,0x1F,0xE0,0x00,0x00,0x00,0x00, // z -0x00,0x00,0x00,0x00,0x01,0xF8,0x03,0x80,0x03,0x80,0x03,0x80,0x07,0x00,0x1C,0x00,0x1C,0x00,0x07,0x00,0x03,0x80,0x03,0x80,0x03,0x80,0x01,0xF8,0x00,0x00,0x00,0x00, // { -0x00,0x00,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0x00, // | -0x00,0x00,0x00,0x00,0x1F,0x80,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x00,0xE0,0x00,0x38,0x00,0x38,0x00,0xE0,0x01,0xC0,0x01,0xC0,0x01,0xC0,0x1F,0x80,0x00,0x00,0x00,0x00, // } -0x00,0x00,0x00,0x00,0x1F,0x1C,0x3B,0x9C,0x39,0xDC,0x38,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 // ~ -}; + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xF0, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0F, 0xF0, 0x0E, 0x00, 0x0E, 0x00, 0x1F, 0x00, // p + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xB0, 0x38, 0xE0, 0x38, 0xE0, 0x38, 0xE0, 0x38, 0xE0, 0x38, 0xE0, 0x1F, 0xE0, 0x00, 0xE0, 0x00, 0xE0, 0x01, 0xF0, // q + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0xF0, 0x0F, 0xF8, 0x0F, 0x38, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x0E, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, // r + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0F, 0xE0, 0x1C, 0x30, 0x1C, 0x30, 0x0F, 0x80, 0x03, 0xE0, 0x18, 0x70, 0x18, 0x70, 0x0F, 0xE0, 0x00, 0x00, 0x00, 0x00, // s + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x1F, 0xF0, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x00, 0x07, 0x70, 0x07, 0x70, 0x03, 0xE0, 0x00, 0x00, 0x00, 0x00, // t + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0F, 0xD8, 0x00, 0x00, 0x00, 0x00, // u + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x1C, 0x70, 0x0E, 0xE0, 0x07, 0xC0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, // v + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x9C, 0x1C, 0x9C, 0x0F, 0xF8, 0x07, 0x70, 0x07, 0x70, 0x00, 0x00, 0x00, 0x00, // w + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1C, 0xE0, 0x1C, 0xE0, 0x0F, 0xC0, 0x07, 0x80, 0x07, 0x80, 0x0F, 0xC0, 0x1C, 0xE0, 0x1C, 0xE0, 0x00, 0x00, 0x00, 0x00, // x + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x0E, 0x38, 0x07, 0xF0, 0x03, 0xE0, 0x00, 0xE0, 0x01, 0xC0, 0x1F, 0x80, // y + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0xE0, 0x18, 0xE0, 0x11, 0xC0, 0x03, 0x80, 0x07, 0x00, 0x0E, 0x20, 0x1C, 0x60, 0x1F, 0xE0, 0x00, 0x00, 0x00, 0x00, // z + 0x00, 0x00, 0x00, 0x00, 0x01, 0xF8, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x07, 0x00, 0x1C, 0x00, 0x1C, 0x00, 0x07, 0x00, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, // { + 0x00, 0x00, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x00, 0x00, // | + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x80, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x00, 0xE0, 0x00, 0x38, 0x00, 0x38, 0x00, 0xE0, 0x01, 0xC0, 0x01, 0xC0, 0x01, 0xC0, 0x1F, 0x80, 0x00, 0x00, 0x00, 0x00, // } + 0x00, 0x00, 0x00, 0x00, 0x1F, 0x1C, 0x3B, 0x9C, 0x39, 0xDC, 0x38, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 // ~ +}; // SevenSegNumFont.c // Font Size : 32x50 // Memory usage : 2004 bytes // # characters : 10 -fontdatatype SevenSegNumFont[2004] PROGMEM={ -0x20,0x32,0x30,0x0A, -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x0C,0xFF,0xFE,0xF0,0x1E,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3E,0x00,0x00,0x78,0x38,0x00,0x00,0x18,0x20,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x38,0x00,0x00,0x18,0x3E,0x00,0x00,0x78,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x1E,0x00,0x00,0xF0,0x0C,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0xF0,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 1 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x00,0xFF,0xFE,0xF0,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0x78,0x01,0xFF,0xFE,0x18,0x03,0xFF,0xFF,0x88,0x0F,0xFF,0xFF,0xE0,0x27,0xFF,0xFF,0xC0,0x39,0xFF,0xFF,0x00,0x3E,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x1E,0x00,0x00,0x00,0x0C,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 2 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x00,0xFF,0xFE,0xF0,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0x78,0x01,0xFF,0xFE,0x18,0x03,0xFF,0xFF,0x88,0x0F,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 3 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x0C,0x00,0x00,0xF0,0x1E,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3E,0x00,0x00,0x78,0x39,0xFF,0xFE,0x18,0x23,0xFF,0xFF,0x88,0x0F,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 4 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x0C,0xFF,0xFE,0x00,0x1E,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x39,0xFF,0xFE,0x00,0x23,0xFF,0xFF,0x80,0x0F,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 5 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x0C,0xFF,0xFE,0x00,0x1E,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x3E,0x00,0x00,0x00,0x39,0xFF,0xFE,0x00,0x23,0xFF,0xFF,0x80,0x0F,0xFF,0xFF,0xE0,0x27,0xFF,0xFF,0xC0,0x39,0xFF,0xFF,0x18,0x3E,0x00,0x00,0x78,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x1E,0x00,0x00,0xF0,0x0C,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 6 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x00,0xFF,0xFE,0xF0,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0x78,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 7 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x0C,0xFF,0xFE,0xF0,0x1E,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3E,0x00,0x00,0x78,0x39,0xFF,0xFE,0x18,0x23,0xFF,0xFF,0x88,0x0F,0xFF,0xFF,0xE0,0x27,0xFF,0xFF,0xC0,0x39,0xFF,0xFF,0x18,0x3E,0x00,0x00,0x78,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x1E,0x00,0x00,0xF0,0x0C,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 8 -0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x0C,0xFF,0xFE,0xF0,0x1E,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3E,0x00,0x00,0x78,0x39,0xFF,0xFE,0x18,0x23,0xFF,0xFF,0x88,0x0F,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 9 +fontdatatype SevenSegNumFont[2004] PROGMEM = { + 0x20, 0x32, 0x30, 0x0A, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x60, 0x0C, 0xFF, 0xFE, 0xF0, 0x1E, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0x78, 0x38, 0x00, 0x00, 0x18, 0x20, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x18, 0x3E, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x1E, 0x00, 0x00, 0xF0, 0x0C, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x60, 0x00, 0xFF, 0xFE, 0xF0, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x78, 0x01, 0xFF, 0xFE, 0x18, 0x03, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, 0x27, 0xFF, 0xFF, 0xC0, 0x39, 0xFF, 0xFF, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x0C, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 2 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x60, 0x00, 0xFF, 0xFE, 0xF0, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x78, 0x01, 0xFF, 0xFE, 0x18, 0x03, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 3 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x0C, 0x00, 0x00, 0xF0, 0x1E, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0x78, 0x39, 0xFF, 0xFE, 0x18, 0x23, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 4 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x0C, 0xFF, 0xFE, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x39, 0xFF, 0xFE, 0x00, 0x23, 0xFF, 0xFF, 0x80, 0x0F, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 5 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x0C, 0xFF, 0xFE, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x39, 0xFF, 0xFE, 0x00, 0x23, 0xFF, 0xFF, 0x80, 0x0F, 0xFF, 0xFF, 0xE0, 0x27, 0xFF, 0xFF, 0xC0, 0x39, 0xFF, 0xFF, 0x18, 0x3E, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x1E, 0x00, 0x00, 0xF0, 0x0C, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 6 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x60, 0x00, 0xFF, 0xFE, 0xF0, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 7 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x60, 0x0C, 0xFF, 0xFE, 0xF0, 0x1E, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0x78, 0x39, 0xFF, 0xFE, 0x18, 0x23, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, 0x27, 0xFF, 0xFF, 0xC0, 0x39, 0xFF, 0xFF, 0x18, 0x3E, 0x00, 0x00, 0x78, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x1E, 0x00, 0x00, 0xF0, 0x0C, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 8 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x60, 0x0C, 0xFF, 0xFE, 0xF0, 0x1E, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3F, 0x00, 0x01, 0xF8, 0x3E, 0x00, 0x00, 0x78, 0x39, 0xFF, 0xFE, 0x18, 0x23, 0xFF, 0xFF, 0x88, 0x0F, 0xFF, 0xFF, 0xE0, 0x07, 0xFF, 0xFF, 0xC0, 0x01, 0xFF, 0xFF, 0x18, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x01, 0xF8, 0x00, 0x00, 0x00, 0xF0, 0x00, 0xFF, 0xFE, 0x60, 0x01, 0xFF, 0xFF, 0x00, 0x03, 0xFF, 0xFF, 0x80, 0x01, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9 }; \ No newline at end of file diff --git a/UTFT4ArduCAM_SPI/HW_AVR_SPI_defines.h b/UTFT4ArduCAM_SPI/HW_AVR_SPI_defines.h index db5c3b90..ecece375 100644 --- a/UTFT4ArduCAM_SPI/HW_AVR_SPI_defines.h +++ b/UTFT4ArduCAM_SPI/HW_AVR_SPI_defines.h @@ -1,83 +1,107 @@ // *** Hardwarespecific defines *** -#if defined (__AVR__) +#if defined(__AVR__) #define UTFT_cbi(reg, bitmask) *reg &= ~bitmask #define UTFT_sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) sbi(reg, bitmask); UTFT_cbi(reg, bitmask); -#define pulse_low(reg, bitmask) UTFT_cbi(reg, bitmask); sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + sbi(reg, bitmask); \ + UTFT_cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + UTFT_cbi(reg, bitmask); \ + sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } -#define fontbyte(x) pgm_read_byte(&cfont.font[x]) +#define fontbyte(x) pgm_read_byte(&cfont.font[x]) #define regtype volatile uint8_t #define regsize uint8_t -#define bitmapdatatype unsigned int* +#define bitmapdatatype unsigned int * #endif - + #if defined(__arm__) #define UTFT_cbi(reg, bitmask) *reg &= ~bitmask #define UTFT_sbi(reg, bitmask) *reg |= bitmask -#define pulse_high(reg, bitmask) UTFT_sbi(reg, bitmask); UTFT_cbi(reg, bitmask); -#define pulse_low(reg, bitmask) UTFT_cbi(reg, bitmask); UTFT_sbi(reg, bitmask); +#define pulse_high(reg, bitmask) \ + UTFT_sbi(reg, bitmask); \ + UTFT_cbi(reg, bitmask); +#define pulse_low(reg, bitmask) \ + UTFT_cbi(reg, bitmask); \ + UTFT_sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } -#define fontbyte(x) cfont.font[x] +#define fontbyte(x) cfont.font[x] #define pgm_read_word(data) *data #define pgm_read_byte(data) *data -#define bitmapdatatype unsigned short* +#define bitmapdatatype unsigned short * #if defined(TEENSYDUINO) && TEENSYDUINO >= 117 - #define regtype volatile uint8_t - #define regsize uint8_t +#define regtype volatile uint8_t +#define regsize uint8_t #else - #define regtype volatile uint32_t - #define regsize uint32_t +#define regtype volatile uint32_t +#define regsize uint32_t #endif #endif #if defined(ESP8266) -#define UTFT_cbi(reg, bitmask) digitalWrite(bitmask,LOW) -#define UTFT_sbi(reg, bitmask) digitalWrite(bitmask,HIGH) +#define UTFT_cbi(reg, bitmask) digitalWrite(bitmask, LOW) +#define UTFT_sbi(reg, bitmask) digitalWrite(bitmask, HIGH) -#define swap(type, i, j) {type t = i; i = j; j = t;} +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } -#define fontbyte(x) cfont.font[x] +#define fontbyte(x) cfont.font[x] -#define bitmapdatatype unsigned short* +#define bitmapdatatype unsigned short * #define regtype volatile uint32_t #define regsize uint32_t -#endif +#endif -#if defined (__CPU_ARC__) +#if defined(__CPU_ARC__) #define UTFT_cbi(reg, bitmask) *reg &= ~bitmask #define UTFT_sbi(reg, bitmask) *reg |= bitmask -//#define pulse_high(reg, bitmask) UTFT_sbi(reg, bitmask); UTFT_cbi(reg, bitmask); -//#define pulse_low(reg, bitmask) UTFT_cbi(reg, bitmask); UTFT_sbi(reg, bitmask); +// #define pulse_high(reg, bitmask) UTFT_sbi(reg, bitmask); UTFT_cbi(reg, bitmask); +// #define pulse_low(reg, bitmask) UTFT_cbi(reg, bitmask); UTFT_sbi(reg, bitmask); #define cport(port, data) port &= data #define sport(port, data) port |= data -#define swap(type, i, j) {type t = i; i = j; j = t;} +#define swap(type, i, j) \ + { \ + type t = i; \ + i = j; \ + j = t; \ + } -#define fontbyte(x) pgm_read_byte(&cfont.font[x]) +#define fontbyte(x) pgm_read_byte(&cfont.font[x]) #define regtype volatile uint32_t #define regsize uint32_t -#define bitmapdatatype unsigned int* +#define bitmapdatatype unsigned int * #endif - - - - \ No newline at end of file diff --git a/UTFT4ArduCAM_SPI/UTFT_SPI.cpp b/UTFT4ArduCAM_SPI/UTFT_SPI.cpp index f43aae70..2c6c8eb6 100644 --- a/UTFT4ArduCAM_SPI/UTFT_SPI.cpp +++ b/UTFT4ArduCAM_SPI/UTFT_SPI.cpp @@ -1,38 +1,38 @@ /* UTFT.cpp - Arduino library support for Color TFT LCD Boards - This is special porting for ArduCAM shield LCD screen. - Use SPI bus interface and SSD1289 controller. Only work on + This is special porting for ArduCAM shield LCD screen. + Use SPI bus interface and SSD1289 controller. Only work on ArduCAM shield Rev.C. For more information about ArduCAM shield please visit www.arducam.com Copyright (C)2010-2014 Henning Karlsen. All right reserved - + This library is the continuation of my ITDB02_Graph, ITDB02_Graph16 - and RGB_GLCD libraries for Arduino and chipKit. As the number of - supported display modules and controllers started to increase I felt - it was time to make a single, universal library as it will be much + and RGB_GLCD libraries for Arduino and chipKit. As the number of + supported display modules and controllers started to increase I felt + it was time to make a single, universal library as it will be much easier to maintain in the future. - Basic functionality of this library was origianlly based on the - demo-code provided by ITead studio (for the ITDB02 modules) and + Basic functionality of this library was origianlly based on the + demo-code provided by ITead studio (for the ITDB02 modules) and NKC Electronics (for the RGB GLCD module/shield). - This library supports a number of 8bit, 16bit and serial graphic - displays, and will work with both Arduino and chipKit boards. For a - full list of tested display modules and controllers, see the + This library supports a number of 8bit, 16bit and serial graphic + displays, and will work with both Arduino and chipKit boards. For a + full list of tested display modules and controllers, see the document UTFT_Supported_display_modules_&_controllers.pdf. - When using 8bit and 16bit display modules there are some - requirements you must adhere to. These requirements can be found + When using 8bit and 16bit display modules there are some + requirements you must adhere to. These requirements can be found in the document UTFT_Requirements.pdf. There are no special requirements when using serial displays. - You can always find the latest version of the library at + You can always find the latest version of the library at http://electronics.henningkarlsen.com/ - If you make any modifications or improvements to the code, I would - appreciate that you share the code with me so that I might include - it in the next release. I can be contacted through + If you make any modifications or improvements to the code, I would + appreciate that you share the code with me so that I might include + it in the next release. I can be contacted through http://electronics.henningkarlsen.com/contact.php. This library is free software; you can redistribute it and/or @@ -55,13 +55,13 @@ #include #if defined(__AVR__) - #include - #include "HW_AVR_SPI_defines.h" +#include +#include "HW_AVR_SPI_defines.h" #endif #if defined(__arm__) || defined(ESP8266) - #include "Arduino.h" - #include "HW_AVR_SPI_defines.h" +#include "Arduino.h" +#include "HW_AVR_SPI_defines.h" #endif UTFT::UTFT() @@ -69,159 +69,159 @@ UTFT::UTFT() } UTFT::UTFT(int CS) -{ +{ #if defined(ESP8266) B_CS = CS; -#else - P_CS = portOutputRegister(digitalPinToPort(CS)); - B_CS = digitalPinToBitMask(CS); -#endif - - pinMode(CS,OUTPUT); - - //Must initialize the Bus default status +#else + P_CS = portOutputRegister(digitalPinToPort(CS)); + B_CS = digitalPinToBitMask(CS); +#endif + + pinMode(CS, OUTPUT); + + // Must initialize the Bus default status UTFT_sbi(P_CS, B_CS); model = SSD1289; - disp_x_size=239; - disp_y_size=319; - display_transfer_mode=8; + disp_x_size = 239; + disp_y_size = 319; + display_transfer_mode = 8; - display_model=model; + display_model = model; //_set_direction_registers(display_transfer_mode); - //P_CS = portOutputRegister(digitalPinToPort(CS)); - //B_CS = digitalPinToBitMask(CS); - //pinMode(CS,OUTPUT); + // P_CS = portOutputRegister(digitalPinToPort(CS)); + // B_CS = digitalPinToBitMask(CS); + // pinMode(CS,OUTPUT); } -int UTFT::bus_write(int address, int value) +int UTFT::bus_write(int address, int value) { - UTFT_cbi(P_CS, B_CS); - SPI.transfer(address); - SPI.transfer(value); - UTFT_sbi(P_CS, B_CS); - return 1; + UTFT_cbi(P_CS, B_CS); + SPI.transfer(address); + SPI.transfer(value); + UTFT_sbi(P_CS, B_CS); + return 1; } -uint8_t UTFT::bus_read(int address) +uint8_t UTFT::bus_read(int address) { - uint8_t value = 0; - UTFT_cbi(P_CS, B_CS); - SPI.transfer(address); - value = SPI.transfer(0x00); - UTFT_sbi(P_CS, B_CS); - return value; + uint8_t value = 0; + UTFT_cbi(P_CS, B_CS); + SPI.transfer(address); + value = SPI.transfer(0x00); + UTFT_sbi(P_CS, B_CS); + return value; } -void UTFT::LCD_Write_COM(char VL) -{ +void UTFT::LCD_Write_COM(char VL) +{ bus_write(0xBE, VL); - #if defined(ESP8266) +#if defined(ESP8266) yield(); - #endif +#endif } -void UTFT::LCD_Write_DATA(char VH,char VL) +void UTFT::LCD_Write_DATA(char VH, char VL) { bus_write(0xBF, VH); - bus_write(0xBF, VL); - #if defined(ESP8266) + bus_write(0xBF, VL); +#if defined(ESP8266) yield(); - #endif +#endif } -void UTFT::LCD_Write_COM_DATA(char com1,int dat1) +void UTFT::LCD_Write_COM_DATA(char com1, int dat1) { - LCD_Write_COM(com1); - LCD_Write_DATA(dat1>>8,dat1); + LCD_Write_COM(com1); + LCD_Write_DATA(dat1 >> 8, dat1); } -void UTFT::LCD_Writ_Bus(char VH,char VL) +void UTFT::LCD_Writ_Bus(char VH, char VL) { - LCD_Write_DATA(VH,VL); + LCD_Write_DATA(VH, VL); } void UTFT::InitLCD(byte orientation) { - orient=orientation; - - LCD_Write_COM_DATA(0x00,0x0001); - LCD_Write_COM_DATA(0x03,0xA8A4); - LCD_Write_COM_DATA(0x0C,0x0000); - LCD_Write_COM_DATA(0x0D,0x080C); - LCD_Write_COM_DATA(0x0E,0x2B00); - LCD_Write_COM_DATA(0x1E,0x00B7); - LCD_Write_COM_DATA(0x01,0x693F); - LCD_Write_COM_DATA(0x02,0x0600); - LCD_Write_COM_DATA(0x10,0x0000); - LCD_Write_COM_DATA(0x11,0x6078); - LCD_Write_COM_DATA(0x05,0x0000); - LCD_Write_COM_DATA(0x06,0x0000); - LCD_Write_COM_DATA(0x16,0xEF1C); - LCD_Write_COM_DATA(0x17,0x0003); - LCD_Write_COM_DATA(0x07,0x0233); - LCD_Write_COM_DATA(0x0B,0x0000); - LCD_Write_COM_DATA(0x0F,0x0000); - LCD_Write_COM_DATA(0x41,0x0000); - LCD_Write_COM_DATA(0x42,0x0000); - LCD_Write_COM_DATA(0x48,0x0000); - LCD_Write_COM_DATA(0x49,0x013F); - LCD_Write_COM_DATA(0x4A,0x0000); - LCD_Write_COM_DATA(0x4B,0x0000); - LCD_Write_COM_DATA(0x44,0xEF00); - LCD_Write_COM_DATA(0x45,0x0000); - LCD_Write_COM_DATA(0x46,0x013F); - LCD_Write_COM_DATA(0x30,0x0707); - LCD_Write_COM_DATA(0x31,0x0204); - LCD_Write_COM_DATA(0x32,0x0204); - LCD_Write_COM_DATA(0x33,0x0502); - LCD_Write_COM_DATA(0x34,0x0507); - LCD_Write_COM_DATA(0x35,0x0204); - LCD_Write_COM_DATA(0x36,0x0204); - LCD_Write_COM_DATA(0x37,0x0502); - LCD_Write_COM_DATA(0x3A,0x0302); - LCD_Write_COM_DATA(0x3B,0x0302); - LCD_Write_COM_DATA(0x23,0x0000); - LCD_Write_COM_DATA(0x24,0x0000); - LCD_Write_COM_DATA(0x25,0x8000); - LCD_Write_COM_DATA(0x4f,0x0000); - LCD_Write_COM_DATA(0x4e,0x0000); + orient = orientation; + + LCD_Write_COM_DATA(0x00, 0x0001); + LCD_Write_COM_DATA(0x03, 0xA8A4); + LCD_Write_COM_DATA(0x0C, 0x0000); + LCD_Write_COM_DATA(0x0D, 0x080C); + LCD_Write_COM_DATA(0x0E, 0x2B00); + LCD_Write_COM_DATA(0x1E, 0x00B7); + LCD_Write_COM_DATA(0x01, 0x693F); + LCD_Write_COM_DATA(0x02, 0x0600); + LCD_Write_COM_DATA(0x10, 0x0000); + LCD_Write_COM_DATA(0x11, 0x6078); + LCD_Write_COM_DATA(0x05, 0x0000); + LCD_Write_COM_DATA(0x06, 0x0000); + LCD_Write_COM_DATA(0x16, 0xEF1C); + LCD_Write_COM_DATA(0x17, 0x0003); + LCD_Write_COM_DATA(0x07, 0x0233); + LCD_Write_COM_DATA(0x0B, 0x0000); + LCD_Write_COM_DATA(0x0F, 0x0000); + LCD_Write_COM_DATA(0x41, 0x0000); + LCD_Write_COM_DATA(0x42, 0x0000); + LCD_Write_COM_DATA(0x48, 0x0000); + LCD_Write_COM_DATA(0x49, 0x013F); + LCD_Write_COM_DATA(0x4A, 0x0000); + LCD_Write_COM_DATA(0x4B, 0x0000); + LCD_Write_COM_DATA(0x44, 0xEF00); + LCD_Write_COM_DATA(0x45, 0x0000); + LCD_Write_COM_DATA(0x46, 0x013F); + LCD_Write_COM_DATA(0x30, 0x0707); + LCD_Write_COM_DATA(0x31, 0x0204); + LCD_Write_COM_DATA(0x32, 0x0204); + LCD_Write_COM_DATA(0x33, 0x0502); + LCD_Write_COM_DATA(0x34, 0x0507); + LCD_Write_COM_DATA(0x35, 0x0204); + LCD_Write_COM_DATA(0x36, 0x0204); + LCD_Write_COM_DATA(0x37, 0x0502); + LCD_Write_COM_DATA(0x3A, 0x0302); + LCD_Write_COM_DATA(0x3B, 0x0302); + LCD_Write_COM_DATA(0x23, 0x0000); + LCD_Write_COM_DATA(0x24, 0x0000); + LCD_Write_COM_DATA(0x25, 0x8000); + LCD_Write_COM_DATA(0x4f, 0x0000); + LCD_Write_COM_DATA(0x4e, 0x0000); LCD_Write_COM(0x22); - - //setColor(255, 255, 255); - //setBackColor(0, 0, 0); - cfont.font=0; + + // setColor(255, 255, 255); + // setBackColor(0, 0, 0); + cfont.font = 0; clrScr(); } void UTFT::setXY(word x1, word y1, word x2, word y2) { - if (orient==LANDSCAPE) + if (orient == LANDSCAPE) { swap(word, x1, y1); swap(word, x2, y2) - y1=disp_y_size-y1; - y2=disp_y_size-y2; + y1 = disp_y_size - y1; + y2 = disp_y_size - y2; swap(word, y1, y2) - #if defined(ESP8266) - yield(); - #endif +#if defined(ESP8266) + yield(); +#endif } - - LCD_Write_COM_DATA(0x44,(x2<<8)+x1); - LCD_Write_COM_DATA(0x45,y1); - LCD_Write_COM_DATA(0x46,y2); - LCD_Write_COM_DATA(0x4e,x1); - LCD_Write_COM_DATA(0x4f,y1); + + LCD_Write_COM_DATA(0x44, (x2 << 8) + x1); + LCD_Write_COM_DATA(0x45, y1); + LCD_Write_COM_DATA(0x46, y2); + LCD_Write_COM_DATA(0x4e, x1); + LCD_Write_COM_DATA(0x4f, y1); LCD_Write_COM(0x22); } void UTFT::clrXY() { - if (orient==PORTRAIT) - setXY(0,0,disp_x_size,disp_y_size); + if (orient == PORTRAIT) + setXY(0, 0, disp_x_size, disp_y_size); else - setXY(0,0,disp_y_size,disp_x_size); + setXY(0, 0, disp_y_size, disp_x_size); } void UTFT::resetXY() @@ -231,101 +231,101 @@ void UTFT::resetXY() void UTFT::drawRect(int x1, int y1, int x2, int y2) { - if (x1>x2) + if (x1 > x2) { swap(int, x1, x2); } - if (y1>y2) + if (y1 > y2) { swap(int, y1, y2); } - drawHLine(x1, y1, x2-x1); - drawHLine(x1, y2, x2-x1); - drawVLine(x1, y1, y2-y1); - drawVLine(x2, y1, y2-y1); + drawHLine(x1, y1, x2 - x1); + drawHLine(x1, y2, x2 - x1); + drawVLine(x1, y1, y2 - y1); + drawVLine(x2, y1, y2 - y1); } void UTFT::drawRoundRect(int x1, int y1, int x2, int y2) { - if (x1>x2) + if (x1 > x2) { swap(int, x1, x2); } - if (y1>y2) + if (y1 > y2) { swap(int, y1, y2); } - if ((x2-x1)>4 && (y2-y1)>4) + if ((x2 - x1) > 4 && (y2 - y1) > 4) { - drawPixel(x1+1,y1+1); - drawPixel(x2-1,y1+1); - drawPixel(x1+1,y2-1); - drawPixel(x2-1,y2-1); - drawHLine(x1+2, y1, x2-x1-4); - drawHLine(x1+2, y2, x2-x1-4); - drawVLine(x1, y1+2, y2-y1-4); - drawVLine(x2, y1+2, y2-y1-4); + drawPixel(x1 + 1, y1 + 1); + drawPixel(x2 - 1, y1 + 1); + drawPixel(x1 + 1, y2 - 1); + drawPixel(x2 - 1, y2 - 1); + drawHLine(x1 + 2, y1, x2 - x1 - 4); + drawHLine(x1 + 2, y2, x2 - x1 - 4); + drawVLine(x1, y1 + 2, y2 - y1 - 4); + drawVLine(x2, y1 + 2, y2 - y1 - 4); } } void UTFT::fillRect(int x1, int y1, int x2, int y2) { - if (x1>x2) + if (x1 > x2) { swap(int, x1, x2); } - if (y1>y2) + if (y1 > y2) { swap(int, y1, y2); } - - if (orient==PORTRAIT) + + if (orient == PORTRAIT) { - for (int i=0; i<((y2-y1)/2)+1; i++) + for (int i = 0; i < ((y2 - y1) / 2) + 1; i++) { - drawHLine(x1, y1+i, x2-x1); - drawHLine(x1, y2-i, x2-x1); + drawHLine(x1, y1 + i, x2 - x1); + drawHLine(x1, y2 - i, x2 - x1); } } else { - for (int i=0; i<((x2-x1)/2)+1; i++) + for (int i = 0; i < ((x2 - x1) / 2) + 1; i++) { - drawVLine(x1+i, y1, y2-y1); - drawVLine(x2-i, y1, y2-y1); + drawVLine(x1 + i, y1, y2 - y1); + drawVLine(x2 - i, y1, y2 - y1); } } } void UTFT::fillRoundRect(int x1, int y1, int x2, int y2) { - if (x1>x2) + if (x1 > x2) { swap(int, x1, x2); } - if (y1>y2) + if (y1 > y2) { swap(int, y1, y2); } - if ((x2-x1)>4 && (y2-y1)>4) + if ((x2 - x1) > 4 && (y2 - y1) > 4) { - for (int i=0; i<((y2-y1)/2)+1; i++) + for (int i = 0; i < ((y2 - y1) / 2) + 1; i++) { - switch(i) + switch (i) { case 0: - drawHLine(x1+2, y1+i, x2-x1-4); - drawHLine(x1+2, y2-i, x2-x1-4); + drawHLine(x1 + 2, y1 + i, x2 - x1 - 4); + drawHLine(x1 + 2, y2 - i, x2 - x1 - 4); break; case 1: - drawHLine(x1+1, y1+i, x2-x1-2); - drawHLine(x1+1, y2-i, x2-x1-2); + drawHLine(x1 + 1, y1 + i, x2 - x1 - 2); + drawHLine(x1 + 1, y2 - i, x2 - x1 - 2); break; default: - drawHLine(x1, y1+i, x2-x1); - drawHLine(x1, y2-i, x2-x1); + drawHLine(x1, y1 + i, x2 - x1); + drawHLine(x1, y2 - i, x2 - x1); } } } @@ -338,20 +338,20 @@ void UTFT::drawCircle(int x, int y, int radius) int ddF_y = -2 * radius; int x1 = 0; int y1 = radius; - + UTFT_cbi(P_CS, B_CS); setXY(x, y + radius, x, y + radius); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x, y - radius, x, y - radius); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x + radius, y, x + radius, y); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x - radius, y, x - radius, y); - LCD_Write_DATA(fch,fcl); - - while(x1 < y1) + LCD_Write_DATA(fch, fcl); + + while (x1 < y1) { - if(f >= 0) + if (f >= 0) { y1--; ddF_y += 2; @@ -359,23 +359,23 @@ void UTFT::drawCircle(int x, int y, int radius) } x1++; ddF_x += 2; - f += ddF_x; + f += ddF_x; setXY(x + x1, y + y1, x + x1, y + y1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x - x1, y + y1, x - x1, y + y1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x + x1, y - y1, x + x1, y - y1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x - x1, y - y1, x - x1, y - y1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x + y1, y + x1, x + y1, y + x1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x - y1, y + x1, x - y1, y + x1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x + y1, y - x1, x + y1, y - x1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); setXY(x - y1, y - x1, x - y1, y - x1); - LCD_Write_DATA(fch,fcl); + LCD_Write_DATA(fch, fcl); } UTFT_sbi(P_CS, B_CS); clrXY(); @@ -383,12 +383,12 @@ void UTFT::drawCircle(int x, int y, int radius) void UTFT::fillCircle(int x, int y, int radius) { - for(int y1=-radius; y1<=0; y1++) - for(int x1=-radius; x1<=0; x1++) - if(x1*x1+y1*y1 <= radius*radius) + for (int y1 = -radius; y1 <= 0; y1++) + for (int x1 = -radius; x1 <= 0; x1++) + if (x1 * x1 + y1 * y1 <= radius * radius) { - drawHLine(x+x1, y+y1, 2*(-x1)); - drawHLine(x+x1, y-y1, 2*(-x1)); + drawHLine(x + x1, y + y1, 2 * (-x1)); + drawHLine(x + x1, y - y1, 2 * (-x1)); break; } } @@ -396,30 +396,30 @@ void UTFT::fillCircle(int x, int y, int radius) void UTFT::clrScr() { long i; - + clrXY(); - for (i=0; i<((disp_x_size+1)*(disp_y_size+1)); i++) + for (i = 0; i < ((disp_x_size + 1) * (disp_y_size + 1)); i++) { - if (display_transfer_mode!=1) - LCD_Writ_Bus(0x00,0x00); + if (display_transfer_mode != 1) + LCD_Writ_Bus(0x00, 0x00); else { - LCD_Writ_Bus(1,0); - LCD_Writ_Bus(1,0); - - //LCD_Writ_Bus(00,0x55); + LCD_Writ_Bus(1, 0); + LCD_Writ_Bus(1, 0); + + // LCD_Writ_Bus(00,0x55); } - //delay(1); -#if defined(ESP8266) - yield(); -#endif + // delay(1); +#if defined(ESP8266) + yield(); +#endif } } void UTFT::fillScr(byte r, byte g, byte b) { - word color = ((r&248)<<8 | (g&252)<<3 | (b&248)>>3); + word color = ((r & 248) << 8 | (g & 252) << 3 | (b & 248) >> 3); fillScr(color); } @@ -427,102 +427,101 @@ void UTFT::fillScr(word color) { long i; char ch, cl; - - ch=byte(color>>8); - cl=byte(color & 0xFF); + + ch = byte(color >> 8); + cl = byte(color & 0xFF); clrXY(); - - for (i=0; i<((disp_x_size+1)*(disp_y_size+1)); i++) + + for (i = 0; i < ((disp_x_size + 1) * (disp_y_size + 1)); i++) { - if (display_transfer_mode!=1) - LCD_Writ_Bus(ch,cl); + if (display_transfer_mode != 1) + LCD_Writ_Bus(ch, cl); else { - LCD_Writ_Bus(1,ch); - LCD_Writ_Bus(1,cl); + LCD_Writ_Bus(1, ch); + LCD_Writ_Bus(1, cl); } -#if defined(ESP8266) - yield(); -#endif +#if defined(ESP8266) + yield(); +#endif } - } void UTFT::setColor(byte r, byte g, byte b) { - fch=((r&248)|g>>5); - fcl=((g&28)<<3|b>>3); + fch = ((r & 248) | g >> 5); + fcl = ((g & 28) << 3 | b >> 3); } void UTFT::setColor(word color) { - fch=byte(color>>8); - fcl=byte(color & 0xFF); + fch = byte(color >> 8); + fcl = byte(color & 0xFF); } word UTFT::getColor() { - return (fch<<8) | fcl; + return (fch << 8) | fcl; } void UTFT::setBackColor(byte r, byte g, byte b) { - bch=((r&248)|g>>5); - bcl=((g&28)<<3|b>>3); - _transparent=false; + bch = ((r & 248) | g >> 5); + bcl = ((g & 28) << 3 | b >> 3); + _transparent = false; } void UTFT::setBackColor(uint32_t color) { - if (color==VGA_TRANSPARENT) - _transparent=true; + if (color == VGA_TRANSPARENT) + _transparent = true; else { - bch=byte(color>>8); - bcl=byte(color & 0xFF); - _transparent=false; + bch = byte(color >> 8); + bcl = byte(color & 0xFF); + _transparent = false; } } word UTFT::getBackColor() { - return (bch<<8) | bcl; + return (bch << 8) | bcl; } void UTFT::setPixel(word color) { - LCD_Write_DATA((color>>8),(color&0xFF)); // rrrrrggggggbbbbb + LCD_Write_DATA((color >> 8), (color & 0xFF)); // rrrrrggggggbbbbb } void UTFT::drawPixel(int x, int y) { setXY(x, y, x, y); - setPixel((fch<<8)|fcl); + setPixel((fch << 8) | fcl); clrXY(); } void UTFT::drawLine(int x1, int y1, int x2, int y2) { - if (y1==y2) - drawHLine(x1, y1, x2-x1); - else if (x1==x2) - drawVLine(x1, y1, y2-y1); + if (y1 == y2) + drawHLine(x1, y1, x2 - x1); + else if (x1 == x2) + drawVLine(x1, y1, y2 - y1); else { - unsigned int dx = (x2 > x1 ? x2 - x1 : x1 - x2); - short xstep = x2 > x1 ? 1 : -1; - unsigned int dy = (y2 > y1 ? y2 - y1 : y1 - y2); - short ystep = y2 > y1 ? 1 : -1; - int col = x1, row = y1; + unsigned int dx = (x2 > x1 ? x2 - x1 : x1 - x2); + short xstep = x2 > x1 ? 1 : -1; + unsigned int dy = (y2 > y1 ? y2 - y1 : y1 - y2); + short ystep = y2 > y1 ? 1 : -1; + int col = x1, row = y1; if (dx < dy) { - int t = - (dy >> 1); + int t = -(dy >> 1); while (true) { - setXY (col, row, col, row); - LCD_Write_DATA (fch, fcl); + setXY(col, row, col, row); + LCD_Write_DATA(fch, fcl); if (row == y2) return; row += ystep; @@ -530,17 +529,17 @@ void UTFT::drawLine(int x1, int y1, int x2, int y2) if (t >= 0) { col += xstep; - t -= dy; + t -= dy; } - } + } } else { - int t = - (dx >> 1); + int t = -(dx >> 1); while (true) { - setXY (col, row, col, row); - LCD_Write_DATA (fch, fcl); + setXY(col, row, col, row); + LCD_Write_DATA(fch, fcl); if (col == x2) return; col += xstep; @@ -548,9 +547,9 @@ void UTFT::drawLine(int x1, int y1, int x2, int y2) if (t >= 0) { row += ystep; - t -= dx; + t -= dx; } - } + } } } clrXY(); @@ -558,23 +557,23 @@ void UTFT::drawLine(int x1, int y1, int x2, int y2) void UTFT::drawHLine(int x, int y, int l) { - if (l<0) + if (l < 0) { l = -l; x -= l; } - setXY(x, y, x+l, y); + setXY(x, y, x + l, y); if (display_transfer_mode == 16) { - _fast_fill_16(fch,fcl,l); + _fast_fill_16(fch, fcl, l); } - else if ((display_transfer_mode==8) and (fch==fcl)) + else if ((display_transfer_mode == 8) and (fch == fcl)) { - _fast_fill_8(fch,l); + _fast_fill_8(fch, l); } else { - for (int i=0; i=0; zz--) + setXY(x, y + (j / (cfont.x_size / 8)), x + cfont.x_size - 1, y + (j / (cfont.x_size / 8))); + for (int zz = (cfont.x_size / 8) - 1; zz >= 0; zz--) { - ch=pgm_read_byte(&cfont.font[temp+zz]); - for(i=0;i<8;i++) - { - if((ch&(1<0) + + while (num > 0) { - buf[c]=48+(num % 10); + buf[c] = 48 + (num % 10); c++; - num=(num-(num % 10))/10; + num = (num - (num % 10)) / 10; } - buf[c]=0; - + buf[c] = 0; + if (neg) { - st[0]=45; + st[0] = 45; } - - if (length>(c+neg)) + + if (length > (c + neg)) { - for (int i=0; i<(length-c-neg); i++) + for (int i = 0; i < (length - c - neg); i++) { - st[i+neg]=filler; + st[i + neg] = filler; f++; } } - for (int i=0; i5) - dec=5; + if (dec < 1) + dec = 1; + else if (dec > 5) + dec = 5; - if (num<0) + if (num < 0) neg = true; _convert_float(st, num, length, dec); if (divider != '.') { - for (unsigned int i=0; i>8,col & 0xff); + col = pgm_read_word(&data[tc]); + LCD_Write_DATA(col >> 8, col & 0xff); } } else { - for (ty=0; ty=0; tx--) + setXY(x, y + ty, x + sx - 1, y + ty); + for (tx = sx - 1; tx >= 0; tx--) { - col=pgm_read_word(&data[(ty*sx)+tx]); - LCD_Write_DATA(col>>8,col & 0xff); + col = pgm_read_word(&data[(ty * sx) + tx]); + LCD_Write_DATA(col >> 8, col & 0xff); } } } } else { - if (orient==PORTRAIT) + if (orient == PORTRAIT) { - for (ty=0; ty>8,col & 0xff); + col = pgm_read_word(&data[(ty * sx) + tx]); + for (tsx = 0; tsx < scale; tsx++) + LCD_Write_DATA(col >> 8, col & 0xff); } } } else { - for (ty=0; ty=0; tx--) + setXY(x, y + (ty * scale) + tsy, x + ((sx * scale) - 1), y + (ty * scale) + tsy); + for (tx = sx - 1; tx >= 0; tx--) { - col=pgm_read_word(&data[(ty*sx)+tx]); - for (tsx=0; tsx>8,col & 0xff); + col = pgm_read_word(&data[(ty * sx) + tx]); + for (tsx = 0; tsx < scale; tsx++) + LCD_Write_DATA(col >> 8, col & 0xff); } } } @@ -960,22 +958,22 @@ void UTFT::drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg unsigned int col; int tx, ty, newx, newy; double radian; - radian=deg*0.0175; + radian = deg * 0.0175; - if (deg==0) + if (deg == 0) drawBitmap(x, y, sx, sy, data); else { - for (ty=0; ty>8,col & 0xff); + LCD_Write_DATA(col >> 8, col & 0xff); } } clrXY(); @@ -983,61 +981,52 @@ void UTFT::drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg void UTFT::lcdOff() { - } void UTFT::lcdOn() { - } void UTFT::setContrast(char c) { - } int UTFT::getDisplayXSize() { - if (orient==PORTRAIT) - return disp_x_size+1; + if (orient == PORTRAIT) + return disp_x_size + 1; else - return disp_y_size+1; + return disp_y_size + 1; } int UTFT::getDisplayYSize() { - if (orient==PORTRAIT) - return disp_y_size+1; + if (orient == PORTRAIT) + return disp_y_size + 1; else - return disp_x_size+1; + return disp_x_size + 1; } void UTFT::_fast_fill_16(int ch, int cl, long pix) { - } void UTFT::_fast_fill_8(int ch, long pix) { - } void UTFT::setBrightness(byte br) { - } void UTFT::setDisplayPage(byte page) { - } void UTFT::setWritePage(byte page) { - } void UTFT::_convert_float(char *buf, double num, int width, byte prec) { - } diff --git a/UTFT4ArduCAM_SPI/UTFT_SPI.h b/UTFT4ArduCAM_SPI/UTFT_SPI.h index b2fd5257..9f644128 100644 --- a/UTFT4ArduCAM_SPI/UTFT_SPI.h +++ b/UTFT4ArduCAM_SPI/UTFT_SPI.h @@ -1,38 +1,38 @@ /* UTFT_SPI.h - Arduino library support for Color TFT LCD Boards - This is special porting for ArduCAM shield LCD screen. - Use SPI bus interface and SSD1289 controller. Only work on + This is special porting for ArduCAM shield LCD screen. + Use SPI bus interface and SSD1289 controller. Only work on ArduCAM shield Rev.C. For more information about ArduCAM shield please visit www.arducam.com Copyright (C)2010-2014 Henning Karlsen. All right reserved - + This library is the continuation of my ITDB02_Graph, ITDB02_Graph16 - and RGB_GLCD libraries for Arduino and chipKit. As the number of - supported display modules and controllers started to increase I felt - it was time to make a single, universal library as it will be much + and RGB_GLCD libraries for Arduino and chipKit. As the number of + supported display modules and controllers started to increase I felt + it was time to make a single, universal library as it will be much easier to maintain in the future. - Basic functionality of this library was origianlly based on the - demo-code provided by ITead studio (for the ITDB02 modules) and + Basic functionality of this library was origianlly based on the + demo-code provided by ITead studio (for the ITDB02 modules) and NKC Electronics (for the RGB GLCD module/shield). - This library supports a number of 8bit, 16bit and serial graphic - displays, and will work with both Arduino and chipKit boards. For a - full list of tested display modules and controllers, see the + This library supports a number of 8bit, 16bit and serial graphic + displays, and will work with both Arduino and chipKit boards. For a + full list of tested display modules and controllers, see the document UTFT_Supported_display_modules_&_controllers.pdf. - When using 8bit and 16bit display modules there are some - requirements you must adhere to. These requirements can be found + When using 8bit and 16bit display modules there are some + requirements you must adhere to. These requirements can be found in the document UTFT_Requirements.pdf. There are no special requirements when using serial displays. - You can always find the latest version of the library at + You can always find the latest version of the library at http://electronics.henningkarlsen.com/ - If you make any modifications or improvements to the code, I would - appreciate that you share the code with me so that I might include - it in the next release. I can be contacted through + If you make any modifications or improvements to the code, I would + appreciate that you share the code with me so that I might include + it in the next release. I can be contacted through http://electronics.henningkarlsen.com/contact.php. This library is free software; you can redistribute it and/or @@ -60,152 +60,152 @@ #define PORTRAIT 1 #define LANDSCAPE 0 -#define HX8347A 0 -#define ILI9327 1 -#define SSD1289 2 -#define ILI9325C 3 -#define ILI9325D_8 4 -#define ILI9325D_16 5 -#define HX8340B_8 6 -#define HX8340B_S 7 -#define HX8352A 8 -#define ST7735 9 -#define PCF8833 10 -#define S1D19122 11 -#define SSD1963_480 12 -#define SSD1963_800 13 -#define S6D1121_8 14 -#define S6D1121_16 15 -#define SSD1289LATCHED 16 -//#define NOT_IN_USE 17 -//#define NOT_IN_USE 18 -#define SSD1289_8 19 -#define SSD1963_800ALT 20 -#define ILI9481 21 -#define ILI9325D_16ALT 22 -#define S6D0164 23 -#define ST7735S 24 -#define ILI9341_S5P 25 -#define ILI9341_S4P 26 -#define R61581 27 -#define ILI9486 28 -#define CPLD 29 -#define HX8353C 30 -#define ST7735_ALT 31 +#define HX8347A 0 +#define ILI9327 1 +#define SSD1289 2 +#define ILI9325C 3 +#define ILI9325D_8 4 +#define ILI9325D_16 5 +#define HX8340B_8 6 +#define HX8340B_S 7 +#define HX8352A 8 +#define ST7735 9 +#define PCF8833 10 +#define S1D19122 11 +#define SSD1963_480 12 +#define SSD1963_800 13 +#define S6D1121_8 14 +#define S6D1121_16 15 +#define SSD1289LATCHED 16 +// #define NOT_IN_USE 17 +// #define NOT_IN_USE 18 +#define SSD1289_8 19 +#define SSD1963_800ALT 20 +#define ILI9481 21 +#define ILI9325D_16ALT 22 +#define S6D0164 23 +#define ST7735S 24 +#define ILI9341_S5P 25 +#define ILI9341_S4P 26 +#define R61581 27 +#define ILI9486 28 +#define CPLD 29 +#define HX8353C 30 +#define ST7735_ALT 31 -#define ITDB32 0 // HX8347-A (16bit) -#define ITDB32WC 1 // ILI9327 (16bit) -#define TFT01_32W 1 // ILI9327 (16bit) -#define ITDB32S 2 // SSD1289 (16bit) -#define TFT01_32 2 // SSD1289 (16bit) -#define CTE32 2 // SSD1289 (16bit) -#define ITDB24 3 // ILI9325C (8bit) -#define ITDB24D 4 // ILI9325D (8bit) -#define ITDB24DWOT 4 // ILI9325D (8bit) -#define ITDB28 4 // ILI9325D (8bit) -#define TFT01_24_8 4 // ILI9325D (8bit) -#define DMTFT24104 4 // ILI9325D (8bit) -#define DMTFT28103 4 // ILI9325D (8bit) -#define TFT01_24_16 5 // ILI9325D (16bit) -#define ITDB22 6 // HX8340-B (8bit) -#define ITDB22SP 7 // HX8340-B (Serial 4Pin) -#define ITDB32WD 8 // HX8352-A (16bit) -#define TFT01_32WD 8 // HX8352-A (16bit) -#define CTE32W 8 // HX8352-A (16bit) -#define ITDB18SP 9 // ST7735 (Serial 5Pin) -#define LPH9135 10 // PCF8833 (Serial 5Pin) -#define ITDB25H 11 // S1D19122 (16bit) -#define ITDB43 12 // SSD1963 (16bit) 480x272 -#define TFT01_43 12 // SSD1963 (16bit) 480x272 -#define ITDB50 13 // SSD1963 (16bit) 800x480 -#define TFT01_50 13 // SSD1963 (16bit) 800x480 -#define CTE50 13 // SSD1963 (16bit) 800x480 -#define EHOUSE50 13 // SSD1963 (16bit) 800x480 -#define ITDB24E_8 14 // S6D1121 (8bit) -#define TFT01_24R2 14 // S6D1121 (8bit) -#define ITDB24E_16 15 // S6D1121 (16bit) -#define INFINIT32 16 // SSD1289 (Latched 16bit) -- Legacy, will be removed later -#define ELEE32_REVA 16 // SSD1289 (Latched 16bit) -//#define NOT_IN_USE 17 -//#define NOT_IN_USE 18 -#define ELEE32_REVB 19 // SSD1289 (8bit) -#define TFT01_70 20 // SSD1963 (16bit) 800x480 Alternative Init -#define CTE70 20 // SSD1963 (16bit) 800x480 Alternative Init -#define EHOUSE70 20 // SSD1963 (16bit) 800x480 Alternative Init -#define CTE32HR 21 // ILI9481 (16bit) -#define CTE28 22 // ILI9325D (16bit) Alternative Init -#define TFT01_28 22 // ILI9325D (16bit) Alternative Init -#define CTE22 23 // S6D0164 (8bit) -#define TFT01_22 23 // S6D0164 (8bit) -#define DMTFT22102 23 // S6D0164 (8bit) -#define TFT01_18SP 24 // ST7735S (Serial 5Pin) -#define TFT01_22SP 25 // ILI9341 (Serial 5Pin) -#define TFT01_24SP 25 // ILI9341 (Serial 5Pin) -#define TFT22SHLD 25 // ILI9341 (Serial 5Pin) -#define DMTFT28105 25 // ILI9341 (Serial 5Pin) -#define MI0283QT9 26 // ILI9341 (Serial 4Pin) -#define CTE35IPS 27 // R61581 (16bit) -#define CTE40 28 // ILI9486 (16bit) -#define EHOUSE50CPLD 29 // CPLD (16bit) -#define CTE50CPLD 29 // CPLD (16bit) -#define CTE70CPLD 29 // CPLD (16bit) -#define DMTFT18101 30 // HX8353C (Serial 5Pin) -#define TFT18SHLD 31 // ST7735 (Serial 5Pin) Alternative Init +#define ITDB32 0 // HX8347-A (16bit) +#define ITDB32WC 1 // ILI9327 (16bit) +#define TFT01_32W 1 // ILI9327 (16bit) +#define ITDB32S 2 // SSD1289 (16bit) +#define TFT01_32 2 // SSD1289 (16bit) +#define CTE32 2 // SSD1289 (16bit) +#define ITDB24 3 // ILI9325C (8bit) +#define ITDB24D 4 // ILI9325D (8bit) +#define ITDB24DWOT 4 // ILI9325D (8bit) +#define ITDB28 4 // ILI9325D (8bit) +#define TFT01_24_8 4 // ILI9325D (8bit) +#define DMTFT24104 4 // ILI9325D (8bit) +#define DMTFT28103 4 // ILI9325D (8bit) +#define TFT01_24_16 5 // ILI9325D (16bit) +#define ITDB22 6 // HX8340-B (8bit) +#define ITDB22SP 7 // HX8340-B (Serial 4Pin) +#define ITDB32WD 8 // HX8352-A (16bit) +#define TFT01_32WD 8 // HX8352-A (16bit) +#define CTE32W 8 // HX8352-A (16bit) +#define ITDB18SP 9 // ST7735 (Serial 5Pin) +#define LPH9135 10 // PCF8833 (Serial 5Pin) +#define ITDB25H 11 // S1D19122 (16bit) +#define ITDB43 12 // SSD1963 (16bit) 480x272 +#define TFT01_43 12 // SSD1963 (16bit) 480x272 +#define ITDB50 13 // SSD1963 (16bit) 800x480 +#define TFT01_50 13 // SSD1963 (16bit) 800x480 +#define CTE50 13 // SSD1963 (16bit) 800x480 +#define EHOUSE50 13 // SSD1963 (16bit) 800x480 +#define ITDB24E_8 14 // S6D1121 (8bit) +#define TFT01_24R2 14 // S6D1121 (8bit) +#define ITDB24E_16 15 // S6D1121 (16bit) +#define INFINIT32 16 // SSD1289 (Latched 16bit) -- Legacy, will be removed later +#define ELEE32_REVA 16 // SSD1289 (Latched 16bit) +// #define NOT_IN_USE 17 +// #define NOT_IN_USE 18 +#define ELEE32_REVB 19 // SSD1289 (8bit) +#define TFT01_70 20 // SSD1963 (16bit) 800x480 Alternative Init +#define CTE70 20 // SSD1963 (16bit) 800x480 Alternative Init +#define EHOUSE70 20 // SSD1963 (16bit) 800x480 Alternative Init +#define CTE32HR 21 // ILI9481 (16bit) +#define CTE28 22 // ILI9325D (16bit) Alternative Init +#define TFT01_28 22 // ILI9325D (16bit) Alternative Init +#define CTE22 23 // S6D0164 (8bit) +#define TFT01_22 23 // S6D0164 (8bit) +#define DMTFT22102 23 // S6D0164 (8bit) +#define TFT01_18SP 24 // ST7735S (Serial 5Pin) +#define TFT01_22SP 25 // ILI9341 (Serial 5Pin) +#define TFT01_24SP 25 // ILI9341 (Serial 5Pin) +#define TFT22SHLD 25 // ILI9341 (Serial 5Pin) +#define DMTFT28105 25 // ILI9341 (Serial 5Pin) +#define MI0283QT9 26 // ILI9341 (Serial 4Pin) +#define CTE35IPS 27 // R61581 (16bit) +#define CTE40 28 // ILI9486 (16bit) +#define EHOUSE50CPLD 29 // CPLD (16bit) +#define CTE50CPLD 29 // CPLD (16bit) +#define CTE70CPLD 29 // CPLD (16bit) +#define DMTFT18101 30 // HX8353C (Serial 5Pin) +#define TFT18SHLD 31 // ST7735 (Serial 5Pin) Alternative Init -#define SERIAL_4PIN 4 -#define SERIAL_5PIN 5 -#define LATCHED_16 17 +#define SERIAL_4PIN 4 +#define SERIAL_5PIN 5 +#define LATCHED_16 17 -#define NOTINUSE 255 +#define NOTINUSE 255 //********************************* // COLORS //********************************* // VGA color palette -#define VGA_BLACK 0x0000 -#define VGA_WHITE 0xFFFF -#define VGA_RED 0xF800 -#define VGA_GREEN 0x0400 -#define VGA_BLUE 0x001F -#define VGA_SILVER 0xC618 -#define VGA_GRAY 0x8410 -#define VGA_MAROON 0x8000 -#define VGA_YELLOW 0xFFE0 -#define VGA_OLIVE 0x8400 -#define VGA_LIME 0x07E0 -#define VGA_AQUA 0x07FF -#define VGA_TEAL 0x0410 -#define VGA_NAVY 0x0010 -#define VGA_FUCHSIA 0xF81F -#define VGA_PURPLE 0x8010 -#define VGA_TRANSPARENT 0xFFFFFFFF +#define VGA_BLACK 0x0000 +#define VGA_WHITE 0xFFFF +#define VGA_RED 0xF800 +#define VGA_GREEN 0x0400 +#define VGA_BLUE 0x001F +#define VGA_SILVER 0xC618 +#define VGA_GRAY 0x8410 +#define VGA_MAROON 0x8000 +#define VGA_YELLOW 0xFFE0 +#define VGA_OLIVE 0x8400 +#define VGA_LIME 0x07E0 +#define VGA_AQUA 0x07FF +#define VGA_TEAL 0x0410 +#define VGA_NAVY 0x0010 +#define VGA_FUCHSIA 0xF81F +#define VGA_PURPLE 0x8010 +#define VGA_TRANSPARENT 0xFFFFFFFF #if defined(__AVR__) - #if defined(ARDUINO) && ARDUINO >= 100 - #include "Arduino.h" - #else - #include "WProgram.h" - #endif - #include "HW_AVR_SPI_defines.h" +#if defined(ARDUINO) && ARDUINO >= 100 +#include "Arduino.h" +#else +#include "WProgram.h" +#endif +#include "HW_AVR_SPI_defines.h" #endif #if defined(__arm__) || defined(ESP8266) - #include "Arduino.h" - #include "HW_AVR_SPI_defines.h" +#include "Arduino.h" +#include "HW_AVR_SPI_defines.h" #endif #if defined(__CPU_ARC__) - #include "Arduino.h" - #include "HW_AVR_SPI_defines.h" +#include "Arduino.h" +#include "HW_AVR_SPI_defines.h" #endif #define BMPIMAGEOFFSET 66 - + struct _current_font { - uint8_t* font; + uint8_t *font; uint8_t x_size; uint8_t y_size; uint8_t offset; @@ -214,85 +214,85 @@ struct _current_font class UTFT { - public: - UTFT(); - UTFT(int CS); - void InitLCD(byte orientation=LANDSCAPE); - void clrScr(); - void drawPixel(int x, int y); - void drawLine(int x1, int y1, int x2, int y2); - void fillScr(byte r, byte g, byte b); - void fillScr(word color); - void drawRect(int x1, int y1, int x2, int y2); - void drawRoundRect(int x1, int y1, int x2, int y2); - void fillRect(int x1, int y1, int x2, int y2); - void fillRoundRect(int x1, int y1, int x2, int y2); - void drawCircle(int x, int y, int radius); - void fillCircle(int x, int y, int radius); - void setColor(byte r, byte g, byte b); - void setColor(word color); - word getColor(); - void setBackColor(byte r, byte g, byte b); - void setBackColor(uint32_t color); - word getBackColor(); - void print(char *st, int x, int y, int deg=0); - void print(String st, int x, int y, int deg=0); - void printNumI(long num, int x, int y, int length=0, char filler=' '); - void printNumF(double num, byte dec, int x, int y, char divider='.', int length=0, char filler=' '); - void setFont(uint8_t* font); - uint8_t* getFont(); - uint8_t getFontXsize(); - uint8_t getFontYsize(); - void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int scale=1); - void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg, int rox, int roy); - int getDisplayXSize(); - int getDisplayYSize(); - - //***********not use***************** - void lcdOff(); - void lcdOn(); - void setContrast(char c); - void setBrightness(byte br); - void setDisplayPage(byte page); - void setWritePage(byte page); - //*********************************** - - int bus_write(int address, int value); - uint8_t bus_read(int address); - - //void dispBitmap(File inFile); +public: + UTFT(); + UTFT(int CS); + void InitLCD(byte orientation = LANDSCAPE); + void clrScr(); + void drawPixel(int x, int y); + void drawLine(int x1, int y1, int x2, int y2); + void fillScr(byte r, byte g, byte b); + void fillScr(word color); + void drawRect(int x1, int y1, int x2, int y2); + void drawRoundRect(int x1, int y1, int x2, int y2); + void fillRect(int x1, int y1, int x2, int y2); + void fillRoundRect(int x1, int y1, int x2, int y2); + void drawCircle(int x, int y, int radius); + void fillCircle(int x, int y, int radius); + void setColor(byte r, byte g, byte b); + void setColor(word color); + word getColor(); + void setBackColor(byte r, byte g, byte b); + void setBackColor(uint32_t color); + word getBackColor(); + void print(char *st, int x, int y, int deg = 0); + void print(String st, int x, int y, int deg = 0); + void printNumI(long num, int x, int y, int length = 0, char filler = ' '); + void printNumF(double num, byte dec, int x, int y, char divider = '.', int length = 0, char filler = ' '); + void setFont(uint8_t *font); + uint8_t *getFont(); + uint8_t getFontXsize(); + uint8_t getFontYsize(); + void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int scale = 1); + void drawBitmap(int x, int y, int sx, int sy, bitmapdatatype data, int deg, int rox, int roy); + int getDisplayXSize(); + int getDisplayYSize(); -/* - The functions and variables below should not normally be used. - They have been left publicly available for use in add-on libraries -*/ - byte fch, fcl, bch, bcl; - byte orient; - byte model; - long disp_x_size, disp_y_size; - byte display_model, display_transfer_mode, display_serial_mode; - regtype *P_RS, *P_WR, *P_CS, *P_RST, *P_SDA, *P_SCL, *P_ALE; - regsize B_RS, B_WR, B_CS, B_RST, B_SDA, B_SCL, B_ALE; - byte __p1, __p2, __p3, __p4, __p5; - _current_font cfont; - boolean _transparent; + //***********not use***************** + void lcdOff(); + void lcdOn(); + void setContrast(char c); + void setBrightness(byte br); + void setDisplayPage(byte page); + void setWritePage(byte page); + //*********************************** + + int bus_write(int address, int value); + uint8_t bus_read(int address); + + // void dispBitmap(File inFile); + + /* + The functions and variables below should not normally be used. + They have been left publicly available for use in add-on libraries + */ + byte fch, fcl, bch, bcl; + byte orient; + byte model; + long disp_x_size, disp_y_size; + byte display_model, display_transfer_mode, display_serial_mode; + regtype *P_RS, *P_WR, *P_CS, *P_RST, *P_SDA, *P_SCL, *P_ALE; + regsize B_RS, B_WR, B_CS, B_RST, B_SDA, B_SCL, B_ALE; + byte __p1, __p2, __p3, __p4, __p5; + _current_font cfont; + boolean _transparent; - void LCD_Writ_Bus(char VH,char VL); - void LCD_Write_COM(char VL); - void LCD_Write_DATA(char VH,char VL); - void LCD_Write_COM_DATA(char com1,int dat1); - void setPixel(word color); - void drawHLine(int x, int y, int l); - void drawVLine(int x, int y, int l); - void printChar(byte c, int x, int y); - void setXY(word x1, word y1, word x2, word y2); - void clrXY(); - void resetXY(); - void rotateChar(byte c, int x, int y, int pos, int deg); - void _set_direction_registers(byte mode); - void _fast_fill_16(int ch, int cl, long pix); - void _fast_fill_8(int ch, long pix); - void _convert_float(char *buf, double num, int width, byte prec); + void LCD_Writ_Bus(char VH, char VL); + void LCD_Write_COM(char VL); + void LCD_Write_DATA(char VH, char VL); + void LCD_Write_COM_DATA(char com1, int dat1); + void setPixel(word color); + void drawHLine(int x, int y, int l); + void drawVLine(int x, int y, int l); + void printChar(byte c, int x, int y); + void setXY(word x1, word y1, word x2, word y2); + void clrXY(); + void resetXY(); + void rotateChar(byte c, int x, int y, int pos, int deg); + void _set_direction_registers(byte mode); + void _fast_fill_16(int ch, int cl, long pix); + void _fast_fill_8(int ch, long pix); + void _convert_float(char *buf, double num, int width, byte prec); }; #endif \ No newline at end of file