From e5d176f6f42b7dcaaa587d69092b12a18e8ffe68 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 19 Nov 2021 11:45:07 +0100 Subject: [PATCH 01/31] init first LED --- tasmota/xdsp_19_max7219_matrix.ino | 275 +++++++++++++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 tasmota/xdsp_19_max7219_matrix.ino diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino new file mode 100644 index 000000000..97c20f00b --- /dev/null +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -0,0 +1,275 @@ +/* + xdsp_19_max7219_matrix.ino.ino - Support for MAX7219 based dot matrix displays for Tasmota + + Copyright (C) 2021 Michael Beuss + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifdef USE_DISPLAY +#ifdef USE_DISPLAY_MAX7219_MATRIX +/*********************************************************************************************\ + This driver enables the display of ascii text on MAX7219 based LED dot matrix modules. + + Connect the MAX7219 display module's pins to any free GPIOs of the ESP8266 or ESP32 module + and assign the pins as follows from Tasmota's GUI: + + DIN hardware pin --> "MAX7219 DIN" + CS hardware pin --> "MAX7219 CS" + CLK hardware pin --> "MAX7219 CLK" + + Once the GPIO configuration is saved and the ESP8266/ESP32 module restarts, + set the Display Model to 19 and Display Mode to 0 + using the command "Backlog DisplayModel 15 ; DisplayMode 0" + + If your display is a TM1637 with 6 digits, set Display Width to the number of digits your + display has, using the command "DisplayWidth 6". + + After the ESP8266/ESP32 module restarts again, turn ON the display with the command "Power 1" + + Now, the following "Display" commands can be used: + + + DisplayClear + + Clears the display, command: "DisplayClear" + + + DisplayNumber num [,position {0-(Settings->display_width-1))} [,leading_zeros {0|1} [,length {1 to Settings->display_width}]]] + + Clears and then displays number without decimal. command e.g., "DisplayNumber 1234" + Control 'leading zeros', 'length' and 'position' with "DisplayNumber 1234, , , " + 'leading zeros' can be 1 or 0 (default), 'length' can be 1 to Settings->display_width, 'position' can be 0 (left-most) to Settings->display_width (right-most). + See function description below for more details. + + DisplayNumberNC num [,position {0-(Settings->display_width-1))} [,leading_zeros {0|1} [,length {1 to Settings->display_width}]]] + + Display integer number as above, but without clearing first. e.g., "DisplayNumberNC 1234". Usage is same as above. + + + + DisplayFloat num [,position {0-(Settings->display_width-1)} [,precision {0-Settings->display_width} [,length {1 to Settings->display_width}]]] + + Clears and then displays float (with decimal point) command e.g., "DisplayFloat 12.34" + See function description below for more details. + + + + DisplayFloatNC num [,position {0-(Settings->display_width-1)} [,precision {0-Settings->display_width} [,length {1 to Settings->display_width}]]] + + Displays float (with decimal point) as above, but without clearing first. command e.g., "DisplayFloatNC 12.34" + See function description below for more details. + + + + DisplayRaw position {0-(Settings->display_width-1)},length {1 to Settings->display_width}, num1 [, num2[, num3[, num4[, ...upto Settings->display_width numbers]]]]] + + Takes upto Settings->display_width comma-separated integers (0-255) and displays raw segments. Each number represents a + 7-segment digit. Each 8-bit number represents individual segments of a digit. + For example, the command "DisplayRaw 0, 4, 255, 255, 255, 255" would display "[8.8.8.8.]" + + + + DisplayText text [, position {0-(Settings->display_width-1)} [,length {1 to Settings->display_width}]] + + Clears and then displays basic text. command e.g., "DisplayText ajith vasudevan" + Control 'length' and 'position' with "DisplayText , , " + 'length' can be 1 to Settings->display_width, 'position' can be 0 (left-most) to Settings->display_width-1 (right-most) + A caret(^) symbol in the text input is dispayed as the degrees(°) symbol. This is useful for displaying Temperature! + For example, the command "DisplayText 22.5^" will display "22.5°". + + + DisplayTextNC text [, position {0-Settings->display_width-1} [,length {1 to Settings->display_width}]] + + Clears first, then displays text. Usage is same as above. + + + + DisplayScrollText text [, num_loops] + + Displays scrolling text indefinitely, until another Display- command (other than DisplayScrollText + or DisplayScrollDelay is issued). Optionally, stop scrolling after num_loops iterations. + + + + DisplayScrollDelay delay {0-15} // default = 4 + + Sets the speed of text scroll. Smaller delay = faster scrolling. + + + + DisplayLevel num {0-100} + + Display a horizontal bar graph (0-100) command e.g., "DisplayLevel 50" will display [|||| ] + + + + DisplayClock 1|2|0 + + Displays a clock. + Commands "DisplayClock 1" // 12 hr format + "DisplayClock 2" // 24 hr format + "DisplayClock 0" // turn off clock + + +In addition, setting DisplayMode to 1 shows the time, setting it to 2 shows the date +and setting it to 3 alternates between time and date. + + + +\*********************************************************************************************/ + +#define XDSP_19 19 +#define CMD_MAX_LEN 55 + + +#include + +LedControl *max7219_Matrix; +bool max2791Matrix_init_done = false; +byte modulesPerRow = 4; + + +bool MAX7291Matrix_init(void) +{ + if (!PinUsed(GPIO_MAX7219DIN) || !PinUsed(GPIO_MAX7219CLK) || !PinUsed(GPIO_MAX7219CS)) + { + AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init GPIO pins missing DIN, CLK or CS")); + return false; // ensure necessariy pins are configurated + } + + Settings->display_model = XDSP_19; + Settings->display_cols[0] = Settings->display_width; + Settings->display_height = 1; + Settings->display_rows = Settings->display_height; + max7219_Matrix = new LedControl(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), modulesPerRow); + MAX7291Matrix_On(true); + MAX7291Matrix_Clear(); + MAX7291Matrix_Dim(); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init")); + max2791Matrix_init_done = true; + + max7219_Matrix->setLed(0, 3, 3, true); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: setLed 3,3")); + return true; +} + +bool MAX7291Matrix_On( bool on ) +{ + for (int addr = 0; addr < modulesPerRow; addr++) + { + max7219_Matrix->shutdown (addr, !on); // false: on, true: off + } + AddLog(LOG_LEVEL_INFO, PSTR("MTX: On %d"), on); + return true; + +} + +bool MAX7291Matrix_Dim(void) +{ + int dim = GetDisplayDimmer16(); + for (int addr = 0; addr < modulesPerRow; addr++) + { + max7219_Matrix->setIntensity(addr, dim); // 1..15 + } + AddLog(LOG_LEVEL_INFO, PSTR("DSP: Dim %d"), dim); + return true; +} + +// /*********************************************************************************************\ +// * Clears the display +// * Command: DisplayClear +// \*********************************************************************************************/ +bool MAX7291Matrix_Clear(void) +{ + for(int addr=0; addrclearDisplay(addr); + } + AddLog(LOG_LEVEL_INFO, PSTR("DSP: Clear")); + return true; +} + +// /*********************************************************************************************\ +// * Clears the display +// * Command: DisplayText +// \*********************************************************************************************/ +bool MAX7291Matrix_Text() +{ + char sString[CMD_MAX_LEN + 1]; + subStr(sString, XdrvMailbox.data, ",", 1); + MAX7291Matrix_Clear; + AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: sString %s"), sString); + + // test + uint8_t length = strlen(sString); + //if(length > modulesPerRow) + length = modulesPerRow; + + for(int addr = 0; addrsetLed(addr, 0, 1, true); + AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: setLed() %d, 0, 1)"), addr); + } + + return true; +} + +bool Xdsp19(uint8_t function) +{ + bool result = false; + + + if (FUNC_DISPLAY_INIT_DRIVER == function) + { + result = MAX7291Matrix_init(); + } + else{ + //if (max2791Matrix_init_done && (XDSP_19 == Settings->display_model)) { + switch (function) { + case FUNC_DISPLAY_MODEL: + result = true; + break; + case FUNC_DISPLAY_CLEAR: + result = MAX7291Matrix_Clear(); + break; + case FUNC_DISPLAY_DIM: + result = MAX7291Matrix_Dim(); + break; + case FUNC_DISPLAY_SEVENSEG_TEXT: + case FUNC_DISPLAY_SEVENSEG_TEXTNC: + case FUNC_DISPLAY_NUMBER: + case FUNC_DISPLAY_NUMBERNC: + case FUNC_DISPLAY_FLOAT: + case FUNC_DISPLAY_FLOATNC: + case FUNC_DISPLAY_RAW: + case FUNC_DISPLAY_LEVEL: + case FUNC_DISPLAY_SCROLLTEXT: + case FUNC_DISPLAY_CLOCK: + case FUNC_DISPLAY_DRAW_STRING: + result = MAX7291Matrix_Text(); + break; + case FUNC_DISPLAY_EVERY_50_MSECOND: + case FUNC_DISPLAY_EVERY_SECOND: + // ignore + return false; + default: + result = false; + } + } + return result; +} + + + +#endif // USE_DISPLAY_MAX7219_MATRIX +#endif // USE_DISPLAY From b3dd33f2488184076eceadaffabaca24f8fd8dd5 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 19 Nov 2021 11:47:00 +0100 Subject: [PATCH 02/31] first init --- tasmota/tasmota_template.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 0de887e9c..e3f3256fc 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -520,6 +520,15 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_SSD1331_CS), AGPIO(GPIO_SSD1331_DC), #endif // USE_DISPLAY_SSD1331 + +#ifdef USE_DISPLAY_MAX7219_MATRIX + #undef USE_DISPLAY_MAX7219 + #undef USE_DISPLAY_TM1637 + AGPIO(GPIO_MAX7219CLK), + AGPIO(GPIO_MAX7219DIN), + AGPIO(GPIO_MAX7219CS), +#endif // USE_DISPLAY_MAX7219_MATRIX + #ifdef USE_DISPLAY_TM1637 AGPIO(GPIO_TM1637CLK), AGPIO(GPIO_TM1637DIO), From 532e5069468f6aff76cf9d8dd2140bdb60b6fab8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 20 Nov 2021 17:28:38 +0100 Subject: [PATCH 03/31] use LedMatrix 1234 --- lib/lib_display/LedControl/src/LedMatrix.cpp | 186 +++++++++++++++++++ lib/lib_display/LedControl/src/LedMatrix.h | 124 +++++++++++++ tasmota/xdsp_19_max7219_matrix.ino | 152 +++++++-------- 3 files changed, 373 insertions(+), 89 deletions(-) create mode 100644 lib/lib_display/LedControl/src/LedMatrix.cpp create mode 100644 lib/lib_display/LedControl/src/LedMatrix.h diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp new file mode 100644 index 000000000..427ae8c52 --- /dev/null +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -0,0 +1,186 @@ +/* + * LedMatrix.h - Extends the Library LedControl for multiple LED dot matrix modules, based on MAX7219/MAX7221 + * Copyright (c) 2021 Michael Beuss + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * This permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LedMatrix.h" + +// public +LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows) +{ + if (colums * rows > MATRIX_MAX_MODULES) + { + // dimension exeeds maximum buffer size + if (colums >= MATRIX_MAX_MODULES) + { + colums = MATRIX_MAX_MODULES; + rows = 1; + } + else + { + rows = MATRIX_MAX_MODULES / colums; + } + } + + modulesPerRow = colums; + modulesPerCol = rows; + width = colums * 8; + height = rows * 8; + modules = colums * rows; + moduleOrientation = ORIENTATION_UPSIDE_DOWN; + ledControl = new LedControl(dataPin, clkPin, csPin, modules); + shutdown(false); // false: on, true: off + clear(); + setIntensity(7); +} + +bool LedMatrix::clear(void) +{ + for (int i = 0; i < MATRIX_BUFFER_SIZE; i++) + { + buffer[i] = 0; + } + for (int addr = 0; addr < modules; addr++) + { + ledControl->clearDisplay(addr); + } + return true; +} + +bool LedMatrix::setIntensity(byte dim) +{ + for (int addr = 0; addr < modules; addr++) + { + ledControl->setIntensity(addr, dim); // 1..15 + } + return true; +} + +bool LedMatrix::setOrientation(ModuleOrientation orientation) +{ + moduleOrientation = orientation; + return true; +} + +bool LedMatrix::setPixel(int x, int y, bool on) +{ + if (x >= width || y >= height) + return false; + + int modul_col = x / 8; // x pos divided by 8 is the index of the modul to the right + int buffer_pos = modul_col + y * width / 8; + byte buffer_byte = 8 >> (x % 8); + if (on) + { + buffer[buffer_pos] |= buffer_byte; // set bit + } + else + { + buffer[buffer_pos] &= ~buffer_byte; // reset bit + } + refreshByteOfBuffer(buffer_pos); + return true; +} + +void LedMatrix::test() +{ + const static byte testMatrix[] PROGMEM = { + B00000010, B00111100, B00111100, B00001000, + B00000110, B01000010, B01000010, B00010000, + B00001010, B00000010, B00000010, B00100000, + B00000010, B00000100, B00001100, B01000100, + B00000010, B00011000, B00000010, B01111110, + B00000010, B00100000, B01000010, B00000100, + B00000000, B11111110, B00111100, B00000100, + B00000000, B00000000, B00000000, B00000000, + }; + for (int i = 0; i < 32; i++) + { + buffer[i] = testMatrix[i]; + } + refresh(); +} + +// private +bool LedMatrix::shutdown(bool b) +{ + for (int addr = 0; addr < modules; addr++) + { + ledControl->shutdown(addr, b); // b: false: on, true: off + } + return true; +} + +void LedMatrix::refresh() +{ + for (int i = 0; i < modulesPerRow * height; i++) + { + refreshByteOfBuffer(i); + } +} + +void LedMatrix::refreshByteOfBuffer(int i) +{ + int line = i / modulesPerRow; + int addr = line / 8 + i % modulesPerRow; + byte b = buffer[i]; + if (moduleOrientation == ORIENTATION_NORMAL || moduleOrientation == ORIENTATION_UPSIDE_DOWN) + { + int rowOfAddr = 0; + if (moduleOrientation == ORIENTATION_NORMAL) + { + rowOfAddr = line % 8; // ORIENTATION_NORMAL + } + else + { + rowOfAddr = 7 - line % 8; // ORIENTATION_UPSIDE_DOWN + b = revereBitorder(b); + } + ledControl->setRow(addr, rowOfAddr, b); + } + else + { + // ORIENTATION_TURN_RIGHT or ORIENTATION_TURN_LEFT + int colOfAddr = 0; + if (moduleOrientation == ORIENTATION_TURN_LEFT) + { + colOfAddr = line % 8; // ORIENTATION_TURN_LEFT + } + else + { + colOfAddr = 7 - line % 8; // ORIENTATION_TURN_RIGHT + b = revereBitorder(b); + } + ledControl->setColumn(addr, colOfAddr, b); + } +} + +byte LedMatrix::revereBitorder (byte b) +{ + const static byte lookup[] PROGMEM = { + 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, + 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, + }; + return (lookup[b & 0b1111] << 4) | lookup[b >> 4]; +} diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h new file mode 100644 index 000000000..f439e5d05 --- /dev/null +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -0,0 +1,124 @@ +/* + * LedMatrix.h - Extends the Library LedControl for multiple LED dot matrix modules, based on MAX7219/MAX7221 + * Copyright (c) 2021 Michael Beuss + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * This permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LedMatrix_h +#define LedMatrix_h + +#include + +#define MATRIX_MAX_MODULES 32 +#define MATRIX_BUFFER_SIZE MATRIX_MAX_MODULES * 8 // 8 bytes per modul. One byte represents 8 LEDs. + + +/** + * @brief LedMatric controls multiple 8x8 LED dot matrx modules. + * All modules in rows and clolums together build a common matrix. + * + */ +class LedMatrix +{ + public: + enum ModuleOrientation // orientation of 8x8 LED dot matrix mdules (first module is top left) + { + ORIENTATION_NORMAL, // first pixel is on top left, no turn is necessary + ORIENTATION_TURN_RIGHT, // first pixel is on bottom left, for correction it has to turn 90° right + ORIENTATION_UPSIDE_DOWN, // first pixel is on bottom right, fpr correction it has to turn 180° + ORIENTATION_TURN_LEFT, // first pixel is on top right, for correction is has to turn 90° left. + }; + + private: + unsigned int modulesPerRow; + unsigned int modulesPerCol; + unsigned int width; // matrix width [pixel] + unsigned int height; // matrix height [pixel] + unsigned int modules; // number of 8x8 mudules + ModuleOrientation moduleOrientation; + byte buffer[MATRIX_BUFFER_SIZE]; + LedControl* ledControl; + + + public: + /** + * @brief Construct a new Led Matrix object + * + * @param colums of 8x8 LED dot matrix modules + * @param rows of 8x8 LED dot matrix modules + */ + LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows); + + /** + * @brief Set all LEDs off. + * + */ + bool clear(void); + + /** + * @brief Set the brightness of the display + * + * @param dim 0..15 + */ + bool setIntensity(byte dim); + + /** + * @brief Switches the display on or off + * + * @param on true: on false: off + */ + void power( bool on ); + + /** + * @brief Set the orientation of the 8x8 LED dot matrix module + * + * @param orientation + */ + bool setOrientation(ModuleOrientation orientation); + + /** + * @brief Set the Pixel object + * + * @param x horizontal position from left + * @param y vertical position from top + * @param on true: on, false: off + */ + bool setPixel( int x, int y, bool on); + void test(); + + private: + bool shutdown(bool b); + + /** + * @brief sends the changed content of the buffer to the display + * + */ + void refresh(); + + void refreshByteOfBuffer( int i); + + byte revereBitorder (byte b); + +}; + +#endif //LedMatrix_h \ No newline at end of file diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index 97c20f00b..da3177f59 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -133,70 +133,45 @@ and setting it to 3 alternates between time and date. #define XDSP_19 19 #define CMD_MAX_LEN 55 +#include -#include - -LedControl *max7219_Matrix; +LedMatrix *max7219_Matrix; bool max2791Matrix_init_done = false; byte modulesPerRow = 4; - +byte modulesPerCol = 1; bool MAX7291Matrix_init(void) { if (!PinUsed(GPIO_MAX7219DIN) || !PinUsed(GPIO_MAX7219CLK) || !PinUsed(GPIO_MAX7219CS)) { - AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init GPIO pins missing DIN, CLK or CS")); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init GPIO pins missing DIN:%d, CLK:%d, CS:%d"), Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS) ); return false; // ensure necessariy pins are configurated } Settings->display_model = XDSP_19; + if (Settings->display_width) // [pixel] + { + modulesPerRow = (Settings->display_width - 1) / 8 + 1; + } + Settings->display_width = 8 * modulesPerRow; Settings->display_cols[0] = Settings->display_width; - Settings->display_height = 1; + if (Settings->display_height) // [pixel] + { + modulesPerCol = (Settings->display_height - 1) / 8 + 1; + } + Settings->display_height = 8 * modulesPerCol; Settings->display_rows = Settings->display_height; - max7219_Matrix = new LedControl(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), modulesPerRow); - MAX7291Matrix_On(true); - MAX7291Matrix_Clear(); - MAX7291Matrix_Dim(); - AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init")); + Settings->display_cols[1] = Settings->display_height; + max7219_Matrix = new LedMatrix(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), modulesPerRow, modulesPerCol); + int intensity = GetDisplayDimmer16(); // 0..15 + max7219_Matrix->setIntensity(intensity); + int orientation = Settings->display_rotate; + max7219_Matrix->setOrientation((LedMatrix::ModuleOrientation)orientation ); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init %dx%d modules, orientation: %d, intensity: %d"), modulesPerRow , modulesPerCol, orientation, intensity); max2791Matrix_init_done = true; - max7219_Matrix->setLed(0, 3, 3, true); - AddLog(LOG_LEVEL_INFO, PSTR("DSP: setLed 3,3")); - return true; -} - -bool MAX7291Matrix_On( bool on ) -{ - for (int addr = 0; addr < modulesPerRow; addr++) - { - max7219_Matrix->shutdown (addr, !on); // false: on, true: off - } - AddLog(LOG_LEVEL_INFO, PSTR("MTX: On %d"), on); - return true; - -} - -bool MAX7291Matrix_Dim(void) -{ - int dim = GetDisplayDimmer16(); - for (int addr = 0; addr < modulesPerRow; addr++) - { - max7219_Matrix->setIntensity(addr, dim); // 1..15 - } - AddLog(LOG_LEVEL_INFO, PSTR("DSP: Dim %d"), dim); - return true; -} - -// /*********************************************************************************************\ -// * Clears the display -// * Command: DisplayClear -// \*********************************************************************************************/ -bool MAX7291Matrix_Clear(void) -{ - for(int addr=0; addrclearDisplay(addr); - } - AddLog(LOG_LEVEL_INFO, PSTR("DSP: Clear")); + max7219_Matrix->test(); + AddLog(LOG_LEVEL_INFO, PSTR("DSP: display test")); return true; } @@ -208,17 +183,18 @@ bool MAX7291Matrix_Text() { char sString[CMD_MAX_LEN + 1]; subStr(sString, XdrvMailbox.data, ",", 1); - MAX7291Matrix_Clear; + max7219_Matrix->clear(); AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: sString %s"), sString); // test uint8_t length = strlen(sString); - //if(length > modulesPerRow) - length = modulesPerRow; + //if(length > modulesPerRow) + length = modulesPerRow; - for(int addr = 0; addrsetLed(addr, 0, 1, true); - AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: setLed() %d, 0, 1)"), addr); + for (int addr = 0; addr < length; addr++) + { + max7219_Matrix->setPixel(addr, addr, true); + AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: setPixel() %d, %d)"), addr, addr); } return true; @@ -226,50 +202,48 @@ bool MAX7291Matrix_Text() bool Xdsp19(uint8_t function) { - bool result = false; - + bool result = false; if (FUNC_DISPLAY_INIT_DRIVER == function) { result = MAX7291Matrix_init(); } - else{ - //if (max2791Matrix_init_done && (XDSP_19 == Settings->display_model)) { - switch (function) { - case FUNC_DISPLAY_MODEL: - result = true; - break; - case FUNC_DISPLAY_CLEAR: - result = MAX7291Matrix_Clear(); - break; - case FUNC_DISPLAY_DIM: - result = MAX7291Matrix_Dim(); - break; - case FUNC_DISPLAY_SEVENSEG_TEXT: - case FUNC_DISPLAY_SEVENSEG_TEXTNC: - case FUNC_DISPLAY_NUMBER: - case FUNC_DISPLAY_NUMBERNC: - case FUNC_DISPLAY_FLOAT: - case FUNC_DISPLAY_FLOATNC: - case FUNC_DISPLAY_RAW: - case FUNC_DISPLAY_LEVEL: - case FUNC_DISPLAY_SCROLLTEXT: - case FUNC_DISPLAY_CLOCK: - case FUNC_DISPLAY_DRAW_STRING: - result = MAX7291Matrix_Text(); - break; - case FUNC_DISPLAY_EVERY_50_MSECOND: - case FUNC_DISPLAY_EVERY_SECOND: - // ignore - return false; - default: - result = false; + else if (max7219_Matrix && (XDSP_19 == Settings->display_model)) + { + switch (function) + { + case FUNC_DISPLAY_MODEL: + result = true; + break; + case FUNC_DISPLAY_CLEAR: + result = max7219_Matrix->clear(); + break; + case FUNC_DISPLAY_DIM: + result = max7219_Matrix->setIntensity(GetDisplayDimmer16()); + break; + case FUNC_DISPLAY_SEVENSEG_TEXT: + case FUNC_DISPLAY_SEVENSEG_TEXTNC: + case FUNC_DISPLAY_NUMBER: + case FUNC_DISPLAY_NUMBERNC: + case FUNC_DISPLAY_FLOAT: + case FUNC_DISPLAY_FLOATNC: + case FUNC_DISPLAY_RAW: + case FUNC_DISPLAY_LEVEL: + case FUNC_DISPLAY_SCROLLTEXT: + case FUNC_DISPLAY_CLOCK: + case FUNC_DISPLAY_DRAW_STRING: + result = MAX7291Matrix_Text(); + break; + case FUNC_DISPLAY_EVERY_50_MSECOND: + case FUNC_DISPLAY_EVERY_SECOND: + // ignore + return false; + default: + result = false; } } return result; } - - #endif // USE_DISPLAY_MAX7219_MATRIX #endif // USE_DISPLAY From 917777d2c50deda43c19c1671c38527b882820bc Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 23 Nov 2021 14:46:19 +0100 Subject: [PATCH 04/31] first scroll --- lib/lib_display/LedControl/src/LedMatrix.cpp | 144 +++++++++- lib/lib_display/LedControl/src/LedMatrix.h | 55 +++- .../LedControl/src/font_5x8_horizontal_MSB.h | 264 ++++++++++++++++++ .../LedControl/src/font_6x8_horizontal_MSB.h | 264 ++++++++++++++++++ tasmota/xdsp_19_max7219_matrix.ino | 36 +-- 5 files changed, 716 insertions(+), 47 deletions(-) create mode 100644 lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h create mode 100644 lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp index 427ae8c52..19ac0dcb2 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.cpp +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -25,6 +25,7 @@ */ #include "LedMatrix.h" +#include "font_6x8_horizontal_MSB.h" // public LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows) @@ -45,22 +46,116 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un modulesPerRow = colums; modulesPerCol = rows; - width = colums * 8; - height = rows * 8; + displayWidth = colums * 8; + displayHeight = rows * 8; modules = colums * rows; moduleOrientation = ORIENTATION_UPSIDE_DOWN; ledControl = new LedControl(dataPin, clkPin, csPin, modules); + textBuf[0] = 0; + textWidth = 0; + textPosX = 0; + textPosY = 0; + appendTextBuf[0] = 0; + setScrollAppendText(" "); shutdown(false); // false: on, true: off clear(); setIntensity(7); } +bool LedMatrix::drawText( const char *str) +{ + strncpy(textBuf, str, TEXT_BUFFER_SIZE -1); + textPosX = 0; + textPosY = 0; + textWidth = strlen(textBuf) * charWidth; + if(textWidth < displayWidth) + { + textPosX = (displayWidth - textWidth) / 2; // center + } + else + { + // The text ist longer than the display width. Scrolling is needed. + // Append a space between end of text and the beginning of the repeting text. + appendSpace(); + } + clear(); + drawTextAt(textBuf, textPosX, textPosY); + refresh(); // refresh display with new string content + return true; +} + +bool LedMatrix::drawTextAt( const char *str, const int x, const int y ) +{ + // draw character by character + unsigned int len = strlen(str); + int xPos = x; + for (unsigned int i = 0; i < len; i++) + { + drawCharAt(str[i], xPos, y); + xPos += charWidth; + } + return true; +} + +bool LedMatrix::scrollText() +{ + if(textWidth < displayWidth) return false; // do not scroll when text fits into the display + + textPosX--; + if(textPosX + textWidth < 0) + { + textPosX = 0; // start from the beginning after text scrolled out of display; + } + drawTextAt(textBuf, textPosX, textPosY); + + int startOfRepeatingTextPos = textPosX + textWidth; + if(startOfRepeatingTextPos < displayWidth) + { + // Draw repeating text. + drawTextAt(textBuf, startOfRepeatingTextPos, textPosY); + } + refresh(); + return true; +} + +bool LedMatrix::drawCharAt( char c, const int x, const int y) +{ + // ignore when the character position is not visible on the display + bool visible = ( + x > 0 - (int)charWidth && x < (int)displayWidth && + y > 0 - (int)charHeight && y < (int)displayHeight + ); + if (!visible) return false; + + // ignore the leading bits above charWidth of the font definition + static const byte charOffset = 8 - charWidth; + + for (byte charY = 0; charY < charHeight; charY++) + { + char pixelRow = (font[c][charY]) << charOffset; // skip the first bits when the character width is smaller than 8 pixel + for (byte charX = 0; charX < charWidth; charX++) + { + bool pixel = (pixelRow & 0x80); // pixel=true when upper bit is set + setPixel(x + charX, y + charY, pixel); + pixelRow = pixelRow << 1; // next pixel + } + } + return true; +} + +bool LedMatrix::clearDisplay(void) +{ + textBuf[0] = 0; + memset(textBuf, 0, TEXT_BUFFER_SIZE); + textWidth = 0; + clear(); + return true; +} + + bool LedMatrix::clear(void) { - for (int i = 0; i < MATRIX_BUFFER_SIZE; i++) - { - buffer[i] = 0; - } + memset(buffer, 0, MATRIX_BUFFER_SIZE); for (int addr = 0; addr < modules; addr++) { ledControl->clearDisplay(addr); @@ -83,14 +178,20 @@ bool LedMatrix::setOrientation(ModuleOrientation orientation) return true; } -bool LedMatrix::setPixel(int x, int y, bool on) +bool LedMatrix::setScrollAppendText(const char* append ) { - if (x >= width || y >= height) + strncpy(appendTextBuf, append, TEXT_APPEND_BUFFER_SIZE -1); + return (strlen(append) < TEXT_APPEND_BUFFER_SIZE); +} + +bool LedMatrix::setPixel(const int x, const int y, bool on) +{ + if (x >= displayWidth || y >= displayHeight) return false; int modul_col = x / 8; // x pos divided by 8 is the index of the modul to the right - int buffer_pos = modul_col + y * width / 8; - byte buffer_byte = 8 >> (x % 8); + int buffer_pos = modul_col + y * modulesPerRow; + byte buffer_byte = 0x80 >> (x % 8); if (on) { buffer[buffer_pos] |= buffer_byte; // set bit @@ -99,12 +200,12 @@ bool LedMatrix::setPixel(int x, int y, bool on) { buffer[buffer_pos] &= ~buffer_byte; // reset bit } - refreshByteOfBuffer(buffer_pos); return true; } void LedMatrix::test() { + /* const static byte testMatrix[] PROGMEM = { B00000010, B00111100, B00111100, B00001000, B00000110, B01000010, B01000010, B00010000, @@ -112,7 +213,7 @@ void LedMatrix::test() B00000010, B00000100, B00001100, B01000100, B00000010, B00011000, B00000010, B01111110, B00000010, B00100000, B01000010, B00000100, - B00000000, B11111110, B00111100, B00000100, + B00000000, B01111110, B00111100, B00000100, B00000000, B00000000, B00000000, B00000000, }; for (int i = 0; i < 32; i++) @@ -120,6 +221,17 @@ void LedMatrix::test() buffer[i] = testMatrix[i]; } refresh(); + */ + drawText("1234567890"); + delay(1000); + for( int i=0; i<320; i++) + { + delay(50); + scrollText(); + } + //drawCharAt(0x31, 1, 0); + //setPixel(1,30); + //refresh(); } // private @@ -134,7 +246,7 @@ bool LedMatrix::shutdown(bool b) void LedMatrix::refresh() { - for (int i = 0; i < modulesPerRow * height; i++) + for (int i = 0; i < modulesPerRow * displayHeight; i++) { refreshByteOfBuffer(i); } @@ -184,3 +296,9 @@ byte LedMatrix::revereBitorder (byte b) }; return (lookup[b & 0b1111] << 4) | lookup[b >> 4]; } + +void LedMatrix::appendSpace() +{ + strncat(textBuf, appendTextBuf, TEXT_BUFFER_SIZE -1); + textWidth = strlen(textBuf) * charWidth; +} diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index f439e5d05..586a06146 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -31,6 +31,8 @@ #define MATRIX_MAX_MODULES 32 #define MATRIX_BUFFER_SIZE MATRIX_MAX_MODULES * 8 // 8 bytes per modul. One byte represents 8 LEDs. +#define TEXT_BUFFER_SIZE 256 +#define TEXT_APPEND_BUFFER_SIZE 16 /** @@ -52,12 +54,19 @@ class LedMatrix private: unsigned int modulesPerRow; unsigned int modulesPerCol; - unsigned int width; // matrix width [pixel] - unsigned int height; // matrix height [pixel] + unsigned int displayWidth; // matrix width [pixel] + unsigned int displayHeight; // matrix height [pixel] unsigned int modules; // number of 8x8 mudules ModuleOrientation moduleOrientation; byte buffer[MATRIX_BUFFER_SIZE]; LedControl* ledControl; + const unsigned int charWidth = 6; + const unsigned int charHeight = 8; + char textBuf[TEXT_BUFFER_SIZE]; + char appendTextBuf[TEXT_APPEND_BUFFER_SIZE]; + unsigned int textWidth; // width of text [pixel] + int textPosX; // horizontal pixel position of scrolling text + int textPosY; // vertical pixelposition of scrolling text; public: @@ -73,7 +82,7 @@ class LedMatrix * @brief Set all LEDs off. * */ - bool clear(void); + bool clearDisplay(void); /** * @brief Set the brightness of the display @@ -82,6 +91,13 @@ class LedMatrix */ bool setIntensity(byte dim); + /** + * @brief Set the a pending string to the scrolling text to set a distance to te repeating text. Usually some spaces. + * + * @param append text to append to the scrolling text before repeating. + */ + bool setScrollAppendText(const char* append ); + /** * @brief Switches the display on or off * @@ -96,6 +112,32 @@ class LedMatrix */ bool setOrientation(ModuleOrientation orientation); + /** + * @brief draw a string to the display. + * When the text fits into the size of the display, it will be shown in the center. + * When the text is longer than than the display width, it can be scrolled per pixel with function scrollText(). + * + * @param str string to display + */ + bool drawText( const char *str ); + + /** + * @brief dwaws a character string to the display. The position (x,y) is used for the upper left pixtel of the text. + * Existing text before the x position will not be cleared. + * + * @param str string to display + * @param x horizantal pixel position to start with string (default 0) + * @param y vertical pixel position for the top position of the string (default 0) + */ + bool drawTextAt( const char *str, const int x, const int y ); + + /** + * @brief Scroll the current teext one picel to the left. + * Repeat with from start when end of text reached. + * + */ + bool scrollText(); + /** * @brief Set the Pixel object * @@ -103,11 +145,14 @@ class LedMatrix * @param y vertical position from top * @param on true: on, false: off */ - bool setPixel( int x, int y, bool on); + bool setPixel( const int x, const int y, bool on=true); void test(); private: + bool drawCharAt( char c, int x, int y ); + bool shutdown(bool b); + bool clear(void); /** * @brief sends the changed content of the buffer to the display @@ -119,6 +164,8 @@ class LedMatrix byte revereBitorder (byte b); + void appendSpace(); + }; #endif //LedMatrix_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h b/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h new file mode 100644 index 000000000..56df774a4 --- /dev/null +++ b/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h @@ -0,0 +1,264 @@ +// 5x8 ascii font +#ifndef font_5x8_horizontal_MSB_h +#define font_5x8_horizontal_MSB_h + +const char font[256][8]={ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 +{0x0E,0x11,0x1B,0x11,0x1F,0x0E,0x00,0x00}, // 0x01 +{0x0E,0x15,0x1F,0x11,0x1F,0x0E,0x00,0x00}, // 0x02 +{0x0A,0x1F,0x1F,0x1F,0x0E,0x04,0x00,0x00}, // 0x03 +{0x04,0x04,0x0E,0x1F,0x0E,0x04,0x04,0x00}, // 0x04 +{0x04,0x0E,0x04,0x1F,0x15,0x04,0x0E,0x00}, // 0x05 +{0x04,0x0E,0x1F,0x1F,0x15,0x04,0x0E,0x00}, // 0x06 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A +{0x03,0x03,0x0E,0x11,0x11,0x11,0x0E,0x00}, // 0x0B +{0x0E,0x11,0x11,0x11,0x0E,0x04,0x0E,0x04}, // 0x0C +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D +{0x03,0x0F,0x09,0x09,0x0B,0x1B,0x18,0x00}, // 0x0E +{0x00,0x15,0x0E,0x1B,0x0E,0x15,0x00,0x00}, // 0x0F +{0x00,0x10,0x1C,0x1F,0x1C,0x10,0x00,0x00}, // 0x10 +{0x00,0x01,0x07,0x1F,0x07,0x01,0x00,0x00}, // 0x11 +{0x04,0x0E,0x04,0x04,0x04,0x0E,0x04,0x00}, // 0x12 +{0x00,0x0A,0x0A,0x0A,0x00,0x0A,0x00,0x00}, // 0x13 +{0x0E,0x1A,0x1A,0x0A,0x0A,0x0A,0x0A,0x00}, // 0x14 +{0x06,0x08,0x04,0x0A,0x04,0x02,0x0C,0x00}, // 0x15 +{0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00}, // 0x16 +{0x04,0x0E,0x04,0x0E,0x04,0x00,0x0E,0x00}, // 0x17 +{0x04,0x0E,0x04,0x04,0x04,0x04,0x04,0x00}, // 0x18 +{0x04,0x04,0x04,0x04,0x04,0x0E,0x04,0x00}, // 0x19 +{0x00,0x00,0x02,0x0F,0x02,0x00,0x00,0x00}, // 0x1A +{0x00,0x00,0x04,0x0F,0x04,0x00,0x00,0x00}, // 0x1B +{0x00,0x00,0x08,0x08,0x08,0x0F,0x00,0x00}, // 0x1C +{0x00,0x00,0x0A,0x1F,0x0A,0x00,0x00,0x00}, // 0x1D +{0x00,0x04,0x04,0x0E,0x0E,0x1F,0x00,0x00}, // 0x1E +{0x00,0x1F,0x0E,0x0E,0x04,0x04,0x00,0x00}, // 0x1F +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20 +{0x04,0x04,0x04,0x04,0x00,0x04,0x00,0x00}, // 0x21 +{0x0A,0x0A,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x22 +{0x00,0x05,0x1F,0x0A,0x1F,0x14,0x00,0x00}, // 0x23 +{0x04,0x0E,0x0C,0x04,0x06,0x0E,0x04,0x00}, // 0x24 +{0x09,0x15,0x0E,0x0E,0x15,0x12,0x00,0x00}, // 0x25 +{0x04,0x0A,0x0C,0x15,0x12,0x0D,0x00,0x00}, // 0x26 +{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x27 +{0x03,0x04,0x08,0x08,0x08,0x04,0x03,0x00}, // 0x28 +{0x18,0x04,0x02,0x02,0x02,0x04,0x18,0x00}, // 0x29 +{0x04,0x0A,0x04,0x0A,0x00,0x00,0x00,0x00}, // 0x2A +{0x00,0x00,0x00,0x04,0x0E,0x04,0x00,0x00}, // 0x2B +{0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x08}, // 0x2C +{0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0x2D +{0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00}, // 0x2E +{0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x00}, // 0x2F +{0x06,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0x30 +{0x04,0x0C,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0x31 +{0x0C,0x02,0x02,0x04,0x08,0x0E,0x00,0x00}, // 0x32 +{0x0C,0x02,0x0C,0x02,0x02,0x0C,0x00,0x00}, // 0x33 +{0x02,0x06,0x0A,0x0F,0x02,0x02,0x00,0x00}, // 0x34 +{0x0E,0x08,0x0C,0x02,0x02,0x0C,0x00,0x00}, // 0x35 +{0x06,0x08,0x0E,0x09,0x09,0x06,0x00,0x00}, // 0x36 +{0x0F,0x01,0x02,0x04,0x04,0x04,0x00,0x00}, // 0x37 +{0x06,0x09,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x38 +{0x06,0x09,0x09,0x07,0x01,0x06,0x00,0x00}, // 0x39 +{0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00}, // 0x3A +{0x00,0x00,0x04,0x00,0x00,0x04,0x04,0x08}, // 0x3B +{0x00,0x01,0x02,0x0C,0x02,0x01,0x00,0x00}, // 0x3C +{0x00,0x00,0x0F,0x00,0x0F,0x00,0x00,0x00}, // 0x3D +{0x00,0x08,0x04,0x03,0x04,0x08,0x00,0x00}, // 0x3E +{0x0E,0x01,0x02,0x04,0x00,0x04,0x00,0x00}, // 0x3F +{0x06,0x09,0x13,0x15,0x17,0x10,0x0F,0x00}, // 0x40 +{0x00,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0x41 +{0x00,0x0E,0x0A,0x0C,0x0A,0x0E,0x00,0x00}, // 0x42 +{0x00,0x07,0x08,0x08,0x08,0x07,0x00,0x00}, // 0x43 +{0x00,0x0E,0x09,0x09,0x09,0x0E,0x00,0x00}, // 0x44 +{0x00,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0x45 +{0x00,0x0E,0x08,0x0E,0x08,0x08,0x00,0x00}, // 0x46 +{0x00,0x07,0x08,0x0B,0x09,0x07,0x00,0x00}, // 0x47 +{0x00,0x09,0x09,0x0F,0x09,0x09,0x00,0x00}, // 0x48 +{0x00,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0x49 +{0x00,0x0E,0x02,0x02,0x02,0x0C,0x00,0x00}, // 0x4A +{0x00,0x09,0x0A,0x0C,0x0A,0x09,0x00,0x00}, // 0x4B +{0x00,0x08,0x08,0x08,0x08,0x0F,0x00,0x00}, // 0x4C +{0x00,0x11,0x1B,0x15,0x15,0x11,0x00,0x00}, // 0x4D +{0x00,0x09,0x0D,0x0B,0x09,0x09,0x00,0x00}, // 0x4E +{0x00,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0x4F +{0x00,0x0E,0x09,0x0E,0x08,0x08,0x00,0x00}, // 0x50 +{0x00,0x0E,0x11,0x11,0x11,0x0E,0x02,0x01}, // 0x51 +{0x00,0x0C,0x0A,0x0C,0x0A,0x09,0x00,0x00}, // 0x52 +{0x00,0x06,0x08,0x04,0x02,0x0C,0x00,0x00}, // 0x53 +{0x00,0x1F,0x04,0x04,0x04,0x04,0x00,0x00}, // 0x54 +{0x00,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0x55 +{0x00,0x09,0x09,0x09,0x06,0x06,0x00,0x00}, // 0x56 +{0x00,0x11,0x15,0x15,0x0A,0x0A,0x00,0x00}, // 0x57 +{0x00,0x11,0x0A,0x04,0x0A,0x11,0x00,0x00}, // 0x58 +{0x00,0x11,0x0A,0x04,0x04,0x04,0x00,0x00}, // 0x59 +{0x00,0x0F,0x01,0x06,0x08,0x0F,0x00,0x00}, // 0x5A +{0x06,0x04,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x5B +{0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00}, // 0x5C +{0x0C,0x04,0x04,0x04,0x04,0x04,0x0C,0x00}, // 0x5D +{0x04,0x0A,0x0A,0x11,0x11,0x00,0x00,0x00}, // 0x5E +{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00}, // 0x5F +{0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x60 +{0x00,0x00,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x61 +{0x08,0x08,0x0E,0x09,0x09,0x0E,0x00,0x00}, // 0x62 +{0x00,0x00,0x06,0x08,0x08,0x06,0x00,0x00}, // 0x63 +{0x02,0x02,0x0E,0x12,0x12,0x0E,0x00,0x00}, // 0x64 +{0x00,0x00,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x65 +{0x03,0x04,0x0F,0x04,0x04,0x04,0x00,0x00}, // 0x66 +{0x00,0x00,0x07,0x09,0x0F,0x01,0x0E,0x00}, // 0x67 +{0x08,0x08,0x0A,0x0D,0x09,0x09,0x00,0x00}, // 0x68 +{0x04,0x00,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x69 +{0x02,0x00,0x0E,0x02,0x02,0x02,0x0C,0x00}, // 0x6A +{0x08,0x08,0x0A,0x0C,0x0A,0x09,0x00,0x00}, // 0x6B +{0x0C,0x04,0x04,0x04,0x04,0x04,0x00,0x00}, // 0x6C +{0x00,0x00,0x15,0x1F,0x15,0x15,0x00,0x00}, // 0x6D +{0x00,0x00,0x0A,0x0D,0x09,0x09,0x00,0x00}, // 0x6E +{0x00,0x00,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x6F +{0x00,0x00,0x0E,0x09,0x09,0x0E,0x08,0x00}, // 0x70 +{0x00,0x00,0x0E,0x12,0x12,0x0E,0x02,0x00}, // 0x71 +{0x00,0x00,0x0A,0x0C,0x08,0x08,0x00,0x00}, // 0x72 +{0x00,0x00,0x06,0x0C,0x02,0x0C,0x00,0x00}, // 0x73 +{0x00,0x04,0x0F,0x04,0x04,0x02,0x00,0x00}, // 0x74 +{0x00,0x00,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x75 +{0x00,0x00,0x09,0x09,0x06,0x06,0x00,0x00}, // 0x76 +{0x00,0x00,0x15,0x15,0x0E,0x0A,0x00,0x00}, // 0x77 +{0x00,0x00,0x09,0x06,0x06,0x09,0x00,0x00}, // 0x78 +{0x00,0x00,0x09,0x09,0x06,0x06,0x1C,0x00}, // 0x79 +{0x00,0x00,0x0E,0x06,0x08,0x0E,0x00,0x00}, // 0x7A +{0x02,0x04,0x04,0x08,0x04,0x04,0x02,0x00}, // 0x7B +{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00}, // 0x7C +{0x08,0x04,0x04,0x02,0x04,0x04,0x08,0x00}, // 0x7D +{0x00,0x00,0x00,0x0D,0x12,0x00,0x00,0x00}, // 0x7E +{0x00,0x04,0x0A,0x0A,0x0A,0x0E,0x00,0x00}, // 0x7F +{0x00,0x07,0x08,0x08,0x08,0x07,0x02,0x04}, // 0x80 +{0x09,0x00,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x81 +{0x01,0x02,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x82 +{0x06,0x09,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x83 +{0x0A,0x00,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x84 +{0x10,0x08,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x85 +{0x04,0x0A,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x86 +{0x00,0x00,0x06,0x08,0x08,0x06,0x02,0x04}, // 0x87 +{0x06,0x09,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x88 +{0x0A,0x00,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x89 +{0x10,0x08,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x8A +{0x0A,0x00,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x8B +{0x06,0x09,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x8C +{0x10,0x08,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x8D +{0x0A,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0x8E +{0x04,0x0A,0x04,0x0A,0x1F,0x11,0x00,0x00}, // 0x8F +{0x01,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0x90 +{0x00,0x00,0x1A,0x07,0x1C,0x13,0x00,0x00}, // 0x91 +{0x00,0x07,0x0A,0x0B,0x1E,0x13,0x00,0x00}, // 0x92 +{0x0C,0x12,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x93 +{0x09,0x00,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x94 +{0x10,0x08,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x95 +{0x0C,0x12,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x96 +{0x08,0x04,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x97 +{0x09,0x00,0x09,0x09,0x06,0x06,0x1C,0x00}, // 0x98 +{0x11,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0x99 +{0x12,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0x9A +{0x00,0x01,0x06,0x0B,0x0D,0x06,0x08,0x00}, // 0x9B +{0x00,0x04,0x08,0x0C,0x18,0x0E,0x00,0x00}, // 0x9C +{0x01,0x0E,0x13,0x15,0x19,0x0E,0x10,0x00}, // 0x9D +{0x00,0x00,0x09,0x06,0x06,0x09,0x00,0x00}, // 0x9E +{0x02,0x04,0x04,0x0E,0x04,0x04,0x08,0x00}, // 0x9F +{0x01,0x02,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0xA0 +{0x01,0x02,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0xA1 +{0x01,0x02,0x06,0x09,0x09,0x06,0x00,0x00}, // 0xA2 +{0x01,0x02,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0xA3 +{0x0F,0x00,0x0A,0x0D,0x09,0x09,0x00,0x00}, // 0xA4 +{0x1F,0x09,0x0D,0x0B,0x09,0x09,0x00,0x00}, // 0xA5 +{0x0C,0x02,0x0E,0x0A,0x0E,0x00,0x00,0x00}, // 0xA6 +{0x04,0x0A,0x0A,0x0A,0x04,0x00,0x00,0x00}, // 0xA7 +{0x00,0x04,0x00,0x04,0x04,0x02,0x0C,0x00}, // 0xA8 +{0x0E,0x17,0x17,0x15,0x17,0x0E,0x00,0x00}, // 0xA9 +{0x00,0x00,0x00,0x0E,0x02,0x02,0x00,0x00}, // 0xAA +{0x19,0x0A,0x0F,0x05,0x0A,0x13,0x00,0x00}, // 0xAB +{0x19,0x0A,0x0A,0x05,0x0B,0x11,0x00,0x00}, // 0xAC +{0x00,0x00,0x04,0x00,0x04,0x04,0x04,0x00}, // 0xAD +{0x00,0x05,0x0A,0x14,0x0A,0x05,0x00,0x00}, // 0xAE +{0x00,0x14,0x0A,0x05,0x0A,0x14,0x00,0x00}, // 0xAF +{0x15,0x00,0x15,0x00,0x15,0x00,0x15,0x00}, // 0xB0 +{0x15,0x0A,0x15,0x0A,0x15,0x0A,0x15,0x0A}, // 0xB1 +{0x1F,0x15,0x1F,0x15,0x1F,0x15,0x1F,0x15}, // 0xB2 +{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04}, // 0xB3 +{0x04,0x04,0x04,0x1C,0x04,0x04,0x04,0x04}, // 0xB4 +{0x02,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0xB5 +{0x06,0x09,0x04,0x0A,0x1F,0x11,0x00,0x00}, // 0xB6 +{0x08,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0xB7 +{0x0E,0x11,0x17,0x15,0x17,0x11,0x0E,0x00}, // 0xB8 +{0x0A,0x0A,0x1A,0x02,0x1A,0x0A,0x0A,0x0A}, // 0xB9 +{0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A}, // 0xBA +{0x00,0x00,0x1E,0x02,0x1A,0x0A,0x0A,0x0A}, // 0xBB +{0x0A,0x0A,0x1A,0x02,0x1E,0x00,0x00,0x00}, // 0xBC +{0x00,0x04,0x0E,0x08,0x0E,0x04,0x00,0x00}, // 0xBD +{0x00,0x11,0x0A,0x04,0x0E,0x04,0x00,0x00}, // 0xBE +{0x00,0x00,0x00,0x1C,0x04,0x04,0x04,0x04}, // 0xBF +{0x04,0x04,0x04,0x07,0x00,0x00,0x00,0x00}, // 0xC0 +{0x04,0x04,0x04,0x1F,0x00,0x00,0x00,0x00}, // 0xC1 +{0x00,0x00,0x00,0x1F,0x04,0x04,0x04,0x04}, // 0xC2 +{0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04}, // 0xC3 +{0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00}, // 0xC4 +{0x04,0x04,0x04,0x1F,0x04,0x04,0x04,0x04}, // 0xC5 +{0x0D,0x12,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0xC6 +{0x0D,0x12,0x04,0x0A,0x1F,0x11,0x00,0x00}, // 0xC7 +{0x0A,0x0A,0x0B,0x08,0x0F,0x00,0x00,0x00}, // 0xC8 +{0x00,0x00,0x0F,0x08,0x0B,0x0A,0x0A,0x0A}, // 0xC9 +{0x0A,0x0A,0x1B,0x00,0x1F,0x00,0x00,0x00}, // 0xCA +{0x00,0x00,0x1F,0x00,0x1B,0x0A,0x0A,0x0A}, // 0xCB +{0x0A,0x0A,0x0B,0x08,0x0B,0x0A,0x0A,0x0A}, // 0xCC +{0x00,0x00,0x1F,0x00,0x1F,0x00,0x00,0x00}, // 0xCD +{0x0A,0x0A,0x1B,0x00,0x1B,0x0A,0x0A,0x0A}, // 0xCE +{0x00,0x11,0x0E,0x0A,0x0E,0x11,0x00,0x00}, // 0xCF +{0x1E,0x04,0x0E,0x12,0x12,0x0C,0x00,0x00}, // 0xD0 +{0x00,0x0E,0x09,0x1D,0x09,0x0E,0x00,0x00}, // 0xD1 +{0x0E,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0xD2 +{0x11,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0xD3 +{0x10,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0xD4 +{0x00,0x00,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0xD5 +{0x01,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xD6 +{0x0E,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xD7 +{0x11,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xD8 +{0x04,0x04,0x04,0x1C,0x00,0x00,0x00,0x00}, // 0xD9 +{0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x04}, // 0xDA +{0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}, // 0xDB +{0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F}, // 0xDC +{0x04,0x04,0x04,0x00,0x00,0x04,0x04,0x04}, // 0xDD +{0x10,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xDE +{0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00}, // 0xDF +{0x01,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE0 +{0x04,0x0A,0x0A,0x0A,0x09,0x0A,0x00,0x00}, // 0xE1 +{0x0E,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE2 +{0x10,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE3 +{0x0D,0x12,0x06,0x09,0x09,0x06,0x00,0x00}, // 0xE4 +{0x1E,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE5 +{0x00,0x00,0x09,0x09,0x0B,0x0D,0x08,0x00}, // 0xE6 +{0x08,0x08,0x0E,0x09,0x09,0x0E,0x08,0x00}, // 0xE7 +{0x00,0x08,0x0E,0x09,0x0E,0x08,0x00,0x00}, // 0xE8 +{0x01,0x12,0x12,0x12,0x12,0x0C,0x00,0x00}, // 0xE9 +{0x0F,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0xEA +{0x10,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0xEB +{0x01,0x02,0x09,0x09,0x06,0x06,0x18,0x00}, // 0xEC +{0x02,0x15,0x0A,0x04,0x04,0x04,0x00,0x00}, // 0xED +{0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEE +{0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEF +{0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0xF0 +{0x00,0x00,0x04,0x0E,0x04,0x0E,0x00,0x00}, // 0xF1 +{0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x1F}, // 0xF2 +{0x19,0x1A,0x0A,0x1D,0x0B,0x11,0x00,0x00}, // 0xF3 +{0x0E,0x1A,0x1A,0x0A,0x0A,0x0A,0x0A,0x00}, // 0xF4 +{0x06,0x08,0x04,0x0A,0x04,0x02,0x0C,0x00}, // 0xF5 +{0x00,0x04,0x00,0x0E,0x00,0x04,0x00,0x00}, // 0xF6 +{0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08}, // 0xF7 +{0x06,0x09,0x09,0x06,0x00,0x00,0x00,0x00}, // 0xF8 +{0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF9 +{0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00}, // 0xFA +{0x0C,0x04,0x04,0x04,0x0E,0x00,0x00,0x00}, // 0xFB +{0x0C,0x02,0x0C,0x02,0x0C,0x00,0x00,0x00}, // 0xFC +{0x0C,0x02,0x04,0x08,0x0E,0x00,0x00,0x00}, // 0xFD +{0x00,0x00,0x0F,0x0F,0x0F,0x0F,0x00,0x00}, // 0xFE +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF +}; + +#endif // font_5x8_horizontal_MSB_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h b/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h new file mode 100644 index 000000000..cc3a323cc --- /dev/null +++ b/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h @@ -0,0 +1,264 @@ +// 6x8 ascii font +#ifndef font_6x8_horizontal_MSB_h +#define font_6x8_horizontal_MSB_h + +const char font[256][8]={ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 +{0x0E,0x11,0x1B,0x11,0x15,0x11,0x0E,0x00}, // 0x01 +{0x0E,0x1F,0x15,0x1F,0x11,0x1F,0x0E,0x00}, // 0x02 +{0x00,0x0A,0x1F,0x1F,0x1F,0x0E,0x04,0x00}, // 0x03 +{0x00,0x04,0x0E,0x1F,0x1F,0x0E,0x04,0x00}, // 0x04 +{0x04,0x0E,0x0E,0x04,0x1F,0x1F,0x04,0x00}, // 0x05 +{0x00,0x04,0x0E,0x1F,0x1F,0x04,0x0E,0x00}, // 0x06 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A +{0x00,0x07,0x03,0x0D,0x12,0x12,0x0C,0x00}, // 0x0B +{0x0E,0x11,0x11,0x0E,0x04,0x0E,0x04,0x00}, // 0x0C +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D +{0x03,0x0D,0x0B,0x0D,0x0B,0x1B,0x18,0x00}, // 0x0E +{0x00,0x15,0x0E,0x1B,0x0E,0x15,0x00,0x00}, // 0x0F +{0x08,0x0C,0x0E,0x0F,0x0E,0x0C,0x08,0x00}, // 0x10 +{0x02,0x06,0x0E,0x1E,0x0E,0x06,0x02,0x00}, // 0x11 +{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x00}, // 0x12 +{0x0A,0x0A,0x0A,0x0A,0x0A,0x00,0x0A,0x00}, // 0x13 +{0x0F,0x15,0x15,0x0D,0x05,0x05,0x05,0x00}, // 0x14 +{0x0E,0x11,0x0C,0x0A,0x06,0x11,0x0E,0x00}, // 0x15 +{0x00,0x00,0x00,0x00,0x00,0x1E,0x1E,0x00}, // 0x16 +{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x0E}, // 0x17 +{0x04,0x0E,0x1F,0x04,0x04,0x04,0x04,0x00}, // 0x18 +{0x04,0x04,0x04,0x04,0x1F,0x0E,0x04,0x00}, // 0x19 +{0x00,0x04,0x06,0x1F,0x06,0x04,0x00,0x00}, // 0x1A +{0x00,0x04,0x0C,0x1F,0x0C,0x04,0x00,0x00}, // 0x1B +{0x00,0x00,0x00,0x10,0x10,0x10,0x1F,0x00}, // 0x1C +{0x00,0x0A,0x0A,0x1F,0x0A,0x0A,0x00,0x00}, // 0x1D +{0x04,0x04,0x0E,0x0E,0x1F,0x1F,0x00,0x00}, // 0x1E +{0x1F,0x1F,0x0E,0x0E,0x04,0x04,0x00,0x00}, // 0x1F +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20 +{0x04,0x0E,0x0E,0x04,0x04,0x00,0x04,0x00}, // 0x21 +{0x1B,0x1B,0x12,0x00,0x00,0x00,0x00,0x00}, // 0x22 +{0x00,0x0A,0x1F,0x0A,0x0A,0x1F,0x0A,0x00}, // 0x23 +{0x08,0x0E,0x10,0x0C,0x02,0x1C,0x04,0x00}, // 0x24 +{0x19,0x19,0x02,0x04,0x08,0x13,0x13,0x00}, // 0x25 +{0x08,0x14,0x14,0x08,0x15,0x12,0x0D,0x00}, // 0x26 +{0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x27 +{0x04,0x08,0x08,0x08,0x08,0x08,0x04,0x00}, // 0x28 +{0x08,0x04,0x04,0x04,0x04,0x04,0x08,0x00}, // 0x29 +{0x00,0x0A,0x0E,0x1F,0x0E,0x0A,0x00,0x00}, // 0x2A +{0x00,0x04,0x04,0x1F,0x04,0x04,0x00,0x00}, // 0x2B +{0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x08}, // 0x2C +{0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00}, // 0x2D +{0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00}, // 0x2E +{0x00,0x01,0x02,0x04,0x08,0x10,0x00,0x00}, // 0x2F +{0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00}, // 0x30 +{0x04,0x0C,0x04,0x04,0x04,0x04,0x0E,0x00}, // 0x31 +{0x0E,0x11,0x01,0x06,0x08,0x10,0x1F,0x00}, // 0x32 +{0x0E,0x11,0x01,0x0E,0x01,0x11,0x0E,0x00}, // 0x33 +{0x02,0x06,0x0A,0x12,0x1F,0x02,0x02,0x00}, // 0x34 +{0x1F,0x10,0x10,0x1E,0x01,0x11,0x0E,0x00}, // 0x35 +{0x06,0x08,0x10,0x1E,0x11,0x11,0x0E,0x00}, // 0x36 +{0x1F,0x01,0x02,0x04,0x08,0x08,0x08,0x00}, // 0x37 +{0x0E,0x11,0x11,0x0E,0x11,0x11,0x0E,0x00}, // 0x38 +{0x0E,0x11,0x11,0x0F,0x01,0x02,0x0C,0x00}, // 0x39 +{0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00}, // 0x3A +{0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x08}, // 0x3B +{0x02,0x04,0x08,0x10,0x08,0x04,0x02,0x00}, // 0x3C +{0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00}, // 0x3D +{0x08,0x04,0x02,0x01,0x02,0x04,0x08,0x00}, // 0x3E +{0x0E,0x11,0x01,0x06,0x04,0x00,0x04,0x00}, // 0x3F +{0x0E,0x11,0x17,0x15,0x17,0x10,0x0E,0x00}, // 0x40 +{0x0E,0x11,0x11,0x11,0x1F,0x11,0x11,0x00}, // 0x41 +{0x1E,0x11,0x11,0x1E,0x11,0x11,0x1E,0x00}, // 0x42 +{0x0E,0x11,0x10,0x10,0x10,0x11,0x0E,0x00}, // 0x43 +{0x1E,0x11,0x11,0x11,0x11,0x11,0x1E,0x00}, // 0x44 +{0x1F,0x10,0x10,0x1E,0x10,0x10,0x1F,0x00}, // 0x45 +{0x1F,0x10,0x10,0x1E,0x10,0x10,0x10,0x00}, // 0x46 +{0x0E,0x11,0x10,0x17,0x11,0x11,0x0F,0x00}, // 0x47 +{0x11,0x11,0x11,0x1F,0x11,0x11,0x11,0x00}, // 0x48 +{0x0E,0x04,0x04,0x04,0x04,0x04,0x0E,0x00}, // 0x49 +{0x01,0x01,0x01,0x01,0x11,0x11,0x0E,0x00}, // 0x4A +{0x11,0x12,0x14,0x18,0x14,0x12,0x11,0x00}, // 0x4B +{0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x00}, // 0x4C +{0x11,0x1B,0x15,0x11,0x11,0x11,0x11,0x00}, // 0x4D +{0x11,0x19,0x15,0x13,0x11,0x11,0x11,0x00}, // 0x4E +{0x0E,0x11,0x11,0x11,0x11,0x11,0x0E,0x00}, // 0x4F +{0x1E,0x11,0x11,0x1E,0x10,0x10,0x10,0x00}, // 0x50 +{0x0E,0x11,0x11,0x11,0x15,0x12,0x0D,0x00}, // 0x51 +{0x1E,0x11,0x11,0x1E,0x12,0x11,0x11,0x00}, // 0x52 +{0x0E,0x11,0x10,0x0E,0x01,0x11,0x0E,0x00}, // 0x53 +{0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x00}, // 0x54 +{0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00}, // 0x55 +{0x11,0x11,0x11,0x11,0x11,0x0A,0x04,0x00}, // 0x56 +{0x11,0x11,0x15,0x15,0x15,0x15,0x0A,0x00}, // 0x57 +{0x11,0x11,0x0A,0x04,0x0A,0x11,0x11,0x00}, // 0x58 +{0x11,0x11,0x11,0x0A,0x04,0x04,0x04,0x00}, // 0x59 +{0x1E,0x02,0x04,0x08,0x10,0x10,0x1E,0x00}, // 0x5A +{0x0E,0x08,0x08,0x08,0x08,0x08,0x0E,0x00}, // 0x5B +{0x00,0x10,0x08,0x04,0x02,0x01,0x00,0x00}, // 0x5C +{0x0E,0x02,0x02,0x02,0x02,0x02,0x0E,0x00}, // 0x5D +{0x04,0x0A,0x11,0x00,0x00,0x00,0x00,0x00}, // 0x5E +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F}, // 0x5F +{0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00}, // 0x60 +{0x00,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x61 +{0x10,0x10,0x1E,0x11,0x11,0x11,0x1E,0x00}, // 0x62 +{0x00,0x00,0x0E,0x11,0x10,0x11,0x0E,0x00}, // 0x63 +{0x01,0x01,0x0F,0x11,0x11,0x11,0x0F,0x00}, // 0x64 +{0x00,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x65 +{0x06,0x08,0x08,0x1E,0x08,0x08,0x08,0x00}, // 0x66 +{0x00,0x00,0x0F,0x11,0x11,0x0F,0x01,0x0E}, // 0x67 +{0x10,0x10,0x1C,0x12,0x12,0x12,0x12,0x00}, // 0x68 +{0x04,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x69 +{0x02,0x00,0x06,0x02,0x02,0x02,0x12,0x0C}, // 0x6A +{0x10,0x10,0x12,0x14,0x18,0x14,0x12,0x00}, // 0x6B +{0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x6C +{0x00,0x00,0x1A,0x15,0x15,0x11,0x11,0x00}, // 0x6D +{0x00,0x00,0x1C,0x12,0x12,0x12,0x12,0x00}, // 0x6E +{0x00,0x00,0x0E,0x11,0x11,0x11,0x0E,0x00}, // 0x6F +{0x00,0x00,0x1E,0x11,0x11,0x11,0x1E,0x10}, // 0x70 +{0x00,0x00,0x0F,0x11,0x11,0x11,0x0F,0x01}, // 0x71 +{0x00,0x00,0x16,0x09,0x08,0x08,0x1C,0x00}, // 0x72 +{0x00,0x00,0x0E,0x10,0x0E,0x01,0x0E,0x00}, // 0x73 +{0x00,0x08,0x1E,0x08,0x08,0x0A,0x04,0x00}, // 0x74 +{0x00,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x75 +{0x00,0x00,0x11,0x11,0x11,0x0A,0x04,0x00}, // 0x76 +{0x00,0x00,0x11,0x11,0x15,0x1F,0x0A,0x00}, // 0x77 +{0x00,0x00,0x12,0x12,0x0C,0x12,0x12,0x00}, // 0x78 +{0x00,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0x79 +{0x00,0x00,0x1E,0x02,0x0C,0x10,0x1E,0x00}, // 0x7A +{0x06,0x08,0x08,0x18,0x08,0x08,0x06,0x00}, // 0x7B +{0x04,0x04,0x04,0x00,0x04,0x04,0x04,0x00}, // 0x7C +{0x0C,0x02,0x02,0x03,0x02,0x02,0x0C,0x00}, // 0x7D +{0x0A,0x14,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7E +{0x04,0x0E,0x1B,0x11,0x11,0x1F,0x00,0x00}, // 0x7F +{0x0E,0x11,0x10,0x10,0x11,0x0E,0x04,0x0C}, // 0x80 +{0x12,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x81 +{0x03,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x82 +{0x0E,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x83 +{0x0A,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x84 +{0x0C,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x85 +{0x0E,0x0A,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x86 +{0x00,0x0E,0x11,0x10,0x11,0x0E,0x04,0x0C}, // 0x87 +{0x0E,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x88 +{0x0A,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x89 +{0x0C,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x8A +{0x0A,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8B +{0x0E,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8C +{0x08,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8D +{0x0A,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0x8E +{0x0E,0x0A,0x0E,0x1B,0x11,0x1F,0x11,0x00}, // 0x8F +{0x03,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0x90 +{0x00,0x00,0x1E,0x05,0x1F,0x14,0x0F,0x00}, // 0x91 +{0x0F,0x14,0x14,0x1F,0x14,0x14,0x17,0x00}, // 0x92 +{0x0E,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x93 +{0x0A,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x94 +{0x18,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x95 +{0x0E,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x96 +{0x18,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x97 +{0x0A,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0x98 +{0x12,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x99 +{0x0A,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x9A +{0x00,0x00,0x01,0x0E,0x16,0x1A,0x1C,0x20}, // 0x9B +{0x06,0x09,0x08,0x1E,0x08,0x09,0x17,0x00}, // 0x9C +{0x0F,0x13,0x15,0x15,0x15,0x19,0x1E,0x00}, // 0x9D +{0x00,0x11,0x0A,0x04,0x0A,0x11,0x00,0x00}, // 0x9E +{0x02,0x05,0x04,0x0E,0x04,0x04,0x14,0x08}, // 0x9F +{0x06,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0xA0 +{0x06,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0xA1 +{0x06,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0xA2 +{0x06,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0xA3 +{0x0A,0x14,0x00,0x1C,0x12,0x12,0x12,0x00}, // 0xA4 +{0x0A,0x14,0x00,0x12,0x1A,0x16,0x12,0x00}, // 0xA5 +{0x0E,0x01,0x0F,0x11,0x0F,0x00,0x0F,0x00}, // 0xA6 +{0x0C,0x12,0x12,0x12,0x0C,0x00,0x1E,0x00}, // 0xA7 +{0x04,0x00,0x04,0x0C,0x10,0x11,0x0E,0x00}, // 0xA8 +{0x1E,0x25,0x2B,0x2D,0x2B,0x21,0x1E,0x00}, // 0xA9 +{0x00,0x00,0x3F,0x01,0x01,0x00,0x00,0x00}, // 0xAA +{0x10,0x12,0x14,0x0E,0x11,0x02,0x07,0x00}, // 0xAB +{0x10,0x12,0x14,0x0B,0x15,0x07,0x01,0x00}, // 0xAC +{0x04,0x00,0x04,0x04,0x0E,0x0E,0x04,0x00}, // 0xAD +{0x00,0x00,0x09,0x12,0x09,0x00,0x00,0x00}, // 0xAE +{0x00,0x00,0x12,0x09,0x12,0x00,0x00,0x00}, // 0xAF +{0x15,0x00,0x2A,0x00,0x15,0x00,0x2A,0x00}, // 0xB0 +{0x15,0x2A,0x15,0x2A,0x15,0x2A,0x15,0x2A}, // 0xB1 +{0x2A,0x3F,0x15,0x3F,0x2A,0x3F,0x15,0x3F}, // 0xB2 +{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04}, // 0xB3 +{0x04,0x04,0x04,0x3C,0x04,0x04,0x04,0x04}, // 0xB4 +{0x06,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xB5 +{0x0E,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xB6 +{0x0C,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xB7 +{0x1E,0x21,0x2D,0x29,0x2D,0x21,0x1E,0x00}, // 0xB8 +{0x14,0x34,0x04,0x34,0x14,0x14,0x14,0x14}, // 0xB9 +{0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14}, // 0xBA +{0x00,0x3C,0x04,0x34,0x14,0x14,0x14,0x14}, // 0xBB +{0x14,0x34,0x04,0x3C,0x00,0x00,0x00,0x00}, // 0xBC +{0x00,0x04,0x0E,0x10,0x10,0x0E,0x04,0x00}, // 0xBD +{0x11,0x0A,0x04,0x1F,0x04,0x1F,0x04,0x00}, // 0xBE +{0x00,0x00,0x00,0x3C,0x04,0x04,0x04,0x04}, // 0xBF +{0x04,0x04,0x04,0x07,0x00,0x00,0x00,0x00}, // 0xC0 +{0x04,0x04,0x04,0x3F,0x00,0x00,0x00,0x00}, // 0xC1 +{0x00,0x00,0x00,0x3F,0x04,0x04,0x04,0x04}, // 0xC2 +{0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04}, // 0xC3 +{0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0xC4 +{0x04,0x04,0x04,0x3F,0x04,0x04,0x04,0x04}, // 0xC5 +{0x05,0x0A,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0xC6 +{0x05,0x0A,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xC7 +{0x14,0x17,0x10,0x1F,0x00,0x00,0x00,0x00}, // 0xC8 +{0x00,0x1F,0x10,0x17,0x14,0x14,0x14,0x14}, // 0xC9 +{0x14,0x37,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0xCA +{0x00,0x3F,0x00,0x37,0x14,0x14,0x14,0x14}, // 0xCB +{0x14,0x17,0x10,0x17,0x14,0x14,0x14,0x14}, // 0xCC +{0x00,0x3F,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0xCD +{0x14,0x37,0x00,0x37,0x14,0x14,0x14,0x14}, // 0xCE +{0x11,0x0E,0x11,0x11,0x11,0x0E,0x11,0x00}, // 0xCF +{0x0C,0x10,0x08,0x04,0x0E,0x12,0x0C,0x00}, // 0xD0 +{0x0E,0x09,0x09,0x1D,0x09,0x09,0x0E,0x00}, // 0xD1 +{0x0E,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0xD2 +{0x0A,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0xD3 +{0x0C,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0xD4 +{0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00}, // 0xD5 +{0x06,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xD6 +{0x0E,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xD7 +{0x0A,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xD8 +{0x04,0x04,0x04,0x3C,0x00,0x00,0x00,0x00}, // 0xD9 +{0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x04}, // 0xDA +{0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F}, // 0xDB +{0x00,0x00,0x00,0x00,0x3F,0x3F,0x3F,0x3F}, // 0xDC +{0x04,0x04,0x04,0x00,0x04,0x04,0x04,0x00}, // 0xDD +{0x0C,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xDE +{0x3F,0x3F,0x3F,0x3F,0x00,0x00,0x00,0x00}, // 0xDF +{0x06,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE0 +{0x00,0x1C,0x12,0x1C,0x12,0x12,0x1C,0x10}, // 0xE1 +{0x0E,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE2 +{0x18,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE3 +{0x0A,0x14,0x00,0x0C,0x12,0x12,0x0C,0x00}, // 0xE4 +{0x0A,0x14,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0xE5 +{0x00,0x00,0x12,0x12,0x12,0x1C,0x10,0x10}, // 0xE6 +{0x00,0x18,0x10,0x1C,0x12,0x1C,0x10,0x18}, // 0xE7 +{0x18,0x10,0x1C,0x12,0x12,0x1C,0x10,0x18}, // 0xE8 +{0x06,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE9 +{0x0E,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xEA +{0x18,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xEB +{0x06,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0xEC +{0x06,0x00,0x11,0x0A,0x04,0x04,0x04,0x00}, // 0xED +{0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEE +{0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00}, // 0xEF +{0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0xF0 +{0x00,0x04,0x0E,0x04,0x00,0x0E,0x00,0x00}, // 0xF1 +{0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00}, // 0xF2 +{0x30,0x1A,0x34,0x0B,0x15,0x07,0x01,0x00}, // 0xF3 +{0x0F,0x15,0x15,0x0D,0x05,0x05,0x05,0x00}, // 0xF4 +{0x0E,0x11,0x0C,0x0A,0x06,0x11,0x0E,0x00}, // 0xF5 +{0x00,0x04,0x00,0x1F,0x00,0x04,0x00,0x00}, // 0xF6 +{0x00,0x00,0x00,0x0E,0x06,0x00,0x00,0x00}, // 0xF7 +{0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00}, // 0xF8 +{0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x00}, // 0xF9 +{0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00}, // 0xFA +{0x08,0x18,0x08,0x08,0x00,0x00,0x00,0x00}, // 0xFB +{0x1C,0x08,0x0C,0x18,0x00,0x00,0x00,0x00}, // 0xFC +{0x18,0x04,0x08,0x1C,0x00,0x00,0x00,0x00}, // 0xFD +{0x00,0x00,0x1E,0x1E,0x1E,0x1E,0x00,0x00}, // 0xFE +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF +}; + +#endif \ No newline at end of file diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index da3177f59..bbd0a069d 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -175,31 +175,6 @@ bool MAX7291Matrix_init(void) return true; } -// /*********************************************************************************************\ -// * Clears the display -// * Command: DisplayText -// \*********************************************************************************************/ -bool MAX7291Matrix_Text() -{ - char sString[CMD_MAX_LEN + 1]; - subStr(sString, XdrvMailbox.data, ",", 1); - max7219_Matrix->clear(); - AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: sString %s"), sString); - - // test - uint8_t length = strlen(sString); - //if(length > modulesPerRow) - length = modulesPerRow; - - for (int addr = 0; addr < length; addr++) - { - max7219_Matrix->setPixel(addr, addr, true); - AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: setPixel() %d, %d)"), addr, addr); - } - - return true; -} - bool Xdsp19(uint8_t function) { bool result = false; @@ -216,7 +191,7 @@ bool Xdsp19(uint8_t function) result = true; break; case FUNC_DISPLAY_CLEAR: - result = max7219_Matrix->clear(); + result = max7219_Matrix->clearDisplay(); break; case FUNC_DISPLAY_DIM: result = max7219_Matrix->setIntensity(GetDisplayDimmer16()); @@ -232,12 +207,13 @@ bool Xdsp19(uint8_t function) case FUNC_DISPLAY_SCROLLTEXT: case FUNC_DISPLAY_CLOCK: case FUNC_DISPLAY_DRAW_STRING: - result = MAX7291Matrix_Text(); + result = max7219_Matrix->drawText(dsp_str); + break; + case FUNC_DISPLAY_EVERY_SECOND: + //result = max7219_Matrix->scrollText(); break; case FUNC_DISPLAY_EVERY_50_MSECOND: - case FUNC_DISPLAY_EVERY_SECOND: - // ignore - return false; + result = max7219_Matrix->scrollText(); default: result = false; } From c4a4bb0ff8ed1cae90237587cbcae0ba091295b8 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 23 Nov 2021 23:08:05 +0100 Subject: [PATCH 05/31] scroll works --- lib/lib_display/LedControl/src/LedMatrix.cpp | 11 +- lib/lib_display/LedControl/src/LedMatrix.h | 6 +- tasmota/tasmota_template.h | 1 + tasmota/xdsp_19_max7219_matrix.ino | 110 +++++++++++++++---- 4 files changed, 102 insertions(+), 26 deletions(-) diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp index 19ac0dcb2..80ded02e2 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.cpp +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -62,6 +62,11 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un setIntensity(7); } +void LedMatrix::power(bool on) +{ + shutdown(!on); // shut down on power off +} + bool LedMatrix::drawText( const char *str) { strncpy(textBuf, str, TEXT_BUFFER_SIZE -1); @@ -70,6 +75,7 @@ bool LedMatrix::drawText( const char *str) textWidth = strlen(textBuf) * charWidth; if(textWidth < displayWidth) { + clear(); textPosX = (displayWidth - textWidth) / 2; // center } else @@ -78,7 +84,6 @@ bool LedMatrix::drawText( const char *str) // Append a space between end of text and the beginning of the repeting text. appendSpace(); } - clear(); drawTextAt(textBuf, textPosX, textPosY); refresh(); // refresh display with new string content return true; @@ -102,7 +107,7 @@ bool LedMatrix::scrollText() if(textWidth < displayWidth) return false; // do not scroll when text fits into the display textPosX--; - if(textPosX + textWidth < 0) + if(textPosX + textWidth < (int)0) { textPosX = 0; // start from the beginning after text scrolled out of display; } @@ -255,7 +260,7 @@ void LedMatrix::refresh() void LedMatrix::refreshByteOfBuffer(int i) { int line = i / modulesPerRow; - int addr = line / 8 + i % modulesPerRow; + int addr = (line / 8) * modulesPerRow + i % modulesPerRow; byte b = buffer[i]; if (moduleOrientation == ORIENTATION_NORMAL || moduleOrientation == ORIENTATION_UPSIDE_DOWN) { diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index 586a06146..1d251030b 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -60,11 +60,11 @@ class LedMatrix ModuleOrientation moduleOrientation; byte buffer[MATRIX_BUFFER_SIZE]; LedControl* ledControl; - const unsigned int charWidth = 6; - const unsigned int charHeight = 8; + const int charWidth = 6; + const int charHeight = 8; char textBuf[TEXT_BUFFER_SIZE]; char appendTextBuf[TEXT_APPEND_BUFFER_SIZE]; - unsigned int textWidth; // width of text [pixel] + int textWidth; // width of text [pixel] int textPosX; // horizontal pixel position of scrolling text int textPosY; // vertical pixelposition of scrolling text; diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index e3f3256fc..13fdf23e4 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -524,6 +524,7 @@ const uint16_t kGpioNiceList[] PROGMEM = { #ifdef USE_DISPLAY_MAX7219_MATRIX #undef USE_DISPLAY_MAX7219 #undef USE_DISPLAY_TM1637 + #define USE_DISPLAY_MODES1TO5 AGPIO(GPIO_MAX7219CLK), AGPIO(GPIO_MAX7219DIN), AGPIO(GPIO_MAX7219CS), diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index bbd0a069d..ec82420e2 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -131,16 +131,22 @@ and setting it to 3 alternates between time and date. \*********************************************************************************************/ #define XDSP_19 19 -#define CMD_MAX_LEN 55 +#include #include -LedMatrix *max7219_Matrix; -bool max2791Matrix_init_done = false; -byte modulesPerRow = 4; -byte modulesPerCol = 1; +LedMatrix *max7219_Matrix = nullptr; +bool max2791Matrix_initDriver_done = false; +struct +{ + byte modulesPerRow = 4; + byte modulesPerCol = 1; + bool show_clock = false; + const char* timeFormat; -bool MAX7291Matrix_init(void) +} LedMatrix_settings; + +bool MAX7291Matrix_initDriver(void) { if (!PinUsed(GPIO_MAX7219DIN) || !PinUsed(GPIO_MAX7219CLK) || !PinUsed(GPIO_MAX7219CS)) { @@ -151,27 +157,79 @@ bool MAX7291Matrix_init(void) Settings->display_model = XDSP_19; if (Settings->display_width) // [pixel] { - modulesPerRow = (Settings->display_width - 1) / 8 + 1; + LedMatrix_settings.modulesPerRow = (Settings->display_width - 1) / 8 + 1; } - Settings->display_width = 8 * modulesPerRow; + Settings->display_width = 8 * LedMatrix_settings.modulesPerRow; Settings->display_cols[0] = Settings->display_width; if (Settings->display_height) // [pixel] { - modulesPerCol = (Settings->display_height - 1) / 8 + 1; + LedMatrix_settings.modulesPerCol = (Settings->display_height - 1) / 8 + 1; } - Settings->display_height = 8 * modulesPerCol; + Settings->display_height = 8 * LedMatrix_settings. modulesPerCol; Settings->display_rows = Settings->display_height; Settings->display_cols[1] = Settings->display_height; - max7219_Matrix = new LedMatrix(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), modulesPerRow, modulesPerCol); + max7219_Matrix = new LedMatrix(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), LedMatrix_settings.modulesPerRow, LedMatrix_settings.modulesPerCol); + max2791Matrix_initDriver_done = true; + + return MAX7291Matrix_init(); +} + +bool MAX7291Matrix_init(void) +{ int intensity = GetDisplayDimmer16(); // 0..15 max7219_Matrix->setIntensity(intensity); int orientation = Settings->display_rotate; max7219_Matrix->setOrientation((LedMatrix::ModuleOrientation)orientation ); - AddLog(LOG_LEVEL_INFO, PSTR("DSP: MAX7291Matrix_init %dx%d modules, orientation: %d, intensity: %d"), modulesPerRow , modulesPerCol, orientation, intensity); - max2791Matrix_init_done = true; + AddLog(LOG_LEVEL_INFO, PSTR("MTX: MAX7291Matrix_init %dx%d modules, orientation: %d, intensity: %d"), LedMatrix_settings.modulesPerRow , LedMatrix_settings.modulesPerCol, orientation, intensity); - max7219_Matrix->test(); - AddLog(LOG_LEVEL_INFO, PSTR("DSP: display test")); + //max7219_Matrix->test(); + AddLog(LOG_LEVEL_INFO, PSTR("MTX: display test")); + return true; +} + +bool MAX7291Matrix_clock(void) +{ + LedMatrix_settings.show_clock = XdrvMailbox.payload; + if (ArgC() == 0) + XdrvMailbox.payload = 1; + if (XdrvMailbox.payload > 1) + { + LedMatrix_settings.timeFormat = "%H:%M"; + if(LedMatrix_settings.modulesPerRow > 6) + { + LedMatrix_settings.timeFormat = "%H:%M:%S"; + } + XdrvMailbox.payload = 2; + } + else + { + LedMatrix_settings.timeFormat = "%I:%M"; + if(LedMatrix_settings.modulesPerRow > 6) + { + LedMatrix_settings.timeFormat = "%I:%M:%S"; + } + XdrvMailbox.payload = 1; + } + + AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: LedMatrix_settings.show_clock %d, timeFormat %s"), LedMatrix_settings.show_clock, LedMatrix_settings.timeFormat); + + //max7219_Matrix->clearDisplay(); + MAX7291Matrix_showTime(); + return true; +} + +bool MAX7291Matrix_showTime() +{ + time_t rawtime; + struct tm *timeinfo; + char timeStr[10]; + + time(&rawtime); + timeinfo = localtime(&rawtime); + strftime(timeStr, 10, LedMatrix_settings.timeFormat, timeinfo); + //AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: showTime:%s"), timeStr); + + max7219_Matrix->drawText(timeStr); return true; } @@ -179,14 +237,20 @@ bool Xdsp19(uint8_t function) { bool result = false; - if (FUNC_DISPLAY_INIT_DRIVER == function) + if (FUNC_DISPLAY_INIT_DRIVER == function && !max2791Matrix_initDriver_done ) { - result = MAX7291Matrix_init(); + result = MAX7291Matrix_initDriver(); } - else if (max7219_Matrix && (XDSP_19 == Settings->display_model)) + else if (max2791Matrix_initDriver_done && max7219_Matrix && (XDSP_19 == Settings->display_model)) { switch (function) { + case FUNC_DISPLAY_INIT: + result = MAX7291Matrix_init(); + break; + case FUNC_DISPLAY_POWER: + max7219_Matrix->power(disp_power!=0); + break; case FUNC_DISPLAY_MODEL: result = true; break; @@ -196,6 +260,9 @@ bool Xdsp19(uint8_t function) case FUNC_DISPLAY_DIM: result = max7219_Matrix->setIntensity(GetDisplayDimmer16()); break; + case FUNC_DISPLAY_CLOCK: + result = MAX7291Matrix_clock(); + break; case FUNC_DISPLAY_SEVENSEG_TEXT: case FUNC_DISPLAY_SEVENSEG_TEXTNC: case FUNC_DISPLAY_NUMBER: @@ -205,12 +272,15 @@ bool Xdsp19(uint8_t function) case FUNC_DISPLAY_RAW: case FUNC_DISPLAY_LEVEL: case FUNC_DISPLAY_SCROLLTEXT: - case FUNC_DISPLAY_CLOCK: case FUNC_DISPLAY_DRAW_STRING: result = max7219_Matrix->drawText(dsp_str); break; case FUNC_DISPLAY_EVERY_SECOND: - //result = max7219_Matrix->scrollText(); + if (LedMatrix_settings.show_clock) + { + result = MAX7291Matrix_showTime(); + } + break; case FUNC_DISPLAY_EVERY_50_MSECOND: result = max7219_Matrix->scrollText(); From f2f6eba00989f03a403f5652d93746ab24adfd9d Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 24 Nov 2021 17:24:40 +0100 Subject: [PATCH 06/31] ready for ESP32 --- lib/lib_display/LedControl/src/LedMatrix.cpp | 119 +++----- lib/lib_display/LedControl/src/LedMatrix.h | 208 +++++++------- .../LedControl/src/font_5x8_horizontal_MSB.h | 3 + .../LedControl/src/font_6x8_horizontal_MSB.h | 3 + .../src/font_8x8_horizontal_latin_MSB.h | 265 ++++++++++++++++++ tasmota/tasmota_template.h | 1 - tasmota/xdsp_19_max7219_matrix.ino | 201 +++++++------ 7 files changed, 515 insertions(+), 285 deletions(-) create mode 100644 lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp index 80ded02e2..b4fb8c260 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.cpp +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -1,5 +1,5 @@ /* - * LedMatrix.h - Extends the Library LedControl for multiple LED dot matrix modules, based on MAX7219/MAX7221 + * LedMatrix.h - Extends the Library LedControl for multiple 8x8 LED dot matrix modules, based on MAX7219/MAX7221 * Copyright (c) 2021 Michael Beuss * * Permission is hereby granted, free of charge, to any person @@ -25,7 +25,9 @@ */ #include "LedMatrix.h" +//#include "font_5x8_horizontal_MSB.h" #include "font_6x8_horizontal_MSB.h" +//#include "font_8x8_horizontal_latin_MSB.h" // public LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows) @@ -44,13 +46,15 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un } } + charWidth = font_char_width; // defined in header file of font + charHeight = font_char_height; // defined in header file of font modulesPerRow = colums; modulesPerCol = rows; displayWidth = colums * 8; displayHeight = rows * 8; modules = colums * rows; - moduleOrientation = ORIENTATION_UPSIDE_DOWN; - ledControl = new LedControl(dataPin, clkPin, csPin, modules); + moduleOrientation = ORIENTATION_UPSIDE_DOWN; // use setOrientation() to turn it + ledControl = new LedControl(dataPin, clkPin, csPin, modules); // initializes all connected LED matrix modules textBuf[0] = 0; textWidth = 0; textPosX = 0; @@ -62,11 +66,6 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un setIntensity(7); } -void LedMatrix::power(bool on) -{ - shutdown(!on); // shut down on power off -} - bool LedMatrix::drawText( const char *str) { strncpy(textBuf, str, TEXT_BUFFER_SIZE -1); @@ -75,6 +74,7 @@ bool LedMatrix::drawText( const char *str) textWidth = strlen(textBuf) * charWidth; if(textWidth < displayWidth) { + // text fits into the display, place it into the center clear(); textPosX = (displayWidth - textWidth) / 2; // center } @@ -85,7 +85,7 @@ bool LedMatrix::drawText( const char *str) appendSpace(); } drawTextAt(textBuf, textPosX, textPosY); - refresh(); // refresh display with new string content + refresh(); // refresh display with the new drawed string content return true; } @@ -116,36 +116,16 @@ bool LedMatrix::scrollText() int startOfRepeatingTextPos = textPosX + textWidth; if(startOfRepeatingTextPos < displayWidth) { - // Draw repeating text. + // draw repeating text drawTextAt(textBuf, startOfRepeatingTextPos, textPosY); } refresh(); return true; } -bool LedMatrix::drawCharAt( char c, const int x, const int y) +void LedMatrix::power(bool on) { - // ignore when the character position is not visible on the display - bool visible = ( - x > 0 - (int)charWidth && x < (int)displayWidth && - y > 0 - (int)charHeight && y < (int)displayHeight - ); - if (!visible) return false; - - // ignore the leading bits above charWidth of the font definition - static const byte charOffset = 8 - charWidth; - - for (byte charY = 0; charY < charHeight; charY++) - { - char pixelRow = (font[c][charY]) << charOffset; // skip the first bits when the character width is smaller than 8 pixel - for (byte charX = 0; charX < charWidth; charX++) - { - bool pixel = (pixelRow & 0x80); // pixel=true when upper bit is set - setPixel(x + charX, y + charY, pixel); - pixelRow = pixelRow << 1; // next pixel - } - } - return true; + shutdown(!on); // power(false) shuts down the display with shutdown(true) } bool LedMatrix::clearDisplay(void) @@ -157,17 +137,6 @@ bool LedMatrix::clearDisplay(void) return true; } - -bool LedMatrix::clear(void) -{ - memset(buffer, 0, MATRIX_BUFFER_SIZE); - for (int addr = 0; addr < modules; addr++) - { - ledControl->clearDisplay(addr); - } - return true; -} - bool LedMatrix::setIntensity(byte dim) { for (int addr = 0; addr < modules; addr++) @@ -208,38 +177,40 @@ bool LedMatrix::setPixel(const int x, const int y, bool on) return true; } -void LedMatrix::test() +void LedMatrix::refresh() { - /* - const static byte testMatrix[] PROGMEM = { - B00000010, B00111100, B00111100, B00001000, - B00000110, B01000010, B01000010, B00010000, - B00001010, B00000010, B00000010, B00100000, - B00000010, B00000100, B00001100, B01000100, - B00000010, B00011000, B00000010, B01111110, - B00000010, B00100000, B01000010, B00000100, - B00000000, B01111110, B00111100, B00000100, - B00000000, B00000000, B00000000, B00000000, - }; - for (int i = 0; i < 32; i++) + for (int i = 0; i < modulesPerRow * displayHeight; i++) { - buffer[i] = testMatrix[i]; + refreshByteOfBuffer(i); } - refresh(); - */ - drawText("1234567890"); - delay(1000); - for( int i=0; i<320; i++) - { - delay(50); - scrollText(); - } - //drawCharAt(0x31, 1, 0); - //setPixel(1,30); - //refresh(); } -// private +// private functions +bool LedMatrix::drawCharAt( char c, const int x, const int y) +{ + // ignore when the character position is not visible on the display + bool visible = ( + x > 0 - (int)charWidth && x < (int)displayWidth && + y > 0 - (int)charHeight && y < (int)displayHeight + ); + if (!visible) return false; + + // ignore the leading bits above charWidth of the font definition + static const byte charOffset = 8 - charWidth; + + for (byte charY = 0; charY < charHeight; charY++) + { + char pixelRow = (font[c][charY]) << charOffset; // skip the first bits when the character width is smaller than 8 pixel + for (byte charX = 0; charX < charWidth; charX++) + { + bool pixel = (pixelRow & 0x80); // pixel=true when upper bit is set + setPixel(x + charX, y + charY, pixel); + pixelRow = pixelRow << 1; // next pixel + } + } + return true; +} + bool LedMatrix::shutdown(bool b) { for (int addr = 0; addr < modules; addr++) @@ -249,12 +220,14 @@ bool LedMatrix::shutdown(bool b) return true; } -void LedMatrix::refresh() +bool LedMatrix::clear(void) { - for (int i = 0; i < modulesPerRow * displayHeight; i++) + memset(buffer, 0, MATRIX_BUFFER_SIZE); + for (int addr = 0; addr < modules; addr++) { - refreshByteOfBuffer(i); + ledControl->clearDisplay(addr); } + return true; } void LedMatrix::refreshByteOfBuffer(int i) diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index 1d251030b..efb50b8e3 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -1,5 +1,5 @@ /* - * LedMatrix.h - Extends the Library LedControl for multiple LED dot matrix modules, based on MAX7219/MAX7221 + * LedMatrix.h - Extends the Library LedControl for multiple 8x8 LED dot matrix modules, based on MAX7219/MAX7221 * Copyright (c) 2021 Michael Beuss * * Permission is hereby granted, free of charge, to any person @@ -29,21 +29,21 @@ #include -#define MATRIX_MAX_MODULES 32 +#define MATRIX_MAX_MODULES 32 // maximum number of modules that can be used #define MATRIX_BUFFER_SIZE MATRIX_MAX_MODULES * 8 // 8 bytes per modul. One byte represents 8 LEDs. -#define TEXT_BUFFER_SIZE 256 -#define TEXT_APPEND_BUFFER_SIZE 16 +#define TEXT_BUFFER_SIZE 256 // maximum text length that can be scrolled +#define TEXT_APPEND_BUFFER_SIZE 16 // used for characters that are appended to the scroll text, before it repeats /** * @brief LedMatric controls multiple 8x8 LED dot matrx modules. - * All modules in rows and clolums together build a common matrix. + * All modules in rows and clolums together build a common display pixel matrix. * */ class LedMatrix { public: - enum ModuleOrientation // orientation of 8x8 LED dot matrix mdules (first module is top left) + enum ModuleOrientation // orientation of 8x8 LED dot matrix mdules (first module starts at top left) { ORIENTATION_NORMAL, // first pixel is on top left, no turn is necessary ORIENTATION_TURN_RIGHT, // first pixel is on bottom left, for correction it has to turn 90° right @@ -51,6 +51,100 @@ class LedMatrix ORIENTATION_TURN_LEFT, // first pixel is on top right, for correction is has to turn 90° left. }; + public: + /** + * @brief Construct a new LED Matrix object + * + * @param colums of 8x8 LED dot matrix modules + * @param rows of 8x8 LED dot matrix modules + */ + LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows); + + /** + * @brief Draws a string to the display. + * When the text fits into the display, it will be shown in the center. + * When the text is longer than than the display width, it can be scrolled per pixel with function scrollText(). + * + * @param str string to display + */ + bool drawText( const char *str ); + + /** + * @brief Dwaws a character string to a defined display position. The position (x,y) is used for the upper left pixel of the text. + * Existing text before the x position will not be cleared. Use refresh() after all text parts are drawed. + * + * @param str string to display + * @param x horizantal pixel position to start with string (0 is most left) + * @param y vertical pixel position for the top position of the string (0 is top) + */ + bool drawTextAt( const char *str, const int x, const int y ); + + /** + * @brief Scroll the current text one pixel to the left. + * Repeat with from start when end of text reached. This function can be called every 50 ms to get a propper scroll speed. + * + */ + bool scrollText(); + + /** + * @brief switches the display on or off + * + * @param on true: on false: off + */ + + void power( bool on ); + + /** + * @brief cleares the display and text buffer + * + */ + bool clearDisplay(void); + + /** + * @brief Set the brightness of the display + * + * @param dim 0..15 (0: dark .. 15: light) + */ + bool setIntensity(byte dim); + + /** + * @brief Set the orientation of the 8x8 LED dot matrix module + * + * @param orientation + */ + bool setOrientation(ModuleOrientation orientation); + + /** + * @brief Set ap pixel at a defined position. + * After all Pixels are set, call refresh() to send it to the display. + * + * @param x horizontal position from left + * @param y vertical position from top + * @param on true: on, false: off + */ + + /** + * @brief Set the a pending string to the scrolling text to set a distance to the repeating text. Usually some spaces are used. + * + * @param append text to append to the scrolling text before repeating. + */ + bool setScrollAppendText(const char* append ); + + bool setPixel( const int x, const int y, bool on=true); + /** + * @brief sends the changed content of the buffer to the display + * + */ + void refresh(); + + private: + bool drawCharAt( char c, int x, int y ); // Draws a character to a defined position + bool shutdown(bool b); // shutdown(true) switches the display off. Text and pixels can be set while it is off. shutdown(false) switches the display on. + bool clear(void); // clears the display content + void refreshByteOfBuffer( int i); // sends one byte of the buffer to the display. This updates an 8 pixel row of one matrix module. + byte revereBitorder(byte b); // returnes the byte in the reverse bit order. + void appendSpace(); // appends characters to the end of the text to get a distance to the repeating scroll text + private: unsigned int modulesPerRow; unsigned int modulesPerCol; @@ -60,112 +154,14 @@ class LedMatrix ModuleOrientation moduleOrientation; byte buffer[MATRIX_BUFFER_SIZE]; LedControl* ledControl; - const int charWidth = 6; - const int charHeight = 8; + int charWidth; + int charHeight; char textBuf[TEXT_BUFFER_SIZE]; char appendTextBuf[TEXT_APPEND_BUFFER_SIZE]; int textWidth; // width of text [pixel] int textPosX; // horizontal pixel position of scrolling text int textPosY; // vertical pixelposition of scrolling text; - - public: - /** - * @brief Construct a new Led Matrix object - * - * @param colums of 8x8 LED dot matrix modules - * @param rows of 8x8 LED dot matrix modules - */ - LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows); - - /** - * @brief Set all LEDs off. - * - */ - bool clearDisplay(void); - - /** - * @brief Set the brightness of the display - * - * @param dim 0..15 - */ - bool setIntensity(byte dim); - - /** - * @brief Set the a pending string to the scrolling text to set a distance to te repeating text. Usually some spaces. - * - * @param append text to append to the scrolling text before repeating. - */ - bool setScrollAppendText(const char* append ); - - /** - * @brief Switches the display on or off - * - * @param on true: on false: off - */ - void power( bool on ); - - /** - * @brief Set the orientation of the 8x8 LED dot matrix module - * - * @param orientation - */ - bool setOrientation(ModuleOrientation orientation); - - /** - * @brief draw a string to the display. - * When the text fits into the size of the display, it will be shown in the center. - * When the text is longer than than the display width, it can be scrolled per pixel with function scrollText(). - * - * @param str string to display - */ - bool drawText( const char *str ); - - /** - * @brief dwaws a character string to the display. The position (x,y) is used for the upper left pixtel of the text. - * Existing text before the x position will not be cleared. - * - * @param str string to display - * @param x horizantal pixel position to start with string (default 0) - * @param y vertical pixel position for the top position of the string (default 0) - */ - bool drawTextAt( const char *str, const int x, const int y ); - - /** - * @brief Scroll the current teext one picel to the left. - * Repeat with from start when end of text reached. - * - */ - bool scrollText(); - - /** - * @brief Set the Pixel object - * - * @param x horizontal position from left - * @param y vertical position from top - * @param on true: on, false: off - */ - bool setPixel( const int x, const int y, bool on=true); - void test(); - - private: - bool drawCharAt( char c, int x, int y ); - - bool shutdown(bool b); - bool clear(void); - - /** - * @brief sends the changed content of the buffer to the display - * - */ - void refresh(); - - void refreshByteOfBuffer( int i); - - byte revereBitorder (byte b); - - void appendSpace(); - }; #endif //LedMatrix_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h b/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h index 56df774a4..da3becc4e 100644 --- a/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h +++ b/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h @@ -2,6 +2,9 @@ #ifndef font_5x8_horizontal_MSB_h #define font_5x8_horizontal_MSB_h +const unsigned int font_char_width = 5; +const unsigned int font_char_height = 8; + const char font[256][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 {0x0E,0x11,0x1B,0x11,0x1F,0x0E,0x00,0x00}, // 0x01 diff --git a/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h b/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h index cc3a323cc..e5c522cd4 100644 --- a/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h +++ b/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h @@ -2,6 +2,9 @@ #ifndef font_6x8_horizontal_MSB_h #define font_6x8_horizontal_MSB_h +const unsigned int font_char_width = 6; +const unsigned int font_char_height = 8; + const char font[256][8]={ {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 {0x0E,0x11,0x1B,0x11,0x15,0x11,0x0E,0x00}, // 0x01 diff --git a/lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h b/lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h new file mode 100644 index 000000000..e1a8af7ae --- /dev/null +++ b/lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h @@ -0,0 +1,265 @@ +#ifndef font_8x8_horizontal_latin_MSB_h +#define font_8x8_horizontal_latin_MSB_h + +const unsigned int font_char_width = 8; +const unsigned int font_char_height = 8; + +const char font[256][8]={ +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 +{0x0E,0x11,0x1B,0x11,0x15,0x11,0x0E,0x00}, // 0x01 +{0x0E,0x1F,0x15,0x1F,0x11,0x1F,0x0E,0x00}, // 0x02 +{0x00,0x0A,0x1F,0x1F,0x1F,0x0E,0x04,0x00}, // 0x03 +{0x00,0x04,0x0E,0x1F,0x1F,0x0E,0x04,0x00}, // 0x04 +{0x04,0x0E,0x0E,0x04,0x1F,0x1F,0x04,0x00}, // 0x05 +{0x00,0x04,0x0E,0x1F,0x1F,0x04,0x0E,0x00}, // 0x06 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A +{0x00,0x07,0x03,0x0D,0x12,0x12,0x0C,0x00}, // 0x0B +{0x0E,0x11,0x11,0x0E,0x04,0x0E,0x04,0x00}, // 0x0C +{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D +{0x03,0x0D,0x0B,0x0D,0x0B,0x1B,0x18,0x00}, // 0x0E +{0x00,0x15,0x0E,0x1B,0x0E,0x15,0x00,0x00}, // 0x0F +{0x08,0x0C,0x0E,0x0F,0x0E,0x0C,0x08,0x00}, // 0x10 +{0x02,0x06,0x0E,0x1E,0x0E,0x06,0x02,0x00}, // 0x11 +{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x00}, // 0x12 +{0x0A,0x0A,0x0A,0x0A,0x0A,0x00,0x0A,0x00}, // 0x13 +{0x0F,0x15,0x15,0x0D,0x05,0x05,0x05,0x00}, // 0x14 +{0x0E,0x11,0x0C,0x0A,0x06,0x11,0x0E,0x00}, // 0x15 +{0x00,0x00,0x00,0x00,0x00,0x1E,0x1E,0x00}, // 0x16 +{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x0E}, // 0x17 +{0x04,0x0E,0x1F,0x04,0x04,0x04,0x04,0x00}, // 0x18 +{0x04,0x04,0x04,0x04,0x1F,0x0E,0x04,0x00}, // 0x19 +{0x00,0x04,0x06,0x1F,0x06,0x04,0x00,0x00}, // 0x1A +{0x00,0x04,0x0C,0x1F,0x0C,0x04,0x00,0x00}, // 0x1B +{0x00,0x00,0x00,0x10,0x10,0x10,0x1F,0x00}, // 0x1C +{0x00,0x0A,0x0A,0x1F,0x0A,0x0A,0x00,0x00}, // 0x1D +{0x04,0x04,0x0E,0x0E,0x1F,0x1F,0x00,0x00}, // 0x1E +{0x1F,0x1F,0x0E,0x0E,0x04,0x04,0x00,0x00}, // 0x1F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) + { 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) + { 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") + { 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) + { 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) + { 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) + { 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) + { 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') + { 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() + { 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) + { 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) + { 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) + { 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) + { 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) + { 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) + { 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) + { 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) + { 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) + { 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) + { 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) + { 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) + { 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) + { 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) + { 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) + { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) + { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;) + { 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) + { 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) + { 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) + { 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) + { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) + { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) + { 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) + { 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) + { 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) + { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) + { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) + { 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) + { 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) + { 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) + { 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) + { 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) + { 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) + { 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) + { 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) + { 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) + { 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) + { 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) + { 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) + { 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) + { 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) + { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) + { 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) + { 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) + { 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) + { 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) + { 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) + { 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) + { 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) + { 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) + { 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) + { 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) + { 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) + { 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) + { 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) + { 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) + { 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) + { 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) + { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) + { 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) + { 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) + { 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) + { 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) + { 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) + { 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) + { 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) + { 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) + { 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) + { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) + { 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) + { 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) + { 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) + { 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) + { 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) + { 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) + { 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) + { 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) + { 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) + { 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) + { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) + { 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) + { 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007F{0x0E,0x11,0x10,0x10,0x11,0x0E,0x04,0x0C}, // 0x80 +{0x12,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x81 +{0x03,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x82 +{0x0E,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x83 +{0x0A,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x84 +{0x0C,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x85 +{0x0E,0x0A,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x86 +{0x00,0x0E,0x11,0x10,0x11,0x0E,0x04,0x0C}, // 0x87 +{0x0E,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x88 +{0x0A,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x89 +{0x0C,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x8A +{0x0A,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8B +{0x0E,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8C +{0x08,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8D +{0x0A,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0x8E +{0x0E,0x0A,0x0E,0x1B,0x11,0x1F,0x11,0x00}, // 0x8F +{0x03,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0x90 +{0x00,0x00,0x1E,0x05,0x1F,0x14,0x0F,0x00}, // 0x91 +{0x0F,0x14,0x14,0x1F,0x14,0x14,0x17,0x00}, // 0x92 +{0x0E,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x93 +{0x0A,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x94 +{0x18,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x95 +{0x0E,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x96 +{0x18,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x97 +{0x0A,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0x98 +{0x12,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x99 +{0x0A,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x9A +{0x00,0x00,0x01,0x0E,0x16,0x1A,0x1C,0x20}, // 0x9B +{0x06,0x09,0x08,0x1E,0x08,0x09,0x17,0x00}, // 0x9C +{0x0F,0x13,0x15,0x15,0x15,0x19,0x1E,0x00}, // 0x9D +{0x00,0x11,0x0A,0x04,0x0A,0x11,0x00,0x00}, // 0x9E +{0x02,0x05,0x04,0x0E,0x04,0x04,0x14,0x08}, // 0x9F + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A0 (no break space) + { 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00}, // U+00A1 (inverted !) + { 0x18, 0x18, 0x7E, 0x03, 0x03, 0x7E, 0x18, 0x18}, // U+00A2 (dollarcents) + { 0x1C, 0x36, 0x26, 0x0F, 0x06, 0x67, 0x3F, 0x00}, // U+00A3 (pound sterling) + { 0x00, 0x00, 0x63, 0x3E, 0x36, 0x3E, 0x63, 0x00}, // U+00A4 (currency mark) + { 0x33, 0x33, 0x1E, 0x3F, 0x0C, 0x3F, 0x0C, 0x0C}, // U+00A5 (yen) + { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+00A6 (broken pipe) + { 0x7C, 0xC6, 0x1C, 0x36, 0x36, 0x1C, 0x33, 0x1E}, // U+00A7 (paragraph) + { 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A8 (diaeresis) + { 0x3C, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3C}, // U+00A9 (copyright symbol) + { 0x3C, 0x36, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00}, // U+00AA (superscript a) + { 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00}, // U+00AB (<<) + { 0x00, 0x00, 0x00, 0x3F, 0x30, 0x30, 0x00, 0x00}, // U+00AC (gun pointing left) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AD (soft hyphen) + { 0x3C, 0x42, 0x9D, 0xA5, 0x9D, 0xA5, 0x42, 0x3C}, // U+00AE (registered symbol) + { 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AF (macron) + { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B0 (degree) + { 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00}, // U+00B1 (plusminus) + { 0x1C, 0x30, 0x18, 0x0C, 0x3C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 2) + { 0x1C, 0x30, 0x18, 0x30, 0x1C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 3) + { 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00B2 (aigu) + { 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x03}, // U+00B5 (mu) + { 0xFE, 0xDB, 0xDB, 0xDE, 0xD8, 0xD8, 0xD8, 0x00}, // U+00B6 (pilcrow) + { 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}, // U+00B7 (central dot) + { 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x1E}, // U+00B8 (cedille) + { 0x08, 0x0C, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B9 (superscript 1) + { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00BA (superscript 0) + { 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00}, // U+00BB (>>) + { 0xC3, 0x63, 0x33, 0xBD, 0xEC, 0xF6, 0xF3, 0x03}, // U+00BC (1/4) + { 0xC3, 0x63, 0x33, 0x7B, 0xCC, 0x66, 0x33, 0xF0}, // U+00BD (1/2) + { 0x03, 0xC4, 0x63, 0xB4, 0xDB, 0xAC, 0xE6, 0x80}, // U+00BE (3/4) + { 0x0C, 0x00, 0x0C, 0x06, 0x03, 0x33, 0x1E, 0x00}, // U+00BF (inverted ?) + { 0x07, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C0 (A grave) + { 0x70, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C1 (A aigu) + { 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C2 (A circumflex) + { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C3 (A ~) + { 0x63, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x63, 0x00}, // U+00C4 (A umlaut) + { 0x0C, 0x0C, 0x00, 0x1E, 0x33, 0x3F, 0x33, 0x00}, // U+00C5 (A ring) + { 0x7C, 0x36, 0x33, 0x7F, 0x33, 0x33, 0x73, 0x00}, // U+00C6 (AE) + { 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x18, 0x30, 0x1E}, // U+00C7 (C cedille) + { 0x07, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C8 (E grave) + { 0x38, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C9 (E aigu) + { 0x0C, 0x12, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CA (E circumflex) + { 0x36, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CB (E umlaut) + { 0x07, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CC (I grave) + { 0x38, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CD (I aigu) + { 0x0C, 0x12, 0x00, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CE (I circumflex) + { 0x33, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CF (I umlaut) + { 0x3F, 0x66, 0x6F, 0x6F, 0x66, 0x66, 0x3F, 0x00}, // U+00D0 (Eth) + { 0x3F, 0x00, 0x33, 0x37, 0x3F, 0x3B, 0x33, 0x00}, // U+00D1 (N ~) + { 0x0E, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D2 (O grave) + { 0x70, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D3 (O aigu) + { 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D4 (O circumflex) + { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x63, 0x3E, 0x00}, // U+00D5 (O ~) + { 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00}, // U+00D6 (O umlaut) + { 0x00, 0x36, 0x1C, 0x08, 0x1C, 0x36, 0x00, 0x00}, // U+00D7 (multiplicative x) + { 0x5C, 0x36, 0x73, 0x7B, 0x6F, 0x36, 0x1D, 0x00}, // U+00D8 (O stroke) + { 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00D9 (U grave) + { 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DA (U aigu) + { 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DB (U circumflex) + { 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+00DC (U umlaut) + { 0x70, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00}, // U+00DD (Y aigu) + { 0x0F, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+00DE (Thorn) + { 0x00, 0x1E, 0x33, 0x1F, 0x33, 0x1F, 0x03, 0x03}, // U+00DF (beta) + { 0x07, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E0 (a grave) + { 0x38, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E1 (a aigu) + { 0x7E, 0xC3, 0x3C, 0x60, 0x7C, 0x66, 0xFC, 0x00}, // U+00E2 (a circumflex) + { 0x6E, 0x3B, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E3 (a ~) + { 0x33, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E4 (a umlaut) + { 0x0C, 0x0C, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E5 (a ring) + { 0x00, 0x00, 0xFE, 0x30, 0xFE, 0x33, 0xFE, 0x00}, // U+00E6 (ae) + { 0x00, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x30, 0x1C}, // U+00E7 (c cedille) + { 0x07, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E8 (e grave) + { 0x38, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E9 (e aigu) + { 0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x06, 0x3C, 0x00}, // U+00EA (e circumflex) + { 0x33, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00EB (e umlaut) + { 0x07, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EC (i grave) + { 0x1C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00ED (i augu) + { 0x3E, 0x63, 0x1C, 0x18, 0x18, 0x18, 0x3C, 0x00}, // U+00EE (i circumflex) + { 0x33, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EF (i umlaut) + { 0x1B, 0x0E, 0x1B, 0x30, 0x3E, 0x33, 0x1E, 0x00}, // U+00F0 (eth) + { 0x00, 0x1F, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x00}, // U+00F1 (n ~) + { 0x00, 0x07, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F2 (o grave) + { 0x00, 0x38, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F3 (o aigu) + { 0x1E, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F4 (o circumflex) + { 0x6E, 0x3B, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F5 (o ~) + { 0x00, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F6 (o umlaut) + { 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00}, // U+00F7 (division) + { 0x00, 0x60, 0x3C, 0x76, 0x7E, 0x6E, 0x3C, 0x06}, // U+00F8 (o stroke) + { 0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00F9 (u grave) + { 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FA (u aigu) + { 0x1E, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FB (u circumflex) + { 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FC (u umlaut) + { 0x00, 0x38, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+00FD (y aigu) + { 0x00, 0x00, 0x06, 0x3E, 0x66, 0x3E, 0x06, 0x00}, // U+00FE (thorn) + { 0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F} // U+00FF (y umlaut) +}; + +#endif \ No newline at end of file diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index 13fdf23e4..e3f3256fc 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -524,7 +524,6 @@ const uint16_t kGpioNiceList[] PROGMEM = { #ifdef USE_DISPLAY_MAX7219_MATRIX #undef USE_DISPLAY_MAX7219 #undef USE_DISPLAY_TM1637 - #define USE_DISPLAY_MODES1TO5 AGPIO(GPIO_MAX7219CLK), AGPIO(GPIO_MAX7219DIN), AGPIO(GPIO_MAX7219CS), diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index ec82420e2..3ec3ac332 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -1,5 +1,5 @@ /* - xdsp_19_max7219_matrix.ino.ino - Support for MAX7219 based dot matrix displays for Tasmota + xdsp_19_max7219_matrix.ino.ino - Support for MAX7219 based 8x8 dot matrix displays for Tasmota Copyright (C) 2021 Michael Beuss @@ -20,111 +20,63 @@ #ifdef USE_DISPLAY #ifdef USE_DISPLAY_MAX7219_MATRIX /*********************************************************************************************\ - This driver enables the display of ascii text on MAX7219 based LED dot matrix modules. + This driver enables the display of ascii text on MAX7219 based 8x8 LED dot matrix modules (1088AS). - Connect the MAX7219 display module's pins to any free GPIOs of the ESP8266 or ESP32 module - and assign the pins as follows from Tasmota's GUI: + Connect the MAX7219 display module's pins to any free GPIOs of the ESP8266 or ESP32 module. + VCC should be 5V. Depending on the number of used modules and the brightness, the used current can be more than 500 mA. + + Connect the 5 outgoing pins (VCC, GND, DI, CS, CLK) of the first module to the next one. + With this you can connect up to 32 modules. + To extend the display hieght, multiple rows are supported. Each module row starts from left to right. + + Assign the pins as follows from Tasmota's GUI: DIN hardware pin --> "MAX7219 DIN" CS hardware pin --> "MAX7219 CS" CLK hardware pin --> "MAX7219 CLK" + Once the GPIO configuration is saved and the ESP8266/ESP32 module restarts, set the Display Model to 19 and Display Mode to 0 - using the command "Backlog DisplayModel 15 ; DisplayMode 0" - If your display is a TM1637 with 6 digits, set Display Width to the number of digits your - display has, using the command "DisplayWidth 6". + Depending on order oth the wired 8x8 matrix modules you have got a display of size pixel_width x pixel_height. + The size has to be set with the commands "DisplayWidth " and "DisplayHeight " After the ESP8266/ESP32 module restarts again, turn ON the display with the command "Power 1" + Now, the following "Display" commands can be used: + DisplayText text + Sends the text to the display. + If the text fits into the display, it is shown in the center. + Otherwise it scrolls to the left and repeats as long it is cleared or new "DisplayText" overwrites it. + + DisplayDimmer [0..100] + Sets the intensity of the display. + + Power [ON|OFF] + Sitches the display on or off. When "off", the display buffer is not cleared and will be shown again when after "Power ON". + Other display commands are still active when off. DisplayClear + Clears the display - Clears the display, command: "DisplayClear" + DisplayScrollDelay [0..15] // default = 0 + Sets the speed of text scroll. Smaller delay = faster scrolling. + The maximum scroll speed is 50ms per pixel on DisplayScrollDelay 0. + DisplayWidth [8..256] + Sets the pixel width of the display (8x number of modules in a row) - DisplayNumber num [,position {0-(Settings->display_width-1))} [,leading_zeros {0|1} [,length {1 to Settings->display_width}]]] + DisplayHeight [8..256] + Sets the pixel height of the display (8x number of module rows) - Clears and then displays number without decimal. command e.g., "DisplayNumber 1234" - Control 'leading zeros', 'length' and 'position' with "DisplayNumber 1234, , , " - 'leading zeros' can be 1 or 0 (default), 'length' can be 1 to Settings->display_width, 'position' can be 0 (left-most) to Settings->display_width (right-most). - See function description below for more details. - - DisplayNumberNC num [,position {0-(Settings->display_width-1))} [,leading_zeros {0|1} [,length {1 to Settings->display_width}]]] - - Display integer number as above, but without clearing first. e.g., "DisplayNumberNC 1234". Usage is same as above. - - - - DisplayFloat num [,position {0-(Settings->display_width-1)} [,precision {0-Settings->display_width} [,length {1 to Settings->display_width}]]] - - Clears and then displays float (with decimal point) command e.g., "DisplayFloat 12.34" - See function description below for more details. - - - - DisplayFloatNC num [,position {0-(Settings->display_width-1)} [,precision {0-Settings->display_width} [,length {1 to Settings->display_width}]]] - - Displays float (with decimal point) as above, but without clearing first. command e.g., "DisplayFloatNC 12.34" - See function description below for more details. - - - - DisplayRaw position {0-(Settings->display_width-1)},length {1 to Settings->display_width}, num1 [, num2[, num3[, num4[, ...upto Settings->display_width numbers]]]]] - - Takes upto Settings->display_width comma-separated integers (0-255) and displays raw segments. Each number represents a - 7-segment digit. Each 8-bit number represents individual segments of a digit. - For example, the command "DisplayRaw 0, 4, 255, 255, 255, 255" would display "[8.8.8.8.]" - - - - DisplayText text [, position {0-(Settings->display_width-1)} [,length {1 to Settings->display_width}]] - - Clears and then displays basic text. command e.g., "DisplayText ajith vasudevan" - Control 'length' and 'position' with "DisplayText , , " - 'length' can be 1 to Settings->display_width, 'position' can be 0 (left-most) to Settings->display_width-1 (right-most) - A caret(^) symbol in the text input is dispayed as the degrees(°) symbol. This is useful for displaying Temperature! - For example, the command "DisplayText 22.5^" will display "22.5°". - - - DisplayTextNC text [, position {0-Settings->display_width-1} [,length {1 to Settings->display_width}]] - - Clears first, then displays text. Usage is same as above. - - - - DisplayScrollText text [, num_loops] - - Displays scrolling text indefinitely, until another Display- command (other than DisplayScrollText - or DisplayScrollDelay is issued). Optionally, stop scrolling after num_loops iterations. - - - - DisplayScrollDelay delay {0-15} // default = 4 - - Sets the speed of text scroll. Smaller delay = faster scrolling. - - - - DisplayLevel num {0-100} - - Display a horizontal bar graph (0-100) command e.g., "DisplayLevel 50" will display [|||| ] - - - - DisplayClock 1|2|0 - - Displays a clock. - Commands "DisplayClock 1" // 12 hr format - "DisplayClock 2" // 24 hr format - "DisplayClock 0" // turn off clock - - -In addition, setting DisplayMode to 1 shows the time, setting it to 2 shows the date -and setting it to 3 alternates between time and date. + DisplayClock [0|1|2] + Displays a clock. + Commands "DisplayClock 1" // 12 hr format + "DisplayClock 2" // 24 hr format + "DisplayClock 0" // turn off clock @@ -132,20 +84,26 @@ and setting it to 3 alternates between time and date. #define XDSP_19 19 -#include #include +#ifdef USE_DISPLAY_MODES1TO5 +#include +#endif + LedMatrix *max7219_Matrix = nullptr; bool max2791Matrix_initDriver_done = false; struct { byte modulesPerRow = 4; byte modulesPerCol = 1; + byte scroll_delay = 0; + byte scroll_iteration = 0; bool show_clock = false; - const char* timeFormat; + const char *timeFormat; } LedMatrix_settings; +// FUNC_DISPLAY_INIT_DRIVER bool MAX7291Matrix_initDriver(void) { if (!PinUsed(GPIO_MAX7219DIN) || !PinUsed(GPIO_MAX7219CLK) || !PinUsed(GPIO_MAX7219CS)) @@ -174,6 +132,7 @@ bool MAX7291Matrix_initDriver(void) return MAX7291Matrix_init(); } +// FUNC_DISPLAY_INIT bool MAX7291Matrix_init(void) { int intensity = GetDisplayDimmer16(); // 0..15 @@ -187,6 +146,39 @@ bool MAX7291Matrix_init(void) return true; } +// FUNC_DISPLAY_SCROLLDELAY +bool MAX7291Matrix_scrollDelay(void) +{ + if (ArgC() == 0) + { + XdrvMailbox.payload = LedMatrix_settings.scroll_delay; + return true; + } + if (LedMatrix_settings.scroll_delay < 0) + LedMatrix_settings.scroll_delay = 0; + LedMatrix_settings.scroll_delay = XdrvMailbox.payload; + return true; +} + +// FUNC_DISPLAY_EVERY_50_MSECOND +bool MAX7291Matrix_scrollText(void) +{ + // This function is called every 50 ms. + // scroll_delay defines the number of cycles to be ignored until the display scrolls by one pixel to the left. + // e.g. scrall_delay = 4 causes a scroll each 200 ms. + LedMatrix_settings.scroll_iteration++; + if (LedMatrix_settings.scroll_delay) + LedMatrix_settings.scroll_iteration = LedMatrix_settings.scroll_iteration % LedMatrix_settings.scroll_delay; + else + LedMatrix_settings.scroll_iteration = 0; + if (LedMatrix_settings.scroll_iteration) + return false; + + return max7219_Matrix->scrollText(); +} + +#ifdef USE_DISPLAY_MODES1TO5 +// FUNC_DISPLAY_CLOCK bool MAX7291Matrix_clock(void) { LedMatrix_settings.show_clock = XdrvMailbox.payload; @@ -213,11 +205,11 @@ bool MAX7291Matrix_clock(void) AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: LedMatrix_settings.show_clock %d, timeFormat %s"), LedMatrix_settings.show_clock, LedMatrix_settings.timeFormat); - //max7219_Matrix->clearDisplay(); MAX7291Matrix_showTime(); return true; } +// FUNC_DISPLAY_EVERY_SECOND bool MAX7291Matrix_showTime() { time_t rawtime; @@ -227,11 +219,12 @@ bool MAX7291Matrix_showTime() time(&rawtime); timeinfo = localtime(&rawtime); strftime(timeStr, 10, LedMatrix_settings.timeFormat, timeinfo); - //AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: showTime:%s"), timeStr); max7219_Matrix->drawText(timeStr); return true; } +#endif // USE_DISPLAY_MODES1TO5 + bool Xdsp19(uint8_t function) { @@ -260,30 +253,28 @@ bool Xdsp19(uint8_t function) case FUNC_DISPLAY_DIM: result = max7219_Matrix->setIntensity(GetDisplayDimmer16()); break; - case FUNC_DISPLAY_CLOCK: - result = MAX7291Matrix_clock(); - break; - case FUNC_DISPLAY_SEVENSEG_TEXT: - case FUNC_DISPLAY_SEVENSEG_TEXTNC: - case FUNC_DISPLAY_NUMBER: - case FUNC_DISPLAY_NUMBERNC: - case FUNC_DISPLAY_FLOAT: - case FUNC_DISPLAY_FLOATNC: - case FUNC_DISPLAY_RAW: - case FUNC_DISPLAY_LEVEL: - case FUNC_DISPLAY_SCROLLTEXT: case FUNC_DISPLAY_DRAW_STRING: result = max7219_Matrix->drawText(dsp_str); break; + case FUNC_DISPLAY_SCROLLDELAY: + result = MAX7291Matrix_scrollDelay(); + break; + case FUNC_DISPLAY_EVERY_50_MSECOND: + result = MAX7291Matrix_scrollText(); + break; + +#ifdef USE_DISPLAY_MODES1TO5 + case FUNC_DISPLAY_CLOCK: + result = MAX7291Matrix_clock(); + break; case FUNC_DISPLAY_EVERY_SECOND: if (LedMatrix_settings.show_clock) { result = MAX7291Matrix_showTime(); } - break; - case FUNC_DISPLAY_EVERY_50_MSECOND: - result = max7219_Matrix->scrollText(); +#endif // USE_DISPLAY_MODES1TO5 + default: result = false; } From 5b3266e7ca90dfdbe750a6be746b14f6de24f884 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 29 Nov 2021 15:27:55 +0100 Subject: [PATCH 07/31] Support for more than 8 matrix devices --- lib/lib_display/LedControl/src/LedControl.cpp | 37 ++- lib/lib_display/LedControl/src/LedControl.h | 20 +- lib/lib_display/LedControl/src/LedMatrix.cpp | 24 +- lib/lib_display/LedControl/src/LedMatrix.h | 13 +- .../LedControl/src/font_5x8_horizontal_MSB.h | 267 ------------------ .../src/font_8x8_horizontal_latin_MSB.h | 265 ----------------- tasmota/xdsp_19_max7219_matrix.ino | 89 ++++-- 7 files changed, 129 insertions(+), 586 deletions(-) delete mode 100644 lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h delete mode 100644 lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h diff --git a/lib/lib_display/LedControl/src/LedControl.cpp b/lib/lib_display/LedControl/src/LedControl.cpp index e43211fd8..11e7a2908 100644 --- a/lib/lib_display/LedControl/src/LedControl.cpp +++ b/lib/lib_display/LedControl/src/LedControl.cpp @@ -47,16 +47,16 @@ LedControl::LedControl(int dataPin, int clkPin, int csPin, int numDevices) { SPI_MOSI=dataPin; SPI_CLK=clkPin; SPI_CS=csPin; - if(numDevices<=0 || numDevices>8 ) - numDevices=8; - maxDevices=numDevices; + if (numDevices <= 0 || numDevices > MAX72XX_MAX_DEVICES) + numDevices = MAX72XX_MAX_DEVICES; + maxDevices = numDevices; pinMode(SPI_MOSI,OUTPUT); pinMode(SPI_CLK,OUTPUT); pinMode(SPI_CS,OUTPUT); digitalWrite(SPI_CS,HIGH); SPI_MOSI=dataPin; - for(int i=0;i<64;i++) - status[i]=0x00; + for (int i = 0; i < 8 * MAX72XX_MAX_DEVICES; i++) + status[i] = 0x00; for(int i=0;i 7) + return; + for (int addr = 0; addr < maxDevices; addr++) + status[addr * 8 + row] = value[addr]; + spiTransferLong(row + 1, value); +} + void LedControl::setColumn(int addr, int col, byte value) { byte val; @@ -195,7 +204,7 @@ void LedControl::spiTransfer(int addr, volatile byte opcode, volatile byte data) int maxbytes=maxDevices*2; for(int i=0;i 0; i--) + shiftOut(SPI_MOSI, SPI_CLK, MSBFIRST, spidata[i - 1]); + //latch the data onto the display + digitalWrite(SPI_CS, HIGH); +} diff --git a/lib/lib_display/LedControl/src/LedControl.h b/lib/lib_display/LedControl/src/LedControl.h index f8180d07d..31fed9ffe 100644 --- a/lib/lib_display/LedControl/src/LedControl.h +++ b/lib/lib_display/LedControl/src/LedControl.h @@ -35,6 +35,10 @@ #include #endif +#ifndef MAX72XX_MAX_DEVICES +#define MAX72XX_MAX_DEVICES 32 // maximum number of devices based on MXA7219/MAX7221 +#endif + /* * Segments to be switched on for characters and digits on * 7-Segment Displays @@ -61,12 +65,14 @@ const static byte charTable [] PROGMEM = { class LedControl { private : /* The array for shifting the data to the devices */ - byte spidata[16]; - /* Send out a single command to the device */ + byte spidata[2 * MAX72XX_MAX_DEVICES]; + /* Send out a single command to one device */ void spiTransfer(int addr, byte opcode, byte data); + /* Send out a command with the same opcode to all devices */ + void spiTransferLong(byte opcode, const byte* data); /* We keep track of the led-status for all 8 devices in this array */ - byte status[64]; + byte status[8 * MAX72XX_MAX_DEVICES]; /* Data is shifted out of this pin*/ int SPI_MOSI; /* The clock is signaled on this pin */ @@ -149,6 +155,14 @@ class LedControl { */ void setRow(int addr, int row, byte value); + /** + * @brief Set data for the same row of all devices + * + * @param row [0..8] + * @param value array of bytes, one for each device + */ + void setRowLong(int row, byte* value); + /* * Set all 8 Led's in a column to a new state * Params: diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp index b4fb8c260..1579e0852 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.cpp +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -32,17 +32,17 @@ // public LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows) { - if (colums * rows > MATRIX_MAX_MODULES) + if (colums * rows > MAX72XX_MAX_DEVICES) { // dimension exeeds maximum buffer size - if (colums >= MATRIX_MAX_MODULES) + if (colums >= MAX72XX_MAX_DEVICES) { - colums = MATRIX_MAX_MODULES; + colums = MAX72XX_MAX_DEVICES; rows = 1; } else { - rows = MATRIX_MAX_MODULES / colums; + rows = MAX72XX_MAX_DEVICES / colums; } } @@ -66,7 +66,7 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un setIntensity(7); } -bool LedMatrix::drawText( const char *str) +bool LedMatrix::drawText( const char *str, bool clearBefore) { strncpy(textBuf, str, TEXT_BUFFER_SIZE -1); textPosX = 0; @@ -75,7 +75,7 @@ bool LedMatrix::drawText( const char *str) if(textWidth < displayWidth) { // text fits into the display, place it into the center - clear(); + if(clearBefore) clear(); textPosX = (displayWidth - textWidth) / 2; // center } else @@ -146,9 +146,13 @@ bool LedMatrix::setIntensity(byte dim) return true; } -bool LedMatrix::setOrientation(ModuleOrientation orientation) +bool LedMatrix::setOrientation(LedMatrix::ModuleOrientation orientation) { - moduleOrientation = orientation; + if(moduleOrientation != orientation) + { + moduleOrientation = orientation; + refresh(); + } return true; } @@ -268,9 +272,9 @@ void LedMatrix::refreshByteOfBuffer(int i) byte LedMatrix::revereBitorder (byte b) { - const static byte lookup[] PROGMEM = { + static const byte lookup[16] = { 0x0, 0x8, 0x4, 0xc, 0x2, 0xa, 0x6, 0xe, - 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf, + 0x1, 0x9, 0x5, 0xd, 0x3, 0xb, 0x7, 0xf }; return (lookup[b & 0b1111] << 4) | lookup[b >> 4]; } diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index efb50b8e3..b369173d0 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -29,8 +29,7 @@ #include -#define MATRIX_MAX_MODULES 32 // maximum number of modules that can be used -#define MATRIX_BUFFER_SIZE MATRIX_MAX_MODULES * 8 // 8 bytes per modul. One byte represents 8 LEDs. +#define MATRIX_BUFFER_SIZE MAX72XX_MAX_DEVICES * 8 // 8 bytes per modul. One byte represents 8 LEDs. #define TEXT_BUFFER_SIZE 256 // maximum text length that can be scrolled #define TEXT_APPEND_BUFFER_SIZE 16 // used for characters that are appended to the scroll text, before it repeats @@ -66,12 +65,14 @@ class LedMatrix * When the text is longer than than the display width, it can be scrolled per pixel with function scrollText(). * * @param str string to display + * @param clearBefore true (default) clears old display content before, false: do not clear display before */ - bool drawText( const char *str ); + bool drawText( const char *str, bool clearBefore = true ); /** * @brief Dwaws a character string to a defined display position. The position (x,y) is used for the upper left pixel of the text. - * Existing text before the x position will not be cleared. Use refresh() after all text parts are drawed. + * Existing content outside the drawing text area will not be cleared. But you can use clearDisplay() before. + * Use refresh() after all text parts are drawed. * * @param str string to display * @param x horizantal pixel position to start with string (0 is most left) @@ -112,7 +113,7 @@ class LedMatrix * * @param orientation */ - bool setOrientation(ModuleOrientation orientation); + bool setOrientation(LedMatrix::ModuleOrientation orientation); /** * @brief Set ap pixel at a defined position. @@ -151,7 +152,7 @@ class LedMatrix unsigned int displayWidth; // matrix width [pixel] unsigned int displayHeight; // matrix height [pixel] unsigned int modules; // number of 8x8 mudules - ModuleOrientation moduleOrientation; + uint8_t moduleOrientation; byte buffer[MATRIX_BUFFER_SIZE]; LedControl* ledControl; int charWidth; diff --git a/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h b/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h deleted file mode 100644 index da3becc4e..000000000 --- a/lib/lib_display/LedControl/src/font_5x8_horizontal_MSB.h +++ /dev/null @@ -1,267 +0,0 @@ -// 5x8 ascii font -#ifndef font_5x8_horizontal_MSB_h -#define font_5x8_horizontal_MSB_h - -const unsigned int font_char_width = 5; -const unsigned int font_char_height = 8; - -const char font[256][8]={ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 -{0x0E,0x11,0x1B,0x11,0x1F,0x0E,0x00,0x00}, // 0x01 -{0x0E,0x15,0x1F,0x11,0x1F,0x0E,0x00,0x00}, // 0x02 -{0x0A,0x1F,0x1F,0x1F,0x0E,0x04,0x00,0x00}, // 0x03 -{0x04,0x04,0x0E,0x1F,0x0E,0x04,0x04,0x00}, // 0x04 -{0x04,0x0E,0x04,0x1F,0x15,0x04,0x0E,0x00}, // 0x05 -{0x04,0x0E,0x1F,0x1F,0x15,0x04,0x0E,0x00}, // 0x06 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A -{0x03,0x03,0x0E,0x11,0x11,0x11,0x0E,0x00}, // 0x0B -{0x0E,0x11,0x11,0x11,0x0E,0x04,0x0E,0x04}, // 0x0C -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D -{0x03,0x0F,0x09,0x09,0x0B,0x1B,0x18,0x00}, // 0x0E -{0x00,0x15,0x0E,0x1B,0x0E,0x15,0x00,0x00}, // 0x0F -{0x00,0x10,0x1C,0x1F,0x1C,0x10,0x00,0x00}, // 0x10 -{0x00,0x01,0x07,0x1F,0x07,0x01,0x00,0x00}, // 0x11 -{0x04,0x0E,0x04,0x04,0x04,0x0E,0x04,0x00}, // 0x12 -{0x00,0x0A,0x0A,0x0A,0x00,0x0A,0x00,0x00}, // 0x13 -{0x0E,0x1A,0x1A,0x0A,0x0A,0x0A,0x0A,0x00}, // 0x14 -{0x06,0x08,0x04,0x0A,0x04,0x02,0x0C,0x00}, // 0x15 -{0x00,0x00,0x00,0x0F,0x0F,0x00,0x00,0x00}, // 0x16 -{0x04,0x0E,0x04,0x0E,0x04,0x00,0x0E,0x00}, // 0x17 -{0x04,0x0E,0x04,0x04,0x04,0x04,0x04,0x00}, // 0x18 -{0x04,0x04,0x04,0x04,0x04,0x0E,0x04,0x00}, // 0x19 -{0x00,0x00,0x02,0x0F,0x02,0x00,0x00,0x00}, // 0x1A -{0x00,0x00,0x04,0x0F,0x04,0x00,0x00,0x00}, // 0x1B -{0x00,0x00,0x08,0x08,0x08,0x0F,0x00,0x00}, // 0x1C -{0x00,0x00,0x0A,0x1F,0x0A,0x00,0x00,0x00}, // 0x1D -{0x00,0x04,0x04,0x0E,0x0E,0x1F,0x00,0x00}, // 0x1E -{0x00,0x1F,0x0E,0x0E,0x04,0x04,0x00,0x00}, // 0x1F -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20 -{0x04,0x04,0x04,0x04,0x00,0x04,0x00,0x00}, // 0x21 -{0x0A,0x0A,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x22 -{0x00,0x05,0x1F,0x0A,0x1F,0x14,0x00,0x00}, // 0x23 -{0x04,0x0E,0x0C,0x04,0x06,0x0E,0x04,0x00}, // 0x24 -{0x09,0x15,0x0E,0x0E,0x15,0x12,0x00,0x00}, // 0x25 -{0x04,0x0A,0x0C,0x15,0x12,0x0D,0x00,0x00}, // 0x26 -{0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x27 -{0x03,0x04,0x08,0x08,0x08,0x04,0x03,0x00}, // 0x28 -{0x18,0x04,0x02,0x02,0x02,0x04,0x18,0x00}, // 0x29 -{0x04,0x0A,0x04,0x0A,0x00,0x00,0x00,0x00}, // 0x2A -{0x00,0x00,0x00,0x04,0x0E,0x04,0x00,0x00}, // 0x2B -{0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x08}, // 0x2C -{0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0x2D -{0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00}, // 0x2E -{0x01,0x02,0x02,0x04,0x04,0x08,0x08,0x00}, // 0x2F -{0x06,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0x30 -{0x04,0x0C,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0x31 -{0x0C,0x02,0x02,0x04,0x08,0x0E,0x00,0x00}, // 0x32 -{0x0C,0x02,0x0C,0x02,0x02,0x0C,0x00,0x00}, // 0x33 -{0x02,0x06,0x0A,0x0F,0x02,0x02,0x00,0x00}, // 0x34 -{0x0E,0x08,0x0C,0x02,0x02,0x0C,0x00,0x00}, // 0x35 -{0x06,0x08,0x0E,0x09,0x09,0x06,0x00,0x00}, // 0x36 -{0x0F,0x01,0x02,0x04,0x04,0x04,0x00,0x00}, // 0x37 -{0x06,0x09,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x38 -{0x06,0x09,0x09,0x07,0x01,0x06,0x00,0x00}, // 0x39 -{0x00,0x00,0x04,0x00,0x00,0x04,0x00,0x00}, // 0x3A -{0x00,0x00,0x04,0x00,0x00,0x04,0x04,0x08}, // 0x3B -{0x00,0x01,0x02,0x0C,0x02,0x01,0x00,0x00}, // 0x3C -{0x00,0x00,0x0F,0x00,0x0F,0x00,0x00,0x00}, // 0x3D -{0x00,0x08,0x04,0x03,0x04,0x08,0x00,0x00}, // 0x3E -{0x0E,0x01,0x02,0x04,0x00,0x04,0x00,0x00}, // 0x3F -{0x06,0x09,0x13,0x15,0x17,0x10,0x0F,0x00}, // 0x40 -{0x00,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0x41 -{0x00,0x0E,0x0A,0x0C,0x0A,0x0E,0x00,0x00}, // 0x42 -{0x00,0x07,0x08,0x08,0x08,0x07,0x00,0x00}, // 0x43 -{0x00,0x0E,0x09,0x09,0x09,0x0E,0x00,0x00}, // 0x44 -{0x00,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0x45 -{0x00,0x0E,0x08,0x0E,0x08,0x08,0x00,0x00}, // 0x46 -{0x00,0x07,0x08,0x0B,0x09,0x07,0x00,0x00}, // 0x47 -{0x00,0x09,0x09,0x0F,0x09,0x09,0x00,0x00}, // 0x48 -{0x00,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0x49 -{0x00,0x0E,0x02,0x02,0x02,0x0C,0x00,0x00}, // 0x4A -{0x00,0x09,0x0A,0x0C,0x0A,0x09,0x00,0x00}, // 0x4B -{0x00,0x08,0x08,0x08,0x08,0x0F,0x00,0x00}, // 0x4C -{0x00,0x11,0x1B,0x15,0x15,0x11,0x00,0x00}, // 0x4D -{0x00,0x09,0x0D,0x0B,0x09,0x09,0x00,0x00}, // 0x4E -{0x00,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0x4F -{0x00,0x0E,0x09,0x0E,0x08,0x08,0x00,0x00}, // 0x50 -{0x00,0x0E,0x11,0x11,0x11,0x0E,0x02,0x01}, // 0x51 -{0x00,0x0C,0x0A,0x0C,0x0A,0x09,0x00,0x00}, // 0x52 -{0x00,0x06,0x08,0x04,0x02,0x0C,0x00,0x00}, // 0x53 -{0x00,0x1F,0x04,0x04,0x04,0x04,0x00,0x00}, // 0x54 -{0x00,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0x55 -{0x00,0x09,0x09,0x09,0x06,0x06,0x00,0x00}, // 0x56 -{0x00,0x11,0x15,0x15,0x0A,0x0A,0x00,0x00}, // 0x57 -{0x00,0x11,0x0A,0x04,0x0A,0x11,0x00,0x00}, // 0x58 -{0x00,0x11,0x0A,0x04,0x04,0x04,0x00,0x00}, // 0x59 -{0x00,0x0F,0x01,0x06,0x08,0x0F,0x00,0x00}, // 0x5A -{0x06,0x04,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x5B -{0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00}, // 0x5C -{0x0C,0x04,0x04,0x04,0x04,0x04,0x0C,0x00}, // 0x5D -{0x04,0x0A,0x0A,0x11,0x11,0x00,0x00,0x00}, // 0x5E -{0x00,0x00,0x00,0x00,0x00,0x00,0x1F,0x00}, // 0x5F -{0x08,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x60 -{0x00,0x00,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x61 -{0x08,0x08,0x0E,0x09,0x09,0x0E,0x00,0x00}, // 0x62 -{0x00,0x00,0x06,0x08,0x08,0x06,0x00,0x00}, // 0x63 -{0x02,0x02,0x0E,0x12,0x12,0x0E,0x00,0x00}, // 0x64 -{0x00,0x00,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x65 -{0x03,0x04,0x0F,0x04,0x04,0x04,0x00,0x00}, // 0x66 -{0x00,0x00,0x07,0x09,0x0F,0x01,0x0E,0x00}, // 0x67 -{0x08,0x08,0x0A,0x0D,0x09,0x09,0x00,0x00}, // 0x68 -{0x04,0x00,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x69 -{0x02,0x00,0x0E,0x02,0x02,0x02,0x0C,0x00}, // 0x6A -{0x08,0x08,0x0A,0x0C,0x0A,0x09,0x00,0x00}, // 0x6B -{0x0C,0x04,0x04,0x04,0x04,0x04,0x00,0x00}, // 0x6C -{0x00,0x00,0x15,0x1F,0x15,0x15,0x00,0x00}, // 0x6D -{0x00,0x00,0x0A,0x0D,0x09,0x09,0x00,0x00}, // 0x6E -{0x00,0x00,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x6F -{0x00,0x00,0x0E,0x09,0x09,0x0E,0x08,0x00}, // 0x70 -{0x00,0x00,0x0E,0x12,0x12,0x0E,0x02,0x00}, // 0x71 -{0x00,0x00,0x0A,0x0C,0x08,0x08,0x00,0x00}, // 0x72 -{0x00,0x00,0x06,0x0C,0x02,0x0C,0x00,0x00}, // 0x73 -{0x00,0x04,0x0F,0x04,0x04,0x02,0x00,0x00}, // 0x74 -{0x00,0x00,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x75 -{0x00,0x00,0x09,0x09,0x06,0x06,0x00,0x00}, // 0x76 -{0x00,0x00,0x15,0x15,0x0E,0x0A,0x00,0x00}, // 0x77 -{0x00,0x00,0x09,0x06,0x06,0x09,0x00,0x00}, // 0x78 -{0x00,0x00,0x09,0x09,0x06,0x06,0x1C,0x00}, // 0x79 -{0x00,0x00,0x0E,0x06,0x08,0x0E,0x00,0x00}, // 0x7A -{0x02,0x04,0x04,0x08,0x04,0x04,0x02,0x00}, // 0x7B -{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x00}, // 0x7C -{0x08,0x04,0x04,0x02,0x04,0x04,0x08,0x00}, // 0x7D -{0x00,0x00,0x00,0x0D,0x12,0x00,0x00,0x00}, // 0x7E -{0x00,0x04,0x0A,0x0A,0x0A,0x0E,0x00,0x00}, // 0x7F -{0x00,0x07,0x08,0x08,0x08,0x07,0x02,0x04}, // 0x80 -{0x09,0x00,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x81 -{0x01,0x02,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x82 -{0x06,0x09,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x83 -{0x0A,0x00,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x84 -{0x10,0x08,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x85 -{0x04,0x0A,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0x86 -{0x00,0x00,0x06,0x08,0x08,0x06,0x02,0x04}, // 0x87 -{0x06,0x09,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x88 -{0x0A,0x00,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x89 -{0x10,0x08,0x04,0x0E,0x08,0x06,0x00,0x00}, // 0x8A -{0x0A,0x00,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x8B -{0x06,0x09,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x8C -{0x10,0x08,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0x8D -{0x0A,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0x8E -{0x04,0x0A,0x04,0x0A,0x1F,0x11,0x00,0x00}, // 0x8F -{0x01,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0x90 -{0x00,0x00,0x1A,0x07,0x1C,0x13,0x00,0x00}, // 0x91 -{0x00,0x07,0x0A,0x0B,0x1E,0x13,0x00,0x00}, // 0x92 -{0x0C,0x12,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x93 -{0x09,0x00,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x94 -{0x10,0x08,0x06,0x09,0x09,0x06,0x00,0x00}, // 0x95 -{0x0C,0x12,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x96 -{0x08,0x04,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0x97 -{0x09,0x00,0x09,0x09,0x06,0x06,0x1C,0x00}, // 0x98 -{0x11,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0x99 -{0x12,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0x9A -{0x00,0x01,0x06,0x0B,0x0D,0x06,0x08,0x00}, // 0x9B -{0x00,0x04,0x08,0x0C,0x18,0x0E,0x00,0x00}, // 0x9C -{0x01,0x0E,0x13,0x15,0x19,0x0E,0x10,0x00}, // 0x9D -{0x00,0x00,0x09,0x06,0x06,0x09,0x00,0x00}, // 0x9E -{0x02,0x04,0x04,0x0E,0x04,0x04,0x08,0x00}, // 0x9F -{0x01,0x02,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0xA0 -{0x01,0x02,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0xA1 -{0x01,0x02,0x06,0x09,0x09,0x06,0x00,0x00}, // 0xA2 -{0x01,0x02,0x09,0x09,0x0B,0x05,0x00,0x00}, // 0xA3 -{0x0F,0x00,0x0A,0x0D,0x09,0x09,0x00,0x00}, // 0xA4 -{0x1F,0x09,0x0D,0x0B,0x09,0x09,0x00,0x00}, // 0xA5 -{0x0C,0x02,0x0E,0x0A,0x0E,0x00,0x00,0x00}, // 0xA6 -{0x04,0x0A,0x0A,0x0A,0x04,0x00,0x00,0x00}, // 0xA7 -{0x00,0x04,0x00,0x04,0x04,0x02,0x0C,0x00}, // 0xA8 -{0x0E,0x17,0x17,0x15,0x17,0x0E,0x00,0x00}, // 0xA9 -{0x00,0x00,0x00,0x0E,0x02,0x02,0x00,0x00}, // 0xAA -{0x19,0x0A,0x0F,0x05,0x0A,0x13,0x00,0x00}, // 0xAB -{0x19,0x0A,0x0A,0x05,0x0B,0x11,0x00,0x00}, // 0xAC -{0x00,0x00,0x04,0x00,0x04,0x04,0x04,0x00}, // 0xAD -{0x00,0x05,0x0A,0x14,0x0A,0x05,0x00,0x00}, // 0xAE -{0x00,0x14,0x0A,0x05,0x0A,0x14,0x00,0x00}, // 0xAF -{0x15,0x00,0x15,0x00,0x15,0x00,0x15,0x00}, // 0xB0 -{0x15,0x0A,0x15,0x0A,0x15,0x0A,0x15,0x0A}, // 0xB1 -{0x1F,0x15,0x1F,0x15,0x1F,0x15,0x1F,0x15}, // 0xB2 -{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04}, // 0xB3 -{0x04,0x04,0x04,0x1C,0x04,0x04,0x04,0x04}, // 0xB4 -{0x02,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0xB5 -{0x06,0x09,0x04,0x0A,0x1F,0x11,0x00,0x00}, // 0xB6 -{0x08,0x04,0x0A,0x0A,0x1F,0x11,0x00,0x00}, // 0xB7 -{0x0E,0x11,0x17,0x15,0x17,0x11,0x0E,0x00}, // 0xB8 -{0x0A,0x0A,0x1A,0x02,0x1A,0x0A,0x0A,0x0A}, // 0xB9 -{0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A,0x0A}, // 0xBA -{0x00,0x00,0x1E,0x02,0x1A,0x0A,0x0A,0x0A}, // 0xBB -{0x0A,0x0A,0x1A,0x02,0x1E,0x00,0x00,0x00}, // 0xBC -{0x00,0x04,0x0E,0x08,0x0E,0x04,0x00,0x00}, // 0xBD -{0x00,0x11,0x0A,0x04,0x0E,0x04,0x00,0x00}, // 0xBE -{0x00,0x00,0x00,0x1C,0x04,0x04,0x04,0x04}, // 0xBF -{0x04,0x04,0x04,0x07,0x00,0x00,0x00,0x00}, // 0xC0 -{0x04,0x04,0x04,0x1F,0x00,0x00,0x00,0x00}, // 0xC1 -{0x00,0x00,0x00,0x1F,0x04,0x04,0x04,0x04}, // 0xC2 -{0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04}, // 0xC3 -{0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00}, // 0xC4 -{0x04,0x04,0x04,0x1F,0x04,0x04,0x04,0x04}, // 0xC5 -{0x0D,0x12,0x0C,0x02,0x0E,0x0F,0x00,0x00}, // 0xC6 -{0x0D,0x12,0x04,0x0A,0x1F,0x11,0x00,0x00}, // 0xC7 -{0x0A,0x0A,0x0B,0x08,0x0F,0x00,0x00,0x00}, // 0xC8 -{0x00,0x00,0x0F,0x08,0x0B,0x0A,0x0A,0x0A}, // 0xC9 -{0x0A,0x0A,0x1B,0x00,0x1F,0x00,0x00,0x00}, // 0xCA -{0x00,0x00,0x1F,0x00,0x1B,0x0A,0x0A,0x0A}, // 0xCB -{0x0A,0x0A,0x0B,0x08,0x0B,0x0A,0x0A,0x0A}, // 0xCC -{0x00,0x00,0x1F,0x00,0x1F,0x00,0x00,0x00}, // 0xCD -{0x0A,0x0A,0x1B,0x00,0x1B,0x0A,0x0A,0x0A}, // 0xCE -{0x00,0x11,0x0E,0x0A,0x0E,0x11,0x00,0x00}, // 0xCF -{0x1E,0x04,0x0E,0x12,0x12,0x0C,0x00,0x00}, // 0xD0 -{0x00,0x0E,0x09,0x1D,0x09,0x0E,0x00,0x00}, // 0xD1 -{0x0E,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0xD2 -{0x11,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0xD3 -{0x10,0x0E,0x08,0x0E,0x08,0x0E,0x00,0x00}, // 0xD4 -{0x00,0x00,0x0C,0x04,0x04,0x04,0x00,0x00}, // 0xD5 -{0x01,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xD6 -{0x0E,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xD7 -{0x11,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xD8 -{0x04,0x04,0x04,0x1C,0x00,0x00,0x00,0x00}, // 0xD9 -{0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x04}, // 0xDA -{0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F}, // 0xDB -{0x00,0x00,0x00,0x00,0x1F,0x1F,0x1F,0x1F}, // 0xDC -{0x04,0x04,0x04,0x00,0x00,0x04,0x04,0x04}, // 0xDD -{0x10,0x0E,0x04,0x04,0x04,0x0E,0x00,0x00}, // 0xDE -{0x1F,0x1F,0x1F,0x1F,0x00,0x00,0x00,0x00}, // 0xDF -{0x01,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE0 -{0x04,0x0A,0x0A,0x0A,0x09,0x0A,0x00,0x00}, // 0xE1 -{0x0E,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE2 -{0x10,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE3 -{0x0D,0x12,0x06,0x09,0x09,0x06,0x00,0x00}, // 0xE4 -{0x1E,0x0E,0x11,0x11,0x11,0x0E,0x00,0x00}, // 0xE5 -{0x00,0x00,0x09,0x09,0x0B,0x0D,0x08,0x00}, // 0xE6 -{0x08,0x08,0x0E,0x09,0x09,0x0E,0x08,0x00}, // 0xE7 -{0x00,0x08,0x0E,0x09,0x0E,0x08,0x00,0x00}, // 0xE8 -{0x01,0x12,0x12,0x12,0x12,0x0C,0x00,0x00}, // 0xE9 -{0x0F,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0xEA -{0x10,0x09,0x09,0x09,0x09,0x06,0x00,0x00}, // 0xEB -{0x01,0x02,0x09,0x09,0x06,0x06,0x18,0x00}, // 0xEC -{0x02,0x15,0x0A,0x04,0x04,0x04,0x00,0x00}, // 0xED -{0x1F,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEE -{0x02,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEF -{0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0xF0 -{0x00,0x00,0x04,0x0E,0x04,0x0E,0x00,0x00}, // 0xF1 -{0x00,0x00,0x00,0x00,0x00,0x1F,0x00,0x1F}, // 0xF2 -{0x19,0x1A,0x0A,0x1D,0x0B,0x11,0x00,0x00}, // 0xF3 -{0x0E,0x1A,0x1A,0x0A,0x0A,0x0A,0x0A,0x00}, // 0xF4 -{0x06,0x08,0x04,0x0A,0x04,0x02,0x0C,0x00}, // 0xF5 -{0x00,0x04,0x00,0x0E,0x00,0x04,0x00,0x00}, // 0xF6 -{0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x08}, // 0xF7 -{0x06,0x09,0x09,0x06,0x00,0x00,0x00,0x00}, // 0xF8 -{0x0A,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xF9 -{0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00}, // 0xFA -{0x0C,0x04,0x04,0x04,0x0E,0x00,0x00,0x00}, // 0xFB -{0x0C,0x02,0x0C,0x02,0x0C,0x00,0x00,0x00}, // 0xFC -{0x0C,0x02,0x04,0x08,0x0E,0x00,0x00,0x00}, // 0xFD -{0x00,0x00,0x0F,0x0F,0x0F,0x0F,0x00,0x00}, // 0xFE -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF -}; - -#endif // font_5x8_horizontal_MSB_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h b/lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h deleted file mode 100644 index e1a8af7ae..000000000 --- a/lib/lib_display/LedControl/src/font_8x8_horizontal_latin_MSB.h +++ /dev/null @@ -1,265 +0,0 @@ -#ifndef font_8x8_horizontal_latin_MSB_h -#define font_8x8_horizontal_latin_MSB_h - -const unsigned int font_char_width = 8; -const unsigned int font_char_height = 8; - -const char font[256][8]={ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 -{0x0E,0x11,0x1B,0x11,0x15,0x11,0x0E,0x00}, // 0x01 -{0x0E,0x1F,0x15,0x1F,0x11,0x1F,0x0E,0x00}, // 0x02 -{0x00,0x0A,0x1F,0x1F,0x1F,0x0E,0x04,0x00}, // 0x03 -{0x00,0x04,0x0E,0x1F,0x1F,0x0E,0x04,0x00}, // 0x04 -{0x04,0x0E,0x0E,0x04,0x1F,0x1F,0x04,0x00}, // 0x05 -{0x00,0x04,0x0E,0x1F,0x1F,0x04,0x0E,0x00}, // 0x06 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A -{0x00,0x07,0x03,0x0D,0x12,0x12,0x0C,0x00}, // 0x0B -{0x0E,0x11,0x11,0x0E,0x04,0x0E,0x04,0x00}, // 0x0C -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D -{0x03,0x0D,0x0B,0x0D,0x0B,0x1B,0x18,0x00}, // 0x0E -{0x00,0x15,0x0E,0x1B,0x0E,0x15,0x00,0x00}, // 0x0F -{0x08,0x0C,0x0E,0x0F,0x0E,0x0C,0x08,0x00}, // 0x10 -{0x02,0x06,0x0E,0x1E,0x0E,0x06,0x02,0x00}, // 0x11 -{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x00}, // 0x12 -{0x0A,0x0A,0x0A,0x0A,0x0A,0x00,0x0A,0x00}, // 0x13 -{0x0F,0x15,0x15,0x0D,0x05,0x05,0x05,0x00}, // 0x14 -{0x0E,0x11,0x0C,0x0A,0x06,0x11,0x0E,0x00}, // 0x15 -{0x00,0x00,0x00,0x00,0x00,0x1E,0x1E,0x00}, // 0x16 -{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x0E}, // 0x17 -{0x04,0x0E,0x1F,0x04,0x04,0x04,0x04,0x00}, // 0x18 -{0x04,0x04,0x04,0x04,0x1F,0x0E,0x04,0x00}, // 0x19 -{0x00,0x04,0x06,0x1F,0x06,0x04,0x00,0x00}, // 0x1A -{0x00,0x04,0x0C,0x1F,0x0C,0x04,0x00,0x00}, // 0x1B -{0x00,0x00,0x00,0x10,0x10,0x10,0x1F,0x00}, // 0x1C -{0x00,0x0A,0x0A,0x1F,0x0A,0x0A,0x00,0x00}, // 0x1D -{0x04,0x04,0x0E,0x0E,0x1F,0x1F,0x00,0x00}, // 0x1E -{0x1F,0x1F,0x0E,0x0E,0x04,0x04,0x00,0x00}, // 0x1F - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0020 (space) - { 0x18, 0x3C, 0x3C, 0x18, 0x18, 0x00, 0x18, 0x00}, // U+0021 (!) - { 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0022 (") - { 0x36, 0x36, 0x7F, 0x36, 0x7F, 0x36, 0x36, 0x00}, // U+0023 (#) - { 0x0C, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x0C, 0x00}, // U+0024 ($) - { 0x00, 0x63, 0x33, 0x18, 0x0C, 0x66, 0x63, 0x00}, // U+0025 (%) - { 0x1C, 0x36, 0x1C, 0x6E, 0x3B, 0x33, 0x6E, 0x00}, // U+0026 (&) - { 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0027 (') - { 0x18, 0x0C, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x00}, // U+0028 (() - { 0x06, 0x0C, 0x18, 0x18, 0x18, 0x0C, 0x06, 0x00}, // U+0029 ()) - { 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66, 0x00, 0x00}, // U+002A (*) - { 0x00, 0x0C, 0x0C, 0x3F, 0x0C, 0x0C, 0x00, 0x00}, // U+002B (+) - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+002C (,) - { 0x00, 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00}, // U+002D (-) - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+002E (.) - { 0x60, 0x30, 0x18, 0x0C, 0x06, 0x03, 0x01, 0x00}, // U+002F (/) - { 0x3E, 0x63, 0x73, 0x7B, 0x6F, 0x67, 0x3E, 0x00}, // U+0030 (0) - { 0x0C, 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x3F, 0x00}, // U+0031 (1) - { 0x1E, 0x33, 0x30, 0x1C, 0x06, 0x33, 0x3F, 0x00}, // U+0032 (2) - { 0x1E, 0x33, 0x30, 0x1C, 0x30, 0x33, 0x1E, 0x00}, // U+0033 (3) - { 0x38, 0x3C, 0x36, 0x33, 0x7F, 0x30, 0x78, 0x00}, // U+0034 (4) - { 0x3F, 0x03, 0x1F, 0x30, 0x30, 0x33, 0x1E, 0x00}, // U+0035 (5) - { 0x1C, 0x06, 0x03, 0x1F, 0x33, 0x33, 0x1E, 0x00}, // U+0036 (6) - { 0x3F, 0x33, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x00}, // U+0037 (7) - { 0x1E, 0x33, 0x33, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+0038 (8) - { 0x1E, 0x33, 0x33, 0x3E, 0x30, 0x18, 0x0E, 0x00}, // U+0039 (9) - { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x00}, // U+003A (:) - { 0x00, 0x0C, 0x0C, 0x00, 0x00, 0x0C, 0x0C, 0x06}, // U+003B (;) - { 0x18, 0x0C, 0x06, 0x03, 0x06, 0x0C, 0x18, 0x00}, // U+003C (<) - { 0x00, 0x00, 0x3F, 0x00, 0x00, 0x3F, 0x00, 0x00}, // U+003D (=) - { 0x06, 0x0C, 0x18, 0x30, 0x18, 0x0C, 0x06, 0x00}, // U+003E (>) - { 0x1E, 0x33, 0x30, 0x18, 0x0C, 0x00, 0x0C, 0x00}, // U+003F (?) - { 0x3E, 0x63, 0x7B, 0x7B, 0x7B, 0x03, 0x1E, 0x00}, // U+0040 (@) - { 0x0C, 0x1E, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x00}, // U+0041 (A) - { 0x3F, 0x66, 0x66, 0x3E, 0x66, 0x66, 0x3F, 0x00}, // U+0042 (B) - { 0x3C, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3C, 0x00}, // U+0043 (C) - { 0x1F, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1F, 0x00}, // U+0044 (D) - { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x46, 0x7F, 0x00}, // U+0045 (E) - { 0x7F, 0x46, 0x16, 0x1E, 0x16, 0x06, 0x0F, 0x00}, // U+0046 (F) - { 0x3C, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7C, 0x00}, // U+0047 (G) - { 0x33, 0x33, 0x33, 0x3F, 0x33, 0x33, 0x33, 0x00}, // U+0048 (H) - { 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0049 (I) - { 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E, 0x00}, // U+004A (J) - { 0x67, 0x66, 0x36, 0x1E, 0x36, 0x66, 0x67, 0x00}, // U+004B (K) - { 0x0F, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7F, 0x00}, // U+004C (L) - { 0x63, 0x77, 0x7F, 0x7F, 0x6B, 0x63, 0x63, 0x00}, // U+004D (M) - { 0x63, 0x67, 0x6F, 0x7B, 0x73, 0x63, 0x63, 0x00}, // U+004E (N) - { 0x1C, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1C, 0x00}, // U+004F (O) - { 0x3F, 0x66, 0x66, 0x3E, 0x06, 0x06, 0x0F, 0x00}, // U+0050 (P) - { 0x1E, 0x33, 0x33, 0x33, 0x3B, 0x1E, 0x38, 0x00}, // U+0051 (Q) - { 0x3F, 0x66, 0x66, 0x3E, 0x36, 0x66, 0x67, 0x00}, // U+0052 (R) - { 0x1E, 0x33, 0x07, 0x0E, 0x38, 0x33, 0x1E, 0x00}, // U+0053 (S) - { 0x3F, 0x2D, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0054 (T) - { 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3F, 0x00}, // U+0055 (U) - { 0x33, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0056 (V) - { 0x63, 0x63, 0x63, 0x6B, 0x7F, 0x77, 0x63, 0x00}, // U+0057 (W) - { 0x63, 0x63, 0x36, 0x1C, 0x1C, 0x36, 0x63, 0x00}, // U+0058 (X) - { 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+0059 (Y) - { 0x7F, 0x63, 0x31, 0x18, 0x4C, 0x66, 0x7F, 0x00}, // U+005A (Z) - { 0x1E, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1E, 0x00}, // U+005B ([) - { 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x40, 0x00}, // U+005C (\) - { 0x1E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1E, 0x00}, // U+005D (]) - { 0x08, 0x1C, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00}, // U+005E (^) - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF}, // U+005F (_) - { 0x0C, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+0060 (`) - { 0x00, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x6E, 0x00}, // U+0061 (a) - { 0x07, 0x06, 0x06, 0x3E, 0x66, 0x66, 0x3B, 0x00}, // U+0062 (b) - { 0x00, 0x00, 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x00}, // U+0063 (c) - { 0x38, 0x30, 0x30, 0x3e, 0x33, 0x33, 0x6E, 0x00}, // U+0064 (d) - { 0x00, 0x00, 0x1E, 0x33, 0x3f, 0x03, 0x1E, 0x00}, // U+0065 (e) - { 0x1C, 0x36, 0x06, 0x0f, 0x06, 0x06, 0x0F, 0x00}, // U+0066 (f) - { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0067 (g) - { 0x07, 0x06, 0x36, 0x6E, 0x66, 0x66, 0x67, 0x00}, // U+0068 (h) - { 0x0C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+0069 (i) - { 0x30, 0x00, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1E}, // U+006A (j) - { 0x07, 0x06, 0x66, 0x36, 0x1E, 0x36, 0x67, 0x00}, // U+006B (k) - { 0x0E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+006C (l) - { 0x00, 0x00, 0x33, 0x7F, 0x7F, 0x6B, 0x63, 0x00}, // U+006D (m) - { 0x00, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x33, 0x00}, // U+006E (n) - { 0x00, 0x00, 0x1E, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+006F (o) - { 0x00, 0x00, 0x3B, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+0070 (p) - { 0x00, 0x00, 0x6E, 0x33, 0x33, 0x3E, 0x30, 0x78}, // U+0071 (q) - { 0x00, 0x00, 0x3B, 0x6E, 0x66, 0x06, 0x0F, 0x00}, // U+0072 (r) - { 0x00, 0x00, 0x3E, 0x03, 0x1E, 0x30, 0x1F, 0x00}, // U+0073 (s) - { 0x08, 0x0C, 0x3E, 0x0C, 0x0C, 0x2C, 0x18, 0x00}, // U+0074 (t) - { 0x00, 0x00, 0x33, 0x33, 0x33, 0x33, 0x6E, 0x00}, // U+0075 (u) - { 0x00, 0x00, 0x33, 0x33, 0x33, 0x1E, 0x0C, 0x00}, // U+0076 (v) - { 0x00, 0x00, 0x63, 0x6B, 0x7F, 0x7F, 0x36, 0x00}, // U+0077 (w) - { 0x00, 0x00, 0x63, 0x36, 0x1C, 0x36, 0x63, 0x00}, // U+0078 (x) - { 0x00, 0x00, 0x33, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+0079 (y) - { 0x00, 0x00, 0x3F, 0x19, 0x0C, 0x26, 0x3F, 0x00}, // U+007A (z) - { 0x38, 0x0C, 0x0C, 0x07, 0x0C, 0x0C, 0x38, 0x00}, // U+007B ({) - { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+007C (|) - { 0x07, 0x0C, 0x0C, 0x38, 0x0C, 0x0C, 0x07, 0x00}, // U+007D (}) - { 0x6E, 0x3B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007E (~) - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+007F{0x0E,0x11,0x10,0x10,0x11,0x0E,0x04,0x0C}, // 0x80 -{0x12,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x81 -{0x03,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x82 -{0x0E,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x83 -{0x0A,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x84 -{0x0C,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x85 -{0x0E,0x0A,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x86 -{0x00,0x0E,0x11,0x10,0x11,0x0E,0x04,0x0C}, // 0x87 -{0x0E,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x88 -{0x0A,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x89 -{0x0C,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x8A -{0x0A,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8B -{0x0E,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8C -{0x08,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8D -{0x0A,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0x8E -{0x0E,0x0A,0x0E,0x1B,0x11,0x1F,0x11,0x00}, // 0x8F -{0x03,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0x90 -{0x00,0x00,0x1E,0x05,0x1F,0x14,0x0F,0x00}, // 0x91 -{0x0F,0x14,0x14,0x1F,0x14,0x14,0x17,0x00}, // 0x92 -{0x0E,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x93 -{0x0A,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x94 -{0x18,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x95 -{0x0E,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x96 -{0x18,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x97 -{0x0A,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0x98 -{0x12,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x99 -{0x0A,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x9A -{0x00,0x00,0x01,0x0E,0x16,0x1A,0x1C,0x20}, // 0x9B -{0x06,0x09,0x08,0x1E,0x08,0x09,0x17,0x00}, // 0x9C -{0x0F,0x13,0x15,0x15,0x15,0x19,0x1E,0x00}, // 0x9D -{0x00,0x11,0x0A,0x04,0x0A,0x11,0x00,0x00}, // 0x9E -{0x02,0x05,0x04,0x0E,0x04,0x04,0x14,0x08}, // 0x9F - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A0 (no break space) - { 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x00}, // U+00A1 (inverted !) - { 0x18, 0x18, 0x7E, 0x03, 0x03, 0x7E, 0x18, 0x18}, // U+00A2 (dollarcents) - { 0x1C, 0x36, 0x26, 0x0F, 0x06, 0x67, 0x3F, 0x00}, // U+00A3 (pound sterling) - { 0x00, 0x00, 0x63, 0x3E, 0x36, 0x3E, 0x63, 0x00}, // U+00A4 (currency mark) - { 0x33, 0x33, 0x1E, 0x3F, 0x0C, 0x3F, 0x0C, 0x0C}, // U+00A5 (yen) - { 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00}, // U+00A6 (broken pipe) - { 0x7C, 0xC6, 0x1C, 0x36, 0x36, 0x1C, 0x33, 0x1E}, // U+00A7 (paragraph) - { 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00A8 (diaeresis) - { 0x3C, 0x42, 0x99, 0x85, 0x85, 0x99, 0x42, 0x3C}, // U+00A9 (copyright symbol) - { 0x3C, 0x36, 0x36, 0x7C, 0x00, 0x00, 0x00, 0x00}, // U+00AA (superscript a) - { 0x00, 0xCC, 0x66, 0x33, 0x66, 0xCC, 0x00, 0x00}, // U+00AB (<<) - { 0x00, 0x00, 0x00, 0x3F, 0x30, 0x30, 0x00, 0x00}, // U+00AC (gun pointing left) - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AD (soft hyphen) - { 0x3C, 0x42, 0x9D, 0xA5, 0x9D, 0xA5, 0x42, 0x3C}, // U+00AE (registered symbol) - { 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00AF (macron) - { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B0 (degree) - { 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x7E, 0x00}, // U+00B1 (plusminus) - { 0x1C, 0x30, 0x18, 0x0C, 0x3C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 2) - { 0x1C, 0x30, 0x18, 0x30, 0x1C, 0x00, 0x00, 0x00}, // U+00B2 (superscript 3) - { 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // U+00B2 (aigu) - { 0x00, 0x00, 0x66, 0x66, 0x66, 0x3E, 0x06, 0x03}, // U+00B5 (mu) - { 0xFE, 0xDB, 0xDB, 0xDE, 0xD8, 0xD8, 0xD8, 0x00}, // U+00B6 (pilcrow) - { 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00}, // U+00B7 (central dot) - { 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x30, 0x1E}, // U+00B8 (cedille) - { 0x08, 0x0C, 0x08, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00B9 (superscript 1) - { 0x1C, 0x36, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00}, // U+00BA (superscript 0) - { 0x00, 0x33, 0x66, 0xCC, 0x66, 0x33, 0x00, 0x00}, // U+00BB (>>) - { 0xC3, 0x63, 0x33, 0xBD, 0xEC, 0xF6, 0xF3, 0x03}, // U+00BC (1/4) - { 0xC3, 0x63, 0x33, 0x7B, 0xCC, 0x66, 0x33, 0xF0}, // U+00BD (1/2) - { 0x03, 0xC4, 0x63, 0xB4, 0xDB, 0xAC, 0xE6, 0x80}, // U+00BE (3/4) - { 0x0C, 0x00, 0x0C, 0x06, 0x03, 0x33, 0x1E, 0x00}, // U+00BF (inverted ?) - { 0x07, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C0 (A grave) - { 0x70, 0x00, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x00}, // U+00C1 (A aigu) - { 0x1C, 0x36, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C2 (A circumflex) - { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x7F, 0x63, 0x00}, // U+00C3 (A ~) - { 0x63, 0x1C, 0x36, 0x63, 0x7F, 0x63, 0x63, 0x00}, // U+00C4 (A umlaut) - { 0x0C, 0x0C, 0x00, 0x1E, 0x33, 0x3F, 0x33, 0x00}, // U+00C5 (A ring) - { 0x7C, 0x36, 0x33, 0x7F, 0x33, 0x33, 0x73, 0x00}, // U+00C6 (AE) - { 0x1E, 0x33, 0x03, 0x33, 0x1E, 0x18, 0x30, 0x1E}, // U+00C7 (C cedille) - { 0x07, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C8 (E grave) - { 0x38, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00C9 (E aigu) - { 0x0C, 0x12, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CA (E circumflex) - { 0x36, 0x00, 0x3F, 0x06, 0x1E, 0x06, 0x3F, 0x00}, // U+00CB (E umlaut) - { 0x07, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CC (I grave) - { 0x38, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CD (I aigu) - { 0x0C, 0x12, 0x00, 0x1E, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CE (I circumflex) - { 0x33, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00CF (I umlaut) - { 0x3F, 0x66, 0x6F, 0x6F, 0x66, 0x66, 0x3F, 0x00}, // U+00D0 (Eth) - { 0x3F, 0x00, 0x33, 0x37, 0x3F, 0x3B, 0x33, 0x00}, // U+00D1 (N ~) - { 0x0E, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D2 (O grave) - { 0x70, 0x00, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D3 (O aigu) - { 0x3C, 0x66, 0x18, 0x3C, 0x66, 0x3C, 0x18, 0x00}, // U+00D4 (O circumflex) - { 0x6E, 0x3B, 0x00, 0x3E, 0x63, 0x63, 0x3E, 0x00}, // U+00D5 (O ~) - { 0xC3, 0x18, 0x3C, 0x66, 0x66, 0x3C, 0x18, 0x00}, // U+00D6 (O umlaut) - { 0x00, 0x36, 0x1C, 0x08, 0x1C, 0x36, 0x00, 0x00}, // U+00D7 (multiplicative x) - { 0x5C, 0x36, 0x73, 0x7B, 0x6F, 0x36, 0x1D, 0x00}, // U+00D8 (O stroke) - { 0x0E, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00D9 (U grave) - { 0x70, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DA (U aigu) - { 0x3C, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3C, 0x00}, // U+00DB (U circumflex) - { 0x33, 0x00, 0x33, 0x33, 0x33, 0x33, 0x1E, 0x00}, // U+00DC (U umlaut) - { 0x70, 0x00, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x00}, // U+00DD (Y aigu) - { 0x0F, 0x06, 0x3E, 0x66, 0x66, 0x3E, 0x06, 0x0F}, // U+00DE (Thorn) - { 0x00, 0x1E, 0x33, 0x1F, 0x33, 0x1F, 0x03, 0x03}, // U+00DF (beta) - { 0x07, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E0 (a grave) - { 0x38, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E1 (a aigu) - { 0x7E, 0xC3, 0x3C, 0x60, 0x7C, 0x66, 0xFC, 0x00}, // U+00E2 (a circumflex) - { 0x6E, 0x3B, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E3 (a ~) - { 0x33, 0x00, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E4 (a umlaut) - { 0x0C, 0x0C, 0x1E, 0x30, 0x3E, 0x33, 0x7E, 0x00}, // U+00E5 (a ring) - { 0x00, 0x00, 0xFE, 0x30, 0xFE, 0x33, 0xFE, 0x00}, // U+00E6 (ae) - { 0x00, 0x00, 0x1E, 0x03, 0x03, 0x1E, 0x30, 0x1C}, // U+00E7 (c cedille) - { 0x07, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E8 (e grave) - { 0x38, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00E9 (e aigu) - { 0x7E, 0xC3, 0x3C, 0x66, 0x7E, 0x06, 0x3C, 0x00}, // U+00EA (e circumflex) - { 0x33, 0x00, 0x1E, 0x33, 0x3F, 0x03, 0x1E, 0x00}, // U+00EB (e umlaut) - { 0x07, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EC (i grave) - { 0x1C, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00ED (i augu) - { 0x3E, 0x63, 0x1C, 0x18, 0x18, 0x18, 0x3C, 0x00}, // U+00EE (i circumflex) - { 0x33, 0x00, 0x0E, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}, // U+00EF (i umlaut) - { 0x1B, 0x0E, 0x1B, 0x30, 0x3E, 0x33, 0x1E, 0x00}, // U+00F0 (eth) - { 0x00, 0x1F, 0x00, 0x1F, 0x33, 0x33, 0x33, 0x00}, // U+00F1 (n ~) - { 0x00, 0x07, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F2 (o grave) - { 0x00, 0x38, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F3 (o aigu) - { 0x1E, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F4 (o circumflex) - { 0x6E, 0x3B, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F5 (o ~) - { 0x00, 0x33, 0x00, 0x1E, 0x33, 0x33, 0x1E, 0x00}, // U+00F6 (o umlaut) - { 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00}, // U+00F7 (division) - { 0x00, 0x60, 0x3C, 0x76, 0x7E, 0x6E, 0x3C, 0x06}, // U+00F8 (o stroke) - { 0x00, 0x07, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00F9 (u grave) - { 0x00, 0x38, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FA (u aigu) - { 0x1E, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FB (u circumflex) - { 0x00, 0x33, 0x00, 0x33, 0x33, 0x33, 0x7E, 0x00}, // U+00FC (u umlaut) - { 0x00, 0x38, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F}, // U+00FD (y aigu) - { 0x00, 0x00, 0x06, 0x3E, 0x66, 0x3E, 0x06, 0x00}, // U+00FE (thorn) - { 0x00, 0x33, 0x00, 0x33, 0x33, 0x3E, 0x30, 0x1F} // U+00FF (y umlaut) -}; - -#endif \ No newline at end of file diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index 3ec3ac332..82a4a24bb 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -113,22 +113,31 @@ bool MAX7291Matrix_initDriver(void) } Settings->display_model = XDSP_19; + renderer = nullptr; // renderer not yet used if (Settings->display_width) // [pixel] { LedMatrix_settings.modulesPerRow = (Settings->display_width - 1) / 8 + 1; } Settings->display_width = 8 * LedMatrix_settings.modulesPerRow; - Settings->display_cols[0] = Settings->display_width; + Settings->display_cols[0] = LedMatrix_settings.modulesPerRow; if (Settings->display_height) // [pixel] { LedMatrix_settings.modulesPerCol = (Settings->display_height - 1) / 8 + 1; } - Settings->display_height = 8 * LedMatrix_settings. modulesPerCol; - Settings->display_rows = Settings->display_height; - Settings->display_cols[1] = Settings->display_height; + Settings->display_height = 8 * LedMatrix_settings.modulesPerCol; + Settings->display_rows = LedMatrix_settings.modulesPerCol; + Settings->display_cols[1] = LedMatrix_settings.modulesPerCol; max7219_Matrix = new LedMatrix(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), LedMatrix_settings.modulesPerRow, LedMatrix_settings.modulesPerCol); + if( LedMatrix_settings.show_clock == 0) + { + Settings->display_mode = 0; // text mode + } + else{ + Settings->display_mode = 1; // clock mode + } max2791Matrix_initDriver_done = true; + AddLog(LOG_LEVEL_INFO, PSTR("MTX: MAX7291Matrix_initDriver DIN:%d CLK:%d CS:%d size(%dx%d)"), Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), LedMatrix_settings.modulesPerRow, LedMatrix_settings.modulesPerCol); return MAX7291Matrix_init(); } @@ -137,12 +146,17 @@ bool MAX7291Matrix_init(void) { int intensity = GetDisplayDimmer16(); // 0..15 max7219_Matrix->setIntensity(intensity); - int orientation = Settings->display_rotate; - max7219_Matrix->setOrientation((LedMatrix::ModuleOrientation)orientation ); - AddLog(LOG_LEVEL_INFO, PSTR("MTX: MAX7291Matrix_init %dx%d modules, orientation: %d, intensity: %d"), LedMatrix_settings.modulesPerRow , LedMatrix_settings.modulesPerCol, orientation, intensity); - - //max7219_Matrix->test(); - AddLog(LOG_LEVEL_INFO, PSTR("MTX: display test")); + if(Settings->display_rotate <= 3) + { + max7219_Matrix->setOrientation((LedMatrix::ModuleOrientation)Settings->display_rotate ); + } + else + { + // default for most 32x8 modules + Settings->display_rotate = LedMatrix::ORIENTATION_UPSIDE_DOWN; + max7219_Matrix->setOrientation( LedMatrix::ORIENTATION_UPSIDE_DOWN ); + } + AddLog(LOG_LEVEL_INFO, PSTR("MTX: MAX7291Matrix_init orientation: %d, intensity: %d"), Settings->display_rotate, intensity); return true; } @@ -183,28 +197,38 @@ bool MAX7291Matrix_clock(void) { LedMatrix_settings.show_clock = XdrvMailbox.payload; if (ArgC() == 0) - XdrvMailbox.payload = 1; - if (XdrvMailbox.payload > 1) - { - LedMatrix_settings.timeFormat = "%H:%M"; - if(LedMatrix_settings.modulesPerRow > 6) - { - LedMatrix_settings.timeFormat = "%H:%M:%S"; - } XdrvMailbox.payload = 2; - } - else - { - LedMatrix_settings.timeFormat = "%I:%M"; - if(LedMatrix_settings.modulesPerRow > 6) + switch(XdrvMailbox.payload) { - LedMatrix_settings.timeFormat = "%I:%M:%S"; + case 0: + // no clock, switch to text mode + Settings->display_mode = 0; + return true; + case 1: + // 12 h clock + LedMatrix_settings.timeFormat = "%I:%M"; + if(LedMatrix_settings.modulesPerRow > 6) + { + LedMatrix_settings.timeFormat = "%I:%M:%S"; + } + Settings->display_mode = 1; + break; + case 2: + // 24 h clock + LedMatrix_settings.timeFormat = "%H:%M"; + if(LedMatrix_settings.modulesPerRow > 6) + { + LedMatrix_settings.timeFormat = "%H:%M:%S"; + } + Settings->display_mode = 1; + break; + default: + return false; } - XdrvMailbox.payload = 1; - } AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: LedMatrix_settings.show_clock %d, timeFormat %s"), LedMatrix_settings.show_clock, LedMatrix_settings.timeFormat); + max7219_Matrix->clearDisplay(); MAX7291Matrix_showTime(); return true; } @@ -220,7 +244,7 @@ bool MAX7291Matrix_showTime() timeinfo = localtime(&rawtime); strftime(timeStr, 10, LedMatrix_settings.timeFormat, timeinfo); - max7219_Matrix->drawText(timeStr); + max7219_Matrix->drawText(timeStr, false); // false: do not clear desplay on update to prevent flicker return true; } #endif // USE_DISPLAY_MODES1TO5 @@ -254,7 +278,16 @@ bool Xdsp19(uint8_t function) result = max7219_Matrix->setIntensity(GetDisplayDimmer16()); break; case FUNC_DISPLAY_DRAW_STRING: - result = max7219_Matrix->drawText(dsp_str); + case FUNC_DISPLAY_SCROLLTEXT: + case FUNC_DISPLAY_SEVENSEG_TEXT: + Settings->display_mode = 0; // text mode + LedMatrix_settings.show_clock = 0; // disable clock mode + result = max7219_Matrix->drawText(XdrvMailbox.data, true); // true: clears display before drawing text + break; + case FUNC_DISPLAY_SEVENSEG_TEXTNC: + Settings->display_mode = 0; // text mode + LedMatrix_settings.show_clock = 0; // disable clock mode + result = max7219_Matrix->drawText(XdrvMailbox.data, false); // false: does not clear display before drawing text break; case FUNC_DISPLAY_SCROLLDELAY: result = MAX7291Matrix_scrollDelay(); From 09974f8873fa1ffdb8eeb19f4568e6dec31b7ed1 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 30 Nov 2021 14:18:26 +0100 Subject: [PATCH 08/31] Command for all Modules at once --- lib/lib_display/LedControl/src/LedControl.cpp | 67 ++++++++++++++----- lib/lib_display/LedControl/src/LedControl.h | 9 ++- lib/lib_display/LedControl/src/LedMatrix.cpp | 56 +++++++++++++--- lib/lib_display/LedControl/src/LedMatrix.h | 1 + 4 files changed, 104 insertions(+), 29 deletions(-) diff --git a/lib/lib_display/LedControl/src/LedControl.cpp b/lib/lib_display/LedControl/src/LedControl.cpp index 11e7a2908..baaa3802c 100644 --- a/lib/lib_display/LedControl/src/LedControl.cpp +++ b/lib/lib_display/LedControl/src/LedControl.cpp @@ -55,18 +55,20 @@ LedControl::LedControl(int dataPin, int clkPin, int csPin, int numDevices) { pinMode(SPI_CS,OUTPUT); digitalWrite(SPI_CS,HIGH); SPI_MOSI=dataPin; - for (int i = 0; i < 8 * MAX72XX_MAX_DEVICES; i++) - status[i] = 0x00; - for(int i=0;i=maxDevices) return; @@ -89,6 +96,13 @@ void LedControl::setScanLimit(int addr, int limit) { spiTransfer(addr, OP_SCANLIMIT,limit); } +void LedControl::setScanLimit_allDevices(int limit) { + if(limit <0 || limit>8) return; + + memset(deviceDataBuff, (byte)limit, maxDevices); + spiTransfer_allDevices(OP_SCANLIMIT,deviceDataBuff); +} + void LedControl::setIntensity(int addr, int intensity) { if(addr<0 || addr>=maxDevices) return; @@ -96,6 +110,15 @@ void LedControl::setIntensity(int addr, int intensity) { spiTransfer(addr, OP_INTENSITY,intensity); } +void LedControl::setIntensity_allDevices(int intensity) +{ + if (intensity < 0 | intensity > 15) + return; + + memset(deviceDataBuff, (byte)intensity, maxDevices); + spiTransfer_allDevices(OP_INTENSITY, deviceDataBuff); +} + void LedControl::clearDisplay(int addr) { int offset; @@ -108,6 +131,16 @@ void LedControl::clearDisplay(int addr) { } } +void LedControl::clearDisplay_allDevices() +{ + memset(status, (byte)0, 8 * maxDevices); + memset(deviceDataBuff, (byte)0, maxDevices); + for (int row = 0; row < 8; row++) + { + spiTransfer_allDevices(row + 1, deviceDataBuff); + } +} + void LedControl::setLed(int addr, int row, int column, boolean state) { int offset; byte val=0x00; @@ -138,13 +171,13 @@ void LedControl::setRow(int addr, int row, byte value) { spiTransfer(addr, row+1,status[offset+row]); } -void LedControl::setRowLong(int row, byte *value) +void LedControl::setRow_allDevices(int row, byte *value) { if (row < 0 || row > 7) return; for (int addr = 0; addr < maxDevices; addr++) status[addr * 8 + row] = value[addr]; - spiTransferLong(row + 1, value); + spiTransfer_allDevices(row + 1, value); } void LedControl::setColumn(int addr, int col, byte value) { @@ -217,7 +250,7 @@ void LedControl::spiTransfer(int addr, volatile byte opcode, volatile byte data) digitalWrite(SPI_CS,HIGH); } -void LedControl::spiTransferLong(byte opcode, const byte* data) { +void LedControl::spiTransfer_allDevices(byte opcode, const byte* data) { //Create an array with the data to shift out for (int addr = 0; addr < maxDevices; addr++) { @@ -227,8 +260,8 @@ void LedControl::spiTransferLong(byte opcode, const byte* data) { //enable the line digitalWrite(SPI_CS, LOW); //Now shift out the data - for (int i = maxDevices * 2; i > 0; i--) - shiftOut(SPI_MOSI, SPI_CLK, MSBFIRST, spidata[i - 1]); + for (int i = maxDevices * 2 -1; i >= 0; i--) + shiftOut(SPI_MOSI, SPI_CLK, MSBFIRST, spidata[i]); //latch the data onto the display digitalWrite(SPI_CS, HIGH); } diff --git a/lib/lib_display/LedControl/src/LedControl.h b/lib/lib_display/LedControl/src/LedControl.h index 31fed9ffe..4fc7523df 100644 --- a/lib/lib_display/LedControl/src/LedControl.h +++ b/lib/lib_display/LedControl/src/LedControl.h @@ -69,10 +69,11 @@ class LedControl { /* Send out a single command to one device */ void spiTransfer(int addr, byte opcode, byte data); /* Send out a command with the same opcode to all devices */ - void spiTransferLong(byte opcode, const byte* data); + void spiTransfer_allDevices(byte opcode, const byte* data); /* We keep track of the led-status for all 8 devices in this array */ byte status[8 * MAX72XX_MAX_DEVICES]; + byte deviceDataBuff[MAX72XX_MAX_DEVICES]; /* Data is shifted out of this pin*/ int SPI_MOSI; /* The clock is signaled on this pin */ @@ -108,6 +109,7 @@ class LedControl { * for normal operation. */ void shutdown(int addr, bool status); + void shutdown_allDevices( bool status); /* * Set the number of digits (or rows) to be displayed. @@ -118,6 +120,7 @@ class LedControl { * limit number of digits to be displayed (1..8) */ void setScanLimit(int addr, int limit); + void setScanLimit_allDevices(int limit); /* * Set the brightness of the display. @@ -126,6 +129,7 @@ class LedControl { * intensity the brightness of the display. (0..15) */ void setIntensity(int addr, int intensity); + void setIntensity_allDevices(int intensity); /* * Switch all Leds on the display off. @@ -133,6 +137,7 @@ class LedControl { * addr address of the display to control */ void clearDisplay(int addr); + void clearDisplay_allDevices(); /* * Set the status of a single Led. @@ -161,7 +166,7 @@ class LedControl { * @param row [0..8] * @param value array of bytes, one for each device */ - void setRowLong(int row, byte* value); + void setRow_allDevices(int row, byte* value); /* * Set all 8 Led's in a column to a new state diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp index 1579e0852..59882cd15 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.cpp +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -139,10 +139,7 @@ bool LedMatrix::clearDisplay(void) bool LedMatrix::setIntensity(byte dim) { - for (int addr = 0; addr < modules; addr++) - { - ledControl->setIntensity(addr, dim); // 1..15 - } + ledControl->setIntensity_allDevices(dim); // 1..15 return true; } @@ -183,9 +180,51 @@ bool LedMatrix::setPixel(const int x, const int y, bool on) void LedMatrix::refresh() { - for (int i = 0; i < modulesPerRow * displayHeight; i++) + int col = 0; + int pixelRow = 0; + int bufPos = 0; + int deviceRow = 0; + for(int ledRow = 7; ledRow >= 0; ledRow--) // refresh from buttom to top { - refreshByteOfBuffer(i); + for( int addr = 0; addr < modules; addr++) + { + switch(moduleOrientation) + { + case ORIENTATION_NORMAL: + col = addr % modulesPerRow; + pixelRow = (addr / modulesPerRow) * 8 + ledRow; + bufPos = pixelRow * modulesPerRow + col; + deviceDataBuff[addr] = buffer[bufPos]; + deviceRow = ledRow; + break; + case ORIENTATION_UPSIDE_DOWN: + col = addr % modulesPerRow; + pixelRow = (addr / modulesPerRow) * 8 + deviceRow; + bufPos = pixelRow * modulesPerRow + col; + deviceDataBuff[addr] = revereBitorder(buffer[bufPos]); // mirror + deviceRow = 7 - ledRow; // upside down + break; + } + if(moduleOrientation == ORIENTATION_NORMAL || moduleOrientation == ORIENTATION_UPSIDE_DOWN) + { + col = addr % modulesPerRow; + pixelRow = (addr / modulesPerRow) * 8 + ledRow; + bufPos = pixelRow * modulesPerRow + col; + if(moduleOrientation == ORIENTATION_NORMAL) + { + // ORIENTATION_NORMAL + deviceDataBuff[addr] = buffer[bufPos]; + deviceRow = ledRow; + } + else + { + // ORIENTATION_UPSIDE_DOWN + deviceDataBuff[addr] = revereBitorder(buffer[bufPos]); // mirror + deviceRow = 7 - ledRow; // upside down + } + } + } + ledControl->setRow_allDevices(deviceRow, deviceDataBuff); // upside down } } @@ -227,10 +266,7 @@ bool LedMatrix::shutdown(bool b) bool LedMatrix::clear(void) { memset(buffer, 0, MATRIX_BUFFER_SIZE); - for (int addr = 0; addr < modules; addr++) - { - ledControl->clearDisplay(addr); - } + ledControl->clearDisplay_allDevices(); return true; } diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index b369173d0..9fee69a5f 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -154,6 +154,7 @@ class LedMatrix unsigned int modules; // number of 8x8 mudules uint8_t moduleOrientation; byte buffer[MATRIX_BUFFER_SIZE]; + byte deviceDataBuff[MAX72XX_MAX_DEVICES]; LedControl* ledControl; int charWidth; int charHeight; From 306ed0d2dd8040f7f56eaba24a9ea3cf8b0925cc Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 3 Dec 2021 16:50:55 +0100 Subject: [PATCH 09/31] max7219 dot matrix ready for pull request --- lib/lib_display/LedControl/src/LedControl.cpp | 82 ++------- lib/lib_display/LedControl/src/LedControl.h | 25 +-- lib/lib_display/LedControl/src/LedMatrix.cpp | 173 +++++++++--------- lib/lib_display/LedControl/src/LedMatrix.h | 59 ++++-- tasmota/xdsp_19_max7219_matrix.ino | 20 +- 5 files changed, 162 insertions(+), 197 deletions(-) diff --git a/lib/lib_display/LedControl/src/LedControl.cpp b/lib/lib_display/LedControl/src/LedControl.cpp index baaa3802c..5807aa6af 100644 --- a/lib/lib_display/LedControl/src/LedControl.cpp +++ b/lib/lib_display/LedControl/src/LedControl.cpp @@ -47,28 +47,26 @@ LedControl::LedControl(int dataPin, int clkPin, int csPin, int numDevices) { SPI_MOSI=dataPin; SPI_CLK=clkPin; SPI_CS=csPin; - if (numDevices <= 0 || numDevices > MAX72XX_MAX_DEVICES) - numDevices = MAX72XX_MAX_DEVICES; + if(numDevices<=0 || numDevices>8 ) + numDevices=8; maxDevices = numDevices; pinMode(SPI_MOSI,OUTPUT); pinMode(SPI_CLK,OUTPUT); pinMode(SPI_CS,OUTPUT); digitalWrite(SPI_CS,HIGH); SPI_MOSI=dataPin; - - memset(status, (byte)0, 8 * MAX72XX_MAX_DEVICES); - memset(deviceDataBuff, (byte)0, MAX72XX_MAX_DEVICES); - - // display test - spiTransfer_allDevices(OP_DISPLAYTEST, deviceDataBuff); + for(int i=0;i<64;i++) + status[i]=0x00; + for(int i=0;i=maxDevices) return; @@ -96,13 +89,6 @@ void LedControl::setScanLimit(int addr, int limit) { spiTransfer(addr, OP_SCANLIMIT,limit); } -void LedControl::setScanLimit_allDevices(int limit) { - if(limit <0 || limit>8) return; - - memset(deviceDataBuff, (byte)limit, maxDevices); - spiTransfer_allDevices(OP_SCANLIMIT,deviceDataBuff); -} - void LedControl::setIntensity(int addr, int intensity) { if(addr<0 || addr>=maxDevices) return; @@ -110,15 +96,6 @@ void LedControl::setIntensity(int addr, int intensity) { spiTransfer(addr, OP_INTENSITY,intensity); } -void LedControl::setIntensity_allDevices(int intensity) -{ - if (intensity < 0 | intensity > 15) - return; - - memset(deviceDataBuff, (byte)intensity, maxDevices); - spiTransfer_allDevices(OP_INTENSITY, deviceDataBuff); -} - void LedControl::clearDisplay(int addr) { int offset; @@ -131,16 +108,6 @@ void LedControl::clearDisplay(int addr) { } } -void LedControl::clearDisplay_allDevices() -{ - memset(status, (byte)0, 8 * maxDevices); - memset(deviceDataBuff, (byte)0, maxDevices); - for (int row = 0; row < 8; row++) - { - spiTransfer_allDevices(row + 1, deviceDataBuff); - } -} - void LedControl::setLed(int addr, int row, int column, boolean state) { int offset; byte val=0x00; @@ -171,15 +138,6 @@ void LedControl::setRow(int addr, int row, byte value) { spiTransfer(addr, row+1,status[offset+row]); } -void LedControl::setRow_allDevices(int row, byte *value) -{ - if (row < 0 || row > 7) - return; - for (int addr = 0; addr < maxDevices; addr++) - status[addr * 8 + row] = value[addr]; - spiTransfer_allDevices(row + 1, value); -} - void LedControl::setColumn(int addr, int col, byte value) { byte val; @@ -237,7 +195,7 @@ void LedControl::spiTransfer(int addr, volatile byte opcode, volatile byte data) int maxbytes=maxDevices*2; for(int i=0;i= 0; i--) - shiftOut(SPI_MOSI, SPI_CLK, MSBFIRST, spidata[i]); - //latch the data onto the display - digitalWrite(SPI_CS, HIGH); -} + diff --git a/lib/lib_display/LedControl/src/LedControl.h b/lib/lib_display/LedControl/src/LedControl.h index 4fc7523df..f8180d07d 100644 --- a/lib/lib_display/LedControl/src/LedControl.h +++ b/lib/lib_display/LedControl/src/LedControl.h @@ -35,10 +35,6 @@ #include #endif -#ifndef MAX72XX_MAX_DEVICES -#define MAX72XX_MAX_DEVICES 32 // maximum number of devices based on MXA7219/MAX7221 -#endif - /* * Segments to be switched on for characters and digits on * 7-Segment Displays @@ -65,15 +61,12 @@ const static byte charTable [] PROGMEM = { class LedControl { private : /* The array for shifting the data to the devices */ - byte spidata[2 * MAX72XX_MAX_DEVICES]; - /* Send out a single command to one device */ + byte spidata[16]; + /* Send out a single command to the device */ void spiTransfer(int addr, byte opcode, byte data); - /* Send out a command with the same opcode to all devices */ - void spiTransfer_allDevices(byte opcode, const byte* data); /* We keep track of the led-status for all 8 devices in this array */ - byte status[8 * MAX72XX_MAX_DEVICES]; - byte deviceDataBuff[MAX72XX_MAX_DEVICES]; + byte status[64]; /* Data is shifted out of this pin*/ int SPI_MOSI; /* The clock is signaled on this pin */ @@ -109,7 +102,6 @@ class LedControl { * for normal operation. */ void shutdown(int addr, bool status); - void shutdown_allDevices( bool status); /* * Set the number of digits (or rows) to be displayed. @@ -120,7 +112,6 @@ class LedControl { * limit number of digits to be displayed (1..8) */ void setScanLimit(int addr, int limit); - void setScanLimit_allDevices(int limit); /* * Set the brightness of the display. @@ -129,7 +120,6 @@ class LedControl { * intensity the brightness of the display. (0..15) */ void setIntensity(int addr, int intensity); - void setIntensity_allDevices(int intensity); /* * Switch all Leds on the display off. @@ -137,7 +127,6 @@ class LedControl { * addr address of the display to control */ void clearDisplay(int addr); - void clearDisplay_allDevices(); /* * Set the status of a single Led. @@ -160,14 +149,6 @@ class LedControl { */ void setRow(int addr, int row, byte value); - /** - * @brief Set data for the same row of all devices - * - * @param row [0..8] - * @param value array of bytes, one for each device - */ - void setRow_allDevices(int row, byte* value); - /* * Set all 8 Led's in a column to a new state * Params: diff --git a/lib/lib_display/LedControl/src/LedMatrix.cpp b/lib/lib_display/LedControl/src/LedMatrix.cpp index 59882cd15..929a09418 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.cpp +++ b/lib/lib_display/LedControl/src/LedMatrix.cpp @@ -1,5 +1,5 @@ /* - * LedMatrix.h - Extends the Library LedControl for multiple 8x8 LED dot matrix modules, based on MAX7219/MAX7221 + * LedMatrix.h - Extends the Library LedControl for multiple 8x8 LED dot matrix maxDevices, based on MAX7219/MAX7221 * Copyright (c) 2021 Michael Beuss * * Permission is hereby granted, free of charge, to any person @@ -29,7 +29,26 @@ #include "font_6x8_horizontal_MSB.h" //#include "font_8x8_horizontal_latin_MSB.h" -// public +//the opcodes for the MAX7221 and MAX7219 +#define OP_NOOP 0 +#define OP_DIGIT0 1 +#define OP_DIGIT1 2 +#define OP_DIGIT2 3 +#define OP_DIGIT3 4 +#define OP_DIGIT4 5 +#define OP_DIGIT5 6 +#define OP_DIGIT6 7 +#define OP_DIGIT7 8 +#define OP_DECODEMODE 9 +#define OP_INTENSITY 10 +#define OP_SCANLIMIT 11 +#define OP_SHUTDOWN 12 +#define OP_DISPLAYTEST 15 + +// test +#include "LedControl.h" +LedControl* ledControl = nullptr; +// end text LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows) { if (colums * rows > MAX72XX_MAX_DEVICES) @@ -52,22 +71,36 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un modulesPerCol = rows; displayWidth = colums * 8; displayHeight = rows * 8; - modules = colums * rows; + maxDevices = colums * rows; moduleOrientation = ORIENTATION_UPSIDE_DOWN; // use setOrientation() to turn it - ledControl = new LedControl(dataPin, clkPin, csPin, modules); // initializes all connected LED matrix modules textBuf[0] = 0; textWidth = 0; textPosX = 0; textPosY = 0; appendTextBuf[0] = 0; setScrollAppendText(" "); - shutdown(false); // false: on, true: off - clear(); - setIntensity(7); + + // initialize all connected MAX7219/MAX7221 devices + SPI_MOSI = dataPin; + SPI_CLK = clkPin; + SPI_CS = csPin; + pinMode(SPI_MOSI, OUTPUT); + pinMode(SPI_CLK, OUTPUT); + pinMode(SPI_CS, OUTPUT); + SPI_MOSI = dataPin; + + //spiTransfer_value(OP_DISPLAYTEST, 0); // display test + spiTransfer_value(OP_SCANLIMIT, 7); // scanlimit is set to max on startup + spiTransfer_value(OP_DECODEMODE, 0); // decode is done in source + clearDisplay(); + //spiTransfer_value(OP_SHUTDOWN, 0); //we go into shutdown-mode (LEDs off) on startup + setIntensity(7); // initialize with the half of the maximum intensity [0..15] + power(true); // power on; } bool LedMatrix::drawText( const char *str, bool clearBefore) { + if(clearBefore) clearDisplay(); strncpy(textBuf, str, TEXT_BUFFER_SIZE -1); textPosX = 0; textPosY = 0; @@ -75,7 +108,6 @@ bool LedMatrix::drawText( const char *str, bool clearBefore) if(textWidth < displayWidth) { // text fits into the display, place it into the center - if(clearBefore) clear(); textPosX = (displayWidth - textWidth) / 2; // center } else @@ -125,21 +157,29 @@ bool LedMatrix::scrollText() void LedMatrix::power(bool on) { - shutdown(!on); // power(false) shuts down the display with shutdown(true) + byte value = 0; // 0: shutdown + if(on) value = 1; // 1: power on + spiTransfer_value(OP_SHUTDOWN, value); // power(false) shuts down the display } bool LedMatrix::clearDisplay(void) { - textBuf[0] = 0; memset(textBuf, 0, TEXT_BUFFER_SIZE); textWidth = 0; - clear(); + memset(buffer, 0, MATRIX_BUFFER_SIZE); + for (int row = 0; row < 8; row++) + { + spiTransfer_value(row + 1, 0); + } return true; } -bool LedMatrix::setIntensity(byte dim) +bool LedMatrix::setIntensity(byte intensity) { - ledControl->setIntensity_allDevices(dim); // 1..15 + if (intensity < 0 || intensity > 15) + return false; + + spiTransfer_value(OP_INTENSITY, intensity); return true; } @@ -186,25 +226,8 @@ void LedMatrix::refresh() int deviceRow = 0; for(int ledRow = 7; ledRow >= 0; ledRow--) // refresh from buttom to top { - for( int addr = 0; addr < modules; addr++) + for( int addr = 0; addr < maxDevices; addr++) { - switch(moduleOrientation) - { - case ORIENTATION_NORMAL: - col = addr % modulesPerRow; - pixelRow = (addr / modulesPerRow) * 8 + ledRow; - bufPos = pixelRow * modulesPerRow + col; - deviceDataBuff[addr] = buffer[bufPos]; - deviceRow = ledRow; - break; - case ORIENTATION_UPSIDE_DOWN: - col = addr % modulesPerRow; - pixelRow = (addr / modulesPerRow) * 8 + deviceRow; - bufPos = pixelRow * modulesPerRow + col; - deviceDataBuff[addr] = revereBitorder(buffer[bufPos]); // mirror - deviceRow = 7 - ledRow; // upside down - break; - } if(moduleOrientation == ORIENTATION_NORMAL || moduleOrientation == ORIENTATION_UPSIDE_DOWN) { col = addr % modulesPerRow; @@ -224,7 +247,7 @@ void LedMatrix::refresh() } } } - ledControl->setRow_allDevices(deviceRow, deviceDataBuff); // upside down + setRow_allDevices(deviceRow, deviceDataBuff); } } @@ -254,58 +277,6 @@ bool LedMatrix::drawCharAt( char c, const int x, const int y) return true; } -bool LedMatrix::shutdown(bool b) -{ - for (int addr = 0; addr < modules; addr++) - { - ledControl->shutdown(addr, b); // b: false: on, true: off - } - return true; -} - -bool LedMatrix::clear(void) -{ - memset(buffer, 0, MATRIX_BUFFER_SIZE); - ledControl->clearDisplay_allDevices(); - return true; -} - -void LedMatrix::refreshByteOfBuffer(int i) -{ - int line = i / modulesPerRow; - int addr = (line / 8) * modulesPerRow + i % modulesPerRow; - byte b = buffer[i]; - if (moduleOrientation == ORIENTATION_NORMAL || moduleOrientation == ORIENTATION_UPSIDE_DOWN) - { - int rowOfAddr = 0; - if (moduleOrientation == ORIENTATION_NORMAL) - { - rowOfAddr = line % 8; // ORIENTATION_NORMAL - } - else - { - rowOfAddr = 7 - line % 8; // ORIENTATION_UPSIDE_DOWN - b = revereBitorder(b); - } - ledControl->setRow(addr, rowOfAddr, b); - } - else - { - // ORIENTATION_TURN_RIGHT or ORIENTATION_TURN_LEFT - int colOfAddr = 0; - if (moduleOrientation == ORIENTATION_TURN_LEFT) - { - colOfAddr = line % 8; // ORIENTATION_TURN_LEFT - } - else - { - colOfAddr = 7 - line % 8; // ORIENTATION_TURN_RIGHT - b = revereBitorder(b); - } - ledControl->setColumn(addr, colOfAddr, b); - } -} - byte LedMatrix::revereBitorder (byte b) { static const byte lookup[16] = { @@ -320,3 +291,37 @@ void LedMatrix::appendSpace() strncat(textBuf, appendTextBuf, TEXT_BUFFER_SIZE -1); textWidth = strlen(textBuf) * charWidth; } + +void LedMatrix::setRow_allDevices(int row, byte *data) +{ + if (row < 0 || row > 7) + return; + spiTransfer_array(row + 1, data); +} + +void LedMatrix::spiTransfer_array(byte opcode, const byte* data) { + // create an array with the data to shift out + for (int addr = 0; addr < maxDevices; addr++) + { + spidata[addr * 2 + 1] = opcode; + spidata[addr * 2] = data[addr]; + } + // enable the line + digitalWrite(SPI_CS, LOW); + // shift out the data + for (int i = maxDevices * 2 -1; i >= 0; i--) + { + shiftOut(SPI_MOSI, SPI_CLK, MSBFIRST, spidata[i]); + } + // latch the data onto the display + digitalWrite(SPI_CS, HIGH); +} + +void LedMatrix::spiTransfer_value(byte opcode, byte value) +{ + memset(deviceDataBuff, (byte)value, maxDevices); + spiTransfer_array(opcode, deviceDataBuff); +} + + + diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index 9fee69a5f..aec15d052 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -1,5 +1,5 @@ /* - * LedMatrix.h - Extends the Library LedControl for multiple 8x8 LED dot matrix modules, based on MAX7219/MAX7221 + * LedMatrix.h - Extends the Library LedControl for multiple 8x8 LED dot matrix devices, based on MAX7219/MAX7221 * Copyright (c) 2021 Michael Beuss * * Permission is hereby granted, free of charge, to any person @@ -27,16 +27,27 @@ #ifndef LedMatrix_h #define LedMatrix_h -#include +#include + +#if (ARDUINO >= 100) +#include +#else +#include +#endif + +#ifndef MAX72XX_MAX_DEVICES +#define MAX72XX_MAX_DEVICES 32 // maximum number of devices based on MXA7219/MAX7221 +#endif #define MATRIX_BUFFER_SIZE MAX72XX_MAX_DEVICES * 8 // 8 bytes per modul. One byte represents 8 LEDs. #define TEXT_BUFFER_SIZE 256 // maximum text length that can be scrolled #define TEXT_APPEND_BUFFER_SIZE 16 // used for characters that are appended to the scroll text, before it repeats +#define SPI_BUFFER_SIZE MAX72XX_MAX_DEVICES * 2 // buffer size fort shifting commands to all devices (2 bytes each) /** - * @brief LedMatric controls multiple 8x8 LED dot matrx modules. - * All modules in rows and clolums together build a common display pixel matrix. + * @brief LedMatrix controls multiple 8x8 LED dot matrx devices. + * All devices in rows and clolums together build a common display pixel matrix. * */ class LedMatrix @@ -54,8 +65,8 @@ class LedMatrix /** * @brief Construct a new LED Matrix object * - * @param colums of 8x8 LED dot matrix modules - * @param rows of 8x8 LED dot matrix modules + * @param colums of 8x8 LED dot matrix devices + * @param rows of 8x8 LED dot matrix devices */ LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, unsigned int rows); @@ -139,23 +150,48 @@ class LedMatrix void refresh(); private: + bool drawCharAt( char c, int x, int y ); // Draws a character to a defined position - bool shutdown(bool b); // shutdown(true) switches the display off. Text and pixels can be set while it is off. shutdown(false) switches the display on. - bool clear(void); // clears the display content - void refreshByteOfBuffer( int i); // sends one byte of the buffer to the display. This updates an 8 pixel row of one matrix module. byte revereBitorder(byte b); // returnes the byte in the reverse bit order. void appendSpace(); // appends characters to the end of the text to get a distance to the repeating scroll text + // device contrl MAX7219/MAX7221 + /** + * @brief Set data for the same row of all devices + * + * @param row [0..8] + * @param value array of bytes, one for each device + */ + void setRow_allDevices(int row, byte* value); + + /* Send out a command with the same opcode to all devices */ + /** + * @brief sends opcode with specific data values to each device + * + * @param opcode + * @param data array of byte values (data[0] is the value for the first device) + */ + void spiTransfer_array(byte opcode, const byte* data); + + /** + * @brief sends opcode with same value to all devices + */ + void spiTransfer_value(byte opcode, byte value); + + private: + int SPI_MOSI; // Data is shifted out of this pin + int SPI_CLK; // The clock is signaled on this pin + int SPI_CS; // This one is driven LOW for chip selectzion + unsigned int modulesPerRow; unsigned int modulesPerCol; unsigned int displayWidth; // matrix width [pixel] unsigned int displayHeight; // matrix height [pixel] - unsigned int modules; // number of 8x8 mudules + int maxDevices; // number of used 8x8 devices uint8_t moduleOrientation; byte buffer[MATRIX_BUFFER_SIZE]; byte deviceDataBuff[MAX72XX_MAX_DEVICES]; - LedControl* ledControl; int charWidth; int charHeight; char textBuf[TEXT_BUFFER_SIZE]; @@ -163,6 +199,7 @@ class LedMatrix int textWidth; // width of text [pixel] int textPosX; // horizontal pixel position of scrolling text int textPosY; // vertical pixelposition of scrolling text; + byte spidata[SPI_BUFFER_SIZE]; // The array for shifting the data to the devices }; diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index 82a4a24bb..ecf500670 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -128,13 +128,6 @@ bool MAX7291Matrix_initDriver(void) Settings->display_rows = LedMatrix_settings.modulesPerCol; Settings->display_cols[1] = LedMatrix_settings.modulesPerCol; max7219_Matrix = new LedMatrix(Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), LedMatrix_settings.modulesPerRow, LedMatrix_settings.modulesPerCol); - if( LedMatrix_settings.show_clock == 0) - { - Settings->display_mode = 0; // text mode - } - else{ - Settings->display_mode = 1; // clock mode - } max2791Matrix_initDriver_done = true; AddLog(LOG_LEVEL_INFO, PSTR("MTX: MAX7291Matrix_initDriver DIN:%d CLK:%d CS:%d size(%dx%d)"), Pin(GPIO_MAX7219DIN), Pin(GPIO_MAX7219CLK), Pin(GPIO_MAX7219CS), LedMatrix_settings.modulesPerRow, LedMatrix_settings.modulesPerCol); @@ -144,8 +137,13 @@ bool MAX7291Matrix_initDriver(void) // FUNC_DISPLAY_INIT bool MAX7291Matrix_init(void) { + Settings->display_mode = 0; // text mode + LedMatrix_settings.show_clock = 0; // no clock + int intensity = GetDisplayDimmer16(); // 0..15 max7219_Matrix->setIntensity(intensity); + + max7219_Matrix->power(true); // power on if(Settings->display_rotate <= 3) { max7219_Matrix->setOrientation((LedMatrix::ModuleOrientation)Settings->display_rotate ); @@ -223,6 +221,8 @@ bool MAX7291Matrix_clock(void) Settings->display_mode = 1; break; default: + //LedMatrix_settings.timeFormat = XdrvMailbox.payload; + //Settings->display_mode = 1; return false; } @@ -280,13 +280,11 @@ bool Xdsp19(uint8_t function) case FUNC_DISPLAY_DRAW_STRING: case FUNC_DISPLAY_SCROLLTEXT: case FUNC_DISPLAY_SEVENSEG_TEXT: - Settings->display_mode = 0; // text mode - LedMatrix_settings.show_clock = 0; // disable clock mode + if(Settings->display_mode != 0) MAX7291Matrix_init(); result = max7219_Matrix->drawText(XdrvMailbox.data, true); // true: clears display before drawing text break; case FUNC_DISPLAY_SEVENSEG_TEXTNC: - Settings->display_mode = 0; // text mode - LedMatrix_settings.show_clock = 0; // disable clock mode + if(Settings->display_mode != 0) MAX7291Matrix_init(); result = max7219_Matrix->drawText(XdrvMailbox.data, false); // false: does not clear display before drawing text break; case FUNC_DISPLAY_SCROLLDELAY: From 8bad0115b03ecb51694fec750e7b523f546729bc Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:01:27 +0100 Subject: [PATCH 10/31] Fix ESP32 webcam WDT Fix ESP32 webcam WDT (#13882) --- lib/libesp32_div/esp32-camera/CMakeLists.txt | 64 + lib/libesp32_div/esp32-camera/Kconfig | 114 ++ lib/libesp32_div/esp32-camera/LICENSE | 202 +++ lib/libesp32_div/esp32-camera/README.md | 368 ++++++ lib/libesp32_div/esp32-camera/component.mk | 4 + .../esp32-camera/conversions/esp_jpg_decode.c | 132 ++ .../conversions/include/esp_jpg_decode.h | 43 + .../conversions/include/img_converters.h | 130 ++ .../esp32-camera/conversions/jpge.cpp | 723 +++++++++++ .../conversions/private_include/jpge.h | 142 +++ .../conversions/private_include/yuv.h | 29 + .../esp32-camera/conversions/to_bmp.c | 393 ++++++ .../esp32-camera/conversions/to_jpg.cpp | 245 ++++ .../esp32-camera/conversions/yuv.c | 298 +++++ .../esp32-camera/driver/cam_hal.c | 483 +++++++ .../esp32-camera/driver/esp_camera.c | 416 ++++++ .../esp32-camera/driver/include/esp_camera.h | 214 ++++ .../esp32-camera/driver/include/sensor.h | 245 ++++ .../driver/private_include/cam_hal.h | 60 + .../driver/private_include/sccb.h | 19 + .../driver/private_include/xclk.h | 9 + lib/libesp32_div/esp32-camera/driver/sccb.c | 184 +++ lib/libesp32_div/esp32-camera/driver/sensor.c | 52 + .../esp32-camera/examples/CMakeLists.txt | 9 + .../esp32-camera/examples/Makefile | 11 + .../esp32-camera/examples/main/CMakeLists.txt | 3 + .../esp32-camera/examples/main/component.mk | 5 + .../esp32-camera/examples/main/take_picture.c | 155 +++ .../esp32-camera/examples/sdkconfig.defaults | 17 + lib/libesp32_div/esp32-camera/library.json | 26 + .../esp32-camera/sensors/gc0308.c | 465 +++++++ .../esp32-camera/sensors/gc032a.c | 391 ++++++ .../esp32-camera/sensors/gc2145.c | 475 +++++++ .../esp32-camera/sensors/nt99141.c | 1022 +++++++++++++++ .../esp32-camera/sensors/ov2640.c | 612 +++++++++ .../esp32-camera/sensors/ov3660.c | 1053 +++++++++++++++ .../esp32-camera/sensors/ov5640.c | 1130 +++++++++++++++++ .../esp32-camera/sensors/ov7670.c | 457 +++++++ .../esp32-camera/sensors/ov7725.c | 575 +++++++++ .../sensors/private_include/gc0308.h | 31 + .../sensors/private_include/gc0308_regs.h | 25 + .../sensors/private_include/gc0308_settings.h | 245 ++++ .../sensors/private_include/gc032a.h | 31 + .../sensors/private_include/gc032a_regs.h | 82 ++ .../sensors/private_include/gc032a_settings.h | 401 ++++++ .../sensors/private_include/gc2145.h | 27 + .../sensors/private_include/gc2145_regs.h | 85 ++ .../sensors/private_include/gc2145_settings.h | 719 +++++++++++ .../sensors/private_include/nt99141.h | 34 + .../sensors/private_include/nt99141_regs.h | 211 +++ .../private_include/nt99141_settings.h | 825 ++++++++++++ .../sensors/private_include/ov2640.h | 32 + .../sensors/private_include/ov2640_regs.h | 216 ++++ .../sensors/private_include/ov2640_settings.h | 485 +++++++ .../sensors/private_include/ov3660.h | 34 + .../sensors/private_include/ov3660_regs.h | 211 +++ .../sensors/private_include/ov3660_settings.h | 318 +++++ .../sensors/private_include/ov5640.h | 27 + .../sensors/private_include/ov5640_regs.h | 213 ++++ .../sensors/private_include/ov5640_settings.h | 334 +++++ .../sensors/private_include/ov7670.h | 33 + .../sensors/private_include/ov7670_regs.h | 354 ++++++ .../sensors/private_include/ov7725.h | 33 + .../sensors/private_include/ov7725_regs.h | 335 +++++ .../esp32-camera/target/esp32/ll_cam.c | 522 ++++++++ .../esp32-camera/target/esp32s2/ll_cam.c | 402 ++++++ .../target/esp32s2/private_include/tjpgd.h | 99 ++ .../esp32-camera/target/esp32s2/tjpgd.c | 970 ++++++++++++++ .../esp32-camera/target/esp32s3/ll_cam.c | 452 +++++++ .../target/private_include/ll_cam.h | 141 ++ lib/libesp32_div/esp32-camera/target/xclk.c | 64 + .../esp32-camera/test/CMakeLists.txt | 4 + .../esp32-camera/test/component.mk | 8 + .../test/pictures/test_inside.jpeg | Bin 0 -> 18832 bytes .../test/pictures/test_outside.jpeg | Bin 0 -> 81744 bytes .../esp32-camera/test/pictures/testimg.jpeg | Bin 0 -> 5764 bytes .../esp32-camera/test/test_camera.c | 500 ++++++++ platformio_tasmota_env32.ini | 2 +- tasmota/support_esp.ino | 25 +- tasmota/tasmota.ino | 7 +- tasmota/xdrv_50_filesystem.ino | 52 +- tasmota/xdrv_81_esp32_webcam.ino | 34 +- 82 files changed, 19546 insertions(+), 52 deletions(-) create mode 100644 lib/libesp32_div/esp32-camera/CMakeLists.txt create mode 100644 lib/libesp32_div/esp32-camera/Kconfig create mode 100644 lib/libesp32_div/esp32-camera/LICENSE create mode 100644 lib/libesp32_div/esp32-camera/README.md create mode 100644 lib/libesp32_div/esp32-camera/component.mk create mode 100644 lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c create mode 100644 lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h create mode 100644 lib/libesp32_div/esp32-camera/conversions/include/img_converters.h create mode 100644 lib/libesp32_div/esp32-camera/conversions/jpge.cpp create mode 100644 lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h create mode 100644 lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h create mode 100644 lib/libesp32_div/esp32-camera/conversions/to_bmp.c create mode 100644 lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp create mode 100644 lib/libesp32_div/esp32-camera/conversions/yuv.c create mode 100644 lib/libesp32_div/esp32-camera/driver/cam_hal.c create mode 100644 lib/libesp32_div/esp32-camera/driver/esp_camera.c create mode 100644 lib/libesp32_div/esp32-camera/driver/include/esp_camera.h create mode 100644 lib/libesp32_div/esp32-camera/driver/include/sensor.h create mode 100644 lib/libesp32_div/esp32-camera/driver/private_include/cam_hal.h create mode 100644 lib/libesp32_div/esp32-camera/driver/private_include/sccb.h create mode 100644 lib/libesp32_div/esp32-camera/driver/private_include/xclk.h create mode 100644 lib/libesp32_div/esp32-camera/driver/sccb.c create mode 100644 lib/libesp32_div/esp32-camera/driver/sensor.c create mode 100644 lib/libesp32_div/esp32-camera/examples/CMakeLists.txt create mode 100644 lib/libesp32_div/esp32-camera/examples/Makefile create mode 100644 lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt create mode 100644 lib/libesp32_div/esp32-camera/examples/main/component.mk create mode 100644 lib/libesp32_div/esp32-camera/examples/main/take_picture.c create mode 100644 lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults create mode 100644 lib/libesp32_div/esp32-camera/library.json create mode 100644 lib/libesp32_div/esp32-camera/sensors/gc0308.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/gc032a.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/gc2145.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/nt99141.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/ov2640.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/ov3660.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/ov5640.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/ov7670.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/ov7725.c create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h create mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h create mode 100644 lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c create mode 100644 lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c create mode 100644 lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h create mode 100644 lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c create mode 100644 lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c create mode 100644 lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h create mode 100644 lib/libesp32_div/esp32-camera/target/xclk.c create mode 100644 lib/libesp32_div/esp32-camera/test/CMakeLists.txt create mode 100644 lib/libesp32_div/esp32-camera/test/component.mk create mode 100644 lib/libesp32_div/esp32-camera/test/pictures/test_inside.jpeg create mode 100644 lib/libesp32_div/esp32-camera/test/pictures/test_outside.jpeg create mode 100644 lib/libesp32_div/esp32-camera/test/pictures/testimg.jpeg create mode 100644 lib/libesp32_div/esp32-camera/test/test_camera.c diff --git a/lib/libesp32_div/esp32-camera/CMakeLists.txt b/lib/libesp32_div/esp32-camera/CMakeLists.txt new file mode 100644 index 000000000..5ceec97c0 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/CMakeLists.txt @@ -0,0 +1,64 @@ +if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") + set(COMPONENT_SRCS + driver/esp_camera.c + driver/cam_hal.c + driver/sccb.c + driver/sensor.c + sensors/ov2640.c + sensors/ov3660.c + sensors/ov5640.c + sensors/ov7725.c + sensors/ov7670.c + sensors/nt99141.c + sensors/gc0308.c + sensors/gc2145.c + sensors/gc032a.c + conversions/yuv.c + conversions/to_jpg.cpp + conversions/to_bmp.c + conversions/jpge.cpp + conversions/esp_jpg_decode.c + ) + + set(COMPONENT_ADD_INCLUDEDIRS + driver/include + conversions/include + ) + + set(COMPONENT_PRIV_INCLUDEDIRS + driver/private_include + sensors/private_include + conversions/private_include + target/private_include + ) + + if(IDF_TARGET STREQUAL "esp32") + list(APPEND COMPONENT_SRCS + target/xclk.c + target/esp32/ll_cam.c + ) + endif() + + if(IDF_TARGET STREQUAL "esp32s2") + list(APPEND COMPONENT_SRCS + target/xclk.c + target/esp32s2/ll_cam.c + target/esp32s2/tjpgd.c + ) + + list(APPEND COMPONENT_PRIV_INCLUDEDIRS + target/esp32s2/private_include + ) + endif() + + if(IDF_TARGET STREQUAL "esp32s3") + list(APPEND COMPONENT_SRCS + target/esp32s3/ll_cam.c + ) + endif() + + set(COMPONENT_REQUIRES driver) + set(COMPONENT_PRIV_REQUIRES freertos nvs_flash) + + register_component() +endif() diff --git a/lib/libesp32_div/esp32-camera/Kconfig b/lib/libesp32_div/esp32-camera/Kconfig new file mode 100644 index 000000000..6fb5aad21 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/Kconfig @@ -0,0 +1,114 @@ +menu "Camera configuration" + + config OV7670_SUPPORT + bool "Support OV7670 VGA" + default y + help + Enable this option if you want to use the OV7670. + Disable this option to save memory. + + config OV7725_SUPPORT + bool "Support OV7725 VGA" + default y + help + Enable this option if you want to use the OV7725. + Disable this option to save memory. + + config NT99141_SUPPORT + bool "Support NT99141 HD" + default y + help + Enable this option if you want to use the NT99141. + Disable this option to save memory. + + config OV2640_SUPPORT + bool "Support OV2640 2MP" + default y + help + Enable this option if you want to use the OV2640. + Disable this option to save memory. + + config OV3660_SUPPORT + bool "Support OV3660 3MP" + default y + help + Enable this option if you want to use the OV3360. + Disable this option to save memory. + + config OV5640_SUPPORT + bool "Support OV5640 5MP" + default y + help + Enable this option if you want to use the OV5640. + Disable this option to save memory. + + config GC2145_SUPPORT + bool "Support GC2145 2MP" + default y + help + Enable this option if you want to use the GC2145. + Disable this option to save memory. + + config GC032A_SUPPORT + bool "Support GC032A VGA" + default y + help + Enable this option if you want to use the GC032A. + Disable this option to save memory. + + config GC0308_SUPPORT + bool "Support GC0308 VGA" + default y + help + Enable this option if you want to use the GC0308. + Disable this option to save memory. + + choice SCCB_HARDWARE_I2C_PORT + bool "I2C peripheral to use for SCCB" + default SCCB_HARDWARE_I2C_PORT1 + + config SCCB_HARDWARE_I2C_PORT0 + bool "I2C0" + config SCCB_HARDWARE_I2C_PORT1 + bool "I2C1" + + endchoice + + choice GC_SENSOR_WINDOW_MODE + bool "GalaxyCore Sensor Window Mode" + depends on (GC2145_SUPPORT || GC032A_SUPPORT || GC0308_SUPPORT) + default GC_SENSOR_SUBSAMPLE_MODE + help + This option determines how to reduce the output size when the resolution you set is less than the maximum resolution. + SUBSAMPLE_MODE has a bigger perspective and WINDOWING_MODE has a higher frame rate. + + config GC_SENSOR_WINDOWING_MODE + bool "Windowing Mode" + config GC_SENSOR_SUBSAMPLE_MODE + bool "Subsample Mode" + endchoice + + choice CAMERA_TASK_PINNED_TO_CORE + bool "Camera task pinned to core" + default CAMERA_CORE0 + help + Pin the camera handle task to a certain core(0/1). It can also be done automatically choosing NO_AFFINITY. + + config CAMERA_CORE0 + bool "CORE0" + config CAMERA_CORE1 + bool "CORE1" + config CAMERA_NO_AFFINITY + bool "NO_AFFINITY" + + endchoice + + config CAMERA_DMA_BUFFER_SIZE_MAX + int "DMA buffer size" + range 8192 32768 + default 32768 + help + Maximum value of DMA buffer + Larger values may fail to allocate due to insufficient contiguous memory blocks, and smaller value may cause DMA interrupt to be too frequent + +endmenu diff --git a/lib/libesp32_div/esp32-camera/LICENSE b/lib/libesp32_div/esp32-camera/LICENSE new file mode 100644 index 000000000..d64569567 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/lib/libesp32_div/esp32-camera/README.md b/lib/libesp32_div/esp32-camera/README.md new file mode 100644 index 000000000..e93d5cdba --- /dev/null +++ b/lib/libesp32_div/esp32-camera/README.md @@ -0,0 +1,368 @@ +# ESP32 Camera Driver + +[![Build examples](https://github.com/espressif/esp32-camera/actions/workflows/build.yml/badge.svg)](https://github.com/espressif/esp32-camera/actions/workflows/build.yml) +## General Information + +This repository hosts ESP32 series Soc compatible driver for image sensors. Additionally it provides a few tools, which allow converting the captured frame data to the more common BMP and JPEG formats. + +### Supported Soc + +- ESP32 +- ESP32-S2 +- ESP32-S3 + +### Supported Sensor + +| model | max resolution | color type | output format | Len Size | +| ------- | -------------- | ---------- | ------------------------------------------------------------ | -------- | +| OV2640 | 1600 x 1200 | color | YUV(422/420)/YCbCr422
RGB565/555
8-bit compressed data
8/10-bit Raw RGB data | 1/4" | +| OV3660 | 2048 x 1536 | color | raw RGB data
RGB565/555/444
CCIR656
YCbCr422
compression | 1/5" | +| OV5640 | 2592 x 1944 | color | RAW RGB
RGB565/555/444
CCIR656
YUV422/420
YCbCr422
compression | 1/4" | +| OV7670 | 640 x 480 | color | Raw Bayer RGB
Processed Bayer RGB
YUV/YCbCr422
GRB422
RGB565/555 | 1/6" | +| OV7725 | 640 x 480 | color | Raw RGB
GRB 422
RGB565/555/444
YCbCr 422 | 1/4" | +| NT99141 | 1280 x 720 | color | YCbCr 422
RGB565/555/444
Raw
CCIR656
JPEG compression | 1/4" | +| GC032A | 640 x 480 | color | YUV/YCbCr422
RAW Bayer
RGB565 | 1/10" | +| GC0308 | 640 x 480 | color | YUV/YCbCr422
RAW Bayer
RGB565 | 1/6.5" | +| GC2145 | 1600 x 1200 | color | YUV/YCbCr422
RAW Bayer
RGB565 | 1/5" | + +## Important to Remember + +- Except when using CIF or lower resolution with JPEG, the driver requires PSRAM to be installed and activated. +- Using YUV or RGB puts a lot of strain on the chip because writing to PSRAM is not particularly fast. The result is that image data might be missing. This is particularly true if WiFi is enabled. If you need RGB data, it is recommended that JPEG is captured and then turned into RGB using `fmt2rgb888` or `fmt2bmp`/`frame2bmp`. +- When 1 frame buffer is used, the driver will wait for the current frame to finish (VSYNC) and start I2S DMA. After the frame is acquired, I2S will be stopped and the frame buffer returned to the application. This approach gives more control over the system, but results in longer time to get the frame. +- When 2 or more frame bufers are used, I2S is running in continuous mode and each frame is pushed to a queue that the application can access. This approach puts more strain on the CPU/Memory, but allows for double the frame rate. Please use only with JPEG. + +## Installation Instructions + + +### Using esp-idf + +- Clone or download and extract the repository to the components folder of your ESP-IDF project +- Enable PSRAM in `menuconfig` (also set Flash and PSRAM frequiencies to 80MHz) +- Include `esp_camera.h` in your code + +### Using PlatformIO + +The easy way -- on the `env` section of `platformio.ini`, add the following: + +```ini +[env] +lib_deps = + esp32-camera +``` + +Now the `esp_camera.h` is available to be included: + +```c +#include "esp_camera.h" +``` + +Enable PSRAM on `menuconfig` or type it direclty on `sdkconfig`. Check the [official doc](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-esp32-spiram-support) for more info. + +``` +CONFIG_ESP32_SPIRAM_SUPPORT=y +``` + +***Arduino*** The easy-way (content above) only seems to work if you're using `framework=arduino` which seems to take a bunch of the guesswork out (thanks Arduino!) but also suck up a lot more memory and flash, almost crippling the performance. If you plan to use the `framework=espidf` then read the sections below carefully!! + +## Platform.io lib/submodule (for framework=espidf) + +It's probably easier to just skip the platform.io library registry version and link the git repo as a submodule. (i.e. using code outside the platform.io library management). In this example we will install this as a submodule inside the platform.io $project/lib folder: +``` +cd $project\lib +git submodule add -b master https://github.com/espressif/esp32-camera.git +``` + +Then in `platformio.ini` file +``` +build_flags = + -I../lib/esp32-camera +``` +After that `#include "esp_camera.h"` statement will be available. Now the module is included, and you're hopefully back to the same place as the easy-Arduino way. + +**Warning about platform.io/espidf and fresh (not initialized) git repos** +There is a sharp-edge on you'll discover in the platform.io build process (in espidf v3.3 & 4.0.1) where a project which has only had `git init` but nothing committed will crash platform.io build process with highly non-useful output. The cause is due to lack of a version (making you think you did something wrong, when you didn't at all) - the output is horribly non-descript. Solution: the devs want you to create a file called version.txt with a number in it, or simply commit any file to the projects git repo and use git. This happens because platform.io build process tries to be too clever and determine the build version number from the git repo - it's a sharp edge you'll only encounter if you're experimenting on a new project with no commits .. like wtf is my camera not working let's try a 'clean project'?! + +## Platform.io Kconfig +Kconfig is used by the platform.io menuconfig (accessed by running: `pio run -t menuconfig`) to interactively manage the various #ifdef statements throughout the espidf and supporting libraries (i.e. this repo: esp32-camera and arduino-esp32.git). The menuconfig process generates the `sdkconfig` file which is ultimately used behind the scenes by espidf compile+build process. + +**Make sure to append or symlink** [this `Kconfig`](./Kconfig) content into the `Kconfig` of your project. + +You symlink (or copy) the included Kconfig into your platform.io projects src directory. The file should be named `Kconfig.projbuild` in your projects src\ directory or you could also add the library path to a CMakefile.txt and hope the `Kconfig` (or `Kconfig.projbuild`) gets discovered by the menuconfig process, though this unpredictable for me. + +The unpredictable wonky behavior in platform.io build process around Kconfig naming (Kconfig vs. Kconfig.projbuild) occurs between espidf versions 3.3 and 4.0 - but if you don't see "Camera configuration" in your `pio run -t menuconfig` then there is no point trying to test camera code (it may compile, but it probably won't work!) and it seems the platform.io devs (when they built their wrapper around the espidf menuconfig) didn't implement it properly. You've probably already figured out you can't use the espidf build tools since the files are in totally different locations and also different versions with sometimes different syntax. This is one of those times you might consider changing the `platformio.ini` from `platform=espressif32` to `platform=https://github.com/platformio/platform-espressif32.git#develop` to get a more recent version of the espidf 4.0 tools. + +However with a bit of patience and experimenting you'll figure the Kconfig out. Once Kconfig (or Kconfig.projbuild) is working then you will be able to choose the configurations according to your setup or the camera libraries will be compiled. Although you might also need to delete your .pio/build directory before the options appear .. again, the `pio run -t menuconfig` doens't always notice the new Kconfig files! + +If you miss-skip-ignore this critical step the camera module will compile but camera logic inside the library will be 'empty' because the Kconfig sets the proper #ifdef statements during the build process to initialize the selected cameras. It's very not optional! + + +## Examples + +### Initialization + +```c +#include "esp_camera.h" + +//WROVER-KIT PIN Map +#define CAM_PIN_PWDN -1 //power down is not used +#define CAM_PIN_RESET -1 //software reset will be performed +#define CAM_PIN_XCLK 21 +#define CAM_PIN_SIOD 26 +#define CAM_PIN_SIOC 27 + +#define CAM_PIN_D7 35 +#define CAM_PIN_D6 34 +#define CAM_PIN_D5 39 +#define CAM_PIN_D4 36 +#define CAM_PIN_D3 19 +#define CAM_PIN_D2 18 +#define CAM_PIN_D1 5 +#define CAM_PIN_D0 4 +#define CAM_PIN_VSYNC 25 +#define CAM_PIN_HREF 23 +#define CAM_PIN_PCLK 22 + +static camera_config_t camera_config = { + .pin_pwdn = CAM_PIN_PWDN, + .pin_reset = CAM_PIN_RESET, + .pin_xclk = CAM_PIN_XCLK, + .pin_sscb_sda = CAM_PIN_SIOD, + .pin_sscb_scl = CAM_PIN_SIOC, + + .pin_d7 = CAM_PIN_D7, + .pin_d6 = CAM_PIN_D6, + .pin_d5 = CAM_PIN_D5, + .pin_d4 = CAM_PIN_D4, + .pin_d3 = CAM_PIN_D3, + .pin_d2 = CAM_PIN_D2, + .pin_d1 = CAM_PIN_D1, + .pin_d0 = CAM_PIN_D0, + .pin_vsync = CAM_PIN_VSYNC, + .pin_href = CAM_PIN_HREF, + .pin_pclk = CAM_PIN_PCLK, + + .xclk_freq_hz = 20000000,//EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_JPEG,//YUV422,GRAYSCALE,RGB565,JPEG + .frame_size = FRAMESIZE_UXGA,//QQVGA-QXGA Do not use sizes above QVGA when not JPEG + + .jpeg_quality = 12, //0-63 lower number means higher quality + .fb_count = 1, //if more than one, i2s runs in continuous mode. Use only with JPEG + .grab_mode = CAMERA_GRAB_WHEN_EMPTY//CAMERA_GRAB_LATEST. Sets when buffers should be filled +}; + +esp_err_t camera_init(){ + //power up the camera if PWDN pin is defined + if(CAM_PIN_PWDN != -1){ + pinMode(CAM_PIN_PWDN, OUTPUT); + digitalWrite(CAM_PIN_PWDN, LOW); + } + + //initialize the camera + esp_err_t err = esp_camera_init(&camera_config); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Camera Init Failed"); + return err; + } + + return ESP_OK; +} + +esp_err_t camera_capture(){ + //acquire a frame + camera_fb_t * fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAG, "Camera Capture Failed"); + return ESP_FAIL; + } + //replace this with your own function + process_image(fb->width, fb->height, fb->format, fb->buf, fb->len); + + //return the frame buffer back to the driver for reuse + esp_camera_fb_return(fb); + return ESP_OK; +} +``` + +### JPEG HTTP Capture + +```c +#include "esp_camera.h" +#include "esp_http_server.h" +#include "esp_timer.h" + +typedef struct { + httpd_req_t *req; + size_t len; +} jpg_chunking_t; + +static size_t jpg_encode_stream(void * arg, size_t index, const void* data, size_t len){ + jpg_chunking_t *j = (jpg_chunking_t *)arg; + if(!index){ + j->len = 0; + } + if(httpd_resp_send_chunk(j->req, (const char *)data, len) != ESP_OK){ + return 0; + } + j->len += len; + return len; +} + +esp_err_t jpg_httpd_handler(httpd_req_t *req){ + camera_fb_t * fb = NULL; + esp_err_t res = ESP_OK; + size_t fb_len = 0; + int64_t fr_start = esp_timer_get_time(); + + fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAG, "Camera capture failed"); + httpd_resp_send_500(req); + return ESP_FAIL; + } + res = httpd_resp_set_type(req, "image/jpeg"); + if(res == ESP_OK){ + res = httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.jpg"); + } + + if(res == ESP_OK){ + if(fb->format == PIXFORMAT_JPEG){ + fb_len = fb->len; + res = httpd_resp_send(req, (const char *)fb->buf, fb->len); + } else { + jpg_chunking_t jchunk = {req, 0}; + res = frame2jpg_cb(fb, 80, jpg_encode_stream, &jchunk)?ESP_OK:ESP_FAIL; + httpd_resp_send_chunk(req, NULL, 0); + fb_len = jchunk.len; + } + } + esp_camera_fb_return(fb); + int64_t fr_end = esp_timer_get_time(); + ESP_LOGI(TAG, "JPG: %uKB %ums", (uint32_t)(fb_len/1024), (uint32_t)((fr_end - fr_start)/1000)); + return res; +} +``` + +### JPEG HTTP Stream + +```c +#include "esp_camera.h" +#include "esp_http_server.h" +#include "esp_timer.h" + +#define PART_BOUNDARY "123456789000000000000987654321" +static const char* _STREAM_CONTENT_TYPE = "multipart/x-mixed-replace;boundary=" PART_BOUNDARY; +static const char* _STREAM_BOUNDARY = "\r\n--" PART_BOUNDARY "\r\n"; +static const char* _STREAM_PART = "Content-Type: image/jpeg\r\nContent-Length: %u\r\n\r\n"; + +esp_err_t jpg_stream_httpd_handler(httpd_req_t *req){ + camera_fb_t * fb = NULL; + esp_err_t res = ESP_OK; + size_t _jpg_buf_len; + uint8_t * _jpg_buf; + char * part_buf[64]; + static int64_t last_frame = 0; + if(!last_frame) { + last_frame = esp_timer_get_time(); + } + + res = httpd_resp_set_type(req, _STREAM_CONTENT_TYPE); + if(res != ESP_OK){ + return res; + } + + while(true){ + fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAG, "Camera capture failed"); + res = ESP_FAIL; + break; + } + if(fb->format != PIXFORMAT_JPEG){ + bool jpeg_converted = frame2jpg(fb, 80, &_jpg_buf, &_jpg_buf_len); + if(!jpeg_converted){ + ESP_LOGE(TAG, "JPEG compression failed"); + esp_camera_fb_return(fb); + res = ESP_FAIL; + } + } else { + _jpg_buf_len = fb->len; + _jpg_buf = fb->buf; + } + + if(res == ESP_OK){ + res = httpd_resp_send_chunk(req, _STREAM_BOUNDARY, strlen(_STREAM_BOUNDARY)); + } + if(res == ESP_OK){ + size_t hlen = snprintf((char *)part_buf, 64, _STREAM_PART, _jpg_buf_len); + + res = httpd_resp_send_chunk(req, (const char *)part_buf, hlen); + } + if(res == ESP_OK){ + res = httpd_resp_send_chunk(req, (const char *)_jpg_buf, _jpg_buf_len); + } + if(fb->format != PIXFORMAT_JPEG){ + free(_jpg_buf); + } + esp_camera_fb_return(fb); + if(res != ESP_OK){ + break; + } + int64_t fr_end = esp_timer_get_time(); + int64_t frame_time = fr_end - last_frame; + last_frame = fr_end; + frame_time /= 1000; + ESP_LOGI(TAG, "MJPG: %uKB %ums (%.1ffps)", + (uint32_t)(_jpg_buf_len/1024), + (uint32_t)frame_time, 1000.0 / (uint32_t)frame_time); + } + + last_frame = 0; + return res; +} +``` + +### BMP HTTP Capture + +```c +#include "esp_camera.h" +#include "esp_http_server.h" +#include "esp_timer.h" + +esp_err_t bmp_httpd_handler(httpd_req_t *req){ + camera_fb_t * fb = NULL; + esp_err_t res = ESP_OK; + int64_t fr_start = esp_timer_get_time(); + + fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAG, "Camera capture failed"); + httpd_resp_send_500(req); + return ESP_FAIL; + } + + uint8_t * buf = NULL; + size_t buf_len = 0; + bool converted = frame2bmp(fb, &buf, &buf_len); + esp_camera_fb_return(fb); + if(!converted){ + ESP_LOGE(TAG, "BMP conversion failed"); + httpd_resp_send_500(req); + return ESP_FAIL; + } + + res = httpd_resp_set_type(req, "image/x-windows-bmp") + || httpd_resp_set_hdr(req, "Content-Disposition", "inline; filename=capture.bmp") + || httpd_resp_send(req, (const char *)buf, buf_len); + free(buf); + int64_t fr_end = esp_timer_get_time(); + ESP_LOGI(TAG, "BMP: %uKB %ums", (uint32_t)(buf_len/1024), (uint32_t)((fr_end - fr_start)/1000)); + return res; +} +``` + + + diff --git a/lib/libesp32_div/esp32-camera/component.mk b/lib/libesp32_div/esp32-camera/component.mk new file mode 100644 index 000000000..8db15eb88 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/component.mk @@ -0,0 +1,4 @@ +COMPONENT_ADD_INCLUDEDIRS := driver/include conversions/include +COMPONENT_PRIV_INCLUDEDIRS := driver/private_include conversions/private_include sensors/private_include target/private_include +COMPONENT_SRCDIRS := driver conversions sensors target target/esp32 +CXXFLAGS += -fno-rtti diff --git a/lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c b/lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c new file mode 100644 index 000000000..a9615e36c --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c @@ -0,0 +1,132 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "esp_jpg_decode.h" + +#include "esp_system.h" +#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 +#include "esp32/rom/tjpgd.h" +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "tjpgd.h" +#elif CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/rom/tjpgd.h" +#else +#error Target CONFIG_IDF_TARGET is not supported +#endif +#else // ESP32 Before IDF 4.0 +#include "rom/tjpgd.h" +#endif + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#define TAG "" +#else +#include "esp_log.h" +static const char* TAG = "esp_jpg_decode"; +#endif + +typedef struct { + jpg_scale_t scale; + jpg_reader_cb reader; + jpg_writer_cb writer; + void * arg; + size_t len; + size_t index; +} esp_jpg_decoder_t; + +static const char * jd_errors[] = { + "Succeeded", + "Interrupted by output function", + "Device error or wrong termination of input stream", + "Insufficient memory pool for the image", + "Insufficient stream input buffer", + "Parameter error", + "Data format error", + "Right format but not supported", + "Not supported JPEG standard" +}; + +static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) +{ + uint16_t x = rect->left; + uint16_t y = rect->top; + uint16_t w = rect->right + 1 - x; + uint16_t h = rect->bottom + 1 - y; + uint8_t *data = (uint8_t *)bitmap; + + esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; + + if (jpeg->writer) { + return jpeg->writer(jpeg->arg, x, y, w, h, data); + } + return 0; +} + +static uint32_t _jpg_read(JDEC *decoder, uint8_t *buf, uint32_t len) +{ + esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; + if (jpeg->len && len > (jpeg->len - jpeg->index)) { + len = jpeg->len - jpeg->index; + } + if (len) { + len = jpeg->reader(jpeg->arg, jpeg->index, buf, len); + if (!len) { + ESP_LOGE(TAG, "Read Fail at %u/%u", jpeg->index, jpeg->len); + } + jpeg->index += len; + } + return len; +} + +esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg) +{ + static uint8_t work[3100]; + JDEC decoder; + esp_jpg_decoder_t jpeg; + + jpeg.len = len; + jpeg.reader = reader; + jpeg.writer = writer; + jpeg.arg = arg; + jpeg.scale = scale; + jpeg.index = 0; + + JRESULT jres = jd_prepare(&decoder, _jpg_read, work, 3100, &jpeg); + if(jres != JDR_OK){ + ESP_LOGE(TAG, "JPG Header Parse Failed! %s", jd_errors[jres]); + return ESP_FAIL; + } + + uint16_t output_width = decoder.width / (1 << (uint8_t)(jpeg.scale)); + uint16_t output_height = decoder.height / (1 << (uint8_t)(jpeg.scale)); + + //output start + writer(arg, 0, 0, output_width, output_height, NULL); + //output write + jres = jd_decomp(&decoder, _jpg_write, (uint8_t)jpeg.scale); + //output end + writer(arg, output_width, output_height, output_width, output_height, NULL); + + if (jres != JDR_OK) { + ESP_LOGE(TAG, "JPG Decompression Failed! %s", jd_errors[jres]); + return ESP_FAIL; + } + //check if all data has been consumed. + if (len && jpeg.index < len) { + _jpg_read(&decoder, NULL, len - jpeg.index); + } + + return ESP_OK; +} + diff --git a/lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h b/lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h new file mode 100644 index 000000000..f13536edf --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h @@ -0,0 +1,43 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef _ESP_JPG_DECODE_H_ +#define _ESP_JPG_DECODE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "esp_err.h" + +typedef enum { + JPG_SCALE_NONE, + JPG_SCALE_2X, + JPG_SCALE_4X, + JPG_SCALE_8X, + JPG_SCALE_MAX = JPG_SCALE_8X +} jpg_scale_t; + +typedef size_t (* jpg_reader_cb)(void * arg, size_t index, uint8_t *buf, size_t len); +typedef bool (* jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data); + +esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg); + +#ifdef __cplusplus +} +#endif + +#endif /* _ESP_JPG_DECODE_H_ */ diff --git a/lib/libesp32_div/esp32-camera/conversions/include/img_converters.h b/lib/libesp32_div/esp32-camera/conversions/include/img_converters.h new file mode 100644 index 000000000..f736200a9 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/include/img_converters.h @@ -0,0 +1,130 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef _IMG_CONVERTERS_H_ +#define _IMG_CONVERTERS_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include "esp_camera.h" +#include "esp_jpg_decode.h" + +typedef size_t (* jpg_out_cb)(void * arg, size_t index, const void* data, size_t len); + +/** + * @brief Convert image buffer to JPEG + * + * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param width Width in pixels of the source image + * @param height Height in pixels of the source image + * @param format Format of the source image + * @param quality JPEG quality of the resulting image + * @param cp Callback to be called to write the bytes of the output JPEG + * @param arg Pointer to be passed to the callback + * + * @return true on success + */ +bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg); + +/** + * @brief Convert camera frame buffer to JPEG + * + * @param fb Source camera frame buffer + * @param quality JPEG quality of the resulting image + * @param cp Callback to be called to write the bytes of the output JPEG + * @param arg Pointer to be passed to the callback + * + * @return true on success + */ +bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg); + +/** + * @brief Convert image buffer to JPEG buffer + * + * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param width Width in pixels of the source image + * @param height Height in pixels of the source image + * @param format Format of the source image + * @param quality JPEG quality of the resulting image + * @param out Pointer to be populated with the address of the resulting buffer. + * You MUST free the pointer once you are done with it. + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert camera frame buffer to JPEG buffer + * + * @param fb Source camera frame buffer + * @param quality JPEG quality of the resulting image + * @param out Pointer to be populated with the address of the resulting buffer + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert image buffer to BMP buffer + * + * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param width Width in pixels of the source image + * @param height Height in pixels of the source image + * @param format Format of the source image + * @param out Pointer to be populated with the address of the resulting buffer + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert camera frame buffer to BMP buffer + * + * @param fb Source camera frame buffer + * @param out Pointer to be populated with the address of the resulting buffer + * @param out_len Pointer to be populated with the length of the output buffer + * + * @return true on success + */ +bool frame2bmp(camera_fb_t * fb, uint8_t ** out, size_t * out_len); + +/** + * @brief Convert image buffer to RGB888 buffer (used for face detection) + * + * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format + * @param src_len Length in bytes of the source buffer + * @param format Format of the source image + * @param rgb_buf Pointer to the output buffer (width * height * 3) + * + * @return true on success + */ +bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf); + +bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale); + +#ifdef __cplusplus +} +#endif + +#endif /* _IMG_CONVERTERS_H_ */ diff --git a/lib/libesp32_div/esp32-camera/conversions/jpge.cpp b/lib/libesp32_div/esp32-camera/conversions/jpge.cpp new file mode 100644 index 000000000..a8ab93e02 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/jpge.cpp @@ -0,0 +1,723 @@ +// jpge.cpp - C++ class for JPEG compression. +// Public domain, Rich Geldreich +// v1.01, Dec. 18, 2010 - Initial release +// v1.02, Apr. 6, 2011 - Removed 2x2 ordered dither in H2V1 chroma subsampling method load_block_16_8_8(). (The rounding factor was 2, when it should have been 1. Either way, it wasn't helping.) +// v1.03, Apr. 16, 2011 - Added support for optimized Huffman code tables, optimized dynamic memory allocation down to only 1 alloc. +// Also from Alex Evans: Added RGBA support, linear memory allocator (no longer needed in v1.03). +// v1.04, May. 19, 2012: Forgot to set m_pFile ptr to NULL in cfile_stream::close(). Thanks to Owen Kaluza for reporting this bug. +// Code tweaks to fix VS2008 static code analysis warnings (all looked harmless). +// Code review revealed method load_block_16_8_8() (used for the non-default H2V1 sampling mode to downsample chroma) somehow didn't get the rounding factor fix from v1.02. + +#include "jpge.h" + +#include +#include +#include +#include +#include +#include +#include +#include "esp_heap_caps.h" + +#define JPGE_MAX(a,b) (((a)>(b))?(a):(b)) +#define JPGE_MIN(a,b) (((a)<(b))?(a):(b)) + +namespace jpge { + + static inline void *jpge_malloc(size_t nSize) { + void * b = malloc(nSize); + if(b){ + return b; + } + return heap_caps_malloc(nSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); + } + static inline void jpge_free(void *p) { free(p); } + + // Various JPEG enums and tables. + enum { M_SOF0 = 0xC0, M_DHT = 0xC4, M_SOI = 0xD8, M_EOI = 0xD9, M_SOS = 0xDA, M_DQT = 0xDB, M_APP0 = 0xE0 }; + enum { DC_LUM_CODES = 12, AC_LUM_CODES = 256, DC_CHROMA_CODES = 12, AC_CHROMA_CODES = 256, MAX_HUFF_SYMBOLS = 257, MAX_HUFF_CODESIZE = 32 }; + + static const uint8 s_zag[64] = { 0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63 }; + static const int16 s_std_lum_quant[64] = { 16,11,12,14,12,10,16,14,13,14,18,17,16,19,24,40,26,24,22,22,24,49,35,37,29,40,58,51,61,60,57,51,56,55,64,72,92,78,64,68,87,69,55,56,80,109,81,87,95,98,103,104,103,62,77,113,121,112,100,120,92,101,103,99 }; + static const int16 s_std_croma_quant[64] = { 17,18,18,24,21,24,47,26,26,47,99,66,56,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 }; + static const uint8 s_dc_lum_bits[17] = { 0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0 }; + static const uint8 s_dc_lum_val[DC_LUM_CODES] = { 0,1,2,3,4,5,6,7,8,9,10,11 }; + static const uint8 s_ac_lum_bits[17] = { 0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d }; + static const uint8 s_ac_lum_val[AC_LUM_CODES] = { + 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 + }; + static const uint8 s_dc_chroma_bits[17] = { 0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0 }; + static const uint8 s_dc_chroma_val[DC_CHROMA_CODES] = { 0,1,2,3,4,5,6,7,8,9,10,11 }; + static const uint8 s_ac_chroma_bits[17] = { 0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77 }; + static const uint8 s_ac_chroma_val[AC_CHROMA_CODES] = { + 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 + }; + + const int YR = 19595, YG = 38470, YB = 7471, CB_R = -11059, CB_G = -21709, CB_B = 32768, CR_R = 32768, CR_G = -27439, CR_B = -5329; + + static int32 m_last_quality = 0; + static int32 m_quantization_tables[2][64]; + + static bool m_huff_initialized = false; + static uint m_huff_codes[4][256]; + static uint8 m_huff_code_sizes[4][256]; + static uint8 m_huff_bits[4][17]; + static uint8 m_huff_val[4][256]; + + static inline uint8 clamp(int i) { + if (i < 0) { + i = 0; + } else if (i > 255){ + i = 255; + } + return static_cast(i); + } + + static void RGB_to_YCC(uint8* pDst, const uint8 *pSrc, int num_pixels) { + for ( ; num_pixels; pDst += 3, pSrc += 3, num_pixels--) { + const int r = pSrc[0], g = pSrc[1], b = pSrc[2]; + pDst[0] = static_cast((r * YR + g * YG + b * YB + 32768) >> 16); + pDst[1] = clamp(128 + ((r * CB_R + g * CB_G + b * CB_B + 32768) >> 16)); + pDst[2] = clamp(128 + ((r * CR_R + g * CR_G + b * CR_B + 32768) >> 16)); + } + } + + static void RGB_to_Y(uint8* pDst, const uint8 *pSrc, int num_pixels) { + for ( ; num_pixels; pDst++, pSrc += 3, num_pixels--) { + pDst[0] = static_cast((pSrc[0] * YR + pSrc[1] * YG + pSrc[2] * YB + 32768) >> 16); + } + } + + static void Y_to_YCC(uint8* pDst, const uint8* pSrc, int num_pixels) { + for( ; num_pixels; pDst += 3, pSrc++, num_pixels--) { + pDst[0] = pSrc[0]; + pDst[1] = 128; + pDst[2] = 128; + } + } + + // Forward DCT - DCT derived from jfdctint. + enum { CONST_BITS = 13, ROW_BITS = 2 }; +#define DCT_DESCALE(x, n) (((x) + (((int32)1) << ((n) - 1))) >> (n)) +#define DCT_MUL(var, c) (static_cast(var) * static_cast(c)) +#define DCT1D(s0, s1, s2, s3, s4, s5, s6, s7) \ + int32 t0 = s0 + s7, t7 = s0 - s7, t1 = s1 + s6, t6 = s1 - s6, t2 = s2 + s5, t5 = s2 - s5, t3 = s3 + s4, t4 = s3 - s4; \ + int32 t10 = t0 + t3, t13 = t0 - t3, t11 = t1 + t2, t12 = t1 - t2; \ + int32 u1 = DCT_MUL(t12 + t13, 4433); \ + s2 = u1 + DCT_MUL(t13, 6270); \ + s6 = u1 + DCT_MUL(t12, -15137); \ + u1 = t4 + t7; \ + int32 u2 = t5 + t6, u3 = t4 + t6, u4 = t5 + t7; \ + int32 z5 = DCT_MUL(u3 + u4, 9633); \ + t4 = DCT_MUL(t4, 2446); t5 = DCT_MUL(t5, 16819); \ + t6 = DCT_MUL(t6, 25172); t7 = DCT_MUL(t7, 12299); \ + u1 = DCT_MUL(u1, -7373); u2 = DCT_MUL(u2, -20995); \ + u3 = DCT_MUL(u3, -16069); u4 = DCT_MUL(u4, -3196); \ + u3 += z5; u4 += z5; \ + s0 = t10 + t11; s1 = t7 + u1 + u4; s3 = t6 + u2 + u3; s4 = t10 - t11; s5 = t5 + u2 + u4; s7 = t4 + u1 + u3; + + static void DCT2D(int32 *p) { + int32 c, *q = p; + for (c = 7; c >= 0; c--, q += 8) { + int32 s0 = q[0], s1 = q[1], s2 = q[2], s3 = q[3], s4 = q[4], s5 = q[5], s6 = q[6], s7 = q[7]; + DCT1D(s0, s1, s2, s3, s4, s5, s6, s7); + q[0] = s0 << ROW_BITS; q[1] = DCT_DESCALE(s1, CONST_BITS-ROW_BITS); q[2] = DCT_DESCALE(s2, CONST_BITS-ROW_BITS); q[3] = DCT_DESCALE(s3, CONST_BITS-ROW_BITS); + q[4] = s4 << ROW_BITS; q[5] = DCT_DESCALE(s5, CONST_BITS-ROW_BITS); q[6] = DCT_DESCALE(s6, CONST_BITS-ROW_BITS); q[7] = DCT_DESCALE(s7, CONST_BITS-ROW_BITS); + } + for (q = p, c = 7; c >= 0; c--, q++) { + int32 s0 = q[0*8], s1 = q[1*8], s2 = q[2*8], s3 = q[3*8], s4 = q[4*8], s5 = q[5*8], s6 = q[6*8], s7 = q[7*8]; + DCT1D(s0, s1, s2, s3, s4, s5, s6, s7); + q[0*8] = DCT_DESCALE(s0, ROW_BITS+3); q[1*8] = DCT_DESCALE(s1, CONST_BITS+ROW_BITS+3); q[2*8] = DCT_DESCALE(s2, CONST_BITS+ROW_BITS+3); q[3*8] = DCT_DESCALE(s3, CONST_BITS+ROW_BITS+3); + q[4*8] = DCT_DESCALE(s4, ROW_BITS+3); q[5*8] = DCT_DESCALE(s5, CONST_BITS+ROW_BITS+3); q[6*8] = DCT_DESCALE(s6, CONST_BITS+ROW_BITS+3); q[7*8] = DCT_DESCALE(s7, CONST_BITS+ROW_BITS+3); + } + } + + // Compute the actual canonical Huffman codes/code sizes given the JPEG huff bits and val arrays. + static void compute_huffman_table(uint *codes, uint8 *code_sizes, uint8 *bits, uint8 *val) + { + int i, l, last_p, si; + static uint8 huff_size[257]; + static uint huff_code[257]; + uint code; + + int p = 0; + for (l = 1; l <= 16; l++) { + for (i = 1; i <= bits[l]; i++) { + huff_size[p++] = (char)l; + } + } + + huff_size[p] = 0; + last_p = p; // write sentinel + + code = 0; si = huff_size[0]; p = 0; + + while (huff_size[p]) { + while (huff_size[p] == si) { + huff_code[p++] = code++; + } + code <<= 1; + si++; + } + + memset(codes, 0, sizeof(codes[0])*256); + memset(code_sizes, 0, sizeof(code_sizes[0])*256); + for (p = 0; p < last_p; p++) { + codes[val[p]] = huff_code[p]; + code_sizes[val[p]] = huff_size[p]; + } + } + + void jpeg_encoder::flush_output_buffer() + { + if (m_out_buf_left != JPGE_OUT_BUF_SIZE) { + m_all_stream_writes_succeeded = m_all_stream_writes_succeeded && m_pStream->put_buf(m_out_buf, JPGE_OUT_BUF_SIZE - m_out_buf_left); + } + m_pOut_buf = m_out_buf; + m_out_buf_left = JPGE_OUT_BUF_SIZE; + } + + void jpeg_encoder::emit_byte(uint8 i) + { + *m_pOut_buf++ = i; + if (--m_out_buf_left == 0) { + flush_output_buffer(); + } + } + + void jpeg_encoder::put_bits(uint bits, uint len) + { + uint8 c = 0; + m_bit_buffer |= ((uint32)bits << (24 - (m_bits_in += len))); + while (m_bits_in >= 8) { + c = (uint8)((m_bit_buffer >> 16) & 0xFF); + emit_byte(c); + if (c == 0xFF) { + emit_byte(0); + } + m_bit_buffer <<= 8; + m_bits_in -= 8; + } + } + + void jpeg_encoder::emit_word(uint i) + { + emit_byte(uint8(i >> 8)); emit_byte(uint8(i & 0xFF)); + } + + // JPEG marker generation. + void jpeg_encoder::emit_marker(int marker) + { + emit_byte(uint8(0xFF)); emit_byte(uint8(marker)); + } + + // Emit JFIF marker + void jpeg_encoder::emit_jfif_app0() + { + emit_marker(M_APP0); + emit_word(2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); + emit_byte(0x4A); emit_byte(0x46); emit_byte(0x49); emit_byte(0x46); /* Identifier: ASCII "JFIF" */ + emit_byte(0); + emit_byte(1); /* Major version */ + emit_byte(1); /* Minor version */ + emit_byte(0); /* Density unit */ + emit_word(1); + emit_word(1); + emit_byte(0); /* No thumbnail image */ + emit_byte(0); + } + + // Emit quantization tables + void jpeg_encoder::emit_dqt() + { + for (int i = 0; i < ((m_num_components == 3) ? 2 : 1); i++) + { + emit_marker(M_DQT); + emit_word(64 + 1 + 2); + emit_byte(static_cast(i)); + for (int j = 0; j < 64; j++) + emit_byte(static_cast(m_quantization_tables[i][j])); + } + } + + // Emit start of frame marker + void jpeg_encoder::emit_sof() + { + emit_marker(M_SOF0); /* baseline */ + emit_word(3 * m_num_components + 2 + 5 + 1); + emit_byte(8); /* precision */ + emit_word(m_image_y); + emit_word(m_image_x); + emit_byte(m_num_components); + for (int i = 0; i < m_num_components; i++) + { + emit_byte(static_cast(i + 1)); /* component ID */ + emit_byte((m_comp_h_samp[i] << 4) + m_comp_v_samp[i]); /* h and v sampling */ + emit_byte(i > 0); /* quant. table num */ + } + } + + // Emit Huffman table. + void jpeg_encoder::emit_dht(uint8 *bits, uint8 *val, int index, bool ac_flag) + { + emit_marker(M_DHT); + + int length = 0; + for (int i = 1; i <= 16; i++) + length += bits[i]; + + emit_word(length + 2 + 1 + 16); + emit_byte(static_cast(index + (ac_flag << 4))); + + for (int i = 1; i <= 16; i++) + emit_byte(bits[i]); + + for (int i = 0; i < length; i++) + emit_byte(val[i]); + } + + // Emit all Huffman tables. + void jpeg_encoder::emit_dhts() + { + emit_dht(m_huff_bits[0+0], m_huff_val[0+0], 0, false); + emit_dht(m_huff_bits[2+0], m_huff_val[2+0], 0, true); + if (m_num_components == 3) { + emit_dht(m_huff_bits[0+1], m_huff_val[0+1], 1, false); + emit_dht(m_huff_bits[2+1], m_huff_val[2+1], 1, true); + } + } + + // emit start of scan + void jpeg_encoder::emit_sos() + { + emit_marker(M_SOS); + emit_word(2 * m_num_components + 2 + 1 + 3); + emit_byte(m_num_components); + for (int i = 0; i < m_num_components; i++) + { + emit_byte(static_cast(i + 1)); + if (i == 0) + emit_byte((0 << 4) + 0); + else + emit_byte((1 << 4) + 1); + } + emit_byte(0); /* spectral selection */ + emit_byte(63); + emit_byte(0); + } + + void jpeg_encoder::load_block_8_8_grey(int x) + { + uint8 *pSrc; + sample_array_t *pDst = m_sample_array; + x <<= 3; + for (int i = 0; i < 8; i++, pDst += 8) + { + pSrc = m_mcu_lines[i] + x; + pDst[0] = pSrc[0] - 128; pDst[1] = pSrc[1] - 128; pDst[2] = pSrc[2] - 128; pDst[3] = pSrc[3] - 128; + pDst[4] = pSrc[4] - 128; pDst[5] = pSrc[5] - 128; pDst[6] = pSrc[6] - 128; pDst[7] = pSrc[7] - 128; + } + } + + void jpeg_encoder::load_block_8_8(int x, int y, int c) + { + uint8 *pSrc; + sample_array_t *pDst = m_sample_array; + x = (x * (8 * 3)) + c; + y <<= 3; + for (int i = 0; i < 8; i++, pDst += 8) + { + pSrc = m_mcu_lines[y + i] + x; + pDst[0] = pSrc[0 * 3] - 128; pDst[1] = pSrc[1 * 3] - 128; pDst[2] = pSrc[2 * 3] - 128; pDst[3] = pSrc[3 * 3] - 128; + pDst[4] = pSrc[4 * 3] - 128; pDst[5] = pSrc[5 * 3] - 128; pDst[6] = pSrc[6 * 3] - 128; pDst[7] = pSrc[7 * 3] - 128; + } + } + + void jpeg_encoder::load_block_16_8(int x, int c) + { + uint8 *pSrc1, *pSrc2; + sample_array_t *pDst = m_sample_array; + x = (x * (16 * 3)) + c; + int a = 0, b = 2; + for (int i = 0; i < 16; i += 2, pDst += 8) + { + pSrc1 = m_mcu_lines[i + 0] + x; + pSrc2 = m_mcu_lines[i + 1] + x; + pDst[0] = ((pSrc1[ 0 * 3] + pSrc1[ 1 * 3] + pSrc2[ 0 * 3] + pSrc2[ 1 * 3] + a) >> 2) - 128; pDst[1] = ((pSrc1[ 2 * 3] + pSrc1[ 3 * 3] + pSrc2[ 2 * 3] + pSrc2[ 3 * 3] + b) >> 2) - 128; + pDst[2] = ((pSrc1[ 4 * 3] + pSrc1[ 5 * 3] + pSrc2[ 4 * 3] + pSrc2[ 5 * 3] + a) >> 2) - 128; pDst[3] = ((pSrc1[ 6 * 3] + pSrc1[ 7 * 3] + pSrc2[ 6 * 3] + pSrc2[ 7 * 3] + b) >> 2) - 128; + pDst[4] = ((pSrc1[ 8 * 3] + pSrc1[ 9 * 3] + pSrc2[ 8 * 3] + pSrc2[ 9 * 3] + a) >> 2) - 128; pDst[5] = ((pSrc1[10 * 3] + pSrc1[11 * 3] + pSrc2[10 * 3] + pSrc2[11 * 3] + b) >> 2) - 128; + pDst[6] = ((pSrc1[12 * 3] + pSrc1[13 * 3] + pSrc2[12 * 3] + pSrc2[13 * 3] + a) >> 2) - 128; pDst[7] = ((pSrc1[14 * 3] + pSrc1[15 * 3] + pSrc2[14 * 3] + pSrc2[15 * 3] + b) >> 2) - 128; + int temp = a; a = b; b = temp; + } + } + + void jpeg_encoder::load_block_16_8_8(int x, int c) + { + uint8 *pSrc1; + sample_array_t *pDst = m_sample_array; + x = (x * (16 * 3)) + c; + for (int i = 0; i < 8; i++, pDst += 8) + { + pSrc1 = m_mcu_lines[i + 0] + x; + pDst[0] = ((pSrc1[ 0 * 3] + pSrc1[ 1 * 3]) >> 1) - 128; pDst[1] = ((pSrc1[ 2 * 3] + pSrc1[ 3 * 3]) >> 1) - 128; + pDst[2] = ((pSrc1[ 4 * 3] + pSrc1[ 5 * 3]) >> 1) - 128; pDst[3] = ((pSrc1[ 6 * 3] + pSrc1[ 7 * 3]) >> 1) - 128; + pDst[4] = ((pSrc1[ 8 * 3] + pSrc1[ 9 * 3]) >> 1) - 128; pDst[5] = ((pSrc1[10 * 3] + pSrc1[11 * 3]) >> 1) - 128; + pDst[6] = ((pSrc1[12 * 3] + pSrc1[13 * 3]) >> 1) - 128; pDst[7] = ((pSrc1[14 * 3] + pSrc1[15 * 3]) >> 1) - 128; + } + } + + void jpeg_encoder::load_quantized_coefficients(int component_num) + { + int32 *q = m_quantization_tables[component_num > 0]; + int16 *pDst = m_coefficient_array; + for (int i = 0; i < 64; i++) + { + sample_array_t j = m_sample_array[s_zag[i]]; + if (j < 0) + { + if ((j = -j + (*q >> 1)) < *q) + *pDst++ = 0; + else + *pDst++ = static_cast(-(j / *q)); + } + else + { + if ((j = j + (*q >> 1)) < *q) + *pDst++ = 0; + else + *pDst++ = static_cast((j / *q)); + } + q++; + } + } + + void jpeg_encoder::code_coefficients_pass_two(int component_num) + { + int i, j, run_len, nbits, temp1, temp2; + int16 *pSrc = m_coefficient_array; + uint *codes[2]; + uint8 *code_sizes[2]; + + if (component_num == 0) + { + codes[0] = m_huff_codes[0 + 0]; codes[1] = m_huff_codes[2 + 0]; + code_sizes[0] = m_huff_code_sizes[0 + 0]; code_sizes[1] = m_huff_code_sizes[2 + 0]; + } + else + { + codes[0] = m_huff_codes[0 + 1]; codes[1] = m_huff_codes[2 + 1]; + code_sizes[0] = m_huff_code_sizes[0 + 1]; code_sizes[1] = m_huff_code_sizes[2 + 1]; + } + + temp1 = temp2 = pSrc[0] - m_last_dc_val[component_num]; + m_last_dc_val[component_num] = pSrc[0]; + + if (temp1 < 0) + { + temp1 = -temp1; temp2--; + } + + nbits = 0; + while (temp1) + { + nbits++; temp1 >>= 1; + } + + put_bits(codes[0][nbits], code_sizes[0][nbits]); + if (nbits) put_bits(temp2 & ((1 << nbits) - 1), nbits); + + for (run_len = 0, i = 1; i < 64; i++) + { + if ((temp1 = m_coefficient_array[i]) == 0) + run_len++; + else + { + while (run_len >= 16) + { + put_bits(codes[1][0xF0], code_sizes[1][0xF0]); + run_len -= 16; + } + if ((temp2 = temp1) < 0) + { + temp1 = -temp1; + temp2--; + } + nbits = 1; + while (temp1 >>= 1) + nbits++; + j = (run_len << 4) + nbits; + put_bits(codes[1][j], code_sizes[1][j]); + put_bits(temp2 & ((1 << nbits) - 1), nbits); + run_len = 0; + } + } + if (run_len) + put_bits(codes[1][0], code_sizes[1][0]); + } + + void jpeg_encoder::code_block(int component_num) + { + DCT2D(m_sample_array); + load_quantized_coefficients(component_num); + code_coefficients_pass_two(component_num); + } + + void jpeg_encoder::process_mcu_row() + { + if (m_num_components == 1) + { + for (int i = 0; i < m_mcus_per_row; i++) + { + load_block_8_8_grey(i); code_block(0); + } + } + else if ((m_comp_h_samp[0] == 1) && (m_comp_v_samp[0] == 1)) + { + for (int i = 0; i < m_mcus_per_row; i++) + { + load_block_8_8(i, 0, 0); code_block(0); load_block_8_8(i, 0, 1); code_block(1); load_block_8_8(i, 0, 2); code_block(2); + } + } + else if ((m_comp_h_samp[0] == 2) && (m_comp_v_samp[0] == 1)) + { + for (int i = 0; i < m_mcus_per_row; i++) + { + load_block_8_8(i * 2 + 0, 0, 0); code_block(0); load_block_8_8(i * 2 + 1, 0, 0); code_block(0); + load_block_16_8_8(i, 1); code_block(1); load_block_16_8_8(i, 2); code_block(2); + } + } + else if ((m_comp_h_samp[0] == 2) && (m_comp_v_samp[0] == 2)) + { + for (int i = 0; i < m_mcus_per_row; i++) + { + load_block_8_8(i * 2 + 0, 0, 0); code_block(0); load_block_8_8(i * 2 + 1, 0, 0); code_block(0); + load_block_8_8(i * 2 + 0, 1, 0); code_block(0); load_block_8_8(i * 2 + 1, 1, 0); code_block(0); + load_block_16_8(i, 1); code_block(1); load_block_16_8(i, 2); code_block(2); + } + } + } + + void jpeg_encoder::load_mcu(const void *pSrc) + { + const uint8* Psrc = reinterpret_cast(pSrc); + + uint8* pDst = m_mcu_lines[m_mcu_y_ofs]; // OK to write up to m_image_bpl_xlt bytes to pDst + + if (m_num_components == 1) { + if (m_image_bpp == 3) + RGB_to_Y(pDst, Psrc, m_image_x); + else + memcpy(pDst, Psrc, m_image_x); + } else { + if (m_image_bpp == 3) + RGB_to_YCC(pDst, Psrc, m_image_x); + else + Y_to_YCC(pDst, Psrc, m_image_x); + } + + // Possibly duplicate pixels at end of scanline if not a multiple of 8 or 16 + if (m_num_components == 1) + memset(m_mcu_lines[m_mcu_y_ofs] + m_image_bpl_xlt, pDst[m_image_bpl_xlt - 1], m_image_x_mcu - m_image_x); + else + { + const uint8 y = pDst[m_image_bpl_xlt - 3 + 0], cb = pDst[m_image_bpl_xlt - 3 + 1], cr = pDst[m_image_bpl_xlt - 3 + 2]; + uint8 *q = m_mcu_lines[m_mcu_y_ofs] + m_image_bpl_xlt; + for (int i = m_image_x; i < m_image_x_mcu; i++) + { + *q++ = y; *q++ = cb; *q++ = cr; + } + } + + if (++m_mcu_y_ofs == m_mcu_y) + { + process_mcu_row(); + m_mcu_y_ofs = 0; + } + } + + // Quantization table generation. + void jpeg_encoder::compute_quant_table(int32 *pDst, const int16 *pSrc) + { + int32 q; + if (m_params.m_quality < 50) + q = 5000 / m_params.m_quality; + else + q = 200 - m_params.m_quality * 2; + for (int i = 0; i < 64; i++) + { + int32 j = *pSrc++; j = (j * q + 50L) / 100L; + *pDst++ = JPGE_MIN(JPGE_MAX(j, 1), 255); + } + } + + // Higher-level methods. + bool jpeg_encoder::jpg_open(int p_x_res, int p_y_res, int src_channels) + { + m_num_components = 3; + switch (m_params.m_subsampling) + { + case Y_ONLY: + { + m_num_components = 1; + m_comp_h_samp[0] = 1; m_comp_v_samp[0] = 1; + m_mcu_x = 8; m_mcu_y = 8; + break; + } + case H1V1: + { + m_comp_h_samp[0] = 1; m_comp_v_samp[0] = 1; + m_comp_h_samp[1] = 1; m_comp_v_samp[1] = 1; + m_comp_h_samp[2] = 1; m_comp_v_samp[2] = 1; + m_mcu_x = 8; m_mcu_y = 8; + break; + } + case H2V1: + { + m_comp_h_samp[0] = 2; m_comp_v_samp[0] = 1; + m_comp_h_samp[1] = 1; m_comp_v_samp[1] = 1; + m_comp_h_samp[2] = 1; m_comp_v_samp[2] = 1; + m_mcu_x = 16; m_mcu_y = 8; + break; + } + case H2V2: + { + m_comp_h_samp[0] = 2; m_comp_v_samp[0] = 2; + m_comp_h_samp[1] = 1; m_comp_v_samp[1] = 1; + m_comp_h_samp[2] = 1; m_comp_v_samp[2] = 1; + m_mcu_x = 16; m_mcu_y = 16; + } + } + + m_image_x = p_x_res; m_image_y = p_y_res; + m_image_bpp = src_channels; + m_image_bpl = m_image_x * src_channels; + m_image_x_mcu = (m_image_x + m_mcu_x - 1) & (~(m_mcu_x - 1)); + m_image_y_mcu = (m_image_y + m_mcu_y - 1) & (~(m_mcu_y - 1)); + m_image_bpl_xlt = m_image_x * m_num_components; + m_image_bpl_mcu = m_image_x_mcu * m_num_components; + m_mcus_per_row = m_image_x_mcu / m_mcu_x; + + if ((m_mcu_lines[0] = static_cast(jpge_malloc(m_image_bpl_mcu * m_mcu_y))) == NULL) { + return false; + } + for (int i = 1; i < m_mcu_y; i++) + m_mcu_lines[i] = m_mcu_lines[i-1] + m_image_bpl_mcu; + + if(m_last_quality != m_params.m_quality){ + m_last_quality = m_params.m_quality; + compute_quant_table(m_quantization_tables[0], s_std_lum_quant); + compute_quant_table(m_quantization_tables[1], s_std_croma_quant); + } + + if(!m_huff_initialized){ + m_huff_initialized = true; + + memcpy(m_huff_bits[0+0], s_dc_lum_bits, 17); memcpy(m_huff_val[0+0], s_dc_lum_val, DC_LUM_CODES); + memcpy(m_huff_bits[2+0], s_ac_lum_bits, 17); memcpy(m_huff_val[2+0], s_ac_lum_val, AC_LUM_CODES); + memcpy(m_huff_bits[0+1], s_dc_chroma_bits, 17); memcpy(m_huff_val[0+1], s_dc_chroma_val, DC_CHROMA_CODES); + memcpy(m_huff_bits[2+1], s_ac_chroma_bits, 17); memcpy(m_huff_val[2+1], s_ac_chroma_val, AC_CHROMA_CODES); + + compute_huffman_table(&m_huff_codes[0+0][0], &m_huff_code_sizes[0+0][0], m_huff_bits[0+0], m_huff_val[0+0]); + compute_huffman_table(&m_huff_codes[2+0][0], &m_huff_code_sizes[2+0][0], m_huff_bits[2+0], m_huff_val[2+0]); + compute_huffman_table(&m_huff_codes[0+1][0], &m_huff_code_sizes[0+1][0], m_huff_bits[0+1], m_huff_val[0+1]); + compute_huffman_table(&m_huff_codes[2+1][0], &m_huff_code_sizes[2+1][0], m_huff_bits[2+1], m_huff_val[2+1]); + } + + m_out_buf_left = JPGE_OUT_BUF_SIZE; + m_pOut_buf = m_out_buf; + m_bit_buffer = 0; + m_bits_in = 0; + m_mcu_y_ofs = 0; + m_pass_num = 2; + memset(m_last_dc_val, 0, 3 * sizeof(m_last_dc_val[0])); + + // Emit all markers at beginning of image file. + emit_marker(M_SOI); + emit_jfif_app0(); + emit_dqt(); + emit_sof(); + emit_dhts(); + emit_sos(); + + return m_all_stream_writes_succeeded; + } + + bool jpeg_encoder::process_end_of_image() + { + if (m_mcu_y_ofs) { + if (m_mcu_y_ofs < 16) { // check here just to shut up static analysis + for (int i = m_mcu_y_ofs; i < m_mcu_y; i++) { + memcpy(m_mcu_lines[i], m_mcu_lines[m_mcu_y_ofs - 1], m_image_bpl_mcu); + } + } + process_mcu_row(); + } + + put_bits(0x7F, 7); + emit_marker(M_EOI); + flush_output_buffer(); + m_all_stream_writes_succeeded = m_all_stream_writes_succeeded && m_pStream->put_buf(NULL, 0); + m_pass_num++; // purposely bump up m_pass_num, for debugging + return true; + } + + void jpeg_encoder::clear() + { + m_mcu_lines[0] = NULL; + m_pass_num = 0; + m_all_stream_writes_succeeded = true; + } + + jpeg_encoder::jpeg_encoder() + { + clear(); + } + + jpeg_encoder::~jpeg_encoder() + { + deinit(); + } + + bool jpeg_encoder::init(output_stream *pStream, int width, int height, int src_channels, const params &comp_params) + { + deinit(); + if (((!pStream) || (width < 1) || (height < 1)) || ((src_channels != 1) && (src_channels != 3) && (src_channels != 4)) || (!comp_params.check())) return false; + m_pStream = pStream; + m_params = comp_params; + return jpg_open(width, height, src_channels); + } + + void jpeg_encoder::deinit() + { + jpge_free(m_mcu_lines[0]); + clear(); + } + + bool jpeg_encoder::process_scanline(const void* pScanline) + { + if ((m_pass_num < 1) || (m_pass_num > 2)) { + return false; + } + if (m_all_stream_writes_succeeded) { + if (!pScanline) { + if (!process_end_of_image()) { + return false; + } + } else { + load_mcu(pScanline); + } + } + return m_all_stream_writes_succeeded; + } + +} // namespace jpge diff --git a/lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h b/lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h new file mode 100644 index 000000000..aa295c8af --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h @@ -0,0 +1,142 @@ +// jpge.h - C++ class for JPEG compression. +// Public domain, Rich Geldreich +// Alex Evans: Added RGBA support, linear memory allocator. +#ifndef JPEG_ENCODER_H +#define JPEG_ENCODER_H + +namespace jpge +{ + typedef unsigned char uint8; + typedef signed short int16; + typedef signed int int32; + typedef unsigned short uint16; + typedef unsigned int uint32; + typedef unsigned int uint; + + // JPEG chroma subsampling factors. Y_ONLY (grayscale images) and H2V2 (color images) are the most common. + enum subsampling_t { Y_ONLY = 0, H1V1 = 1, H2V1 = 2, H2V2 = 3 }; + + // JPEG compression parameters structure. + struct params { + inline params() : m_quality(85), m_subsampling(H2V2) { } + + inline bool check() const { + if ((m_quality < 1) || (m_quality > 100)) { + return false; + } + if ((uint)m_subsampling > (uint)H2V2) { + return false; + } + return true; + } + + // Quality: 1-100, higher is better. Typical values are around 50-95. + int m_quality; + + // m_subsampling: + // 0 = Y (grayscale) only + // 1 = H1V1 subsampling (YCbCr 1x1x1, 3 blocks per MCU) + // 2 = H2V1 subsampling (YCbCr 2x1x1, 4 blocks per MCU) + // 3 = H2V2 subsampling (YCbCr 4x1x1, 6 blocks per MCU-- very common) + subsampling_t m_subsampling; + }; + + // Output stream abstract class - used by the jpeg_encoder class to write to the output stream. + // put_buf() is generally called with len==JPGE_OUT_BUF_SIZE bytes, but for headers it'll be called with smaller amounts. + class output_stream { + public: + virtual ~output_stream() { }; + virtual bool put_buf(const void* Pbuf, int len) = 0; + virtual uint get_size() const = 0; + }; + + // Lower level jpeg_encoder class - useful if more control is needed than the above helper functions. + class jpeg_encoder { + public: + jpeg_encoder(); + ~jpeg_encoder(); + + // Initializes the compressor. + // pStream: The stream object to use for writing compressed data. + // params - Compression parameters structure, defined above. + // width, height - Image dimensions. + // channels - May be 1, or 3. 1 indicates grayscale, 3 indicates RGB source data. + // Returns false on out of memory or if a stream write fails. + bool init(output_stream *pStream, int width, int height, int src_channels, const params &comp_params = params()); + + // Call this method with each source scanline. + // width * src_channels bytes per scanline is expected (RGB or Y format). + // You must call with NULL after all scanlines are processed to finish compression. + // Returns false on out of memory or if a stream write fails. + bool process_scanline(const void* pScanline); + + // Deinitializes the compressor, freeing any allocated memory. May be called at any time. + void deinit(); + + private: + jpeg_encoder(const jpeg_encoder &); + jpeg_encoder &operator =(const jpeg_encoder &); + + typedef int32 sample_array_t; + enum { JPGE_OUT_BUF_SIZE = 512 }; + + output_stream *m_pStream; + params m_params; + uint8 m_num_components; + uint8 m_comp_h_samp[3], m_comp_v_samp[3]; + int m_image_x, m_image_y, m_image_bpp, m_image_bpl; + int m_image_x_mcu, m_image_y_mcu; + int m_image_bpl_xlt, m_image_bpl_mcu; + int m_mcus_per_row; + int m_mcu_x, m_mcu_y; + uint8 *m_mcu_lines[16]; + uint8 m_mcu_y_ofs; + sample_array_t m_sample_array[64]; + int16 m_coefficient_array[64]; + + int m_last_dc_val[3]; + uint8 m_out_buf[JPGE_OUT_BUF_SIZE]; + uint8 *m_pOut_buf; + uint m_out_buf_left; + uint32 m_bit_buffer; + uint m_bits_in; + uint8 m_pass_num; + bool m_all_stream_writes_succeeded; + + bool jpg_open(int p_x_res, int p_y_res, int src_channels); + + void flush_output_buffer(); + void put_bits(uint bits, uint len); + + void emit_byte(uint8 i); + void emit_word(uint i); + void emit_marker(int marker); + + void emit_jfif_app0(); + void emit_dqt(); + void emit_sof(); + void emit_dht(uint8 *bits, uint8 *val, int index, bool ac_flag); + void emit_dhts(); + void emit_sos(); + + void compute_quant_table(int32 *dst, const int16 *src); + void load_quantized_coefficients(int component_num); + + void load_block_8_8_grey(int x); + void load_block_8_8(int x, int y, int c); + void load_block_16_8(int x, int c); + void load_block_16_8_8(int x, int c); + + void code_coefficients_pass_two(int component_num); + void code_block(int component_num); + + void process_mcu_row(); + bool process_end_of_image(); + void load_mcu(const void* src); + void clear(); + void init(); + }; + +} // namespace jpge + +#endif // JPEG_ENCODER diff --git a/lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h b/lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h new file mode 100644 index 000000000..c5a0577ef --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h @@ -0,0 +1,29 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef _CONVERSIONS_YUV_H_ +#define _CONVERSIONS_YUV_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +void yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b); + +#ifdef __cplusplus +} +#endif + +#endif /* _CONVERSIONS_YUV_H_ */ diff --git a/lib/libesp32_div/esp32-camera/conversions/to_bmp.c b/lib/libesp32_div/esp32-camera/conversions/to_bmp.c new file mode 100644 index 000000000..5a54bdbae --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/to_bmp.c @@ -0,0 +1,393 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include +#include +#include "img_converters.h" +#include "soc/efuse_reg.h" +#include "esp_heap_caps.h" +#include "yuv.h" +#include "sdkconfig.h" +#include "esp_jpg_decode.h" + +#include "esp_system.h" +#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 +#include "esp32/spiram.h" +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "esp32s2/spiram.h" +#elif CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/spiram.h" +#else +#error Target CONFIG_IDF_TARGET is not supported +#endif +#else // ESP32 Before IDF 4.0 +#include "esp_spiram.h" +#endif + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#define TAG "" +#else +#include "esp_log.h" +static const char* TAG = "to_bmp"; +#endif + +static const int BMP_HEADER_LEN = 54; + +typedef struct { + uint32_t filesize; + uint32_t reserved; + uint32_t fileoffset_to_pixelarray; + uint32_t dibheadersize; + int32_t width; + int32_t height; + uint16_t planes; + uint16_t bitsperpixel; + uint32_t compression; + uint32_t imagesize; + uint32_t ypixelpermeter; + uint32_t xpixelpermeter; + uint32_t numcolorspallette; + uint32_t mostimpcolor; +} bmp_header_t; + +typedef struct { + uint16_t width; + uint16_t height; + uint16_t data_offset; + const uint8_t *input; + uint8_t *output; +} rgb_jpg_decoder; + +static void *_malloc(size_t size) +{ + return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); +} + +//output buffer and image width +static bool _rgb_write(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data) +{ + rgb_jpg_decoder * jpeg = (rgb_jpg_decoder *)arg; + if(!data){ + if(x == 0 && y == 0){ + //write start + jpeg->width = w; + jpeg->height = h; + //if output is null, this is BMP + if(!jpeg->output){ + jpeg->output = (uint8_t *)_malloc((w*h*3)+jpeg->data_offset); + if(!jpeg->output){ + return false; + } + } + } else { + //write end + } + return true; + } + + size_t jw = jpeg->width*3; + size_t t = y * jw; + size_t b = t + (h * jw); + size_t l = x * 3; + uint8_t *out = jpeg->output+jpeg->data_offset; + uint8_t *o = out; + size_t iy, ix; + + w = w * 3; + + for(iy=t; iywidth = w; + jpeg->height = h; + //if output is null, this is BMP + if(!jpeg->output){ + jpeg->output = (uint8_t *)_malloc((w*h*3)+jpeg->data_offset); + if(!jpeg->output){ + return false; + } + } + } else { + //write end + } + return true; + } + + size_t jw = jpeg->width*3; + size_t jw2 = jpeg->width*2; + size_t t = y * jw; + size_t t2 = y * jw2; + size_t b = t + (h * jw); + size_t l = x * 2; + uint8_t *out = jpeg->output+jpeg->data_offset; + uint8_t *o = out; + size_t iy, iy2, ix, ix2; + + w = w * 3; + + for(iy=t, iy2=t2; iy> 3); + o[ix2+1] = c>>8; + o[ix2] = c&0xff; + } + data+=w; + } + return true; +} + +//input buffer +static uint32_t _jpg_read(void * arg, size_t index, uint8_t *buf, size_t len) +{ + rgb_jpg_decoder * jpeg = (rgb_jpg_decoder *)arg; + if(buf) { + memcpy(buf, jpeg->input + index, len); + } + return len; +} + +static bool jpg2rgb888(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale) +{ + rgb_jpg_decoder jpeg; + jpeg.width = 0; + jpeg.height = 0; + jpeg.input = src; + jpeg.output = out; + jpeg.data_offset = 0; + + if(esp_jpg_decode(src_len, scale, _jpg_read, _rgb_write, (void*)&jpeg) != ESP_OK){ + return false; + } + return true; +} + +bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale) +{ + rgb_jpg_decoder jpeg; + jpeg.width = 0; + jpeg.height = 0; + jpeg.input = src; + jpeg.output = out; + jpeg.data_offset = 0; + + if(esp_jpg_decode(src_len, scale, _jpg_read, _rgb565_write, (void*)&jpeg) != ESP_OK){ + return false; + } + return true; +} + +bool jpg2bmp(const uint8_t *src, size_t src_len, uint8_t ** out, size_t * out_len) +{ + + rgb_jpg_decoder jpeg; + jpeg.width = 0; + jpeg.height = 0; + jpeg.input = src; + jpeg.output = NULL; + jpeg.data_offset = BMP_HEADER_LEN; + + if(esp_jpg_decode(src_len, JPG_SCALE_NONE, _jpg_read, _rgb_write, (void*)&jpeg) != ESP_OK){ + return false; + } + + size_t output_size = jpeg.width*jpeg.height*3; + + jpeg.output[0] = 'B'; + jpeg.output[1] = 'M'; + bmp_header_t * bitmap = (bmp_header_t*)&jpeg.output[2]; + bitmap->reserved = 0; + bitmap->filesize = output_size+BMP_HEADER_LEN; + bitmap->fileoffset_to_pixelarray = BMP_HEADER_LEN; + bitmap->dibheadersize = 40; + bitmap->width = jpeg.width; + bitmap->height = -jpeg.height;//set negative for top to bottom + bitmap->planes = 1; + bitmap->bitsperpixel = 24; + bitmap->compression = 0; + bitmap->imagesize = output_size; + bitmap->ypixelpermeter = 0x0B13 ; //2835 , 72 DPI + bitmap->xpixelpermeter = 0x0B13 ; //2835 , 72 DPI + bitmap->numcolorspallette = 0; + bitmap->mostimpcolor = 0; + + *out = jpeg.output; + *out_len = output_size+BMP_HEADER_LEN; + + return true; +} + +bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf) +{ + int pix_count = 0; + if(format == PIXFORMAT_JPEG) { + return jpg2rgb888(src_buf, src_len, rgb_buf, JPG_SCALE_NONE); + } else if(format == PIXFORMAT_RGB888) { + memcpy(rgb_buf, src_buf, src_len); + } else if(format == PIXFORMAT_RGB565) { + int i; + uint8_t hb, lb; + pix_count = src_len / 2; + for(i=0; i> 3; + *rgb_buf++ = hb & 0xF8; + } + } else if(format == PIXFORMAT_GRAYSCALE) { + int i; + uint8_t b; + pix_count = src_len; + for(i=0; ireserved = 0; + bitmap->filesize = out_size; + bitmap->fileoffset_to_pixelarray = BMP_HEADER_LEN; + bitmap->dibheadersize = 40; + bitmap->width = width; + bitmap->height = -height;//set negative for top to bottom + bitmap->planes = 1; + bitmap->bitsperpixel = 24; + bitmap->compression = 0; + bitmap->imagesize = pix_count * 3; + bitmap->ypixelpermeter = 0x0B13 ; //2835 , 72 DPI + bitmap->xpixelpermeter = 0x0B13 ; //2835 , 72 DPI + bitmap->numcolorspallette = 0; + bitmap->mostimpcolor = 0; + + uint8_t * rgb_buf = out_buf + BMP_HEADER_LEN; + uint8_t * src_buf = src; + + + //convert data to RGB888 + if(format == PIXFORMAT_RGB888) { + memcpy(rgb_buf, src_buf, pix_count*3); + } else if(format == PIXFORMAT_RGB565) { + int i; + uint8_t hb, lb; + for(i=0; i> 3; + *rgb_buf++ = hb & 0xF8; + } + } else if(format == PIXFORMAT_GRAYSCALE) { + int i; + uint8_t b; + for(i=0; ibuf, fb->len, fb->width, fb->height, fb->format, out, out_len); +} diff --git a/lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp b/lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp new file mode 100644 index 000000000..9b8905a73 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp @@ -0,0 +1,245 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include +#include +#include "esp_attr.h" +#include "soc/efuse_reg.h" +#include "esp_heap_caps.h" +#include "esp_camera.h" +#include "img_converters.h" +#include "jpge.h" +#include "yuv.h" + +#include "esp_system.h" +#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 +#include "esp32/spiram.h" +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "esp32s2/spiram.h" +#elif CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/spiram.h" +#else +#error Target CONFIG_IDF_TARGET is not supported +#endif +#else // ESP32 Before IDF 4.0 +#include "esp_spiram.h" +#endif + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#define TAG "" +#else +#include "esp_log.h" +static const char* TAG = "to_jpg"; +#endif + +static void *_malloc(size_t size) +{ + void * res = malloc(size); + if(res) { + return res; + } + return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); +} + +static IRAM_ATTR void convert_line_format(uint8_t * src, pixformat_t format, uint8_t * dst, size_t width, size_t in_channels, size_t line) +{ + int i=0, o=0, l=0; + if(format == PIXFORMAT_GRAYSCALE) { + memcpy(dst, src + line * width, width); + } else if(format == PIXFORMAT_RGB888) { + l = width * 3; + src += l * line; + for(i=0; i> 3; + dst[o++] = (src[i+1] & 0x1F) << 3; + } + } else if(format == PIXFORMAT_YUV422) { + uint8_t y0, y1, u, v; + uint8_t r, g, b; + l = width * 2; + src += l * line; + for(i=0; i 100) { + quality = 100; + } + + jpge::params comp_params = jpge::params(); + comp_params.m_subsampling = subsampling; + comp_params.m_quality = quality; + + jpge::jpeg_encoder dst_image; + + if (!dst_image.init(dst_stream, width, height, num_channels, comp_params)) { + ESP_LOGE(TAG, "JPG encoder init failed"); + return false; + } + + uint8_t* line = (uint8_t*)_malloc(width * num_channels); + if(!line) { + ESP_LOGE(TAG, "Scan line malloc failed"); + return false; + } + + for (int i = 0; i < height; i++) { + convert_line_format(src, format, line, width, num_channels, i); + if (!dst_image.process_scanline(line)) { + ESP_LOGE(TAG, "JPG process line %u failed", i); + free(line); + return false; + } + } + free(line); + + if (!dst_image.process_scanline(NULL)) { + ESP_LOGE(TAG, "JPG image finish failed"); + return false; + } + dst_image.deinit(); + return true; +} + +class callback_stream : public jpge::output_stream { +protected: + jpg_out_cb ocb; + void * oarg; + size_t index; + +public: + callback_stream(jpg_out_cb cb, void * arg) : ocb(cb), oarg(arg), index(0) { } + virtual ~callback_stream() { } + virtual bool put_buf(const void* data, int len) + { + index += ocb(oarg, index, data, len); + return true; + } + virtual size_t get_size() const + { + return index; + } +}; + +bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg) +{ + callback_stream dst_stream(cb, arg); + return convert_image(src, width, height, format, quality, &dst_stream); +} + +bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg) +{ + return fmt2jpg_cb(fb->buf, fb->len, fb->width, fb->height, fb->format, quality, cb, arg); +} + + + +class memory_stream : public jpge::output_stream { +protected: + uint8_t *out_buf; + size_t max_len, index; + +public: + memory_stream(void *pBuf, uint buf_size) : out_buf(static_cast(pBuf)), max_len(buf_size), index(0) { } + + virtual ~memory_stream() { } + + virtual bool put_buf(const void* pBuf, int len) + { + if (!pBuf) { + //end of image + return true; + } + if ((size_t)len > (max_len - index)) { + //ESP_LOGW(TAG, "JPG output overflow: %d bytes (%d,%d,%d)", len - (max_len - index), len, index, max_len); + len = max_len - index; + } + if (len) { + memcpy(out_buf + index, pBuf, len); + index += len; + } + return true; + } + + virtual size_t get_size() const + { + return index; + } +}; + +bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len) +{ + //todo: allocate proper buffer for holding JPEG data + //this should be enough for CIF frame size + int jpg_buf_len = 128*1024; + + + uint8_t * jpg_buf = (uint8_t *)_malloc(jpg_buf_len); + if(jpg_buf == NULL) { + ESP_LOGE(TAG, "JPG buffer malloc failed"); + return false; + } + memory_stream dst_stream(jpg_buf, jpg_buf_len); + + if(!convert_image(src, width, height, format, quality, &dst_stream)) { + free(jpg_buf); + return false; + } + + *out = jpg_buf; + *out_len = dst_stream.get_size(); + return true; +} + +bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len) +{ + return fmt2jpg(fb->buf, fb->len, fb->width, fb->height, fb->format, quality, out, out_len); +} diff --git a/lib/libesp32_div/esp32-camera/conversions/yuv.c b/lib/libesp32_div/esp32-camera/conversions/yuv.c new file mode 100644 index 000000000..46034cc86 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/conversions/yuv.c @@ -0,0 +1,298 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include "yuv.h" +#include "esp_attr.h" + +typedef struct { + int16_t vY; + int16_t vVr; + int16_t vVg; + int16_t vUg; + int16_t vUb; +} yuv_table_row; + +static const yuv_table_row yuv_table[256] = { + // Y Vr Vg Ug Ub // # + { -18, -204, 50, 104, -258 }, // 0 + { -17, -202, 49, 103, -256 }, // 1 + { -16, -201, 49, 102, -254 }, // 2 + { -15, -199, 48, 101, -252 }, // 3 + { -13, -197, 48, 100, -250 }, // 4 + { -12, -196, 48, 99, -248 }, // 5 + { -11, -194, 47, 99, -246 }, // 6 + { -10, -193, 47, 98, -244 }, // 7 + { -9, -191, 46, 97, -242 }, // 8 + { -8, -189, 46, 96, -240 }, // 9 + { -6, -188, 46, 95, -238 }, // 10 + { -5, -186, 45, 95, -236 }, // 11 + { -4, -185, 45, 94, -234 }, // 12 + { -3, -183, 44, 93, -232 }, // 13 + { -2, -181, 44, 92, -230 }, // 14 + { -1, -180, 44, 91, -228 }, // 15 + { 0, -178, 43, 91, -226 }, // 16 + { 1, -177, 43, 90, -223 }, // 17 + { 2, -175, 43, 89, -221 }, // 18 + { 3, -173, 42, 88, -219 }, // 19 + { 4, -172, 42, 87, -217 }, // 20 + { 5, -170, 41, 86, -215 }, // 21 + { 6, -169, 41, 86, -213 }, // 22 + { 8, -167, 41, 85, -211 }, // 23 + { 9, -165, 40, 84, -209 }, // 24 + { 10, -164, 40, 83, -207 }, // 25 + { 11, -162, 39, 82, -205 }, // 26 + { 12, -161, 39, 82, -203 }, // 27 + { 13, -159, 39, 81, -201 }, // 28 + { 15, -158, 38, 80, -199 }, // 29 + { 16, -156, 38, 79, -197 }, // 30 + { 17, -154, 37, 78, -195 }, // 31 + { 18, -153, 37, 78, -193 }, // 32 + { 19, -151, 37, 77, -191 }, // 33 + { 20, -150, 36, 76, -189 }, // 34 + { 22, -148, 36, 75, -187 }, // 35 + { 23, -146, 35, 74, -185 }, // 36 + { 24, -145, 35, 73, -183 }, // 37 + { 25, -143, 35, 73, -181 }, // 38 + { 26, -142, 34, 72, -179 }, // 39 + { 27, -140, 34, 71, -177 }, // 40 + { 29, -138, 34, 70, -175 }, // 41 + { 30, -137, 33, 69, -173 }, // 42 + { 31, -135, 33, 69, -171 }, // 43 + { 32, -134, 32, 68, -169 }, // 44 + { 33, -132, 32, 67, -167 }, // 45 + { 34, -130, 32, 66, -165 }, // 46 + { 36, -129, 31, 65, -163 }, // 47 + { 37, -127, 31, 65, -161 }, // 48 + { 38, -126, 30, 64, -159 }, // 49 + { 39, -124, 30, 63, -157 }, // 50 + { 40, -122, 30, 62, -155 }, // 51 + { 41, -121, 29, 61, -153 }, // 52 + { 43, -119, 29, 60, -151 }, // 53 + { 44, -118, 28, 60, -149 }, // 54 + { 45, -116, 28, 59, -147 }, // 55 + { 46, -114, 28, 58, -145 }, // 56 + { 47, -113, 27, 57, -143 }, // 57 + { 48, -111, 27, 56, -141 }, // 58 + { 50, -110, 26, 56, -139 }, // 59 + { 51, -108, 26, 55, -137 }, // 60 + { 52, -106, 26, 54, -135 }, // 61 + { 53, -105, 25, 53, -133 }, // 62 + { 54, -103, 25, 52, -131 }, // 63 + { 55, -102, 25, 52, -129 }, // 64 + { 57, -100, 24, 51, -127 }, // 65 + { 58, -98, 24, 50, -125 }, // 66 + { 59, -97, 23, 49, -123 }, // 67 + { 60, -95, 23, 48, -121 }, // 68 + { 61, -94, 23, 47, -119 }, // 69 + { 62, -92, 22, 47, -117 }, // 70 + { 64, -90, 22, 46, -115 }, // 71 + { 65, -89, 21, 45, -113 }, // 72 + { 66, -87, 21, 44, -110 }, // 73 + { 67, -86, 21, 43, -108 }, // 74 + { 68, -84, 20, 43, -106 }, // 75 + { 69, -82, 20, 42, -104 }, // 76 + { 71, -81, 19, 41, -102 }, // 77 + { 72, -79, 19, 40, -100 }, // 78 + { 73, -78, 19, 39, -98 }, // 79 + { 74, -76, 18, 39, -96 }, // 80 + { 75, -75, 18, 38, -94 }, // 81 + { 76, -73, 17, 37, -92 }, // 82 + { 77, -71, 17, 36, -90 }, // 83 + { 79, -70, 17, 35, -88 }, // 84 + { 80, -68, 16, 34, -86 }, // 85 + { 81, -67, 16, 34, -84 }, // 86 + { 82, -65, 16, 33, -82 }, // 87 + { 83, -63, 15, 32, -80 }, // 88 + { 84, -62, 15, 31, -78 }, // 89 + { 86, -60, 14, 30, -76 }, // 90 + { 87, -59, 14, 30, -74 }, // 91 + { 88, -57, 14, 29, -72 }, // 92 + { 89, -55, 13, 28, -70 }, // 93 + { 90, -54, 13, 27, -68 }, // 94 + { 91, -52, 12, 26, -66 }, // 95 + { 93, -51, 12, 26, -64 }, // 96 + { 94, -49, 12, 25, -62 }, // 97 + { 95, -47, 11, 24, -60 }, // 98 + { 96, -46, 11, 23, -58 }, // 99 + { 97, -44, 10, 22, -56 }, // 100 + { 98, -43, 10, 21, -54 }, // 101 + { 100, -41, 10, 21, -52 }, // 102 + { 101, -39, 9, 20, -50 }, // 103 + { 102, -38, 9, 19, -48 }, // 104 + { 103, -36, 8, 18, -46 }, // 105 + { 104, -35, 8, 17, -44 }, // 106 + { 105, -33, 8, 17, -42 }, // 107 + { 107, -31, 7, 16, -40 }, // 108 + { 108, -30, 7, 15, -38 }, // 109 + { 109, -28, 7, 14, -36 }, // 110 + { 110, -27, 6, 13, -34 }, // 111 + { 111, -25, 6, 13, -32 }, // 112 + { 112, -23, 5, 12, -30 }, // 113 + { 114, -22, 5, 11, -28 }, // 114 + { 115, -20, 5, 10, -26 }, // 115 + { 116, -19, 4, 9, -24 }, // 116 + { 117, -17, 4, 8, -22 }, // 117 + { 118, -15, 3, 8, -20 }, // 118 + { 119, -14, 3, 7, -18 }, // 119 + { 121, -12, 3, 6, -16 }, // 120 + { 122, -11, 2, 5, -14 }, // 121 + { 123, -9, 2, 4, -12 }, // 122 + { 124, -7, 1, 4, -10 }, // 123 + { 125, -6, 1, 3, -8 }, // 124 + { 126, -4, 1, 2, -6 }, // 125 + { 128, -3, 0, 1, -4 }, // 126 + { 129, -1, 0, 0, -2 }, // 127 + { 130, 0, 0, 0, 0 }, // 128 + { 131, 1, 0, 0, 2 }, // 129 + { 132, 3, 0, -1, 4 }, // 130 + { 133, 4, -1, -2, 6 }, // 131 + { 135, 6, -1, -3, 8 }, // 132 + { 136, 7, -1, -4, 10 }, // 133 + { 137, 9, -2, -4, 12 }, // 134 + { 138, 11, -2, -5, 14 }, // 135 + { 139, 12, -3, -6, 16 }, // 136 + { 140, 14, -3, -7, 18 }, // 137 + { 142, 15, -3, -8, 20 }, // 138 + { 143, 17, -4, -8, 22 }, // 139 + { 144, 19, -4, -9, 24 }, // 140 + { 145, 20, -5, -10, 26 }, // 141 + { 146, 22, -5, -11, 28 }, // 142 + { 147, 23, -5, -12, 30 }, // 143 + { 148, 25, -6, -13, 32 }, // 144 + { 150, 27, -6, -13, 34 }, // 145 + { 151, 28, -7, -14, 36 }, // 146 + { 152, 30, -7, -15, 38 }, // 147 + { 153, 31, -7, -16, 40 }, // 148 + { 154, 33, -8, -17, 42 }, // 149 + { 155, 35, -8, -17, 44 }, // 150 + { 157, 36, -8, -18, 46 }, // 151 + { 158, 38, -9, -19, 48 }, // 152 + { 159, 39, -9, -20, 50 }, // 153 + { 160, 41, -10, -21, 52 }, // 154 + { 161, 43, -10, -21, 54 }, // 155 + { 162, 44, -10, -22, 56 }, // 156 + { 164, 46, -11, -23, 58 }, // 157 + { 165, 47, -11, -24, 60 }, // 158 + { 166, 49, -12, -25, 62 }, // 159 + { 167, 51, -12, -26, 64 }, // 160 + { 168, 52, -12, -26, 66 }, // 161 + { 169, 54, -13, -27, 68 }, // 162 + { 171, 55, -13, -28, 70 }, // 163 + { 172, 57, -14, -29, 72 }, // 164 + { 173, 59, -14, -30, 74 }, // 165 + { 174, 60, -14, -30, 76 }, // 166 + { 175, 62, -15, -31, 78 }, // 167 + { 176, 63, -15, -32, 80 }, // 168 + { 178, 65, -16, -33, 82 }, // 169 + { 179, 67, -16, -34, 84 }, // 170 + { 180, 68, -16, -34, 86 }, // 171 + { 181, 70, -17, -35, 88 }, // 172 + { 182, 71, -17, -36, 90 }, // 173 + { 183, 73, -17, -37, 92 }, // 174 + { 185, 75, -18, -38, 94 }, // 175 + { 186, 76, -18, -39, 96 }, // 176 + { 187, 78, -19, -39, 98 }, // 177 + { 188, 79, -19, -40, 100 }, // 178 + { 189, 81, -19, -41, 102 }, // 179 + { 190, 82, -20, -42, 104 }, // 180 + { 192, 84, -20, -43, 106 }, // 181 + { 193, 86, -21, -43, 108 }, // 182 + { 194, 87, -21, -44, 110 }, // 183 + { 195, 89, -21, -45, 113 }, // 184 + { 196, 90, -22, -46, 115 }, // 185 + { 197, 92, -22, -47, 117 }, // 186 + { 199, 94, -23, -47, 119 }, // 187 + { 200, 95, -23, -48, 121 }, // 188 + { 201, 97, -23, -49, 123 }, // 189 + { 202, 98, -24, -50, 125 }, // 190 + { 203, 100, -24, -51, 127 }, // 191 + { 204, 102, -25, -52, 129 }, // 192 + { 206, 103, -25, -52, 131 }, // 193 + { 207, 105, -25, -53, 133 }, // 194 + { 208, 106, -26, -54, 135 }, // 195 + { 209, 108, -26, -55, 137 }, // 196 + { 210, 110, -26, -56, 139 }, // 197 + { 211, 111, -27, -56, 141 }, // 198 + { 213, 113, -27, -57, 143 }, // 199 + { 214, 114, -28, -58, 145 }, // 200 + { 215, 116, -28, -59, 147 }, // 201 + { 216, 118, -28, -60, 149 }, // 202 + { 217, 119, -29, -60, 151 }, // 203 + { 218, 121, -29, -61, 153 }, // 204 + { 219, 122, -30, -62, 155 }, // 205 + { 221, 124, -30, -63, 157 }, // 206 + { 222, 126, -30, -64, 159 }, // 207 + { 223, 127, -31, -65, 161 }, // 208 + { 224, 129, -31, -65, 163 }, // 209 + { 225, 130, -32, -66, 165 }, // 210 + { 226, 132, -32, -67, 167 }, // 211 + { 228, 134, -32, -68, 169 }, // 212 + { 229, 135, -33, -69, 171 }, // 213 + { 230, 137, -33, -69, 173 }, // 214 + { 231, 138, -34, -70, 175 }, // 215 + { 232, 140, -34, -71, 177 }, // 216 + { 233, 142, -34, -72, 179 }, // 217 + { 235, 143, -35, -73, 181 }, // 218 + { 236, 145, -35, -73, 183 }, // 219 + { 237, 146, -35, -74, 185 }, // 220 + { 238, 148, -36, -75, 187 }, // 221 + { 239, 150, -36, -76, 189 }, // 222 + { 240, 151, -37, -77, 191 }, // 223 + { 242, 153, -37, -78, 193 }, // 224 + { 243, 154, -37, -78, 195 }, // 225 + { 244, 156, -38, -79, 197 }, // 226 + { 245, 158, -38, -80, 199 }, // 227 + { 246, 159, -39, -81, 201 }, // 228 + { 247, 161, -39, -82, 203 }, // 229 + { 249, 162, -39, -82, 205 }, // 230 + { 250, 164, -40, -83, 207 }, // 231 + { 251, 165, -40, -84, 209 }, // 232 + { 252, 167, -41, -85, 211 }, // 233 + { 253, 169, -41, -86, 213 }, // 234 + { 254, 170, -41, -86, 215 }, // 235 + { 256, 172, -42, -87, 217 }, // 236 + { 257, 173, -42, -88, 219 }, // 237 + { 258, 175, -43, -89, 221 }, // 238 + { 259, 177, -43, -90, 223 }, // 239 + { 260, 178, -43, -91, 226 }, // 240 + { 261, 180, -44, -91, 228 }, // 241 + { 263, 181, -44, -92, 230 }, // 242 + { 264, 183, -44, -93, 232 }, // 243 + { 265, 185, -45, -94, 234 }, // 244 + { 266, 186, -45, -95, 236 }, // 245 + { 267, 188, -46, -95, 238 }, // 246 + { 268, 189, -46, -96, 240 }, // 247 + { 270, 191, -46, -97, 242 }, // 248 + { 271, 193, -47, -98, 244 }, // 249 + { 272, 194, -47, -99, 246 }, // 250 + { 273, 196, -48, -99, 248 }, // 251 + { 274, 197, -48, -100, 250 }, // 252 + { 275, 199, -48, -101, 252 }, // 253 + { 277, 201, -49, -102, 254 }, // 254 + { 278, 202, -49, -103, 256 } // 255 +}; + +#define YUYV_CONSTRAIN(v) ((v)<0)?0:(((v)>255)?255:(v)) + +void IRAM_ATTR yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b) +{ + int16_t ri, gi, bi; + + ri = yuv_table[y].vY + yuv_table[v].vVr; + gi = yuv_table[y].vY + yuv_table[u].vUg + yuv_table[v].vVg; + bi = yuv_table[y].vY + yuv_table[u].vUb; + + *r = YUYV_CONSTRAIN(ri); + *g = YUYV_CONSTRAIN(gi); + *b = YUYV_CONSTRAIN(bi); +} diff --git a/lib/libesp32_div/esp32-camera/driver/cam_hal.c b/lib/libesp32_div/esp32-camera/driver/cam_hal.c new file mode 100644 index 000000000..c54fb8172 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/cam_hal.c @@ -0,0 +1,483 @@ +// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "esp_heap_caps.h" +#include "ll_cam.h" +#include "cam_hal.h" + +static const char *TAG = "cam_hal"; + +static cam_obj_t *cam_obj = NULL; + +static const uint32_t JPEG_SOI_MARKER = 0xFFD8FF; // written in little-endian for esp32 +static const uint16_t JPEG_EOI_MARKER = 0xD9FF; // written in little-endian for esp32 + +static int cam_verify_jpeg_soi(const uint8_t *inbuf, uint32_t length) +{ + uint32_t sig = *((uint32_t *)inbuf) & 0xFFFFFF; + if(sig != JPEG_SOI_MARKER) { + for (uint32_t i = 0; i < length; i++) { + sig = *((uint32_t *)(&inbuf[i])) & 0xFFFFFF; + if (sig == JPEG_SOI_MARKER) { + ESP_LOGW(TAG, "SOI: %d", i); + return i; + } + } + ESP_LOGW(TAG, "NO-SOI"); + return -1; + } + return 0; +} + +static int cam_verify_jpeg_eoi(const uint8_t *inbuf, uint32_t length) +{ + int offset = -1; + uint8_t *dptr = (uint8_t *)inbuf + length - 2; + while (dptr > inbuf) { + uint16_t sig = *((uint16_t *)dptr); + if (JPEG_EOI_MARKER == sig) { + offset = dptr - inbuf; + //ESP_LOGW(TAG, "EOI: %d", length - (offset + 2)); + return offset; + } + dptr--; + } + return -1; +} + +static bool cam_get_next_frame(int * frame_pos) +{ + if(!cam_obj->frames[*frame_pos].en){ + for (int x = 0; x < cam_obj->frame_cnt; x++) { + if (cam_obj->frames[x].en) { + *frame_pos = x; + return true; + } + } + } else { + return true; + } + return false; +} + +static bool cam_start_frame(int * frame_pos) +{ + if (cam_get_next_frame(frame_pos)) { + if(ll_cam_start(cam_obj, *frame_pos)){ + // Vsync the frame manually + ll_cam_do_vsync(cam_obj); + uint64_t us = (uint64_t)esp_timer_get_time(); + cam_obj->frames[*frame_pos].fb.timestamp.tv_sec = us / 1000000UL; + cam_obj->frames[*frame_pos].fb.timestamp.tv_usec = us % 1000000UL; + return true; + } + } + return false; +} + +void IRAM_ATTR ll_cam_send_event(cam_obj_t *cam, cam_event_t cam_event, BaseType_t * HPTaskAwoken) +{ + if (xQueueSendFromISR(cam->event_queue, (void *)&cam_event, HPTaskAwoken) != pdTRUE) { + ll_cam_stop(cam); + cam->state = CAM_STATE_IDLE; + ESP_EARLY_LOGE(TAG, "EV-%s-OVF", cam_event==CAM_IN_SUC_EOF_EVENT ? "EOF" : "VSYNC"); + } +} + +//Copy fram from DMA dma_buffer to fram dma_buffer +static void cam_task(void *arg) +{ + int cnt = 0; + int frame_pos = 0; + cam_obj->state = CAM_STATE_IDLE; + cam_event_t cam_event = 0; + + xQueueReset(cam_obj->event_queue); + + while (1) { + xQueueReceive(cam_obj->event_queue, (void *)&cam_event, portMAX_DELAY); + DBG_PIN_SET(1); + switch (cam_obj->state) { + + case CAM_STATE_IDLE: { + if (cam_event == CAM_VSYNC_EVENT) { + //DBG_PIN_SET(1); + if(cam_start_frame(&frame_pos)){ + cam_obj->frames[frame_pos].fb.len = 0; + cam_obj->state = CAM_STATE_READ_BUF; + } + cnt = 0; + } + } + break; + + case CAM_STATE_READ_BUF: { + camera_fb_t * frame_buffer_event = &cam_obj->frames[frame_pos].fb; + size_t pixels_per_dma = (cam_obj->dma_half_buffer_size * cam_obj->fb_bytes_per_pixel) / (cam_obj->dma_bytes_per_item * cam_obj->in_bytes_per_pixel); + + if (cam_event == CAM_IN_SUC_EOF_EVENT) { + if(!cam_obj->psram_mode){ + if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) { + ESP_LOGW(TAG, "FB-OVF"); + ll_cam_stop(cam_obj); + DBG_PIN_SET(0); + continue; + } + frame_buffer_event->len += ll_cam_memcpy(cam_obj, + &frame_buffer_event->buf[frame_buffer_event->len], + &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], + cam_obj->dma_half_buffer_size); + } + //Check for JPEG SOI in the first buffer. stop if not found + if (cam_obj->jpeg_mode && cnt == 0 && cam_verify_jpeg_soi(frame_buffer_event->buf, frame_buffer_event->len) != 0) { + ll_cam_stop(cam_obj); + cam_obj->state = CAM_STATE_IDLE; + } + cnt++; + + } else if (cam_event == CAM_VSYNC_EVENT) { + //DBG_PIN_SET(1); + ll_cam_stop(cam_obj); + + if (cnt || !cam_obj->jpeg_mode || cam_obj->psram_mode) { + if (cam_obj->jpeg_mode) { + if (!cam_obj->psram_mode) { + if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) { + ESP_LOGW(TAG, "FB-OVF"); + cnt--; + } else { + frame_buffer_event->len += ll_cam_memcpy(cam_obj, + &frame_buffer_event->buf[frame_buffer_event->len], + &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], + cam_obj->dma_half_buffer_size); + } + } + cnt++; + } + + cam_obj->frames[frame_pos].en = 0; + + if (cam_obj->psram_mode) { + if (cam_obj->jpeg_mode) { + frame_buffer_event->len = cnt * cam_obj->dma_half_buffer_size; + } else { + frame_buffer_event->len = cam_obj->recv_size; + } + } else if (!cam_obj->jpeg_mode) { + if (frame_buffer_event->len != cam_obj->fb_size) { + cam_obj->frames[frame_pos].en = 1; + ESP_LOGE(TAG, "FB-SIZE: %u != %u", frame_buffer_event->len, cam_obj->fb_size); + } + } + //send frame + if(!cam_obj->frames[frame_pos].en && xQueueSend(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0) != pdTRUE) { + //pop frame buffer from the queue + camera_fb_t * fb2 = NULL; + if(xQueueReceive(cam_obj->frame_buffer_queue, &fb2, 0) == pdTRUE) { + //push the new frame to the end of the queue + if (xQueueSend(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0) != pdTRUE) { + cam_obj->frames[frame_pos].en = 1; + ESP_LOGE(TAG, "FBQ-SND"); + } + //free the popped buffer + cam_give(fb2); + } else { + //queue is full and we could not pop a frame from it + cam_obj->frames[frame_pos].en = 1; + ESP_LOGE(TAG, "FBQ-RCV"); + } + } + } + + if(!cam_start_frame(&frame_pos)){ + cam_obj->state = CAM_STATE_IDLE; + } else { + cam_obj->frames[frame_pos].fb.len = 0; + } + cnt = 0; + } + } + break; + } + DBG_PIN_SET(0); + } +} + +static lldesc_t * allocate_dma_descriptors(uint32_t count, uint16_t size, uint8_t * buffer) +{ + lldesc_t *dma = (lldesc_t *)heap_caps_malloc(count * sizeof(lldesc_t), MALLOC_CAP_DMA); + if (dma == NULL) { + return dma; + } + + for (int x = 0; x < count; x++) { + dma[x].size = size; + dma[x].length = 0; + dma[x].sosf = 0; + dma[x].eof = 0; + dma[x].owner = 1; + dma[x].buf = (buffer + size * x); + dma[x].empty = (uint32_t)&dma[(x + 1) % count]; + } + return dma; +} + +static esp_err_t cam_dma_config(const camera_config_t *config) +{ + bool ret = ll_cam_dma_sizes(cam_obj); + if (0 == ret) { + return ESP_FAIL; + } + + cam_obj->dma_node_cnt = (cam_obj->dma_buffer_size) / cam_obj->dma_node_buffer_size; // Number of DMA nodes + cam_obj->frame_copy_cnt = cam_obj->recv_size / cam_obj->dma_half_buffer_size; // Number of interrupted copies, ping-pong copy + + ESP_LOGI(TAG, "buffer_size: %d, half_buffer_size: %d, node_buffer_size: %d, node_cnt: %d, total_cnt: %d", + cam_obj->dma_buffer_size, cam_obj->dma_half_buffer_size, cam_obj->dma_node_buffer_size, cam_obj->dma_node_cnt, cam_obj->frame_copy_cnt); + + cam_obj->dma_buffer = NULL; + cam_obj->dma = NULL; + + cam_obj->frames = (cam_frame_t *)heap_caps_calloc(1, cam_obj->frame_cnt * sizeof(cam_frame_t), MALLOC_CAP_DEFAULT); + CAM_CHECK(cam_obj->frames != NULL, "frames malloc failed", ESP_FAIL); + + uint8_t dma_align = 0; + size_t fb_size = cam_obj->fb_size; + if (cam_obj->psram_mode) { + dma_align = ll_cam_get_dma_align(cam_obj); + if (cam_obj->fb_size < cam_obj->recv_size) { + fb_size = cam_obj->recv_size; + } + } + + /* Allocate memeory for frame buffer */ + size_t alloc_size = fb_size * sizeof(uint8_t) + dma_align; + uint32_t _caps = MALLOC_CAP_8BIT; + if (CAMERA_FB_IN_DRAM == config->fb_location) { + _caps |= MALLOC_CAP_INTERNAL; + } else { + _caps |= MALLOC_CAP_SPIRAM; + } + for (int x = 0; x < cam_obj->frame_cnt; x++) { + cam_obj->frames[x].dma = NULL; + cam_obj->frames[x].fb_offset = 0; + cam_obj->frames[x].en = 0; + ESP_LOGI(TAG, "Allocating %d Byte frame buffer in %s", alloc_size, _caps & MALLOC_CAP_SPIRAM ? "PSRAM" : "OnBoard RAM"); + cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_malloc(alloc_size, _caps); + CAM_CHECK(cam_obj->frames[x].fb.buf != NULL, "frame buffer malloc failed", ESP_FAIL); + if (cam_obj->psram_mode) { + //align PSRAM buffer. TODO: save the offset so proper address can be freed later + cam_obj->frames[x].fb_offset = dma_align - ((uint32_t)cam_obj->frames[x].fb.buf & (dma_align - 1)); + cam_obj->frames[x].fb.buf += cam_obj->frames[x].fb_offset; + ESP_LOGI(TAG, "Frame[%d]: Offset: %u, Addr: 0x%08X", x, cam_obj->frames[x].fb_offset, (uint32_t)cam_obj->frames[x].fb.buf); + cam_obj->frames[x].dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->frames[x].fb.buf); + CAM_CHECK(cam_obj->frames[x].dma != NULL, "frame dma malloc failed", ESP_FAIL); + } + cam_obj->frames[x].en = 1; + } + + if (!cam_obj->psram_mode) { + cam_obj->dma_buffer = (uint8_t *)heap_caps_malloc(cam_obj->dma_buffer_size * sizeof(uint8_t), MALLOC_CAP_DMA); + if(NULL == cam_obj->dma_buffer) { + ESP_LOGE(TAG,"%s(%d): DMA buffer %d Byte malloc failed, the current largest free block:%d Byte", __FUNCTION__, __LINE__, + cam_obj->dma_buffer_size, heap_caps_get_largest_free_block(MALLOC_CAP_DMA)); + return ESP_FAIL; + } + + cam_obj->dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->dma_buffer); + CAM_CHECK(cam_obj->dma != NULL, "dma malloc failed", ESP_FAIL); + } + + return ESP_OK; +} + +esp_err_t cam_init(const camera_config_t *config) +{ + CAM_CHECK(NULL != config, "config pointer is invalid", ESP_ERR_INVALID_ARG); + + esp_err_t ret = ESP_OK; + cam_obj = (cam_obj_t *)heap_caps_calloc(1, sizeof(cam_obj_t), MALLOC_CAP_DMA); + CAM_CHECK(NULL != cam_obj, "lcd_cam object malloc error", ESP_ERR_NO_MEM); + + cam_obj->swap_data = 0; + cam_obj->vsync_pin = config->pin_vsync; + cam_obj->vsync_invert = true; + + ll_cam_set_pin(cam_obj, config); + ret = ll_cam_config(cam_obj, config); + CAM_CHECK_GOTO(ret == ESP_OK, "ll_cam initialize failed", err); + +#if CAMERA_DBG_PIN_ENABLE + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[DBG_PIN_NUM], PIN_FUNC_GPIO); + gpio_set_direction(DBG_PIN_NUM, GPIO_MODE_OUTPUT); + gpio_set_pull_mode(DBG_PIN_NUM, GPIO_FLOATING); +#endif + + ESP_LOGI(TAG, "cam init ok"); + return ESP_OK; + +err: + free(cam_obj); + cam_obj = NULL; + return ESP_FAIL; +} + +esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint16_t sensor_pid) +{ + CAM_CHECK(NULL != config, "config pointer is invalid", ESP_ERR_INVALID_ARG); + esp_err_t ret = ESP_OK; + + ret = ll_cam_set_sample_mode(cam_obj, (pixformat_t)config->pixel_format, config->xclk_freq_hz, sensor_pid); + + cam_obj->jpeg_mode = config->pixel_format == PIXFORMAT_JPEG; +#if CONFIG_IDF_TARGET_ESP32 + cam_obj->psram_mode = false; +#else + cam_obj->psram_mode = (config->xclk_freq_hz == 16000000); +#endif + cam_obj->frame_cnt = config->fb_count; + cam_obj->width = resolution[frame_size].width; + cam_obj->height = resolution[frame_size].height; + + if(cam_obj->jpeg_mode){ + cam_obj->recv_size = cam_obj->width * cam_obj->height / 5; + cam_obj->fb_size = cam_obj->recv_size; + } else { + cam_obj->recv_size = cam_obj->width * cam_obj->height * cam_obj->in_bytes_per_pixel; + cam_obj->fb_size = cam_obj->width * cam_obj->height * cam_obj->fb_bytes_per_pixel; + } + + ret = cam_dma_config(config); + CAM_CHECK_GOTO(ret == ESP_OK, "cam_dma_config failed", err); + + cam_obj->event_queue = xQueueCreate(cam_obj->dma_half_buffer_cnt - 1, sizeof(cam_event_t)); + CAM_CHECK_GOTO(cam_obj->event_queue != NULL, "event_queue create failed", err); + + size_t frame_buffer_queue_len = cam_obj->frame_cnt; + if (config->grab_mode == CAMERA_GRAB_LATEST && cam_obj->frame_cnt > 1) { + frame_buffer_queue_len = cam_obj->frame_cnt - 1; + } + cam_obj->frame_buffer_queue = xQueueCreate(frame_buffer_queue_len, sizeof(camera_fb_t*)); + CAM_CHECK_GOTO(cam_obj->frame_buffer_queue != NULL, "frame_buffer_queue create failed", err); + + ret = ll_cam_init_isr(cam_obj); + CAM_CHECK_GOTO(ret == ESP_OK, "cam intr alloc failed", err); + + +#if CONFIG_CAMERA_CORE0 + xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 0); +#elif CONFIG_CAMERA_CORE1 + xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 1); +#else + xTaskCreate(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle); +#endif + + ESP_LOGI(TAG, "cam config ok"); + return ESP_OK; + +err: + cam_deinit(); + return ESP_FAIL; +} + +esp_err_t cam_deinit(void) +{ + if (!cam_obj) { + return ESP_FAIL; + } + + cam_stop(); + if (cam_obj->task_handle) { + vTaskDelete(cam_obj->task_handle); + } + if (cam_obj->event_queue) { + vQueueDelete(cam_obj->event_queue); + } + if (cam_obj->frame_buffer_queue) { + vQueueDelete(cam_obj->frame_buffer_queue); + } + if (cam_obj->dma) { + free(cam_obj->dma); + } + if (cam_obj->dma_buffer) { + free(cam_obj->dma_buffer); + } + if (cam_obj->frames) { + for (int x = 0; x < cam_obj->frame_cnt; x++) { + free(cam_obj->frames[x].fb.buf - cam_obj->frames[x].fb_offset); + if (cam_obj->frames[x].dma) { + free(cam_obj->frames[x].dma); + } + } + free(cam_obj->frames); + } + + ll_cam_deinit(cam_obj); + + free(cam_obj); + cam_obj = NULL; + return ESP_OK; +} + +void cam_stop(void) +{ + ll_cam_vsync_intr_enable(cam_obj, false); + ll_cam_stop(cam_obj); +} + +void cam_start(void) +{ + ll_cam_vsync_intr_enable(cam_obj, true); +} + +camera_fb_t *cam_take(TickType_t timeout) +{ + camera_fb_t *dma_buffer = NULL; + TickType_t start = xTaskGetTickCount(); + xQueueReceive(cam_obj->frame_buffer_queue, (void *)&dma_buffer, timeout); + if (dma_buffer) { + if(cam_obj->jpeg_mode){ + // find the end marker for JPEG. Data after that can be discarded + int offset_e = cam_verify_jpeg_eoi(dma_buffer->buf, dma_buffer->len); + if (offset_e >= 0) { + // adjust buffer length + dma_buffer->len = offset_e + sizeof(JPEG_EOI_MARKER); + return dma_buffer; + } else { + ESP_LOGW(TAG, "NO-EOI"); + cam_give(dma_buffer); + return cam_take(timeout - (xTaskGetTickCount() - start));//recurse!!!! + } + } else if(cam_obj->psram_mode && cam_obj->in_bytes_per_pixel != cam_obj->fb_bytes_per_pixel){ + //currently this is used only for YUV to GRAYSCALE + dma_buffer->len = ll_cam_memcpy(cam_obj, dma_buffer->buf, dma_buffer->buf, dma_buffer->len); + } + return dma_buffer; + } else { + ESP_LOGW(TAG, "Failed to get the frame on time!"); + } + return NULL; +} + +void cam_give(camera_fb_t *dma_buffer) +{ + for (int x = 0; x < cam_obj->frame_cnt; x++) { + if (&cam_obj->frames[x].fb == dma_buffer) { + cam_obj->frames[x].en = 1; + break; + } + } +} diff --git a/lib/libesp32_div/esp32-camera/driver/esp_camera.c b/lib/libesp32_div/esp32-camera/driver/esp_camera.c new file mode 100644 index 000000000..9ae1b56ca --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/esp_camera.c @@ -0,0 +1,416 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#include +#include +#include +#include "time.h" +#include "sys/time.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "driver/gpio.h" +#include "esp_system.h" +#include "nvs_flash.h" +#include "nvs.h" +#include "sensor.h" +#include "sccb.h" +#include "cam_hal.h" +#include "esp_camera.h" +#include "xclk.h" +#if CONFIG_OV2640_SUPPORT +#include "ov2640.h" +#endif +#if CONFIG_OV7725_SUPPORT +#include "ov7725.h" +#endif +#if CONFIG_OV3660_SUPPORT +#include "ov3660.h" +#endif +#if CONFIG_OV5640_SUPPORT +#include "ov5640.h" +#endif +#if CONFIG_NT99141_SUPPORT +#include "nt99141.h" +#endif +#if CONFIG_OV7670_SUPPORT +#include "ov7670.h" +#endif +#if CONFIG_GC2145_SUPPORT +#include "gc2145.h" +#endif +#if CONFIG_GC032A_SUPPORT +#include "gc032a.h" +#endif +#if CONFIG_GC0308_SUPPORT +#include "gc0308.h" +#endif + + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#define TAG "" +#else +#include "esp_log.h" +static const char *TAG = "camera"; +#endif + +typedef struct { + sensor_t sensor; + camera_fb_t fb; +} camera_state_t; + +static const char *CAMERA_SENSOR_NVS_KEY = "sensor"; +static const char *CAMERA_PIXFORMAT_NVS_KEY = "pixformat"; +static camera_state_t *s_state = NULL; + +#if CONFIG_IDF_TARGET_ESP32S3 // LCD_CAM module of ESP32-S3 will generate xclk +#define CAMERA_ENABLE_OUT_CLOCK(v) +#define CAMERA_DISABLE_OUT_CLOCK() +#else +#define CAMERA_ENABLE_OUT_CLOCK(v) camera_enable_out_clock((v)) +#define CAMERA_DISABLE_OUT_CLOCK() camera_disable_out_clock() +#endif + +typedef struct { + int (*detect)(int slv_addr, sensor_id_t *id); + int (*init)(sensor_t *sensor); +} sensor_func_t; + +static const sensor_func_t g_sensors[] = { +#if CONFIG_OV7725_SUPPORT + {ov7725_detect, ov7725_init}, +#endif +#if CONFIG_OV7670_SUPPORT + {ov7670_detect, ov7670_init}, +#endif +#if CONFIG_OV2640_SUPPORT + {ov2640_detect, ov2640_init}, +#endif +#if CONFIG_OV3660_SUPPORT + {ov3660_detect, ov3660_init}, +#endif +#if CONFIG_OV5640_SUPPORT + {ov5640_detect, ov5640_init}, +#endif +#if CONFIG_NT99141_SUPPORT + {nt99141_detect, nt99141_init}, +#endif +#if CONFIG_GC2145_SUPPORT + {gc2145_detect, gc2145_init}, +#endif +#if CONFIG_GC032A_SUPPORT + {gc032a_detect, gc032a_init}, +#endif +#if CONFIG_GC0308_SUPPORT + {gc0308_detect, gc0308_init}, +#endif +}; + +static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out_camera_model) +{ + *out_camera_model = CAMERA_NONE; + if (s_state != NULL) { + return ESP_ERR_INVALID_STATE; + } + + s_state = (camera_state_t *) calloc(sizeof(camera_state_t), 1); + if (!s_state) { + return ESP_ERR_NO_MEM; + } + + if (config->pin_xclk >= 0) { + ESP_LOGD(TAG, "Enabling XCLK output"); + CAMERA_ENABLE_OUT_CLOCK(config); + } + + if (config->pin_sscb_sda != -1) { + ESP_LOGD(TAG, "Initializing SSCB"); + SCCB_Init(config->pin_sscb_sda, config->pin_sscb_scl); + } + + if (config->pin_pwdn >= 0) { + ESP_LOGD(TAG, "Resetting camera by power down line"); + gpio_config_t conf = { 0 }; + conf.pin_bit_mask = 1LL << config->pin_pwdn; + conf.mode = GPIO_MODE_OUTPUT; + gpio_config(&conf); + + // carefull, logic is inverted compared to reset pin + gpio_set_level(config->pin_pwdn, 1); + vTaskDelay(10 / portTICK_PERIOD_MS); + gpio_set_level(config->pin_pwdn, 0); + vTaskDelay(10 / portTICK_PERIOD_MS); + } + + if (config->pin_reset >= 0) { + ESP_LOGD(TAG, "Resetting camera"); + gpio_config_t conf = { 0 }; + conf.pin_bit_mask = 1LL << config->pin_reset; + conf.mode = GPIO_MODE_OUTPUT; + gpio_config(&conf); + + gpio_set_level(config->pin_reset, 0); + vTaskDelay(10 / portTICK_PERIOD_MS); + gpio_set_level(config->pin_reset, 1); + vTaskDelay(10 / portTICK_PERIOD_MS); + } + + + ESP_LOGD(TAG, "Searching for camera address"); + vTaskDelay(10 / portTICK_PERIOD_MS); + + uint8_t slv_addr = SCCB_Probe(); + + if (slv_addr == 0) { + CAMERA_DISABLE_OUT_CLOCK(); + return ESP_ERR_NOT_FOUND; + } + + ESP_LOGI(TAG, "Detected camera at address=0x%02x", slv_addr); + s_state->sensor.slv_addr = slv_addr; + s_state->sensor.xclk_freq_hz = config->xclk_freq_hz; + + /** + * Read sensor ID and then initialize sensor + * Attention: Some sensors have the same SCCB address. Therefore, several attempts may be made in the detection process + */ + sensor_id_t *id = &s_state->sensor.id; + for (size_t i = 0; i < sizeof(g_sensors) / sizeof(sensor_func_t); i++) { + if (g_sensors[i].detect(slv_addr, id)) { + camera_sensor_info_t *info = esp_camera_sensor_get_info(id); + if (NULL != info) { + *out_camera_model = info->model; + ESP_LOGI(TAG, "Detected %s camera", info->name); + g_sensors[i].init(&s_state->sensor); + break; + } + } + } + + if (CAMERA_NONE == *out_camera_model) { //If no supported sensors are detected + CAMERA_DISABLE_OUT_CLOCK(); + ESP_LOGE(TAG, "Detected camera not supported."); + return ESP_ERR_NOT_SUPPORTED; + } + + ESP_LOGI(TAG, "Camera PID=0x%02x VER=0x%02x MIDL=0x%02x MIDH=0x%02x", + id->PID, id->VER, id->MIDH, id->MIDL); + + ESP_LOGD(TAG, "Doing SW reset of sensor"); + vTaskDelay(10 / portTICK_PERIOD_MS); + s_state->sensor.reset(&s_state->sensor); + + return ESP_OK; +} + +esp_err_t esp_camera_init(const camera_config_t *config) +{ + esp_err_t err; + err = cam_init(config); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); + return err; + } + + camera_model_t camera_model = CAMERA_NONE; + err = camera_probe(config, &camera_model); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Camera probe failed with error 0x%x(%s)", err, esp_err_to_name(err)); + goto fail; + } + + framesize_t frame_size = (framesize_t) config->frame_size; + pixformat_t pix_format = (pixformat_t) config->pixel_format; + + if (PIXFORMAT_JPEG == pix_format && (!camera_sensor[camera_model].support_jpeg)) { + ESP_LOGE(TAG, "JPEG format is not supported on this sensor"); + err = ESP_ERR_NOT_SUPPORTED; + goto fail; + } + + if (frame_size > camera_sensor[camera_model].max_size) { + ESP_LOGW(TAG, "The frame size exceeds the maximum for this sensor, it will be forced to the maximum possible value"); + frame_size = camera_sensor[camera_model].max_size; + } + + err = cam_config(config, frame_size, s_state->sensor.id.PID); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Camera config failed with error 0x%x", err); + goto fail; + } + + s_state->sensor.status.framesize = frame_size; + s_state->sensor.pixformat = pix_format; + ESP_LOGD(TAG, "Setting frame size to %dx%d", resolution[frame_size].width, resolution[frame_size].height); + if (s_state->sensor.set_framesize(&s_state->sensor, frame_size) != 0) { + ESP_LOGE(TAG, "Failed to set frame size"); + err = ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE; + goto fail; + } + s_state->sensor.set_pixformat(&s_state->sensor, pix_format); + + if (s_state->sensor.id.PID == OV2640_PID) { + s_state->sensor.set_gainceiling(&s_state->sensor, GAINCEILING_2X); + s_state->sensor.set_bpc(&s_state->sensor, false); + s_state->sensor.set_wpc(&s_state->sensor, true); + s_state->sensor.set_lenc(&s_state->sensor, true); + } + + if (pix_format == PIXFORMAT_JPEG) { + s_state->sensor.set_quality(&s_state->sensor, config->jpeg_quality); + } + s_state->sensor.init_status(&s_state->sensor); + + cam_start(); + + return ESP_OK; + +fail: + esp_camera_deinit(); + return err; +} + +esp_err_t esp_camera_deinit() +{ + esp_err_t ret = cam_deinit(); + CAMERA_DISABLE_OUT_CLOCK(); + if (s_state) { + SCCB_Deinit(); + + free(s_state); + s_state = NULL; + } + + return ret; +} + +#define FB_GET_TIMEOUT (4000 / portTICK_PERIOD_MS) + +camera_fb_t *esp_camera_fb_get() +{ + if (s_state == NULL) { + return NULL; + } + camera_fb_t *fb = cam_take(FB_GET_TIMEOUT); + //set the frame properties + if (fb) { + fb->width = resolution[s_state->sensor.status.framesize].width; + fb->height = resolution[s_state->sensor.status.framesize].height; + fb->format = s_state->sensor.pixformat; + } + return fb; +} + +void esp_camera_fb_return(camera_fb_t *fb) +{ + if (s_state == NULL) { + return; + } + cam_give(fb); +} + +sensor_t *esp_camera_sensor_get() +{ + if (s_state == NULL) { + return NULL; + } + return &s_state->sensor; +} + +esp_err_t esp_camera_save_to_nvs(const char *key) +{ +#if ESP_IDF_VERSION_MAJOR > 3 + nvs_handle_t handle; +#else + nvs_handle handle; +#endif + esp_err_t ret = nvs_open(key, NVS_READWRITE, &handle); + + if (ret == ESP_OK) { + sensor_t *s = esp_camera_sensor_get(); + if (s != NULL) { + ret = nvs_set_blob(handle, CAMERA_SENSOR_NVS_KEY, &s->status, sizeof(camera_status_t)); + if (ret == ESP_OK) { + uint8_t pf = s->pixformat; + ret = nvs_set_u8(handle, CAMERA_PIXFORMAT_NVS_KEY, pf); + } + return ret; + } else { + return ESP_ERR_CAMERA_NOT_DETECTED; + } + nvs_close(handle); + return ret; + } else { + return ret; + } +} + +esp_err_t esp_camera_load_from_nvs(const char *key) +{ +#if ESP_IDF_VERSION_MAJOR > 3 + nvs_handle_t handle; +#else + nvs_handle handle; +#endif + uint8_t pf; + + esp_err_t ret = nvs_open(key, NVS_READWRITE, &handle); + + if (ret == ESP_OK) { + sensor_t *s = esp_camera_sensor_get(); + camera_status_t st; + if (s != NULL) { + size_t size = sizeof(camera_status_t); + ret = nvs_get_blob(handle, CAMERA_SENSOR_NVS_KEY, &st, &size); + if (ret == ESP_OK) { + s->set_ae_level(s, st.ae_level); + s->set_aec2(s, st.aec2); + s->set_aec_value(s, st.aec_value); + s->set_agc_gain(s, st.agc_gain); + s->set_awb_gain(s, st.awb_gain); + s->set_bpc(s, st.bpc); + s->set_brightness(s, st.brightness); + s->set_colorbar(s, st.colorbar); + s->set_contrast(s, st.contrast); + s->set_dcw(s, st.dcw); + s->set_denoise(s, st.denoise); + s->set_exposure_ctrl(s, st.aec); + s->set_framesize(s, st.framesize); + s->set_gain_ctrl(s, st.agc); + s->set_gainceiling(s, st.gainceiling); + s->set_hmirror(s, st.hmirror); + s->set_lenc(s, st.lenc); + s->set_quality(s, st.quality); + s->set_raw_gma(s, st.raw_gma); + s->set_saturation(s, st.saturation); + s->set_sharpness(s, st.sharpness); + s->set_special_effect(s, st.special_effect); + s->set_vflip(s, st.vflip); + s->set_wb_mode(s, st.wb_mode); + s->set_whitebal(s, st.awb); + s->set_wpc(s, st.wpc); + } + ret = nvs_get_u8(handle, CAMERA_PIXFORMAT_NVS_KEY, &pf); + if (ret == ESP_OK) { + s->set_pixformat(s, pf); + } + } else { + return ESP_ERR_CAMERA_NOT_DETECTED; + } + nvs_close(handle); + return ret; + } else { + ESP_LOGW(TAG, "Error (%d) opening nvs key \"%s\"", ret, key); + return ret; + } +} diff --git a/lib/libesp32_div/esp32-camera/driver/include/esp_camera.h b/lib/libesp32_div/esp32-camera/driver/include/esp_camera.h new file mode 100644 index 000000000..e9981671f --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/include/esp_camera.h @@ -0,0 +1,214 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +/* + * Example Use + * + static camera_config_t camera_example_config = { + .pin_pwdn = PIN_PWDN, + .pin_reset = PIN_RESET, + .pin_xclk = PIN_XCLK, + .pin_sscb_sda = PIN_SIOD, + .pin_sscb_scl = PIN_SIOC, + .pin_d7 = PIN_D7, + .pin_d6 = PIN_D6, + .pin_d5 = PIN_D5, + .pin_d4 = PIN_D4, + .pin_d3 = PIN_D3, + .pin_d2 = PIN_D2, + .pin_d1 = PIN_D1, + .pin_d0 = PIN_D0, + .pin_vsync = PIN_VSYNC, + .pin_href = PIN_HREF, + .pin_pclk = PIN_PCLK, + + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + .pixel_format = PIXFORMAT_JPEG, + .frame_size = FRAMESIZE_SVGA, + .jpeg_quality = 10, + .fb_count = 2, + .grab_mode = CAMERA_GRAB_WHEN_EMPTY + }; + + esp_err_t camera_example_init(){ + return esp_camera_init(&camera_example_config); + } + + esp_err_t camera_example_capture(){ + //capture a frame + camera_fb_t * fb = esp_camera_fb_get(); + if (!fb) { + ESP_LOGE(TAG, "Frame buffer could not be acquired"); + return ESP_FAIL; + } + + //replace this with your own function + display_image(fb->width, fb->height, fb->pixformat, fb->buf, fb->len); + + //return the frame buffer back to be reused + esp_camera_fb_return(fb); + + return ESP_OK; + } +*/ + +#pragma once + +#include "esp_err.h" +#include "driver/ledc.h" +#include "sensor.h" +#include "sys/time.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Configuration structure for camera initialization + */ +typedef enum { + CAMERA_GRAB_WHEN_EMPTY, /*!< Fills buffers when they are empty. Less resources but first 'fb_count' frames might be old */ + CAMERA_GRAB_LATEST /*!< Except when 1 frame buffer is used, queue will always contain the last 'fb_count' frames */ +} camera_grab_mode_t; + +/** + * @brief Camera frame buffer location + */ +typedef enum { + CAMERA_FB_IN_PSRAM, /*!< Frame buffer is placed in external PSRAM */ + CAMERA_FB_IN_DRAM /*!< Frame buffer is placed in internal DRAM */ +} camera_fb_location_t; + +/** + * @brief Configuration structure for camera initialization + */ +typedef struct { + int pin_pwdn; /*!< GPIO pin for camera power down line */ + int pin_reset; /*!< GPIO pin for camera reset line */ + int pin_xclk; /*!< GPIO pin for camera XCLK line */ + int pin_sscb_sda; /*!< GPIO pin for camera SDA line */ + int pin_sscb_scl; /*!< GPIO pin for camera SCL line */ + int pin_d7; /*!< GPIO pin for camera D7 line */ + int pin_d6; /*!< GPIO pin for camera D6 line */ + int pin_d5; /*!< GPIO pin for camera D5 line */ + int pin_d4; /*!< GPIO pin for camera D4 line */ + int pin_d3; /*!< GPIO pin for camera D3 line */ + int pin_d2; /*!< GPIO pin for camera D2 line */ + int pin_d1; /*!< GPIO pin for camera D1 line */ + int pin_d0; /*!< GPIO pin for camera D0 line */ + int pin_vsync; /*!< GPIO pin for camera VSYNC line */ + int pin_href; /*!< GPIO pin for camera HREF line */ + int pin_pclk; /*!< GPIO pin for camera PCLK line */ + + int xclk_freq_hz; /*!< Frequency of XCLK signal, in Hz. EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode */ + + ledc_timer_t ledc_timer; /*!< LEDC timer to be used for generating XCLK */ + ledc_channel_t ledc_channel; /*!< LEDC channel to be used for generating XCLK */ + + pixformat_t pixel_format; /*!< Format of the pixel data: PIXFORMAT_ + YUV422|GRAYSCALE|RGB565|JPEG */ + framesize_t frame_size; /*!< Size of the output image: FRAMESIZE_ + QVGA|CIF|VGA|SVGA|XGA|SXGA|UXGA */ + + int jpeg_quality; /*!< Quality of JPEG output. 0-63 lower means higher quality */ + size_t fb_count; /*!< Number of frame buffers to be allocated. If more than one, then each frame will be acquired (double speed) */ + camera_fb_location_t fb_location; /*!< The location where the frame buffer will be allocated */ + camera_grab_mode_t grab_mode; /*!< When buffers should be filled */ +} camera_config_t; + +/** + * @brief Data structure of camera frame buffer + */ +typedef struct { + uint8_t * buf; /*!< Pointer to the pixel data */ + size_t len; /*!< Length of the buffer in bytes */ + size_t width; /*!< Width of the buffer in pixels */ + size_t height; /*!< Height of the buffer in pixels */ + pixformat_t format; /*!< Format of the pixel data */ + struct timeval timestamp; /*!< Timestamp since boot of the first DMA buffer of the frame */ +} camera_fb_t; + +#define ESP_ERR_CAMERA_BASE 0x20000 +#define ESP_ERR_CAMERA_NOT_DETECTED (ESP_ERR_CAMERA_BASE + 1) +#define ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE (ESP_ERR_CAMERA_BASE + 2) +#define ESP_ERR_CAMERA_FAILED_TO_SET_OUT_FORMAT (ESP_ERR_CAMERA_BASE + 3) +#define ESP_ERR_CAMERA_NOT_SUPPORTED (ESP_ERR_CAMERA_BASE + 4) + +/** + * @brief Initialize the camera driver + * + * @note call camera_probe before calling this function + * + * This function detects and configures camera over I2C interface, + * allocates framebuffer and DMA buffers, + * initializes parallel I2S input, and sets up DMA descriptors. + * + * Currently this function can only be called once and there is + * no way to de-initialize this module. + * + * @param config Camera configuration parameters + * + * @return ESP_OK on success + */ +esp_err_t esp_camera_init(const camera_config_t* config); + +/** + * @brief Deinitialize the camera driver + * + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_STATE if the driver hasn't been initialized yet + */ +esp_err_t esp_camera_deinit(); + +/** + * @brief Obtain pointer to a frame buffer. + * + * @return pointer to the frame buffer + */ +camera_fb_t* esp_camera_fb_get(); + +/** + * @brief Return the frame buffer to be reused again. + * + * @param fb Pointer to the frame buffer + */ +void esp_camera_fb_return(camera_fb_t * fb); + +/** + * @brief Get a pointer to the image sensor control structure + * + * @return pointer to the sensor + */ +sensor_t * esp_camera_sensor_get(); + +/** + * @brief Save camera settings to non-volatile-storage (NVS) + * + * @param key A unique nvs key name for the camera settings + */ +esp_err_t esp_camera_save_to_nvs(const char *key); + +/** + * @brief Load camera settings from non-volatile-storage (NVS) + * + * @param key A unique nvs key name for the camera settings + */ +esp_err_t esp_camera_load_from_nvs(const char *key); + +#ifdef __cplusplus +} +#endif + +#include "img_converters.h" + diff --git a/lib/libesp32_div/esp32-camera/driver/include/sensor.h b/lib/libesp32_div/esp32-camera/driver/include/sensor.h new file mode 100644 index 000000000..1f99c1541 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/include/sensor.h @@ -0,0 +1,245 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * Sensor abstraction layer. + * + */ +#ifndef __SENSOR_H__ +#define __SENSOR_H__ +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + OV9650_PID = 0x96, + OV7725_PID = 0x77, + OV2640_PID = 0x26, + OV3660_PID = 0x3660, + OV5640_PID = 0x5640, + OV7670_PID = 0x76, + NT99141_PID = 0x1410, + GC2145_PID = 0x2145, + GC032A_PID = 0x232a, + GC0308_PID = 0x9b, +} camera_pid_t; + +typedef enum { + CAMERA_OV7725, + CAMERA_OV2640, + CAMERA_OV3660, + CAMERA_OV5640, + CAMERA_OV7670, + CAMERA_NT99141, + CAMERA_GC2145, + CAMERA_GC032A, + CAMERA_GC0308, + CAMERA_MODEL_MAX, + CAMERA_NONE, +} camera_model_t; + +typedef enum { + OV2640_SCCB_ADDR = 0x30,// 0x60 >> 1 + OV5640_SCCB_ADDR = 0x3C,// 0x78 >> 1 + OV3660_SCCB_ADDR = 0x3C,// 0x78 >> 1 + OV7725_SCCB_ADDR = 0x21,// 0x42 >> 1 + OV7670_SCCB_ADDR = 0x21,// 0x42 >> 1 + NT99141_SCCB_ADDR = 0x2A,// 0x54 >> 1 + GC2145_SCCB_ADDR = 0x3C,// 0x78 >> 1 + GC032A_SCCB_ADDR = 0x21,// 0x42 >> 1 + GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1 +} camera_sccb_addr_t; + +typedef enum { + PIXFORMAT_RGB565, // 2BPP/RGB565 + PIXFORMAT_YUV422, // 2BPP/YUV422 + PIXFORMAT_GRAYSCALE, // 1BPP/GRAYSCALE + PIXFORMAT_JPEG, // JPEG/COMPRESSED + PIXFORMAT_RGB888, // 3BPP/RGB888 + PIXFORMAT_RAW, // RAW + PIXFORMAT_RGB444, // 3BP2P/RGB444 + PIXFORMAT_RGB555, // 3BP2P/RGB555 +} pixformat_t; + +typedef enum { + FRAMESIZE_96X96, // 96x96 + FRAMESIZE_QQVGA, // 160x120 + FRAMESIZE_QCIF, // 176x144 + FRAMESIZE_HQVGA, // 240x176 + FRAMESIZE_240X240, // 240x240 + FRAMESIZE_QVGA, // 320x240 + FRAMESIZE_CIF, // 400x296 + FRAMESIZE_HVGA, // 480x320 + FRAMESIZE_VGA, // 640x480 + FRAMESIZE_SVGA, // 800x600 + FRAMESIZE_XGA, // 1024x768 + FRAMESIZE_HD, // 1280x720 + FRAMESIZE_SXGA, // 1280x1024 + FRAMESIZE_UXGA, // 1600x1200 + // 3MP Sensors + FRAMESIZE_FHD, // 1920x1080 + FRAMESIZE_P_HD, // 720x1280 + FRAMESIZE_P_3MP, // 864x1536 + FRAMESIZE_QXGA, // 2048x1536 + // 5MP Sensors + FRAMESIZE_QHD, // 2560x1440 + FRAMESIZE_WQXGA, // 2560x1600 + FRAMESIZE_P_FHD, // 1080x1920 + FRAMESIZE_QSXGA, // 2560x1920 + FRAMESIZE_INVALID +} framesize_t; + +typedef struct { + const camera_model_t model; + const char *name; + const camera_sccb_addr_t sccb_addr; + const camera_pid_t pid; + const framesize_t max_size; + const bool support_jpeg; +} camera_sensor_info_t; + +typedef enum { + ASPECT_RATIO_4X3, + ASPECT_RATIO_3X2, + ASPECT_RATIO_16X10, + ASPECT_RATIO_5X3, + ASPECT_RATIO_16X9, + ASPECT_RATIO_21X9, + ASPECT_RATIO_5X4, + ASPECT_RATIO_1X1, + ASPECT_RATIO_9X16 +} aspect_ratio_t; + +typedef enum { + GAINCEILING_2X, + GAINCEILING_4X, + GAINCEILING_8X, + GAINCEILING_16X, + GAINCEILING_32X, + GAINCEILING_64X, + GAINCEILING_128X, +} gainceiling_t; + +typedef struct { + uint16_t max_width; + uint16_t max_height; + uint16_t start_x; + uint16_t start_y; + uint16_t end_x; + uint16_t end_y; + uint16_t offset_x; + uint16_t offset_y; + uint16_t total_x; + uint16_t total_y; +} ratio_settings_t; + +typedef struct { + const uint16_t width; + const uint16_t height; + const aspect_ratio_t aspect_ratio; +} resolution_info_t; + +// Resolution table (in sensor.c) +extern const resolution_info_t resolution[]; +// camera sensor table (in sensor.c) +extern const camera_sensor_info_t camera_sensor[]; + +typedef struct { + uint8_t MIDH; + uint8_t MIDL; + uint16_t PID; + uint8_t VER; +} sensor_id_t; + +typedef struct { + framesize_t framesize;//0 - 10 + bool scale; + bool binning; + uint8_t quality;//0 - 63 + int8_t brightness;//-2 - 2 + int8_t contrast;//-2 - 2 + int8_t saturation;//-2 - 2 + int8_t sharpness;//-2 - 2 + uint8_t denoise; + uint8_t special_effect;//0 - 6 + uint8_t wb_mode;//0 - 4 + uint8_t awb; + uint8_t awb_gain; + uint8_t aec; + uint8_t aec2; + int8_t ae_level;//-2 - 2 + uint16_t aec_value;//0 - 1200 + uint8_t agc; + uint8_t agc_gain;//0 - 30 + uint8_t gainceiling;//0 - 6 + uint8_t bpc; + uint8_t wpc; + uint8_t raw_gma; + uint8_t lenc; + uint8_t hmirror; + uint8_t vflip; + uint8_t dcw; + uint8_t colorbar; +} camera_status_t; + +typedef struct _sensor sensor_t; +typedef struct _sensor { + sensor_id_t id; // Sensor ID. + uint8_t slv_addr; // Sensor I2C slave address. + pixformat_t pixformat; + camera_status_t status; + int xclk_freq_hz; + + // Sensor function pointers + int (*init_status) (sensor_t *sensor); + int (*reset) (sensor_t *sensor); + int (*set_pixformat) (sensor_t *sensor, pixformat_t pixformat); + int (*set_framesize) (sensor_t *sensor, framesize_t framesize); + int (*set_contrast) (sensor_t *sensor, int level); + int (*set_brightness) (sensor_t *sensor, int level); + int (*set_saturation) (sensor_t *sensor, int level); + int (*set_sharpness) (sensor_t *sensor, int level); + int (*set_denoise) (sensor_t *sensor, int level); + int (*set_gainceiling) (sensor_t *sensor, gainceiling_t gainceiling); + int (*set_quality) (sensor_t *sensor, int quality); + int (*set_colorbar) (sensor_t *sensor, int enable); + int (*set_whitebal) (sensor_t *sensor, int enable); + int (*set_gain_ctrl) (sensor_t *sensor, int enable); + int (*set_exposure_ctrl) (sensor_t *sensor, int enable); + int (*set_hmirror) (sensor_t *sensor, int enable); + int (*set_vflip) (sensor_t *sensor, int enable); + + int (*set_aec2) (sensor_t *sensor, int enable); + int (*set_awb_gain) (sensor_t *sensor, int enable); + int (*set_agc_gain) (sensor_t *sensor, int gain); + int (*set_aec_value) (sensor_t *sensor, int gain); + + int (*set_special_effect) (sensor_t *sensor, int effect); + int (*set_wb_mode) (sensor_t *sensor, int mode); + int (*set_ae_level) (sensor_t *sensor, int level); + + int (*set_dcw) (sensor_t *sensor, int enable); + int (*set_bpc) (sensor_t *sensor, int enable); + int (*set_wpc) (sensor_t *sensor, int enable); + + int (*set_raw_gma) (sensor_t *sensor, int enable); + int (*set_lenc) (sensor_t *sensor, int enable); + + int (*get_reg) (sensor_t *sensor, int reg, int mask); + int (*set_reg) (sensor_t *sensor, int reg, int mask, int value); + int (*set_res_raw) (sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning); + int (*set_pll) (sensor_t *sensor, int bypass, int mul, int sys, int root, int pre, int seld5, int pclken, int pclk); + int (*set_xclk) (sensor_t *sensor, int timer, int xclk); +} sensor_t; + +camera_sensor_info_t *esp_camera_sensor_get_info(sensor_id_t *id); + +#ifdef __cplusplus +} +#endif + +#endif /* __SENSOR_H__ */ diff --git a/lib/libesp32_div/esp32-camera/driver/private_include/cam_hal.h b/lib/libesp32_div/esp32-camera/driver/private_include/cam_hal.h new file mode 100644 index 000000000..c8e38ed47 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/private_include/cam_hal.h @@ -0,0 +1,60 @@ +// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include "esp_camera.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Uninitialize the lcd_cam module + * + * @param handle Provide handle pointer to release resources + * + * @return + * - ESP_OK Success + * - ESP_FAIL Uninitialize fail + */ +esp_err_t cam_deinit(void); + +/** + * @brief Initialize the lcd_cam module + * + * @param config Configurations - see lcd_cam_config_t struct + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_ERR_NO_MEM No memory to initialize lcd_cam + * - ESP_FAIL Initialize fail + */ +esp_err_t cam_init(const camera_config_t *config); + +esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint16_t sensor_pid); + +void cam_stop(void); + +void cam_start(void); + +camera_fb_t *cam_take(TickType_t timeout); + +void cam_give(camera_fb_t *dma_buffer); + +#ifdef __cplusplus +} +#endif diff --git a/lib/libesp32_div/esp32-camera/driver/private_include/sccb.h b/lib/libesp32_div/esp32-camera/driver/private_include/sccb.h new file mode 100644 index 000000000..ace081a48 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/private_include/sccb.h @@ -0,0 +1,19 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * SCCB (I2C like) driver. + * + */ +#ifndef __SCCB_H__ +#define __SCCB_H__ +#include +int SCCB_Init(int pin_sda, int pin_scl); +int SCCB_Deinit(void); +uint8_t SCCB_Probe(); +uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg); +uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data); +uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg); +uint8_t SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data); +#endif // __SCCB_H__ diff --git a/lib/libesp32_div/esp32-camera/driver/private_include/xclk.h b/lib/libesp32_div/esp32-camera/driver/private_include/xclk.h new file mode 100644 index 000000000..3d721a613 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/private_include/xclk.h @@ -0,0 +1,9 @@ +#pragma once + +#include "esp_system.h" + +esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz); + +esp_err_t camera_enable_out_clock(); + +void camera_disable_out_clock(); diff --git a/lib/libesp32_div/esp32-camera/driver/sccb.c b/lib/libesp32_div/esp32-camera/driver/sccb.c new file mode 100644 index 000000000..1a2c56e23 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/sccb.c @@ -0,0 +1,184 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * SCCB (I2C like) driver. + * + */ +#include +#include +#include +#include +#include "sccb.h" +#include "sensor.h" +#include +#include "sdkconfig.h" +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "sccb"; +#endif + +#define LITTLETOBIG(x) ((x<<8)|(x>>8)) + +#include "driver/i2c.h" + +#define SCCB_FREQ 100000 /*!< I2C master frequency*/ +#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */ +#define READ_BIT I2C_MASTER_READ /*!< I2C master read */ +#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/ +#define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */ +#define ACK_VAL 0x0 /*!< I2C ack value */ +#define NACK_VAL 0x1 /*!< I2C nack value */ +#if CONFIG_SCCB_HARDWARE_I2C_PORT1 +const int SCCB_I2C_PORT = 1; +#else +const int SCCB_I2C_PORT = 0; +#endif + +int SCCB_Init(int pin_sda, int pin_scl) +{ + ESP_LOGI(TAG, "pin_sda %d pin_scl %d", pin_sda, pin_scl); + i2c_config_t conf; + memset(&conf, 0, sizeof(i2c_config_t)); + conf.mode = I2C_MODE_MASTER; + conf.sda_io_num = pin_sda; + conf.sda_pullup_en = GPIO_PULLUP_ENABLE; + conf.scl_io_num = pin_scl; + conf.scl_pullup_en = GPIO_PULLUP_ENABLE; + conf.master.clk_speed = SCCB_FREQ; + + i2c_param_config(SCCB_I2C_PORT, &conf); + i2c_driver_install(SCCB_I2C_PORT, conf.mode, 0, 0, 0); + return 0; +} + +int SCCB_Deinit(void) +{ + return i2c_driver_delete(SCCB_I2C_PORT); +} + +uint8_t SCCB_Probe(void) +{ + uint8_t slave_addr = 0x0; + // for (size_t i = 1; i < 0x80; i++) { + // i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + // i2c_master_start(cmd); + // i2c_master_write_byte(cmd, ( i << 1 ) | WRITE_BIT, ACK_CHECK_EN); + // i2c_master_stop(cmd); + // esp_err_t ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + // i2c_cmd_link_delete(cmd); + // if( ret == ESP_OK) { + // ESP_LOGW(TAG, "Found I2C Device at 0x%02X", i); + // } + // } + for (size_t i = 0; i < CAMERA_MODEL_MAX; i++) { + if (slave_addr == camera_sensor[i].sccb_addr) { + continue; + } + slave_addr = camera_sensor[i].sccb_addr; + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slave_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); + i2c_master_stop(cmd); + esp_err_t ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if( ret == ESP_OK) { + return slave_addr; + } + } + return 0; +} + +uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg) +{ + uint8_t data=0; + esp_err_t ret = ESP_FAIL; + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); + i2c_master_write_byte(cmd, reg, ACK_CHECK_EN); + i2c_master_stop(cmd); + ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if(ret != ESP_OK) return -1; + cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slv_addr << 1 ) | READ_BIT, ACK_CHECK_EN); + i2c_master_read_byte(cmd, &data, NACK_VAL); + i2c_master_stop(cmd); + ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if(ret != ESP_OK) { + ESP_LOGE(TAG, "SCCB_Read Failed addr:0x%02x, reg:0x%02x, data:0x%02x, ret:%d", slv_addr, reg, data, ret); + } + return data; +} + +uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data) +{ + esp_err_t ret = ESP_FAIL; + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); + i2c_master_write_byte(cmd, reg, ACK_CHECK_EN); + i2c_master_write_byte(cmd, data, ACK_CHECK_EN); + i2c_master_stop(cmd); + ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if(ret != ESP_OK) { + ESP_LOGE(TAG, "SCCB_Write Failed addr:0x%02x, reg:0x%02x, data:0x%02x, ret:%d", slv_addr, reg, data, ret); + } + return ret == ESP_OK ? 0 : -1; +} + +uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg) +{ + uint8_t data=0; + esp_err_t ret = ESP_FAIL; + uint16_t reg_htons = LITTLETOBIG(reg); + uint8_t *reg_u8 = (uint8_t *)®_htons; + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); + i2c_master_write_byte(cmd, reg_u8[0], ACK_CHECK_EN); + i2c_master_write_byte(cmd, reg_u8[1], ACK_CHECK_EN); + i2c_master_stop(cmd); + ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if(ret != ESP_OK) return -1; + cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slv_addr << 1 ) | READ_BIT, ACK_CHECK_EN); + i2c_master_read_byte(cmd, &data, NACK_VAL); + i2c_master_stop(cmd); + ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if(ret != ESP_OK) { + ESP_LOGE(TAG, "W [%04x]=%02x fail\n", reg, data); + } + return data; +} + +uint8_t SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data) +{ + static uint16_t i = 0; + esp_err_t ret = ESP_FAIL; + uint16_t reg_htons = LITTLETOBIG(reg); + uint8_t *reg_u8 = (uint8_t *)®_htons; + i2c_cmd_handle_t cmd = i2c_cmd_link_create(); + i2c_master_start(cmd); + i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); + i2c_master_write_byte(cmd, reg_u8[0], ACK_CHECK_EN); + i2c_master_write_byte(cmd, reg_u8[1], ACK_CHECK_EN); + i2c_master_write_byte(cmd, data, ACK_CHECK_EN); + i2c_master_stop(cmd); + ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); + i2c_cmd_link_delete(cmd); + if(ret != ESP_OK) { + ESP_LOGE(TAG, "W [%04x]=%02x %d fail\n", reg, data, i++); + } + return ret == ESP_OK ? 0 : -1; +} diff --git a/lib/libesp32_div/esp32-camera/driver/sensor.c b/lib/libesp32_div/esp32-camera/driver/sensor.c new file mode 100644 index 000000000..7ebd7af21 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/driver/sensor.c @@ -0,0 +1,52 @@ +#include +#include "sensor.h" + +const camera_sensor_info_t camera_sensor[CAMERA_MODEL_MAX] = { + // The sequence must be consistent with camera_model_t + {CAMERA_OV7725, "OV7725", OV7725_SCCB_ADDR, OV7725_PID, FRAMESIZE_VGA, false}, + {CAMERA_OV2640, "OV2640", OV2640_SCCB_ADDR, OV2640_PID, FRAMESIZE_UXGA, true}, + {CAMERA_OV3660, "OV3660", OV3660_SCCB_ADDR, OV3660_PID, FRAMESIZE_QXGA, true}, + {CAMERA_OV5640, "OV5640", OV5640_SCCB_ADDR, OV5640_PID, FRAMESIZE_QSXGA, true}, + {CAMERA_OV7670, "OV7670", OV7670_SCCB_ADDR, OV7670_PID, FRAMESIZE_VGA, false}, + {CAMERA_NT99141, "NT99141", NT99141_SCCB_ADDR, NT99141_PID, FRAMESIZE_HD, true}, + {CAMERA_GC2145, "GC2145", GC2145_SCCB_ADDR, GC2145_PID, FRAMESIZE_UXGA, false}, + {CAMERA_GC032A, "GC032A", GC032A_SCCB_ADDR, GC032A_PID, FRAMESIZE_VGA, false}, + {CAMERA_GC0308, "GC0308", GC0308_SCCB_ADDR, GC0308_PID, FRAMESIZE_VGA, false}, +}; + +const resolution_info_t resolution[FRAMESIZE_INVALID] = { + { 96, 96, ASPECT_RATIO_1X1 }, /* 96x96 */ + { 160, 120, ASPECT_RATIO_4X3 }, /* QQVGA */ + { 176, 144, ASPECT_RATIO_5X4 }, /* QCIF */ + { 240, 176, ASPECT_RATIO_4X3 }, /* HQVGA */ + { 240, 240, ASPECT_RATIO_1X1 }, /* 240x240 */ + { 320, 240, ASPECT_RATIO_4X3 }, /* QVGA */ + { 400, 296, ASPECT_RATIO_4X3 }, /* CIF */ + { 480, 320, ASPECT_RATIO_3X2 }, /* HVGA */ + { 640, 480, ASPECT_RATIO_4X3 }, /* VGA */ + { 800, 600, ASPECT_RATIO_4X3 }, /* SVGA */ + { 1024, 768, ASPECT_RATIO_4X3 }, /* XGA */ + { 1280, 720, ASPECT_RATIO_16X9 }, /* HD */ + { 1280, 1024, ASPECT_RATIO_5X4 }, /* SXGA */ + { 1600, 1200, ASPECT_RATIO_4X3 }, /* UXGA */ + // 3MP Sensors + { 1920, 1080, ASPECT_RATIO_16X9 }, /* FHD */ + { 720, 1280, ASPECT_RATIO_9X16 }, /* Portrait HD */ + { 864, 1536, ASPECT_RATIO_9X16 }, /* Portrait 3MP */ + { 2048, 1536, ASPECT_RATIO_4X3 }, /* QXGA */ + // 5MP Sensors + { 2560, 1440, ASPECT_RATIO_16X9 }, /* QHD */ + { 2560, 1600, ASPECT_RATIO_16X10 }, /* WQXGA */ + { 1088, 1920, ASPECT_RATIO_9X16 }, /* Portrait FHD */ + { 2560, 1920, ASPECT_RATIO_4X3 }, /* QSXGA */ +}; + +camera_sensor_info_t *esp_camera_sensor_get_info(sensor_id_t *id) +{ + for (int i = 0; i < CAMERA_MODEL_MAX; i++) { + if (id->PID == camera_sensor[i].pid) { + return (camera_sensor_info_t *)&camera_sensor[i]; + } + } + return NULL; +} diff --git a/lib/libesp32_div/esp32-camera/examples/CMakeLists.txt b/lib/libesp32_div/esp32-camera/examples/CMakeLists.txt new file mode 100644 index 000000000..0a0396884 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/examples/CMakeLists.txt @@ -0,0 +1,9 @@ +# The following lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.5) + +set(EXTRA_COMPONENT_DIRS "../") + +add_compile_options(-fdiagnostics-color=always) +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(camera_example) \ No newline at end of file diff --git a/lib/libesp32_div/esp32-camera/examples/Makefile b/lib/libesp32_div/esp32-camera/examples/Makefile new file mode 100644 index 000000000..f06df0ecc --- /dev/null +++ b/lib/libesp32_div/esp32-camera/examples/Makefile @@ -0,0 +1,11 @@ +# +# This is a project Makefile. It is assumed the directory this Makefile resides in is a +# project subdirectory. +# + +PROJECT_NAME := camera_example + +EXTRA_COMPONENT_DIRS := ../ + +include $(IDF_PATH)/make/project.mk + diff --git a/lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt b/lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt new file mode 100644 index 000000000..1735fb184 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt @@ -0,0 +1,3 @@ +set(COMPONENT_SRCS take_picture.c) +set(COMPONENT_ADD_INCLUDEDIRS .) +register_component() \ No newline at end of file diff --git a/lib/libesp32_div/esp32-camera/examples/main/component.mk b/lib/libesp32_div/esp32-camera/examples/main/component.mk new file mode 100644 index 000000000..0b9d7585e --- /dev/null +++ b/lib/libesp32_div/esp32-camera/examples/main/component.mk @@ -0,0 +1,5 @@ +# +# "main" pseudo-component makefile. +# +# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) + diff --git a/lib/libesp32_div/esp32-camera/examples/main/take_picture.c b/lib/libesp32_div/esp32-camera/examples/main/take_picture.c new file mode 100644 index 000000000..1cbad908b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/examples/main/take_picture.c @@ -0,0 +1,155 @@ +/** + * This example takes a picture every 5s and print its size on serial monitor. + */ + +// =============================== SETUP ====================================== + +// 1. Board setup (Uncomment): +// #define BOARD_WROVER_KIT +// #define BOARD_ESP32CAM_AITHINKER + +/** + * 2. Kconfig setup + * + * If you have a Kconfig file, copy the content from + * https://github.com/espressif/esp32-camera/blob/master/Kconfig into it. + * In case you haven't, copy and paste this Kconfig file inside the src directory. + * This Kconfig file has definitions that allows more control over the camera and + * how it will be initialized. + */ + +/** + * 3. Enable PSRAM on sdkconfig: + * + * CONFIG_ESP32_SPIRAM_SUPPORT=y + * + * More info on + * https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-esp32-spiram-support + */ + +// ================================ CODE ====================================== + +#include +#include +#include +#include +#include + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#include "esp_camera.h" + +#define BOARD_WROVER_KIT 1 + +// WROVER-KIT PIN Map +#ifdef BOARD_WROVER_KIT + +#define CAM_PIN_PWDN -1 //power down is not used +#define CAM_PIN_RESET -1 //software reset will be performed +#define CAM_PIN_XCLK 21 +#define CAM_PIN_SIOD 26 +#define CAM_PIN_SIOC 27 + +#define CAM_PIN_D7 35 +#define CAM_PIN_D6 34 +#define CAM_PIN_D5 39 +#define CAM_PIN_D4 36 +#define CAM_PIN_D3 19 +#define CAM_PIN_D2 18 +#define CAM_PIN_D1 5 +#define CAM_PIN_D0 4 +#define CAM_PIN_VSYNC 25 +#define CAM_PIN_HREF 23 +#define CAM_PIN_PCLK 22 + +#endif + +// ESP32Cam (AiThinker) PIN Map +#ifdef BOARD_ESP32CAM_AITHINKER + +#define CAM_PIN_PWDN 32 +#define CAM_PIN_RESET -1 //software reset will be performed +#define CAM_PIN_XCLK 0 +#define CAM_PIN_SIOD 26 +#define CAM_PIN_SIOC 27 + +#define CAM_PIN_D7 35 +#define CAM_PIN_D6 34 +#define CAM_PIN_D5 39 +#define CAM_PIN_D4 36 +#define CAM_PIN_D3 21 +#define CAM_PIN_D2 19 +#define CAM_PIN_D1 18 +#define CAM_PIN_D0 5 +#define CAM_PIN_VSYNC 25 +#define CAM_PIN_HREF 23 +#define CAM_PIN_PCLK 22 + +#endif + +static const char *TAG = "example:take_picture"; + +static camera_config_t camera_config = { + .pin_pwdn = CAM_PIN_PWDN, + .pin_reset = CAM_PIN_RESET, + .pin_xclk = CAM_PIN_XCLK, + .pin_sscb_sda = CAM_PIN_SIOD, + .pin_sscb_scl = CAM_PIN_SIOC, + + .pin_d7 = CAM_PIN_D7, + .pin_d6 = CAM_PIN_D6, + .pin_d5 = CAM_PIN_D5, + .pin_d4 = CAM_PIN_D4, + .pin_d3 = CAM_PIN_D3, + .pin_d2 = CAM_PIN_D2, + .pin_d1 = CAM_PIN_D1, + .pin_d0 = CAM_PIN_D0, + .pin_vsync = CAM_PIN_VSYNC, + .pin_href = CAM_PIN_HREF, + .pin_pclk = CAM_PIN_PCLK, + + //XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental) + .xclk_freq_hz = 20000000, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = PIXFORMAT_RGB565, //YUV422,GRAYSCALE,RGB565,JPEG + .frame_size = FRAMESIZE_QVGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG + + .jpeg_quality = 12, //0-63 lower number means higher quality + .fb_count = 1, //if more than one, i2s runs in continuous mode. Use only with JPEG + .grab_mode = CAMERA_GRAB_WHEN_EMPTY, +}; + +static esp_err_t init_camera() +{ + //initialize the camera + esp_err_t err = esp_camera_init(&camera_config); + if (err != ESP_OK) + { + ESP_LOGE(TAG, "Camera Init Failed"); + return err; + } + + return ESP_OK; +} + +void app_main() +{ + if(ESP_OK != init_camera()) { + return; + } + + while (1) + { + ESP_LOGI(TAG, "Taking picture..."); + camera_fb_t *pic = esp_camera_fb_get(); + + // use pic->buf to access the image + ESP_LOGI(TAG, "Picture taken! Its size was: %zu bytes", pic->len); + esp_camera_fb_return(pic); + + vTaskDelay(5000 / portTICK_RATE_MS); + } +} diff --git a/lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults b/lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults new file mode 100644 index 000000000..e5ac4557a --- /dev/null +++ b/lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults @@ -0,0 +1,17 @@ +CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y +CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y + +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_PARTITION_TABLE_OFFSET=0x10000 + +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESPTOOLPY_FLASHFREQ_80M=y +CONFIG_ESPTOOLPY_FLASHMODE_QIO=y + +CONFIG_SPIRAM_SUPPORT=y +CONFIG_ESP32_SPIRAM_SUPPORT=y +CONFIG_ESP32S2_SPIRAM_SUPPORT=y +CONFIG_ESP32S3_SPIRAM_SUPPORT=y +CONFIG_SPIRAM_SPEED_80M=y + diff --git a/lib/libesp32_div/esp32-camera/library.json b/lib/libesp32_div/esp32-camera/library.json new file mode 100644 index 000000000..2147a3908 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/library.json @@ -0,0 +1,26 @@ +{ + "name": "esp32-camera", + "version": "1.0.0", + "keywords": "esp32, camera, espressif, esp32-cam", + "description": "ESP32 compatible driver for OV2640, OV3660, OV5640, OV7670 and OV7725 image sensors.", + "repository": { + "type": "git", + "url": "https://github.com/espressif/esp32-camera" + }, + "frameworks": "*", + "platforms": "*", + "build": { + "flags": [ + "-Idriver/include", + "-Iconversions/include", + "-Idriver/private_include", + "-Iconversions/private_include", + "-Isensors/private_include", + "-Itarget/private_include", + "-fno-rtti" + ], + "includeDir": ".", + "srcDir": ".", + "srcFilter": ["-<*>", "+", "+", "+"] + } +} diff --git a/lib/libesp32_div/esp32-camera/sensors/gc0308.c b/lib/libesp32_div/esp32-camera/sensors/gc0308.c new file mode 100644 index 000000000..19064d3a7 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/gc0308.c @@ -0,0 +1,465 @@ +// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "sccb.h" +#include "gc0308.h" +#include "gc0308_regs.h" +#include "gc0308_settings.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "gc0308"; +#endif + +#define H8(v) ((v)>>8) +#define L8(v) ((v)&0xff) + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg) +{ + int ret = SCCB_Read(slv_addr, reg); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) +{ + int ret = 0; +#ifndef REG_DEBUG_ON + ret = SCCB_Write(slv_addr, reg, value); +#else + int old_value = read_reg(slv_addr, reg); + if (old_value < 0) { + return old_value; + } + if ((uint8_t)old_value != value) { + ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); + ret = SCCB_Write(slv_addr, reg, value); + } else { + ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); + ret = SCCB_Write(slv_addr, reg, value);//maybe not? + } + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) +{ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + ret = read_reg(slv_addr, reg); + if (ret < 0) { + return ret; + } + c_value = ret; + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = write_reg(slv_addr, reg, new_value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +{ + int i = 0, ret = 0; + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + i++; + } + return ret; +} + +static void print_regs(uint8_t slv_addr) +{ +#ifdef DEBUG_PRINT_REG + ESP_LOGI(TAG, "REG list look ======================"); + for (size_t i = 0xf0; i <= 0xfe; i++) { + ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 0 ==="); + write_reg(slv_addr, 0xfe, 0x00); // page 0 + for (size_t i = 0x03; i <= 0xa2; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + + ESP_LOGI(TAG, "\npage 3 ==="); + write_reg(slv_addr, 0xfe, 0x03); // page 3 + for (size_t i = 0x01; i <= 0x43; i++) { + ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } +#endif +} + +static int reset(sensor_t *sensor) +{ + int ret = 0; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, RESET_RELATED, 0xf0); + if (ret) { + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + vTaskDelay(100 / portTICK_PERIOD_MS); + ret = write_regs(sensor->slv_addr, gc0308_sensor_default_regs); + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + vTaskDelay(100 / portTICK_PERIOD_MS); + write_reg(sensor->slv_addr, 0xfe, 0x00); +#ifdef CONFIG_IDF_TARGET_ESP32 + set_reg_bits(sensor->slv_addr, 0x28, 4, 0x07, 1); //frequency division for esp32, ensure pclk <= 15MHz +#endif + } + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + + switch (pixformat) { + case PIXFORMAT_RGB565: + write_reg(sensor->slv_addr, 0xfe, 0x00); + ret = set_reg_bits(sensor->slv_addr, 0x24, 0, 0x0f, 6); //RGB565 + break; + + case PIXFORMAT_YUV422: + write_reg(sensor->slv_addr, 0xfe, 0x00); + ret = set_reg_bits(sensor->slv_addr, 0x24, 0, 0x0f, 2); //yuv422 Y Cb Y Cr + break; + default: + ESP_LOGW(TAG, "unsupport format"); + ret = -1; + break; + } + + if (ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + if (framesize > FRAMESIZE_VGA) { + ESP_LOGW(TAG, "Invalid framesize: %u", framesize); + framesize = FRAMESIZE_VGA; + } + sensor->status.framesize = framesize; + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + uint16_t row_s = (resolution[FRAMESIZE_VGA].height - h) / 2; + uint16_t col_s = (resolution[FRAMESIZE_VGA].width - w) / 2; + +#if CONFIG_GC_SENSOR_SUBSAMPLE_MODE + struct subsample_cfg { + uint16_t ratio_numerator; + uint16_t ratio_denominator; + uint8_t reg0x54; + uint8_t reg0x56; + uint8_t reg0x57; + uint8_t reg0x58; + uint8_t reg0x59; + }; + const struct subsample_cfg subsample_cfgs[] = { // define some subsample ratio + {84, 420, 0x55, 0x00, 0x00, 0x00, 0x00}, //1/5 + {105, 420, 0x44, 0x00, 0x00, 0x00, 0x00},//1/4 + {140, 420, 0x33, 0x00, 0x00, 0x00, 0x00},//1/3 + {210, 420, 0x22, 0x00, 0x00, 0x00, 0x00},//1/2 + {240, 420, 0x77, 0x02, 0x46, 0x02, 0x46},//4/7 + {252, 420, 0x55, 0x02, 0x04, 0x02, 0x04},//3/5 + {280, 420, 0x33, 0x02, 0x00, 0x02, 0x00},//2/3 + {420, 420, 0x11, 0x00, 0x00, 0x00, 0x00},//1/1 + }; + uint16_t win_w = 640; + uint16_t win_h = 480; + const struct subsample_cfg *cfg = NULL; + /** + * Strategy: try to keep the maximum perspective + */ + for (size_t i = 0; i < sizeof(subsample_cfgs) / sizeof(struct subsample_cfg); i++) { + cfg = &subsample_cfgs[i]; + if ((win_w * cfg->ratio_numerator / cfg->ratio_denominator >= w) && (win_h * cfg->ratio_numerator / cfg->ratio_denominator >= h)) { + win_w = w * cfg->ratio_denominator / cfg->ratio_numerator; + win_h = h * cfg->ratio_denominator / cfg->ratio_numerator; + row_s = (resolution[FRAMESIZE_VGA].height - win_h) / 2; + col_s = (resolution[FRAMESIZE_VGA].width - win_w) / 2; + ESP_LOGI(TAG, "subsample win:%dx%d, ratio:%f", win_w, win_h, (float)cfg->ratio_numerator / (float)cfg->ratio_denominator); + break; + } + } + + write_reg(sensor->slv_addr, 0xfe, 0x00); + + write_reg(sensor->slv_addr, 0x05, H8(row_s)); + write_reg(sensor->slv_addr, 0x06, L8(row_s)); + write_reg(sensor->slv_addr, 0x07, H8(col_s)); + write_reg(sensor->slv_addr, 0x08, L8(col_s)); + write_reg(sensor->slv_addr, 0x09, H8(win_h + 8)); + write_reg(sensor->slv_addr, 0x0a, L8(win_h + 8)); + write_reg(sensor->slv_addr, 0x0b, H8(win_w + 8)); + write_reg(sensor->slv_addr, 0x0c, L8(win_w + 8)); + + write_reg(sensor->slv_addr, 0xfe, 0x01); + set_reg_bits(sensor->slv_addr, 0x53, 7, 0x01, 1); + set_reg_bits(sensor->slv_addr, 0x55, 0, 0x01, 1); + write_reg(sensor->slv_addr, 0x54, cfg->reg0x54); + write_reg(sensor->slv_addr, 0x56, cfg->reg0x56); + write_reg(sensor->slv_addr, 0x57, cfg->reg0x57); + write_reg(sensor->slv_addr, 0x58, cfg->reg0x58); + write_reg(sensor->slv_addr, 0x59, cfg->reg0x59); + + write_reg(sensor->slv_addr, 0xfe, 0x00); + +#elif CONFIG_GC_SENSOR_WINDOWING_MODE + write_reg(sensor->slv_addr, 0xfe, 0x00); + + write_reg(sensor->slv_addr, 0xf7, col_s / 4); + write_reg(sensor->slv_addr, 0xf8, row_s / 4); + write_reg(sensor->slv_addr, 0xf9, (col_s + h) / 4); + write_reg(sensor->slv_addr, 0xfa, (row_s + w) / 4); + + write_reg(sensor->slv_addr, 0x05, H8(row_s)); + write_reg(sensor->slv_addr, 0x06, L8(row_s)); + write_reg(sensor->slv_addr, 0x07, H8(col_s)); + write_reg(sensor->slv_addr, 0x08, L8(col_s)); + + write_reg(sensor->slv_addr, 0x09, H8(h + 8)); + write_reg(sensor->slv_addr, 0x0a, L8(h + 8)); + write_reg(sensor->slv_addr, 0x0b, H8(w + 8)); + write_reg(sensor->slv_addr, 0x0c, L8(w + 8)); + +#endif + if (ret == 0) { + ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); + } + return 0; +} + +static int set_contrast(sensor_t *sensor, int contrast) +{ + if (contrast != 0) { + write_reg(sensor->slv_addr, 0xfe, 0x00); + write_reg(sensor->slv_addr, 0xb3, contrast); + } + return 0; +} + +static int set_global_gain(sensor_t *sensor, int gain_level) +{ + if (gain_level != 0) { + write_reg(sensor->slv_addr, 0xfe, 0x00); + write_reg(sensor->slv_addr, 0x50, gain_level); + } + return 0; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, 0x14, 0, 0x01, enable != 0); + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, 0x14, 1, 0x01, enable != 0); + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, 0x2e, 0, 0x01, enable); + if (ret == 0) { + sensor->status.colorbar = enable; + ESP_LOGD(TAG, "Set colorbar to: %d", enable); + } + return ret; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret > 0) { + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret < 0) { + return ret; + } + value = (ret & ~mask) | (value & mask); + + if (mask > 0xFF) { + + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + return ret; +} + +static int init_status(sensor_t *sensor) +{ + write_reg(sensor->slv_addr, 0xfe, 0x00); + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.sharpness = 0; + sensor->status.denoise = 0; + sensor->status.ae_level = 0; + sensor->status.gainceiling = 0; + sensor->status.awb = 0; + sensor->status.dcw = 0; + sensor->status.agc = 0; + sensor->status.aec = 0; + sensor->status.hmirror = check_reg_mask(sensor->slv_addr, 0x14, 0x01); + sensor->status.vflip = check_reg_mask(sensor->slv_addr, 0x14, 0x02); + sensor->status.colorbar = 0; + sensor->status.bpc = 0; + sensor->status.wpc = 0; + sensor->status.raw_gma = 0; + sensor->status.lenc = 0; + sensor->status.quality = 0; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = 0; + sensor->status.agc_gain = 0; + sensor->status.aec_value = 0; + sensor->status.aec2 = 0; + + print_regs(sensor->slv_addr); + return 0; +} + +static int set_dummy(sensor_t *sensor, int val) +{ + ESP_LOGW(TAG, "Unsupported"); + return -1; +} +static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) +{ + ESP_LOGW(TAG, "Unsupported"); + return -1; +} + +int gc0308_detect(int slv_addr, sensor_id_t *id) +{ + if (GC0308_SCCB_ADDR == slv_addr) { + write_reg(slv_addr, 0xfe, 0x00); + uint8_t PID = SCCB_Read(slv_addr, 0x00); + if (GC0308_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int gc0308_init(sensor_t *sensor) +{ + sensor->init_status = init_status; + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_contrast; + sensor->set_brightness = set_dummy; + sensor->set_saturation = set_dummy; + sensor->set_sharpness = set_dummy; + sensor->set_denoise = set_dummy; + sensor->set_gainceiling = set_gainceiling_dummy; + sensor->set_quality = set_dummy; + sensor->set_colorbar = set_colorbar; + sensor->set_whitebal = set_dummy; + sensor->set_gain_ctrl = set_global_gain; + sensor->set_exposure_ctrl = set_dummy; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + + sensor->set_aec2 = set_dummy; + sensor->set_awb_gain = set_dummy; + sensor->set_agc_gain = set_dummy; + sensor->set_aec_value = set_dummy; + + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + + sensor->set_dcw = set_dummy; + sensor->set_bpc = set_dummy; + sensor->set_wpc = set_dummy; + + sensor->set_raw_gma = set_dummy; + sensor->set_lenc = set_dummy; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = NULL; + sensor->set_pll = NULL; + sensor->set_xclk = NULL; + + ESP_LOGD(TAG, "GC0308 Attached"); + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/gc032a.c b/lib/libesp32_div/esp32-camera/sensors/gc032a.c new file mode 100644 index 000000000..612e17b1e --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/gc032a.c @@ -0,0 +1,391 @@ +// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "sccb.h" +#include "gc032a.h" +#include "gc032a_regs.h" +#include "gc032a_settings.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "gc032a"; +#endif + +#define H8(v) ((v)>>8) +#define L8(v) ((v)&0xff) + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg) +{ + int ret = SCCB_Read(slv_addr, reg); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) +{ + int ret = 0; +#ifndef REG_DEBUG_ON + ret = SCCB_Write(slv_addr, reg, value); +#else + int old_value = read_reg(slv_addr, reg); + if (old_value < 0) { + return old_value; + } + if ((uint8_t)old_value != value) { + ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); + ret = SCCB_Write(slv_addr, reg, value); + } else { + ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); + ret = SCCB_Write(slv_addr, reg, value);//maybe not? + } + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) +{ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static void print_regs(uint8_t slv_addr) +{ +#ifdef DEBUG_PRINT_REG + vTaskDelay(pdMS_TO_TICKS(100)); + ESP_LOGI(TAG, "REG list look ======================"); + for (size_t i = 0xf0; i <= 0xfe; i++) { + ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 0 ==="); + write_reg(slv_addr, 0xfe, 0x00); // page 0 + for (size_t i = 0x03; i <= 0x24; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + for (size_t i = 0x40; i <= 0x95; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 3 ==="); + write_reg(slv_addr, 0xfe, 0x03); // page 3 + for (size_t i = 0x01; i <= 0x43; i++) { + ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } +#endif +} + +static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + ret = read_reg(slv_addr, reg); + if (ret < 0) { + return ret; + } + c_value = ret; + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = write_reg(slv_addr, reg, new_value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +{ + int i = 0, ret = 0; + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + i++; + } + return ret; +} + +static int reset(sensor_t *sensor) +{ + int ret; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, RESET_RELATED, 0xf0); + if (ret) { + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + vTaskDelay(100 / portTICK_PERIOD_MS); + + ret = write_regs(sensor->slv_addr, gc032a_default_regs); + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + vTaskDelay(100 / portTICK_PERIOD_MS); + write_reg(sensor->slv_addr, 0xfe, 0x00); + set_reg_bits(sensor->slv_addr, 0xf7, 1, 0x01, 1); // PLL_mode1:div2en + set_reg_bits(sensor->slv_addr, 0xf7, 7, 0x01, 1); // PLL_mode1:dvp mode + set_reg_bits(sensor->slv_addr, 0xf8, 0, 0x3f, 8); //PLL_mode2 :divx4 + set_reg_bits(sensor->slv_addr, 0xfa, 4, 0x0f, 2); //vlk div mode :divide_by + } + + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + switch (pixformat) { + case PIXFORMAT_RGB565: + write_reg(sensor->slv_addr, 0xfe, 0x00); + ret = set_reg_bits(sensor->slv_addr, 0x44, 0, 0x1f, 6); //RGB565 + break; + + case PIXFORMAT_YUV422: + write_reg(sensor->slv_addr, 0xfe, 0x00); + ret = set_reg_bits(sensor->slv_addr, 0x44, 0, 0x1f, 3); + break; + default: + ESP_LOGW(TAG, "unsupport format"); + ret = -1; + break; + } + if (ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + ESP_LOGI(TAG, "set_framesize"); + int ret = 0; + if (framesize > FRAMESIZE_VGA) { + ESP_LOGW(TAG, "Invalid framesize: %u", framesize); + framesize = FRAMESIZE_VGA; + } + sensor->status.framesize = framesize; + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + uint16_t row_s = (resolution[FRAMESIZE_VGA].height - h) / 2; + uint16_t col_s = (resolution[FRAMESIZE_VGA].width - w) / 2; + + write_reg(sensor->slv_addr, 0xfe, 0x00); + write_reg(sensor->slv_addr, P0_ROW_START_HIGH, H8(row_s)); // Row_start[8] + write_reg(sensor->slv_addr, P0_ROW_START_LOW, L8(row_s)); // Row_start[7:0] + write_reg(sensor->slv_addr, P0_COLUMN_START_HIGH, H8(col_s)); // Column_start[9:8] + write_reg(sensor->slv_addr, P0_COLUMN_START_LOW, L8(col_s)); // Column_start[7:0] + write_reg(sensor->slv_addr, P0_WINDOW_HEIGHT_HIGH, H8(h + 8)); //window_height [8] + write_reg(sensor->slv_addr, P0_WINDOW_HEIGHT_LOW, L8(h + 8)); //window_height [7:0] + write_reg(sensor->slv_addr, P0_WINDOW_WIDTH_HIGH, H8(w + 8)); //window_width [9:8] + write_reg(sensor->slv_addr, P0_WINDOW_WIDTH_LOW, L8(w + 8)); //window_width [7:0] + + write_reg(sensor->slv_addr, P0_WIN_MODE, 0x01); + write_reg(sensor->slv_addr, P0_OUT_WIN_HEIGHT_HIGH, H8(h)); + write_reg(sensor->slv_addr, P0_OUT_WIN_HEIGHT_LOW, L8(h)); + write_reg(sensor->slv_addr, P0_OUT_WIN_WIDTH_HIGH, H8(w)); + write_reg(sensor->slv_addr, P0_OUT_WIN_WIDTH_LOW, L8(w)); + + if (ret == 0) { + ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); + } + print_regs(sensor->slv_addr); + return ret; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, P0_CISCTL_MODE1, 0, 0x01, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, P0_CISCTL_MODE1, 1, 0x01, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, P0_DEBUG_MODE2, 3, 0x01, enable); + if (ret == 0) { + sensor->status.colorbar = enable; + ESP_LOGD(TAG, "Set colorbar to: %d", enable); + } + return ret; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret > 0) { + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret < 0) { + return ret; + } + value = (ret & ~mask) | (value & mask); + + if (mask > 0xFF) { + + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + return ret; +} + +static int init_status(sensor_t *sensor) +{ + write_reg(sensor->slv_addr, 0xfe, 0x00); + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.sharpness = 0; + sensor->status.denoise = 0; + sensor->status.ae_level = 0; + sensor->status.gainceiling = 0; + sensor->status.awb = 0; + sensor->status.dcw = 0; + sensor->status.agc = 0; + sensor->status.aec = 0; + sensor->status.hmirror = check_reg_mask(sensor->slv_addr, P0_CISCTL_MODE1, 0x01); + sensor->status.vflip = check_reg_mask(sensor->slv_addr, P0_CISCTL_MODE1, 0x02); + sensor->status.colorbar = 0; + sensor->status.bpc = 0; + sensor->status.wpc = 0; + sensor->status.raw_gma = 0; + sensor->status.lenc = 0; + sensor->status.quality = 0; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = 0; + sensor->status.agc_gain = 0; + sensor->status.aec_value = 0; + sensor->status.aec2 = 0; + return 0; +} + +static int set_dummy(sensor_t *sensor, int val) +{ + ESP_LOGW(TAG, "Unsupported"); + return -1; +} +static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) +{ + ESP_LOGW(TAG, "Unsupported"); + return -1; +} + +int gc032a_detect(int slv_addr, sensor_id_t *id) +{ + if (GC032A_SCCB_ADDR == slv_addr) { + uint8_t MIDL = SCCB_Read(slv_addr, SENSOR_ID_LOW); + uint8_t MIDH = SCCB_Read(slv_addr, SENSOR_ID_HIGH); + uint16_t PID = MIDH << 8 | MIDL; + if (GC032A_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int gc032a_init(sensor_t *sensor) +{ + sensor->init_status = init_status; + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_dummy; + sensor->set_brightness = set_dummy; + sensor->set_saturation = set_dummy; + sensor->set_sharpness = set_dummy; + sensor->set_denoise = set_dummy; + sensor->set_gainceiling = set_gainceiling_dummy; + sensor->set_quality = set_dummy; + sensor->set_colorbar = set_colorbar; + sensor->set_whitebal = set_dummy; + sensor->set_gain_ctrl = set_dummy; + sensor->set_exposure_ctrl = set_dummy; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + + sensor->set_aec2 = set_dummy; + sensor->set_awb_gain = set_dummy; + sensor->set_agc_gain = set_dummy; + sensor->set_aec_value = set_dummy; + + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + + sensor->set_dcw = set_dummy; + sensor->set_bpc = set_dummy; + sensor->set_wpc = set_dummy; + + sensor->set_raw_gma = set_dummy; + sensor->set_lenc = set_dummy; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = NULL; + sensor->set_pll = NULL; + sensor->set_xclk = NULL; + + ESP_LOGD(TAG, "GC032A Attached"); + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/gc2145.c b/lib/libesp32_div/esp32-camera/sensors/gc2145.c new file mode 100644 index 000000000..311308290 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/gc2145.c @@ -0,0 +1,475 @@ +// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "sccb.h" +#include "gc2145.h" +#include "gc2145_regs.h" +#include "gc2145_settings.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "gc2145"; +#endif + +#define H8(v) ((v)>>8) +#define L8(v) ((v)&0xff) + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg) +{ + int ret = SCCB_Read(slv_addr, reg); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) +{ + int ret = 0; +#ifndef REG_DEBUG_ON + ret = SCCB_Write(slv_addr, reg, value); +#else + int old_value = read_reg(slv_addr, reg); + if (old_value < 0) { + return old_value; + } + if ((uint8_t)old_value != value) { + ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); + ret = SCCB_Write(slv_addr, reg, value); + } else { + ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); + ret = SCCB_Write(slv_addr, reg, value);//maybe not? + } + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) +{ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + ret = read_reg(slv_addr, reg); + if (ret < 0) { + return ret; + } + c_value = ret; + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = write_reg(slv_addr, reg, new_value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +{ + int i = 0, ret = 0; + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + i++; + } + return ret; +} + +static void print_regs(uint8_t slv_addr) +{ +#ifdef DEBUG_PRINT_REG + vTaskDelay(pdMS_TO_TICKS(100)); + ESP_LOGI(TAG, "REG list look ======================"); + for (size_t i = 0xf0; i <= 0xfe; i++) { + ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 0 ==="); + write_reg(slv_addr, 0xfe, 0x00); // page 0 + for (size_t i = 0x03; i <= 0x24; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + for (size_t i = 0x80; i <= 0xa2; i++) { + ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } + ESP_LOGI(TAG, "\npage 3 ==="); + write_reg(slv_addr, 0xfe, 0x03); // page 3 + for (size_t i = 0x01; i <= 0x43; i++) { + ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); + } +#endif +} + +static int reset(sensor_t *sensor) +{ + int ret = 0; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, RESET_RELATED, 0xe0); + if (ret) { + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + vTaskDelay(100 / portTICK_PERIOD_MS); + ret = write_regs(sensor->slv_addr, gc2145_default_init_regs); + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + vTaskDelay(100 / portTICK_PERIOD_MS); +#ifdef CONFIG_IDF_TARGET_ESP32 + write_reg(sensor->slv_addr, 0xfe, 0x00); + //ensure pclk <= 15MHz for esp32 + set_reg_bits(sensor->slv_addr, 0xf8, 0, 0x3f, 2); // divx4 + set_reg_bits(sensor->slv_addr, 0xfa, 4, 0x0f, 2); // divide_by +#endif + + } + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + + switch (pixformat) { + case PIXFORMAT_RGB565: + write_reg(sensor->slv_addr, 0xfe, 0x00); + ret = set_reg_bits(sensor->slv_addr, P0_OUTPUT_FORMAT, 0, 0x1f, 6); //RGB565 + break; + + case PIXFORMAT_YUV422: + write_reg(sensor->slv_addr, 0xfe, 0x00); + ret = set_reg_bits(sensor->slv_addr, P0_OUTPUT_FORMAT, 0, 0x1f, 2); //yuv422 + break; + default: + ESP_LOGW(TAG, "unsupport format"); + ret = -1; + break; + } + + if (ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + if (framesize > FRAMESIZE_UXGA) { + ESP_LOGW(TAG, "Invalid framesize: %u", framesize); + framesize = FRAMESIZE_UXGA; + } + sensor->status.framesize = framesize; + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + uint16_t row_s = (resolution[FRAMESIZE_UXGA].height - h) / 2; + uint16_t col_s = (resolution[FRAMESIZE_UXGA].width - w) / 2; + +#if CONFIG_GC_SENSOR_SUBSAMPLE_MODE + struct subsample_cfg { + uint16_t ratio_numerator; + uint16_t ratio_denominator; + uint8_t reg0x99; + uint8_t reg0x9b; + uint8_t reg0x9c; + uint8_t reg0x9d; + uint8_t reg0x9e; + uint8_t reg0x9f; + uint8_t reg0xa0; + uint8_t reg0xa1; + uint8_t reg0xa2; + }; + const struct subsample_cfg subsample_cfgs[] = { // define some subsample ratio + // {60, 420, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //1/7 // A smaller ratio brings a larger view, but it reduces the frame rate + // {84, 420, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //1/5 + // {105, 420, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/4 + {140, 420, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/3 + {210, 420, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/2 + {240, 420, 0x77, 0x02, 0x46, 0x02, 0x46, 0x02, 0x46, 0x02, 0x46},//4/7 + {252, 420, 0x55, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04},//3/5 + {280, 420, 0x33, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00},//2/3 + {420, 420, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/1 + }; + uint16_t win_w = resolution[FRAMESIZE_UXGA].width; + uint16_t win_h = resolution[FRAMESIZE_UXGA].height; + const struct subsample_cfg *cfg = NULL; + /** + * Strategy: try to keep the maximum perspective + */ + uint8_t i = 0; + if (framesize >= FRAMESIZE_QVGA) { + i = 1; + } + for (; i < sizeof(subsample_cfgs) / sizeof(struct subsample_cfg); i++) { + cfg = &subsample_cfgs[i]; + if ((win_w * cfg->ratio_numerator / cfg->ratio_denominator >= w) && (win_h * cfg->ratio_numerator / cfg->ratio_denominator >= h)) { + win_w = w * cfg->ratio_denominator / cfg->ratio_numerator; + win_h = h * cfg->ratio_denominator / cfg->ratio_numerator; + row_s = (resolution[FRAMESIZE_UXGA].height - win_h) / 2; + col_s = (resolution[FRAMESIZE_UXGA].width - win_w) / 2; + ESP_LOGI(TAG, "subsample win:%dx%d, ratio:%f", win_w, win_h, (float)cfg->ratio_numerator / (float)cfg->ratio_denominator); + break; + } + } + + write_reg(sensor->slv_addr, 0xfe, 0x00); + write_reg(sensor->slv_addr, P0_CROP_ENABLE, 0x01); + write_reg(sensor->slv_addr, 0x09, H8(row_s)); + write_reg(sensor->slv_addr, 0x0a, L8(row_s)); + write_reg(sensor->slv_addr, 0x0b, H8(col_s)); + write_reg(sensor->slv_addr, 0x0c, L8(col_s)); + write_reg(sensor->slv_addr, 0x0d, H8(win_h + 8)); + write_reg(sensor->slv_addr, 0x0e, L8(win_h + 8)); + write_reg(sensor->slv_addr, 0x0f, H8(win_w + 16)); + write_reg(sensor->slv_addr, 0x10, L8(win_w + 16)); + + write_reg(sensor->slv_addr, 0x99, cfg->reg0x99); + write_reg(sensor->slv_addr, 0x9b, cfg->reg0x9b); + write_reg(sensor->slv_addr, 0x9c, cfg->reg0x9c); + write_reg(sensor->slv_addr, 0x9d, cfg->reg0x9d); + write_reg(sensor->slv_addr, 0x9e, cfg->reg0x9e); + write_reg(sensor->slv_addr, 0x9f, cfg->reg0x9f); + write_reg(sensor->slv_addr, 0xa0, cfg->reg0xa0); + write_reg(sensor->slv_addr, 0xa1, cfg->reg0xa1); + write_reg(sensor->slv_addr, 0xa2, cfg->reg0xa2); + + write_reg(sensor->slv_addr, 0x95, H8(h)); + write_reg(sensor->slv_addr, 0x96, L8(h)); + write_reg(sensor->slv_addr, 0x97, H8(w)); + write_reg(sensor->slv_addr, 0x98, L8(w)); + + +#elif CONFIG_GC_SENSOR_WINDOWING_MODE + write_reg(sensor->slv_addr, 0xfe, 0x00); + + write_reg(sensor->slv_addr, P0_CROP_ENABLE, 0x01); + // write_reg(sensor->slv_addr, 0xec, col_s / 8); //measure window + // write_reg(sensor->slv_addr, 0xed, row_s / 8); + // write_reg(sensor->slv_addr, 0xee, (col_s + h) / 8); + // write_reg(sensor->slv_addr, 0xef, (row_s + w) / 8); + + write_reg(sensor->slv_addr, 0x09, H8(row_s)); + write_reg(sensor->slv_addr, 0x0a, L8(row_s)); + write_reg(sensor->slv_addr, 0x0b, H8(col_s)); + write_reg(sensor->slv_addr, 0x0c, L8(col_s)); + write_reg(sensor->slv_addr, 0x0d, H8(h + 8)); + write_reg(sensor->slv_addr, 0x0e, L8(h + 8)); + write_reg(sensor->slv_addr, 0x0f, H8(w + 8)); + write_reg(sensor->slv_addr, 0x10, L8(w + 8)); + + write_reg(sensor->slv_addr, 0x95, H8(h)); + write_reg(sensor->slv_addr, 0x96, L8(h)); + write_reg(sensor->slv_addr, 0x97, H8(w)); + write_reg(sensor->slv_addr, 0x98, L8(w)); + +#endif + + if (ret == 0) { + ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); + } + return ret; + +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, P0_ANALOG_MODE1, 0, 0x01, enable != 0); + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + ret |= set_reg_bits(sensor->slv_addr, P0_ANALOG_MODE1, 1, 0x01, enable != 0); + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + // ret = write_reg(sensor->slv_addr, 0xfe, 0x00); + // ret |= set_reg_bits(sensor->slv_addr, P0_DEBUG_MODE3, 3, 0x01, enable); + if (ret == 0) { + sensor->status.colorbar = enable; + ESP_LOGD(TAG, "Set colorbar to: %d", enable); + } + return ret; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret > 0) { + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + if (mask > 0xFF) { + ESP_LOGE(TAG, "mask should not more than 0xff"); + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if (ret < 0) { + return ret; + } + value = (ret & ~mask) | (value & mask); + + if (mask > 0xFF) { + + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + return ret; +} + +static int init_status(sensor_t *sensor) +{ + write_reg(sensor->slv_addr, 0xfe, 0x00); + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.sharpness = 0; + sensor->status.denoise = 0; + sensor->status.ae_level = 0; + sensor->status.gainceiling = 0; + sensor->status.awb = 0; + sensor->status.dcw = 0; + sensor->status.agc = 0; + sensor->status.aec = 0; + sensor->status.hmirror = check_reg_mask(sensor->slv_addr, P0_ANALOG_MODE1, 0x01); + sensor->status.vflip = check_reg_mask(sensor->slv_addr, P0_ANALOG_MODE1, 0x02); + sensor->status.colorbar = 0; + sensor->status.bpc = 0; + sensor->status.wpc = 0; + sensor->status.raw_gma = 0; + sensor->status.lenc = 0; + sensor->status.quality = 0; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = 0; + sensor->status.agc_gain = 0; + sensor->status.aec_value = 0; + sensor->status.aec2 = 0; + + print_regs(sensor->slv_addr); + return 0; +} + +static int set_dummy(sensor_t *sensor, int val) +{ + ESP_LOGW(TAG, "Unsupported"); + return -1; +} +static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) +{ + ESP_LOGW(TAG, "Unsupported"); + return -1; +} + +int gc2145_detect(int slv_addr, sensor_id_t *id) +{ + if (GC2145_SCCB_ADDR == slv_addr) { + uint8_t MIDL = SCCB_Read(slv_addr, CHIP_ID_LOW); + uint8_t MIDH = SCCB_Read(slv_addr, CHIP_ID_HIGH); + uint16_t PID = MIDH << 8 | MIDL; + if (GC2145_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int gc2145_init(sensor_t *sensor) +{ + sensor->init_status = init_status; + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_dummy; + sensor->set_brightness = set_dummy; + sensor->set_saturation = set_dummy; + sensor->set_sharpness = set_dummy; + sensor->set_denoise = set_dummy; + sensor->set_gainceiling = set_gainceiling_dummy; + sensor->set_quality = set_dummy; + sensor->set_colorbar = set_colorbar; + sensor->set_whitebal = set_dummy; + sensor->set_gain_ctrl = set_dummy; + sensor->set_exposure_ctrl = set_dummy; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + + sensor->set_aec2 = set_dummy; + sensor->set_awb_gain = set_dummy; + sensor->set_agc_gain = set_dummy; + sensor->set_aec_value = set_dummy; + + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + + sensor->set_dcw = set_dummy; + sensor->set_bpc = set_dummy; + sensor->set_wpc = set_dummy; + + sensor->set_raw_gma = set_dummy; + sensor->set_lenc = set_dummy; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = NULL; + sensor->set_pll = NULL; + sensor->set_xclk = NULL; + + ESP_LOGD(TAG, "GC2145 Attached"); + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/nt99141.c b/lib/libesp32_div/esp32-camera/sensors/nt99141.c new file mode 100644 index 000000000..86a8b8a0b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/nt99141.c @@ -0,0 +1,1022 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * NT99141 driver. + * + */ +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "nt99141.h" +#include "nt99141_regs.h" +#include "nt99141_settings.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "NT99141"; +#endif + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg) +{ + int ret = SCCB_Read16(slv_addr, reg); +#ifdef REG_DEBUG_ON + + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } + +#endif + return ret; +} + +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) +{ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static int read_reg16(uint8_t slv_addr, const uint16_t reg) +{ + int ret = 0, ret2 = 0; + ret = read_reg(slv_addr, reg); + + if (ret >= 0) { + ret = (ret & 0xFF) << 8; + ret2 = read_reg(slv_addr, reg + 1); + + if (ret2 < 0) { + ret = ret2; + } else { + ret |= ret2 & 0xFF; + } + } + + return ret; +} + + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) +{ + int ret = 0; +#ifndef REG_DEBUG_ON + ret = SCCB_Write16(slv_addr, reg, value); +#else + int old_value = read_reg(slv_addr, reg); + + if (old_value < 0) { + return old_value; + } + + if ((uint8_t)old_value != value) { + ESP_LOGD(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); + ret = SCCB_Write16(slv_addr, reg, value); + } else { + ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); + ret = SCCB_Write16(slv_addr, reg, value);//maybe not? + } + + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } + +#endif + return ret; +} + +static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + ret = read_reg(slv_addr, reg); + + if (ret < 0) { + return ret; + } + + c_value = ret; + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = write_reg(slv_addr, reg, new_value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +{ + int i = 0, ret = 0; + + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + + i++; + } + + return ret; +} + +static int write_reg16(uint8_t slv_addr, const uint16_t reg, uint16_t value) +{ + if (write_reg(slv_addr, reg, value >> 8) || write_reg(slv_addr, reg + 1, value)) { + return -1; + } + + return 0; +} + +static int write_addr_reg(uint8_t slv_addr, const uint16_t reg, uint16_t x_value, uint16_t y_value) +{ + if (write_reg16(slv_addr, reg, x_value) || write_reg16(slv_addr, reg + 2, y_value)) { + return -1; + } + + return 0; +} + +#define write_reg_bits(slv_addr, reg, mask, enable) set_reg_bits(slv_addr, reg, 0, mask, enable?mask:0) + +static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sys_div, uint8_t pre_div, bool root_2x, uint8_t seld5, bool pclk_manual, uint8_t pclk_div) +{ + return -1; +} + +static int set_ae_level(sensor_t *sensor, int level); + +static int reset(sensor_t *sensor) +{ + + int ret = 0; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, SYSTEM_CTROL0, 0x01); + + if (ret) { + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + + vTaskDelay(100 / portTICK_PERIOD_MS); + ret = write_regs(sensor->slv_addr, sensor_default_regs); //re-initial + + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + ret = set_ae_level(sensor, 0); + vTaskDelay(100 / portTICK_PERIOD_MS); + } + + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + const uint16_t (*regs)[2]; + + switch (pixformat) { + case PIXFORMAT_YUV422: + regs = sensor_fmt_yuv422; + break; + + case PIXFORMAT_GRAYSCALE: + regs = sensor_fmt_grayscale; + break; + + case PIXFORMAT_RGB565: + case PIXFORMAT_RGB888: + regs = sensor_fmt_rgb565; + break; + + case PIXFORMAT_JPEG: + regs = sensor_fmt_jpeg; + break; + + case PIXFORMAT_RAW: + regs = sensor_fmt_raw; + break; + + default: + ESP_LOGE(TAG, "Unsupported pixformat: %u", pixformat); + return -1; + } + + ret = write_regs(sensor->slv_addr, regs); + + if (ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + + return ret; +} + +static int set_image_options(sensor_t *sensor) +{ + int ret = 0; + uint8_t reg20 = 0; + uint8_t reg21 = 0; + uint8_t reg4514 = 0; + uint8_t reg4514_test = 0; + + // V-Flip + if (sensor->status.vflip) { + reg20 |= 0x01; + reg4514_test |= 1; + } + + // H-Mirror + if (sensor->status.hmirror) { + reg21 |= 0x02; + reg4514_test |= 2; + } + + switch (reg4514_test) { + + } + + if (write_reg(sensor->slv_addr, TIMING_TC_REG20, reg20 | reg21)) { + ESP_LOGE(TAG, "Setting Image Options Failed"); + ret = -1; + } + + ESP_LOGD(TAG, "Set Image Options: Compression: %u, Binning: %u, V-Flip: %u, H-Mirror: %u, Reg-4514: 0x%02x", + sensor->pixformat == PIXFORMAT_JPEG, sensor->status.binning, sensor->status.vflip, sensor->status.hmirror, reg4514); + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + + sensor->status.framesize = framesize; + ret = write_regs(sensor->slv_addr, sensor_default_regs); + + if (framesize == FRAMESIZE_QVGA) { + ESP_LOGD(TAG, "Set FRAMESIZE_QVGA"); + ret = write_regs(sensor->slv_addr, sensor_framesize_QVGA); +#if CONFIG_NT99141_SUPPORT_XSKIP + ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: xskip mode"); + ret = write_regs(sensor->slv_addr, sensor_framesize_QVGA_xskip); +#elif CONFIG_NT99141_SUPPORT_CROP + ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: crop mode"); + ret = write_regs(sensor->slv_addr, sensor_framesize_QVGA_crop); +#endif + } else if (framesize == FRAMESIZE_VGA) { + ESP_LOGD(TAG, "Set FRAMESIZE_VGA"); + // ret = write_regs(sensor->slv_addr, sensor_framesize_VGA); + ret = write_regs(sensor->slv_addr, sensor_framesize_VGA_xyskip);// Resolution:640*360 This configuration is equally-scaled without deforming +#ifdef CONFIG_NT99141_SUPPORT_XSKIP + ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: xskip mode"); + ret = write_regs(sensor->slv_addr, sensor_framesize_VGA_xskip); +#elif CONFIG_NT99141_SUPPORT_CROP + ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: crop mode"); + ret = write_regs(sensor->slv_addr, sensor_framesize_VGA_crop); +#endif + } else if (framesize >= FRAMESIZE_HD) { + ESP_LOGD(TAG, "Set FRAMESIZE_HD"); + ret = write_regs(sensor->slv_addr, sensor_framesize_HD); + } else { + ESP_LOGD(TAG, "Dont suppost this size, Set FRAMESIZE_VGA"); + ret = write_regs(sensor->slv_addr, sensor_framesize_VGA); + } + + return ret; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + ret = set_image_options(sensor); + + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = set_image_options(sensor); + + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + + return ret; +} + +static int set_quality(sensor_t *sensor, int qs) +{ + int ret = 0; + ret = write_reg(sensor->slv_addr, COMPRESSION_CTRL07, qs & 0x3f); + + if (ret == 0) { + sensor->status.quality = qs; + ESP_LOGD(TAG, "Set quality to: %d", qs); + } + + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR, enable); + + if (ret == 0) { + sensor->status.colorbar = enable; + ESP_LOGD(TAG, "Set colorbar to: %d", enable); + } + + return ret; +} + +static int set_gain_ctrl(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x32bb, 0x87, enable); + + if (ret == 0) { + ESP_LOGD(TAG, "Set gain_ctrl to: %d", enable); + sensor->status.agc = enable; + } + + return ret; +} + +static int set_exposure_ctrl(sensor_t *sensor, int enable) +{ + int ret = 0; + int data = 0; + // ret = write_reg_bits(sensor->slv_addr, 0x32bb, 0x87, enable); + data = read_reg(sensor->slv_addr, 0x3201); + ESP_LOGD(TAG, "set_exposure_ctrl:enable"); + if (enable) { + ESP_LOGD(TAG, "set_exposure_ctrl:enable"); + ret = write_reg(sensor->slv_addr, 0x3201, (1 << 5) | data); + } else { + ESP_LOGD(TAG, "set_exposure_ctrl:disable"); + ret = write_reg(sensor->slv_addr, 0x3201, (~(1 << 5)) & data); + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set exposure_ctrl to: %d", enable); + sensor->status.aec = enable; + } + + return ret; +} + +static int set_whitebal(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set awb to: %d", enable); + sensor->status.awb = enable; + } + + return ret; +} + +//Advanced AWB +static int set_dcw_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set dcw to: %d", enable); + sensor->status.dcw = enable; + } + + return ret; +} + +//night mode enable +static int set_aec2(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set aec2 to: %d", enable); + sensor->status.aec2 = enable; + } + + return ret; +} + +static int set_bpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set bpc to: %d", enable); + sensor->status.bpc = enable; + } + + return ret; +} + +static int set_wpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set wpc to: %d", enable); + sensor->status.wpc = enable; + } + + return ret; +} + +//Gamma enable +static int set_raw_gma_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set raw_gma to: %d", enable); + sensor->status.raw_gma = enable; + } + + return ret; +} + +static int set_lenc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + + if (ret == 0) { + ESP_LOGD(TAG, "Set lenc to: %d", enable); + sensor->status.lenc = enable; + } + + return ret; +} + +static int get_agc_gain(sensor_t *sensor) +{ + ESP_LOGD(TAG, "get_agc_gain can not be configured at present"); + return 0; +} + +//real gain +static int set_agc_gain(sensor_t *sensor, int gain) +{ + ESP_LOGD(TAG, "set_agc_gain can not be configured at present"); + // ESP_LOGD(TAG, "GAIN = %d\n", gain); + int cnt = gain / 2; + + switch (cnt) { + case 0: + ESP_LOGD(TAG, "set_agc_gain: 1x"); + write_reg(sensor->slv_addr, 0X301D, 0X00); + break; + + case 1: + ESP_LOGD(TAG,"set_agc_gain: 2x"); + write_reg(sensor->slv_addr, 0X301D, 0X0F); + break; + + case 2: + ESP_LOGD(TAG,"set_agc_gain: 4x"); + write_reg(sensor->slv_addr, 0X301D, 0X2F); + break; + + case 3: + ESP_LOGD(TAG,"set_agc_gain: 6x"); + write_reg(sensor->slv_addr, 0X301D, 0X37); + break; + + case 4: + ESP_LOGD(TAG,"set_agc_gain: 8x"); + write_reg(sensor->slv_addr, 0X301D, 0X3F); + break; + + default: + ESP_LOGD(TAG,"fail set_agc_gain"); + break; + } + + return 0; +} + +static int get_aec_value(sensor_t *sensor) +{ + ESP_LOGD(TAG, "get_aec_value can not be configured at present"); + return 0; +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + ESP_LOGD(TAG, "set_aec_value can not be configured at present"); + int ret = 0; + // ESP_LOGD(TAG, " set_aec_value to: %d", value); + ret = write_reg_bits(sensor->slv_addr, 0x3012, 0x00, (value >> 8) & 0xff); + ret = write_reg_bits(sensor->slv_addr, 0x3013, 0x01, value & 0xff); + + if (ret == 0) { + ESP_LOGD(TAG, " set_aec_value to: %d", value); + // sensor->status.aec = enable; + } + + return ret; +} + +static int set_ae_level(sensor_t *sensor, int level) +{ + ESP_LOGD(TAG, "set_ae_level can not be configured at present"); + int ret = 0; + + if (level < 0) { + level = 0; + } else if (level > 9) { + level = 9; + } + + for (int i = 0; i < 5; i++) { + ret += write_reg(sensor->slv_addr, sensor_ae_level[ 5 * level + i ][0], sensor_ae_level[5 * level + i ][1]); + } + + if (ret) { + ESP_LOGE(TAG, " fail to set ae level: %d", ret); + } + + return 0; +} + +static int set_wb_mode(sensor_t *sensor, int mode) +{ + int ret = 0; + + if (mode < 0 || mode > 4) { + return -1; + } + + ret = write_reg(sensor->slv_addr, 0x3201, (mode != 0)); + + if (ret) { + return ret; + } + + switch (mode) { + case 1://Sunny + ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) + || write_reg16(sensor->slv_addr, 0x3291, 0x38) + || write_reg16(sensor->slv_addr, 0x3296, 0x01) + || write_reg16(sensor->slv_addr, 0x3297, 0x68) + || write_reg16(sensor->slv_addr, 0x3060, 0x01); + + break; + + case 2://Cloudy + + ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) + || write_reg16(sensor->slv_addr, 0x3291, 0x51) + || write_reg16(sensor->slv_addr, 0x3296, 0x01) + || write_reg16(sensor->slv_addr, 0x3297, 0x00) + || write_reg16(sensor->slv_addr, 0x3060, 0x01); + break; + + case 3://INCANDESCENCE] + ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) + || write_reg16(sensor->slv_addr, 0x3291, 0x30) + || write_reg16(sensor->slv_addr, 0x3296, 0x01) + || write_reg16(sensor->slv_addr, 0x3297, 0xCB) + || write_reg16(sensor->slv_addr, 0x3060, 0x01); + break; + + case 4://FLUORESCENT + ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) + || write_reg16(sensor->slv_addr, 0x3291, 0x70) + || write_reg16(sensor->slv_addr, 0x3296, 0x01) + || write_reg16(sensor->slv_addr, 0x3297, 0xFF) + || write_reg16(sensor->slv_addr, 0x3060, 0x01); + break; + + default://AUTO + break; + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set wb_mode to: %d", mode); + sensor->status.wb_mode = mode; + } + + return ret; +} + +static int set_awb_gain_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + int old_mode = sensor->status.wb_mode; + int mode = enable ? old_mode : 0; + + ret = set_wb_mode(sensor, mode); + + if (ret == 0) { + sensor->status.wb_mode = old_mode; + ESP_LOGD(TAG, "Set awb_gain to: %d", enable); + sensor->status.awb_gain = enable; + } + + return ret; +} + +static int set_special_effect(sensor_t *sensor, int effect) +{ + int ret = 0; + + if (effect < 0 || effect > 6) { + return -1; + } + + uint8_t *regs = (uint8_t *)sensor_special_effects[effect]; + ret = write_reg(sensor->slv_addr, 0x32F1, regs[0]) + || write_reg(sensor->slv_addr, 0x32F4, regs[1]) + || write_reg(sensor->slv_addr, 0x32F5, regs[2]) + || write_reg(sensor->slv_addr, 0x3060, regs[3]); + + if (ret == 0) { + ESP_LOGD(TAG, "Set special_effect to: %d", effect); + sensor->status.special_effect = effect; + } + + return ret; +} + +static int set_brightness(sensor_t *sensor, int level) +{ + int ret = 0; + uint8_t value = 0; + + switch (level) { + case 3: + value = 0xA0; + break; + + case 2: + value = 0x90; + break; + + case 1: + value = 0x88; + break; + + case -1: + value = 0x78; + break; + + case -2: + value = 0x70; + break; + + case -3: + value = 0x60; + break; + + default: // 0 + break; + } + + ret = write_reg(sensor->slv_addr, 0x32F2, value); + + if (ret == 0) { + ESP_LOGD(TAG, "Set brightness to: %d", level); + sensor->status.brightness = level; + } + + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret = 0; + uint8_t value1 = 0, value2 = 0 ; + + switch (level) { + case 3: + value1 = 0xD0; + value2 = 0xB0; + break; + + case 2: + value1 = 0xE0; + value2 = 0xA0; + break; + + case 1: + value1 = 0xF0; + value2 = 0x90; + break; + + case 0: + value1 = 0x00; + value2 = 0x80; + break; + + case -1: + value1 = 0x10; + value2 = 0x70; + break; + + case -2: + value1 = 0x20; + value2 = 0x60; + break; + + case -3: + value1 = 0x30; + value2 = 0x50; + break; + + default: // 0 + break; + } + + ret = write_reg(sensor->slv_addr, 0x32FC, value1); + ret = write_reg(sensor->slv_addr, 0x32F2, value2); + ret = write_reg(sensor->slv_addr, 0x3060, 0x01); + + if (ret == 0) { + ESP_LOGD(TAG, "Set contrast to: %d", level); + sensor->status.contrast = level; + } + + return ret; +} + +static int set_saturation(sensor_t *sensor, int level) +{ + int ret = 0; + + if (level > 4 || level < -4) { + return -1; + } + + uint8_t *regs = (uint8_t *)sensor_saturation_levels[level + 4]; + { + ret = write_reg(sensor->slv_addr, 0x32F3, regs[0]); + + if (ret) { + return ret; + } + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set saturation to: %d", level); + sensor->status.saturation = level; + } + + return ret; +} + +static int set_sharpness(sensor_t *sensor, int level) +{ + int ret = 0; + + if (level > 3 || level < -3) { + return -1; + } + + uint8_t mt_offset_2 = (level + 3) * 8; + uint8_t mt_offset_1 = mt_offset_2 + 1; + + ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x40, false)//0x40 means auto + || write_reg(sensor->slv_addr, 0x5300, 0x10) + || write_reg(sensor->slv_addr, 0x5301, 0x10) + || write_reg(sensor->slv_addr, 0x5302, mt_offset_1) + || write_reg(sensor->slv_addr, 0x5303, mt_offset_2) + || write_reg(sensor->slv_addr, 0x5309, 0x10) + || write_reg(sensor->slv_addr, 0x530a, 0x10) + || write_reg(sensor->slv_addr, 0x530b, 0x04) + || write_reg(sensor->slv_addr, 0x530c, 0x06); + + if (ret == 0) { + ESP_LOGD(TAG, "Set sharpness to: %d", level); + sensor->status.sharpness = level; + } + + return ret; +} + +static int set_gainceiling(sensor_t *sensor, gainceiling_t level) +{ + ESP_LOGD(TAG, "set_gainceiling can not be configured at present"); + return 0; +} + +static int get_denoise(sensor_t *sensor) +{ + + return (read_reg(sensor->slv_addr, 0x5306) / 4) + 1; +} + +static int set_denoise(sensor_t *sensor, int level) +{ + ESP_LOGD(TAG, "set_denoise can not be configured at present"); + return 0; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0, ret2 = 0; + + if (mask > 0xFF) { + ret = read_reg16(sensor->slv_addr, reg); + + if (ret >= 0 && mask > 0xFFFF) { + ret2 = read_reg(sensor->slv_addr, reg + 2); + + if (ret2 >= 0) { + ret = (ret << 8) | ret2 ; + } else { + ret = ret2; + } + } + } else { + ret = read_reg(sensor->slv_addr, reg); + } + + if (ret > 0) { + ret &= mask; + } + + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0, ret2 = 0; + + if (mask > 0xFF) { + ret = read_reg16(sensor->slv_addr, reg); + + if (ret >= 0 && mask > 0xFFFF) { + ret2 = read_reg(sensor->slv_addr, reg + 2); + + if (ret2 >= 0) { + ret = (ret << 8) | ret2 ; + } else { + ret = ret2; + } + } + } else { + ret = read_reg(sensor->slv_addr, reg); + } + + if (ret < 0) { + return ret; + } + + value = (ret & ~mask) | (value & mask); + + if (mask > 0xFFFF) { + ret = write_reg16(sensor->slv_addr, reg, value >> 8); + + if (ret >= 0) { + ret = write_reg(sensor->slv_addr, reg + 2, value & 0xFF); + } + } else if (mask > 0xFF) { + ret = write_reg16(sensor->slv_addr, reg, value); + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + + return ret; +} + +static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) +{ + int ret = 0; + ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, startX, startY) + || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, endX, endY) + || write_addr_reg(sensor->slv_addr, X_OFFSET_H, offsetX, offsetY) + || write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, totalX, totalY) + || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, outputX, outputY); + + if (!ret) { + sensor->status.scale = scale; + sensor->status.binning = binning; + ret = set_image_options(sensor); + } + + return ret; +} + +static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) +{ + return set_pll(sensor, bypass > 0, multiplier, sys_div, pre_div, root_2x > 0, seld5, pclk_manual > 0, pclk_div); +} + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + if (xclk > 10) + { + ESP_LOGE(TAG, "only XCLK under 10MHz is supported, and XCLK is now set to 10M"); + xclk = 10; + } + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +int nt99141_detect(int slv_addr, sensor_id_t *id) +{ + if (NT99141_SCCB_ADDR == slv_addr) { + SCCB_Write16(slv_addr, 0x3008, 0x01);//bank sensor + uint16_t h = SCCB_Read16(slv_addr, 0x3000); + uint16_t l = SCCB_Read16(slv_addr, 0x3001); + uint16_t PID = (h<<8) | l; + if (NT99141_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +static int init_status(sensor_t *sensor) +{ + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.sharpness = (read_reg(sensor->slv_addr, 0x3301)); + sensor->status.denoise = get_denoise(sensor); + sensor->status.ae_level = 0; + sensor->status.gainceiling = read_reg16(sensor->slv_addr, 0x32F0) & 0xFF; + sensor->status.awb = check_reg_mask(sensor->slv_addr, ISP_CONTROL_01, 0x10); + sensor->status.dcw = !check_reg_mask(sensor->slv_addr, 0x5183, 0x80); + sensor->status.agc = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN); + sensor->status.aec = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN); + sensor->status.hmirror = check_reg_mask(sensor->slv_addr, TIMING_TC_REG21, TIMING_TC_REG21_HMIRROR); + sensor->status.vflip = check_reg_mask(sensor->slv_addr, TIMING_TC_REG20, TIMING_TC_REG20_VFLIP); + sensor->status.colorbar = check_reg_mask(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR); + sensor->status.bpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x04); + sensor->status.wpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x02); + sensor->status.raw_gma = check_reg_mask(sensor->slv_addr, 0x5000, 0x20); + sensor->status.lenc = check_reg_mask(sensor->slv_addr, 0x5000, 0x80); + sensor->status.quality = read_reg(sensor->slv_addr, COMPRESSION_CTRL07) & 0x3f; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = check_reg_mask(sensor->slv_addr, 0x3000, 0x01); + sensor->status.agc_gain = get_agc_gain(sensor); + sensor->status.aec_value = get_aec_value(sensor); + sensor->status.aec2 = check_reg_mask(sensor->slv_addr, 0x3000, 0x04); + return 0; +} + +int nt99141_init(sensor_t *sensor) +{ + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_contrast; + sensor->set_brightness = set_brightness; + sensor->set_saturation = set_saturation; + sensor->set_sharpness = set_sharpness; + sensor->set_gainceiling = set_gainceiling; + sensor->set_quality = set_quality; + sensor->set_colorbar = set_colorbar; + sensor->set_gain_ctrl = set_gain_ctrl; + sensor->set_exposure_ctrl = set_exposure_ctrl; + sensor->set_whitebal = set_whitebal; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + sensor->init_status = init_status; + sensor->set_aec2 = set_aec2; + sensor->set_aec_value = set_aec_value; + sensor->set_special_effect = set_special_effect; + sensor->set_wb_mode = set_wb_mode; + sensor->set_ae_level = set_ae_level; + sensor->set_dcw = set_dcw_dsp; + sensor->set_bpc = set_bpc_dsp; + sensor->set_wpc = set_wpc_dsp; + sensor->set_awb_gain = set_awb_gain_dsp; + sensor->set_agc_gain = set_agc_gain; + sensor->set_raw_gma = set_raw_gma_dsp; + sensor->set_lenc = set_lenc_dsp; + sensor->set_denoise = set_denoise; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = set_res_raw; + sensor->set_pll = _set_pll; + sensor->set_xclk = set_xclk; + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov2640.c b/lib/libesp32_div/esp32-camera/sensors/ov2640.c new file mode 100644 index 000000000..7e3d77174 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/ov2640.c @@ -0,0 +1,612 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV2640 driver. + * + */ +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "ov2640.h" +#include "ov2640_regs.h" +#include "ov2640_settings.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "ov2640"; +#endif + +static volatile ov2640_bank_t reg_bank = BANK_MAX; +static int set_bank(sensor_t *sensor, ov2640_bank_t bank) +{ + int res = 0; + if (bank != reg_bank) { + reg_bank = bank; + res = SCCB_Write(sensor->slv_addr, BANK_SEL, bank); + } + return res; +} + +static int write_regs(sensor_t *sensor, const uint8_t (*regs)[2]) +{ + int i=0, res = 0; + while (regs[i][0]) { + if (regs[i][0] == BANK_SEL) { + res = set_bank(sensor, regs[i][1]); + } else { + res = SCCB_Write(sensor->slv_addr, regs[i][0], regs[i][1]); + } + if (res) { + return res; + } + i++; + } + return res; +} + +static int write_reg(sensor_t *sensor, ov2640_bank_t bank, uint8_t reg, uint8_t value) +{ + int ret = set_bank(sensor, bank); + if(!ret) { + ret = SCCB_Write(sensor->slv_addr, reg, value); + } + return ret; +} + +static int set_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + + ret = set_bank(sensor, bank); + if(ret) { + return ret; + } + c_value = SCCB_Read(sensor->slv_addr, reg); + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = SCCB_Write(sensor->slv_addr, reg, new_value); + return ret; +} + +static int read_reg(sensor_t *sensor, ov2640_bank_t bank, uint8_t reg) +{ + if(set_bank(sensor, bank)){ + return 0; + } + return SCCB_Read(sensor->slv_addr, reg); +} + +static uint8_t get_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t offset, uint8_t mask) +{ + return (read_reg(sensor, bank, reg) >> offset) & mask; +} + +static int write_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t mask, int enable) +{ + return set_reg_bits(sensor, bank, reg, 0, mask, enable?mask:0); +} + +#define WRITE_REGS_OR_RETURN(regs) ret = write_regs(sensor, regs); if(ret){return ret;} +#define WRITE_REG_OR_RETURN(bank, reg, val) ret = write_reg(sensor, bank, reg, val); if(ret){return ret;} +#define SET_REG_BITS_OR_RETURN(bank, reg, offset, mask, val) ret = set_reg_bits(sensor, bank, reg, offset, mask, val); if(ret){return ret;} + +static int reset(sensor_t *sensor) +{ + int ret = 0; + WRITE_REG_OR_RETURN(BANK_SENSOR, COM7, COM7_SRST); + vTaskDelay(10 / portTICK_PERIOD_MS); + WRITE_REGS_OR_RETURN(ov2640_settings_cif); + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + sensor->pixformat = pixformat; + switch (pixformat) { + case PIXFORMAT_RGB565: + case PIXFORMAT_RGB888: + WRITE_REGS_OR_RETURN(ov2640_settings_rgb565); + break; + case PIXFORMAT_YUV422: + case PIXFORMAT_GRAYSCALE: + WRITE_REGS_OR_RETURN(ov2640_settings_yuv422); + break; + case PIXFORMAT_JPEG: + WRITE_REGS_OR_RETURN(ov2640_settings_jpeg3); + break; + default: + ret = -1; + break; + } + if(!ret) { + vTaskDelay(10 / portTICK_PERIOD_MS); + } + + return ret; +} + +static int set_window(sensor_t *sensor, ov2640_sensor_mode_t mode, int offset_x, int offset_y, int max_x, int max_y, int w, int h){ + int ret = 0; + const uint8_t (*regs)[2]; + ov2640_clk_t c; + c.reserved = 0; + + max_x /= 4; + max_y /= 4; + w /= 4; + h /= 4; + uint8_t win_regs[][2] = { + {BANK_SEL, BANK_DSP}, + {HSIZE, max_x & 0xFF}, + {VSIZE, max_y & 0xFF}, + {XOFFL, offset_x & 0xFF}, + {YOFFL, offset_y & 0xFF}, + {VHYX, ((max_y >> 1) & 0X80) | ((offset_y >> 4) & 0X70) | ((max_x >> 5) & 0X08) | ((offset_x >> 8) & 0X07)}, + {TEST, (max_x >> 2) & 0X80}, + {ZMOW, (w)&0xFF}, + {ZMOH, (h)&0xFF}, + {ZMHH, ((h>>6)&0x04)|((w>>8)&0x03)}, + {0, 0} + }; + + if (sensor->pixformat == PIXFORMAT_JPEG) { + c.clk_2x = 0; + c.clk_div = 0; + c.pclk_auto = 0; + c.pclk_div = 8; + if(mode == OV2640_MODE_UXGA) { + c.pclk_div = 12; + } + // if (sensor->xclk_freq_hz == 16000000) { + // c.pclk_div = c.pclk_div / 2; + // } + } else { +#if CONFIG_IDF_TARGET_ESP32 + c.clk_2x = 0; +#else + c.clk_2x = 1; +#endif + c.clk_div = 7; + c.pclk_auto = 1; + c.pclk_div = 8; + if (mode == OV2640_MODE_CIF) { + c.clk_div = 3; + } else if(mode == OV2640_MODE_UXGA) { + c.pclk_div = 12; + } + } + ESP_LOGI(TAG, "Set PLL: clk_2x: %u, clk_div: %u, pclk_auto: %u, pclk_div: %u", c.clk_2x, c.clk_div, c.pclk_auto, c.pclk_div); + + if (mode == OV2640_MODE_CIF) { + regs = ov2640_settings_to_cif; + } else if (mode == OV2640_MODE_SVGA) { + regs = ov2640_settings_to_svga; + } else { + regs = ov2640_settings_to_uxga; + } + + WRITE_REG_OR_RETURN(BANK_DSP, R_BYPASS, R_BYPASS_DSP_BYPAS); + WRITE_REGS_OR_RETURN(regs); + WRITE_REGS_OR_RETURN(win_regs); + WRITE_REG_OR_RETURN(BANK_SENSOR, CLKRC, c.clk); + WRITE_REG_OR_RETURN(BANK_DSP, R_DVP_SP, c.pclk); + WRITE_REG_OR_RETURN(BANK_DSP, R_BYPASS, R_BYPASS_DSP_EN); + + vTaskDelay(10 / portTICK_PERIOD_MS); + //required when changing resolution + set_pixformat(sensor, sensor->pixformat); + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + aspect_ratio_t ratio = resolution[framesize].aspect_ratio; + uint16_t max_x = ratio_table[ratio].max_x; + uint16_t max_y = ratio_table[ratio].max_y; + uint16_t offset_x = ratio_table[ratio].offset_x; + uint16_t offset_y = ratio_table[ratio].offset_y; + ov2640_sensor_mode_t mode = OV2640_MODE_UXGA; + + sensor->status.framesize = framesize; + + + + if (framesize <= FRAMESIZE_CIF) { + mode = OV2640_MODE_CIF; + max_x /= 4; + max_y /= 4; + offset_x /= 4; + offset_y /= 4; + if(max_y > 296){ + max_y = 296; + } + } else if (framesize <= FRAMESIZE_SVGA) { + mode = OV2640_MODE_SVGA; + max_x /= 2; + max_y /= 2; + offset_x /= 2; + offset_y /= 2; + } + + ret = set_window(sensor, mode, offset_x, offset_y, max_x, max_y, w, h); + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret=0; + level += 3; + if (level <= 0 || level > NUM_CONTRAST_LEVELS) { + return -1; + } + sensor->status.contrast = level-3; + for (int i=0; i<7; i++) { + WRITE_REG_OR_RETURN(BANK_DSP, contrast_regs[0][i], contrast_regs[level][i]); + } + return ret; +} + +static int set_brightness(sensor_t *sensor, int level) +{ + int ret=0; + level += 3; + if (level <= 0 || level > NUM_BRIGHTNESS_LEVELS) { + return -1; + } + sensor->status.brightness = level-3; + for (int i=0; i<5; i++) { + WRITE_REG_OR_RETURN(BANK_DSP, brightness_regs[0][i], brightness_regs[level][i]); + } + return ret; +} + +static int set_saturation(sensor_t *sensor, int level) +{ + int ret=0; + level += 3; + if (level <= 0 || level > NUM_SATURATION_LEVELS) { + return -1; + } + sensor->status.saturation = level-3; + for (int i=0; i<5; i++) { + WRITE_REG_OR_RETURN(BANK_DSP, saturation_regs[0][i], saturation_regs[level][i]); + } + return ret; +} + +static int set_special_effect(sensor_t *sensor, int effect) +{ + int ret=0; + effect++; + if (effect <= 0 || effect > NUM_SPECIAL_EFFECTS) { + return -1; + } + sensor->status.special_effect = effect-1; + for (int i=0; i<5; i++) { + WRITE_REG_OR_RETURN(BANK_DSP, special_effects_regs[0][i], special_effects_regs[effect][i]); + } + return ret; +} + +static int set_wb_mode(sensor_t *sensor, int mode) +{ + int ret=0; + if (mode < 0 || mode > NUM_WB_MODES) { + return -1; + } + sensor->status.wb_mode = mode; + SET_REG_BITS_OR_RETURN(BANK_DSP, 0XC7, 6, 1, mode?1:0); + if(mode) { + for (int i=0; i<3; i++) { + WRITE_REG_OR_RETURN(BANK_DSP, wb_modes_regs[0][i], wb_modes_regs[mode][i]); + } + } + return ret; +} + +static int set_ae_level(sensor_t *sensor, int level) +{ + int ret=0; + level += 3; + if (level <= 0 || level > NUM_AE_LEVELS) { + return -1; + } + sensor->status.ae_level = level-3; + for (int i=0; i<3; i++) { + WRITE_REG_OR_RETURN(BANK_SENSOR, ae_levels_regs[0][i], ae_levels_regs[level][i]); + } + return ret; +} + +static int set_quality(sensor_t *sensor, int quality) +{ + if(quality < 0) { + quality = 0; + } else if(quality > 63) { + quality = 63; + } + sensor->status.quality = quality; + return write_reg(sensor, BANK_DSP, QS, quality); +} + +static int set_agc_gain(sensor_t *sensor, int gain) +{ + if(gain < 0) { + gain = 0; + } else if(gain > 30) { + gain = 30; + } + sensor->status.agc_gain = gain; + return write_reg(sensor, BANK_SENSOR, GAIN, agc_gain_tbl[gain]); +} + +static int set_gainceiling_sensor(sensor_t *sensor, gainceiling_t gainceiling) +{ + sensor->status.gainceiling = gainceiling; + //return write_reg(sensor, BANK_SENSOR, COM9, COM9_AGC_SET(gainceiling)); + return set_reg_bits(sensor, BANK_SENSOR, COM9, 5, 7, gainceiling); +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + if(value < 0) { + value = 0; + } else if(value > 1200) { + value = 1200; + } + sensor->status.aec_value = value; + return set_reg_bits(sensor, BANK_SENSOR, REG04, 0, 3, value & 0x3) + || write_reg(sensor, BANK_SENSOR, AEC, (value >> 2) & 0xFF) + || set_reg_bits(sensor, BANK_SENSOR, REG45, 0, 0x3F, value >> 10); +} + +static int set_aec2(sensor_t *sensor, int enable) +{ + sensor->status.aec2 = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL0, 6, 1, enable?0:1); +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + sensor->status.colorbar = enable; + return write_reg_bits(sensor, BANK_SENSOR, COM7, COM7_COLOR_BAR, enable?1:0); +} + +static int set_agc_sensor(sensor_t *sensor, int enable) +{ + sensor->status.agc = enable; + return write_reg_bits(sensor, BANK_SENSOR, COM8, COM8_AGC_EN, enable?1:0); +} + +static int set_aec_sensor(sensor_t *sensor, int enable) +{ + sensor->status.aec = enable; + return write_reg_bits(sensor, BANK_SENSOR, COM8, COM8_AEC_EN, enable?1:0); +} + +static int set_hmirror_sensor(sensor_t *sensor, int enable) +{ + sensor->status.hmirror = enable; + return write_reg_bits(sensor, BANK_SENSOR, REG04, REG04_HFLIP_IMG, enable?1:0); +} + +static int set_vflip_sensor(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = write_reg_bits(sensor, BANK_SENSOR, REG04, REG04_VREF_EN, enable?1:0); + return ret & write_reg_bits(sensor, BANK_SENSOR, REG04, REG04_VFLIP_IMG, enable?1:0); +} + +static int set_raw_gma_dsp(sensor_t *sensor, int enable) +{ + sensor->status.raw_gma = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL1, 5, 1, enable?1:0); +} + +static int set_awb_dsp(sensor_t *sensor, int enable) +{ + sensor->status.awb = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL1, 3, 1, enable?1:0); +} + +static int set_awb_gain_dsp(sensor_t *sensor, int enable) +{ + sensor->status.awb_gain = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL1, 2, 1, enable?1:0); +} + +static int set_lenc_dsp(sensor_t *sensor, int enable) +{ + sensor->status.lenc = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL1, 1, 1, enable?1:0); +} + +static int set_dcw_dsp(sensor_t *sensor, int enable) +{ + sensor->status.dcw = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL2, 5, 1, enable?1:0); +} + +static int set_bpc_dsp(sensor_t *sensor, int enable) +{ + sensor->status.bpc = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL3, 7, 1, enable?1:0); +} + +static int set_wpc_dsp(sensor_t *sensor, int enable) +{ + sensor->status.wpc = enable; + return set_reg_bits(sensor, BANK_DSP, CTRL3, 6, 1, enable?1:0); +} + +//unsupported +static int set_sharpness(sensor_t *sensor, int level) +{ + return -1; +} + +static int set_denoise(sensor_t *sensor, int level) +{ + return -1; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = read_reg(sensor, (reg >> 8) & 0x01, reg & 0xFF); + if(ret > 0){ + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + ret = read_reg(sensor, (reg >> 8) & 0x01, reg & 0xFF); + if(ret < 0){ + return ret; + } + value = (ret & ~mask) | (value & mask); + ret = write_reg(sensor, (reg >> 8) & 0x01, reg & 0xFF, value); + return ret; +} + +static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) +{ + return set_window(sensor, (ov2640_sensor_mode_t)startX, offsetX, offsetY, totalX, totalY, outputX, outputY); +} + +static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) +{ + return -1; +} + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +static int init_status(sensor_t *sensor){ + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.ae_level = 0; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + + sensor->status.agc_gain = 30; + int agc_gain = read_reg(sensor, BANK_SENSOR, GAIN); + for (int i=0; i<30; i++){ + if(agc_gain >= agc_gain_tbl[i] && agc_gain < agc_gain_tbl[i+1]){ + sensor->status.agc_gain = i; + break; + } + } + + sensor->status.aec_value = ((uint16_t)get_reg_bits(sensor, BANK_SENSOR, REG45, 0, 0x3F) << 10) + | ((uint16_t)read_reg(sensor, BANK_SENSOR, AEC) << 2) + | get_reg_bits(sensor, BANK_SENSOR, REG04, 0, 3);//0 - 1200 + sensor->status.quality = read_reg(sensor, BANK_DSP, QS); + sensor->status.gainceiling = get_reg_bits(sensor, BANK_SENSOR, COM9, 5, 7); + + sensor->status.awb = get_reg_bits(sensor, BANK_DSP, CTRL1, 3, 1); + sensor->status.awb_gain = get_reg_bits(sensor, BANK_DSP, CTRL1, 2, 1); + sensor->status.aec = get_reg_bits(sensor, BANK_SENSOR, COM8, 0, 1); + sensor->status.aec2 = get_reg_bits(sensor, BANK_DSP, CTRL0, 6, 1); + sensor->status.agc = get_reg_bits(sensor, BANK_SENSOR, COM8, 2, 1); + sensor->status.bpc = get_reg_bits(sensor, BANK_DSP, CTRL3, 7, 1); + sensor->status.wpc = get_reg_bits(sensor, BANK_DSP, CTRL3, 6, 1); + sensor->status.raw_gma = get_reg_bits(sensor, BANK_DSP, CTRL1, 5, 1); + sensor->status.lenc = get_reg_bits(sensor, BANK_DSP, CTRL1, 1, 1); + sensor->status.hmirror = get_reg_bits(sensor, BANK_SENSOR, REG04, 7, 1); + sensor->status.vflip = get_reg_bits(sensor, BANK_SENSOR, REG04, 6, 1); + sensor->status.dcw = get_reg_bits(sensor, BANK_DSP, CTRL2, 5, 1); + sensor->status.colorbar = get_reg_bits(sensor, BANK_SENSOR, COM7, 1, 1); + + sensor->status.sharpness = 0;//not supported + sensor->status.denoise = 0; + return 0; +} + +int ov2640_detect(int slv_addr, sensor_id_t *id) +{ + if (OV2640_SCCB_ADDR == slv_addr) { + SCCB_Write(slv_addr, 0xFF, 0x01);//bank sensor + uint16_t PID = SCCB_Read(slv_addr, 0x0A); + if (OV2640_PID == PID) { + id->PID = PID; + id->VER = SCCB_Read(slv_addr, REG_VER); + id->MIDL = SCCB_Read(slv_addr, REG_MIDL); + id->MIDH = SCCB_Read(slv_addr, REG_MIDH); + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int ov2640_init(sensor_t *sensor) +{ + sensor->reset = reset; + sensor->init_status = init_status; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_contrast; + sensor->set_brightness= set_brightness; + sensor->set_saturation= set_saturation; + + sensor->set_quality = set_quality; + sensor->set_colorbar = set_colorbar; + + sensor->set_gainceiling = set_gainceiling_sensor; + sensor->set_gain_ctrl = set_agc_sensor; + sensor->set_exposure_ctrl = set_aec_sensor; + sensor->set_hmirror = set_hmirror_sensor; + sensor->set_vflip = set_vflip_sensor; + + sensor->set_whitebal = set_awb_dsp; + sensor->set_aec2 = set_aec2; + sensor->set_aec_value = set_aec_value; + sensor->set_special_effect = set_special_effect; + sensor->set_wb_mode = set_wb_mode; + sensor->set_ae_level = set_ae_level; + + sensor->set_dcw = set_dcw_dsp; + sensor->set_bpc = set_bpc_dsp; + sensor->set_wpc = set_wpc_dsp; + sensor->set_awb_gain = set_awb_gain_dsp; + sensor->set_agc_gain = set_agc_gain; + + sensor->set_raw_gma = set_raw_gma_dsp; + sensor->set_lenc = set_lenc_dsp; + + //not supported + sensor->set_sharpness = set_sharpness; + sensor->set_denoise = set_denoise; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = set_res_raw; + sensor->set_pll = _set_pll; + sensor->set_xclk = set_xclk; + ESP_LOGD(TAG, "OV2640 Attached"); + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov3660.c b/lib/libesp32_div/esp32-camera/sensors/ov3660.c new file mode 100644 index 000000000..b9ebdba3b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/ov3660.c @@ -0,0 +1,1053 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV3660 driver. + * + */ +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "ov3660.h" +#include "ov3660_regs.h" +#include "ov3660_settings.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "ov3660"; +#endif + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg){ + int ret = SCCB_Read16(slv_addr, reg); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask){ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static int read_reg16(uint8_t slv_addr, const uint16_t reg){ + int ret = 0, ret2 = 0; + ret = read_reg(slv_addr, reg); + if (ret >= 0) { + ret = (ret & 0xFF) << 8; + ret2 = read_reg(slv_addr, reg+1); + if (ret2 < 0) { + ret = ret2; + } else { + ret |= ret2 & 0xFF; + } + } + return ret; +} + + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value){ + int ret = 0; +#ifndef REG_DEBUG_ON + ret = SCCB_Write16(slv_addr, reg, value); +#else + int old_value = read_reg(slv_addr, reg); + if (old_value < 0) { + return old_value; + } + if ((uint8_t)old_value != value) { + ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); + ret = SCCB_Write16(slv_addr, reg, value); + } else { + ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); + ret = SCCB_Write16(slv_addr, reg, value);//maybe not? + } + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + ret = read_reg(slv_addr, reg); + if(ret < 0) { + return ret; + } + c_value = ret; + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = write_reg(slv_addr, reg, new_value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +{ + int i = 0, ret = 0; + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + i++; + } + return ret; +} + +static int write_reg16(uint8_t slv_addr, const uint16_t reg, uint16_t value) +{ + if (write_reg(slv_addr, reg, value >> 8) || write_reg(slv_addr, reg + 1, value)) { + return -1; + } + return 0; +} + +static int write_addr_reg(uint8_t slv_addr, const uint16_t reg, uint16_t x_value, uint16_t y_value) +{ + if (write_reg16(slv_addr, reg, x_value) || write_reg16(slv_addr, reg + 2, y_value)) { + return -1; + } + return 0; +} + +#define write_reg_bits(slv_addr, reg, mask, enable) set_reg_bits(slv_addr, reg, 0, mask, enable?mask:0) + +static int calc_sysclk(int xclk, bool pll_bypass, int pll_multiplier, int pll_sys_div, int pll_pre_div, bool pll_root_2x, int pll_seld5, bool pclk_manual, int pclk_div) +{ + const int pll_pre_div2x_map[] = { 2, 3, 4, 6 };//values are multiplied by two to avoid floats + const int pll_seld52x_map[] = { 2, 2, 4, 5 }; + + if(!pll_sys_div) { + pll_sys_div = 1; + } + + int pll_pre_div2x = pll_pre_div2x_map[pll_pre_div]; + int pll_root_div = pll_root_2x?2:1; + int pll_seld52x = pll_seld52x_map[pll_seld5]; + + int VCO = (xclk / 1000) * pll_multiplier * pll_root_div * 2 / pll_pre_div2x; + int PLLCLK = pll_bypass?(xclk):(VCO * 1000 * 2 / pll_sys_div / pll_seld52x); + int PCLK = PLLCLK / 2 / ((pclk_manual && pclk_div)?pclk_div:1); + int SYSCLK = PLLCLK / 4; + + ESP_LOGI(TAG, "Calculated VCO: %d Hz, PLLCLK: %d Hz, SYSCLK: %d Hz, PCLK: %d Hz", VCO*1000, PLLCLK, SYSCLK, PCLK); + return SYSCLK; +} + +static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sys_div, uint8_t pre_div, bool root_2x, uint8_t seld5, bool pclk_manual, uint8_t pclk_div){ + int ret = 0; + if(multiplier > 31 || sys_div > 15 || pre_div > 3 || pclk_div > 31 || seld5 > 3){ + ESP_LOGE(TAG, "Invalid arguments"); + return -1; + } + + calc_sysclk(sensor->xclk_freq_hz, bypass, multiplier, sys_div, pre_div, root_2x, seld5, pclk_manual, pclk_div); + + ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL0, bypass?0x80:0x00); + if (ret == 0) { + ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL1, multiplier & 0x1f); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL2, 0x10 | (sys_div & 0x0f)); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL3, (pre_div & 0x3) << 4 | seld5 | (root_2x?0x40:0x00)); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, PCLK_RATIO, pclk_div & 0x1f); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, VFIFO_CTRL0C, pclk_manual?0x22:0x20); + } + if(ret){ + ESP_LOGE(TAG, "set_sensor_pll FAILED!"); + } + return ret; +} + +static int set_ae_level(sensor_t *sensor, int level); + +static int reset(sensor_t *sensor) +{ + int ret = 0; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, SYSTEM_CTROL0, 0x82); + if(ret){ + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + vTaskDelay(100 / portTICK_PERIOD_MS); + ret = write_regs(sensor->slv_addr, sensor_default_regs); + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + ret = set_ae_level(sensor, 0); + vTaskDelay(100 / portTICK_PERIOD_MS); + } + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + const uint16_t (*regs)[2]; + + switch (pixformat) { + case PIXFORMAT_YUV422: + regs = sensor_fmt_yuv422; + break; + + case PIXFORMAT_GRAYSCALE: + regs = sensor_fmt_grayscale; + break; + + case PIXFORMAT_RGB565: + case PIXFORMAT_RGB888: + regs = sensor_fmt_rgb565; + break; + + case PIXFORMAT_JPEG: + regs = sensor_fmt_jpeg; + break; + + case PIXFORMAT_RAW: + regs = sensor_fmt_raw; + break; + + default: + ESP_LOGE(TAG, "Unsupported pixformat: %u", pixformat); + return -1; + } + + ret = write_regs(sensor->slv_addr, regs); + if(ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + return ret; +} + +static int set_image_options(sensor_t *sensor) +{ + int ret = 0; + uint8_t reg20 = 0; + uint8_t reg21 = 0; + uint8_t reg4514 = 0; + uint8_t reg4514_test = 0; + + // compression + if (sensor->pixformat == PIXFORMAT_JPEG) { + reg21 |= 0x20; + } + + // binning + if (sensor->status.binning) { + reg20 |= 0x01; + reg21 |= 0x01; + reg4514_test |= 4; + } else { + reg20 |= 0x40; + } + + // V-Flip + if (sensor->status.vflip) { + reg20 |= 0x06; + reg4514_test |= 1; + } + + // H-Mirror + if (sensor->status.hmirror) { + reg21 |= 0x06; + reg4514_test |= 2; + } + + switch (reg4514_test) { + //no binning + case 0: reg4514 = 0x88; break;//normal + case 1: reg4514 = 0x88; break;//v-flip + case 2: reg4514 = 0xbb; break;//h-mirror + case 3: reg4514 = 0xbb; break;//v-flip+h-mirror + //binning + case 4: reg4514 = 0xaa; break;//normal + case 5: reg4514 = 0xbb; break;//v-flip + case 6: reg4514 = 0xbb; break;//h-mirror + case 7: reg4514 = 0xaa; break;//v-flip+h-mirror + } + + if(write_reg(sensor->slv_addr, TIMING_TC_REG20, reg20) + || write_reg(sensor->slv_addr, TIMING_TC_REG21, reg21) + || write_reg(sensor->slv_addr, 0x4514, reg4514)){ + ESP_LOGE(TAG, "Setting Image Options Failed"); + ret = -1; + } + + if (sensor->status.binning) { + ret = write_reg(sensor->slv_addr, 0x4520, 0x0b) + || write_reg(sensor->slv_addr, X_INCREMENT, 0x31)//odd:3, even: 1 + || write_reg(sensor->slv_addr, Y_INCREMENT, 0x31);//odd:3, even: 1 + } else { + ret = write_reg(sensor->slv_addr, 0x4520, 0xb0) + || write_reg(sensor->slv_addr, X_INCREMENT, 0x11)//odd:1, even: 1 + || write_reg(sensor->slv_addr, Y_INCREMENT, 0x11);//odd:1, even: 1 + } + + ESP_LOGD(TAG, "Set Image Options: Compression: %u, Binning: %u, V-Flip: %u, H-Mirror: %u, Reg-4514: 0x%02x", + sensor->pixformat == PIXFORMAT_JPEG, sensor->status.binning, sensor->status.vflip, sensor->status.hmirror, reg4514); + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + + if(framesize > FRAMESIZE_QXGA){ + ESP_LOGW(TAG, "Invalid framesize: %u", framesize); + framesize = FRAMESIZE_QXGA; + } + framesize_t old_framesize = sensor->status.framesize; + sensor->status.framesize = framesize; + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + aspect_ratio_t ratio = resolution[sensor->status.framesize].aspect_ratio; + ratio_settings_t settings = ratio_table[ratio]; + + sensor->status.binning = (w <= (settings.max_width / 2) && h <= (settings.max_height / 2)); + sensor->status.scale = !((w == settings.max_width && h == settings.max_height) + || (w == (settings.max_width / 2) && h == (settings.max_height / 2))); + + ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, settings.start_x, settings.start_y) + || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, settings.end_x, settings.end_y) + || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, w, h); + + if (ret) { + goto fail; + } + + if (sensor->status.binning) { + ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x, (settings.total_y / 2) + 1) + || write_addr_reg(sensor->slv_addr, X_OFFSET_H, 8, 2); + } else { + ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x, settings.total_y) + || write_addr_reg(sensor->slv_addr, X_OFFSET_H, 16, 6); + } + + if (ret == 0) { + ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, sensor->status.scale); + } + + if (ret == 0) { + ret = set_image_options(sensor); + } + + if (ret) { + goto fail; + } + + if (sensor->pixformat == PIXFORMAT_JPEG) { + if (framesize == FRAMESIZE_QXGA || sensor->xclk_freq_hz == 16000000) { + //40MHz SYSCLK and 10MHz PCLK + ret = set_pll(sensor, false, 24, 1, 3, false, 0, true, 8); + } else { + //50MHz SYSCLK and 10MHz PCLK + ret = set_pll(sensor, false, 30, 1, 3, false, 0, true, 10); + } + } else { + //tuned for 16MHz XCLK and 8MHz PCLK + if (framesize > FRAMESIZE_HVGA) { + //8MHz SYSCLK and 8MHz PCLK (4.44 FPS) + ret = set_pll(sensor, false, 4, 1, 0, false, 2, true, 2); + } else if (framesize >= FRAMESIZE_QVGA) { + //16MHz SYSCLK and 8MHz PCLK (10.25 FPS) + ret = set_pll(sensor, false, 8, 1, 0, false, 2, true, 4); + } else { + //32MHz SYSCLK and 8MHz PCLK (17.77 FPS) + ret = set_pll(sensor, false, 8, 1, 0, false, 0, true, 8); + } + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); + } + return ret; + +fail: + sensor->status.framesize = old_framesize; + ESP_LOGE(TAG, "Setting framesize to: %ux%u failed", w, h); + return ret; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + ret = set_image_options(sensor); + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = set_image_options(sensor); + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + return ret; +} + +static int set_quality(sensor_t *sensor, int qs) +{ + int ret = 0; + ret = write_reg(sensor->slv_addr, COMPRESSION_CTRL07, qs & 0x3f); + if (ret == 0) { + sensor->status.quality = qs; + ESP_LOGD(TAG, "Set quality to: %d", qs); + } + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR, enable); + if (ret == 0) { + sensor->status.colorbar = enable; + ESP_LOGD(TAG, "Set colorbar to: %d", enable); + } + return ret; +} + +static int set_gain_ctrl(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set gain_ctrl to: %d", enable); + sensor->status.agc = enable; + } + return ret; +} + +static int set_exposure_ctrl(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set exposure_ctrl to: %d", enable); + sensor->status.aec = enable; + } + return ret; +} + +static int set_whitebal(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x01, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set awb to: %d", enable); + sensor->status.awb = enable; + } + return ret; +} + +//Advanced AWB +static int set_dcw_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5183, 0x80, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set dcw to: %d", enable); + sensor->status.dcw = enable; + } + return ret; +} + +//night mode enable +static int set_aec2(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x3a00, 0x04, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set aec2 to: %d", enable); + sensor->status.aec2 = enable; + } + return ret; +} + +static int set_bpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x04, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set bpc to: %d", enable); + sensor->status.bpc = enable; + } + return ret; +} + +static int set_wpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x02, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set wpc to: %d", enable); + sensor->status.wpc = enable; + } + return ret; +} + +//Gamma enable +static int set_raw_gma_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x20, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set raw_gma to: %d", enable); + sensor->status.raw_gma = enable; + } + return ret; +} + +static int set_lenc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x80, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set lenc to: %d", enable); + sensor->status.lenc = enable; + } + return ret; +} + +static int get_agc_gain(sensor_t *sensor) +{ + int ra = read_reg(sensor->slv_addr, 0x350a); + if (ra < 0) { + return 0; + } + int rb = read_reg(sensor->slv_addr, 0x350b); + if (rb < 0) { + return 0; + } + int res = (rb & 0xF0) >> 4 | (ra & 0x03) << 4; + if (rb & 0x0F) { + res += 1; + } + return res; +} + +//real gain +static int set_agc_gain(sensor_t *sensor, int gain) +{ + int ret = 0; + if(gain < 0) { + gain = 0; + } else if(gain > 64) { + gain = 64; + } + + //gain value is 6.4 bits float + //in order to use the max range, we deduct 1/16 + int gainv = gain << 4; + if(gainv){ + gainv -= 1; + } + + ret = write_reg(sensor->slv_addr, 0x350a, gainv >> 8) || write_reg(sensor->slv_addr, 0x350b, gainv & 0xff); + if (ret == 0) { + ESP_LOGD(TAG, "Set agc_gain to: %d", gain); + sensor->status.agc_gain = gain; + } + return ret; +} + +static int get_aec_value(sensor_t *sensor) +{ + int ra = read_reg(sensor->slv_addr, 0x3500); + if (ra < 0) { + return 0; + } + int rb = read_reg(sensor->slv_addr, 0x3501); + if (rb < 0) { + return 0; + } + int rc = read_reg(sensor->slv_addr, 0x3502); + if (rc < 0) { + return 0; + } + int res = (ra & 0x0F) << 12 | (rb & 0xFF) << 4 | (rc & 0xF0) >> 4; + return res; +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + int ret = 0, max_val = 0; + max_val = read_reg16(sensor->slv_addr, 0x380e); + if (max_val < 0) { + ESP_LOGE(TAG, "Could not read max aec_value"); + return -1; + } + if (value > max_val) { + value =max_val; + } + + ret = write_reg(sensor->slv_addr, 0x3500, (value >> 12) & 0x0F) + || write_reg(sensor->slv_addr, 0x3501, (value >> 4) & 0xFF) + || write_reg(sensor->slv_addr, 0x3502, (value << 4) & 0xF0); + + if (ret == 0) { + ESP_LOGD(TAG, "Set aec_value to: %d / %d", value, max_val); + sensor->status.aec_value = value; + } + return ret; +} + +static int set_ae_level(sensor_t *sensor, int level) +{ + int ret = 0; + if (level < -5 || level > 5) { + return -1; + } + //good targets are between 5 and 115 + int target_level = ((level + 5) * 10) + 5; + + int level_high, level_low; + int fast_high, fast_low; + + level_low = target_level * 23 / 25; //0.92 (0.46) + level_high = target_level * 27 / 25; //1.08 (2.08) + + fast_low = level_low >> 1; + fast_high = level_high << 1; + + if(fast_high>255) { + fast_high = 255; + } + + ret = write_reg(sensor->slv_addr, 0x3a0f, level_high) + || write_reg(sensor->slv_addr, 0x3a10, level_low) + || write_reg(sensor->slv_addr, 0x3a1b, level_high) + || write_reg(sensor->slv_addr, 0x3a1e, level_low) + || write_reg(sensor->slv_addr, 0x3a11, fast_high) + || write_reg(sensor->slv_addr, 0x3a1f, fast_low); + + if (ret == 0) { + ESP_LOGD(TAG, "Set ae_level to: %d", level); + sensor->status.ae_level = level; + } + return ret; +} + +static int set_wb_mode(sensor_t *sensor, int mode) +{ + int ret = 0; + if (mode < 0 || mode > 4) { + return -1; + } + + ret = write_reg(sensor->slv_addr, 0x3406, (mode != 0)); + if (ret) { + return ret; + } + switch (mode) { + case 1://Sunny + ret = write_reg16(sensor->slv_addr, 0x3400, 0x5e0) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x540);//AWB B GAIN + break; + case 2://Cloudy + ret = write_reg16(sensor->slv_addr, 0x3400, 0x650) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x4f0);//AWB B GAIN + break; + case 3://Office + ret = write_reg16(sensor->slv_addr, 0x3400, 0x520) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x660);//AWB B GAIN + break; + case 4://HOME + ret = write_reg16(sensor->slv_addr, 0x3400, 0x420) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x3f0) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x710);//AWB B GAIN + break; + default://AUTO + break; + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set wb_mode to: %d", mode); + sensor->status.wb_mode = mode; + } + return ret; +} + +static int set_awb_gain_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + int old_mode = sensor->status.wb_mode; + int mode = enable?old_mode:0; + + ret = set_wb_mode(sensor, mode); + + if (ret == 0) { + sensor->status.wb_mode = old_mode; + ESP_LOGD(TAG, "Set awb_gain to: %d", enable); + sensor->status.awb_gain = enable; + } + return ret; +} + +static int set_special_effect(sensor_t *sensor, int effect) +{ + int ret=0; + if (effect < 0 || effect > 6) { + return -1; + } + + uint8_t * regs = (uint8_t *)sensor_special_effects[effect]; + ret = write_reg(sensor->slv_addr, 0x5580, regs[0]) + || write_reg(sensor->slv_addr, 0x5583, regs[1]) + || write_reg(sensor->slv_addr, 0x5584, regs[2]) + || write_reg(sensor->slv_addr, 0x5003, regs[3]); + + if (ret == 0) { + ESP_LOGD(TAG, "Set special_effect to: %d", effect); + sensor->status.special_effect = effect; + } + return ret; +} + +static int set_brightness(sensor_t *sensor, int level) +{ + int ret = 0; + uint8_t value = 0; + bool negative = false; + + switch (level) { + case 3: + value = 0x30; + break; + case 2: + value = 0x20; + break; + case 1: + value = 0x10; + break; + case -1: + value = 0x10; + negative = true; + break; + case -2: + value = 0x20; + negative = true; + break; + case -3: + value = 0x30; + negative = true; + break; + default: // 0 + break; + } + + ret = write_reg(sensor->slv_addr, 0x5587, value); + if (ret == 0) { + ret = write_reg_bits(sensor->slv_addr, 0x5588, 0x08, negative); + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set brightness to: %d", level); + sensor->status.brightness = level; + } + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret = 0; + if(level > 3 || level < -3) { + return -1; + } + ret = write_reg(sensor->slv_addr, 0x5586, (level + 4) << 3); + + if (ret == 0) { + ESP_LOGD(TAG, "Set contrast to: %d", level); + sensor->status.contrast = level; + } + return ret; +} + +static int set_saturation(sensor_t *sensor, int level) +{ + int ret = 0; + if(level > 4 || level < -4) { + return -1; + } + + uint8_t * regs = (uint8_t *)sensor_saturation_levels[level+4]; + for(int i=0; i<11; i++) { + ret = write_reg(sensor->slv_addr, 0x5381 + i, regs[i]); + if (ret) { + break; + } + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set saturation to: %d", level); + sensor->status.saturation = level; + } + return ret; +} + +static int set_sharpness(sensor_t *sensor, int level) +{ + int ret = 0; + if(level > 3 || level < -3) { + return -1; + } + + uint8_t mt_offset_2 = (level + 3) * 8; + uint8_t mt_offset_1 = mt_offset_2 + 1; + + ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x40, false)//0x40 means auto + || write_reg(sensor->slv_addr, 0x5300, 0x10) + || write_reg(sensor->slv_addr, 0x5301, 0x10) + || write_reg(sensor->slv_addr, 0x5302, mt_offset_1) + || write_reg(sensor->slv_addr, 0x5303, mt_offset_2) + || write_reg(sensor->slv_addr, 0x5309, 0x10) + || write_reg(sensor->slv_addr, 0x530a, 0x10) + || write_reg(sensor->slv_addr, 0x530b, 0x04) + || write_reg(sensor->slv_addr, 0x530c, 0x06); + + if (ret == 0) { + ESP_LOGD(TAG, "Set sharpness to: %d", level); + sensor->status.sharpness = level; + } + return ret; +} + +static int set_gainceiling(sensor_t *sensor, gainceiling_t level) +{ + int ret = 0, l = (int)level; + + ret = write_reg(sensor->slv_addr, 0x3A18, (l >> 8) & 3) + || write_reg(sensor->slv_addr, 0x3A19, l & 0xFF); + + if (ret == 0) { + ESP_LOGD(TAG, "Set gainceiling to: %d", l); + sensor->status.gainceiling = l; + } + return ret; +} + +static int get_denoise(sensor_t *sensor) +{ + if (!check_reg_mask(sensor->slv_addr, 0x5308, 0x10)) { + return 0; + } + return (read_reg(sensor->slv_addr, 0x5306) / 4) + 1; +} + +static int set_denoise(sensor_t *sensor, int level) +{ + int ret = 0; + if (level < 0 || level > 8) { + return -1; + } + + ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x10, level > 0); + if (ret == 0 && level > 0) { + ret = write_reg(sensor->slv_addr, 0x5306, (level - 1) * 4); + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set denoise to: %d", level); + sensor->status.denoise = level; + } + return ret; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0, ret2 = 0; + if(mask > 0xFF){ + ret = read_reg16(sensor->slv_addr, reg); + if(ret >= 0 && mask > 0xFFFF){ + ret2 = read_reg(sensor->slv_addr, reg+2); + if(ret2 >= 0){ + ret = (ret << 8) | ret2 ; + } else { + ret = ret2; + } + } + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if(ret > 0){ + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0, ret2 = 0; + if(mask > 0xFF){ + ret = read_reg16(sensor->slv_addr, reg); + if(ret >= 0 && mask > 0xFFFF){ + ret2 = read_reg(sensor->slv_addr, reg+2); + if(ret2 >= 0){ + ret = (ret << 8) | ret2 ; + } else { + ret = ret2; + } + } + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if(ret < 0){ + return ret; + } + value = (ret & ~mask) | (value & mask); + if(mask > 0xFFFF){ + ret = write_reg16(sensor->slv_addr, reg, value >> 8); + if(ret >= 0){ + ret = write_reg(sensor->slv_addr, reg+2, value & 0xFF); + } + } else if(mask > 0xFF){ + ret = write_reg16(sensor->slv_addr, reg, value); + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + return ret; +} + +static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) +{ + int ret = 0; + ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, startX, startY) + || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, endX, endY) + || write_addr_reg(sensor->slv_addr, X_OFFSET_H, offsetX, offsetY) + || write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, totalX, totalY) + || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, outputX, outputY) + || write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, scale); + if(!ret){ + sensor->status.scale = scale; + sensor->status.binning = binning; + ret = set_image_options(sensor); + } + return ret; +} + +static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) +{ + return set_pll(sensor, bypass > 0, multiplier, sys_div, pre_div, root_2x > 0, seld5, pclk_manual > 0, pclk_div); +} + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +static int init_status(sensor_t *sensor) +{ + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.sharpness = (read_reg(sensor->slv_addr, 0x5303) / 8) - 3; + sensor->status.denoise = get_denoise(sensor); + sensor->status.ae_level = 0; + sensor->status.gainceiling = read_reg16(sensor->slv_addr, 0x3A18) & 0x3FF; + sensor->status.awb = check_reg_mask(sensor->slv_addr, ISP_CONTROL_01, 0x01); + sensor->status.dcw = !check_reg_mask(sensor->slv_addr, 0x5183, 0x80); + sensor->status.agc = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN); + sensor->status.aec = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN); + sensor->status.hmirror = check_reg_mask(sensor->slv_addr, TIMING_TC_REG21, TIMING_TC_REG21_HMIRROR); + sensor->status.vflip = check_reg_mask(sensor->slv_addr, TIMING_TC_REG20, TIMING_TC_REG20_VFLIP); + sensor->status.colorbar = check_reg_mask(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR); + sensor->status.bpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x04); + sensor->status.wpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x02); + sensor->status.raw_gma = check_reg_mask(sensor->slv_addr, 0x5000, 0x20); + sensor->status.lenc = check_reg_mask(sensor->slv_addr, 0x5000, 0x80); + sensor->status.quality = read_reg(sensor->slv_addr, COMPRESSION_CTRL07) & 0x3f; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = check_reg_mask(sensor->slv_addr, 0x3406, 0x01); + sensor->status.agc_gain = get_agc_gain(sensor); + sensor->status.aec_value = get_aec_value(sensor); + sensor->status.aec2 = check_reg_mask(sensor->slv_addr, 0x3a00, 0x04); + return 0; +} + +int ov3660_detect(int slv_addr, sensor_id_t *id) +{ + if (OV3660_SCCB_ADDR == slv_addr) { + uint8_t h = SCCB_Read16(slv_addr, 0x300A); + uint8_t l = SCCB_Read16(slv_addr, 0x300B); + uint16_t PID = (h<<8) | l; + if (OV3660_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int ov3660_init(sensor_t *sensor) +{ + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_contrast; + sensor->set_brightness = set_brightness; + sensor->set_saturation = set_saturation; + sensor->set_sharpness = set_sharpness; + sensor->set_gainceiling = set_gainceiling; + sensor->set_quality = set_quality; + sensor->set_colorbar = set_colorbar; + sensor->set_gain_ctrl = set_gain_ctrl; + sensor->set_exposure_ctrl = set_exposure_ctrl; + sensor->set_whitebal = set_whitebal; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + sensor->init_status = init_status; + sensor->set_aec2 = set_aec2; + sensor->set_aec_value = set_aec_value; + sensor->set_special_effect = set_special_effect; + sensor->set_wb_mode = set_wb_mode; + sensor->set_ae_level = set_ae_level; + sensor->set_dcw = set_dcw_dsp; + sensor->set_bpc = set_bpc_dsp; + sensor->set_wpc = set_wpc_dsp; + sensor->set_awb_gain = set_awb_gain_dsp; + sensor->set_agc_gain = set_agc_gain; + sensor->set_raw_gma = set_raw_gma_dsp; + sensor->set_lenc = set_lenc_dsp; + sensor->set_denoise = set_denoise; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = set_res_raw; + sensor->set_pll = _set_pll; + sensor->set_xclk = set_xclk; + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov5640.c b/lib/libesp32_div/esp32-camera/sensors/ov5640.c new file mode 100644 index 000000000..a32b374f5 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/ov5640.c @@ -0,0 +1,1130 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV3660 driver. + * + */ +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "ov5640.h" +#include "ov5640_regs.h" +#include "ov5640_settings.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char *TAG = "ov5640"; +#endif + +//#define REG_DEBUG_ON + +static int read_reg(uint8_t slv_addr, const uint16_t reg){ + int ret = SCCB_Read16(slv_addr, reg); +#ifdef REG_DEBUG_ON + if (ret < 0) { + ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask){ + return (read_reg(slv_addr, reg) & mask) == mask; +} + +static int read_reg16(uint8_t slv_addr, const uint16_t reg){ + int ret = 0, ret2 = 0; + ret = read_reg(slv_addr, reg); + if (ret >= 0) { + ret = (ret & 0xFF) << 8; + ret2 = read_reg(slv_addr, reg+1); + if (ret2 < 0) { + ret = ret2; + } else { + ret |= ret2 & 0xFF; + } + } + return ret; +} + +//static void dump_reg(sensor_t *sensor, const uint16_t reg){ +// int v = SCCB_Read16(sensor->slv_addr, reg); +// if(v < 0){ +// ets_printf(" 0x%04x: FAIL[%d]\n", reg, v); +// } else { +// ets_printf(" 0x%04x: 0x%02X\n", reg, v); +// } +//} +// +//static void dump_range(sensor_t *sensor, const char * name, const uint16_t start_reg, const uint16_t end_reg){ +// ets_printf("%s: 0x%04x - 0x%04X\n", name, start_reg, end_reg); +// for(uint16_t reg = start_reg; reg <= end_reg; reg++){ +// dump_reg(sensor, reg); +// } +//} +// +//static void dump_regs(sensor_t *sensor){ +//// dump_range(sensor, "All Regs", 0x3000, 0x6100); +//// dump_range(sensor, "system and IO pad control", 0x3000, 0x3052); +//// dump_range(sensor, "SCCB control", 0x3100, 0x3108); +//// dump_range(sensor, "SRB control", 0x3200, 0x3211); +//// dump_range(sensor, "AWB gain control", 0x3400, 0x3406); +//// dump_range(sensor, "AEC/AGC control", 0x3500, 0x350D); +//// dump_range(sensor, "VCM control", 0x3600, 0x3606); +//// dump_range(sensor, "timing control", 0x3800, 0x3821); +//// dump_range(sensor, "AEC/AGC power down domain control", 0x3A00, 0x3A25); +//// dump_range(sensor, "strobe control", 0x3B00, 0x3B0C); +//// dump_range(sensor, "50/60Hz detector control", 0x3C00, 0x3C1E); +//// dump_range(sensor, "OTP control", 0x3D00, 0x3D21); +//// dump_range(sensor, "MC control", 0x3F00, 0x3F0D); +//// dump_range(sensor, "BLC control", 0x4000, 0x4033); +//// dump_range(sensor, "frame control", 0x4201, 0x4202); +//// dump_range(sensor, "format control", 0x4300, 0x430D); +//// dump_range(sensor, "JPEG control", 0x4400, 0x4431); +//// dump_range(sensor, "VFIFO control", 0x4600, 0x460D); +//// dump_range(sensor, "DVP control", 0x4709, 0x4745); +//// dump_range(sensor, "MIPI control", 0x4800, 0x4837); +//// dump_range(sensor, "ISP frame control", 0x4901, 0x4902); +//// dump_range(sensor, "ISP top control", 0x5000, 0x5063); +//// dump_range(sensor, "AWB control", 0x5180, 0x51D0); +//// dump_range(sensor, "CIP control", 0x5300, 0x530F); +//// dump_range(sensor, "CMX control", 0x5380, 0x538B); +//// dump_range(sensor, "gamma control", 0x5480, 0x5490); +//// dump_range(sensor, "SDE control", 0x5580, 0x558C); +//// dump_range(sensor, "scale control", 0x5600, 0x5606); +//// dump_range(sensor, "AVG control", 0x5680, 0x56A2); +//// dump_range(sensor, "LENC control", 0x5800, 0x5849); +//// dump_range(sensor, "AFC control", 0x6000, 0x603F); +//} + +static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value){ + int ret = 0; +#ifndef REG_DEBUG_ON + ret = SCCB_Write16(slv_addr, reg, value); +#else + int old_value = read_reg(slv_addr, reg); + if (old_value < 0) { + return old_value; + } + if ((uint8_t)old_value != value) { + ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); + ret = SCCB_Write16(slv_addr, reg, value); + } else { + ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); + ret = SCCB_Write16(slv_addr, reg, value);//maybe not? + } + if (ret < 0) { + ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); + } +#endif + return ret; +} + +static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) +{ + int ret = 0; + uint8_t c_value, new_value; + ret = read_reg(slv_addr, reg); + if(ret < 0) { + return ret; + } + c_value = ret; + new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); + ret = write_reg(slv_addr, reg, new_value); + return ret; +} + +static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) +{ + int i = 0, ret = 0; + while (!ret && regs[i][0] != REGLIST_TAIL) { + if (regs[i][0] == REG_DLY) { + vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); + } else { + ret = write_reg(slv_addr, regs[i][0], regs[i][1]); + } + i++; + } + return ret; +} + +static int write_reg16(uint8_t slv_addr, const uint16_t reg, uint16_t value) +{ + if (write_reg(slv_addr, reg, value >> 8) || write_reg(slv_addr, reg + 1, value)) { + return -1; + } + return 0; +} + +static int write_addr_reg(uint8_t slv_addr, const uint16_t reg, uint16_t x_value, uint16_t y_value) +{ + if (write_reg16(slv_addr, reg, x_value) || write_reg16(slv_addr, reg + 2, y_value)) { + return -1; + } + return 0; +} + +#define write_reg_bits(slv_addr, reg, mask, enable) set_reg_bits(slv_addr, reg, 0, mask, (enable)?(mask):0) + +static int calc_sysclk(int xclk, bool pll_bypass, int pll_multiplier, int pll_sys_div, int pre_div, bool root_2x, int pclk_root_div, bool pclk_manual, int pclk_div) +{ + const float pll_pre_div2x_map[] = { 1, 1, 2, 3, 4, 1.5, 6, 2.5, 8}; + const int pll_pclk_root_div_map[] = { 1, 2, 4, 8 }; + + if(!pll_sys_div) { + pll_sys_div = 1; + } + + float pll_pre_div = pll_pre_div2x_map[pre_div]; + unsigned int root_2x_div = root_2x?2:1; + unsigned int pll_pclk_root_div = pll_pclk_root_div_map[pclk_root_div]; + + unsigned int REFIN = xclk / pll_pre_div; + + unsigned int VCO = REFIN * pll_multiplier / root_2x_div; + + unsigned int PLL_CLK = pll_bypass?(xclk):(VCO / pll_sys_div * 2 / 5);//5 here is 10bit mode / 2, for 8bit it should be 4 (reg 0x3034) + + unsigned int PCLK = PLL_CLK / pll_pclk_root_div / ((pclk_manual && pclk_div)?pclk_div:2); + + unsigned int SYSCLK = PLL_CLK / 4; + + ESP_LOGI(TAG, "Calculated XVCLK: %d Hz, REFIN: %u Hz, VCO: %u Hz, PLL_CLK: %u Hz, SYSCLK: %u Hz, PCLK: %u Hz", xclk, REFIN, VCO, PLL_CLK, SYSCLK, PCLK); + return SYSCLK; +} + +static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sys_div, uint8_t pre_div, bool root_2x, uint8_t pclk_root_div, bool pclk_manual, uint8_t pclk_div){ + int ret = 0; + if(multiplier > 252 || multiplier < 4 || sys_div > 15 || pre_div > 8 || pclk_div > 31 || pclk_root_div > 3){ + ESP_LOGE(TAG, "Invalid arguments"); + return -1; + } + if(multiplier > 127){ + multiplier &= 0xFE;//only even integers above 127 + } + ESP_LOGI(TAG, "Set PLL: bypass: %u, multiplier: %u, sys_div: %u, pre_div: %u, root_2x: %u, pclk_root_div: %u, pclk_manual: %u, pclk_div: %u", bypass, multiplier, sys_div, pre_div, root_2x, pclk_root_div, pclk_manual, pclk_div); + + calc_sysclk(sensor->xclk_freq_hz, bypass, multiplier, sys_div, pre_div, root_2x, pclk_root_div, pclk_manual, pclk_div); + + ret = write_reg(sensor->slv_addr, 0x3039, bypass?0x80:0x00); + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3034, 0x1A);//10bit mode + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3035, 0x01 | ((sys_div & 0x0f) << 4)); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3036, multiplier & 0xff); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3037, (pre_div & 0xf) | (root_2x?0x10:0x00)); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3108, (pclk_root_div & 0x3) << 4 | 0x06); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3824, pclk_div & 0x1f); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x460C, pclk_manual?0x22:0x20); + } + if (ret == 0) { + ret = write_reg(sensor->slv_addr, 0x3103, 0x13);// system clock from pll, bit[1] + } + if(ret){ + ESP_LOGE(TAG, "set_sensor_pll FAILED!"); + } + return ret; +} + +static int set_ae_level(sensor_t *sensor, int level); + +static int reset(sensor_t *sensor) +{ + //dump_regs(sensor); + vTaskDelay(100 / portTICK_PERIOD_MS); + int ret = 0; + // Software Reset: clear all registers and reset them to their default values + ret = write_reg(sensor->slv_addr, SYSTEM_CTROL0, 0x82); + if(ret){ + ESP_LOGE(TAG, "Software Reset FAILED!"); + return ret; + } + vTaskDelay(100 / portTICK_PERIOD_MS); + ret = write_regs(sensor->slv_addr, sensor_default_regs); + if (ret == 0) { + ESP_LOGD(TAG, "Camera defaults loaded"); + vTaskDelay(100 / portTICK_PERIOD_MS); + //write_regs(sensor->slv_addr, sensor_regs_awb0); + //write_regs(sensor->slv_addr, sensor_regs_gamma1); + } + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret = 0; + const uint16_t (*regs)[2]; + + switch (pixformat) { + case PIXFORMAT_YUV422: + regs = sensor_fmt_yuv422; + break; + + case PIXFORMAT_GRAYSCALE: + regs = sensor_fmt_grayscale; + break; + + case PIXFORMAT_RGB565: + case PIXFORMAT_RGB888: + regs = sensor_fmt_rgb565; + break; + + case PIXFORMAT_JPEG: + regs = sensor_fmt_jpeg; + break; + + case PIXFORMAT_RAW: + regs = sensor_fmt_raw; + break; + + default: + ESP_LOGE(TAG, "Unsupported pixformat: %u", pixformat); + return -1; + } + + ret = write_regs(sensor->slv_addr, regs); + if(ret == 0) { + sensor->pixformat = pixformat; + ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); + } + return ret; +} + +static int set_image_options(sensor_t *sensor) +{ + int ret = 0; + uint8_t reg20 = 0; + uint8_t reg21 = 0; + uint8_t reg4514 = 0; + uint8_t reg4514_test = 0; + + // compression + if (sensor->pixformat == PIXFORMAT_JPEG) { + reg21 |= 0x20; + } + + // binning + if (!sensor->status.binning) { + reg20 |= 0x40; + } else { + reg20 |= 0x01; + reg21 |= 0x01; + reg4514_test |= 4; + } + + // V-Flip + if (sensor->status.vflip) { + reg20 |= 0x06; + reg4514_test |= 1; + } + + // H-Mirror + if (sensor->status.hmirror) { + reg21 |= 0x06; + reg4514_test |= 2; + } + + switch (reg4514_test) { + //no binning + case 0: reg4514 = 0x88; break;//normal + case 1: reg4514 = 0x00; break;//v-flip + case 2: reg4514 = 0xbb; break;//h-mirror + case 3: reg4514 = 0x00; break;//v-flip+h-mirror + //binning + case 4: reg4514 = 0xaa; break;//normal + case 5: reg4514 = 0xbb; break;//v-flip + case 6: reg4514 = 0xbb; break;//h-mirror + case 7: reg4514 = 0xaa; break;//v-flip+h-mirror + } + + if(write_reg(sensor->slv_addr, TIMING_TC_REG20, reg20) + || write_reg(sensor->slv_addr, TIMING_TC_REG21, reg21) + || write_reg(sensor->slv_addr, 0x4514, reg4514)){ + ESP_LOGE(TAG, "Setting Image Options Failed"); + return -1; + } + + if (!sensor->status.binning) { + ret = write_reg(sensor->slv_addr, 0x4520, 0x10) + || write_reg(sensor->slv_addr, X_INCREMENT, 0x11)//odd:1, even: 1 + || write_reg(sensor->slv_addr, Y_INCREMENT, 0x11);//odd:1, even: 1 + } else { + ret = write_reg(sensor->slv_addr, 0x4520, 0x0b) + || write_reg(sensor->slv_addr, X_INCREMENT, 0x31)//odd:3, even: 1 + || write_reg(sensor->slv_addr, Y_INCREMENT, 0x31);//odd:3, even: 1 + } + + ESP_LOGD(TAG, "Set Image Options: Compression: %u, Binning: %u, V-Flip: %u, H-Mirror: %u, Reg-4514: 0x%02x", + sensor->pixformat == PIXFORMAT_JPEG, sensor->status.binning, sensor->status.vflip, sensor->status.hmirror, reg4514); + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret = 0; + framesize_t old_framesize = sensor->status.framesize; + sensor->status.framesize = framesize; + + if(framesize > FRAMESIZE_QSXGA){ + ESP_LOGE(TAG, "Invalid framesize: %u", framesize); + return -1; + } + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + aspect_ratio_t ratio = resolution[framesize].aspect_ratio; + ratio_settings_t settings = ratio_table[ratio]; + + sensor->status.binning = (w <= (settings.max_width / 2) && h <= (settings.max_height / 2)); + sensor->status.scale = !((w == settings.max_width && h == settings.max_height) + || (w == (settings.max_width / 2) && h == (settings.max_height / 2))); + + ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, settings.start_x, settings.start_y) + || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, settings.end_x, settings.end_y) + || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, w, h); + + if (ret) { + goto fail; + } + + if (!sensor->status.binning) { + ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x, settings.total_y) + || write_addr_reg(sensor->slv_addr, X_OFFSET_H, settings.offset_x, settings.offset_y); + } else { + if (w > 920) { + ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x - 200, settings.total_y / 2); + } else { + ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, 2060, settings.total_y / 2); + } + if (ret == 0) { + ret = write_addr_reg(sensor->slv_addr, X_OFFSET_H, settings.offset_x / 2, settings.offset_y / 2); + } + } + + if (ret == 0) { + ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, sensor->status.scale); + } + + if (ret == 0) { + ret = set_image_options(sensor); + } + + if (ret) { + goto fail; + } + + if (sensor->pixformat == PIXFORMAT_JPEG) { + //10MHz PCLK + uint8_t sys_mul = 200; + if(framesize < FRAMESIZE_QVGA || sensor->xclk_freq_hz == 16000000){ + sys_mul = 160; + } else if(framesize < FRAMESIZE_XGA){ + sys_mul = 180; + } + ret = set_pll(sensor, false, sys_mul, 4, 2, false, 2, true, 4); + //Set PLL: bypass: 0, multiplier: sys_mul, sys_div: 4, pre_div: 2, root_2x: 0, pclk_root_div: 2, pclk_manual: 1, pclk_div: 4 + } else { + //ret = set_pll(sensor, false, 8, 1, 1, false, 1, true, 4); + if (framesize > FRAMESIZE_HVGA) { + ret = set_pll(sensor, false, 10, 1, 2, false, 1, true, 2); + } else if (framesize >= FRAMESIZE_QVGA) { + ret = set_pll(sensor, false, 8, 1, 1, false, 1, true, 4); + } else { + ret = set_pll(sensor, false, 20, 1, 1, false, 1, true, 8); + } + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); + } + return ret; + +fail: + sensor->status.framesize = old_framesize; + ESP_LOGE(TAG, "Setting framesize to: %ux%u failed", w, h); + return ret; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.hmirror = enable; + ret = set_image_options(sensor); + if (ret == 0) { + ESP_LOGD(TAG, "Set h-mirror to: %d", enable); + } + return ret; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + int ret = 0; + sensor->status.vflip = enable; + ret = set_image_options(sensor); + if (ret == 0) { + ESP_LOGD(TAG, "Set v-flip to: %d", enable); + } + return ret; +} + +static int set_quality(sensor_t *sensor, int qs) +{ + int ret = 0; + ret = write_reg(sensor->slv_addr, COMPRESSION_CTRL07, qs & 0x3f); + if (ret == 0) { + sensor->status.quality = qs; + ESP_LOGD(TAG, "Set quality to: %d", qs); + } + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR, enable); + if (ret == 0) { + sensor->status.colorbar = enable; + ESP_LOGD(TAG, "Set colorbar to: %d", enable); + } + return ret; +} + +static int set_gain_ctrl(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set gain_ctrl to: %d", enable); + sensor->status.agc = enable; + } + return ret; +} + +static int set_exposure_ctrl(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set exposure_ctrl to: %d", enable); + sensor->status.aec = enable; + } + return ret; +} + +static int set_whitebal(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x01, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set awb to: %d", enable); + sensor->status.awb = enable; + } + return ret; +} + +//Advanced AWB +static int set_dcw_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5183, 0x80, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set dcw to: %d", enable); + sensor->status.dcw = enable; + } + return ret; +} + +//night mode enable +static int set_aec2(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x3a00, 0x04, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set aec2 to: %d", enable); + sensor->status.aec2 = enable; + } + return ret; +} + +static int set_bpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x04, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set bpc to: %d", enable); + sensor->status.bpc = enable; + } + return ret; +} + +static int set_wpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x02, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set wpc to: %d", enable); + sensor->status.wpc = enable; + } + return ret; +} + +//Gamma enable +static int set_raw_gma_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x20, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set raw_gma to: %d", enable); + sensor->status.raw_gma = enable; + } + return ret; +} + +static int set_lenc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x80, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set lenc to: %d", enable); + sensor->status.lenc = enable; + } + return ret; +} + +static int get_agc_gain(sensor_t *sensor) +{ + int ra = read_reg(sensor->slv_addr, 0x350a); + if (ra < 0) { + return 0; + } + int rb = read_reg(sensor->slv_addr, 0x350b); + if (rb < 0) { + return 0; + } + int res = (rb & 0xF0) >> 4 | (ra & 0x03) << 4; + if (rb & 0x0F) { + res += 1; + } + return res; +} + +//real gain +static int set_agc_gain(sensor_t *sensor, int gain) +{ + int ret = 0; + if(gain < 0) { + gain = 0; + } else if(gain > 64) { + gain = 64; + } + + //gain value is 6.4 bits float + //in order to use the max range, we deduct 1/16 + int gainv = gain << 4; + if(gainv){ + gainv -= 1; + } + + ret = write_reg(sensor->slv_addr, 0x350a, gainv >> 8) || write_reg(sensor->slv_addr, 0x350b, gainv & 0xff); + if (ret == 0) { + ESP_LOGD(TAG, "Set agc_gain to: %d", gain); + sensor->status.agc_gain = gain; + } + return ret; +} + +static int get_aec_value(sensor_t *sensor) +{ + int ra = read_reg(sensor->slv_addr, 0x3500); + if (ra < 0) { + return 0; + } + int rb = read_reg(sensor->slv_addr, 0x3501); + if (rb < 0) { + return 0; + } + int rc = read_reg(sensor->slv_addr, 0x3502); + if (rc < 0) { + return 0; + } + int res = (ra & 0x0F) << 12 | (rb & 0xFF) << 4 | (rc & 0xF0) >> 4; + return res; +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + int ret = 0, max_val = 0; + max_val = read_reg16(sensor->slv_addr, 0x380e); + if (max_val < 0) { + ESP_LOGE(TAG, "Could not read max aec_value"); + return -1; + } + if (value > max_val) { + value =max_val; + } + + ret = write_reg(sensor->slv_addr, 0x3500, (value >> 12) & 0x0F) + || write_reg(sensor->slv_addr, 0x3501, (value >> 4) & 0xFF) + || write_reg(sensor->slv_addr, 0x3502, (value << 4) & 0xF0); + + if (ret == 0) { + ESP_LOGD(TAG, "Set aec_value to: %d / %d", value, max_val); + sensor->status.aec_value = value; + } + return ret; +} + +static int set_ae_level(sensor_t *sensor, int level) +{ + int ret = 0; + if (level < -5 || level > 5) { + return -1; + } + //good targets are between 5 and 115 + int target_level = ((level + 5) * 10) + 5; + + int level_high, level_low; + int fast_high, fast_low; + + level_low = target_level * 23 / 25; //0.92 (0.46) + level_high = target_level * 27 / 25; //1.08 (2.08) + + fast_low = level_low >> 1; + fast_high = level_high << 1; + + if(fast_high>255) { + fast_high = 255; + } + + ret = write_reg(sensor->slv_addr, 0x3a0f, level_high) + || write_reg(sensor->slv_addr, 0x3a10, level_low) + || write_reg(sensor->slv_addr, 0x3a1b, level_high) + || write_reg(sensor->slv_addr, 0x3a1e, level_low) + || write_reg(sensor->slv_addr, 0x3a11, fast_high) + || write_reg(sensor->slv_addr, 0x3a1f, fast_low); + + if (ret == 0) { + ESP_LOGD(TAG, "Set ae_level to: %d", level); + sensor->status.ae_level = level; + } + return ret; +} + +static int set_wb_mode(sensor_t *sensor, int mode) +{ + int ret = 0; + if (mode < 0 || mode > 4) { + return -1; + } + + ret = write_reg(sensor->slv_addr, 0x3406, (mode != 0)); + if (ret) { + return ret; + } + switch (mode) { + case 1://Sunny + ret = write_reg16(sensor->slv_addr, 0x3400, 0x5e0) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x540);//AWB B GAIN + break; + case 2://Cloudy + ret = write_reg16(sensor->slv_addr, 0x3400, 0x650) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x4f0);//AWB B GAIN + break; + case 3://Office + ret = write_reg16(sensor->slv_addr, 0x3400, 0x520) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x660);//AWB B GAIN + break; + case 4://HOME + ret = write_reg16(sensor->slv_addr, 0x3400, 0x420) //AWB R GAIN + || write_reg16(sensor->slv_addr, 0x3402, 0x3f0) //AWB G GAIN + || write_reg16(sensor->slv_addr, 0x3404, 0x710);//AWB B GAIN + break; + default://AUTO + break; + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set wb_mode to: %d", mode); + sensor->status.wb_mode = mode; + } + return ret; +} + +static int set_awb_gain_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + int old_mode = sensor->status.wb_mode; + int mode = enable?old_mode:0; + + ret = set_wb_mode(sensor, mode); + + if (ret == 0) { + sensor->status.wb_mode = old_mode; + ESP_LOGD(TAG, "Set awb_gain to: %d", enable); + sensor->status.awb_gain = enable; + } + return ret; +} + +static int set_special_effect(sensor_t *sensor, int effect) +{ + int ret=0; + if (effect < 0 || effect > 6) { + return -1; + } + + uint8_t * regs = (uint8_t *)sensor_special_effects[effect]; + ret = write_reg(sensor->slv_addr, 0x5580, regs[0]) + || write_reg(sensor->slv_addr, 0x5583, regs[1]) + || write_reg(sensor->slv_addr, 0x5584, regs[2]) + || write_reg(sensor->slv_addr, 0x5003, regs[3]); + + if (ret == 0) { + ESP_LOGD(TAG, "Set special_effect to: %d", effect); + sensor->status.special_effect = effect; + } + return ret; +} + +static int set_brightness(sensor_t *sensor, int level) +{ + int ret = 0; + uint8_t value = 0; + bool negative = false; + + switch (level) { + case 3: + value = 0x30; + break; + case 2: + value = 0x20; + break; + case 1: + value = 0x10; + break; + case -1: + value = 0x10; + negative = true; + break; + case -2: + value = 0x20; + negative = true; + break; + case -3: + value = 0x30; + negative = true; + break; + default: // 0 + break; + } + + ret = write_reg(sensor->slv_addr, 0x5587, value); + if (ret == 0) { + ret = write_reg_bits(sensor->slv_addr, 0x5588, 0x08, negative); + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set brightness to: %d", level); + sensor->status.brightness = level; + } + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret = 0; + if(level > 3 || level < -3) { + return -1; + } + ret = write_reg(sensor->slv_addr, 0x5586, (level + 4) << 3); + + if (ret == 0) { + ESP_LOGD(TAG, "Set contrast to: %d", level); + sensor->status.contrast = level; + } + return ret; +} + +static int set_saturation(sensor_t *sensor, int level) +{ + int ret = 0; + if(level > 4 || level < -4) { + return -1; + } + + uint8_t * regs = (uint8_t *)sensor_saturation_levels[level+4]; + for(int i=0; i<11; i++) { + ret = write_reg(sensor->slv_addr, 0x5381 + i, regs[i]); + if (ret) { + break; + } + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set saturation to: %d", level); + sensor->status.saturation = level; + } + return ret; +} + +static int set_sharpness(sensor_t *sensor, int level) +{ + int ret = 0; + if(level > 3 || level < -3) { + return -1; + } + + uint8_t mt_offset_2 = (level + 3) * 8; + uint8_t mt_offset_1 = mt_offset_2 + 1; + + ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x40, false)//0x40 means auto + || write_reg(sensor->slv_addr, 0x5300, 0x10) + || write_reg(sensor->slv_addr, 0x5301, 0x10) + || write_reg(sensor->slv_addr, 0x5302, mt_offset_1) + || write_reg(sensor->slv_addr, 0x5303, mt_offset_2) + || write_reg(sensor->slv_addr, 0x5309, 0x10) + || write_reg(sensor->slv_addr, 0x530a, 0x10) + || write_reg(sensor->slv_addr, 0x530b, 0x04) + || write_reg(sensor->slv_addr, 0x530c, 0x06); + + if (ret == 0) { + ESP_LOGD(TAG, "Set sharpness to: %d", level); + sensor->status.sharpness = level; + } + return ret; +} + +static int set_gainceiling(sensor_t *sensor, gainceiling_t level) +{ + int ret = 0, l = (int)level; + + ret = write_reg(sensor->slv_addr, 0x3A18, (l >> 8) & 3) + || write_reg(sensor->slv_addr, 0x3A19, l & 0xFF); + + if (ret == 0) { + ESP_LOGD(TAG, "Set gainceiling to: %d", l); + sensor->status.gainceiling = l; + } + return ret; +} + +static int get_denoise(sensor_t *sensor) +{ + if (!check_reg_mask(sensor->slv_addr, 0x5308, 0x10)) { + return 0; + } + return (read_reg(sensor->slv_addr, 0x5306) / 4) + 1; +} + +static int set_denoise(sensor_t *sensor, int level) +{ + int ret = 0; + if (level < 0 || level > 8) { + return -1; + } + + ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x10, level > 0); + if (ret == 0 && level > 0) { + ret = write_reg(sensor->slv_addr, 0x5306, (level - 1) * 4); + } + + if (ret == 0) { + ESP_LOGD(TAG, "Set denoise to: %d", level); + sensor->status.denoise = level; + } + return ret; +} + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = 0, ret2 = 0; + if(mask > 0xFF){ + ret = read_reg16(sensor->slv_addr, reg); + if(ret >= 0 && mask > 0xFFFF){ + ret2 = read_reg(sensor->slv_addr, reg+2); + if(ret2 >= 0){ + ret = (ret << 8) | ret2 ; + } else { + ret = ret2; + } + } + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if(ret > 0){ + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0, ret2 = 0; + if(mask > 0xFF){ + ret = read_reg16(sensor->slv_addr, reg); + if(ret >= 0 && mask > 0xFFFF){ + ret2 = read_reg(sensor->slv_addr, reg+2); + if(ret2 >= 0){ + ret = (ret << 8) | ret2 ; + } else { + ret = ret2; + } + } + } else { + ret = read_reg(sensor->slv_addr, reg); + } + if(ret < 0){ + return ret; + } + value = (ret & ~mask) | (value & mask); + if(mask > 0xFFFF){ + ret = write_reg16(sensor->slv_addr, reg, value >> 8); + if(ret >= 0){ + ret = write_reg(sensor->slv_addr, reg+2, value & 0xFF); + } + } else if(mask > 0xFF){ + ret = write_reg16(sensor->slv_addr, reg, value); + } else { + ret = write_reg(sensor->slv_addr, reg, value); + } + return ret; +} + +static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) +{ + int ret = 0; + ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, startX, startY) + || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, endX, endY) + || write_addr_reg(sensor->slv_addr, X_OFFSET_H, offsetX, offsetY) + || write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, totalX, totalY) + || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, outputX, outputY) + || write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, scale); + if(!ret){ + sensor->status.scale = scale; + sensor->status.binning = binning; + ret = set_image_options(sensor); + } + return ret; +} + +static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) +{ + int ret = 0; + ret = set_pll(sensor, bypass > 0, multiplier, sys_div, pre_div, root_2x > 0, seld5, pclk_manual > 0, pclk_div); + return ret; +} + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +static int init_status(sensor_t *sensor) +{ + sensor->status.brightness = 0; + sensor->status.contrast = 0; + sensor->status.saturation = 0; + sensor->status.sharpness = (read_reg(sensor->slv_addr, 0x5303) / 8) - 3; + sensor->status.denoise = get_denoise(sensor); + sensor->status.ae_level = 0; + sensor->status.gainceiling = read_reg16(sensor->slv_addr, 0x3A18) & 0x3FF; + sensor->status.awb = check_reg_mask(sensor->slv_addr, ISP_CONTROL_01, 0x01); + sensor->status.dcw = !check_reg_mask(sensor->slv_addr, 0x5183, 0x80); + sensor->status.agc = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN); + sensor->status.aec = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN); + sensor->status.hmirror = check_reg_mask(sensor->slv_addr, TIMING_TC_REG21, TIMING_TC_REG21_HMIRROR); + sensor->status.vflip = check_reg_mask(sensor->slv_addr, TIMING_TC_REG20, TIMING_TC_REG20_VFLIP); + sensor->status.colorbar = check_reg_mask(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR); + sensor->status.bpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x04); + sensor->status.wpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x02); + sensor->status.raw_gma = check_reg_mask(sensor->slv_addr, 0x5000, 0x20); + sensor->status.lenc = check_reg_mask(sensor->slv_addr, 0x5000, 0x80); + sensor->status.quality = read_reg(sensor->slv_addr, COMPRESSION_CTRL07) & 0x3f; + sensor->status.special_effect = 0; + sensor->status.wb_mode = 0; + sensor->status.awb_gain = check_reg_mask(sensor->slv_addr, 0x3406, 0x01); + sensor->status.agc_gain = get_agc_gain(sensor); + sensor->status.aec_value = get_aec_value(sensor); + sensor->status.aec2 = check_reg_mask(sensor->slv_addr, 0x3a00, 0x04); + return 0; +} + +int ov5640_detect(int slv_addr, sensor_id_t *id) +{ + if (OV5640_SCCB_ADDR == slv_addr) { + uint8_t h = SCCB_Read16(slv_addr, 0x300A); + uint8_t l = SCCB_Read16(slv_addr, 0x300B); + uint16_t PID = (h<<8) | l; + if (OV5640_PID == PID) { + id->PID = PID; + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int ov5640_init(sensor_t *sensor) +{ + sensor->reset = reset; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_contrast = set_contrast; + sensor->set_brightness = set_brightness; + sensor->set_saturation = set_saturation; + sensor->set_sharpness = set_sharpness; + sensor->set_gainceiling = set_gainceiling; + sensor->set_quality = set_quality; + sensor->set_colorbar = set_colorbar; + sensor->set_gain_ctrl = set_gain_ctrl; + sensor->set_exposure_ctrl = set_exposure_ctrl; + sensor->set_whitebal = set_whitebal; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + sensor->init_status = init_status; + sensor->set_aec2 = set_aec2; + sensor->set_aec_value = set_aec_value; + sensor->set_special_effect = set_special_effect; + sensor->set_wb_mode = set_wb_mode; + sensor->set_ae_level = set_ae_level; + sensor->set_dcw = set_dcw_dsp; + sensor->set_bpc = set_bpc_dsp; + sensor->set_wpc = set_wpc_dsp; + sensor->set_awb_gain = set_awb_gain_dsp; + sensor->set_agc_gain = set_agc_gain; + sensor->set_raw_gma = set_raw_gma_dsp; + sensor->set_lenc = set_lenc_dsp; + sensor->set_denoise = set_denoise; + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = set_res_raw; + sensor->set_pll = _set_pll; + sensor->set_xclk = set_xclk; + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov7670.c b/lib/libesp32_div/esp32-camera/sensors/ov7670.c new file mode 100644 index 000000000..b9dcf2327 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/ov7670.c @@ -0,0 +1,457 @@ +/* + * This file is part of the OpenMV project. + * author: Juan Schiavoni + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV7725 driver. + * + */ +#include +#include +#include +#include "sccb.h" +#include "ov7670.h" +#include "ov7670_regs.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "ov7760"; +#endif + +static int ov7670_clkrc = 0x01; + +/* + * The default register settings, as obtained from OmniVision. There + * is really no making sense of most of these - lots of "reserved" values + * and such. + * + * These settings give VGA YUYV. + */ +struct regval_list { + uint8_t reg_num; + uint8_t value; +}; + +static struct regval_list ov7670_default_regs[] = { + /* Sensor automatically sets output window when resolution changes. */ + {TSLB, 0x04}, + + /* Frame rate 30 fps at 12 Mhz clock */ + {CLKRC, 0x00}, + {DBLV, 0x4A}, + + {COM10, COM10_VSYNC_NEG | COM10_PCLK_MASK}, + + /* Improve white balance */ + {COM4, 0x40}, + + /* Improve color */ + {RSVD_B0, 0x84}, + + /* Enable 50/60 Hz auto detection */ + {COM11, COM11_EXP|COM11_HZAUTO}, + + /* Disable some delays */ + {HSYST, 0}, + {HSYEN, 0}, + + {MVFP, MVFP_SUN}, + + /* More reserved magic, some of which tweaks white balance */ + {AWBC1, 0x0a}, + {AWBC2, 0xf0}, + {AWBC3, 0x34}, + {AWBC4, 0x58}, + {AWBC5, 0x28}, + {AWBC6, 0x3a}, + + {AWBCTR3, 0x0a}, + {AWBCTR2, 0x55}, + {AWBCTR1, 0x11}, + {AWBCTR0, 0x9e}, + + {COM8, COM8_FAST_AUTO|COM8_STEP_UNLIMIT|COM8_AGC_EN|COM8_AEC_EN|COM8_AWB_EN}, + + /* End marker is FF because in ov7670 the address of GAIN 0 and default value too. */ + {0xFF, 0xFF}, +}; + +static struct regval_list ov7670_fmt_yuv422[] = { + { COM7, 0x0 }, /* Selects YUV mode */ + { RGB444, 0 }, /* No RGB444 please */ + { COM1, 0 }, /* CCIR601 */ + { COM15, COM15_R00FF }, + { MVFP, MVFP_SUN }, + { COM9, 0x6A }, /* 128x gain ceiling; 0x8 is reserved bit */ + { MTX1, 0x80 }, /* "matrix coefficient 1" */ + { MTX2, 0x80 }, /* "matrix coefficient 2" */ + { MTX3, 0 }, /* vb */ + { MTX4, 0x22 }, /* "matrix coefficient 4" */ + { MTX5, 0x5e }, /* "matrix coefficient 5" */ + { MTX6, 0x80 }, /* "matrix coefficient 6" */ + { COM13, COM13_UVSAT }, + { 0xff, 0xff }, /* END MARKER */ +}; + +static struct regval_list ov7670_fmt_rgb565[] = { + { COM7, COM7_FMT_RGB565 }, /* Selects RGB mode */ + { RGB444, 0 }, /* No RGB444 please */ + { COM1, 0x0 }, /* CCIR601 */ + { COM15, COM15_RGB565 |COM15_R00FF }, + { MVFP, MVFP_SUN }, + { COM9, 0x6A }, /* 128x gain ceiling; 0x8 is reserved bit */ + { MTX1, 0xb3 }, /* "matrix coefficient 1" */ + { MTX2, 0xb3 }, /* "matrix coefficient 2" */ + { MTX3, 0 }, /* vb */ + { MTX4, 0x3d }, /* "matrix coefficient 4" */ + { MTX5, 0xa7 }, /* "matrix coefficient 5" */ + { MTX6, 0xe4 }, /* "matrix coefficient 6" */ + { COM13, COM13_UVSAT }, + { 0xff, 0xff }, /* END MARKER */ +}; + + +static struct regval_list ov7670_vga[] = { + { COM3, 0x00 }, + { COM14, 0x00 }, + { SCALING_XSC, 0x3A }, + { SCALING_YSC, 0x35 }, + { SCALING_DCWCTR, 0x11 }, + { SCALING_PCLK_DIV, 0xF0 }, + { SCALING_PCLK_DELAY, 0x02 }, + { 0xff, 0xff }, +}; + +static struct regval_list ov7670_qvga[] = { + { COM3, 0x04 }, + { COM14, 0x19 }, + { SCALING_XSC, 0x3A }, + { SCALING_YSC, 0x35 }, + { SCALING_DCWCTR, 0x11 }, + { SCALING_PCLK_DIV, 0xF1 }, + { SCALING_PCLK_DELAY, 0x02 }, + { 0xff, 0xff }, +}; + +static struct regval_list ov7670_qqvga[] = { + { COM3, 0x04 }, //DCW enable + { COM14, 0x1a }, //pixel clock divided by 4, manual scaling enable, DCW and PCLK controlled by register + { SCALING_XSC, 0x3a }, + { SCALING_YSC, 0x35 }, + { SCALING_DCWCTR, 0x22 }, //downsample by 4 + { SCALING_PCLK_DIV, 0xf2 }, //pixel clock divided by 4 + { SCALING_PCLK_DELAY, 0x02 }, + { 0xff, 0xff }, +}; + +/* + * Write a list of register settings; ff/ff stops the process. + */ +static int ov7670_write_array(sensor_t *sensor, struct regval_list *vals) +{ +int ret = 0; + + while ( (vals->reg_num != 0xff || vals->value != 0xff) && (ret == 0) ) { + ret = SCCB_Write(sensor->slv_addr, vals->reg_num, vals->value); + + ESP_LOGD(TAG, "reset reg %02X, W(%02X) R(%02X)", vals->reg_num, + vals->value, SCCB_Read(sensor->slv_addr, vals->reg_num) ); + + vals++; + } + + return ret; +} + +/* + * Calculate the frame control registers. + */ +static int ov7670_frame_control(sensor_t *sensor, int hstart, int hstop, int vstart, int vstop) +{ +struct regval_list frame[7]; + + frame[0].reg_num = HSTART; + frame[0].value = (hstart >> 3); + + frame[1].reg_num = HSTOP; + frame[1].value = (hstop >> 3); + + frame[2].reg_num = HREF; + frame[2].value = (((hstop & 0x07) << 3) | (hstart & 0x07)); + + frame[3].reg_num = VSTART; + frame[3].value = (vstart >> 2); + + frame[4].reg_num = VSTOP; + frame[4].value = (vstop >> 2); + + frame[5].reg_num = VREF; + frame[5].value = (((vstop & 0x02) << 2) | (vstart & 0x02)); + + /* End mark */ + frame[5].reg_num = 0xFF; + frame[5].value = 0xFF; + + return ov7670_write_array(sensor, frame); +} + +static int reset(sensor_t *sensor) +{ + int ret; + + // Reset all registers + SCCB_Write(sensor->slv_addr, COM7, COM7_RESET); + + // Delay 10 ms + vTaskDelay(10 / portTICK_PERIOD_MS); + + ret = ov7670_write_array(sensor, ov7670_default_regs); + + // Delay + vTaskDelay(30 / portTICK_PERIOD_MS); + + return ret; +} + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ +int ret; + + switch (pixformat) { + case PIXFORMAT_RGB565: + case PIXFORMAT_RGB888: + ret = ov7670_write_array(sensor, ov7670_fmt_rgb565); + break; + + case PIXFORMAT_YUV422: + case PIXFORMAT_GRAYSCALE: + default: + ret = ov7670_write_array(sensor, ov7670_fmt_yuv422); + break; + } + + vTaskDelay(30 / portTICK_PERIOD_MS); + + /* + * If we're running RGB565, we must rewrite clkrc after setting + * the other parameters or the image looks poor. If we're *not* + * doing RGB565, we must not rewrite clkrc or the image looks + * *really* poor. + * + * (Update) Now that we retain clkrc state, we should be able + * to write it unconditionally, and that will make the frame + * rate persistent too. + */ + if (pixformat == PIXFORMAT_RGB565) { + ret = SCCB_Write(sensor->slv_addr, CLKRC, ov7670_clkrc); + } + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret; + + // store clkrc before changing window settings... + ov7670_clkrc = SCCB_Read(sensor->slv_addr, CLKRC); + + switch (framesize){ + case FRAMESIZE_VGA: + if( (ret = ov7670_write_array(sensor, ov7670_vga)) == 0 ) { + /* These values from Omnivision */ + ret = ov7670_frame_control(sensor, 158, 14, 10, 490); + } + break; + case FRAMESIZE_QVGA: + if( (ret = ov7670_write_array(sensor, ov7670_qvga)) == 0 ) { + /* These values from Omnivision */ + ret = ov7670_frame_control(sensor, 158, 14, 10, 490); + } + break; + case FRAMESIZE_QQVGA: + if( (ret = ov7670_write_array(sensor, ov7670_qqvga)) == 0 ) { + /* These values from Omnivision */ + ret = ov7670_frame_control(sensor, 158, 14, 10, 490); + } + break; + + default: + ret = -1; + } + + vTaskDelay(30 / portTICK_PERIOD_MS); + + if (ret == 0) { + sensor->status.framesize = framesize; + } + + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + uint8_t ret = 0; + // Read register scaling_xsc + uint8_t reg = SCCB_Read(sensor->slv_addr, SCALING_XSC); + + // Pattern to set color bar bit[0]=0 in every case + reg = SCALING_XSC_CBAR(reg); + + // Write pattern to SCALING_XSC + ret = SCCB_Write(sensor->slv_addr, SCALING_XSC, reg); + + // Read register scaling_ysc + reg = SCCB_Read(sensor->slv_addr, SCALING_YSC); + + // Pattern to set color bar bit[0]=0 in every case + reg = SCALING_YSC_CBAR(reg, enable); + + // Write pattern to SCALING_YSC + ret = ret | SCCB_Write(sensor->slv_addr, SCALING_YSC, reg); + + // return 0 or 0xFF + return ret; +} + +static int set_whitebal(sensor_t *sensor, int enable) +{ + // Read register COM8 + uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); + + // Set white bal on/off + reg = COM8_SET_AWB(reg, enable); + + // Write back register COM8 + return SCCB_Write(sensor->slv_addr, COM8, reg); +} + +static int set_gain_ctrl(sensor_t *sensor, int enable) +{ + // Read register COM8 + uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); + + // Set white bal on/off + reg = COM8_SET_AGC(reg, enable); + + // Write back register COM8 + return SCCB_Write(sensor->slv_addr, COM8, reg); +} + +static int set_exposure_ctrl(sensor_t *sensor, int enable) +{ + // Read register COM8 + uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); + + // Set white bal on/off + reg = COM8_SET_AEC(reg, enable); + + // Write back register COM8 + return SCCB_Write(sensor->slv_addr, COM8, reg); +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + // Read register MVFP + uint8_t reg = SCCB_Read(sensor->slv_addr, MVFP); + + // Set mirror on/off + reg = MVFP_SET_MIRROR(reg, enable); + + // Write back register MVFP + return SCCB_Write(sensor->slv_addr, MVFP, reg); +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + // Read register MVFP + uint8_t reg = SCCB_Read(sensor->slv_addr, MVFP); + + // Set mirror on/off + reg = MVFP_SET_FLIP(reg, enable); + + // Write back register MVFP + return SCCB_Write(sensor->slv_addr, MVFP, reg); +} + +static int init_status(sensor_t *sensor) +{ + sensor->status.awb = 0; + sensor->status.aec = 0; + sensor->status.agc = 0; + sensor->status.hmirror = 0; + sensor->status.vflip = 0; + sensor->status.colorbar = 0; + return 0; +} + +static int set_dummy(sensor_t *sensor, int val){ return -1; } +static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val){ return -1; } + +int ov7670_detect(int slv_addr, sensor_id_t *id) +{ + if (OV7670_SCCB_ADDR == slv_addr) { + SCCB_Write(slv_addr, 0xFF, 0x01);//bank sensor + uint16_t PID = SCCB_Read(slv_addr, 0x0A); + if (OV7670_PID == PID) { + id->PID = PID; + id->VER = SCCB_Read(slv_addr, REG_VER); + id->MIDL = SCCB_Read(slv_addr, REG_MIDL); + id->MIDH = SCCB_Read(slv_addr, REG_MIDH); + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int ov7670_init(sensor_t *sensor) +{ + // Set function pointers + sensor->reset = reset; + sensor->init_status = init_status; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_colorbar = set_colorbar; + sensor->set_whitebal = set_whitebal; + sensor->set_gain_ctrl = set_gain_ctrl; + sensor->set_exposure_ctrl = set_exposure_ctrl; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + + //not supported + sensor->set_brightness= set_dummy; + sensor->set_saturation= set_dummy; + sensor->set_quality = set_dummy; + sensor->set_gainceiling = set_gainceiling_dummy; + sensor->set_aec2 = set_dummy; + sensor->set_aec_value = set_dummy; + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + sensor->set_dcw = set_dummy; + sensor->set_bpc = set_dummy; + sensor->set_wpc = set_dummy; + sensor->set_awb_gain = set_dummy; + sensor->set_agc_gain = set_dummy; + sensor->set_raw_gma = set_dummy; + sensor->set_lenc = set_dummy; + sensor->set_sharpness = set_dummy; + sensor->set_denoise = set_dummy; + + // Retrieve sensor's signature + sensor->id.MIDH = SCCB_Read(sensor->slv_addr, REG_MIDH); + sensor->id.MIDL = SCCB_Read(sensor->slv_addr, REG_MIDL); + sensor->id.PID = SCCB_Read(sensor->slv_addr, REG_PID); + sensor->id.VER = SCCB_Read(sensor->slv_addr, REG_VER); + + ESP_LOGD(TAG, "OV7670 Attached"); + + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov7725.c b/lib/libesp32_div/esp32-camera/sensors/ov7725.c new file mode 100644 index 000000000..ad5d89541 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/ov7725.c @@ -0,0 +1,575 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV7725 driver. + * + */ +#include +#include +#include +#include +#include "sccb.h" +#include "xclk.h" +#include "ov7725.h" +#include "ov7725_regs.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "ov7725"; +#endif + + +static const uint8_t default_regs[][2] = { + {COM3, COM3_SWAP_YUV}, + {COM7, COM7_RES_QVGA | COM7_FMT_YUV}, + + {COM4, 0x01 | 0x00}, /* bypass PLL (0x00:off, 0x40:4x, 0x80:6x, 0xC0:8x) */ + {CLKRC, 0x80 | 0x03}, /* Res/Bypass pre-scalar (0x40:bypass, 0x00-0x3F:prescaler PCLK=XCLK/(prescaler + 1)/2 ) */ + + // QVGA Window Size + {HSTART, 0x3F}, + {HSIZE, 0x50}, + {VSTART, 0x03}, + {VSIZE, 0x78}, + {HREF, 0x00}, + + // Scale down to QVGA Resolution + {HOUTSIZE, 0x50}, + {VOUTSIZE, 0x78}, + {EXHCH, 0x00}, + + {COM12, 0x03}, + {TGT_B, 0x7F}, + {FIXGAIN, 0x09}, + {AWB_CTRL0, 0xE0}, + {DSP_CTRL1, 0xFF}, + + {DSP_CTRL2, DSP_CTRL2_VDCW_EN | DSP_CTRL2_HDCW_EN | DSP_CTRL2_HZOOM_EN | DSP_CTRL2_VZOOM_EN}, + + {DSP_CTRL3, 0x00}, + {DSP_CTRL4, 0x00}, + {DSPAUTO, 0xFF}, + + {COM8, 0xF0}, + {COM6, 0xC5}, + {COM9, 0x11}, + {COM10, COM10_VSYNC_NEG | COM10_PCLK_MASK}, //Invert VSYNC and MASK PCLK + {BDBASE, 0x7F}, + {DBSTEP, 0x03}, + {AEW, 0x96}, + {AEB, 0x64}, + {VPT, 0xA1}, + {EXHCL, 0x00}, + {AWB_CTRL3, 0xAA}, + {COM8, 0xFF}, + + //Gamma + {GAM1, 0x0C}, + {GAM2, 0x16}, + {GAM3, 0x2A}, + {GAM4, 0x4E}, + {GAM5, 0x61}, + {GAM6, 0x6F}, + {GAM7, 0x7B}, + {GAM8, 0x86}, + {GAM9, 0x8E}, + {GAM10, 0x97}, + {GAM11, 0xA4}, + {GAM12, 0xAF}, + {GAM13, 0xC5}, + {GAM14, 0xD7}, + {GAM15, 0xE8}, + + {SLOP, 0x20}, + {EDGE1, 0x05}, + {EDGE2, 0x03}, + {EDGE3, 0x00}, + {DNSOFF, 0x01}, + + {MTX1, 0xB0}, + {MTX2, 0x9D}, + {MTX3, 0x13}, + {MTX4, 0x16}, + {MTX5, 0x7B}, + {MTX6, 0x91}, + {MTX_CTRL, 0x1E}, + + {BRIGHTNESS, 0x08}, + {CONTRAST, 0x30}, + {UVADJ0, 0x81}, + {SDE, (SDE_CONT_BRIGHT_EN | SDE_SATURATION_EN)}, + + // For 30 fps/60Hz + {DM_LNL, 0x00}, + {DM_LNH, 0x00}, + {BDBASE, 0x7F}, + {DBSTEP, 0x03}, + + // Lens Correction, should be tuned with real camera module + {LC_RADI, 0x10}, + {LC_COEF, 0x10}, + {LC_COEFB, 0x14}, + {LC_COEFR, 0x17}, + {LC_CTR, 0x05}, + {COM5, 0xF5}, //0x65 + + {0x00, 0x00}, +}; + +static int get_reg(sensor_t *sensor, int reg, int mask) +{ + int ret = SCCB_Read(sensor->slv_addr, reg & 0xFF); + if(ret > 0){ + ret &= mask; + } + return ret; +} + +static int set_reg(sensor_t *sensor, int reg, int mask, int value) +{ + int ret = 0; + ret = SCCB_Read(sensor->slv_addr, reg & 0xFF); + if(ret < 0){ + return ret; + } + value = (ret & ~mask) | (value & mask); + ret = SCCB_Write(sensor->slv_addr, reg & 0xFF, value); + return ret; +} + +static int set_reg_bits(sensor_t *sensor, uint8_t reg, uint8_t offset, uint8_t length, uint8_t value) +{ + int ret = 0; + ret = SCCB_Read(sensor->slv_addr, reg); + if(ret < 0){ + return ret; + } + uint8_t mask = ((1 << length) - 1) << offset; + value = (ret & ~mask) | ((value << offset) & mask); + ret = SCCB_Write(sensor->slv_addr, reg & 0xFF, value); + return ret; +} + +static int get_reg_bits(sensor_t *sensor, uint8_t reg, uint8_t offset, uint8_t length) +{ + int ret = 0; + ret = SCCB_Read(sensor->slv_addr, reg); + if(ret < 0){ + return ret; + } + uint8_t mask = ((1 << length) - 1) << offset; + return (ret & mask) >> offset; +} + + +static int reset(sensor_t *sensor) +{ + int i=0; + const uint8_t (*regs)[2]; + + // Reset all registers + SCCB_Write(sensor->slv_addr, COM7, COM7_RESET); + + // Delay 10 ms + vTaskDelay(10 / portTICK_PERIOD_MS); + + // Write default regsiters + for (i=0, regs = default_regs; regs[i][0]; i++) { + SCCB_Write(sensor->slv_addr, regs[i][0], regs[i][1]); + } + + // Delay + vTaskDelay(30 / portTICK_PERIOD_MS); + + return 0; +} + + +static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) +{ + int ret=0; + sensor->pixformat = pixformat; + // Read register COM7 + uint8_t reg = SCCB_Read(sensor->slv_addr, COM7); + + switch (pixformat) { + case PIXFORMAT_RGB565: + reg = COM7_SET_RGB(reg, COM7_FMT_RGB565); + break; + case PIXFORMAT_YUV422: + case PIXFORMAT_GRAYSCALE: + reg = COM7_SET_FMT(reg, COM7_FMT_YUV); + break; + default: + return -1; + } + + // Write back register COM7 + ret = SCCB_Write(sensor->slv_addr, COM7, reg); + + // Delay + vTaskDelay(30 / portTICK_PERIOD_MS); + + return ret; +} + +static int set_framesize(sensor_t *sensor, framesize_t framesize) +{ + int ret=0; + if (framesize > FRAMESIZE_VGA) { + return -1; + } + uint16_t w = resolution[framesize].width; + uint16_t h = resolution[framesize].height; + uint8_t reg = SCCB_Read(sensor->slv_addr, COM7); + + sensor->status.framesize = framesize; + + // Write MSBs + ret |= SCCB_Write(sensor->slv_addr, HOUTSIZE, w>>2); + ret |= SCCB_Write(sensor->slv_addr, VOUTSIZE, h>>1); + + ret |= SCCB_Write(sensor->slv_addr, HSIZE, w>>2); + ret |= SCCB_Write(sensor->slv_addr, VSIZE, h>>1); + + // Write LSBs + ret |= SCCB_Write(sensor->slv_addr, HREF, ((w&0x3) | ((h&0x1) << 2))); + + if (framesize < FRAMESIZE_VGA) { + // Enable auto-scaling/zooming factors + ret |= SCCB_Write(sensor->slv_addr, DSPAUTO, 0xFF); + + ret |= SCCB_Write(sensor->slv_addr, HSTART, 0x3F); + ret |= SCCB_Write(sensor->slv_addr, VSTART, 0x03); + + ret |= SCCB_Write(sensor->slv_addr, COM7, reg | COM7_RES_QVGA); + + ret |= SCCB_Write(sensor->slv_addr, CLKRC, 0x80 | 0x01); + + } else { + // Disable auto-scaling/zooming factors + ret |= SCCB_Write(sensor->slv_addr, DSPAUTO, 0xF3); + + // Clear auto-scaling/zooming factors + ret |= SCCB_Write(sensor->slv_addr, SCAL0, 0x00); + ret |= SCCB_Write(sensor->slv_addr, SCAL1, 0x00); + ret |= SCCB_Write(sensor->slv_addr, SCAL2, 0x00); + + ret |= SCCB_Write(sensor->slv_addr, HSTART, 0x23); + ret |= SCCB_Write(sensor->slv_addr, VSTART, 0x07); + + ret |= SCCB_Write(sensor->slv_addr, COM7, reg & ~COM7_RES_QVGA); + + ret |= SCCB_Write(sensor->slv_addr, CLKRC, 0x80 | 0x03); + } + + // Delay + vTaskDelay(30 / portTICK_PERIOD_MS); + + return ret; +} + +static int set_colorbar(sensor_t *sensor, int enable) +{ + int ret=0; + uint8_t reg; + sensor->status.colorbar = enable; + + // Read reg COM3 + reg = SCCB_Read(sensor->slv_addr, COM3); + // Enable colorbar test pattern output + reg = COM3_SET_CBAR(reg, enable); + // Write back COM3 + ret |= SCCB_Write(sensor->slv_addr, COM3, reg); + + // Read reg DSP_CTRL3 + reg = SCCB_Read(sensor->slv_addr, DSP_CTRL3); + // Enable DSP colorbar output + reg = DSP_CTRL3_SET_CBAR(reg, enable); + // Write back DSP_CTRL3 + ret |= SCCB_Write(sensor->slv_addr, DSP_CTRL3, reg); + + return ret; +} + +static int set_whitebal(sensor_t *sensor, int enable) +{ + if(set_reg_bits(sensor, COM8, 1, 1, enable) >= 0){ + sensor->status.awb = !!enable; + } + return sensor->status.awb; +} + +static int set_gain_ctrl(sensor_t *sensor, int enable) +{ + if(set_reg_bits(sensor, COM8, 2, 1, enable) >= 0){ + sensor->status.agc = !!enable; + } + return sensor->status.agc; +} + +static int set_exposure_ctrl(sensor_t *sensor, int enable) +{ + if(set_reg_bits(sensor, COM8, 0, 1, enable) >= 0){ + sensor->status.aec = !!enable; + } + return sensor->status.aec; +} + +static int set_hmirror(sensor_t *sensor, int enable) +{ + if(set_reg_bits(sensor, COM3, 6, 1, enable) >= 0){ + sensor->status.hmirror = !!enable; + } + return sensor->status.hmirror; +} + +static int set_vflip(sensor_t *sensor, int enable) +{ + if(set_reg_bits(sensor, COM3, 7, 1, enable) >= 0){ + sensor->status.vflip = !!enable; + } + return sensor->status.vflip; +} + +static int set_dcw_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, 0x65, 2, 1, !enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set dcw to: %d", enable); + sensor->status.dcw = enable; + } + return ret; +} + +static int set_aec2(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, COM8, 7, 1, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set aec2 to: %d", enable); + sensor->status.aec2 = enable; + } + return ret; +} + +static int set_bpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, 0x64, 1, 1, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set bpc to: %d", enable); + sensor->status.bpc = enable; + } + return ret; +} + +static int set_wpc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, 0x64, 0, 1, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set wpc to: %d", enable); + sensor->status.wpc = enable; + } + return ret; +} + +static int set_raw_gma_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, 0x64, 2, 1, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set raw_gma to: %d", enable); + sensor->status.raw_gma = enable; + } + return ret; +} + +static int set_lenc_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, LC_CTR, 0, 1, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set lenc to: %d", enable); + sensor->status.lenc = enable; + } + return ret; +} + +//real gain +static int set_agc_gain(sensor_t *sensor, int gain) +{ + int ret = 0; + ret = set_reg_bits(sensor, COM9, 4, 3, gain % 5); + if (ret == 0) { + ESP_LOGD(TAG, "Set gain to: %d", gain); + sensor->status.agc_gain = gain; + } + return ret; +} + +static int set_aec_value(sensor_t *sensor, int value) +{ + int ret = 0; + ret = SCCB_Write(sensor->slv_addr, AEC, value & 0xff) | SCCB_Write(sensor->slv_addr, AECH, value >> 8); + if (ret == 0) { + ESP_LOGD(TAG, "Set aec_value to: %d", value); + sensor->status.aec_value = value; + } + return ret; +} + +static int set_awb_gain_dsp(sensor_t *sensor, int enable) +{ + int ret = 0; + ret = set_reg_bits(sensor, 0x63, 7, 1, enable); + if (ret == 0) { + ESP_LOGD(TAG, "Set awb_gain to: %d", enable); + sensor->status.awb_gain = enable; + } + return ret; +} + +static int set_brightness(sensor_t *sensor, int level) +{ + int ret = 0; + ret = SCCB_Write(sensor->slv_addr, 0x9B, level); + if (ret == 0) { + ESP_LOGD(TAG, "Set brightness to: %d", level); + sensor->status.brightness = level; + } + return ret; +} + +static int set_contrast(sensor_t *sensor, int level) +{ + int ret = 0; + ret = SCCB_Write(sensor->slv_addr, 0x9C, level); + if (ret == 0) { + ESP_LOGD(TAG, "Set contrast to: %d", level); + sensor->status.contrast = level; + } + return ret; +} + +static int init_status(sensor_t *sensor) +{ + sensor->status.brightness = SCCB_Read(sensor->slv_addr, 0x9B); + sensor->status.contrast = SCCB_Read(sensor->slv_addr, 0x9C); + sensor->status.saturation = 0; + sensor->status.ae_level = 0; + sensor->status.special_effect = get_reg_bits(sensor, 0x64, 5, 1); + sensor->status.wb_mode = get_reg_bits(sensor, 0x6B, 7, 1); + sensor->status.agc_gain = get_reg_bits(sensor, COM9, 4, 3); + sensor->status.aec_value = SCCB_Read(sensor->slv_addr, AEC) | (SCCB_Read(sensor->slv_addr, AECH) << 8); + sensor->status.gainceiling = SCCB_Read(sensor->slv_addr, 0x00); + sensor->status.awb = get_reg_bits(sensor, COM8, 1, 1); + sensor->status.awb_gain = get_reg_bits(sensor, 0x63, 7, 1); + sensor->status.aec = get_reg_bits(sensor, COM8, 0, 1); + sensor->status.aec2 = get_reg_bits(sensor, COM8, 7, 1); + sensor->status.agc = get_reg_bits(sensor, COM8, 2, 1); + sensor->status.bpc = get_reg_bits(sensor, 0x64, 1, 1); + sensor->status.wpc = get_reg_bits(sensor, 0x64, 0, 1); + sensor->status.raw_gma = get_reg_bits(sensor, 0x64, 2, 1); + sensor->status.lenc = get_reg_bits(sensor, LC_CTR, 0, 1); + sensor->status.hmirror = get_reg_bits(sensor, COM3, 6, 1); + sensor->status.vflip = get_reg_bits(sensor, COM3, 7, 1); + sensor->status.dcw = get_reg_bits(sensor, 0x65, 2, 1); + sensor->status.colorbar = get_reg_bits(sensor, COM3, 0, 1); + sensor->status.sharpness = get_reg_bits(sensor, EDGE0, 0, 5); + sensor->status.denoise = SCCB_Read(sensor->slv_addr, 0x8E); + return 0; +} + +static int set_dummy(sensor_t *sensor, int val){ return -1; } +static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val){ return -1; } +static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning){return -1;} +static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div){return -1;} + +static int set_xclk(sensor_t *sensor, int timer, int xclk) +{ + int ret = 0; + sensor->xclk_freq_hz = xclk * 1000000U; + ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); + return ret; +} + +int ov7725_detect(int slv_addr, sensor_id_t *id) +{ + if (OV7725_SCCB_ADDR == slv_addr) { + SCCB_Write(slv_addr, 0xFF, 0x01);//bank sensor + uint16_t PID = SCCB_Read(slv_addr, 0x0A); + if (OV7725_PID == PID) { + id->PID = PID; + id->VER = SCCB_Read(slv_addr, REG_VER); + id->MIDL = SCCB_Read(slv_addr, REG_MIDL); + id->MIDH = SCCB_Read(slv_addr, REG_MIDH); + return PID; + } else { + ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); + } + } + return 0; +} + +int ov7725_init(sensor_t *sensor) +{ + // Set function pointers + sensor->reset = reset; + sensor->init_status = init_status; + sensor->set_pixformat = set_pixformat; + sensor->set_framesize = set_framesize; + sensor->set_colorbar = set_colorbar; + sensor->set_whitebal = set_whitebal; + sensor->set_gain_ctrl = set_gain_ctrl; + sensor->set_exposure_ctrl = set_exposure_ctrl; + sensor->set_hmirror = set_hmirror; + sensor->set_vflip = set_vflip; + + sensor->set_brightness = set_brightness; + sensor->set_contrast = set_contrast; + sensor->set_aec2 = set_aec2; + sensor->set_aec_value = set_aec_value; + sensor->set_awb_gain = set_awb_gain_dsp; + sensor->set_agc_gain = set_agc_gain; + sensor->set_dcw = set_dcw_dsp; + sensor->set_bpc = set_bpc_dsp; + sensor->set_wpc = set_wpc_dsp; + sensor->set_raw_gma = set_raw_gma_dsp; + sensor->set_lenc = set_lenc_dsp; + + //not supported + sensor->set_saturation= set_dummy; + sensor->set_sharpness = set_dummy; + sensor->set_denoise = set_dummy; + sensor->set_quality = set_dummy; + sensor->set_special_effect = set_dummy; + sensor->set_wb_mode = set_dummy; + sensor->set_ae_level = set_dummy; + sensor->set_gainceiling = set_gainceiling_dummy; + + + sensor->get_reg = get_reg; + sensor->set_reg = set_reg; + sensor->set_res_raw = set_res_raw; + sensor->set_pll = _set_pll; + sensor->set_xclk = set_xclk; + + // Retrieve sensor's signature + sensor->id.MIDH = SCCB_Read(sensor->slv_addr, REG_MIDH); + sensor->id.MIDL = SCCB_Read(sensor->slv_addr, REG_MIDL); + sensor->id.PID = SCCB_Read(sensor->slv_addr, REG_PID); + sensor->id.VER = SCCB_Read(sensor->slv_addr, REG_VER); + + ESP_LOGD(TAG, "OV7725 Attached"); + + return 0; +} diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h new file mode 100644 index 000000000..edffca1e0 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h @@ -0,0 +1,31 @@ +#pragma once + +#include "sensor.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int gc0308_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int gc0308_init(sensor_t *sensor); + +#ifdef __cplusplus +} +#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h new file mode 100644 index 000000000..f1cb4532b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h @@ -0,0 +1,25 @@ +/* + * GC0308 register definitions. + */ +#ifndef __GC0308_REG_REGS_H__ +#define __GC0308_REG_REGS_H__ + +#define RESET_RELATED 0xfe // Bit[7]: Software reset + // Bit[6:5]: NA + // Bit[4]: CISCTL_restart_n + // Bit[3:1]: NA + // Bit[0]: page select + // 0:page0 + // 1:page1 + + +// page0: + + + +/** + * @brief register value + */ + + +#endif // __GC0308_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h new file mode 100644 index 000000000..32ef3816a --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h @@ -0,0 +1,245 @@ +#ifndef _GC0308_SETTINGS_H_ +#define _GC0308_SETTINGS_H_ + +#include + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0x0000 /* Array end token */ + +static const uint16_t gc0308_sensor_default_regs[][2] = { + {0xfe, 0x00}, + {0xec, 0x20}, + {0x05, 0x00}, + {0x06, 0x00}, + {0x07, 0x00}, + {0x08, 0x00}, + {0x09, 0x01}, + {0x0a, 0xe8}, + {0x0b, 0x02}, + {0x0c, 0x88}, + {0x0d, 0x02}, + {0x0e, 0x02}, + {0x10, 0x26}, + {0x11, 0x0d}, + {0x12, 0x2a}, + {0x13, 0x00}, + {0x14, 0x11}, + {0x15, 0x0a}, + {0x16, 0x05}, + {0x17, 0x01}, + {0x18, 0x44}, + {0x19, 0x44}, + {0x1a, 0x2a}, + {0x1b, 0x00}, + {0x1c, 0x49}, + {0x1d, 0x9a}, + {0x1e, 0x61}, + {0x1f, 0x00}, //pad drv <=24MHz, use 0x00 is ok + {0x20, 0x7f}, + {0x21, 0xfa}, + {0x22, 0x57}, + {0x24, 0xa2}, //YCbYCr + {0x25, 0x0f}, + {0x26, 0x03}, // 0x01 + {0x28, 0x00}, + {0x2d, 0x0a}, + {0x2f, 0x01}, + {0x30, 0xf7}, + {0x31, 0x50}, + {0x32, 0x00}, + {0x33, 0x28}, + {0x34, 0x2a}, + {0x35, 0x28}, + {0x39, 0x04}, + {0x3a, 0x20}, + {0x3b, 0x20}, + {0x3c, 0x00}, + {0x3d, 0x00}, + {0x3e, 0x00}, + {0x3f, 0x00}, + {0x50, 0x14}, // 0x14 + {0x52, 0x41}, + {0x53, 0x80}, + {0x54, 0x80}, + {0x55, 0x80}, + {0x56, 0x80}, + {0x8b, 0x20}, + {0x8c, 0x20}, + {0x8d, 0x20}, + {0x8e, 0x14}, + {0x8f, 0x10}, + {0x90, 0x14}, + {0x91, 0x3c}, + {0x92, 0x50}, +//{0x8b,0x10}, +//{0x8c,0x10}, +//{0x8d,0x10}, +//{0x8e,0x10}, +//{0x8f,0x10}, +//{0x90,0x10}, +//{0x91,0x3c}, +//{0x92,0x50}, + {0x5d, 0x12}, + {0x5e, 0x1a}, + {0x5f, 0x24}, + {0x60, 0x07}, + {0x61, 0x15}, + {0x62, 0x08}, // 0x08 + {0x64, 0x03}, // 0x03 + {0x66, 0xe8}, + {0x67, 0x86}, + {0x68, 0x82}, + {0x69, 0x18}, + {0x6a, 0x0f}, + {0x6b, 0x00}, + {0x6c, 0x5f}, + {0x6d, 0x8f}, + {0x6e, 0x55}, + {0x6f, 0x38}, + {0x70, 0x15}, + {0x71, 0x33}, + {0x72, 0xdc}, + {0x73, 0x00}, + {0x74, 0x02}, + {0x75, 0x3f}, + {0x76, 0x02}, + {0x77, 0x38}, // 0x47 + {0x78, 0x88}, + {0x79, 0x81}, + {0x7a, 0x81}, + {0x7b, 0x22}, + {0x7c, 0xff}, + {0x93, 0x48}, //color matrix default + {0x94, 0x02}, + {0x95, 0x07}, + {0x96, 0xe0}, + {0x97, 0x40}, + {0x98, 0xf0}, + {0xb1, 0x40}, + {0xb2, 0x40}, + {0xb3, 0x40}, //0x40 + {0xb6, 0xe0}, + {0xbd, 0x38}, + {0xbe, 0x36}, + {0xd0, 0xCB}, + {0xd1, 0x10}, + {0xd2, 0x90}, + {0xd3, 0x48}, + {0xd5, 0xF2}, + {0xd6, 0x16}, + {0xdb, 0x92}, + {0xdc, 0xA5}, + {0xdf, 0x23}, + {0xd9, 0x00}, + {0xda, 0x00}, + {0xe0, 0x09}, + {0xed, 0x04}, + {0xee, 0xa0}, + {0xef, 0x40}, + {0x80, 0x03}, + + {0x9F, 0x10}, + {0xA0, 0x20}, + {0xA1, 0x38}, + {0xA2, 0x4e}, + {0xA3, 0x63}, + {0xA4, 0x76}, + {0xA5, 0x87}, + {0xA6, 0xa2}, + {0xA7, 0xb8}, + {0xA8, 0xca}, + {0xA9, 0xd8}, + {0xAA, 0xe3}, + {0xAB, 0xeb}, + {0xAC, 0xf0}, + {0xAD, 0xF8}, + {0xAE, 0xFd}, + {0xAF, 0xFF}, + + {0xc0, 0x00}, + {0xc1, 0x10}, + {0xc2, 0x1c}, + {0xc3, 0x30}, + {0xc4, 0x43}, + {0xc5, 0x54}, + {0xc6, 0x65}, + {0xc7, 0x75}, + {0xc8, 0x93}, + {0xc9, 0xB0}, + {0xca, 0xCB}, + {0xcb, 0xE6}, + {0xcc, 0xFF}, + {0xf0, 0x02}, + {0xf1, 0x01}, + {0xf2, 0x02}, + {0xf3, 0x30}, + {0xf7, 0x04}, + {0xf8, 0x02}, + {0xf9, 0x9f}, + {0xfa, 0x78}, + {0xfe, 0x01}, + {0x00, 0xf5}, + {0x02, 0x20}, + {0x04, 0x10}, + {0x05, 0x08}, + {0x06, 0x20}, + {0x08, 0x0a}, + {0x0a, 0xa0}, + {0x0b, 0x60}, + {0x0c, 0x08}, + {0x0e, 0x44}, + {0x0f, 0x32}, + {0x10, 0x41}, + {0x11, 0x37}, + {0x12, 0x22}, + {0x13, 0x19}, + {0x14, 0x44}, + {0x15, 0x44}, + {0x16, 0xc2}, + {0x17, 0xA8}, + {0x18, 0x18}, + {0x19, 0x50}, + {0x1a, 0xd8}, + {0x1b, 0xf5}, + {0x70, 0x40}, + {0x71, 0x58}, + {0x72, 0x30}, + {0x73, 0x48}, + {0x74, 0x20}, + {0x75, 0x60}, + {0x77, 0x20}, + {0x78, 0x32}, + {0x30, 0x03}, + {0x31, 0x40}, + {0x32, 0x10}, + {0x33, 0xe0}, + {0x34, 0xe0}, + {0x35, 0x00}, + {0x36, 0x80}, + {0x37, 0x00}, + {0x38, 0x04}, + {0x39, 0x09}, + {0x3a, 0x12}, + {0x3b, 0x1C}, + {0x3c, 0x28}, + {0x3d, 0x31}, + {0x3e, 0x44}, + {0x3f, 0x57}, + {0x40, 0x6C}, + {0x41, 0x81}, + {0x42, 0x94}, + {0x43, 0xA7}, + {0x44, 0xB8}, + {0x45, 0xD6}, + {0x46, 0xEE}, + {0x47, 0x0d}, + {0x62, 0xf7}, + {0x63, 0x68}, + {0x64, 0xd3}, + {0x65, 0xd3}, + {0x66, 0x60}, + {0xfe, 0x00}, + {REGLIST_TAIL, 0x00}, +}; + +#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h new file mode 100644 index 000000000..7679f0708 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h @@ -0,0 +1,31 @@ +/* + * + * GC032A driver. + * + */ +#ifndef __GC032A_H__ +#define __GC032A_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int gc032a_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int gc032a_init(sensor_t *sensor); + +#endif // __GC032A_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h new file mode 100644 index 000000000..5de59d1d2 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h @@ -0,0 +1,82 @@ +/* + * GC032A register definitions. + */ +#ifndef __GC032A_REG_REGS_H__ +#define __GC032A_REG_REGS_H__ + +#define SENSOR_ID_HIGH 0XF0 +#define SENSOR_ID_LOW 0XF1 +#define PAD_VB_HIZ_MODE 0XF2 +#define SYNC_OUTPUT 0XF3 +#define I2C_CONFIG 0XF4 +#define PLL_MODE1 0XF7 +#define PLL_MODE2 0XF8 +#define CM_MODE 0XF9 +#define ISP_DIV_MODE 0XFA +#define I2C_DEVICE_ID 0XFB +#define ANALOG_PWC 0XFC +#define ISP_DIV_MODE2 0XFD +#define RESET_RELATED 0XFE // Bit[7]: Software reset + // Bit[6]: cm reset + // Bit[5]: spi reset + // Bit[4]: CISCTL_restart_n + // Bit[3]: PLL_rst + // Bit[2:0]: page select + // 000:page0 + // 001:page1 + // 010:page2 + // 011:page3 + +//----page0----------------------------- +#define P0_EXPOSURE_HIGH 0X03 +#define P0_EXPOSURE_LOW 0X04 +#define P0_HB_HIGH 0X05 +#define P0_HB_LOW 0X06 +#define P0_VB_HIGH 0X07 +#define P0_VB_LOW 0X08 +#define P0_ROW_START_HIGH 0X09 +#define P0_ROW_START_LOW 0X0A +#define P0_COLUMN_START_HIGH 0X0B +#define P0_COLUMN_START_LOW 0X0C +#define P0_WINDOW_HEIGHT_HIGH 0X0D +#define P0_WINDOW_HEIGHT_LOW 0X0E +#define P0_WINDOW_WIDTH_HIGH 0X0F +#define P0_WINDOW_WIDTH_LOW 0X10 +#define P0_SH_DELAY 0X11 +#define P0_VS_ST 0X12 +#define P0_VS_ET 0X13 +#define P0_CISCTL_MODE1 0X17 + +#define P0_BLOCK_ENABLE_1 0X40 +#define P0_AAAA_ENABLE 0X42 +#define P0_SPECIAL_EFFECT 0X43 +#define P0_SYNC_MODE 0X46 +#define P0_GAIN_CODE 0X48 +#define P0_DEBUG_MODE2 0X4C +#define P0_WIN_MODE 0X50 +#define P0_OUT_WIN_Y1_HIGH 0X51 +#define P0_OUT_WIN_Y1_LOW 0X52 +#define P0_OUT_WIN_X1_HIGH 0X53 +#define P0_OUT_WIN_X1_LOW 0X54 +#define P0_OUT_WIN_HEIGHT_HIGH 0X55 +#define P0_OUT_WIN_HEIGHT_LOW 0X56 +#define P0_OUT_WIN_WIDTH_HIGH 0X57 +#define P0_OUT_WIN_WIDTH_LOW 0X58 + +#define P0_GLOBAL_SATURATION 0XD0 +#define P0_SATURATION_CB 0XD1 +#define P0_SATURATION_CR 0XD2 +#define P0_LUMA_CONTRAST 0XD3 +#define P0_CONTRAST_CENTER 0XD4 +#define P0_LUMA_OFFSET 0XD5 +#define P0_FIXED_CB 0XDA +#define P0_FIXED_CR 0XDB + +//----page3----------------------------- +#define P3_IMAGE_WIDTH_LOW 0X5B +#define P3_IMAGE_WIDTH_HIGH 0X5C +#define P3_IMAGE_HEIGHT_LOW 0X5D +#define P3_IMAGE_HEIGHT_HIGH 0X5E + + +#endif //__GC032A_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h new file mode 100644 index 000000000..a19ffc7c6 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h @@ -0,0 +1,401 @@ +#ifndef _GC032A_SETTINGS_H_ +#define _GC032A_SETTINGS_H_ + +#include +#include +#include "esp_attr.h" +#include "gc032a_regs.h" + + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0x0000 + + +/* + * The default register settings, as obtained from OmniVision. There + * is really no making sense of most of these - lots of "reserved" values + * and such. + * + */ +static const uint16_t gc032a_default_regs[][2] = { + /*System*/ + {0xf3, 0xff}, + {0xf5, 0x06}, + {0xf7, 0x01}, + {0xf8, 0x03}, + {0xf9, 0xce}, + {0xfa, 0x00}, + {0xfc, 0x02}, + {0xfe, 0x02}, + {0x81, 0x03}, + + {0xfe, 0x00}, + {0x77, 0x64}, + {0x78, 0x40}, + {0x79, 0x60}, + /*ANALOG & CISCTL*/ + {0xfe, 0x00}, + {0x03, 0x01}, + {0x04, 0xce}, + {0x05, 0x01}, + {0x06, 0xad}, + {0x07, 0x00}, + {0x08, 0x10}, + {0x0a, 0x00}, + {0x0c, 0x00}, + {0x0d, 0x01}, + {0x0e, 0xe8}, // height 488 + {0x0f, 0x02}, + {0x10, 0x88}, // width 648 + {0x17, 0x54}, + {0x19, 0x08}, + {0x1a, 0x0a}, + {0x1f, 0x40}, + {0x20, 0x30}, + {0x2e, 0x80}, + {0x2f, 0x2b}, + {0x30, 0x1a}, + {0xfe, 0x02}, + {0x03, 0x02}, + {0x05, 0xd7}, + {0x06, 0x60}, + {0x08, 0x80}, + {0x12, 0x89}, + + /*blk*/ + {0xfe, 0x00}, + {0x18, 0x02}, + {0xfe, 0x02}, + {0x40, 0x22}, + {0x45, 0x00}, + {0x46, 0x00}, + {0x49, 0x20}, + {0x4b, 0x3c}, + {0x50, 0x20}, + {0x42, 0x10}, + + /*isp*/ + {0xfe, 0x01}, + {0x0a, 0xc5}, + {0x45, 0x00}, + {0xfe, 0x00}, + {0x40, 0xff}, + {0x41, 0x25}, + {0x42, 0xcf}, + {0x43, 0x10}, + {0x44, 0x83}, + {0x46, 0x23}, + {0x49, 0x03}, + {0x52, 0x02}, + {0x54, 0x00}, + {0xfe, 0x02}, + {0x22, 0xf6}, + + /*Shading*/ + {0xfe, 0x01}, + {0xc1, 0x38}, + {0xc2, 0x4c}, + {0xc3, 0x00}, + {0xc4, 0x32}, + {0xc5, 0x24}, + {0xc6, 0x16}, + {0xc7, 0x08}, + {0xc8, 0x08}, + {0xc9, 0x00}, + {0xca, 0x20}, + {0xdc, 0x8a}, + {0xdd, 0xa0}, + {0xde, 0xa6}, + {0xdf, 0x75}, + + /*AWB*/ + {0xfe, 0x01}, + {0x7c, 0x09}, + {0x65, 0x06}, + {0x7c, 0x08}, + {0x56, 0xf4}, + {0x66, 0x0f}, + {0x67, 0x84}, + {0x6b, 0x80}, + {0x6d, 0x12}, + {0x6e, 0xb0}, + {0x86, 0x00}, + {0x87, 0x00}, + {0x88, 0x00}, + {0x89, 0x00}, + {0x8a, 0x00}, + {0x8b, 0x00}, + {0x8c, 0x00}, + {0x8d, 0x00}, + {0x8e, 0x00}, + {0x8f, 0x00}, + {0x90, 0x00}, + {0x91, 0x00}, + {0x92, 0xf4}, + {0x93, 0xd5}, + {0x94, 0x50}, + {0x95, 0x0f}, + {0x96, 0xf4}, + {0x97, 0x2d}, + {0x98, 0x0f}, + {0x99, 0xa6}, + {0x9a, 0x2d}, + {0x9b, 0x0f}, + {0x9c, 0x59}, + {0x9d, 0x2d}, + {0x9e, 0xaa}, + {0x9f, 0x67}, + {0xa0, 0x59}, + {0xa1, 0x00}, + {0xa2, 0x00}, + {0xa3, 0x0a}, + {0xa4, 0x00}, + {0xa5, 0x00}, + {0xa6, 0xd4}, + {0xa7, 0x9f}, + {0xa8, 0x55}, + {0xa9, 0xd4}, + {0xaa, 0x9f}, + {0xab, 0xac}, + {0xac, 0x9f}, + {0xad, 0x55}, + {0xae, 0xd4}, + {0xaf, 0xac}, + {0xb0, 0xd4}, + {0xb1, 0xa3}, + {0xb2, 0x55}, + {0xb3, 0xd4}, + {0xb4, 0xac}, + {0xb5, 0x00}, + {0xb6, 0x00}, + {0xb7, 0x05}, + {0xb8, 0xd6}, + {0xb9, 0x8c}, + + /*CC*/ + {0xfe, 0x01}, + {0xd0, 0x40}, + {0xd1, 0xf8}, + {0xd2, 0x00}, + {0xd3, 0xfa}, + {0xd4, 0x45}, + {0xd5, 0x02}, + + {0xd6, 0x30}, + {0xd7, 0xfa}, + {0xd8, 0x08}, + {0xd9, 0x08}, + {0xda, 0x58}, + {0xdb, 0x02}, + {0xfe, 0x00}, + + /*Gamma*/ + {0xfe, 0x00}, + {0xba, 0x00}, + {0xbb, 0x04}, + {0xbc, 0x0a}, + {0xbd, 0x0e}, + {0xbe, 0x22}, + {0xbf, 0x30}, + {0xc0, 0x3d}, + {0xc1, 0x4a}, + {0xc2, 0x5d}, + {0xc3, 0x6b}, + {0xc4, 0x7a}, + {0xc5, 0x85}, + {0xc6, 0x90}, + {0xc7, 0xa5}, + {0xc8, 0xb5}, + {0xc9, 0xc2}, + {0xca, 0xcc}, + {0xcb, 0xd5}, + {0xcc, 0xde}, + {0xcd, 0xea}, + {0xce, 0xf5}, + {0xcf, 0xff}, + + /*Auto Gamma*/ + {0xfe, 0x00}, + {0x5a, 0x08}, + {0x5b, 0x0f}, + {0x5c, 0x15}, + {0x5d, 0x1c}, + {0x5e, 0x28}, + {0x5f, 0x36}, + {0x60, 0x45}, + {0x61, 0x51}, + {0x62, 0x6a}, + {0x63, 0x7d}, + {0x64, 0x8d}, + {0x65, 0x98}, + {0x66, 0xa2}, + {0x67, 0xb5}, + {0x68, 0xc3}, + {0x69, 0xcd}, + {0x6a, 0xd4}, + {0x6b, 0xdc}, + {0x6c, 0xe3}, + {0x6d, 0xf0}, + {0x6e, 0xf9}, + {0x6f, 0xff}, + + /*Gain*/ + {0xfe, 0x00}, + {0x70, 0x50}, + + /*AEC*/ + {0xfe, 0x00}, + {0x4f, 0x01}, + {0xfe, 0x01}, + {0x0d, 0x00}, + {0x12, 0xa0}, + {0x13, 0x3a}, + {0x44, 0x04}, + {0x1f, 0x30}, + {0x20, 0x40}, + {0x26, 0x9a}, + {0x3e, 0x20}, + {0x3f, 0x2d}, + {0x40, 0x40}, + {0x41, 0x5b}, + {0x42, 0x82}, + {0x43, 0xb7}, + {0x04, 0x0a}, + {0x02, 0x79}, + {0x03, 0xc0}, + + /*measure window*/ + {0xfe, 0x01}, + {0xcc, 0x08}, + {0xcd, 0x08}, + {0xce, 0xa4}, + {0xcf, 0xec}, + + /*DNDD*/ + {0xfe, 0x00}, + {0x81, 0xb8}, + {0x82, 0x12}, + {0x83, 0x0a}, + {0x84, 0x01}, + {0x86, 0x50}, + {0x87, 0x18}, + {0x88, 0x10}, + {0x89, 0x70}, + {0x8a, 0x20}, + {0x8b, 0x10}, + {0x8c, 0x08}, + {0x8d, 0x0a}, + + /*Intpee*/ + {0xfe, 0x00}, + {0x8f, 0xaa}, + {0x90, 0x9c}, + {0x91, 0x52}, + {0x92, 0x03}, + {0x93, 0x03}, + {0x94, 0x08}, + {0x95, 0x44}, + {0x97, 0x00}, + {0x98, 0x00}, + + /*ASDE*/ + {0xfe, 0x00}, + {0xa1, 0x30}, + {0xa2, 0x41}, + {0xa4, 0x30}, + {0xa5, 0x20}, + {0xaa, 0x30}, + {0xac, 0x32}, + + /*YCP*/ + {0xfe, 0x00}, + {0xd1, 0x3c}, + {0xd2, 0x3c}, + {0xd3, 0x38}, + {0xd6, 0xf4}, + {0xd7, 0x1d}, + {0xdd, 0x73}, + {0xde, 0x84}, + + /*Banding*/ + {0xfe, 0x00}, + {0x05, 0x01}, + {0x06, 0xad}, + {0x07, 0x00}, + {0x08, 0x10}, + + {0xfe, 0x01}, + {0x25, 0x00}, + {0x26, 0x9a}, + + {0x27, 0x01}, + {0x28, 0xce}, + {0x29, 0x02}, + {0x2a, 0x68}, + {0x2b, 0x02}, + {0x2c, 0x68}, + {0x2d, 0x07}, + {0x2e, 0xd2}, + {0x2f, 0x0b}, + {0x30, 0x6e}, + {0x31, 0x0e}, + {0x32, 0x70}, + {0x33, 0x12}, + {0x34, 0x0c}, + {0x3c, 0x30}, + + /*Analog&Cisctl*/ + {0xfe, 0x00}, + {0x05, 0x01}, + {0x06, 0xa0}, + {0x07, 0x00}, + {0x08, 0x20}, + {0x0a, 0x78}, + {0x0c, 0xa0}, + {0x0d, 0x00}, //window_height [8] + {0x0e, 0xf8}, //window_height [7:0] 248 + {0x0f, 0x01}, //window_width [9:8] + {0x10, 0x48}, //window_width [7:0] 328 + + {0x55, 0x00}, + {0x56, 0xf0}, // 240 + {0x57, 0x01}, + {0x58, 0x40}, // 320 + + /*SPI*/ + {0xfe, 0x03}, + {0x5b, 0x40}, + {0x5c, 0x01}, + {0x5d, 0xf0}, + {0x5e, 0x00}, + + /*AEC*/ + {0xfe, 0x01}, + {0x25, 0x00}, //step + {0x26, 0x63}, + {0x27, 0x01}, + {0x28, 0x29}, + {0x29, 0x01}, + {0x2a, 0x29}, + {0x2b, 0x01}, + {0x2c, 0x29}, + {0x2d, 0x01}, + {0x2e, 0x29}, + {0x2f, 0x01}, + {0x30, 0x29}, + {0x31, 0x01}, + {0x32, 0x29}, + {0x33, 0x01}, + {0x34, 0x29}, + {0x3c, 0x00}, + + /*measure window*/ + {0xfe, 0x01}, + {0xcc, 0x04}, + {0xcd, 0x04}, + {0xce, 0x72}, + {0xcf, 0x52}, + {REGLIST_TAIL, 0x00}, +}; + +#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h new file mode 100644 index 000000000..6c5b60f70 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h @@ -0,0 +1,27 @@ + +#ifndef __GC2145_H__ +#define __GC2145_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int gc2145_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int gc2145_init(sensor_t *sensor); + +#endif // __GC2145_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h new file mode 100644 index 000000000..b034a1689 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h @@ -0,0 +1,85 @@ +/* + * GC2145 register definitions. + */ +#ifndef __GC2145_REG_REGS_H__ +#define __GC2145_REG_REGS_H__ + +#define CHIP_ID_HIGH 0XF0 +#define CHIP_ID_LOW 0XF1 +#define PLL_MODE1 0XF7 +#define PLL_MODE2 0XF8 +#define CM_MODE 0XF9 +#define CLK_DIV_MODE 0XFA +#define RESET_RELATED 0xfe // Bit[7]: Software reset + // Bit[6]: cm reset + // Bit[5]: mipi reset + // Bit[4]: CISCTL_restart_n + // Bit[3]: NA + // Bit[2:0]: page select + // 000:page0 + // 001:page1 + // 010:page2 + // 011:page3 + +//-page0---------------- + +#define P0_EXPOSURE_HIGH 0X03 +#define P0_EXPOSURE_LOW 0X04 +#define P0_HB_HIGH 0X05 +#define P0_HB_LOW 0X06 +#define P0_VB_HIGH 0X07 +#define P0_VB_LOW 0X08 +#define P0_ROW_START_HIGH 0X09 +#define P0_ROW_START_LOW 0X0A +#define P0_COL_START_HIGH 0X0B +#define P0_COL_START_LOW 0X0C + +#define P0_WIN_HEIGHT_HIGH 0X0D +#define P0_WIN_HEIGHT_LOW 0X0E +#define P0_WIN_WIDTH_HIGH 0X0F +#define P0_WIN_WIDTH_LOW 0X10 +#define P0_ANALOG_MODE1 0X17 +#define P0_ANALOG_MODE2 0X18 + +#define P0_SPECIAL_EFFECT 0X83 +#define P0_OUTPUT_FORMAT 0x84 // Format select + // Bit[7]:YUV420 row switch + // Bit[6]:YUV420 col switch + // Bit[7]:YUV420_legacy + // Bit[4:0]:output data mode + // 5’h00 Cb Y Cr Y + // 5’h01 Cr Y Cb Y + // 5’h02 Y Cb Y Cr + // 5’h03 Y Cr Y Cb + // 5’h04 LSC bypass, C/Y + // 5’h05 LSC bypass, Y/C + // 5’h06 RGB 565 + // 5’h0f bypass 10bits + // 5’h17 switch odd/even column /row to controls output Bayer pattern + // 00 RGBG + // 01 RGGB + // 10 BGGR + // 11 GBRG + // 5'h18 DNDD out mode + // 5'h19 LSC out mode + // 5;h1b EEINTP out mode +#define P0_FRAME_START 0X85 +#define P0_SYNC_MODE 0X86 +#define P0_MODULE_GATING 0X88 +#define P0_BYPASS_MODE 0X89 +#define P0_DEBUG_MODE2 0X8C +#define P0_DEBUG_MODE3 0X8D +#define P0_CROP_ENABLE 0X90 +#define P0_OUT_WIN_Y1_HIGH 0X91 +#define P0_OUT_WIN_Y1_LOW 0X92 +#define P0_OUT_WIN_X1_HIGH 0X93 +#define P0_OUT_WIN_X1_LOW 0X94 +#define P0_OUT_WIN_HEIGHT_HIGH 0X95 +#define P0_OUT_WIN_HEIGHT_LOW 0X96 +#define P0_OUT_WIN_WIDTH_HIGH 0X97 +#define P0_OUT_WIN_WIDTH_LOW 0X98 +#define P0_SUBSAMPLE 0X99 +#define P0_SUBSAMPLE_MODE 0X9A + + +#endif // __GC2145_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h new file mode 100644 index 000000000..879fd53b3 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h @@ -0,0 +1,719 @@ + +#include + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0x0000 /* Array end token */ + +static const uint16_t gc2145_default_init_regs[][2] = { + {0xfe, 0xf0}, + {0xfe, 0xf0}, + {0xfe, 0xf0}, + + {0xfc, 0x06}, + {0xf6, 0x00}, + + {0xf7, 0x1d}, //37 //17 //37 //1d//05 + {0xf8, 0x83}, //87 //83 //82 + {0xfa, 0x00}, + {0xf9, 0xfe}, //ff + {0xfd, 0x00}, + {0xc2, 0x00}, + {0xf2, 0x0f}, +////////////////////////////////////////////////////// +//////////////////// Analog & Cisctl //////////////// +////////////////////////////////////////////////////// + {0xfe, 0x00}, + + {0x03, 0x04}, //exp time + {0x04, 0x62}, //exp time + + {0x05, 0x01}, //00 //hb[11:8] + {0x06, 0x3b}, //0b //hb + + {0x09, 0x00}, //row start + {0x0a, 0x00}, // + {0x0b, 0x00}, //col start + {0x0c, 0x00}, + {0x0d, 0x04}, //height + {0x0e, 0xc0}, + {0x0f, 0x06}, //width + {0x10, 0x52}, + + {0x12, 0x2e}, //sh_delay 太短 YUV出图异常 + {0x17, 0x14}, //CISCTL Mode1 [1:0]mirror flip + {0x18, 0x22}, //sdark mode + {0x19, 0x0f}, // AD pipe number + {0x1a, 0x01}, //AD manual switch mode + + {0x1b, 0x4b}, //48 restg Width,SH width + {0x1c, 0x07}, //06 帧率快后,横条纹 //12 //TX Width,Space Width + {0x1d, 0x10}, //double reset + {0x1e, 0x88}, //90//98 //fix 竖线//Analog Mode1,TX high,Coln_r + {0x1f, 0x78}, //78 //38 //18 //Analog Mode2,txlow + {0x20, 0x03}, //07 //Analog Mode3,comv,ad_clk mode + {0x21, 0x40}, //10//20//40 //fix 灯管横条纹 + {0x22, 0xa0}, //d0//f0 //a2 //Vref vpix FPN严重 + {0x24, 0x1e}, + {0x25, 0x01}, //col sel + {0x26, 0x10}, //Analog PGA gain1 + {0x2d, 0x60}, //40//40 //txl drv mode + {0x30, 0x01}, //Analog Mode4 + {0x31, 0x90}, //b0//70 // Analog Mode7 [7:5]rsgh_r灯管横条纹[4:3]isp_g + {0x33, 0x06}, //03//02//01 //EQ_hstart_width + {0x34, 0x01}, +// +/////////////////////////////////////////////////// +//////////////////// ISP reg ////////////////////// +////////////////////////////////////////////////////// + {0x80, 0xff}, //outdoor gamma_en, GAMMA_en, CC_en, EE_en, INTP_en, DN_en, DD_en,LSC_en + {0x81, 0x24}, //26//24 //BLK dither mode, ll_y_en ,skin_en, edge SA, new_skin_mode, autogray_en,ll_gamma_en,BFF test image + {0x82, 0xfa}, //FA //auto_SA, auto_EE, auto_DN, auto_DD, auto_LSC, ABS_en, AWB_en, NA + {0x83, 0x00}, //special_effect + {0x84, 0x02}, //output format + {0x86, 0x03}, //c2 //46 //c2 //sync mode + {0x88, 0x03}, //[1]ctl_auto_gating [0]out_auto_gating + {0x89, 0x03}, //bypass disable + {0x85, 0x30}, //60//frame start cut + {0x8a, 0x00}, //ISP_quiet_mode,close aaa pclk,BLK gate mode,exception,close first pipe clock,close dndd clock,close intp clock,DIV_gatedclk_en + {0x8b, 0x00}, //[7:6]BFF_gate_mode,[5]BLK switch gain,[4]protect exp,[3:2]pipe gate mode,[1]not split sram,[0]dark current update + + {0xb0, 0x55}, //60 //global gain + {0xc3, 0x00}, //[7:4]auto_exp_gamma_th1[11:8],[3:0]auto_exp_gamma_th2[11:8] + {0xc4, 0x80}, //auto_exp_gamma_th1[7:0] into + {0xc5, 0x90}, //auto_exp_gamma_th2[7:0] out //outdoor gamma + {0xc6, 0x38}, //auto_gamma_th1 + {0xc7, 0x40}, //auto_gamma_th2 + + {0xec, 0x06}, //measure window + {0xed, 0x04}, + {0xee, 0x60}, //16 col + {0xef, 0x90}, //8 row + + {0xb6, 0x01}, //[0]aec en + + {0x90, 0x01}, //crop + {0x91, 0x00}, + {0x92, 0x00}, + {0x93, 0x00}, + {0x94, 0x00}, //08 + {0x95, 0x04}, + {0x96, 0xb0}, + {0x97, 0x06}, + {0x98, 0x40}, + +/////////////////////////////////////////////// +/////////// BLK //////////////////////// +/////////////////////////////////////////////// + {0x18, 0x02}, + {0x40, 0x42}, //2b //27 + {0x41, 0x00}, //80 //dark row sel + {0x43, 0x54}, //[7:4]BLK start not smooth [3:0]output start frame + + {0x5e, 0x00}, //00//10 //18 + {0x5f, 0x00}, //00//10 //18 + {0x60, 0x00}, //00//10 //18 + {0x61, 0x00}, //00///10 //18 + {0x62, 0x00}, //00//10 //18 + {0x63, 0x00}, //00//10 //18 + {0x64, 0x00}, //00/10 //18 + {0x65, 0x00}, //00//10 //18 + {0x66, 0x20}, //1e + {0x67, 0x20}, //1e + {0x68, 0x20}, //1e + {0x69, 0x20}, //1e + + + {0x76, 0x00}, //0f + + {0x6a, 0x00}, //06 + {0x6b, 0x00}, //06 + {0x6c, 0x3e}, //06 + {0x6d, 0x3e}, //06 + {0x6e, 0x3f}, //06 + {0x6f, 0x3f}, //06 + {0x70, 0x00}, //06 + {0x71, 0x00}, //06 //manual offset + + {0x76, 0x00}, //1f//add offset + {0x72, 0xf0}, //[7:4]BLK DD th [3:0]BLK various th + {0x7e, 0x3c}, //ndark + {0x7f, 0x00}, + + {0xfe, 0x02}, + {0x48, 0x15}, + {0x49, 0x00}, //04//04 //ASDE OFFSET SLOPE + {0x4b, 0x0b}, //ASDE y OFFSET SLOPE + {0xfe, 0x00}, + +/////////////////////////////////////////////// +/////////// AEC //////////////////////// +/////////////////////////////////////////////// + {0xfe, 0x01}, + + {0x01, 0x04}, //AEC X1 + {0x02, 0xc0}, //AEC X2 + {0x03, 0x04}, //AEC Y1 + {0x04, 0x90}, //AEC Y2 + {0x05, 0x30}, //20 //AEC center X1 + {0x06, 0x90}, //40 //AEC center X2 + {0x07, 0x20}, //30 //AEC center Y1 + {0x08, 0x70}, //60 //AEC center Y2 + + {0x09, 0x00}, //AEC show mode + {0x0a, 0xc2}, //[7]col gain enable + {0x0b, 0x11}, //AEC every N + {0x0c, 0x10}, //AEC_mode3 center weight + {0x13, 0x40}, //2a //AEC Y target + {0x17, 0x00}, //AEC ignore mode + {0x1c, 0x11}, // + {0x1e, 0x61}, // + {0x1f, 0x30}, //40//50 //max pre gain + {0x20, 0x40}, //60//40 //max post gain + {0x22, 0x80}, //AEC outdoor THD + {0x23, 0x20}, //target_Y_low_limit + {0xfe, 0x02}, + {0x0f, 0x04}, //05 + {0xfe, 0x01}, + + {0x12, 0x35}, //35 //[5:4]group_size [3]slope_disable [2]outdoor_enable [0]histogram_enable + {0x15, 0x50}, //target_Y_high_limit + {0x10, 0x31}, //num_thd_high + {0x3e, 0x28}, //num_thd_low + {0x3f, 0xe0}, //luma_thd + {0x40, 0x20}, //luma_slope + {0x41, 0x0f}, //color_diff + + {0xfe, 0x02}, + {0x0f, 0x05}, //max_col_level +/////////////////////////// +////// INTPEE ///////////// +/////////////////////////// + {0xfe, 0x02}, //page2 + {0x90, 0x6c}, //ac //eeintp mode1 + {0x91, 0x03}, //02 ////eeintp mode2 + {0x92, 0xc8}, //44 //low criteria for direction + {0x94, 0x66}, + {0x95, 0xb5}, + {0x97, 0x64}, //78 ////edge effect + {0xa2, 0x11}, //fix direction + {0xfe, 0x00}, + +///////////////////////////// +//////// DNDD/////////////// +///////////////////////////// + {0xfe, 0x02}, + {0x80, 0xc1}, //c1 //[7]share mode [6]skin mode [5]is 5x5 mode [1:0]noise value select 0:2 1:2.5 2:3 3:4 + {0x81, 0x08}, // + {0x82, 0x08}, //signal a 0.6 + {0x83, 0x08}, //04 //signal b 2.5 + + {0x84, 0x0a}, //10 //05 dark_DD_TH + {0x86, 0xf0}, //a0 Y_value_dd_th2 + {0x87, 0x50}, //90 Y_value_dd_th3 + {0x88, 0x15}, //60 Y_value_dd_th4 + + {0x89, 0x50}, //80 // asde th2 + {0x8a, 0x30}, //60 // asde th3 + {0x8b, 0x10}, //30 // asde th4 + +///////////////////////////////////////////////// +///////////// ASDE //////////////////////// +///////////////////////////////////////////////// + {0xfe, 0x01}, //page 1 + {0x21, 0x14}, //luma_value_div_sel(分频,与0xef呈2倍关系,增大1,0xef的值减小1倍) +//ff ef luma_value read_only + + {0xfe, 0x02}, //page2 + {0xa3, 0x40}, //ASDE_low_luma_value_LSC_th_H + {0xa4, 0x20}, //ASDE_low_luma_value_LSC_th_L + + {0xa5, 0x40}, //80 //ASDE_LSC_gain_dec_slope_H + {0xa6, 0x80}, // 80 //ASDE_LSC_gain_dec_slope_L +//ff a7 ASDE_LSC_gain_dec //read only + + {0xab, 0x40}, //50 //ASDE_low_luma_value_OT_th + + {0xae, 0x0c}, //[3]EE1_effect_inc_or_dec_high,[2]EE2_effect_inc_or_dec_high, + //[1]EE1_effect_inc_or_dec_low,[0]EE2_effect_inc_or_dec_low, 1:inc 0:dec + + {0xb3, 0x34}, //44 //ASDE_EE1_effect_slope_low,ASDE_EE2_effect_slope_low + {0xb4, 0x44}, //12 //ASDE_EE1_effect_slope_high,ASDE_EE2_effect_slope_high + + {0xb6, 0x38}, //40//40 //ASDE_auto_saturation_dec_slope + {0xb7, 0x02}, //04 //ASDE_sub_saturation_slope + {0xb9, 0x30}, //[7:0]ASDE_auto_saturation_low_limit + {0x3c, 0x08}, //[3:0]auto gray_dec_slope + {0x3d, 0x30}, //[7:0]auto gray_dec_th + + + {0x4b, 0x0d}, //y offset slope + {0x4c, 0x20}, //y offset limit + + {0xfe, 0x00}, +// +///////////////////gamma1//////////////////// +////Gamma + {0xfe, 0x02}, + {0x10, 0x10}, + {0x11, 0x15}, + {0x12, 0x1a}, + {0x13, 0x1f}, + {0x14, 0x2c}, + {0x15, 0x39}, + {0x16, 0x45}, + {0x17, 0x54}, + {0x18, 0x69}, + {0x19, 0x7d}, + {0x1a, 0x8f}, + {0x1b, 0x9d}, + {0x1c, 0xa9}, + {0x1d, 0xbd}, + {0x1e, 0xcd}, + {0x1f, 0xd9}, + {0x20, 0xe3}, + {0x21, 0xea}, + {0x22, 0xef}, + {0x23, 0xf5}, + {0x24, 0xf9}, + {0x25, 0xff}, + +/////auto gamma///// + {0xfe, 0x02}, + {0x26, 0x0f}, + {0x27, 0x14}, + {0x28, 0x19}, + {0x29, 0x1e}, + {0x2a, 0x27}, + {0x2b, 0x33}, + {0x2c, 0x3b}, + {0x2d, 0x45}, + {0x2e, 0x59}, + {0x2f, 0x69}, + {0x30, 0x7c}, + {0x31, 0x89}, + {0x32, 0x98}, + {0x33, 0xae}, + {0x34, 0xc0}, + {0x35, 0xcf}, + {0x36, 0xda}, + {0x37, 0xe2}, + {0x38, 0xe9}, + {0x39, 0xf3}, + {0x3a, 0xf9}, + {0x3b, 0xff}, + +/////////////////////////////////////////////// +/////////// YCP /////////////////////// +/////////////////////////////////////////////// + {0xfe, 0x02}, + {0xd1, 0x30}, //32 // + {0xd2, 0x30}, //32 // + {0xd3, 0x45}, + {0xdd, 0x14}, //edge sa + {0xde, 0x86}, //asde auto gray + {0xed, 0x01}, // + {0xee, 0x28}, + {0xef, 0x30}, + {0xd8, 0xd8}, //autogray protecy + +//////////////////////////// +//////// LSC 0.8/////////////// +//////////////////////////// + {0xfe, 0x01}, + {0xa1, 0x80}, // center_row + {0xa2, 0x80}, // center_col + {0xa4, 0x00}, // sign of b1 + {0xa5, 0x00}, // sign of b1 + {0xa6, 0x70}, // sign of b4 + {0xa7, 0x00}, // sign of b4 + {0xa8, 0x77}, // sign of b22 + {0xa9, 0x77}, // sign of b22 + {0xaa, 0x1f}, // Q1_b1 of R + {0xab, 0x0d}, // Q1_b1 of G + {0xac, 0x19}, // Q1_b1 of B + {0xad, 0x24}, // Q2_b1 of R + {0xae, 0x0e}, // Q2_b1 of G + {0xaf, 0x1d}, // Q2_b1 of B + {0xb0, 0x12}, // Q3_b1 of R + {0xb1, 0x0c}, // Q3_b1 of G + {0xb2, 0x06}, // Q3_b1 of B + {0xb3, 0x13}, // Q4_b1 of R + {0xb4, 0x10}, // Q4_b1 of G + {0xb5, 0x0c}, // Q4_b1 of B + {0xb6, 0x6a}, // right_b2 of R + {0xb7, 0x46}, // right_b2 of G + {0xb8, 0x40}, // right_b2 of B + {0xb9, 0x0b}, // right_b4 of R + {0xba, 0x04}, // right_b4 of G + {0xbb, 0x00}, // right_b4 of B + {0xbc, 0x53}, // left_b2 of R + {0xbd, 0x37}, // left_b2 of G + {0xbe, 0x2d}, // left_b2 of B + {0xbf, 0x0a}, // left_b4 of R + {0xc0, 0x0a}, // left_b4 of G + {0xc1, 0x14}, // left_b4 of B + {0xc2, 0x34}, // up_b2 of R + {0xc3, 0x22}, // up_b2 of G + {0xc4, 0x18}, // up_b2 of B + {0xc5, 0x23}, // up_b4 of R + {0xc6, 0x0f}, // up_b4 of G + {0xc7, 0x3c}, // up_b4 of B + {0xc8, 0x20}, // down_b2 of R + {0xc9, 0x1f}, // down_b2 of G + {0xca, 0x17}, // down_b2 of B + {0xcb, 0x2d}, // down_b4 of R + {0xcc, 0x12}, // down_b4 of G + {0xcd, 0x20}, // down_b4 of B + {0xd0, 0x61}, // right_up_b22 of R + {0xd1, 0x2f}, // right_up_b22 of G + {0xd2, 0x39}, // right_up_b22 of B + {0xd3, 0x45}, // right_down_b22 of R + {0xd4, 0x2c}, // right_down_b22 of G + {0xd5, 0x21}, // right_down_b22 of B + {0xd6, 0x64}, // left_up_b22 of R + {0xd7, 0x2d}, // left_up_b22 of G + {0xd8, 0x30}, // left_up_b22 of B + {0xd9, 0x42}, // left_down_b22 of R + {0xda, 0x27}, // left_down_b22 of G + {0xdb, 0x13}, // left_down_b22 of B + {0xfe, 0x00}, + +///////////////////////////////////////////////// +///////////// AWB //////////////////////// +///////////////////////////////////////////////// + {0xfe, 0x01}, + + {0x4f, 0x00}, + {0x4f, 0x00}, + {0x4b, 0x01}, + {0x4f, 0x00}, + + + {0x4c, 0x01}, + {0x4d, 0x6f}, + {0x4e, 0x02}, + {0x4c, 0x01}, + {0x4d, 0x70}, + + {0x4e, 0x02}, + {0x4c, 0x01}, + {0x4d, 0x8f}, + {0x4e, 0x02}, + + {0x4c, 0x01}, + {0x4d, 0x90}, + {0x4e, 0x02}, //light + + + {0x4c, 0x01}, + {0x4d, 0xed}, + {0x4e, 0x33}, //light + {0x4c, 0x01}, + {0x4d, 0xcd}, + {0x4e, 0x33}, //light + {0x4c, 0x01}, + {0x4d, 0xec}, + {0x4e, 0x03}, //light + + {0x4c, 0x01}, + {0x4d, 0x6c}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0x6d}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0x6e}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0x8c}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0x8d}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0x8e}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xab}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xac}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xad}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xae}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xcb}, + {0x4e, 0x03}, + + {0x4c, 0x01}, + {0x4d, 0xcc}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xce}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xeb}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xec}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xee}, + {0x4e, 0x03}, + {0x4c, 0x02}, + {0x4d, 0x0c}, + {0x4e, 0x03}, + {0x4c, 0x02}, + {0x4d, 0x0d}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xea}, + {0x4e, 0x03}, + {0x4c, 0x01}, + {0x4d, 0xaf}, + {0x4e, 0x03}, //dark + {0x4c, 0x01}, + {0x4d, 0xcf}, + {0x4e, 0x03}, //dark + + {0x4c, 0x01}, + {0x4d, 0xca}, + {0x4e, 0x04}, //light + {0x4c, 0x02}, + {0x4d, 0x0b}, + {0x4e, 0x05}, //light + {0x4c, 0x02}, + {0x4d, 0xc8}, + {0x4e, 0x06}, //light 100lux + {0x4c, 0x02}, + {0x4d, 0xa8}, + + {0x4e, 0x06}, //light + {0x4c, 0x02}, + {0x4d, 0xa9}, + {0x4e, 0x06}, //light + + + {0x4c, 0x02}, + {0x4d, 0x89}, + {0x4e, 0x06}, //400lux + {0x4c, 0x02}, + {0x4d, 0x69}, + {0x4e, 0x06}, //f12 + {0x4c, 0x02}, + {0x4d, 0x6a}, + {0x4e, 0x06}, //f12 + {0x4c, 0x02}, + {0x4d, 0xc7}, + {0x4e, 0x07}, + {0x4c, 0x02}, + {0x4d, 0xe7}, + {0x4e, 0x07}, //100lux + {0x4c, 0x03}, + {0x4d, 0x07}, + {0x4e, 0x07}, //light + + {0x4c, 0x02}, + {0x4d, 0xe8}, + {0x4e, 0x07}, + {0x4c, 0x02}, + {0x4d, 0xe9}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x08}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x09}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x27}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x28}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x29}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x47}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x48}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x49}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x67}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x68}, + {0x4e, 0x07}, + {0x4c, 0x03}, + {0x4d, 0x69}, + {0x4e, 0x07}, + + {0x4f, 0x01}, + {0xfe, 0x01}, + {0x50, 0x80}, //AWB_PRE_mode + {0x51, 0xa8}, //AWB_pre_THD_min[7:0] + {0x52, 0x57}, //AWB_pre_THD_min[15:8] Dominiate luma 0.25=639c 0.22=57a8 + {0x53, 0x38}, //AWB_pre_THD_min_MIX[7:0] + {0x54, 0xc7}, //AWB_pre_THD_min_MIX[15:8] Mix luma 0.5 + + {0x56, 0x0e}, //AWB_tone mode + {0x58, 0x08}, //AWB_C_num_sel,AWB_D_num_sel + {0x5b, 0x00}, //AWB_mix_mode + + {0x5c, 0x74}, //green_num0[7:0] + {0x5d, 0x8b}, //green_num0[15:8] 0.35 + + {0x61, 0xd3}, //R2G_stand0 + {0x62, 0xb5}, //B2G_stand0 + {0x63, 0x00}, //88//a4 //AWB gray mode [7]enable + {0x65, 0x04}, //AWB margin + + {0x67, 0xb2}, //R2G_stand3[7:0] FF/CWF + {0x68, 0xac}, //B2G_stand3[7:0] + {0x69, 0x00}, //R2G_stand4[9:8] B2G_stand4[9:8] R2G_stand3[9:8] B2G_stand3[9:8] + {0x6a, 0xb2}, //R2G_stand4[7:0] TL84/TL84&CWF + {0x6b, 0xac}, //B2G_stand4[7:0] + {0x6c, 0xb2}, //R2G_stand5[7:0] A + {0x6d, 0xac}, //B2G_stand5[7:0] + {0x6e, 0x40}, //AWB_skin_weight R2G_stand5[9:8] B2G_stand5[9:8] + {0x6f, 0x18}, //AWB_indoor_THD (0x21=17 caculate) + {0x73, 0x00}, //AWB_indoor_mode + + {0x70, 0x10}, //AWB low luma TH + {0x71, 0xe8}, //AWB outdoor TH + {0x72, 0xc0}, //outdoor mode + {0x74, 0x01}, //[2:0]AWB skip mode 2x2,4x4,4x8,8x8 + {0x75, 0x01}, //[1:0]AWB_every_N + {0x7f, 0x08}, //[3]gray world frame start + + {0x76, 0x70}, //R limit + {0x77, 0x58}, //G limit + {0x78, 0xa0}, //d8 //B limit + + {0xfe, 0x00}, +// +////////////////////////////////////////// +/////////// CC //////////////////////// +////////////////////////////////////////// + {0xfe, 0x02}, + + {0xc0, 0x01}, //[5:4] CC mode [0]CCT enable + + {0xC1, 0x50}, //D50/D65 + {0xc2, 0xF9}, + {0xc3, 0x00}, //0 + {0xc4, 0xe8}, //e0 + {0xc5, 0x48}, + {0xc6, 0xf0}, + + + {0xC7, 0x50}, + {0xc8, 0xf2}, + {0xc9, 0x00}, + {0xcA, 0xE0}, + {0xcB, 0x45}, + {0xcC, 0xec}, + + {0xCd, 0x45}, + {0xce, 0xf0}, + {0xcf, 0x00}, + {0xe3, 0xf0}, + {0xe4, 0x45}, + {0xe5, 0xe8}, + + + {0xfe, 0x00}, + + {0xf2, 0x0f}, + + +//////////////frame rate 50Hz + {0xfe, 0x00}, + + {0xf7, 0x1d}, + {0xf8, 0x84}, + {0xfa, 0x00}, + + {0x05, 0x01}, //hb + {0x06, 0x3b}, + {0x07, 0x01}, //Vb + {0x08, 0x0b}, + + {0xfe, 0x01}, + {0x25, 0x01}, + {0x26, 0x32}, //step + {0x27, 0x03}, //8.15fps + {0x28, 0x96}, + {0x29, 0x03}, //8.15fps + {0x2a, 0x96}, + {0x2b, 0x03}, //8.15fps + {0x2c, 0x96}, + {0x2d, 0x04}, //8.15fps + {0x2e, 0x62}, + {0x3c, 0x00}, + {0xfe, 0x00}, + +/////////dark sun////// + {0xfe, 0x00}, + {0x18, 0x22}, + {0xfe, 0x02}, + {0x40, 0xbf}, + {0x46, 0xcf}, + {0xfe, 0x00}, + + {0xfe, 0x00}, + + {0xf7, 0x1d}, + {0xf8, 0x84}, + {0xfa, 0x10}, + + {0x05, 0x01}, //hb + {0x06, 0x18}, + {0x07, 0x00}, //Vb + {0x08, 0x2e}, + + {0xfe, 0x01}, + {0x25, 0x00}, + {0x26, 0xa2}, //step + {0x27, 0x01}, + {0x28, 0xe6}, + {0x29, 0x01}, + {0x2a, 0xe6}, + {0x2b, 0x01}, + {0x2c, 0xe6}, + {0x2d, 0x04}, // AEC_exp_level4[12:8] + {0x2e, 0x62}, // AEC_exp_level4[7:0] + {0x3c, 0x00}, + {0xfe, 0x00}, + + {0x09, 0x01}, //row start + {0x0a, 0xd0}, // + {0x0b, 0x02}, //col start + {0x0c, 0x70}, + {0x0d, 0x01}, //height + {0x0e, 0x00}, + {0x0f, 0x01}, //width + {0x10, 0x50}, + + {0x90, 0x01}, //crop + {0x91, 0x00}, + {0x92, 0x00}, + {0x93, 0x00}, + {0x94, 0x00}, + {0x95, 0x00}, + {0x96, 0xf0}, + {0x97, 0x01}, + {0x98, 0x40}, + + + {REGLIST_TAIL, 0x00}, +}; diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h new file mode 100644 index 000000000..8b0c562b9 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h @@ -0,0 +1,34 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * NT99141 driver. + * + */ +#ifndef __NT99141_H__ +#define __NT99141_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int nt99141_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int nt99141_init(sensor_t *sensor); + +#endif // __NT99141_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h new file mode 100644 index 000000000..8301db901 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h @@ -0,0 +1,211 @@ +/* + * NT99141 register definitions. + */ +#ifndef __NT99141_REG_REGS_H__ +#define __NT99141_REG_REGS_H__ + +/* system control registers */ +#define SYSTEM_CTROL0 0x3021 // Bit[7]: Software reset + // Bit[6]: Software power down + // Bit[5]: Reserved + // Bit[4]: SRB clock SYNC enable + // Bit[3]: Isolation suspend select + // Bit[2:0]: Not used + +/* output format control registers */ +#define FORMAT_CTRL 0x501F // Format select + // Bit[2:0]: + // 000: YUV422 + // 001: RGB + // 010: Dither + // 011: RAW after DPC + // 101: RAW after CIP + +/* format control registers */ +#define FORMAT_CTRL00 0x4300 + +/* frame control registers */ +#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode + // Bit[7:4]: Not used + // Bit[3:0]: Frame ON number +#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode + // Bit[7:4]: Not used + // BIT[3:0]: Frame OFF number + +/* ISP top control registers */ +#define PRE_ISP_TEST_SETTING_1 0x3025 // Bit[7]: Test enable + // 0: Test disable + // 1: Color bar enable + // Bit[6]: Rolling + // Bit[5]: Transparent + // Bit[4]: Square black and white + // Bit[3:2]: Color bar style + // 00: Standard 8 color bar + // 01: Gradual change at vertical mode 1 + // 10: Gradual change at horizontal + // 11: Gradual change at vertical mode 2 + // Bit[1:0]: Test select + // 00: Color bar + // 01: Random data + // 10: Square data + // 11: Black image + +//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW + +/* AEC/AGC control functions */ +#define AEC_PK_MANUAL 0x3201 // AEC Manual Mode Control + // Bit[7:6]: Reserved + // Bit[5]: Gain delay option + // Valid when 0x3503[4]=1’b0 + // 0: Delay one frame latch + // 1: One frame latch + // Bit[4:2]: Reserved + // Bit[1]: AGC manual + // 0: Auto enable + // 1: Manual enable + // Bit[0]: AEC manual + // 0: Auto enable + // 1: Manual enable + +//gain = {0x350A[1:0], 0x350B[7:0]} / 16 + +/* mirror and flip registers */ +#define TIMING_TC_REG20 0x3022 // Timing Control Register + // Bit[2:1]: Vertical flip enable + // 00: Normal + // 11: Vertical flip + // Bit[0]: Vertical binning enable +#define TIMING_TC_REG21 0x3022 // Timing Control Register + // Bit[5]: Compression Enable + // Bit[2:1]: Horizontal mirror enable + // 00: Normal + // 11: Horizontal mirror + // Bit[0]: Horizontal binning enable + +#define CLOCK_POL_CONTROL 0x3024// Bit[5]: PCLK polarity 0: active low + // 1: active high + // Bit[3]: Gate PCLK under VSYNC + // Bit[2]: Gate PCLK under HREF + // Bit[1]: HREF polarity + // 0: active low + // 1: active high + // Bit[0] VSYNC polarity + // 0: active low + // 1: active high +#define DRIVE_CAPABILITY 0x306a // Bit[7:6]: + // 00: 1x + // 01: 2x + // 10: 3x + // 11: 4x + + +#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8] +#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0] +#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8] +#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0] +#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8] +#define X_ADDR_END_L 0x3805 //Bit[7:0]: +#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8] +#define Y_ADDR_END_L 0x3807 //Bit[7:0]: +// Size after scaling +#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8] +#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]: +#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8] +#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]: +#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8] +#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]: +#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8] +#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]: +#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8] +#define X_OFFSET_L 0x3811 //Bit[7:0]: +#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8] +#define Y_OFFSET_L 0x3813 //Bit[7:0]: +#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment + //Bit[3:0]: Horizontal even subsample increment +#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment + //Bit[3:0]: Vertical even subsample increment +// Size before scaling +//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET)) +//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET)) + +#define ISP_CONTROL_01 0x3021 // Bit[5]: Scale enable + // 0: Disable + // 1: Enable + +#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW + // DCW scale times + // 000: DCW 1 time + // 001: DCW 2 times + // 010: DCW 4 times + // 100: DCW 8 times + // 101: DCW 16 times + // Others: DCW 16 times + // Bit[2:0]: VDIV RW + // DCW scale times + // 000: DCW 1 time + // 001: DCW 2 times + // 010: DCW 4 times + // 100: DCW 8 times + // 101: DCW 16 times + // Others: DCW 16 times + +#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits +#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits +#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits +#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits +#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset + +#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual +#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable + // 0: Auto + // 1: Manual by PCLK_RATIO + +#define VFIFO_X_SIZE_H 0x4602 +#define VFIFO_X_SIZE_L 0x4603 +#define VFIFO_Y_SIZE_H 0x4604 +#define VFIFO_Y_SIZE_L 0x4605 + +#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass +#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier +#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control + // Bit[3:0]: PLLS system divider +#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider + // 00: 1 + // 01: 1.5 + // 10: 2 + // 11: 3 + // Bit[2]: PLLS root-divider - 1 + // Bit[1:0]: PLLS seld5 + // 00: 1 + // 01: 1 + // 10: 2 + // 11: 2.5 + +#define COMPRESSION_CTRL00 0x4400 // +#define COMPRESSION_CTRL01 0x4401 // +#define COMPRESSION_CTRL02 0x4402 // +#define COMPRESSION_CTRL03 0x4403 // +#define COMPRESSION_CTRL04 0x4404 // +#define COMPRESSION_CTRL05 0x4405 // +#define COMPRESSION_CTRL06 0x4406 // +#define COMPRESSION_CTRL07 0x3401 // Bit[5:0]: QS +#define COMPRESSION_ISI_CTRL 0x4408 // +#define COMPRESSION_CTRL09 0x4409 // +#define COMPRESSION_CTRL0a 0x440a // +#define COMPRESSION_CTRL0b 0x440b // +#define COMPRESSION_CTRL0c 0x440c // +#define COMPRESSION_CTRL0d 0x440d // +#define COMPRESSION_CTRL0E 0x440e // + +/** + * @brief register value + */ +#define TEST_COLOR_BAR 0x02 /* Enable Color Bar roling Test */ + +#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */ +#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */ + +#define TIMING_TC_REG20_VFLIP 0x01 /* Vertical flip enable */ +#define TIMING_TC_REG21_HMIRROR 0x02 /* Horizontal mirror enable */ + +#endif // __NT99141_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h new file mode 100644 index 000000000..1ffec2053 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h @@ -0,0 +1,825 @@ +#ifndef _NT99141_SETTINGS_H_ +#define _NT99141_SETTINGS_H_ + +#include +#include +#include "esp_attr.h" +#include "nt99141_regs.h" + +static const ratio_settings_t ratio_table[] = { + // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty + { 1280, 720, 0, 4, 1283, 723, 0, 4, 1660, 963 }, + +}; + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0x0000 + +static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { + //initial +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x3109, 0x04}, +{0x3040, 0x04}, +{0x3041, 0x02}, +{0x3042, 0xFF}, +{0x3043, 0x08}, +{0x3052, 0xE0}, +{0x305F, 0x33}, +{0x3100, 0x07}, +{0x3106, 0x03}, +{0x3105, 0x01}, +{0x3108, 0x05}, +{0x3110, 0x22}, +{0x3111, 0x57}, +{0x3112, 0x22}, +{0x3113, 0x55}, +{0x3114, 0x05}, +{0x3135, 0x00}, +{0x32F0, 0x01}, +{0x3290, 0x01}, +{0x3291, 0x80}, +{0x3296, 0x01}, +{0x3297, 0x73}, +{0x3250, 0x80}, +{0x3251, 0x03}, +{0x3252, 0xFF}, +{0x3253, 0x00}, +{0x3254, 0x03}, +{0x3255, 0xFF}, +{0x3256, 0x00}, +{0x3257, 0x50}, +{0x3270, 0x00}, +{0x3271, 0x0C}, +{0x3272, 0x18}, +{0x3273, 0x32}, +{0x3274, 0x44}, +{0x3275, 0x54}, +{0x3276, 0x70}, +{0x3277, 0x88}, +{0x3278, 0x9D}, +{0x3279, 0xB0}, +{0x327A, 0xCF}, +{0x327B, 0xE2}, +{0x327C, 0xEF}, +{0x327D, 0xF7}, +{0x327E, 0xFF}, +{0x3302, 0x00}, +{0x3303, 0x40}, +{0x3304, 0x00}, +{0x3305, 0x96}, +{0x3306, 0x00}, +{0x3307, 0x29}, +{0x3308, 0x07}, +{0x3309, 0xBA}, +{0x330A, 0x06}, +{0x330B, 0xF5}, +{0x330C, 0x01}, +{0x330D, 0x51}, +{0x330E, 0x01}, +{0x330F, 0x30}, +{0x3310, 0x07}, +{0x3311, 0x16}, +{0x3312, 0x07}, +{0x3313, 0xBA}, +{0x3326, 0x02}, +{0x32F6, 0x0F}, +{0x32F9, 0x42}, +{0x32FA, 0x24}, +{0x3325, 0x4A}, +{0x3330, 0x00}, +{0x3331, 0x0A}, +{0x3332, 0xFF}, +{0x3338, 0x30}, +{0x3339, 0x84}, +{0x333A, 0x48}, +{0x333F, 0x07}, +{0x3360, 0x10}, +{0x3361, 0x18}, +{0x3362, 0x1f}, +{0x3363, 0x37}, +{0x3364, 0x80}, +{0x3365, 0x80}, +{0x3366, 0x68}, +{0x3367, 0x60}, +{0x3368, 0x30}, +{0x3369, 0x28}, +{0x336A, 0x20}, +{0x336B, 0x10}, +{0x336C, 0x00}, +{0x336D, 0x20}, +{0x336E, 0x1C}, +{0x336F, 0x18}, +{0x3370, 0x10}, +{0x3371, 0x38}, +{0x3372, 0x3C}, +{0x3373, 0x3F}, +{0x3374, 0x3F}, +{0x338A, 0x34}, +{0x338B, 0x7F}, +{0x338C, 0x10}, +{0x338D, 0x23}, +{0x338E, 0x7F}, +{0x338F, 0x14}, +{0x3375, 0x08}, +{0x3376, 0x0C}, +{0x3377, 0x18}, +{0x3378, 0x20}, +{0x3012, 0x02}, +{0x3013, 0xD0}, +{0x3025, 0x02}, //colorbar +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_jpeg[][2] = { + {0x32F0, 0x70}, // YUV422 + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_raw[][2] = { + {0x32F0, 0x50}, // RAW + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_grayscale[][2] = { + {0x32F1, 0x01}, + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_yuv422[][2] = { + {0x32F0, 0x00}, // YUV422 + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_rgb565[][2] = { + {0x32F0, 0x01}, // RGB + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint8_t sensor_saturation_levels[9][1] = { + {0x60},//-4 + {0x68},//-3 + {0x70},//-2 + {0x78},//-1 + {0x80},//0 + {0x88},//+1 + {0x90},//+2 + {0x98},//+3 + {0xA0},//+4 +}; + +static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = { + {0x00, 0x80, 0x80, 0x01},//Normal + {0x03, 0x80, 0x80, 0x01},//Negative + {0x01, 0x80, 0x80, 0x01},//Grayscale + {0x05, 0x2A, 0xF0, 0x01},//Red Tint + {0x05, 0x60, 0x20, 0x01},//Green Tint + {0x05, 0xF0, 0x80, 0x01},//Blue Tint + {0x02, 0x80, 0x80, 0x01},//Sepia + +}; + +// AE LEVEL +static const DRAM_ATTR uint16_t sensor_ae_level[][2] = { + +// 1. [AE_Target : 0x24] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x29 }, + {0x32B9, 0x1F }, + {0x32BC, 0x24 }, + {0x32BD, 0x27 }, + {0x32BE, 0x21 }, +//------------------------------------------------------------------------ +// 2. [AE_Target : 0x28] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x2D }, + {0x32B9, 0x23 }, + {0x32BC, 0x28 }, + {0x32BD, 0x2B }, + {0x32BE, 0x25 }, +//------------------------------------------------------------------------ +// 3. [AE_Target : 0x2C] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x32 }, + {0x32B9, 0x26 }, + {0x32BC, 0x2C }, + {0x32BD, 0x2F }, + {0x32BE, 0x29 }, +//------------------------------------------------------------------------ +// 4, [AE_Target : 0x30] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x36 }, + {0x32B9, 0x2A }, + {0x32BC, 0x30 }, + {0x32BD, 0x33 }, + {0x32BE, 0x2D }, +//------------------------------------------------------------------------ +// 5. [AE_Target : 0x34] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x3B }, + {0x32B9, 0x2D }, + {0x32BC, 0x34 }, + {0x32BD, 0x38 }, + {0x32BE, 0x30 }, +//------------------------------------------------------------------------ +// 6. [AE_Target : 0x38] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x3F }, + {0x32B9, 0x31 }, + {0x32BC, 0x38 }, + {0x32BD, 0x3C }, + {0x32BE, 0x34 }, +//------------------------------------------------------------------------ +// 7. [AE_Target : 0x3D] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x44 }, + {0x32B9, 0x34 }, + {0x32BC, 0x3C }, + {0x32BD, 0x40 }, + {0x32BE, 0x38 }, +//------------------------------------------------------------------------ +// 8. [AE_Target : 0x40] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x48 }, + {0x32B9, 0x38 }, + {0x32BC, 0x40 }, + {0x32BD, 0x44 }, + {0x32BE, 0x3C }, +//------------------------------------------------------------------------ +// 9. [AE_Target : 0x44] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 + {0x32B8, 0x4D }, + {0x32B9, 0x3B }, + {0x32BC, 0x44 }, + {0x32BD, 0x49 }, + {0x32BE, 0x3F }, +}; + +static const DRAM_ATTR uint16_t sensor_framesize_HD[][2] = { +//[JPEG_1280x720_8.18_8.18_Fps] +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x3C}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x5E}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x24}, +{0x3002, 0x00}, +{0x3003, 0x04}, +{0x3004, 0x00}, +{0x3005, 0x04}, +{0x3006, 0x05}, +{0x3007, 0x03}, +{0x3008, 0x02}, +{0x3009, 0xD3}, +{0x300A, 0x06}, +{0x300B, 0x7C}, +{0x300C, 0x02}, +{0x300D, 0xE0}, +{0x300E, 0x05}, +{0x300F, 0x00}, +{0x3010, 0x02}, +{0x3011, 0xD0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x3F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_framesize_VGA[][2] = { +//[JPEG_640x480_10.14_10.14_Fps] +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x4B}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x62}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x32E0, 0x02}, +{0x32E1, 0x80}, +{0x32E2, 0x01}, +{0x32E3, 0xE0}, +{0x32E4, 0x00}, +{0x32E5, 0x80}, +{0x32E6, 0x00}, +{0x32E7, 0x80}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x24}, +{0x3002, 0x00}, +{0x3003, 0xA4}, +{0x3004, 0x00}, +{0x3005, 0x04}, +{0x3006, 0x04}, +{0x3007, 0x63}, +{0x3008, 0x02}, +{0x3009, 0xD3}, +{0x300A, 0x05}, +{0x300B, 0x3C}, +{0x300C, 0x02}, +{0x300D, 0xE0}, +{0x300E, 0x03}, +{0x300F, 0xC0}, +{0x3010, 0x02}, +{0x3011, 0xD0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x7F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_framesize_QVGA[][2] = { +//[JPEG_320x240_10.14_10.14_Fps] +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x4B}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x62}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x32E0, 0x01}, +{0x32E1, 0x40}, +{0x32E2, 0x00}, +{0x32E3, 0xF0}, +{0x32E4, 0x02}, +{0x32E5, 0x02}, +{0x32E6, 0x02}, +{0x32E7, 0x03}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x24}, +{0x3002, 0x00}, +{0x3003, 0xA4}, +{0x3004, 0x00}, +{0x3005, 0x04}, +{0x3006, 0x04}, +{0x3007, 0x63}, +{0x3008, 0x02}, +{0x3009, 0xD3}, +{0x300A, 0x05}, +{0x300B, 0x3C}, +{0x300C, 0x02}, +{0x300D, 0xE0}, +{0x300E, 0x03}, +{0x300F, 0xC0}, +{0x3010, 0x02}, +{0x3011, 0xD0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x7F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_framesize_VGA_xyskip[][2] = { +// [JPEG_640x360_20.00_25.01_Fps_XY_Skip] +// Set_Device_Format = FORMAT_16_8 +// SET_Device_Addr = 0x54 +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60 }, +{0x320A, 0xB2 }, +{0x32C0, 0x64 }, +{0x32C1, 0x64 }, +{0x32C2, 0x64 }, +{0x32C3, 0x00 }, +{0x32C4, 0x20 }, +{0x32C5, 0x20 }, +{0x32C6, 0x20 }, +{0x32C7, 0x00 }, +{0x32C8, 0x62 }, +{0x32C9, 0x64 }, +{0x32CA, 0x84 }, +{0x32CB, 0x84 }, +{0x32CC, 0x84 }, +{0x32CD, 0x84 }, +{0x32DB, 0x68 }, +{0x32F0, 0x70 }, +{0x3400, 0x08 }, +{0x3400, 0x00 }, +{0x3401, 0x4E }, +{0x3404, 0x00 }, +{0x3405, 0x00 }, +{0x3410, 0x00 }, +{0x3200, 0x3E }, +{0x3201, 0x0F }, +{0x3028, 0x0F }, +{0x3029, 0x00 }, +{0x302A, 0x08 }, +{0x3022, 0x24 }, +{0x3023, 0x6C }, +{0x3002, 0x00 }, +{0x3003, 0x04 }, +{0x3004, 0x00 }, +{0x3005, 0x04 }, +{0x3006, 0x05 }, +{0x3007, 0x03 }, +{0x3008, 0x02 }, +{0x3009, 0xD3 }, +{0x300A, 0x03 }, +{0x300B, 0xFC }, +{0x300C, 0x01 }, +{0x300D, 0x88 }, +{0x300E, 0x02 }, +{0x300F, 0x80 }, +{0x3010, 0x01 }, +{0x3011, 0x68 }, +{0x32B8, 0x3F }, +{0x32B9, 0x31 }, +{0x32BB, 0x87 }, +{0x32BC, 0x38 }, +{0x32BD, 0x3C }, +{0x32BE, 0x34 }, +{0x3201, 0x3F }, +{0x3025, 0x00 }, //normal +{0x3021, 0x06 }, +{0x3400, 0x01 }, +{0x3060, 0x01 }, +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_framesize_VGA_xskip[][2] = { +//[JPEG_640x480_Xskip_13.32_13.32_Fps] +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x62}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x68}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x32E0, 0x02}, +{0x32E1, 0x80}, +{0x32E2, 0x01}, +{0x32E3, 0xE0}, +{0x32E4, 0x00}, +{0x32E5, 0x00}, +{0x32E6, 0x00}, +{0x32E7, 0x80}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x2C}, +{0x3002, 0x00}, +{0x3003, 0x04}, +{0x3004, 0x00}, +{0x3005, 0x04}, +{0x3006, 0x05}, +{0x3007, 0x03}, +{0x3008, 0x02}, +{0x3009, 0xD3}, +{0x300A, 0x03}, +{0x300B, 0xFC}, +{0x300C, 0x02}, +{0x300D, 0xE0}, +{0x300E, 0x02}, +{0x300F, 0x80}, +{0x3010, 0x02}, +{0x3011, 0xD0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x7F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_framesize_QVGA_xskip[][2] = { +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +//[JPEG_320x240_Xskip_13.32_13.32_Fps] +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x62}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x68}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x32E0, 0x01}, +{0x32E1, 0x40}, +{0x32E2, 0x00}, +{0x32E3, 0xF0}, +{0x32E4, 0x01}, +{0x32E5, 0x01}, +{0x32E6, 0x02}, +{0x32E7, 0x03}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x2C}, +{0x3002, 0x00}, +{0x3003, 0x04}, +{0x3004, 0x00}, +{0x3005, 0x04}, +{0x3006, 0x05}, +{0x3007, 0x03}, +{0x3008, 0x02}, +{0x3009, 0xD3}, +{0x300A, 0x03}, +{0x300B, 0xFC}, +{0x300C, 0x02}, +{0x300D, 0xE0}, +{0x300E, 0x02}, +{0x300F, 0x80}, +{0x3010, 0x02}, +{0x3011, 0xD0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x7F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + + +static const DRAM_ATTR uint16_t sensor_framesize_VGA_crop[][2] = { +//[JPEG_640x480_Crop_19.77_19.77_Fps] +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x62}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x68}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x24}, +{0x3002, 0x01}, +{0x3003, 0x44}, +{0x3004, 0x00}, +{0x3005, 0x7C}, +{0x3006, 0x03}, +{0x3007, 0xC3}, +{0x3008, 0x02}, +{0x3009, 0x5B}, +{0x300A, 0x03}, +{0x300B, 0xFC}, +{0x300C, 0x01}, +{0x300D, 0xF0}, +{0x300E, 0x02}, +{0x300F, 0x80}, +{0x3010, 0x01}, +{0x3011, 0xE0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x3F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_framesize_QVGA_crop[][2] = { +//[JPEG_320x240_Crop_19.77_19.77_Fps] +{0x3021, 0x00}, +{REG_DLY, 100}, // delay 100ms +{0x32BF, 0x60}, +{0x32C0, 0x5A}, +{0x32C1, 0x5A}, +{0x32C2, 0x5A}, +{0x32C3, 0x00}, +{0x32C4, 0x20}, +{0x32C5, 0x20}, +{0x32C6, 0x20}, +{0x32C7, 0x00}, +{0x32C8, 0x62}, +{0x32C9, 0x5A}, +{0x32CA, 0x7A}, +{0x32CB, 0x7A}, +{0x32CC, 0x7A}, +{0x32CD, 0x7A}, +{0x32DB, 0x68}, +{0x32F0, 0x70}, +{0x3400, 0x08}, +{0x3400, 0x00}, +{0x3401, 0x4E}, +{0x3404, 0x00}, +{0x3405, 0x00}, +{0x3410, 0x00}, +{0x32E0, 0x01}, +{0x32E1, 0x40}, +{0x32E2, 0x00}, +{0x32E3, 0xF0}, +{0x32E4, 0x01}, +{0x32E5, 0x01}, +{0x32E6, 0x01}, +{0x32E7, 0x02}, +{0x3200, 0x3E}, +{0x3201, 0x0F}, +{0x3028, 0x0F}, +{0x3029, 0x00}, +{0x302A, 0x08}, +{0x3022, 0x24}, +{0x3023, 0x24}, +{0x3002, 0x01}, +{0x3003, 0x44}, +{0x3004, 0x00}, +{0x3005, 0x7C}, +{0x3006, 0x03}, +{0x3007, 0xC3}, +{0x3008, 0x02}, +{0x3009, 0x5B}, +{0x300A, 0x03}, +{0x300B, 0xFC}, +{0x300C, 0x01}, +{0x300D, 0xF0}, +{0x300E, 0x02}, +{0x300F, 0x80}, +{0x3010, 0x01}, +{0x3011, 0xE0}, +{0x32B8, 0x3F}, +{0x32B9, 0x31}, +{0x32BB, 0x87}, +{0x32BC, 0x38}, +{0x32BD, 0x3C}, +{0x32BE, 0x34}, +{0x3201, 0x7F}, +{0x3021, 0x06}, +{0x3025, 0x00}, //normal +{0x3400, 0x01}, +{0x3060, 0x01}, +{REGLIST_TAIL, 0x00}, // tail +}; + +#endif + + diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h new file mode 100644 index 000000000..342ab2132 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h @@ -0,0 +1,32 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV2640 driver. + * + */ +#ifndef __OV2640_H__ +#define __OV2640_H__ +#include "sensor.h" +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int ov2640_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int ov2640_init(sensor_t *sensor); + +#endif // __OV2640_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h new file mode 100644 index 000000000..8f47333fa --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h @@ -0,0 +1,216 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV2640 register definitions. + */ +#ifndef __REG_REGS_H__ +#define __REG_REGS_H__ +/* DSP register bank FF=0x00*/ +#define R_BYPASS 0x05 +#define QS 0x44 +#define CTRLI 0x50 +#define HSIZE 0x51 +#define VSIZE 0x52 +#define XOFFL 0x53 +#define YOFFL 0x54 +#define VHYX 0x55 +#define DPRP 0x56 +#define TEST 0x57 +#define ZMOW 0x5A +#define ZMOH 0x5B +#define ZMHH 0x5C +#define BPADDR 0x7C +#define BPDATA 0x7D +#define CTRL2 0x86 +#define CTRL3 0x87 +#define SIZEL 0x8C +#define HSIZE8 0xC0 +#define VSIZE8 0xC1 +#define CTRL0 0xC2 +#define CTRL1 0xC3 +#define R_DVP_SP 0xD3 +#define IMAGE_MODE 0xDA +#define RESET 0xE0 +#define MS_SP 0xF0 +#define SS_ID 0xF7 +#define SS_CTRL 0xF7 +#define MC_BIST 0xF9 +#define MC_AL 0xFA +#define MC_AH 0xFB +#define MC_D 0xFC +#define P_CMD 0xFD +#define P_STATUS 0xFE +#define BANK_SEL 0xFF + +#define CTRLI_LP_DP 0x80 +#define CTRLI_ROUND 0x40 + +#define CTRL0_AEC_EN 0x80 +#define CTRL0_AEC_SEL 0x40 +#define CTRL0_STAT_SEL 0x20 +#define CTRL0_VFIRST 0x10 +#define CTRL0_YUV422 0x08 +#define CTRL0_YUV_EN 0x04 +#define CTRL0_RGB_EN 0x02 +#define CTRL0_RAW_EN 0x01 + +#define CTRL2_DCW_EN 0x20 +#define CTRL2_SDE_EN 0x10 +#define CTRL2_UV_ADJ_EN 0x08 +#define CTRL2_UV_AVG_EN 0x04 +#define CTRL2_CMX_EN 0x01 + +#define CTRL3_BPC_EN 0x80 +#define CTRL3_WPC_EN 0x40 + +#define R_DVP_SP_AUTO_MODE 0x80 + +#define R_BYPASS_DSP_EN 0x00 +#define R_BYPASS_DSP_BYPAS 0x01 + +#define IMAGE_MODE_Y8_DVP_EN 0x40 +#define IMAGE_MODE_JPEG_EN 0x10 +#define IMAGE_MODE_YUV422 0x00 +#define IMAGE_MODE_RAW10 0x04 +#define IMAGE_MODE_RGB565 0x08 +#define IMAGE_MODE_HREF_VSYNC 0x02 +#define IMAGE_MODE_LBYTE_FIRST 0x01 + +#define RESET_MICROC 0x40 +#define RESET_SCCB 0x20 +#define RESET_JPEG 0x10 +#define RESET_DVP 0x04 +#define RESET_IPU 0x02 +#define RESET_CIF 0x01 + +#define MC_BIST_RESET 0x80 +#define MC_BIST_BOOT_ROM_SEL 0x40 +#define MC_BIST_12KB_SEL 0x20 +#define MC_BIST_12KB_MASK 0x30 +#define MC_BIST_512KB_SEL 0x08 +#define MC_BIST_512KB_MASK 0x0C +#define MC_BIST_BUSY_BIT_R 0x02 +#define MC_BIST_MC_RES_ONE_SH_W 0x02 +#define MC_BIST_LAUNCH 0x01 + + +typedef enum { + BANK_DSP, BANK_SENSOR, BANK_MAX +} ov2640_bank_t; + +/* Sensor register bank FF=0x01*/ +#define GAIN 0x00 +#define COM1 0x03 +#define REG04 0x04 +#define REG08 0x08 +#define COM2 0x09 +#define REG_PID 0x0A +#define REG_VER 0x0B +#define COM3 0x0C +#define COM4 0x0D +#define AEC 0x10 +#define CLKRC 0x11 +#define COM7 0x12 +#define COM8 0x13 +#define COM9 0x14 /* AGC gain ceiling */ +#define COM10 0x15 +#define HSTART 0x17 +#define HSTOP 0x18 +#define VSTART 0x19 +#define VSTOP 0x1A +#define REG_MIDH 0x1C +#define REG_MIDL 0x1D +#define AEW 0x24 +#define AEB 0x25 +#define VV 0x26 +#define REG2A 0x2A +#define FRARL 0x2B +#define ADDVSL 0x2D +#define ADDVSH 0x2E +#define YAVG 0x2F +#define HSDY 0x30 +#define HEDY 0x31 +#define REG32 0x32 +#define ARCOM2 0x34 +#define REG45 0x45 +#define FLL 0x46 +#define FLH 0x47 +#define COM19 0x48 +#define ZOOMS 0x49 +#define COM22 0x4B +#define COM25 0x4E +#define BD50 0x4F +#define BD60 0x50 +#define REG5D 0x5D +#define REG5E 0x5E +#define REG5F 0x5F +#define REG60 0x60 +#define HISTO_LOW 0x61 +#define HISTO_HIGH 0x62 + +#define REG04_DEFAULT 0x28 +#define REG04_HFLIP_IMG 0x80 +#define REG04_VFLIP_IMG 0x40 +#define REG04_VREF_EN 0x10 +#define REG04_HREF_EN 0x08 +#define REG04_SET(x) (REG04_DEFAULT|x) + +#define COM2_STDBY 0x10 +#define COM2_OUT_DRIVE_1x 0x00 +#define COM2_OUT_DRIVE_2x 0x01 +#define COM2_OUT_DRIVE_3x 0x02 +#define COM2_OUT_DRIVE_4x 0x03 + +#define COM3_DEFAULT 0x38 +#define COM3_BAND_50Hz 0x04 +#define COM3_BAND_60Hz 0x00 +#define COM3_BAND_AUTO 0x02 +#define COM3_BAND_SET(x) (COM3_DEFAULT|x) + +#define COM7_SRST 0x80 +#define COM7_RES_UXGA 0x00 /* UXGA */ +#define COM7_RES_SVGA 0x40 /* SVGA */ +#define COM7_RES_CIF 0x20 /* CIF */ +#define COM7_ZOOM_EN 0x04 /* Enable Zoom */ +#define COM7_COLOR_BAR 0x02 /* Enable Color Bar Test */ + +#define COM8_DEFAULT 0xC0 +#define COM8_BNDF_EN 0x20 /* Enable Banding filter */ +#define COM8_AGC_EN 0x04 /* AGC Auto/Manual control selection */ +#define COM8_AEC_EN 0x01 /* Auto/Manual Exposure control */ +#define COM8_SET(x) (COM8_DEFAULT|x) + +#define COM9_DEFAULT 0x08 +#define COM9_AGC_GAIN_2x 0x00 /* AGC: 2x */ +#define COM9_AGC_GAIN_4x 0x01 /* AGC: 4x */ +#define COM9_AGC_GAIN_8x 0x02 /* AGC: 8x */ +#define COM9_AGC_GAIN_16x 0x03 /* AGC: 16x */ +#define COM9_AGC_GAIN_32x 0x04 /* AGC: 32x */ +#define COM9_AGC_GAIN_64x 0x05 /* AGC: 64x */ +#define COM9_AGC_GAIN_128x 0x06 /* AGC: 128x */ +#define COM9_AGC_SET(x) (COM9_DEFAULT|(x<<5)) + +#define COM10_HREF_EN 0x80 /* HSYNC changes to HREF */ +#define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ +#define COM10_PCLK_FREE 0x20 /* PCLK output option: free running PCLK */ +#define COM10_PCLK_EDGE 0x10 /* Data is updated at the rising edge of PCLK */ +#define COM10_HREF_NEG 0x08 /* HREF negative */ +#define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ +#define COM10_HSYNC_NEG 0x01 /* HSYNC negative */ + +#define CTRL1_AWB 0x08 /* Enable AWB */ + +#define VV_AGC_TH_SET(h,l) ((h<<4)|(l&0x0F)) + +#define REG32_UXGA 0x36 +#define REG32_SVGA 0x09 +#define REG32_CIF 0x89 + +#define CLKRC_2X 0x80 +#define CLKRC_2X_UXGA (0x01 | CLKRC_2X) +#define CLKRC_2X_SVGA CLKRC_2X +#define CLKRC_2X_CIF CLKRC_2X + +#endif //__REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h new file mode 100644 index 000000000..f151f0a42 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h @@ -0,0 +1,485 @@ +// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +#ifndef _OV2640_SETTINGS_H_ +#define _OV2640_SETTINGS_H_ + +#include +#include +#include "esp_attr.h" +#include "ov2640_regs.h" + +typedef enum { + OV2640_MODE_UXGA, OV2640_MODE_SVGA, OV2640_MODE_CIF, OV2640_MODE_MAX +} ov2640_sensor_mode_t; + +typedef struct { + union { + struct { + uint8_t pclk_div:7; + uint8_t pclk_auto:1; + }; + uint8_t pclk; + }; + union { + struct { + uint8_t clk_div:6; + uint8_t reserved:1; + uint8_t clk_2x:1; + }; + uint8_t clk; + }; +} ov2640_clk_t; + +typedef struct { + uint16_t offset_x; + uint16_t offset_y; + uint16_t max_x; + uint16_t max_y; +} ov2640_ratio_settings_t; + +static const DRAM_ATTR ov2640_ratio_settings_t ratio_table[] = { + // ox, oy, mx, my + { 0, 0, 1600, 1200 }, //4x3 + { 8, 72, 1584, 1056 }, //3x2 + { 0, 100, 1600, 1000 }, //16x10 + { 0, 120, 1600, 960 }, //5x3 + { 0, 150, 1600, 900 }, //16x9 + { 2, 258, 1596, 684 }, //21x9 + { 50, 0, 1500, 1200 }, //5x4 + { 200, 0, 1200, 1200 }, //1x1 + { 462, 0, 676, 1200 } //9x16 +}; + +// 30fps@24MHz +const DRAM_ATTR uint8_t ov2640_settings_cif[][2] = { + {BANK_SEL, BANK_DSP}, + {0x2c, 0xff}, + {0x2e, 0xdf}, + {BANK_SEL, BANK_SENSOR}, + {0x3c, 0x32}, + {CLKRC, 0x01}, + {COM2, COM2_OUT_DRIVE_3x}, + {REG04, REG04_DEFAULT}, + {COM8, COM8_DEFAULT | COM8_BNDF_EN | COM8_AGC_EN | COM8_AEC_EN}, + {COM9, COM9_AGC_SET(COM9_AGC_GAIN_8x)}, + {0x2c, 0x0c}, + {0x33, 0x78}, + {0x3a, 0x33}, + {0x3b, 0xfB}, + {0x3e, 0x00}, + {0x43, 0x11}, + {0x16, 0x10}, + {0x39, 0x92}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {ARCOM2, 0xc0}, + {0x06, 0x88}, + {0x07, 0xc0}, + {COM4, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {0x4a, 0x81}, + {0x21, 0x99}, + {AEW, 0x40}, + {AEB, 0x38}, + {VV, VV_AGC_TH_SET(8,2)}, + {0x5c, 0x00}, + {0x63, 0x00}, + {HISTO_LOW, 0x70}, + {HISTO_HIGH, 0x80}, + {0x7c, 0x05}, + {0x20, 0x80}, + {0x28, 0x30}, + {0x6c, 0x00}, + {0x6d, 0x80}, + {0x6e, 0x00}, + {0x70, 0x02}, + {0x71, 0x94}, + {0x73, 0xc1}, + {0x3d, 0x34}, + {0x5a, 0x57}, + {BD50, 0xbb}, + {BD60, 0x9c}, + {COM7, COM7_RES_CIF}, + {HSTART, 0x11}, + {HSTOP, 0x43}, + {VSTART, 0x00}, + {VSTOP, 0x25}, + {REG32, 0x89}, + {0x37, 0xc0}, + {BD50, 0xca}, + {BD60, 0xa8}, + {0x6d, 0x00}, + {0x3d, 0x38}, + {BANK_SEL, BANK_DSP}, + {0xe5, 0x7f}, + {MC_BIST, MC_BIST_RESET | MC_BIST_BOOT_ROM_SEL}, + {0x41, 0x24}, + {RESET, RESET_JPEG | RESET_DVP}, + {0x76, 0xff}, + {0x33, 0xa0}, + {0x42, 0x20}, + {0x43, 0x18}, + {0x4c, 0x00}, + {CTRL3, CTRL3_WPC_EN | 0x10 }, + {0x88, 0x3f}, + {0xd7, 0x03}, + {0xd9, 0x10}, + {R_DVP_SP, R_DVP_SP_AUTO_MODE | 0x02}, + {0xc8, 0x08}, + {0xc9, 0x80}, + {BPADDR, 0x00}, + {BPDATA, 0x00}, + {BPADDR, 0x03}, + {BPDATA, 0x48}, + {BPDATA, 0x48}, + {BPADDR, 0x08}, + {BPDATA, 0x20}, + {BPDATA, 0x10}, + {BPDATA, 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}, + {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}, + {CTRL1, 0xfd}, + {0x7f, 0x00}, + {0xe5, 0x1f}, + {0xe1, 0x67}, + {0xdd, 0x7f}, + {IMAGE_MODE, 0x00}, + {RESET, 0x00}, + {R_BYPASS, R_BYPASS_DSP_EN}, + {0, 0} +}; + +const DRAM_ATTR uint8_t ov2640_settings_to_cif[][2] = { + {BANK_SEL, BANK_SENSOR}, + {COM7, COM7_RES_CIF}, + + //Set the sensor output window + {COM1, 0x0A}, + {REG32, REG32_CIF}, + {HSTART, 0x11}, + {HSTOP, 0x43}, + {VSTART, 0x00}, + {VSTOP, 0x25}, + + //{CLKRC, 0x00}, + {BD50, 0xca}, + {BD60, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x3d, 0x38}, + {0x39, 0x92}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {ARCOM2, 0xc0}, + {0x06, 0x88}, + {0x07, 0xc0}, + {COM4, 0x87}, + {0x0e, 0x41}, + {0x4c, 0x00}, + {BANK_SEL, BANK_DSP}, + {RESET, RESET_DVP}, + + //Set the sensor resolution (UXGA, SVGA, CIF) + {HSIZE8, 0x32}, + {VSIZE8, 0x25}, + {SIZEL, 0x00}, + + //Set the image window size >= output size + {HSIZE, 0x64}, + {VSIZE, 0x4a}, + {XOFFL, 0x00}, + {YOFFL, 0x00}, + {VHYX, 0x00}, + {TEST, 0x00}, + + {CTRL2, CTRL2_DCW_EN | 0x1D}, + {CTRLI, CTRLI_LP_DP | 0x00}, + //{R_DVP_SP, 0x08}, + {0, 0} +}; + +const DRAM_ATTR uint8_t ov2640_settings_to_svga[][2] = { + {BANK_SEL, BANK_SENSOR}, + {COM7, COM7_RES_SVGA}, + + //Set the sensor output window + {COM1, 0x0A}, + {REG32, REG32_SVGA}, + {HSTART, 0x11}, + {HSTOP, 0x43}, + {VSTART, 0x00}, + {VSTOP, 0x4b}, + + //{CLKRC, 0x00}, + {0x37, 0xc0}, + {BD50, 0xca}, + {BD60, 0xa8}, + {0x5a, 0x23}, + {0x6d, 0x00}, + {0x3d, 0x38}, + {0x39, 0x92}, + {0x35, 0xda}, + {0x22, 0x1a}, + {0x37, 0xc3}, + {0x23, 0x00}, + {ARCOM2, 0xc0}, + {0x06, 0x88}, + {0x07, 0xc0}, + {COM4, 0x87}, + {0x0e, 0x41}, + {0x42, 0x03}, + {0x4c, 0x00}, + {BANK_SEL, BANK_DSP}, + {RESET, RESET_DVP}, + + //Set the sensor resolution (UXGA, SVGA, CIF) + {HSIZE8, 0x64}, + {VSIZE8, 0x4B}, + {SIZEL, 0x00}, + + //Set the image window size >= output size + {HSIZE, 0xC8}, + {VSIZE, 0x96}, + {XOFFL, 0x00}, + {YOFFL, 0x00}, + {VHYX, 0x00}, + {TEST, 0x00}, + + {CTRL2, CTRL2_DCW_EN | 0x1D}, + {CTRLI, CTRLI_LP_DP | 0x00}, + //{R_DVP_SP, 0x08}, + {0, 0} +}; + +const DRAM_ATTR uint8_t ov2640_settings_to_uxga[][2] = { + {BANK_SEL, BANK_SENSOR}, + {COM7, COM7_RES_UXGA}, + + //Set the sensor output window + {COM1, 0x0F}, + {REG32, REG32_UXGA}, + {HSTART, 0x11}, + {HSTOP, 0x75}, + {VSTART, 0x01}, + {VSTOP, 0x97}, + + //{CLKRC, 0x00}, + {0x3d, 0x34}, + {BD50, 0xbb}, + {BD60, 0x9c}, + {0x5a, 0x57}, + {0x6d, 0x80}, + {0x39, 0x82}, + {0x23, 0x00}, + {0x07, 0xc0}, + {0x4c, 0x00}, + {0x35, 0x88}, + {0x22, 0x0a}, + {0x37, 0x40}, + {ARCOM2, 0xa0}, + {0x06, 0x02}, + {COM4, 0xb7}, + {0x0e, 0x01}, + {0x42, 0x83}, + {BANK_SEL, BANK_DSP}, + {RESET, RESET_DVP}, + + //Set the sensor resolution (UXGA, SVGA, CIF) + {HSIZE8, 0xc8}, + {VSIZE8, 0x96}, + {SIZEL, 0x00}, + + //Set the image window size >= output size + {HSIZE, 0x90}, + {VSIZE, 0x2c}, + {XOFFL, 0x00}, + {YOFFL, 0x00}, + {VHYX, 0x88}, + {TEST, 0x00}, + + {CTRL2, CTRL2_DCW_EN | 0x1d}, + {CTRLI, 0x00}, + //{R_DVP_SP, 0x06}, + {0, 0} +}; + +const DRAM_ATTR uint8_t ov2640_settings_jpeg3[][2] = { + {BANK_SEL, BANK_DSP}, + {RESET, RESET_JPEG | RESET_DVP}, + {IMAGE_MODE, IMAGE_MODE_JPEG_EN | IMAGE_MODE_HREF_VSYNC}, + {0xD7, 0x03}, + {0xE1, 0x77}, + {0xE5, 0x1F}, + {0xD9, 0x10}, + {0xDF, 0x80}, + {0x33, 0x80}, + {0x3C, 0x10}, + {0xEB, 0x30}, + {0xDD, 0x7F}, + {RESET, 0x00}, + {0, 0} +}; + +static const uint8_t ov2640_settings_yuv422[][2] = { + {BANK_SEL, BANK_DSP}, + {RESET, RESET_DVP}, + {IMAGE_MODE, IMAGE_MODE_YUV422}, + {0xD7, 0x01}, + {0xE1, 0x67}, + {RESET, 0x00}, + {0, 0}, +}; + +static const uint8_t ov2640_settings_rgb565[][2] = { + {BANK_SEL, BANK_DSP}, + {RESET, RESET_DVP}, + {IMAGE_MODE, IMAGE_MODE_RGB565}, + {0xD7, 0x03}, + {0xE1, 0x77}, + {RESET, 0x00}, + {0, 0}, +}; + +#define NUM_BRIGHTNESS_LEVELS (5) +static const uint8_t brightness_regs[NUM_BRIGHTNESS_LEVELS + 1][5] = { + {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA }, + {0x00, 0x04, 0x09, 0x00, 0x00 }, /* -2 */ + {0x00, 0x04, 0x09, 0x10, 0x00 }, /* -1 */ + {0x00, 0x04, 0x09, 0x20, 0x00 }, /* 0 */ + {0x00, 0x04, 0x09, 0x30, 0x00 }, /* +1 */ + {0x00, 0x04, 0x09, 0x40, 0x00 }, /* +2 */ +}; + +#define NUM_CONTRAST_LEVELS (5) +static const uint8_t contrast_regs[NUM_CONTRAST_LEVELS + 1][7] = { + {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA, BPDATA, BPDATA }, + {0x00, 0x04, 0x07, 0x20, 0x18, 0x34, 0x06 }, /* -2 */ + {0x00, 0x04, 0x07, 0x20, 0x1c, 0x2a, 0x06 }, /* -1 */ + {0x00, 0x04, 0x07, 0x20, 0x20, 0x20, 0x06 }, /* 0 */ + {0x00, 0x04, 0x07, 0x20, 0x24, 0x16, 0x06 }, /* +1 */ + {0x00, 0x04, 0x07, 0x20, 0x28, 0x0c, 0x06 }, /* +2 */ +}; + +#define NUM_SATURATION_LEVELS (5) +static const uint8_t saturation_regs[NUM_SATURATION_LEVELS + 1][5] = { + {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA }, + {0x00, 0x02, 0x03, 0x28, 0x28 }, /* -2 */ + {0x00, 0x02, 0x03, 0x38, 0x38 }, /* -1 */ + {0x00, 0x02, 0x03, 0x48, 0x48 }, /* 0 */ + {0x00, 0x02, 0x03, 0x58, 0x58 }, /* +1 */ + {0x00, 0x02, 0x03, 0x68, 0x68 }, /* +2 */ +}; + +#define NUM_SPECIAL_EFFECTS (7) +static const uint8_t special_effects_regs[NUM_SPECIAL_EFFECTS + 1][5] = { + {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA }, + {0x00, 0X00, 0x05, 0X80, 0X80 }, /* no effect */ + {0x00, 0X40, 0x05, 0X80, 0X80 }, /* negative */ + {0x00, 0X18, 0x05, 0X80, 0X80 }, /* black and white */ + {0x00, 0X18, 0x05, 0X40, 0XC0 }, /* reddish */ + {0x00, 0X18, 0x05, 0X40, 0X40 }, /* greenish */ + {0x00, 0X18, 0x05, 0XA0, 0X40 }, /* blue */ + {0x00, 0X18, 0x05, 0X40, 0XA6 }, /* retro */ +}; + +#define NUM_WB_MODES (4) +static const uint8_t wb_modes_regs[NUM_WB_MODES + 1][3] = { + {0XCC, 0XCD, 0XCE }, + {0x5E, 0X41, 0x54 }, /* sunny */ + {0x65, 0X41, 0x4F }, /* cloudy */ + {0x52, 0X41, 0x66 }, /* office */ + {0x42, 0X3F, 0x71 }, /* home */ +}; + +#define NUM_AE_LEVELS (5) +static const uint8_t ae_levels_regs[NUM_AE_LEVELS + 1][3] = { + { AEW, AEB, VV }, + {0x20, 0X18, 0x60 }, + {0x34, 0X1C, 0x00 }, + {0x3E, 0X38, 0x81 }, + {0x48, 0X40, 0x81 }, + {0x58, 0X50, 0x92 }, +}; + +const uint8_t agc_gain_tbl[31] = { + 0x00, 0x10, 0x18, 0x30, 0x34, 0x38, 0x3C, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E, 0xF0, + 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF +}; + +#endif /* _OV2640_SETTINGS_H_ */ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h new file mode 100644 index 000000000..341d68861 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h @@ -0,0 +1,34 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV3660 driver. + * + */ +#ifndef __OV3660_H__ +#define __OV3660_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int ov3660_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int ov3660_init(sensor_t *sensor); + +#endif // __OV3660_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h new file mode 100644 index 000000000..b5cf30a5b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h @@ -0,0 +1,211 @@ +/* + * OV3660 register definitions. + */ +#ifndef __OV3660_REG_REGS_H__ +#define __OV3660_REG_REGS_H__ + +/* system control registers */ +#define SYSTEM_CTROL0 0x3008 // Bit[7]: Software reset + // Bit[6]: Software power down + // Bit[5]: Reserved + // Bit[4]: SRB clock SYNC enable + // Bit[3]: Isolation suspend select + // Bit[2:0]: Not used + +/* output format control registers */ +#define FORMAT_CTRL 0x501F // Format select + // Bit[2:0]: + // 000: YUV422 + // 001: RGB + // 010: Dither + // 011: RAW after DPC + // 101: RAW after CIP + +/* format control registers */ +#define FORMAT_CTRL00 0x4300 + +/* frame control registers */ +#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode + // Bit[7:4]: Not used + // Bit[3:0]: Frame ON number +#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode + // Bit[7:4]: Not used + // BIT[3:0]: Frame OFF number + +/* ISP top control registers */ +#define PRE_ISP_TEST_SETTING_1 0x503D // Bit[7]: Test enable + // 0: Test disable + // 1: Color bar enable + // Bit[6]: Rolling + // Bit[5]: Transparent + // Bit[4]: Square black and white + // Bit[3:2]: Color bar style + // 00: Standard 8 color bar + // 01: Gradual change at vertical mode 1 + // 10: Gradual change at horizontal + // 11: Gradual change at vertical mode 2 + // Bit[1:0]: Test select + // 00: Color bar + // 01: Random data + // 10: Square data + // 11: Black image + +//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW + +/* AEC/AGC control functions */ +#define AEC_PK_MANUAL 0x3503 // AEC Manual Mode Control + // Bit[7:6]: Reserved + // Bit[5]: Gain delay option + // Valid when 0x3503[4]=1’b0 + // 0: Delay one frame latch + // 1: One frame latch + // Bit[4:2]: Reserved + // Bit[1]: AGC manual + // 0: Auto enable + // 1: Manual enable + // Bit[0]: AEC manual + // 0: Auto enable + // 1: Manual enable + +//gain = {0x350A[1:0], 0x350B[7:0]} / 16 + +/* mirror and flip registers */ +#define TIMING_TC_REG20 0x3820 // Timing Control Register + // Bit[2:1]: Vertical flip enable + // 00: Normal + // 11: Vertical flip + // Bit[0]: Vertical binning enable +#define TIMING_TC_REG21 0x3821 // Timing Control Register + // Bit[5]: Compression Enable + // Bit[2:1]: Horizontal mirror enable + // 00: Normal + // 11: Horizontal mirror + // Bit[0]: Horizontal binning enable + +#define CLOCK_POL_CONTROL 0x4740// Bit[5]: PCLK polarity 0: active low + // 1: active high + // Bit[3]: Gate PCLK under VSYNC + // Bit[2]: Gate PCLK under HREF + // Bit[1]: HREF polarity + // 0: active low + // 1: active high + // Bit[0] VSYNC polarity + // 0: active low + // 1: active high +#define DRIVE_CAPABILITY 0x302c // Bit[7:6]: + // 00: 1x + // 01: 2x + // 10: 3x + // 11: 4x + + +#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8] +#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0] +#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8] +#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0] +#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8] +#define X_ADDR_END_L 0x3805 //Bit[7:0]: +#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8] +#define Y_ADDR_END_L 0x3807 //Bit[7:0]: +// Size after scaling +#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8] +#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]: +#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8] +#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]: +#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8] +#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]: +#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8] +#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]: +#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8] +#define X_OFFSET_L 0x3811 //Bit[7:0]: +#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8] +#define Y_OFFSET_L 0x3813 //Bit[7:0]: +#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment + //Bit[3:0]: Horizontal even subsample increment +#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment + //Bit[3:0]: Vertical even subsample increment +// Size before scaling +//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET)) +//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET)) + +#define ISP_CONTROL_01 0x5001 // Bit[5]: Scale enable + // 0: Disable + // 1: Enable + +#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW + // DCW scale times + // 000: DCW 1 time + // 001: DCW 2 times + // 010: DCW 4 times + // 100: DCW 8 times + // 101: DCW 16 times + // Others: DCW 16 times + // Bit[2:0]: VDIV RW + // DCW scale times + // 000: DCW 1 time + // 001: DCW 2 times + // 010: DCW 4 times + // 100: DCW 8 times + // 101: DCW 16 times + // Others: DCW 16 times + +#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits +#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits +#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits +#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits +#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset + +#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual +#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable + // 0: Auto + // 1: Manual by PCLK_RATIO + +#define VFIFO_X_SIZE_H 0x4602 +#define VFIFO_X_SIZE_L 0x4603 +#define VFIFO_Y_SIZE_H 0x4604 +#define VFIFO_Y_SIZE_L 0x4605 + +#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass +#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier +#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control + // Bit[3:0]: PLLS system divider +#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider + // 00: 1 + // 01: 1.5 + // 10: 2 + // 11: 3 + // Bit[2]: PLLS root-divider - 1 + // Bit[1:0]: PLLS seld5 + // 00: 1 + // 01: 1 + // 10: 2 + // 11: 2.5 + +#define COMPRESSION_CTRL00 0x4400 // +#define COMPRESSION_CTRL01 0x4401 // +#define COMPRESSION_CTRL02 0x4402 // +#define COMPRESSION_CTRL03 0x4403 // +#define COMPRESSION_CTRL04 0x4404 // +#define COMPRESSION_CTRL05 0x4405 // +#define COMPRESSION_CTRL06 0x4406 // +#define COMPRESSION_CTRL07 0x4407 // Bit[5:0]: QS +#define COMPRESSION_ISI_CTRL 0x4408 // +#define COMPRESSION_CTRL09 0x4409 // +#define COMPRESSION_CTRL0a 0x440a // +#define COMPRESSION_CTRL0b 0x440b // +#define COMPRESSION_CTRL0c 0x440c // +#define COMPRESSION_CTRL0d 0x440d // +#define COMPRESSION_CTRL0E 0x440e // + +/** + * @brief register value + */ +#define TEST_COLOR_BAR 0xC0 /* Enable Color Bar roling Test */ + +#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */ +#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */ + +#define TIMING_TC_REG20_VFLIP 0x06 /* Vertical flip enable */ +#define TIMING_TC_REG21_HMIRROR 0x06 /* Horizontal mirror enable */ + +#endif // __OV3660_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h new file mode 100644 index 000000000..97c4e03b6 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h @@ -0,0 +1,318 @@ +#ifndef _OV3660_SETTINGS_H_ +#define _OV3660_SETTINGS_H_ + +#include +#include +#include "esp_attr.h" +#include "ov3660_regs.h" + +static const ratio_settings_t ratio_table[] = { + // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty + { 2048, 1536, 0, 0, 2079, 1547, 16, 6, 2300, 1564 }, //4x3 + { 1920, 1280, 64, 128, 2015, 1419, 16, 6, 2172, 1436 }, //3x2 + { 2048, 1280, 0, 128, 2079, 1419, 16, 6, 2300, 1436 }, //16x10 + { 1920, 1152, 64, 192, 2015, 1355, 16, 6, 2172, 1372 }, //5x3 + { 1920, 1080, 64, 242, 2015, 1333, 16, 6, 2172, 1322 }, //16x9 + { 2048, 880, 0, 328, 2079, 1219, 16, 6, 2300, 1236 }, //21x9 + { 1920, 1536, 64, 0, 2015, 1547, 16, 6, 2172, 1564 }, //5x4 + { 1536, 1536, 256, 0, 1823, 1547, 16, 6, 2044, 1564 }, //1x1 + { 864, 1536, 592, 0, 1487, 1547, 16, 6, 2044, 1564 } //9x16 +}; + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0x0000 + +static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { + {SYSTEM_CTROL0, 0x82}, // software reset + {REG_DLY, 10}, // delay 10ms + + {0x3103, 0x13}, + {SYSTEM_CTROL0, 0x42}, + {0x3017, 0xff}, + {0x3018, 0xff}, + {DRIVE_CAPABILITY, 0xc3}, + {CLOCK_POL_CONTROL, 0x21}, + + {0x3611, 0x01}, + {0x3612, 0x2d}, + + {0x3032, 0x00}, + {0x3614, 0x80}, + {0x3618, 0x00}, + {0x3619, 0x75}, + {0x3622, 0x80}, + {0x3623, 0x00}, + {0x3624, 0x03}, + {0x3630, 0x52}, + {0x3632, 0x07}, + {0x3633, 0xd2}, + {0x3704, 0x80}, + {0x3708, 0x66}, + {0x3709, 0x12}, + {0x370b, 0x12}, + {0x3717, 0x00}, + {0x371b, 0x60}, + {0x371c, 0x00}, + {0x3901, 0x13}, + + {0x3600, 0x08}, + {0x3620, 0x43}, + {0x3702, 0x20}, + {0x3739, 0x48}, + {0x3730, 0x20}, + {0x370c, 0x0c}, + + {0x3a18, 0x00}, + {0x3a19, 0xf8}, + + {0x3000, 0x10}, + {0x3004, 0xef}, + + {0x6700, 0x05}, + {0x6701, 0x19}, + {0x6702, 0xfd}, + {0x6703, 0xd1}, + {0x6704, 0xff}, + {0x6705, 0xff}, + + {0x3c01, 0x80}, + {0x3c00, 0x04}, + {0x3a08, 0x00}, {0x3a09, 0x62}, //50Hz Band Width Step (10bit) + {0x3a0e, 0x08}, //50Hz Max Bands in One Frame (6 bit) + {0x3a0a, 0x00}, {0x3a0b, 0x52}, //60Hz Band Width Step (10bit) + {0x3a0d, 0x09}, //60Hz Max Bands in One Frame (6 bit) + + {0x3a00, 0x3a},//night mode off + {0x3a14, 0x09}, + {0x3a15, 0x30}, + {0x3a02, 0x09}, + {0x3a03, 0x30}, + + {COMPRESSION_CTRL0E, 0x08}, + {0x4520, 0x0b}, + {0x460b, 0x37}, + {0x4713, 0x02}, + {0x471c, 0xd0}, + {0x5086, 0x00}, + + {0x5002, 0x00}, + {0x501f, 0x00}, + + {SYSTEM_CTROL0, 0x02}, + + {0x5180, 0xff}, + {0x5181, 0xf2}, + {0x5182, 0x00}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x16}, + {0x5187, 0x16}, + {0x5188, 0x16}, + {0x5189, 0x68}, + {0x518a, 0x60}, + {0x518b, 0xe0}, + {0x518c, 0xb2}, + {0x518d, 0x42}, + {0x518e, 0x35}, + {0x518f, 0x56}, + {0x5190, 0x56}, + {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}, + + {0x5381, 0x1d}, + {0x5382, 0x60}, + {0x5383, 0x03}, + {0x5384, 0x0c}, + {0x5385, 0x78}, + {0x5386, 0x84}, + {0x5387, 0x7d}, + {0x5388, 0x6b}, + {0x5389, 0x12}, + {0x538a, 0x01}, + {0x538b, 0x98}, + + {0x5480, 0x01}, +// {0x5481, 0x05}, +// {0x5482, 0x09}, +// {0x5483, 0x10}, +// {0x5484, 0x3a}, +// {0x5485, 0x4c}, +// {0x5486, 0x5a}, +// {0x5487, 0x68}, +// {0x5488, 0x74}, +// {0x5489, 0x80}, +// {0x548a, 0x8e}, +// {0x548b, 0xa4}, +// {0x548c, 0xb4}, +// {0x548d, 0xc8}, +// {0x548e, 0xde}, +// {0x548f, 0xf0}, +// {0x5490, 0x15}, + + {0x5000, 0xa7}, + {0x5800, 0x0C}, + {0x5801, 0x09}, + {0x5802, 0x0C}, + {0x5803, 0x0C}, + {0x5804, 0x0D}, + {0x5805, 0x17}, + {0x5806, 0x06}, + {0x5807, 0x05}, + {0x5808, 0x04}, + {0x5809, 0x06}, + {0x580a, 0x09}, + {0x580b, 0x0E}, + {0x580c, 0x05}, + {0x580d, 0x01}, + {0x580e, 0x01}, + {0x580f, 0x01}, + {0x5810, 0x05}, + {0x5811, 0x0D}, + {0x5812, 0x05}, + {0x5813, 0x01}, + {0x5814, 0x01}, + {0x5815, 0x01}, + {0x5816, 0x05}, + {0x5817, 0x0D}, + {0x5818, 0x08}, + {0x5819, 0x06}, + {0x581a, 0x05}, + {0x581b, 0x07}, + {0x581c, 0x0B}, + {0x581d, 0x0D}, + {0x581e, 0x12}, + {0x581f, 0x0D}, + {0x5820, 0x0E}, + {0x5821, 0x10}, + {0x5822, 0x10}, + {0x5823, 0x1E}, + {0x5824, 0x53}, + {0x5825, 0x15}, + {0x5826, 0x05}, + {0x5827, 0x14}, + {0x5828, 0x54}, + {0x5829, 0x25}, + {0x582a, 0x33}, + {0x582b, 0x33}, + {0x582c, 0x34}, + {0x582d, 0x16}, + {0x582e, 0x24}, + {0x582f, 0x41}, + {0x5830, 0x50}, + {0x5831, 0x42}, + {0x5832, 0x15}, + {0x5833, 0x25}, + {0x5834, 0x34}, + {0x5835, 0x33}, + {0x5836, 0x24}, + {0x5837, 0x26}, + {0x5838, 0x54}, + {0x5839, 0x25}, + {0x583a, 0x15}, + {0x583b, 0x25}, + {0x583c, 0x53}, + {0x583d, 0xCF}, + + {0x3a0f, 0x30}, + {0x3a10, 0x28}, + {0x3a1b, 0x30}, + {0x3a1e, 0x28}, + {0x3a11, 0x60}, + {0x3a1f, 0x14}, + + {0x5302, 0x28}, + {0x5303, 0x20}, + + {0x5306, 0x1c}, //de-noise offset 1 + {0x5307, 0x28}, //de-noise offset 2 + + {0x4002, 0xc5}, + {0x4003, 0x81}, + {0x4005, 0x12}, + + {0x5688, 0x11}, + {0x5689, 0x11}, + {0x568a, 0x11}, + {0x568b, 0x11}, + {0x568c, 0x11}, + {0x568d, 0x11}, + {0x568e, 0x11}, + {0x568f, 0x11}, + + {0x5580, 0x06}, + {0x5588, 0x00}, + {0x5583, 0x40}, + {0x5584, 0x2c}, + + {ISP_CONTROL_01, 0x83}, // turn color matrix, awb and SDE + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_jpeg[][2] = { + {FORMAT_CTRL, 0x00}, // YUV422 + {FORMAT_CTRL00, 0x30}, // YUYV + {0x3002, 0x00},//0x1c to 0x00 !!! + {0x3006, 0xff},//0xc3 to 0xff !!! + {0x471c, 0x50},//0xd0 to 0x50 !!! + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_raw[][2] = { + {FORMAT_CTRL00, 0x00}, // RAW + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint16_t sensor_fmt_grayscale[][2] = { + {FORMAT_CTRL, 0x00}, // YUV422 + {FORMAT_CTRL00, 0x10}, // Y8 + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint16_t sensor_fmt_yuv422[][2] = { + {FORMAT_CTRL, 0x00}, // YUV422 + {FORMAT_CTRL00, 0x30}, // YUYV + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint16_t sensor_fmt_rgb565[][2] = { + {FORMAT_CTRL, 0x01}, // RGB + {FORMAT_CTRL00, 0x61}, // RGB565 (BGR) + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint8_t sensor_saturation_levels[9][11] = { + {0x1d, 0x60, 0x03, 0x07, 0x48, 0x4f, 0x4b, 0x40, 0x0b, 0x01, 0x98},//-4 + {0x1d, 0x60, 0x03, 0x08, 0x54, 0x5c, 0x58, 0x4b, 0x0d, 0x01, 0x98},//-3 + {0x1d, 0x60, 0x03, 0x0a, 0x60, 0x6a, 0x64, 0x56, 0x0e, 0x01, 0x98},//-2 + {0x1d, 0x60, 0x03, 0x0b, 0x6c, 0x77, 0x70, 0x60, 0x10, 0x01, 0x98},//-1 + {0x1d, 0x60, 0x03, 0x0c, 0x78, 0x84, 0x7d, 0x6b, 0x12, 0x01, 0x98},//0 + {0x1d, 0x60, 0x03, 0x0d, 0x84, 0x91, 0x8a, 0x76, 0x14, 0x01, 0x98},//+1 + {0x1d, 0x60, 0x03, 0x0e, 0x90, 0x9e, 0x96, 0x80, 0x16, 0x01, 0x98},//+2 + {0x1d, 0x60, 0x03, 0x10, 0x9c, 0xac, 0xa2, 0x8b, 0x17, 0x01, 0x98},//+3 + {0x1d, 0x60, 0x03, 0x11, 0xa8, 0xb9, 0xaf, 0x96, 0x19, 0x01, 0x98},//+4 +}; + +static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = { + {0x06, 0x40, 0x2c, 0x08},//Normal + {0x46, 0x40, 0x28, 0x08},//Negative + {0x1e, 0x80, 0x80, 0x08},//Grayscale + {0x1e, 0x80, 0xc0, 0x08},//Red Tint + {0x1e, 0x60, 0x60, 0x08},//Green Tint + {0x1e, 0xa0, 0x40, 0x08},//Blue Tint + {0x1e, 0x40, 0xa0, 0x08},//Sepia +}; + +#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h new file mode 100644 index 000000000..120ae7205 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h @@ -0,0 +1,27 @@ + +#ifndef __OV5640_H__ +#define __OV5640_H__ + +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int ov5640_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int ov5640_init(sensor_t *sensor); + +#endif // __OV5640_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h new file mode 100644 index 000000000..c28d80f5b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h @@ -0,0 +1,213 @@ +/* + * OV5640 register definitions. + */ +#ifndef __OV5640_REG_REGS_H__ +#define __OV5640_REG_REGS_H__ + +/* system control registers */ +#define SYSTEM_CTROL0 0x3008 // Bit[7]: Software reset + // Bit[6]: Software power down + // Bit[5]: Reserved + // Bit[4]: SRB clock SYNC enable + // Bit[3]: Isolation suspend select + // Bit[2:0]: Not used + +#define DRIVE_CAPABILITY 0x302c // Bit[7:6]: + // 00: 1x + // 01: 2x + // 10: 3x + // 11: 4x + +#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass +#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier +#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control + // Bit[3:0]: PLLS system divider +#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider + // 00: 1 + // 01: 1.5 + // 10: 2 + // 11: 3 + // Bit[2]: PLLS root-divider - 1 + // Bit[1:0]: PLLS seld5 + // 00: 1 + // 01: 1 + // 10: 2 + // 11: 2.5 + +/* AEC/AGC control functions */ +#define AEC_PK_MANUAL 0x3503 // AEC Manual Mode Control + // Bit[7:6]: Reserved + // Bit[5]: Gain delay option + // Valid when 0x3503[4]=1’b0 + // 0: Delay one frame latch + // 1: One frame latch + // Bit[4:2]: Reserved + // Bit[1]: AGC manual + // 0: Auto enable + // 1: Manual enable + // Bit[0]: AEC manual + // 0: Auto enable + // 1: Manual enable + +//gain = {0x350A[1:0], 0x350B[7:0]} / 16 + + +#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8] +#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0] +#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8] +#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0] +#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8] +#define X_ADDR_END_L 0x3805 //Bit[7:0]: +#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8] +#define Y_ADDR_END_L 0x3807 //Bit[7:0]: +// Size after scaling +#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8] +#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]: +#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8] +#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]: +#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8] +#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]: +#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8] +#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]: +#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8] +#define X_OFFSET_L 0x3811 //Bit[7:0]: +#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8] +#define Y_OFFSET_L 0x3813 //Bit[7:0]: +#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment + //Bit[3:0]: Horizontal even subsample increment +#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment + //Bit[3:0]: Vertical even subsample increment +// Size before scaling +//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET)) +//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET)) + +/* mirror and flip registers */ +#define TIMING_TC_REG20 0x3820 // Timing Control Register + // Bit[2:1]: Vertical flip enable + // 00: Normal + // 11: Vertical flip + // Bit[0]: Vertical binning enable +#define TIMING_TC_REG21 0x3821 // Timing Control Register + // Bit[5]: Compression Enable + // Bit[2:1]: Horizontal mirror enable + // 00: Normal + // 11: Horizontal mirror + // Bit[0]: Horizontal binning enable + +#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual + +/* frame control registers */ +#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode + // Bit[7:4]: Not used + // Bit[3:0]: Frame ON number +#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode + // Bit[7:4]: Not used + // BIT[3:0]: Frame OFF number + +/* format control registers */ +#define FORMAT_CTRL00 0x4300 + +#define CLOCK_POL_CONTROL 0x4740// Bit[5]: PCLK polarity 0: active low + // 1: active high + // Bit[3]: Gate PCLK under VSYNC + // Bit[2]: Gate PCLK under HREF + // Bit[1]: HREF polarity + // 0: active low + // 1: active high + // Bit[0] VSYNC polarity + // 0: active low + // 1: active high + +#define ISP_CONTROL_01 0x5001 // Bit[5]: Scale enable + // 0: Disable + // 1: Enable + +/* output format control registers */ +#define FORMAT_CTRL 0x501F // Format select + // Bit[2:0]: + // 000: YUV422 + // 001: RGB + // 010: Dither + // 011: RAW after DPC + // 101: RAW after CIP + +/* ISP top control registers */ +#define PRE_ISP_TEST_SETTING_1 0x503D // Bit[7]: Test enable + // 0: Test disable + // 1: Color bar enable + // Bit[6]: Rolling + // Bit[5]: Transparent + // Bit[4]: Square black and white + // Bit[3:2]: Color bar style + // 00: Standard 8 color bar + // 01: Gradual change at vertical mode 1 + // 10: Gradual change at horizontal + // 11: Gradual change at vertical mode 2 + // Bit[1:0]: Test select + // 00: Color bar + // 01: Random data + // 10: Square data + // 11: Black image + +//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW + +#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW + // DCW scale times + // 000: DCW 1 time + // 001: DCW 2 times + // 010: DCW 4 times + // 100: DCW 8 times + // 101: DCW 16 times + // Others: DCW 16 times + // Bit[2:0]: VDIV RW + // DCW scale times + // 000: DCW 1 time + // 001: DCW 2 times + // 010: DCW 4 times + // 100: DCW 8 times + // 101: DCW 16 times + // Others: DCW 16 times + +#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits +#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits +#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits +#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits +#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset + +#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable + // 0: Auto + // 1: Manual by PCLK_RATIO + +#define VFIFO_X_SIZE_H 0x4602 +#define VFIFO_X_SIZE_L 0x4603 +#define VFIFO_Y_SIZE_H 0x4604 +#define VFIFO_Y_SIZE_L 0x4605 + +#define COMPRESSION_CTRL00 0x4400 // +#define COMPRESSION_CTRL01 0x4401 // +#define COMPRESSION_CTRL02 0x4402 // +#define COMPRESSION_CTRL03 0x4403 // +#define COMPRESSION_CTRL04 0x4404 // +#define COMPRESSION_CTRL05 0x4405 // +#define COMPRESSION_CTRL06 0x4406 // +#define COMPRESSION_CTRL07 0x4407 // Bit[5:0]: QS +#define COMPRESSION_ISI_CTRL 0x4408 // +#define COMPRESSION_CTRL09 0x4409 // +#define COMPRESSION_CTRL0a 0x440a // +#define COMPRESSION_CTRL0b 0x440b // +#define COMPRESSION_CTRL0c 0x440c // +#define COMPRESSION_CTRL0d 0x440d // +#define COMPRESSION_CTRL0E 0x440e // + +/** + * @brief register value + */ +#define TEST_COLOR_BAR 0xC0 /* Enable Color Bar roling Test */ + +#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */ +#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */ + +#define TIMING_TC_REG20_VFLIP 0x06 /* Vertical flip enable */ +#define TIMING_TC_REG21_HMIRROR 0x06 /* Horizontal mirror enable */ + +#endif // __OV3660_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h new file mode 100644 index 000000000..fec7d679f --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h @@ -0,0 +1,334 @@ +#ifndef _OV5640_SETTINGS_H_ +#define _OV5640_SETTINGS_H_ + +#include +#include +#include "esp_attr.h" +#include "ov5640_regs.h" + +static const ratio_settings_t ratio_table[] = { + // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty + { 2560, 1920, 0, 0, 2623, 1951, 32, 16, 2844, 1968 }, //4x3 + { 2560, 1704, 0, 110, 2623, 1843, 32, 16, 2844, 1752 }, //3x2 + { 2560, 1600, 0, 160, 2623, 1791, 32, 16, 2844, 1648 }, //16x10 + { 2560, 1536, 0, 192, 2623, 1759, 32, 16, 2844, 1584 }, //5x3 + { 2560, 1440, 0, 240, 2623, 1711, 32, 16, 2844, 1488 }, //16x9 + { 2560, 1080, 0, 420, 2623, 1531, 32, 16, 2844, 1128 }, //21x9 + { 2400, 1920, 80, 0, 2543, 1951, 32, 16, 2684, 1968 }, //5x4 + { 1920, 1920, 320, 0, 2543, 1951, 32, 16, 2684, 1968 }, //1x1 + { 1088, 1920, 736, 0, 1887, 1951, 32, 16, 1884, 1968 } //9x16 +}; + +#define REG_DLY 0xffff +#define REGLIST_TAIL 0x0000 + +static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { + {SYSTEM_CTROL0, 0x82}, // software reset + {REG_DLY, 10}, // delay 10ms + {SYSTEM_CTROL0, 0x42}, // power down + + //enable pll + {0x3103, 0x13}, + + //io direction + {0x3017, 0xff}, + {0x3018, 0xff}, + + {DRIVE_CAPABILITY, 0xc3}, + {CLOCK_POL_CONTROL, 0x21}, + + {0x4713, 0x02},//jpg mode select + + {ISP_CONTROL_01, 0x83}, // turn color matrix, awb and SDE + + //sys reset + {0x3000, 0x00}, + {0x3002, 0x1c}, + + //clock enable + {0x3004, 0xff}, + {0x3006, 0xc3}, + + //isp control + {0x5000, 0xa7}, + {ISP_CONTROL_01, 0xa3},//+scaling? + {0x5003, 0x08},//special_effect + + //unknown + {0x370c, 0x02},//!!IMPORTANT + {0x3634, 0x40},//!!IMPORTANT + + //AEC/AGC + {0x3a02, 0x03}, + {0x3a03, 0xd8}, + {0x3a08, 0x01}, + {0x3a09, 0x27}, + {0x3a0a, 0x00}, + {0x3a0b, 0xf6}, + {0x3a0d, 0x04}, + {0x3a0e, 0x03}, + {0x3a0f, 0x30},//ae_level + {0x3a10, 0x28},//ae_level + {0x3a11, 0x60},//ae_level + {0x3a13, 0x43}, + {0x3a14, 0x03}, + {0x3a15, 0xd8}, + {0x3a18, 0x00},//gainceiling + {0x3a19, 0xf8},//gainceiling + {0x3a1b, 0x30},//ae_level + {0x3a1e, 0x26},//ae_level + {0x3a1f, 0x14},//ae_level + + //vcm debug + {0x3600, 0x08}, + {0x3601, 0x33}, + + //50/60Hz + {0x3c01, 0xa4}, + {0x3c04, 0x28}, + {0x3c05, 0x98}, + {0x3c06, 0x00}, + {0x3c07, 0x08}, + {0x3c08, 0x00}, + {0x3c09, 0x1c}, + {0x3c0a, 0x9c}, + {0x3c0b, 0x40}, + + {0x460c, 0x22},//disable jpeg footer + + //BLC + {0x4001, 0x02}, + {0x4004, 0x02}, + + //AWB + {0x5180, 0xff}, + {0x5181, 0xf2}, + {0x5182, 0x00}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x09}, + {0x5187, 0x09}, + {0x5188, 0x09}, + {0x5189, 0x75}, + {0x518a, 0x54}, + {0x518b, 0xe0}, + {0x518c, 0xb2}, + {0x518d, 0x42}, + {0x518e, 0x3d}, + {0x518f, 0x56}, + {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, 0x38}, + + //color matrix (Saturation) + {0x5381, 0x1e}, + {0x5382, 0x5b}, + {0x5383, 0x08}, + {0x5384, 0x0a}, + {0x5385, 0x7e}, + {0x5386, 0x88}, + {0x5387, 0x7c}, + {0x5388, 0x6c}, + {0x5389, 0x10}, + {0x538a, 0x01}, + {0x538b, 0x98}, + + //CIP control (Sharpness) + {0x5300, 0x10},//sharpness + {0x5301, 0x10},//sharpness + {0x5302, 0x18},//sharpness + {0x5303, 0x19},//sharpness + {0x5304, 0x10}, + {0x5305, 0x10}, + {0x5306, 0x08},//denoise + {0x5307, 0x16}, + {0x5308, 0x40}, + {0x5309, 0x10},//sharpness + {0x530a, 0x10},//sharpness + {0x530b, 0x04},//sharpness + {0x530c, 0x06},//sharpness + + //GAMMA + {0x5480, 0x01}, + {0x5481, 0x00}, + {0x5482, 0x1e}, + {0x5483, 0x3b}, + {0x5484, 0x58}, + {0x5485, 0x66}, + {0x5486, 0x71}, + {0x5487, 0x7d}, + {0x5488, 0x83}, + {0x5489, 0x8f}, + {0x548a, 0x98}, + {0x548b, 0xa6}, + {0x548c, 0xb8}, + {0x548d, 0xca}, + {0x548e, 0xd7}, + {0x548f, 0xe3}, + {0x5490, 0x1d}, + + //Special Digital Effects (SDE) (UV adjust) + {0x5580, 0x06},//enable brightness and contrast + {0x5583, 0x40},//special_effect + {0x5584, 0x10},//special_effect + {0x5586, 0x20},//contrast + {0x5587, 0x00},//brightness + {0x5588, 0x00},//brightness + {0x5589, 0x10}, + {0x558a, 0x00}, + {0x558b, 0xf8}, + {0x501d, 0x40},// enable manual offset of contrast + + //power on + {0x3008, 0x02}, + + //50Hz + {0x3c00, 0x04}, + + {REG_DLY, 300}, + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_jpeg[][2] = { + {FORMAT_CTRL, 0x00}, // YUV422 + {FORMAT_CTRL00, 0x30}, // YUYV + {0x3002, 0x00},//0x1c to 0x00 !!! + {0x3006, 0xff},//0xc3 to 0xff !!! + {0x471c, 0x50},//0xd0 to 0x50 !!! + {REGLIST_TAIL, 0x00}, // tail +}; + +static const DRAM_ATTR uint16_t sensor_fmt_raw[][2] = { + {FORMAT_CTRL, 0x03}, // RAW (DPC) + {FORMAT_CTRL00, 0x00}, // RAW + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint16_t sensor_fmt_grayscale[][2] = { + {FORMAT_CTRL, 0x00}, // YUV422 + {FORMAT_CTRL00, 0x10}, // Y8 + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint16_t sensor_fmt_yuv422[][2] = { + {FORMAT_CTRL, 0x00}, // YUV422 + {FORMAT_CTRL00, 0x30}, // YUYV + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint16_t sensor_fmt_rgb565[][2] = { + {FORMAT_CTRL, 0x01}, // RGB + {FORMAT_CTRL00, 0x61}, // RGB565 (BGR) + {REGLIST_TAIL, 0x00} +}; + +static const DRAM_ATTR uint8_t sensor_saturation_levels[9][11] = { + {0x1d, 0x60, 0x03, 0x07, 0x48, 0x4f, 0x4b, 0x40, 0x0b, 0x01, 0x98},//-4 + {0x1d, 0x60, 0x03, 0x08, 0x54, 0x5c, 0x58, 0x4b, 0x0d, 0x01, 0x98},//-3 + {0x1d, 0x60, 0x03, 0x0a, 0x60, 0x6a, 0x64, 0x56, 0x0e, 0x01, 0x98},//-2 + {0x1d, 0x60, 0x03, 0x0b, 0x6c, 0x77, 0x70, 0x60, 0x10, 0x01, 0x98},//-1 + {0x1d, 0x60, 0x03, 0x0c, 0x78, 0x84, 0x7d, 0x6b, 0x12, 0x01, 0x98},//0 + {0x1d, 0x60, 0x03, 0x0d, 0x84, 0x91, 0x8a, 0x76, 0x14, 0x01, 0x98},//+1 + {0x1d, 0x60, 0x03, 0x0e, 0x90, 0x9e, 0x96, 0x80, 0x16, 0x01, 0x98},//+2 + {0x1d, 0x60, 0x03, 0x10, 0x9c, 0xac, 0xa2, 0x8b, 0x17, 0x01, 0x98},//+3 + {0x1d, 0x60, 0x03, 0x11, 0xa8, 0xb9, 0xaf, 0x96, 0x19, 0x01, 0x98},//+4 +}; + +static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = { + {0x06, 0x40, 0x2c, 0x08},//Normal + {0x46, 0x40, 0x28, 0x08},//Negative + {0x1e, 0x80, 0x80, 0x08},//Grayscale + {0x1e, 0x80, 0xc0, 0x08},//Red Tint + {0x1e, 0x60, 0x60, 0x08},//Green Tint + {0x1e, 0xa0, 0x40, 0x08},//Blue Tint + {0x1e, 0x40, 0xa0, 0x08},//Sepia +}; + +static const DRAM_ATTR uint16_t sensor_regs_gamma0[][2] = { + {0x5480, 0x01}, + {0x5481, 0x08}, + {0x5482, 0x14}, + {0x5483, 0x28}, + {0x5484, 0x51}, + {0x5485, 0x65}, + {0x5486, 0x71}, + {0x5487, 0x7d}, + {0x5488, 0x87}, + {0x5489, 0x91}, + {0x548a, 0x9a}, + {0x548b, 0xaa}, + {0x548c, 0xb8}, + {0x548d, 0xcd}, + {0x548e, 0xdd}, + {0x548f, 0xea}, + {0x5490, 0x1d} +}; + +static const DRAM_ATTR uint16_t sensor_regs_gamma1[][2] = { + {0x5480, 0x1}, + {0x5481, 0x0}, + {0x5482, 0x1e}, + {0x5483, 0x3b}, + {0x5484, 0x58}, + {0x5485, 0x66}, + {0x5486, 0x71}, + {0x5487, 0x7d}, + {0x5488, 0x83}, + {0x5489, 0x8f}, + {0x548a, 0x98}, + {0x548b, 0xa6}, + {0x548c, 0xb8}, + {0x548d, 0xca}, + {0x548e, 0xd7}, + {0x548f, 0xe3}, + {0x5490, 0x1d} +}; + +static const DRAM_ATTR uint16_t sensor_regs_awb0[][2] = { + {0x5180, 0xff}, + {0x5181, 0xf2}, + {0x5182, 0x00}, + {0x5183, 0x14}, + {0x5184, 0x25}, + {0x5185, 0x24}, + {0x5186, 0x09}, + {0x5187, 0x09}, + {0x5188, 0x09}, + {0x5189, 0x75}, + {0x518a, 0x54}, + {0x518b, 0xe0}, + {0x518c, 0xb2}, + {0x518d, 0x42}, + {0x518e, 0x3d}, + {0x518f, 0x56}, + {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, 0x38} +}; + +#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h new file mode 100644 index 000000000..b3a645a70 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h @@ -0,0 +1,33 @@ +/* + * This file is part of the OpenMV project. + * author: Juan Schiavoni + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV7670 driver. + * + */ +#ifndef __OV7670_H__ +#define __OV7670_H__ +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int ov7670_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int ov7670_init(sensor_t *sensor); + +#endif // __OV7670_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h new file mode 100644 index 000000000..699354877 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h @@ -0,0 +1,354 @@ +/* + * This file is for the OpenMV project so the OV7670 can be used + * author: Juan Schiavoni + * + * OV7670 register definitions. + */ +#ifndef __OV7670_REG_REGS_H__ +#define __OV7670_REG_REGS_H__ +#define GAIN 0x00 /* AGC – Gain control gain setting */ +#define BLUE 0x01 /* AWB – Blue channel gain setting */ +#define RED 0x02 /* AWB – Red channel gain setting */ +#define VREF 0x03 /* AWB – Green channel gain setting */ +#define COM1 0x04 /* Common Control 1 */ +#define BAVG 0x05 /* U/B Average Level */ +#define GAVG 0x06 /* Y/Gb Average Level */ +#define AECH 0x07 /* Exposure VAlue - AEC MSB 5 bits */ +#define RAVG 0x08 /* V/R Average Level */ + +#define COM2 0x09 /* Common Control 2 */ +#define COM2_SOFT_SLEEP 0x10 /* Soft sleep mode */ +#define COM2_OUT_DRIVE_1x 0x00 /* Output drive capability 1x */ +#define COM2_OUT_DRIVE_2x 0x01 /* Output drive capability 2x */ +#define COM2_OUT_DRIVE_3x 0x02 /* Output drive capability 3x */ +#define COM2_OUT_DRIVE_4x 0x03 /* Output drive capability 4x */ + +#define REG_PID 0x0A /* Product ID Number MSB */ +#define REG_VER 0x0B /* Product ID Number LSB */ + +#define COM3 0x0C /* Common Control 3 */ +#define COM3_SWAP_OUT 0x40 /* Output data MSB/LSB swap */ +#define COM3_TRI_CLK 0x20 /* Tri-state output clock */ +#define COM3_TRI_DATA 0x10 /* Tri-state option output */ +#define COM3_SCALE_EN 0x08 /* Scale enable */ +#define COM3_DCW 0x04 /* DCW enable */ + +#define COM4 0x0D /* Common Control 4 */ +#define COM4_PLL_BYPASS 0x00 /* Bypass PLL */ +#define COM4_PLL_4x 0x40 /* PLL frequency 4x */ +#define COM4_PLL_6x 0x80 /* PLL frequency 6x */ +#define COM4_PLL_8x 0xc0 /* PLL frequency 8x */ +#define COM4_AEC_FULL 0x00 /* AEC evaluate full window */ +#define COM4_AEC_1_2 0x10 /* AEC evaluate 1/2 window */ +#define COM4_AEC_1_4 0x20 /* AEC evaluate 1/4 window */ +#define COM4_AEC_2_3 0x30 /* AEC evaluate 2/3 window */ + +#define COM5 0x0E /* Common Control 5 */ +#define COM5_AFR 0x80 /* Auto frame rate control ON/OFF selection (night mode) */ +#define COM5_AFR_SPEED 0x40 /* Auto frame rate control speed selection */ +#define COM5_AFR_0 0x00 /* No reduction of frame rate */ +#define COM5_AFR_1_2 0x10 /* Max reduction to 1/2 frame rate */ +#define COM5_AFR_1_4 0x20 /* Max reduction to 1/4 frame rate */ +#define COM5_AFR_1_8 0x30 /* Max reduction to 1/8 frame rate */ +#define COM5_AFR_4x 0x04 /* Add frame when AGC reaches 4x gain */ +#define COM5_AFR_8x 0x08 /* Add frame when AGC reaches 8x gain */ +#define COM5_AFR_16x 0x0c /* Add frame when AGC reaches 16x gain */ +#define COM5_AEC_NO_LIMIT 0x01 /* No limit to AEC increase step */ + +#define COM6 0x0F /* Common Control 6 */ +#define COM6_AUTO_WINDOW 0x01 /* Auto window setting ON/OFF selection when format changes */ + +#define AEC 0x10 /* AEC[7:0] (see register AECH for AEC[15:8]) */ +#define CLKRC 0x11 /* Internal Clock */ + +#define COM7 0x12 /* Common Control 7 */ +#define COM7_RESET 0x80 /* SCCB Register Reset */ +#define COM7_RES_VGA 0x00 /* Resolution VGA */ +#define COM7_RES_QVGA 0x40 /* Resolution QVGA */ +#define COM7_BT656 0x20 /* BT.656 protocol ON/OFF */ +#define COM7_SENSOR_RAW 0x10 /* Sensor RAW */ +#define COM7_FMT_GBR422 0x00 /* RGB output format GBR422 */ +#define COM7_FMT_RGB565 0x04 /* RGB output format RGB565 */ +#define COM7_FMT_RGB555 0x08 /* RGB output format RGB555 */ +#define COM7_FMT_RGB444 0x0C /* RGB output format RGB444 */ +#define COM7_FMT_YUV 0x00 /* Output format YUV */ +#define COM7_FMT_P_BAYER 0x01 /* Output format Processed Bayer RAW */ +#define COM7_FMT_RGB 0x04 /* Output format RGB */ +#define COM7_FMT_R_BAYER 0x03 /* Output format Bayer RAW */ +#define COM7_SET_FMT(r, x) ((r&0xFC)|((x&0x5)<<0)) + +#define COM8 0x13 /* Common Control 8 */ +#define COM8_FAST_AUTO 0x80 /* Enable fast AGC/AEC algorithm */ +#define COM8_STEP_VSYNC 0x00 /* AEC - Step size limited to vertical blank */ +#define COM8_STEP_UNLIMIT 0x40 /* AEC - Step size unlimited step size */ +#define COM8_BANDF_EN 0x20 /* Banding filter ON/OFF */ +#define COM8_AEC_BANDF 0x10 /* Enable AEC below banding value */ +#define COM8_AEC_FINE_EN 0x08 /* Fine AEC ON/OFF control */ +#define COM8_AGC_EN 0x04 /* AGC Enable */ +#define COM8_AWB_EN 0x02 /* AWB Enable */ +#define COM8_AEC_EN 0x01 /* AEC Enable */ +#define COM8_SET_AGC(r, x) ((r&0xFB)|((x&0x1)<<2)) +#define COM8_SET_AWB(r, x) ((r&0xFD)|((x&0x1)<<1)) +#define COM8_SET_AEC(r, x) ((r&0xFE)|((x&0x1)<<0)) + +#define COM9 0x14 /* Common Control 9 */ +#define COM9_HISTO_AVG 0x80 /* Histogram or average based AEC/AGC selection */ +#define COM9_AGC_GAIN_2x 0x00 /* Automatic Gain Ceiling 2x */ +#define COM9_AGC_GAIN_4x 0x10 /* Automatic Gain Ceiling 4x */ +#define COM9_AGC_GAIN_8x 0x20 /* Automatic Gain Ceiling 8x */ +#define COM9_AGC_GAIN_16x 0x30 /* Automatic Gain Ceiling 16x */ +#define COM9_AGC_GAIN_32x 0x40 /* Automatic Gain Ceiling 32x */ +#define COM9_DROP_VSYNC 0x04 /* Drop VSYNC output of corrupt frame */ +#define COM9_DROP_HREF 0x02 /* Drop HREF output of corrupt frame */ +#define COM9_SET_AGC(r, x) ((r&0x8F)|((x&0x07)<<4)) + +#define COM10 0x15 /* Common Control 10 */ +#define COM10_NEGATIVE 0x80 /* Output negative data */ +#define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ +#define COM10_PCLK_FREE 0x00 /* PCLK output option: free running PCLK */ +#define COM10_PCLK_MASK 0x20 /* PCLK output option: masked during horizontal blank */ +#define COM10_PCLK_REV 0x10 /* PCLK reverse */ +#define COM10_HREF_REV 0x08 /* HREF reverse */ +#define COM10_VSYNC_FALLING 0x00 /* VSYNC changes on falling edge of PCLK */ +#define COM10_VSYNC_RISING 0x04 /* VSYNC changes on rising edge of PCLK */ +#define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ +#define COM10_OUT_RANGE_8 0x01 /* Output data range: Full range */ +#define COM10_OUT_RANGE_10 0x00 /* Output data range: Data from [10] to [F0] (8 MSBs) */ + +#define RSVD_16 0x16 /* Reserved register */ + +#define HSTART 0x17 /* Horizontal Frame (HREF column) Start high 8-bit(low 3 bits are at HREF[2:0]) */ +#define HSTOP 0x18 /* Horizontal Frame (HREF column) end high 8-bit (low 3 bits are at HREF[5:3]) */ +#define VSTART 0x19 /* Vertical Frame (row) Start high 8-bit (low 2 bits are at VREF[1:0]) */ +#define VSTOP 0x1A /* Vertical Frame (row) End high 8-bit (low 2 bits are at VREF[3:2]) */ +#define PSHFT 0x1B /* Data Format - Pixel Delay Select */ +#define REG_MIDH 0x1C /* Manufacturer ID Byte – High */ +#define REG_MIDL 0x1D /* Manufacturer ID Byte – Low */ + +#define MVFP 0x1E /* Mirror/Vflip Enable */ +#define MVFP_MIRROR 0x20 /* Mirror image */ +#define MVFP_FLIP 0x10 /* Vertical flip */ +#define MVFP_SUN 0x02 /* Black sun enable */ +#define MVFP_SET_MIRROR(r,x) ((r&0xDF)|((x&1)<<5)) /* change only bit5 according to x */ +#define MVFP_SET_FLIP(r,x) ((r&0xEF)|((x&1)<<4)) /* change only bit4 according to x */ + +#define LAEC 0x1F /* Fine AEC Value - defines exposure value less than one row period (Reserved?) */ +#define ADCCTR0 0x20 /* ADC control */ +#define ADCCTR1 0x21 /* reserved */ +#define ADCCTR2 0x22 /* reserved */ +#define ADCCTR3 0x23 /* reserved */ +#define AEW 0x24 /* AGC/AEC - Stable Operating Region (Upper Limit) */ +#define AEB 0x25 /* AGC/AEC - Stable Operating Region (Lower Limit) */ +#define VPT 0x26 /* AGC/AEC Fast Mode Operating Region */ +#define BBIAS 0x27 /* B channel signal output bias (effective only when COM6[3]=1) */ +#define GbBIAS 0x28 /* Gb channel signal output bias (effective only when COM6[3]=1) */ +#define RSVD_29 0x29 /* reserved */ +#define EXHCH 0x2A /* Dummy Pixel Insert MSB */ +#define EXHCL 0x2B /* Dummy Pixel Insert LSB */ +#define RBIAS 0x2C /* R channel signal output bias (effective only when COM6[3]=1) */ +#define ADVFL 0x2D /* LSB of Insert Dummy Rows in Vertical Sync (1 bit equals 1 row) */ +#define ADVFH 0x2E /* MSB of Insert Dummy Rows in Vertical Sync */ +#define YAVE 0x2F /* Y/G Channel Average Value */ +#define HSYST 0x30 /* HSync rising edge delay */ +#define HSYEN 0x31 /* HSync falling edge delay */ +#define HREF 0x32 /* Image Start and Size Control DIFFERENT CONTROL SEQUENCE */ +#define CHLF 0x33 /* Array Current control */ +#define ARBLM 0x34 /* Array reference control */ +#define RSVD_35 0x35 /* Reserved */ +#define RSVD_36 0x36 /* Reserved */ +#define ADC 0x37 /* ADC control */ +#define ACOM 0x38 /* ADC and analog common mode control */ +#define OFON 0x39 /* ADC offset control */ +#define TSLB 0x3A /* Line buffer test option */ + +#define COM11 0x3B /* Common control 11 */ +#define COM11_EXP 0x02 +#define COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */ + +#define COM12 0x3C /* Common control 12 */ + +#define COM13 0x3D /* Common control 13 */ +#define COM13_GAMMA 0x80 /* Gamma enable */ +#define COM13_UVSAT 0x40 /* UV saturation auto adjustment */ + +#define COM14 0x3E /* Common Control 14 */ + +#define EDGE 0x3F /* edge enhancement adjustment */ +#define COM15 0x40 /* Common Control 15 DIFFERENT CONTROLS */ +#define COM15_SET_RGB565(r,x) ((r&0xEF)|((x&1)<<4)) /* set rgb565 mode */ +#define COM15_RGB565 0x10 /* RGB565 output */ +#define COM15_R00FF 0xC0 /* Output range: [00] to [FF] */ + +#define COM16 0x41 /* Common Control 16 DIFFERENT CONTROLS */ +#define COM16_AWBGAIN 0x08 /* AWB gain enable */ +#define COM17 0x42 /* Common Control 17 */ + +#define AWBC1 0x43 /* Reserved */ +#define AWBC2 0x44 /* Reserved */ +#define AWBC3 0x45 /* Reserved */ +#define AWBC4 0x46 /* Reserved */ +#define AWBC5 0x47 /* Reserved */ +#define AWBC6 0x48 /* Reserved */ + +#define RSVD_49 0x49 /* Reserved */ +#define RSVD_4A 0x4A /* Reserved */ + +#define REG4B 0x4B /* Register 4B */ +#define DNSTH 0x4C /* Denoise strength */ + +#define RSVD_4D 0x4D /* Reserved */ +#define RSVD_4E 0x4E /* Reserved */ + +#define MTX1 0x4F /* Matrix coefficient 1 */ +#define MTX2 0x50 /* Matrix coefficient 2 */ +#define MTX3 0x51 /* Matrix coefficient 3 */ +#define MTX4 0x52 /* Matrix coefficient 4 */ +#define MTX5 0x53 /* Matrix coefficient 5 */ +#define MTX6 0x54 /* Matrix coefficient 6 */ +#define BRIGHTNESS 0x55 /* Brightness control */ +#define CONTRAST 0x56 /* Contrast control */ +#define CONTRASCENTER 0x57 /* Contrast center */ +#define MTXS 0x58 /* Matrix coefficient sign for coefficient 5 to 0*/ + +#define RSVD_59 0x59 /* Reserved */ +#define RSVD_5A 0x5A /* Reserved */ +#define RSVD_5B 0x5B /* Reserved */ +#define RSVD_5C 0x5C /* Reserved */ +#define RSVD_5D 0x5D /* Reserved */ +#define RSVD_5E 0x5E /* Reserved */ +#define RSVD_5F 0x5F /* Reserved */ +#define RSVD_60 0x60 /* Reserved */ +#define RSVD_61 0x61 /* Reserved */ + +#define LCC1 0x62 /* Lens correction option 1 */ + +#define LCC2 0x63 /* Lens correction option 2 */ +#define LCC3 0x64 /* Lens correction option 3 */ +#define LCC4 0x65 /* Lens correction option 4 */ +#define LCC5 0x66 /* Lens correction option 5 */ + +#define MANU 0x67 /* Manual U Value */ +#define MANV 0x68 /* Manual V Value */ +#define GFIX 0x69 /* Fix gain control */ +#define GGAIN 0x6A /* G channel AWB gain */ + +#define DBLV 0x6B /* PLL and clock ? */ + +#define AWBCTR3 0x6C /* AWB Control 3 */ +#define AWBCTR2 0x6D /* AWB Control 2 */ +#define AWBCTR1 0x6E /* AWB Control 1 */ +#define AWBCTR0 0x6F /* AWB Control 0 */ +#define SCALING_XSC 0x70 /* test pattern and horizontal scaling factor */ +#define SCALING_XSC_CBAR(r) (r&0x7F) /* make sure bit7 is 0 for color bar */ +#define SCALING_YSC 0x71 /* test pattern and vertical scaling factor */ +#define SCALING_YSC_CBAR(r,x) ((r&0x7F)|((x&1)<<7)) /* change bit7 for color bar on/off */ +#define SCALING_DCWCTR 0x72 /* DCW control */ +#define SCALING_PCLK_DIV 0x73 /* */ +#define REG74 0x74 /* */ +#define REG75 0x75 /* */ +#define REG76 0x76 /* */ +#define REG77 0x77 /* */ + +#define RSVD_78 0x78 /* Reserved */ +#define RSVD_79 0x79 /* Reserved */ + +#define SLOP 0x7A /* Gamma curve highest segment slope */ +#define GAM1 0x7B /* Gamma Curve 1st Segment Input End Point 0x04 Output Value */ +#define GAM2 0x7C /* Gamma Curve 2nd Segment Input End Point 0x08 Output Value */ +#define GAM3 0x7D /* Gamma Curve 3rd Segment Input End Point 0x10 Output Value */ +#define GAM4 0x7E /* Gamma Curve 4th Segment Input End Point 0x20 Output Value */ +#define GAM5 0x7F /* Gamma Curve 5th Segment Input End Point 0x28 Output Value */ +#define GAM6 0x80 /* Gamma Curve 6rd Segment Input End Point 0x30 Output Value */ +#define GAM7 0x81 /* Gamma Curve 7th Segment Input End Point 0x38 Output Value */ +#define GAM8 0x82 /* Gamma Curve 8th Segment Input End Point 0x40 Output Value */ +#define GAM9 0x83 /* Gamma Curve 9th Segment Input End Point 0x48 Output Value */ +#define GAM10 0x84 /* Gamma Curve 10th Segment Input End Point 0x50 Output Value */ +#define GAM11 0x85 /* Gamma Curve 11th Segment Input End Point 0x60 Output Value */ +#define GAM12 0x86 /* Gamma Curve 12th Segment Input End Point 0x70 Output Value */ +#define GAM13 0x87 /* Gamma Curve 13th Segment Input End Point 0x90 Output Value */ +#define GAM14 0x88 /* Gamma Curve 14th Segment Input End Point 0xB0 Output Value */ +#define GAM15 0x89 /* Gamma Curve 15th Segment Input End Point 0xD0 Output Value */ + +#define RSVD_8A 0x8A /* Reserved */ +#define RSVD_8B 0x8B /* Reserved */ + +#define RGB444 0x8C /* */ + +#define RSVD_8D 0x8D /* Reserved */ +#define RSVD_8E 0x8E /* Reserved */ +#define RSVD_8F 0x8F /* Reserved */ +#define RSVD_90 0x90 /* Reserved */ +#define RSVD_91 0x91 /* Reserved */ + +#define DM_LNL 0x92 /* Dummy line low 8 bit */ +#define DM_LNH 0x93 /* Dummy line high 8 bit */ +#define LCC6 0x94 /* Lens correction option 6 */ +#define LCC7 0x95 /* Lens correction option 7 */ + +#define RSVD_96 0x96 /* Reserved */ +#define RSVD_97 0x97 /* Reserved */ +#define RSVD_98 0x98 /* Reserved */ +#define RSVD_99 0x99 /* Reserved */ +#define RSVD_9A 0x9A /* Reserved */ +#define RSVD_9B 0x9B /* Reserved */ +#define RSVD_9C 0x9C /* Reserved */ + +#define BD50ST 0x9D /* 50 Hz banding filter value */ +#define BD60ST 0x9E /* 60 Hz banding filter value */ +#define HAECC1 0x9F /* Histogram-based AEC/AGC control 1 */ +#define HAECC2 0xA0 /* Histogram-based AEC/AGC control 2 */ + +#define RSVD_A1 0xA1 /* Reserved */ + +#define SCALING_PCLK_DELAY 0xA2 /* Pixel clock delay */ + +#define RSVD_A3 0xA3 /* Reserved */ + +#define NT_CNTRL 0xA4 /* */ +#define BD50MAX 0xA5 /* 50 Hz banding step limit */ +#define HAECC3 0xA6 /* Histogram-based AEC/AGC control 3 */ +#define HAECC4 0xA7 /* Histogram-based AEC/AGC control 4 */ +#define HAECC5 0xA8 /* Histogram-based AEC/AGC control 5 */ +#define HAECC6 0xA9 /* Histogram-based AEC/AGC control 6 */ + +#define HAECC7 0xAA /* Histogram-based AEC/AGC control 7 */ +#define HAECC_EN 0x80 /* Histogram-based AEC algorithm enable */ + +#define BD60MAX 0xAB /* 60 Hz banding step limit */ + +#define STR_OPT 0xAC /* Register AC */ +#define STR_R 0xAD /* R gain for led output frame */ +#define STR_G 0xAE /* G gain for led output frame */ +#define STR_B 0xAF /* B gain for led output frame */ +#define RSVD_B0 0xB0 /* Reserved */ +#define ABLC1 0xB1 /* */ +#define RSVD_B2 0xB2 /* Reserved */ +#define THL_ST 0xB3 /* ABLC target */ +#define THL_DLT 0xB5 /* ABLC stable range */ + +#define RSVD_B6 0xB6 /* Reserved */ +#define RSVD_B7 0xB7 /* Reserved */ +#define RSVD_B8 0xB8 /* Reserved */ +#define RSVD_B9 0xB9 /* Reserved */ +#define RSVD_BA 0xBA /* Reserved */ +#define RSVD_BB 0xBB /* Reserved */ +#define RSVD_BC 0xBC /* Reserved */ +#define RSVD_BD 0xBD /* Reserved */ + +#define AD_CHB 0xBE /* blue channel black level compensation */ +#define AD_CHR 0xBF /* Red channel black level compensation */ +#define AD_CHGb 0xC0 /* Gb channel black level compensation */ +#define AD_CHGr 0xC1 /* Gr channel black level compensation */ + +#define RSVD_C2 0xC2 /* Reserved */ +#define RSVD_C3 0xC3 /* Reserved */ +#define RSVD_C4 0xC4 /* Reserved */ +#define RSVD_C5 0xC5 /* Reserved */ +#define RSVD_C6 0xC6 /* Reserved */ +#define RSVD_C7 0xC7 /* Reserved */ +#define RSVD_C8 0xC8 /* Reserved */ + +#define SATCTR 0xC9 /* Saturation control */ +#define SET_REG(reg, x) (##reg_DEFAULT|x) + +#endif //__OV7670_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h new file mode 100644 index 000000000..291b26680 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h @@ -0,0 +1,33 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV7725 driver. + * + */ +#ifndef __OV7725_H__ +#define __OV7725_H__ +#include "sensor.h" + +/** + * @brief Detect sensor pid + * + * @param slv_addr SCCB address + * @param id Detection result + * @return + * 0: Can't detect this sensor + * Nonzero: This sensor has been detected + */ +int ov7725_detect(int slv_addr, sensor_id_t *id); + +/** + * @brief initialize sensor function pointers + * + * @param sensor pointer of sensor + * @return + * Always 0 + */ +int ov7725_init(sensor_t *sensor); + +#endif // __OV7725_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h new file mode 100644 index 000000000..5cb233dc9 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h @@ -0,0 +1,335 @@ +/* + * This file is part of the OpenMV project. + * Copyright (c) 2013/2014 Ibrahim Abdelkader + * This work is licensed under the MIT license, see the file LICENSE for details. + * + * OV2640 register definitions. + */ +#ifndef __REG_REGS_H__ +#define __REG_REGS_H__ +#define GAIN 0x00 /* AGC – Gain control gain setting */ +#define BLUE 0x01 /* AWB – Blue channel gain setting */ +#define RED 0x02 /* AWB – Red channel gain setting */ +#define GREEN 0x03 /* AWB – Green channel gain setting */ +#define BAVG 0x05 /* U/B Average Level */ +#define GAVG 0x06 /* Y/Gb Average Level */ +#define RAVG 0x07 /* V/R Average Level */ +#define AECH 0x08 /* Exposure Value – AEC MSBs */ + +#define COM2 0x09 /* Common Control 2 */ +#define COM2_SOFT_SLEEP 0x10 /* Soft sleep mode */ +#define COM2_OUT_DRIVE_1x 0x00 /* Output drive capability 1x */ +#define COM2_OUT_DRIVE_2x 0x01 /* Output drive capability 2x */ +#define COM2_OUT_DRIVE_3x 0x02 /* Output drive capability 3x */ +#define COM2_OUT_DRIVE_4x 0x03 /* Output drive capability 4x */ + +#define REG_PID 0x0A /* Product ID Number MSB */ +#define REG_VER 0x0B /* Product ID Number LSB */ + +#define COM3 0x0C /* Common Control 3 */ +#define COM3_VFLIP 0x80 /* Vertical flip image ON/OFF selection */ +#define COM3_MIRROR 0x40 /* Horizontal mirror image ON/OFF selection */ +#define COM3_SWAP_BR 0x20 /* Swap B/R output sequence in RGB output mode */ +#define COM3_SWAP_YUV 0x10 /* Swap Y/UV output sequence in YUV output mode */ +#define COM3_SWAP_MSB 0x08 /* Swap output MSB/LSB */ +#define COM3_TRI_CLOCK 0x04 /* Tri-state option for output clock at power-down period */ +#define COM3_TRI_DATA 0x02 /* Tri-state option for output data at power-down period */ +#define COM3_COLOR_BAR 0x01 /* Sensor color bar test pattern output enable */ +#define COM3_SET_CBAR(r, x) ((r&0xFE)|((x&1)<<0)) +#define COM3_SET_MIRROR(r, x) ((r&0xBF)|((x&1)<<6)) +#define COM3_SET_FLIP(r, x) ((r&0x7F)|((x&1)<<7)) + +#define COM4 0x0D /* Common Control 4 */ +#define COM4_PLL_BYPASS 0x00 /* Bypass PLL */ +#define COM4_PLL_4x 0x40 /* PLL frequency 4x */ +#define COM4_PLL_6x 0x80 /* PLL frequency 6x */ +#define COM4_PLL_8x 0xc0 /* PLL frequency 8x */ +#define COM4_AEC_FULL 0x00 /* AEC evaluate full window */ +#define COM4_AEC_1_2 0x10 /* AEC evaluate 1/2 window */ +#define COM4_AEC_1_4 0x20 /* AEC evaluate 1/4 window */ +#define COM4_AEC_2_3 0x30 /* AEC evaluate 2/3 window */ + +#define COM5 0x0E /* Common Control 5 */ +#define COM5_AFR 0x80 /* Auto frame rate control ON/OFF selection (night mode) */ +#define COM5_AFR_SPEED 0x40 /* Auto frame rate control speed selection */ +#define COM5_AFR_0 0x00 /* No reduction of frame rate */ +#define COM5_AFR_1_2 0x10 /* Max reduction to 1/2 frame rate */ +#define COM5_AFR_1_4 0x20 /* Max reduction to 1/4 frame rate */ +#define COM5_AFR_1_8 0x30 /* Max reduction to 1/8 frame rate */ +#define COM5_AFR_4x 0x04 /* Add frame when AGC reaches 4x gain */ +#define COM5_AFR_8x 0x08 /* Add frame when AGC reaches 8x gain */ +#define COM5_AFR_16x 0x0c /* Add frame when AGC reaches 16x gain */ +#define COM5_AEC_NO_LIMIT 0x01 /* No limit to AEC increase step */ + +#define COM6 0x0F /* Common Control 6 */ +#define COM6_AUTO_WINDOW 0x01 /* Auto window setting ON/OFF selection when format changes */ + +#define AEC 0x10 /* AEC[7:0] (see register AECH for AEC[15:8]) */ +#define CLKRC 0x11 /* Internal Clock */ + +#define COM7 0x12 /* Common Control 7 */ +#define COM7_RESET 0x80 /* SCCB Register Reset */ +#define COM7_RES_VGA 0x00 /* Resolution VGA */ +#define COM7_RES_QVGA 0x40 /* Resolution QVGA */ +#define COM7_BT656 0x20 /* BT.656 protocol ON/OFF */ +#define COM7_SENSOR_RAW 0x10 /* Sensor RAW */ +#define COM7_FMT_GBR422 0x00 /* RGB output format GBR422 */ +#define COM7_FMT_RGB565 0x04 /* RGB output format RGB565 */ +#define COM7_FMT_RGB555 0x08 /* RGB output format RGB555 */ +#define COM7_FMT_RGB444 0x0C /* RGB output format RGB444 */ +#define COM7_FMT_YUV 0x00 /* Output format YUV */ +#define COM7_FMT_P_BAYER 0x01 /* Output format Processed Bayer RAW */ +#define COM7_FMT_RGB 0x02 /* Output format RGB */ +#define COM7_FMT_R_BAYER 0x03 /* Output format Bayer RAW */ +#define COM7_SET_FMT(r, x) ((r&0xFC)|((x&0x3)<<0)) +#define COM7_SET_RGB(r, x) ((r&0xF0)|(x&0x0C)|COM7_FMT_RGB) + +#define COM8 0x13 /* Common Control 8 */ +#define COM8_FAST_AUTO 0x80 /* Enable fast AGC/AEC algorithm */ +#define COM8_STEP_VSYNC 0x00 /* AEC - Step size limited to vertical blank */ +#define COM8_STEP_UNLIMIT 0x40 /* AEC - Step size unlimited step size */ +#define COM8_BANDF_EN 0x20 /* Banding filter ON/OFF */ +#define COM8_AEC_BANDF 0x10 /* Enable AEC below banding value */ +#define COM8_AEC_FINE_EN 0x08 /* Fine AEC ON/OFF control */ +#define COM8_AGC_EN 0x04 /* AGC Enable */ +#define COM8_AWB_EN 0x02 /* AWB Enable */ +#define COM8_AEC_EN 0x01 /* AEC Enable */ +#define COM8_SET_AGC(r, x) ((r&0xFB)|((x&0x1)<<2)) +#define COM8_SET_AWB(r, x) ((r&0xFD)|((x&0x1)<<1)) +#define COM8_SET_AEC(r, x) ((r&0xFE)|((x&0x1)<<0)) + +#define COM9 0x14 /* Common Control 9 */ +#define COM9_HISTO_AVG 0x80 /* Histogram or average based AEC/AGC selection */ +#define COM9_AGC_GAIN_2x 0x00 /* Automatic Gain Ceiling 2x */ +#define COM9_AGC_GAIN_4x 0x10 /* Automatic Gain Ceiling 4x */ +#define COM9_AGC_GAIN_8x 0x20 /* Automatic Gain Ceiling 8x */ +#define COM9_AGC_GAIN_16x 0x30 /* Automatic Gain Ceiling 16x */ +#define COM9_AGC_GAIN_32x 0x40 /* Automatic Gain Ceiling 32x */ +#define COM9_DROP_VSYNC 0x04 /* Drop VSYNC output of corrupt frame */ +#define COM9_DROP_HREF 0x02 /* Drop HREF output of corrupt frame */ +#define COM9_SET_AGC(r, x) ((r&0x8F)|((x&0x07)<<4)) + +#define COM10 0x15 /* Common Control 10 */ +#define COM10_NEGATIVE 0x80 /* Output negative data */ +#define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ +#define COM10_PCLK_FREE 0x00 /* PCLK output option: free running PCLK */ +#define COM10_PCLK_MASK 0x20 /* PCLK output option: masked during horizontal blank */ +#define COM10_PCLK_REV 0x10 /* PCLK reverse */ +#define COM10_HREF_REV 0x08 /* HREF reverse */ +#define COM10_VSYNC_FALLING 0x00 /* VSYNC changes on falling edge of PCLK */ +#define COM10_VSYNC_RISING 0x04 /* VSYNC changes on rising edge of PCLK */ +#define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ +#define COM10_OUT_RANGE_8 0x01 /* Output data range: Full range */ +#define COM10_OUT_RANGE_10 0x00 /* Output data range: Data from [10] to [F0] (8 MSBs) */ + +#define REG16 0x16 /* Register 16 */ +#define REG16_BIT_SHIFT 0x80 /* Bit shift test pattern options */ +#define HSTART 0x17 /* Horizontal Frame (HREF column) Start 8 MSBs (2 LSBs are at HREF[5:4]) */ +#define HSIZE 0x18 /* Horizontal Sensor Size (2 LSBs are at HREF[1:0]) */ +#define VSTART 0x19 /* Vertical Frame (row) Start 8 MSBs (1 LSB is at HREF[6]) */ +#define VSIZE 0x1A /* Vertical Sensor Size (1 LSB is at HREF[2]) */ +#define PSHFT 0x1B /* Data Format - Pixel Delay Select */ +#define REG_MIDH 0x1C /* Manufacturer ID Byte – High */ +#define REG_MIDL 0x1D /* Manufacturer ID Byte – Low */ +#define LAEC 0x1F /* Fine AEC Value - defines exposure value less than one row period */ + +#define COM11 0x20 /* Common Control 11 */ +#define COM11_SNGL_FRAME_EN 0x02 /* Single frame ON/OFF selection */ +#define COM11_SNGL_XFR_TRIG 0x01 /* Single frame transfer trigger */ + +#define BDBASE 0x22 /* Banding Filter Minimum AEC Value */ +#define DBSTEP 0x23 /* Banding Filter Maximum Step */ +#define AEW 0x24 /* AGC/AEC - Stable Operating Region (Upper Limit) */ +#define AEB 0x25 /* AGC/AEC - Stable Operating Region (Lower Limit) */ +#define VPT 0x26 /* AGC/AEC Fast Mode Operating Region */ +#define REG28 0x28 /* Selection on the number of dummy rows, N */ +#define HOUTSIZE 0x29 /* Horizontal Data Output Size MSBs (2 LSBs at register EXHCH[1:0]) */ +#define EXHCH 0x2A /* Dummy Pixel Insert MSB */ +#define EXHCL 0x2B /* Dummy Pixel Insert LSB */ +#define VOUTSIZE 0x2C /* Vertical Data Output Size MSBs (LSB at register EXHCH[2]) */ +#define ADVFL 0x2D /* LSB of Insert Dummy Rows in Vertical Sync (1 bit equals 1 row) */ +#define ADVFH 0x2E /* MSB of Insert Dummy Rows in Vertical Sync */ +#define YAVE 0x2F /* Y/G Channel Average Value */ +#define LUMHTH 0x30 /* Histogram AEC/AGC Luminance High Level Threshold */ +#define LUMLTH 0x31 /* Histogram AEC/AGC Luminance Low Level Threshold */ +#define HREF 0x32 /* Image Start and Size Control */ +#define DM_LNL 0x33 /* Dummy Row Low 8 Bits */ +#define DM_LNH 0x34 /* Dummy Row High 8 Bits */ +#define ADOFF_B 0x35 /* AD Offset Compensation Value for B Channel */ +#define ADOFF_R 0x36 /* AD Offset Compensation Value for R Channel */ +#define ADOFF_GB 0x37 /* AD Offset Compensation Value for GB Channel */ +#define ADOFF_GR 0x38 /* AD Offset Compensation Value for GR Channel */ +#define OFF_B 0x39 /* AD Offset Compensation Value for B Channel */ +#define OFF_R 0x3A /* AD Offset Compensation Value for R Channel */ +#define OFF_GB 0x3B /* AD Offset Compensation Value for GB Channel */ +#define OFF_GR 0x3C /* AD Offset Compensation Value for GR Channel */ +#define COM12 0x3D /* DC offset compensation for analog process */ + +#define COM13 0x3E /* Common Control 13 */ +#define COM13_BLC_EN 0x80 /* BLC enable */ +#define COM13_ADC_EN 0x40 /* ADC channel BLC ON/OFF control */ +#define COM13_ANALOG_BLC 0x20 /* Analog processing channel BLC ON/OFF control */ +#define COM13_ABLC_GAIN_EN 0x04 /* ABLC gain trigger enable */ + +#define COM14 0x3F /* Common Control 14 */ +#define COM15 0x40 /* Common Control 15 */ +#define COM16 0x41 /* Common Control 16 */ +#define TGT_B 0x42 /* BLC Blue Channel Target Value */ +#define TGT_R 0x43 /* BLC Red Channel Target Value */ +#define TGT_GB 0x44 /* BLC Gb Channel Target Value */ +#define TGT_GR 0x45 /* BLC Gr Channel Target Value */ + +#define LC_CTR 0x46 /* Lens Correction Control */ +#define LC_CTR_RGB_COMP_1 0x00 /* R, G, and B channel compensation coefficient is set by LC_COEF (0x49) */ +#define LC_CTR_RGB_COMP_3 0x04 /* R, G, and B channel compensation coefficient is set by registers + LC_COEFB (0x4B), LC_COEF (0x49), and LC_COEFR (0x4C), respectively */ +#define LC_CTR_EN 0x01 /* Lens correction enable */ +#define LC_XC 0x47 /* X Coordinate of Lens Correction Center Relative to Array Center */ +#define LC_YC 0x48 /* Y Coordinate of Lens Correction Center Relative to Array Center */ +#define LC_COEF 0x49 /* Lens Correction Coefficient */ +#define LC_RADI 0x4A /* Lens Correction Radius */ +#define LC_COEFB 0x4B /* Lens Correction B Channel Compensation Coefficient */ +#define LC_COEFR 0x4C /* Lens Correction R Channel Compensation Coefficient */ + +#define FIXGAIN 0x4D /* Analog Fix Gain Amplifier */ +#define AREF0 0x4E /* Sensor Reference Control */ +#define AREF1 0x4F /* Sensor Reference Current Control */ +#define AREF2 0x50 /* Analog Reference Control */ +#define AREF3 0x51 /* ADC Reference Control */ +#define AREF4 0x52 /* ADC Reference Control */ +#define AREF5 0x53 /* ADC Reference Control */ +#define AREF6 0x54 /* Analog Reference Control */ +#define AREF7 0x55 /* Analog Reference Control */ +#define UFIX 0x60 /* U Channel Fixed Value Output */ +#define VFIX 0x61 /* V Channel Fixed Value Output */ +#define AWBB_BLK 0x62 /* AWB Option for Advanced AWB */ + +#define AWB_CTRL0 0x63 /* AWB Control Byte 0 */ +#define AWB_CTRL0_GAIN_EN 0x80 /* AWB gain enable */ +#define AWB_CTRL0_CALC_EN 0x40 /* AWB calculate enable */ +#define AWB_CTRL0_WBC_MASK 0x0F /* WBC threshold 2 */ + +#define DSP_CTRL1 0x64 /* DSP Control Byte 1 */ +#define DSP_CTRL1_FIFO_EN 0x80 /* FIFO enable/disable selection */ +#define DSP_CTRL1_UV_EN 0x40 /* UV adjust function ON/OFF selection */ +#define DSP_CTRL1_SDE_EN 0x20 /* SDE enable */ +#define DSP_CTRL1_MTRX_EN 0x10 /* Color matrix ON/OFF selection */ +#define DSP_CTRL1_INTRP_EN 0x08 /* Interpolation ON/OFF selection */ +#define DSP_CTRL1_GAMMA_EN 0x04 /* Gamma function ON/OFF selection */ +#define DSP_CTRL1_BLACK_EN 0x02 /* Black defect auto correction ON/OFF */ +#define DSP_CTRL1_WHITE_EN 0x01 /* White defect auto correction ON/OFF */ + +#define DSP_CTRL2 0x65 /* DSP Control Byte 2 */ +#define DSP_CTRL2_VDCW_EN 0x08 /* Vertical DCW enable */ +#define DSP_CTRL2_HDCW_EN 0x04 /* Horizontal DCW enable */ +#define DSP_CTRL2_VZOOM_EN 0x02 /* Vertical zoom out enable */ +#define DSP_CTRL2_HZOOM_EN 0x01 /* Horizontal zoom out enable */ + +#define DSP_CTRL3 0x66 /* DSP Control Byte 3 */ +#define DSP_CTRL3_UV_EN 0x80 /* UV output sequence option */ +#define DSP_CTRL3_CBAR_EN 0x20 /* DSP color bar ON/OFF selection */ +#define DSP_CTRL3_FIFO_EN 0x08 /* FIFO power down ON/OFF selection */ +#define DSP_CTRL3_SCAL1_PWDN 0x04 /* Scaling module power down control 1 */ +#define DSP_CTRL3_SCAL2_PWDN 0x02 /* Scaling module power down control 2 */ +#define DSP_CTRL3_INTRP_PWDN 0x01 /* Interpolation module power down control */ +#define DSP_CTRL3_SET_CBAR(r, x) ((r&0xDF)|((x&1)<<5)) + + +#define DSP_CTRL4 0x67 /* DSP Control Byte 4 */ +#define DSP_CTRL4_YUV_RGB 0x00 /* Output selection YUV or RGB */ +#define DSP_CTRL4_RAW8 0x02 /* Output selection RAW8 */ +#define DSP_CTRL4_RAW10 0x03 /* Output selection RAW10 */ + + +#define AWB_BIAS 0x68 /* AWB BLC Level Clip */ +#define AWB_CTRL1 0x69 /* AWB Control 1 */ +#define AWB_CTRL2 0x6A /* AWB Control 2 */ + +#define AWB_CTRL3 0x6B /* AWB Control 3 */ +#define AWB_CTRL3_ADVANCED 0x80 /* AWB mode select - Advanced AWB */ +#define AWB_CTRL3_SIMPLE 0x00 /* AWB mode select - Simple AWB */ + +#define AWB_CTRL4 0x6C /* AWB Control 4 */ +#define AWB_CTRL5 0x6D /* AWB Control 5 */ +#define AWB_CTRL6 0x6E /* AWB Control 6 */ +#define AWB_CTRL7 0x6F /* AWB Control 7 */ +#define AWB_CTRL8 0x70 /* AWB Control 8 */ +#define AWB_CTRL9 0x71 /* AWB Control 9 */ +#define AWB_CTRL10 0x72 /* AWB Control 10 */ +#define AWB_CTRL11 0x73 /* AWB Control 11 */ +#define AWB_CTRL12 0x74 /* AWB Control 12 */ +#define AWB_CTRL13 0x75 /* AWB Control 13 */ +#define AWB_CTRL14 0x76 /* AWB Control 14 */ +#define AWB_CTRL15 0x77 /* AWB Control 15 */ +#define AWB_CTRL16 0x78 /* AWB Control 16 */ +#define AWB_CTRL17 0x79 /* AWB Control 17 */ +#define AWB_CTRL18 0x7A /* AWB Control 18 */ +#define AWB_CTRL19 0x7B /* AWB Control 19 */ +#define AWB_CTRL20 0x7C /* AWB Control 20 */ +#define AWB_CTRL21 0x7D /* AWB Control 21 */ +#define GAM1 0x7E /* Gamma Curve 1st Segment Input End Point 0x04 Output Value */ +#define GAM2 0x7F /* Gamma Curve 2nd Segment Input End Point 0x08 Output Value */ +#define GAM3 0x80 /* Gamma Curve 3rd Segment Input End Point 0x10 Output Value */ +#define GAM4 0x81 /* Gamma Curve 4th Segment Input End Point 0x20 Output Value */ +#define GAM5 0x82 /* Gamma Curve 5th Segment Input End Point 0x28 Output Value */ +#define GAM6 0x83 /* Gamma Curve 6th Segment Input End Point 0x30 Output Value */ +#define GAM7 0x84 /* Gamma Curve 7th Segment Input End Point 0x38 Output Value */ +#define GAM8 0x85 /* Gamma Curve 8th Segment Input End Point 0x40 Output Value */ +#define GAM9 0x86 /* Gamma Curve 9th Segment Input End Point 0x48 Output Value */ +#define GAM10 0x87 /* Gamma Curve 10th Segment Input End Point 0x50 Output Value */ +#define GAM11 0x88 /* Gamma Curve 11th Segment Input End Point 0x60 Output Value */ +#define GAM12 0x89 /* Gamma Curve 12th Segment Input End Point 0x70 Output Value */ +#define GAM13 0x8A /* Gamma Curve 13th Segment Input End Point 0x90 Output Value */ +#define GAM14 0x8B /* Gamma Curve 14th Segment Input End Point 0xB0 Output Value */ +#define GAM15 0x8C /* Gamma Curve 15th Segment Input End Point 0xD0 Output Value */ +#define SLOP 0x8D /* Gamma Curve Highest Segment Slope */ +#define DNSTH 0x8E /* De-noise Threshold */ +#define EDGE0 0x8F /* Edge Enhancement Strength Control */ +#define EDGE1 0x90 /* Edge Enhancement Threshold Control */ +#define DNSOFF 0x91 /* Auto De-noise Threshold Control */ +#define EDGE2 0x92 /* Edge Enhancement Strength Upper Limit */ +#define EDGE3 0x93 /* Edge Enhancement Strength Upper Limit */ +#define MTX1 0x94 /* Matrix Coefficient 1 */ +#define MTX2 0x95 /* Matrix Coefficient 2 */ +#define MTX3 0x96 /* Matrix Coefficient 3 */ +#define MTX4 0x97 /* Matrix Coefficient 4 */ +#define MTX5 0x98 /* Matrix Coefficient 5 */ +#define MTX6 0x99 /* Matrix Coefficient 6 */ + +#define MTX_CTRL 0x9A /* Matrix Control */ +#define MTX_CTRL_DBL_EN 0x80 /* Matrix double ON/OFF selection */ + +#define BRIGHTNESS 0x9B /* Brightness Control */ +#define CONTRAST 0x9C /* Contrast Gain */ +#define UVADJ0 0x9E /* Auto UV Adjust Control 0 */ +#define UVADJ1 0x9F /* Auto UV Adjust Control 1 */ +#define SCAL0 0xA0 /* DCW Ratio Control */ +#define SCAL1 0xA1 /* Horizontal Zoom Out Control */ +#define SCAL2 0xA2 /* Vertical Zoom Out Control */ +#define FIFODLYM 0xA3 /* FIFO Manual Mode Delay Control */ +#define FIFODLYA 0xA4 /* FIFO Auto Mode Delay Control */ + +#define SDE 0xA6 /* Special Digital Effect Control */ +#define SDE_NEGATIVE_EN 0x40 /* Negative image enable */ +#define SDE_GRAYSCALE_EN 0x20 /* Gray scale image enable */ +#define SDE_V_FIXED_EN 0x10 /* V fixed value enable */ +#define SDE_U_FIXED_EN 0x08 /* U fixed value enable */ +#define SDE_CONT_BRIGHT_EN 0x04 /* Contrast/Brightness enable */ +#define SDE_SATURATION_EN 0x02 /* Saturation enable */ +#define SDE_HUE_EN 0x01 /* Hue enable */ + +#define USAT 0xA7 /* U Component Saturation Gain */ +#define VSAT 0xA8 /* V Component Saturation Gain */ +#define HUECOS 0xA9 /* Cosine value × 0x80 */ +#define HUESIN 0xAA /* Sine value × 0x80 */ +#define SIGN_BIT 0xAB /* Sign Bit for Hue and Brightness */ + +#define DSPAUTO 0xAC /* DSP Auto Function ON/OFF Control */ +#define DSPAUTO_AWB_EN 0x80 /* AWB auto threshold control */ +#define DSPAUTO_DENOISE_EN 0x40 /* De-noise auto threshold control */ +#define DSPAUTO_EDGE_EN 0x20 /* Sharpness (edge enhancement) auto strength control */ +#define DSPAUTO_UV_EN 0x10 /* UV adjust auto slope control */ +#define DSPAUTO_SCAL0_EN 0x08 /* Auto scaling factor control (register SCAL0 (0xA0)) */ +#define DSPAUTO_SCAL1_EN 0x04 /* Auto scaling factor control (registers SCAL1 (0xA1 and SCAL2 (0xA2))*/ +#define SET_REG(reg, x) (##reg_DEFAULT|x) +#endif //__REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c b/lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c new file mode 100644 index 000000000..e513205d2 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c @@ -0,0 +1,522 @@ +// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "soc/i2s_struct.h" +#include "esp_idf_version.h" +#if (ESP_IDF_VERSION_MAJOR >= 4) && (ESP_IDF_VERSION_MINOR > 1) +#include "hal/gpio_ll.h" +#else +#include "soc/gpio_periph.h" +#define esp_rom_delay_us ets_delay_us +static inline int gpio_ll_get_level(gpio_dev_t *hw, int gpio_num) +{ + if (gpio_num < 32) { + return (hw->in >> gpio_num) & 0x1; + } else { + return (hw->in1.data >> (gpio_num - 32)) & 0x1; + } +} +#endif +#include "ll_cam.h" +#include "xclk.h" +#include "cam_hal.h" + +static const char *TAG = "esp32 ll_cam"; + +#define I2S_ISR_ENABLE(i) {I2S0.int_clr.i = 1;I2S0.int_ena.i = 1;} +#define I2S_ISR_DISABLE(i) {I2S0.int_ena.i = 0;I2S0.int_clr.i = 1;} + +typedef union { + struct { + uint32_t sample2:8; + uint32_t unused2:8; + uint32_t sample1:8; + uint32_t unused1:8; + }; + uint32_t val; +} dma_elem_t; + +typedef enum { + /* camera sends byte sequence: s1, s2, s3, s4, ... + * fifo receives: 00 s1 00 s2, 00 s2 00 s3, 00 s3 00 s4, ... + */ + SM_0A0B_0B0C = 0, + /* camera sends byte sequence: s1, s2, s3, s4, ... + * fifo receives: 00 s1 00 s2, 00 s3 00 s4, ... + */ + SM_0A0B_0C0D = 1, + /* camera sends byte sequence: s1, s2, s3, s4, ... + * fifo receives: 00 s1 00 00, 00 s2 00 00, 00 s3 00 00, ... + */ + SM_0A00_0B00 = 3, +} i2s_sampling_mode_t; + +typedef size_t (*dma_filter_t)(uint8_t* dst, const uint8_t* src, size_t len); + +static i2s_sampling_mode_t sampling_mode = SM_0A00_0B00; + +static size_t ll_cam_bytes_per_sample(i2s_sampling_mode_t mode) +{ + switch(mode) { + case SM_0A00_0B00: + return 4; + case SM_0A0B_0B0C: + return 4; + case SM_0A0B_0C0D: + return 2; + default: + assert(0 && "invalid sampling mode"); + return 0; + } +} + +static size_t IRAM_ATTR ll_cam_dma_filter_jpeg(uint8_t* dst, const uint8_t* src, size_t len) +{ + const dma_elem_t* dma_el = (const dma_elem_t*)src; + size_t elements = len / sizeof(dma_elem_t); + size_t end = elements / 4; + // manually unrolling 4 iterations of the loop here + for (size_t i = 0; i < end; ++i) { + dst[0] = dma_el[0].sample1; + dst[1] = dma_el[1].sample1; + dst[2] = dma_el[2].sample1; + dst[3] = dma_el[3].sample1; + dma_el += 4; + dst += 4; + } + return elements; +} + +static size_t IRAM_ATTR ll_cam_dma_filter_grayscale(uint8_t* dst, const uint8_t* src, size_t len) +{ + const dma_elem_t* dma_el = (const dma_elem_t*)src; + size_t elements = len / sizeof(dma_elem_t); + size_t end = elements / 4; + for (size_t i = 0; i < end; ++i) { + // manually unrolling 4 iterations of the loop here + dst[0] = dma_el[0].sample1; + dst[1] = dma_el[1].sample1; + dst[2] = dma_el[2].sample1; + dst[3] = dma_el[3].sample1; + dma_el += 4; + dst += 4; + } + return elements; +} + +static size_t IRAM_ATTR ll_cam_dma_filter_grayscale_highspeed(uint8_t* dst, const uint8_t* src, size_t len) +{ + const dma_elem_t* dma_el = (const dma_elem_t*)src; + size_t elements = len / sizeof(dma_elem_t); + size_t end = elements / 8; + for (size_t i = 0; i < end; ++i) { + // manually unrolling 4 iterations of the loop here + dst[0] = dma_el[0].sample1; + dst[1] = dma_el[2].sample1; + dst[2] = dma_el[4].sample1; + dst[3] = dma_el[6].sample1; + dma_el += 8; + dst += 4; + } + // the final sample of a line in SM_0A0B_0B0C sampling mode needs special handling + if ((elements & 0x7) != 0) { + dst[0] = dma_el[0].sample1; + dst[1] = dma_el[2].sample1; + elements += 1; + } + return elements / 2; +} + +static size_t IRAM_ATTR ll_cam_dma_filter_yuyv(uint8_t* dst, const uint8_t* src, size_t len) +{ + const dma_elem_t* dma_el = (const dma_elem_t*)src; + size_t elements = len / sizeof(dma_elem_t); + size_t end = elements / 4; + for (size_t i = 0; i < end; ++i) { + dst[0] = dma_el[0].sample1;//y0 + dst[1] = dma_el[0].sample2;//u + dst[2] = dma_el[1].sample1;//y1 + dst[3] = dma_el[1].sample2;//v + + dst[4] = dma_el[2].sample1;//y0 + dst[5] = dma_el[2].sample2;//u + dst[6] = dma_el[3].sample1;//y1 + dst[7] = dma_el[3].sample2;//v + dma_el += 4; + dst += 8; + } + return elements * 2; +} + +static size_t IRAM_ATTR ll_cam_dma_filter_yuyv_highspeed(uint8_t* dst, const uint8_t* src, size_t len) +{ + const dma_elem_t* dma_el = (const dma_elem_t*)src; + size_t elements = len / sizeof(dma_elem_t); + size_t end = elements / 8; + for (size_t i = 0; i < end; ++i) { + dst[0] = dma_el[0].sample1;//y0 + dst[1] = dma_el[1].sample1;//u + dst[2] = dma_el[2].sample1;//y1 + dst[3] = dma_el[3].sample1;//v + + dst[4] = dma_el[4].sample1;//y0 + dst[5] = dma_el[5].sample1;//u + dst[6] = dma_el[6].sample1;//y1 + dst[7] = dma_el[7].sample1;//v + dma_el += 8; + dst += 8; + } + if ((elements & 0x7) != 0) { + dst[0] = dma_el[0].sample1;//y0 + dst[1] = dma_el[1].sample1;//u + dst[2] = dma_el[2].sample1;//y1 + dst[3] = dma_el[2].sample2;//v + elements += 4; + } + return elements; +} + +static void IRAM_ATTR ll_cam_vsync_isr(void *arg) +{ + //DBG_PIN_SET(1); + cam_obj_t *cam = (cam_obj_t *)arg; + BaseType_t HPTaskAwoken = pdFALSE; + // filter + ets_delay_us(1); + if (gpio_ll_get_level(&GPIO, cam->vsync_pin) == !cam->vsync_invert) { + ll_cam_send_event(cam, CAM_VSYNC_EVENT, &HPTaskAwoken); + if (HPTaskAwoken == pdTRUE) { + portYIELD_FROM_ISR(); + } + } + //DBG_PIN_SET(0); +} + +static void IRAM_ATTR ll_cam_dma_isr(void *arg) +{ + //DBG_PIN_SET(1); + cam_obj_t *cam = (cam_obj_t *)arg; + BaseType_t HPTaskAwoken = pdFALSE; + + typeof(I2S0.int_st) status = I2S0.int_st; + if (status.val == 0) { + return; + } + + I2S0.int_clr.val = status.val; + + if (status.in_suc_eof) { + ll_cam_send_event(cam, CAM_IN_SUC_EOF_EVENT, &HPTaskAwoken); + } + if (HPTaskAwoken == pdTRUE) { + portYIELD_FROM_ISR(); + } + //DBG_PIN_SET(0); +} + +bool ll_cam_stop(cam_obj_t *cam) +{ + I2S0.conf.rx_start = 0; + I2S_ISR_DISABLE(in_suc_eof); + I2S0.in_link.stop = 1; + return true; +} + +esp_err_t ll_cam_deinit(cam_obj_t *cam) +{ + gpio_isr_handler_remove(cam->vsync_pin); + + if (cam->cam_intr_handle) { + esp_intr_free(cam->cam_intr_handle); + cam->cam_intr_handle = NULL; + } + + return ESP_OK; +} + +bool ll_cam_start(cam_obj_t *cam, int frame_pos) +{ + I2S0.conf.rx_start = 0; + + I2S_ISR_ENABLE(in_suc_eof); + + I2S0.conf.rx_reset = 1; + I2S0.conf.rx_reset = 0; + I2S0.conf.rx_fifo_reset = 1; + I2S0.conf.rx_fifo_reset = 0; + I2S0.lc_conf.in_rst = 1; + I2S0.lc_conf.in_rst = 0; + I2S0.lc_conf.ahbm_fifo_rst = 1; + I2S0.lc_conf.ahbm_fifo_rst = 0; + I2S0.lc_conf.ahbm_rst = 1; + I2S0.lc_conf.ahbm_rst = 0; + + I2S0.rx_eof_num = cam->dma_half_buffer_size / sizeof(dma_elem_t); + I2S0.in_link.addr = ((uint32_t)&cam->dma[0]) & 0xfffff; + + I2S0.in_link.start = 1; + I2S0.conf.rx_start = 1; + return true; +} + +esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) +{ + // Enable and configure I2S peripheral + periph_module_enable(PERIPH_I2S0_MODULE); + + I2S0.conf.rx_reset = 1; + I2S0.conf.rx_reset = 0; + I2S0.conf.rx_fifo_reset = 1; + I2S0.conf.rx_fifo_reset = 0; + I2S0.lc_conf.in_rst = 1; + I2S0.lc_conf.in_rst = 0; + I2S0.lc_conf.ahbm_fifo_rst = 1; + I2S0.lc_conf.ahbm_fifo_rst = 0; + I2S0.lc_conf.ahbm_rst = 1; + I2S0.lc_conf.ahbm_rst = 0; + + I2S0.conf.rx_slave_mod = 1; + I2S0.conf.rx_right_first = 0; + I2S0.conf.rx_msb_right = 0; + I2S0.conf.rx_msb_shift = 0; + I2S0.conf.rx_mono = 0; + I2S0.conf.rx_short_sync = 0; + + I2S0.conf2.lcd_en = 1; + I2S0.conf2.camera_en = 1; + + // Configure clock divider + I2S0.clkm_conf.clkm_div_a = 0; + I2S0.clkm_conf.clkm_div_b = 0; + I2S0.clkm_conf.clkm_div_num = 2; + + I2S0.fifo_conf.dscr_en = 1; + I2S0.fifo_conf.rx_fifo_mod = sampling_mode; + I2S0.fifo_conf.rx_fifo_mod_force_en = 1; + + I2S0.conf_chan.rx_chan_mod = 1; + I2S0.sample_rate_conf.rx_bits_mod = 0; + I2S0.timing.val = 0; + I2S0.timing.rx_dsync_sw = 1; + + return ESP_OK; +} + +void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) +{ + if (en) { + gpio_intr_enable(cam->vsync_pin); + } else { + gpio_intr_disable(cam->vsync_pin); + } +} + +esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) +{ + gpio_config_t io_conf = {0}; + io_conf.intr_type = cam->vsync_invert ? GPIO_PIN_INTR_NEGEDGE : GPIO_PIN_INTR_POSEDGE; + io_conf.pin_bit_mask = 1ULL << config->pin_vsync; + io_conf.mode = GPIO_MODE_INPUT; + io_conf.pull_up_en = 1; + io_conf.pull_down_en = 0; + gpio_config(&io_conf); + gpio_install_isr_service(ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM); + gpio_isr_handler_add(config->pin_vsync, ll_cam_vsync_isr, cam); + gpio_intr_disable(config->pin_vsync); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_pclk], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_pclk, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_pclk, GPIO_FLOATING); + gpio_matrix_in(config->pin_pclk, I2S0I_WS_IN_IDX, false); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_vsync], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_vsync, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_vsync, GPIO_FLOATING); + gpio_matrix_in(config->pin_vsync, I2S0I_V_SYNC_IDX, false); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_href], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_href, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_href, GPIO_FLOATING); + gpio_matrix_in(config->pin_href, I2S0I_H_SYNC_IDX, false); + + int data_pins[8] = { + config->pin_d0, config->pin_d1, config->pin_d2, config->pin_d3, config->pin_d4, config->pin_d5, config->pin_d6, config->pin_d7, + }; + for (int i = 0; i < 8; i++) { + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[data_pins[i]], PIN_FUNC_GPIO); + gpio_set_direction(data_pins[i], GPIO_MODE_INPUT); + gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); + gpio_matrix_in(data_pins[i], I2S0I_DATA_IN0_IDX + i, false); + } + + gpio_matrix_in(0x38, I2S0I_H_ENABLE_IDX, false); + return ESP_OK; +} + +esp_err_t ll_cam_init_isr(cam_obj_t *cam) +{ + return esp_intr_alloc(ETS_I2S0_INTR_SOURCE, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, ll_cam_dma_isr, cam, &cam->cam_intr_handle); +} + +void ll_cam_do_vsync(cam_obj_t *cam) +{ +} + +uint8_t ll_cam_get_dma_align(cam_obj_t *cam) +{ + return 0; +} + +static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ + size_t dma_half_buffer_max = CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX / 2 / cam->dma_bytes_per_item; + size_t dma_buffer_max = 2 * dma_half_buffer_max; + size_t node_max = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE / cam->dma_bytes_per_item; + + size_t line_width = cam->width * cam->in_bytes_per_pixel; + size_t image_size = cam->height * line_width; + if (image_size > (4 * 1024 * 1024) || (line_width > dma_half_buffer_max)) { + ESP_LOGE(TAG, "Resolution too high"); + return 0; + } + + size_t node_size = node_max; + size_t nodes_per_line = 1; + size_t lines_per_node = 1; + size_t lines_per_half_buffer = 1; + size_t dma_half_buffer_min = node_max; + size_t dma_half_buffer = dma_half_buffer_max; + size_t dma_buffer_size = dma_buffer_max; + + // Calculate DMA Node Size so that it's divisable by or divisor of the line width + if(line_width >= node_max){ + // One or more nodes will be requied for one line + for(size_t i = node_max; i > 0; i=i-1){ + if ((line_width % i) == 0) { + node_size = i; + nodes_per_line = line_width / node_size; + break; + } + } + } else { + // One or more lines can fit into one node + for(size_t i = node_max; i > 0; i=i-1){ + if ((i % line_width) == 0) { + node_size = i; + lines_per_node = node_size / line_width; + while((cam->height % lines_per_node) != 0){ + lines_per_node = lines_per_node - 1; + node_size = lines_per_node * line_width; + } + break; + } + } + } + // Calculate minimum EOF size = max(mode_size, line_size) + dma_half_buffer_min = node_size * nodes_per_line; + // Calculate max EOF size divisable by node size + dma_half_buffer = (dma_half_buffer_max / dma_half_buffer_min) * dma_half_buffer_min; + // Adjust EOF size so that height will be divisable by the number of lines in each EOF + lines_per_half_buffer = dma_half_buffer / line_width; + while((cam->height % lines_per_half_buffer) != 0){ + dma_half_buffer = dma_half_buffer - dma_half_buffer_min; + lines_per_half_buffer = dma_half_buffer / line_width; + } + // Calculate DMA size + dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; + + ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u, dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u, image_size: %u", + node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node, dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item, image_size); + + cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; + cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; + cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; + cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; + return 1; +} + +bool ll_cam_dma_sizes(cam_obj_t *cam) +{ + cam->dma_bytes_per_item = ll_cam_bytes_per_sample(sampling_mode); + if (cam->jpeg_mode) { + cam->dma_half_buffer_cnt = 8; + cam->dma_node_buffer_size = 2048; + cam->dma_half_buffer_size = cam->dma_node_buffer_size * 2; + cam->dma_buffer_size = cam->dma_half_buffer_cnt * cam->dma_half_buffer_size; + } else { + return ll_cam_calc_rgb_dma(cam); + } + return 1; +} + +static dma_filter_t dma_filter = ll_cam_dma_filter_jpeg; + +size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len) +{ + //DBG_PIN_SET(1); + size_t r = dma_filter(out, in, len); + //DBG_PIN_SET(0); + return r; +} + +esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid) +{ + if (pix_format == PIXFORMAT_GRAYSCALE) { + if (sensor_pid == OV3660_PID || sensor_pid == OV5640_PID || sensor_pid == NT99141_PID) { + if (xclk_freq_hz > 10000000) { + sampling_mode = SM_0A00_0B00; + dma_filter = ll_cam_dma_filter_yuyv_highspeed; + } else { + sampling_mode = SM_0A0B_0C0D; + dma_filter = ll_cam_dma_filter_yuyv; + } + cam->in_bytes_per_pixel = 1; // camera sends Y8 + } else { + if (xclk_freq_hz > 10000000 && sensor_pid != OV7725_PID) { + sampling_mode = SM_0A00_0B00; + dma_filter = ll_cam_dma_filter_grayscale_highspeed; + } else { + sampling_mode = SM_0A0B_0C0D; + dma_filter = ll_cam_dma_filter_grayscale; + } + cam->in_bytes_per_pixel = 2; // camera sends YU/YV + } + cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 + } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { + if (xclk_freq_hz > 10000000 && sensor_pid != OV7725_PID) { + if (sensor_pid == OV7670_PID) { + sampling_mode = SM_0A0B_0B0C; + } else { + sampling_mode = SM_0A00_0B00; + } + dma_filter = ll_cam_dma_filter_yuyv_highspeed; + } else { + sampling_mode = SM_0A0B_0C0D; + dma_filter = ll_cam_dma_filter_yuyv; + } + cam->in_bytes_per_pixel = 2; // camera sends YU/YV + cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 + } else if (pix_format == PIXFORMAT_JPEG) { + cam->in_bytes_per_pixel = 1; + cam->fb_bytes_per_pixel = 1; + dma_filter = ll_cam_dma_filter_jpeg; + sampling_mode = SM_0A00_0B00; + } else { + ESP_LOGE(TAG, "Requested format is not supported"); + return ESP_ERR_NOT_SUPPORTED; + } + I2S0.fifo_conf.rx_fifo_mod = sampling_mode; + return ESP_OK; +} diff --git a/lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c b/lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c new file mode 100644 index 000000000..d3cb5353b --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c @@ -0,0 +1,402 @@ +// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "soc/system_reg.h" +#include "soc/i2s_struct.h" +#include "hal/gpio_ll.h" +#include "ll_cam.h" +#include "xclk.h" +#include "cam_hal.h" + +static const char *TAG = "s2 ll_cam"; + +#define I2S_ISR_ENABLE(i) {I2S0.int_clr.i = 1;I2S0.int_ena.i = 1;} +#define I2S_ISR_DISABLE(i) {I2S0.int_ena.i = 0;I2S0.int_clr.i = 1;} + +static void IRAM_ATTR ll_cam_vsync_isr(void *arg) +{ + //DBG_PIN_SET(1); + cam_obj_t *cam = (cam_obj_t *)arg; + BaseType_t HPTaskAwoken = pdFALSE; + // filter + ets_delay_us(1); + if (gpio_ll_get_level(&GPIO, cam->vsync_pin) == !cam->vsync_invert) { + ll_cam_send_event(cam, CAM_VSYNC_EVENT, &HPTaskAwoken); + } + + if (HPTaskAwoken == pdTRUE) { + portYIELD_FROM_ISR(); + } + //DBG_PIN_SET(0); +} + +static void IRAM_ATTR ll_cam_dma_isr(void *arg) +{ + cam_obj_t *cam = (cam_obj_t *)arg; + BaseType_t HPTaskAwoken = pdFALSE; + + typeof(I2S0.int_st) status = I2S0.int_st; + if (status.val == 0) { + return; + } + + I2S0.int_clr.val = status.val; + + if (status.in_suc_eof) { + ll_cam_send_event(cam, CAM_IN_SUC_EOF_EVENT, &HPTaskAwoken); + } + + if (HPTaskAwoken == pdTRUE) { + portYIELD_FROM_ISR(); + } +} + +bool ll_cam_stop(cam_obj_t *cam) +{ + I2S0.conf.rx_start = 0; + + if (cam->jpeg_mode || !cam->psram_mode) { + I2S_ISR_DISABLE(in_suc_eof); + } + + I2S0.in_link.stop = 1; + return true; +} + +esp_err_t ll_cam_deinit(cam_obj_t *cam) +{ + gpio_isr_handler_remove(cam->vsync_pin); + + if (cam->cam_intr_handle) { + esp_intr_free(cam->cam_intr_handle); + cam->cam_intr_handle = NULL; + } + + return ESP_OK; +} + +bool ll_cam_start(cam_obj_t *cam, int frame_pos) +{ + I2S0.conf.rx_start = 0; + + if (cam->jpeg_mode || !cam->psram_mode) { + I2S_ISR_ENABLE(in_suc_eof); + } + + I2S0.conf.rx_reset = 1; + I2S0.conf.rx_reset = 0; + I2S0.conf.rx_fifo_reset = 1; + I2S0.conf.rx_fifo_reset = 0; + I2S0.lc_conf.in_rst = 1; + I2S0.lc_conf.in_rst = 0; + I2S0.lc_conf.ahbm_fifo_rst = 1; + I2S0.lc_conf.ahbm_fifo_rst = 0; + I2S0.lc_conf.ahbm_rst = 1; + I2S0.lc_conf.ahbm_rst = 0; + + I2S0.rx_eof_num = cam->dma_half_buffer_size; // Ping pong operation + if (!cam->psram_mode) { + I2S0.in_link.addr = ((uint32_t)&cam->dma[0]) & 0xfffff; + } else { + I2S0.in_link.addr = ((uint32_t)&cam->frames[frame_pos].dma[0]) & 0xfffff; + } + + I2S0.in_link.start = 1; + I2S0.conf.rx_start = 1; + return true; +} + +esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) +{ + esp_err_t err = camera_enable_out_clock(config); + if(err != ESP_OK) { + return err; + } + periph_module_enable(PERIPH_I2S0_MODULE); + // Configure the clock + I2S0.clkm_conf.clkm_div_num = 2; // 160MHz / 2 = 80MHz + I2S0.clkm_conf.clkm_div_b = 0; + I2S0.clkm_conf.clkm_div_a = 0; + I2S0.clkm_conf.clk_sel = 2; + I2S0.clkm_conf.clk_en = 1; + + + I2S0.conf.val = 0; + I2S0.fifo_conf.val = 0; + I2S0.fifo_conf.dscr_en = 1; + + I2S0.lc_conf.ahbm_fifo_rst = 1; + I2S0.lc_conf.ahbm_fifo_rst = 0; + I2S0.lc_conf.ahbm_rst = 1; + I2S0.lc_conf.ahbm_rst = 0; + I2S0.lc_conf.check_owner = 0; + //I2S0.lc_conf.indscr_burst_en = 1; + //I2S0.lc_conf.ext_mem_bk_size = 0; // DMA access external memory block size. 0: 16 bytes, 1: 32 bytes, 2:64 bytes, 3:reserved + + I2S0.timing.val = 0; + + I2S0.int_ena.val = 0; + I2S0.int_clr.val = ~0; + + I2S0.conf2.lcd_en = 1; + I2S0.conf2.camera_en = 1; + + // Configuration data format + I2S0.conf.rx_slave_mod = 1; + I2S0.conf.rx_right_first = 0; + I2S0.conf.rx_msb_right = cam->swap_data; + I2S0.conf.rx_short_sync = 0; + I2S0.conf.rx_mono = 0; + I2S0.conf.rx_msb_shift = 0; + I2S0.conf.rx_dma_equal = 1; + + // Configure sampling rate + I2S0.sample_rate_conf.rx_bck_div_num = 1; + I2S0.sample_rate_conf.rx_bits_mod = 8; + + I2S0.conf1.rx_pcm_bypass = 1; + + I2S0.conf2.i_v_sync_filter_en = 1; + I2S0.conf2.i_v_sync_filter_thres = 4; + I2S0.conf2.cam_sync_fifo_reset = 1; + I2S0.conf2.cam_sync_fifo_reset = 0; + + I2S0.conf_chan.rx_chan_mod = 1; + + I2S0.fifo_conf.rx_fifo_mod_force_en = 1; + I2S0.fifo_conf.rx_data_num = 32; + I2S0.fifo_conf.rx_fifo_mod = 2; + + I2S0.lc_conf.in_rst = 1; + I2S0.lc_conf.in_rst = 0; + + I2S0.conf.rx_start = 1; + + return ESP_OK; +} + +void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) +{ + if (en) { + gpio_intr_enable(cam->vsync_pin); + } else { + gpio_intr_disable(cam->vsync_pin); + } +} + +esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) +{ + gpio_config_t io_conf = {0}; + io_conf.intr_type = cam->vsync_invert ? GPIO_PIN_INTR_NEGEDGE : GPIO_PIN_INTR_POSEDGE; + io_conf.pin_bit_mask = 1ULL << config->pin_vsync; + io_conf.mode = GPIO_MODE_INPUT; + io_conf.pull_up_en = 1; + io_conf.pull_down_en = 0; + gpio_config(&io_conf); + gpio_install_isr_service(ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM); + gpio_isr_handler_add(config->pin_vsync, ll_cam_vsync_isr, cam); + gpio_intr_disable(config->pin_vsync); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_pclk], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_pclk, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_pclk, GPIO_FLOATING); + gpio_matrix_in(config->pin_pclk, I2S0I_WS_IN_IDX, false); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_vsync], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_vsync, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_vsync, GPIO_FLOATING); + gpio_matrix_in(config->pin_vsync, I2S0I_V_SYNC_IDX, cam->vsync_invert); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_href], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_href, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_href, GPIO_FLOATING); + gpio_matrix_in(config->pin_href, I2S0I_H_SYNC_IDX, false); + + int data_pins[8] = { + config->pin_d0, config->pin_d1, config->pin_d2, config->pin_d3, config->pin_d4, config->pin_d5, config->pin_d6, config->pin_d7, + }; + for (int i = 0; i < 8; i++) { + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[data_pins[i]], PIN_FUNC_GPIO); + gpio_set_direction(data_pins[i], GPIO_MODE_INPUT); + gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); + // High bit alignment, IN16 is always the highest bit + // fifo accesses data by bit, when rx_bits_mod is 8, the data needs to be aligned by 8 bits + gpio_matrix_in(data_pins[i], I2S0I_DATA_IN0_IDX + 8 + i, false); + } + + gpio_matrix_in(0x38, I2S0I_H_ENABLE_IDX, false); + + return ESP_OK; +} + +esp_err_t ll_cam_init_isr(cam_obj_t *cam) +{ + return esp_intr_alloc(ETS_I2S0_INTR_SOURCE, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, ll_cam_dma_isr, cam, &cam->cam_intr_handle); +} + +void ll_cam_do_vsync(cam_obj_t *cam) +{ + ll_cam_vsync_intr_enable(cam, false); + gpio_matrix_in(cam->vsync_pin, I2S0I_V_SYNC_IDX, !cam->vsync_invert); + ets_delay_us(10); + gpio_matrix_in(cam->vsync_pin, I2S0I_V_SYNC_IDX, cam->vsync_invert); + ll_cam_vsync_intr_enable(cam, true); +} + +uint8_t ll_cam_get_dma_align(cam_obj_t *cam) +{ + return 64;//16 << I2S0.lc_conf.ext_mem_bk_size; +} + +static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ + size_t node_max = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE / cam->dma_bytes_per_item; + size_t line_width = cam->width * cam->in_bytes_per_pixel; + size_t node_size = node_max; + size_t nodes_per_line = 1; + size_t lines_per_node = 1; + + // Calculate DMA Node Size so that it's divisable by or divisor of the line width + if(line_width >= node_max){ + // One or more nodes will be requied for one line + for(size_t i = node_max; i > 0; i=i-1){ + if ((line_width % i) == 0) { + node_size = i; + nodes_per_line = line_width / node_size; + break; + } + } + } else { + // One or more lines can fit into one node + for(size_t i = node_max; i > 0; i=i-1){ + if ((i % line_width) == 0) { + node_size = i; + lines_per_node = node_size / line_width; + while((cam->height % lines_per_node) != 0){ + lines_per_node = lines_per_node - 1; + node_size = lines_per_node * line_width; + } + break; + } + } + } + + ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", + node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node); + + cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; + + if (cam->psram_mode) { + cam->dma_buffer_size = cam->recv_size * cam->dma_bytes_per_item; + cam->dma_half_buffer_cnt = 2; + cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt; + } else { + size_t dma_half_buffer_max = CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX / 2 / cam->dma_bytes_per_item; + if (line_width > dma_half_buffer_max) { + ESP_LOGE(TAG, "Resolution too high"); + return 0; + } + + // Calculate minimum EOF size = max(mode_size, line_size) + size_t dma_half_buffer_min = node_size * nodes_per_line; + + // Calculate max EOF size divisable by node size + size_t dma_half_buffer = (dma_half_buffer_max / dma_half_buffer_min) * dma_half_buffer_min; + + // Adjust EOF size so that height will be divisable by the number of lines in each EOF + size_t lines_per_half_buffer = dma_half_buffer / line_width; + while((cam->height % lines_per_half_buffer) != 0){ + dma_half_buffer = dma_half_buffer - dma_half_buffer_min; + lines_per_half_buffer = dma_half_buffer / line_width; + } + + // Calculate DMA size + size_t dma_buffer_max = 2 * dma_half_buffer_max; + size_t dma_buffer_size = dma_buffer_max; + dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; + + ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", + dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item); + + cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; + cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; + cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; + } + return 1; +} + +bool ll_cam_dma_sizes(cam_obj_t *cam) +{ + cam->dma_bytes_per_item = 1; + if (cam->jpeg_mode) { + if (cam->psram_mode) { + cam->dma_buffer_size = cam->recv_size; + cam->dma_half_buffer_size = 1024; + cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; + cam->dma_node_buffer_size = cam->dma_half_buffer_size; + } else { + cam->dma_half_buffer_cnt = 16; + cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024; + cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt; + cam->dma_node_buffer_size = cam->dma_half_buffer_size; + } + } else { + return ll_cam_calc_rgb_dma(cam); + } + return 1; +} + +size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len) +{ + // YUV to Grayscale + if (cam->in_bytes_per_pixel == 2 && cam->fb_bytes_per_pixel == 1) { + size_t end = len / 8; + for (size_t i = 0; i < end; ++i) { + out[0] = in[0]; + out[1] = in[2]; + out[2] = in[4]; + out[3] = in[6]; + out += 4; + in += 8; + } + return len / 2; + } + + // just memcpy + memcpy(out, in, len); + return len; +} + +esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid) +{ + if (pix_format == PIXFORMAT_GRAYSCALE) { + if (sensor_pid == OV3660_PID || sensor_pid == OV5640_PID || sensor_pid == NT99141_PID) { + cam->in_bytes_per_pixel = 1; // camera sends Y8 + } else { + cam->in_bytes_per_pixel = 2; // camera sends YU/YV + } + cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 + } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { + cam->in_bytes_per_pixel = 2; // camera sends YU/YV + cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 + } else if (pix_format == PIXFORMAT_JPEG) { + cam->in_bytes_per_pixel = 1; + cam->fb_bytes_per_pixel = 1; + } else { + ESP_LOGE(TAG, "Requested format is not supported"); + return ESP_ERR_NOT_SUPPORTED; + } + return ESP_OK; +} diff --git a/lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h b/lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h new file mode 100644 index 000000000..31fbc97cc --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h @@ -0,0 +1,99 @@ +/*----------------------------------------------------------------------------/ +/ TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2012 +/----------------------------------------------------------------------------*/ +#ifndef _TJPGDEC +#define _TJPGDEC +/*---------------------------------------------------------------------------*/ +/* System Configurations */ + +#define JD_SZBUF 512 /* Size of stream input buffer */ +#define JD_FORMAT 0 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */ +#define JD_USE_SCALE 1 /* Use descaling feature for output */ +#define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */ + +/*---------------------------------------------------------------------------*/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* These types must be 16-bit, 32-bit or larger integer */ +typedef int INT; +typedef unsigned int UINT; + +/* These types must be 8-bit integer */ +typedef char CHAR; +typedef unsigned char UCHAR; +typedef unsigned char BYTE; + +/* These types must be 16-bit integer */ +typedef short SHORT; +typedef unsigned short USHORT; +typedef unsigned short WORD; +typedef unsigned short WCHAR; + +/* These types must be 32-bit integer */ +typedef long LONG; +typedef unsigned long ULONG; +typedef unsigned long DWORD; + + +/* Error code */ +typedef enum { + JDR_OK = 0, /* 0: Succeeded */ + JDR_INTR, /* 1: Interrupted by output function */ + JDR_INP, /* 2: Device error or wrong termination of input stream */ + JDR_MEM1, /* 3: Insufficient memory pool for the image */ + JDR_MEM2, /* 4: Insufficient stream input buffer */ + JDR_PAR, /* 5: Parameter error */ + JDR_FMT1, /* 6: Data format error (may be damaged data) */ + JDR_FMT2, /* 7: Right format but not supported */ + JDR_FMT3 /* 8: Not supported JPEG standard */ +} JRESULT; + + + +/* Rectangular structure */ +typedef struct { + WORD left, right, top, bottom; +} JRECT; + + + +/* Decompressor object structure */ +typedef struct JDEC JDEC; +struct JDEC { + UINT dctr; /* Number of bytes available in the input buffer */ + BYTE* dptr; /* Current data read ptr */ + BYTE* inbuf; /* Bit stream input buffer */ + BYTE dmsk; /* Current bit in the current read byte */ + BYTE scale; /* Output scaling ratio */ + BYTE msx, msy; /* MCU size in unit of block (width, height) */ + BYTE qtid[3]; /* Quantization table ID of each component */ + SHORT dcv[3]; /* Previous DC element of each component */ + WORD nrst; /* Restart inverval */ + UINT width, height; /* Size of the input image (pixel) */ + BYTE* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ + WORD* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ + BYTE* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ + LONG* qttbl[4]; /* Dequaitizer tables [id] */ + void* workbuf; /* Working buffer for IDCT and RGB output */ + BYTE* mcubuf; /* Working buffer for the MCU */ + void* pool; /* Pointer to available memory pool */ + UINT sz_pool; /* Size of momory pool (bytes available) */ + UINT (*infunc)(JDEC*, BYTE*, UINT);/* Pointer to jpeg stream input function */ + void* device; /* Pointer to I/O device identifiler for the session */ +}; + + + +/* TJpgDec API functions */ +JRESULT jd_prepare (JDEC*, UINT(*)(JDEC*,BYTE*,UINT), void*, UINT, void*); +JRESULT jd_decomp (JDEC*, UINT(*)(JDEC*,void*,JRECT*), BYTE); + + +#ifdef __cplusplus +} +#endif + +#endif /* _TJPGDEC */ diff --git a/lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c b/lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c new file mode 100644 index 000000000..5a983c4c7 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c @@ -0,0 +1,970 @@ +/*----------------------------------------------------------------------------/ +/ TJpgDec - Tiny JPEG Decompressor R0.01b (C)ChaN, 2012 +/-----------------------------------------------------------------------------/ +/ The TJpgDec is a generic JPEG decompressor module for tiny embedded systems. +/ This is a free software that opened for education, research and commercial +/ developments under license policy of following terms. +/ +/ Copyright (C) 2012, ChaN, all right reserved. +/ +/ * The TJpgDec module is a free software and there is NO WARRANTY. +/ * No restriction on use. You can use, modify and redistribute it for +/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. +/ * Redistributions of source code must retain the above copyright notice. +/ +/-----------------------------------------------------------------------------/ +/ Oct 04,'11 R0.01 First release. +/ Feb 19,'12 R0.01a Fixed decompression fails when scan starts with an escape seq. +/ Sep 03,'12 R0.01b Added JD_TBLCLIP option. +/----------------------------------------------------------------------------*/ + +#include "tjpgd.h" + +#define SUPPORT_JPEG 1 + +#ifdef SUPPORT_JPEG +/*-----------------------------------------------*/ +/* Zigzag-order to raster-order conversion table */ +/*-----------------------------------------------*/ + +#define ZIG(n) Zig[n] + +static +const BYTE Zig[64] = { /* Zigzag-order to raster-order conversion table */ + 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 +}; + + + +/*-------------------------------------------------*/ +/* Input scale factor of Arai algorithm */ +/* (scaled up 16 bits for fixed point operations) */ +/*-------------------------------------------------*/ + +#define IPSF(n) Ipsf[n] + +static +const WORD Ipsf[64] = { /* See also aa_idct.png */ + (WORD)(1.00000*8192), (WORD)(1.38704*8192), (WORD)(1.30656*8192), (WORD)(1.17588*8192), (WORD)(1.00000*8192), (WORD)(0.78570*8192), (WORD)(0.54120*8192), (WORD)(0.27590*8192), + (WORD)(1.38704*8192), (WORD)(1.92388*8192), (WORD)(1.81226*8192), (WORD)(1.63099*8192), (WORD)(1.38704*8192), (WORD)(1.08979*8192), (WORD)(0.75066*8192), (WORD)(0.38268*8192), + (WORD)(1.30656*8192), (WORD)(1.81226*8192), (WORD)(1.70711*8192), (WORD)(1.53636*8192), (WORD)(1.30656*8192), (WORD)(1.02656*8192), (WORD)(0.70711*8192), (WORD)(0.36048*8192), + (WORD)(1.17588*8192), (WORD)(1.63099*8192), (WORD)(1.53636*8192), (WORD)(1.38268*8192), (WORD)(1.17588*8192), (WORD)(0.92388*8192), (WORD)(0.63638*8192), (WORD)(0.32442*8192), + (WORD)(1.00000*8192), (WORD)(1.38704*8192), (WORD)(1.30656*8192), (WORD)(1.17588*8192), (WORD)(1.00000*8192), (WORD)(0.78570*8192), (WORD)(0.54120*8192), (WORD)(0.27590*8192), + (WORD)(0.78570*8192), (WORD)(1.08979*8192), (WORD)(1.02656*8192), (WORD)(0.92388*8192), (WORD)(0.78570*8192), (WORD)(0.61732*8192), (WORD)(0.42522*8192), (WORD)(0.21677*8192), + (WORD)(0.54120*8192), (WORD)(0.75066*8192), (WORD)(0.70711*8192), (WORD)(0.63638*8192), (WORD)(0.54120*8192), (WORD)(0.42522*8192), (WORD)(0.29290*8192), (WORD)(0.14932*8192), + (WORD)(0.27590*8192), (WORD)(0.38268*8192), (WORD)(0.36048*8192), (WORD)(0.32442*8192), (WORD)(0.27590*8192), (WORD)(0.21678*8192), (WORD)(0.14932*8192), (WORD)(0.07612*8192) +}; + + + +/*---------------------------------------------*/ +/* Conversion table for fast clipping process */ +/*---------------------------------------------*/ + +#if JD_TBLCLIP + +#define BYTECLIP(v) Clip8[(UINT)(v) & 0x3FF] + +static +const BYTE Clip8[1024] = { + /* 0..255 */ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, + 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, + 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, + 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, + /* 256..511 */ + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, + /* -512..-257 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* -256..-1 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +#else /* JD_TBLCLIP */ + +inline +BYTE BYTECLIP ( + INT val +) +{ + if (val < 0) val = 0; + if (val > 255) val = 255; + + return (BYTE)val; +} + +#endif + + + +/*-----------------------------------------------------------------------*/ +/* Allocate a memory block from memory pool */ +/*-----------------------------------------------------------------------*/ + +static +void* alloc_pool ( /* Pointer to allocated memory block (NULL:no memory available) */ + JDEC* jd, /* Pointer to the decompressor object */ + UINT nd /* Number of bytes to allocate */ +) +{ + char *rp = 0; + + + nd = (nd + 3) & ~3; /* Align block size to the word boundary */ + + if (jd->sz_pool >= nd) { + jd->sz_pool -= nd; + rp = (char*)jd->pool; /* Get start of available memory pool */ + jd->pool = (void*)(rp + nd); /* Allocate requierd bytes */ + } + + return (void*)rp; /* Return allocated memory block (NULL:no memory to allocate) */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Create de-quantization and prescaling tables with a DQT segment */ +/*-----------------------------------------------------------------------*/ + +static +UINT create_qt_tbl ( /* 0:OK, !0:Failed */ + JDEC* jd, /* Pointer to the decompressor object */ + const BYTE* data, /* Pointer to the quantizer tables */ + UINT ndata /* Size of input data */ +) +{ + UINT i; + BYTE d, z; + LONG *pb; + + + while (ndata) { /* Process all tables in the segment */ + if (ndata < 65) return JDR_FMT1; /* Err: table size is unaligned */ + ndata -= 65; + d = *data++; /* Get table property */ + if (d & 0xF0) return JDR_FMT1; /* Err: not 8-bit resolution */ + i = d & 3; /* Get table ID */ + pb = alloc_pool(jd, 64 * sizeof (LONG));/* Allocate a memory block for the table */ + if (!pb) return JDR_MEM1; /* Err: not enough memory */ + jd->qttbl[i] = pb; /* Register the table */ + for (i = 0; i < 64; i++) { /* Load the table */ + z = ZIG(i); /* Zigzag-order to raster-order conversion */ + pb[z] = (LONG)((DWORD)*data++ * IPSF(z)); /* Apply scale factor of Arai algorithm to the de-quantizers */ + } + } + + return JDR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Create huffman code tables with a DHT segment */ +/*-----------------------------------------------------------------------*/ + +static +UINT create_huffman_tbl ( /* 0:OK, !0:Failed */ + JDEC* jd, /* Pointer to the decompressor object */ + const BYTE* data, /* Pointer to the packed huffman tables */ + UINT ndata /* Size of input data */ +) +{ + UINT i, j, b, np, cls, num; + BYTE d, *pb, *pd; + WORD hc, *ph; + + + while (ndata) { /* Process all tables in the segment */ + if (ndata < 17) return JDR_FMT1; /* Err: wrong data size */ + ndata -= 17; + d = *data++; /* Get table number and class */ + cls = (d >> 4); num = d & 0x0F; /* class = dc(0)/ac(1), table number = 0/1 */ + if (d & 0xEE) return JDR_FMT1; /* Err: invalid class/number */ + pb = alloc_pool(jd, 16); /* Allocate a memory block for the bit distribution table */ + if (!pb) return JDR_MEM1; /* Err: not enough memory */ + jd->huffbits[num][cls] = pb; + for (np = i = 0; i < 16; i++) { /* Load number of patterns for 1 to 16-bit code */ + pb[i] = b = *data++; + np += b; /* Get sum of code words for each code */ + } + + ph = alloc_pool(jd, np * sizeof (WORD));/* Allocate a memory block for the code word table */ + if (!ph) return JDR_MEM1; /* Err: not enough memory */ + jd->huffcode[num][cls] = ph; + hc = 0; + for (j = i = 0; i < 16; i++) { /* Re-build huffman code word table */ + b = pb[i]; + while (b--) ph[j++] = hc++; + hc <<= 1; + } + + if (ndata < np) return JDR_FMT1; /* Err: wrong data size */ + ndata -= np; + pd = alloc_pool(jd, np); /* Allocate a memory block for the decoded data */ + if (!pd) return JDR_MEM1; /* Err: not enough memory */ + jd->huffdata[num][cls] = pd; + for (i = 0; i < np; i++) { /* Load decoded data corresponds to each code ward */ + d = *data++; + if (!cls && d > 11) return JDR_FMT1; + *pd++ = d; + } + } + + return JDR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Extract N bits from input stream */ +/*-----------------------------------------------------------------------*/ + +static +INT bitext ( /* >=0: extracted data, <0: error code */ + JDEC* jd, /* Pointer to the decompressor object */ + UINT nbit /* Number of bits to extract (1 to 11) */ +) +{ + BYTE msk, s, *dp; + UINT dc, v, f; + + + msk = jd->dmsk; dc = jd->dctr; dp = jd->dptr; /* Bit mask, number of data available, read ptr */ + s = *dp; v = f = 0; + do { + if (!msk) { /* Next byte? */ + if (!dc) { /* No input data is available, re-fill input buffer */ + dp = jd->inbuf; /* Top of input buffer */ + dc = jd->infunc(jd, dp, JD_SZBUF); + if (!dc) return 0 - (INT)JDR_INP; /* Err: read error or wrong stream termination */ + } else { + dp++; /* Next data ptr */ + } + dc--; /* Decrement number of available bytes */ + if (f) { /* In flag sequence? */ + f = 0; /* Exit flag sequence */ + if (*dp != 0) return 0 - (INT)JDR_FMT1; /* Err: unexpected flag is detected (may be collapted data) */ + *dp = s = 0xFF; /* The flag is a data 0xFF */ + } else { + s = *dp; /* Get next data byte */ + if (s == 0xFF) { /* Is start of flag sequence? */ + f = 1; continue; /* Enter flag sequence */ + } + } + msk = 0x80; /* Read from MSB */ + } + v <<= 1; /* Get a bit */ + if (s & msk) v++; + msk >>= 1; + nbit--; + } while (nbit); + jd->dmsk = msk; jd->dctr = dc; jd->dptr = dp; + + return (INT)v; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Extract a huffman decoded data from input stream */ +/*-----------------------------------------------------------------------*/ + +static +INT huffext ( /* >=0: decoded data, <0: error code */ + JDEC* jd, /* Pointer to the decompressor object */ + const BYTE* hbits, /* Pointer to the bit distribution table */ + const WORD* hcode, /* Pointer to the code word table */ + const BYTE* hdata /* Pointer to the data table */ +) +{ + BYTE msk, s, *dp; + UINT dc, v, f, bl, nd; + + + msk = jd->dmsk; dc = jd->dctr; dp = jd->dptr; /* Bit mask, number of data available, read ptr */ + s = *dp; v = f = 0; + bl = 16; /* Max code length */ + do { + if (!msk) { /* Next byte? */ + if (!dc) { /* No input data is available, re-fill input buffer */ + dp = jd->inbuf; /* Top of input buffer */ + dc = jd->infunc(jd, dp, JD_SZBUF); + if (!dc) return 0 - (INT)JDR_INP; /* Err: read error or wrong stream termination */ + } else { + dp++; /* Next data ptr */ + } + dc--; /* Decrement number of available bytes */ + if (f) { /* In flag sequence? */ + f = 0; /* Exit flag sequence */ + if (*dp != 0) + return 0 - (INT)JDR_FMT1; /* Err: unexpected flag is detected (may be collapted data) */ + *dp = s = 0xFF; /* The flag is a data 0xFF */ + } else { + s = *dp; /* Get next data byte */ + if (s == 0xFF) { /* Is start of flag sequence? */ + f = 1; continue; /* Enter flag sequence, get trailing byte */ + } + } + msk = 0x80; /* Read from MSB */ + } + v <<= 1; /* Get a bit */ + if (s & msk) v++; + msk >>= 1; + + for (nd = *hbits++; nd; nd--) { /* Search the code word in this bit length */ + if (v == *hcode++) { /* Matched? */ + jd->dmsk = msk; jd->dctr = dc; jd->dptr = dp; + return *hdata; /* Return the decoded data */ + } + hdata++; + } + bl--; + } while (bl); + + return 0 - (INT)JDR_FMT1; /* Err: code not found (may be collapted data) */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Apply Inverse-DCT in Arai Algorithm (see also aa_idct.png) */ +/*-----------------------------------------------------------------------*/ + +static +void block_idct ( + LONG* src, /* Input block data (de-quantized and pre-scaled for Arai Algorithm) */ + BYTE* dst /* Pointer to the destination to store the block as byte array */ +) +{ + const LONG M13 = (LONG)(1.41421*4096), M2 = (LONG)(1.08239*4096), M4 = (LONG)(2.61313*4096), M5 = (LONG)(1.84776*4096); + LONG v0, v1, v2, v3, v4, v5, v6, v7; + LONG t10, t11, t12, t13; + UINT i; + + /* Process columns */ + for (i = 0; i < 8; i++) { + v0 = src[8 * 0]; /* Get even elements */ + v1 = src[8 * 2]; + v2 = src[8 * 4]; + v3 = src[8 * 6]; + + t10 = v0 + v2; /* Process the even elements */ + t12 = v0 - v2; + t11 = (v1 - v3) * M13 >> 12; + v3 += v1; + t11 -= v3; + v0 = t10 + v3; + v3 = t10 - v3; + v1 = t11 + t12; + v2 = t12 - t11; + + v4 = src[8 * 7]; /* Get odd elements */ + v5 = src[8 * 1]; + v6 = src[8 * 5]; + v7 = src[8 * 3]; + + t10 = v5 - v4; /* Process the odd elements */ + t11 = v5 + v4; + t12 = v6 - v7; + v7 += v6; + v5 = (t11 - v7) * M13 >> 12; + v7 += t11; + t13 = (t10 + t12) * M5 >> 12; + v4 = t13 - (t10 * M2 >> 12); + v6 = t13 - (t12 * M4 >> 12) - v7; + v5 -= v6; + v4 -= v5; + + src[8 * 0] = v0 + v7; /* Write-back transformed values */ + src[8 * 7] = v0 - v7; + src[8 * 1] = v1 + v6; + src[8 * 6] = v1 - v6; + src[8 * 2] = v2 + v5; + src[8 * 5] = v2 - v5; + src[8 * 3] = v3 + v4; + src[8 * 4] = v3 - v4; + + src++; /* Next column */ + } + + /* Process rows */ + src -= 8; + for (i = 0; i < 8; i++) { + v0 = src[0] + (128L << 8); /* Get even elements (remove DC offset (-128) here) */ + v1 = src[2]; + v2 = src[4]; + v3 = src[6]; + + t10 = v0 + v2; /* Process the even elements */ + t12 = v0 - v2; + t11 = (v1 - v3) * M13 >> 12; + v3 += v1; + t11 -= v3; + v0 = t10 + v3; + v3 = t10 - v3; + v1 = t11 + t12; + v2 = t12 - t11; + + v4 = src[7]; /* Get odd elements */ + v5 = src[1]; + v6 = src[5]; + v7 = src[3]; + + t10 = v5 - v4; /* Process the odd elements */ + t11 = v5 + v4; + t12 = v6 - v7; + v7 += v6; + v5 = (t11 - v7) * M13 >> 12; + v7 += t11; + t13 = (t10 + t12) * M5 >> 12; + v4 = t13 - (t10 * M2 >> 12); + v6 = t13 - (t12 * M4 >> 12) - v7; + v5 -= v6; + v4 -= v5; + + dst[0] = BYTECLIP((v0 + v7) >> 8); /* Descale the transformed values 8 bits and output */ + dst[7] = BYTECLIP((v0 - v7) >> 8); + dst[1] = BYTECLIP((v1 + v6) >> 8); + dst[6] = BYTECLIP((v1 - v6) >> 8); + dst[2] = BYTECLIP((v2 + v5) >> 8); + dst[5] = BYTECLIP((v2 - v5) >> 8); + dst[3] = BYTECLIP((v3 + v4) >> 8); + dst[4] = BYTECLIP((v3 - v4) >> 8); + dst += 8; + + src += 8; /* Next row */ + } +} + + + + +/*-----------------------------------------------------------------------*/ +/* Load all blocks in the MCU into working buffer */ +/*-----------------------------------------------------------------------*/ + +static +JRESULT mcu_load ( + JDEC* jd /* Pointer to the decompressor object */ +) +{ + LONG *tmp = (LONG*)jd->workbuf; /* Block working buffer for de-quantize and IDCT */ + UINT blk, nby, nbc, i, z, id, cmp; + INT b, d, e; + BYTE *bp; + const BYTE *hb, *hd; + const WORD *hc; + const LONG *dqf; + + + nby = jd->msx * jd->msy; /* Number of Y blocks (1, 2 or 4) */ + nbc = 2; /* Number of C blocks (2) */ + bp = jd->mcubuf; /* Pointer to the first block */ + + for (blk = 0; blk < nby + nbc; blk++) { + cmp = (blk < nby) ? 0 : blk - nby + 1; /* Component number 0:Y, 1:Cb, 2:Cr */ + id = cmp ? 1 : 0; /* Huffman table ID of the component */ + + /* Extract a DC element from input stream */ + hb = jd->huffbits[id][0]; /* Huffman table for the DC element */ + hc = jd->huffcode[id][0]; + hd = jd->huffdata[id][0]; + b = huffext(jd, hb, hc, hd); /* Extract a huffman coded data (bit length) */ + if (b < 0) return 0 - b; /* Err: invalid code or input */ + d = jd->dcv[cmp]; /* DC value of previous block */ + if (b) { /* If there is any difference from previous block */ + e = bitext(jd, b); /* Extract data bits */ + if (e < 0) return 0 - e; /* Err: input */ + b = 1 << (b - 1); /* MSB position */ + if (!(e & b)) e -= (b << 1) - 1; /* Restore sign if needed */ + d += e; /* Get current value */ + jd->dcv[cmp] = (SHORT)d; /* Save current DC value for next block */ + } + dqf = jd->qttbl[jd->qtid[cmp]]; /* De-quantizer table ID for this component */ + tmp[0] = d * dqf[0] >> 8; /* De-quantize, apply scale factor of Arai algorithm and descale 8 bits */ + + /* Extract following 63 AC elements from input stream */ + for (i = 1; i < 64; i++) tmp[i] = 0; /* Clear rest of elements */ + hb = jd->huffbits[id][1]; /* Huffman table for the AC elements */ + hc = jd->huffcode[id][1]; + hd = jd->huffdata[id][1]; + i = 1; /* Top of the AC elements */ + do { + b = huffext(jd, hb, hc, hd); /* Extract a huffman coded value (zero runs and bit length) */ + if (b == 0) break; /* EOB? */ + if (b < 0) return 0 - b; /* Err: invalid code or input error */ + z = (UINT)b >> 4; /* Number of leading zero elements */ + if (z) { + i += z; /* Skip zero elements */ + if (i >= 64) return JDR_FMT1; /* Too long zero run */ + } + if (b &= 0x0F) { /* Bit length */ + d = bitext(jd, b); /* Extract data bits */ + if (d < 0) return 0 - d; /* Err: input device */ + b = 1 << (b - 1); /* MSB position */ + if (!(d & b)) d -= (b << 1) - 1;/* Restore negative value if needed */ + z = ZIG(i); /* Zigzag-order to raster-order converted index */ + tmp[z] = d * dqf[z] >> 8; /* De-quantize, apply scale factor of Arai algorithm and descale 8 bits */ + } + } while (++i < 64); /* Next AC element */ + + if (JD_USE_SCALE && jd->scale == 3) + *bp = (*tmp / 256) + 128; /* If scale ratio is 1/8, IDCT can be ommited and only DC element is used */ + else + block_idct(tmp, bp); /* Apply IDCT and store the block to the MCU buffer */ + + bp += 64; /* Next block */ + } + + return JDR_OK; /* All blocks have been loaded successfully */ +} + + + + +/*-----------------------------------------------------------------------*/ +/* Output an MCU: Convert YCrCb to RGB and output it in RGB form */ +/*-----------------------------------------------------------------------*/ + +static +JRESULT mcu_output ( + JDEC* jd, /* Pointer to the decompressor object */ + UINT (*outfunc)(JDEC*, void*, JRECT*), /* RGB output function */ + UINT x, /* MCU position in the image (left of the MCU) */ + UINT y /* MCU position in the image (top of the MCU) */ +) +{ + const INT CVACC = (sizeof (INT) > 2) ? 1024 : 128; + UINT ix, iy, mx, my, rx, ry; + INT yy, cb, cr; + BYTE *py, *pc, *rgb24; + JRECT rect; + + + mx = jd->msx * 8; my = jd->msy * 8; /* MCU size (pixel) */ + rx = (x + mx <= jd->width) ? mx : jd->width - x; /* Output rectangular size (it may be clipped at right/bottom end) */ + ry = (y + my <= jd->height) ? my : jd->height - y; + if (JD_USE_SCALE) { + rx >>= jd->scale; ry >>= jd->scale; + if (!rx || !ry) return JDR_OK; /* Skip this MCU if all pixel is to be rounded off */ + x >>= jd->scale; y >>= jd->scale; + } + rect.left = x; rect.right = x + rx - 1; /* Rectangular area in the frame buffer */ + rect.top = y; rect.bottom = y + ry - 1; + + + if (!JD_USE_SCALE || jd->scale != 3) { /* Not for 1/8 scaling */ + + /* Build an RGB MCU from discrete comopnents */ + rgb24 = (BYTE*)jd->workbuf; + for (iy = 0; iy < my; iy++) { + pc = jd->mcubuf; + py = pc + iy * 8; + if (my == 16) { /* Double block height? */ + pc += 64 * 4 + (iy >> 1) * 8; + if (iy >= 8) py += 64; + } else { /* Single block height */ + pc += mx * 8 + iy * 8; + } + for (ix = 0; ix < mx; ix++) { + cb = pc[0] - 128; /* Get Cb/Cr component and restore right level */ + cr = pc[64] - 128; + if (mx == 16) { /* Double block width? */ + if (ix == 8) py += 64 - 8; /* Jump to next block if double block heigt */ + pc += ix & 1; /* Increase chroma pointer every two pixels */ + } else { /* Single block width */ + pc++; /* Increase chroma pointer every pixel */ + } + yy = *py++; /* Get Y component */ + + /* Convert YCbCr to RGB */ + *rgb24++ = /* R */ BYTECLIP(yy + ((INT)(1.402 * CVACC) * cr) / CVACC); + *rgb24++ = /* G */ BYTECLIP(yy - ((INT)(0.344 * CVACC) * cb + (INT)(0.714 * CVACC) * cr) / CVACC); + *rgb24++ = /* B */ BYTECLIP(yy + ((INT)(1.772 * CVACC) * cb) / CVACC); + } + } + + /* Descale the MCU rectangular if needed */ + if (JD_USE_SCALE && jd->scale) { + UINT x, y, r, g, b, s, w, a; + BYTE *op; + + /* Get averaged RGB value of each square correcponds to a pixel */ + s = jd->scale * 2; /* Bumber of shifts for averaging */ + w = 1 << jd->scale; /* Width of square */ + a = (mx - w) * 3; /* Bytes to skip for next line in the square */ + op = (BYTE*)jd->workbuf; + for (iy = 0; iy < my; iy += w) { + for (ix = 0; ix < mx; ix += w) { + rgb24 = (BYTE*)jd->workbuf + (iy * mx + ix) * 3; + r = g = b = 0; + for (y = 0; y < w; y++) { /* Accumulate RGB value in the square */ + for (x = 0; x < w; x++) { + r += *rgb24++; + g += *rgb24++; + b += *rgb24++; + } + rgb24 += a; + } /* Put the averaged RGB value as a pixel */ + *op++ = (BYTE)(r >> s); + *op++ = (BYTE)(g >> s); + *op++ = (BYTE)(b >> s); + } + } + } + + } else { /* For only 1/8 scaling (left-top pixel in each block are the DC value of the block) */ + + /* Build a 1/8 descaled RGB MCU from discrete comopnents */ + rgb24 = (BYTE*)jd->workbuf; + pc = jd->mcubuf + mx * my; + cb = pc[0] - 128; /* Get Cb/Cr component and restore right level */ + cr = pc[64] - 128; + for (iy = 0; iy < my; iy += 8) { + py = jd->mcubuf; + if (iy == 8) py += 64 * 2; + for (ix = 0; ix < mx; ix += 8) { + yy = *py; /* Get Y component */ + py += 64; + + /* Convert YCbCr to RGB */ + *rgb24++ = /* R */ BYTECLIP(yy + ((INT)(1.402 * CVACC) * cr / CVACC)); + *rgb24++ = /* G */ BYTECLIP(yy - ((INT)(0.344 * CVACC) * cb + (INT)(0.714 * CVACC) * cr) / CVACC); + *rgb24++ = /* B */ BYTECLIP(yy + ((INT)(1.772 * CVACC) * cb / CVACC)); + } + } + } + + /* Squeeze up pixel table if a part of MCU is to be truncated */ + mx >>= jd->scale; + if (rx < mx) { + BYTE *s, *d; + UINT x, y; + + s = d = (BYTE*)jd->workbuf; + for (y = 0; y < ry; y++) { + for (x = 0; x < rx; x++) { /* Copy effective pixels */ + *d++ = *s++; + *d++ = *s++; + *d++ = *s++; + } + s += (mx - rx) * 3; /* Skip truncated pixels */ + } + } + + /* Convert RGB888 to RGB565 if needed */ + if (JD_FORMAT == 1) { + BYTE *s = (BYTE*)jd->workbuf; + WORD w, *d = (WORD*)s; + UINT n = rx * ry; + + do { + w = (*s++ & 0xF8) << 8; /* RRRRR----------- */ + w |= (*s++ & 0xFC) << 3; /* -----GGGGGG----- */ + w |= *s++ >> 3; /* -----------BBBBB */ + *d++ = w; + } while (--n); + } + + /* Output the RGB rectangular */ + return outfunc(jd, jd->workbuf, &rect) ? JDR_OK : JDR_INTR; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Process restart interval */ +/*-----------------------------------------------------------------------*/ + +static +JRESULT restart ( + JDEC* jd, /* Pointer to the decompressor object */ + WORD rstn /* Expected restert sequense number */ +) +{ + UINT i, dc; + WORD d; + BYTE *dp; + + + /* Discard padding bits and get two bytes from the input stream */ + dp = jd->dptr; dc = jd->dctr; + d = 0; + for (i = 0; i < 2; i++) { + if (!dc) { /* No input data is available, re-fill input buffer */ + dp = jd->inbuf; + dc = jd->infunc(jd, dp, JD_SZBUF); + if (!dc) return JDR_INP; + } else { + dp++; + } + dc--; + d = (d << 8) | *dp; /* Get a byte */ + } + jd->dptr = dp; jd->dctr = dc; jd->dmsk = 0; + + /* Check the marker */ + if ((d & 0xFFD8) != 0xFFD0 || (d & 7) != (rstn & 7)) + return JDR_FMT1; /* Err: expected RSTn marker is not detected (may be collapted data) */ + + /* Reset DC offset */ + jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; + + return JDR_OK; +} + + + + +/*-----------------------------------------------------------------------*/ +/* Analyze the JPEG image and Initialize decompressor object */ +/*-----------------------------------------------------------------------*/ + +#define LDB_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr))<<8)|(WORD)*(BYTE*)((ptr)+1)) + + +JRESULT jd_prepare ( + JDEC* jd, /* Blank decompressor object */ + UINT (*infunc)(JDEC*, BYTE*, UINT), /* JPEG strem input function */ + void* pool, /* Working buffer for the decompression session */ + UINT sz_pool, /* Size of working buffer */ + void* dev /* I/O device identifier for the session */ +) +{ + BYTE *seg, b; + WORD marker; + DWORD ofs; + UINT n, i, j, len; + JRESULT rc; + + + if (!pool) return JDR_PAR; + + jd->pool = pool; /* Work memroy */ + jd->sz_pool = sz_pool; /* Size of given work memory */ + jd->infunc = infunc; /* Stream input function */ + jd->device = dev; /* I/O device identifier */ + jd->nrst = 0; /* No restart interval (default) */ + + for (i = 0; i < 2; i++) { /* Nulls pointers */ + for (j = 0; j < 2; j++) { + jd->huffbits[i][j] = 0; + jd->huffcode[i][j] = 0; + jd->huffdata[i][j] = 0; + } + } + for (i = 0; i < 4; i++) jd->qttbl[i] = 0; + + jd->inbuf = seg = alloc_pool(jd, JD_SZBUF); /* Allocate stream input buffer */ + if (!seg) return JDR_MEM1; + + if (jd->infunc(jd, seg, 2) != 2) return JDR_INP;/* Check SOI marker */ + if (LDB_WORD(seg) != 0xFFD8) return JDR_FMT1; /* Err: SOI is not detected */ + ofs = 2; + + for (;;) { + /* Get a JPEG marker */ + if (jd->infunc(jd, seg, 4) != 4) return JDR_INP; + marker = LDB_WORD(seg); /* Marker */ + len = LDB_WORD(seg + 2); /* Length field */ + if (len <= 2 || (marker >> 8) != 0xFF) return JDR_FMT1; + len -= 2; /* Content size excluding length field */ + ofs += 4 + len; /* Number of bytes loaded */ + + switch (marker & 0xFF) { + case 0xC0: /* SOF0 (baseline JPEG) */ + /* Load segment data */ + if (len > JD_SZBUF) return JDR_MEM2; + if (jd->infunc(jd, seg, len) != len) return JDR_INP; + + jd->width = LDB_WORD(seg+3); /* Image width in unit of pixel */ + jd->height = LDB_WORD(seg+1); /* Image height in unit of pixel */ + if (seg[5] != 3) return JDR_FMT3; /* Err: Supports only Y/Cb/Cr format */ + + /* Check three image components */ + for (i = 0; i < 3; i++) { + b = seg[7 + 3 * i]; /* Get sampling factor */ + if (!i) { /* Y component */ + if (b != 0x11 && b != 0x22 && b != 0x21)/* Check sampling factor */ + return JDR_FMT3; /* Err: Supports only 4:4:4, 4:2:0 or 4:2:2 */ + jd->msx = b >> 4; jd->msy = b & 15; /* Size of MCU [blocks] */ + } else { /* Cb/Cr component */ + if (b != 0x11) return JDR_FMT3; /* Err: Sampling factor of Cr/Cb must be 1 */ + } + b = seg[8 + 3 * i]; /* Get dequantizer table ID for this component */ + if (b > 3) return JDR_FMT3; /* Err: Invalid ID */ + jd->qtid[i] = b; + } + break; + + case 0xDD: /* DRI */ + /* Load segment data */ + if (len > JD_SZBUF) return JDR_MEM2; + if (jd->infunc(jd, seg, len) != len) return JDR_INP; + + /* Get restart interval (MCUs) */ + jd->nrst = LDB_WORD(seg); + break; + + case 0xC4: /* DHT */ + /* Load segment data */ + if (len > JD_SZBUF) return JDR_MEM2; + if (jd->infunc(jd, seg, len) != len) return JDR_INP; + + /* Create huffman tables */ + rc = create_huffman_tbl(jd, seg, len); + if (rc) return rc; + break; + + case 0xDB: /* DQT */ + /* Load segment data */ + if (len > JD_SZBUF) return JDR_MEM2; + if (jd->infunc(jd, seg, len) != len) return JDR_INP; + + /* Create de-quantizer tables */ + rc = create_qt_tbl(jd, seg, len); + if (rc) return rc; + break; + + case 0xDA: /* SOS */ + /* Load segment data */ + if (len > JD_SZBUF) return JDR_MEM2; + if (jd->infunc(jd, seg, len) != len) return JDR_INP; + + if (!jd->width || !jd->height) return JDR_FMT1; /* Err: Invalid image size */ + + if (seg[0] != 3) return JDR_FMT3; /* Err: Supports only three color components format */ + + /* Check if all tables corresponding to each components have been loaded */ + for (i = 0; i < 3; i++) { + b = seg[2 + 2 * i]; /* Get huffman table ID */ + if (b != 0x00 && b != 0x11) return JDR_FMT3; /* Err: Different table number for DC/AC element */ + b = i ? 1 : 0; + if (!jd->huffbits[b][0] || !jd->huffbits[b][1]) /* Check huffman table for this component */ + return JDR_FMT1; /* Err: Huffman table not loaded */ + if (!jd->qttbl[jd->qtid[i]]) return JDR_FMT1; /* Err: Dequantizer table not loaded */ + } + + /* Allocate working buffer for MCU and RGB */ + n = jd->msy * jd->msx; /* Number of Y blocks in the MCU */ + if (!n) return JDR_FMT1; /* Err: SOF0 has not been loaded */ + len = n * 64 * 2 + 64; /* Allocate buffer for IDCT and RGB output */ + if (len < 256) len = 256; /* but at least 256 byte is required for IDCT */ + jd->workbuf = alloc_pool(jd, len); /* and it may occupy a part of following MCU working buffer for RGB output */ + if (!jd->workbuf) return JDR_MEM1; /* Err: not enough memory */ + jd->mcubuf = alloc_pool(jd, (n + 2) * 64); /* Allocate MCU working buffer */ + if (!jd->mcubuf) return JDR_MEM1; /* Err: not enough memory */ + + /* Pre-load the JPEG data to extract it from the bit stream */ + jd->dptr = seg; jd->dctr = 0; jd->dmsk = 0; /* Prepare to read bit stream */ + if (ofs %= JD_SZBUF) { /* Align read offset to JD_SZBUF */ + jd->dctr = jd->infunc(jd, seg + ofs, JD_SZBUF - (UINT)ofs); + jd->dptr = seg + ofs - 1; + } + + return JDR_OK; /* Initialization succeeded. Ready to decompress the JPEG image. */ + + case 0xC1: /* SOF1 */ + case 0xC2: /* SOF2 */ + case 0xC3: /* SOF3 */ + case 0xC5: /* SOF5 */ + case 0xC6: /* SOF6 */ + case 0xC7: /* SOF7 */ + case 0xC9: /* SOF9 */ + case 0xCA: /* SOF10 */ + case 0xCB: /* SOF11 */ + case 0xCD: /* SOF13 */ + case 0xCE: /* SOF14 */ + case 0xCF: /* SOF15 */ + case 0xD9: /* EOI */ + return JDR_FMT3; /* Unsuppoted JPEG standard (may be progressive JPEG) */ + + default: /* Unknown segment (comment, exif or etc..) */ + /* Skip segment data */ + if (jd->infunc(jd, 0, len) != len) /* Null pointer specifies to skip bytes of stream */ + return JDR_INP; + } + } +} + + + + +/*-----------------------------------------------------------------------*/ +/* Start to decompress the JPEG picture */ +/*-----------------------------------------------------------------------*/ + +JRESULT jd_decomp ( + JDEC* jd, /* Initialized decompression object */ + UINT (*outfunc)(JDEC*, void*, JRECT*), /* RGB output function */ + BYTE scale /* Output de-scaling factor (0 to 3) */ +) +{ + UINT x, y, mx, my; + WORD rst, rsc; + JRESULT rc; + + + if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR; + jd->scale = scale; + + mx = jd->msx * 8; my = jd->msy * 8; /* Size of the MCU (pixel) */ + + jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */ + rst = rsc = 0; + + rc = JDR_OK; + for (y = 0; y < jd->height; y += my) { /* Vertical loop of MCUs */ + for (x = 0; x < jd->width; x += mx) { /* Horizontal loop of MCUs */ + if (jd->nrst && rst++ == jd->nrst) { /* Process restart interval if enabled */ + rc = restart(jd, rsc++); + if (rc != JDR_OK) return rc; + rst = 1; + } + rc = mcu_load(jd); /* Load an MCU (decompress huffman coded stream and apply IDCT) */ + if (rc != JDR_OK) return rc; + rc = mcu_output(jd, outfunc, x, y); /* Output the MCU (color space conversion, scaling and output) */ + if (rc != JDR_OK) return rc; + } + } + + return rc; +} +#endif//SUPPORT_JPEG + + diff --git a/lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c b/lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c new file mode 100644 index 000000000..9a1f185c4 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c @@ -0,0 +1,452 @@ +// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include "soc/system_reg.h" +#include "soc/lcd_cam_struct.h" +#include "soc/lcd_cam_reg.h" +#include "soc/gdma_struct.h" +#include "soc/gdma_periph.h" +#include "soc/gdma_reg.h" +#include "ll_cam.h" +#include "cam_hal.h" + +static const char *TAG = "s3 ll_cam"; + +static void IRAM_ATTR ll_cam_vsync_isr(void *arg) +{ + //DBG_PIN_SET(1); + cam_obj_t *cam = (cam_obj_t *)arg; + BaseType_t HPTaskAwoken = pdFALSE; + + typeof(LCD_CAM.lc_dma_int_st) status = LCD_CAM.lc_dma_int_st; + if (status.val == 0) { + return; + } + + LCD_CAM.lc_dma_int_clr.val = status.val; + + if (status.cam_vsync_int_st) { + ll_cam_send_event(cam, CAM_VSYNC_EVENT, &HPTaskAwoken); + } + + if (HPTaskAwoken == pdTRUE) { + portYIELD_FROM_ISR(); + } + //DBG_PIN_SET(0); +} + +static void IRAM_ATTR ll_cam_dma_isr(void *arg) +{ + cam_obj_t *cam = (cam_obj_t *)arg; + BaseType_t HPTaskAwoken = pdFALSE; + + typeof(GDMA.channel[cam->dma_num].in.int_st) status = GDMA.channel[cam->dma_num].in.int_st; + if (status.val == 0) { + return; + } + + GDMA.channel[cam->dma_num].in.int_clr.val = status.val; + + if (status.in_suc_eof) { + ll_cam_send_event(cam, CAM_IN_SUC_EOF_EVENT, &HPTaskAwoken); + } + + if (HPTaskAwoken == pdTRUE) { + portYIELD_FROM_ISR(); + } +} + +bool ll_cam_stop(cam_obj_t *cam) +{ + if (cam->jpeg_mode || !cam->psram_mode) { + GDMA.channel[cam->dma_num].in.int_ena.in_suc_eof = 0; + GDMA.channel[cam->dma_num].in.int_clr.in_suc_eof = 1; + } + GDMA.channel[cam->dma_num].in.link.stop = 1; + return true; +} + +esp_err_t ll_cam_deinit(cam_obj_t *cam) +{ + if (cam->cam_intr_handle) { + esp_intr_free(cam->cam_intr_handle); + cam->cam_intr_handle = NULL; + } + + if (cam->dma_intr_handle) { + esp_intr_free(cam->dma_intr_handle); + cam->dma_intr_handle = NULL; + } + GDMA.channel[cam->dma_num].in.link.addr = 0x0; + + LCD_CAM.cam_ctrl1.cam_start = 0; + LCD_CAM.cam_ctrl1.cam_reset = 1; + LCD_CAM.cam_ctrl1.cam_reset = 0; + return ESP_OK; +} + +bool ll_cam_start(cam_obj_t *cam, int frame_pos) +{ + LCD_CAM.cam_ctrl1.cam_start = 0; + + if (cam->jpeg_mode || !cam->psram_mode) { + GDMA.channel[cam->dma_num].in.int_clr.in_suc_eof = 1; + GDMA.channel[cam->dma_num].in.int_ena.in_suc_eof = 1; + } + + LCD_CAM.cam_ctrl1.cam_reset = 1; + LCD_CAM.cam_ctrl1.cam_reset = 0; + LCD_CAM.cam_ctrl1.cam_afifo_reset = 1; + LCD_CAM.cam_ctrl1.cam_afifo_reset = 0; + GDMA.channel[cam->dma_num].in.conf0.in_rst = 1; + GDMA.channel[cam->dma_num].in.conf0.in_rst = 0; + + LCD_CAM.cam_ctrl1.cam_rec_data_bytelen = cam->dma_half_buffer_size - 1; // Ping pong operation + + if (!cam->psram_mode) { + GDMA.channel[cam->dma_num].in.link.addr = ((uint32_t)&cam->dma[0]) & 0xfffff; + } else { + GDMA.channel[cam->dma_num].in.link.addr = ((uint32_t)&cam->frames[frame_pos].dma[0]) & 0xfffff; + } + + GDMA.channel[cam->dma_num].in.link.start = 1; + + LCD_CAM.cam_ctrl.cam_update = 1; + LCD_CAM.cam_ctrl1.cam_start = 1; + return true; +} + +static esp_err_t ll_cam_dma_init(cam_obj_t *cam) +{ + for (int x = (SOC_GDMA_PAIRS_PER_GROUP - 1); x >= 0; x--) { + if (GDMA.channel[x].in.link.addr == 0x0) { + cam->dma_num = x; + ESP_LOGI(TAG, "DMA Channel=%d", cam->dma_num); + break; + } + if (x == 0) { + cam_deinit(); + ESP_LOGE(TAG, "Can't found available GDMA channel"); + return ESP_FAIL; + } + } + + if (REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN) == 0) { + REG_CLR_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN); + REG_SET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN); + REG_SET_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST); + REG_CLR_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST); + } + + GDMA.channel[cam->dma_num].in.int_clr.val = ~0; + GDMA.channel[cam->dma_num].in.int_ena.val = 0; + + GDMA.channel[cam->dma_num].in.conf0.val = 0; + GDMA.channel[cam->dma_num].in.conf0.in_rst = 1; + GDMA.channel[cam->dma_num].in.conf0.in_rst = 0; + + //internal SRAM only + if (!cam->psram_mode) { + GDMA.channel[cam->dma_num].in.conf0.indscr_burst_en = 1; + GDMA.channel[cam->dma_num].in.conf0.in_data_burst_en = 1; + } + + GDMA.channel[cam->dma_num].in.conf1.in_check_owner = 0; + + GDMA.channel[cam->dma_num].in.peri_sel.sel = 5; + //GDMA.channel[cam->dma_num].in.pri.rx_pri = 1;//rx prio 0-15 + //GDMA.channel[cam->dma_num].in.sram_size.in_size = 6;//This register is used to configure the size of L2 Tx FIFO for Rx channel. 0:16 bytes, 1:24 bytes, 2:32 bytes, 3: 40 bytes, 4: 48 bytes, 5:56 bytes, 6: 64 bytes, 7: 72 bytes, 8: 80 bytes. + //GDMA.channel[cam->dma_num].in.wight.rx_weight = 7;//The weight of Rx channel 0-15 + return ESP_OK; +} + +esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) +{ + if (REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN) == 0) { + REG_CLR_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN); + REG_SET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN); + REG_SET_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_LCD_CAM_RST); + REG_CLR_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_LCD_CAM_RST); + } + + LCD_CAM.cam_ctrl.val = 0; + + LCD_CAM.cam_ctrl.cam_clkm_div_b = 0; + LCD_CAM.cam_ctrl.cam_clkm_div_a = 0; + LCD_CAM.cam_ctrl.cam_clkm_div_num = 160000000 / config->xclk_freq_hz; + LCD_CAM.cam_ctrl.cam_clk_sel = 3;//Select Camera module source clock. 0: no clock. 1: APLL. 2: CLK160. 3: no clock. + + LCD_CAM.cam_ctrl.cam_stop_en = 0; + LCD_CAM.cam_ctrl.cam_vsync_filter_thres = 4; // Filter by LCD_CAM clock + LCD_CAM.cam_ctrl.cam_update = 0; + LCD_CAM.cam_ctrl.cam_byte_order = cam->swap_data; + LCD_CAM.cam_ctrl.cam_bit_order = 0; + LCD_CAM.cam_ctrl.cam_line_int_en = 0; + LCD_CAM.cam_ctrl.cam_vs_eof_en = 0; //1: CAM_VSYNC to generate in_suc_eof. 0: in_suc_eof is controlled by reg_cam_rec_data_cyclelen + + LCD_CAM.cam_ctrl1.val = 0; + LCD_CAM.cam_ctrl1.cam_rec_data_bytelen = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE - 1; // Cannot be assigned to 0, and it is easy to overflow + LCD_CAM.cam_ctrl1.cam_line_int_num = 0; // The number of hsyncs that generate hs interrupts + LCD_CAM.cam_ctrl1.cam_clk_inv = 0; + LCD_CAM.cam_ctrl1.cam_vsync_filter_en = 1; + LCD_CAM.cam_ctrl1.cam_2byte_en = 0; + LCD_CAM.cam_ctrl1.cam_de_inv = 0; + LCD_CAM.cam_ctrl1.cam_hsync_inv = 0; + LCD_CAM.cam_ctrl1.cam_vsync_inv = 0; + LCD_CAM.cam_ctrl1.cam_vh_de_mode_en = 0; + + LCD_CAM.cam_rgb_yuv.val = 0; + + LCD_CAM.cam_ctrl.cam_update = 1; + LCD_CAM.cam_ctrl1.cam_start = 1; + + esp_err_t err = ll_cam_dma_init(cam); + if(err != ESP_OK) { + return err; + } + + return ESP_OK; +} + +void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) +{ + LCD_CAM.lc_dma_int_clr.cam_vsync_int_clr = 1; + if (en) { + LCD_CAM.lc_dma_int_ena.cam_vsync_int_ena = 1; + } else { + LCD_CAM.lc_dma_int_ena.cam_vsync_int_ena = 0; + } +} + +esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) +{ + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_pclk], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_pclk, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_pclk, GPIO_FLOATING); + gpio_matrix_in(config->pin_pclk, CAM_PCLK_IDX, false); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_vsync], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_vsync, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_vsync, GPIO_FLOATING); + gpio_matrix_in(config->pin_vsync, CAM_V_SYNC_IDX, cam->vsync_invert); + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_href], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_href, GPIO_MODE_INPUT); + gpio_set_pull_mode(config->pin_href, GPIO_FLOATING); + gpio_matrix_in(config->pin_href, CAM_H_ENABLE_IDX, false); + + int data_pins[8] = { + config->pin_d0, config->pin_d1, config->pin_d2, config->pin_d3, config->pin_d4, config->pin_d5, config->pin_d6, config->pin_d7, + }; + for (int i = 0; i < 8; i++) { + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[data_pins[i]], PIN_FUNC_GPIO); + gpio_set_direction(data_pins[i], GPIO_MODE_INPUT); + gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); + gpio_matrix_in(data_pins[i], CAM_DATA_IN0_IDX + i, false); + } + + PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_xclk], PIN_FUNC_GPIO); + gpio_set_direction(config->pin_xclk, GPIO_MODE_OUTPUT); + gpio_set_pull_mode(config->pin_xclk, GPIO_FLOATING); + gpio_matrix_out(config->pin_xclk, CAM_CLK_IDX, false, false); + + return ESP_OK; +} + +esp_err_t ll_cam_init_isr(cam_obj_t *cam) +{ + esp_err_t ret = ESP_OK; + ret = esp_intr_alloc_intrstatus(gdma_periph_signals.groups[0].pairs[cam->dma_num].rx_irq_id, + ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_IRAM, + (uint32_t)&GDMA.channel[cam->dma_num].in.int_st, GDMA_IN_SUC_EOF_CH0_INT_ST_M, + ll_cam_dma_isr, cam, &cam->dma_intr_handle); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "DMA interrupt allocation of camera failed"); + return ret; + } + + ret = esp_intr_alloc_intrstatus(ETS_LCD_CAM_INTR_SOURCE, + ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_IRAM, + (uint32_t)&LCD_CAM.lc_dma_int_st.val, LCD_CAM_CAM_VSYNC_INT_ST_M, + ll_cam_vsync_isr, cam, &cam->cam_intr_handle); + if (ret != ESP_OK) { + ESP_LOGE(TAG, "LCD_CAM interrupt allocation of camera failed"); + return ret; + } + return ESP_OK; +} + +void ll_cam_do_vsync(cam_obj_t *cam) +{ + gpio_matrix_in(cam->vsync_pin, CAM_V_SYNC_IDX, !cam->vsync_invert); + ets_delay_us(10); + gpio_matrix_in(cam->vsync_pin, CAM_V_SYNC_IDX, cam->vsync_invert); +} + +uint8_t ll_cam_get_dma_align(cam_obj_t *cam) +{ + return 16 << GDMA.channel[cam->dma_num].in.conf1.in_ext_mem_bk_size; +} + +static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ + size_t node_max = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE / cam->dma_bytes_per_item; + size_t line_width = cam->width * cam->in_bytes_per_pixel; + size_t node_size = node_max; + size_t nodes_per_line = 1; + size_t lines_per_node = 1; + + // Calculate DMA Node Size so that it's divisable by or divisor of the line width + if(line_width >= node_max){ + // One or more nodes will be requied for one line + for(size_t i = node_max; i > 0; i=i-1){ + if ((line_width % i) == 0) { + node_size = i; + nodes_per_line = line_width / node_size; + break; + } + } + } else { + // One or more lines can fit into one node + for(size_t i = node_max; i > 0; i=i-1){ + if ((i % line_width) == 0) { + node_size = i; + lines_per_node = node_size / line_width; + while((cam->height % lines_per_node) != 0){ + lines_per_node = lines_per_node - 1; + node_size = lines_per_node * line_width; + } + break; + } + } + } + + ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", + node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node); + + cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; + + size_t dma_half_buffer_max = CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX / 2 / cam->dma_bytes_per_item; + if (line_width > dma_half_buffer_max) { + ESP_LOGE(TAG, "Resolution too high"); + return 0; + } + + // Calculate minimum EOF size = max(mode_size, line_size) + size_t dma_half_buffer_min = node_size * nodes_per_line; + + // Calculate max EOF size divisable by node size + size_t dma_half_buffer = (dma_half_buffer_max / dma_half_buffer_min) * dma_half_buffer_min; + + // Adjust EOF size so that height will be divisable by the number of lines in each EOF + size_t lines_per_half_buffer = dma_half_buffer / line_width; + while((cam->height % lines_per_half_buffer) != 0){ + dma_half_buffer = dma_half_buffer - dma_half_buffer_min; + lines_per_half_buffer = dma_half_buffer / line_width; + } + + // Calculate DMA size + size_t dma_buffer_max = 2 * dma_half_buffer_max; + if (cam->psram_mode) { + dma_buffer_max = cam->recv_size / cam->dma_bytes_per_item; + } + size_t dma_buffer_size = dma_buffer_max; + if (!cam->psram_mode) { + dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; + } + + ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", + dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item); + + cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; + cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; + cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; + return 1; +} + +bool ll_cam_dma_sizes(cam_obj_t *cam) +{ + cam->dma_bytes_per_item = 1; + if (cam->jpeg_mode) { + if (cam->psram_mode) { + cam->dma_buffer_size = cam->recv_size; + cam->dma_half_buffer_size = 1024; + cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; + cam->dma_node_buffer_size = cam->dma_half_buffer_size; + } else { + cam->dma_half_buffer_cnt = 16; + cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024; + cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt; + cam->dma_node_buffer_size = cam->dma_half_buffer_size; + } + } else { + return ll_cam_calc_rgb_dma(cam); + } + return 1; +} + +size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len) +{ + // YUV to Grayscale + if (cam->in_bytes_per_pixel == 2 && cam->fb_bytes_per_pixel == 1) { + size_t end = len / 8; + for (size_t i = 0; i < end; ++i) { + out[0] = in[0]; + out[1] = in[2]; + out[2] = in[4]; + out[3] = in[6]; + out += 4; + in += 8; + } + return len / 2; + } + + // just memcpy + memcpy(out, in, len); + return len; +} + +esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid) +{ + if (pix_format == PIXFORMAT_GRAYSCALE) { + if (sensor_pid == OV3660_PID || sensor_pid == OV5640_PID || sensor_pid == NT99141_PID) { + cam->in_bytes_per_pixel = 1; // camera sends Y8 + } else { + cam->in_bytes_per_pixel = 2; // camera sends YU/YV + } + cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 + } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { + cam->in_bytes_per_pixel = 2; // camera sends YU/YV + cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 + } else if (pix_format == PIXFORMAT_JPEG) { + cam->in_bytes_per_pixel = 1; + cam->fb_bytes_per_pixel = 1; + } else { + ESP_LOGE(TAG, "Requested format is not supported"); + return ESP_ERR_NOT_SUPPORTED; + } + return ESP_OK; +} + +// implements function from xclk.c to allow dynamic XCLK change +esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz) +{ + LCD_CAM.cam_ctrl.cam_clkm_div_b = 0; + LCD_CAM.cam_ctrl.cam_clkm_div_a = 0; + LCD_CAM.cam_ctrl.cam_clkm_div_num = 160000000 / xclk_freq_hz; + LCD_CAM.cam_ctrl.cam_clk_sel = 3;//Select Camera module source clock. 0: no clock. 1: APLL. 2: CLK160. 3: no clock. + LCD_CAM.cam_ctrl.cam_update = 1; + return ESP_OK; +} diff --git a/lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h b/lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h new file mode 100644 index 000000000..7d30c370a --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h @@ -0,0 +1,141 @@ +// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include +#include "sdkconfig.h" +#include "esp_idf_version.h" +#if CONFIG_IDF_TARGET_ESP32 +#if ESP_IDF_VERSION_MAJOR >= 4 +#include "esp32/rom/lldesc.h" +#else +#include "rom/lldesc.h" +#endif +#elif CONFIG_IDF_TARGET_ESP32S2 +#include "esp32s2/rom/lldesc.h" +#elif CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/rom/lldesc.h" +#endif +#include "esp_log.h" +#include "esp_camera.h" +#include "freertos/FreeRTOS.h" +#include "freertos/queue.h" +#include "freertos/task.h" +#include "freertos/semphr.h" + +#if __has_include("esp_private/periph_ctrl.h") +# include "esp_private/periph_ctrl.h" +#endif + +#define CAMERA_DBG_PIN_ENABLE 0 +#if CAMERA_DBG_PIN_ENABLE + #if CONFIG_IDF_TARGET_ESP32 + #define DBG_PIN_NUM 26 + #else + #define DBG_PIN_NUM 7 + #endif + #include "hal/gpio_ll.h" + #define DBG_PIN_SET(v) gpio_ll_set_level(&GPIO, DBG_PIN_NUM, v) +#else + #define DBG_PIN_SET(v) +#endif + +#define CAM_CHECK(a, str, ret) if (!(a)) { \ + ESP_LOGE(TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + return (ret); \ + } + +#define CAM_CHECK_GOTO(a, str, lab) if (!(a)) { \ + ESP_LOGE(TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ + goto lab; \ + } + +#define LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE (4092) + +typedef enum { + CAM_IN_SUC_EOF_EVENT = 0, + CAM_VSYNC_EVENT +} cam_event_t; + +typedef enum { + CAM_STATE_IDLE = 0, + CAM_STATE_READ_BUF = 1, +} cam_state_t; + +typedef struct { + camera_fb_t fb; + uint8_t en; + //for RGB/YUV modes + lldesc_t *dma; + size_t fb_offset; +} cam_frame_t; + +typedef struct { + uint32_t dma_bytes_per_item; + uint32_t dma_buffer_size; + uint32_t dma_half_buffer_size; + uint32_t dma_half_buffer_cnt; + uint32_t dma_node_buffer_size; + uint32_t dma_node_cnt; + uint32_t frame_copy_cnt; + + //for JPEG mode + lldesc_t *dma; + uint8_t *dma_buffer; + + cam_frame_t *frames; + + QueueHandle_t event_queue; + QueueHandle_t frame_buffer_queue; + TaskHandle_t task_handle; + intr_handle_t cam_intr_handle; + + uint8_t dma_num;//ESP32-S3 + intr_handle_t dma_intr_handle;//ESP32-S3 + + uint8_t jpeg_mode; + uint8_t vsync_pin; + uint8_t vsync_invert; + uint32_t frame_cnt; + uint32_t recv_size; + bool swap_data; + bool psram_mode; + + //for RGB/YUV modes + uint16_t width; + uint16_t height; + uint8_t in_bytes_per_pixel; + uint8_t fb_bytes_per_pixel; + uint32_t fb_size; + + cam_state_t state; +} cam_obj_t; + + +bool ll_cam_stop(cam_obj_t *cam); +bool ll_cam_start(cam_obj_t *cam, int frame_pos); +esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config); +esp_err_t ll_cam_deinit(cam_obj_t *cam); +void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en); +esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config); +esp_err_t ll_cam_init_isr(cam_obj_t *cam); +void ll_cam_do_vsync(cam_obj_t *cam); +uint8_t ll_cam_get_dma_align(cam_obj_t *cam); +bool ll_cam_dma_sizes(cam_obj_t *cam); +size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len); +esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid); + +// implemented in cam_hal +void ll_cam_send_event(cam_obj_t *cam, cam_event_t cam_event, BaseType_t * HPTaskAwoken); diff --git a/lib/libesp32_div/esp32-camera/target/xclk.c b/lib/libesp32_div/esp32-camera/target/xclk.c new file mode 100644 index 000000000..b5ea53e77 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/target/xclk.c @@ -0,0 +1,64 @@ +#include "driver/gpio.h" +#include "driver/ledc.h" +#include "esp_err.h" +#include "esp_log.h" +#include "esp_system.h" +#include "xclk.h" +#include "esp_camera.h" + +#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) +#include "esp32-hal-log.h" +#else +#include "esp_log.h" +static const char* TAG = "camera_xclk"; +#endif + +static ledc_channel_t g_ledc_channel = 0; + +esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz) +{ + ledc_timer_config_t timer_conf; + timer_conf.duty_resolution = LEDC_TIMER_1_BIT; + timer_conf.freq_hz = xclk_freq_hz; + timer_conf.speed_mode = LEDC_LOW_SPEED_MODE; + +#if ESP_IDF_VERSION_MAJOR >= 4 + timer_conf.clk_cfg = LEDC_AUTO_CLK; +#endif + timer_conf.timer_num = (ledc_timer_t)ledc_timer; + esp_err_t err = ledc_timer_config(&timer_conf); + if (err != ESP_OK) { + ESP_LOGE(TAG, "ledc_timer_config failed for freq %d, rc=%x", xclk_freq_hz, err); + } + return err; +} + +esp_err_t camera_enable_out_clock(camera_config_t* config) +{ + esp_err_t err = xclk_timer_conf(config->ledc_timer, config->xclk_freq_hz); + if (err != ESP_OK) { + ESP_LOGE(TAG, "ledc_timer_config failed, rc=%x", err); + return err; + } + + g_ledc_channel = config->ledc_channel; + ledc_channel_config_t ch_conf; + ch_conf.gpio_num = config->pin_xclk; + ch_conf.speed_mode = LEDC_LOW_SPEED_MODE; + ch_conf.channel = config->ledc_channel; + ch_conf.intr_type = LEDC_INTR_DISABLE; + ch_conf.timer_sel = config->ledc_timer; + ch_conf.duty = 1; + ch_conf.hpoint = 0; + err = ledc_channel_config(&ch_conf); + if (err != ESP_OK) { + ESP_LOGE(TAG, "ledc_channel_config failed, rc=%x", err); + return err; + } + return ESP_OK; +} + +void camera_disable_out_clock() +{ + ledc_stop(LEDC_LOW_SPEED_MODE, g_ledc_channel, 0); +} diff --git a/lib/libesp32_div/esp32-camera/test/CMakeLists.txt b/lib/libesp32_div/esp32-camera/test/CMakeLists.txt new file mode 100644 index 000000000..a8c3d16b7 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/test/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register(SRC_DIRS . + PRIV_INCLUDE_DIRS . + PRIV_REQUIRES test_utils esp32-camera nvs_flash + EMBED_TXTFILES pictures/testimg.jpeg pictures/test_outside.jpeg pictures/test_inside.jpeg) diff --git a/lib/libesp32_div/esp32-camera/test/component.mk b/lib/libesp32_div/esp32-camera/test/component.mk new file mode 100644 index 000000000..5fb883650 --- /dev/null +++ b/lib/libesp32_div/esp32-camera/test/component.mk @@ -0,0 +1,8 @@ +# +#Component Makefile +# + +COMPONENT_SRCDIRS += ./ +COMPONENT_PRIV_INCLUDEDIRS += ./ + +COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive diff --git a/lib/libesp32_div/esp32-camera/test/pictures/test_inside.jpeg b/lib/libesp32_div/esp32-camera/test/pictures/test_inside.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..92e7bc3694e8568be514673432c3601a8c1c4126 GIT binary patch literal 18832 zcmbTdWl&r}*Dg9RxCVj-4MQNfyF;)Lg4bgvmf9O1wEs|v6TL;A1I`Jck8AOa9`(EnTW+6e&s-#YAn8UZiM z04V?v5%E9iRghj2G8!^65)v{7Dk=&Z76uj;CI%)ZHV*z9Y#clsOw2b#Z}8p{5E2q% z;S!S&5s=^$5EA_7B?!RRF-XYh$jImf*qGP^|DWZh3xJ0PfFXzj5oiF2cnCl|gqJ=5 z)hjsU*LC>MQv7d0KzyAe3Mv{p2Igyr`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d#q+?Dt<&TPyK&#%uFm{@?2xi2D>HnRw&UZC_f zQgi1fg+GQSfk2%1`EM zj-j=)ByJg4;Gchb66{GonIvK2&&tQ0!yl$9?7wBdhvZd;LP-pxzoDsW%(T-+Wu4Po zC|L=TK7jWEtlZkHgUpIe>;2$)ti^M0Ga*cK%Ae;_M|N!4+B3ZmB|UzXHrGJEa#L|6 z0hT}=f4z=J)Kxj5V*YizY;0txIR60k){KG++kNQk3-#Jh%sq`{9Ky^Pm2BtQv`e^L F|Jg`@ubTh> literal 0 HcmV?d00001 diff --git a/lib/libesp32_div/esp32-camera/test/pictures/test_outside.jpeg b/lib/libesp32_div/esp32-camera/test/pictures/test_outside.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..dcb4bf1b3c82c9aa3858223414be90a54a1ff4c6 GIT binary patch literal 81744 zcmeFYbyQtVlrMO3cX!CeEx0?ug9f*dV8Jc8J0Z9`BzSOwJHb7;y9IZ*IVAaBe?6<$ z%k%6%n=$H^tAP8W5?t~C9zsCsx6aB>t0H*!R0|{VOU@j^! zZUCJPz&OBo3Uqz|QvoA9AP5WcKV)J+voocq5lO72t)%)@%!UxTPP4H z{V#R_@QaW?o&z9=<}Wq^Fw0;3905=i90>ZE#>UP96$J^x2Cxq>0s1eF129DNA07xG z63{V-zpW|&=rA#V)-4AxT+E-fV1W7Xe=z_-2!Am;fD!-l*8%(oMDAoOhj4gxSE z@SG8dR#Xfm2q1xYSwNuZf8m&aVNljzoq+&CWc^w932-xH7Q%1cRsgp{{ly{x#{2q* z=eNDtaKCw;*MRtopQ8i`;OE@d1ayGN`NI!<1VR1_L;VXw=lrqV0N{uDOZNu&VgKT1 znQ;H&hyNEw_!ma}7e@XUeqQ@o#RAP89C?fxSl1c3~~`j>nHz@lf}t^s}`fc`8K7(m4T ziysz5@>d5`fKCcLeCB`dWB|`|tZ)JPi@)^ec!B{sA25;vA1MFISpgSub$G_1 z|I+g_AoKa%5&>)v1F#sd);%yc8o+J<76KNG2W$jLpgJJ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4PG97JDu5|YY5qe< zhm_co)B^$X#f}O%H|$u77JHCiU;k(`fqL~0)y)sXNuOAcOOdaMy9szrD)dpo^jOJX ze`{-Q)Y7M#y@>Cx15fNAoKm*DU!qOnA%Hq_78*}dneqF*2)Ij~Id`!IFl7~2ekkO* zla40dld9b*KXTJCA!k4cq%}z@PDQ>P%spXBx1`7=dd~YF>&qLVuDLrqXKCe6^#k)t z=zNP|`_6;&QFNPb?LY1Mb4I_mEk)neVQ-4{-3lTT$W+gZi*Rn&Y}U7`8>WcIb{SI2+lxgCIV z#LoI!)vCcwAY=rGm#PNLCYN(l{{fmkq>*7_=!y3${CEIYB-E`ZwawbFOVpALhSXcu z#WwD-qnWG9-HPC1*y_<^@h)ERS4kad6dUIerZPoGvTmcn^q=X(YvMmT^;@&*v&mU8 zq3!lU{nLGOImt{XFcU{6^}L7Hvdc;0r5}6SG%Q!>R(h4(G$KpSzZ92TSAaRC2c0u+ z6O0+(4vG(M1?sbX?ej-hc77IUAzo~d{pC5O(%w&w&^okE47^IRnxy0%5KBd8$l7_o zYD?>u4IEW9RDjv))Zz>w5L1qF- +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "unity.h" +#include +#include "esp_log.h" + +#include "esp_camera.h" + +#ifdef CONFIG_IDF_TARGET_ESP32 +#define BOARD_WROVER_KIT 1 +#elif defined CONFIG_IDF_TARGET_ESP32S2 +#define BOARD_CAMERA_MODEL_ESP32S2 1 +#elif defined CONFIG_IDF_TARGET_ESP32S3 +#define BOARD_CAMERA_MODEL_ESP32_S3_EYE 1 +#endif + +// WROVER-KIT PIN Map +#if BOARD_WROVER_KIT + +#define PWDN_GPIO_NUM -1 //power down is not used +#define RESET_GPIO_NUM -1 //software reset will be performed +#define XCLK_GPIO_NUM 21 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 19 +#define Y4_GPIO_NUM 18 +#define Y3_GPIO_NUM 5 +#define Y2_GPIO_NUM 4 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +// ESP32Cam (AiThinker) PIN Map +#elif BOARD_ESP32CAM_AITHINKER + +#define PWDN_GPIO_NUM 32 +#define RESET_GPIO_NUM -1 //software reset will be performed +#define XCLK_GPIO_NUM 0 +#define SIOD_GPIO_NUM 26 +#define SIOC_GPIO_NUM 27 + +#define Y9_GPIO_NUM 35 +#define Y8_GPIO_NUM 34 +#define Y7_GPIO_NUM 39 +#define Y6_GPIO_NUM 36 +#define Y5_GPIO_NUM 21 +#define Y4_GPIO_NUM 19 +#define Y3_GPIO_NUM 18 +#define Y2_GPIO_NUM 5 +#define VSYNC_GPIO_NUM 25 +#define HREF_GPIO_NUM 23 +#define PCLK_GPIO_NUM 22 + +#elif BOARD_CAMERA_MODEL_ESP32S2 + +#define PWDN_GPIO_NUM -1 +#define RESET_GPIO_NUM -1 + +#define VSYNC_GPIO_NUM 21 +#define HREF_GPIO_NUM 38 +#define PCLK_GPIO_NUM 11 +#define XCLK_GPIO_NUM 40 + +#define SIOD_GPIO_NUM 17 +#define SIOC_GPIO_NUM 18 + +#define Y9_GPIO_NUM 39 +#define Y8_GPIO_NUM 41 +#define Y7_GPIO_NUM 42 +#define Y6_GPIO_NUM 12 +#define Y5_GPIO_NUM 3 +#define Y4_GPIO_NUM 14 +#define Y3_GPIO_NUM 37 +#define Y2_GPIO_NUM 13 + +#elif BOARD_CAMERA_MODEL_ESP32_S3_EYE + +#define PWDN_GPIO_NUM 43 +#define RESET_GPIO_NUM 44 + +#define VSYNC_GPIO_NUM 6 +#define HREF_GPIO_NUM 7 +#define PCLK_GPIO_NUM 13 +#define XCLK_GPIO_NUM 15 + +#define SIOD_GPIO_NUM 4 +#define SIOC_GPIO_NUM 5 + +#define Y9_GPIO_NUM 16 +#define Y8_GPIO_NUM 17 +#define Y7_GPIO_NUM 18 +#define Y6_GPIO_NUM 12 +#define Y5_GPIO_NUM 11 +#define Y4_GPIO_NUM 10 +#define Y3_GPIO_NUM 9 +#define Y2_GPIO_NUM 8 + +#endif + +static const char *TAG = "test camera"; + +typedef void (*decode_func_t)(uint8_t *jpegbuffer, uint32_t size, uint8_t *outbuffer); + +static esp_err_t init_camera(uint32_t xclk_freq_hz, pixformat_t pixel_format, framesize_t frame_size, uint8_t fb_count) +{ + framesize_t size_bak = frame_size; + if (PIXFORMAT_JPEG == pixel_format && FRAMESIZE_SVGA > frame_size) { + frame_size = FRAMESIZE_HD; + } + camera_config_t camera_config = { + .pin_pwdn = PWDN_GPIO_NUM, + .pin_reset = RESET_GPIO_NUM, + .pin_xclk = XCLK_GPIO_NUM, + .pin_sscb_sda = SIOD_GPIO_NUM, + .pin_sscb_scl = SIOC_GPIO_NUM, + + .pin_d7 = Y9_GPIO_NUM, + .pin_d6 = Y8_GPIO_NUM, + .pin_d5 = Y7_GPIO_NUM, + .pin_d4 = Y6_GPIO_NUM, + .pin_d3 = Y5_GPIO_NUM, + .pin_d2 = Y4_GPIO_NUM, + .pin_d1 = Y3_GPIO_NUM, + .pin_d0 = Y2_GPIO_NUM, + .pin_vsync = VSYNC_GPIO_NUM, + .pin_href = HREF_GPIO_NUM, + .pin_pclk = PCLK_GPIO_NUM, + + //EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode + .xclk_freq_hz = xclk_freq_hz, + .ledc_timer = LEDC_TIMER_0, + .ledc_channel = LEDC_CHANNEL_0, + + .pixel_format = pixel_format, //YUV422,GRAYSCALE,RGB565,JPEG + .frame_size = frame_size, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG + + .jpeg_quality = 12, //0-63 lower number means higher quality + .fb_count = fb_count, //if more than one, i2s runs in continuous mode. Use only with JPEG + .grab_mode = CAMERA_GRAB_WHEN_EMPTY + }; + + //initialize the camera + esp_err_t ret = esp_camera_init(&camera_config); + + if (ESP_OK == ret && PIXFORMAT_JPEG == pixel_format && FRAMESIZE_SVGA > size_bak) { + sensor_t *s = esp_camera_sensor_get(); + s->set_framesize(s, size_bak); + } + + return ret; +} + +static bool camera_test_fps(uint16_t times, float *fps, uint32_t *size) +{ + *fps = 0.0f; + *size = 0; + uint32_t s = 0; + uint32_t num = 0; + uint64_t total_time = esp_timer_get_time(); + for (size_t i = 0; i < times; i++) { + camera_fb_t *pic = esp_camera_fb_get(); + if (NULL == pic) { + ESP_LOGW(TAG, "fb get failed"); + return 0; + } else { + s += pic->len; + num++; + } + esp_camera_fb_return(pic); + } + total_time = esp_timer_get_time() - total_time; + if (num) { + *fps = num * 1000000.0f / total_time ; + *size = s / num; + } + return 1; +} + +static const char *get_cam_format_name(pixformat_t pixel_format) +{ + switch (pixel_format) { + case PIXFORMAT_JPEG: return "JPEG"; + case PIXFORMAT_RGB565: return "RGB565"; + case PIXFORMAT_RGB888: return "RGB888"; + case PIXFORMAT_YUV422: return "YUV422"; + default: + break; + } + return "UNKNOW"; +} + +static void printf_img_base64(const camera_fb_t *pic) +{ + uint8_t *outbuffer = NULL; + size_t outsize = 0; + if (PIXFORMAT_JPEG != pic->format) { + fmt2jpg(pic->buf, pic->width * pic->height * 2, pic->width, pic->height, pic->format, 50, &outbuffer, &outsize); + } else { + outbuffer = pic->buf; + outsize = pic->len; + } + + uint8_t *base64_buf = calloc(1, outsize * 4); + if (NULL != base64_buf) { + size_t out_len = 0; + mbedtls_base64_encode(base64_buf, outsize * 4, &out_len, outbuffer, outsize); + printf("%s\n", base64_buf); + free(base64_buf); + if (PIXFORMAT_JPEG != pic->format) { + free(outbuffer); + } + } else { + ESP_LOGE(TAG, "malloc for base64 buffer failed"); + } +} + +static void camera_performance_test(uint32_t xclk_freq, uint32_t pic_num) +{ + esp_err_t ret = ESP_OK; + //detect sensor information + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); + sensor_t *s = esp_camera_sensor_get(); + camera_sensor_info_t *info = esp_camera_sensor_get_info(&s->id); + TEST_ASSERT_NOT_NULL(info); + TEST_ESP_OK(esp_camera_deinit()); + vTaskDelay(500 / portTICK_RATE_MS); + framesize_t max_size = info->max_size; + pixformat_t all_format[] = {PIXFORMAT_JPEG, PIXFORMAT_RGB565, PIXFORMAT_YUV422, }; + pixformat_t *format_s = &all_format[0]; + pixformat_t *format_e = &all_format[2]; + if (false == info->support_jpeg) { + format_s++; // skip jpeg + } + + struct fps_result { + float fps[FRAMESIZE_INVALID]; + uint32_t size[FRAMESIZE_INVALID]; + }; + struct fps_result results[3] = {0}; + + for (; format_s <= format_e; format_s++) { + for (size_t i = 0; i <= max_size; i++) { + ESP_LOGI(TAG, "\n\n===> Testing format:%s resolution: %d x %d <===", get_cam_format_name(*format_s), resolution[i].width, resolution[i].height); + ret = init_camera(xclk_freq, *format_s, i, 2); + vTaskDelay(100 / portTICK_RATE_MS); + if (ESP_OK != ret) { + ESP_LOGW(TAG, "Testing init failed :-(, skip this item"); + vTaskDelay(500 / portTICK_RATE_MS); + continue; + } + camera_test_fps(pic_num, &results[format_s - all_format].fps[i], &results[format_s - all_format].size[i]); + TEST_ESP_OK(esp_camera_deinit()); + } + } + + printf("FPS Result\n"); + printf("resolution , JPEG fps, JPEG size, RGB565 fps, RGB565 size, YUV422 fps, YUV422 size \n"); + for (size_t i = 0; i <= max_size; i++) { + printf("%4d x %4d , %5.2f, %6d, %5.2f, %7d, %5.2f, %7d \n", + resolution[i].width, resolution[i].height, + results[0].fps[i], results[0].size[i], + results[1].fps[i], results[1].size[i], + results[2].fps[i], results[2].size[i]); + } + printf("----------------------------------------------------------------------------------------\n"); +} + +TEST_CASE("Camera driver init, deinit test", "[camera]") +{ + uint64_t t1 = esp_timer_get_time(); + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); + uint64_t t2 = esp_timer_get_time(); + ESP_LOGI(TAG, "Camera init time %llu ms", (t2 - t1) / 1000); + + TEST_ESP_OK(esp_camera_deinit()); +} + +TEST_CASE("Camera driver take RGB565 picture test", "[camera]") +{ + TEST_ESP_OK(init_camera(10000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); + vTaskDelay(500 / portTICK_RATE_MS); + ESP_LOGI(TAG, "Taking picture..."); + camera_fb_t *pic = esp_camera_fb_get(); + if (pic) { + ESP_LOGI(TAG, "picture: %d x %d, size: %u", pic->width, pic->height, pic->len); + printf_img_base64(pic); + esp_camera_fb_return(pic); + } + + TEST_ESP_OK(esp_camera_deinit()); + TEST_ASSERT_NOT_NULL(pic); +} + +TEST_CASE("Camera driver take YUV422 picture test", "[camera]") +{ + TEST_ESP_OK(init_camera(10000000, PIXFORMAT_YUV422, FRAMESIZE_QVGA, 2)); + vTaskDelay(500 / portTICK_RATE_MS); + ESP_LOGI(TAG, "Taking picture..."); + camera_fb_t *pic = esp_camera_fb_get(); + if (pic) { + ESP_LOGI(TAG, "picture: %d x %d, size: %u", pic->width, pic->height, pic->len); + printf_img_base64(pic); + esp_camera_fb_return(pic); + } + + TEST_ESP_OK(esp_camera_deinit()); + TEST_ASSERT_NOT_NULL(pic); +} + +TEST_CASE("Camera driver take JPEG picture test", "[camera]") +{ + TEST_ESP_OK(init_camera(20000000, PIXFORMAT_JPEG, FRAMESIZE_QVGA, 2)); + vTaskDelay(500 / portTICK_RATE_MS); + ESP_LOGI(TAG, "Taking picture..."); + camera_fb_t *pic = esp_camera_fb_get(); + if (pic) { + ESP_LOGI(TAG, "picture: %d x %d, size: %u", pic->width, pic->height, pic->len); + printf_img_base64(pic); + esp_camera_fb_return(pic); + } + + TEST_ESP_OK(esp_camera_deinit()); + TEST_ASSERT_NOT_NULL(pic); +} + +TEST_CASE("Camera driver performance test", "[camera]") +{ + camera_performance_test(20 * 1000000, 16); +} + + +static void print_rgb565_img(uint8_t *img, int width, int height) +{ + uint16_t *p = (uint16_t *)img; + const char temp2char[17] = "@MNHQ&#UJ*x7^i;."; + for (size_t j = 0; j < height; j++) { + for (size_t i = 0; i < width; i++) { + uint32_t c = p[j * width + i]; + uint8_t r = c >> 11; + uint8_t g = (c >> 6) & 0x1f; + uint8_t b = c & 0x1f; + c = (r + g + b) / 3; + c >>= 1; + printf("%c", temp2char[15 - c]); + } + printf("\n"); + } +} + +static void print_rgb888_img(uint8_t *img, int width, int height) +{ + uint8_t *p = (uint8_t *)img; + const char temp2char[17] = "@MNHQ&#UJ*x7^i;."; + for (size_t j = 0; j < height; j++) { + for (size_t i = 0; i < width; i++) { + uint8_t *c = p + 3 * (j * width + i); + uint8_t r = *c++; + uint8_t g = *c++; + uint8_t b = *c; + uint32_t v = (r + g + b) / 3; + v >>= 4; + printf("%c", temp2char[15 - v]); + } + printf("\n"); + } +} + +static void tjpgd_decode_rgb565(uint8_t *mjpegbuffer, uint32_t size, uint8_t *outbuffer) +{ + jpg2rgb565(mjpegbuffer, size, outbuffer, JPG_SCALE_NONE); +} + +static void tjpgd_decode_rgb888(uint8_t *mjpegbuffer, uint32_t size, uint8_t *outbuffer) +{ + fmt2rgb888(mjpegbuffer, size, PIXFORMAT_JPEG, outbuffer); +} + +typedef enum { + DECODE_RGB565, + DECODE_RGB888, +} decode_type_t; + +static const decode_func_t g_decode_func[2][2] = { + {tjpgd_decode_rgb565,}, + {tjpgd_decode_rgb888,}, +}; + + +static float jpg_decode_test(uint8_t decoder_index, decode_type_t type, const uint8_t *jpg, uint32_t length, uint32_t img_w, uint32_t img_h, uint32_t times) +{ + uint8_t *jpg_buf = malloc(length); + if (NULL == jpg_buf) { + ESP_LOGE(TAG, "malloc for jpg buffer failed"); + return 0; + } + memcpy(jpg_buf, jpg, length); + + uint8_t *rgb_buf = heap_caps_malloc(img_w * img_h * 3, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); + if (NULL == rgb_buf) { + free(jpg_buf); + ESP_LOGE(TAG, "malloc for rgb buffer failed"); + return 0; + } + decode_func_t decode = g_decode_func[type][decoder_index]; + decode(jpg_buf, length, rgb_buf); + if (DECODE_RGB565 == type) { + ESP_LOGI(TAG, "jpeg decode to rgb565"); + print_rgb565_img(rgb_buf, img_w, img_h); + } else { + ESP_LOGI(TAG, "jpeg decode to rgb888"); + print_rgb888_img(rgb_buf, img_w, img_h); + } + + uint64_t t_decode[times]; + for (size_t i = 0; i < times; i++) { + uint64_t t1 = esp_timer_get_time(); + decode(jpg_buf, length, rgb_buf); + t_decode[i] = esp_timer_get_time() - t1; + } + + printf("resolution , t \n"); + uint64_t t_total = 0; + for (size_t i = 0; i < times; i++) { + t_total += t_decode[i]; + float t = t_decode[i] / 1000.0f; + printf("%4d x %4d , %5.2f ms \n", img_w, img_h, t); + } + + float fps = times / (t_total / 1000000.0f); + printf("Decode FPS Result\n"); + printf("resolution , fps \n"); + printf("%4d x %4d , %5.2f \n", img_w, img_h, fps); + + free(jpg_buf); + heap_caps_free(rgb_buf); + return fps; +} + +static void img_jpeg_decode_test(uint16_t pic_index, uint16_t lib_index) +{ + extern const uint8_t img1_start[] asm("_binary_testimg_jpeg_start"); + extern const uint8_t img1_end[] asm("_binary_testimg_jpeg_end"); + extern const uint8_t img2_start[] asm("_binary_test_inside_jpeg_start"); + extern const uint8_t img2_end[] asm("_binary_test_inside_jpeg_end"); + extern const uint8_t img3_start[] asm("_binary_test_outside_jpeg_start"); + extern const uint8_t img3_end[] asm("_binary_test_outside_jpeg_end"); + + struct img_t { + const uint8_t *buf; + uint32_t length; + uint16_t w, h; + }; + struct img_t imgs[3] = { + { + .buf = img1_start, + .length = img1_end - img1_start, + .w = 227, + .h = 149, + }, + { + .buf = img2_start, + .length = img2_end - img2_start, + .w = 320, + .h = 240, + }, + { + .buf = img3_start, + .length = img3_end - img3_start, + .w = 480, + .h = 320, + }, + }; + + ESP_LOGI(TAG, "pic_index:%d", pic_index); + ESP_LOGI(TAG, "lib_index:%d", lib_index); + jpg_decode_test(lib_index, DECODE_RGB565, imgs[pic_index].buf, imgs[pic_index].length, imgs[pic_index].w, imgs[pic_index].h, 16); +} + +TEST_CASE("Conversions image 227x149 jpeg decode test", "[camera]") +{ + img_jpeg_decode_test(0, 0); +} + +TEST_CASE("Conversions image 320x240 jpeg decode test", "[camera]") +{ + img_jpeg_decode_test(1, 0); +} + +TEST_CASE("Conversions image 480x320 jpeg decode test", "[camera]") +{ + img_jpeg_decode_test(2, 0); +} diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index bb8cc70d6..c52786497 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -56,7 +56,7 @@ build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 extends = env:tasmota32_base board = esp32-cam build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_WEBCAM -lib_extra_dirs = lib/libesp32 +lib_extra_dirs = lib/libesp32, lib/libesp32_div [env:tasmota32-odroidgo] extends = env:tasmota32_base diff --git a/tasmota/support_esp.ino b/tasmota/support_esp.ino index 81b6ee6f6..27a00e108 100644 --- a/tasmota/support_esp.ino +++ b/tasmota/support_esp.ino @@ -139,7 +139,6 @@ String GetDeviceHardware(void) { bool NvmLoad(const char *sNvsName, const char *sName, void *pSettings, unsigned nSettingsLen) { nvs_handle_t handle; -// noInterrupts(); esp_err_t result = nvs_open(sNvsName, NVS_READONLY, &handle); if (result != ESP_OK) { AddLog(LOG_LEVEL_DEBUG, PSTR("NVS: Error %d"), result); @@ -148,32 +147,33 @@ bool NvmLoad(const char *sNvsName, const char *sName, void *pSettings, unsigned size_t size = nSettingsLen; nvs_get_blob(handle, sName, pSettings, &size); nvs_close(handle); -// interrupts(); return true; } void NvmSave(const char *sNvsName, const char *sName, const void *pSettings, unsigned nSettingsLen) { +#ifdef USE_WEBCAM + WcInterrupt(0); // Stop stream if active to fix TG1WDT_SYS_RESET +#endif nvs_handle_t handle; -// noInterrupts(); esp_err_t result = nvs_open(sNvsName, NVS_READWRITE, &handle); if (result != ESP_OK) { AddLog(LOG_LEVEL_DEBUG, PSTR("NVS: Error %d"), result); - return; + } else { + nvs_set_blob(handle, sName, pSettings, nSettingsLen); + nvs_commit(handle); + nvs_close(handle); } - nvs_set_blob(handle, sName, pSettings, nSettingsLen); - nvs_commit(handle); - nvs_close(handle); -// interrupts(); +#ifdef USE_WEBCAM + WcInterrupt(1); +#endif } int32_t NvmErase(const char *sNvsName) { nvs_handle_t handle; -// noInterrupts(); int32_t result = nvs_open(sNvsName, NVS_READWRITE, &handle); if (ESP_OK == result) { result = nvs_erase_all(handle); } if (ESP_OK == result) { result = nvs_commit(handle); } nvs_close(handle); -// interrupts(); return result; } @@ -232,10 +232,7 @@ void SettingsWrite(const void *pSettings, unsigned nSettingsLen) { #ifdef USE_UFILESYS TfsSaveFile(TASM_FILE_SETTINGS, (const uint8_t*)pSettings, nSettingsLen); #endif -#ifdef USE_WEBCAM - if (!WcStreamActive()) -#endif - NvmSave("main", "Settings", pSettings, nSettingsLen); + NvmSave("main", "Settings", pSettings, nSettingsLen); } void QPCRead(void *pSettings, unsigned nSettingsLen) { diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 872ad6ace..6ebe7d7d2 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -232,8 +232,7 @@ void setup(void) { #ifdef ESP32 #ifdef DISABLE_ESP32_BROWNOUT DisableBrownout(); // Workaround possible weak LDO resulting in brownout detection during Wifi connection -#endif -#endif +#endif // DISABLE_ESP32_BROWNOUT #ifdef CONFIG_IDF_TARGET_ESP32 // restore GPIO16/17 if no PSRAM is found @@ -246,7 +245,9 @@ void setup(void) { gpio_reset_pin(GPIO_NUM_17); } } -#endif +#endif // CONFIG_IDF_TARGET_ESP32 +#endif // ESP32 + RtcPreInit(); SettingsInit(); diff --git a/tasmota/xdrv_50_filesystem.ino b/tasmota/xdrv_50_filesystem.ino index 7150fbd85..0785a7329 100644 --- a/tasmota/xdrv_50_filesystem.ino +++ b/tasmota/xdrv_50_filesystem.ino @@ -287,32 +287,40 @@ bool TfsFileExists(const char *fname){ bool TfsSaveFile(const char *fname, const uint8_t *buf, uint32_t len) { if (!ffs_type) { return false; } - +#ifdef USE_WEBCAM + WcInterrupt(0); // Stop stream if active to fix TG1WDT_SYS_RESET +#endif + bool result = false; File file = ffsp->open(fname, "w"); if (!file) { AddLog(LOG_LEVEL_INFO, PSTR("TFS: Save failed")); - return false; + } else { + // This will timeout on ESP32-webcam + // But now solved with WcInterrupt(0) in support_esp.ino + file.write(buf, len); + /* + // This will still timeout on ESP32-webcam when wcresolution 10 + uint32_t count = len / 512; + uint32_t chunk = len / count; + for (uint32_t i = 0; i < count; i++) { + file.write(buf + (i * chunk), chunk); + // do actually wait a little to allow ESP32 tasks to tick + // fixes task timeout in ESP32Solo1 style unicore code and webcam. + delay(10); + OsWatchLoop(); + } + uint32_t left = len % count; + if (left) { + file.write(buf + (count * chunk), left); + } + */ + file.close(); + result = true; } - -// This will timeout on ESP32-webcam -// file.write(buf, len); - - uint32_t count = len / 512; - uint32_t chunk = len / count; - for (uint32_t i = 0; i < count; i++) { - file.write(buf + (i * chunk), chunk); - // do actually wait a little to allow ESP32 tasks to tick - // fixes task timeout in ESP32Solo1 style unicore code and webcam. - delay(10); - OsWatchLoop(); - } - uint32_t left = len % count; - if (left) { - file.write(buf + (count * chunk), left); - } - - file.close(); - return true; +#ifdef USE_WEBCAM + WcInterrupt(1); +#endif + return result; } bool TfsInitFile(const char *fname, uint32_t len, uint8_t init_value) { diff --git a/tasmota/xdrv_81_esp32_webcam.ino b/tasmota/xdrv_81_esp32_webcam.ino index 273885049..b89bc7930 100644 --- a/tasmota/xdrv_81_esp32_webcam.ino +++ b/tasmota/xdrv_81_esp32_webcam.ino @@ -26,7 +26,7 @@ * {"NAME":"AITHINKER CAM","GPIO":[4992,1,672,1,416,5088,1,1,1,6720,736,704,1,1,5089,5090,0,5091,5184,5152,0,5120,5024,5056,0,0,0,0,4928,1,5094,5095,5092,0,0,5093],"FLAG":0,"BASE":2} * * Supported commands: - * WcStream = Control streaming, 0 = stop, 1 = start + * WcInterrupt = Control streaming, 0 = stop, 1 = start * WcResolution = Set resolution 0 = FRAMESIZE_96X96, // 96x96 1 = FRAMESIZE_QQVGA, // 160x120 @@ -78,6 +78,7 @@ #define XDRV_81 81 +#include "cam_hal.h" #include "esp_camera.h" #include "sensor.h" #include "fb_gfx.h" @@ -162,10 +163,21 @@ struct { #endif // ENABLE_RTSPSERVER } Wc; - - /*********************************************************************************************/ +void WcInterrupt(uint32_t state) { + // Stop camera ISR if active to fix TG1WDT_SYS_RESET + if (!Wc.up) { return; } + + if (state) { + // Re-enable interrupts + cam_start(); + } else { + // Stop interrupts + cam_stop(); + } +} + bool WcPinUsed(void) { bool pin_used = true; for (uint32_t i = 0; i < MAX_WEBCAM_DATA; i++) { @@ -711,7 +723,7 @@ void HandleImageBasic(void) { if (Settings->webcam_config.stream) { if (!Wc.CamServer) { - WcStreamControl(); + WcInterruptControl(); } } @@ -871,19 +883,17 @@ uint32_t WcSetStreamserver(uint32_t flag) { return 0; } -void WcStreamControl() { +void WcInterruptControl() { WcSetStreamserver(Settings->webcam_config.stream); WcSetup(Settings->webcam_config.resolution); } -bool WcStreamActive(void) { - return (Wc.stream_active); -} - /*********************************************************************************************/ void WcLoop(void) { + if (4 == Wc.stream_active) { return; } + if (Wc.CamServer) { Wc.CamServer->handleClient(); if (Wc.stream_active) { HandleWebcamMjpegTask(); } @@ -945,7 +955,7 @@ void WcShowStream(void) { if (Settings->webcam_config.stream) { // if (!Wc.CamServer || !Wc.up) { if (!Wc.CamServer) { - WcStreamControl(); + WcInterruptControl(); delay(50); // Give the webcam webserver some time to prepare the stream } if (Wc.CamServer && Wc.up) { @@ -1018,7 +1028,7 @@ void CmndWebcam(void) { void CmndWebcamStream(void) { if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 1)) { Settings->webcam_config.stream = XdrvMailbox.payload; - if (!Settings->webcam_config.stream) { WcStreamControl(); } // Stop stream + if (!Settings->webcam_config.stream) { WcInterruptControl(); } // Stop stream } ResponseCmndStateText(Settings->webcam_config.stream); } @@ -1072,7 +1082,7 @@ void CmndWebcamContrast(void) { } void CmndWebcamInit(void) { - WcStreamControl(); + WcInterruptControl(); ResponseCmndDone(); } From 394ae4961303ad426262eb8b52cbab215da5ef96 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Fri, 17 Dec 2021 18:54:27 +0100 Subject: [PATCH 11/31] fix c3 compile no webcam --- platformio_tasmota_env32.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index c52786497..7a686762f 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -102,6 +102,7 @@ lib_ignore = TTGO TWatch Library Micro-RTSP epdiy + esp32-camera [env:tasmota32-AF] extends = env:tasmota32_base From 26a7fad65b00547a4677e13719edcc8f6a87b784 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 17 Dec 2021 19:41:36 +0100 Subject: [PATCH 12/31] Berry C mapping moved to a separate ``berry_mapping`` library --- CHANGELOG.md | 1 + .../default/be_lvgl_ctypes_definitions.c | 2 +- lib/libesp32/berry/default/be_lvgl_glob_lib.c | 81 ++-- lib/libesp32/berry/default/be_lvgl_module.c | 11 +- .../berry/default/embedded/lvgl_glob.be | 11 +- lib/libesp32/berry/include/be_lvgl.h | 40 -- .../berry_mapping/src/be_class_wrapper.c | 406 ++++++++++++++++++ .../berry_mapping/src/be_const_members.c | 64 +++ lib/libesp32/berry_mapping/src/be_mapping.h | 58 ++- .../berry_mapping/src/be_mapping_utils.c | 97 +++++ lib/libesp32/berry_mapping/src/be_raisef.c | 22 + tasmota/berry/include/be_gpio_defines.h | 2 +- tasmota/lvgl_berry/be_lv_c_mapping.h | 119 ++--- tasmota/xdrv_52_1_berry_native.ino | 350 --------------- tasmota/xdrv_52_3_berry_gpio.ino | 2 +- tasmota/xdrv_52_3_berry_light.ino | 32 +- tasmota/xdrv_52_3_berry_lvgl.ino | 175 +------- tasmota/xdrv_52_3_berry_tasmota.ino | 78 ++-- tasmota/xdrv_52_3_berry_webclient.ino | 2 +- tasmota/xdrv_52_3_berry_webserver.ino | 4 +- tools/lv_berry/convert.py | 22 +- tools/lv_gpio/gpio_convert.py | 2 +- 22 files changed, 843 insertions(+), 738 deletions(-) delete mode 100644 lib/libesp32/berry/include/be_lvgl.h create mode 100644 lib/libesp32/berry_mapping/src/be_class_wrapper.c create mode 100644 lib/libesp32/berry_mapping/src/be_const_members.c create mode 100644 lib/libesp32/berry_mapping/src/be_mapping_utils.c create mode 100644 lib/libesp32/berry_mapping/src/be_raisef.c diff --git a/CHANGELOG.md b/CHANGELOG.md index e5d9a8633..6ca69c83c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -893,6 +893,7 @@ All notable changes to this project will be documented in this file. ### Changed - Triple-mode TLS via configuration in a single firmware (TLS AWS IoT, Letsencrypt and No-TLS) +- Berry C mapping moved to a separate ``berry_mapping`` library ### Fixed - ESP32 PWM range diff --git a/lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c b/lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c index bb1ffb65c..74797a760 100644 --- a/lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c +++ b/lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c @@ -6,7 +6,7 @@ #ifdef USE_LVGL #include "lvgl.h" -#include "be_lvgl.h" +#include "be_mapping.h" /******************************************************************** * Generated code, don't edit diff --git a/lib/libesp32/berry/default/be_lvgl_glob_lib.c b/lib/libesp32/berry/default/be_lvgl_glob_lib.c index 06827fc0e..49848e1dc 100644 --- a/lib/libesp32/berry/default/be_lvgl_glob_lib.c +++ b/lib/libesp32/berry/default/be_lvgl_glob_lib.c @@ -249,7 +249,7 @@ be_local_closure(LVGL_glob_register_obj, /* name */ be_local_closure(LVGL_glob_gen_cb, /* name */ be_nested_proto( 8, /* nstack */ - 5, /* argc */ + 4, /* argc */ 0, /* varg */ 0, /* has upvals */ NULL, /* no upvals */ @@ -281,56 +281,57 @@ be_local_closure(LVGL_glob_gen_cb, /* name */ ), }), 1, /* has constants */ - ( &(const bvalue[ 8]) { /* constants */ - /* K0 */ be_nested_str(lv_event_cb), - /* K1 */ be_nested_str(cb_event_closure), - /* K2 */ be_nested_str(event_cb), - /* K3 */ be_nested_str(tasmota), + ( &(const bvalue[ 9]) { /* constants */ + /* K0 */ be_nested_str(cb), + /* K1 */ be_nested_str(lv_event_cb), + /* K2 */ be_nested_str(cb_event_closure), + /* K3 */ be_nested_str(event_cb), /* K4 */ be_nested_str(gen_cb), /* K5 */ be_nested_str(register_obj), - /* K6 */ be_nested_str(null_cb), - /* K7 */ be_nested_str(cb_do_nothing), + /* K6 */ be_nested_str(_p), + /* K7 */ be_nested_str(null_cb), + /* K8 */ be_nested_str(cb_do_nothing), }), &be_const_str_gen_cb, &be_const_str_solidified, ( &(const binstruction[41]) { /* code */ - 0x1C140300, // 0000 EQ R5 R1 K0 - 0x78160018, // 0001 JMPF R5 #001B - 0x88140101, // 0002 GETMBR R5 R0 K1 - 0x4C180000, // 0003 LDNIL R6 - 0x1C140A06, // 0004 EQ R5 R5 R6 - 0x78160002, // 0005 JMPF R5 #0009 - 0x60140013, // 0006 GETGBL R5 G19 - 0x7C140000, // 0007 CALL R5 0 - 0x90020205, // 0008 SETMBR R0 K1 R5 - 0x88140102, // 0009 GETMBR R5 R0 K2 - 0x4C180000, // 000A LDNIL R6 - 0x1C140A06, // 000B EQ R5 R5 R6 - 0x78160004, // 000C JMPF R5 #0012 - 0xB8160600, // 000D GETNGBL R5 K3 - 0x8C140B04, // 000E GETMET R5 R5 K4 + 0xA4120000, // 0000 IMPORT R4 K0 + 0x1C140701, // 0001 EQ R5 R3 K1 + 0x78160018, // 0002 JMPF R5 #001C + 0x88140102, // 0003 GETMBR R5 R0 K2 + 0x4C180000, // 0004 LDNIL R6 + 0x1C140A06, // 0005 EQ R5 R5 R6 + 0x78160002, // 0006 JMPF R5 #000A + 0x60140013, // 0007 GETGBL R5 G19 + 0x7C140000, // 0008 CALL R5 0 + 0x90020405, // 0009 SETMBR R0 K2 R5 + 0x88140103, // 000A GETMBR R5 R0 K3 + 0x4C180000, // 000B LDNIL R6 + 0x1C140A06, // 000C EQ R5 R5 R6 + 0x78160003, // 000D JMPF R5 #0012 + 0x8C140904, // 000E GETMET R5 R4 K4 0x841C0000, // 000F CLOSURE R7 P0 0x7C140400, // 0010 CALL R5 2 - 0x90020405, // 0011 SETMBR R0 K2 R5 + 0x90020605, // 0011 SETMBR R0 K3 R5 0x8C140105, // 0012 GETMET R5 R0 K5 - 0x5C1C0600, // 0013 MOVE R7 R3 + 0x5C1C0400, // 0013 MOVE R7 R2 0x7C140400, // 0014 CALL R5 2 - 0x88140101, // 0015 GETMBR R5 R0 K1 - 0x98140802, // 0016 SETIDX R5 R4 R2 - 0x88140102, // 0017 GETMBR R5 R0 K2 - 0xA0000000, // 0018 CLOSE R0 - 0x80040A00, // 0019 RET 1 R5 - 0x7002000B, // 001A JMP #0027 - 0x88140106, // 001B GETMBR R5 R0 K6 - 0x4C180000, // 001C LDNIL R6 - 0x1C140A06, // 001D EQ R5 R5 R6 - 0x78160004, // 001E JMPF R5 #0024 - 0xB8160600, // 001F GETNGBL R5 K3 - 0x8C140B04, // 0020 GETMET R5 R5 K4 - 0x881C0107, // 0021 GETMBR R7 R0 K7 + 0x88140506, // 0015 GETMBR R5 R2 K6 + 0x88180102, // 0016 GETMBR R6 R0 K2 + 0x98180A01, // 0017 SETIDX R6 R5 R1 + 0x88140103, // 0018 GETMBR R5 R0 K3 + 0xA0000000, // 0019 CLOSE R0 + 0x80040A00, // 001A RET 1 R5 + 0x7002000A, // 001B JMP #0027 + 0x88140107, // 001C GETMBR R5 R0 K7 + 0x4C180000, // 001D LDNIL R6 + 0x1C140A06, // 001E EQ R5 R5 R6 + 0x78160003, // 001F JMPF R5 #0024 + 0x8C140904, // 0020 GETMET R5 R4 K4 + 0x881C0108, // 0021 GETMBR R7 R0 K8 0x7C140400, // 0022 CALL R5 2 - 0x90020C05, // 0023 SETMBR R0 K6 R5 - 0x88140106, // 0024 GETMBR R5 R0 K6 + 0x90020E05, // 0023 SETMBR R0 K7 R5 + 0x88140107, // 0024 GETMBR R5 R0 K7 0xA0000000, // 0025 CLOSE R0 0x80040A00, // 0026 RET 1 R5 0xA0000000, // 0027 CLOSE R0 diff --git a/lib/libesp32/berry/default/be_lvgl_module.c b/lib/libesp32/berry/default/be_lvgl_module.c index 890efd2ff..bb9b86e3e 100644 --- a/lib/libesp32/berry/default/be_lvgl_module.c +++ b/lib/libesp32/berry/default/be_lvgl_module.c @@ -9,7 +9,7 @@ #ifdef USE_LVGL #include "lvgl.h" -#include "be_lvgl.h" +#include "be_mapping.h" #include "lv_theme_openhasp.h" extern int lv0_member(bvm *vm); // resolve virtual members @@ -34,7 +34,7 @@ static int lv_get_ver_res(void) { } /* `lv` methods */ -const lvbe_call_c_t lv_func[] = { +const be_ntv_func_def_t lv_func[] = { { "clamp_height", (void*) &lv_clamp_height, "i", "iiii" }, { "clamp_width", (void*) &lv_clamp_width, "i", "iiii" }, @@ -111,12 +111,7 @@ const size_t lv_func_size = sizeof(lv_func) / sizeof(lv_func[0]); -typedef struct be_constint_t { - const char * name; - int32_t value; -} be_constint_t; - -const be_constint_t lv0_constants[] = { +const be_const_member_t lv0_constants[] = { { "ALIGN_BOTTOM_LEFT", LV_ALIGN_BOTTOM_LEFT }, { "ALIGN_BOTTOM_MID", LV_ALIGN_BOTTOM_MID }, diff --git a/lib/libesp32/berry/default/embedded/lvgl_glob.be b/lib/libesp32/berry/default/embedded/lvgl_glob.be index 04250ff54..17a62bf31 100644 --- a/lib/libesp32/berry/default/embedded/lvgl_glob.be +++ b/lib/libesp32/berry/default/embedded/lvgl_glob.be @@ -44,20 +44,21 @@ class LVGL_glob f(obj, event) end - def gen_cb(name, f, obj, ptr) - #print('>> gen_cb', name, obj, ptr) + def gen_cb(f, obj, name) + import cb + # print('>> gen_cb', f, name, obj) # record the object, whatever the callback if name == "lv_event_cb" if self.cb_event_closure == nil self.cb_event_closure = {} end - if self.event_cb == nil self.event_cb = tasmota.gen_cb(/ event_ptr -> self.lvgl_event_dispatch(event_ptr)) end # encapsulate 'self' in closure + if self.event_cb == nil self.event_cb = cb.gen_cb(/ event_ptr -> self.lvgl_event_dispatch(event_ptr)) end # encapsulate 'self' in closure self.register_obj(obj) - self.cb_event_closure[ptr] = f + self.cb_event_closure[obj._p] = f return self.event_cb # elif name == "" else - if self.null_cb == nil self.null_cb = tasmota.gen_cb(self.cb_do_nothing) end + if self.null_cb == nil self.null_cb = cb.gen_cb(self.cb_do_nothing) end return self.null_cb end end diff --git a/lib/libesp32/berry/include/be_lvgl.h b/lib/libesp32/berry/include/be_lvgl.h deleted file mode 100644 index 52b5edc2d..000000000 --- a/lib/libesp32/berry/include/be_lvgl.h +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************** - * Tasmota LVGL Headers - *******************************************************************/ -#ifndef __BE_LVGL_H__ -#define __BE_LVGL_H__ - -#include "be_constobj.h" - -#ifdef USE_LVGL - -#include "lvgl.h" - -#ifdef __cplusplus -extern "C" { -#endif - // table of functions per class - typedef struct lvbe_call_c_t { - const char * name; - void * func; - const char * return_type; - const char * arg_type; - } lvbe_call_c_t; - - // list of classes and function tables - typedef struct lvbe_call_c_classes_t { - const char * name; - const bclass * cl; - const lvbe_call_c_t * func_table; - size_t size; - } lvbe_call_c_classes_t; - extern const lvbe_call_c_classes_t lv_classes[]; - extern const size_t lv_classes_size; - -#ifdef __cplusplus -} -#endif - -#endif // USE_LVGL - -#endif // __BE_LVGL_H__ \ No newline at end of file diff --git a/lib/libesp32/berry_mapping/src/be_class_wrapper.c b/lib/libesp32/berry_mapping/src/be_class_wrapper.c new file mode 100644 index 000000000..5f71e7da1 --- /dev/null +++ b/lib/libesp32/berry_mapping/src/be_class_wrapper.c @@ -0,0 +1,406 @@ +/*********************************************************************************************\ + * Class wrappers for native objects + * + * These class are simple wrappers (containers) for a pointer of an external object. + * The pointer is stored interanlly by the class. + * + * The constructor of this class must accept the first argument to be `comptr`, + * in such case, the constructor must store the pointer. + * The class is not supposed to free the object at `deinit` time. +\*********************************************************************************************/ + +#include "be_mapping.h" +#include "be_exec.h" +#include + +/*********************************************************************************************\ + * Create an object of `class_name` given an external poinrt `ptr`. + * + * Instanciates the class and calls `init()` with `ptr` wrapped in `comptr` as single arg. + * Both arguments but nost bu NULL. + * + * On return, the created instance is top of stack. +\*********************************************************************************************/ +void be_create_class_wrapper(bvm *vm, const char * class_name, void * ptr) { + if (ptr == NULL) { + be_throw(vm, BE_MALLOC_FAIL); + } + + be_getglobal(vm, class_name); // stack = class + be_call(vm, 0); // instanciate, stack = instance + be_getmember(vm, -1, "init"); // stack = instance, init_func + be_pushvalue(vm, -2); // stack = instance, init_func, instance + be_pushcomptr(vm, ptr); // stack = instance, init_func, instance, ptr + be_call(vm, 2); // stack = instance, ret, instance, ptr + be_pop(vm, 3); // stack = instance +} + + +/*********************************************************************************************\ + * Find an object by global or composite name. + * + * I.e. `lv.lv_object` will check for a global called `lv` and a member `lv_object` + * + * Only supports one level of depth, meaning a class within a module. + * Does not check the type of the object found. + * + * Arguments: + * `name`: can be NULL, in such case considers the member as not found + * + * Case 1: (no dot in name) `lv_wifi_bars` will look for a global variable `lv_wifi_bars` + * Case 2: (dot in name) `lvgl.lv_obj` will get global `lvgl` and look for `lv_obj` within this module + * + * Returns the number of elements pushed on the stack: 1 for module, 2 for instance method, 0 if not found +\*********************************************************************************************/ +int be_find_global_or_module_member(bvm *vm, const char * name) { + char *saveptr; + + if (name == NULL) { + be_pushnil(vm); + return 0; + } + char name_buf[strlen(name)+1]; + strcpy(name_buf, name); + + char * prefix = strtok_r(name_buf, ".", &saveptr); + char * suffix = strtok_r(NULL, ".", &saveptr); + if (suffix) { + if (be_getglobal(vm, prefix)) { + if (be_getmember(vm, -1, suffix)) { + if (be_isinstance(vm, -2)) { // instance, so we need to push method + instance + be_pushvalue(vm, -2); + be_remove(vm, -3); + return 2; + } else { // not instane, so keep only the top object + be_remove(vm, -2); + return 1; + } + } else { + be_pop(vm, 2); + return 0; + } + } + be_pop(vm, 1); // remove nil + return 0; + } else { // no suffix, get the global object + if (be_getglobal(vm, prefix)) { + return 1; + } + be_pop(vm, 1); + return 0; + } +} + + +/*********************************************************************************************\ + * Automatically parse Berry stack and call the C function accordingly + * + * This function takes the n incoming arguments and pushes them as arguments + * on the stack for the C function: + * - be_int -> int32_t + * - be_bool -> int32_t with value 0/1 + * - be_string -> const char * + * - be_instance -> gets the member "_p" and pushes as void* + * + * This works because C silently ignores any unwanted arguments. + * There is a strong requirements that all ints and pointers are 32 bits. + * Float is not supported but could be added. Double cannot be supported because they are 64 bits + * + * Optional argument: + * - return_type: the C function return value is int32_t and is converted to the + * relevant Berry object depending on this char: + * '' (default): nil, no value + * 'i' be_int + * 'b' be_bool + * 's' be_str + * + * - arg_type: optionally check the types of input arguments, or throw an error + * string of argument types, '+' marks optional arguments + * '.' don't care + * 'i' be_int + * 'b' be_bool + * 's' be_string + * 'c' C callback + * '-' ignore and don't send to C function + * 'lv_obj' be_instance of type or subtype + * '^lv_event_cb' callback of a named class - will call `_lvgl.gen_cb(arg_type, closure, self)` and expects a callback address in return + * + * Ex: "oii+s" takes 3 mandatory arguments (obj_instance, int, int) and an optional fourth one [,string] +\*********************************************************************************************/ +// general form of lv_obj_t* function, up to 4 parameters +// We can only send 32 bits arguments (no 64 bits nor double) and we expect pointers to be 32 bits + +// read a single value at stack position idx, convert to int. +// if object instance, get `_p` member and convert it recursively +intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const char * gen_cb) { + // berry_log_C("be_convert_single_elt(idx=%i, argtype='%s', gen_cb=%p", idx, arg_type, gen_cb); + int ret = 0; + char provided_type = 0; + idx = be_absindex(vm, idx); // make sure we have an absolute index + + // berry_log_C(">> 0 idx=%i arg_type=%s", idx, arg_type ? arg_type : "NULL"); + if (arg_type == NULL) { arg_type = "."; } // if no type provided, replace with wildchar + size_t arg_type_len = strlen(arg_type); + + // handle callbacks first, since a wrong parameter will always yield to a crash + if (arg_type_len > 1 && arg_type[0] == '^') { // it is a callback + arg_type++; // skip first character + if (be_isclosure(vm, idx)) { + ret = be_find_global_or_module_member(vm, gen_cb); + if (ret) { + be_remove(vm, -3); // stack contains method + instance + be_pushvalue(vm, idx); + be_pushvalue(vm, 1); + be_pushstring(vm, arg_type); + be_call(vm, 2 + ret); + const void * func = be_tocomptr(vm, -(3 + ret)); + be_pop(vm, 3 + ret); + + // berry_log_C("func=%p", func); + return (int32_t) func; + } else { + be_raisef(vm, "type_error", "Can't find callback generator: %s", gen_cb); + } + } else { + be_raise(vm, "type_error", "Closure expected for callback type"); + } + } + + // first convert the value to int32 + if (be_isint(vm, idx)) { ret = be_toint(vm, idx); provided_type = 'i'; } + else if (be_isbool(vm, idx)) { ret = be_tobool(vm, idx); provided_type = 'b'; } + else if (be_isstring(vm, idx)) { ret = (intptr_t) be_tostring(vm, idx); provided_type = 's'; } + else if (be_iscomptr(vm, idx)) { ret = (intptr_t) be_tocomptr(vm, idx); provided_type = 'c'; } + else if (be_isnil(vm, idx)) { ret = 0; provided_type = 'c'; } + + // check if simple type was a match + if (provided_type) { + bbool type_ok = bfalse; + type_ok = (arg_type[0] == '.'); // any type is accepted + type_ok = type_ok || (arg_type[0] == provided_type); // or type is a match + type_ok = type_ok || (ret == 0 && arg_type_len != 1); // or NULL is accepted for an instance + + if (!type_ok) { + be_raisef(vm, "type_error", "Unexpected argument type '%c', expected '%s'", provided_type, arg_type); + } + // berry_log_C("be_convert_single_elt provided type=%i", ret); + return ret; + } + + // berry_log_C("be_convert_single_elt non simple type"); + // non-simple type + if (be_isinstance(vm, idx)) { + // check if the instance is a subclass of `bytes()`` + be_getbuiltin(vm, "bytes"); + if (be_isderived(vm, idx)) { + be_pop(vm, 1); + be_getmember(vm, idx, "_buffer"); + be_pushvalue(vm, idx); + be_call(vm, 1); + int32_t ret = (int32_t) be_tocomptr(vm, -2); + be_pop(vm, 2); + return ret; + } else { + be_pop(vm, 1); + // we accept either `_p` or `.p` attribute to retrieve a pointer + if (!be_getmember(vm, idx, "_p")) { + be_pop(vm, 1); // remove `nil` + be_getmember(vm, idx, ".p"); + } + int32_t ret = be_convert_single_elt(vm, -1, NULL, NULL); // recurse + be_pop(vm, 1); + + if (arg_type_len > 1) { + // Check type + be_classof(vm, idx); + int class_found = be_find_global_or_module_member(vm, arg_type); + // Stack: class_of_idx, class_of_target (or nil) + if (class_found) { + if (!be_isderived(vm, -2)) { + be_raisef(vm, "type_error", "Unexpected class type '%s', expected '%s'", be_classname(vm, idx), arg_type); + } + } else { + be_raisef(vm, "value_error", "Unable to find class '%s' (%d)", arg_type, arg_type_len); + } + be_pop(vm, 2); + } else if (arg_type[0] != '.') { + be_raisef(vm, "value_error", "Unexpected instance type '%s', expected '%s'", be_classname(vm, idx), arg_type); + } + + return ret; + } + } else { + be_raisef(vm, "value_error", "Unexpected '%s'", be_typename(vm, idx)); + } + + return ret; +} + +/*********************************************************************************************\ + * Calling any LVGL function with auto-mapping + * +\*********************************************************************************************/ + +// check input parameters, and create callbacks if needed +// change values in place +// +// Format: +// - either a lowercase character encoding for a simple type +// - 'b': bool +// - 'i': int (int32_t) +// - 's': string (const char *) +// +// - a class name surroungded by parenthesis +// - '(lv_button)' -> lv_button class or derived +// - '[lv_event_cb]' -> callback type, still prefixed with '^' to mark that it is cb +// +void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type, intptr_t p[8]) { + bbool arg_type_check = (arg_type != NULL); // is type checking activated + int32_t arg_idx = 0; // position in arg_type string + char type_short_name[32]; + + uint32_t p_idx = 0; // index in p[], is incremented with each parameter except '-' + for (uint32_t i = 0; i < argc; i++) { + type_short_name[0] = 0; // clear string + // extract individual type + if (NULL != arg_type) { + switch (arg_type[arg_idx]) { + case '-': + arg_idx++; + continue; // ignore current parameter and advance + case '.': + case 'a'...'z': + type_short_name[0] = arg_type[arg_idx]; + type_short_name[1] = 0; + arg_idx++; + break; + case '(': + case '^': + { + uint32_t prefix = 0; + if (arg_type[arg_idx] == '^') { + type_short_name[0] = '^'; + type_short_name[1] = 0; + prefix = 1; + } + uint32_t offset = 0; + arg_idx++; + while (arg_type[arg_idx + offset] != ')' && arg_type[arg_idx + offset] != '^' && arg_type[arg_idx + offset] != 0 && offset+prefix+1 < sizeof(type_short_name)) { + type_short_name[offset+prefix] = arg_type[arg_idx + offset]; + type_short_name[offset+prefix+1] = 0; + offset++; + } + if (arg_type[arg_idx + offset] == 0) { + arg_type = NULL; // no more parameters, stop iterations + } + arg_idx += offset + 1; + } + break; + case 0: + arg_type = NULL; // stop iterations + break; + } + } + // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func arg %i, type %s", i, arg_type_check ? type_short_name : ""); + p[p_idx++] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : NULL, "_lvgl.gen_cb"); + } + + // check if we are missing arguments + if (arg_type != NULL && arg_type[arg_idx] != 0) { + be_raisef(vm, "value_error", "Missing arguments, remaining type '%s'", &arg_type[arg_idx]); + } +} + +// +// Internal function +// +// Called for constructors, i.e. C function mapped to Berry `init()` +// +// Pre-conditions: +// The instance must be at stack position `1` (default when calling `init()`) +// +// Arguments: +// vm: point to Berry vm (as usual) +// ptr: the C pointer for internal data (can be NULL), will be stored in an instance variable +// name: name of instance variable to store the pointer as `comptr`. +// If NULL, this function does nothing +// the name can be prefixed with `+`, if so first char is ignored. +// Ex: `+_p` stores in instance variable `_p` +static void be_set_ctor_ptr(bvm *vm, void * ptr, const char *name) { + if (name == NULL) return; // do nothing if no name of attribute + if (name[0] == '+') { name++; } // skip prefix '^' if any + if (strlen(name) == 0) return; // do nothing if name is empty + + be_pushcomptr(vm, ptr); + if (be_setmember(vm, 1, name)) { + be_pop(vm, 1); + } else { + be_raisef(vm, "attribute_error", "Missing member '%s' in ctor", name); + } +} + +/*********************************************************************************************\ + * Call a C function with auto-mapping + * + * Arguments: + * vm: pointer to Berry vm (as ususal) + * func: pointer to C function + * return_type: how to convert the result into a Berry type + * arg_type: string describing the optional and mandatory parameters + * + * Note: the C function mapping supports max 8 arguments and does not directly support + * pointers to values (although it is possible to mimick with classes) +\*********************************************************************************************/ +int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type) { + intptr_t p[8] = {0,0,0,0,0,0,0,0}; + int argc = be_top(vm); // Get the number of arguments + + // the following describe the active payload for the C function (start and count) + // this is because the `init()` constructor first arg is not passed to the C function + int arg_start = 1; // start with standard values + int arg_count = argc; + + // check if we call a constructor, in this case we store the return type into the new object + // check if we call a constructor with a comptr as first arg + if (return_type && return_type[0] == '+') { + if (argc > 1 && be_iscomptr(vm, 2)) { + void * obj = be_tocomptr(vm, 2); + be_set_ctor_ptr(vm, obj, return_type); + be_return_nil(vm); + } else { + // we need to discard the first arg + arg_start++; + arg_count--; + } + } + + fn_any_callable f = (fn_any_callable) func; + be_check_arg_type(vm, arg_start, arg_count, arg_type, p); + intptr_t ret = (*f)(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); + // berry_log_C("be_call_c_func '%s' -> '%s': (%i,%i,%i,%i,%i,%i) -> %i", return_type, arg_type, p[0], p[1], p[2], p[3], p[4], p[5], ret); + + if ((return_type == NULL) || (strlen(return_type) == 0)) { be_return_nil(vm); } // does not return + else if (return_type[0] == '+') { + void * obj = (void*) ret; + be_set_ctor_ptr(vm, obj, return_type); + be_return_nil(vm); + } + else if (strlen(return_type) == 1) { + switch (return_type[0]) { + case '.': // fallback next + case 'i': be_pushint(vm, ret); break; + case 'b': be_pushbool(vm, ret); break; + case 's': be_pushstring(vm, (const char*) ret); break; + case 'c': be_pushint(vm, ret); break; // TODO missing 'c' general callback type + default: be_raise(vm, "internal_error", "Unsupported return type"); break; + } + be_return(vm); + } else { // class name + be_find_global_or_module_member(vm, return_type); + be_pushcomptr(vm, (void*) ret); // stack = class, ptr + be_pushcomptr(vm, (void*) -1); // stack = class, ptr, -1 + be_call(vm, 2); // instanciate with 2 arguments, stack = instance, -1, ptr + be_pop(vm, 2); // stack = instance + be_return(vm); + } +} diff --git a/lib/libesp32/berry_mapping/src/be_const_members.c b/lib/libesp32/berry_mapping/src/be_const_members.c new file mode 100644 index 000000000..7a1a796df --- /dev/null +++ b/lib/libesp32/berry_mapping/src/be_const_members.c @@ -0,0 +1,64 @@ +/*********************************************************************************************\ + * Add const virtual members to classes and modules from C static tables + * + * This allows to creates hundreds of constant members (integers, strings...) + * stored in a C array instead of explicit berry members. + * + * It has the following advantages: + * - consumes much less flash memory, especially with hundreds of members + * - allows C preprocessor to compute the value at compile time (instead of pure numerical numbers) + * - allows to compute pointer addresses to C structures + * + * Takes a pointer to be_const_member_t array and size + * Returns true if a match was found. In such case the result is on Berry stack + * + * Encoding depend on prefix (which is skipped when matching names): + * 1. `COLOR_WHITE` int value + * 3. `$SYMBOL_OK"` string pointer + * 4. `&seg7_font` comptr +\*********************************************************************************************/ + +#include "be_mapping.h" +#include "be_exec.h" +#include +/*********************************************************************************************\ + * Takes a pointer to be_const_member_t array and size + * Returns true if a match was found. In such case the result is on Berry stack + * + * Can be called directly by `member()` function, takes the name of the member from + * berry stack at position 1. + * + * Encoding depend on prefix (which is skipped when matching names): + * 1. `COLOR_WHITE` int value + * 3. `$SYMBOL_OK"` string pointer + * 4. `&seg7_font` comptr + * + * The array must be lexically sorted, but the sort function must ignore the prefix `$` or `&` +\*********************************************************************************************/ +bbool be_const_member(bvm *vm, const be_const_member_t * definitions, size_t def_len) { + int32_t argc = be_top(vm); // Get the number of arguments + if (argc == 1 && be_isstring(vm, 1)) { + const char * needle = be_tostring(vm, 1); + int32_t idx; + + idx = be_map_bin_search(needle, &definitions[0].name, sizeof(definitions[0]), def_len); + if (idx >= 0) { + // we did have a match + const char * key = definitions[idx].name; + switch (key[0]) { + // switch depending on the first char of the key, indicating the type + case '$': // string + be_pushstring(vm, (const char*) definitions[idx].value); + break; + case '&': // native function + be_pushntvfunction(vm, (bntvfunc) definitions[idx].value); + break; + default: // int + be_pushint(vm, definitions[idx].value); + break; + } + return btrue; + } + } + return bfalse; +} \ No newline at end of file diff --git a/lib/libesp32/berry_mapping/src/be_mapping.h b/lib/libesp32/berry_mapping/src/be_mapping.h index 850cd08c0..108db129b 100644 --- a/lib/libesp32/berry_mapping/src/be_mapping.h +++ b/lib/libesp32/berry_mapping/src/be_mapping.h @@ -3,8 +3,64 @@ #ifndef __BE_MAPPING__ #define __BE_MAPPING__ -// include this header to force compilation fo this module +#ifdef __cplusplus +extern "C" { +#endif +#include "berry.h" + +// include this header to force compilation fo this module #define BE_MAX_CB 20 // max number of callbacks, each callback requires a distinct address +/*********************************************************************************************\ + * Support for Berry int constants + * as virtual members + \*********************************************************************************************/ + +typedef intptr_t (*fn_any_callable)(intptr_t p0, intptr_t p1, intptr_t p2, intptr_t p3, + intptr_t p4, intptr_t p5, intptr_t p6, intptr_t p7); + +typedef struct be_const_member_t { + const char * name; + int value; +} be_const_member_t; + +// table of functions per class +typedef struct be_ntv_func_def_t { + const char * name; + void * func; + const char * return_type; + const char * arg_type; +} be_ntv_func_def_t; + +struct bclass; +// list of classes and function tables +typedef struct be_ntv_class_def_t { + const char * name; + const struct bclass * cl; + const be_ntv_func_def_t * func_table; + size_t size; +} be_ntv_class_def_t; + +void be_raisef(bvm *vm, const char *except, const char *msg, ...); + +extern void be_map_insert_int(bvm *vm, const char *key, bint value); +extern void be_map_insert_bool(bvm *vm, const char *key, bbool value); +extern void be_map_insert_real(bvm *vm, const char *key, breal value); +extern void be_map_insert_str(bvm *vm, const char *key, const char *value); +extern void be_map_insert_list_uint8(bvm *vm, const char *key, const uint8_t *value, size_t size); + +extern int be_map_bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements); + +extern void be_create_class_wrapper(bvm *vm, const char * class_name, void * ptr); +extern int be_find_global_or_module_member(bvm *vm, const char * cl_name); + +extern bbool be_const_member(bvm *vm, const be_const_member_t * definitions, size_t def_len); +extern intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const char * gen_cb); +extern void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type, intptr_t p[8]);; +extern int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type); + +#ifdef __cplusplus +} +#endif #endif // __BE_MAPPING__ diff --git a/lib/libesp32/berry_mapping/src/be_mapping_utils.c b/lib/libesp32/berry_mapping/src/be_mapping_utils.c new file mode 100644 index 000000000..e3a2cc6e2 --- /dev/null +++ b/lib/libesp32/berry_mapping/src/be_mapping_utils.c @@ -0,0 +1,97 @@ +#include "be_mapping.h" +#include +#include + +/*********************************************************************************************\ + * Helper functions to create a map with single line calls +\*********************************************************************************************/ +/* Insert an int to a key */ +void be_map_insert_int(bvm *vm, const char *key, bint value) +{ + be_pushstring(vm, key); + be_pushint(vm, value); + be_data_insert(vm, -3); + be_pop(vm, 2); +} +/* Insert an bbool to a key */ +void be_map_insert_bool(bvm *vm, const char *key, bbool value) +{ + be_pushstring(vm, key); + be_pushbool(vm, value); + be_data_insert(vm, -3); + be_pop(vm, 2); +} +/* Insert an real to a key */ +/* if value == NAN, ignore */ +void be_map_insert_real(bvm *vm, const char *key, breal value) +{ + if (!isnan(value)) { + be_pushstring(vm, key); + be_pushreal(vm, value); + be_data_insert(vm, -3); + be_pop(vm, 2); + } +} +/* Insert an C string to a key */ +void be_map_insert_str(bvm *vm, const char *key, const char *value) +{ + be_pushstring(vm, key); + be_pushstring(vm, value); + be_data_insert(vm, -3); + be_pop(vm, 2); +} +/* Insert list of bytes as individual integers to a key */ +void be_map_insert_list_uint8(bvm *vm, const char *key, const uint8_t *value, size_t size) +{ + be_pushstring(vm, key); + + be_newobject(vm, "list"); + for (uint32_t i=0; i < size; i++) { + be_pushint(vm, value[i]); + be_data_push(vm, -2); + be_pop(vm, 1); + } + be_pop(vm, 1); // now list is on top + + be_data_insert(vm, -3); // insert into map, key/value + be_pop(vm, 2); // pop both key and value +} + +/*********************************************************************************************\ + * Binary search for dynamic attributes + * + * Names need to be sorted +\*********************************************************************************************/ +// binary search within an array of sorted strings +// the first 4 bytes are a pointer to a string +// returns 0..total_elements-1 or -1 if not found +// +// This version skips the first character of the string if it's not a letter, +// the first character is used to indicate the type of the value associated to the key +int be_map_bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements) { + int low = 0; + int high = total_elements - 1; + int mid = (low + high) / 2; + // start a dissect + while (low <= high) { + const char * elt = *(const char **) ( ((uint8_t*)table) + mid * elt_size ); + char first_char = elt[0]; + if ( !(first_char >= 'a' && first_char <='z') && !(first_char >= 'A' && first_char <='Z') ) { + elt++; // skip first char + } + int comp = strcmp(needle, elt); + if (comp < 0) { + high = mid - 1; + } else if (comp > 0) { + low = mid + 1; + } else { + break; + } + mid = (low + high) / 2; + } + if (low <= high) { + return mid; + } else { + return -1; + } +} \ No newline at end of file diff --git a/lib/libesp32/berry_mapping/src/be_raisef.c b/lib/libesp32/berry_mapping/src/be_raisef.c new file mode 100644 index 000000000..6d8451bab --- /dev/null +++ b/lib/libesp32/berry_mapping/src/be_raisef.c @@ -0,0 +1,22 @@ +/*********************************************************************************************\ + * Extended version of be_raise() +\*********************************************************************************************/ + +#include "be_mapping.h" +#include "be_exec.h" +#include +#include +#include + +// variant of be_raise with string format +void be_raisef(bvm *vm, const char *except, const char *msg, ...) { + // To save stack space support logging for max text length of 128 characters + char log_data[128]; + + va_list arg; + va_start(arg, msg); + uint32_t len = vsnprintf(log_data, sizeof(log_data)-3, msg, arg); + va_end(arg); + if (len+3 > sizeof(log_data)) { strcat(log_data, "..."); } // Actual data is more + be_raise(vm, except, log_data); +} diff --git a/tasmota/berry/include/be_gpio_defines.h b/tasmota/berry/include/be_gpio_defines.h index 73f37825e..e40219dc4 100644 --- a/tasmota/berry/include/be_gpio_defines.h +++ b/tasmota/berry/include/be_gpio_defines.h @@ -2,7 +2,7 @@ * Generated code, don't edit *******************************************************************/ -const be_constint_t lv_gpio_constants[] = { +const be_const_member_t lv_gpio_constants[] = { { "A4988_DIR", (int32_t) GPIO_A4988_DIR }, { "A4988_ENA", (int32_t) GPIO_A4988_ENA }, diff --git a/tasmota/lvgl_berry/be_lv_c_mapping.h b/tasmota/lvgl_berry/be_lv_c_mapping.h index 553238373..dd654f5f3 100644 --- a/tasmota/lvgl_berry/be_lv_c_mapping.h +++ b/tasmota/lvgl_berry/be_lv_c_mapping.h @@ -8,9 +8,10 @@ extern "C" { #endif #include "be_ctypes.h" +#include "be_mapping.h" /* `lv_style` methods */ -const lvbe_call_c_t lv_style_func[] = { +const be_ntv_func_def_t lv_style_func[] = { { "set_align", (void*) &lv_style_set_align, "", "(lv.lv_style)i" }, { "set_anim_speed", (void*) &lv_style_set_anim_speed, "", "(lv.lv_style)i" }, { "set_anim_time", (void*) &lv_style_set_anim_time, "", "(lv.lv_style)i" }, @@ -103,20 +104,20 @@ const lvbe_call_c_t lv_style_func[] = { }; /* `lv_font` methods */ -const lvbe_call_c_t lv_font_func[] = { +const be_ntv_func_def_t lv_font_func[] = { }; /* `lv_color` methods */ -const lvbe_call_c_t lv_color_func[] = { +const be_ntv_func_def_t lv_color_func[] = { }; /* `lv_theme` methods */ -const lvbe_call_c_t lv_theme_func[] = { +const be_ntv_func_def_t lv_theme_func[] = { }; /* `lv_img` methods */ #ifdef BE_LV_WIDGET_IMG -const lvbe_call_c_t lv_img_func[] = { +const be_ntv_func_def_t lv_img_func[] = { { "get_angle", (void*) &lv_img_get_angle, "i", "(lv.lv_obj)" }, { "get_antialias", (void*) &lv_img_get_antialias, "b", "(lv.lv_obj)" }, { "get_offset_x", (void*) &lv_img_get_offset_x, "i", "(lv.lv_obj)" }, @@ -136,7 +137,7 @@ const lvbe_call_c_t lv_img_func[] = { #endif // BE_LV_WIDGET_IMG /* `lv_disp` methods */ -const lvbe_call_c_t lv_disp_func[] = { +const be_ntv_func_def_t lv_disp_func[] = { { "clean_dcache", (void*) &lv_disp_clean_dcache, "", "(lv.lv_disp)" }, { "dpx", (void*) &lv_disp_dpx, "i", "(lv.lv_disp)i" }, { "get_inactive_time", (void*) &lv_disp_get_inactive_time, "i", "(lv.lv_disp)" }, @@ -154,7 +155,7 @@ const lvbe_call_c_t lv_disp_func[] = { }; /* `lv_obj` methods */ -const lvbe_call_c_t lv_obj_func[] = { +const be_ntv_func_def_t lv_obj_func[] = { { "add_event_cb", (void*) &lv_obj_add_event_cb, "i", "(lv.lv_obj)^lv_event_cb^i." }, { "add_flag", (void*) &lv_obj_add_flag, "", "(lv.lv_obj)i" }, { "add_state", (void*) &lv_obj_add_state, "", "(lv.lv_obj)i" }, @@ -458,7 +459,7 @@ const lvbe_call_c_t lv_obj_func[] = { }; /* `lv_group` methods */ -const lvbe_call_c_t lv_group_func[] = { +const be_ntv_func_def_t lv_group_func[] = { { "add_obj", (void*) &lv_group_add_obj, "", "(lv.lv_group)(lv.lv_obj)" }, { "del", (void*) &lv_group_del, "", "(lv.lv_group)" }, { "focus_freeze", (void*) &lv_group_focus_freeze, "", "(lv.lv_group)b" }, @@ -481,7 +482,7 @@ const lvbe_call_c_t lv_group_func[] = { }; /* `lv_indev` methods */ -const lvbe_call_c_t lv_indev_func[] = { +const be_ntv_func_def_t lv_indev_func[] = { { "enable", (void*) &lv_indev_enable, "", "(lv.lv_indev)b" }, { "get_gesture_dir", (void*) &lv_indev_get_gesture_dir, "i", "(lv.lv_indev)" }, { "get_key", (void*) &lv_indev_get_key, "i", "(lv.lv_indev)" }, @@ -501,7 +502,7 @@ const lvbe_call_c_t lv_indev_func[] = { /* `lv_chart` methods */ #ifdef BE_LV_WIDGET_CHART -const lvbe_call_c_t lv_chart_func[] = { +const be_ntv_func_def_t lv_chart_func[] = { { "get_cursor_point", (void*) &lv_chart_get_cursor_point, "i", "(lv.lv_obj)(lv.lv_chart_cursor)" }, { "get_point_count", (void*) &lv_chart_get_point_count, "i", "(lv.lv_obj)" }, { "get_point_pos_by_id", (void*) &lv_chart_get_point_pos_by_id, "", "(lv.lv_obj)(lv.lv_chart_series)i(lv.lv_point)" }, @@ -537,7 +538,7 @@ const lvbe_call_c_t lv_chart_func[] = { /* `lv_colorwheel` methods */ #ifdef BE_LV_WIDGET_COLORWHEEL -const lvbe_call_c_t lv_colorwheel_func[] = { +const be_ntv_func_def_t lv_colorwheel_func[] = { { "get_color_mode", (void*) &lv_colorwheel_get_color_mode, "i", "(lv.lv_obj)" }, { "get_color_mode_fixed", (void*) &lv_colorwheel_get_color_mode_fixed, "b", "(lv.lv_obj)" }, { "get_hsv", (void*) &lv_colorwheel_get_hsv, "i", "(lv.lv_obj)" }, @@ -551,14 +552,14 @@ const lvbe_call_c_t lv_colorwheel_func[] = { /* `lv_imgbtn` methods */ #ifdef BE_LV_WIDGET_IMGBTN -const lvbe_call_c_t lv_imgbtn_func[] = { +const be_ntv_func_def_t lv_imgbtn_func[] = { { "set_src", (void*) &lv_imgbtn_set_src, "", "(lv.lv_obj)(lv.lv_imgbtn_state)..." }, }; #endif // BE_LV_WIDGET_IMGBTN /* `lv_led` methods */ #ifdef BE_LV_WIDGET_LED -const lvbe_call_c_t lv_led_func[] = { +const be_ntv_func_def_t lv_led_func[] = { { "get_brightness", (void*) &lv_led_get_brightness, "i", "(lv.lv_obj)" }, { "off", (void*) &lv_led_off, "", "(lv.lv_obj)" }, { "on", (void*) &lv_led_on, "", "(lv.lv_obj)" }, @@ -570,7 +571,7 @@ const lvbe_call_c_t lv_led_func[] = { /* `lv_meter` methods */ #ifdef BE_LV_WIDGET_METER -const lvbe_call_c_t lv_meter_func[] = { +const be_ntv_func_def_t lv_meter_func[] = { { "add_arc", (void*) &lv_meter_add_arc, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale)i(lv.lv_color)i" }, { "add_needle_img", (void*) &lv_meter_add_needle_img, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale).ii" }, { "add_needle_line", (void*) &lv_meter_add_needle_line, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale)i(lv.lv_color)i" }, @@ -587,7 +588,7 @@ const lvbe_call_c_t lv_meter_func[] = { /* `lv_msgbox` methods */ #ifdef BE_LV_WIDGET_MSGBOX -const lvbe_call_c_t lv_msgbox_func[] = { +const be_ntv_func_def_t lv_msgbox_func[] = { { "close", (void*) &lv_msgbox_close, "", "(lv.lv_obj)" }, { "get_active_btn_text", (void*) &lv_msgbox_get_active_btn_text, "s", "(lv.lv_obj)" }, { "get_btns", (void*) &lv_msgbox_get_btns, "lv.lv_obj", "(lv.lv_obj)" }, @@ -599,7 +600,7 @@ const lvbe_call_c_t lv_msgbox_func[] = { /* `lv_spinbox` methods */ #ifdef BE_LV_WIDGET_SPINBOX -const lvbe_call_c_t lv_spinbox_func[] = { +const be_ntv_func_def_t lv_spinbox_func[] = { { "decrement", (void*) &lv_spinbox_decrement, "", "(lv.lv_obj)" }, { "get_rollover", (void*) &lv_spinbox_get_rollover, "b", "(lv.lv_obj)" }, { "get_step", (void*) &lv_spinbox_get_step, "i", "(lv.lv_obj)" }, @@ -617,13 +618,13 @@ const lvbe_call_c_t lv_spinbox_func[] = { /* `lv_spinner` methods */ #ifdef BE_LV_WIDGET_SPINNER -const lvbe_call_c_t lv_spinner_func[] = { +const be_ntv_func_def_t lv_spinner_func[] = { }; #endif // BE_LV_WIDGET_SPINNER /* `lv_arc` methods */ #ifdef BE_LV_WIDGET_ARC -const lvbe_call_c_t lv_arc_func[] = { +const be_ntv_func_def_t lv_arc_func[] = { { "get_angle_end", (void*) &lv_arc_get_angle_end, "i", "(lv.lv_obj)" }, { "get_angle_start", (void*) &lv_arc_get_angle_start, "i", "(lv.lv_obj)" }, { "get_bg_angle_end", (void*) &lv_arc_get_bg_angle_end, "i", "(lv.lv_obj)" }, @@ -648,7 +649,7 @@ const lvbe_call_c_t lv_arc_func[] = { /* `lv_bar` methods */ #ifdef BE_LV_WIDGET_BAR -const lvbe_call_c_t lv_bar_func[] = { +const be_ntv_func_def_t lv_bar_func[] = { { "get_max_value", (void*) &lv_bar_get_max_value, "i", "(lv.lv_obj)" }, { "get_min_value", (void*) &lv_bar_get_min_value, "i", "(lv.lv_obj)" }, { "get_mode", (void*) &lv_bar_get_mode, "i", "(lv.lv_obj)" }, @@ -663,13 +664,13 @@ const lvbe_call_c_t lv_bar_func[] = { /* `lv_btn` methods */ #ifdef BE_LV_WIDGET_BTN -const lvbe_call_c_t lv_btn_func[] = { +const be_ntv_func_def_t lv_btn_func[] = { }; #endif // BE_LV_WIDGET_BTN /* `lv_btnmatrix` methods */ #ifdef BE_LV_WIDGET_BTNMATRIX -const lvbe_call_c_t lv_btnmatrix_func[] = { +const be_ntv_func_def_t lv_btnmatrix_func[] = { { "clear_btn_ctrl", (void*) &lv_btnmatrix_clear_btn_ctrl, "", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" }, { "clear_btn_ctrl_all", (void*) &lv_btnmatrix_clear_btn_ctrl_all, "", "(lv.lv_obj)(lv.lv_btnmatrix_ctrl)" }, { "get_btn_text", (void*) &lv_btnmatrix_get_btn_text, "s", "(lv.lv_obj)i" }, @@ -688,7 +689,7 @@ const lvbe_call_c_t lv_btnmatrix_func[] = { /* `lv_canvas` methods */ #ifdef BE_LV_WIDGET_CANVAS -const lvbe_call_c_t lv_canvas_func[] = { +const be_ntv_func_def_t lv_canvas_func[] = { { "blur_hor", (void*) &lv_canvas_blur_hor, "", "(lv.lv_obj)(lv.lv_area)i" }, { "blur_ver", (void*) &lv_canvas_blur_ver, "", "(lv.lv_obj)(lv.lv_area)i" }, { "copy_buf", (void*) &lv_canvas_copy_buf, "", "(lv.lv_obj).iiii" }, @@ -709,7 +710,7 @@ const lvbe_call_c_t lv_canvas_func[] = { /* `lv_checkbox` methods */ #ifdef BE_LV_WIDGET_CHECKBOX -const lvbe_call_c_t lv_checkbox_func[] = { +const be_ntv_func_def_t lv_checkbox_func[] = { { "get_text", (void*) &lv_checkbox_get_text, "s", "(lv.lv_obj)" }, { "set_text", (void*) &lv_checkbox_set_text, "", "(lv.lv_obj)s" }, { "set_text_static", (void*) &lv_checkbox_set_text_static, "", "(lv.lv_obj)s" }, @@ -718,7 +719,7 @@ const lvbe_call_c_t lv_checkbox_func[] = { /* `lv_dropdown` methods */ #ifdef BE_LV_WIDGET_DROPDOWN -const lvbe_call_c_t lv_dropdown_func[] = { +const be_ntv_func_def_t lv_dropdown_func[] = { { "add_option", (void*) &lv_dropdown_add_option, "", "(lv.lv_obj)si" }, { "clear_options", (void*) &lv_dropdown_clear_options, "", "(lv.lv_obj)" }, { "close", (void*) &lv_dropdown_close, "", "(lv.lv_obj)" }, @@ -744,7 +745,7 @@ const lvbe_call_c_t lv_dropdown_func[] = { /* `lv_label` methods */ #ifdef BE_LV_WIDGET_LABEL -const lvbe_call_c_t lv_label_func[] = { +const be_ntv_func_def_t lv_label_func[] = { { "cut_text", (void*) &lv_label_cut_text, "", "(lv.lv_obj)ii" }, { "get_letter_on", (void*) &lv_label_get_letter_on, "i", "(lv.lv_obj)(lv.lv_point)" }, { "get_letter_pos", (void*) &lv_label_get_letter_pos, "", "(lv.lv_obj)i(lv.lv_point)" }, @@ -767,7 +768,7 @@ const lvbe_call_c_t lv_label_func[] = { /* `lv_line` methods */ #ifdef BE_LV_WIDGET_LINE -const lvbe_call_c_t lv_line_func[] = { +const be_ntv_func_def_t lv_line_func[] = { { "get_y_invert", (void*) &lv_line_get_y_invert, "b", "(lv.lv_obj)" }, { "set_points", (void*) &lv_line_set_points, "", "(lv.lv_obj)ii" }, { "set_y_invert", (void*) &lv_line_set_y_invert, "", "(lv.lv_obj)b" }, @@ -776,7 +777,7 @@ const lvbe_call_c_t lv_line_func[] = { /* `lv_roller` methods */ #ifdef BE_LV_WIDGET_ROLLER -const lvbe_call_c_t lv_roller_func[] = { +const be_ntv_func_def_t lv_roller_func[] = { { "get_option_cnt", (void*) &lv_roller_get_option_cnt, "i", "(lv.lv_obj)" }, { "get_options", (void*) &lv_roller_get_options, "s", "(lv.lv_obj)" }, { "get_selected", (void*) &lv_roller_get_selected, "i", "(lv.lv_obj)" }, @@ -789,7 +790,7 @@ const lvbe_call_c_t lv_roller_func[] = { /* `lv_slider` methods */ #ifdef BE_LV_WIDGET_SLIDER -const lvbe_call_c_t lv_slider_func[] = { +const be_ntv_func_def_t lv_slider_func[] = { { "get_left_value", (void*) &lv_slider_get_left_value, "i", "(lv.lv_obj)" }, { "get_max_value", (void*) &lv_slider_get_max_value, "i", "(lv.lv_obj)" }, { "get_min_value", (void*) &lv_slider_get_min_value, "i", "(lv.lv_obj)" }, @@ -805,13 +806,13 @@ const lvbe_call_c_t lv_slider_func[] = { /* `lv_switch` methods */ #ifdef BE_LV_WIDGET_SWITCH -const lvbe_call_c_t lv_switch_func[] = { +const be_ntv_func_def_t lv_switch_func[] = { }; #endif // BE_LV_WIDGET_SWITCH /* `lv_table` methods */ #ifdef BE_LV_WIDGET_TABLE -const lvbe_call_c_t lv_table_func[] = { +const be_ntv_func_def_t lv_table_func[] = { { "add_cell_ctrl", (void*) &lv_table_add_cell_ctrl, "", "(lv.lv_obj)ii(lv.lv_table_cell_ctrl)" }, { "clear_cell_ctrl", (void*) &lv_table_clear_cell_ctrl, "", "(lv.lv_obj)ii(lv.lv_table_cell_ctrl)" }, { "get_cell_value", (void*) &lv_table_get_cell_value, "s", "(lv.lv_obj)ii" }, @@ -830,7 +831,7 @@ const lvbe_call_c_t lv_table_func[] = { /* `lv_textarea` methods */ #ifdef BE_LV_WIDGET_TEXTAREA -const lvbe_call_c_t lv_textarea_func[] = { +const be_ntv_func_def_t lv_textarea_func[] = { { "add_char", (void*) &lv_textarea_add_char, "", "(lv.lv_obj)i" }, { "add_text", (void*) &lv_textarea_add_text, "", "(lv.lv_obj)s" }, { "clear_selection", (void*) &lv_textarea_clear_selection, "", "(lv.lv_obj)" }, @@ -901,7 +902,7 @@ extern const bclass be_class_lv_theme; // map of clases -const lvbe_call_c_classes_t lv_classes[] = { +const be_ntv_class_def_t lv_classes[] = { #ifdef BE_LV_WIDGET_ARC { "lv_arc", &be_class_lv_arc, lv_arc_func, sizeof(lv_arc_func) / sizeof(lv_arc_func[0]) }, #endif // BE_LV_WIDGET_ARC @@ -988,106 +989,106 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]); /* `lv_theme` methods */ /* `lv_img` methods */ #ifdef BE_LV_WIDGET_IMG - int be_ntv_lv_img_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_img_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_img_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_img_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_IMG /* `lv_disp` methods */ /* `lv_obj` methods */ - int be_ntv_lv_obj_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_obj_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_obj_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_obj_create, "+_p", "(lv.lv_obj)"); } /* `lv_group` methods */ - int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+", ""); } + int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+_p", ""); } /* `lv_indev` methods */ /* `lv_chart` methods */ #ifdef BE_LV_WIDGET_CHART - int be_ntv_lv_chart_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_chart_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_chart_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_chart_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_CHART /* `lv_colorwheel` methods */ #ifdef BE_LV_WIDGET_COLORWHEEL - int be_ntv_lv_colorwheel_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_colorwheel_create, "+", "(lv.lv_obj)b"); } + int be_ntv_lv_colorwheel_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_colorwheel_create, "+_p", "(lv.lv_obj)b"); } #endif // BE_LV_WIDGET_COLORWHEEL /* `lv_imgbtn` methods */ #ifdef BE_LV_WIDGET_IMGBTN - int be_ntv_lv_imgbtn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_imgbtn_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_imgbtn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_imgbtn_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_IMGBTN /* `lv_led` methods */ #ifdef BE_LV_WIDGET_LED - int be_ntv_lv_led_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_led_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_led_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_led_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_LED /* `lv_meter` methods */ #ifdef BE_LV_WIDGET_METER - int be_ntv_lv_meter_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_meter_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_meter_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_meter_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_METER /* `lv_msgbox` methods */ #ifdef BE_LV_WIDGET_MSGBOX - int be_ntv_lv_msgbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_msgbox_create, "+", "(lv.lv_obj)sssb"); } + int be_ntv_lv_msgbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_msgbox_create, "+_p", "(lv.lv_obj)sssb"); } #endif // BE_LV_WIDGET_MSGBOX /* `lv_spinbox` methods */ #ifdef BE_LV_WIDGET_SPINBOX - int be_ntv_lv_spinbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinbox_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_spinbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinbox_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_SPINBOX /* `lv_spinner` methods */ #ifdef BE_LV_WIDGET_SPINNER - int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+", "(lv.lv_obj)ii"); } + int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+_p", "(lv.lv_obj)ii"); } #endif // BE_LV_WIDGET_SPINNER /* `lv_arc` methods */ #ifdef BE_LV_WIDGET_ARC - int be_ntv_lv_arc_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_arc_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_arc_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_arc_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_ARC /* `lv_bar` methods */ #ifdef BE_LV_WIDGET_BAR - int be_ntv_lv_bar_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_bar_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_bar_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_bar_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_BAR /* `lv_btn` methods */ #ifdef BE_LV_WIDGET_BTN - int be_ntv_lv_btn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btn_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_btn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btn_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_BTN /* `lv_btnmatrix` methods */ #ifdef BE_LV_WIDGET_BTNMATRIX - int be_ntv_lv_btnmatrix_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btnmatrix_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_btnmatrix_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btnmatrix_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_BTNMATRIX /* `lv_canvas` methods */ #ifdef BE_LV_WIDGET_CANVAS - int be_ntv_lv_canvas_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_canvas_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_canvas_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_canvas_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_CANVAS /* `lv_checkbox` methods */ #ifdef BE_LV_WIDGET_CHECKBOX - int be_ntv_lv_checkbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_checkbox_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_checkbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_checkbox_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_CHECKBOX /* `lv_dropdown` methods */ #ifdef BE_LV_WIDGET_DROPDOWN - int be_ntv_lv_dropdown_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_dropdown_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_dropdown_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_dropdown_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_DROPDOWN /* `lv_label` methods */ #ifdef BE_LV_WIDGET_LABEL - int be_ntv_lv_label_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_label_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_label_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_label_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_LABEL /* `lv_line` methods */ #ifdef BE_LV_WIDGET_LINE - int be_ntv_lv_line_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_line_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_line_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_line_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_LINE /* `lv_roller` methods */ #ifdef BE_LV_WIDGET_ROLLER - int be_ntv_lv_roller_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_roller_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_roller_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_roller_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_ROLLER /* `lv_slider` methods */ #ifdef BE_LV_WIDGET_SLIDER - int be_ntv_lv_slider_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_slider_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_slider_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_slider_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_SLIDER /* `lv_switch` methods */ #ifdef BE_LV_WIDGET_SWITCH - int be_ntv_lv_switch_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_switch_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_switch_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_switch_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_SWITCH /* `lv_table` methods */ #ifdef BE_LV_WIDGET_TABLE - int be_ntv_lv_table_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_table_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_table_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_table_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_TABLE /* `lv_textarea` methods */ #ifdef BE_LV_WIDGET_TEXTAREA - int be_ntv_lv_textarea_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_textarea_create, "+", "(lv.lv_obj)"); } + int be_ntv_lv_textarea_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_textarea_create, "+_p", "(lv.lv_obj)"); } #endif // BE_LV_WIDGET_TEXTAREA // create font either empty or from parameter on stack -int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_font", ""); } -int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_theme", ""); } +int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); } +int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); } #ifdef __cplusplus diff --git a/tasmota/xdrv_52_1_berry_native.ino b/tasmota/xdrv_52_1_berry_native.ino index 2bf1f152e..4481320d7 100644 --- a/tasmota/xdrv_52_1_berry_native.ino +++ b/tasmota/xdrv_52_1_berry_native.ino @@ -26,19 +26,6 @@ const char kTypeError[] PROGMEM = "type_error"; const char kInternalError[] PROGMEM = "intenal_error"; -extern "C" { - - /*********************************************************************************************\ - * Support for Berry int constants - * as virtual members - \*********************************************************************************************/ - typedef struct be_constint_t { - const char * name; - int32_t value; - } be_constint_t; - -} - /*********************************************************************************************\ * LVGL top level virtual members * @@ -76,65 +63,6 @@ extern "C" { return v; } - // variant of be_raise with string format - [[ noreturn ]] void be_raisef(bvm *vm, const char *except, const char *msg, ...) { - // To save stack space support logging for max text length of 128 characters - char log_data[128]; - - va_list arg; - va_start(arg, msg); - uint32_t len = ext_vsnprintf_P(log_data, sizeof(log_data)-3, msg, arg); - va_end(arg); - if (len+3 > sizeof(log_data)) { strcat(log_data, "..."); } // Actual data is more - be_raise(vm, except, log_data); - } - - static void map_insert_int(bvm *vm, const char *key, int value) - { - be_pushstring(vm, key); - be_pushint(vm, value); - be_data_insert(vm, -3); - be_pop(vm, 2); - } - static void map_insert_bool(bvm *vm, const char *key, bool value) - { - be_pushstring(vm, key); - be_pushbool(vm, value); - be_data_insert(vm, -3); - be_pop(vm, 2); - } - // if value == NAN, ignore - static void map_insert_float(bvm *vm, const char *key, float value) - { - if (!isnan(value)) { - be_pushstring(vm, key); - be_pushreal(vm, value); - be_data_insert(vm, -3); - be_pop(vm, 2); - } - } - static void map_insert_str(bvm *vm, const char *key, const char *value) - { - be_pushstring(vm, key); - be_pushstring(vm, value); - be_data_insert(vm, -3); - be_pop(vm, 2); - } - static void map_insert_list_uint8(bvm *vm, const char *key, const uint8_t *value, size_t size) - { - be_pushstring(vm, key); - - be_newobject(vm, "list"); - for (uint32_t i=0; i < size; i++) { - be_pushint(vm, value[i]); - be_data_push(vm, -2); - be_pop(vm, 1); - } - be_pop(vm, 1); // now list is on top - - be_data_insert(vm, -3); // insert into map, key/value - be_pop(vm, 2); // pop both key and value - } int32_t member_find(bvm *vm, const char *key, int32_t default_value) { int32_t ret = default_value; if (be_getmember(vm, -1, key)) { @@ -171,283 +99,6 @@ extern "C" { be_call(vm, 2); // call wirn 2 parameters (implicit instance and key) be_pop(vm, 2); // pop 2 arguments and return value } - - // create an object from the pointer and a class name - // on return, instance is pushed on the stack - void lv_create_object(bvm *vm, const char * class_name, void * ptr); - void lv_create_object(bvm *vm, const char * class_name, void * ptr) { - if (ptr == nullptr) { - be_throw(vm, BE_MALLOC_FAIL); - } - - be_getglobal(vm, class_name); // stack = class - be_call(vm, 0); // instanciate, stack = instance - be_getmember(vm, -1, "init"); // stack = instance, init_func - be_pushvalue(vm, -2); // stack = instance, init_func, instance - be_pushcomptr(vm, ptr); // stack = instance, init_func, instance, ptr - be_call(vm, 2); // stack = instance, ret, instance, ptr - be_pop(vm, 3); // stack = instance - } - - extern void berry_log_C(const char * berry_buf, ...); - // Create a class given a global name or a name within a module - // Case 1: (no dot in name) `lv_wifi_bars` will look for a global variable `lv_wifi_bars` - // Case 2: (dot in name) `lvgl.lv_obj` will import `lvgl` and look for `lv_obj` within this module - // returns true if successful and result is top of stack, or false if not found and `nil` is at top of stack - bbool be_find_class(bvm *vm, const char * cl_name); - bbool be_find_class(bvm *vm, const char * cl_name) { - char *saveptr; - bbool ret = false; - - if (cl_name == NULL) { - be_pushnil(vm); - return ret; - } - // berry_log_C(">> be_find_class %s", cl_name); - char cl_name_buf[strlen(cl_name)+1]; - strcpy(cl_name_buf, cl_name); - - char * prefix = strtok_r(cl_name_buf, ".", &saveptr); - char * suffix = strtok_r(NULL, ".", &saveptr); - if (suffix) { - // berry_log_C(">> be_find_class %s - %s", prefix, suffix); - be_getmodule(vm, prefix); - ret = be_getmember(vm, -1, suffix); - // berry_log_C(">> be_find_class ret=%i", ret); - be_remove(vm, -2); - } else { - ret = be_getglobal(vm, prefix); - } - return ret; - } -} - -/*********************************************************************************************\ - * Binary search for dynamic attributes - * - * Names need to be sorted -\*********************************************************************************************/ -// binary search within an array of sorted strings -// the first 4 bytes are a pointer to a string -// returns 0..total_elements-1 or -1 if not found -// -// This version skips the first character of the string if it's not a letter, -// the first character is used to indicate the type of the value associated to the key -extern "C" { - int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements); - int32_t bin_search(const char * needle, const void * table, size_t elt_size, size_t total_elements) { - int32_t low = 0; - int32_t high = total_elements - 1; - int32_t mid = (low + high) / 2; - // start a dissect - while (low <= high) { - const char * elt = *(const char **) ( ((uint8_t*)table) + mid * elt_size ); - char first_char = elt[0]; - if ( !(first_char >= 'a' && first_char <='z') && !(first_char >= 'A' && first_char <='Z') ) { - elt++; // skip first char - } - int32_t comp = strcmp(needle, elt); - if (comp < 0) { - high = mid - 1; - } else if (comp > 0) { - low = mid + 1; - } else { - break; - } - mid = (low + high) / 2; - } - if (low <= high) { - return mid; - } else { - return -1; - } - } -} - -/*********************************************************************************************\ - * Generalized callbacks - * - * Warning, the following expect all parameters to be 32 bits wide -\*********************************************************************************************/ - -/*********************************************************************************************\ - * Automatically parse Berry stack and call the C function accordingly - * - * This function takes the n incoming arguments and pushes them as arguments - * on the stack for the C function: - * - be_int -> int32_t - * - be_bool -> int32_t with value 0/1 - * - be_string -> const char * - * - be_instance -> gets the member "_p" and pushes as void* - * - * This works because C silently ignores any unwanted arguments. - * There is a strong requirements that all ints and pointers are 32 bits. - * Float is not supported but could be added. Double cannot be supported because they are 64 bits - * - * Optional argument: - * - return_type: the C function return value is int32_t and is converted to the - * relevant Berry object depending on this char: - * '' (default): nil, no value - * 'i' be_int - * 'b' be_bool - * 's' be_str - * - * - arg_type: optionally check the types of input arguments, or throw an error - * string of argument types, '+' marks optional arguments - * '.' don't care - * 'i' be_int - * 'b' be_bool - * 's' be_string - * 'c' C callback - * 'lv_obj' be_instance of type or subtype - * '^lv_event_cb' callback of a named class - will call `_lvgl.gen_cb(arg_type, closure, self, lv native pointer)` and expects a callback address in return - * - * Ex: "oii+s" takes 3 mandatory arguments (obj_instance, int, int) and an optional fourth one [,string] -\*********************************************************************************************/ -// general form of lv_obj_t* function, up to 4 parameters -// We can only send 32 bits arguments (no 64 bits nor double) and we expect pointers to be 32 bits - -#define LVBE_LVGL_GLOB "_lvgl" -#define LVBE_LVGL_CB_GEN "gen_cb" - -// read a single value at stack position idx, convert to int. -// if object instance, get `_p` member and convert it recursively -int32_t be_convert_single_elt(bvm *vm, int32_t idx, const char * arg_type = nullptr, void * lv_obj_cb = nullptr) { - int32_t ret = 0; - char provided_type = 0; - idx = be_absindex(vm, idx); // make sure we have an absolute index - - // berry_log_C(">> 0 idx=%i arg_type=%s", idx, arg_type ? arg_type : "NULL"); - if (arg_type == nullptr) { arg_type = "."; } // if no type provided, replace with wildchar - size_t arg_type_len = strlen(arg_type); - - // handle callbacks first, since a wrong parameter will always yield to a crash - if (arg_type_len > 1 && arg_type[0] == '^') { // it is a callback - arg_type++; // skip first character - if (be_isclosure(vm, idx)) { - be_getglobal(vm, LVBE_LVGL_GLOB); - be_getmethod(vm, -1, LVBE_LVGL_CB_GEN); - be_pushvalue(vm, -2); - be_remove(vm, -3); // stack contains method + instance - be_pushstring(vm, arg_type); - be_pushvalue(vm, idx); - be_pushvalue(vm, 1); - be_pushcomptr(vm, lv_obj_cb); - be_call(vm, 5); - const void * func = be_tocomptr(vm, -6); - be_pop(vm, 6); - - // berry_log_C("func=%p", func); - return (int32_t) func; - } else { - be_raise(vm, kTypeError, "Closure expected for callback type"); - } - } - - // first convert the value to int32 - if (be_isint(vm, idx)) { ret = be_toint(vm, idx); provided_type = 'i'; } - else if (be_isbool(vm, idx)) { ret = be_tobool(vm, idx); provided_type = 'b'; } - else if (be_isstring(vm, idx)) { ret = (int32_t) be_tostring(vm, idx); provided_type = 's'; } - else if (be_iscomptr(vm, idx)) { ret = (int32_t) be_tocomptr(vm, idx); provided_type = 'c'; } - - // check if simple type was a match - if (provided_type) { - bool type_ok = false; - type_ok = (arg_type[0] == '.'); // any type is accepted - type_ok = type_ok || (arg_type[0] == provided_type); // or type is a match - type_ok = type_ok || (ret == 0 && arg_type_len != 1); // or NULL is accepted for an instance - - if (!type_ok) { - berry_log_C("Unexpected argument type '%c', expected '%s'", provided_type, arg_type); - } - return ret; - } - - // non-simple type - if (be_isinstance(vm, idx)) { - // check if the instance is a subclass of `bytes()`` - be_getbuiltin(vm, "bytes"); // add "list" class - if (be_isderived(vm, idx)) { - be_pop(vm, 1); - be_getmember(vm, idx, "_buffer"); - be_pushvalue(vm, idx); - be_call(vm, 1); - int32_t ret = (int32_t) be_tocomptr(vm, -2); - be_pop(vm, 2); - return ret; - } else { - be_pop(vm, 1); - be_getmember(vm, idx, "_p"); - int32_t ret = be_convert_single_elt(vm, -1, nullptr); // recurse - be_pop(vm, 1); - - if (arg_type_len > 1) { - // Check type - be_classof(vm, idx); - bool class_found = be_find_class(vm, arg_type); - // Stack: class_of_idx, class_of_target (or nil) - if (class_found) { - if (!be_isderived(vm, -2)) { - berry_log_C("Unexpected class type '%s', expected '%s'", be_classname(vm, idx), arg_type); - } - } else { - berry_log_C("Unable to find class '%s' (%d)", arg_type, arg_type_len); - } - be_pop(vm, 2); - } else if (arg_type[0] != '.') { - berry_log_C("Unexpected instance type '%s', expected '%s'", be_classname(vm, idx), arg_type); - } - - return ret; - } - } else { - be_raise(vm, kTypeError, nullptr); - } - - return ret; -} - -extern "C" { - - /*********************************************************************************************\ - * Generalized virtual members for modules - * - * Takes a pointer to be_constint_t array and size - * Returns true if a match was found. In such case the result is on Berry stack - * - * Encoding depend on prefix (which is skipped when matching names): - * 1. `COLOR_WHITE` int value - * 3. `$SYMBOL_OK"` string pointer - * 4. `&seg7_font` comptr - \*********************************************************************************************/ - bool be_module_member(bvm *vm, const be_constint_t * definitions, size_t def_len); - bool be_module_member(bvm *vm, const be_constint_t * definitions, size_t def_len) { - int32_t argc = be_top(vm); // Get the number of arguments - if (argc == 1 && be_isstring(vm, 1)) { - const char * needle = be_tostring(vm, 1); - int32_t idx; - - idx = bin_search(needle, &definitions[0].name, sizeof(definitions[0]), def_len); - if (idx >= 0) { - // we did have a match - const char * key = definitions[idx].name; - switch (key[0]) { - // switch depending on the first char of the key, indicating the type - case '$': // string - be_pushstring(vm, (const char*) definitions[idx].value); - break; - case '&': // native function - be_pushntvfunction(vm, (bntvfunc) definitions[idx].value); - break; - default: // int - be_pushint(vm, definitions[idx].value); - break; - } - return true; - } - } - return false; - } } /*********************************************************************************************\ @@ -459,7 +110,6 @@ void BrTimeoutStart(void) { if (0 == berry.timeout) { berry.timeout = 1; // rare case when value accidentally computes to zero } - } void BrTimeoutYield(void) { diff --git a/tasmota/xdrv_52_3_berry_gpio.ino b/tasmota/xdrv_52_3_berry_gpio.ino index f694b6444..63f29c258 100644 --- a/tasmota/xdrv_52_3_berry_gpio.ino +++ b/tasmota/xdrv_52_3_berry_gpio.ino @@ -39,7 +39,7 @@ extern "C" { // virtual member int gp_member(bvm *vm); int gp_member(bvm *vm) { - if (be_module_member(vm, lv_gpio_constants, lv_gpio_constants_size)) { + if (be_const_member(vm, lv_gpio_constants, lv_gpio_constants_size)) { be_return(vm); } else { be_return_nil(vm); diff --git a/tasmota/xdrv_52_3_berry_light.ino b/tasmota/xdrv_52_3_berry_light.ino index 19aa3cfb6..89ba735e3 100644 --- a/tasmota/xdrv_52_3_berry_light.ino +++ b/tasmota/xdrv_52_3_berry_light.ino @@ -50,11 +50,11 @@ extern "C" { light_controller.calcLevels(channels); uint8_t bri = light_state.getBri(); - // map_insert_int(vm, "_devices_present", TasmotaGlobal.devices_present); - // map_insert_int(vm, "_light_device", Light.device); - // map_insert_int(vm, "_light_subtype", Light.subtype); - // map_insert_int(vm, "_light_multi", Light.pwm_multi_channels); - // map_insert_int(vm, "_light_linked", light_controller.isCTRGBLinked()); + // be_map_insert_int(vm, "_devices_present", TasmotaGlobal.devices_present); + // be_map_insert_int(vm, "_light_device", Light.device); + // be_map_insert_int(vm, "_light_subtype", Light.subtype); + // be_map_insert_int(vm, "_light_multi", Light.pwm_multi_channels); + // be_map_insert_int(vm, "_light_linked", light_controller.isCTRGBLinked()); if (!Light.pwm_multi_channels) { uint32_t subtype = Light.subtype; // virtual sub-type, for SO37 128 @@ -64,7 +64,7 @@ extern "C" { if (light_controller.isCTRGBLinked() && (light_num == 0)) { data_present = true; // valid combination if (subtype >= LST_RGBW) { - map_insert_str(vm, "colormode", (light_state.getColorMode() & LCM_RGB ? "rgb" : "ct")); + be_map_insert_str(vm, "colormode", (light_state.getColorMode() & LCM_RGB ? "rgb" : "ct")); } } if (!light_controller.isCTRGBLinked()) { @@ -83,33 +83,33 @@ extern "C" { if (data_present) { // see ResponseLightState() - map_insert_bool(vm, "power", bitRead(TasmotaGlobal.power, light_num + Light.device - 1)); - map_insert_int(vm, "bri", bri); + be_map_insert_bool(vm, "power", bitRead(TasmotaGlobal.power, light_num + Light.device - 1)); + be_map_insert_int(vm, "bri", bri); if (subtype >= LST_RGB) { uint16_t hue; uint8_t sat, bri; light_state.getHSB(&hue, &sat, &bri); - map_insert_int(vm, "hue", hue); - map_insert_int(vm, "sat", sat); + be_map_insert_int(vm, "hue", hue); + be_map_insert_int(vm, "sat", sat); } if ((LST_COLDWARM == subtype) || (LST_RGBW <= subtype)) { - map_insert_int(vm, "ct", light_state.getCT()); + be_map_insert_int(vm, "ct", light_state.getCT()); } if (subtype >= LST_RGB) { snprintf(s_rgb, sizeof(s_rgb), PSTR("%02X%02X%02X"), channels[0], channels[1], channels[2]); - map_insert_str(vm, "rgb", s_rgb); + be_map_insert_str(vm, "rgb", s_rgb); } if (subtype > LST_NONE) { - map_insert_list_uint8(vm, "channels", &channels[chanidx], subtype); + be_map_insert_list_uint8(vm, "channels", &channels[chanidx], subtype); } } } else { // Light.pwm_multi_channels if ((light_num >= 0) && (light_num < LST_MAX)) { data_present = true; - map_insert_bool(vm, "power", Light.power & (1 << light_num)); - map_insert_int(vm, "bri", Light.current_color[light_num]); - map_insert_list_uint8(vm, "channels", &channels[light_num], 1); + be_map_insert_bool(vm, "power", Light.power & (1 << light_num)); + be_map_insert_int(vm, "bri", Light.current_color[light_num]); + be_map_insert_list_uint8(vm, "channels", &channels[light_num], 1); } } diff --git a/tasmota/xdrv_52_3_berry_lvgl.ino b/tasmota/xdrv_52_3_berry_lvgl.ino index f0cba617a..f86ed7db7 100644 --- a/tasmota/xdrv_52_3_berry_lvgl.ino +++ b/tasmota/xdrv_52_3_berry_lvgl.ino @@ -23,7 +23,7 @@ #include #include "lvgl.h" -#include "be_lvgl.h" +#include "be_mapping.h" #include "be_ctypes.h" #include "Adafruit_LvGL_Glue.h" @@ -35,6 +35,8 @@ // Berry easy logging extern "C" { extern void berry_log_C(const char * berry_buf, ...); + extern const be_ntv_class_def_t lv_classes[]; + extern const size_t lv_classes_size; } extern Adafruit_LvGL_Glue * glue; @@ -99,80 +101,6 @@ LVBE_globals lvbe; extern void start_lvgl(const char * uconfig); extern void lv_ex_get_started_1(void); -/*********************************************************************************************\ - * Calling any LVGL function with auto-mapping - * -\*********************************************************************************************/ - -// check input parameters, and create callbacks if needed -// change values in place -// -// Format: -// - either a lowercase character encoding for a simple type -// - 'b': bool -// - 'i': int (int32_t) -// - 's': string (const char *) -// -// - a class name surroungded by parenthesis -// - '(lv_button)' -> lv_button class or derived -// - '[lv_event_cb]' -> callback type, still prefixed with '^' to mark that it is cb -// -void be_check_arg_type(bvm *vm, int32_t arg_start, int32_t argc, const char * arg_type, int32_t p[8]); -void be_check_arg_type(bvm *vm, int32_t arg_start, int32_t argc, const char * arg_type, int32_t p[8]) { - bool arg_type_check = (arg_type != nullptr); // is type checking activated - int32_t arg_idx = 0; // position in arg_type string - char type_short_name[32]; - - for (uint32_t i = 0; i < argc; i++) { - type_short_name[0] = 0; // clear string - // extract individual type - if (nullptr != arg_type) { - switch (arg_type[arg_idx]) { - case '.': - case 'a'...'z': - type_short_name[0] = arg_type[arg_idx]; - type_short_name[1] = 0; - arg_idx++; - break; - case '(': - case '^': - { - uint32_t prefix = 0; - if (arg_type[arg_idx] == '^') { - type_short_name[0] = '^'; - type_short_name[1] = 0; - prefix = 1; - } - uint32_t offset = 0; - arg_idx++; - while (arg_type[arg_idx + offset] != ')' && arg_type[arg_idx + offset] != '^' && arg_type[arg_idx + offset] != 0 && offset+prefix+1 < sizeof(type_short_name)) { - type_short_name[offset+prefix] = arg_type[arg_idx + offset]; - type_short_name[offset+prefix+1] = 0; - offset++; - } - if (arg_type[arg_idx + offset] == 0) { - arg_type = nullptr; // no more parameters, stop iterations - } - arg_idx += offset + 1; - } - break; - case 0: - arg_type = nullptr; // stop iterations - break; - } - } - // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func arg %i, type %s", i, arg_type_check ? type_short_name : ""); - p[i] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : nullptr, (void*) p[0]); - } - - // check if we are missing arguments - if (arg_type != nullptr && arg_type[arg_idx] != 0) { - berry_log_C("Missing arguments, remaining type '%s'", &arg_type[arg_idx]); - } -} - -typedef int32_t (*fn_any_callable)(int32_t p0, int32_t p1, int32_t p2, int32_t p3, - int32_t p4, int32_t p5, int32_t p6, int32_t p7); extern "C" { void lv_init_set_member(bvm *vm, int index, void * ptr); @@ -205,15 +133,15 @@ extern "C" { // berry_log_C("lvx_member looking for method '%s' of class '%s'", method_name, class_name); // look for class descriptor - int32_t class_idx = bin_search(class_name, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size); + int32_t class_idx = be_map_bin_search(class_name, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size); if (class_idx >= 0) { - const lvbe_call_c_t * methods_calls = lv_classes[class_idx].func_table; + const be_ntv_func_def_t * methods_calls = lv_classes[class_idx].func_table; size_t methods_size = lv_classes[class_idx].size; - int32_t method_idx = bin_search(method_name, methods_calls, sizeof(lvbe_call_c_t), methods_size); + int32_t method_idx = be_map_bin_search(method_name, methods_calls, sizeof(be_ntv_func_def_t), methods_size); if (method_idx >= 0) { // method found - const lvbe_call_c_t * method = &methods_calls[method_idx]; + const be_ntv_func_def_t * method = &methods_calls[method_idx]; // berry_log_C("lvx_member method found func=%p return_type=%s arg_type=%s", method->func, method->return_type, method->arg_type); // push native closure be_pushntvclosure(vm, &lvx_call_c, 3); // 3 upvals @@ -245,63 +173,6 @@ extern "C" { } be_raise(vm, kTypeError, nullptr); } - - int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type) { - // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func, func=%p, return_type=%s, arg_type=%s", func, return_type ? return_type : "", arg_type ? arg_type : ""); - int32_t p[8] = {0,0,0,0,0,0,0,0}; - int32_t argc = be_top(vm); // Get the number of arguments - - // the following describe the active payload for the C function (start and count) - // this is because the `init()` constructor first arg is not passed to the C function - int32_t arg_start = 1; // start with standard values - int32_t arg_count = argc; - - // check if we call a constructor, in this case we store the return type into the new object - // check if we call a constructor with a comptr as first arg - if (return_type && return_type[0] == '+') { - if (argc > 1 && be_iscomptr(vm, 2)) { - lv_obj_t * obj = (lv_obj_t*) be_tocomptr(vm, 2); - lv_init_set_member(vm, 1, obj); - be_return_nil(vm); - } else { - // we need to discard the first arg - arg_start++; - arg_count--; - } - } - - fn_any_callable f = (fn_any_callable) func; - // AddLog(LOG_LEVEL_INFO, ">> before be_check_arg_type argc=%i - %i", arg_count, arg_start); - be_check_arg_type(vm, arg_start, arg_count, arg_type, p); - // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func(%p) - %p,%p,%p,%p,%p - %s", f, p[0], p[1], p[2], p[3], p[4], return_type ? return_type : "NULL"); - int32_t ret = (*f)(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]); - // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func, ret = %p", ret); - if ((return_type == nullptr) || (strlen(return_type) == 0)) { be_return_nil(vm); } // does not return - else if (return_type[0] == '+') { - lv_obj_t * obj = (lv_obj_t*) ret; - lv_init_set_member(vm, 1, obj); - be_return_nil(vm); - } - else if (strlen(return_type) == 1) { - switch (return_type[0]) { - case '.': // fallback next - case 'i': be_pushint(vm, ret); break; - case 'b': be_pushbool(vm, ret); break; - case 's': be_pushstring(vm, (const char*) ret); break; - case 'c': be_pushint(vm, ret); break; // TODO missing 'c' general callback type - default: be_raise(vm, "internal_error", "Unsupported return type"); break; - } - be_return(vm); - } else { // class name - // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func, create_obj ret=%i return_type=%s", ret, return_type); - be_find_class(vm, return_type); - be_pushcomptr(vm, (void*) ret); // stack = class, ptr - be_pushcomptr(vm, (void*) -1); // stack = class, ptr, -1 - be_call(vm, 2); // instanciate with 2 arguments, stack = instance, -1, ptr - be_pop(vm, 2); // stack = instance - be_return(vm); - } - } } /*********************************************************************************************\ @@ -396,7 +267,7 @@ extern "C" { typedef lv_obj_t* (*fn_lvobj__void)(void); // f() -> newly created lv_obj() int lv0_lvobj__void_call(bvm *vm, fn_lvobj__void func) { lv_obj_t * obj = (*func)(); - be_find_class(vm, "lv.lv_obj"); + be_find_global_or_module_member(vm, "lv.lv_obj"); be_pushcomptr(vm, (void*) -1); // stack = class, -1 be_pushcomptr(vm, (void*) obj); // stack = class, -1, ptr be_call(vm, 2); // instanciate, stack = instance (don't call init() ) @@ -413,7 +284,7 @@ extern "C" { if (argc == 1 && be_isstring(vm, 1)) { lv_font_t * font = lv_font_load(be_tostring(vm, 1)); if (font != nullptr) { - be_find_class(vm, "lv.lv_font"); + be_find_global_or_module_member(vm, "lv.lv_font"); be_pushcomptr(vm, font); be_call(vm, 1); be_pop(vm, 1); @@ -441,7 +312,7 @@ extern "C" { lv_font_t * font = info.font; if (font != nullptr) { - be_find_class(vm, "lv.lv_font"); + be_find_global_or_module_member(vm, "lv.lv_font"); be_pushcomptr(vm, font); be_call(vm, 1); be_pop(vm, 1); @@ -637,7 +508,7 @@ extern "C" { be_raisef(vm, "value_error", "unknown font size '%s-%i'", name, size); } - be_find_class(vm, "lv.lv_font"); + be_find_global_or_module_member(vm, "lv.lv_font"); be_pushcomptr(vm, (void*)font_entry->font); be_call(vm, 1); be_pop(vm, 1); @@ -674,10 +545,10 @@ extern "C" { * Responds to virtual constants \*********************************************************************************************/ - extern const lvbe_call_c_t lv_func[]; + extern const be_ntv_func_def_t lv_func[]; extern const size_t lv_func_size; - extern const be_constint_t lv0_constants[]; + extern const be_const_member_t lv0_constants[]; extern const size_t lv0_constants_size; extern const be_ctypes_class_by_name_t be_ctypes_lvgl_classes[]; @@ -686,7 +557,7 @@ extern "C" { int lv0_member(bvm *vm); int lv0_member(bvm *vm) { // first try the standard way - if (be_module_member(vm, lv0_constants, lv0_constants_size)) { + if (be_const_member(vm, lv0_constants, lv0_constants_size)) { be_return(vm); } // try alternative members @@ -698,9 +569,9 @@ extern "C" { // search for a class with this name char cl_prefixed[32]; snprintf(cl_prefixed, sizeof(cl_prefixed), "lv_%s", needle); // we try both actual name and prefixed with `lv_` so both `lv.obj` and `lv.lv_obj` work - idx = bin_search(cl_prefixed, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size); + idx = be_map_bin_search(cl_prefixed, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size); if (idx < 0) { - idx = bin_search(needle, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size); + idx = be_map_bin_search(needle, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size); } if (idx >= 0) { // we did have a match @@ -708,9 +579,9 @@ extern "C" { be_return(vm); } // same search for ctypes - idx = bin_search(cl_prefixed, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size); + idx = be_map_bin_search(cl_prefixed, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size); if (idx < 0) { - idx = bin_search(needle, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size); + idx = be_map_bin_search(needle, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size); } if (idx >= 0) { // we did have a match @@ -719,9 +590,9 @@ extern "C" { } // search for a method with this name - idx = bin_search(needle, &lv_func[0].name, sizeof(lv_func[0]), lv_func_size); + idx = be_map_bin_search(needle, &lv_func[0].name, sizeof(lv_func[0]), lv_func_size); if (idx >= 0) { - const lvbe_call_c_t * method = &lv_func[idx]; + const be_ntv_func_def_t * method = &lv_func[idx]; // push native closure be_pushntvclosure(vm, &lvx_call_c, 3); // 3 upvals @@ -803,7 +674,7 @@ extern "C" { lv_indev_t * indev = lv_indev_drv_register(&lvbe.indev_drv); lvbe.indev_list.addHead(indev); // keep track of indevs - be_find_class(vm, "lv.lv_indev"); + be_find_global_or_module_member(vm, "lv.lv_indev"); be_pushint(vm, (int32_t) indev); be_call(vm, 1); be_pop(vm, 1); @@ -859,7 +730,7 @@ extern "C" { void * obj = nullptr; int argc = be_top(vm); if (argc > 1) { - obj = (void*) be_convert_single_elt(vm, 2); + obj = (void*) be_convert_single_elt(vm, 2, NULL, NULL); } lv_init_set_member(vm, 1, obj); be_return_nil(vm); @@ -885,7 +756,7 @@ extern "C" { lv_style_t * style = nullptr; if (argc > 1) { - style = (lv_style_t*) be_convert_single_elt(vm, 2); + style = (lv_style_t*) be_convert_single_elt(vm, 2, NULL, NULL); } if (style == nullptr) { style = (lv_style_t*) be_malloc(vm, sizeof(lv_style_t)); diff --git a/tasmota/xdrv_52_3_berry_tasmota.ino b/tasmota/xdrv_52_3_berry_tasmota.ino index a9d0ad734..fdff25f1e 100644 --- a/tasmota/xdrv_52_3_berry_tasmota.ino +++ b/tasmota/xdrv_52_3_berry_tasmota.ino @@ -181,10 +181,10 @@ extern "C" { int32_t top = be_top(vm); // Get the number of arguments if (top == 1) { // no argument (instance only) be_newobject(vm, "map"); - map_insert_int(vm, "utc", Rtc.utc_time); - map_insert_int(vm, "local", Rtc.local_time); - map_insert_int(vm, "restart", Rtc.restart_time); - map_insert_int(vm, "timezone", Rtc.time_timezone); + be_map_insert_int(vm, "utc", Rtc.utc_time); + be_map_insert_int(vm, "local", Rtc.local_time); + be_map_insert_int(vm, "restart", Rtc.restart_time); + be_map_insert_int(vm, "timezone", Rtc.time_timezone); be_pop(vm, 1); be_return(vm); } @@ -198,14 +198,14 @@ extern "C" { int32_t top = be_top(vm); // Get the number of arguments if (top == 1) { // no argument (instance only) be_newobject(vm, "map"); - map_insert_int(vm, "flash", ESP.getFlashChipSize() / 1024); - map_insert_int(vm, "program", ESP_getSketchSize() / 1024); - map_insert_int(vm, "program_free", ESP.getFreeSketchSpace() / 1024); - map_insert_int(vm, "heap_free", ESP_getFreeHeap() / 1024); - map_insert_int(vm, "frag", ESP_getHeapFragmentation()); + be_map_insert_int(vm, "flash", ESP.getFlashChipSize() / 1024); + be_map_insert_int(vm, "program", ESP_getSketchSize() / 1024); + be_map_insert_int(vm, "program_free", ESP.getFreeSketchSpace() / 1024); + be_map_insert_int(vm, "heap_free", ESP_getFreeHeap() / 1024); + be_map_insert_int(vm, "frag", ESP_getHeapFragmentation()); if (UsePSRAM()) { - map_insert_int(vm, "psram", ESP.getPsramSize() / 1024); - map_insert_int(vm, "psram_free", ESP.getFreePsram() / 1024); + be_map_insert_int(vm, "psram", ESP.getPsramSize() / 1024); + be_map_insert_int(vm, "psram_free", ESP.getFreePsram() / 1024); } be_pop(vm, 1); be_return(vm); @@ -222,17 +222,17 @@ extern "C" { be_newobject(vm, "map"); if (Settings->flag4.network_wifi) { int32_t rssi = WiFi.RSSI(); - map_insert_int(vm, "rssi", rssi); - map_insert_int(vm, "quality", WifiGetRssiAsQuality(rssi)); + be_map_insert_int(vm, "rssi", rssi); + be_map_insert_int(vm, "quality", WifiGetRssiAsQuality(rssi)); #if LWIP_IPV6 String ipv6_addr = WifiGetIPv6(); if (ipv6_addr != "") { - map_insert_str(vm, "ip6", ipv6_addr.c_str()); + be_map_insert_str(vm, "ip6", ipv6_addr.c_str()); } #endif if (static_cast(WiFi.localIP()) != 0) { - map_insert_str(vm, "mac", WiFi.macAddress().c_str()); - map_insert_str(vm, "ip", WiFi.localIP().toString().c_str()); + be_map_insert_str(vm, "mac", WiFi.macAddress().c_str()); + be_map_insert_str(vm, "ip", WiFi.localIP().toString().c_str()); } } be_pop(vm, 1); @@ -250,8 +250,8 @@ extern "C" { be_newobject(vm, "map"); #ifdef USE_ETHERNET if (static_cast(EthernetLocalIP()) != 0) { - map_insert_str(vm, "mac", EthernetMacAddress().c_str()); - map_insert_str(vm, "ip", EthernetLocalIP().toString().c_str()); + be_map_insert_str(vm, "mac", EthernetMacAddress().c_str()); + be_map_insert_str(vm, "ip", EthernetLocalIP().toString().c_str()); } #endif be_pop(vm, 1); @@ -262,14 +262,14 @@ extern "C" { static void l_push_time(bvm *vm, struct tm *t, const char *unparsed) { be_newobject(vm, "map"); - map_insert_int(vm, "year", t->tm_year + 1900); - map_insert_int(vm, "month", t->tm_mon + 1); - map_insert_int(vm, "day", t->tm_mday); - map_insert_int(vm, "hour", t->tm_hour); - map_insert_int(vm, "min", t->tm_min); - map_insert_int(vm, "sec", t->tm_sec); - map_insert_int(vm, "weekday", t->tm_wday); - if (unparsed) map_insert_str(vm, "unparsed", unparsed); + be_map_insert_int(vm, "year", t->tm_year + 1900); + be_map_insert_int(vm, "month", t->tm_mon + 1); + be_map_insert_int(vm, "day", t->tm_mday); + be_map_insert_int(vm, "hour", t->tm_hour); + be_map_insert_int(vm, "min", t->tm_min); + be_map_insert_int(vm, "sec", t->tm_sec); + be_map_insert_int(vm, "weekday", t->tm_wday); + if (unparsed) be_map_insert_str(vm, "unparsed", unparsed); be_pop(vm, 1); } @@ -332,27 +332,14 @@ extern "C" { // ESP object int32_t l_yield(bvm *vm); int32_t l_yield(bvm *vm) { - BrTimeoutYield(); // reset timeout - be_return_nil(vm); + return be_call_c_func(vm, (void*) &BrTimeoutYield, NULL, "-"); } // Berry: tasmota.scale_uint(int * 5) -> int // int32_t l_scaleuint(struct bvm *vm); int32_t l_scaleuint(struct bvm *vm) { - int32_t top = be_top(vm); // Get the number of arguments - if (top == 6 && be_isint(vm, 2) && be_isint(vm, 3) && be_isint(vm, 4) && be_isint(vm, 5) && be_isint(vm, 6)) { // only 1 argument of type string accepted - int32_t v = be_toint(vm, 2); - int32_t from1 = be_toint(vm, 3); - int32_t from2 = be_toint(vm, 4); - int32_t to1 = be_toint(vm, 5); - int32_t to2 = be_toint(vm, 6); - - int32_t ret = changeUIntScale(v, from1, from2, to1, to2); - be_pushint(vm, ret); - be_return(vm); - } - be_raise(vm, kTypeError, nullptr); + return be_call_c_func(vm, (void*) &changeUIntScale, "i", "-iiiii"); } int32_t l_respCmnd(bvm *vm); @@ -379,20 +366,17 @@ extern "C" { int32_t l_respCmndDone(bvm *vm); int32_t l_respCmndDone(bvm *vm) { - ResponseCmndDone(); - be_return_nil(vm); + return be_call_c_func(vm, (void*) &ResponseCmndDone, NULL, "-"); } int32_t l_respCmndError(bvm *vm); int32_t l_respCmndError(bvm *vm) { - ResponseCmndError(); - be_return_nil(vm); + return be_call_c_func(vm, (void*) &ResponseCmndError, NULL, "-"); } int32_t l_respCmndFailed(bvm *vm); int32_t l_respCmndFailed(bvm *vm) { - ResponseCmndFailed(); - be_return_nil(vm); + return be_call_c_func(vm, (void*) &ResponseCmndFailed, NULL, "-"); } // update XdrvMailbox.command with actual command diff --git a/tasmota/xdrv_52_3_berry_webclient.ino b/tasmota/xdrv_52_3_berry_webclient.ino index 5c1700ebf..625c54622 100644 --- a/tasmota/xdrv_52_3_berry_webclient.ino +++ b/tasmota/xdrv_52_3_berry_webclient.ino @@ -57,7 +57,7 @@ String wc_UrlEncode(const String& text) { /*********************************************************************************************\ * Int constants *********************************************************************************************/ -// const be_constint_t webserver_constants[] = { +// const be_const_member_t webserver_constants[] = { // { "BUTTON_CONFIGURATION", BUTTON_CONFIGURATION }, // { "BUTTON_INFORMATION", BUTTON_INFORMATION }, // { "BUTTON_MAIN", BUTTON_MAIN }, diff --git a/tasmota/xdrv_52_3_berry_webserver.ino b/tasmota/xdrv_52_3_berry_webserver.ino index 2faa223ba..00f260d5a 100644 --- a/tasmota/xdrv_52_3_berry_webserver.ino +++ b/tasmota/xdrv_52_3_berry_webserver.ino @@ -27,7 +27,7 @@ /*********************************************************************************************\ * Int constants *********************************************************************************************/ -const be_constint_t webserver_constants[] = { +const be_const_member_t webserver_constants[] = { { "BUTTON_CONFIGURATION", BUTTON_CONFIGURATION }, { "BUTTON_INFORMATION", BUTTON_INFORMATION }, { "BUTTON_MAIN", BUTTON_MAIN }, @@ -51,7 +51,7 @@ extern "C" { if (argc == 1 && be_isstring(vm, 1)) { const char * needle = be_tostring(vm, 1); - int32_t constant_idx = bin_search(needle, &webserver_constants[0].name, sizeof(webserver_constants[0]), ARRAY_SIZE(webserver_constants)); + int32_t constant_idx = be_map_bin_search(needle, &webserver_constants[0].name, sizeof(webserver_constants[0]), ARRAY_SIZE(webserver_constants)); if (constant_idx >= 0) { // we did have a match, low == high diff --git a/tools/lv_berry/convert.py b/tools/lv_berry/convert.py index a814af381..86a4b86d4 100644 --- a/tools/lv_berry/convert.py +++ b/tools/lv_berry/convert.py @@ -320,13 +320,14 @@ extern "C" { #endif #include "be_ctypes.h" +#include "be_mapping.h" """) for subtype, flv in lv.items(): print(f"/* `lv_{subtype}` methods */") if subtype in lv_widgets: print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}") - print(f"const lvbe_call_c_t lv_{subtype}_func[] = {{") + print(f"const be_ntv_func_def_t lv_{subtype}_func[] = {{") func_out = {} # used to sort output for f in flv: @@ -361,7 +362,7 @@ print() # print the global map of classes print(f""" // map of clases -const lvbe_call_c_classes_t lv_classes[] = {{""") +const be_ntv_class_def_t lv_classes[] = {{""") for subtype in sorted(lv): # for subtype, flv in lv.items(): @@ -391,7 +392,7 @@ for subtype, flv in lv.items(): if len(c_ret_type) > 1: c_ret_type = "lv." + c_ret_type if c_func_name.endswith("_create"): - c_ret_type = "+" # constructor, init method does not return any value + c_ret_type = "+_p" # constructor, init method does not return any value if subtype in lv_widgets: print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}") print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'}); }}") @@ -401,8 +402,8 @@ for subtype, flv in lv.items(): print(""" // create font either empty or from parameter on stack -int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_font", ""); } -int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+lv_theme", ""); } +int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); } +int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); } """) print() @@ -660,7 +661,7 @@ print("""/******************************************************************** #ifdef USE_LVGL #include "lvgl.h" -#include "be_lvgl.h" +#include "be_mapping.h" #include "lv_theme_openhasp.h" extern int lv0_member(bvm *vm); // resolve virtual members @@ -685,7 +686,7 @@ static int lv_get_ver_res(void) { } /* `lv` methods */ -const lvbe_call_c_t lv_func[] = { +const be_ntv_func_def_t lv_func[] = { """) func_out = {} # used to sort output @@ -728,12 +729,7 @@ const size_t lv_func_size = sizeof(lv_func) / sizeof(lv_func[0]); print(""" -typedef struct be_constint_t { - const char * name; - int32_t value; -} be_constint_t; - -const be_constint_t lv0_constants[] = { +const be_const_member_t lv0_constants[] = { """) lv_module2 = {} diff --git a/tools/lv_gpio/gpio_convert.py b/tools/lv_gpio/gpio_convert.py index dfa3d78f0..6232fd287 100644 --- a/tools/lv_gpio/gpio_convert.py +++ b/tools/lv_gpio/gpio_convert.py @@ -56,7 +56,7 @@ print(" * Generated code, don't edit") print(" *******************************************************************/") print(""" -const be_constint_t lv_gpio_constants[] = { +const be_const_member_t lv_gpio_constants[] = { """) lv_module2 = {} From e5479cdc9643391af8c7fb3e3d888829b11dc9e3 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sat, 18 Dec 2021 11:47:03 +0100 Subject: [PATCH 13/31] Berry move LVGL mapping to its own library --- lib/libesp32/berry/default/be_modtab.c | 9 +- lib/libesp32/berry/gen.sh | 2 +- .../berry_mapping/src/be_class_wrapper.c | 24 +- lib/libesp32/berry_mapping/src/be_mapping.h | 1 + .../lv_berry/generate/be_lv_c_mapping.h | 1097 +++++++++++++++++ .../lv_berry/generate}/be_lvgl_module.c | 4 - .../lv_berry/generate}/be_lvgl_widgets_lib.c | 5 - lib/libesp32_lvgl/lv_berry/library.json | 25 + .../libesp32_lvgl/lv_berry/mapping}/lv_enum.h | 0 .../lv_berry/mapping}/lv_funcs.h | 110 +- .../src}/be_lvgl_ctypes_definitions.c | 4 - .../lv_berry/src}/be_lvgl_glob_lib.c | 6 - .../lv_berry/src}/embedded/lvgl_glob.be | 0 lib/libesp32_lvgl/lv_berry/src/lv_berry.c | 11 + lib/libesp32_lvgl/lv_berry/src/lv_berry.h | 17 + .../libesp32_lvgl/lv_berry/tools}/convert.py | 17 +- .../lv_berry/tools}/preprocessor.py | 10 +- lib/libesp32_lvgl/{LVGL8 => lvgl}/Kconfig | 0 lib/libesp32_lvgl/{LVGL8 => lvgl}/LICENCE.txt | 0 lib/libesp32_lvgl/{LVGL8 => lvgl}/README.md | 0 .../{LVGL8 => lvgl}/library.json | 0 .../{LVGL8 => lvgl}/library.properties | 0 .../{LVGL8 => lvgl}/lv_conf_template.h | 0 lib/libesp32_lvgl/{LVGL8 => lvgl}/lvgl.h | 0 lib/libesp32_lvgl/{LVGL8 => lvgl}/lvgl.mk | 0 .../{LVGL8 => lvgl}/src/core/lv_core.mk | 0 .../{LVGL8 => lvgl}/src/core/lv_disp.c | 0 .../{LVGL8 => lvgl}/src/core/lv_disp.h | 0 .../{LVGL8 => lvgl}/src/core/lv_event.c | 0 .../{LVGL8 => lvgl}/src/core/lv_event.h | 0 .../{LVGL8 => lvgl}/src/core/lv_group.c | 0 .../{LVGL8 => lvgl}/src/core/lv_group.h | 0 .../{LVGL8 => lvgl}/src/core/lv_indev.c | 0 .../{LVGL8 => lvgl}/src/core/lv_indev.h | 0 .../src/core/lv_indev_scroll.c | 0 .../src/core/lv_indev_scroll.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_class.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_class.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_draw.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_draw.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_pos.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_pos.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_scroll.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_scroll.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_style.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_style.h | 0 .../src/core/lv_obj_style_gen.c | 0 .../src/core/lv_obj_style_gen.h | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_tree.c | 0 .../{LVGL8 => lvgl}/src/core/lv_obj_tree.h | 0 .../{LVGL8 => lvgl}/src/core/lv_refr.c | 0 .../{LVGL8 => lvgl}/src/core/lv_refr.h | 0 .../{LVGL8 => lvgl}/src/core/lv_theme.c | 0 .../{LVGL8 => lvgl}/src/core/lv_theme.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw.mk | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_arc.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_arc.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_blend.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_blend.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_img.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_img.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_label.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_label.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_line.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_line.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_mask.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_mask.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_rect.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_draw_rect.h | 0 .../src/draw/lv_draw_triangle.c | 0 .../src/draw/lv_draw_triangle.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_img_buf.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_img_buf.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_img_cache.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_img_cache.h | 0 .../{LVGL8 => lvgl}/src/draw/lv_img_decoder.c | 0 .../{LVGL8 => lvgl}/src/draw/lv_img_decoder.h | 0 .../{LVGL8 => lvgl}/src/extra/extra.mk | 0 .../src/extra/layouts/flex/lv_flex.c | 0 .../src/extra/layouts/flex/lv_flex.h | 0 .../src/extra/layouts/grid/lv_grid.c | 0 .../src/extra/layouts/grid/lv_grid.h | 0 .../src/extra/layouts/lv_layouts.h | 0 .../{LVGL8 => lvgl}/src/extra/lv_extra.c | 0 .../{LVGL8 => lvgl}/src/extra/lv_extra.h | 0 .../src/extra/themes/basic/lv_theme_basic.c | 0 .../src/extra/themes/basic/lv_theme_basic.h | 0 .../extra/themes/default/lv_theme_default.c | 0 .../extra/themes/default/lv_theme_default.h | 0 .../src/extra/themes/lv_themes.h | 0 .../src/extra/themes/mono/lv_theme_mono.c | 0 .../src/extra/themes/mono/lv_theme_mono.h | 0 .../src/extra/widgets/animimg/lv_animimg.c | 0 .../src/extra/widgets/animimg/lv_animimg.h | 0 .../src/extra/widgets/calendar/lv_calendar.c | 0 .../src/extra/widgets/calendar/lv_calendar.h | 0 .../calendar/lv_calendar_header_arrow.c | 0 .../calendar/lv_calendar_header_arrow.h | 0 .../calendar/lv_calendar_header_dropdown.c | 0 .../calendar/lv_calendar_header_dropdown.h | 0 .../src/extra/widgets/chart/lv_chart.c | 0 .../src/extra/widgets/chart/lv_chart.h | 0 .../extra/widgets/colorwheel/lv_colorwheel.c | 0 .../extra/widgets/colorwheel/lv_colorwheel.h | 0 .../src/extra/widgets/imgbtn/lv_imgbtn.c | 0 .../src/extra/widgets/imgbtn/lv_imgbtn.h | 0 .../src/extra/widgets/keyboard/lv_keyboard.c | 0 .../src/extra/widgets/keyboard/lv_keyboard.h | 0 .../src/extra/widgets/led/lv_led.c | 0 .../src/extra/widgets/led/lv_led.h | 0 .../src/extra/widgets/list/lv_list.c | 0 .../src/extra/widgets/list/lv_list.h | 0 .../src/extra/widgets/lv_widgets.h | 0 .../src/extra/widgets/meter/lv_meter.c | 0 .../src/extra/widgets/meter/lv_meter.h | 0 .../src/extra/widgets/msgbox/lv_msgbox.c | 0 .../src/extra/widgets/msgbox/lv_msgbox.h | 0 .../src/extra/widgets/span/lv_span.c | 0 .../src/extra/widgets/span/lv_span.h | 0 .../src/extra/widgets/spinbox/lv_spinbox.c | 0 .../src/extra/widgets/spinbox/lv_spinbox.h | 0 .../src/extra/widgets/spinner/lv_spinner.c | 0 .../src/extra/widgets/spinner/lv_spinner.h | 0 .../src/extra/widgets/tabview/lv_tabview.c | 0 .../src/extra/widgets/tabview/lv_tabview.h | 0 .../src/extra/widgets/tileview/lv_tileview.c | 0 .../src/extra/widgets/tileview/lv_tileview.h | 0 .../src/extra/widgets/win/lv_win.c | 0 .../src/extra/widgets/win/lv_win.h | 0 .../{LVGL8 => lvgl}/src/font/korean.ttf | Bin .../{LVGL8 => lvgl}/src/font/lv_font.c | 0 .../{LVGL8 => lvgl}/src/font/lv_font.h | 0 .../{LVGL8 => lvgl}/src/font/lv_font.mk | 0 .../font/lv_font_dejavu_16_persian_hebrew.c | 0 .../src/font/lv_font_fmt_txt.c | 0 .../src/font/lv_font_fmt_txt.h | 0 .../{LVGL8 => lvgl}/src/font/lv_font_loader.c | 0 .../{LVGL8 => lvgl}/src/font/lv_font_loader.h | 0 .../src/font/lv_font_montserrat_10.c | 0 .../src/font/lv_font_montserrat_12.c | 0 .../src/font/lv_font_montserrat_12_subpx.c | 0 .../src/font/lv_font_montserrat_14.c | 0 .../src/font/lv_font_montserrat_16.c | 0 .../src/font/lv_font_montserrat_18.c | 0 .../src/font/lv_font_montserrat_20.c | 0 .../src/font/lv_font_montserrat_22.c | 0 .../src/font/lv_font_montserrat_24.c | 0 .../src/font/lv_font_montserrat_26.c | 0 .../src/font/lv_font_montserrat_28.c | 0 .../font/lv_font_montserrat_28_compressed.c | 0 .../src/font/lv_font_montserrat_30.c | 0 .../src/font/lv_font_montserrat_32.c | 0 .../src/font/lv_font_montserrat_34.c | 0 .../src/font/lv_font_montserrat_36.c | 0 .../src/font/lv_font_montserrat_38.c | 0 .../src/font/lv_font_montserrat_40.c | 0 .../src/font/lv_font_montserrat_42.c | 0 .../src/font/lv_font_montserrat_44.c | 0 .../src/font/lv_font_montserrat_46.c | 0 .../src/font/lv_font_montserrat_48.c | 0 .../src/font/lv_font_montserrat_8.c | 0 .../src/font/lv_font_simsun_16_cjk.c | 0 .../src/font/lv_font_unscii_16.c | 0 .../src/font/lv_font_unscii_8.c | 0 .../{LVGL8 => lvgl}/src/font/lv_symbol_def.h | 0 .../{LVGL8 => lvgl}/src/gpu/lv_gpu.mk | 0 .../{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_pxp.c | 0 .../{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_pxp.h | 0 .../src/gpu/lv_gpu_nxp_pxp_osa.c | 0 .../src/gpu/lv_gpu_nxp_pxp_osa.h | 0 .../src/gpu/lv_gpu_nxp_vglite.c | 0 .../src/gpu/lv_gpu_nxp_vglite.h | 0 .../src/gpu/lv_gpu_stm32_dma2d.c | 0 .../src/gpu/lv_gpu_stm32_dma2d.h | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal.h | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal.mk | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal_disp.c | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal_disp.h | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal_indev.c | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal_indev.h | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal_tick.c | 0 .../{LVGL8 => lvgl}/src/hal/lv_hal_tick.h | 0 .../{LVGL8 => lvgl}/src/lv_api_map.h | 0 .../{LVGL8 => lvgl}/src/lv_conf_internal.h | 0 .../{LVGL8 => lvgl}/src/lv_conf_kconfig.h | 0 lib/libesp32_lvgl/{LVGL8 => lvgl}/src/lvgl.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_anim.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_anim.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_area.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_area.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_assert.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_async.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_async.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_bidi.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_bidi.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_color.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_color.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_fs.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_fs.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_gc.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_gc.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_ll.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_ll.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_log.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_log.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_math.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_math.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_mem.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_mem.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_misc.mk | 0 .../{LVGL8 => lvgl}/src/misc/lv_printf.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_printf.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_style.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_style.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_style_gen.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_style_gen.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_templ.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_templ.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_timer.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_timer.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_tlsf.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_tlsf.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_txt.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_txt.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_txt_ap.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_txt_ap.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_types.h | 0 .../{LVGL8 => lvgl}/src/misc/lv_utils.c | 0 .../{LVGL8 => lvgl}/src/misc/lv_utils.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_arc.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_arc.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_bar.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_bar.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_btn.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_btn.h | 0 .../src/widgets/lv_btnmatrix.c | 0 .../src/widgets/lv_btnmatrix.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_canvas.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_canvas.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_checkbox.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_checkbox.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_dropdown.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_dropdown.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_img.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_img.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_label.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_label.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_line.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_line.h | 0 .../src/widgets/lv_objx_templ.c | 0 .../src/widgets/lv_objx_templ.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_roller.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_roller.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_slider.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_slider.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_switch.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_switch.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_table.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_table.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_textarea.c | 0 .../{LVGL8 => lvgl}/src/widgets/lv_textarea.h | 0 .../{LVGL8 => lvgl}/src/widgets/lv_widgets.mk | 0 tasmota/xdrv_52_3_berry_lvgl.ino | 2 + tools/lv_berry/lv_symbol.h | 62 - tools/lv_berry/lv_symbols.h | 61 - 268 files changed, 1237 insertions(+), 230 deletions(-) create mode 100644 lib/libesp32_lvgl/lv_berry/generate/be_lv_c_mapping.h rename lib/{libesp32/berry/default => libesp32_lvgl/lv_berry/generate}/be_lvgl_module.c (99%) rename lib/{libesp32/berry/default => libesp32_lvgl/lv_berry/generate}/be_lvgl_widgets_lib.c (99%) create mode 100644 lib/libesp32_lvgl/lv_berry/library.json rename {tools/lv_berry => lib/libesp32_lvgl/lv_berry/mapping}/lv_enum.h (100%) rename {tools/lv_berry => lib/libesp32_lvgl/lv_berry/mapping}/lv_funcs.h (95%) rename lib/{libesp32/berry/default => libesp32_lvgl/lv_berry/src}/be_lvgl_ctypes_definitions.c (99%) rename lib/{libesp32/berry/default => libesp32_lvgl/lv_berry/src}/be_lvgl_glob_lib.c (99%) rename lib/{libesp32/berry/default => libesp32_lvgl/lv_berry/src}/embedded/lvgl_glob.be (100%) create mode 100644 lib/libesp32_lvgl/lv_berry/src/lv_berry.c create mode 100644 lib/libesp32_lvgl/lv_berry/src/lv_berry.h rename {tools/lv_berry => lib/libesp32_lvgl/lv_berry/tools}/convert.py (99%) rename {tools/lv_berry => lib/libesp32_lvgl/lv_berry/tools}/preprocessor.py (97%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/Kconfig (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/LICENCE.txt (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/README.md (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/library.json (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/library.properties (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/lv_conf_template.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/lvgl.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/lvgl.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_core.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_disp.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_disp.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_event.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_event.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_group.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_group.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_indev.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_indev.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_indev_scroll.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_indev_scroll.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_class.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_class.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_draw.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_draw.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_pos.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_pos.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_scroll.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_scroll.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_style.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_style.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_style_gen.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_style_gen.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_tree.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_obj_tree.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_refr.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_refr.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_theme.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/core/lv_theme.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_arc.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_arc.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_blend.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_blend.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_img.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_img.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_label.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_label.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_line.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_line.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_mask.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_mask.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_rect.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_rect.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_triangle.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_draw_triangle.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_img_buf.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_img_buf.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_img_cache.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_img_cache.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_img_decoder.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/draw/lv_img_decoder.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/extra.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/layouts/flex/lv_flex.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/layouts/flex/lv_flex.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/layouts/grid/lv_grid.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/layouts/grid/lv_grid.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/layouts/lv_layouts.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/lv_extra.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/lv_extra.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/basic/lv_theme_basic.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/basic/lv_theme_basic.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/default/lv_theme_default.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/default/lv_theme_default.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/lv_themes.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/mono/lv_theme_mono.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/themes/mono/lv_theme_mono.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/animimg/lv_animimg.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/animimg/lv_animimg.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/calendar/lv_calendar.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/calendar/lv_calendar.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/calendar/lv_calendar_header_arrow.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/calendar/lv_calendar_header_arrow.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/calendar/lv_calendar_header_dropdown.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/calendar/lv_calendar_header_dropdown.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/chart/lv_chart.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/chart/lv_chart.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/colorwheel/lv_colorwheel.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/colorwheel/lv_colorwheel.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/imgbtn/lv_imgbtn.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/imgbtn/lv_imgbtn.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/keyboard/lv_keyboard.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/keyboard/lv_keyboard.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/led/lv_led.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/led/lv_led.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/list/lv_list.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/list/lv_list.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/lv_widgets.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/meter/lv_meter.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/meter/lv_meter.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/msgbox/lv_msgbox.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/msgbox/lv_msgbox.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/span/lv_span.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/span/lv_span.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/spinbox/lv_spinbox.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/spinbox/lv_spinbox.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/spinner/lv_spinner.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/spinner/lv_spinner.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/tabview/lv_tabview.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/tabview/lv_tabview.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/tileview/lv_tileview.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/tileview/lv_tileview.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/win/lv_win.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/extra/widgets/win/lv_win.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/korean.ttf (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_dejavu_16_persian_hebrew.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_fmt_txt.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_fmt_txt.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_loader.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_loader.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_10.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_12.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_12_subpx.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_14.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_16.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_18.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_20.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_22.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_24.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_26.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_28.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_28_compressed.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_30.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_32.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_34.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_36.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_38.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_40.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_42.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_44.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_46.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_48.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_montserrat_8.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_simsun_16_cjk.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_unscii_16.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_font_unscii_8.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/font/lv_symbol_def.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_pxp.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_pxp.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_pxp_osa.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_pxp_osa.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_vglite.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_nxp_vglite.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_stm32_dma2d.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/gpu/lv_gpu_stm32_dma2d.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal_disp.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal_disp.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal_indev.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal_indev.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal_tick.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/hal/lv_hal_tick.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/lv_api_map.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/lv_conf_internal.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/lv_conf_kconfig.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/lvgl.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_anim.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_anim.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_area.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_area.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_assert.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_async.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_async.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_bidi.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_bidi.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_color.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_color.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_fs.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_fs.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_gc.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_gc.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_ll.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_ll.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_log.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_log.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_math.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_math.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_mem.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_mem.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_misc.mk (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_printf.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_printf.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_style.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_style.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_style_gen.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_style_gen.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_templ.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_templ.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_timer.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_timer.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_tlsf.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_tlsf.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_txt.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_txt.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_txt_ap.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_txt_ap.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_types.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_utils.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/misc/lv_utils.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_arc.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_arc.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_bar.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_bar.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_btn.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_btn.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_btnmatrix.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_btnmatrix.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_canvas.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_canvas.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_checkbox.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_checkbox.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_dropdown.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_dropdown.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_img.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_img.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_label.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_label.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_line.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_line.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_objx_templ.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_objx_templ.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_roller.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_roller.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_slider.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_slider.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_switch.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_switch.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_table.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_table.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_textarea.c (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_textarea.h (100%) rename lib/libesp32_lvgl/{LVGL8 => lvgl}/src/widgets/lv_widgets.mk (100%) delete mode 100644 tools/lv_berry/lv_symbol.h delete mode 100644 tools/lv_berry/lv_symbols.h diff --git a/lib/libesp32/berry/default/be_modtab.c b/lib/libesp32/berry/default/be_modtab.c index 934400bbb..02b25a747 100644 --- a/lib/libesp32/berry/default/be_modtab.c +++ b/lib/libesp32/berry/default/be_modtab.c @@ -157,9 +157,7 @@ extern void be_load_driver_audio_lib(bvm *vm); #endif #ifdef USE_LVGL -extern void be_load_lv_color_class(bvm *vm); -extern void be_load_lv_font_class(bvm *vm); -extern void be_load_LVGL_glob_class(bvm *vm); +#include "lv_berry.h" // custom widgets extern void be_load_lv_signal_bars_class(bvm *vm); extern void be_load_lv_wifi_bars_class(bvm *vm); @@ -213,10 +211,7 @@ BERRY_API void be_load_custom_libs(bvm *vm) #endif #ifdef USE_LVGL // LVGL - be_load_lv_color_class(vm); - be_load_lv_font_class(vm); - - be_load_LVGL_glob_class(vm); + be_load_lvgl_classes(vm); // custom widgets be_load_lv_signal_bars_class(vm); be_load_lv_wifi_bars_class(vm); diff --git a/lib/libesp32/berry/gen.sh b/lib/libesp32/berry/gen.sh index 303a62c95..0dc462474 100755 --- a/lib/libesp32/berry/gen.sh +++ b/lib/libesp32/berry/gen.sh @@ -1,2 +1,2 @@ #!/bin/bash -python3 tools/pycoc/main.py -o generate src default ../berry_mapping/src -c default/berry_conf.h +python3 tools/pycoc/main.py -o generate src default ../berry_mapping/src ../../libesp32_lvgl/lv_berry/src -c default/berry_conf.h diff --git a/lib/libesp32/berry_mapping/src/be_class_wrapper.c b/lib/libesp32/berry_mapping/src/be_class_wrapper.c index 5f71e7da1..aa03fa4dd 100644 --- a/lib/libesp32/berry_mapping/src/be_class_wrapper.c +++ b/lib/libesp32/berry_mapping/src/be_class_wrapper.c @@ -13,6 +13,14 @@ #include "be_exec.h" #include +// By default the cb generator is cb.gen_cb +// This can be changed. Note: it is across all VMs +static const char * be_gen_cb_name = "cb.gen_cb"; + +void be_set_gen_cb_name(bvm *vm, const char * gen_cb) { + if (gen_cb) be_gen_cb_name = gen_cb; +} + /*********************************************************************************************\ * Create an object of `class_name` given an external poinrt `ptr`. * @@ -115,7 +123,7 @@ int be_find_global_or_module_member(bvm *vm, const char * name) { * 's' be_str * * - arg_type: optionally check the types of input arguments, or throw an error - * string of argument types, '+' marks optional arguments + * string of argument types * '.' don't care * 'i' be_int * 'b' be_bool @@ -125,7 +133,7 @@ int be_find_global_or_module_member(bvm *vm, const char * name) { * 'lv_obj' be_instance of type or subtype * '^lv_event_cb' callback of a named class - will call `_lvgl.gen_cb(arg_type, closure, self)` and expects a callback address in return * - * Ex: "oii+s" takes 3 mandatory arguments (obj_instance, int, int) and an optional fourth one [,string] + * Ex: ".ii" takes 3 arguments, first one is any type, followed by 2 ints \*********************************************************************************************/ // general form of lv_obj_t* function, up to 4 parameters // We can only send 32 bits arguments (no 64 bits nor double) and we expect pointers to be 32 bits @@ -302,7 +310,7 @@ void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type, } } // AddLog(LOG_LEVEL_INFO, ">> be_call_c_func arg %i, type %s", i, arg_type_check ? type_short_name : ""); - p[p_idx++] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : NULL, "_lvgl.gen_cb"); + p[p_idx++] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : NULL, be_gen_cb_name); } // check if we are missing arguments @@ -324,11 +332,13 @@ void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type, // ptr: the C pointer for internal data (can be NULL), will be stored in an instance variable // name: name of instance variable to store the pointer as `comptr`. // If NULL, this function does nothing -// the name can be prefixed with `+`, if so first char is ignored. +// the name can be prefixed with `+` or `=`, if so first char is ignored. // Ex: `+_p` stores in instance variable `_p` +// `+` forbids any NULL value (raises an exception) while `=` allows a NULL value static void be_set_ctor_ptr(bvm *vm, void * ptr, const char *name) { if (name == NULL) return; // do nothing if no name of attribute - if (name[0] == '+') { name++; } // skip prefix '^' if any + if (name[0] == '=' && ptr == NULL) { be_raise(vm, "value_error", "argument cannot be NULL"); } + if (name[0] == '+' || name[0] == '=') { name++; } // skip prefix '^' if any if (strlen(name) == 0) return; // do nothing if name is empty be_pushcomptr(vm, ptr); @@ -362,7 +372,7 @@ int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * // check if we call a constructor, in this case we store the return type into the new object // check if we call a constructor with a comptr as first arg - if (return_type && return_type[0] == '+') { + if (return_type && (return_type[0] == '+' || return_type[0] == '=')) { if (argc > 1 && be_iscomptr(vm, 2)) { void * obj = be_tocomptr(vm, 2); be_set_ctor_ptr(vm, obj, return_type); @@ -380,7 +390,7 @@ int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * // berry_log_C("be_call_c_func '%s' -> '%s': (%i,%i,%i,%i,%i,%i) -> %i", return_type, arg_type, p[0], p[1], p[2], p[3], p[4], p[5], ret); if ((return_type == NULL) || (strlen(return_type) == 0)) { be_return_nil(vm); } // does not return - else if (return_type[0] == '+') { + else if (return_type[0] == '+' || return_type[0] == '=') { void * obj = (void*) ret; be_set_ctor_ptr(vm, obj, return_type); be_return_nil(vm); diff --git a/lib/libesp32/berry_mapping/src/be_mapping.h b/lib/libesp32/berry_mapping/src/be_mapping.h index 108db129b..d41d04fbc 100644 --- a/lib/libesp32/berry_mapping/src/be_mapping.h +++ b/lib/libesp32/berry_mapping/src/be_mapping.h @@ -43,6 +43,7 @@ typedef struct be_ntv_class_def_t { } be_ntv_class_def_t; void be_raisef(bvm *vm, const char *except, const char *msg, ...); +void be_set_gen_cb_name(bvm *vm, const char * gen_cb); extern void be_map_insert_int(bvm *vm, const char *key, bint value); extern void be_map_insert_bool(bvm *vm, const char *key, bbool value); diff --git a/lib/libesp32_lvgl/lv_berry/generate/be_lv_c_mapping.h b/lib/libesp32_lvgl/lv_berry/generate/be_lv_c_mapping.h new file mode 100644 index 000000000..dd654f5f3 --- /dev/null +++ b/lib/libesp32_lvgl/lv_berry/generate/be_lv_c_mapping.h @@ -0,0 +1,1097 @@ + +/******************************************************************** + * Generated code, don't edit + *******************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "be_ctypes.h" +#include "be_mapping.h" + +/* `lv_style` methods */ +const be_ntv_func_def_t lv_style_func[] = { + { "set_align", (void*) &lv_style_set_align, "", "(lv.lv_style)i" }, + { "set_anim_speed", (void*) &lv_style_set_anim_speed, "", "(lv.lv_style)i" }, + { "set_anim_time", (void*) &lv_style_set_anim_time, "", "(lv.lv_style)i" }, + { "set_arc_color", (void*) &lv_style_set_arc_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_arc_color_filtered", (void*) &lv_style_set_arc_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_arc_img_src", (void*) &lv_style_set_arc_img_src, "", "(lv.lv_style)." }, + { "set_arc_opa", (void*) &lv_style_set_arc_opa, "", "(lv.lv_style)i" }, + { "set_arc_rounded", (void*) &lv_style_set_arc_rounded, "", "(lv.lv_style)i" }, + { "set_arc_width", (void*) &lv_style_set_arc_width, "", "(lv.lv_style)i" }, + { "set_base_dir", (void*) &lv_style_set_base_dir, "", "(lv.lv_style)i" }, + { "set_bg_color", (void*) &lv_style_set_bg_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_bg_color_filtered", (void*) &lv_style_set_bg_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_bg_grad_color", (void*) &lv_style_set_bg_grad_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_bg_grad_color_filtered", (void*) &lv_style_set_bg_grad_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_bg_grad_dir", (void*) &lv_style_set_bg_grad_dir, "", "(lv.lv_style)i" }, + { "set_bg_grad_stop", (void*) &lv_style_set_bg_grad_stop, "", "(lv.lv_style)i" }, + { "set_bg_img_opa", (void*) &lv_style_set_bg_img_opa, "", "(lv.lv_style)i" }, + { "set_bg_img_recolor", (void*) &lv_style_set_bg_img_recolor, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_bg_img_recolor_filtered", (void*) &lv_style_set_bg_img_recolor_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_bg_img_recolor_opa", (void*) &lv_style_set_bg_img_recolor_opa, "", "(lv.lv_style)i" }, + { "set_bg_img_src", (void*) &lv_style_set_bg_img_src, "", "(lv.lv_style)." }, + { "set_bg_img_tiled", (void*) &lv_style_set_bg_img_tiled, "", "(lv.lv_style)b" }, + { "set_bg_main_stop", (void*) &lv_style_set_bg_main_stop, "", "(lv.lv_style)i" }, + { "set_bg_opa", (void*) &lv_style_set_bg_opa, "", "(lv.lv_style)i" }, + { "set_blend_mode", (void*) &lv_style_set_blend_mode, "", "(lv.lv_style)i" }, + { "set_border_color", (void*) &lv_style_set_border_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_border_color_filtered", (void*) &lv_style_set_border_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_border_opa", (void*) &lv_style_set_border_opa, "", "(lv.lv_style)i" }, + { "set_border_post", (void*) &lv_style_set_border_post, "", "(lv.lv_style)b" }, + { "set_border_side", (void*) &lv_style_set_border_side, "", "(lv.lv_style)i" }, + { "set_border_width", (void*) &lv_style_set_border_width, "", "(lv.lv_style)i" }, + { "set_clip_corner", (void*) &lv_style_set_clip_corner, "", "(lv.lv_style)b" }, + { "set_color_filter_dsc", (void*) &lv_style_set_color_filter_dsc, "", "(lv.lv_style)(lv.lv_color_filter_dsc)" }, + { "set_color_filter_opa", (void*) &lv_style_set_color_filter_opa, "", "(lv.lv_style)i" }, + { "set_height", (void*) &lv_style_set_height, "", "(lv.lv_style)i" }, + { "set_img_opa", (void*) &lv_style_set_img_opa, "", "(lv.lv_style)i" }, + { "set_img_recolor", (void*) &lv_style_set_img_recolor, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_img_recolor_filtered", (void*) &lv_style_set_img_recolor_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_img_recolor_opa", (void*) &lv_style_set_img_recolor_opa, "", "(lv.lv_style)i" }, + { "set_layout", (void*) &lv_style_set_layout, "", "(lv.lv_style)i" }, + { "set_line_color", (void*) &lv_style_set_line_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_line_color_filtered", (void*) &lv_style_set_line_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_line_dash_gap", (void*) &lv_style_set_line_dash_gap, "", "(lv.lv_style)i" }, + { "set_line_dash_width", (void*) &lv_style_set_line_dash_width, "", "(lv.lv_style)i" }, + { "set_line_opa", (void*) &lv_style_set_line_opa, "", "(lv.lv_style)i" }, + { "set_line_rounded", (void*) &lv_style_set_line_rounded, "", "(lv.lv_style)i" }, + { "set_line_width", (void*) &lv_style_set_line_width, "", "(lv.lv_style)i" }, + { "set_max_height", (void*) &lv_style_set_max_height, "", "(lv.lv_style)i" }, + { "set_max_width", (void*) &lv_style_set_max_width, "", "(lv.lv_style)i" }, + { "set_min_height", (void*) &lv_style_set_min_height, "", "(lv.lv_style)i" }, + { "set_min_width", (void*) &lv_style_set_min_width, "", "(lv.lv_style)i" }, + { "set_opa", (void*) &lv_style_set_opa, "", "(lv.lv_style)i" }, + { "set_outline_color", (void*) &lv_style_set_outline_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_outline_color_filtered", (void*) &lv_style_set_outline_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_outline_opa", (void*) &lv_style_set_outline_opa, "", "(lv.lv_style)i" }, + { "set_outline_pad", (void*) &lv_style_set_outline_pad, "", "(lv.lv_style)i" }, + { "set_outline_width", (void*) &lv_style_set_outline_width, "", "(lv.lv_style)i" }, + { "set_pad_bottom", (void*) &lv_style_set_pad_bottom, "", "(lv.lv_style)i" }, + { "set_pad_column", (void*) &lv_style_set_pad_column, "", "(lv.lv_style)i" }, + { "set_pad_left", (void*) &lv_style_set_pad_left, "", "(lv.lv_style)i" }, + { "set_pad_right", (void*) &lv_style_set_pad_right, "", "(lv.lv_style)i" }, + { "set_pad_row", (void*) &lv_style_set_pad_row, "", "(lv.lv_style)i" }, + { "set_pad_top", (void*) &lv_style_set_pad_top, "", "(lv.lv_style)i" }, + { "set_radius", (void*) &lv_style_set_radius, "", "(lv.lv_style)i" }, + { "set_shadow_color", (void*) &lv_style_set_shadow_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_shadow_color_filtered", (void*) &lv_style_set_shadow_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_shadow_ofs_x", (void*) &lv_style_set_shadow_ofs_x, "", "(lv.lv_style)i" }, + { "set_shadow_ofs_y", (void*) &lv_style_set_shadow_ofs_y, "", "(lv.lv_style)i" }, + { "set_shadow_opa", (void*) &lv_style_set_shadow_opa, "", "(lv.lv_style)i" }, + { "set_shadow_spread", (void*) &lv_style_set_shadow_spread, "", "(lv.lv_style)i" }, + { "set_shadow_width", (void*) &lv_style_set_shadow_width, "", "(lv.lv_style)i" }, + { "set_text_align", (void*) &lv_style_set_text_align, "", "(lv.lv_style)i" }, + { "set_text_color", (void*) &lv_style_set_text_color, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_text_color_filtered", (void*) &lv_style_set_text_color_filtered, "", "(lv.lv_style)(lv.lv_color)" }, + { "set_text_decor", (void*) &lv_style_set_text_decor, "", "(lv.lv_style)i" }, + { "set_text_font", (void*) &lv_style_set_text_font, "", "(lv.lv_style)(lv.lv_font)" }, + { "set_text_letter_space", (void*) &lv_style_set_text_letter_space, "", "(lv.lv_style)i" }, + { "set_text_line_space", (void*) &lv_style_set_text_line_space, "", "(lv.lv_style)i" }, + { "set_text_opa", (void*) &lv_style_set_text_opa, "", "(lv.lv_style)i" }, + { "set_transform_angle", (void*) &lv_style_set_transform_angle, "", "(lv.lv_style)i" }, + { "set_transform_height", (void*) &lv_style_set_transform_height, "", "(lv.lv_style)i" }, + { "set_transform_width", (void*) &lv_style_set_transform_width, "", "(lv.lv_style)i" }, + { "set_transform_zoom", (void*) &lv_style_set_transform_zoom, "", "(lv.lv_style)i" }, + { "set_transition", (void*) &lv_style_set_transition, "", "(lv.lv_style)(lv.lv_style_transition_dsc)" }, + { "set_translate_x", (void*) &lv_style_set_translate_x, "", "(lv.lv_style)i" }, + { "set_translate_y", (void*) &lv_style_set_translate_y, "", "(lv.lv_style)i" }, + { "set_width", (void*) &lv_style_set_width, "", "(lv.lv_style)i" }, + { "set_x", (void*) &lv_style_set_x, "", "(lv.lv_style)i" }, + { "set_y", (void*) &lv_style_set_y, "", "(lv.lv_style)i" }, +}; + +/* `lv_font` methods */ +const be_ntv_func_def_t lv_font_func[] = { +}; + +/* `lv_color` methods */ +const be_ntv_func_def_t lv_color_func[] = { +}; + +/* `lv_theme` methods */ +const be_ntv_func_def_t lv_theme_func[] = { +}; + +/* `lv_img` methods */ +#ifdef BE_LV_WIDGET_IMG +const be_ntv_func_def_t lv_img_func[] = { + { "get_angle", (void*) &lv_img_get_angle, "i", "(lv.lv_obj)" }, + { "get_antialias", (void*) &lv_img_get_antialias, "b", "(lv.lv_obj)" }, + { "get_offset_x", (void*) &lv_img_get_offset_x, "i", "(lv.lv_obj)" }, + { "get_offset_y", (void*) &lv_img_get_offset_y, "i", "(lv.lv_obj)" }, + { "get_pivot", (void*) &lv_img_get_pivot, "", "(lv.lv_obj)(lv.lv_point)" }, + { "get_src", (void*) &lv_img_get_src, ".", "(lv.lv_obj)" }, + { "get_zoom", (void*) &lv_img_get_zoom, "i", "(lv.lv_obj)" }, + { "set_angle", (void*) &lv_img_set_angle, "", "(lv.lv_obj)i" }, + { "set_antialias", (void*) &lv_img_set_antialias, "", "(lv.lv_obj)b" }, + { "set_offset_x", (void*) &lv_img_set_offset_x, "", "(lv.lv_obj)i" }, + { "set_offset_y", (void*) &lv_img_set_offset_y, "", "(lv.lv_obj)i" }, + { "set_pivot", (void*) &lv_img_set_pivot, "", "(lv.lv_obj)ii" }, + { "set_src", (void*) &lv_img_set_src, "", "(lv.lv_obj)." }, + { "set_tasmota_logo", (void*) &lv_img_set_tasmota_logo, "", "(lv.lv_obj)" }, + { "set_zoom", (void*) &lv_img_set_zoom, "", "(lv.lv_obj)i" }, +}; +#endif // BE_LV_WIDGET_IMG + +/* `lv_disp` methods */ +const be_ntv_func_def_t lv_disp_func[] = { + { "clean_dcache", (void*) &lv_disp_clean_dcache, "", "(lv.lv_disp)" }, + { "dpx", (void*) &lv_disp_dpx, "i", "(lv.lv_disp)i" }, + { "get_inactive_time", (void*) &lv_disp_get_inactive_time, "i", "(lv.lv_disp)" }, + { "get_layer_sys", (void*) &lv_disp_get_layer_sys, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_layer_top", (void*) &lv_disp_get_layer_top, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_scr_act", (void*) &lv_disp_get_scr_act, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_scr_prev", (void*) &lv_disp_get_scr_prev, "lv.lv_obj", "(lv.lv_disp)" }, + { "get_theme", (void*) &lv_disp_get_theme, "lv.lv_theme", "(lv.lv_disp)" }, + { "load_scr", (void*) &lv_disp_load_scr, "", "(lv.lv_obj)" }, + { "set_bg_color", (void*) &lv_disp_set_bg_color, "", "(lv.lv_disp)(lv.lv_color)" }, + { "set_bg_image", (void*) &lv_disp_set_bg_image, "", "(lv.lv_disp)." }, + { "set_bg_opa", (void*) &lv_disp_set_bg_opa, "", "(lv.lv_disp)i" }, + { "set_theme", (void*) &lv_disp_set_theme, "", "(lv.lv_disp)(lv.lv_theme)" }, + { "trig_activity", (void*) &lv_disp_trig_activity, "", "(lv.lv_disp)" }, +}; + +/* `lv_obj` methods */ +const be_ntv_func_def_t lv_obj_func[] = { + { "add_event_cb", (void*) &lv_obj_add_event_cb, "i", "(lv.lv_obj)^lv_event_cb^i." }, + { "add_flag", (void*) &lv_obj_add_flag, "", "(lv.lv_obj)i" }, + { "add_state", (void*) &lv_obj_add_state, "", "(lv.lv_obj)i" }, + { "add_style", (void*) &lv_obj_add_style, "", "(lv.lv_obj)(lv.lv_style)i" }, + { "align", (void*) &lv_obj_align, "", "(lv.lv_obj)iii" }, + { "align_to", (void*) &lv_obj_align_to, "", "(lv.lv_obj)(lv.lv_obj)iii" }, + { "allocate_spec_attr", (void*) &lv_obj_allocate_spec_attr, "", "(lv.lv_obj)" }, + { "area_is_visible", (void*) &lv_obj_area_is_visible, "b", "(lv.lv_obj)(lv.lv_area)" }, + { "calculate_ext_draw_size", (void*) &lv_obj_calculate_ext_draw_size, "i", "(lv.lv_obj)i" }, + { "center", (void*) &lv_obj_center, "", "(lv.lv_obj)" }, + { "check_type", (void*) &lv_obj_check_type, "b", "(lv.lv_obj)(lv.lv_obj_class)" }, + { "class_init_obj", (void*) &lv_obj_class_init_obj, "", "(lv.lv_obj)" }, + { "clean", (void*) &lv_obj_clean, "", "(lv.lv_obj)" }, + { "clear_flag", (void*) &lv_obj_clear_flag, "", "(lv.lv_obj)i" }, + { "clear_state", (void*) &lv_obj_clear_state, "", "(lv.lv_obj)i" }, + { "del", (void*) &lv_obj_del, "", "(lv.lv_obj)" }, + { "del_async", (void*) &lv_obj_del_async, "", "(lv.lv_obj)" }, + { "dpx", (void*) &lv_obj_dpx, "i", "(lv.lv_obj)i" }, + { "fade_in", (void*) &lv_obj_fade_in, "", "(lv.lv_obj)ii" }, + { "fade_out", (void*) &lv_obj_fade_out, "", "(lv.lv_obj)ii" }, + { "get_child", (void*) &lv_obj_get_child, "lv.lv_obj", "(lv.lv_obj)i" }, + { "get_child_cnt", (void*) &lv_obj_get_child_cnt, "i", "(lv.lv_obj)" }, + { "get_child_id", (void*) &lv_obj_get_child_id, "i", "(lv.lv_obj)" }, + { "get_class", (void*) &lv_obj_get_class, "lv.lv_obj_class", "(lv.lv_obj)" }, + { "get_click_area", (void*) &lv_obj_get_click_area, "", "(lv.lv_obj)(lv.lv_area)" }, + { "get_content_coords", (void*) &lv_obj_get_content_coords, "", "(lv.lv_obj)(lv.lv_area)" }, + { "get_content_height", (void*) &lv_obj_get_content_height, "i", "(lv.lv_obj)" }, + { "get_content_width", (void*) &lv_obj_get_content_width, "i", "(lv.lv_obj)" }, + { "get_coords", (void*) &lv_obj_get_coords, "", "(lv.lv_obj)(lv.lv_area)" }, + { "get_disp", (void*) &lv_obj_get_disp, "lv.lv_disp", "(lv.lv_obj)" }, + { "get_group", (void*) &lv_obj_get_group, ".", "(lv.lv_obj)" }, + { "get_height", (void*) &lv_obj_get_height, "i", "(lv.lv_obj)" }, + { "get_local_style_prop", (void*) &lv_obj_get_local_style_prop, "i", "(lv.lv_obj)(lv.lv_style_prop)(lv.lv_style_value)i" }, + { "get_parent", (void*) &lv_obj_get_parent, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_screen", (void*) &lv_obj_get_screen, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_scroll_bottom", (void*) &lv_obj_get_scroll_bottom, "i", "(lv.lv_obj)" }, + { "get_scroll_dir", (void*) &lv_obj_get_scroll_dir, "i", "(lv.lv_obj)" }, + { "get_scroll_end", (void*) &lv_obj_get_scroll_end, "", "(lv.lv_obj)(lv.lv_point)" }, + { "get_scroll_left", (void*) &lv_obj_get_scroll_left, "i", "(lv.lv_obj)" }, + { "get_scroll_right", (void*) &lv_obj_get_scroll_right, "i", "(lv.lv_obj)" }, + { "get_scroll_snap_x", (void*) &lv_obj_get_scroll_snap_x, "i", "(lv.lv_obj)" }, + { "get_scroll_snap_y", (void*) &lv_obj_get_scroll_snap_y, "i", "(lv.lv_obj)" }, + { "get_scroll_top", (void*) &lv_obj_get_scroll_top, "i", "(lv.lv_obj)" }, + { "get_scroll_x", (void*) &lv_obj_get_scroll_x, "i", "(lv.lv_obj)" }, + { "get_scroll_y", (void*) &lv_obj_get_scroll_y, "i", "(lv.lv_obj)" }, + { "get_scrollbar_area", (void*) &lv_obj_get_scrollbar_area, "", "(lv.lv_obj)(lv.lv_area)(lv.lv_area)" }, + { "get_scrollbar_mode", (void*) &lv_obj_get_scrollbar_mode, "i", "(lv.lv_obj)" }, + { "get_self_height", (void*) &lv_obj_get_self_height, "i", "(lv.lv_obj)" }, + { "get_self_width", (void*) &lv_obj_get_self_width, "i", "(lv.lv_obj)" }, + { "get_state", (void*) &lv_obj_get_state, "i", "(lv.lv_obj)" }, + { "get_style_align", (void*) &lv_obj_get_style_align, "i", "(lv.lv_obj)i" }, + { "get_style_anim_speed", (void*) &lv_obj_get_style_anim_speed, "i", "(lv.lv_obj)i" }, + { "get_style_anim_time", (void*) &lv_obj_get_style_anim_time, "i", "(lv.lv_obj)i" }, + { "get_style_arc_color", (void*) &lv_obj_get_style_arc_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_arc_color_filtered", (void*) &lv_obj_get_style_arc_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_arc_img_src", (void*) &lv_obj_get_style_arc_img_src, ".", "(lv.lv_obj)i" }, + { "get_style_arc_opa", (void*) &lv_obj_get_style_arc_opa, "i", "(lv.lv_obj)i" }, + { "get_style_arc_rounded", (void*) &lv_obj_get_style_arc_rounded, "i", "(lv.lv_obj)i" }, + { "get_style_arc_width", (void*) &lv_obj_get_style_arc_width, "i", "(lv.lv_obj)i" }, + { "get_style_base_dir", (void*) &lv_obj_get_style_base_dir, "i", "(lv.lv_obj)i" }, + { "get_style_bg_color", (void*) &lv_obj_get_style_bg_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_bg_color_filtered", (void*) &lv_obj_get_style_bg_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_bg_grad_color", (void*) &lv_obj_get_style_bg_grad_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_bg_grad_color_filtered", (void*) &lv_obj_get_style_bg_grad_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_bg_grad_dir", (void*) &lv_obj_get_style_bg_grad_dir, "i", "(lv.lv_obj)i" }, + { "get_style_bg_grad_stop", (void*) &lv_obj_get_style_bg_grad_stop, "i", "(lv.lv_obj)i" }, + { "get_style_bg_img_opa", (void*) &lv_obj_get_style_bg_img_opa, "i", "(lv.lv_obj)i" }, + { "get_style_bg_img_recolor", (void*) &lv_obj_get_style_bg_img_recolor, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_bg_img_recolor_filtered", (void*) &lv_obj_get_style_bg_img_recolor_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_bg_img_recolor_opa", (void*) &lv_obj_get_style_bg_img_recolor_opa, "i", "(lv.lv_obj)i" }, + { "get_style_bg_img_src", (void*) &lv_obj_get_style_bg_img_src, ".", "(lv.lv_obj)i" }, + { "get_style_bg_img_tiled", (void*) &lv_obj_get_style_bg_img_tiled, "b", "(lv.lv_obj)i" }, + { "get_style_bg_main_stop", (void*) &lv_obj_get_style_bg_main_stop, "i", "(lv.lv_obj)i" }, + { "get_style_bg_opa", (void*) &lv_obj_get_style_bg_opa, "i", "(lv.lv_obj)i" }, + { "get_style_blend_mode", (void*) &lv_obj_get_style_blend_mode, "i", "(lv.lv_obj)i" }, + { "get_style_border_color", (void*) &lv_obj_get_style_border_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_border_color_filtered", (void*) &lv_obj_get_style_border_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_border_opa", (void*) &lv_obj_get_style_border_opa, "i", "(lv.lv_obj)i" }, + { "get_style_border_post", (void*) &lv_obj_get_style_border_post, "b", "(lv.lv_obj)i" }, + { "get_style_border_side", (void*) &lv_obj_get_style_border_side, "i", "(lv.lv_obj)i" }, + { "get_style_border_width", (void*) &lv_obj_get_style_border_width, "i", "(lv.lv_obj)i" }, + { "get_style_clip_corner", (void*) &lv_obj_get_style_clip_corner, "b", "(lv.lv_obj)i" }, + { "get_style_color_filter_opa", (void*) &lv_obj_get_style_color_filter_opa, "i", "(lv.lv_obj)i" }, + { "get_style_height", (void*) &lv_obj_get_style_height, "i", "(lv.lv_obj)i" }, + { "get_style_img_opa", (void*) &lv_obj_get_style_img_opa, "i", "(lv.lv_obj)i" }, + { "get_style_img_recolor", (void*) &lv_obj_get_style_img_recolor, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_img_recolor_filtered", (void*) &lv_obj_get_style_img_recolor_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_img_recolor_opa", (void*) &lv_obj_get_style_img_recolor_opa, "i", "(lv.lv_obj)i" }, + { "get_style_layout", (void*) &lv_obj_get_style_layout, "i", "(lv.lv_obj)i" }, + { "get_style_line_color", (void*) &lv_obj_get_style_line_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_line_color_filtered", (void*) &lv_obj_get_style_line_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_line_dash_gap", (void*) &lv_obj_get_style_line_dash_gap, "i", "(lv.lv_obj)i" }, + { "get_style_line_dash_width", (void*) &lv_obj_get_style_line_dash_width, "i", "(lv.lv_obj)i" }, + { "get_style_line_opa", (void*) &lv_obj_get_style_line_opa, "i", "(lv.lv_obj)i" }, + { "get_style_line_rounded", (void*) &lv_obj_get_style_line_rounded, "i", "(lv.lv_obj)i" }, + { "get_style_line_width", (void*) &lv_obj_get_style_line_width, "i", "(lv.lv_obj)i" }, + { "get_style_max_height", (void*) &lv_obj_get_style_max_height, "i", "(lv.lv_obj)i" }, + { "get_style_max_width", (void*) &lv_obj_get_style_max_width, "i", "(lv.lv_obj)i" }, + { "get_style_min_height", (void*) &lv_obj_get_style_min_height, "i", "(lv.lv_obj)i" }, + { "get_style_min_width", (void*) &lv_obj_get_style_min_width, "i", "(lv.lv_obj)i" }, + { "get_style_opa", (void*) &lv_obj_get_style_opa, "i", "(lv.lv_obj)i" }, + { "get_style_outline_color", (void*) &lv_obj_get_style_outline_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_outline_color_filtered", (void*) &lv_obj_get_style_outline_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_outline_opa", (void*) &lv_obj_get_style_outline_opa, "i", "(lv.lv_obj)i" }, + { "get_style_outline_pad", (void*) &lv_obj_get_style_outline_pad, "i", "(lv.lv_obj)i" }, + { "get_style_outline_width", (void*) &lv_obj_get_style_outline_width, "i", "(lv.lv_obj)i" }, + { "get_style_pad_bottom", (void*) &lv_obj_get_style_pad_bottom, "i", "(lv.lv_obj)i" }, + { "get_style_pad_column", (void*) &lv_obj_get_style_pad_column, "i", "(lv.lv_obj)i" }, + { "get_style_pad_left", (void*) &lv_obj_get_style_pad_left, "i", "(lv.lv_obj)i" }, + { "get_style_pad_right", (void*) &lv_obj_get_style_pad_right, "i", "(lv.lv_obj)i" }, + { "get_style_pad_row", (void*) &lv_obj_get_style_pad_row, "i", "(lv.lv_obj)i" }, + { "get_style_pad_top", (void*) &lv_obj_get_style_pad_top, "i", "(lv.lv_obj)i" }, + { "get_style_prop", (void*) &lv_obj_get_style_prop, "i", "(lv.lv_obj)i(lv.lv_style_prop)" }, + { "get_style_radius", (void*) &lv_obj_get_style_radius, "i", "(lv.lv_obj)i" }, + { "get_style_shadow_color", (void*) &lv_obj_get_style_shadow_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_shadow_color_filtered", (void*) &lv_obj_get_style_shadow_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_shadow_ofs_x", (void*) &lv_obj_get_style_shadow_ofs_x, "i", "(lv.lv_obj)i" }, + { "get_style_shadow_ofs_y", (void*) &lv_obj_get_style_shadow_ofs_y, "i", "(lv.lv_obj)i" }, + { "get_style_shadow_opa", (void*) &lv_obj_get_style_shadow_opa, "i", "(lv.lv_obj)i" }, + { "get_style_shadow_spread", (void*) &lv_obj_get_style_shadow_spread, "i", "(lv.lv_obj)i" }, + { "get_style_shadow_width", (void*) &lv_obj_get_style_shadow_width, "i", "(lv.lv_obj)i" }, + { "get_style_text_align", (void*) &lv_obj_get_style_text_align, "i", "(lv.lv_obj)i" }, + { "get_style_text_color", (void*) &lv_obj_get_style_text_color, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_text_color_filtered", (void*) &lv_obj_get_style_text_color_filtered, "lv.lv_color", "(lv.lv_obj)i" }, + { "get_style_text_decor", (void*) &lv_obj_get_style_text_decor, "i", "(lv.lv_obj)i" }, + { "get_style_text_font", (void*) &lv_obj_get_style_text_font, "lv.lv_font", "(lv.lv_obj)i" }, + { "get_style_text_letter_space", (void*) &lv_obj_get_style_text_letter_space, "i", "(lv.lv_obj)i" }, + { "get_style_text_line_space", (void*) &lv_obj_get_style_text_line_space, "i", "(lv.lv_obj)i" }, + { "get_style_text_opa", (void*) &lv_obj_get_style_text_opa, "i", "(lv.lv_obj)i" }, + { "get_style_transform_angle", (void*) &lv_obj_get_style_transform_angle, "i", "(lv.lv_obj)i" }, + { "get_style_transform_height", (void*) &lv_obj_get_style_transform_height, "i", "(lv.lv_obj)i" }, + { "get_style_transform_width", (void*) &lv_obj_get_style_transform_width, "i", "(lv.lv_obj)i" }, + { "get_style_transform_zoom", (void*) &lv_obj_get_style_transform_zoom, "i", "(lv.lv_obj)i" }, + { "get_style_translate_x", (void*) &lv_obj_get_style_translate_x, "i", "(lv.lv_obj)i" }, + { "get_style_translate_y", (void*) &lv_obj_get_style_translate_y, "i", "(lv.lv_obj)i" }, + { "get_style_width", (void*) &lv_obj_get_style_width, "i", "(lv.lv_obj)i" }, + { "get_style_x", (void*) &lv_obj_get_style_x, "i", "(lv.lv_obj)i" }, + { "get_style_y", (void*) &lv_obj_get_style_y, "i", "(lv.lv_obj)i" }, + { "get_user_data", (void*) &lv_obj_get_user_data, ".", "(lv.lv_obj)" }, + { "get_width", (void*) &lv_obj_get_width, "i", "(lv.lv_obj)" }, + { "get_x", (void*) &lv_obj_get_x, "i", "(lv.lv_obj)" }, + { "get_x2", (void*) &lv_obj_get_x2, "i", "(lv.lv_obj)" }, + { "get_y", (void*) &lv_obj_get_y, "i", "(lv.lv_obj)" }, + { "get_y2", (void*) &lv_obj_get_y2, "i", "(lv.lv_obj)" }, + { "has_class", (void*) &lv_obj_has_class, "b", "(lv.lv_obj)(lv.lv_obj_class)" }, + { "has_flag", (void*) &lv_obj_has_flag, "b", "(lv.lv_obj)i" }, + { "has_flag_any", (void*) &lv_obj_has_flag_any, "b", "(lv.lv_obj)i" }, + { "has_state", (void*) &lv_obj_has_state, "b", "(lv.lv_obj)i" }, + { "hit_test", (void*) &lv_obj_hit_test, "b", "(lv.lv_obj)(lv.lv_point)" }, + { "init_draw_arc_dsc", (void*) &lv_obj_init_draw_arc_dsc, "", "(lv.lv_obj)i(lv.lv_draw_arc_dsc)" }, + { "init_draw_img_dsc", (void*) &lv_obj_init_draw_img_dsc, "", "(lv.lv_obj)i(lv.lv_draw_img_dsc)" }, + { "init_draw_label_dsc", (void*) &lv_obj_init_draw_label_dsc, "", "(lv.lv_obj)i(lv.lv_draw_label_dsc)" }, + { "init_draw_line_dsc", (void*) &lv_obj_init_draw_line_dsc, "", "(lv.lv_obj)i(lv.lv_draw_line_dsc)" }, + { "init_draw_rect_dsc", (void*) &lv_obj_init_draw_rect_dsc, "", "(lv.lv_obj)i(lv.lv_draw_rect_dsc)" }, + { "invalidate", (void*) &lv_obj_invalidate, "", "(lv.lv_obj)" }, + { "invalidate_area", (void*) &lv_obj_invalidate_area, "", "(lv.lv_obj)(lv.lv_area)" }, + { "is_editable", (void*) &lv_obj_is_editable, "b", "(lv.lv_obj)" }, + { "is_group_def", (void*) &lv_obj_is_group_def, "b", "(lv.lv_obj)" }, + { "is_layout_positioned", (void*) &lv_obj_is_layout_positioned, "b", "(lv.lv_obj)" }, + { "is_scrolling", (void*) &lv_obj_is_scrolling, "b", "(lv.lv_obj)" }, + { "is_valid", (void*) &lv_obj_is_valid, "b", "(lv.lv_obj)" }, + { "is_visible", (void*) &lv_obj_is_visible, "b", "(lv.lv_obj)" }, + { "mark_layout_as_dirty", (void*) &lv_obj_mark_layout_as_dirty, "", "(lv.lv_obj)" }, + { "move_background", (void*) &lv_obj_move_background, "", "(lv.lv_obj)" }, + { "move_children_by", (void*) &lv_obj_move_children_by, "", "(lv.lv_obj)iib" }, + { "move_foreground", (void*) &lv_obj_move_foreground, "", "(lv.lv_obj)" }, + { "move_to", (void*) &lv_obj_move_to, "", "(lv.lv_obj)ii" }, + { "readjust_scroll", (void*) &lv_obj_readjust_scroll, "", "(lv.lv_obj)(lv.lv_anim_enable)" }, + { "refr_pos", (void*) &lv_obj_refr_pos, "", "(lv.lv_obj)" }, + { "refr_size", (void*) &lv_obj_refr_size, "b", "(lv.lv_obj)" }, + { "refresh_ext_draw_size", (void*) &lv_obj_refresh_ext_draw_size, "", "(lv.lv_obj)" }, + { "refresh_self_size", (void*) &lv_obj_refresh_self_size, "b", "(lv.lv_obj)" }, + { "refresh_style", (void*) &lv_obj_refresh_style, "", "(lv.lv_obj)i(lv.lv_style_prop)" }, + { "remove_event_cb", (void*) &lv_obj_remove_event_cb, "b", "(lv.lv_obj)^lv_event_cb^" }, + { "remove_event_dsc", (void*) &lv_obj_remove_event_dsc, "b", "(lv.lv_obj)i" }, + { "remove_local_style_prop", (void*) &lv_obj_remove_local_style_prop, "b", "(lv.lv_obj)(lv.lv_style_prop)i" }, + { "remove_style", (void*) &lv_obj_remove_style, "", "(lv.lv_obj)(lv.lv_style)i" }, + { "remove_style_all", (void*) &lv_obj_remove_style_all, "", "(lv.lv_obj)" }, + { "scroll_by", (void*) &lv_obj_scroll_by, "", "(lv.lv_obj)ii(lv.lv_anim_enable)" }, + { "scroll_to", (void*) &lv_obj_scroll_to, "", "(lv.lv_obj)ii(lv.lv_anim_enable)" }, + { "scroll_to_view", (void*) &lv_obj_scroll_to_view, "", "(lv.lv_obj)(lv.lv_anim_enable)" }, + { "scroll_to_view_recursive", (void*) &lv_obj_scroll_to_view_recursive, "", "(lv.lv_obj)(lv.lv_anim_enable)" }, + { "scroll_to_x", (void*) &lv_obj_scroll_to_x, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, + { "scroll_to_y", (void*) &lv_obj_scroll_to_y, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, + { "scrollbar_invalidate", (void*) &lv_obj_scrollbar_invalidate, "", "(lv.lv_obj)" }, + { "set_align", (void*) &lv_obj_set_align, "", "(lv.lv_obj)i" }, + { "set_content_height", (void*) &lv_obj_set_content_height, "", "(lv.lv_obj)i" }, + { "set_content_width", (void*) &lv_obj_set_content_width, "", "(lv.lv_obj)i" }, + { "set_ext_click_area", (void*) &lv_obj_set_ext_click_area, "", "(lv.lv_obj)i" }, + { "set_height", (void*) &lv_obj_set_height, "", "(lv.lv_obj)i" }, + { "set_layout", (void*) &lv_obj_set_layout, "", "(lv.lv_obj)i" }, + { "set_local_style_prop", (void*) &lv_obj_set_local_style_prop, "", "(lv.lv_obj)(lv.lv_style_prop)ii" }, + { "set_parent", (void*) &lv_obj_set_parent, "", "(lv.lv_obj)(lv.lv_obj)" }, + { "set_pos", (void*) &lv_obj_set_pos, "", "(lv.lv_obj)ii" }, + { "set_scroll_dir", (void*) &lv_obj_set_scroll_dir, "", "(lv.lv_obj)i" }, + { "set_scroll_snap_x", (void*) &lv_obj_set_scroll_snap_x, "", "(lv.lv_obj)i" }, + { "set_scroll_snap_y", (void*) &lv_obj_set_scroll_snap_y, "", "(lv.lv_obj)i" }, + { "set_scrollbar_mode", (void*) &lv_obj_set_scrollbar_mode, "", "(lv.lv_obj)i" }, + { "set_size", (void*) &lv_obj_set_size, "", "(lv.lv_obj)ii" }, + { "set_style_align", (void*) &lv_obj_set_style_align, "", "(lv.lv_obj)ii" }, + { "set_style_anim_speed", (void*) &lv_obj_set_style_anim_speed, "", "(lv.lv_obj)ii" }, + { "set_style_anim_time", (void*) &lv_obj_set_style_anim_time, "", "(lv.lv_obj)ii" }, + { "set_style_arc_color", (void*) &lv_obj_set_style_arc_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_arc_color_filtered", (void*) &lv_obj_set_style_arc_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_arc_img_src", (void*) &lv_obj_set_style_arc_img_src, "", "(lv.lv_obj).i" }, + { "set_style_arc_opa", (void*) &lv_obj_set_style_arc_opa, "", "(lv.lv_obj)ii" }, + { "set_style_arc_rounded", (void*) &lv_obj_set_style_arc_rounded, "", "(lv.lv_obj)ii" }, + { "set_style_arc_width", (void*) &lv_obj_set_style_arc_width, "", "(lv.lv_obj)ii" }, + { "set_style_base_dir", (void*) &lv_obj_set_style_base_dir, "", "(lv.lv_obj)ii" }, + { "set_style_bg_color", (void*) &lv_obj_set_style_bg_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_color_filtered", (void*) &lv_obj_set_style_bg_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_grad_color", (void*) &lv_obj_set_style_bg_grad_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_grad_color_filtered", (void*) &lv_obj_set_style_bg_grad_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_grad_dir", (void*) &lv_obj_set_style_bg_grad_dir, "", "(lv.lv_obj)ii" }, + { "set_style_bg_grad_stop", (void*) &lv_obj_set_style_bg_grad_stop, "", "(lv.lv_obj)ii" }, + { "set_style_bg_img_opa", (void*) &lv_obj_set_style_bg_img_opa, "", "(lv.lv_obj)ii" }, + { "set_style_bg_img_recolor", (void*) &lv_obj_set_style_bg_img_recolor, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_img_recolor_filtered", (void*) &lv_obj_set_style_bg_img_recolor_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_bg_img_recolor_opa", (void*) &lv_obj_set_style_bg_img_recolor_opa, "", "(lv.lv_obj)ii" }, + { "set_style_bg_img_src", (void*) &lv_obj_set_style_bg_img_src, "", "(lv.lv_obj).i" }, + { "set_style_bg_img_tiled", (void*) &lv_obj_set_style_bg_img_tiled, "", "(lv.lv_obj)bi" }, + { "set_style_bg_main_stop", (void*) &lv_obj_set_style_bg_main_stop, "", "(lv.lv_obj)ii" }, + { "set_style_bg_opa", (void*) &lv_obj_set_style_bg_opa, "", "(lv.lv_obj)ii" }, + { "set_style_blend_mode", (void*) &lv_obj_set_style_blend_mode, "", "(lv.lv_obj)ii" }, + { "set_style_border_color", (void*) &lv_obj_set_style_border_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_border_color_filtered", (void*) &lv_obj_set_style_border_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_border_opa", (void*) &lv_obj_set_style_border_opa, "", "(lv.lv_obj)ii" }, + { "set_style_border_post", (void*) &lv_obj_set_style_border_post, "", "(lv.lv_obj)bi" }, + { "set_style_border_side", (void*) &lv_obj_set_style_border_side, "", "(lv.lv_obj)ii" }, + { "set_style_border_width", (void*) &lv_obj_set_style_border_width, "", "(lv.lv_obj)ii" }, + { "set_style_clip_corner", (void*) &lv_obj_set_style_clip_corner, "", "(lv.lv_obj)bi" }, + { "set_style_color_filter_dsc", (void*) &lv_obj_set_style_color_filter_dsc, "", "(lv.lv_obj)(lv.lv_color_filter_dsc)i" }, + { "set_style_color_filter_opa", (void*) &lv_obj_set_style_color_filter_opa, "", "(lv.lv_obj)ii" }, + { "set_style_height", (void*) &lv_obj_set_style_height, "", "(lv.lv_obj)ii" }, + { "set_style_img_opa", (void*) &lv_obj_set_style_img_opa, "", "(lv.lv_obj)ii" }, + { "set_style_img_recolor", (void*) &lv_obj_set_style_img_recolor, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_img_recolor_filtered", (void*) &lv_obj_set_style_img_recolor_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_img_recolor_opa", (void*) &lv_obj_set_style_img_recolor_opa, "", "(lv.lv_obj)ii" }, + { "set_style_layout", (void*) &lv_obj_set_style_layout, "", "(lv.lv_obj)ii" }, + { "set_style_line_color", (void*) &lv_obj_set_style_line_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_line_color_filtered", (void*) &lv_obj_set_style_line_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_line_dash_gap", (void*) &lv_obj_set_style_line_dash_gap, "", "(lv.lv_obj)ii" }, + { "set_style_line_dash_width", (void*) &lv_obj_set_style_line_dash_width, "", "(lv.lv_obj)ii" }, + { "set_style_line_opa", (void*) &lv_obj_set_style_line_opa, "", "(lv.lv_obj)ii" }, + { "set_style_line_rounded", (void*) &lv_obj_set_style_line_rounded, "", "(lv.lv_obj)ii" }, + { "set_style_line_width", (void*) &lv_obj_set_style_line_width, "", "(lv.lv_obj)ii" }, + { "set_style_max_height", (void*) &lv_obj_set_style_max_height, "", "(lv.lv_obj)ii" }, + { "set_style_max_width", (void*) &lv_obj_set_style_max_width, "", "(lv.lv_obj)ii" }, + { "set_style_min_height", (void*) &lv_obj_set_style_min_height, "", "(lv.lv_obj)ii" }, + { "set_style_min_width", (void*) &lv_obj_set_style_min_width, "", "(lv.lv_obj)ii" }, + { "set_style_opa", (void*) &lv_obj_set_style_opa, "", "(lv.lv_obj)ii" }, + { "set_style_outline_color", (void*) &lv_obj_set_style_outline_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_outline_color_filtered", (void*) &lv_obj_set_style_outline_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_outline_opa", (void*) &lv_obj_set_style_outline_opa, "", "(lv.lv_obj)ii" }, + { "set_style_outline_pad", (void*) &lv_obj_set_style_outline_pad, "", "(lv.lv_obj)ii" }, + { "set_style_outline_width", (void*) &lv_obj_set_style_outline_width, "", "(lv.lv_obj)ii" }, + { "set_style_pad_all", (void*) &lv_obj_set_style_pad_all, "", "(lv.lv_obj)ii" }, + { "set_style_pad_bottom", (void*) &lv_obj_set_style_pad_bottom, "", "(lv.lv_obj)ii" }, + { "set_style_pad_column", (void*) &lv_obj_set_style_pad_column, "", "(lv.lv_obj)ii" }, + { "set_style_pad_gap", (void*) &lv_obj_set_style_pad_gap, "", "(lv.lv_obj)ii" }, + { "set_style_pad_hor", (void*) &lv_obj_set_style_pad_hor, "", "(lv.lv_obj)ii" }, + { "set_style_pad_left", (void*) &lv_obj_set_style_pad_left, "", "(lv.lv_obj)ii" }, + { "set_style_pad_right", (void*) &lv_obj_set_style_pad_right, "", "(lv.lv_obj)ii" }, + { "set_style_pad_row", (void*) &lv_obj_set_style_pad_row, "", "(lv.lv_obj)ii" }, + { "set_style_pad_top", (void*) &lv_obj_set_style_pad_top, "", "(lv.lv_obj)ii" }, + { "set_style_pad_ver", (void*) &lv_obj_set_style_pad_ver, "", "(lv.lv_obj)ii" }, + { "set_style_radius", (void*) &lv_obj_set_style_radius, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_color", (void*) &lv_obj_set_style_shadow_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_shadow_color_filtered", (void*) &lv_obj_set_style_shadow_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_shadow_ofs_x", (void*) &lv_obj_set_style_shadow_ofs_x, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_ofs_y", (void*) &lv_obj_set_style_shadow_ofs_y, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_opa", (void*) &lv_obj_set_style_shadow_opa, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_spread", (void*) &lv_obj_set_style_shadow_spread, "", "(lv.lv_obj)ii" }, + { "set_style_shadow_width", (void*) &lv_obj_set_style_shadow_width, "", "(lv.lv_obj)ii" }, + { "set_style_size", (void*) &lv_obj_set_style_size, "", "(lv.lv_obj)ii" }, + { "set_style_text_align", (void*) &lv_obj_set_style_text_align, "", "(lv.lv_obj)ii" }, + { "set_style_text_color", (void*) &lv_obj_set_style_text_color, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_text_color_filtered", (void*) &lv_obj_set_style_text_color_filtered, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "set_style_text_decor", (void*) &lv_obj_set_style_text_decor, "", "(lv.lv_obj)ii" }, + { "set_style_text_font", (void*) &lv_obj_set_style_text_font, "", "(lv.lv_obj)(lv.lv_font)i" }, + { "set_style_text_letter_space", (void*) &lv_obj_set_style_text_letter_space, "", "(lv.lv_obj)ii" }, + { "set_style_text_line_space", (void*) &lv_obj_set_style_text_line_space, "", "(lv.lv_obj)ii" }, + { "set_style_text_opa", (void*) &lv_obj_set_style_text_opa, "", "(lv.lv_obj)ii" }, + { "set_style_transform_angle", (void*) &lv_obj_set_style_transform_angle, "", "(lv.lv_obj)ii" }, + { "set_style_transform_height", (void*) &lv_obj_set_style_transform_height, "", "(lv.lv_obj)ii" }, + { "set_style_transform_width", (void*) &lv_obj_set_style_transform_width, "", "(lv.lv_obj)ii" }, + { "set_style_transform_zoom", (void*) &lv_obj_set_style_transform_zoom, "", "(lv.lv_obj)ii" }, + { "set_style_transition", (void*) &lv_obj_set_style_transition, "", "(lv.lv_obj)(lv.lv_style_transition_dsc)i" }, + { "set_style_translate_x", (void*) &lv_obj_set_style_translate_x, "", "(lv.lv_obj)ii" }, + { "set_style_translate_y", (void*) &lv_obj_set_style_translate_y, "", "(lv.lv_obj)ii" }, + { "set_style_width", (void*) &lv_obj_set_style_width, "", "(lv.lv_obj)ii" }, + { "set_style_x", (void*) &lv_obj_set_style_x, "", "(lv.lv_obj)ii" }, + { "set_style_y", (void*) &lv_obj_set_style_y, "", "(lv.lv_obj)ii" }, + { "set_user_data", (void*) &lv_obj_set_user_data, "", "(lv.lv_obj)." }, + { "set_width", (void*) &lv_obj_set_width, "", "(lv.lv_obj)i" }, + { "set_x", (void*) &lv_obj_set_x, "", "(lv.lv_obj)i" }, + { "set_y", (void*) &lv_obj_set_y, "", "(lv.lv_obj)i" }, + { "tree_walk", (void*) &lv_obj_tree_walk, "", "(lv.lv_obj)^lv_obj_tree_walk_cb^." }, + { "update_layout", (void*) &lv_obj_update_layout, "", "(lv.lv_obj)" }, + { "update_snap", (void*) &lv_obj_update_snap, "", "(lv.lv_obj)(lv.lv_anim_enable)" }, +}; + +/* `lv_group` methods */ +const be_ntv_func_def_t lv_group_func[] = { + { "add_obj", (void*) &lv_group_add_obj, "", "(lv.lv_group)(lv.lv_obj)" }, + { "del", (void*) &lv_group_del, "", "(lv.lv_group)" }, + { "focus_freeze", (void*) &lv_group_focus_freeze, "", "(lv.lv_group)b" }, + { "focus_next", (void*) &lv_group_focus_next, "", "(lv.lv_group)" }, + { "focus_obj", (void*) &lv_group_focus_obj, "", "(lv.lv_obj)" }, + { "focus_prev", (void*) &lv_group_focus_prev, "", "(lv.lv_group)" }, + { "get_editing", (void*) &lv_group_get_editing, "b", "(lv.lv_group)" }, + { "get_focus_cb", (void*) &lv_group_get_focus_cb, "lv.lv_group_focus_cb", "(lv.lv_group)" }, + { "get_focused", (void*) &lv_group_get_focused, "lv.lv_obj", "(lv.lv_group)" }, + { "get_obj_count", (void*) &lv_group_get_obj_count, "i", "(lv.lv_group)" }, + { "get_wrap", (void*) &lv_group_get_wrap, "b", "(lv.lv_group)" }, + { "remove_all_objs", (void*) &lv_group_remove_all_objs, "", "(lv.lv_group)" }, + { "remove_obj", (void*) &lv_group_remove_obj, "", "(lv.lv_obj)" }, + { "send_data", (void*) &lv_group_send_data, "i", "(lv.lv_group)i" }, + { "set_default", (void*) &lv_group_set_default, "", "(lv.lv_group)" }, + { "set_editing", (void*) &lv_group_set_editing, "", "(lv.lv_group)b" }, + { "set_focus_cb", (void*) &lv_group_set_focus_cb, "", "(lv.lv_group)^lv_group_focus_cb^" }, + { "set_refocus_policy", (void*) &lv_group_set_refocus_policy, "", "(lv.lv_group)(lv.lv_group_refocus_policy)" }, + { "set_wrap", (void*) &lv_group_set_wrap, "", "(lv.lv_group)b" }, +}; + +/* `lv_indev` methods */ +const be_ntv_func_def_t lv_indev_func[] = { + { "enable", (void*) &lv_indev_enable, "", "(lv.lv_indev)b" }, + { "get_gesture_dir", (void*) &lv_indev_get_gesture_dir, "i", "(lv.lv_indev)" }, + { "get_key", (void*) &lv_indev_get_key, "i", "(lv.lv_indev)" }, + { "get_point", (void*) &lv_indev_get_point, "", "(lv.lv_indev)(lv.lv_point)" }, + { "get_scroll_dir", (void*) &lv_indev_get_scroll_dir, "i", "(lv.lv_indev)" }, + { "get_scroll_obj", (void*) &lv_indev_get_scroll_obj, "lv.lv_obj", "(lv.lv_indev)" }, + { "get_type", (void*) &lv_indev_get_type, "i", "(lv.lv_indev)" }, + { "get_vect", (void*) &lv_indev_get_vect, "", "(lv.lv_indev)(lv.lv_point)" }, + { "reset", (void*) &lv_indev_reset, "", "(lv.lv_indev)(lv.lv_obj)" }, + { "reset_long_press", (void*) &lv_indev_reset_long_press, "", "(lv.lv_indev)" }, + { "search_obj", (void*) &lv_indev_search_obj, "lv.lv_obj", "(lv.lv_obj)(lv.lv_point)" }, + { "set_button_points", (void*) &lv_indev_set_button_points, "", "(lv.lv_indev)i" }, + { "set_cursor", (void*) &lv_indev_set_cursor, "", "(lv.lv_indev)(lv.lv_obj)" }, + { "set_group", (void*) &lv_indev_set_group, "", "(lv.lv_indev)(lv.lv_group)" }, + { "wait_release", (void*) &lv_indev_wait_release, "", "(lv.lv_indev)" }, +}; + +/* `lv_chart` methods */ +#ifdef BE_LV_WIDGET_CHART +const be_ntv_func_def_t lv_chart_func[] = { + { "get_cursor_point", (void*) &lv_chart_get_cursor_point, "i", "(lv.lv_obj)(lv.lv_chart_cursor)" }, + { "get_point_count", (void*) &lv_chart_get_point_count, "i", "(lv.lv_obj)" }, + { "get_point_pos_by_id", (void*) &lv_chart_get_point_pos_by_id, "", "(lv.lv_obj)(lv.lv_chart_series)i(lv.lv_point)" }, + { "get_pressed_point", (void*) &lv_chart_get_pressed_point, "i", "(lv.lv_obj)" }, + { "get_type", (void*) &lv_chart_get_type, "i", "(lv.lv_obj)" }, + { "get_x_start_point", (void*) &lv_chart_get_x_start_point, "i", "(lv.lv_obj)(lv.lv_chart_series)" }, + { "get_zoom_x", (void*) &lv_chart_get_zoom_x, "i", "(lv.lv_obj)" }, + { "get_zoom_y", (void*) &lv_chart_get_zoom_y, "i", "(lv.lv_obj)" }, + { "hide_series", (void*) &lv_chart_hide_series, "", "(lv.lv_obj)(lv.lv_chart_series)b" }, + { "refresh", (void*) &lv_chart_refresh, "", "(lv.lv_obj)" }, + { "remove_series", (void*) &lv_chart_remove_series, "", "(lv.lv_obj)(lv.lv_chart_series)" }, + { "set_all_value", (void*) &lv_chart_set_all_value, "", "(lv.lv_obj)(lv.lv_chart_series)i" }, + { "set_axis_tick", (void*) &lv_chart_set_axis_tick, "", "(lv.lv_obj)iiiiibi" }, + { "set_cursor_point", (void*) &lv_chart_set_cursor_point, "", "(lv.lv_obj)(lv.lv_chart_cursor)(lv.lv_chart_series)i" }, + { "set_cursor_pos", (void*) &lv_chart_set_cursor_pos, "", "(lv.lv_obj)(lv.lv_chart_cursor)(lv.lv_point)" }, + { "set_div_line_count", (void*) &lv_chart_set_div_line_count, "", "(lv.lv_obj)ii" }, + { "set_ext_x_array", (void*) &lv_chart_set_ext_x_array, "", "(lv.lv_obj)(lv.lv_chart_series)i" }, + { "set_ext_y_array", (void*) &lv_chart_set_ext_y_array, "", "(lv.lv_obj)(lv.lv_chart_series)i" }, + { "set_next_value", (void*) &lv_chart_set_next_value, "", "(lv.lv_obj)(lv.lv_chart_series)i" }, + { "set_next_value2", (void*) &lv_chart_set_next_value2, "", "(lv.lv_obj)(lv.lv_chart_series)ii" }, + { "set_point_count", (void*) &lv_chart_set_point_count, "", "(lv.lv_obj)i" }, + { "set_range", (void*) &lv_chart_set_range, "", "(lv.lv_obj)iii" }, + { "set_series_color", (void*) &lv_chart_set_series_color, "", "(lv.lv_obj)(lv.lv_chart_series)(lv.lv_color)" }, + { "set_type", (void*) &lv_chart_set_type, "", "(lv.lv_obj)i" }, + { "set_update_mode", (void*) &lv_chart_set_update_mode, "", "(lv.lv_obj)(lv.lv_chart_update_mode)" }, + { "set_value_by_id", (void*) &lv_chart_set_value_by_id, "", "(lv.lv_obj)(lv.lv_chart_series)ii" }, + { "set_value_by_id2", (void*) &lv_chart_set_value_by_id2, "", "(lv.lv_obj)(lv.lv_chart_series)iii" }, + { "set_x_start_point", (void*) &lv_chart_set_x_start_point, "", "(lv.lv_obj)(lv.lv_chart_series)i" }, + { "set_zoom_x", (void*) &lv_chart_set_zoom_x, "", "(lv.lv_obj)i" }, + { "set_zoom_y", (void*) &lv_chart_set_zoom_y, "", "(lv.lv_obj)i" }, +}; +#endif // BE_LV_WIDGET_CHART + +/* `lv_colorwheel` methods */ +#ifdef BE_LV_WIDGET_COLORWHEEL +const be_ntv_func_def_t lv_colorwheel_func[] = { + { "get_color_mode", (void*) &lv_colorwheel_get_color_mode, "i", "(lv.lv_obj)" }, + { "get_color_mode_fixed", (void*) &lv_colorwheel_get_color_mode_fixed, "b", "(lv.lv_obj)" }, + { "get_hsv", (void*) &lv_colorwheel_get_hsv, "i", "(lv.lv_obj)" }, + { "get_rgb", (void*) &lv_colorwheel_get_rgb, "lv.lv_color", "(lv.lv_obj)" }, + { "set_hsv", (void*) &lv_colorwheel_set_hsv, "b", "(lv.lv_obj)i" }, + { "set_mode", (void*) &lv_colorwheel_set_mode, "", "(lv.lv_obj)i" }, + { "set_mode_fixed", (void*) &lv_colorwheel_set_mode_fixed, "", "(lv.lv_obj)b" }, + { "set_rgb", (void*) &lv_colorwheel_set_rgb, "b", "(lv.lv_obj)(lv.lv_color)" }, +}; +#endif // BE_LV_WIDGET_COLORWHEEL + +/* `lv_imgbtn` methods */ +#ifdef BE_LV_WIDGET_IMGBTN +const be_ntv_func_def_t lv_imgbtn_func[] = { + { "set_src", (void*) &lv_imgbtn_set_src, "", "(lv.lv_obj)(lv.lv_imgbtn_state)..." }, +}; +#endif // BE_LV_WIDGET_IMGBTN + +/* `lv_led` methods */ +#ifdef BE_LV_WIDGET_LED +const be_ntv_func_def_t lv_led_func[] = { + { "get_brightness", (void*) &lv_led_get_brightness, "i", "(lv.lv_obj)" }, + { "off", (void*) &lv_led_off, "", "(lv.lv_obj)" }, + { "on", (void*) &lv_led_on, "", "(lv.lv_obj)" }, + { "set_brightness", (void*) &lv_led_set_brightness, "", "(lv.lv_obj)i" }, + { "set_color", (void*) &lv_led_set_color, "", "(lv.lv_obj)(lv.lv_color)" }, + { "toggle", (void*) &lv_led_toggle, "", "(lv.lv_obj)" }, +}; +#endif // BE_LV_WIDGET_LED + +/* `lv_meter` methods */ +#ifdef BE_LV_WIDGET_METER +const be_ntv_func_def_t lv_meter_func[] = { + { "add_arc", (void*) &lv_meter_add_arc, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale)i(lv.lv_color)i" }, + { "add_needle_img", (void*) &lv_meter_add_needle_img, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale).ii" }, + { "add_needle_line", (void*) &lv_meter_add_needle_line, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale)i(lv.lv_color)i" }, + { "add_scale", (void*) &lv_meter_add_scale, "lv.lv_meter_scale", "(lv.lv_obj)" }, + { "add_scale_lines", (void*) &lv_meter_add_scale_lines, "lv.lv_meter_indicator", "(lv.lv_obj)(lv.lv_meter_scale)(lv.lv_color)(lv.lv_color)bi" }, + { "set_indicator_end_value", (void*) &lv_meter_set_indicator_end_value, "", "(lv.lv_obj)(lv.lv_meter_indicator)i" }, + { "set_indicator_start_value", (void*) &lv_meter_set_indicator_start_value, "", "(lv.lv_obj)(lv.lv_meter_indicator)i" }, + { "set_indicator_value", (void*) &lv_meter_set_indicator_value, "", "(lv.lv_obj)(lv.lv_meter_indicator)i" }, + { "set_scale_major_ticks", (void*) &lv_meter_set_scale_major_ticks, "", "(lv.lv_obj)(lv.lv_meter_scale)iii(lv.lv_color)i" }, + { "set_scale_range", (void*) &lv_meter_set_scale_range, "", "(lv.lv_obj)(lv.lv_meter_scale)iiii" }, + { "set_scale_ticks", (void*) &lv_meter_set_scale_ticks, "", "(lv.lv_obj)(lv.lv_meter_scale)iii(lv.lv_color)" }, +}; +#endif // BE_LV_WIDGET_METER + +/* `lv_msgbox` methods */ +#ifdef BE_LV_WIDGET_MSGBOX +const be_ntv_func_def_t lv_msgbox_func[] = { + { "close", (void*) &lv_msgbox_close, "", "(lv.lv_obj)" }, + { "get_active_btn_text", (void*) &lv_msgbox_get_active_btn_text, "s", "(lv.lv_obj)" }, + { "get_btns", (void*) &lv_msgbox_get_btns, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_close_btn", (void*) &lv_msgbox_get_close_btn, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_text", (void*) &lv_msgbox_get_text, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_title", (void*) &lv_msgbox_get_title, "lv.lv_obj", "(lv.lv_obj)" }, +}; +#endif // BE_LV_WIDGET_MSGBOX + +/* `lv_spinbox` methods */ +#ifdef BE_LV_WIDGET_SPINBOX +const be_ntv_func_def_t lv_spinbox_func[] = { + { "decrement", (void*) &lv_spinbox_decrement, "", "(lv.lv_obj)" }, + { "get_rollover", (void*) &lv_spinbox_get_rollover, "b", "(lv.lv_obj)" }, + { "get_step", (void*) &lv_spinbox_get_step, "i", "(lv.lv_obj)" }, + { "get_value", (void*) &lv_spinbox_get_value, "i", "(lv.lv_obj)" }, + { "increment", (void*) &lv_spinbox_increment, "", "(lv.lv_obj)" }, + { "set_digit_format", (void*) &lv_spinbox_set_digit_format, "", "(lv.lv_obj)ii" }, + { "set_range", (void*) &lv_spinbox_set_range, "", "(lv.lv_obj)ii" }, + { "set_rollover", (void*) &lv_spinbox_set_rollover, "", "(lv.lv_obj)b" }, + { "set_step", (void*) &lv_spinbox_set_step, "", "(lv.lv_obj)i" }, + { "set_value", (void*) &lv_spinbox_set_value, "", "(lv.lv_obj)i" }, + { "step_next", (void*) &lv_spinbox_step_next, "", "(lv.lv_obj)" }, + { "step_prev", (void*) &lv_spinbox_step_prev, "", "(lv.lv_obj)" }, +}; +#endif // BE_LV_WIDGET_SPINBOX + +/* `lv_spinner` methods */ +#ifdef BE_LV_WIDGET_SPINNER +const be_ntv_func_def_t lv_spinner_func[] = { +}; +#endif // BE_LV_WIDGET_SPINNER + +/* `lv_arc` methods */ +#ifdef BE_LV_WIDGET_ARC +const be_ntv_func_def_t lv_arc_func[] = { + { "get_angle_end", (void*) &lv_arc_get_angle_end, "i", "(lv.lv_obj)" }, + { "get_angle_start", (void*) &lv_arc_get_angle_start, "i", "(lv.lv_obj)" }, + { "get_bg_angle_end", (void*) &lv_arc_get_bg_angle_end, "i", "(lv.lv_obj)" }, + { "get_bg_angle_start", (void*) &lv_arc_get_bg_angle_start, "i", "(lv.lv_obj)" }, + { "get_max_value", (void*) &lv_arc_get_max_value, "i", "(lv.lv_obj)" }, + { "get_min_value", (void*) &lv_arc_get_min_value, "i", "(lv.lv_obj)" }, + { "get_mode", (void*) &lv_arc_get_mode, "i", "(lv.lv_obj)" }, + { "get_value", (void*) &lv_arc_get_value, "i", "(lv.lv_obj)" }, + { "set_angles", (void*) &lv_arc_set_angles, "", "(lv.lv_obj)ii" }, + { "set_bg_angles", (void*) &lv_arc_set_bg_angles, "", "(lv.lv_obj)ii" }, + { "set_bg_end_angle", (void*) &lv_arc_set_bg_end_angle, "", "(lv.lv_obj)i" }, + { "set_bg_start_angle", (void*) &lv_arc_set_bg_start_angle, "", "(lv.lv_obj)i" }, + { "set_change_rate", (void*) &lv_arc_set_change_rate, "", "(lv.lv_obj)i" }, + { "set_end_angle", (void*) &lv_arc_set_end_angle, "", "(lv.lv_obj)i" }, + { "set_mode", (void*) &lv_arc_set_mode, "", "(lv.lv_obj)i" }, + { "set_range", (void*) &lv_arc_set_range, "", "(lv.lv_obj)ii" }, + { "set_rotation", (void*) &lv_arc_set_rotation, "", "(lv.lv_obj)i" }, + { "set_start_angle", (void*) &lv_arc_set_start_angle, "", "(lv.lv_obj)i" }, + { "set_value", (void*) &lv_arc_set_value, "", "(lv.lv_obj)i" }, +}; +#endif // BE_LV_WIDGET_ARC + +/* `lv_bar` methods */ +#ifdef BE_LV_WIDGET_BAR +const be_ntv_func_def_t lv_bar_func[] = { + { "get_max_value", (void*) &lv_bar_get_max_value, "i", "(lv.lv_obj)" }, + { "get_min_value", (void*) &lv_bar_get_min_value, "i", "(lv.lv_obj)" }, + { "get_mode", (void*) &lv_bar_get_mode, "i", "(lv.lv_obj)" }, + { "get_start_value", (void*) &lv_bar_get_start_value, "i", "(lv.lv_obj)" }, + { "get_value", (void*) &lv_bar_get_value, "i", "(lv.lv_obj)" }, + { "set_mode", (void*) &lv_bar_set_mode, "", "(lv.lv_obj)i" }, + { "set_range", (void*) &lv_bar_set_range, "", "(lv.lv_obj)ii" }, + { "set_start_value", (void*) &lv_bar_set_start_value, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, + { "set_value", (void*) &lv_bar_set_value, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, +}; +#endif // BE_LV_WIDGET_BAR + +/* `lv_btn` methods */ +#ifdef BE_LV_WIDGET_BTN +const be_ntv_func_def_t lv_btn_func[] = { +}; +#endif // BE_LV_WIDGET_BTN + +/* `lv_btnmatrix` methods */ +#ifdef BE_LV_WIDGET_BTNMATRIX +const be_ntv_func_def_t lv_btnmatrix_func[] = { + { "clear_btn_ctrl", (void*) &lv_btnmatrix_clear_btn_ctrl, "", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" }, + { "clear_btn_ctrl_all", (void*) &lv_btnmatrix_clear_btn_ctrl_all, "", "(lv.lv_obj)(lv.lv_btnmatrix_ctrl)" }, + { "get_btn_text", (void*) &lv_btnmatrix_get_btn_text, "s", "(lv.lv_obj)i" }, + { "get_one_checked", (void*) &lv_btnmatrix_get_one_checked, "b", "(lv.lv_obj)" }, + { "get_selected_btn", (void*) &lv_btnmatrix_get_selected_btn, "i", "(lv.lv_obj)" }, + { "has_btn_ctrl", (void*) &lv_btnmatrix_has_btn_ctrl, "b", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" }, + { "set_btn_ctrl", (void*) &lv_btnmatrix_set_btn_ctrl, "", "(lv.lv_obj)i(lv.lv_btnmatrix_ctrl)" }, + { "set_btn_ctrl_all", (void*) &lv_btnmatrix_set_btn_ctrl_all, "", "(lv.lv_obj)(lv.lv_btnmatrix_ctrl)" }, + { "set_btn_width", (void*) &lv_btnmatrix_set_btn_width, "", "(lv.lv_obj)ii" }, + { "set_ctrl_map", (void*) &lv_btnmatrix_set_ctrl_map, "", "(lv.lv_obj)(lv.lv_btnmatrix_ctrl)" }, + { "set_map", (void*) &lv_btnmatrix_set_map, "", "(lv.lv_obj)s" }, + { "set_one_checked", (void*) &lv_btnmatrix_set_one_checked, "", "(lv.lv_obj)b" }, + { "set_selected_btn", (void*) &lv_btnmatrix_set_selected_btn, "", "(lv.lv_obj)i" }, +}; +#endif // BE_LV_WIDGET_BTNMATRIX + +/* `lv_canvas` methods */ +#ifdef BE_LV_WIDGET_CANVAS +const be_ntv_func_def_t lv_canvas_func[] = { + { "blur_hor", (void*) &lv_canvas_blur_hor, "", "(lv.lv_obj)(lv.lv_area)i" }, + { "blur_ver", (void*) &lv_canvas_blur_ver, "", "(lv.lv_obj)(lv.lv_area)i" }, + { "copy_buf", (void*) &lv_canvas_copy_buf, "", "(lv.lv_obj).iiii" }, + { "draw_arc", (void*) &lv_canvas_draw_arc, "", "(lv.lv_obj)iiiii(lv.lv_draw_arc_dsc)" }, + { "draw_img", (void*) &lv_canvas_draw_img, "", "(lv.lv_obj)ii.(lv.lv_draw_img_dsc)" }, + { "draw_line", (void*) &lv_canvas_draw_line, "", "(lv.lv_obj)ii(lv.lv_draw_line_dsc)" }, + { "draw_polygon", (void*) &lv_canvas_draw_polygon, "", "(lv.lv_obj)ii(lv.lv_draw_rect_dsc)" }, + { "draw_rect", (void*) &lv_canvas_draw_rect, "", "(lv.lv_obj)iiii(lv.lv_draw_rect_dsc)" }, + { "draw_text", (void*) &lv_canvas_draw_text, "", "(lv.lv_obj)iii(lv.lv_draw_label_dsc)s" }, + { "fill_bg", (void*) &lv_canvas_fill_bg, "", "(lv.lv_obj)(lv.lv_color)i" }, + { "get_px", (void*) &lv_canvas_get_px, "lv.lv_color", "(lv.lv_obj)ii" }, + { "set_buffer", (void*) &lv_canvas_set_buffer, "", "(lv.lv_obj).iii" }, + { "set_palette", (void*) &lv_canvas_set_palette, "", "(lv.lv_obj)i(lv.lv_color)" }, + { "set_px", (void*) &lv_canvas_set_px, "", "(lv.lv_obj)ii(lv.lv_color)" }, + { "transform", (void*) &lv_canvas_transform, "", "(lv.lv_obj)(lv.lv_img_dsc)iiiiiib" }, +}; +#endif // BE_LV_WIDGET_CANVAS + +/* `lv_checkbox` methods */ +#ifdef BE_LV_WIDGET_CHECKBOX +const be_ntv_func_def_t lv_checkbox_func[] = { + { "get_text", (void*) &lv_checkbox_get_text, "s", "(lv.lv_obj)" }, + { "set_text", (void*) &lv_checkbox_set_text, "", "(lv.lv_obj)s" }, + { "set_text_static", (void*) &lv_checkbox_set_text_static, "", "(lv.lv_obj)s" }, +}; +#endif // BE_LV_WIDGET_CHECKBOX + +/* `lv_dropdown` methods */ +#ifdef BE_LV_WIDGET_DROPDOWN +const be_ntv_func_def_t lv_dropdown_func[] = { + { "add_option", (void*) &lv_dropdown_add_option, "", "(lv.lv_obj)si" }, + { "clear_options", (void*) &lv_dropdown_clear_options, "", "(lv.lv_obj)" }, + { "close", (void*) &lv_dropdown_close, "", "(lv.lv_obj)" }, + { "get_dir", (void*) &lv_dropdown_get_dir, "i", "(lv.lv_obj)" }, + { "get_list", (void*) &lv_dropdown_get_list, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_option_cnt", (void*) &lv_dropdown_get_option_cnt, "i", "(lv.lv_obj)" }, + { "get_options", (void*) &lv_dropdown_get_options, "s", "(lv.lv_obj)" }, + { "get_selected", (void*) &lv_dropdown_get_selected, "i", "(lv.lv_obj)" }, + { "get_selected_highlight", (void*) &lv_dropdown_get_selected_highlight, "b", "(lv.lv_obj)" }, + { "get_selected_str", (void*) &lv_dropdown_get_selected_str, "", "(lv.lv_obj)si" }, + { "get_symbol", (void*) &lv_dropdown_get_symbol, "s", "(lv.lv_obj)" }, + { "get_text", (void*) &lv_dropdown_get_text, "s", "(lv.lv_obj)" }, + { "open", (void*) &lv_dropdown_open, "", "(lv.lv_obj)" }, + { "set_dir", (void*) &lv_dropdown_set_dir, "", "(lv.lv_obj)i" }, + { "set_options", (void*) &lv_dropdown_set_options, "", "(lv.lv_obj)s" }, + { "set_options_static", (void*) &lv_dropdown_set_options_static, "", "(lv.lv_obj)s" }, + { "set_selected", (void*) &lv_dropdown_set_selected, "", "(lv.lv_obj)i" }, + { "set_selected_highlight", (void*) &lv_dropdown_set_selected_highlight, "", "(lv.lv_obj)b" }, + { "set_symbol", (void*) &lv_dropdown_set_symbol, "", "(lv.lv_obj)." }, + { "set_text", (void*) &lv_dropdown_set_text, "", "(lv.lv_obj)s" }, +}; +#endif // BE_LV_WIDGET_DROPDOWN + +/* `lv_label` methods */ +#ifdef BE_LV_WIDGET_LABEL +const be_ntv_func_def_t lv_label_func[] = { + { "cut_text", (void*) &lv_label_cut_text, "", "(lv.lv_obj)ii" }, + { "get_letter_on", (void*) &lv_label_get_letter_on, "i", "(lv.lv_obj)(lv.lv_point)" }, + { "get_letter_pos", (void*) &lv_label_get_letter_pos, "", "(lv.lv_obj)i(lv.lv_point)" }, + { "get_long_mode", (void*) &lv_label_get_long_mode, "i", "(lv.lv_obj)" }, + { "get_recolor", (void*) &lv_label_get_recolor, "b", "(lv.lv_obj)" }, + { "get_text", (void*) &lv_label_get_text, "s", "(lv.lv_obj)" }, + { "get_text_selection_end", (void*) &lv_label_get_text_selection_end, "i", "(lv.lv_obj)" }, + { "get_text_selection_start", (void*) &lv_label_get_text_selection_start, "i", "(lv.lv_obj)" }, + { "ins_text", (void*) &lv_label_ins_text, "", "(lv.lv_obj)is" }, + { "is_char_under_pos", (void*) &lv_label_is_char_under_pos, "b", "(lv.lv_obj)(lv.lv_point)" }, + { "set_long_mode", (void*) &lv_label_set_long_mode, "", "(lv.lv_obj)i" }, + { "set_recolor", (void*) &lv_label_set_recolor, "", "(lv.lv_obj)b" }, + { "set_text", (void*) &lv_label_set_text, "", "(lv.lv_obj)s" }, + { "set_text_fmt", (void*) &lv_label_set_text_fmt, "", "(lv.lv_obj)s" }, + { "set_text_sel_end", (void*) &lv_label_set_text_sel_end, "", "(lv.lv_obj)i" }, + { "set_text_sel_start", (void*) &lv_label_set_text_sel_start, "", "(lv.lv_obj)i" }, + { "set_text_static", (void*) &lv_label_set_text_static, "", "(lv.lv_obj)s" }, +}; +#endif // BE_LV_WIDGET_LABEL + +/* `lv_line` methods */ +#ifdef BE_LV_WIDGET_LINE +const be_ntv_func_def_t lv_line_func[] = { + { "get_y_invert", (void*) &lv_line_get_y_invert, "b", "(lv.lv_obj)" }, + { "set_points", (void*) &lv_line_set_points, "", "(lv.lv_obj)ii" }, + { "set_y_invert", (void*) &lv_line_set_y_invert, "", "(lv.lv_obj)b" }, +}; +#endif // BE_LV_WIDGET_LINE + +/* `lv_roller` methods */ +#ifdef BE_LV_WIDGET_ROLLER +const be_ntv_func_def_t lv_roller_func[] = { + { "get_option_cnt", (void*) &lv_roller_get_option_cnt, "i", "(lv.lv_obj)" }, + { "get_options", (void*) &lv_roller_get_options, "s", "(lv.lv_obj)" }, + { "get_selected", (void*) &lv_roller_get_selected, "i", "(lv.lv_obj)" }, + { "get_selected_str", (void*) &lv_roller_get_selected_str, "", "(lv.lv_obj)si" }, + { "set_options", (void*) &lv_roller_set_options, "", "(lv.lv_obj)s(lv.lv_roller_mode)" }, + { "set_selected", (void*) &lv_roller_set_selected, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, + { "set_visible_row_count", (void*) &lv_roller_set_visible_row_count, "", "(lv.lv_obj)i" }, +}; +#endif // BE_LV_WIDGET_ROLLER + +/* `lv_slider` methods */ +#ifdef BE_LV_WIDGET_SLIDER +const be_ntv_func_def_t lv_slider_func[] = { + { "get_left_value", (void*) &lv_slider_get_left_value, "i", "(lv.lv_obj)" }, + { "get_max_value", (void*) &lv_slider_get_max_value, "i", "(lv.lv_obj)" }, + { "get_min_value", (void*) &lv_slider_get_min_value, "i", "(lv.lv_obj)" }, + { "get_mode", (void*) &lv_slider_get_mode, "i", "(lv.lv_obj)" }, + { "get_value", (void*) &lv_slider_get_value, "i", "(lv.lv_obj)" }, + { "is_dragged", (void*) &lv_slider_is_dragged, "b", "(lv.lv_obj)" }, + { "set_left_value", (void*) &lv_slider_set_left_value, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, + { "set_mode", (void*) &lv_slider_set_mode, "", "(lv.lv_obj)i" }, + { "set_range", (void*) &lv_slider_set_range, "", "(lv.lv_obj)ii" }, + { "set_value", (void*) &lv_slider_set_value, "", "(lv.lv_obj)i(lv.lv_anim_enable)" }, +}; +#endif // BE_LV_WIDGET_SLIDER + +/* `lv_switch` methods */ +#ifdef BE_LV_WIDGET_SWITCH +const be_ntv_func_def_t lv_switch_func[] = { +}; +#endif // BE_LV_WIDGET_SWITCH + +/* `lv_table` methods */ +#ifdef BE_LV_WIDGET_TABLE +const be_ntv_func_def_t lv_table_func[] = { + { "add_cell_ctrl", (void*) &lv_table_add_cell_ctrl, "", "(lv.lv_obj)ii(lv.lv_table_cell_ctrl)" }, + { "clear_cell_ctrl", (void*) &lv_table_clear_cell_ctrl, "", "(lv.lv_obj)ii(lv.lv_table_cell_ctrl)" }, + { "get_cell_value", (void*) &lv_table_get_cell_value, "s", "(lv.lv_obj)ii" }, + { "get_col_cnt", (void*) &lv_table_get_col_cnt, "i", "(lv.lv_obj)" }, + { "get_col_width", (void*) &lv_table_get_col_width, "i", "(lv.lv_obj)i" }, + { "get_row_cnt", (void*) &lv_table_get_row_cnt, "i", "(lv.lv_obj)" }, + { "get_selected_cell", (void*) &lv_table_get_selected_cell, "", "(lv.lv_obj)(lv.uint16)(lv.uint16)" }, + { "has_cell_ctrl", (void*) &lv_table_has_cell_ctrl, "b", "(lv.lv_obj)ii(lv.lv_table_cell_ctrl)" }, + { "set_cell_value", (void*) &lv_table_set_cell_value, "", "(lv.lv_obj)iis" }, + { "set_cell_value_fmt", (void*) &lv_table_set_cell_value_fmt, "", "(lv.lv_obj)iis" }, + { "set_col_cnt", (void*) &lv_table_set_col_cnt, "", "(lv.lv_obj)i" }, + { "set_col_width", (void*) &lv_table_set_col_width, "", "(lv.lv_obj)ii" }, + { "set_row_cnt", (void*) &lv_table_set_row_cnt, "", "(lv.lv_obj)i" }, +}; +#endif // BE_LV_WIDGET_TABLE + +/* `lv_textarea` methods */ +#ifdef BE_LV_WIDGET_TEXTAREA +const be_ntv_func_def_t lv_textarea_func[] = { + { "add_char", (void*) &lv_textarea_add_char, "", "(lv.lv_obj)i" }, + { "add_text", (void*) &lv_textarea_add_text, "", "(lv.lv_obj)s" }, + { "clear_selection", (void*) &lv_textarea_clear_selection, "", "(lv.lv_obj)" }, + { "cursor_down", (void*) &lv_textarea_cursor_down, "", "(lv.lv_obj)" }, + { "cursor_left", (void*) &lv_textarea_cursor_left, "", "(lv.lv_obj)" }, + { "cursor_right", (void*) &lv_textarea_cursor_right, "", "(lv.lv_obj)" }, + { "cursor_up", (void*) &lv_textarea_cursor_up, "", "(lv.lv_obj)" }, + { "del_char", (void*) &lv_textarea_del_char, "", "(lv.lv_obj)" }, + { "del_char_forward", (void*) &lv_textarea_del_char_forward, "", "(lv.lv_obj)" }, + { "get_accepted_chars", (void*) &lv_textarea_get_accepted_chars, "s", "(lv.lv_obj)" }, + { "get_cursor_click_pos", (void*) &lv_textarea_get_cursor_click_pos, "b", "(lv.lv_obj)" }, + { "get_cursor_pos", (void*) &lv_textarea_get_cursor_pos, "i", "(lv.lv_obj)" }, + { "get_label", (void*) &lv_textarea_get_label, "lv.lv_obj", "(lv.lv_obj)" }, + { "get_max_length", (void*) &lv_textarea_get_max_length, "i", "(lv.lv_obj)" }, + { "get_one_line", (void*) &lv_textarea_get_one_line, "b", "(lv.lv_obj)" }, + { "get_password_mode", (void*) &lv_textarea_get_password_mode, "b", "(lv.lv_obj)" }, + { "get_password_show_time", (void*) &lv_textarea_get_password_show_time, "i", "(lv.lv_obj)" }, + { "get_placeholder_text", (void*) &lv_textarea_get_placeholder_text, "s", "(lv.lv_obj)" }, + { "get_text", (void*) &lv_textarea_get_text, "s", "(lv.lv_obj)" }, + { "get_text_selection", (void*) &lv_textarea_get_text_selection, "b", "(lv.lv_obj)" }, + { "set_accepted_chars", (void*) &lv_textarea_set_accepted_chars, "", "(lv.lv_obj)s" }, + { "set_align", (void*) &lv_textarea_set_align, "", "(lv.lv_obj)i" }, + { "set_cursor_click_pos", (void*) &lv_textarea_set_cursor_click_pos, "", "(lv.lv_obj)b" }, + { "set_cursor_pos", (void*) &lv_textarea_set_cursor_pos, "", "(lv.lv_obj)i" }, + { "set_insert_replace", (void*) &lv_textarea_set_insert_replace, "", "(lv.lv_obj)s" }, + { "set_max_length", (void*) &lv_textarea_set_max_length, "", "(lv.lv_obj)i" }, + { "set_one_line", (void*) &lv_textarea_set_one_line, "", "(lv.lv_obj)b" }, + { "set_password_mode", (void*) &lv_textarea_set_password_mode, "", "(lv.lv_obj)b" }, + { "set_password_show_time", (void*) &lv_textarea_set_password_show_time, "", "(lv.lv_obj)i" }, + { "set_placeholder_text", (void*) &lv_textarea_set_placeholder_text, "", "(lv.lv_obj)s" }, + { "set_text", (void*) &lv_textarea_set_text, "", "(lv.lv_obj)s" }, + { "set_text_selection", (void*) &lv_textarea_set_text_selection, "", "(lv.lv_obj)b" }, + { "text_is_selected", (void*) &lv_textarea_text_is_selected, "b", "(lv.lv_obj)" }, +}; +#endif // BE_LV_WIDGET_TEXTAREA + +extern const bclass be_class_lv_arc; +extern const bclass be_class_lv_bar; +extern const bclass be_class_lv_btn; +extern const bclass be_class_lv_btnmatrix; +extern const bclass be_class_lv_canvas; +extern const bclass be_class_lv_chart; +extern const bclass be_class_lv_checkbox; +extern const bclass be_class_lv_color; +extern const bclass be_class_lv_colorwheel; +extern const bclass be_class_lv_disp; +extern const bclass be_class_lv_dropdown; +extern const bclass be_class_lv_font; +extern const bclass be_class_lv_group; +extern const bclass be_class_lv_img; +extern const bclass be_class_lv_imgbtn; +extern const bclass be_class_lv_indev; +extern const bclass be_class_lv_label; +extern const bclass be_class_lv_led; +extern const bclass be_class_lv_line; +extern const bclass be_class_lv_meter; +extern const bclass be_class_lv_msgbox; +extern const bclass be_class_lv_obj; +extern const bclass be_class_lv_roller; +extern const bclass be_class_lv_slider; +extern const bclass be_class_lv_spinbox; +extern const bclass be_class_lv_spinner; +extern const bclass be_class_lv_style; +extern const bclass be_class_lv_switch; +extern const bclass be_class_lv_table; +extern const bclass be_class_lv_textarea; +extern const bclass be_class_lv_theme; + + +// map of clases +const be_ntv_class_def_t lv_classes[] = { +#ifdef BE_LV_WIDGET_ARC + { "lv_arc", &be_class_lv_arc, lv_arc_func, sizeof(lv_arc_func) / sizeof(lv_arc_func[0]) }, +#endif // BE_LV_WIDGET_ARC +#ifdef BE_LV_WIDGET_BAR + { "lv_bar", &be_class_lv_bar, lv_bar_func, sizeof(lv_bar_func) / sizeof(lv_bar_func[0]) }, +#endif // BE_LV_WIDGET_BAR +#ifdef BE_LV_WIDGET_BTN + { "lv_btn", &be_class_lv_btn, lv_btn_func, sizeof(lv_btn_func) / sizeof(lv_btn_func[0]) }, +#endif // BE_LV_WIDGET_BTN +#ifdef BE_LV_WIDGET_BTNMATRIX + { "lv_btnmatrix", &be_class_lv_btnmatrix, lv_btnmatrix_func, sizeof(lv_btnmatrix_func) / sizeof(lv_btnmatrix_func[0]) }, +#endif // BE_LV_WIDGET_BTNMATRIX +#ifdef BE_LV_WIDGET_CANVAS + { "lv_canvas", &be_class_lv_canvas, lv_canvas_func, sizeof(lv_canvas_func) / sizeof(lv_canvas_func[0]) }, +#endif // BE_LV_WIDGET_CANVAS +#ifdef BE_LV_WIDGET_CHART + { "lv_chart", &be_class_lv_chart, lv_chart_func, sizeof(lv_chart_func) / sizeof(lv_chart_func[0]) }, +#endif // BE_LV_WIDGET_CHART +#ifdef BE_LV_WIDGET_CHECKBOX + { "lv_checkbox", &be_class_lv_checkbox, lv_checkbox_func, sizeof(lv_checkbox_func) / sizeof(lv_checkbox_func[0]) }, +#endif // BE_LV_WIDGET_CHECKBOX + { "lv_color", &be_class_lv_color, lv_color_func, sizeof(lv_color_func) / sizeof(lv_color_func[0]) }, +#ifdef BE_LV_WIDGET_COLORWHEEL + { "lv_colorwheel", &be_class_lv_colorwheel, lv_colorwheel_func, sizeof(lv_colorwheel_func) / sizeof(lv_colorwheel_func[0]) }, +#endif // BE_LV_WIDGET_COLORWHEEL + { "lv_disp", &be_class_lv_disp, lv_disp_func, sizeof(lv_disp_func) / sizeof(lv_disp_func[0]) }, +#ifdef BE_LV_WIDGET_DROPDOWN + { "lv_dropdown", &be_class_lv_dropdown, lv_dropdown_func, sizeof(lv_dropdown_func) / sizeof(lv_dropdown_func[0]) }, +#endif // BE_LV_WIDGET_DROPDOWN + { "lv_font", &be_class_lv_font, lv_font_func, sizeof(lv_font_func) / sizeof(lv_font_func[0]) }, + { "lv_group", &be_class_lv_group, lv_group_func, sizeof(lv_group_func) / sizeof(lv_group_func[0]) }, +#ifdef BE_LV_WIDGET_IMG + { "lv_img", &be_class_lv_img, lv_img_func, sizeof(lv_img_func) / sizeof(lv_img_func[0]) }, +#endif // BE_LV_WIDGET_IMG +#ifdef BE_LV_WIDGET_IMGBTN + { "lv_imgbtn", &be_class_lv_imgbtn, lv_imgbtn_func, sizeof(lv_imgbtn_func) / sizeof(lv_imgbtn_func[0]) }, +#endif // BE_LV_WIDGET_IMGBTN + { "lv_indev", &be_class_lv_indev, lv_indev_func, sizeof(lv_indev_func) / sizeof(lv_indev_func[0]) }, +#ifdef BE_LV_WIDGET_LABEL + { "lv_label", &be_class_lv_label, lv_label_func, sizeof(lv_label_func) / sizeof(lv_label_func[0]) }, +#endif // BE_LV_WIDGET_LABEL +#ifdef BE_LV_WIDGET_LED + { "lv_led", &be_class_lv_led, lv_led_func, sizeof(lv_led_func) / sizeof(lv_led_func[0]) }, +#endif // BE_LV_WIDGET_LED +#ifdef BE_LV_WIDGET_LINE + { "lv_line", &be_class_lv_line, lv_line_func, sizeof(lv_line_func) / sizeof(lv_line_func[0]) }, +#endif // BE_LV_WIDGET_LINE +#ifdef BE_LV_WIDGET_METER + { "lv_meter", &be_class_lv_meter, lv_meter_func, sizeof(lv_meter_func) / sizeof(lv_meter_func[0]) }, +#endif // BE_LV_WIDGET_METER +#ifdef BE_LV_WIDGET_MSGBOX + { "lv_msgbox", &be_class_lv_msgbox, lv_msgbox_func, sizeof(lv_msgbox_func) / sizeof(lv_msgbox_func[0]) }, +#endif // BE_LV_WIDGET_MSGBOX + { "lv_obj", &be_class_lv_obj, lv_obj_func, sizeof(lv_obj_func) / sizeof(lv_obj_func[0]) }, +#ifdef BE_LV_WIDGET_ROLLER + { "lv_roller", &be_class_lv_roller, lv_roller_func, sizeof(lv_roller_func) / sizeof(lv_roller_func[0]) }, +#endif // BE_LV_WIDGET_ROLLER +#ifdef BE_LV_WIDGET_SLIDER + { "lv_slider", &be_class_lv_slider, lv_slider_func, sizeof(lv_slider_func) / sizeof(lv_slider_func[0]) }, +#endif // BE_LV_WIDGET_SLIDER +#ifdef BE_LV_WIDGET_SPINBOX + { "lv_spinbox", &be_class_lv_spinbox, lv_spinbox_func, sizeof(lv_spinbox_func) / sizeof(lv_spinbox_func[0]) }, +#endif // BE_LV_WIDGET_SPINBOX +#ifdef BE_LV_WIDGET_SPINNER + { "lv_spinner", &be_class_lv_spinner, lv_spinner_func, sizeof(lv_spinner_func) / sizeof(lv_spinner_func[0]) }, +#endif // BE_LV_WIDGET_SPINNER + { "lv_style", &be_class_lv_style, lv_style_func, sizeof(lv_style_func) / sizeof(lv_style_func[0]) }, +#ifdef BE_LV_WIDGET_SWITCH + { "lv_switch", &be_class_lv_switch, lv_switch_func, sizeof(lv_switch_func) / sizeof(lv_switch_func[0]) }, +#endif // BE_LV_WIDGET_SWITCH +#ifdef BE_LV_WIDGET_TABLE + { "lv_table", &be_class_lv_table, lv_table_func, sizeof(lv_table_func) / sizeof(lv_table_func[0]) }, +#endif // BE_LV_WIDGET_TABLE +#ifdef BE_LV_WIDGET_TEXTAREA + { "lv_textarea", &be_class_lv_textarea, lv_textarea_func, sizeof(lv_textarea_func) / sizeof(lv_textarea_func[0]) }, +#endif // BE_LV_WIDGET_TEXTAREA + { "lv_theme", &be_class_lv_theme, lv_theme_func, sizeof(lv_theme_func) / sizeof(lv_theme_func[0]) }, +}; +const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]); + + /* `lv_style` methods */ + /* `lv_font` methods */ + /* `lv_color` methods */ + /* `lv_theme` methods */ + /* `lv_img` methods */ +#ifdef BE_LV_WIDGET_IMG + int be_ntv_lv_img_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_img_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_IMG + /* `lv_disp` methods */ + /* `lv_obj` methods */ + int be_ntv_lv_obj_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_obj_create, "+_p", "(lv.lv_obj)"); } + /* `lv_group` methods */ + int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+_p", ""); } + /* `lv_indev` methods */ + /* `lv_chart` methods */ +#ifdef BE_LV_WIDGET_CHART + int be_ntv_lv_chart_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_chart_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_CHART + /* `lv_colorwheel` methods */ +#ifdef BE_LV_WIDGET_COLORWHEEL + int be_ntv_lv_colorwheel_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_colorwheel_create, "+_p", "(lv.lv_obj)b"); } +#endif // BE_LV_WIDGET_COLORWHEEL + /* `lv_imgbtn` methods */ +#ifdef BE_LV_WIDGET_IMGBTN + int be_ntv_lv_imgbtn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_imgbtn_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_IMGBTN + /* `lv_led` methods */ +#ifdef BE_LV_WIDGET_LED + int be_ntv_lv_led_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_led_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_LED + /* `lv_meter` methods */ +#ifdef BE_LV_WIDGET_METER + int be_ntv_lv_meter_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_meter_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_METER + /* `lv_msgbox` methods */ +#ifdef BE_LV_WIDGET_MSGBOX + int be_ntv_lv_msgbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_msgbox_create, "+_p", "(lv.lv_obj)sssb"); } +#endif // BE_LV_WIDGET_MSGBOX + /* `lv_spinbox` methods */ +#ifdef BE_LV_WIDGET_SPINBOX + int be_ntv_lv_spinbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinbox_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_SPINBOX + /* `lv_spinner` methods */ +#ifdef BE_LV_WIDGET_SPINNER + int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+_p", "(lv.lv_obj)ii"); } +#endif // BE_LV_WIDGET_SPINNER + /* `lv_arc` methods */ +#ifdef BE_LV_WIDGET_ARC + int be_ntv_lv_arc_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_arc_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_ARC + /* `lv_bar` methods */ +#ifdef BE_LV_WIDGET_BAR + int be_ntv_lv_bar_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_bar_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_BAR + /* `lv_btn` methods */ +#ifdef BE_LV_WIDGET_BTN + int be_ntv_lv_btn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btn_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_BTN + /* `lv_btnmatrix` methods */ +#ifdef BE_LV_WIDGET_BTNMATRIX + int be_ntv_lv_btnmatrix_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btnmatrix_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_BTNMATRIX + /* `lv_canvas` methods */ +#ifdef BE_LV_WIDGET_CANVAS + int be_ntv_lv_canvas_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_canvas_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_CANVAS + /* `lv_checkbox` methods */ +#ifdef BE_LV_WIDGET_CHECKBOX + int be_ntv_lv_checkbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_checkbox_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_CHECKBOX + /* `lv_dropdown` methods */ +#ifdef BE_LV_WIDGET_DROPDOWN + int be_ntv_lv_dropdown_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_dropdown_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_DROPDOWN + /* `lv_label` methods */ +#ifdef BE_LV_WIDGET_LABEL + int be_ntv_lv_label_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_label_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_LABEL + /* `lv_line` methods */ +#ifdef BE_LV_WIDGET_LINE + int be_ntv_lv_line_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_line_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_LINE + /* `lv_roller` methods */ +#ifdef BE_LV_WIDGET_ROLLER + int be_ntv_lv_roller_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_roller_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_ROLLER + /* `lv_slider` methods */ +#ifdef BE_LV_WIDGET_SLIDER + int be_ntv_lv_slider_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_slider_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_SLIDER + /* `lv_switch` methods */ +#ifdef BE_LV_WIDGET_SWITCH + int be_ntv_lv_switch_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_switch_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_SWITCH + /* `lv_table` methods */ +#ifdef BE_LV_WIDGET_TABLE + int be_ntv_lv_table_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_table_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_TABLE + /* `lv_textarea` methods */ +#ifdef BE_LV_WIDGET_TEXTAREA + int be_ntv_lv_textarea_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_textarea_create, "+_p", "(lv.lv_obj)"); } +#endif // BE_LV_WIDGET_TEXTAREA + +// create font either empty or from parameter on stack +int lvbe_font_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); } +int lvbe_theme_create(bvm *vm) { return be_call_c_func(vm, NULL, "+_p", ""); } + + +#ifdef __cplusplus +} /* extern "C" */ +#endif +/********************************************************************/ diff --git a/lib/libesp32/berry/default/be_lvgl_module.c b/lib/libesp32_lvgl/lv_berry/generate/be_lvgl_module.c similarity index 99% rename from lib/libesp32/berry/default/be_lvgl_module.c rename to lib/libesp32_lvgl/lv_berry/generate/be_lvgl_module.c index bb9b86e3e..706f4559f 100644 --- a/lib/libesp32/berry/default/be_lvgl_module.c +++ b/lib/libesp32_lvgl/lv_berry/generate/be_lvgl_module.c @@ -6,8 +6,6 @@ *******************************************************************/ #include "be_constobj.h" -#ifdef USE_LVGL - #include "lvgl.h" #include "be_mapping.h" #include "lv_theme_openhasp.h" @@ -682,6 +680,4 @@ be_local_module(lv, ); BE_EXPORT_VARIABLE be_define_const_native_module(lv); -#endif // USE_LVGL - /********************************************************************/ diff --git a/lib/libesp32/berry/default/be_lvgl_widgets_lib.c b/lib/libesp32_lvgl/lv_berry/generate/be_lvgl_widgets_lib.c similarity index 99% rename from lib/libesp32/berry/default/be_lvgl_widgets_lib.c rename to lib/libesp32_lvgl/lv_berry/generate/be_lvgl_widgets_lib.c index 68950d144..1d20bee34 100644 --- a/lib/libesp32/berry/default/be_lvgl_widgets_lib.c +++ b/lib/libesp32_lvgl/lv_berry/generate/be_lvgl_widgets_lib.c @@ -8,8 +8,6 @@ *******************************************************************/ #include "be_constobj.h" -#ifdef USE_LVGL - #include "lvgl.h" extern int lv0_init(bvm *vm); @@ -1559,6 +1557,3 @@ void be_load_lv_textarea_class(bvm *vm) { be_pop(vm, 1); } - -#endif // USE_LVGL - diff --git a/lib/libesp32_lvgl/lv_berry/library.json b/lib/libesp32_lvgl/lv_berry/library.json new file mode 100644 index 000000000..c5cd36d2f --- /dev/null +++ b/lib/libesp32_lvgl/lv_berry/library.json @@ -0,0 +1,25 @@ +{ + "name": "Berry mapping to LVGL", + "version": "1.0", + "description": "Mapping of LVGL functions to Berry", + "license": "MIT", + "homepage": "https://github.com/arendst/Tasmota", + "frameworks": "*", + "platforms": "*", + "authors": + { + "name": "Stephan Hadinger", + "maintainer": true + }, + "build": { + "srcFilter": [ + "+<*.c>", + "+<../generate/*.c>", + "+<../generate/*.cpp>", + "+<../generate/*.hpp>", + "+<*.cpp>", + "+<*.h>" + ], + "flags": [ "-I$PROJECT_DIR/include" ] + } + } \ No newline at end of file diff --git a/tools/lv_berry/lv_enum.h b/lib/libesp32_lvgl/lv_berry/mapping/lv_enum.h similarity index 100% rename from tools/lv_berry/lv_enum.h rename to lib/libesp32_lvgl/lv_berry/mapping/lv_enum.h diff --git a/tools/lv_berry/lv_funcs.h b/lib/libesp32_lvgl/lv_berry/mapping/lv_funcs.h similarity index 95% rename from tools/lv_berry/lv_funcs.h rename to lib/libesp32_lvgl/lv_berry/mapping/lv_funcs.h index 31367d8bf..8531ba8ac 100644 --- a/tools/lv_berry/lv_funcs.h +++ b/lib/libesp32_lvgl/lv_berry/mapping/lv_funcs.h @@ -28,7 +28,7 @@ lv_coord_t lv_get_ver_res(void); // ====================================================================== -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_disp.h +// ../../lvgl/src/core/lv_disp.h lv_obj_t * lv_disp_get_scr_act(lv_disp_t * disp) lv_obj_t * lv_disp_get_scr_prev(lv_disp_t * disp) void lv_disp_load_scr(lv_obj_t * scr) @@ -50,7 +50,7 @@ static inline void lv_scr_load(lv_obj_t * scr) static inline lv_coord_t lv_dpx(lv_coord_t n) static inline lv_coord_t lv_disp_dpx(const lv_disp_t * disp, lv_coord_t n) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_event.h +// ../../lvgl/src/core/lv_event.h lv_res_t lv_event_send(struct _lv_obj_t * obj, lv_event_code_t event_code, void * param) lv_res_t lv_obj_event_base(const lv_obj_class_t * class_p, lv_event_t * e) uint32_t lv_event_register_id(void) @@ -60,7 +60,7 @@ bool lv_obj_remove_event_dsc(struct _lv_obj_t * obj, struct _lv_event_dsc_t * ev void lv_event_set_ext_draw_size(lv_event_t * e, lv_coord_t size) void lv_event_set_cover_res(lv_event_t * e, lv_cover_res_t res) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_group.h +// ../../lvgl/src/core/lv_group.h lv_group_t * lv_group_create(void) void lv_group_del(lv_group_t * group) void lv_group_set_default(lv_group_t * group) @@ -83,7 +83,7 @@ bool lv_group_get_editing(const lv_group_t * group) bool lv_group_get_wrap(lv_group_t * group) uint32_t lv_group_get_obj_count(lv_group_t * group) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_indev.h +// ../../lvgl/src/core/lv_indev.h void lv_indev_read_timer_cb(lv_timer_t * timer) void lv_indev_enable(lv_indev_t * indev, bool en) lv_indev_t * lv_indev_get_act(void) @@ -104,9 +104,9 @@ lv_obj_t * lv_indev_get_obj_act(void) lv_timer_t * lv_indev_get_read_timer(lv_disp_t * indev) lv_obj_t * lv_indev_search_obj(lv_obj_t * obj, lv_point_t * point) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_indev_scroll.h +// ../../lvgl/src/core/lv_indev_scroll.h -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj.h +// ../../lvgl/src/core/lv_obj.h lv_obj_t * lv_obj_create(lv_obj_t * parent) void lv_obj_add_flag(lv_obj_t * obj, lv_obj_flag_t f) void lv_obj_clear_flag(lv_obj_t * obj, lv_obj_flag_t f) @@ -126,13 +126,13 @@ const lv_obj_class_t * lv_obj_get_class(const lv_obj_t * obj) bool lv_obj_is_valid(const lv_obj_t * obj) static inline lv_coord_t lv_obj_dpx(const lv_obj_t * obj, lv_coord_t n) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_class.h +// ../../lvgl/src/core/lv_obj_class.h struct _lv_obj_t * lv_obj_class_create_obj(const struct _lv_obj_class_t * class_p, struct _lv_obj_t * parent) void lv_obj_class_init_obj(struct _lv_obj_t * obj) bool lv_obj_is_editable(struct _lv_obj_t * obj) bool lv_obj_is_group_def(struct _lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_draw.h +// ../../lvgl/src/core/lv_obj_draw.h void lv_obj_init_draw_rect_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_rect_dsc_t * draw_dsc) void lv_obj_init_draw_label_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_label_dsc_t * draw_dsc) void lv_obj_init_draw_img_dsc(struct _lv_obj_t * obj, uint32_t part, lv_draw_img_dsc_t * draw_dsc) @@ -142,7 +142,7 @@ lv_coord_t lv_obj_calculate_ext_draw_size(struct _lv_obj_t * obj, uint32_t part) void lv_obj_draw_dsc_init(lv_obj_draw_part_dsc_t * dsc, const lv_area_t * clip_area) void lv_obj_refresh_ext_draw_size(struct _lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_pos.h +// ../../lvgl/src/core/lv_obj_pos.h void lv_obj_set_pos(struct _lv_obj_t * obj, lv_coord_t x, lv_coord_t y) void lv_obj_set_x(struct _lv_obj_t * obj, lv_coord_t x) void lv_obj_set_y(struct _lv_obj_t * obj, lv_coord_t y) @@ -187,7 +187,7 @@ bool lv_obj_hit_test(struct _lv_obj_t * obj, const lv_point_t * point) lv_coord_t lv_clamp_width(lv_coord_t width, lv_coord_t min_width, lv_coord_t max_width, lv_coord_t ref_width) lv_coord_t lv_clamp_height(lv_coord_t height, lv_coord_t min_height, lv_coord_t max_height, lv_coord_t ref_height) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_scroll.h +// ../../lvgl/src/core/lv_obj_scroll.h void lv_obj_set_scrollbar_mode(struct _lv_obj_t * obj, lv_scrollbar_mode_t mode) void lv_obj_set_scroll_dir(struct _lv_obj_t * obj, lv_dir_t dir) void lv_obj_set_scroll_snap_x(struct _lv_obj_t * obj, lv_scroll_snap_t align) @@ -215,7 +215,7 @@ void lv_obj_get_scrollbar_area(struct _lv_obj_t * obj, lv_area_t * hor, lv_area_ void lv_obj_scrollbar_invalidate(struct _lv_obj_t * obj) void lv_obj_readjust_scroll(struct _lv_obj_t * obj, lv_anim_enable_t anim_en) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style.h +// ../../lvgl/src/core/lv_obj_style.h void lv_obj_add_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector) void lv_obj_remove_style(struct _lv_obj_t * obj, lv_style_t * style, lv_style_selector_t selector) static inline void lv_obj_remove_style_all(struct _lv_obj_t * obj) @@ -236,7 +236,7 @@ static inline void lv_obj_set_style_pad_ver(struct _lv_obj_t * obj, lv_coord_t v static inline void lv_obj_set_style_pad_gap(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) static inline void lv_obj_set_style_size(struct _lv_obj_t * obj, lv_coord_t value, lv_style_selector_t selector) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style_gen.h +// ../../lvgl/src/core/lv_obj_style_gen.h static inline lv_coord_t lv_obj_get_style_width(const struct _lv_obj_t * obj, uint32_t part) static inline lv_coord_t lv_obj_get_style_min_width(const struct _lv_obj_t * obj, uint32_t part) static inline lv_coord_t lv_obj_get_style_max_width(const struct _lv_obj_t * obj, uint32_t part) @@ -416,7 +416,7 @@ void lv_obj_set_style_arc_color_filtered(struct _lv_obj_t * obj, lv_color_t valu void lv_obj_set_style_arc_opa(struct _lv_obj_t * obj, lv_opa_t value, lv_style_selector_t selector) void lv_obj_set_style_arc_img_src(struct _lv_obj_t * obj, const void * value, lv_style_selector_t selector) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_obj_tree.h +// ../../lvgl/src/core/lv_obj_tree.h void lv_obj_del(struct _lv_obj_t * obj) void lv_obj_clean(struct _lv_obj_t * obj) void lv_obj_del_anim_ready_cb(lv_anim_t * a) @@ -432,10 +432,10 @@ uint32_t lv_obj_get_child_cnt(const struct _lv_obj_t * obj) uint32_t lv_obj_get_child_id(const struct _lv_obj_t * obj) void lv_obj_tree_walk(struct _lv_obj_t * start_obj, lv_obj_tree_walk_cb_t cb, void * user_data) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_refr.h +// ../../lvgl/src/core/lv_refr.h void lv_refr_now(lv_disp_t * disp) -// ../../lib/libesp32_lvgl/LVGL8/src/core/lv_theme.h +// ../../lvgl/src/core/lv_theme.h lv_theme_t * lv_theme_get_from_obj(lv_obj_t * obj) void lv_theme_apply(lv_obj_t * obj) void lv_theme_set_parent(lv_theme_t * new_theme, lv_theme_t * parent) @@ -446,30 +446,30 @@ const lv_font_t * lv_theme_get_font_large(lv_obj_t * obj) lv_color_t lv_theme_get_color_primary(lv_obj_t * obj) lv_color_t lv_theme_get_color_secondary(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw.h +// ../../lvgl/src/draw/lv_draw.h -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_arc.h +// ../../lvgl/src/draw/lv_draw_arc.h void lv_draw_arc_dsc_init(lv_draw_arc_dsc_t * dsc) void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, const lv_area_t * clip_area, const lv_draw_arc_dsc_t * dsc) void lv_draw_arc_get_area(lv_coord_t x, lv_coord_t y, uint16_t radius, uint16_t start_angle, uint16_t end_angle, lv_coord_t w, bool rounded, lv_area_t * area) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_blend.h +// ../../lvgl/src/draw/lv_draw_blend.h -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_img.h +// ../../lvgl/src/draw/lv_draw_img.h void lv_draw_img_dsc_init(lv_draw_img_dsc_t * dsc) void lv_draw_img(const lv_area_t * coords, const lv_area_t * mask, const void * src, const lv_draw_img_dsc_t * dsc) lv_img_src_t lv_img_src_get_type(const void * src) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_label.h +// ../../lvgl/src/draw/lv_draw_label.h void lv_draw_label_dsc_init(lv_draw_label_dsc_t * dsc) void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_label_dsc_t * dsc, const char * txt, lv_draw_label_hint_t * hint) void lv_draw_letter(const lv_point_t * pos_p, const lv_area_t * clip_area, const lv_font_t * font_p, uint32_t letter, lv_color_t color, lv_opa_t opa, lv_blend_mode_t blend_mode) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_line.h +// ../../lvgl/src/draw/lv_draw_line.h void lv_draw_line(const lv_point_t * point1, const lv_point_t * point2, const lv_area_t * clip, const lv_draw_line_dsc_t * dsc) void lv_draw_line_dsc_init(lv_draw_line_dsc_t * dsc) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_mask.h +// ../../lvgl/src/draw/lv_draw_mask.h static inline uint8_t lv_draw_mask_get_cnt(void) int16_t lv_draw_mask_add(void * param, void * custom_id) lv_draw_mask_res_t lv_draw_mask_apply(lv_opa_t * mask_buf, lv_coord_t abs_x, lv_coord_t abs_y, lv_coord_t len) @@ -483,28 +483,28 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, const lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top, lv_opa_t opa_bottom, lv_coord_t y_bottom) void lv_draw_mask_map_init(lv_draw_mask_map_param_t * param, const lv_area_t * coords, const lv_opa_t * map) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_rect.h +// ../../lvgl/src/draw/lv_draw_rect.h void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc) void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_triangle.h +// ../../lvgl/src/draw/lv_draw_triangle.h void lv_draw_triangle(const lv_point_t points[], const lv_area_t * clip, const lv_draw_rect_dsc_t * draw_dsc) void lv_draw_polygon(const lv_point_t points[], uint16_t point_cnt, const lv_area_t * mask, const lv_draw_rect_dsc_t * draw_dsc) -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_img_buf.h +// ../../lvgl/src/draw/lv_img_buf.h -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_img_cache.h +// ../../lvgl/src/draw/lv_img_cache.h -// ../../lib/libesp32_lvgl/LVGL8/src/draw/lv_img_decoder.h +// ../../lvgl/src/draw/lv_img_decoder.h -// ../../lib/libesp32_lvgl/LVGL8/src/extra/themes/default/lv_theme_default.h +// ../../lvgl/src/extra/themes/default/lv_theme_default.h lv_theme_t * lv_theme_default_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) bool lv_theme_default_is_inited(void) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/themes/mono/lv_theme_mono.h +// ../../lvgl/src/extra/themes/mono/lv_theme_mono.h lv_theme_t * lv_theme_mono_init(lv_disp_t * disp, bool dark_bg, const lv_font_t * font) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/chart/lv_chart.h +// ../../lvgl/src/extra/widgets/chart/lv_chart.h lv_obj_t * lv_chart_create(lv_obj_t * parent) void lv_chart_set_type(lv_obj_t * obj, lv_chart_type_t type) void lv_chart_set_point_count(lv_obj_t * obj, uint16_t cnt) @@ -542,7 +542,7 @@ lv_coord_t * lv_chart_get_y_array(const lv_obj_t * obj, lv_chart_series_t * ser) lv_coord_t * lv_chart_get_x_array(const lv_obj_t * obj, lv_chart_series_t * ser) uint32_t lv_chart_get_pressed_point(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/colorwheel/lv_colorwheel.h +// ../../lvgl/src/extra/widgets/colorwheel/lv_colorwheel.h lv_obj_t * lv_colorwheel_create(lv_obj_t * parent, bool knob_recolor) bool lv_colorwheel_set_hsv(lv_obj_t * obj, lv_color_hsv_t hsv) bool lv_colorwheel_set_rgb(lv_obj_t * obj, lv_color_t color) @@ -553,11 +553,11 @@ lv_color_t lv_colorwheel_get_rgb(lv_obj_t * obj) lv_colorwheel_mode_t lv_colorwheel_get_color_mode(lv_obj_t * obj) bool lv_colorwheel_get_color_mode_fixed(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/imgbtn/lv_imgbtn.h +// ../../lvgl/src/extra/widgets/imgbtn/lv_imgbtn.h lv_obj_t * lv_imgbtn_create(lv_obj_t * parent) void lv_imgbtn_set_src(lv_obj_t * imgbtn, lv_imgbtn_state_t state, const void * src_left, const void * src_mid, const void * src_right) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/led/lv_led.h +// ../../lvgl/src/extra/widgets/led/lv_led.h lv_obj_t * lv_led_create(lv_obj_t * parent) void lv_led_set_color(lv_obj_t * led, lv_color_t color) void lv_led_set_brightness(lv_obj_t * led, uint8_t bright) @@ -566,7 +566,7 @@ void lv_led_off(lv_obj_t * led) void lv_led_toggle(lv_obj_t * led) uint8_t lv_led_get_brightness(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/meter/lv_meter.h +// ../../lvgl/src/extra/widgets/meter/lv_meter.h lv_obj_t * lv_meter_create(lv_obj_t * parent) lv_meter_scale_t * lv_meter_add_scale(lv_obj_t * obj) void lv_meter_set_scale_ticks(lv_obj_t * obj, lv_meter_scale_t * scale, uint16_t cnt, uint16_t width, uint16_t len, lv_color_t color) @@ -580,7 +580,7 @@ void lv_meter_set_indicator_value(lv_obj_t * obj, lv_meter_indicator_t * indic, void lv_meter_set_indicator_start_value(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value) void lv_meter_set_indicator_end_value(lv_obj_t * obj, lv_meter_indicator_t * indic, int32_t value) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/msgbox/lv_msgbox.h +// ../../lvgl/src/extra/widgets/msgbox/lv_msgbox.h lv_obj_t * lv_msgbox_create(lv_obj_t * parent, const char * title, const char * txt, const char * btn_txts[], bool add_close_btn) lv_obj_t * lv_msgbox_get_title(lv_obj_t * mbox) lv_obj_t * lv_msgbox_get_close_btn(lv_obj_t * mbox) @@ -589,7 +589,7 @@ lv_obj_t * lv_msgbox_get_btns(lv_obj_t * mbox) const char * lv_msgbox_get_active_btn_text(lv_obj_t * mbox) void lv_msgbox_close(lv_obj_t * mbox) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinbox/lv_spinbox.h +// ../../lvgl/src/extra/widgets/spinbox/lv_spinbox.h lv_obj_t * lv_spinbox_create(lv_obj_t * parent) void lv_spinbox_set_value(lv_obj_t * obj, int32_t i) void lv_spinbox_set_rollover(lv_obj_t * obj, bool b) @@ -604,10 +604,10 @@ void lv_spinbox_step_prev(lv_obj_t * obj) void lv_spinbox_increment(lv_obj_t * obj) void lv_spinbox_decrement(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinner/lv_spinner.h +// ../../lvgl/src/extra/widgets/spinner/lv_spinner.h lv_obj_t * lv_spinner_create(lv_obj_t * parent, uint32_t time, uint32_t arc_length) -// ../../lib/libesp32_lvgl/LVGL8/src/misc/lv_style_gen.h +// ../../lvgl/src/misc/lv_style_gen.h void lv_style_set_width(lv_style_t * style, lv_coord_t value) void lv_style_set_min_width(lv_style_t * style, lv_coord_t value) void lv_style_set_max_width(lv_style_t * style, lv_coord_t value) @@ -698,7 +698,7 @@ void lv_style_set_arc_color_filtered(lv_style_t * style, lv_color_t value) void lv_style_set_arc_opa(lv_style_t * style, lv_opa_t value) void lv_style_set_arc_img_src(lv_style_t * style, const void * value) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_arc.h +// ../../lvgl/src/widgets/lv_arc.h lv_obj_t * lv_arc_create(lv_obj_t * parent) void lv_arc_set_start_angle(lv_obj_t * arc, uint16_t start) void lv_arc_set_end_angle(lv_obj_t * arc, uint16_t end) @@ -720,7 +720,7 @@ int16_t lv_arc_get_min_value(const lv_obj_t * obj) int16_t lv_arc_get_max_value(const lv_obj_t * obj) lv_arc_mode_t lv_arc_get_mode(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_bar.h +// ../../lvgl/src/widgets/lv_bar.h lv_obj_t * lv_bar_create(lv_obj_t * parent) void lv_bar_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim) void lv_bar_set_start_value(lv_obj_t * obj, int32_t start_value, lv_anim_enable_t anim) @@ -732,10 +732,10 @@ int32_t lv_bar_get_min_value(const lv_obj_t * obj) int32_t lv_bar_get_max_value(const lv_obj_t * obj) lv_bar_mode_t lv_bar_get_mode(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_btn.h +// ../../lvgl/src/widgets/lv_btn.h lv_obj_t * lv_btn_create(lv_obj_t * parent) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_btnmatrix.h +// ../../lvgl/src/widgets/lv_btnmatrix.h lv_obj_t * lv_btnmatrix_create(lv_obj_t * parent) void lv_btnmatrix_set_map(lv_obj_t * obj, const char * map[]) void lv_btnmatrix_set_ctrl_map(lv_obj_t * obj, const lv_btnmatrix_ctrl_t ctrl_map[]) @@ -752,7 +752,7 @@ const char * lv_btnmatrix_get_btn_text(const lv_obj_t * obj, uint16_t btn_id) bool lv_btnmatrix_has_btn_ctrl(lv_obj_t * obj, uint16_t btn_id, lv_btnmatrix_ctrl_t ctrl) bool lv_btnmatrix_get_one_checked(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_canvas.h +// ../../lvgl/src/widgets/lv_canvas.h lv_obj_t * lv_canvas_create(lv_obj_t * parent) void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf) void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c) @@ -771,13 +771,13 @@ void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt, const lv_draw_rect_dsc_t * draw_dsc) void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle, int32_t end_angle, const lv_draw_arc_dsc_t * draw_dsc) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_checkbox.h +// ../../lvgl/src/widgets/lv_checkbox.h lv_obj_t * lv_checkbox_create(lv_obj_t * parent) void lv_checkbox_set_text(lv_obj_t * obj, const char * txt) void lv_checkbox_set_text_static(lv_obj_t * obj, const char * txt) const char * lv_checkbox_get_text(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_dropdown.h +// ../../lvgl/src/widgets/lv_dropdown.h lv_obj_t * lv_dropdown_create(lv_obj_t * parent) void lv_dropdown_set_text(lv_obj_t * obj, const char * txt) void lv_dropdown_set_options(lv_obj_t * obj, const char * options) @@ -800,7 +800,7 @@ lv_dir_t lv_dropdown_get_dir(const lv_obj_t * obj) void lv_dropdown_open(lv_obj_t * dropdown_obj) void lv_dropdown_close(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_img.h +// ../../lvgl/src/widgets/lv_img.h lv_obj_t * lv_img_create(lv_obj_t * parent) void lv_img_set_src(lv_obj_t * obj, const void * src) void lv_img_set_offset_x(lv_obj_t * obj, lv_coord_t x) @@ -817,7 +817,7 @@ void lv_img_get_pivot(lv_obj_t * obj, lv_point_t * pivot) uint16_t lv_img_get_zoom(lv_obj_t * obj) bool lv_img_get_antialias(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_label.h +// ../../lvgl/src/widgets/lv_label.h lv_obj_t * lv_label_create(lv_obj_t * parent) void lv_label_set_text(lv_obj_t * obj, const char * text) void lv_label_set_text_fmt(lv_obj_t * obj, const char * fmt, ...) LV_FORMAT_ATTRIBUTE(2, 3) @@ -837,15 +837,15 @@ uint32_t lv_label_get_text_selection_end(const lv_obj_t * obj) void lv_label_ins_text(lv_obj_t * obj, uint32_t pos, const char * txt) void lv_label_cut_text(lv_obj_t * obj, uint32_t pos, uint32_t cnt) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_line.h +// ../../lvgl/src/widgets/lv_line.h lv_obj_t * lv_line_create(lv_obj_t * parent) void lv_line_set_points(lv_obj_t * obj, const lv_point_t points[], uint16_t point_num) void lv_line_set_y_invert(lv_obj_t * obj, bool en) bool lv_line_get_y_invert(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_objx_templ.h +// ../../lvgl/src/widgets/lv_objx_templ.h -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_roller.h +// ../../lvgl/src/widgets/lv_roller.h lv_obj_t * lv_roller_create(lv_obj_t * parent) void lv_roller_set_options(lv_obj_t * obj, const char * options, lv_roller_mode_t mode) void lv_roller_set_selected(lv_obj_t * obj, uint16_t sel_opt, lv_anim_enable_t anim) @@ -855,7 +855,7 @@ void lv_roller_get_selected_str(const lv_obj_t * obj, char * buf, uint32_t buf_s const char * lv_roller_get_options(const lv_obj_t * obj) uint16_t lv_roller_get_option_cnt(const lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_slider.h +// ../../lvgl/src/widgets/lv_slider.h lv_obj_t * lv_slider_create(lv_obj_t * parent) static inline void lv_slider_set_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim) static inline void lv_slider_set_left_value(lv_obj_t * obj, int32_t value, lv_anim_enable_t anim) @@ -868,10 +868,10 @@ static inline int32_t lv_slider_get_max_value(const lv_obj_t * obj) bool lv_slider_is_dragged(const lv_obj_t * obj) static inline lv_slider_mode_t lv_slider_get_mode(lv_obj_t * slider) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_switch.h +// ../../lvgl/src/widgets/lv_switch.h lv_obj_t * lv_switch_create(lv_obj_t * parent) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_table.h +// ../../lvgl/src/widgets/lv_table.h lv_obj_t * lv_table_create(lv_obj_t * parent) void lv_table_set_cell_value(lv_obj_t * obj, uint16_t row, uint16_t col, const char * txt) void lv_table_set_cell_value_fmt(lv_obj_t * obj, uint16_t row, uint16_t col, const char * fmt, ...) @@ -887,7 +887,7 @@ lv_coord_t lv_table_get_col_width(lv_obj_t * obj, uint16_t col) bool lv_table_has_cell_ctrl(lv_obj_t * obj, uint16_t row, uint16_t col, lv_table_cell_ctrl_t ctrl) void lv_table_get_selected_cell(lv_obj_t * obj, uint16_t * row, uint16_t * col) -// ../../lib/libesp32_lvgl/LVGL8/src/widgets/lv_textarea.h +// ../../lvgl/src/widgets/lv_textarea.h lv_obj_t * lv_textarea_create(lv_obj_t * parent) void lv_textarea_add_char(lv_obj_t * obj, uint32_t c) void lv_textarea_add_text(lv_obj_t * obj, const char * txt) @@ -923,7 +923,7 @@ void lv_textarea_cursor_left(lv_obj_t * obj) void lv_textarea_cursor_down(lv_obj_t * obj) void lv_textarea_cursor_up(lv_obj_t * obj) -// ../../lib/libesp32_lvgl/LVGL_assets/src/lv_theme_openhasp.h +// ../../LVGL_assets/src/lv_theme_openhasp.h lv_theme_t * lv_theme_openhasp_init(lv_disp_t * disp, lv_color_t color_primary, lv_color_t color_secondary, bool dark, const lv_font_t * font) bool lv_theme_openhasp_is_inited(void) diff --git a/lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c b/lib/libesp32_lvgl/lv_berry/src/be_lvgl_ctypes_definitions.c similarity index 99% rename from lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c rename to lib/libesp32_lvgl/lv_berry/src/be_lvgl_ctypes_definitions.c index 74797a760..e632ed6b2 100644 --- a/lib/libesp32/berry/default/be_lvgl_ctypes_definitions.c +++ b/lib/libesp32_lvgl/lv_berry/src/be_lvgl_ctypes_definitions.c @@ -3,8 +3,6 @@ *******************************************************************/ #include "be_ctypes.h" -#ifdef USE_LVGL - #include "lvgl.h" #include "be_mapping.h" @@ -527,5 +525,3 @@ be_ctypes_class_by_name_t be_ctypes_lvgl_classes[] = { const size_t be_ctypes_lvgl_classes_size = sizeof(be_ctypes_lvgl_classes)/sizeof(be_ctypes_lvgl_classes[0]); /********************************************************************/ - -#endif // USE_LVGL \ No newline at end of file diff --git a/lib/libesp32/berry/default/be_lvgl_glob_lib.c b/lib/libesp32_lvgl/lv_berry/src/be_lvgl_glob_lib.c similarity index 99% rename from lib/libesp32/berry/default/be_lvgl_glob_lib.c rename to lib/libesp32_lvgl/lv_berry/src/be_lvgl_glob_lib.c index 49848e1dc..1c11b078e 100644 --- a/lib/libesp32/berry/default/be_lvgl_glob_lib.c +++ b/lib/libesp32_lvgl/lv_berry/src/be_lvgl_glob_lib.c @@ -3,10 +3,6 @@ *******************************************************************/ #include "be_constobj.h" -#ifdef USE_LVGL - -#include "lvgl.h" - /******************************************************************** ** Solidified function: get_object_from_ptr ********************************************************************/ @@ -823,5 +819,3 @@ void be_load_LVGL_glob_class(bvm *vm) { be_setglobal(vm, "LVGL_glob"); be_pop(vm, 1); } - -#endif // USE_LVGL \ No newline at end of file diff --git a/lib/libesp32/berry/default/embedded/lvgl_glob.be b/lib/libesp32_lvgl/lv_berry/src/embedded/lvgl_glob.be similarity index 100% rename from lib/libesp32/berry/default/embedded/lvgl_glob.be rename to lib/libesp32_lvgl/lv_berry/src/embedded/lvgl_glob.be diff --git a/lib/libesp32_lvgl/lv_berry/src/lv_berry.c b/lib/libesp32_lvgl/lv_berry/src/lv_berry.c new file mode 100644 index 000000000..ae56cf4bc --- /dev/null +++ b/lib/libesp32_lvgl/lv_berry/src/lv_berry.c @@ -0,0 +1,11 @@ +#include "lv_berry.h" + +extern void be_load_lv_color_class(bvm *vm); +extern void be_load_lv_font_class(bvm *vm); +extern void be_load_LVGL_glob_class(bvm *vm); + +void be_load_lvgl_classes(bvm *vm) { + be_load_lv_color_class(vm); + be_load_lv_font_class(vm); + be_load_LVGL_glob_class(vm); +} diff --git a/lib/libesp32_lvgl/lv_berry/src/lv_berry.h b/lib/libesp32_lvgl/lv_berry/src/lv_berry.h new file mode 100644 index 000000000..869628bfd --- /dev/null +++ b/lib/libesp32_lvgl/lv_berry/src/lv_berry.h @@ -0,0 +1,17 @@ + + +#ifndef __LV_BERRY__ +#define __LV_BERRY__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "berry.h" + +extern void be_load_lvgl_classes(bvm *vm); + +#ifdef __cplusplus +} +#endif +#endif // __LV_BERRY__ diff --git a/tools/lv_berry/convert.py b/lib/libesp32_lvgl/lv_berry/tools/convert.py similarity index 99% rename from tools/lv_berry/convert.py rename to lib/libesp32_lvgl/lv_berry/tools/convert.py index 86a4b86d4..01abafad0 100644 --- a/tools/lv_berry/convert.py +++ b/lib/libesp32_lvgl/lv_berry/tools/convert.py @@ -1,11 +1,11 @@ import re import sys -lv_widgets_file = "lv_funcs.h" -lv_module_file = "lv_enum.h" +lv_widgets_file = "../mapping/lv_funcs.h" +lv_module_file = "../mapping/lv_enum.h" -out_prefix = "../../tasmota/lvgl_berry/" -lvgl_prefix = "../../lib/libesp32/Berry/default/" +out_prefix = "../generate/" +lvgl_prefix = "../generate/" be_lv_defines = "be_lv_defines.h" be_lv_c_mapping = "be_lv_c_mapping.h" @@ -425,8 +425,6 @@ print(""" *******************************************************************/ #include "be_constobj.h" -#ifdef USE_LVGL - #include "lvgl.h" extern int lv0_init(bvm *vm); @@ -642,9 +640,6 @@ be_local_class(lv_{subtype}, }} """) -print(""" -#endif // USE_LVGL -""") sys.stdout.close() @@ -658,8 +653,6 @@ print("""/******************************************************************** *******************************************************************/ #include "be_constobj.h" -#ifdef USE_LVGL - #include "lvgl.h" #include "be_mapping.h" #include "lv_theme_openhasp.h" @@ -778,8 +771,6 @@ be_local_module(lv, })) ); BE_EXPORT_VARIABLE be_define_const_native_module(lv); - -#endif // USE_LVGL """) print("/********************************************************************/") diff --git a/tools/lv_berry/preprocessor.py b/lib/libesp32_lvgl/lv_berry/tools/preprocessor.py similarity index 97% rename from tools/lv_berry/preprocessor.py rename to lib/libesp32_lvgl/lv_berry/tools/preprocessor.py index 216a726fb..678237b52 100644 --- a/tools/lv_berry/preprocessor.py +++ b/lib/libesp32_lvgl/lv_berry/tools/preprocessor.py @@ -48,7 +48,7 @@ def clean_source(raw): # Parse function signatures # ################################################################################ -lv_src_prefix = "../../lib/libesp32_lvgl/LVGL8/src/" +lv_src_prefix = "../../lvgl/src/" lv_fun_globs = [ "widgets/*.h", # all widgets # "extra/widgets/*/*.h", @@ -69,14 +69,14 @@ lv_fun_globs = [ #"**/*.h", ] headers_names = list_files(lv_src_prefix, lv_fun_globs) -headers_names += list_files("../../lib/libesp32_lvgl/LVGL_assets/src/", ["lv_theme_openhasp.h"]) +headers_names += list_files("../../LVGL_assets/src/", ["lv_theme_openhasp.h"]) # headers_names += ["lv_pre_style.h"] # for LVGL v7, add pre-generated style functions from C preprocessor # unit test # headers_names = [ '../../lib/libesp32_lvgl/LVGL/src/lv_widgets/lv_btn.h' ] # headers_names = [ '../../lib/libesp32_lvgl/LVGL/src/lv_api_map.h' ] -output_filename = "lv_funcs.h" +output_filename = "../mapping/lv_funcs.h" sys.stdout = open(output_filename, 'w') print(""" @@ -169,11 +169,11 @@ sys.stdout.close() # Parse 'enum' # ################################################################################ -lv_src_prefix = "../../lib/libesp32_lvgl/LVGL8/src/" +lv_src_prefix = "../../lvgl/src/" lv_fun_globs = [ "**/*.h" ] headers_names = list_files(lv_src_prefix, lv_fun_globs) -output_filename = "lv_enum.h" +output_filename = "../mapping/lv_enum.h" sys.stdout = open(output_filename, 'w') print("""// ====================================================================== // Functions diff --git a/lib/libesp32_lvgl/LVGL8/Kconfig b/lib/libesp32_lvgl/lvgl/Kconfig similarity index 100% rename from lib/libesp32_lvgl/LVGL8/Kconfig rename to lib/libesp32_lvgl/lvgl/Kconfig diff --git a/lib/libesp32_lvgl/LVGL8/LICENCE.txt b/lib/libesp32_lvgl/lvgl/LICENCE.txt similarity index 100% rename from lib/libesp32_lvgl/LVGL8/LICENCE.txt rename to lib/libesp32_lvgl/lvgl/LICENCE.txt diff --git a/lib/libesp32_lvgl/LVGL8/README.md b/lib/libesp32_lvgl/lvgl/README.md similarity index 100% rename from lib/libesp32_lvgl/LVGL8/README.md rename to lib/libesp32_lvgl/lvgl/README.md diff --git a/lib/libesp32_lvgl/LVGL8/library.json b/lib/libesp32_lvgl/lvgl/library.json similarity index 100% rename from lib/libesp32_lvgl/LVGL8/library.json rename to lib/libesp32_lvgl/lvgl/library.json diff --git a/lib/libesp32_lvgl/LVGL8/library.properties b/lib/libesp32_lvgl/lvgl/library.properties similarity index 100% rename from lib/libesp32_lvgl/LVGL8/library.properties rename to lib/libesp32_lvgl/lvgl/library.properties diff --git a/lib/libesp32_lvgl/LVGL8/lv_conf_template.h b/lib/libesp32_lvgl/lvgl/lv_conf_template.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/lv_conf_template.h rename to lib/libesp32_lvgl/lvgl/lv_conf_template.h diff --git a/lib/libesp32_lvgl/LVGL8/lvgl.h b/lib/libesp32_lvgl/lvgl/lvgl.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/lvgl.h rename to lib/libesp32_lvgl/lvgl/lvgl.h diff --git a/lib/libesp32_lvgl/LVGL8/lvgl.mk b/lib/libesp32_lvgl/lvgl/lvgl.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/lvgl.mk rename to lib/libesp32_lvgl/lvgl/lvgl.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_core.mk b/lib/libesp32_lvgl/lvgl/src/core/lv_core.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_core.mk rename to lib/libesp32_lvgl/lvgl/src/core/lv_core.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_disp.c b/lib/libesp32_lvgl/lvgl/src/core/lv_disp.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_disp.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_disp.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_disp.h b/lib/libesp32_lvgl/lvgl/src/core/lv_disp.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_disp.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_disp.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_event.c b/lib/libesp32_lvgl/lvgl/src/core/lv_event.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_event.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_event.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_event.h b/lib/libesp32_lvgl/lvgl/src/core/lv_event.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_event.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_event.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_group.c b/lib/libesp32_lvgl/lvgl/src/core/lv_group.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_group.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_group.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_group.h b/lib/libesp32_lvgl/lvgl/src/core/lv_group.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_group.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_group.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_indev.c b/lib/libesp32_lvgl/lvgl/src/core/lv_indev.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_indev.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_indev.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_indev.h b/lib/libesp32_lvgl/lvgl/src/core/lv_indev.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_indev.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_indev.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_indev_scroll.c b/lib/libesp32_lvgl/lvgl/src/core/lv_indev_scroll.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_indev_scroll.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_indev_scroll.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_indev_scroll.h b/lib/libesp32_lvgl/lvgl/src/core/lv_indev_scroll.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_indev_scroll.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_indev_scroll.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_class.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_class.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_class.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_class.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_class.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_class.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_class.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_class.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_draw.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_draw.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_draw.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_draw.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_draw.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_draw.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_draw.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_draw.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_pos.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_pos.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_pos.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_pos.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_pos.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_pos.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_pos.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_pos.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_scroll.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_scroll.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_scroll.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_scroll.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_scroll.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_scroll.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_scroll.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_scroll.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_style.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_style.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_style.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_style.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style_gen.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_style_gen.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style_gen.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_style_gen.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style_gen.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_style_gen.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_style_gen.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_style_gen.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_tree.c b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_tree.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_tree.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_tree.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_obj_tree.h b/lib/libesp32_lvgl/lvgl/src/core/lv_obj_tree.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_obj_tree.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_obj_tree.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_refr.c b/lib/libesp32_lvgl/lvgl/src/core/lv_refr.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_refr.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_refr.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_refr.h b/lib/libesp32_lvgl/lvgl/src/core/lv_refr.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_refr.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_refr.h diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_theme.c b/lib/libesp32_lvgl/lvgl/src/core/lv_theme.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_theme.c rename to lib/libesp32_lvgl/lvgl/src/core/lv_theme.c diff --git a/lib/libesp32_lvgl/LVGL8/src/core/lv_theme.h b/lib/libesp32_lvgl/lvgl/src/core/lv_theme.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/core/lv_theme.h rename to lib/libesp32_lvgl/lvgl/src/core/lv_theme.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw.mk b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw.mk rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_arc.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_arc.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_arc.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_arc.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_arc.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_arc.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_arc.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_arc.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_blend.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_blend.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_blend.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_blend.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_blend.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_blend.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_blend.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_blend.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_img.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_img.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_img.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_img.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_img.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_img.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_img.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_img.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_label.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_label.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_label.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_label.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_label.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_label.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_label.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_label.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_line.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_line.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_line.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_line.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_line.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_line.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_line.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_line.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_mask.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_mask.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_mask.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_mask.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_mask.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_mask.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_mask.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_mask.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_rect.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_rect.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_rect.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_rect.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_rect.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_rect.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_rect.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_rect.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_triangle.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_triangle.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_triangle.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_triangle.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_triangle.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_draw_triangle.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_draw_triangle.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_draw_triangle.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_img_buf.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_img_buf.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_img_buf.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_img_buf.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_img_buf.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_img_buf.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_img_buf.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_img_buf.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_img_cache.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_img_cache.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_img_cache.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_img_cache.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_img_cache.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_img_cache.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_img_cache.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_img_cache.h diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_img_decoder.c b/lib/libesp32_lvgl/lvgl/src/draw/lv_img_decoder.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_img_decoder.c rename to lib/libesp32_lvgl/lvgl/src/draw/lv_img_decoder.c diff --git a/lib/libesp32_lvgl/LVGL8/src/draw/lv_img_decoder.h b/lib/libesp32_lvgl/lvgl/src/draw/lv_img_decoder.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/draw/lv_img_decoder.h rename to lib/libesp32_lvgl/lvgl/src/draw/lv_img_decoder.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/extra.mk b/lib/libesp32_lvgl/lvgl/src/extra/extra.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/extra.mk rename to lib/libesp32_lvgl/lvgl/src/extra/extra.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/layouts/flex/lv_flex.c b/lib/libesp32_lvgl/lvgl/src/extra/layouts/flex/lv_flex.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/layouts/flex/lv_flex.c rename to lib/libesp32_lvgl/lvgl/src/extra/layouts/flex/lv_flex.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/layouts/flex/lv_flex.h b/lib/libesp32_lvgl/lvgl/src/extra/layouts/flex/lv_flex.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/layouts/flex/lv_flex.h rename to lib/libesp32_lvgl/lvgl/src/extra/layouts/flex/lv_flex.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/layouts/grid/lv_grid.c b/lib/libesp32_lvgl/lvgl/src/extra/layouts/grid/lv_grid.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/layouts/grid/lv_grid.c rename to lib/libesp32_lvgl/lvgl/src/extra/layouts/grid/lv_grid.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/layouts/grid/lv_grid.h b/lib/libesp32_lvgl/lvgl/src/extra/layouts/grid/lv_grid.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/layouts/grid/lv_grid.h rename to lib/libesp32_lvgl/lvgl/src/extra/layouts/grid/lv_grid.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/layouts/lv_layouts.h b/lib/libesp32_lvgl/lvgl/src/extra/layouts/lv_layouts.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/layouts/lv_layouts.h rename to lib/libesp32_lvgl/lvgl/src/extra/layouts/lv_layouts.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/lv_extra.c b/lib/libesp32_lvgl/lvgl/src/extra/lv_extra.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/lv_extra.c rename to lib/libesp32_lvgl/lvgl/src/extra/lv_extra.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/lv_extra.h b/lib/libesp32_lvgl/lvgl/src/extra/lv_extra.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/lv_extra.h rename to lib/libesp32_lvgl/lvgl/src/extra/lv_extra.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/basic/lv_theme_basic.c b/lib/libesp32_lvgl/lvgl/src/extra/themes/basic/lv_theme_basic.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/basic/lv_theme_basic.c rename to lib/libesp32_lvgl/lvgl/src/extra/themes/basic/lv_theme_basic.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/basic/lv_theme_basic.h b/lib/libesp32_lvgl/lvgl/src/extra/themes/basic/lv_theme_basic.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/basic/lv_theme_basic.h rename to lib/libesp32_lvgl/lvgl/src/extra/themes/basic/lv_theme_basic.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/default/lv_theme_default.c b/lib/libesp32_lvgl/lvgl/src/extra/themes/default/lv_theme_default.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/default/lv_theme_default.c rename to lib/libesp32_lvgl/lvgl/src/extra/themes/default/lv_theme_default.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/default/lv_theme_default.h b/lib/libesp32_lvgl/lvgl/src/extra/themes/default/lv_theme_default.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/default/lv_theme_default.h rename to lib/libesp32_lvgl/lvgl/src/extra/themes/default/lv_theme_default.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/lv_themes.h b/lib/libesp32_lvgl/lvgl/src/extra/themes/lv_themes.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/lv_themes.h rename to lib/libesp32_lvgl/lvgl/src/extra/themes/lv_themes.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/mono/lv_theme_mono.c b/lib/libesp32_lvgl/lvgl/src/extra/themes/mono/lv_theme_mono.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/mono/lv_theme_mono.c rename to lib/libesp32_lvgl/lvgl/src/extra/themes/mono/lv_theme_mono.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/themes/mono/lv_theme_mono.h b/lib/libesp32_lvgl/lvgl/src/extra/themes/mono/lv_theme_mono.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/themes/mono/lv_theme_mono.h rename to lib/libesp32_lvgl/lvgl/src/extra/themes/mono/lv_theme_mono.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/animimg/lv_animimg.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/animimg/lv_animimg.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/animimg/lv_animimg.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/animimg/lv_animimg.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/animimg/lv_animimg.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/animimg/lv_animimg.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/animimg/lv_animimg.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/animimg/lv_animimg.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_arrow.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_arrow.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_arrow.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_arrow.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_arrow.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_dropdown.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_dropdown.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_dropdown.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/calendar/lv_calendar_header_dropdown.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/calendar/lv_calendar_header_dropdown.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/chart/lv_chart.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/chart/lv_chart.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/chart/lv_chart.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/chart/lv_chart.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/chart/lv_chart.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/chart/lv_chart.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/chart/lv_chart.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/chart/lv_chart.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/colorwheel/lv_colorwheel.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/colorwheel/lv_colorwheel.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/colorwheel/lv_colorwheel.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/colorwheel/lv_colorwheel.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/colorwheel/lv_colorwheel.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/imgbtn/lv_imgbtn.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/imgbtn/lv_imgbtn.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/imgbtn/lv_imgbtn.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/imgbtn/lv_imgbtn.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/imgbtn/lv_imgbtn.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/keyboard/lv_keyboard.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/keyboard/lv_keyboard.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/keyboard/lv_keyboard.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/keyboard/lv_keyboard.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/keyboard/lv_keyboard.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/keyboard/lv_keyboard.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/keyboard/lv_keyboard.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/keyboard/lv_keyboard.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/led/lv_led.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/led/lv_led.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/led/lv_led.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/led/lv_led.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/led/lv_led.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/led/lv_led.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/led/lv_led.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/led/lv_led.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/list/lv_list.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/list/lv_list.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/list/lv_list.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/list/lv_list.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/list/lv_list.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/list/lv_list.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/list/lv_list.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/list/lv_list.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/lv_widgets.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/lv_widgets.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/lv_widgets.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/lv_widgets.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/meter/lv_meter.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/meter/lv_meter.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/meter/lv_meter.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/meter/lv_meter.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/meter/lv_meter.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/meter/lv_meter.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/meter/lv_meter.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/meter/lv_meter.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/msgbox/lv_msgbox.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/msgbox/lv_msgbox.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/msgbox/lv_msgbox.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/msgbox/lv_msgbox.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/msgbox/lv_msgbox.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/msgbox/lv_msgbox.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/msgbox/lv_msgbox.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/msgbox/lv_msgbox.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/span/lv_span.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/span/lv_span.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/span/lv_span.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/span/lv_span.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/span/lv_span.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/span/lv_span.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/span/lv_span.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/span/lv_span.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinbox/lv_spinbox.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/spinbox/lv_spinbox.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinbox/lv_spinbox.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/spinbox/lv_spinbox.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinbox/lv_spinbox.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/spinbox/lv_spinbox.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinbox/lv_spinbox.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/spinbox/lv_spinbox.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinner/lv_spinner.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/spinner/lv_spinner.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinner/lv_spinner.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/spinner/lv_spinner.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinner/lv_spinner.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/spinner/lv_spinner.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/spinner/lv_spinner.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/spinner/lv_spinner.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/tabview/lv_tabview.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/tabview/lv_tabview.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/tabview/lv_tabview.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/tabview/lv_tabview.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/tabview/lv_tabview.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/tabview/lv_tabview.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/tabview/lv_tabview.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/tabview/lv_tabview.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/tileview/lv_tileview.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/tileview/lv_tileview.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/tileview/lv_tileview.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/tileview/lv_tileview.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/tileview/lv_tileview.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/tileview/lv_tileview.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/tileview/lv_tileview.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/tileview/lv_tileview.h diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/win/lv_win.c b/lib/libesp32_lvgl/lvgl/src/extra/widgets/win/lv_win.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/win/lv_win.c rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/win/lv_win.c diff --git a/lib/libesp32_lvgl/LVGL8/src/extra/widgets/win/lv_win.h b/lib/libesp32_lvgl/lvgl/src/extra/widgets/win/lv_win.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/extra/widgets/win/lv_win.h rename to lib/libesp32_lvgl/lvgl/src/extra/widgets/win/lv_win.h diff --git a/lib/libesp32_lvgl/LVGL8/src/font/korean.ttf b/lib/libesp32_lvgl/lvgl/src/font/korean.ttf similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/korean.ttf rename to lib/libesp32_lvgl/lvgl/src/font/korean.ttf diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font.h b/lib/libesp32_lvgl/lvgl/src/font/lv_font.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font.h rename to lib/libesp32_lvgl/lvgl/src/font/lv_font.h diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font.mk b/lib/libesp32_lvgl/lvgl/src/font/lv_font.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font.mk rename to lib/libesp32_lvgl/lvgl/src/font/lv_font.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_dejavu_16_persian_hebrew.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_dejavu_16_persian_hebrew.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_dejavu_16_persian_hebrew.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_dejavu_16_persian_hebrew.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_fmt_txt.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_fmt_txt.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_fmt_txt.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_fmt_txt.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_fmt_txt.h b/lib/libesp32_lvgl/lvgl/src/font/lv_font_fmt_txt.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_fmt_txt.h rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_fmt_txt.h diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_loader.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_loader.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_loader.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_loader.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_loader.h b/lib/libesp32_lvgl/lvgl/src/font/lv_font_loader.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_loader.h rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_loader.h diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_10.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_10.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_10.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_10.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_12.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_12.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_12.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_12.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_12_subpx.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_12_subpx.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_12_subpx.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_12_subpx.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_14.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_14.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_14.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_14.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_16.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_16.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_16.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_16.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_18.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_18.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_18.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_18.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_20.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_20.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_20.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_20.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_22.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_22.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_22.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_22.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_24.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_24.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_24.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_24.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_26.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_26.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_26.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_26.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_28.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_28.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_28.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_28.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_28_compressed.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_28_compressed.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_28_compressed.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_28_compressed.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_30.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_30.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_30.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_30.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_32.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_32.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_32.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_32.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_34.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_34.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_34.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_34.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_36.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_36.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_36.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_36.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_38.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_38.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_38.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_38.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_40.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_40.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_40.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_40.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_42.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_42.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_42.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_42.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_44.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_44.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_44.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_44.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_46.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_46.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_46.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_46.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_48.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_48.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_48.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_48.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_8.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_8.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_montserrat_8.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_montserrat_8.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_simsun_16_cjk.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_simsun_16_cjk.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_simsun_16_cjk.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_simsun_16_cjk.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_unscii_16.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_unscii_16.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_unscii_16.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_unscii_16.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_font_unscii_8.c b/lib/libesp32_lvgl/lvgl/src/font/lv_font_unscii_8.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_font_unscii_8.c rename to lib/libesp32_lvgl/lvgl/src/font/lv_font_unscii_8.c diff --git a/lib/libesp32_lvgl/LVGL8/src/font/lv_symbol_def.h b/lib/libesp32_lvgl/lvgl/src/font/lv_symbol_def.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/font/lv_symbol_def.h rename to lib/libesp32_lvgl/lvgl/src/font/lv_symbol_def.h diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu.mk b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu.mk rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp.c b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp.c rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp.c diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp.h b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp.h rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp.h diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp_osa.c b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp_osa.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp_osa.c rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp_osa.c diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp_osa.h b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp_osa.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_pxp_osa.h rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_pxp_osa.h diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_vglite.c b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_vglite.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_vglite.c rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_vglite.c diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_vglite.h b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_vglite.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_nxp_vglite.h rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_nxp_vglite.h diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_stm32_dma2d.c b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_stm32_dma2d.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_stm32_dma2d.c rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_stm32_dma2d.c diff --git a/lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_stm32_dma2d.h b/lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_stm32_dma2d.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/gpu/lv_gpu_stm32_dma2d.h rename to lib/libesp32_lvgl/lvgl/src/gpu/lv_gpu_stm32_dma2d.h diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal.h b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal.h rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal.h diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal.mk b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal.mk rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_disp.c b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal_disp.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_disp.c rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal_disp.c diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_disp.h b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal_disp.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_disp.h rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal_disp.h diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_indev.c b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal_indev.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_indev.c rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal_indev.c diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_indev.h b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal_indev.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_indev.h rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal_indev.h diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_tick.c b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal_tick.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_tick.c rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal_tick.c diff --git a/lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_tick.h b/lib/libesp32_lvgl/lvgl/src/hal/lv_hal_tick.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/hal/lv_hal_tick.h rename to lib/libesp32_lvgl/lvgl/src/hal/lv_hal_tick.h diff --git a/lib/libesp32_lvgl/LVGL8/src/lv_api_map.h b/lib/libesp32_lvgl/lvgl/src/lv_api_map.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/lv_api_map.h rename to lib/libesp32_lvgl/lvgl/src/lv_api_map.h diff --git a/lib/libesp32_lvgl/LVGL8/src/lv_conf_internal.h b/lib/libesp32_lvgl/lvgl/src/lv_conf_internal.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/lv_conf_internal.h rename to lib/libesp32_lvgl/lvgl/src/lv_conf_internal.h diff --git a/lib/libesp32_lvgl/LVGL8/src/lv_conf_kconfig.h b/lib/libesp32_lvgl/lvgl/src/lv_conf_kconfig.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/lv_conf_kconfig.h rename to lib/libesp32_lvgl/lvgl/src/lv_conf_kconfig.h diff --git a/lib/libesp32_lvgl/LVGL8/src/lvgl.h b/lib/libesp32_lvgl/lvgl/src/lvgl.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/lvgl.h rename to lib/libesp32_lvgl/lvgl/src/lvgl.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_anim.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_anim.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_anim.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_anim.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_anim.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_anim.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_anim.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_anim.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_area.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_area.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_area.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_area.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_area.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_area.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_area.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_area.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_assert.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_assert.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_assert.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_assert.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_async.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_async.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_async.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_async.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_async.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_async.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_async.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_async.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_bidi.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_bidi.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_bidi.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_bidi.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_bidi.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_bidi.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_bidi.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_bidi.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_color.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_color.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_color.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_color.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_color.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_color.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_color.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_color.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_fs.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_fs.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_fs.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_fs.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_fs.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_fs.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_fs.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_fs.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_gc.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_gc.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_gc.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_gc.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_gc.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_gc.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_gc.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_gc.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_ll.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_ll.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_ll.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_ll.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_ll.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_ll.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_ll.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_ll.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_log.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_log.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_log.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_log.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_log.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_log.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_log.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_log.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_math.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_math.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_math.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_math.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_math.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_math.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_math.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_math.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_mem.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_mem.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_mem.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_mem.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_mem.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_mem.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_mem.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_mem.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_misc.mk b/lib/libesp32_lvgl/lvgl/src/misc/lv_misc.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_misc.mk rename to lib/libesp32_lvgl/lvgl/src/misc/lv_misc.mk diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_printf.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_printf.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_printf.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_printf.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_printf.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_printf.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_printf.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_printf.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_style.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_style.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_style.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_style.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_style.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_style.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_style.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_style.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_style_gen.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_style_gen.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_style_gen.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_style_gen.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_style_gen.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_style_gen.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_style_gen.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_style_gen.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_templ.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_templ.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_templ.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_templ.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_templ.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_templ.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_templ.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_templ.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_timer.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_timer.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_timer.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_timer.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_timer.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_timer.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_timer.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_timer.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_tlsf.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_tlsf.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_tlsf.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_tlsf.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_tlsf.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_tlsf.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_tlsf.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_tlsf.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_txt.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_txt.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_txt.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_txt.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_txt.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_txt.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_txt.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_txt.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_txt_ap.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_txt_ap.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_txt_ap.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_txt_ap.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_txt_ap.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_txt_ap.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_txt_ap.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_txt_ap.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_types.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_types.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_types.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_types.h diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_utils.c b/lib/libesp32_lvgl/lvgl/src/misc/lv_utils.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_utils.c rename to lib/libesp32_lvgl/lvgl/src/misc/lv_utils.c diff --git a/lib/libesp32_lvgl/LVGL8/src/misc/lv_utils.h b/lib/libesp32_lvgl/lvgl/src/misc/lv_utils.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/misc/lv_utils.h rename to lib/libesp32_lvgl/lvgl/src/misc/lv_utils.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_arc.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_arc.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_arc.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_arc.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_arc.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_arc.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_arc.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_arc.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_bar.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_bar.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_bar.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_bar.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_bar.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_bar.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_bar.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_bar.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_btn.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_btn.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_btn.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_btn.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_btn.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_btn.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_btn.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_btn.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_btnmatrix.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_btnmatrix.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_btnmatrix.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_btnmatrix.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_btnmatrix.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_btnmatrix.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_btnmatrix.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_btnmatrix.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_canvas.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_canvas.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_canvas.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_canvas.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_canvas.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_canvas.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_canvas.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_canvas.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_checkbox.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_checkbox.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_checkbox.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_checkbox.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_checkbox.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_checkbox.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_checkbox.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_checkbox.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_dropdown.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_dropdown.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_dropdown.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_dropdown.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_dropdown.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_dropdown.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_dropdown.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_dropdown.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_img.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_img.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_img.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_img.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_img.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_img.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_img.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_img.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_label.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_label.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_label.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_label.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_label.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_label.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_label.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_label.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_line.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_line.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_line.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_line.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_line.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_line.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_line.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_line.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_objx_templ.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_objx_templ.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_objx_templ.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_objx_templ.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_objx_templ.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_objx_templ.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_objx_templ.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_objx_templ.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_roller.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_roller.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_roller.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_roller.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_roller.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_roller.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_roller.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_roller.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_slider.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_slider.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_slider.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_slider.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_slider.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_slider.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_slider.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_slider.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_switch.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_switch.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_switch.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_switch.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_switch.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_switch.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_switch.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_switch.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_table.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_table.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_table.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_table.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_table.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_table.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_table.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_table.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_textarea.c b/lib/libesp32_lvgl/lvgl/src/widgets/lv_textarea.c similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_textarea.c rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_textarea.c diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_textarea.h b/lib/libesp32_lvgl/lvgl/src/widgets/lv_textarea.h similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_textarea.h rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_textarea.h diff --git a/lib/libesp32_lvgl/LVGL8/src/widgets/lv_widgets.mk b/lib/libesp32_lvgl/lvgl/src/widgets/lv_widgets.mk similarity index 100% rename from lib/libesp32_lvgl/LVGL8/src/widgets/lv_widgets.mk rename to lib/libesp32_lvgl/lvgl/src/widgets/lv_widgets.mk diff --git a/tasmota/xdrv_52_3_berry_lvgl.ino b/tasmota/xdrv_52_3_berry_lvgl.ino index f86ed7db7..8398ecbd9 100644 --- a/tasmota/xdrv_52_3_berry_lvgl.ino +++ b/tasmota/xdrv_52_3_berry_lvgl.ino @@ -25,6 +25,7 @@ #include "lvgl.h" #include "be_mapping.h" #include "be_ctypes.h" +#include "lv_berry.h" #include "Adafruit_LvGL_Glue.h" #ifdef USE_LVGL_FREETYPE @@ -629,6 +630,7 @@ extern "C" { if (argc == 1) { uconfig = be_tostring(vm, 1); } + be_set_gen_cb_name(vm, "_lvgl.gen_cb"); // TODO maybe not the best place for it start_lvgl(uconfig); be_return_nil(vm); } diff --git a/tools/lv_berry/lv_symbol.h b/tools/lv_berry/lv_symbol.h deleted file mode 100644 index 8006c215c..000000000 --- a/tools/lv_berry/lv_symbol.h +++ /dev/null @@ -1,62 +0,0 @@ - -SYMBOL_AUDIO="\xef\x80\x81" -SYMBOL_VIDEO="\xef\x80\x88" -SYMBOL_LIST="\xef\x80\x8b" -SYMBOL_OK="\xef\x80\x8c" -SYMBOL_CLOSE="\xef\x80\x8d" -SYMBOL_POWER="\xef\x80\x91" -SYMBOL_SETTINGS="\xef\x80\x93" -SYMBOL_HOME="\xef\x80\x95" -SYMBOL_DOWNLOAD="\xef\x80\x99" -SYMBOL_DRIVE="\xef\x80\x9c" -SYMBOL_REFRESH="\xef\x80\xa1" -SYMBOL_MUTE="\xef\x80\xa6" -SYMBOL_VOLUME_MID="\xef\x80\xa7" -SYMBOL_VOLUME_MAX="\xef\x80\xa8" -SYMBOL_IMAGE="\xef\x80\xbe" -SYMBOL_EDIT="\xef\x8C\x84" -SYMBOL_PREV="\xef\x81\x88" -SYMBOL_PLAY="\xef\x81\x8b" -SYMBOL_PAUSE="\xef\x81\x8c" -SYMBOL_STOP="\xef\x81\x8d" -SYMBOL_NEXT="\xef\x81\x91" -SYMBOL_EJECT="\xef\x81\x92" -SYMBOL_LEFT="\xef\x81\x93" -SYMBOL_RIGHT="\xef\x81\x94" -SYMBOL_PLUS="\xef\x81\xa7" -SYMBOL_MINUS="\xef\x81\xa8" -SYMBOL_EYE_OPEN="\xef\x81\xae" -SYMBOL_EYE_CLOSE="\xef\x81\xb0" -SYMBOL_WARNING="\xef\x81\xb1" -SYMBOL_SHUFFLE="\xef\x81\xb4" -SYMBOL_UP="\xef\x81\xb7" -SYMBOL_DOWN="\xef\x81\xb8" -SYMBOL_LOOP="\xef\x81\xb9" -SYMBOL_DIRECTORY="\xef\x81\xbb" -SYMBOL_UPLOAD="\xef\x82\x93" -SYMBOL_CALL="\xef\x82\x95" -SYMBOL_CUT="\xef\x83\x84" -SYMBOL_COPY="\xef\x83\x85" -SYMBOL_SAVE="\xef\x83\x87" -SYMBOL_CHARGE="\xef\x83\xa7" -SYMBOL_PASTE="\xef\x83\xAA" -SYMBOL_BELL="\xef\x83\xb3" -SYMBOL_KEYBOARD="\xef\x84\x9c" -SYMBOL_GPS="\xef\x84\xa4" -SYMBOL_FILE="\xef\x85\x9b" -SYMBOL_WIFI="\xef\x87\xab" -SYMBOL_BATTERY_FULL="\xef\x89\x80" -SYMBOL_BATTERY_3="\xef\x89\x81" -SYMBOL_BATTERY_2="\xef\x89\x82" -SYMBOL_BATTERY_1="\xef\x89\x83" -SYMBOL_BATTERY_EMPTY="\xef\x89\x84" -SYMBOL_USB="\xef\x8a\x87" -SYMBOL_BLUETOOTH="\xef\x8a\x93" -SYMBOL_TRASH="\xef\x8B\xAD" -SYMBOL_BACKSPACE="\xef\x95\x9A" -SYMBOL_SD_CARD="\xef\x9F\x82" -SYMBOL_NEW_LINE="\xef\xA2\xA2" - -SYMBOL_DUMMY="\xEF\xA3\xBF" - -SYMBOL_BULLET="\xE2\x80\xA2" \ No newline at end of file diff --git a/tools/lv_berry/lv_symbols.h b/tools/lv_berry/lv_symbols.h deleted file mode 100644 index cce4f230a..000000000 --- a/tools/lv_berry/lv_symbols.h +++ /dev/null @@ -1,61 +0,0 @@ -SYMBOL_AUDIO "\\xef\\x80\\x81" -SYMBOL_VIDEO "\\xef\\x80\\x88" -SYMBOL_LIST "\\xef\\x80\\x8b" -SYMBOL_OK "\\xef\\x80\\x8c" -SYMBOL_CLOSE "\\xef\\x80\\x8d" -SYMBOL_POWER "\\xef\\x80\\x91" -SYMBOL_SETTINGS "\\xef\\x80\\x93" -SYMBOL_HOME "\\xef\\x80\\x95" -SYMBOL_DOWNLOAD "\\xef\\x80\\x99" -SYMBOL_DRIVE "\\xef\\x80\\x9c" -SYMBOL_REFRESH "\\xef\\x80\\xa1" -SYMBOL_MUTE "\\xef\\x80\\xa6" -SYMBOL_VOLUME_MID "\\xef\\x80\\xa7" -SYMBOL_VOLUME_MAX "\\xef\\x80\\xa8" -SYMBOL_IMAGE "\\xef\\x80\\xbe" -SYMBOL_EDIT "\\xef\\x8C\\x84" -SYMBOL_PREV "\\xef\\x81\\x88" -SYMBOL_PLAY "\\xef\\x81\\x8b" -SYMBOL_PAUSE "\\xef\\x81\\x8c" -SYMBOL_STOP "\\xef\\x81\\x8d" -SYMBOL_NEXT "\\xef\\x81\\x91" -SYMBOL_EJECT "\\xef\\x81\\x92" -SYMBOL_LEFT "\\xef\\x81\\x93" -SYMBOL_RIGHT "\\xef\\x81\\x94" -SYMBOL_PLUS "\\xef\\x81\\xa7" -SYMBOL_MINUS "\\xef\\x81\\xa8" -SYMBOL_EYE_OPEN "\\xef\\x81\\xae" -SYMBOL_EYE_CLOSE "\\xef\\x81\\xb0" -SYMBOL_WARNING "\\xef\\x81\\xb1" -SYMBOL_SHUFFLE "\\xef\\x81\\xb4" -SYMBOL_UP "\\xef\\x81\\xb7" -SYMBOL_DOWN "\\xef\\x81\\xb8" -SYMBOL_LOOP "\\xef\\x81\\xb9" -SYMBOL_DIRECTORY "\\xef\\x81\\xbb" -SYMBOL_UPLOAD "\\xef\\x82\\x93" -SYMBOL_CALL "\\xef\\x82\\x95" -SYMBOL_CUT "\\xef\\x83\\x84" -SYMBOL_COPY "\\xef\\x83\\x85" -SYMBOL_SAVE "\\xef\\x83\\x87" -SYMBOL_CHARGE "\\xef\\x83\\xa7" -SYMBOL_PASTE "\\xef\\x83\\xAA" -SYMBOL_BELL "\\xef\\x83\\xb3" -SYMBOL_KEYBOARD "\\xef\\x84\\x9c" -SYMBOL_GPS "\\xef\\x84\\xa4" -SYMBOL_FILE "\\xef\\x85\\x9b" -SYMBOL_WIFI "\\xef\\x87\\xab" -SYMBOL_BATTERY_FULL "\\xef\\x89\\x80" -SYMBOL_BATTERY_3 "\\xef\\x89\\x81" -SYMBOL_BATTERY_2 "\\xef\\x89\\x82" -SYMBOL_BATTERY_1 "\\xef\\x89\\x83" -SYMBOL_BATTERY_EMPTY "\\xef\\x89\\x84" -SYMBOL_USB "\\xef\\x8a\\x87" -SYMBOL_BLUETOOTH "\\xef\\x8a\\x93" -SYMBOL_TRASH "\\xef\\x8B\\xAD" -SYMBOL_BACKSPACE "\\xef\\x95\\x9A" -SYMBOL_SD_CARD "\\xef\\x9F\\x82" -SYMBOL_NEW_LINE "\\xef\\xA2\\xA2" - -SYMBOL_DUMMY "\\xEF\\xA3\\xBF" - -SYMBOL_BULLET "\\xE2\\x80\\xA2" From 699515fc4e9caa583345f7482c81ccfa50963a95 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Dec 2021 13:01:07 +0100 Subject: [PATCH 14/31] fix s2 build --- platformio_tasmota_cenv_sample.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio_tasmota_cenv_sample.ini b/platformio_tasmota_cenv_sample.ini index ea5114455..44cfd6ca5 100644 --- a/platformio_tasmota_cenv_sample.ini +++ b/platformio_tasmota_cenv_sample.ini @@ -9,6 +9,7 @@ lib_ignore = TTGO TWatch Library NimBLE-Arduino epdiy + esp32-camera [env:tasmota-rangeextender] build_flags = ${env.build_flags} From 3d716866b17e4e6d9f5640c894b93bb9ed8eca8b Mon Sep 17 00:00:00 2001 From: Jason2866 Date: Sat, 18 Dec 2021 13:26:16 +0100 Subject: [PATCH 15/31] fix compiler warning webcam --- lib/libesp32/Berry-HttpClientLight/library.json | 4 ++-- lib/libesp32/Zip-readonly-FS/library.json | 4 ++-- lib/libesp32/berry/library.json | 4 ++-- lib/libesp32/berry_mapping/library.json | 4 ++-- lib/libesp32/re1.5/library.json | 4 ++-- lib/libesp32_div/esp32-camera/library.json | 7 +++---- lib/libesp32_lvgl/freetype/library.json | 4 ++-- lib/libesp32_lvgl/lv_berry/library.json | 4 ++-- lib/libesp32_lvgl/lvgl/library.json | 4 ++-- 9 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/libesp32/Berry-HttpClientLight/library.json b/lib/libesp32/Berry-HttpClientLight/library.json index 1e1479bbb..c9e5208f9 100644 --- a/lib/libesp32/Berry-HttpClientLight/library.json +++ b/lib/libesp32/Berry-HttpClientLight/library.json @@ -4,8 +4,8 @@ "description": "Forked version of Arduino HttpClient to support BearSSL instead of mbedTLS", "license": "MIT", "homepage": "https://github.com/arendst/Tasmota", - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "authors": { "name": "Stephan Hadinger", diff --git a/lib/libesp32/Zip-readonly-FS/library.json b/lib/libesp32/Zip-readonly-FS/library.json index a8c83f81b..e57844d30 100644 --- a/lib/libesp32/Zip-readonly-FS/library.json +++ b/lib/libesp32/Zip-readonly-FS/library.json @@ -4,8 +4,8 @@ "description": "Simple filesystem to open an uncompressed ZIP file and read-only", "license": "MIT", "homepage": "https://github.com/arendst/Tasmota", - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "authors": { "name": "Stephan Hadinger", diff --git a/lib/libesp32/berry/library.json b/lib/libesp32/berry/library.json index 705592bd5..901800fca 100644 --- a/lib/libesp32/berry/library.json +++ b/lib/libesp32/berry/library.json @@ -14,8 +14,8 @@ }, "version": "7.0", "license": "MIT License", - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "build": { "srcFilter": [ "+<*.c>", diff --git a/lib/libesp32/berry_mapping/library.json b/lib/libesp32/berry_mapping/library.json index 6bcf119fa..1add02751 100644 --- a/lib/libesp32/berry_mapping/library.json +++ b/lib/libesp32/berry_mapping/library.json @@ -4,8 +4,8 @@ "description": "Mapping to C functions", "license": "MIT", "homepage": "https://github.com/arendst/Tasmota", - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "authors": { "name": "Stephan Hadinger", diff --git a/lib/libesp32/re1.5/library.json b/lib/libesp32/re1.5/library.json index 8233b2142..7584bee24 100644 --- a/lib/libesp32/re1.5/library.json +++ b/lib/libesp32/re1.5/library.json @@ -8,6 +8,6 @@ "type": "git", "url": "https://github.com/pfalcon/re1.5" }, - "frameworks": "*", - "platforms": "*" + "frameworks": "arduino", + "platforms": "espressif32" } \ No newline at end of file diff --git a/lib/libesp32_div/esp32-camera/library.json b/lib/libesp32_div/esp32-camera/library.json index 2147a3908..2f2c9fc1b 100644 --- a/lib/libesp32_div/esp32-camera/library.json +++ b/lib/libesp32_div/esp32-camera/library.json @@ -7,8 +7,8 @@ "type": "git", "url": "https://github.com/espressif/esp32-camera" }, - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "build": { "flags": [ "-Idriver/include", @@ -16,8 +16,7 @@ "-Idriver/private_include", "-Iconversions/private_include", "-Isensors/private_include", - "-Itarget/private_include", - "-fno-rtti" + "-Itarget/private_include" ], "includeDir": ".", "srcDir": ".", diff --git a/lib/libesp32_lvgl/freetype/library.json b/lib/libesp32_lvgl/freetype/library.json index 1349b099a..f8864de49 100644 --- a/lib/libesp32_lvgl/freetype/library.json +++ b/lib/libesp32_lvgl/freetype/library.json @@ -8,8 +8,8 @@ "type": "git", "url": "https://gitlab.freedesktop.org/freetype" }, - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "build": { "srcFilter": [ "+", diff --git a/lib/libesp32_lvgl/lv_berry/library.json b/lib/libesp32_lvgl/lv_berry/library.json index c5cd36d2f..cecb243ce 100644 --- a/lib/libesp32_lvgl/lv_berry/library.json +++ b/lib/libesp32_lvgl/lv_berry/library.json @@ -4,8 +4,8 @@ "description": "Mapping of LVGL functions to Berry", "license": "MIT", "homepage": "https://github.com/arendst/Tasmota", - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "authors": { "name": "Stephan Hadinger", diff --git a/lib/libesp32_lvgl/lvgl/library.json b/lib/libesp32_lvgl/lvgl/library.json index 4582bb729..441a52235 100644 --- a/lib/libesp32_lvgl/lvgl/library.json +++ b/lib/libesp32_lvgl/lvgl/library.json @@ -12,8 +12,8 @@ }, "license": "MIT", "homepage": "https://lvgl.io", - "frameworks": "*", - "platforms": "*", + "frameworks": "arduino", + "platforms": "espressif32", "build": { "flags": [ "-I$PROJECT_DIR/tasmota/lvgl_berry" ] } From 85731148c52b4121b2808ff1ced47cf3658f762d Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 18 Dec 2021 14:30:25 +0100 Subject: [PATCH 16/31] Refactor GPIO_HEARTBEAT Remove delay from interrupt by refactoring GPIO_HEARTBEAT --- tasmota/support_rtc.ino | 6 ------ tasmota/support_tasmota.ino | 6 ++++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tasmota/support_rtc.ino b/tasmota/support_rtc.ino index 03b7164fa..fe5fd10ec 100644 --- a/tasmota/support_rtc.ino +++ b/tasmota/support_rtc.ino @@ -377,12 +377,6 @@ void RtcSecond(void) static uint32_t last_sync = 0; static bool mutex = false; - if ((TasmotaGlobal.init_state >= INIT_GPIOS) && PinUsed(GPIO_HEARTBEAT)) { - digitalWrite(Pin(GPIO_HEARTBEAT), ~TasmotaGlobal.heartbeat_inverted &1); - delayMicroseconds(50); - digitalWrite(Pin(GPIO_HEARTBEAT), TasmotaGlobal.heartbeat_inverted); - } - if (mutex) { return; } if (Rtc.time_synced) { diff --git a/tasmota/support_tasmota.ino b/tasmota/support_tasmota.ino index 3129c2831..72a1b7ced 100644 --- a/tasmota/support_tasmota.ino +++ b/tasmota/support_tasmota.ino @@ -983,6 +983,12 @@ void PerformEverySecond(void) ResetGlobalValues(); + if ((TasmotaGlobal.init_state >= INIT_GPIOS) && PinUsed(GPIO_HEARTBEAT)) { + digitalWrite(Pin(GPIO_HEARTBEAT), ~TasmotaGlobal.heartbeat_inverted &1); + delayMicroseconds(50); + digitalWrite(Pin(GPIO_HEARTBEAT), TasmotaGlobal.heartbeat_inverted); + } + if (Settings->tele_period || (3601 == TasmotaGlobal.tele_period)) { if (TasmotaGlobal.tele_period >= 9999) { if (!TasmotaGlobal.global_state.network_down) { From 2d7a48152bce1f80ef508df221af178d12aaea4f Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sat, 18 Dec 2021 14:47:03 +0100 Subject: [PATCH 17/31] Fix exception 28 on HRG15 Fix exception 28 on HRG15 (#14067) --- tasmota/xsns_90_hrg15.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tasmota/xsns_90_hrg15.ino b/tasmota/xsns_90_hrg15.ino index 46c17b28a..ca90df2ee 100644 --- a/tasmota/xsns_90_hrg15.ino +++ b/tasmota/xsns_90_hrg15.ino @@ -91,7 +91,8 @@ bool Rg15Poll(void) { while (HydreonSerial->available()) { Rg15ReadLine(rg15_buffer); - AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HRG: Received '%s'"), rg15_buffer); + // AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HRG: Received '%s'"), rg15_buffer); + AddLog(LOG_LEVEL_DEBUG_MORE, PSTR("HRG: Received %*_H"), strlen(rg15_buffer), rg15_buffer); Rg15Process(rg15_buffer); } From 7b7913e8f32389b383b68ee0a9433d07c1ac74a1 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 18 Dec 2021 15:14:47 +0100 Subject: [PATCH 18/31] merged, ready for PR2 --- lib/lib_display/LedControl/src/LedControl.cpp | 11 +- lib/lib_display/LedControl/src/LedControl.h | 1 - lib/lib_display/LedControl/src/LedMatrix.cpp | 141 ++- lib/lib_display/LedControl/src/LedMatrix.h | 11 +- .../LedControl/src/font_6x8_UTF8_C2.h | 340 ++++++ .../LedControl/src/font_6x8_UTF8_C3.h | 678 ++++++++++++ .../LedControl/src/font_6x8_base.h | 986 ++++++++++++++++++ .../LedControl/src/font_6x8_horizontal_MSB.h | 267 ----- tasmota/xdsp_19_max7219_matrix.ino | 123 ++- 9 files changed, 2226 insertions(+), 332 deletions(-) create mode 100644 lib/lib_display/LedControl/src/font_6x8_UTF8_C2.h create mode 100644 lib/lib_display/LedControl/src/font_6x8_UTF8_C3.h create mode 100644 lib/lib_display/LedControl/src/font_6x8_base.h delete mode 100644 lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h diff --git a/lib/lib_display/LedControl/src/LedControl.cpp b/lib/lib_display/LedControl/src/LedControl.cpp index 5807aa6af..e2230944c 100644 --- a/lib/lib_display/LedControl/src/LedControl.cpp +++ b/lib/lib_display/LedControl/src/LedControl.cpp @@ -49,7 +49,7 @@ LedControl::LedControl(int dataPin, int clkPin, int csPin, int numDevices) { SPI_CS=csPin; if(numDevices<=0 || numDevices>8 ) numDevices=8; - maxDevices = numDevices; + maxDevices=numDevices; pinMode(SPI_MOSI,OUTPUT); pinMode(SPI_CLK,OUTPUT); pinMode(SPI_CS,OUTPUT); @@ -59,14 +59,14 @@ LedControl::LedControl(int dataPin, int clkPin, int csPin, int numDevices) { status[i]=0x00; for(int i=0;i MAX72XX_MAX_DEVICES) @@ -79,6 +81,7 @@ LedMatrix::LedMatrix(int dataPin, int clkPin, int csPin, unsigned int colums, un textPosY = 0; appendTextBuf[0] = 0; setScrollAppendText(" "); + powerIsOn = false; // initialize all connected MAX7219/MAX7221 devices SPI_MOSI = dataPin; @@ -104,8 +107,9 @@ bool LedMatrix::drawText( const char *str, bool clearBefore) strncpy(textBuf, str, TEXT_BUFFER_SIZE -1); textPosX = 0; textPosY = 0; - textWidth = strlen(textBuf) * charWidth; - if(textWidth < displayWidth) + textLen = countChars(str); + textWidth = textLen * charWidth; + if(textWidth <= displayWidth) { // text fits into the display, place it into the center textPosX = (displayWidth - textWidth) / 2; // center @@ -113,8 +117,8 @@ bool LedMatrix::drawText( const char *str, bool clearBefore) else { // The text ist longer than the display width. Scrolling is needed. - // Append a space between end of text and the beginning of the repeting text. - appendSpace(); + // Add a space in front of text to have a distance to the pervious scroll text. + addSpace(); } drawTextAt(textBuf, textPosX, textPosY); refresh(); // refresh display with the new drawed string content @@ -124,19 +128,90 @@ bool LedMatrix::drawText( const char *str, bool clearBefore) bool LedMatrix::drawTextAt( const char *str, const int x, const int y ) { // draw character by character - unsigned int len = strlen(str); int xPos = x; - for (unsigned int i = 0; i < len; i++) + const char* fontChar = nullptr; + for (unsigned int i = 0; (i= 0x20 && c < 0x80) // basic font + { + fontChar = font_20_7F[c-0x20]; + } + +#ifdef font_6x8_UTF8_C2_h + else if(c == 0xC2) // UTF special characters + { + i++; + c= str[i]; + if(c>= 0xA0 && c < 0xC0) + { + fontChar = font_UTF_C2_A0_BF[c - 0xA0]; + } + } +#endif // font_6x8_UTF8_C2_h + +#ifdef font_6x8_UTF8_C3_h + else if(c == 0xC3) // UTF latin1 + { + i++; + c= str[i]; + if(c>= 0x80 && c < 0xC0) + { + fontChar = font_UTF_C3_80_BF[c - 0x80]; + } + } +#endif // font_6x8_UTF8_C3_h + + else if(c>= 0xC0 && c <= 0xDF) + { + i += 1; // 2 byte UTF sequence + } + else if(c>= 0xE0 && c <= 0xEF) + { + i += 2; // 3 byte UTF sequence + } + else if(c>= 0xF0 && c <= 0xF7) + { + i += 3; // 4 byte UTF sequence + } + + drawCharAt(fontChar, xPos, y); xPos += charWidth; } return true; } +int LedMatrix::countChars( const char* utfText) +{ + int len = 0; + for( int i = 0; (i> 4]; } -void LedMatrix::appendSpace() +void LedMatrix::addSpace() { strncat(textBuf, appendTextBuf, TEXT_BUFFER_SIZE -1); - textWidth = strlen(textBuf) * charWidth; + textPosX = strlen(appendTextBuf) * charWidth; // start scrolling with space + textLen = countChars(textBuf); + textWidth = countChars(textBuf) * charWidth; } void LedMatrix::setRow_allDevices(int row, byte *data) diff --git a/lib/lib_display/LedControl/src/LedMatrix.h b/lib/lib_display/LedControl/src/LedMatrix.h index aec15d052..b77038ecc 100644 --- a/lib/lib_display/LedControl/src/LedMatrix.h +++ b/lib/lib_display/LedControl/src/LedMatrix.h @@ -106,6 +106,8 @@ class LedMatrix void power( bool on ); + bool isPowerOn(); + /** * @brief cleares the display and text buffer * @@ -136,7 +138,7 @@ class LedMatrix */ /** - * @brief Set the a pending string to the scrolling text to set a distance to the repeating text. Usually some spaces are used. + * @brief Adds a string before the scrolling text to set a distance. Usually some spaces are used. * * @param append text to append to the scrolling text before repeating. */ @@ -151,9 +153,10 @@ class LedMatrix private: - bool drawCharAt( char c, int x, int y ); // Draws a character to a defined position + bool drawCharAt( const char* fontChar, int x, int y ); // Draws a character to a defined position + int countChars( const char* utfText); // count the characters of an UTF8 string. To be uesd instead of strlen(). byte revereBitorder(byte b); // returnes the byte in the reverse bit order. - void appendSpace(); // appends characters to the end of the text to get a distance to the repeating scroll text + void addSpace(); // adds characters in front of the text to get a distance to the repeating scroll text // device contrl MAX7219/MAX7221 /** @@ -196,10 +199,12 @@ class LedMatrix int charHeight; char textBuf[TEXT_BUFFER_SIZE]; char appendTextBuf[TEXT_APPEND_BUFFER_SIZE]; + int textLen; // number of UTF8 characters int textWidth; // width of text [pixel] int textPosX; // horizontal pixel position of scrolling text int textPosY; // vertical pixelposition of scrolling text; byte spidata[SPI_BUFFER_SIZE]; // The array for shifting the data to the devices + bool powerIsOn; }; diff --git a/lib/lib_display/LedControl/src/font_6x8_UTF8_C2.h b/lib/lib_display/LedControl/src/font_6x8_UTF8_C2.h new file mode 100644 index 000000000..72854b4da --- /dev/null +++ b/lib/lib_display/LedControl/src/font_6x8_UTF8_C2.h @@ -0,0 +1,340 @@ +// 6x8 ascii font +#ifndef font_6x8_UTF8_C2_h +#define font_6x8_UTF8_C2_h +/** + * additional characters to font_6x8_base.h + * 256 bytes + * + */ + +/* +UTF8 after 0xC2 + …0 …1 …2 …3 …4 …5 …6 …7 …8 …9 …A …B …C …D …E …F +A… NBSP¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ SHY ® ¯ +B… ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ +*/ +const char font_UTF_C2_A0_BF[0xC0-0xA0][8] = { + + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x80 NBSP + { + 0b00000100, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00001110, + 0b00000100, + 0b00000000, + }, // 0x81 ¡ + { + 0b00000000, + 0b00000100, + 0b00001110, + 0b00010000, + 0b00010000, + 0b00001110, + 0b00000100, + 0b00000000, + }, // 0x82 ¢ + { + 0b00000110, + 0b00001001, + 0b00001000, + 0b00011110, + 0b00001000, + 0b00001001, + 0b00010111, + 0b00000000, + }, // 0x83 £ + { + 0b00010001, + 0b00001110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00010001, + 0b00000000, + }, // 0x84 ¤ + { + 0b00010001, + 0b00001010, + 0b00000100, + 0b00011111, + 0b00000100, + 0b00011111, + 0b00000100, + 0b00000000, + }, // 0x85 ¥ + { + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + }, // 0x86 ¦ + { + 0b00001110, + 0b00010001, + 0b00001100, + 0b00001010, + 0b00000110, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x87 § + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00001010, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x88 ¨ + { + 0b00011110, + 0b00100001, + 0b00101101, + 0b00101001, + 0b00101101, + 0b00100001, + 0b00011110, + 0b00000000, + }, // 0x89 © + { + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + 0b00001111, + 0b00000000, + }, // 0x8A ª + { + 0b00000000, + 0b00000000, + 0b00001001, + 0b00010010, + 0b00001001, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x8B « + { + 0b00000000, + 0b00000000, + 0b00111111, + 0b00000001, + 0b00000001, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x8C ¬ + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000001, + 0b00000001, + 0b00000000, + 0b11111111, + 0b00000000, + }, // 0x8D SHY + { + 0b00011110, + 0b00100101, + 0b00101011, + 0b00101101, + 0b00101011, + 0b00100001, + 0b00011110, + 0b00000000, + }, // 0x8E ® + { + 0b00000000, + 0b00001110, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x8F ¯ + { + 0b00001100, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x90 ° + { + 0b00000000, + 0b00000100, + 0b00001110, + 0b00000100, + 0b00000000, + 0b00001110, + 0b00000000, + 0b00000000, + }, // 0x91 ± + { + 0b00011000, + 0b00000100, + 0b00001000, + 0b00011100, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x92 ² + { + 0b00011100, + 0b00001000, + 0b00001100, + 0b00011000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x93 ³ + { + 0b00001100, + 0b00001100, + 0b00001000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x94 ´ + { + 0b00000000, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00011100, + 0b00010000, + 0b00010000, + }, // 0x95 µ + { + 0b00001111, + 0b00010101, + 0b00010101, + 0b00001101, + 0b00000101, + 0b00000101, + 0b00000101, + 0b00000000, + }, // 0x96 ¶ + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00001000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x97 · + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00001110, + 0b00000110, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x98 ¸ + { + 0b00001000, + 0b00011000, + 0b00001000, + 0b00001000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x99 ¹ + { + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + 0b00011110, + 0b00000000, + }, // 0x9A º + { + 0b00000000, + 0b00000000, + 0b00010010, + 0b00001001, + 0b00010010, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x9B » + { + 0b00010000, + 0b00010010, + 0b00010100, + 0b00001011, + 0b00010101, + 0b00000111, + 0b00000001, + 0b00000000, + }, // 0x9C ¼ + { + 0b00010000, + 0b00010010, + 0b00010100, + 0b00001110, + 0b00010001, + 0b00000010, + 0b00000111, + 0b00000000, + }, // 0x9D ½ + { + 0b00110000, + 0b00011010, + 0b00110100, + 0b00001011, + 0b00010101, + 0b00000111, + 0b00000001, + 0b00000000, + }, // 0x9E ¾ + { + 0b00000100, + 0b00000000, + 0b00000100, + 0b00001100, + 0b00010000, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x9F ¿ +}; + +#endif // font_6x8_UTF8_C2_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_6x8_UTF8_C3.h b/lib/lib_display/LedControl/src/font_6x8_UTF8_C3.h new file mode 100644 index 000000000..aa32f434a --- /dev/null +++ b/lib/lib_display/LedControl/src/font_6x8_UTF8_C3.h @@ -0,0 +1,678 @@ +// 6x8 ascii font +#ifndef font_6x8_UTF8_C3_h +#define font_6x8_UTF8_C3_h +/** + * additional characters to font_6x8_base.h + * 512 bytes + * + */ + +/* +UTF8 after 0xC3 + …0 …1 …2 …3 …4 …5 …6 …7 …8 …9 …A …B …C …D …E …F +8… À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï +9… Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß +A… à á â ã ä å æ ç è é ê ë ì í î ï +B… ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ +*/ +const char font_UTF_C3_80_BF[0xC0-0x80][8] = { + + { + 0b00001100, + 0b00000000, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00000000, + }, // 0x80 À + { + 0b00000110, + 0b00000000, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00000000, + }, // 0x81 Á + { + 0b00001110, + 0b00000000, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00000000, + }, // 0x82 Â + { + 0b00000101, + 0b00001010, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00000000, + }, // 0x83 Ã + { + 0b00001010, + 0b00000000, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00000000, + }, // 0x84 Ä + { + 0b00001110, + 0b00001010, + 0b00001110, + 0b00011011, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00000000, + }, // 0x85 Å + { + 0b00000111, + 0b00001100, + 0b00010100, + 0b00010111, + 0b00011100, + 0b00010100, + 0b00010111, + 0b00000000, + }, // 0x86 Æ + { + 0b00001110, + 0b00010001, + 0b00010000, + 0b00010000, + 0b00010001, + 0b00001110, + 0b00000100, + 0b00001100, + }, // 0x87 Ç + { + 0b00001100, + 0b00000000, + 0b00011111, + 0b00010000, + 0b00011110, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x88 È + + { + 0b00000011, + 0b00000000, + 0b00011111, + 0b00010000, + 0b00011110, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x89 É + { + 0b00001110, + 0b00000000, + 0b00011111, + 0b00010000, + 0b00011110, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x8A Ê + { + 0b00001010, + 0b00000000, + 0b00011111, + 0b00010000, + 0b00011110, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x8B Ë + { + 0b00001100, + 0b00000000, + 0b00001110, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00000000, + }, // 0x8C Ì + { + 0b00000110, + 0b00000000, + 0b00001110, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00000000, + }, // 0x8D Í + { + 0b00001110, + 0b00000000, + 0b00001110, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00000000, + }, // 0x8E Î + { + 0b00001010, + 0b00000000, + 0b00001110, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00000000, + }, // 0x8F Ï + + { + 0b00001110, + 0b00001001, + 0b00001001, + 0b00011101, + 0b00001001, + 0b00001001, + 0b00001110, + 0b00000000, + }, // 0x90 Ð + { + 0b00001010, + 0b00010100, + 0b00000000, + 0b00010010, + 0b00011010, + 0b00010110, + 0b00010010, + 0b00000000, + }, // 0x91 Ñ + { + 0b00011000, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x92 Ò + { + 0b00000110, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x93 Ó + { + 0b00001110, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x94 Ô + { + 0b00001010, + 0b00010100, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x95 Õ + { + 0b00010010, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x96 Ö + { + 0b00000000, + 0b00010001, + 0b00001010, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00000000, + 0b00000000, + }, // 0x97 × + { + 0b00001111, + 0b00010011, + 0b00010101, + 0b00010101, + 0b00010101, + 0b00011001, + 0b00011110, + 0b00000000, + }, // 0x98 Ø + + { + 0b00011000, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x99 Ù + { + 0b00000110, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x9A Ú + { + 0b00001110, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x9B Û + { + 0b00001010, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0x9C Ü + { + 0b00000110, + 0b00000000, + 0b00010001, + 0b00001010, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + }, // 0x9D Ý + { + 0b00011000, + 0b00010000, + 0b00011100, + 0b00010010, + 0b00010010, + 0b00011100, + 0b00010000, + 0b00011000, + }, // 0x9E Þ + { + 0b00000000, + 0b00011100, + 0b00010010, + 0b00011100, + 0b00010010, + 0b00010010, + 0b00011100, + 0b00010000, + }, // 0x9F ß + + { + 0b00001100, + 0b00000000, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0xA0 à + { + 0b00000110, + 0b00000000, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0xA1 á + { + 0b00001110, + 0b00000000, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0xA2 â + { + 0b00000101, + 0b00001010, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0xA3 ã + { + 0b00001010, + 0b00000000, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0xA4 ä + { + 0b00001110, + 0b00001010, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0xA5 å + { + 0b00000000, + 0b00000000, + 0b00011110, + 0b00000101, + 0b00011111, + 0b00010100, + 0b00001111, + 0b00000000, + }, // 0xA6 æ + { + 0b00000000, + 0b00001110, + 0b00010001, + 0b00010000, + 0b00010001, + 0b00001110, + 0b00000100, + 0b00001100, + }, // 0xA7 ç + { + 0b00001100, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00011110, + 0b00010000, + 0b00001110, + 0b00000000, + }, // 0xA8 è + { + 0b00000011, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00011110, + 0b00010000, + 0b00001110, + 0b00000000, + }, // 0xA9 é + { + 0b00001110, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00011110, + 0b00010000, + 0b00001110, + 0b00000000, + }, // 0xAA ê + { + 0b00001010, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00011110, + 0b00010000, + 0b00001110, + 0b00000000, + }, // 0xAB ë + { + 0b00001000, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000110, + 0b00000000, + }, // 0xAC ì + { + 0b00000110, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000110, + 0b00000000, + }, // 0xAD í + { + 0b00000110, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000110, + 0b00000000, + }, // 0xAE î + { + 0b00001010, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000110, + 0b00000000, + }, // 0xAF ï + + { + 0b00001100, + 0b00010000, + 0b00001000, + 0b00000100, + 0b00001110, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0xB0 ð + { + 0b00001010, + 0b00010100, + 0b00000000, + 0b00011100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00000000, + }, // 0xB1 ñ + { + 0b00011000, + 0b00000000, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0xB2 ò + { + 0b00000110, + 0b00000000, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0xB3 ó + { + 0b00001110, + 0b00000000, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0xB4 ô + { + 0b00001010, + 0b00010100, + 0b00000000, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0xB5 õ + { + 0b00001010, + 0b00000000, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00000000, + }, // 0xB6 ö + { + 0b00000000, + 0b00000100, + 0b00000000, + 0b00011111, + 0b00000000, + 0b00000100, + 0b00000000, + 0b00000000, + }, // 0xB7 ÷ + { + 0b00000000, + 0b00000000, + 0b00000001, + 0b00001110, + 0b00010110, + 0b00011010, + 0b00011100, + 0b00100000, + }, // 0xB8 ø + { + 0b00011000, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010110, + 0b00001010, + 0b00000000, + }, // 0xB9 ù + { + 0b00000110, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010110, + 0b00001010, + 0b00000000, + }, // 0xBA ú + { + 0b00001110, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010110, + 0b00001010, + 0b00000000, + }, // 0xBB û + { + 0b00010010, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010110, + 0b00001010, + 0b00000000, + }, // 0xBC ü + { + 0b00000110, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001110, + 0b00000100, + 0b00011000, + }, // 0xBD ý + { + 0b00000000, + 0b00011000, + 0b00010000, + 0b00011100, + 0b00010010, + 0b00011100, + 0b00010000, + 0b00011000, + }, // 0xBE þ + { + 0b00001010, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001110, + 0b00000100, + 0b00011000, + }, // 0xBF ÿ +}; + +/* +ISO/IEC 8859-1 (latin1) + …0 …1 …2 …3 …4 …5 …6 …7 …8 …9 …A …B …C …D …E …F +A… NBSP ¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ SHY ® ¯ +B… ° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ +C… À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï +D… Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß +E… à á â ã ä å æ ç è é ê ë ì í î ï +F… ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ +*/ + +#endif // font_6x8_UTF8_C3_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_6x8_base.h b/lib/lib_display/LedControl/src/font_6x8_base.h new file mode 100644 index 000000000..084b28c00 --- /dev/null +++ b/lib/lib_display/LedControl/src/font_6x8_base.h @@ -0,0 +1,986 @@ +// 6x8 ascii font +#ifndef font_6x8_base_h +#define font_6x8_base_h +/** + * Momory size of basic ascii font: 768 bytes + * + */ + +/* + …0 …1 …2 …3 …4 …5 …6 …7 …8 …9 …A …B …C …D …E …F +2… SP ! " # $ % & ' ( ) * + , - . / +3… 0 1 2 3 4 5 6 7 8 9 : ; < = > ? +4… @ A B C D E F G H I J K L M N O +5… P Q R S T U V W X Y Z [ \ ] ^ _ +6… ` a b c d e f g h i j k l m n o +7… p q r s t u v w x y z { | } ~ +*/ + +const unsigned int font_char_width = 6; +const unsigned int font_char_height = 8; + +const char font_20_7F[0x80-0x20][8] = { + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x20 + { + 0b00000100, + 0b00001110, + 0b00001110, + 0b00000100, + 0b00000100, + 0b00000000, + 0b00000100, + 0b00000000, + }, // 0x21 ! + { + 0b00011011, + 0b00011011, + 0b00010010, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x22 " + { + 0b00000000, + 0b00001010, + 0b00011111, + 0b00001010, + 0b00001010, + 0b00011111, + 0b00001010, + 0b00000000, + }, // 0x23 # + { + 0b00001000, + 0b00001110, + 0b00010000, + 0b00001100, + 0b00000010, + 0b00011100, + 0b00000100, + 0b00000000, + }, // 0x24 $ + { + 0b00011001, + 0b00011001, + 0b00000010, + 0b00000100, + 0b00001000, + 0b00010011, + 0b00010011, + 0b00000000, + }, // 0x25 % + { + 0b00001000, + 0b00010100, + 0b00010100, + 0b00001000, + 0b00010101, + 0b00010010, + 0b00001101, + 0b00000000, + }, // 0x26 & + { + 0b00001100, + 0b00001100, + 0b00001000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x27 ' + { + 0b00000100, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00000100, + 0b00000000, + }, // 0x28 ( + { + 0b00001000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001000, + 0b00000000, + }, // 0x29 ) + { + 0b00000000, + 0b00001010, + 0b00001110, + 0b00011111, + 0b00001110, + 0b00001010, + 0b00000000, + 0b00000000, + }, // 0x2A * + { + 0b00000000, + 0b00000100, + 0b00000100, + 0b00011111, + 0b00000100, + 0b00000100, + 0b00000000, + 0b00000000, + }, // 0x2B + + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00001100, + 0b00001100, + 0b00001000, + }, // 0x2C , + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00011111, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x2D - + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00001100, + 0b00001100, + 0b00000000, + }, // 0x2E . + { + 0b00000000, + 0b00000001, + 0b00000010, + 0b00000100, + 0b00001000, + 0b00010000, + 0b00000000, + 0b00000000, + }, // 0x2F / + { + 0b00001110, + 0b00010001, + 0b00010011, + 0b00010101, + 0b00011001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x30 0 + { + 0b00000100, + 0b00001100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00000000, + }, // 0x31 1 + { + 0b00001110, + 0b00010001, + 0b00000001, + 0b00000110, + 0b00001000, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x32 2 + { + 0b00001110, + 0b00010001, + 0b00000001, + 0b00001110, + 0b00000001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x33 3 + { + 0b00000010, + 0b00000110, + 0b00001010, + 0b00010010, + 0b00011111, + 0b00000010, + 0b00000010, + 0b00000000, + }, // 0x34 4 + { + 0b00011111, + 0b00010000, + 0b00010000, + 0b00011110, + 0b00000001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x35 5 + { + 0b00000110, + 0b00001000, + 0b00010000, + 0b00011110, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x36 6 + { + 0b00011111, + 0b00000001, + 0b00000010, + 0b00000100, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00000000, + }, // 0x37 7 + { + 0b00001110, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x38 8 + { + 0b00001110, + 0b00010001, + 0b00010001, + 0b00001111, + 0b00000001, + 0b00000010, + 0b00001100, + 0b00000000, + }, // 0x39 9 + { + 0b00000000, + 0b00000000, + 0b00001100, + 0b00001100, + 0b00000000, + 0b00001100, + 0b00001100, + 0b00000000, + }, // 0x3A : + { + 0b00000000, + 0b00000000, + 0b00001100, + 0b00001100, + 0b00000000, + 0b00001100, + 0b00001100, + 0b00001000, + }, // 0x3B ; + { + 0b00000010, + 0b00000100, + 0b00001000, + 0b00010000, + 0b00001000, + 0b00000100, + 0b00000010, + 0b00000000, + }, // 0x3C < + { + 0b00000000, + 0b00000000, + 0b00011111, + 0b00000000, + 0b00000000, + 0b00011111, + 0b00000000, + 0b00000000, + }, // 0x3D = + { + 0b00001000, + 0b00000100, + 0b00000010, + 0b00000001, + 0b00000010, + 0b00000100, + 0b00001000, + 0b00000000, + }, // 0x3E > + { + 0b00001110, + 0b00010001, + 0b00000001, + 0b00000110, + 0b00000100, + 0b00000000, + 0b00000100, + 0b00000000, + }, // 0x3F ? + + { + 0b00001110, + 0b00010001, + 0b00010111, + 0b00010101, + 0b00010111, + 0b00010000, + 0b00001110, + 0b00000000, + }, // 0x40 @ + { + 0b00001110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x41 A + { + 0b00011110, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00000000, + }, // 0x42 B + { + 0b00001110, + 0b00010001, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x43 C + { + 0b00011110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00000000, + }, // 0x44 D + { + 0b00011111, + 0b00010000, + 0b00010000, + 0b00011110, + 0b00010000, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x45 E + { + 0b00011111, + 0b00010000, + 0b00010000, + 0b00011110, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00000000, + }, // 0x46 F + { + 0b00001110, + 0b00010001, + 0b00010000, + 0b00010111, + 0b00010001, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0x47 G + { + 0b00010001, + 0b00010001, + 0b00010001, + 0b00011111, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x48 H + { + 0b00001110, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00001110, + 0b00000000, + }, // 0x49 I + { + 0b00000001, + 0b00000001, + 0b00000001, + 0b00000001, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x4A J + { + 0b00010001, + 0b00010010, + 0b00010100, + 0b00011000, + 0b00010100, + 0b00010010, + 0b00010001, + 0b00000000, + }, // 0x4B K + { + 0b00010000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00011111, + 0b00000000, + }, // 0x4C L + { + 0b00010001, + 0b00011011, + 0b00010101, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x4D M + { + 0b00010001, + 0b00011001, + 0b00010101, + 0b00010011, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x4E N + { + 0b00001110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x4F O + { + 0b00011110, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00010000, + 0b00010000, + 0b00010000, + 0b00000000, + }, // 0x50 P + { + 0b00001110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010101, + 0b00010010, + 0b00001101, + 0b00000000, + }, // 0x51 Q + { + 0b00011110, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00010010, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x52 R + { + 0b00001110, + 0b00010001, + 0b00010000, + 0b00001110, + 0b00000001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x53 S + { + 0b00011111, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + }, // 0x54 T + { + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x55 U + { + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001010, + 0b00000100, + 0b00000000, + }, // 0x56 V + { + 0b00010001, + 0b00010001, + 0b00010101, + 0b00010101, + 0b00010101, + 0b00010101, + 0b00001010, + 0b00000000, + }, // 0x57 W + { + 0b00010001, + 0b00010001, + 0b00001010, + 0b00000100, + 0b00001010, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x58 X + { + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001010, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + }, // 0x59 Y + { + 0b00011110, + 0b00000010, + 0b00000100, + 0b00001000, + 0b00010000, + 0b00010000, + 0b00011110, + 0b00000000, + }, // 0x5A Z + { + 0b00001110, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00001110, + 0b00000000, + }, // 0x5B [ + { + 0b00000000, + 0b00010000, + 0b00001000, + 0b00000100, + 0b00000010, + 0b00000001, + 0b00000000, + 0b00000000, + }, // 0x5C backslash + { + 0b00001110, + 0b00000010, + 0b00000010, + 0b00000010, + 0b00000010, + 0b00000010, + 0b00001110, + 0b00000000, + }, // 0x5D ] + { + 0b00000100, + 0b00001010, + 0b00010001, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x5E ^ + { + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00111111, + }, // 0x5F _ + { + 0b00001100, + 0b00001100, + 0b00000100, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x60 ` + { + 0b00000000, + 0b00000000, + 0b00001110, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0x61 a + { + 0b00010000, + 0b00010000, + 0b00011110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00000000, + }, // 0x62 b + { + 0b00000000, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00010000, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x63 c + { + 0b00000001, + 0b00000001, + 0b00001111, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001111, + 0b00000000, + }, // 0x64 d + { + 0b00000000, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00011110, + 0b00010000, + 0b00001110, + 0b00000000, + }, // 0x65 e + { + 0b00000110, + 0b00001000, + 0b00001000, + 0b00011110, + 0b00001000, + 0b00001000, + 0b00001000, + 0b00000000, + }, // 0x66 f + { + 0b00000000, + 0b00000000, + 0b00001111, + 0b00010001, + 0b00010001, + 0b00001111, + 0b00000001, + 0b00001110, + }, // 0x67 g + { + 0b00010000, + 0b00010000, + 0b00011100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00000000, + }, // 0x68 h + { + 0b00000100, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000110, + 0b00000000, + }, // 0x69 i + { + 0b00000010, + 0b00000000, + 0b00000110, + 0b00000010, + 0b00000010, + 0b00000010, + 0b00010010, + 0b00001100, + }, // 0x6A j + { + 0b00010000, + 0b00010000, + 0b00010010, + 0b00010100, + 0b00011000, + 0b00010100, + 0b00010010, + 0b00000000, + }, // 0x6B k + { + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000110, + 0b00000000, + }, // 0x6C l + { + 0b00000000, + 0b00000000, + 0b00011010, + 0b00010101, + 0b00010101, + 0b00010001, + 0b00010001, + 0b00000000, + }, // 0x6D m + { + 0b00000000, + 0b00000000, + 0b00011100, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00000000, + }, // 0x6E n + { + 0b00000000, + 0b00000000, + 0b00001110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001110, + 0b00000000, + }, // 0x6F o + { + 0b00000000, + 0b00000000, + 0b00011110, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00011110, + 0b00010000, + }, // 0x70 p + { + 0b00000000, + 0b00000000, + 0b00001111, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001111, + 0b00000001, + }, // 0x71 q + { + 0b00000000, + 0b00000000, + 0b00010110, + 0b00001001, + 0b00001000, + 0b00001000, + 0b00011100, + 0b00000000, + }, // 0x72 r + { + 0b00000000, + 0b00000000, + 0b00001110, + 0b00010000, + 0b00001110, + 0b00000001, + 0b00001110, + 0b00000000, + }, // 0x73 s + { + 0b00000000, + 0b00001000, + 0b00011110, + 0b00001000, + 0b00001000, + 0b00001010, + 0b00000100, + 0b00000000, + }, // 0x74 t + { + 0b00000000, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00010110, + 0b00001010, + 0b00000000, + }, // 0x75 u + { + 0b00000000, + 0b00000000, + 0b00010001, + 0b00010001, + 0b00010001, + 0b00001010, + 0b00000100, + 0b00000000, + }, // 0x76 v + { + 0b00000000, + 0b00000000, + 0b00010001, + 0b00010001, + 0b00010101, + 0b00011111, + 0b00001010, + 0b00000000, + }, // 0x77 w + { + 0b00000000, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00001100, + 0b00010010, + 0b00010010, + 0b00000000, + }, // 0x78 x + { + 0b00000000, + 0b00000000, + 0b00010010, + 0b00010010, + 0b00010010, + 0b00001110, + 0b00000100, + 0b00011000, + }, // 0x79 y + { + 0b00000000, + 0b00000000, + 0b00011110, + 0b00000010, + 0b00001100, + 0b00010000, + 0b00011110, + 0b00000000, + }, // 0x7A z + { + 0b00000110, + 0b00001000, + 0b00001000, + 0b00011000, + 0b00001000, + 0b00001000, + 0b00000110, + 0b00000000, + }, // 0x7B { + { + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + 0b00000100, + 0b00000100, + 0b00000100, + 0b00000000, + }, // 0x7C | + { + 0b00001100, + 0b00000010, + 0b00000010, + 0b00000011, + 0b00000010, + 0b00000010, + 0b00001100, + 0b00000000, + }, // 0x7D } + { + 0b00001010, + 0b00010100, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + 0b00000000, + }, // 0x7E ~ + { + 0b00000100, + 0b00001110, + 0b00011011, + 0b00010001, + 0b00010001, + 0b00011111, + 0b00000000, + 0b00000000, + }, // 0x7F ␡ +}; + +#endif // font_6x8_base_h \ No newline at end of file diff --git a/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h b/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h deleted file mode 100644 index e5c522cd4..000000000 --- a/lib/lib_display/LedControl/src/font_6x8_horizontal_MSB.h +++ /dev/null @@ -1,267 +0,0 @@ -// 6x8 ascii font -#ifndef font_6x8_horizontal_MSB_h -#define font_6x8_horizontal_MSB_h - -const unsigned int font_char_width = 6; -const unsigned int font_char_height = 8; - -const char font[256][8]={ -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 -{0x0E,0x11,0x1B,0x11,0x15,0x11,0x0E,0x00}, // 0x01 -{0x0E,0x1F,0x15,0x1F,0x11,0x1F,0x0E,0x00}, // 0x02 -{0x00,0x0A,0x1F,0x1F,0x1F,0x0E,0x04,0x00}, // 0x03 -{0x00,0x04,0x0E,0x1F,0x1F,0x0E,0x04,0x00}, // 0x04 -{0x04,0x0E,0x0E,0x04,0x1F,0x1F,0x04,0x00}, // 0x05 -{0x00,0x04,0x0E,0x1F,0x1F,0x04,0x0E,0x00}, // 0x06 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A -{0x00,0x07,0x03,0x0D,0x12,0x12,0x0C,0x00}, // 0x0B -{0x0E,0x11,0x11,0x0E,0x04,0x0E,0x04,0x00}, // 0x0C -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D -{0x03,0x0D,0x0B,0x0D,0x0B,0x1B,0x18,0x00}, // 0x0E -{0x00,0x15,0x0E,0x1B,0x0E,0x15,0x00,0x00}, // 0x0F -{0x08,0x0C,0x0E,0x0F,0x0E,0x0C,0x08,0x00}, // 0x10 -{0x02,0x06,0x0E,0x1E,0x0E,0x06,0x02,0x00}, // 0x11 -{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x00}, // 0x12 -{0x0A,0x0A,0x0A,0x0A,0x0A,0x00,0x0A,0x00}, // 0x13 -{0x0F,0x15,0x15,0x0D,0x05,0x05,0x05,0x00}, // 0x14 -{0x0E,0x11,0x0C,0x0A,0x06,0x11,0x0E,0x00}, // 0x15 -{0x00,0x00,0x00,0x00,0x00,0x1E,0x1E,0x00}, // 0x16 -{0x04,0x0E,0x1F,0x04,0x1F,0x0E,0x04,0x0E}, // 0x17 -{0x04,0x0E,0x1F,0x04,0x04,0x04,0x04,0x00}, // 0x18 -{0x04,0x04,0x04,0x04,0x1F,0x0E,0x04,0x00}, // 0x19 -{0x00,0x04,0x06,0x1F,0x06,0x04,0x00,0x00}, // 0x1A -{0x00,0x04,0x0C,0x1F,0x0C,0x04,0x00,0x00}, // 0x1B -{0x00,0x00,0x00,0x10,0x10,0x10,0x1F,0x00}, // 0x1C -{0x00,0x0A,0x0A,0x1F,0x0A,0x0A,0x00,0x00}, // 0x1D -{0x04,0x04,0x0E,0x0E,0x1F,0x1F,0x00,0x00}, // 0x1E -{0x1F,0x1F,0x0E,0x0E,0x04,0x04,0x00,0x00}, // 0x1F -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20 -{0x04,0x0E,0x0E,0x04,0x04,0x00,0x04,0x00}, // 0x21 -{0x1B,0x1B,0x12,0x00,0x00,0x00,0x00,0x00}, // 0x22 -{0x00,0x0A,0x1F,0x0A,0x0A,0x1F,0x0A,0x00}, // 0x23 -{0x08,0x0E,0x10,0x0C,0x02,0x1C,0x04,0x00}, // 0x24 -{0x19,0x19,0x02,0x04,0x08,0x13,0x13,0x00}, // 0x25 -{0x08,0x14,0x14,0x08,0x15,0x12,0x0D,0x00}, // 0x26 -{0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00}, // 0x27 -{0x04,0x08,0x08,0x08,0x08,0x08,0x04,0x00}, // 0x28 -{0x08,0x04,0x04,0x04,0x04,0x04,0x08,0x00}, // 0x29 -{0x00,0x0A,0x0E,0x1F,0x0E,0x0A,0x00,0x00}, // 0x2A -{0x00,0x04,0x04,0x1F,0x04,0x04,0x00,0x00}, // 0x2B -{0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x08}, // 0x2C -{0x00,0x00,0x00,0x1F,0x00,0x00,0x00,0x00}, // 0x2D -{0x00,0x00,0x00,0x00,0x00,0x0C,0x0C,0x00}, // 0x2E -{0x00,0x01,0x02,0x04,0x08,0x10,0x00,0x00}, // 0x2F -{0x0E,0x11,0x13,0x15,0x19,0x11,0x0E,0x00}, // 0x30 -{0x04,0x0C,0x04,0x04,0x04,0x04,0x0E,0x00}, // 0x31 -{0x0E,0x11,0x01,0x06,0x08,0x10,0x1F,0x00}, // 0x32 -{0x0E,0x11,0x01,0x0E,0x01,0x11,0x0E,0x00}, // 0x33 -{0x02,0x06,0x0A,0x12,0x1F,0x02,0x02,0x00}, // 0x34 -{0x1F,0x10,0x10,0x1E,0x01,0x11,0x0E,0x00}, // 0x35 -{0x06,0x08,0x10,0x1E,0x11,0x11,0x0E,0x00}, // 0x36 -{0x1F,0x01,0x02,0x04,0x08,0x08,0x08,0x00}, // 0x37 -{0x0E,0x11,0x11,0x0E,0x11,0x11,0x0E,0x00}, // 0x38 -{0x0E,0x11,0x11,0x0F,0x01,0x02,0x0C,0x00}, // 0x39 -{0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x00}, // 0x3A -{0x00,0x00,0x0C,0x0C,0x00,0x0C,0x0C,0x08}, // 0x3B -{0x02,0x04,0x08,0x10,0x08,0x04,0x02,0x00}, // 0x3C -{0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00}, // 0x3D -{0x08,0x04,0x02,0x01,0x02,0x04,0x08,0x00}, // 0x3E -{0x0E,0x11,0x01,0x06,0x04,0x00,0x04,0x00}, // 0x3F -{0x0E,0x11,0x17,0x15,0x17,0x10,0x0E,0x00}, // 0x40 -{0x0E,0x11,0x11,0x11,0x1F,0x11,0x11,0x00}, // 0x41 -{0x1E,0x11,0x11,0x1E,0x11,0x11,0x1E,0x00}, // 0x42 -{0x0E,0x11,0x10,0x10,0x10,0x11,0x0E,0x00}, // 0x43 -{0x1E,0x11,0x11,0x11,0x11,0x11,0x1E,0x00}, // 0x44 -{0x1F,0x10,0x10,0x1E,0x10,0x10,0x1F,0x00}, // 0x45 -{0x1F,0x10,0x10,0x1E,0x10,0x10,0x10,0x00}, // 0x46 -{0x0E,0x11,0x10,0x17,0x11,0x11,0x0F,0x00}, // 0x47 -{0x11,0x11,0x11,0x1F,0x11,0x11,0x11,0x00}, // 0x48 -{0x0E,0x04,0x04,0x04,0x04,0x04,0x0E,0x00}, // 0x49 -{0x01,0x01,0x01,0x01,0x11,0x11,0x0E,0x00}, // 0x4A -{0x11,0x12,0x14,0x18,0x14,0x12,0x11,0x00}, // 0x4B -{0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0x00}, // 0x4C -{0x11,0x1B,0x15,0x11,0x11,0x11,0x11,0x00}, // 0x4D -{0x11,0x19,0x15,0x13,0x11,0x11,0x11,0x00}, // 0x4E -{0x0E,0x11,0x11,0x11,0x11,0x11,0x0E,0x00}, // 0x4F -{0x1E,0x11,0x11,0x1E,0x10,0x10,0x10,0x00}, // 0x50 -{0x0E,0x11,0x11,0x11,0x15,0x12,0x0D,0x00}, // 0x51 -{0x1E,0x11,0x11,0x1E,0x12,0x11,0x11,0x00}, // 0x52 -{0x0E,0x11,0x10,0x0E,0x01,0x11,0x0E,0x00}, // 0x53 -{0x1F,0x04,0x04,0x04,0x04,0x04,0x04,0x00}, // 0x54 -{0x11,0x11,0x11,0x11,0x11,0x11,0x0E,0x00}, // 0x55 -{0x11,0x11,0x11,0x11,0x11,0x0A,0x04,0x00}, // 0x56 -{0x11,0x11,0x15,0x15,0x15,0x15,0x0A,0x00}, // 0x57 -{0x11,0x11,0x0A,0x04,0x0A,0x11,0x11,0x00}, // 0x58 -{0x11,0x11,0x11,0x0A,0x04,0x04,0x04,0x00}, // 0x59 -{0x1E,0x02,0x04,0x08,0x10,0x10,0x1E,0x00}, // 0x5A -{0x0E,0x08,0x08,0x08,0x08,0x08,0x0E,0x00}, // 0x5B -{0x00,0x10,0x08,0x04,0x02,0x01,0x00,0x00}, // 0x5C -{0x0E,0x02,0x02,0x02,0x02,0x02,0x0E,0x00}, // 0x5D -{0x04,0x0A,0x11,0x00,0x00,0x00,0x00,0x00}, // 0x5E -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F}, // 0x5F -{0x0C,0x0C,0x04,0x00,0x00,0x00,0x00,0x00}, // 0x60 -{0x00,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x61 -{0x10,0x10,0x1E,0x11,0x11,0x11,0x1E,0x00}, // 0x62 -{0x00,0x00,0x0E,0x11,0x10,0x11,0x0E,0x00}, // 0x63 -{0x01,0x01,0x0F,0x11,0x11,0x11,0x0F,0x00}, // 0x64 -{0x00,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x65 -{0x06,0x08,0x08,0x1E,0x08,0x08,0x08,0x00}, // 0x66 -{0x00,0x00,0x0F,0x11,0x11,0x0F,0x01,0x0E}, // 0x67 -{0x10,0x10,0x1C,0x12,0x12,0x12,0x12,0x00}, // 0x68 -{0x04,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x69 -{0x02,0x00,0x06,0x02,0x02,0x02,0x12,0x0C}, // 0x6A -{0x10,0x10,0x12,0x14,0x18,0x14,0x12,0x00}, // 0x6B -{0x04,0x04,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x6C -{0x00,0x00,0x1A,0x15,0x15,0x11,0x11,0x00}, // 0x6D -{0x00,0x00,0x1C,0x12,0x12,0x12,0x12,0x00}, // 0x6E -{0x00,0x00,0x0E,0x11,0x11,0x11,0x0E,0x00}, // 0x6F -{0x00,0x00,0x1E,0x11,0x11,0x11,0x1E,0x10}, // 0x70 -{0x00,0x00,0x0F,0x11,0x11,0x11,0x0F,0x01}, // 0x71 -{0x00,0x00,0x16,0x09,0x08,0x08,0x1C,0x00}, // 0x72 -{0x00,0x00,0x0E,0x10,0x0E,0x01,0x0E,0x00}, // 0x73 -{0x00,0x08,0x1E,0x08,0x08,0x0A,0x04,0x00}, // 0x74 -{0x00,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x75 -{0x00,0x00,0x11,0x11,0x11,0x0A,0x04,0x00}, // 0x76 -{0x00,0x00,0x11,0x11,0x15,0x1F,0x0A,0x00}, // 0x77 -{0x00,0x00,0x12,0x12,0x0C,0x12,0x12,0x00}, // 0x78 -{0x00,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0x79 -{0x00,0x00,0x1E,0x02,0x0C,0x10,0x1E,0x00}, // 0x7A -{0x06,0x08,0x08,0x18,0x08,0x08,0x06,0x00}, // 0x7B -{0x04,0x04,0x04,0x00,0x04,0x04,0x04,0x00}, // 0x7C -{0x0C,0x02,0x02,0x03,0x02,0x02,0x0C,0x00}, // 0x7D -{0x0A,0x14,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x7E -{0x04,0x0E,0x1B,0x11,0x11,0x1F,0x00,0x00}, // 0x7F -{0x0E,0x11,0x10,0x10,0x11,0x0E,0x04,0x0C}, // 0x80 -{0x12,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x81 -{0x03,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x82 -{0x0E,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x83 -{0x0A,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x84 -{0x0C,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x85 -{0x0E,0x0A,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0x86 -{0x00,0x0E,0x11,0x10,0x11,0x0E,0x04,0x0C}, // 0x87 -{0x0E,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x88 -{0x0A,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x89 -{0x0C,0x00,0x0E,0x11,0x1E,0x10,0x0E,0x00}, // 0x8A -{0x0A,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8B -{0x0E,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8C -{0x08,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0x8D -{0x0A,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0x8E -{0x0E,0x0A,0x0E,0x1B,0x11,0x1F,0x11,0x00}, // 0x8F -{0x03,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0x90 -{0x00,0x00,0x1E,0x05,0x1F,0x14,0x0F,0x00}, // 0x91 -{0x0F,0x14,0x14,0x1F,0x14,0x14,0x17,0x00}, // 0x92 -{0x0E,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x93 -{0x0A,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x94 -{0x18,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0x95 -{0x0E,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x96 -{0x18,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0x97 -{0x0A,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0x98 -{0x12,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x99 -{0x0A,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0x9A -{0x00,0x00,0x01,0x0E,0x16,0x1A,0x1C,0x20}, // 0x9B -{0x06,0x09,0x08,0x1E,0x08,0x09,0x17,0x00}, // 0x9C -{0x0F,0x13,0x15,0x15,0x15,0x19,0x1E,0x00}, // 0x9D -{0x00,0x11,0x0A,0x04,0x0A,0x11,0x00,0x00}, // 0x9E -{0x02,0x05,0x04,0x0E,0x04,0x04,0x14,0x08}, // 0x9F -{0x06,0x00,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0xA0 -{0x06,0x00,0x04,0x04,0x04,0x04,0x06,0x00}, // 0xA1 -{0x06,0x00,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0xA2 -{0x06,0x00,0x12,0x12,0x12,0x16,0x0A,0x00}, // 0xA3 -{0x0A,0x14,0x00,0x1C,0x12,0x12,0x12,0x00}, // 0xA4 -{0x0A,0x14,0x00,0x12,0x1A,0x16,0x12,0x00}, // 0xA5 -{0x0E,0x01,0x0F,0x11,0x0F,0x00,0x0F,0x00}, // 0xA6 -{0x0C,0x12,0x12,0x12,0x0C,0x00,0x1E,0x00}, // 0xA7 -{0x04,0x00,0x04,0x0C,0x10,0x11,0x0E,0x00}, // 0xA8 -{0x1E,0x25,0x2B,0x2D,0x2B,0x21,0x1E,0x00}, // 0xA9 -{0x00,0x00,0x3F,0x01,0x01,0x00,0x00,0x00}, // 0xAA -{0x10,0x12,0x14,0x0E,0x11,0x02,0x07,0x00}, // 0xAB -{0x10,0x12,0x14,0x0B,0x15,0x07,0x01,0x00}, // 0xAC -{0x04,0x00,0x04,0x04,0x0E,0x0E,0x04,0x00}, // 0xAD -{0x00,0x00,0x09,0x12,0x09,0x00,0x00,0x00}, // 0xAE -{0x00,0x00,0x12,0x09,0x12,0x00,0x00,0x00}, // 0xAF -{0x15,0x00,0x2A,0x00,0x15,0x00,0x2A,0x00}, // 0xB0 -{0x15,0x2A,0x15,0x2A,0x15,0x2A,0x15,0x2A}, // 0xB1 -{0x2A,0x3F,0x15,0x3F,0x2A,0x3F,0x15,0x3F}, // 0xB2 -{0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04}, // 0xB3 -{0x04,0x04,0x04,0x3C,0x04,0x04,0x04,0x04}, // 0xB4 -{0x06,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xB5 -{0x0E,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xB6 -{0x0C,0x00,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xB7 -{0x1E,0x21,0x2D,0x29,0x2D,0x21,0x1E,0x00}, // 0xB8 -{0x14,0x34,0x04,0x34,0x14,0x14,0x14,0x14}, // 0xB9 -{0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14}, // 0xBA -{0x00,0x3C,0x04,0x34,0x14,0x14,0x14,0x14}, // 0xBB -{0x14,0x34,0x04,0x3C,0x00,0x00,0x00,0x00}, // 0xBC -{0x00,0x04,0x0E,0x10,0x10,0x0E,0x04,0x00}, // 0xBD -{0x11,0x0A,0x04,0x1F,0x04,0x1F,0x04,0x00}, // 0xBE -{0x00,0x00,0x00,0x3C,0x04,0x04,0x04,0x04}, // 0xBF -{0x04,0x04,0x04,0x07,0x00,0x00,0x00,0x00}, // 0xC0 -{0x04,0x04,0x04,0x3F,0x00,0x00,0x00,0x00}, // 0xC1 -{0x00,0x00,0x00,0x3F,0x04,0x04,0x04,0x04}, // 0xC2 -{0x04,0x04,0x04,0x07,0x04,0x04,0x04,0x04}, // 0xC3 -{0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0xC4 -{0x04,0x04,0x04,0x3F,0x04,0x04,0x04,0x04}, // 0xC5 -{0x05,0x0A,0x0E,0x01,0x0F,0x11,0x0F,0x00}, // 0xC6 -{0x05,0x0A,0x04,0x0A,0x11,0x1F,0x11,0x00}, // 0xC7 -{0x14,0x17,0x10,0x1F,0x00,0x00,0x00,0x00}, // 0xC8 -{0x00,0x1F,0x10,0x17,0x14,0x14,0x14,0x14}, // 0xC9 -{0x14,0x37,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0xCA -{0x00,0x3F,0x00,0x37,0x14,0x14,0x14,0x14}, // 0xCB -{0x14,0x17,0x10,0x17,0x14,0x14,0x14,0x14}, // 0xCC -{0x00,0x3F,0x00,0x3F,0x00,0x00,0x00,0x00}, // 0xCD -{0x14,0x37,0x00,0x37,0x14,0x14,0x14,0x14}, // 0xCE -{0x11,0x0E,0x11,0x11,0x11,0x0E,0x11,0x00}, // 0xCF -{0x0C,0x10,0x08,0x04,0x0E,0x12,0x0C,0x00}, // 0xD0 -{0x0E,0x09,0x09,0x1D,0x09,0x09,0x0E,0x00}, // 0xD1 -{0x0E,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0xD2 -{0x0A,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0xD3 -{0x0C,0x00,0x1F,0x10,0x1E,0x10,0x1F,0x00}, // 0xD4 -{0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00}, // 0xD5 -{0x06,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xD6 -{0x0E,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xD7 -{0x0A,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xD8 -{0x04,0x04,0x04,0x3C,0x00,0x00,0x00,0x00}, // 0xD9 -{0x00,0x00,0x00,0x07,0x04,0x04,0x04,0x04}, // 0xDA -{0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F}, // 0xDB -{0x00,0x00,0x00,0x00,0x3F,0x3F,0x3F,0x3F}, // 0xDC -{0x04,0x04,0x04,0x00,0x04,0x04,0x04,0x00}, // 0xDD -{0x0C,0x00,0x0E,0x04,0x04,0x04,0x0E,0x00}, // 0xDE -{0x3F,0x3F,0x3F,0x3F,0x00,0x00,0x00,0x00}, // 0xDF -{0x06,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE0 -{0x00,0x1C,0x12,0x1C,0x12,0x12,0x1C,0x10}, // 0xE1 -{0x0E,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE2 -{0x18,0x0C,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE3 -{0x0A,0x14,0x00,0x0C,0x12,0x12,0x0C,0x00}, // 0xE4 -{0x0A,0x14,0x0C,0x12,0x12,0x12,0x0C,0x00}, // 0xE5 -{0x00,0x00,0x12,0x12,0x12,0x1C,0x10,0x10}, // 0xE6 -{0x00,0x18,0x10,0x1C,0x12,0x1C,0x10,0x18}, // 0xE7 -{0x18,0x10,0x1C,0x12,0x12,0x1C,0x10,0x18}, // 0xE8 -{0x06,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xE9 -{0x0E,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xEA -{0x18,0x00,0x12,0x12,0x12,0x12,0x0C,0x00}, // 0xEB -{0x06,0x00,0x12,0x12,0x12,0x0E,0x04,0x18}, // 0xEC -{0x06,0x00,0x11,0x0A,0x04,0x04,0x04,0x00}, // 0xED -{0x00,0x0E,0x00,0x00,0x00,0x00,0x00,0x00}, // 0xEE -{0x0C,0x0C,0x08,0x00,0x00,0x00,0x00,0x00}, // 0xEF -{0x00,0x00,0x00,0x0E,0x00,0x00,0x00,0x00}, // 0xF0 -{0x00,0x04,0x0E,0x04,0x00,0x0E,0x00,0x00}, // 0xF1 -{0x00,0x00,0x1F,0x00,0x00,0x1F,0x00,0x00}, // 0xF2 -{0x30,0x1A,0x34,0x0B,0x15,0x07,0x01,0x00}, // 0xF3 -{0x0F,0x15,0x15,0x0D,0x05,0x05,0x05,0x00}, // 0xF4 -{0x0E,0x11,0x0C,0x0A,0x06,0x11,0x0E,0x00}, // 0xF5 -{0x00,0x04,0x00,0x1F,0x00,0x04,0x00,0x00}, // 0xF6 -{0x00,0x00,0x00,0x0E,0x06,0x00,0x00,0x00}, // 0xF7 -{0x0C,0x12,0x12,0x0C,0x00,0x00,0x00,0x00}, // 0xF8 -{0x00,0x00,0x00,0x0A,0x00,0x00,0x00,0x00}, // 0xF9 -{0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00}, // 0xFA -{0x08,0x18,0x08,0x08,0x00,0x00,0x00,0x00}, // 0xFB -{0x1C,0x08,0x0C,0x18,0x00,0x00,0x00,0x00}, // 0xFC -{0x18,0x04,0x08,0x1C,0x00,0x00,0x00,0x00}, // 0xFD -{0x00,0x00,0x1E,0x1E,0x1E,0x1E,0x00,0x00}, // 0xFE -{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF -}; - -#endif \ No newline at end of file diff --git a/tasmota/xdsp_19_max7219_matrix.ino b/tasmota/xdsp_19_max7219_matrix.ino index ecf500670..3e1a5c258 100644 --- a/tasmota/xdsp_19_max7219_matrix.ino +++ b/tasmota/xdsp_19_max7219_matrix.ino @@ -39,7 +39,7 @@ Once the GPIO configuration is saved and the ESP8266/ESP32 module restarts, set the Display Model to 19 and Display Mode to 0 - Depending on order oth the wired 8x8 matrix modules you have got a display of size pixel_width x pixel_height. + Depending on order of the wired 8x8 matrix modules you have got a display of size pixel_width x pixel_height. The size has to be set with the commands "DisplayWidth " and "DisplayHeight " After the ESP8266/ESP32 module restarts again, turn ON the display with the command "Power 1" @@ -55,6 +55,10 @@ DisplayDimmer [0..100] Sets the intensity of the display. + DisplayBlinkrate [0..3] + 0: not blinking + 1: slow, 2: medium 3: fast blinking + Power [ON|OFF] Sitches the display on or off. When "off", the display buffer is not cleared and will be shown again when after "Power ON". Other display commands are still active when off. @@ -72,13 +76,18 @@ DisplayHeight [8..256] Sets the pixel height of the display (8x number of module rows) + DisplayRotate [0|2] + 0: normal orientation; devide 0 starts at top left + 2: upside down; device 0 starts at bottom right + DisplayClock [0|1|2] Displays a clock. Commands "DisplayClock 1" // 12 hr format "DisplayClock 2" // 24 hr format - "DisplayClock 0" // turn off clock - + "DisplayClock 0" // turn off clock; please use additional cammand: DisplayMode 0 + If you would like to use the UTF8 latin1 character set, it cam be added by copile option: + #define USE_UTF8_LATIN1 \*********************************************************************************************/ @@ -86,10 +95,6 @@ #include -#ifdef USE_DISPLAY_MODES1TO5 -#include -#endif - LedMatrix *max7219_Matrix = nullptr; bool max2791Matrix_initDriver_done = false; struct @@ -99,7 +104,9 @@ struct byte scroll_delay = 0; byte scroll_iteration = 0; bool show_clock = false; - const char *timeFormat; + bool timeFormat24 = true; + byte blink_delay = 0; // 0: not blinking + byte blink_iteration = 0; } LedMatrix_settings; @@ -138,7 +145,8 @@ bool MAX7291Matrix_initDriver(void) bool MAX7291Matrix_init(void) { Settings->display_mode = 0; // text mode - LedMatrix_settings.show_clock = 0; // no clock + LedMatrix_settings.show_clock = 0; // no + LedMatrix_settings.blink_delay = 0; // no blinking int intensity = GetDisplayDimmer16(); // 0..15 max7219_Matrix->setIntensity(intensity); @@ -158,6 +166,13 @@ bool MAX7291Matrix_init(void) return true; } +bool MAX7291Matrix_setText(bool clearBefore=true) +{ + if(Settings->display_mode != 0) MAX7291Matrix_init(); + LedMatrix_settings.blink_delay = 0; // no blinking + return max7219_Matrix->drawText(XdrvMailbox.data, clearBefore); +} + // FUNC_DISPLAY_SCROLLDELAY bool MAX7291Matrix_scrollDelay(void) { @@ -178,6 +193,8 @@ bool MAX7291Matrix_scrollText(void) // This function is called every 50 ms. // scroll_delay defines the number of cycles to be ignored until the display scrolls by one pixel to the left. // e.g. scrall_delay = 4 causes a scroll each 200 ms. + + if(!max7219_Matrix->isPowerOn()) return false; // do not scroll on power off LedMatrix_settings.scroll_iteration++; if (LedMatrix_settings.scroll_delay) LedMatrix_settings.scroll_iteration = LedMatrix_settings.scroll_iteration % LedMatrix_settings.scroll_delay; @@ -189,6 +206,41 @@ bool MAX7291Matrix_scrollText(void) return max7219_Matrix->scrollText(); } +bool MAX7291Matrix_blink(void) +{ + // This function is called every 50 ms. + // blink_delay defines the number of cycles to be ignored until the blinkstate changes. + if(LedMatrix_settings.blink_delay == 0) return false; + + LedMatrix_settings.blink_iteration++; + if(LedMatrix_settings.blink_iteration == LedMatrix_settings.blink_delay) + { + max7219_Matrix->power(false); + } + else if(LedMatrix_settings.blink_iteration == 2* LedMatrix_settings.blink_delay ) + { + LedMatrix_settings.blink_iteration = 0; + max7219_Matrix->power(true); + } + return true; +} + + +bool MAX7291Matrix_setBlinkRate() +{ + LedMatrix_settings.blink_iteration = 0; + max7219_Matrix->power(true); + if (ArgC() == 0) + { + XdrvMailbox.payload = 0; + } + if (XdrvMailbox.payload) + LedMatrix_settings.blink_delay = 20 / XdrvMailbox.payload; // 1: once per second; 2: twice per second; 3: three times per second + else + LedMatrix_settings.blink_delay = 0; // do not blink + return true; +} + #ifdef USE_DISPLAY_MODES1TO5 // FUNC_DISPLAY_CLOCK bool MAX7291Matrix_clock(void) @@ -204,29 +256,19 @@ bool MAX7291Matrix_clock(void) return true; case 1: // 12 h clock - LedMatrix_settings.timeFormat = "%I:%M"; - if(LedMatrix_settings.modulesPerRow > 6) - { - LedMatrix_settings.timeFormat = "%I:%M:%S"; - } + LedMatrix_settings.timeFormat24 = false; Settings->display_mode = 1; break; case 2: // 24 h clock - LedMatrix_settings.timeFormat = "%H:%M"; - if(LedMatrix_settings.modulesPerRow > 6) - { - LedMatrix_settings.timeFormat = "%H:%M:%S"; - } + LedMatrix_settings.timeFormat24 = true; Settings->display_mode = 1; break; default: - //LedMatrix_settings.timeFormat = XdrvMailbox.payload; - //Settings->display_mode = 1; return false; } - AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: LedMatrix_settings.show_clock %d, timeFormat %s"), LedMatrix_settings.show_clock, LedMatrix_settings.timeFormat); + AddLog(LOG_LEVEL_DEBUG, PSTR("MTX: LedMatrix_settings.show_clock %d, 24h: %b"), LedMatrix_settings.show_clock, LedMatrix_settings.timeFormat24); max7219_Matrix->clearDisplay(); MAX7291Matrix_showTime(); @@ -236,17 +278,30 @@ bool MAX7291Matrix_clock(void) // FUNC_DISPLAY_EVERY_SECOND bool MAX7291Matrix_showTime() { - time_t rawtime; - struct tm *timeinfo; + if(!LedMatrix_settings.show_clock) return false; + + uint8_t hr = RtcTime.hour; + uint8_t mn = RtcTime.minute; + uint8_t sc = RtcTime.second; char timeStr[10]; + if(!LedMatrix_settings.timeFormat24) + { + if(hr == 0) hr = 12; + if(hr > 12 ) hr -= 12; + } - time(&rawtime); - timeinfo = localtime(&rawtime); - strftime(timeStr, 10, LedMatrix_settings.timeFormat, timeinfo); - + if(LedMatrix_settings.modulesPerRow >= 6) + { + snprintf(timeStr, 10, "%02d:%02d:%02d", hr , mn, sc); + } + else + { + snprintf(timeStr, 10, "%02d:%02d", hr , mn); + } max7219_Matrix->drawText(timeStr, false); // false: do not clear desplay on update to prevent flicker return true; } + #endif // USE_DISPLAY_MODES1TO5 @@ -280,17 +335,21 @@ bool Xdsp19(uint8_t function) case FUNC_DISPLAY_DRAW_STRING: case FUNC_DISPLAY_SCROLLTEXT: case FUNC_DISPLAY_SEVENSEG_TEXT: - if(Settings->display_mode != 0) MAX7291Matrix_init(); - result = max7219_Matrix->drawText(XdrvMailbox.data, true); // true: clears display before drawing text + result = MAX7291Matrix_setText(true); // true: clears display before drawing text break; case FUNC_DISPLAY_SEVENSEG_TEXTNC: - if(Settings->display_mode != 0) MAX7291Matrix_init(); - result = max7219_Matrix->drawText(XdrvMailbox.data, false); // false: does not clear display before drawing text + result = MAX7291Matrix_setText(false); // false: does not clear display before drawing text break; case FUNC_DISPLAY_SCROLLDELAY: result = MAX7291Matrix_scrollDelay(); break; + case FUNC_DISPLAY_BLINKRATE: + { + result = MAX7291Matrix_setBlinkRate(); + break; + } case FUNC_DISPLAY_EVERY_50_MSECOND: + MAX7291Matrix_blink(); result = MAX7291Matrix_scrollText(); break; From 805006468f716b890d938d04fb8cd5a795a7779b Mon Sep 17 00:00:00 2001 From: Meek Home Automation <44222882+Meek-HA@users.noreply.github.com> Date: Sat, 18 Dec 2021 21:52:23 +0100 Subject: [PATCH 19/31] ESP32 Compile error when I2S_AUDIO is enabled Solves the compiling error with env:tasmota32 when I2s Audio is enabled: #ifndef USE_I2S_AUDIO #define USE_I2S_AUDIO #endif #ifdef USE_I2S_EXTERNAL_DAC #undef USE_I2S_EXTERNAL_DAC #endif #ifndef USE_I2S_NO_DAC #define USE_I2S_NO_DAC #endif Resolving the following compiling error: tasmota/xdrv_42_i2s_audio.ino:326:11: error: invalid conversion from 'AudioOutputI2S*' to 'AudioOutputI2SNoDAC*' [-fpermissive] --- tasmota/xdrv_42_i2s_audio.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tasmota/xdrv_42_i2s_audio.ino b/tasmota/xdrv_42_i2s_audio.ino index c7b0c460b..c87d763da 100644 --- a/tasmota/xdrv_42_i2s_audio.ino +++ b/tasmota/xdrv_42_i2s_audio.ino @@ -320,7 +320,11 @@ uint32_t SpeakerMic(uint8_t spkr) { i2s_driver_uninstall(Speak_I2S_NUMBER); if (spkr==MODE_SPK) { - out = new AudioOutputI2S(); + #ifdef USE_I2S_NO_DAC + out = new AudioOutputI2SNoDAC(); + #else + out = new AudioOutputI2S(0, 1); + #endif out->SetPinout(DAC_IIS_BCK, DAC_IIS_WS, DAC_IIS_DOUT); out->SetGain(((float)is2_volume/100.0)*4.0); out->stop(); From 8004a81d834d785288a936e3a69b0209dfa4cb3c Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sat, 18 Dec 2021 22:17:26 +0100 Subject: [PATCH 20/31] ignore Micro-RTSP lib for S2 --- platformio_tasmota_cenv_sample.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/platformio_tasmota_cenv_sample.ini b/platformio_tasmota_cenv_sample.ini index 44cfd6ca5..446f0aaa8 100644 --- a/platformio_tasmota_cenv_sample.ini +++ b/platformio_tasmota_cenv_sample.ini @@ -10,6 +10,7 @@ lib_ignore = NimBLE-Arduino epdiy esp32-camera + Micro-RTSP [env:tasmota-rangeextender] build_flags = ${env.build_flags} From 416cadd22981958e4499d06e9a2c7a99e2d5eec6 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 13:52:50 +0100 Subject: [PATCH 21/31] Webcam reduce lib --- .gitpod.Dockerfile | 2 +- .gitpod.yml | 2 +- .../esp32-camera/LICENSE | 0 .../esp32-camera/README.md | 0 .../esp32-camera/driver/include}/cam_hal.h | 0 .../esp32-camera/driver/include/esp_camera.h | 0 .../esp32-camera/driver/include/sensor.h | 0 .../esp32-camera/driver/include}/xclk.h | 0 lib/libesp32/esp32-camera/library.json | 20 + lib/libesp32_div/esp32-camera/CMakeLists.txt | 64 - lib/libesp32_div/esp32-camera/Kconfig | 114 -- lib/libesp32_div/esp32-camera/component.mk | 4 - .../esp32-camera/conversions/esp_jpg_decode.c | 132 -- .../conversions/include/esp_jpg_decode.h | 43 - .../conversions/include/img_converters.h | 130 -- .../esp32-camera/conversions/jpge.cpp | 723 ----------- .../conversions/private_include/jpge.h | 142 --- .../conversions/private_include/yuv.h | 29 - .../esp32-camera/conversions/to_bmp.c | 393 ------ .../esp32-camera/conversions/to_jpg.cpp | 245 ---- .../esp32-camera/conversions/yuv.c | 298 ----- .../esp32-camera/driver/cam_hal.c | 483 ------- .../esp32-camera/driver/esp_camera.c | 416 ------ .../driver/private_include/sccb.h | 19 - lib/libesp32_div/esp32-camera/driver/sccb.c | 184 --- lib/libesp32_div/esp32-camera/driver/sensor.c | 52 - .../esp32-camera/examples/CMakeLists.txt | 9 - .../esp32-camera/examples/Makefile | 11 - .../esp32-camera/examples/main/CMakeLists.txt | 3 - .../esp32-camera/examples/main/component.mk | 5 - .../esp32-camera/examples/main/take_picture.c | 155 --- .../esp32-camera/examples/sdkconfig.defaults | 17 - lib/libesp32_div/esp32-camera/library.json | 25 - .../esp32-camera/sensors/gc0308.c | 465 ------- .../esp32-camera/sensors/gc032a.c | 391 ------ .../esp32-camera/sensors/gc2145.c | 475 ------- .../esp32-camera/sensors/nt99141.c | 1022 --------------- .../esp32-camera/sensors/ov2640.c | 612 --------- .../esp32-camera/sensors/ov3660.c | 1053 --------------- .../esp32-camera/sensors/ov5640.c | 1130 ----------------- .../esp32-camera/sensors/ov7670.c | 457 ------- .../esp32-camera/sensors/ov7725.c | 575 --------- .../sensors/private_include/gc0308.h | 31 - .../sensors/private_include/gc0308_regs.h | 25 - .../sensors/private_include/gc0308_settings.h | 245 ---- .../sensors/private_include/gc032a.h | 31 - .../sensors/private_include/gc032a_regs.h | 82 -- .../sensors/private_include/gc032a_settings.h | 401 ------ .../sensors/private_include/gc2145.h | 27 - .../sensors/private_include/gc2145_regs.h | 85 -- .../sensors/private_include/gc2145_settings.h | 719 ----------- .../sensors/private_include/nt99141.h | 34 - .../sensors/private_include/nt99141_regs.h | 211 --- .../private_include/nt99141_settings.h | 825 ------------ .../sensors/private_include/ov2640.h | 32 - .../sensors/private_include/ov2640_regs.h | 216 ---- .../sensors/private_include/ov2640_settings.h | 485 ------- .../sensors/private_include/ov3660.h | 34 - .../sensors/private_include/ov3660_regs.h | 211 --- .../sensors/private_include/ov3660_settings.h | 318 ----- .../sensors/private_include/ov5640.h | 27 - .../sensors/private_include/ov5640_regs.h | 213 ---- .../sensors/private_include/ov5640_settings.h | 334 ----- .../sensors/private_include/ov7670.h | 33 - .../sensors/private_include/ov7670_regs.h | 354 ------ .../sensors/private_include/ov7725.h | 33 - .../sensors/private_include/ov7725_regs.h | 335 ----- .../esp32-camera/target/esp32/ll_cam.c | 522 -------- .../esp32-camera/target/esp32s2/ll_cam.c | 402 ------ .../target/esp32s2/private_include/tjpgd.h | 99 -- .../esp32-camera/target/esp32s2/tjpgd.c | 970 -------------- .../esp32-camera/target/esp32s3/ll_cam.c | 452 ------- .../target/private_include/ll_cam.h | 141 -- lib/libesp32_div/esp32-camera/target/xclk.c | 64 - .../esp32-camera/test/CMakeLists.txt | 4 - .../esp32-camera/test/component.mk | 8 - .../test/pictures/test_inside.jpeg | Bin 18832 -> 0 bytes .../test/pictures/test_outside.jpeg | Bin 81744 -> 0 bytes .../esp32-camera/test/pictures/testimg.jpeg | Bin 5764 -> 0 bytes .../esp32-camera/test/test_camera.c | 500 -------- ...ride_sample.ini => platformio_override.ini | 4 +- 81 files changed, 24 insertions(+), 18383 deletions(-) rename lib/{libesp32_div => libesp32}/esp32-camera/LICENSE (100%) rename lib/{libesp32_div => libesp32}/esp32-camera/README.md (100%) rename lib/{libesp32_div/esp32-camera/driver/private_include => libesp32/esp32-camera/driver/include}/cam_hal.h (100%) rename lib/{libesp32_div => libesp32}/esp32-camera/driver/include/esp_camera.h (100%) rename lib/{libesp32_div => libesp32}/esp32-camera/driver/include/sensor.h (100%) rename lib/{libesp32_div/esp32-camera/driver/private_include => libesp32/esp32-camera/driver/include}/xclk.h (100%) create mode 100644 lib/libesp32/esp32-camera/library.json delete mode 100644 lib/libesp32_div/esp32-camera/CMakeLists.txt delete mode 100644 lib/libesp32_div/esp32-camera/Kconfig delete mode 100644 lib/libesp32_div/esp32-camera/component.mk delete mode 100644 lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c delete mode 100644 lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h delete mode 100644 lib/libesp32_div/esp32-camera/conversions/include/img_converters.h delete mode 100644 lib/libesp32_div/esp32-camera/conversions/jpge.cpp delete mode 100644 lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h delete mode 100644 lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h delete mode 100644 lib/libesp32_div/esp32-camera/conversions/to_bmp.c delete mode 100644 lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp delete mode 100644 lib/libesp32_div/esp32-camera/conversions/yuv.c delete mode 100644 lib/libesp32_div/esp32-camera/driver/cam_hal.c delete mode 100644 lib/libesp32_div/esp32-camera/driver/esp_camera.c delete mode 100644 lib/libesp32_div/esp32-camera/driver/private_include/sccb.h delete mode 100644 lib/libesp32_div/esp32-camera/driver/sccb.c delete mode 100644 lib/libesp32_div/esp32-camera/driver/sensor.c delete mode 100644 lib/libesp32_div/esp32-camera/examples/CMakeLists.txt delete mode 100644 lib/libesp32_div/esp32-camera/examples/Makefile delete mode 100644 lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt delete mode 100644 lib/libesp32_div/esp32-camera/examples/main/component.mk delete mode 100644 lib/libesp32_div/esp32-camera/examples/main/take_picture.c delete mode 100644 lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults delete mode 100644 lib/libesp32_div/esp32-camera/library.json delete mode 100644 lib/libesp32_div/esp32-camera/sensors/gc0308.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/gc032a.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/gc2145.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/nt99141.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/ov2640.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/ov3660.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/ov5640.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/ov7670.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/ov7725.c delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h delete mode 100644 lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h delete mode 100644 lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c delete mode 100644 lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c delete mode 100644 lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h delete mode 100644 lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c delete mode 100644 lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c delete mode 100644 lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h delete mode 100644 lib/libesp32_div/esp32-camera/target/xclk.c delete mode 100644 lib/libesp32_div/esp32-camera/test/CMakeLists.txt delete mode 100644 lib/libesp32_div/esp32-camera/test/component.mk delete mode 100644 lib/libesp32_div/esp32-camera/test/pictures/test_inside.jpeg delete mode 100644 lib/libesp32_div/esp32-camera/test/pictures/test_outside.jpeg delete mode 100644 lib/libesp32_div/esp32-camera/test/pictures/testimg.jpeg delete mode 100644 lib/libesp32_div/esp32-camera/test/test_camera.c rename platformio_override_sample.ini => platformio_override.ini (96%) diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 909bcf681..29d75d19d 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -2,4 +2,4 @@ FROM gitpod/workspace-full USER gitpod -RUN pip3 install -U platformio && brew install uncrustify +RUN pip3 install -U platformio diff --git a/.gitpod.yml b/.gitpod.yml index 50d9a86d9..7a7300013 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,6 +1,6 @@ tasks: - before: platformio upgrade - - command: platformio run -e tasmota + - command: platformio run -e tasmota32-webcam image: file: .gitpod.Dockerfile diff --git a/lib/libesp32_div/esp32-camera/LICENSE b/lib/libesp32/esp32-camera/LICENSE similarity index 100% rename from lib/libesp32_div/esp32-camera/LICENSE rename to lib/libesp32/esp32-camera/LICENSE diff --git a/lib/libesp32_div/esp32-camera/README.md b/lib/libesp32/esp32-camera/README.md similarity index 100% rename from lib/libesp32_div/esp32-camera/README.md rename to lib/libesp32/esp32-camera/README.md diff --git a/lib/libesp32_div/esp32-camera/driver/private_include/cam_hal.h b/lib/libesp32/esp32-camera/driver/include/cam_hal.h similarity index 100% rename from lib/libesp32_div/esp32-camera/driver/private_include/cam_hal.h rename to lib/libesp32/esp32-camera/driver/include/cam_hal.h diff --git a/lib/libesp32_div/esp32-camera/driver/include/esp_camera.h b/lib/libesp32/esp32-camera/driver/include/esp_camera.h similarity index 100% rename from lib/libesp32_div/esp32-camera/driver/include/esp_camera.h rename to lib/libesp32/esp32-camera/driver/include/esp_camera.h diff --git a/lib/libesp32_div/esp32-camera/driver/include/sensor.h b/lib/libesp32/esp32-camera/driver/include/sensor.h similarity index 100% rename from lib/libesp32_div/esp32-camera/driver/include/sensor.h rename to lib/libesp32/esp32-camera/driver/include/sensor.h diff --git a/lib/libesp32_div/esp32-camera/driver/private_include/xclk.h b/lib/libesp32/esp32-camera/driver/include/xclk.h similarity index 100% rename from lib/libesp32_div/esp32-camera/driver/private_include/xclk.h rename to lib/libesp32/esp32-camera/driver/include/xclk.h diff --git a/lib/libesp32/esp32-camera/library.json b/lib/libesp32/esp32-camera/library.json new file mode 100644 index 000000000..bb542c0bf --- /dev/null +++ b/lib/libesp32/esp32-camera/library.json @@ -0,0 +1,20 @@ +{ + "name": "esp32-camera-header", + "version": "1.0.0", + "keywords": "esp32, camera, espressif, esp32-cam", + "description": "ESP32 camera header files", + "repository": { + "type": "git", + "url": "https://github.com/espressif/esp32-camera" + }, + "frameworks": "arduino", + "platforms": "espressif32", + "build": { + "flags": [ + "-Idriver/include" + ], + "includeDir": ".", + "srcDir": ".", + "srcFilter": ["-<*>", "+"] + } +} diff --git a/lib/libesp32_div/esp32-camera/CMakeLists.txt b/lib/libesp32_div/esp32-camera/CMakeLists.txt deleted file mode 100644 index 5ceec97c0..000000000 --- a/lib/libesp32_div/esp32-camera/CMakeLists.txt +++ /dev/null @@ -1,64 +0,0 @@ -if(IDF_TARGET STREQUAL "esp32" OR IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3") - set(COMPONENT_SRCS - driver/esp_camera.c - driver/cam_hal.c - driver/sccb.c - driver/sensor.c - sensors/ov2640.c - sensors/ov3660.c - sensors/ov5640.c - sensors/ov7725.c - sensors/ov7670.c - sensors/nt99141.c - sensors/gc0308.c - sensors/gc2145.c - sensors/gc032a.c - conversions/yuv.c - conversions/to_jpg.cpp - conversions/to_bmp.c - conversions/jpge.cpp - conversions/esp_jpg_decode.c - ) - - set(COMPONENT_ADD_INCLUDEDIRS - driver/include - conversions/include - ) - - set(COMPONENT_PRIV_INCLUDEDIRS - driver/private_include - sensors/private_include - conversions/private_include - target/private_include - ) - - if(IDF_TARGET STREQUAL "esp32") - list(APPEND COMPONENT_SRCS - target/xclk.c - target/esp32/ll_cam.c - ) - endif() - - if(IDF_TARGET STREQUAL "esp32s2") - list(APPEND COMPONENT_SRCS - target/xclk.c - target/esp32s2/ll_cam.c - target/esp32s2/tjpgd.c - ) - - list(APPEND COMPONENT_PRIV_INCLUDEDIRS - target/esp32s2/private_include - ) - endif() - - if(IDF_TARGET STREQUAL "esp32s3") - list(APPEND COMPONENT_SRCS - target/esp32s3/ll_cam.c - ) - endif() - - set(COMPONENT_REQUIRES driver) - set(COMPONENT_PRIV_REQUIRES freertos nvs_flash) - - register_component() -endif() diff --git a/lib/libesp32_div/esp32-camera/Kconfig b/lib/libesp32_div/esp32-camera/Kconfig deleted file mode 100644 index 6fb5aad21..000000000 --- a/lib/libesp32_div/esp32-camera/Kconfig +++ /dev/null @@ -1,114 +0,0 @@ -menu "Camera configuration" - - config OV7670_SUPPORT - bool "Support OV7670 VGA" - default y - help - Enable this option if you want to use the OV7670. - Disable this option to save memory. - - config OV7725_SUPPORT - bool "Support OV7725 VGA" - default y - help - Enable this option if you want to use the OV7725. - Disable this option to save memory. - - config NT99141_SUPPORT - bool "Support NT99141 HD" - default y - help - Enable this option if you want to use the NT99141. - Disable this option to save memory. - - config OV2640_SUPPORT - bool "Support OV2640 2MP" - default y - help - Enable this option if you want to use the OV2640. - Disable this option to save memory. - - config OV3660_SUPPORT - bool "Support OV3660 3MP" - default y - help - Enable this option if you want to use the OV3360. - Disable this option to save memory. - - config OV5640_SUPPORT - bool "Support OV5640 5MP" - default y - help - Enable this option if you want to use the OV5640. - Disable this option to save memory. - - config GC2145_SUPPORT - bool "Support GC2145 2MP" - default y - help - Enable this option if you want to use the GC2145. - Disable this option to save memory. - - config GC032A_SUPPORT - bool "Support GC032A VGA" - default y - help - Enable this option if you want to use the GC032A. - Disable this option to save memory. - - config GC0308_SUPPORT - bool "Support GC0308 VGA" - default y - help - Enable this option if you want to use the GC0308. - Disable this option to save memory. - - choice SCCB_HARDWARE_I2C_PORT - bool "I2C peripheral to use for SCCB" - default SCCB_HARDWARE_I2C_PORT1 - - config SCCB_HARDWARE_I2C_PORT0 - bool "I2C0" - config SCCB_HARDWARE_I2C_PORT1 - bool "I2C1" - - endchoice - - choice GC_SENSOR_WINDOW_MODE - bool "GalaxyCore Sensor Window Mode" - depends on (GC2145_SUPPORT || GC032A_SUPPORT || GC0308_SUPPORT) - default GC_SENSOR_SUBSAMPLE_MODE - help - This option determines how to reduce the output size when the resolution you set is less than the maximum resolution. - SUBSAMPLE_MODE has a bigger perspective and WINDOWING_MODE has a higher frame rate. - - config GC_SENSOR_WINDOWING_MODE - bool "Windowing Mode" - config GC_SENSOR_SUBSAMPLE_MODE - bool "Subsample Mode" - endchoice - - choice CAMERA_TASK_PINNED_TO_CORE - bool "Camera task pinned to core" - default CAMERA_CORE0 - help - Pin the camera handle task to a certain core(0/1). It can also be done automatically choosing NO_AFFINITY. - - config CAMERA_CORE0 - bool "CORE0" - config CAMERA_CORE1 - bool "CORE1" - config CAMERA_NO_AFFINITY - bool "NO_AFFINITY" - - endchoice - - config CAMERA_DMA_BUFFER_SIZE_MAX - int "DMA buffer size" - range 8192 32768 - default 32768 - help - Maximum value of DMA buffer - Larger values may fail to allocate due to insufficient contiguous memory blocks, and smaller value may cause DMA interrupt to be too frequent - -endmenu diff --git a/lib/libesp32_div/esp32-camera/component.mk b/lib/libesp32_div/esp32-camera/component.mk deleted file mode 100644 index 8db15eb88..000000000 --- a/lib/libesp32_div/esp32-camera/component.mk +++ /dev/null @@ -1,4 +0,0 @@ -COMPONENT_ADD_INCLUDEDIRS := driver/include conversions/include -COMPONENT_PRIV_INCLUDEDIRS := driver/private_include conversions/private_include sensors/private_include target/private_include -COMPONENT_SRCDIRS := driver conversions sensors target target/esp32 -CXXFLAGS += -fno-rtti diff --git a/lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c b/lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c deleted file mode 100644 index a9615e36c..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/esp_jpg_decode.c +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "esp_jpg_decode.h" - -#include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 -#include "esp32/rom/tjpgd.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "tjpgd.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/tjpgd.h" -#else -#error Target CONFIG_IDF_TARGET is not supported -#endif -#else // ESP32 Before IDF 4.0 -#include "rom/tjpgd.h" -#endif - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#define TAG "" -#else -#include "esp_log.h" -static const char* TAG = "esp_jpg_decode"; -#endif - -typedef struct { - jpg_scale_t scale; - jpg_reader_cb reader; - jpg_writer_cb writer; - void * arg; - size_t len; - size_t index; -} esp_jpg_decoder_t; - -static const char * jd_errors[] = { - "Succeeded", - "Interrupted by output function", - "Device error or wrong termination of input stream", - "Insufficient memory pool for the image", - "Insufficient stream input buffer", - "Parameter error", - "Data format error", - "Right format but not supported", - "Not supported JPEG standard" -}; - -static uint32_t _jpg_write(JDEC *decoder, void *bitmap, JRECT *rect) -{ - uint16_t x = rect->left; - uint16_t y = rect->top; - uint16_t w = rect->right + 1 - x; - uint16_t h = rect->bottom + 1 - y; - uint8_t *data = (uint8_t *)bitmap; - - esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; - - if (jpeg->writer) { - return jpeg->writer(jpeg->arg, x, y, w, h, data); - } - return 0; -} - -static uint32_t _jpg_read(JDEC *decoder, uint8_t *buf, uint32_t len) -{ - esp_jpg_decoder_t * jpeg = (esp_jpg_decoder_t *)decoder->device; - if (jpeg->len && len > (jpeg->len - jpeg->index)) { - len = jpeg->len - jpeg->index; - } - if (len) { - len = jpeg->reader(jpeg->arg, jpeg->index, buf, len); - if (!len) { - ESP_LOGE(TAG, "Read Fail at %u/%u", jpeg->index, jpeg->len); - } - jpeg->index += len; - } - return len; -} - -esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg) -{ - static uint8_t work[3100]; - JDEC decoder; - esp_jpg_decoder_t jpeg; - - jpeg.len = len; - jpeg.reader = reader; - jpeg.writer = writer; - jpeg.arg = arg; - jpeg.scale = scale; - jpeg.index = 0; - - JRESULT jres = jd_prepare(&decoder, _jpg_read, work, 3100, &jpeg); - if(jres != JDR_OK){ - ESP_LOGE(TAG, "JPG Header Parse Failed! %s", jd_errors[jres]); - return ESP_FAIL; - } - - uint16_t output_width = decoder.width / (1 << (uint8_t)(jpeg.scale)); - uint16_t output_height = decoder.height / (1 << (uint8_t)(jpeg.scale)); - - //output start - writer(arg, 0, 0, output_width, output_height, NULL); - //output write - jres = jd_decomp(&decoder, _jpg_write, (uint8_t)jpeg.scale); - //output end - writer(arg, output_width, output_height, output_width, output_height, NULL); - - if (jres != JDR_OK) { - ESP_LOGE(TAG, "JPG Decompression Failed! %s", jd_errors[jres]); - return ESP_FAIL; - } - //check if all data has been consumed. - if (len && jpeg.index < len) { - _jpg_read(&decoder, NULL, len - jpeg.index); - } - - return ESP_OK; -} - diff --git a/lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h b/lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h deleted file mode 100644 index f13536edf..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/include/esp_jpg_decode.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef _ESP_JPG_DECODE_H_ -#define _ESP_JPG_DECODE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "esp_err.h" - -typedef enum { - JPG_SCALE_NONE, - JPG_SCALE_2X, - JPG_SCALE_4X, - JPG_SCALE_8X, - JPG_SCALE_MAX = JPG_SCALE_8X -} jpg_scale_t; - -typedef size_t (* jpg_reader_cb)(void * arg, size_t index, uint8_t *buf, size_t len); -typedef bool (* jpg_writer_cb)(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data); - -esp_err_t esp_jpg_decode(size_t len, jpg_scale_t scale, jpg_reader_cb reader, jpg_writer_cb writer, void * arg); - -#ifdef __cplusplus -} -#endif - -#endif /* _ESP_JPG_DECODE_H_ */ diff --git a/lib/libesp32_div/esp32-camera/conversions/include/img_converters.h b/lib/libesp32_div/esp32-camera/conversions/include/img_converters.h deleted file mode 100644 index f736200a9..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/include/img_converters.h +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef _IMG_CONVERTERS_H_ -#define _IMG_CONVERTERS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include "esp_camera.h" -#include "esp_jpg_decode.h" - -typedef size_t (* jpg_out_cb)(void * arg, size_t index, const void* data, size_t len); - -/** - * @brief Convert image buffer to JPEG - * - * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format - * @param src_len Length in bytes of the source buffer - * @param width Width in pixels of the source image - * @param height Height in pixels of the source image - * @param format Format of the source image - * @param quality JPEG quality of the resulting image - * @param cp Callback to be called to write the bytes of the output JPEG - * @param arg Pointer to be passed to the callback - * - * @return true on success - */ -bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg); - -/** - * @brief Convert camera frame buffer to JPEG - * - * @param fb Source camera frame buffer - * @param quality JPEG quality of the resulting image - * @param cp Callback to be called to write the bytes of the output JPEG - * @param arg Pointer to be passed to the callback - * - * @return true on success - */ -bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg); - -/** - * @brief Convert image buffer to JPEG buffer - * - * @param src Source buffer in RGB565, RGB888, YUYV or GRAYSCALE format - * @param src_len Length in bytes of the source buffer - * @param width Width in pixels of the source image - * @param height Height in pixels of the source image - * @param format Format of the source image - * @param quality JPEG quality of the resulting image - * @param out Pointer to be populated with the address of the resulting buffer. - * You MUST free the pointer once you are done with it. - * @param out_len Pointer to be populated with the length of the output buffer - * - * @return true on success - */ -bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len); - -/** - * @brief Convert camera frame buffer to JPEG buffer - * - * @param fb Source camera frame buffer - * @param quality JPEG quality of the resulting image - * @param out Pointer to be populated with the address of the resulting buffer - * @param out_len Pointer to be populated with the length of the output buffer - * - * @return true on success - */ -bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len); - -/** - * @brief Convert image buffer to BMP buffer - * - * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format - * @param src_len Length in bytes of the source buffer - * @param width Width in pixels of the source image - * @param height Height in pixels of the source image - * @param format Format of the source image - * @param out Pointer to be populated with the address of the resulting buffer - * @param out_len Pointer to be populated with the length of the output buffer - * - * @return true on success - */ -bool fmt2bmp(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t ** out, size_t * out_len); - -/** - * @brief Convert camera frame buffer to BMP buffer - * - * @param fb Source camera frame buffer - * @param out Pointer to be populated with the address of the resulting buffer - * @param out_len Pointer to be populated with the length of the output buffer - * - * @return true on success - */ -bool frame2bmp(camera_fb_t * fb, uint8_t ** out, size_t * out_len); - -/** - * @brief Convert image buffer to RGB888 buffer (used for face detection) - * - * @param src Source buffer in JPEG, RGB565, RGB888, YUYV or GRAYSCALE format - * @param src_len Length in bytes of the source buffer - * @param format Format of the source image - * @param rgb_buf Pointer to the output buffer (width * height * 3) - * - * @return true on success - */ -bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf); - -bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale); - -#ifdef __cplusplus -} -#endif - -#endif /* _IMG_CONVERTERS_H_ */ diff --git a/lib/libesp32_div/esp32-camera/conversions/jpge.cpp b/lib/libesp32_div/esp32-camera/conversions/jpge.cpp deleted file mode 100644 index a8ab93e02..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/jpge.cpp +++ /dev/null @@ -1,723 +0,0 @@ -// jpge.cpp - C++ class for JPEG compression. -// Public domain, Rich Geldreich -// v1.01, Dec. 18, 2010 - Initial release -// v1.02, Apr. 6, 2011 - Removed 2x2 ordered dither in H2V1 chroma subsampling method load_block_16_8_8(). (The rounding factor was 2, when it should have been 1. Either way, it wasn't helping.) -// v1.03, Apr. 16, 2011 - Added support for optimized Huffman code tables, optimized dynamic memory allocation down to only 1 alloc. -// Also from Alex Evans: Added RGBA support, linear memory allocator (no longer needed in v1.03). -// v1.04, May. 19, 2012: Forgot to set m_pFile ptr to NULL in cfile_stream::close(). Thanks to Owen Kaluza for reporting this bug. -// Code tweaks to fix VS2008 static code analysis warnings (all looked harmless). -// Code review revealed method load_block_16_8_8() (used for the non-default H2V1 sampling mode to downsample chroma) somehow didn't get the rounding factor fix from v1.02. - -#include "jpge.h" - -#include -#include -#include -#include -#include -#include -#include -#include "esp_heap_caps.h" - -#define JPGE_MAX(a,b) (((a)>(b))?(a):(b)) -#define JPGE_MIN(a,b) (((a)<(b))?(a):(b)) - -namespace jpge { - - static inline void *jpge_malloc(size_t nSize) { - void * b = malloc(nSize); - if(b){ - return b; - } - return heap_caps_malloc(nSize, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); - } - static inline void jpge_free(void *p) { free(p); } - - // Various JPEG enums and tables. - enum { M_SOF0 = 0xC0, M_DHT = 0xC4, M_SOI = 0xD8, M_EOI = 0xD9, M_SOS = 0xDA, M_DQT = 0xDB, M_APP0 = 0xE0 }; - enum { DC_LUM_CODES = 12, AC_LUM_CODES = 256, DC_CHROMA_CODES = 12, AC_CHROMA_CODES = 256, MAX_HUFF_SYMBOLS = 257, MAX_HUFF_CODESIZE = 32 }; - - static const uint8 s_zag[64] = { 0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63 }; - static const int16 s_std_lum_quant[64] = { 16,11,12,14,12,10,16,14,13,14,18,17,16,19,24,40,26,24,22,22,24,49,35,37,29,40,58,51,61,60,57,51,56,55,64,72,92,78,64,68,87,69,55,56,80,109,81,87,95,98,103,104,103,62,77,113,121,112,100,120,92,101,103,99 }; - static const int16 s_std_croma_quant[64] = { 17,18,18,24,21,24,47,26,26,47,99,66,56,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99 }; - static const uint8 s_dc_lum_bits[17] = { 0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0 }; - static const uint8 s_dc_lum_val[DC_LUM_CODES] = { 0,1,2,3,4,5,6,7,8,9,10,11 }; - static const uint8 s_ac_lum_bits[17] = { 0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,0x7d }; - static const uint8 s_ac_lum_val[AC_LUM_CODES] = { - 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 - }; - static const uint8 s_dc_chroma_bits[17] = { 0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0 }; - static const uint8 s_dc_chroma_val[DC_CHROMA_CODES] = { 0,1,2,3,4,5,6,7,8,9,10,11 }; - static const uint8 s_ac_chroma_bits[17] = { 0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,0x77 }; - static const uint8 s_ac_chroma_val[AC_CHROMA_CODES] = { - 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 - }; - - const int YR = 19595, YG = 38470, YB = 7471, CB_R = -11059, CB_G = -21709, CB_B = 32768, CR_R = 32768, CR_G = -27439, CR_B = -5329; - - static int32 m_last_quality = 0; - static int32 m_quantization_tables[2][64]; - - static bool m_huff_initialized = false; - static uint m_huff_codes[4][256]; - static uint8 m_huff_code_sizes[4][256]; - static uint8 m_huff_bits[4][17]; - static uint8 m_huff_val[4][256]; - - static inline uint8 clamp(int i) { - if (i < 0) { - i = 0; - } else if (i > 255){ - i = 255; - } - return static_cast(i); - } - - static void RGB_to_YCC(uint8* pDst, const uint8 *pSrc, int num_pixels) { - for ( ; num_pixels; pDst += 3, pSrc += 3, num_pixels--) { - const int r = pSrc[0], g = pSrc[1], b = pSrc[2]; - pDst[0] = static_cast((r * YR + g * YG + b * YB + 32768) >> 16); - pDst[1] = clamp(128 + ((r * CB_R + g * CB_G + b * CB_B + 32768) >> 16)); - pDst[2] = clamp(128 + ((r * CR_R + g * CR_G + b * CR_B + 32768) >> 16)); - } - } - - static void RGB_to_Y(uint8* pDst, const uint8 *pSrc, int num_pixels) { - for ( ; num_pixels; pDst++, pSrc += 3, num_pixels--) { - pDst[0] = static_cast((pSrc[0] * YR + pSrc[1] * YG + pSrc[2] * YB + 32768) >> 16); - } - } - - static void Y_to_YCC(uint8* pDst, const uint8* pSrc, int num_pixels) { - for( ; num_pixels; pDst += 3, pSrc++, num_pixels--) { - pDst[0] = pSrc[0]; - pDst[1] = 128; - pDst[2] = 128; - } - } - - // Forward DCT - DCT derived from jfdctint. - enum { CONST_BITS = 13, ROW_BITS = 2 }; -#define DCT_DESCALE(x, n) (((x) + (((int32)1) << ((n) - 1))) >> (n)) -#define DCT_MUL(var, c) (static_cast(var) * static_cast(c)) -#define DCT1D(s0, s1, s2, s3, s4, s5, s6, s7) \ - int32 t0 = s0 + s7, t7 = s0 - s7, t1 = s1 + s6, t6 = s1 - s6, t2 = s2 + s5, t5 = s2 - s5, t3 = s3 + s4, t4 = s3 - s4; \ - int32 t10 = t0 + t3, t13 = t0 - t3, t11 = t1 + t2, t12 = t1 - t2; \ - int32 u1 = DCT_MUL(t12 + t13, 4433); \ - s2 = u1 + DCT_MUL(t13, 6270); \ - s6 = u1 + DCT_MUL(t12, -15137); \ - u1 = t4 + t7; \ - int32 u2 = t5 + t6, u3 = t4 + t6, u4 = t5 + t7; \ - int32 z5 = DCT_MUL(u3 + u4, 9633); \ - t4 = DCT_MUL(t4, 2446); t5 = DCT_MUL(t5, 16819); \ - t6 = DCT_MUL(t6, 25172); t7 = DCT_MUL(t7, 12299); \ - u1 = DCT_MUL(u1, -7373); u2 = DCT_MUL(u2, -20995); \ - u3 = DCT_MUL(u3, -16069); u4 = DCT_MUL(u4, -3196); \ - u3 += z5; u4 += z5; \ - s0 = t10 + t11; s1 = t7 + u1 + u4; s3 = t6 + u2 + u3; s4 = t10 - t11; s5 = t5 + u2 + u4; s7 = t4 + u1 + u3; - - static void DCT2D(int32 *p) { - int32 c, *q = p; - for (c = 7; c >= 0; c--, q += 8) { - int32 s0 = q[0], s1 = q[1], s2 = q[2], s3 = q[3], s4 = q[4], s5 = q[5], s6 = q[6], s7 = q[7]; - DCT1D(s0, s1, s2, s3, s4, s5, s6, s7); - q[0] = s0 << ROW_BITS; q[1] = DCT_DESCALE(s1, CONST_BITS-ROW_BITS); q[2] = DCT_DESCALE(s2, CONST_BITS-ROW_BITS); q[3] = DCT_DESCALE(s3, CONST_BITS-ROW_BITS); - q[4] = s4 << ROW_BITS; q[5] = DCT_DESCALE(s5, CONST_BITS-ROW_BITS); q[6] = DCT_DESCALE(s6, CONST_BITS-ROW_BITS); q[7] = DCT_DESCALE(s7, CONST_BITS-ROW_BITS); - } - for (q = p, c = 7; c >= 0; c--, q++) { - int32 s0 = q[0*8], s1 = q[1*8], s2 = q[2*8], s3 = q[3*8], s4 = q[4*8], s5 = q[5*8], s6 = q[6*8], s7 = q[7*8]; - DCT1D(s0, s1, s2, s3, s4, s5, s6, s7); - q[0*8] = DCT_DESCALE(s0, ROW_BITS+3); q[1*8] = DCT_DESCALE(s1, CONST_BITS+ROW_BITS+3); q[2*8] = DCT_DESCALE(s2, CONST_BITS+ROW_BITS+3); q[3*8] = DCT_DESCALE(s3, CONST_BITS+ROW_BITS+3); - q[4*8] = DCT_DESCALE(s4, ROW_BITS+3); q[5*8] = DCT_DESCALE(s5, CONST_BITS+ROW_BITS+3); q[6*8] = DCT_DESCALE(s6, CONST_BITS+ROW_BITS+3); q[7*8] = DCT_DESCALE(s7, CONST_BITS+ROW_BITS+3); - } - } - - // Compute the actual canonical Huffman codes/code sizes given the JPEG huff bits and val arrays. - static void compute_huffman_table(uint *codes, uint8 *code_sizes, uint8 *bits, uint8 *val) - { - int i, l, last_p, si; - static uint8 huff_size[257]; - static uint huff_code[257]; - uint code; - - int p = 0; - for (l = 1; l <= 16; l++) { - for (i = 1; i <= bits[l]; i++) { - huff_size[p++] = (char)l; - } - } - - huff_size[p] = 0; - last_p = p; // write sentinel - - code = 0; si = huff_size[0]; p = 0; - - while (huff_size[p]) { - while (huff_size[p] == si) { - huff_code[p++] = code++; - } - code <<= 1; - si++; - } - - memset(codes, 0, sizeof(codes[0])*256); - memset(code_sizes, 0, sizeof(code_sizes[0])*256); - for (p = 0; p < last_p; p++) { - codes[val[p]] = huff_code[p]; - code_sizes[val[p]] = huff_size[p]; - } - } - - void jpeg_encoder::flush_output_buffer() - { - if (m_out_buf_left != JPGE_OUT_BUF_SIZE) { - m_all_stream_writes_succeeded = m_all_stream_writes_succeeded && m_pStream->put_buf(m_out_buf, JPGE_OUT_BUF_SIZE - m_out_buf_left); - } - m_pOut_buf = m_out_buf; - m_out_buf_left = JPGE_OUT_BUF_SIZE; - } - - void jpeg_encoder::emit_byte(uint8 i) - { - *m_pOut_buf++ = i; - if (--m_out_buf_left == 0) { - flush_output_buffer(); - } - } - - void jpeg_encoder::put_bits(uint bits, uint len) - { - uint8 c = 0; - m_bit_buffer |= ((uint32)bits << (24 - (m_bits_in += len))); - while (m_bits_in >= 8) { - c = (uint8)((m_bit_buffer >> 16) & 0xFF); - emit_byte(c); - if (c == 0xFF) { - emit_byte(0); - } - m_bit_buffer <<= 8; - m_bits_in -= 8; - } - } - - void jpeg_encoder::emit_word(uint i) - { - emit_byte(uint8(i >> 8)); emit_byte(uint8(i & 0xFF)); - } - - // JPEG marker generation. - void jpeg_encoder::emit_marker(int marker) - { - emit_byte(uint8(0xFF)); emit_byte(uint8(marker)); - } - - // Emit JFIF marker - void jpeg_encoder::emit_jfif_app0() - { - emit_marker(M_APP0); - emit_word(2 + 4 + 1 + 2 + 1 + 2 + 2 + 1 + 1); - emit_byte(0x4A); emit_byte(0x46); emit_byte(0x49); emit_byte(0x46); /* Identifier: ASCII "JFIF" */ - emit_byte(0); - emit_byte(1); /* Major version */ - emit_byte(1); /* Minor version */ - emit_byte(0); /* Density unit */ - emit_word(1); - emit_word(1); - emit_byte(0); /* No thumbnail image */ - emit_byte(0); - } - - // Emit quantization tables - void jpeg_encoder::emit_dqt() - { - for (int i = 0; i < ((m_num_components == 3) ? 2 : 1); i++) - { - emit_marker(M_DQT); - emit_word(64 + 1 + 2); - emit_byte(static_cast(i)); - for (int j = 0; j < 64; j++) - emit_byte(static_cast(m_quantization_tables[i][j])); - } - } - - // Emit start of frame marker - void jpeg_encoder::emit_sof() - { - emit_marker(M_SOF0); /* baseline */ - emit_word(3 * m_num_components + 2 + 5 + 1); - emit_byte(8); /* precision */ - emit_word(m_image_y); - emit_word(m_image_x); - emit_byte(m_num_components); - for (int i = 0; i < m_num_components; i++) - { - emit_byte(static_cast(i + 1)); /* component ID */ - emit_byte((m_comp_h_samp[i] << 4) + m_comp_v_samp[i]); /* h and v sampling */ - emit_byte(i > 0); /* quant. table num */ - } - } - - // Emit Huffman table. - void jpeg_encoder::emit_dht(uint8 *bits, uint8 *val, int index, bool ac_flag) - { - emit_marker(M_DHT); - - int length = 0; - for (int i = 1; i <= 16; i++) - length += bits[i]; - - emit_word(length + 2 + 1 + 16); - emit_byte(static_cast(index + (ac_flag << 4))); - - for (int i = 1; i <= 16; i++) - emit_byte(bits[i]); - - for (int i = 0; i < length; i++) - emit_byte(val[i]); - } - - // Emit all Huffman tables. - void jpeg_encoder::emit_dhts() - { - emit_dht(m_huff_bits[0+0], m_huff_val[0+0], 0, false); - emit_dht(m_huff_bits[2+0], m_huff_val[2+0], 0, true); - if (m_num_components == 3) { - emit_dht(m_huff_bits[0+1], m_huff_val[0+1], 1, false); - emit_dht(m_huff_bits[2+1], m_huff_val[2+1], 1, true); - } - } - - // emit start of scan - void jpeg_encoder::emit_sos() - { - emit_marker(M_SOS); - emit_word(2 * m_num_components + 2 + 1 + 3); - emit_byte(m_num_components); - for (int i = 0; i < m_num_components; i++) - { - emit_byte(static_cast(i + 1)); - if (i == 0) - emit_byte((0 << 4) + 0); - else - emit_byte((1 << 4) + 1); - } - emit_byte(0); /* spectral selection */ - emit_byte(63); - emit_byte(0); - } - - void jpeg_encoder::load_block_8_8_grey(int x) - { - uint8 *pSrc; - sample_array_t *pDst = m_sample_array; - x <<= 3; - for (int i = 0; i < 8; i++, pDst += 8) - { - pSrc = m_mcu_lines[i] + x; - pDst[0] = pSrc[0] - 128; pDst[1] = pSrc[1] - 128; pDst[2] = pSrc[2] - 128; pDst[3] = pSrc[3] - 128; - pDst[4] = pSrc[4] - 128; pDst[5] = pSrc[5] - 128; pDst[6] = pSrc[6] - 128; pDst[7] = pSrc[7] - 128; - } - } - - void jpeg_encoder::load_block_8_8(int x, int y, int c) - { - uint8 *pSrc; - sample_array_t *pDst = m_sample_array; - x = (x * (8 * 3)) + c; - y <<= 3; - for (int i = 0; i < 8; i++, pDst += 8) - { - pSrc = m_mcu_lines[y + i] + x; - pDst[0] = pSrc[0 * 3] - 128; pDst[1] = pSrc[1 * 3] - 128; pDst[2] = pSrc[2 * 3] - 128; pDst[3] = pSrc[3 * 3] - 128; - pDst[4] = pSrc[4 * 3] - 128; pDst[5] = pSrc[5 * 3] - 128; pDst[6] = pSrc[6 * 3] - 128; pDst[7] = pSrc[7 * 3] - 128; - } - } - - void jpeg_encoder::load_block_16_8(int x, int c) - { - uint8 *pSrc1, *pSrc2; - sample_array_t *pDst = m_sample_array; - x = (x * (16 * 3)) + c; - int a = 0, b = 2; - for (int i = 0; i < 16; i += 2, pDst += 8) - { - pSrc1 = m_mcu_lines[i + 0] + x; - pSrc2 = m_mcu_lines[i + 1] + x; - pDst[0] = ((pSrc1[ 0 * 3] + pSrc1[ 1 * 3] + pSrc2[ 0 * 3] + pSrc2[ 1 * 3] + a) >> 2) - 128; pDst[1] = ((pSrc1[ 2 * 3] + pSrc1[ 3 * 3] + pSrc2[ 2 * 3] + pSrc2[ 3 * 3] + b) >> 2) - 128; - pDst[2] = ((pSrc1[ 4 * 3] + pSrc1[ 5 * 3] + pSrc2[ 4 * 3] + pSrc2[ 5 * 3] + a) >> 2) - 128; pDst[3] = ((pSrc1[ 6 * 3] + pSrc1[ 7 * 3] + pSrc2[ 6 * 3] + pSrc2[ 7 * 3] + b) >> 2) - 128; - pDst[4] = ((pSrc1[ 8 * 3] + pSrc1[ 9 * 3] + pSrc2[ 8 * 3] + pSrc2[ 9 * 3] + a) >> 2) - 128; pDst[5] = ((pSrc1[10 * 3] + pSrc1[11 * 3] + pSrc2[10 * 3] + pSrc2[11 * 3] + b) >> 2) - 128; - pDst[6] = ((pSrc1[12 * 3] + pSrc1[13 * 3] + pSrc2[12 * 3] + pSrc2[13 * 3] + a) >> 2) - 128; pDst[7] = ((pSrc1[14 * 3] + pSrc1[15 * 3] + pSrc2[14 * 3] + pSrc2[15 * 3] + b) >> 2) - 128; - int temp = a; a = b; b = temp; - } - } - - void jpeg_encoder::load_block_16_8_8(int x, int c) - { - uint8 *pSrc1; - sample_array_t *pDst = m_sample_array; - x = (x * (16 * 3)) + c; - for (int i = 0; i < 8; i++, pDst += 8) - { - pSrc1 = m_mcu_lines[i + 0] + x; - pDst[0] = ((pSrc1[ 0 * 3] + pSrc1[ 1 * 3]) >> 1) - 128; pDst[1] = ((pSrc1[ 2 * 3] + pSrc1[ 3 * 3]) >> 1) - 128; - pDst[2] = ((pSrc1[ 4 * 3] + pSrc1[ 5 * 3]) >> 1) - 128; pDst[3] = ((pSrc1[ 6 * 3] + pSrc1[ 7 * 3]) >> 1) - 128; - pDst[4] = ((pSrc1[ 8 * 3] + pSrc1[ 9 * 3]) >> 1) - 128; pDst[5] = ((pSrc1[10 * 3] + pSrc1[11 * 3]) >> 1) - 128; - pDst[6] = ((pSrc1[12 * 3] + pSrc1[13 * 3]) >> 1) - 128; pDst[7] = ((pSrc1[14 * 3] + pSrc1[15 * 3]) >> 1) - 128; - } - } - - void jpeg_encoder::load_quantized_coefficients(int component_num) - { - int32 *q = m_quantization_tables[component_num > 0]; - int16 *pDst = m_coefficient_array; - for (int i = 0; i < 64; i++) - { - sample_array_t j = m_sample_array[s_zag[i]]; - if (j < 0) - { - if ((j = -j + (*q >> 1)) < *q) - *pDst++ = 0; - else - *pDst++ = static_cast(-(j / *q)); - } - else - { - if ((j = j + (*q >> 1)) < *q) - *pDst++ = 0; - else - *pDst++ = static_cast((j / *q)); - } - q++; - } - } - - void jpeg_encoder::code_coefficients_pass_two(int component_num) - { - int i, j, run_len, nbits, temp1, temp2; - int16 *pSrc = m_coefficient_array; - uint *codes[2]; - uint8 *code_sizes[2]; - - if (component_num == 0) - { - codes[0] = m_huff_codes[0 + 0]; codes[1] = m_huff_codes[2 + 0]; - code_sizes[0] = m_huff_code_sizes[0 + 0]; code_sizes[1] = m_huff_code_sizes[2 + 0]; - } - else - { - codes[0] = m_huff_codes[0 + 1]; codes[1] = m_huff_codes[2 + 1]; - code_sizes[0] = m_huff_code_sizes[0 + 1]; code_sizes[1] = m_huff_code_sizes[2 + 1]; - } - - temp1 = temp2 = pSrc[0] - m_last_dc_val[component_num]; - m_last_dc_val[component_num] = pSrc[0]; - - if (temp1 < 0) - { - temp1 = -temp1; temp2--; - } - - nbits = 0; - while (temp1) - { - nbits++; temp1 >>= 1; - } - - put_bits(codes[0][nbits], code_sizes[0][nbits]); - if (nbits) put_bits(temp2 & ((1 << nbits) - 1), nbits); - - for (run_len = 0, i = 1; i < 64; i++) - { - if ((temp1 = m_coefficient_array[i]) == 0) - run_len++; - else - { - while (run_len >= 16) - { - put_bits(codes[1][0xF0], code_sizes[1][0xF0]); - run_len -= 16; - } - if ((temp2 = temp1) < 0) - { - temp1 = -temp1; - temp2--; - } - nbits = 1; - while (temp1 >>= 1) - nbits++; - j = (run_len << 4) + nbits; - put_bits(codes[1][j], code_sizes[1][j]); - put_bits(temp2 & ((1 << nbits) - 1), nbits); - run_len = 0; - } - } - if (run_len) - put_bits(codes[1][0], code_sizes[1][0]); - } - - void jpeg_encoder::code_block(int component_num) - { - DCT2D(m_sample_array); - load_quantized_coefficients(component_num); - code_coefficients_pass_two(component_num); - } - - void jpeg_encoder::process_mcu_row() - { - if (m_num_components == 1) - { - for (int i = 0; i < m_mcus_per_row; i++) - { - load_block_8_8_grey(i); code_block(0); - } - } - else if ((m_comp_h_samp[0] == 1) && (m_comp_v_samp[0] == 1)) - { - for (int i = 0; i < m_mcus_per_row; i++) - { - load_block_8_8(i, 0, 0); code_block(0); load_block_8_8(i, 0, 1); code_block(1); load_block_8_8(i, 0, 2); code_block(2); - } - } - else if ((m_comp_h_samp[0] == 2) && (m_comp_v_samp[0] == 1)) - { - for (int i = 0; i < m_mcus_per_row; i++) - { - load_block_8_8(i * 2 + 0, 0, 0); code_block(0); load_block_8_8(i * 2 + 1, 0, 0); code_block(0); - load_block_16_8_8(i, 1); code_block(1); load_block_16_8_8(i, 2); code_block(2); - } - } - else if ((m_comp_h_samp[0] == 2) && (m_comp_v_samp[0] == 2)) - { - for (int i = 0; i < m_mcus_per_row; i++) - { - load_block_8_8(i * 2 + 0, 0, 0); code_block(0); load_block_8_8(i * 2 + 1, 0, 0); code_block(0); - load_block_8_8(i * 2 + 0, 1, 0); code_block(0); load_block_8_8(i * 2 + 1, 1, 0); code_block(0); - load_block_16_8(i, 1); code_block(1); load_block_16_8(i, 2); code_block(2); - } - } - } - - void jpeg_encoder::load_mcu(const void *pSrc) - { - const uint8* Psrc = reinterpret_cast(pSrc); - - uint8* pDst = m_mcu_lines[m_mcu_y_ofs]; // OK to write up to m_image_bpl_xlt bytes to pDst - - if (m_num_components == 1) { - if (m_image_bpp == 3) - RGB_to_Y(pDst, Psrc, m_image_x); - else - memcpy(pDst, Psrc, m_image_x); - } else { - if (m_image_bpp == 3) - RGB_to_YCC(pDst, Psrc, m_image_x); - else - Y_to_YCC(pDst, Psrc, m_image_x); - } - - // Possibly duplicate pixels at end of scanline if not a multiple of 8 or 16 - if (m_num_components == 1) - memset(m_mcu_lines[m_mcu_y_ofs] + m_image_bpl_xlt, pDst[m_image_bpl_xlt - 1], m_image_x_mcu - m_image_x); - else - { - const uint8 y = pDst[m_image_bpl_xlt - 3 + 0], cb = pDst[m_image_bpl_xlt - 3 + 1], cr = pDst[m_image_bpl_xlt - 3 + 2]; - uint8 *q = m_mcu_lines[m_mcu_y_ofs] + m_image_bpl_xlt; - for (int i = m_image_x; i < m_image_x_mcu; i++) - { - *q++ = y; *q++ = cb; *q++ = cr; - } - } - - if (++m_mcu_y_ofs == m_mcu_y) - { - process_mcu_row(); - m_mcu_y_ofs = 0; - } - } - - // Quantization table generation. - void jpeg_encoder::compute_quant_table(int32 *pDst, const int16 *pSrc) - { - int32 q; - if (m_params.m_quality < 50) - q = 5000 / m_params.m_quality; - else - q = 200 - m_params.m_quality * 2; - for (int i = 0; i < 64; i++) - { - int32 j = *pSrc++; j = (j * q + 50L) / 100L; - *pDst++ = JPGE_MIN(JPGE_MAX(j, 1), 255); - } - } - - // Higher-level methods. - bool jpeg_encoder::jpg_open(int p_x_res, int p_y_res, int src_channels) - { - m_num_components = 3; - switch (m_params.m_subsampling) - { - case Y_ONLY: - { - m_num_components = 1; - m_comp_h_samp[0] = 1; m_comp_v_samp[0] = 1; - m_mcu_x = 8; m_mcu_y = 8; - break; - } - case H1V1: - { - m_comp_h_samp[0] = 1; m_comp_v_samp[0] = 1; - m_comp_h_samp[1] = 1; m_comp_v_samp[1] = 1; - m_comp_h_samp[2] = 1; m_comp_v_samp[2] = 1; - m_mcu_x = 8; m_mcu_y = 8; - break; - } - case H2V1: - { - m_comp_h_samp[0] = 2; m_comp_v_samp[0] = 1; - m_comp_h_samp[1] = 1; m_comp_v_samp[1] = 1; - m_comp_h_samp[2] = 1; m_comp_v_samp[2] = 1; - m_mcu_x = 16; m_mcu_y = 8; - break; - } - case H2V2: - { - m_comp_h_samp[0] = 2; m_comp_v_samp[0] = 2; - m_comp_h_samp[1] = 1; m_comp_v_samp[1] = 1; - m_comp_h_samp[2] = 1; m_comp_v_samp[2] = 1; - m_mcu_x = 16; m_mcu_y = 16; - } - } - - m_image_x = p_x_res; m_image_y = p_y_res; - m_image_bpp = src_channels; - m_image_bpl = m_image_x * src_channels; - m_image_x_mcu = (m_image_x + m_mcu_x - 1) & (~(m_mcu_x - 1)); - m_image_y_mcu = (m_image_y + m_mcu_y - 1) & (~(m_mcu_y - 1)); - m_image_bpl_xlt = m_image_x * m_num_components; - m_image_bpl_mcu = m_image_x_mcu * m_num_components; - m_mcus_per_row = m_image_x_mcu / m_mcu_x; - - if ((m_mcu_lines[0] = static_cast(jpge_malloc(m_image_bpl_mcu * m_mcu_y))) == NULL) { - return false; - } - for (int i = 1; i < m_mcu_y; i++) - m_mcu_lines[i] = m_mcu_lines[i-1] + m_image_bpl_mcu; - - if(m_last_quality != m_params.m_quality){ - m_last_quality = m_params.m_quality; - compute_quant_table(m_quantization_tables[0], s_std_lum_quant); - compute_quant_table(m_quantization_tables[1], s_std_croma_quant); - } - - if(!m_huff_initialized){ - m_huff_initialized = true; - - memcpy(m_huff_bits[0+0], s_dc_lum_bits, 17); memcpy(m_huff_val[0+0], s_dc_lum_val, DC_LUM_CODES); - memcpy(m_huff_bits[2+0], s_ac_lum_bits, 17); memcpy(m_huff_val[2+0], s_ac_lum_val, AC_LUM_CODES); - memcpy(m_huff_bits[0+1], s_dc_chroma_bits, 17); memcpy(m_huff_val[0+1], s_dc_chroma_val, DC_CHROMA_CODES); - memcpy(m_huff_bits[2+1], s_ac_chroma_bits, 17); memcpy(m_huff_val[2+1], s_ac_chroma_val, AC_CHROMA_CODES); - - compute_huffman_table(&m_huff_codes[0+0][0], &m_huff_code_sizes[0+0][0], m_huff_bits[0+0], m_huff_val[0+0]); - compute_huffman_table(&m_huff_codes[2+0][0], &m_huff_code_sizes[2+0][0], m_huff_bits[2+0], m_huff_val[2+0]); - compute_huffman_table(&m_huff_codes[0+1][0], &m_huff_code_sizes[0+1][0], m_huff_bits[0+1], m_huff_val[0+1]); - compute_huffman_table(&m_huff_codes[2+1][0], &m_huff_code_sizes[2+1][0], m_huff_bits[2+1], m_huff_val[2+1]); - } - - m_out_buf_left = JPGE_OUT_BUF_SIZE; - m_pOut_buf = m_out_buf; - m_bit_buffer = 0; - m_bits_in = 0; - m_mcu_y_ofs = 0; - m_pass_num = 2; - memset(m_last_dc_val, 0, 3 * sizeof(m_last_dc_val[0])); - - // Emit all markers at beginning of image file. - emit_marker(M_SOI); - emit_jfif_app0(); - emit_dqt(); - emit_sof(); - emit_dhts(); - emit_sos(); - - return m_all_stream_writes_succeeded; - } - - bool jpeg_encoder::process_end_of_image() - { - if (m_mcu_y_ofs) { - if (m_mcu_y_ofs < 16) { // check here just to shut up static analysis - for (int i = m_mcu_y_ofs; i < m_mcu_y; i++) { - memcpy(m_mcu_lines[i], m_mcu_lines[m_mcu_y_ofs - 1], m_image_bpl_mcu); - } - } - process_mcu_row(); - } - - put_bits(0x7F, 7); - emit_marker(M_EOI); - flush_output_buffer(); - m_all_stream_writes_succeeded = m_all_stream_writes_succeeded && m_pStream->put_buf(NULL, 0); - m_pass_num++; // purposely bump up m_pass_num, for debugging - return true; - } - - void jpeg_encoder::clear() - { - m_mcu_lines[0] = NULL; - m_pass_num = 0; - m_all_stream_writes_succeeded = true; - } - - jpeg_encoder::jpeg_encoder() - { - clear(); - } - - jpeg_encoder::~jpeg_encoder() - { - deinit(); - } - - bool jpeg_encoder::init(output_stream *pStream, int width, int height, int src_channels, const params &comp_params) - { - deinit(); - if (((!pStream) || (width < 1) || (height < 1)) || ((src_channels != 1) && (src_channels != 3) && (src_channels != 4)) || (!comp_params.check())) return false; - m_pStream = pStream; - m_params = comp_params; - return jpg_open(width, height, src_channels); - } - - void jpeg_encoder::deinit() - { - jpge_free(m_mcu_lines[0]); - clear(); - } - - bool jpeg_encoder::process_scanline(const void* pScanline) - { - if ((m_pass_num < 1) || (m_pass_num > 2)) { - return false; - } - if (m_all_stream_writes_succeeded) { - if (!pScanline) { - if (!process_end_of_image()) { - return false; - } - } else { - load_mcu(pScanline); - } - } - return m_all_stream_writes_succeeded; - } - -} // namespace jpge diff --git a/lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h b/lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h deleted file mode 100644 index aa295c8af..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/private_include/jpge.h +++ /dev/null @@ -1,142 +0,0 @@ -// jpge.h - C++ class for JPEG compression. -// Public domain, Rich Geldreich -// Alex Evans: Added RGBA support, linear memory allocator. -#ifndef JPEG_ENCODER_H -#define JPEG_ENCODER_H - -namespace jpge -{ - typedef unsigned char uint8; - typedef signed short int16; - typedef signed int int32; - typedef unsigned short uint16; - typedef unsigned int uint32; - typedef unsigned int uint; - - // JPEG chroma subsampling factors. Y_ONLY (grayscale images) and H2V2 (color images) are the most common. - enum subsampling_t { Y_ONLY = 0, H1V1 = 1, H2V1 = 2, H2V2 = 3 }; - - // JPEG compression parameters structure. - struct params { - inline params() : m_quality(85), m_subsampling(H2V2) { } - - inline bool check() const { - if ((m_quality < 1) || (m_quality > 100)) { - return false; - } - if ((uint)m_subsampling > (uint)H2V2) { - return false; - } - return true; - } - - // Quality: 1-100, higher is better. Typical values are around 50-95. - int m_quality; - - // m_subsampling: - // 0 = Y (grayscale) only - // 1 = H1V1 subsampling (YCbCr 1x1x1, 3 blocks per MCU) - // 2 = H2V1 subsampling (YCbCr 2x1x1, 4 blocks per MCU) - // 3 = H2V2 subsampling (YCbCr 4x1x1, 6 blocks per MCU-- very common) - subsampling_t m_subsampling; - }; - - // Output stream abstract class - used by the jpeg_encoder class to write to the output stream. - // put_buf() is generally called with len==JPGE_OUT_BUF_SIZE bytes, but for headers it'll be called with smaller amounts. - class output_stream { - public: - virtual ~output_stream() { }; - virtual bool put_buf(const void* Pbuf, int len) = 0; - virtual uint get_size() const = 0; - }; - - // Lower level jpeg_encoder class - useful if more control is needed than the above helper functions. - class jpeg_encoder { - public: - jpeg_encoder(); - ~jpeg_encoder(); - - // Initializes the compressor. - // pStream: The stream object to use for writing compressed data. - // params - Compression parameters structure, defined above. - // width, height - Image dimensions. - // channels - May be 1, or 3. 1 indicates grayscale, 3 indicates RGB source data. - // Returns false on out of memory or if a stream write fails. - bool init(output_stream *pStream, int width, int height, int src_channels, const params &comp_params = params()); - - // Call this method with each source scanline. - // width * src_channels bytes per scanline is expected (RGB or Y format). - // You must call with NULL after all scanlines are processed to finish compression. - // Returns false on out of memory or if a stream write fails. - bool process_scanline(const void* pScanline); - - // Deinitializes the compressor, freeing any allocated memory. May be called at any time. - void deinit(); - - private: - jpeg_encoder(const jpeg_encoder &); - jpeg_encoder &operator =(const jpeg_encoder &); - - typedef int32 sample_array_t; - enum { JPGE_OUT_BUF_SIZE = 512 }; - - output_stream *m_pStream; - params m_params; - uint8 m_num_components; - uint8 m_comp_h_samp[3], m_comp_v_samp[3]; - int m_image_x, m_image_y, m_image_bpp, m_image_bpl; - int m_image_x_mcu, m_image_y_mcu; - int m_image_bpl_xlt, m_image_bpl_mcu; - int m_mcus_per_row; - int m_mcu_x, m_mcu_y; - uint8 *m_mcu_lines[16]; - uint8 m_mcu_y_ofs; - sample_array_t m_sample_array[64]; - int16 m_coefficient_array[64]; - - int m_last_dc_val[3]; - uint8 m_out_buf[JPGE_OUT_BUF_SIZE]; - uint8 *m_pOut_buf; - uint m_out_buf_left; - uint32 m_bit_buffer; - uint m_bits_in; - uint8 m_pass_num; - bool m_all_stream_writes_succeeded; - - bool jpg_open(int p_x_res, int p_y_res, int src_channels); - - void flush_output_buffer(); - void put_bits(uint bits, uint len); - - void emit_byte(uint8 i); - void emit_word(uint i); - void emit_marker(int marker); - - void emit_jfif_app0(); - void emit_dqt(); - void emit_sof(); - void emit_dht(uint8 *bits, uint8 *val, int index, bool ac_flag); - void emit_dhts(); - void emit_sos(); - - void compute_quant_table(int32 *dst, const int16 *src); - void load_quantized_coefficients(int component_num); - - void load_block_8_8_grey(int x); - void load_block_8_8(int x, int y, int c); - void load_block_16_8(int x, int c); - void load_block_16_8_8(int x, int c); - - void code_coefficients_pass_two(int component_num); - void code_block(int component_num); - - void process_mcu_row(); - bool process_end_of_image(); - void load_mcu(const void* src); - void clear(); - void init(); - }; - -} // namespace jpge - -#endif // JPEG_ENCODER diff --git a/lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h b/lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h deleted file mode 100644 index c5a0577ef..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/private_include/yuv.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef _CONVERSIONS_YUV_H_ -#define _CONVERSIONS_YUV_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -void yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b); - -#ifdef __cplusplus -} -#endif - -#endif /* _CONVERSIONS_YUV_H_ */ diff --git a/lib/libesp32_div/esp32-camera/conversions/to_bmp.c b/lib/libesp32_div/esp32-camera/conversions/to_bmp.c deleted file mode 100644 index 5a54bdbae..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/to_bmp.c +++ /dev/null @@ -1,393 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include -#include -#include "img_converters.h" -#include "soc/efuse_reg.h" -#include "esp_heap_caps.h" -#include "yuv.h" -#include "sdkconfig.h" -#include "esp_jpg_decode.h" - -#include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 -#include "esp32/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/spiram.h" -#else -#error Target CONFIG_IDF_TARGET is not supported -#endif -#else // ESP32 Before IDF 4.0 -#include "esp_spiram.h" -#endif - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#define TAG "" -#else -#include "esp_log.h" -static const char* TAG = "to_bmp"; -#endif - -static const int BMP_HEADER_LEN = 54; - -typedef struct { - uint32_t filesize; - uint32_t reserved; - uint32_t fileoffset_to_pixelarray; - uint32_t dibheadersize; - int32_t width; - int32_t height; - uint16_t planes; - uint16_t bitsperpixel; - uint32_t compression; - uint32_t imagesize; - uint32_t ypixelpermeter; - uint32_t xpixelpermeter; - uint32_t numcolorspallette; - uint32_t mostimpcolor; -} bmp_header_t; - -typedef struct { - uint16_t width; - uint16_t height; - uint16_t data_offset; - const uint8_t *input; - uint8_t *output; -} rgb_jpg_decoder; - -static void *_malloc(size_t size) -{ - return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); -} - -//output buffer and image width -static bool _rgb_write(void * arg, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint8_t *data) -{ - rgb_jpg_decoder * jpeg = (rgb_jpg_decoder *)arg; - if(!data){ - if(x == 0 && y == 0){ - //write start - jpeg->width = w; - jpeg->height = h; - //if output is null, this is BMP - if(!jpeg->output){ - jpeg->output = (uint8_t *)_malloc((w*h*3)+jpeg->data_offset); - if(!jpeg->output){ - return false; - } - } - } else { - //write end - } - return true; - } - - size_t jw = jpeg->width*3; - size_t t = y * jw; - size_t b = t + (h * jw); - size_t l = x * 3; - uint8_t *out = jpeg->output+jpeg->data_offset; - uint8_t *o = out; - size_t iy, ix; - - w = w * 3; - - for(iy=t; iywidth = w; - jpeg->height = h; - //if output is null, this is BMP - if(!jpeg->output){ - jpeg->output = (uint8_t *)_malloc((w*h*3)+jpeg->data_offset); - if(!jpeg->output){ - return false; - } - } - } else { - //write end - } - return true; - } - - size_t jw = jpeg->width*3; - size_t jw2 = jpeg->width*2; - size_t t = y * jw; - size_t t2 = y * jw2; - size_t b = t + (h * jw); - size_t l = x * 2; - uint8_t *out = jpeg->output+jpeg->data_offset; - uint8_t *o = out; - size_t iy, iy2, ix, ix2; - - w = w * 3; - - for(iy=t, iy2=t2; iy> 3); - o[ix2+1] = c>>8; - o[ix2] = c&0xff; - } - data+=w; - } - return true; -} - -//input buffer -static uint32_t _jpg_read(void * arg, size_t index, uint8_t *buf, size_t len) -{ - rgb_jpg_decoder * jpeg = (rgb_jpg_decoder *)arg; - if(buf) { - memcpy(buf, jpeg->input + index, len); - } - return len; -} - -static bool jpg2rgb888(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale) -{ - rgb_jpg_decoder jpeg; - jpeg.width = 0; - jpeg.height = 0; - jpeg.input = src; - jpeg.output = out; - jpeg.data_offset = 0; - - if(esp_jpg_decode(src_len, scale, _jpg_read, _rgb_write, (void*)&jpeg) != ESP_OK){ - return false; - } - return true; -} - -bool jpg2rgb565(const uint8_t *src, size_t src_len, uint8_t * out, jpg_scale_t scale) -{ - rgb_jpg_decoder jpeg; - jpeg.width = 0; - jpeg.height = 0; - jpeg.input = src; - jpeg.output = out; - jpeg.data_offset = 0; - - if(esp_jpg_decode(src_len, scale, _jpg_read, _rgb565_write, (void*)&jpeg) != ESP_OK){ - return false; - } - return true; -} - -bool jpg2bmp(const uint8_t *src, size_t src_len, uint8_t ** out, size_t * out_len) -{ - - rgb_jpg_decoder jpeg; - jpeg.width = 0; - jpeg.height = 0; - jpeg.input = src; - jpeg.output = NULL; - jpeg.data_offset = BMP_HEADER_LEN; - - if(esp_jpg_decode(src_len, JPG_SCALE_NONE, _jpg_read, _rgb_write, (void*)&jpeg) != ESP_OK){ - return false; - } - - size_t output_size = jpeg.width*jpeg.height*3; - - jpeg.output[0] = 'B'; - jpeg.output[1] = 'M'; - bmp_header_t * bitmap = (bmp_header_t*)&jpeg.output[2]; - bitmap->reserved = 0; - bitmap->filesize = output_size+BMP_HEADER_LEN; - bitmap->fileoffset_to_pixelarray = BMP_HEADER_LEN; - bitmap->dibheadersize = 40; - bitmap->width = jpeg.width; - bitmap->height = -jpeg.height;//set negative for top to bottom - bitmap->planes = 1; - bitmap->bitsperpixel = 24; - bitmap->compression = 0; - bitmap->imagesize = output_size; - bitmap->ypixelpermeter = 0x0B13 ; //2835 , 72 DPI - bitmap->xpixelpermeter = 0x0B13 ; //2835 , 72 DPI - bitmap->numcolorspallette = 0; - bitmap->mostimpcolor = 0; - - *out = jpeg.output; - *out_len = output_size+BMP_HEADER_LEN; - - return true; -} - -bool fmt2rgb888(const uint8_t *src_buf, size_t src_len, pixformat_t format, uint8_t * rgb_buf) -{ - int pix_count = 0; - if(format == PIXFORMAT_JPEG) { - return jpg2rgb888(src_buf, src_len, rgb_buf, JPG_SCALE_NONE); - } else if(format == PIXFORMAT_RGB888) { - memcpy(rgb_buf, src_buf, src_len); - } else if(format == PIXFORMAT_RGB565) { - int i; - uint8_t hb, lb; - pix_count = src_len / 2; - for(i=0; i> 3; - *rgb_buf++ = hb & 0xF8; - } - } else if(format == PIXFORMAT_GRAYSCALE) { - int i; - uint8_t b; - pix_count = src_len; - for(i=0; ireserved = 0; - bitmap->filesize = out_size; - bitmap->fileoffset_to_pixelarray = BMP_HEADER_LEN; - bitmap->dibheadersize = 40; - bitmap->width = width; - bitmap->height = -height;//set negative for top to bottom - bitmap->planes = 1; - bitmap->bitsperpixel = 24; - bitmap->compression = 0; - bitmap->imagesize = pix_count * 3; - bitmap->ypixelpermeter = 0x0B13 ; //2835 , 72 DPI - bitmap->xpixelpermeter = 0x0B13 ; //2835 , 72 DPI - bitmap->numcolorspallette = 0; - bitmap->mostimpcolor = 0; - - uint8_t * rgb_buf = out_buf + BMP_HEADER_LEN; - uint8_t * src_buf = src; - - - //convert data to RGB888 - if(format == PIXFORMAT_RGB888) { - memcpy(rgb_buf, src_buf, pix_count*3); - } else if(format == PIXFORMAT_RGB565) { - int i; - uint8_t hb, lb; - for(i=0; i> 3; - *rgb_buf++ = hb & 0xF8; - } - } else if(format == PIXFORMAT_GRAYSCALE) { - int i; - uint8_t b; - for(i=0; ibuf, fb->len, fb->width, fb->height, fb->format, out, out_len); -} diff --git a/lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp b/lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp deleted file mode 100644 index 9b8905a73..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/to_jpg.cpp +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include -#include -#include "esp_attr.h" -#include "soc/efuse_reg.h" -#include "esp_heap_caps.h" -#include "esp_camera.h" -#include "img_converters.h" -#include "jpge.h" -#include "yuv.h" - -#include "esp_system.h" -#if ESP_IDF_VERSION_MAJOR >= 4 // IDF 4+ -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 -#include "esp32/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/spiram.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/spiram.h" -#else -#error Target CONFIG_IDF_TARGET is not supported -#endif -#else // ESP32 Before IDF 4.0 -#include "esp_spiram.h" -#endif - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#define TAG "" -#else -#include "esp_log.h" -static const char* TAG = "to_jpg"; -#endif - -static void *_malloc(size_t size) -{ - void * res = malloc(size); - if(res) { - return res; - } - return heap_caps_malloc(size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); -} - -static IRAM_ATTR void convert_line_format(uint8_t * src, pixformat_t format, uint8_t * dst, size_t width, size_t in_channels, size_t line) -{ - int i=0, o=0, l=0; - if(format == PIXFORMAT_GRAYSCALE) { - memcpy(dst, src + line * width, width); - } else if(format == PIXFORMAT_RGB888) { - l = width * 3; - src += l * line; - for(i=0; i> 3; - dst[o++] = (src[i+1] & 0x1F) << 3; - } - } else if(format == PIXFORMAT_YUV422) { - uint8_t y0, y1, u, v; - uint8_t r, g, b; - l = width * 2; - src += l * line; - for(i=0; i 100) { - quality = 100; - } - - jpge::params comp_params = jpge::params(); - comp_params.m_subsampling = subsampling; - comp_params.m_quality = quality; - - jpge::jpeg_encoder dst_image; - - if (!dst_image.init(dst_stream, width, height, num_channels, comp_params)) { - ESP_LOGE(TAG, "JPG encoder init failed"); - return false; - } - - uint8_t* line = (uint8_t*)_malloc(width * num_channels); - if(!line) { - ESP_LOGE(TAG, "Scan line malloc failed"); - return false; - } - - for (int i = 0; i < height; i++) { - convert_line_format(src, format, line, width, num_channels, i); - if (!dst_image.process_scanline(line)) { - ESP_LOGE(TAG, "JPG process line %u failed", i); - free(line); - return false; - } - } - free(line); - - if (!dst_image.process_scanline(NULL)) { - ESP_LOGE(TAG, "JPG image finish failed"); - return false; - } - dst_image.deinit(); - return true; -} - -class callback_stream : public jpge::output_stream { -protected: - jpg_out_cb ocb; - void * oarg; - size_t index; - -public: - callback_stream(jpg_out_cb cb, void * arg) : ocb(cb), oarg(arg), index(0) { } - virtual ~callback_stream() { } - virtual bool put_buf(const void* data, int len) - { - index += ocb(oarg, index, data, len); - return true; - } - virtual size_t get_size() const - { - return index; - } -}; - -bool fmt2jpg_cb(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, jpg_out_cb cb, void * arg) -{ - callback_stream dst_stream(cb, arg); - return convert_image(src, width, height, format, quality, &dst_stream); -} - -bool frame2jpg_cb(camera_fb_t * fb, uint8_t quality, jpg_out_cb cb, void * arg) -{ - return fmt2jpg_cb(fb->buf, fb->len, fb->width, fb->height, fb->format, quality, cb, arg); -} - - - -class memory_stream : public jpge::output_stream { -protected: - uint8_t *out_buf; - size_t max_len, index; - -public: - memory_stream(void *pBuf, uint buf_size) : out_buf(static_cast(pBuf)), max_len(buf_size), index(0) { } - - virtual ~memory_stream() { } - - virtual bool put_buf(const void* pBuf, int len) - { - if (!pBuf) { - //end of image - return true; - } - if ((size_t)len > (max_len - index)) { - //ESP_LOGW(TAG, "JPG output overflow: %d bytes (%d,%d,%d)", len - (max_len - index), len, index, max_len); - len = max_len - index; - } - if (len) { - memcpy(out_buf + index, pBuf, len); - index += len; - } - return true; - } - - virtual size_t get_size() const - { - return index; - } -}; - -bool fmt2jpg(uint8_t *src, size_t src_len, uint16_t width, uint16_t height, pixformat_t format, uint8_t quality, uint8_t ** out, size_t * out_len) -{ - //todo: allocate proper buffer for holding JPEG data - //this should be enough for CIF frame size - int jpg_buf_len = 128*1024; - - - uint8_t * jpg_buf = (uint8_t *)_malloc(jpg_buf_len); - if(jpg_buf == NULL) { - ESP_LOGE(TAG, "JPG buffer malloc failed"); - return false; - } - memory_stream dst_stream(jpg_buf, jpg_buf_len); - - if(!convert_image(src, width, height, format, quality, &dst_stream)) { - free(jpg_buf); - return false; - } - - *out = jpg_buf; - *out_len = dst_stream.get_size(); - return true; -} - -bool frame2jpg(camera_fb_t * fb, uint8_t quality, uint8_t ** out, size_t * out_len) -{ - return fmt2jpg(fb->buf, fb->len, fb->width, fb->height, fb->format, quality, out, out_len); -} diff --git a/lib/libesp32_div/esp32-camera/conversions/yuv.c b/lib/libesp32_div/esp32-camera/conversions/yuv.c deleted file mode 100644 index 46034cc86..000000000 --- a/lib/libesp32_div/esp32-camera/conversions/yuv.c +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include "yuv.h" -#include "esp_attr.h" - -typedef struct { - int16_t vY; - int16_t vVr; - int16_t vVg; - int16_t vUg; - int16_t vUb; -} yuv_table_row; - -static const yuv_table_row yuv_table[256] = { - // Y Vr Vg Ug Ub // # - { -18, -204, 50, 104, -258 }, // 0 - { -17, -202, 49, 103, -256 }, // 1 - { -16, -201, 49, 102, -254 }, // 2 - { -15, -199, 48, 101, -252 }, // 3 - { -13, -197, 48, 100, -250 }, // 4 - { -12, -196, 48, 99, -248 }, // 5 - { -11, -194, 47, 99, -246 }, // 6 - { -10, -193, 47, 98, -244 }, // 7 - { -9, -191, 46, 97, -242 }, // 8 - { -8, -189, 46, 96, -240 }, // 9 - { -6, -188, 46, 95, -238 }, // 10 - { -5, -186, 45, 95, -236 }, // 11 - { -4, -185, 45, 94, -234 }, // 12 - { -3, -183, 44, 93, -232 }, // 13 - { -2, -181, 44, 92, -230 }, // 14 - { -1, -180, 44, 91, -228 }, // 15 - { 0, -178, 43, 91, -226 }, // 16 - { 1, -177, 43, 90, -223 }, // 17 - { 2, -175, 43, 89, -221 }, // 18 - { 3, -173, 42, 88, -219 }, // 19 - { 4, -172, 42, 87, -217 }, // 20 - { 5, -170, 41, 86, -215 }, // 21 - { 6, -169, 41, 86, -213 }, // 22 - { 8, -167, 41, 85, -211 }, // 23 - { 9, -165, 40, 84, -209 }, // 24 - { 10, -164, 40, 83, -207 }, // 25 - { 11, -162, 39, 82, -205 }, // 26 - { 12, -161, 39, 82, -203 }, // 27 - { 13, -159, 39, 81, -201 }, // 28 - { 15, -158, 38, 80, -199 }, // 29 - { 16, -156, 38, 79, -197 }, // 30 - { 17, -154, 37, 78, -195 }, // 31 - { 18, -153, 37, 78, -193 }, // 32 - { 19, -151, 37, 77, -191 }, // 33 - { 20, -150, 36, 76, -189 }, // 34 - { 22, -148, 36, 75, -187 }, // 35 - { 23, -146, 35, 74, -185 }, // 36 - { 24, -145, 35, 73, -183 }, // 37 - { 25, -143, 35, 73, -181 }, // 38 - { 26, -142, 34, 72, -179 }, // 39 - { 27, -140, 34, 71, -177 }, // 40 - { 29, -138, 34, 70, -175 }, // 41 - { 30, -137, 33, 69, -173 }, // 42 - { 31, -135, 33, 69, -171 }, // 43 - { 32, -134, 32, 68, -169 }, // 44 - { 33, -132, 32, 67, -167 }, // 45 - { 34, -130, 32, 66, -165 }, // 46 - { 36, -129, 31, 65, -163 }, // 47 - { 37, -127, 31, 65, -161 }, // 48 - { 38, -126, 30, 64, -159 }, // 49 - { 39, -124, 30, 63, -157 }, // 50 - { 40, -122, 30, 62, -155 }, // 51 - { 41, -121, 29, 61, -153 }, // 52 - { 43, -119, 29, 60, -151 }, // 53 - { 44, -118, 28, 60, -149 }, // 54 - { 45, -116, 28, 59, -147 }, // 55 - { 46, -114, 28, 58, -145 }, // 56 - { 47, -113, 27, 57, -143 }, // 57 - { 48, -111, 27, 56, -141 }, // 58 - { 50, -110, 26, 56, -139 }, // 59 - { 51, -108, 26, 55, -137 }, // 60 - { 52, -106, 26, 54, -135 }, // 61 - { 53, -105, 25, 53, -133 }, // 62 - { 54, -103, 25, 52, -131 }, // 63 - { 55, -102, 25, 52, -129 }, // 64 - { 57, -100, 24, 51, -127 }, // 65 - { 58, -98, 24, 50, -125 }, // 66 - { 59, -97, 23, 49, -123 }, // 67 - { 60, -95, 23, 48, -121 }, // 68 - { 61, -94, 23, 47, -119 }, // 69 - { 62, -92, 22, 47, -117 }, // 70 - { 64, -90, 22, 46, -115 }, // 71 - { 65, -89, 21, 45, -113 }, // 72 - { 66, -87, 21, 44, -110 }, // 73 - { 67, -86, 21, 43, -108 }, // 74 - { 68, -84, 20, 43, -106 }, // 75 - { 69, -82, 20, 42, -104 }, // 76 - { 71, -81, 19, 41, -102 }, // 77 - { 72, -79, 19, 40, -100 }, // 78 - { 73, -78, 19, 39, -98 }, // 79 - { 74, -76, 18, 39, -96 }, // 80 - { 75, -75, 18, 38, -94 }, // 81 - { 76, -73, 17, 37, -92 }, // 82 - { 77, -71, 17, 36, -90 }, // 83 - { 79, -70, 17, 35, -88 }, // 84 - { 80, -68, 16, 34, -86 }, // 85 - { 81, -67, 16, 34, -84 }, // 86 - { 82, -65, 16, 33, -82 }, // 87 - { 83, -63, 15, 32, -80 }, // 88 - { 84, -62, 15, 31, -78 }, // 89 - { 86, -60, 14, 30, -76 }, // 90 - { 87, -59, 14, 30, -74 }, // 91 - { 88, -57, 14, 29, -72 }, // 92 - { 89, -55, 13, 28, -70 }, // 93 - { 90, -54, 13, 27, -68 }, // 94 - { 91, -52, 12, 26, -66 }, // 95 - { 93, -51, 12, 26, -64 }, // 96 - { 94, -49, 12, 25, -62 }, // 97 - { 95, -47, 11, 24, -60 }, // 98 - { 96, -46, 11, 23, -58 }, // 99 - { 97, -44, 10, 22, -56 }, // 100 - { 98, -43, 10, 21, -54 }, // 101 - { 100, -41, 10, 21, -52 }, // 102 - { 101, -39, 9, 20, -50 }, // 103 - { 102, -38, 9, 19, -48 }, // 104 - { 103, -36, 8, 18, -46 }, // 105 - { 104, -35, 8, 17, -44 }, // 106 - { 105, -33, 8, 17, -42 }, // 107 - { 107, -31, 7, 16, -40 }, // 108 - { 108, -30, 7, 15, -38 }, // 109 - { 109, -28, 7, 14, -36 }, // 110 - { 110, -27, 6, 13, -34 }, // 111 - { 111, -25, 6, 13, -32 }, // 112 - { 112, -23, 5, 12, -30 }, // 113 - { 114, -22, 5, 11, -28 }, // 114 - { 115, -20, 5, 10, -26 }, // 115 - { 116, -19, 4, 9, -24 }, // 116 - { 117, -17, 4, 8, -22 }, // 117 - { 118, -15, 3, 8, -20 }, // 118 - { 119, -14, 3, 7, -18 }, // 119 - { 121, -12, 3, 6, -16 }, // 120 - { 122, -11, 2, 5, -14 }, // 121 - { 123, -9, 2, 4, -12 }, // 122 - { 124, -7, 1, 4, -10 }, // 123 - { 125, -6, 1, 3, -8 }, // 124 - { 126, -4, 1, 2, -6 }, // 125 - { 128, -3, 0, 1, -4 }, // 126 - { 129, -1, 0, 0, -2 }, // 127 - { 130, 0, 0, 0, 0 }, // 128 - { 131, 1, 0, 0, 2 }, // 129 - { 132, 3, 0, -1, 4 }, // 130 - { 133, 4, -1, -2, 6 }, // 131 - { 135, 6, -1, -3, 8 }, // 132 - { 136, 7, -1, -4, 10 }, // 133 - { 137, 9, -2, -4, 12 }, // 134 - { 138, 11, -2, -5, 14 }, // 135 - { 139, 12, -3, -6, 16 }, // 136 - { 140, 14, -3, -7, 18 }, // 137 - { 142, 15, -3, -8, 20 }, // 138 - { 143, 17, -4, -8, 22 }, // 139 - { 144, 19, -4, -9, 24 }, // 140 - { 145, 20, -5, -10, 26 }, // 141 - { 146, 22, -5, -11, 28 }, // 142 - { 147, 23, -5, -12, 30 }, // 143 - { 148, 25, -6, -13, 32 }, // 144 - { 150, 27, -6, -13, 34 }, // 145 - { 151, 28, -7, -14, 36 }, // 146 - { 152, 30, -7, -15, 38 }, // 147 - { 153, 31, -7, -16, 40 }, // 148 - { 154, 33, -8, -17, 42 }, // 149 - { 155, 35, -8, -17, 44 }, // 150 - { 157, 36, -8, -18, 46 }, // 151 - { 158, 38, -9, -19, 48 }, // 152 - { 159, 39, -9, -20, 50 }, // 153 - { 160, 41, -10, -21, 52 }, // 154 - { 161, 43, -10, -21, 54 }, // 155 - { 162, 44, -10, -22, 56 }, // 156 - { 164, 46, -11, -23, 58 }, // 157 - { 165, 47, -11, -24, 60 }, // 158 - { 166, 49, -12, -25, 62 }, // 159 - { 167, 51, -12, -26, 64 }, // 160 - { 168, 52, -12, -26, 66 }, // 161 - { 169, 54, -13, -27, 68 }, // 162 - { 171, 55, -13, -28, 70 }, // 163 - { 172, 57, -14, -29, 72 }, // 164 - { 173, 59, -14, -30, 74 }, // 165 - { 174, 60, -14, -30, 76 }, // 166 - { 175, 62, -15, -31, 78 }, // 167 - { 176, 63, -15, -32, 80 }, // 168 - { 178, 65, -16, -33, 82 }, // 169 - { 179, 67, -16, -34, 84 }, // 170 - { 180, 68, -16, -34, 86 }, // 171 - { 181, 70, -17, -35, 88 }, // 172 - { 182, 71, -17, -36, 90 }, // 173 - { 183, 73, -17, -37, 92 }, // 174 - { 185, 75, -18, -38, 94 }, // 175 - { 186, 76, -18, -39, 96 }, // 176 - { 187, 78, -19, -39, 98 }, // 177 - { 188, 79, -19, -40, 100 }, // 178 - { 189, 81, -19, -41, 102 }, // 179 - { 190, 82, -20, -42, 104 }, // 180 - { 192, 84, -20, -43, 106 }, // 181 - { 193, 86, -21, -43, 108 }, // 182 - { 194, 87, -21, -44, 110 }, // 183 - { 195, 89, -21, -45, 113 }, // 184 - { 196, 90, -22, -46, 115 }, // 185 - { 197, 92, -22, -47, 117 }, // 186 - { 199, 94, -23, -47, 119 }, // 187 - { 200, 95, -23, -48, 121 }, // 188 - { 201, 97, -23, -49, 123 }, // 189 - { 202, 98, -24, -50, 125 }, // 190 - { 203, 100, -24, -51, 127 }, // 191 - { 204, 102, -25, -52, 129 }, // 192 - { 206, 103, -25, -52, 131 }, // 193 - { 207, 105, -25, -53, 133 }, // 194 - { 208, 106, -26, -54, 135 }, // 195 - { 209, 108, -26, -55, 137 }, // 196 - { 210, 110, -26, -56, 139 }, // 197 - { 211, 111, -27, -56, 141 }, // 198 - { 213, 113, -27, -57, 143 }, // 199 - { 214, 114, -28, -58, 145 }, // 200 - { 215, 116, -28, -59, 147 }, // 201 - { 216, 118, -28, -60, 149 }, // 202 - { 217, 119, -29, -60, 151 }, // 203 - { 218, 121, -29, -61, 153 }, // 204 - { 219, 122, -30, -62, 155 }, // 205 - { 221, 124, -30, -63, 157 }, // 206 - { 222, 126, -30, -64, 159 }, // 207 - { 223, 127, -31, -65, 161 }, // 208 - { 224, 129, -31, -65, 163 }, // 209 - { 225, 130, -32, -66, 165 }, // 210 - { 226, 132, -32, -67, 167 }, // 211 - { 228, 134, -32, -68, 169 }, // 212 - { 229, 135, -33, -69, 171 }, // 213 - { 230, 137, -33, -69, 173 }, // 214 - { 231, 138, -34, -70, 175 }, // 215 - { 232, 140, -34, -71, 177 }, // 216 - { 233, 142, -34, -72, 179 }, // 217 - { 235, 143, -35, -73, 181 }, // 218 - { 236, 145, -35, -73, 183 }, // 219 - { 237, 146, -35, -74, 185 }, // 220 - { 238, 148, -36, -75, 187 }, // 221 - { 239, 150, -36, -76, 189 }, // 222 - { 240, 151, -37, -77, 191 }, // 223 - { 242, 153, -37, -78, 193 }, // 224 - { 243, 154, -37, -78, 195 }, // 225 - { 244, 156, -38, -79, 197 }, // 226 - { 245, 158, -38, -80, 199 }, // 227 - { 246, 159, -39, -81, 201 }, // 228 - { 247, 161, -39, -82, 203 }, // 229 - { 249, 162, -39, -82, 205 }, // 230 - { 250, 164, -40, -83, 207 }, // 231 - { 251, 165, -40, -84, 209 }, // 232 - { 252, 167, -41, -85, 211 }, // 233 - { 253, 169, -41, -86, 213 }, // 234 - { 254, 170, -41, -86, 215 }, // 235 - { 256, 172, -42, -87, 217 }, // 236 - { 257, 173, -42, -88, 219 }, // 237 - { 258, 175, -43, -89, 221 }, // 238 - { 259, 177, -43, -90, 223 }, // 239 - { 260, 178, -43, -91, 226 }, // 240 - { 261, 180, -44, -91, 228 }, // 241 - { 263, 181, -44, -92, 230 }, // 242 - { 264, 183, -44, -93, 232 }, // 243 - { 265, 185, -45, -94, 234 }, // 244 - { 266, 186, -45, -95, 236 }, // 245 - { 267, 188, -46, -95, 238 }, // 246 - { 268, 189, -46, -96, 240 }, // 247 - { 270, 191, -46, -97, 242 }, // 248 - { 271, 193, -47, -98, 244 }, // 249 - { 272, 194, -47, -99, 246 }, // 250 - { 273, 196, -48, -99, 248 }, // 251 - { 274, 197, -48, -100, 250 }, // 252 - { 275, 199, -48, -101, 252 }, // 253 - { 277, 201, -49, -102, 254 }, // 254 - { 278, 202, -49, -103, 256 } // 255 -}; - -#define YUYV_CONSTRAIN(v) ((v)<0)?0:(((v)>255)?255:(v)) - -void IRAM_ATTR yuv2rgb(uint8_t y, uint8_t u, uint8_t v, uint8_t *r, uint8_t *g, uint8_t *b) -{ - int16_t ri, gi, bi; - - ri = yuv_table[y].vY + yuv_table[v].vVr; - gi = yuv_table[y].vY + yuv_table[u].vUg + yuv_table[v].vVg; - bi = yuv_table[y].vY + yuv_table[u].vUb; - - *r = YUYV_CONSTRAIN(ri); - *g = YUYV_CONSTRAIN(gi); - *b = YUYV_CONSTRAIN(bi); -} diff --git a/lib/libesp32_div/esp32-camera/driver/cam_hal.c b/lib/libesp32_div/esp32-camera/driver/cam_hal.c deleted file mode 100644 index c54fb8172..000000000 --- a/lib/libesp32_div/esp32-camera/driver/cam_hal.c +++ /dev/null @@ -1,483 +0,0 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include "esp_heap_caps.h" -#include "ll_cam.h" -#include "cam_hal.h" - -static const char *TAG = "cam_hal"; - -static cam_obj_t *cam_obj = NULL; - -static const uint32_t JPEG_SOI_MARKER = 0xFFD8FF; // written in little-endian for esp32 -static const uint16_t JPEG_EOI_MARKER = 0xD9FF; // written in little-endian for esp32 - -static int cam_verify_jpeg_soi(const uint8_t *inbuf, uint32_t length) -{ - uint32_t sig = *((uint32_t *)inbuf) & 0xFFFFFF; - if(sig != JPEG_SOI_MARKER) { - for (uint32_t i = 0; i < length; i++) { - sig = *((uint32_t *)(&inbuf[i])) & 0xFFFFFF; - if (sig == JPEG_SOI_MARKER) { - ESP_LOGW(TAG, "SOI: %d", i); - return i; - } - } - ESP_LOGW(TAG, "NO-SOI"); - return -1; - } - return 0; -} - -static int cam_verify_jpeg_eoi(const uint8_t *inbuf, uint32_t length) -{ - int offset = -1; - uint8_t *dptr = (uint8_t *)inbuf + length - 2; - while (dptr > inbuf) { - uint16_t sig = *((uint16_t *)dptr); - if (JPEG_EOI_MARKER == sig) { - offset = dptr - inbuf; - //ESP_LOGW(TAG, "EOI: %d", length - (offset + 2)); - return offset; - } - dptr--; - } - return -1; -} - -static bool cam_get_next_frame(int * frame_pos) -{ - if(!cam_obj->frames[*frame_pos].en){ - for (int x = 0; x < cam_obj->frame_cnt; x++) { - if (cam_obj->frames[x].en) { - *frame_pos = x; - return true; - } - } - } else { - return true; - } - return false; -} - -static bool cam_start_frame(int * frame_pos) -{ - if (cam_get_next_frame(frame_pos)) { - if(ll_cam_start(cam_obj, *frame_pos)){ - // Vsync the frame manually - ll_cam_do_vsync(cam_obj); - uint64_t us = (uint64_t)esp_timer_get_time(); - cam_obj->frames[*frame_pos].fb.timestamp.tv_sec = us / 1000000UL; - cam_obj->frames[*frame_pos].fb.timestamp.tv_usec = us % 1000000UL; - return true; - } - } - return false; -} - -void IRAM_ATTR ll_cam_send_event(cam_obj_t *cam, cam_event_t cam_event, BaseType_t * HPTaskAwoken) -{ - if (xQueueSendFromISR(cam->event_queue, (void *)&cam_event, HPTaskAwoken) != pdTRUE) { - ll_cam_stop(cam); - cam->state = CAM_STATE_IDLE; - ESP_EARLY_LOGE(TAG, "EV-%s-OVF", cam_event==CAM_IN_SUC_EOF_EVENT ? "EOF" : "VSYNC"); - } -} - -//Copy fram from DMA dma_buffer to fram dma_buffer -static void cam_task(void *arg) -{ - int cnt = 0; - int frame_pos = 0; - cam_obj->state = CAM_STATE_IDLE; - cam_event_t cam_event = 0; - - xQueueReset(cam_obj->event_queue); - - while (1) { - xQueueReceive(cam_obj->event_queue, (void *)&cam_event, portMAX_DELAY); - DBG_PIN_SET(1); - switch (cam_obj->state) { - - case CAM_STATE_IDLE: { - if (cam_event == CAM_VSYNC_EVENT) { - //DBG_PIN_SET(1); - if(cam_start_frame(&frame_pos)){ - cam_obj->frames[frame_pos].fb.len = 0; - cam_obj->state = CAM_STATE_READ_BUF; - } - cnt = 0; - } - } - break; - - case CAM_STATE_READ_BUF: { - camera_fb_t * frame_buffer_event = &cam_obj->frames[frame_pos].fb; - size_t pixels_per_dma = (cam_obj->dma_half_buffer_size * cam_obj->fb_bytes_per_pixel) / (cam_obj->dma_bytes_per_item * cam_obj->in_bytes_per_pixel); - - if (cam_event == CAM_IN_SUC_EOF_EVENT) { - if(!cam_obj->psram_mode){ - if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) { - ESP_LOGW(TAG, "FB-OVF"); - ll_cam_stop(cam_obj); - DBG_PIN_SET(0); - continue; - } - frame_buffer_event->len += ll_cam_memcpy(cam_obj, - &frame_buffer_event->buf[frame_buffer_event->len], - &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], - cam_obj->dma_half_buffer_size); - } - //Check for JPEG SOI in the first buffer. stop if not found - if (cam_obj->jpeg_mode && cnt == 0 && cam_verify_jpeg_soi(frame_buffer_event->buf, frame_buffer_event->len) != 0) { - ll_cam_stop(cam_obj); - cam_obj->state = CAM_STATE_IDLE; - } - cnt++; - - } else if (cam_event == CAM_VSYNC_EVENT) { - //DBG_PIN_SET(1); - ll_cam_stop(cam_obj); - - if (cnt || !cam_obj->jpeg_mode || cam_obj->psram_mode) { - if (cam_obj->jpeg_mode) { - if (!cam_obj->psram_mode) { - if (cam_obj->fb_size < (frame_buffer_event->len + pixels_per_dma)) { - ESP_LOGW(TAG, "FB-OVF"); - cnt--; - } else { - frame_buffer_event->len += ll_cam_memcpy(cam_obj, - &frame_buffer_event->buf[frame_buffer_event->len], - &cam_obj->dma_buffer[(cnt % cam_obj->dma_half_buffer_cnt) * cam_obj->dma_half_buffer_size], - cam_obj->dma_half_buffer_size); - } - } - cnt++; - } - - cam_obj->frames[frame_pos].en = 0; - - if (cam_obj->psram_mode) { - if (cam_obj->jpeg_mode) { - frame_buffer_event->len = cnt * cam_obj->dma_half_buffer_size; - } else { - frame_buffer_event->len = cam_obj->recv_size; - } - } else if (!cam_obj->jpeg_mode) { - if (frame_buffer_event->len != cam_obj->fb_size) { - cam_obj->frames[frame_pos].en = 1; - ESP_LOGE(TAG, "FB-SIZE: %u != %u", frame_buffer_event->len, cam_obj->fb_size); - } - } - //send frame - if(!cam_obj->frames[frame_pos].en && xQueueSend(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0) != pdTRUE) { - //pop frame buffer from the queue - camera_fb_t * fb2 = NULL; - if(xQueueReceive(cam_obj->frame_buffer_queue, &fb2, 0) == pdTRUE) { - //push the new frame to the end of the queue - if (xQueueSend(cam_obj->frame_buffer_queue, (void *)&frame_buffer_event, 0) != pdTRUE) { - cam_obj->frames[frame_pos].en = 1; - ESP_LOGE(TAG, "FBQ-SND"); - } - //free the popped buffer - cam_give(fb2); - } else { - //queue is full and we could not pop a frame from it - cam_obj->frames[frame_pos].en = 1; - ESP_LOGE(TAG, "FBQ-RCV"); - } - } - } - - if(!cam_start_frame(&frame_pos)){ - cam_obj->state = CAM_STATE_IDLE; - } else { - cam_obj->frames[frame_pos].fb.len = 0; - } - cnt = 0; - } - } - break; - } - DBG_PIN_SET(0); - } -} - -static lldesc_t * allocate_dma_descriptors(uint32_t count, uint16_t size, uint8_t * buffer) -{ - lldesc_t *dma = (lldesc_t *)heap_caps_malloc(count * sizeof(lldesc_t), MALLOC_CAP_DMA); - if (dma == NULL) { - return dma; - } - - for (int x = 0; x < count; x++) { - dma[x].size = size; - dma[x].length = 0; - dma[x].sosf = 0; - dma[x].eof = 0; - dma[x].owner = 1; - dma[x].buf = (buffer + size * x); - dma[x].empty = (uint32_t)&dma[(x + 1) % count]; - } - return dma; -} - -static esp_err_t cam_dma_config(const camera_config_t *config) -{ - bool ret = ll_cam_dma_sizes(cam_obj); - if (0 == ret) { - return ESP_FAIL; - } - - cam_obj->dma_node_cnt = (cam_obj->dma_buffer_size) / cam_obj->dma_node_buffer_size; // Number of DMA nodes - cam_obj->frame_copy_cnt = cam_obj->recv_size / cam_obj->dma_half_buffer_size; // Number of interrupted copies, ping-pong copy - - ESP_LOGI(TAG, "buffer_size: %d, half_buffer_size: %d, node_buffer_size: %d, node_cnt: %d, total_cnt: %d", - cam_obj->dma_buffer_size, cam_obj->dma_half_buffer_size, cam_obj->dma_node_buffer_size, cam_obj->dma_node_cnt, cam_obj->frame_copy_cnt); - - cam_obj->dma_buffer = NULL; - cam_obj->dma = NULL; - - cam_obj->frames = (cam_frame_t *)heap_caps_calloc(1, cam_obj->frame_cnt * sizeof(cam_frame_t), MALLOC_CAP_DEFAULT); - CAM_CHECK(cam_obj->frames != NULL, "frames malloc failed", ESP_FAIL); - - uint8_t dma_align = 0; - size_t fb_size = cam_obj->fb_size; - if (cam_obj->psram_mode) { - dma_align = ll_cam_get_dma_align(cam_obj); - if (cam_obj->fb_size < cam_obj->recv_size) { - fb_size = cam_obj->recv_size; - } - } - - /* Allocate memeory for frame buffer */ - size_t alloc_size = fb_size * sizeof(uint8_t) + dma_align; - uint32_t _caps = MALLOC_CAP_8BIT; - if (CAMERA_FB_IN_DRAM == config->fb_location) { - _caps |= MALLOC_CAP_INTERNAL; - } else { - _caps |= MALLOC_CAP_SPIRAM; - } - for (int x = 0; x < cam_obj->frame_cnt; x++) { - cam_obj->frames[x].dma = NULL; - cam_obj->frames[x].fb_offset = 0; - cam_obj->frames[x].en = 0; - ESP_LOGI(TAG, "Allocating %d Byte frame buffer in %s", alloc_size, _caps & MALLOC_CAP_SPIRAM ? "PSRAM" : "OnBoard RAM"); - cam_obj->frames[x].fb.buf = (uint8_t *)heap_caps_malloc(alloc_size, _caps); - CAM_CHECK(cam_obj->frames[x].fb.buf != NULL, "frame buffer malloc failed", ESP_FAIL); - if (cam_obj->psram_mode) { - //align PSRAM buffer. TODO: save the offset so proper address can be freed later - cam_obj->frames[x].fb_offset = dma_align - ((uint32_t)cam_obj->frames[x].fb.buf & (dma_align - 1)); - cam_obj->frames[x].fb.buf += cam_obj->frames[x].fb_offset; - ESP_LOGI(TAG, "Frame[%d]: Offset: %u, Addr: 0x%08X", x, cam_obj->frames[x].fb_offset, (uint32_t)cam_obj->frames[x].fb.buf); - cam_obj->frames[x].dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->frames[x].fb.buf); - CAM_CHECK(cam_obj->frames[x].dma != NULL, "frame dma malloc failed", ESP_FAIL); - } - cam_obj->frames[x].en = 1; - } - - if (!cam_obj->psram_mode) { - cam_obj->dma_buffer = (uint8_t *)heap_caps_malloc(cam_obj->dma_buffer_size * sizeof(uint8_t), MALLOC_CAP_DMA); - if(NULL == cam_obj->dma_buffer) { - ESP_LOGE(TAG,"%s(%d): DMA buffer %d Byte malloc failed, the current largest free block:%d Byte", __FUNCTION__, __LINE__, - cam_obj->dma_buffer_size, heap_caps_get_largest_free_block(MALLOC_CAP_DMA)); - return ESP_FAIL; - } - - cam_obj->dma = allocate_dma_descriptors(cam_obj->dma_node_cnt, cam_obj->dma_node_buffer_size, cam_obj->dma_buffer); - CAM_CHECK(cam_obj->dma != NULL, "dma malloc failed", ESP_FAIL); - } - - return ESP_OK; -} - -esp_err_t cam_init(const camera_config_t *config) -{ - CAM_CHECK(NULL != config, "config pointer is invalid", ESP_ERR_INVALID_ARG); - - esp_err_t ret = ESP_OK; - cam_obj = (cam_obj_t *)heap_caps_calloc(1, sizeof(cam_obj_t), MALLOC_CAP_DMA); - CAM_CHECK(NULL != cam_obj, "lcd_cam object malloc error", ESP_ERR_NO_MEM); - - cam_obj->swap_data = 0; - cam_obj->vsync_pin = config->pin_vsync; - cam_obj->vsync_invert = true; - - ll_cam_set_pin(cam_obj, config); - ret = ll_cam_config(cam_obj, config); - CAM_CHECK_GOTO(ret == ESP_OK, "ll_cam initialize failed", err); - -#if CAMERA_DBG_PIN_ENABLE - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[DBG_PIN_NUM], PIN_FUNC_GPIO); - gpio_set_direction(DBG_PIN_NUM, GPIO_MODE_OUTPUT); - gpio_set_pull_mode(DBG_PIN_NUM, GPIO_FLOATING); -#endif - - ESP_LOGI(TAG, "cam init ok"); - return ESP_OK; - -err: - free(cam_obj); - cam_obj = NULL; - return ESP_FAIL; -} - -esp_err_t cam_config(const camera_config_t *config, framesize_t frame_size, uint16_t sensor_pid) -{ - CAM_CHECK(NULL != config, "config pointer is invalid", ESP_ERR_INVALID_ARG); - esp_err_t ret = ESP_OK; - - ret = ll_cam_set_sample_mode(cam_obj, (pixformat_t)config->pixel_format, config->xclk_freq_hz, sensor_pid); - - cam_obj->jpeg_mode = config->pixel_format == PIXFORMAT_JPEG; -#if CONFIG_IDF_TARGET_ESP32 - cam_obj->psram_mode = false; -#else - cam_obj->psram_mode = (config->xclk_freq_hz == 16000000); -#endif - cam_obj->frame_cnt = config->fb_count; - cam_obj->width = resolution[frame_size].width; - cam_obj->height = resolution[frame_size].height; - - if(cam_obj->jpeg_mode){ - cam_obj->recv_size = cam_obj->width * cam_obj->height / 5; - cam_obj->fb_size = cam_obj->recv_size; - } else { - cam_obj->recv_size = cam_obj->width * cam_obj->height * cam_obj->in_bytes_per_pixel; - cam_obj->fb_size = cam_obj->width * cam_obj->height * cam_obj->fb_bytes_per_pixel; - } - - ret = cam_dma_config(config); - CAM_CHECK_GOTO(ret == ESP_OK, "cam_dma_config failed", err); - - cam_obj->event_queue = xQueueCreate(cam_obj->dma_half_buffer_cnt - 1, sizeof(cam_event_t)); - CAM_CHECK_GOTO(cam_obj->event_queue != NULL, "event_queue create failed", err); - - size_t frame_buffer_queue_len = cam_obj->frame_cnt; - if (config->grab_mode == CAMERA_GRAB_LATEST && cam_obj->frame_cnt > 1) { - frame_buffer_queue_len = cam_obj->frame_cnt - 1; - } - cam_obj->frame_buffer_queue = xQueueCreate(frame_buffer_queue_len, sizeof(camera_fb_t*)); - CAM_CHECK_GOTO(cam_obj->frame_buffer_queue != NULL, "frame_buffer_queue create failed", err); - - ret = ll_cam_init_isr(cam_obj); - CAM_CHECK_GOTO(ret == ESP_OK, "cam intr alloc failed", err); - - -#if CONFIG_CAMERA_CORE0 - xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 0); -#elif CONFIG_CAMERA_CORE1 - xTaskCreatePinnedToCore(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle, 1); -#else - xTaskCreate(cam_task, "cam_task", 2048, NULL, configMAX_PRIORITIES - 2, &cam_obj->task_handle); -#endif - - ESP_LOGI(TAG, "cam config ok"); - return ESP_OK; - -err: - cam_deinit(); - return ESP_FAIL; -} - -esp_err_t cam_deinit(void) -{ - if (!cam_obj) { - return ESP_FAIL; - } - - cam_stop(); - if (cam_obj->task_handle) { - vTaskDelete(cam_obj->task_handle); - } - if (cam_obj->event_queue) { - vQueueDelete(cam_obj->event_queue); - } - if (cam_obj->frame_buffer_queue) { - vQueueDelete(cam_obj->frame_buffer_queue); - } - if (cam_obj->dma) { - free(cam_obj->dma); - } - if (cam_obj->dma_buffer) { - free(cam_obj->dma_buffer); - } - if (cam_obj->frames) { - for (int x = 0; x < cam_obj->frame_cnt; x++) { - free(cam_obj->frames[x].fb.buf - cam_obj->frames[x].fb_offset); - if (cam_obj->frames[x].dma) { - free(cam_obj->frames[x].dma); - } - } - free(cam_obj->frames); - } - - ll_cam_deinit(cam_obj); - - free(cam_obj); - cam_obj = NULL; - return ESP_OK; -} - -void cam_stop(void) -{ - ll_cam_vsync_intr_enable(cam_obj, false); - ll_cam_stop(cam_obj); -} - -void cam_start(void) -{ - ll_cam_vsync_intr_enable(cam_obj, true); -} - -camera_fb_t *cam_take(TickType_t timeout) -{ - camera_fb_t *dma_buffer = NULL; - TickType_t start = xTaskGetTickCount(); - xQueueReceive(cam_obj->frame_buffer_queue, (void *)&dma_buffer, timeout); - if (dma_buffer) { - if(cam_obj->jpeg_mode){ - // find the end marker for JPEG. Data after that can be discarded - int offset_e = cam_verify_jpeg_eoi(dma_buffer->buf, dma_buffer->len); - if (offset_e >= 0) { - // adjust buffer length - dma_buffer->len = offset_e + sizeof(JPEG_EOI_MARKER); - return dma_buffer; - } else { - ESP_LOGW(TAG, "NO-EOI"); - cam_give(dma_buffer); - return cam_take(timeout - (xTaskGetTickCount() - start));//recurse!!!! - } - } else if(cam_obj->psram_mode && cam_obj->in_bytes_per_pixel != cam_obj->fb_bytes_per_pixel){ - //currently this is used only for YUV to GRAYSCALE - dma_buffer->len = ll_cam_memcpy(cam_obj, dma_buffer->buf, dma_buffer->buf, dma_buffer->len); - } - return dma_buffer; - } else { - ESP_LOGW(TAG, "Failed to get the frame on time!"); - } - return NULL; -} - -void cam_give(camera_fb_t *dma_buffer) -{ - for (int x = 0; x < cam_obj->frame_cnt; x++) { - if (&cam_obj->frames[x].fb == dma_buffer) { - cam_obj->frames[x].en = 1; - break; - } - } -} diff --git a/lib/libesp32_div/esp32-camera/driver/esp_camera.c b/lib/libesp32_div/esp32-camera/driver/esp_camera.c deleted file mode 100644 index 9ae1b56ca..000000000 --- a/lib/libesp32_div/esp32-camera/driver/esp_camera.c +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#include -#include -#include -#include "time.h" -#include "sys/time.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/gpio.h" -#include "esp_system.h" -#include "nvs_flash.h" -#include "nvs.h" -#include "sensor.h" -#include "sccb.h" -#include "cam_hal.h" -#include "esp_camera.h" -#include "xclk.h" -#if CONFIG_OV2640_SUPPORT -#include "ov2640.h" -#endif -#if CONFIG_OV7725_SUPPORT -#include "ov7725.h" -#endif -#if CONFIG_OV3660_SUPPORT -#include "ov3660.h" -#endif -#if CONFIG_OV5640_SUPPORT -#include "ov5640.h" -#endif -#if CONFIG_NT99141_SUPPORT -#include "nt99141.h" -#endif -#if CONFIG_OV7670_SUPPORT -#include "ov7670.h" -#endif -#if CONFIG_GC2145_SUPPORT -#include "gc2145.h" -#endif -#if CONFIG_GC032A_SUPPORT -#include "gc032a.h" -#endif -#if CONFIG_GC0308_SUPPORT -#include "gc0308.h" -#endif - - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#define TAG "" -#else -#include "esp_log.h" -static const char *TAG = "camera"; -#endif - -typedef struct { - sensor_t sensor; - camera_fb_t fb; -} camera_state_t; - -static const char *CAMERA_SENSOR_NVS_KEY = "sensor"; -static const char *CAMERA_PIXFORMAT_NVS_KEY = "pixformat"; -static camera_state_t *s_state = NULL; - -#if CONFIG_IDF_TARGET_ESP32S3 // LCD_CAM module of ESP32-S3 will generate xclk -#define CAMERA_ENABLE_OUT_CLOCK(v) -#define CAMERA_DISABLE_OUT_CLOCK() -#else -#define CAMERA_ENABLE_OUT_CLOCK(v) camera_enable_out_clock((v)) -#define CAMERA_DISABLE_OUT_CLOCK() camera_disable_out_clock() -#endif - -typedef struct { - int (*detect)(int slv_addr, sensor_id_t *id); - int (*init)(sensor_t *sensor); -} sensor_func_t; - -static const sensor_func_t g_sensors[] = { -#if CONFIG_OV7725_SUPPORT - {ov7725_detect, ov7725_init}, -#endif -#if CONFIG_OV7670_SUPPORT - {ov7670_detect, ov7670_init}, -#endif -#if CONFIG_OV2640_SUPPORT - {ov2640_detect, ov2640_init}, -#endif -#if CONFIG_OV3660_SUPPORT - {ov3660_detect, ov3660_init}, -#endif -#if CONFIG_OV5640_SUPPORT - {ov5640_detect, ov5640_init}, -#endif -#if CONFIG_NT99141_SUPPORT - {nt99141_detect, nt99141_init}, -#endif -#if CONFIG_GC2145_SUPPORT - {gc2145_detect, gc2145_init}, -#endif -#if CONFIG_GC032A_SUPPORT - {gc032a_detect, gc032a_init}, -#endif -#if CONFIG_GC0308_SUPPORT - {gc0308_detect, gc0308_init}, -#endif -}; - -static esp_err_t camera_probe(const camera_config_t *config, camera_model_t *out_camera_model) -{ - *out_camera_model = CAMERA_NONE; - if (s_state != NULL) { - return ESP_ERR_INVALID_STATE; - } - - s_state = (camera_state_t *) calloc(sizeof(camera_state_t), 1); - if (!s_state) { - return ESP_ERR_NO_MEM; - } - - if (config->pin_xclk >= 0) { - ESP_LOGD(TAG, "Enabling XCLK output"); - CAMERA_ENABLE_OUT_CLOCK(config); - } - - if (config->pin_sscb_sda != -1) { - ESP_LOGD(TAG, "Initializing SSCB"); - SCCB_Init(config->pin_sscb_sda, config->pin_sscb_scl); - } - - if (config->pin_pwdn >= 0) { - ESP_LOGD(TAG, "Resetting camera by power down line"); - gpio_config_t conf = { 0 }; - conf.pin_bit_mask = 1LL << config->pin_pwdn; - conf.mode = GPIO_MODE_OUTPUT; - gpio_config(&conf); - - // carefull, logic is inverted compared to reset pin - gpio_set_level(config->pin_pwdn, 1); - vTaskDelay(10 / portTICK_PERIOD_MS); - gpio_set_level(config->pin_pwdn, 0); - vTaskDelay(10 / portTICK_PERIOD_MS); - } - - if (config->pin_reset >= 0) { - ESP_LOGD(TAG, "Resetting camera"); - gpio_config_t conf = { 0 }; - conf.pin_bit_mask = 1LL << config->pin_reset; - conf.mode = GPIO_MODE_OUTPUT; - gpio_config(&conf); - - gpio_set_level(config->pin_reset, 0); - vTaskDelay(10 / portTICK_PERIOD_MS); - gpio_set_level(config->pin_reset, 1); - vTaskDelay(10 / portTICK_PERIOD_MS); - } - - - ESP_LOGD(TAG, "Searching for camera address"); - vTaskDelay(10 / portTICK_PERIOD_MS); - - uint8_t slv_addr = SCCB_Probe(); - - if (slv_addr == 0) { - CAMERA_DISABLE_OUT_CLOCK(); - return ESP_ERR_NOT_FOUND; - } - - ESP_LOGI(TAG, "Detected camera at address=0x%02x", slv_addr); - s_state->sensor.slv_addr = slv_addr; - s_state->sensor.xclk_freq_hz = config->xclk_freq_hz; - - /** - * Read sensor ID and then initialize sensor - * Attention: Some sensors have the same SCCB address. Therefore, several attempts may be made in the detection process - */ - sensor_id_t *id = &s_state->sensor.id; - for (size_t i = 0; i < sizeof(g_sensors) / sizeof(sensor_func_t); i++) { - if (g_sensors[i].detect(slv_addr, id)) { - camera_sensor_info_t *info = esp_camera_sensor_get_info(id); - if (NULL != info) { - *out_camera_model = info->model; - ESP_LOGI(TAG, "Detected %s camera", info->name); - g_sensors[i].init(&s_state->sensor); - break; - } - } - } - - if (CAMERA_NONE == *out_camera_model) { //If no supported sensors are detected - CAMERA_DISABLE_OUT_CLOCK(); - ESP_LOGE(TAG, "Detected camera not supported."); - return ESP_ERR_NOT_SUPPORTED; - } - - ESP_LOGI(TAG, "Camera PID=0x%02x VER=0x%02x MIDL=0x%02x MIDH=0x%02x", - id->PID, id->VER, id->MIDH, id->MIDL); - - ESP_LOGD(TAG, "Doing SW reset of sensor"); - vTaskDelay(10 / portTICK_PERIOD_MS); - s_state->sensor.reset(&s_state->sensor); - - return ESP_OK; -} - -esp_err_t esp_camera_init(const camera_config_t *config) -{ - esp_err_t err; - err = cam_init(config); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Camera init failed with error 0x%x", err); - return err; - } - - camera_model_t camera_model = CAMERA_NONE; - err = camera_probe(config, &camera_model); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Camera probe failed with error 0x%x(%s)", err, esp_err_to_name(err)); - goto fail; - } - - framesize_t frame_size = (framesize_t) config->frame_size; - pixformat_t pix_format = (pixformat_t) config->pixel_format; - - if (PIXFORMAT_JPEG == pix_format && (!camera_sensor[camera_model].support_jpeg)) { - ESP_LOGE(TAG, "JPEG format is not supported on this sensor"); - err = ESP_ERR_NOT_SUPPORTED; - goto fail; - } - - if (frame_size > camera_sensor[camera_model].max_size) { - ESP_LOGW(TAG, "The frame size exceeds the maximum for this sensor, it will be forced to the maximum possible value"); - frame_size = camera_sensor[camera_model].max_size; - } - - err = cam_config(config, frame_size, s_state->sensor.id.PID); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Camera config failed with error 0x%x", err); - goto fail; - } - - s_state->sensor.status.framesize = frame_size; - s_state->sensor.pixformat = pix_format; - ESP_LOGD(TAG, "Setting frame size to %dx%d", resolution[frame_size].width, resolution[frame_size].height); - if (s_state->sensor.set_framesize(&s_state->sensor, frame_size) != 0) { - ESP_LOGE(TAG, "Failed to set frame size"); - err = ESP_ERR_CAMERA_FAILED_TO_SET_FRAME_SIZE; - goto fail; - } - s_state->sensor.set_pixformat(&s_state->sensor, pix_format); - - if (s_state->sensor.id.PID == OV2640_PID) { - s_state->sensor.set_gainceiling(&s_state->sensor, GAINCEILING_2X); - s_state->sensor.set_bpc(&s_state->sensor, false); - s_state->sensor.set_wpc(&s_state->sensor, true); - s_state->sensor.set_lenc(&s_state->sensor, true); - } - - if (pix_format == PIXFORMAT_JPEG) { - s_state->sensor.set_quality(&s_state->sensor, config->jpeg_quality); - } - s_state->sensor.init_status(&s_state->sensor); - - cam_start(); - - return ESP_OK; - -fail: - esp_camera_deinit(); - return err; -} - -esp_err_t esp_camera_deinit() -{ - esp_err_t ret = cam_deinit(); - CAMERA_DISABLE_OUT_CLOCK(); - if (s_state) { - SCCB_Deinit(); - - free(s_state); - s_state = NULL; - } - - return ret; -} - -#define FB_GET_TIMEOUT (4000 / portTICK_PERIOD_MS) - -camera_fb_t *esp_camera_fb_get() -{ - if (s_state == NULL) { - return NULL; - } - camera_fb_t *fb = cam_take(FB_GET_TIMEOUT); - //set the frame properties - if (fb) { - fb->width = resolution[s_state->sensor.status.framesize].width; - fb->height = resolution[s_state->sensor.status.framesize].height; - fb->format = s_state->sensor.pixformat; - } - return fb; -} - -void esp_camera_fb_return(camera_fb_t *fb) -{ - if (s_state == NULL) { - return; - } - cam_give(fb); -} - -sensor_t *esp_camera_sensor_get() -{ - if (s_state == NULL) { - return NULL; - } - return &s_state->sensor; -} - -esp_err_t esp_camera_save_to_nvs(const char *key) -{ -#if ESP_IDF_VERSION_MAJOR > 3 - nvs_handle_t handle; -#else - nvs_handle handle; -#endif - esp_err_t ret = nvs_open(key, NVS_READWRITE, &handle); - - if (ret == ESP_OK) { - sensor_t *s = esp_camera_sensor_get(); - if (s != NULL) { - ret = nvs_set_blob(handle, CAMERA_SENSOR_NVS_KEY, &s->status, sizeof(camera_status_t)); - if (ret == ESP_OK) { - uint8_t pf = s->pixformat; - ret = nvs_set_u8(handle, CAMERA_PIXFORMAT_NVS_KEY, pf); - } - return ret; - } else { - return ESP_ERR_CAMERA_NOT_DETECTED; - } - nvs_close(handle); - return ret; - } else { - return ret; - } -} - -esp_err_t esp_camera_load_from_nvs(const char *key) -{ -#if ESP_IDF_VERSION_MAJOR > 3 - nvs_handle_t handle; -#else - nvs_handle handle; -#endif - uint8_t pf; - - esp_err_t ret = nvs_open(key, NVS_READWRITE, &handle); - - if (ret == ESP_OK) { - sensor_t *s = esp_camera_sensor_get(); - camera_status_t st; - if (s != NULL) { - size_t size = sizeof(camera_status_t); - ret = nvs_get_blob(handle, CAMERA_SENSOR_NVS_KEY, &st, &size); - if (ret == ESP_OK) { - s->set_ae_level(s, st.ae_level); - s->set_aec2(s, st.aec2); - s->set_aec_value(s, st.aec_value); - s->set_agc_gain(s, st.agc_gain); - s->set_awb_gain(s, st.awb_gain); - s->set_bpc(s, st.bpc); - s->set_brightness(s, st.brightness); - s->set_colorbar(s, st.colorbar); - s->set_contrast(s, st.contrast); - s->set_dcw(s, st.dcw); - s->set_denoise(s, st.denoise); - s->set_exposure_ctrl(s, st.aec); - s->set_framesize(s, st.framesize); - s->set_gain_ctrl(s, st.agc); - s->set_gainceiling(s, st.gainceiling); - s->set_hmirror(s, st.hmirror); - s->set_lenc(s, st.lenc); - s->set_quality(s, st.quality); - s->set_raw_gma(s, st.raw_gma); - s->set_saturation(s, st.saturation); - s->set_sharpness(s, st.sharpness); - s->set_special_effect(s, st.special_effect); - s->set_vflip(s, st.vflip); - s->set_wb_mode(s, st.wb_mode); - s->set_whitebal(s, st.awb); - s->set_wpc(s, st.wpc); - } - ret = nvs_get_u8(handle, CAMERA_PIXFORMAT_NVS_KEY, &pf); - if (ret == ESP_OK) { - s->set_pixformat(s, pf); - } - } else { - return ESP_ERR_CAMERA_NOT_DETECTED; - } - nvs_close(handle); - return ret; - } else { - ESP_LOGW(TAG, "Error (%d) opening nvs key \"%s\"", ret, key); - return ret; - } -} diff --git a/lib/libesp32_div/esp32-camera/driver/private_include/sccb.h b/lib/libesp32_div/esp32-camera/driver/private_include/sccb.h deleted file mode 100644 index ace081a48..000000000 --- a/lib/libesp32_div/esp32-camera/driver/private_include/sccb.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * SCCB (I2C like) driver. - * - */ -#ifndef __SCCB_H__ -#define __SCCB_H__ -#include -int SCCB_Init(int pin_sda, int pin_scl); -int SCCB_Deinit(void); -uint8_t SCCB_Probe(); -uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg); -uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data); -uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg); -uint8_t SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data); -#endif // __SCCB_H__ diff --git a/lib/libesp32_div/esp32-camera/driver/sccb.c b/lib/libesp32_div/esp32-camera/driver/sccb.c deleted file mode 100644 index 1a2c56e23..000000000 --- a/lib/libesp32_div/esp32-camera/driver/sccb.c +++ /dev/null @@ -1,184 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * SCCB (I2C like) driver. - * - */ -#include -#include -#include -#include -#include "sccb.h" -#include "sensor.h" -#include -#include "sdkconfig.h" -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char* TAG = "sccb"; -#endif - -#define LITTLETOBIG(x) ((x<<8)|(x>>8)) - -#include "driver/i2c.h" - -#define SCCB_FREQ 100000 /*!< I2C master frequency*/ -#define WRITE_BIT I2C_MASTER_WRITE /*!< I2C master write */ -#define READ_BIT I2C_MASTER_READ /*!< I2C master read */ -#define ACK_CHECK_EN 0x1 /*!< I2C master will check ack from slave*/ -#define ACK_CHECK_DIS 0x0 /*!< I2C master will not check ack from slave */ -#define ACK_VAL 0x0 /*!< I2C ack value */ -#define NACK_VAL 0x1 /*!< I2C nack value */ -#if CONFIG_SCCB_HARDWARE_I2C_PORT1 -const int SCCB_I2C_PORT = 1; -#else -const int SCCB_I2C_PORT = 0; -#endif - -int SCCB_Init(int pin_sda, int pin_scl) -{ - ESP_LOGI(TAG, "pin_sda %d pin_scl %d", pin_sda, pin_scl); - i2c_config_t conf; - memset(&conf, 0, sizeof(i2c_config_t)); - conf.mode = I2C_MODE_MASTER; - conf.sda_io_num = pin_sda; - conf.sda_pullup_en = GPIO_PULLUP_ENABLE; - conf.scl_io_num = pin_scl; - conf.scl_pullup_en = GPIO_PULLUP_ENABLE; - conf.master.clk_speed = SCCB_FREQ; - - i2c_param_config(SCCB_I2C_PORT, &conf); - i2c_driver_install(SCCB_I2C_PORT, conf.mode, 0, 0, 0); - return 0; -} - -int SCCB_Deinit(void) -{ - return i2c_driver_delete(SCCB_I2C_PORT); -} - -uint8_t SCCB_Probe(void) -{ - uint8_t slave_addr = 0x0; - // for (size_t i = 1; i < 0x80; i++) { - // i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - // i2c_master_start(cmd); - // i2c_master_write_byte(cmd, ( i << 1 ) | WRITE_BIT, ACK_CHECK_EN); - // i2c_master_stop(cmd); - // esp_err_t ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - // i2c_cmd_link_delete(cmd); - // if( ret == ESP_OK) { - // ESP_LOGW(TAG, "Found I2C Device at 0x%02X", i); - // } - // } - for (size_t i = 0; i < CAMERA_MODEL_MAX; i++) { - if (slave_addr == camera_sensor[i].sccb_addr) { - continue; - } - slave_addr = camera_sensor[i].sccb_addr; - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slave_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); - i2c_master_stop(cmd); - esp_err_t ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if( ret == ESP_OK) { - return slave_addr; - } - } - return 0; -} - -uint8_t SCCB_Read(uint8_t slv_addr, uint8_t reg) -{ - uint8_t data=0; - esp_err_t ret = ESP_FAIL; - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); - i2c_master_write_byte(cmd, reg, ACK_CHECK_EN); - i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if(ret != ESP_OK) return -1; - cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slv_addr << 1 ) | READ_BIT, ACK_CHECK_EN); - i2c_master_read_byte(cmd, &data, NACK_VAL); - i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if(ret != ESP_OK) { - ESP_LOGE(TAG, "SCCB_Read Failed addr:0x%02x, reg:0x%02x, data:0x%02x, ret:%d", slv_addr, reg, data, ret); - } - return data; -} - -uint8_t SCCB_Write(uint8_t slv_addr, uint8_t reg, uint8_t data) -{ - esp_err_t ret = ESP_FAIL; - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); - i2c_master_write_byte(cmd, reg, ACK_CHECK_EN); - i2c_master_write_byte(cmd, data, ACK_CHECK_EN); - i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if(ret != ESP_OK) { - ESP_LOGE(TAG, "SCCB_Write Failed addr:0x%02x, reg:0x%02x, data:0x%02x, ret:%d", slv_addr, reg, data, ret); - } - return ret == ESP_OK ? 0 : -1; -} - -uint8_t SCCB_Read16(uint8_t slv_addr, uint16_t reg) -{ - uint8_t data=0; - esp_err_t ret = ESP_FAIL; - uint16_t reg_htons = LITTLETOBIG(reg); - uint8_t *reg_u8 = (uint8_t *)®_htons; - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); - i2c_master_write_byte(cmd, reg_u8[0], ACK_CHECK_EN); - i2c_master_write_byte(cmd, reg_u8[1], ACK_CHECK_EN); - i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if(ret != ESP_OK) return -1; - cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slv_addr << 1 ) | READ_BIT, ACK_CHECK_EN); - i2c_master_read_byte(cmd, &data, NACK_VAL); - i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if(ret != ESP_OK) { - ESP_LOGE(TAG, "W [%04x]=%02x fail\n", reg, data); - } - return data; -} - -uint8_t SCCB_Write16(uint8_t slv_addr, uint16_t reg, uint8_t data) -{ - static uint16_t i = 0; - esp_err_t ret = ESP_FAIL; - uint16_t reg_htons = LITTLETOBIG(reg); - uint8_t *reg_u8 = (uint8_t *)®_htons; - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, ( slv_addr << 1 ) | WRITE_BIT, ACK_CHECK_EN); - i2c_master_write_byte(cmd, reg_u8[0], ACK_CHECK_EN); - i2c_master_write_byte(cmd, reg_u8[1], ACK_CHECK_EN); - i2c_master_write_byte(cmd, data, ACK_CHECK_EN); - i2c_master_stop(cmd); - ret = i2c_master_cmd_begin(SCCB_I2C_PORT, cmd, 1000 / portTICK_RATE_MS); - i2c_cmd_link_delete(cmd); - if(ret != ESP_OK) { - ESP_LOGE(TAG, "W [%04x]=%02x %d fail\n", reg, data, i++); - } - return ret == ESP_OK ? 0 : -1; -} diff --git a/lib/libesp32_div/esp32-camera/driver/sensor.c b/lib/libesp32_div/esp32-camera/driver/sensor.c deleted file mode 100644 index 7ebd7af21..000000000 --- a/lib/libesp32_div/esp32-camera/driver/sensor.c +++ /dev/null @@ -1,52 +0,0 @@ -#include -#include "sensor.h" - -const camera_sensor_info_t camera_sensor[CAMERA_MODEL_MAX] = { - // The sequence must be consistent with camera_model_t - {CAMERA_OV7725, "OV7725", OV7725_SCCB_ADDR, OV7725_PID, FRAMESIZE_VGA, false}, - {CAMERA_OV2640, "OV2640", OV2640_SCCB_ADDR, OV2640_PID, FRAMESIZE_UXGA, true}, - {CAMERA_OV3660, "OV3660", OV3660_SCCB_ADDR, OV3660_PID, FRAMESIZE_QXGA, true}, - {CAMERA_OV5640, "OV5640", OV5640_SCCB_ADDR, OV5640_PID, FRAMESIZE_QSXGA, true}, - {CAMERA_OV7670, "OV7670", OV7670_SCCB_ADDR, OV7670_PID, FRAMESIZE_VGA, false}, - {CAMERA_NT99141, "NT99141", NT99141_SCCB_ADDR, NT99141_PID, FRAMESIZE_HD, true}, - {CAMERA_GC2145, "GC2145", GC2145_SCCB_ADDR, GC2145_PID, FRAMESIZE_UXGA, false}, - {CAMERA_GC032A, "GC032A", GC032A_SCCB_ADDR, GC032A_PID, FRAMESIZE_VGA, false}, - {CAMERA_GC0308, "GC0308", GC0308_SCCB_ADDR, GC0308_PID, FRAMESIZE_VGA, false}, -}; - -const resolution_info_t resolution[FRAMESIZE_INVALID] = { - { 96, 96, ASPECT_RATIO_1X1 }, /* 96x96 */ - { 160, 120, ASPECT_RATIO_4X3 }, /* QQVGA */ - { 176, 144, ASPECT_RATIO_5X4 }, /* QCIF */ - { 240, 176, ASPECT_RATIO_4X3 }, /* HQVGA */ - { 240, 240, ASPECT_RATIO_1X1 }, /* 240x240 */ - { 320, 240, ASPECT_RATIO_4X3 }, /* QVGA */ - { 400, 296, ASPECT_RATIO_4X3 }, /* CIF */ - { 480, 320, ASPECT_RATIO_3X2 }, /* HVGA */ - { 640, 480, ASPECT_RATIO_4X3 }, /* VGA */ - { 800, 600, ASPECT_RATIO_4X3 }, /* SVGA */ - { 1024, 768, ASPECT_RATIO_4X3 }, /* XGA */ - { 1280, 720, ASPECT_RATIO_16X9 }, /* HD */ - { 1280, 1024, ASPECT_RATIO_5X4 }, /* SXGA */ - { 1600, 1200, ASPECT_RATIO_4X3 }, /* UXGA */ - // 3MP Sensors - { 1920, 1080, ASPECT_RATIO_16X9 }, /* FHD */ - { 720, 1280, ASPECT_RATIO_9X16 }, /* Portrait HD */ - { 864, 1536, ASPECT_RATIO_9X16 }, /* Portrait 3MP */ - { 2048, 1536, ASPECT_RATIO_4X3 }, /* QXGA */ - // 5MP Sensors - { 2560, 1440, ASPECT_RATIO_16X9 }, /* QHD */ - { 2560, 1600, ASPECT_RATIO_16X10 }, /* WQXGA */ - { 1088, 1920, ASPECT_RATIO_9X16 }, /* Portrait FHD */ - { 2560, 1920, ASPECT_RATIO_4X3 }, /* QSXGA */ -}; - -camera_sensor_info_t *esp_camera_sensor_get_info(sensor_id_t *id) -{ - for (int i = 0; i < CAMERA_MODEL_MAX; i++) { - if (id->PID == camera_sensor[i].pid) { - return (camera_sensor_info_t *)&camera_sensor[i]; - } - } - return NULL; -} diff --git a/lib/libesp32_div/esp32-camera/examples/CMakeLists.txt b/lib/libesp32_div/esp32-camera/examples/CMakeLists.txt deleted file mode 100644 index 0a0396884..000000000 --- a/lib/libesp32_div/esp32-camera/examples/CMakeLists.txt +++ /dev/null @@ -1,9 +0,0 @@ -# The following lines of boilerplate have to be in your project's -# CMakeLists in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.5) - -set(EXTRA_COMPONENT_DIRS "../") - -add_compile_options(-fdiagnostics-color=always) -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(camera_example) \ No newline at end of file diff --git a/lib/libesp32_div/esp32-camera/examples/Makefile b/lib/libesp32_div/esp32-camera/examples/Makefile deleted file mode 100644 index f06df0ecc..000000000 --- a/lib/libesp32_div/esp32-camera/examples/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# -# This is a project Makefile. It is assumed the directory this Makefile resides in is a -# project subdirectory. -# - -PROJECT_NAME := camera_example - -EXTRA_COMPONENT_DIRS := ../ - -include $(IDF_PATH)/make/project.mk - diff --git a/lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt b/lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt deleted file mode 100644 index 1735fb184..000000000 --- a/lib/libesp32_div/esp32-camera/examples/main/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -set(COMPONENT_SRCS take_picture.c) -set(COMPONENT_ADD_INCLUDEDIRS .) -register_component() \ No newline at end of file diff --git a/lib/libesp32_div/esp32-camera/examples/main/component.mk b/lib/libesp32_div/esp32-camera/examples/main/component.mk deleted file mode 100644 index 0b9d7585e..000000000 --- a/lib/libesp32_div/esp32-camera/examples/main/component.mk +++ /dev/null @@ -1,5 +0,0 @@ -# -# "main" pseudo-component makefile. -# -# (Uses default behaviour of compiling all source files in directory, adding 'include' to include path.) - diff --git a/lib/libesp32_div/esp32-camera/examples/main/take_picture.c b/lib/libesp32_div/esp32-camera/examples/main/take_picture.c deleted file mode 100644 index 1cbad908b..000000000 --- a/lib/libesp32_div/esp32-camera/examples/main/take_picture.c +++ /dev/null @@ -1,155 +0,0 @@ -/** - * This example takes a picture every 5s and print its size on serial monitor. - */ - -// =============================== SETUP ====================================== - -// 1. Board setup (Uncomment): -// #define BOARD_WROVER_KIT -// #define BOARD_ESP32CAM_AITHINKER - -/** - * 2. Kconfig setup - * - * If you have a Kconfig file, copy the content from - * https://github.com/espressif/esp32-camera/blob/master/Kconfig into it. - * In case you haven't, copy and paste this Kconfig file inside the src directory. - * This Kconfig file has definitions that allows more control over the camera and - * how it will be initialized. - */ - -/** - * 3. Enable PSRAM on sdkconfig: - * - * CONFIG_ESP32_SPIRAM_SUPPORT=y - * - * More info on - * https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/kconfig.html#config-esp32-spiram-support - */ - -// ================================ CODE ====================================== - -#include -#include -#include -#include -#include - -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#include "esp_camera.h" - -#define BOARD_WROVER_KIT 1 - -// WROVER-KIT PIN Map -#ifdef BOARD_WROVER_KIT - -#define CAM_PIN_PWDN -1 //power down is not used -#define CAM_PIN_RESET -1 //software reset will be performed -#define CAM_PIN_XCLK 21 -#define CAM_PIN_SIOD 26 -#define CAM_PIN_SIOC 27 - -#define CAM_PIN_D7 35 -#define CAM_PIN_D6 34 -#define CAM_PIN_D5 39 -#define CAM_PIN_D4 36 -#define CAM_PIN_D3 19 -#define CAM_PIN_D2 18 -#define CAM_PIN_D1 5 -#define CAM_PIN_D0 4 -#define CAM_PIN_VSYNC 25 -#define CAM_PIN_HREF 23 -#define CAM_PIN_PCLK 22 - -#endif - -// ESP32Cam (AiThinker) PIN Map -#ifdef BOARD_ESP32CAM_AITHINKER - -#define CAM_PIN_PWDN 32 -#define CAM_PIN_RESET -1 //software reset will be performed -#define CAM_PIN_XCLK 0 -#define CAM_PIN_SIOD 26 -#define CAM_PIN_SIOC 27 - -#define CAM_PIN_D7 35 -#define CAM_PIN_D6 34 -#define CAM_PIN_D5 39 -#define CAM_PIN_D4 36 -#define CAM_PIN_D3 21 -#define CAM_PIN_D2 19 -#define CAM_PIN_D1 18 -#define CAM_PIN_D0 5 -#define CAM_PIN_VSYNC 25 -#define CAM_PIN_HREF 23 -#define CAM_PIN_PCLK 22 - -#endif - -static const char *TAG = "example:take_picture"; - -static camera_config_t camera_config = { - .pin_pwdn = CAM_PIN_PWDN, - .pin_reset = CAM_PIN_RESET, - .pin_xclk = CAM_PIN_XCLK, - .pin_sscb_sda = CAM_PIN_SIOD, - .pin_sscb_scl = CAM_PIN_SIOC, - - .pin_d7 = CAM_PIN_D7, - .pin_d6 = CAM_PIN_D6, - .pin_d5 = CAM_PIN_D5, - .pin_d4 = CAM_PIN_D4, - .pin_d3 = CAM_PIN_D3, - .pin_d2 = CAM_PIN_D2, - .pin_d1 = CAM_PIN_D1, - .pin_d0 = CAM_PIN_D0, - .pin_vsync = CAM_PIN_VSYNC, - .pin_href = CAM_PIN_HREF, - .pin_pclk = CAM_PIN_PCLK, - - //XCLK 20MHz or 10MHz for OV2640 double FPS (Experimental) - .xclk_freq_hz = 20000000, - .ledc_timer = LEDC_TIMER_0, - .ledc_channel = LEDC_CHANNEL_0, - - .pixel_format = PIXFORMAT_RGB565, //YUV422,GRAYSCALE,RGB565,JPEG - .frame_size = FRAMESIZE_QVGA, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG - - .jpeg_quality = 12, //0-63 lower number means higher quality - .fb_count = 1, //if more than one, i2s runs in continuous mode. Use only with JPEG - .grab_mode = CAMERA_GRAB_WHEN_EMPTY, -}; - -static esp_err_t init_camera() -{ - //initialize the camera - esp_err_t err = esp_camera_init(&camera_config); - if (err != ESP_OK) - { - ESP_LOGE(TAG, "Camera Init Failed"); - return err; - } - - return ESP_OK; -} - -void app_main() -{ - if(ESP_OK != init_camera()) { - return; - } - - while (1) - { - ESP_LOGI(TAG, "Taking picture..."); - camera_fb_t *pic = esp_camera_fb_get(); - - // use pic->buf to access the image - ESP_LOGI(TAG, "Picture taken! Its size was: %zu bytes", pic->len); - esp_camera_fb_return(pic); - - vTaskDelay(5000 / portTICK_RATE_MS); - } -} diff --git a/lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults b/lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults deleted file mode 100644 index e5ac4557a..000000000 --- a/lib/libesp32_div/esp32-camera/examples/sdkconfig.defaults +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y - -CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y -CONFIG_PARTITION_TABLE_OFFSET=0x10000 - -CONFIG_FREERTOS_HZ=1000 -CONFIG_ESPTOOLPY_FLASHFREQ_80M=y -CONFIG_ESPTOOLPY_FLASHMODE_QIO=y - -CONFIG_SPIRAM_SUPPORT=y -CONFIG_ESP32_SPIRAM_SUPPORT=y -CONFIG_ESP32S2_SPIRAM_SUPPORT=y -CONFIG_ESP32S3_SPIRAM_SUPPORT=y -CONFIG_SPIRAM_SPEED_80M=y - diff --git a/lib/libesp32_div/esp32-camera/library.json b/lib/libesp32_div/esp32-camera/library.json deleted file mode 100644 index 2f2c9fc1b..000000000 --- a/lib/libesp32_div/esp32-camera/library.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "esp32-camera", - "version": "1.0.0", - "keywords": "esp32, camera, espressif, esp32-cam", - "description": "ESP32 compatible driver for OV2640, OV3660, OV5640, OV7670 and OV7725 image sensors.", - "repository": { - "type": "git", - "url": "https://github.com/espressif/esp32-camera" - }, - "frameworks": "arduino", - "platforms": "espressif32", - "build": { - "flags": [ - "-Idriver/include", - "-Iconversions/include", - "-Idriver/private_include", - "-Iconversions/private_include", - "-Isensors/private_include", - "-Itarget/private_include" - ], - "includeDir": ".", - "srcDir": ".", - "srcFilter": ["-<*>", "+", "+", "+"] - } -} diff --git a/lib/libesp32_div/esp32-camera/sensors/gc0308.c b/lib/libesp32_div/esp32-camera/sensors/gc0308.c deleted file mode 100644 index 19064d3a7..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/gc0308.c +++ /dev/null @@ -1,465 +0,0 @@ -// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "sccb.h" -#include "gc0308.h" -#include "gc0308_regs.h" -#include "gc0308_settings.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char *TAG = "gc0308"; -#endif - -#define H8(v) ((v)>>8) -#define L8(v) ((v)&0xff) - -//#define REG_DEBUG_ON - -static int read_reg(uint8_t slv_addr, const uint16_t reg) -{ - int ret = SCCB_Read(slv_addr, reg); -#ifdef REG_DEBUG_ON - if (ret < 0) { - ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) -{ - int ret = 0; -#ifndef REG_DEBUG_ON - ret = SCCB_Write(slv_addr, reg, value); -#else - int old_value = read_reg(slv_addr, reg); - if (old_value < 0) { - return old_value; - } - if ((uint8_t)old_value != value) { - ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); - ret = SCCB_Write(slv_addr, reg, value); - } else { - ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); - ret = SCCB_Write(slv_addr, reg, value);//maybe not? - } - if (ret < 0) { - ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) -{ - return (read_reg(slv_addr, reg) & mask) == mask; -} - -static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - ret = read_reg(slv_addr, reg); - if (ret < 0) { - return ret; - } - c_value = ret; - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = write_reg(slv_addr, reg, new_value); - return ret; -} - -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) -{ - int i = 0, ret = 0; - while (!ret && regs[i][0] != REGLIST_TAIL) { - if (regs[i][0] == REG_DLY) { - vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); - } else { - ret = write_reg(slv_addr, regs[i][0], regs[i][1]); - } - i++; - } - return ret; -} - -static void print_regs(uint8_t slv_addr) -{ -#ifdef DEBUG_PRINT_REG - ESP_LOGI(TAG, "REG list look ======================"); - for (size_t i = 0xf0; i <= 0xfe; i++) { - ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - ESP_LOGI(TAG, "\npage 0 ==="); - write_reg(slv_addr, 0xfe, 0x00); // page 0 - for (size_t i = 0x03; i <= 0xa2; i++) { - ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - - ESP_LOGI(TAG, "\npage 3 ==="); - write_reg(slv_addr, 0xfe, 0x03); // page 3 - for (size_t i = 0x01; i <= 0x43; i++) { - ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } -#endif -} - -static int reset(sensor_t *sensor) -{ - int ret = 0; - // Software Reset: clear all registers and reset them to their default values - ret = write_reg(sensor->slv_addr, RESET_RELATED, 0xf0); - if (ret) { - ESP_LOGE(TAG, "Software Reset FAILED!"); - return ret; - } - vTaskDelay(100 / portTICK_PERIOD_MS); - ret = write_regs(sensor->slv_addr, gc0308_sensor_default_regs); - if (ret == 0) { - ESP_LOGD(TAG, "Camera defaults loaded"); - vTaskDelay(100 / portTICK_PERIOD_MS); - write_reg(sensor->slv_addr, 0xfe, 0x00); -#ifdef CONFIG_IDF_TARGET_ESP32 - set_reg_bits(sensor->slv_addr, 0x28, 4, 0x07, 1); //frequency division for esp32, ensure pclk <= 15MHz -#endif - } - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - - switch (pixformat) { - case PIXFORMAT_RGB565: - write_reg(sensor->slv_addr, 0xfe, 0x00); - ret = set_reg_bits(sensor->slv_addr, 0x24, 0, 0x0f, 6); //RGB565 - break; - - case PIXFORMAT_YUV422: - write_reg(sensor->slv_addr, 0xfe, 0x00); - ret = set_reg_bits(sensor->slv_addr, 0x24, 0, 0x0f, 2); //yuv422 Y Cb Y Cr - break; - default: - ESP_LOGW(TAG, "unsupport format"); - ret = -1; - break; - } - - if (ret == 0) { - sensor->pixformat = pixformat; - ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); - } - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret = 0; - if (framesize > FRAMESIZE_VGA) { - ESP_LOGW(TAG, "Invalid framesize: %u", framesize); - framesize = FRAMESIZE_VGA; - } - sensor->status.framesize = framesize; - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - uint16_t row_s = (resolution[FRAMESIZE_VGA].height - h) / 2; - uint16_t col_s = (resolution[FRAMESIZE_VGA].width - w) / 2; - -#if CONFIG_GC_SENSOR_SUBSAMPLE_MODE - struct subsample_cfg { - uint16_t ratio_numerator; - uint16_t ratio_denominator; - uint8_t reg0x54; - uint8_t reg0x56; - uint8_t reg0x57; - uint8_t reg0x58; - uint8_t reg0x59; - }; - const struct subsample_cfg subsample_cfgs[] = { // define some subsample ratio - {84, 420, 0x55, 0x00, 0x00, 0x00, 0x00}, //1/5 - {105, 420, 0x44, 0x00, 0x00, 0x00, 0x00},//1/4 - {140, 420, 0x33, 0x00, 0x00, 0x00, 0x00},//1/3 - {210, 420, 0x22, 0x00, 0x00, 0x00, 0x00},//1/2 - {240, 420, 0x77, 0x02, 0x46, 0x02, 0x46},//4/7 - {252, 420, 0x55, 0x02, 0x04, 0x02, 0x04},//3/5 - {280, 420, 0x33, 0x02, 0x00, 0x02, 0x00},//2/3 - {420, 420, 0x11, 0x00, 0x00, 0x00, 0x00},//1/1 - }; - uint16_t win_w = 640; - uint16_t win_h = 480; - const struct subsample_cfg *cfg = NULL; - /** - * Strategy: try to keep the maximum perspective - */ - for (size_t i = 0; i < sizeof(subsample_cfgs) / sizeof(struct subsample_cfg); i++) { - cfg = &subsample_cfgs[i]; - if ((win_w * cfg->ratio_numerator / cfg->ratio_denominator >= w) && (win_h * cfg->ratio_numerator / cfg->ratio_denominator >= h)) { - win_w = w * cfg->ratio_denominator / cfg->ratio_numerator; - win_h = h * cfg->ratio_denominator / cfg->ratio_numerator; - row_s = (resolution[FRAMESIZE_VGA].height - win_h) / 2; - col_s = (resolution[FRAMESIZE_VGA].width - win_w) / 2; - ESP_LOGI(TAG, "subsample win:%dx%d, ratio:%f", win_w, win_h, (float)cfg->ratio_numerator / (float)cfg->ratio_denominator); - break; - } - } - - write_reg(sensor->slv_addr, 0xfe, 0x00); - - write_reg(sensor->slv_addr, 0x05, H8(row_s)); - write_reg(sensor->slv_addr, 0x06, L8(row_s)); - write_reg(sensor->slv_addr, 0x07, H8(col_s)); - write_reg(sensor->slv_addr, 0x08, L8(col_s)); - write_reg(sensor->slv_addr, 0x09, H8(win_h + 8)); - write_reg(sensor->slv_addr, 0x0a, L8(win_h + 8)); - write_reg(sensor->slv_addr, 0x0b, H8(win_w + 8)); - write_reg(sensor->slv_addr, 0x0c, L8(win_w + 8)); - - write_reg(sensor->slv_addr, 0xfe, 0x01); - set_reg_bits(sensor->slv_addr, 0x53, 7, 0x01, 1); - set_reg_bits(sensor->slv_addr, 0x55, 0, 0x01, 1); - write_reg(sensor->slv_addr, 0x54, cfg->reg0x54); - write_reg(sensor->slv_addr, 0x56, cfg->reg0x56); - write_reg(sensor->slv_addr, 0x57, cfg->reg0x57); - write_reg(sensor->slv_addr, 0x58, cfg->reg0x58); - write_reg(sensor->slv_addr, 0x59, cfg->reg0x59); - - write_reg(sensor->slv_addr, 0xfe, 0x00); - -#elif CONFIG_GC_SENSOR_WINDOWING_MODE - write_reg(sensor->slv_addr, 0xfe, 0x00); - - write_reg(sensor->slv_addr, 0xf7, col_s / 4); - write_reg(sensor->slv_addr, 0xf8, row_s / 4); - write_reg(sensor->slv_addr, 0xf9, (col_s + h) / 4); - write_reg(sensor->slv_addr, 0xfa, (row_s + w) / 4); - - write_reg(sensor->slv_addr, 0x05, H8(row_s)); - write_reg(sensor->slv_addr, 0x06, L8(row_s)); - write_reg(sensor->slv_addr, 0x07, H8(col_s)); - write_reg(sensor->slv_addr, 0x08, L8(col_s)); - - write_reg(sensor->slv_addr, 0x09, H8(h + 8)); - write_reg(sensor->slv_addr, 0x0a, L8(h + 8)); - write_reg(sensor->slv_addr, 0x0b, H8(w + 8)); - write_reg(sensor->slv_addr, 0x0c, L8(w + 8)); - -#endif - if (ret == 0) { - ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); - } - return 0; -} - -static int set_contrast(sensor_t *sensor, int contrast) -{ - if (contrast != 0) { - write_reg(sensor->slv_addr, 0xfe, 0x00); - write_reg(sensor->slv_addr, 0xb3, contrast); - } - return 0; -} - -static int set_global_gain(sensor_t *sensor, int gain_level) -{ - if (gain_level != 0) { - write_reg(sensor->slv_addr, 0xfe, 0x00); - write_reg(sensor->slv_addr, 0x50, gain_level); - } - return 0; -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.hmirror = enable; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, 0x14, 0, 0x01, enable != 0); - if (ret == 0) { - ESP_LOGD(TAG, "Set h-mirror to: %d", enable); - } - return ret; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, 0x14, 1, 0x01, enable != 0); - if (ret == 0) { - ESP_LOGD(TAG, "Set v-flip to: %d", enable); - } - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, 0x2e, 0, 0x01, enable); - if (ret == 0) { - sensor->status.colorbar = enable; - ESP_LOGD(TAG, "Set colorbar to: %d", enable); - } - return ret; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = 0; - if (mask > 0xFF) { - ESP_LOGE(TAG, "mask should not more than 0xff"); - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if (ret > 0) { - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0; - if (mask > 0xFF) { - ESP_LOGE(TAG, "mask should not more than 0xff"); - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if (ret < 0) { - return ret; - } - value = (ret & ~mask) | (value & mask); - - if (mask > 0xFF) { - - } else { - ret = write_reg(sensor->slv_addr, reg, value); - } - return ret; -} - -static int init_status(sensor_t *sensor) -{ - write_reg(sensor->slv_addr, 0xfe, 0x00); - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.sharpness = 0; - sensor->status.denoise = 0; - sensor->status.ae_level = 0; - sensor->status.gainceiling = 0; - sensor->status.awb = 0; - sensor->status.dcw = 0; - sensor->status.agc = 0; - sensor->status.aec = 0; - sensor->status.hmirror = check_reg_mask(sensor->slv_addr, 0x14, 0x01); - sensor->status.vflip = check_reg_mask(sensor->slv_addr, 0x14, 0x02); - sensor->status.colorbar = 0; - sensor->status.bpc = 0; - sensor->status.wpc = 0; - sensor->status.raw_gma = 0; - sensor->status.lenc = 0; - sensor->status.quality = 0; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - sensor->status.awb_gain = 0; - sensor->status.agc_gain = 0; - sensor->status.aec_value = 0; - sensor->status.aec2 = 0; - - print_regs(sensor->slv_addr); - return 0; -} - -static int set_dummy(sensor_t *sensor, int val) -{ - ESP_LOGW(TAG, "Unsupported"); - return -1; -} -static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) -{ - ESP_LOGW(TAG, "Unsupported"); - return -1; -} - -int gc0308_detect(int slv_addr, sensor_id_t *id) -{ - if (GC0308_SCCB_ADDR == slv_addr) { - write_reg(slv_addr, 0xfe, 0x00); - uint8_t PID = SCCB_Read(slv_addr, 0x00); - if (GC0308_PID == PID) { - id->PID = PID; - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int gc0308_init(sensor_t *sensor) -{ - sensor->init_status = init_status; - sensor->reset = reset; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_contrast; - sensor->set_brightness = set_dummy; - sensor->set_saturation = set_dummy; - sensor->set_sharpness = set_dummy; - sensor->set_denoise = set_dummy; - sensor->set_gainceiling = set_gainceiling_dummy; - sensor->set_quality = set_dummy; - sensor->set_colorbar = set_colorbar; - sensor->set_whitebal = set_dummy; - sensor->set_gain_ctrl = set_global_gain; - sensor->set_exposure_ctrl = set_dummy; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - - sensor->set_aec2 = set_dummy; - sensor->set_awb_gain = set_dummy; - sensor->set_agc_gain = set_dummy; - sensor->set_aec_value = set_dummy; - - sensor->set_special_effect = set_dummy; - sensor->set_wb_mode = set_dummy; - sensor->set_ae_level = set_dummy; - - sensor->set_dcw = set_dummy; - sensor->set_bpc = set_dummy; - sensor->set_wpc = set_dummy; - - sensor->set_raw_gma = set_dummy; - sensor->set_lenc = set_dummy; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = NULL; - sensor->set_pll = NULL; - sensor->set_xclk = NULL; - - ESP_LOGD(TAG, "GC0308 Attached"); - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/gc032a.c b/lib/libesp32_div/esp32-camera/sensors/gc032a.c deleted file mode 100644 index 612e17b1e..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/gc032a.c +++ /dev/null @@ -1,391 +0,0 @@ -// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "sccb.h" -#include "gc032a.h" -#include "gc032a_regs.h" -#include "gc032a_settings.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char *TAG = "gc032a"; -#endif - -#define H8(v) ((v)>>8) -#define L8(v) ((v)&0xff) - -//#define REG_DEBUG_ON - -static int read_reg(uint8_t slv_addr, const uint16_t reg) -{ - int ret = SCCB_Read(slv_addr, reg); -#ifdef REG_DEBUG_ON - if (ret < 0) { - ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) -{ - int ret = 0; -#ifndef REG_DEBUG_ON - ret = SCCB_Write(slv_addr, reg, value); -#else - int old_value = read_reg(slv_addr, reg); - if (old_value < 0) { - return old_value; - } - if ((uint8_t)old_value != value) { - ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); - ret = SCCB_Write(slv_addr, reg, value); - } else { - ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); - ret = SCCB_Write(slv_addr, reg, value);//maybe not? - } - if (ret < 0) { - ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) -{ - return (read_reg(slv_addr, reg) & mask) == mask; -} - -static void print_regs(uint8_t slv_addr) -{ -#ifdef DEBUG_PRINT_REG - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_LOGI(TAG, "REG list look ======================"); - for (size_t i = 0xf0; i <= 0xfe; i++) { - ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - ESP_LOGI(TAG, "\npage 0 ==="); - write_reg(slv_addr, 0xfe, 0x00); // page 0 - for (size_t i = 0x03; i <= 0x24; i++) { - ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - for (size_t i = 0x40; i <= 0x95; i++) { - ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - ESP_LOGI(TAG, "\npage 3 ==="); - write_reg(slv_addr, 0xfe, 0x03); // page 3 - for (size_t i = 0x01; i <= 0x43; i++) { - ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } -#endif -} - -static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - ret = read_reg(slv_addr, reg); - if (ret < 0) { - return ret; - } - c_value = ret; - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = write_reg(slv_addr, reg, new_value); - return ret; -} - -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) -{ - int i = 0, ret = 0; - while (!ret && regs[i][0] != REGLIST_TAIL) { - if (regs[i][0] == REG_DLY) { - vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); - } else { - ret = write_reg(slv_addr, regs[i][0], regs[i][1]); - } - i++; - } - return ret; -} - -static int reset(sensor_t *sensor) -{ - int ret; - // Software Reset: clear all registers and reset them to their default values - ret = write_reg(sensor->slv_addr, RESET_RELATED, 0xf0); - if (ret) { - ESP_LOGE(TAG, "Software Reset FAILED!"); - return ret; - } - vTaskDelay(100 / portTICK_PERIOD_MS); - - ret = write_regs(sensor->slv_addr, gc032a_default_regs); - if (ret == 0) { - ESP_LOGD(TAG, "Camera defaults loaded"); - vTaskDelay(100 / portTICK_PERIOD_MS); - write_reg(sensor->slv_addr, 0xfe, 0x00); - set_reg_bits(sensor->slv_addr, 0xf7, 1, 0x01, 1); // PLL_mode1:div2en - set_reg_bits(sensor->slv_addr, 0xf7, 7, 0x01, 1); // PLL_mode1:dvp mode - set_reg_bits(sensor->slv_addr, 0xf8, 0, 0x3f, 8); //PLL_mode2 :divx4 - set_reg_bits(sensor->slv_addr, 0xfa, 4, 0x0f, 2); //vlk div mode :divide_by - } - - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - switch (pixformat) { - case PIXFORMAT_RGB565: - write_reg(sensor->slv_addr, 0xfe, 0x00); - ret = set_reg_bits(sensor->slv_addr, 0x44, 0, 0x1f, 6); //RGB565 - break; - - case PIXFORMAT_YUV422: - write_reg(sensor->slv_addr, 0xfe, 0x00); - ret = set_reg_bits(sensor->slv_addr, 0x44, 0, 0x1f, 3); - break; - default: - ESP_LOGW(TAG, "unsupport format"); - ret = -1; - break; - } - if (ret == 0) { - sensor->pixformat = pixformat; - ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); - } - - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - ESP_LOGI(TAG, "set_framesize"); - int ret = 0; - if (framesize > FRAMESIZE_VGA) { - ESP_LOGW(TAG, "Invalid framesize: %u", framesize); - framesize = FRAMESIZE_VGA; - } - sensor->status.framesize = framesize; - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - uint16_t row_s = (resolution[FRAMESIZE_VGA].height - h) / 2; - uint16_t col_s = (resolution[FRAMESIZE_VGA].width - w) / 2; - - write_reg(sensor->slv_addr, 0xfe, 0x00); - write_reg(sensor->slv_addr, P0_ROW_START_HIGH, H8(row_s)); // Row_start[8] - write_reg(sensor->slv_addr, P0_ROW_START_LOW, L8(row_s)); // Row_start[7:0] - write_reg(sensor->slv_addr, P0_COLUMN_START_HIGH, H8(col_s)); // Column_start[9:8] - write_reg(sensor->slv_addr, P0_COLUMN_START_LOW, L8(col_s)); // Column_start[7:0] - write_reg(sensor->slv_addr, P0_WINDOW_HEIGHT_HIGH, H8(h + 8)); //window_height [8] - write_reg(sensor->slv_addr, P0_WINDOW_HEIGHT_LOW, L8(h + 8)); //window_height [7:0] - write_reg(sensor->slv_addr, P0_WINDOW_WIDTH_HIGH, H8(w + 8)); //window_width [9:8] - write_reg(sensor->slv_addr, P0_WINDOW_WIDTH_LOW, L8(w + 8)); //window_width [7:0] - - write_reg(sensor->slv_addr, P0_WIN_MODE, 0x01); - write_reg(sensor->slv_addr, P0_OUT_WIN_HEIGHT_HIGH, H8(h)); - write_reg(sensor->slv_addr, P0_OUT_WIN_HEIGHT_LOW, L8(h)); - write_reg(sensor->slv_addr, P0_OUT_WIN_WIDTH_HIGH, H8(w)); - write_reg(sensor->slv_addr, P0_OUT_WIN_WIDTH_LOW, L8(w)); - - if (ret == 0) { - ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); - } - print_regs(sensor->slv_addr); - return ret; -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.hmirror = enable; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, P0_CISCTL_MODE1, 0, 0x01, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set h-mirror to: %d", enable); - } - return ret; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, P0_CISCTL_MODE1, 1, 0x01, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set v-flip to: %d", enable); - } - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, P0_DEBUG_MODE2, 3, 0x01, enable); - if (ret == 0) { - sensor->status.colorbar = enable; - ESP_LOGD(TAG, "Set colorbar to: %d", enable); - } - return ret; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = 0; - if (mask > 0xFF) { - ESP_LOGE(TAG, "mask should not more than 0xff"); - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if (ret > 0) { - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0; - if (mask > 0xFF) { - ESP_LOGE(TAG, "mask should not more than 0xff"); - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if (ret < 0) { - return ret; - } - value = (ret & ~mask) | (value & mask); - - if (mask > 0xFF) { - - } else { - ret = write_reg(sensor->slv_addr, reg, value); - } - return ret; -} - -static int init_status(sensor_t *sensor) -{ - write_reg(sensor->slv_addr, 0xfe, 0x00); - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.sharpness = 0; - sensor->status.denoise = 0; - sensor->status.ae_level = 0; - sensor->status.gainceiling = 0; - sensor->status.awb = 0; - sensor->status.dcw = 0; - sensor->status.agc = 0; - sensor->status.aec = 0; - sensor->status.hmirror = check_reg_mask(sensor->slv_addr, P0_CISCTL_MODE1, 0x01); - sensor->status.vflip = check_reg_mask(sensor->slv_addr, P0_CISCTL_MODE1, 0x02); - sensor->status.colorbar = 0; - sensor->status.bpc = 0; - sensor->status.wpc = 0; - sensor->status.raw_gma = 0; - sensor->status.lenc = 0; - sensor->status.quality = 0; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - sensor->status.awb_gain = 0; - sensor->status.agc_gain = 0; - sensor->status.aec_value = 0; - sensor->status.aec2 = 0; - return 0; -} - -static int set_dummy(sensor_t *sensor, int val) -{ - ESP_LOGW(TAG, "Unsupported"); - return -1; -} -static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) -{ - ESP_LOGW(TAG, "Unsupported"); - return -1; -} - -int gc032a_detect(int slv_addr, sensor_id_t *id) -{ - if (GC032A_SCCB_ADDR == slv_addr) { - uint8_t MIDL = SCCB_Read(slv_addr, SENSOR_ID_LOW); - uint8_t MIDH = SCCB_Read(slv_addr, SENSOR_ID_HIGH); - uint16_t PID = MIDH << 8 | MIDL; - if (GC032A_PID == PID) { - id->PID = PID; - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int gc032a_init(sensor_t *sensor) -{ - sensor->init_status = init_status; - sensor->reset = reset; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_dummy; - sensor->set_brightness = set_dummy; - sensor->set_saturation = set_dummy; - sensor->set_sharpness = set_dummy; - sensor->set_denoise = set_dummy; - sensor->set_gainceiling = set_gainceiling_dummy; - sensor->set_quality = set_dummy; - sensor->set_colorbar = set_colorbar; - sensor->set_whitebal = set_dummy; - sensor->set_gain_ctrl = set_dummy; - sensor->set_exposure_ctrl = set_dummy; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - - sensor->set_aec2 = set_dummy; - sensor->set_awb_gain = set_dummy; - sensor->set_agc_gain = set_dummy; - sensor->set_aec_value = set_dummy; - - sensor->set_special_effect = set_dummy; - sensor->set_wb_mode = set_dummy; - sensor->set_ae_level = set_dummy; - - sensor->set_dcw = set_dummy; - sensor->set_bpc = set_dummy; - sensor->set_wpc = set_dummy; - - sensor->set_raw_gma = set_dummy; - sensor->set_lenc = set_dummy; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = NULL; - sensor->set_pll = NULL; - sensor->set_xclk = NULL; - - ESP_LOGD(TAG, "GC032A Attached"); - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/gc2145.c b/lib/libesp32_div/esp32-camera/sensors/gc2145.c deleted file mode 100644 index 311308290..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/gc2145.c +++ /dev/null @@ -1,475 +0,0 @@ -// Copyright 2015-2021 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "sccb.h" -#include "gc2145.h" -#include "gc2145_regs.h" -#include "gc2145_settings.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char *TAG = "gc2145"; -#endif - -#define H8(v) ((v)>>8) -#define L8(v) ((v)&0xff) - -//#define REG_DEBUG_ON - -static int read_reg(uint8_t slv_addr, const uint16_t reg) -{ - int ret = SCCB_Read(slv_addr, reg); -#ifdef REG_DEBUG_ON - if (ret < 0) { - ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) -{ - int ret = 0; -#ifndef REG_DEBUG_ON - ret = SCCB_Write(slv_addr, reg, value); -#else - int old_value = read_reg(slv_addr, reg); - if (old_value < 0) { - return old_value; - } - if ((uint8_t)old_value != value) { - ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); - ret = SCCB_Write(slv_addr, reg, value); - } else { - ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); - ret = SCCB_Write(slv_addr, reg, value);//maybe not? - } - if (ret < 0) { - ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) -{ - return (read_reg(slv_addr, reg) & mask) == mask; -} - -static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - ret = read_reg(slv_addr, reg); - if (ret < 0) { - return ret; - } - c_value = ret; - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = write_reg(slv_addr, reg, new_value); - return ret; -} - -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) -{ - int i = 0, ret = 0; - while (!ret && regs[i][0] != REGLIST_TAIL) { - if (regs[i][0] == REG_DLY) { - vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); - } else { - ret = write_reg(slv_addr, regs[i][0], regs[i][1]); - } - i++; - } - return ret; -} - -static void print_regs(uint8_t slv_addr) -{ -#ifdef DEBUG_PRINT_REG - vTaskDelay(pdMS_TO_TICKS(100)); - ESP_LOGI(TAG, "REG list look ======================"); - for (size_t i = 0xf0; i <= 0xfe; i++) { - ESP_LOGI(TAG, "reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - ESP_LOGI(TAG, "\npage 0 ==="); - write_reg(slv_addr, 0xfe, 0x00); // page 0 - for (size_t i = 0x03; i <= 0x24; i++) { - ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - for (size_t i = 0x80; i <= 0xa2; i++) { - ESP_LOGI(TAG, "p0 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } - ESP_LOGI(TAG, "\npage 3 ==="); - write_reg(slv_addr, 0xfe, 0x03); // page 3 - for (size_t i = 0x01; i <= 0x43; i++) { - ESP_LOGI(TAG, "p3 reg[0x%02x] = 0x%02x", i, read_reg(slv_addr, i)); - } -#endif -} - -static int reset(sensor_t *sensor) -{ - int ret = 0; - // Software Reset: clear all registers and reset them to their default values - ret = write_reg(sensor->slv_addr, RESET_RELATED, 0xe0); - if (ret) { - ESP_LOGE(TAG, "Software Reset FAILED!"); - return ret; - } - vTaskDelay(100 / portTICK_PERIOD_MS); - ret = write_regs(sensor->slv_addr, gc2145_default_init_regs); - if (ret == 0) { - ESP_LOGD(TAG, "Camera defaults loaded"); - vTaskDelay(100 / portTICK_PERIOD_MS); -#ifdef CONFIG_IDF_TARGET_ESP32 - write_reg(sensor->slv_addr, 0xfe, 0x00); - //ensure pclk <= 15MHz for esp32 - set_reg_bits(sensor->slv_addr, 0xf8, 0, 0x3f, 2); // divx4 - set_reg_bits(sensor->slv_addr, 0xfa, 4, 0x0f, 2); // divide_by -#endif - - } - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - - switch (pixformat) { - case PIXFORMAT_RGB565: - write_reg(sensor->slv_addr, 0xfe, 0x00); - ret = set_reg_bits(sensor->slv_addr, P0_OUTPUT_FORMAT, 0, 0x1f, 6); //RGB565 - break; - - case PIXFORMAT_YUV422: - write_reg(sensor->slv_addr, 0xfe, 0x00); - ret = set_reg_bits(sensor->slv_addr, P0_OUTPUT_FORMAT, 0, 0x1f, 2); //yuv422 - break; - default: - ESP_LOGW(TAG, "unsupport format"); - ret = -1; - break; - } - - if (ret == 0) { - sensor->pixformat = pixformat; - ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); - } - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret = 0; - if (framesize > FRAMESIZE_UXGA) { - ESP_LOGW(TAG, "Invalid framesize: %u", framesize); - framesize = FRAMESIZE_UXGA; - } - sensor->status.framesize = framesize; - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - uint16_t row_s = (resolution[FRAMESIZE_UXGA].height - h) / 2; - uint16_t col_s = (resolution[FRAMESIZE_UXGA].width - w) / 2; - -#if CONFIG_GC_SENSOR_SUBSAMPLE_MODE - struct subsample_cfg { - uint16_t ratio_numerator; - uint16_t ratio_denominator; - uint8_t reg0x99; - uint8_t reg0x9b; - uint8_t reg0x9c; - uint8_t reg0x9d; - uint8_t reg0x9e; - uint8_t reg0x9f; - uint8_t reg0xa0; - uint8_t reg0xa1; - uint8_t reg0xa2; - }; - const struct subsample_cfg subsample_cfgs[] = { // define some subsample ratio - // {60, 420, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //1/7 // A smaller ratio brings a larger view, but it reduces the frame rate - // {84, 420, 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, //1/5 - // {105, 420, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/4 - {140, 420, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/3 - {210, 420, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/2 - {240, 420, 0x77, 0x02, 0x46, 0x02, 0x46, 0x02, 0x46, 0x02, 0x46},//4/7 - {252, 420, 0x55, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0x04},//3/5 - {280, 420, 0x33, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00},//2/3 - {420, 420, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},//1/1 - }; - uint16_t win_w = resolution[FRAMESIZE_UXGA].width; - uint16_t win_h = resolution[FRAMESIZE_UXGA].height; - const struct subsample_cfg *cfg = NULL; - /** - * Strategy: try to keep the maximum perspective - */ - uint8_t i = 0; - if (framesize >= FRAMESIZE_QVGA) { - i = 1; - } - for (; i < sizeof(subsample_cfgs) / sizeof(struct subsample_cfg); i++) { - cfg = &subsample_cfgs[i]; - if ((win_w * cfg->ratio_numerator / cfg->ratio_denominator >= w) && (win_h * cfg->ratio_numerator / cfg->ratio_denominator >= h)) { - win_w = w * cfg->ratio_denominator / cfg->ratio_numerator; - win_h = h * cfg->ratio_denominator / cfg->ratio_numerator; - row_s = (resolution[FRAMESIZE_UXGA].height - win_h) / 2; - col_s = (resolution[FRAMESIZE_UXGA].width - win_w) / 2; - ESP_LOGI(TAG, "subsample win:%dx%d, ratio:%f", win_w, win_h, (float)cfg->ratio_numerator / (float)cfg->ratio_denominator); - break; - } - } - - write_reg(sensor->slv_addr, 0xfe, 0x00); - write_reg(sensor->slv_addr, P0_CROP_ENABLE, 0x01); - write_reg(sensor->slv_addr, 0x09, H8(row_s)); - write_reg(sensor->slv_addr, 0x0a, L8(row_s)); - write_reg(sensor->slv_addr, 0x0b, H8(col_s)); - write_reg(sensor->slv_addr, 0x0c, L8(col_s)); - write_reg(sensor->slv_addr, 0x0d, H8(win_h + 8)); - write_reg(sensor->slv_addr, 0x0e, L8(win_h + 8)); - write_reg(sensor->slv_addr, 0x0f, H8(win_w + 16)); - write_reg(sensor->slv_addr, 0x10, L8(win_w + 16)); - - write_reg(sensor->slv_addr, 0x99, cfg->reg0x99); - write_reg(sensor->slv_addr, 0x9b, cfg->reg0x9b); - write_reg(sensor->slv_addr, 0x9c, cfg->reg0x9c); - write_reg(sensor->slv_addr, 0x9d, cfg->reg0x9d); - write_reg(sensor->slv_addr, 0x9e, cfg->reg0x9e); - write_reg(sensor->slv_addr, 0x9f, cfg->reg0x9f); - write_reg(sensor->slv_addr, 0xa0, cfg->reg0xa0); - write_reg(sensor->slv_addr, 0xa1, cfg->reg0xa1); - write_reg(sensor->slv_addr, 0xa2, cfg->reg0xa2); - - write_reg(sensor->slv_addr, 0x95, H8(h)); - write_reg(sensor->slv_addr, 0x96, L8(h)); - write_reg(sensor->slv_addr, 0x97, H8(w)); - write_reg(sensor->slv_addr, 0x98, L8(w)); - - -#elif CONFIG_GC_SENSOR_WINDOWING_MODE - write_reg(sensor->slv_addr, 0xfe, 0x00); - - write_reg(sensor->slv_addr, P0_CROP_ENABLE, 0x01); - // write_reg(sensor->slv_addr, 0xec, col_s / 8); //measure window - // write_reg(sensor->slv_addr, 0xed, row_s / 8); - // write_reg(sensor->slv_addr, 0xee, (col_s + h) / 8); - // write_reg(sensor->slv_addr, 0xef, (row_s + w) / 8); - - write_reg(sensor->slv_addr, 0x09, H8(row_s)); - write_reg(sensor->slv_addr, 0x0a, L8(row_s)); - write_reg(sensor->slv_addr, 0x0b, H8(col_s)); - write_reg(sensor->slv_addr, 0x0c, L8(col_s)); - write_reg(sensor->slv_addr, 0x0d, H8(h + 8)); - write_reg(sensor->slv_addr, 0x0e, L8(h + 8)); - write_reg(sensor->slv_addr, 0x0f, H8(w + 8)); - write_reg(sensor->slv_addr, 0x10, L8(w + 8)); - - write_reg(sensor->slv_addr, 0x95, H8(h)); - write_reg(sensor->slv_addr, 0x96, L8(h)); - write_reg(sensor->slv_addr, 0x97, H8(w)); - write_reg(sensor->slv_addr, 0x98, L8(w)); - -#endif - - if (ret == 0) { - ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); - } - return ret; - -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.hmirror = enable; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, P0_ANALOG_MODE1, 0, 0x01, enable != 0); - if (ret == 0) { - ESP_LOGD(TAG, "Set h-mirror to: %d", enable); - } - return ret; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - ret |= set_reg_bits(sensor->slv_addr, P0_ANALOG_MODE1, 1, 0x01, enable != 0); - if (ret == 0) { - ESP_LOGD(TAG, "Set v-flip to: %d", enable); - } - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret = 0; - // ret = write_reg(sensor->slv_addr, 0xfe, 0x00); - // ret |= set_reg_bits(sensor->slv_addr, P0_DEBUG_MODE3, 3, 0x01, enable); - if (ret == 0) { - sensor->status.colorbar = enable; - ESP_LOGD(TAG, "Set colorbar to: %d", enable); - } - return ret; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = 0; - if (mask > 0xFF) { - ESP_LOGE(TAG, "mask should not more than 0xff"); - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if (ret > 0) { - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0; - if (mask > 0xFF) { - ESP_LOGE(TAG, "mask should not more than 0xff"); - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if (ret < 0) { - return ret; - } - value = (ret & ~mask) | (value & mask); - - if (mask > 0xFF) { - - } else { - ret = write_reg(sensor->slv_addr, reg, value); - } - return ret; -} - -static int init_status(sensor_t *sensor) -{ - write_reg(sensor->slv_addr, 0xfe, 0x00); - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.sharpness = 0; - sensor->status.denoise = 0; - sensor->status.ae_level = 0; - sensor->status.gainceiling = 0; - sensor->status.awb = 0; - sensor->status.dcw = 0; - sensor->status.agc = 0; - sensor->status.aec = 0; - sensor->status.hmirror = check_reg_mask(sensor->slv_addr, P0_ANALOG_MODE1, 0x01); - sensor->status.vflip = check_reg_mask(sensor->slv_addr, P0_ANALOG_MODE1, 0x02); - sensor->status.colorbar = 0; - sensor->status.bpc = 0; - sensor->status.wpc = 0; - sensor->status.raw_gma = 0; - sensor->status.lenc = 0; - sensor->status.quality = 0; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - sensor->status.awb_gain = 0; - sensor->status.agc_gain = 0; - sensor->status.aec_value = 0; - sensor->status.aec2 = 0; - - print_regs(sensor->slv_addr); - return 0; -} - -static int set_dummy(sensor_t *sensor, int val) -{ - ESP_LOGW(TAG, "Unsupported"); - return -1; -} -static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val) -{ - ESP_LOGW(TAG, "Unsupported"); - return -1; -} - -int gc2145_detect(int slv_addr, sensor_id_t *id) -{ - if (GC2145_SCCB_ADDR == slv_addr) { - uint8_t MIDL = SCCB_Read(slv_addr, CHIP_ID_LOW); - uint8_t MIDH = SCCB_Read(slv_addr, CHIP_ID_HIGH); - uint16_t PID = MIDH << 8 | MIDL; - if (GC2145_PID == PID) { - id->PID = PID; - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int gc2145_init(sensor_t *sensor) -{ - sensor->init_status = init_status; - sensor->reset = reset; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_dummy; - sensor->set_brightness = set_dummy; - sensor->set_saturation = set_dummy; - sensor->set_sharpness = set_dummy; - sensor->set_denoise = set_dummy; - sensor->set_gainceiling = set_gainceiling_dummy; - sensor->set_quality = set_dummy; - sensor->set_colorbar = set_colorbar; - sensor->set_whitebal = set_dummy; - sensor->set_gain_ctrl = set_dummy; - sensor->set_exposure_ctrl = set_dummy; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - - sensor->set_aec2 = set_dummy; - sensor->set_awb_gain = set_dummy; - sensor->set_agc_gain = set_dummy; - sensor->set_aec_value = set_dummy; - - sensor->set_special_effect = set_dummy; - sensor->set_wb_mode = set_dummy; - sensor->set_ae_level = set_dummy; - - sensor->set_dcw = set_dummy; - sensor->set_bpc = set_dummy; - sensor->set_wpc = set_dummy; - - sensor->set_raw_gma = set_dummy; - sensor->set_lenc = set_dummy; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = NULL; - sensor->set_pll = NULL; - sensor->set_xclk = NULL; - - ESP_LOGD(TAG, "GC2145 Attached"); - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/nt99141.c b/lib/libesp32_div/esp32-camera/sensors/nt99141.c deleted file mode 100644 index 86a8b8a0b..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/nt99141.c +++ /dev/null @@ -1,1022 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * NT99141 driver. - * - */ -#include -#include -#include -#include "sccb.h" -#include "xclk.h" -#include "nt99141.h" -#include "nt99141_regs.h" -#include "nt99141_settings.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char *TAG = "NT99141"; -#endif - -//#define REG_DEBUG_ON - -static int read_reg(uint8_t slv_addr, const uint16_t reg) -{ - int ret = SCCB_Read16(slv_addr, reg); -#ifdef REG_DEBUG_ON - - if (ret < 0) { - ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); - } - -#endif - return ret; -} - -static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask) -{ - return (read_reg(slv_addr, reg) & mask) == mask; -} - -static int read_reg16(uint8_t slv_addr, const uint16_t reg) -{ - int ret = 0, ret2 = 0; - ret = read_reg(slv_addr, reg); - - if (ret >= 0) { - ret = (ret & 0xFF) << 8; - ret2 = read_reg(slv_addr, reg + 1); - - if (ret2 < 0) { - ret = ret2; - } else { - ret |= ret2 & 0xFF; - } - } - - return ret; -} - - -static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value) -{ - int ret = 0; -#ifndef REG_DEBUG_ON - ret = SCCB_Write16(slv_addr, reg, value); -#else - int old_value = read_reg(slv_addr, reg); - - if (old_value < 0) { - return old_value; - } - - if ((uint8_t)old_value != value) { - ESP_LOGD(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); - ret = SCCB_Write16(slv_addr, reg, value); - } else { - ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); - ret = SCCB_Write16(slv_addr, reg, value);//maybe not? - } - - if (ret < 0) { - ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); - } - -#endif - return ret; -} - -static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - ret = read_reg(slv_addr, reg); - - if (ret < 0) { - return ret; - } - - c_value = ret; - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = write_reg(slv_addr, reg, new_value); - return ret; -} - -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) -{ - int i = 0, ret = 0; - - while (!ret && regs[i][0] != REGLIST_TAIL) { - if (regs[i][0] == REG_DLY) { - vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); - } else { - ret = write_reg(slv_addr, regs[i][0], regs[i][1]); - } - - i++; - } - - return ret; -} - -static int write_reg16(uint8_t slv_addr, const uint16_t reg, uint16_t value) -{ - if (write_reg(slv_addr, reg, value >> 8) || write_reg(slv_addr, reg + 1, value)) { - return -1; - } - - return 0; -} - -static int write_addr_reg(uint8_t slv_addr, const uint16_t reg, uint16_t x_value, uint16_t y_value) -{ - if (write_reg16(slv_addr, reg, x_value) || write_reg16(slv_addr, reg + 2, y_value)) { - return -1; - } - - return 0; -} - -#define write_reg_bits(slv_addr, reg, mask, enable) set_reg_bits(slv_addr, reg, 0, mask, enable?mask:0) - -static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sys_div, uint8_t pre_div, bool root_2x, uint8_t seld5, bool pclk_manual, uint8_t pclk_div) -{ - return -1; -} - -static int set_ae_level(sensor_t *sensor, int level); - -static int reset(sensor_t *sensor) -{ - - int ret = 0; - // Software Reset: clear all registers and reset them to their default values - ret = write_reg(sensor->slv_addr, SYSTEM_CTROL0, 0x01); - - if (ret) { - ESP_LOGE(TAG, "Software Reset FAILED!"); - return ret; - } - - vTaskDelay(100 / portTICK_PERIOD_MS); - ret = write_regs(sensor->slv_addr, sensor_default_regs); //re-initial - - if (ret == 0) { - ESP_LOGD(TAG, "Camera defaults loaded"); - ret = set_ae_level(sensor, 0); - vTaskDelay(100 / portTICK_PERIOD_MS); - } - - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - const uint16_t (*regs)[2]; - - switch (pixformat) { - case PIXFORMAT_YUV422: - regs = sensor_fmt_yuv422; - break; - - case PIXFORMAT_GRAYSCALE: - regs = sensor_fmt_grayscale; - break; - - case PIXFORMAT_RGB565: - case PIXFORMAT_RGB888: - regs = sensor_fmt_rgb565; - break; - - case PIXFORMAT_JPEG: - regs = sensor_fmt_jpeg; - break; - - case PIXFORMAT_RAW: - regs = sensor_fmt_raw; - break; - - default: - ESP_LOGE(TAG, "Unsupported pixformat: %u", pixformat); - return -1; - } - - ret = write_regs(sensor->slv_addr, regs); - - if (ret == 0) { - sensor->pixformat = pixformat; - ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); - } - - return ret; -} - -static int set_image_options(sensor_t *sensor) -{ - int ret = 0; - uint8_t reg20 = 0; - uint8_t reg21 = 0; - uint8_t reg4514 = 0; - uint8_t reg4514_test = 0; - - // V-Flip - if (sensor->status.vflip) { - reg20 |= 0x01; - reg4514_test |= 1; - } - - // H-Mirror - if (sensor->status.hmirror) { - reg21 |= 0x02; - reg4514_test |= 2; - } - - switch (reg4514_test) { - - } - - if (write_reg(sensor->slv_addr, TIMING_TC_REG20, reg20 | reg21)) { - ESP_LOGE(TAG, "Setting Image Options Failed"); - ret = -1; - } - - ESP_LOGD(TAG, "Set Image Options: Compression: %u, Binning: %u, V-Flip: %u, H-Mirror: %u, Reg-4514: 0x%02x", - sensor->pixformat == PIXFORMAT_JPEG, sensor->status.binning, sensor->status.vflip, sensor->status.hmirror, reg4514); - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret = 0; - - sensor->status.framesize = framesize; - ret = write_regs(sensor->slv_addr, sensor_default_regs); - - if (framesize == FRAMESIZE_QVGA) { - ESP_LOGD(TAG, "Set FRAMESIZE_QVGA"); - ret = write_regs(sensor->slv_addr, sensor_framesize_QVGA); -#if CONFIG_NT99141_SUPPORT_XSKIP - ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: xskip mode"); - ret = write_regs(sensor->slv_addr, sensor_framesize_QVGA_xskip); -#elif CONFIG_NT99141_SUPPORT_CROP - ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: crop mode"); - ret = write_regs(sensor->slv_addr, sensor_framesize_QVGA_crop); -#endif - } else if (framesize == FRAMESIZE_VGA) { - ESP_LOGD(TAG, "Set FRAMESIZE_VGA"); - // ret = write_regs(sensor->slv_addr, sensor_framesize_VGA); - ret = write_regs(sensor->slv_addr, sensor_framesize_VGA_xyskip);// Resolution:640*360 This configuration is equally-scaled without deforming -#ifdef CONFIG_NT99141_SUPPORT_XSKIP - ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: xskip mode"); - ret = write_regs(sensor->slv_addr, sensor_framesize_VGA_xskip); -#elif CONFIG_NT99141_SUPPORT_CROP - ESP_LOGD(TAG, "Set FRAMESIZE_QVGA: crop mode"); - ret = write_regs(sensor->slv_addr, sensor_framesize_VGA_crop); -#endif - } else if (framesize >= FRAMESIZE_HD) { - ESP_LOGD(TAG, "Set FRAMESIZE_HD"); - ret = write_regs(sensor->slv_addr, sensor_framesize_HD); - } else { - ESP_LOGD(TAG, "Dont suppost this size, Set FRAMESIZE_VGA"); - ret = write_regs(sensor->slv_addr, sensor_framesize_VGA); - } - - return ret; -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.hmirror = enable; - ret = set_image_options(sensor); - - if (ret == 0) { - ESP_LOGD(TAG, "Set h-mirror to: %d", enable); - } - - return ret; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = set_image_options(sensor); - - if (ret == 0) { - ESP_LOGD(TAG, "Set v-flip to: %d", enable); - } - - return ret; -} - -static int set_quality(sensor_t *sensor, int qs) -{ - int ret = 0; - ret = write_reg(sensor->slv_addr, COMPRESSION_CTRL07, qs & 0x3f); - - if (ret == 0) { - sensor->status.quality = qs; - ESP_LOGD(TAG, "Set quality to: %d", qs); - } - - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR, enable); - - if (ret == 0) { - sensor->status.colorbar = enable; - ESP_LOGD(TAG, "Set colorbar to: %d", enable); - } - - return ret; -} - -static int set_gain_ctrl(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x32bb, 0x87, enable); - - if (ret == 0) { - ESP_LOGD(TAG, "Set gain_ctrl to: %d", enable); - sensor->status.agc = enable; - } - - return ret; -} - -static int set_exposure_ctrl(sensor_t *sensor, int enable) -{ - int ret = 0; - int data = 0; - // ret = write_reg_bits(sensor->slv_addr, 0x32bb, 0x87, enable); - data = read_reg(sensor->slv_addr, 0x3201); - ESP_LOGD(TAG, "set_exposure_ctrl:enable"); - if (enable) { - ESP_LOGD(TAG, "set_exposure_ctrl:enable"); - ret = write_reg(sensor->slv_addr, 0x3201, (1 << 5) | data); - } else { - ESP_LOGD(TAG, "set_exposure_ctrl:disable"); - ret = write_reg(sensor->slv_addr, 0x3201, (~(1 << 5)) & data); - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set exposure_ctrl to: %d", enable); - sensor->status.aec = enable; - } - - return ret; -} - -static int set_whitebal(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set awb to: %d", enable); - sensor->status.awb = enable; - } - - return ret; -} - -//Advanced AWB -static int set_dcw_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set dcw to: %d", enable); - sensor->status.dcw = enable; - } - - return ret; -} - -//night mode enable -static int set_aec2(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set aec2 to: %d", enable); - sensor->status.aec2 = enable; - } - - return ret; -} - -static int set_bpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set bpc to: %d", enable); - sensor->status.bpc = enable; - } - - return ret; -} - -static int set_wpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set wpc to: %d", enable); - sensor->status.wpc = enable; - } - - return ret; -} - -//Gamma enable -static int set_raw_gma_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set raw_gma to: %d", enable); - sensor->status.raw_gma = enable; - } - - return ret; -} - -static int set_lenc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - - if (ret == 0) { - ESP_LOGD(TAG, "Set lenc to: %d", enable); - sensor->status.lenc = enable; - } - - return ret; -} - -static int get_agc_gain(sensor_t *sensor) -{ - ESP_LOGD(TAG, "get_agc_gain can not be configured at present"); - return 0; -} - -//real gain -static int set_agc_gain(sensor_t *sensor, int gain) -{ - ESP_LOGD(TAG, "set_agc_gain can not be configured at present"); - // ESP_LOGD(TAG, "GAIN = %d\n", gain); - int cnt = gain / 2; - - switch (cnt) { - case 0: - ESP_LOGD(TAG, "set_agc_gain: 1x"); - write_reg(sensor->slv_addr, 0X301D, 0X00); - break; - - case 1: - ESP_LOGD(TAG,"set_agc_gain: 2x"); - write_reg(sensor->slv_addr, 0X301D, 0X0F); - break; - - case 2: - ESP_LOGD(TAG,"set_agc_gain: 4x"); - write_reg(sensor->slv_addr, 0X301D, 0X2F); - break; - - case 3: - ESP_LOGD(TAG,"set_agc_gain: 6x"); - write_reg(sensor->slv_addr, 0X301D, 0X37); - break; - - case 4: - ESP_LOGD(TAG,"set_agc_gain: 8x"); - write_reg(sensor->slv_addr, 0X301D, 0X3F); - break; - - default: - ESP_LOGD(TAG,"fail set_agc_gain"); - break; - } - - return 0; -} - -static int get_aec_value(sensor_t *sensor) -{ - ESP_LOGD(TAG, "get_aec_value can not be configured at present"); - return 0; -} - -static int set_aec_value(sensor_t *sensor, int value) -{ - ESP_LOGD(TAG, "set_aec_value can not be configured at present"); - int ret = 0; - // ESP_LOGD(TAG, " set_aec_value to: %d", value); - ret = write_reg_bits(sensor->slv_addr, 0x3012, 0x00, (value >> 8) & 0xff); - ret = write_reg_bits(sensor->slv_addr, 0x3013, 0x01, value & 0xff); - - if (ret == 0) { - ESP_LOGD(TAG, " set_aec_value to: %d", value); - // sensor->status.aec = enable; - } - - return ret; -} - -static int set_ae_level(sensor_t *sensor, int level) -{ - ESP_LOGD(TAG, "set_ae_level can not be configured at present"); - int ret = 0; - - if (level < 0) { - level = 0; - } else if (level > 9) { - level = 9; - } - - for (int i = 0; i < 5; i++) { - ret += write_reg(sensor->slv_addr, sensor_ae_level[ 5 * level + i ][0], sensor_ae_level[5 * level + i ][1]); - } - - if (ret) { - ESP_LOGE(TAG, " fail to set ae level: %d", ret); - } - - return 0; -} - -static int set_wb_mode(sensor_t *sensor, int mode) -{ - int ret = 0; - - if (mode < 0 || mode > 4) { - return -1; - } - - ret = write_reg(sensor->slv_addr, 0x3201, (mode != 0)); - - if (ret) { - return ret; - } - - switch (mode) { - case 1://Sunny - ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) - || write_reg16(sensor->slv_addr, 0x3291, 0x38) - || write_reg16(sensor->slv_addr, 0x3296, 0x01) - || write_reg16(sensor->slv_addr, 0x3297, 0x68) - || write_reg16(sensor->slv_addr, 0x3060, 0x01); - - break; - - case 2://Cloudy - - ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) - || write_reg16(sensor->slv_addr, 0x3291, 0x51) - || write_reg16(sensor->slv_addr, 0x3296, 0x01) - || write_reg16(sensor->slv_addr, 0x3297, 0x00) - || write_reg16(sensor->slv_addr, 0x3060, 0x01); - break; - - case 3://INCANDESCENCE] - ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) - || write_reg16(sensor->slv_addr, 0x3291, 0x30) - || write_reg16(sensor->slv_addr, 0x3296, 0x01) - || write_reg16(sensor->slv_addr, 0x3297, 0xCB) - || write_reg16(sensor->slv_addr, 0x3060, 0x01); - break; - - case 4://FLUORESCENT - ret = write_reg16(sensor->slv_addr, 0x3290, 0x01) - || write_reg16(sensor->slv_addr, 0x3291, 0x70) - || write_reg16(sensor->slv_addr, 0x3296, 0x01) - || write_reg16(sensor->slv_addr, 0x3297, 0xFF) - || write_reg16(sensor->slv_addr, 0x3060, 0x01); - break; - - default://AUTO - break; - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set wb_mode to: %d", mode); - sensor->status.wb_mode = mode; - } - - return ret; -} - -static int set_awb_gain_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - int old_mode = sensor->status.wb_mode; - int mode = enable ? old_mode : 0; - - ret = set_wb_mode(sensor, mode); - - if (ret == 0) { - sensor->status.wb_mode = old_mode; - ESP_LOGD(TAG, "Set awb_gain to: %d", enable); - sensor->status.awb_gain = enable; - } - - return ret; -} - -static int set_special_effect(sensor_t *sensor, int effect) -{ - int ret = 0; - - if (effect < 0 || effect > 6) { - return -1; - } - - uint8_t *regs = (uint8_t *)sensor_special_effects[effect]; - ret = write_reg(sensor->slv_addr, 0x32F1, regs[0]) - || write_reg(sensor->slv_addr, 0x32F4, regs[1]) - || write_reg(sensor->slv_addr, 0x32F5, regs[2]) - || write_reg(sensor->slv_addr, 0x3060, regs[3]); - - if (ret == 0) { - ESP_LOGD(TAG, "Set special_effect to: %d", effect); - sensor->status.special_effect = effect; - } - - return ret; -} - -static int set_brightness(sensor_t *sensor, int level) -{ - int ret = 0; - uint8_t value = 0; - - switch (level) { - case 3: - value = 0xA0; - break; - - case 2: - value = 0x90; - break; - - case 1: - value = 0x88; - break; - - case -1: - value = 0x78; - break; - - case -2: - value = 0x70; - break; - - case -3: - value = 0x60; - break; - - default: // 0 - break; - } - - ret = write_reg(sensor->slv_addr, 0x32F2, value); - - if (ret == 0) { - ESP_LOGD(TAG, "Set brightness to: %d", level); - sensor->status.brightness = level; - } - - return ret; -} - -static int set_contrast(sensor_t *sensor, int level) -{ - int ret = 0; - uint8_t value1 = 0, value2 = 0 ; - - switch (level) { - case 3: - value1 = 0xD0; - value2 = 0xB0; - break; - - case 2: - value1 = 0xE0; - value2 = 0xA0; - break; - - case 1: - value1 = 0xF0; - value2 = 0x90; - break; - - case 0: - value1 = 0x00; - value2 = 0x80; - break; - - case -1: - value1 = 0x10; - value2 = 0x70; - break; - - case -2: - value1 = 0x20; - value2 = 0x60; - break; - - case -3: - value1 = 0x30; - value2 = 0x50; - break; - - default: // 0 - break; - } - - ret = write_reg(sensor->slv_addr, 0x32FC, value1); - ret = write_reg(sensor->slv_addr, 0x32F2, value2); - ret = write_reg(sensor->slv_addr, 0x3060, 0x01); - - if (ret == 0) { - ESP_LOGD(TAG, "Set contrast to: %d", level); - sensor->status.contrast = level; - } - - return ret; -} - -static int set_saturation(sensor_t *sensor, int level) -{ - int ret = 0; - - if (level > 4 || level < -4) { - return -1; - } - - uint8_t *regs = (uint8_t *)sensor_saturation_levels[level + 4]; - { - ret = write_reg(sensor->slv_addr, 0x32F3, regs[0]); - - if (ret) { - return ret; - } - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set saturation to: %d", level); - sensor->status.saturation = level; - } - - return ret; -} - -static int set_sharpness(sensor_t *sensor, int level) -{ - int ret = 0; - - if (level > 3 || level < -3) { - return -1; - } - - uint8_t mt_offset_2 = (level + 3) * 8; - uint8_t mt_offset_1 = mt_offset_2 + 1; - - ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x40, false)//0x40 means auto - || write_reg(sensor->slv_addr, 0x5300, 0x10) - || write_reg(sensor->slv_addr, 0x5301, 0x10) - || write_reg(sensor->slv_addr, 0x5302, mt_offset_1) - || write_reg(sensor->slv_addr, 0x5303, mt_offset_2) - || write_reg(sensor->slv_addr, 0x5309, 0x10) - || write_reg(sensor->slv_addr, 0x530a, 0x10) - || write_reg(sensor->slv_addr, 0x530b, 0x04) - || write_reg(sensor->slv_addr, 0x530c, 0x06); - - if (ret == 0) { - ESP_LOGD(TAG, "Set sharpness to: %d", level); - sensor->status.sharpness = level; - } - - return ret; -} - -static int set_gainceiling(sensor_t *sensor, gainceiling_t level) -{ - ESP_LOGD(TAG, "set_gainceiling can not be configured at present"); - return 0; -} - -static int get_denoise(sensor_t *sensor) -{ - - return (read_reg(sensor->slv_addr, 0x5306) / 4) + 1; -} - -static int set_denoise(sensor_t *sensor, int level) -{ - ESP_LOGD(TAG, "set_denoise can not be configured at present"); - return 0; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = 0, ret2 = 0; - - if (mask > 0xFF) { - ret = read_reg16(sensor->slv_addr, reg); - - if (ret >= 0 && mask > 0xFFFF) { - ret2 = read_reg(sensor->slv_addr, reg + 2); - - if (ret2 >= 0) { - ret = (ret << 8) | ret2 ; - } else { - ret = ret2; - } - } - } else { - ret = read_reg(sensor->slv_addr, reg); - } - - if (ret > 0) { - ret &= mask; - } - - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0, ret2 = 0; - - if (mask > 0xFF) { - ret = read_reg16(sensor->slv_addr, reg); - - if (ret >= 0 && mask > 0xFFFF) { - ret2 = read_reg(sensor->slv_addr, reg + 2); - - if (ret2 >= 0) { - ret = (ret << 8) | ret2 ; - } else { - ret = ret2; - } - } - } else { - ret = read_reg(sensor->slv_addr, reg); - } - - if (ret < 0) { - return ret; - } - - value = (ret & ~mask) | (value & mask); - - if (mask > 0xFFFF) { - ret = write_reg16(sensor->slv_addr, reg, value >> 8); - - if (ret >= 0) { - ret = write_reg(sensor->slv_addr, reg + 2, value & 0xFF); - } - } else if (mask > 0xFF) { - ret = write_reg16(sensor->slv_addr, reg, value); - } else { - ret = write_reg(sensor->slv_addr, reg, value); - } - - return ret; -} - -static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) -{ - int ret = 0; - ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, startX, startY) - || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, endX, endY) - || write_addr_reg(sensor->slv_addr, X_OFFSET_H, offsetX, offsetY) - || write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, totalX, totalY) - || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, outputX, outputY); - - if (!ret) { - sensor->status.scale = scale; - sensor->status.binning = binning; - ret = set_image_options(sensor); - } - - return ret; -} - -static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) -{ - return set_pll(sensor, bypass > 0, multiplier, sys_div, pre_div, root_2x > 0, seld5, pclk_manual > 0, pclk_div); -} - -static int set_xclk(sensor_t *sensor, int timer, int xclk) -{ - int ret = 0; - if (xclk > 10) - { - ESP_LOGE(TAG, "only XCLK under 10MHz is supported, and XCLK is now set to 10M"); - xclk = 10; - } - sensor->xclk_freq_hz = xclk * 1000000U; - ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); - return ret; -} - -int nt99141_detect(int slv_addr, sensor_id_t *id) -{ - if (NT99141_SCCB_ADDR == slv_addr) { - SCCB_Write16(slv_addr, 0x3008, 0x01);//bank sensor - uint16_t h = SCCB_Read16(slv_addr, 0x3000); - uint16_t l = SCCB_Read16(slv_addr, 0x3001); - uint16_t PID = (h<<8) | l; - if (NT99141_PID == PID) { - id->PID = PID; - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -static int init_status(sensor_t *sensor) -{ - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.sharpness = (read_reg(sensor->slv_addr, 0x3301)); - sensor->status.denoise = get_denoise(sensor); - sensor->status.ae_level = 0; - sensor->status.gainceiling = read_reg16(sensor->slv_addr, 0x32F0) & 0xFF; - sensor->status.awb = check_reg_mask(sensor->slv_addr, ISP_CONTROL_01, 0x10); - sensor->status.dcw = !check_reg_mask(sensor->slv_addr, 0x5183, 0x80); - sensor->status.agc = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN); - sensor->status.aec = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN); - sensor->status.hmirror = check_reg_mask(sensor->slv_addr, TIMING_TC_REG21, TIMING_TC_REG21_HMIRROR); - sensor->status.vflip = check_reg_mask(sensor->slv_addr, TIMING_TC_REG20, TIMING_TC_REG20_VFLIP); - sensor->status.colorbar = check_reg_mask(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR); - sensor->status.bpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x04); - sensor->status.wpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x02); - sensor->status.raw_gma = check_reg_mask(sensor->slv_addr, 0x5000, 0x20); - sensor->status.lenc = check_reg_mask(sensor->slv_addr, 0x5000, 0x80); - sensor->status.quality = read_reg(sensor->slv_addr, COMPRESSION_CTRL07) & 0x3f; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - sensor->status.awb_gain = check_reg_mask(sensor->slv_addr, 0x3000, 0x01); - sensor->status.agc_gain = get_agc_gain(sensor); - sensor->status.aec_value = get_aec_value(sensor); - sensor->status.aec2 = check_reg_mask(sensor->slv_addr, 0x3000, 0x04); - return 0; -} - -int nt99141_init(sensor_t *sensor) -{ - sensor->reset = reset; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_contrast; - sensor->set_brightness = set_brightness; - sensor->set_saturation = set_saturation; - sensor->set_sharpness = set_sharpness; - sensor->set_gainceiling = set_gainceiling; - sensor->set_quality = set_quality; - sensor->set_colorbar = set_colorbar; - sensor->set_gain_ctrl = set_gain_ctrl; - sensor->set_exposure_ctrl = set_exposure_ctrl; - sensor->set_whitebal = set_whitebal; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - sensor->init_status = init_status; - sensor->set_aec2 = set_aec2; - sensor->set_aec_value = set_aec_value; - sensor->set_special_effect = set_special_effect; - sensor->set_wb_mode = set_wb_mode; - sensor->set_ae_level = set_ae_level; - sensor->set_dcw = set_dcw_dsp; - sensor->set_bpc = set_bpc_dsp; - sensor->set_wpc = set_wpc_dsp; - sensor->set_awb_gain = set_awb_gain_dsp; - sensor->set_agc_gain = set_agc_gain; - sensor->set_raw_gma = set_raw_gma_dsp; - sensor->set_lenc = set_lenc_dsp; - sensor->set_denoise = set_denoise; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = set_res_raw; - sensor->set_pll = _set_pll; - sensor->set_xclk = set_xclk; - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov2640.c b/lib/libesp32_div/esp32-camera/sensors/ov2640.c deleted file mode 100644 index 7e3d77174..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/ov2640.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV2640 driver. - * - */ -#include -#include -#include -#include "sccb.h" -#include "xclk.h" -#include "ov2640.h" -#include "ov2640_regs.h" -#include "ov2640_settings.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char* TAG = "ov2640"; -#endif - -static volatile ov2640_bank_t reg_bank = BANK_MAX; -static int set_bank(sensor_t *sensor, ov2640_bank_t bank) -{ - int res = 0; - if (bank != reg_bank) { - reg_bank = bank; - res = SCCB_Write(sensor->slv_addr, BANK_SEL, bank); - } - return res; -} - -static int write_regs(sensor_t *sensor, const uint8_t (*regs)[2]) -{ - int i=0, res = 0; - while (regs[i][0]) { - if (regs[i][0] == BANK_SEL) { - res = set_bank(sensor, regs[i][1]); - } else { - res = SCCB_Write(sensor->slv_addr, regs[i][0], regs[i][1]); - } - if (res) { - return res; - } - i++; - } - return res; -} - -static int write_reg(sensor_t *sensor, ov2640_bank_t bank, uint8_t reg, uint8_t value) -{ - int ret = set_bank(sensor, bank); - if(!ret) { - ret = SCCB_Write(sensor->slv_addr, reg, value); - } - return ret; -} - -static int set_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - - ret = set_bank(sensor, bank); - if(ret) { - return ret; - } - c_value = SCCB_Read(sensor->slv_addr, reg); - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = SCCB_Write(sensor->slv_addr, reg, new_value); - return ret; -} - -static int read_reg(sensor_t *sensor, ov2640_bank_t bank, uint8_t reg) -{ - if(set_bank(sensor, bank)){ - return 0; - } - return SCCB_Read(sensor->slv_addr, reg); -} - -static uint8_t get_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t offset, uint8_t mask) -{ - return (read_reg(sensor, bank, reg) >> offset) & mask; -} - -static int write_reg_bits(sensor_t *sensor, uint8_t bank, uint8_t reg, uint8_t mask, int enable) -{ - return set_reg_bits(sensor, bank, reg, 0, mask, enable?mask:0); -} - -#define WRITE_REGS_OR_RETURN(regs) ret = write_regs(sensor, regs); if(ret){return ret;} -#define WRITE_REG_OR_RETURN(bank, reg, val) ret = write_reg(sensor, bank, reg, val); if(ret){return ret;} -#define SET_REG_BITS_OR_RETURN(bank, reg, offset, mask, val) ret = set_reg_bits(sensor, bank, reg, offset, mask, val); if(ret){return ret;} - -static int reset(sensor_t *sensor) -{ - int ret = 0; - WRITE_REG_OR_RETURN(BANK_SENSOR, COM7, COM7_SRST); - vTaskDelay(10 / portTICK_PERIOD_MS); - WRITE_REGS_OR_RETURN(ov2640_settings_cif); - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - sensor->pixformat = pixformat; - switch (pixformat) { - case PIXFORMAT_RGB565: - case PIXFORMAT_RGB888: - WRITE_REGS_OR_RETURN(ov2640_settings_rgb565); - break; - case PIXFORMAT_YUV422: - case PIXFORMAT_GRAYSCALE: - WRITE_REGS_OR_RETURN(ov2640_settings_yuv422); - break; - case PIXFORMAT_JPEG: - WRITE_REGS_OR_RETURN(ov2640_settings_jpeg3); - break; - default: - ret = -1; - break; - } - if(!ret) { - vTaskDelay(10 / portTICK_PERIOD_MS); - } - - return ret; -} - -static int set_window(sensor_t *sensor, ov2640_sensor_mode_t mode, int offset_x, int offset_y, int max_x, int max_y, int w, int h){ - int ret = 0; - const uint8_t (*regs)[2]; - ov2640_clk_t c; - c.reserved = 0; - - max_x /= 4; - max_y /= 4; - w /= 4; - h /= 4; - uint8_t win_regs[][2] = { - {BANK_SEL, BANK_DSP}, - {HSIZE, max_x & 0xFF}, - {VSIZE, max_y & 0xFF}, - {XOFFL, offset_x & 0xFF}, - {YOFFL, offset_y & 0xFF}, - {VHYX, ((max_y >> 1) & 0X80) | ((offset_y >> 4) & 0X70) | ((max_x >> 5) & 0X08) | ((offset_x >> 8) & 0X07)}, - {TEST, (max_x >> 2) & 0X80}, - {ZMOW, (w)&0xFF}, - {ZMOH, (h)&0xFF}, - {ZMHH, ((h>>6)&0x04)|((w>>8)&0x03)}, - {0, 0} - }; - - if (sensor->pixformat == PIXFORMAT_JPEG) { - c.clk_2x = 0; - c.clk_div = 0; - c.pclk_auto = 0; - c.pclk_div = 8; - if(mode == OV2640_MODE_UXGA) { - c.pclk_div = 12; - } - // if (sensor->xclk_freq_hz == 16000000) { - // c.pclk_div = c.pclk_div / 2; - // } - } else { -#if CONFIG_IDF_TARGET_ESP32 - c.clk_2x = 0; -#else - c.clk_2x = 1; -#endif - c.clk_div = 7; - c.pclk_auto = 1; - c.pclk_div = 8; - if (mode == OV2640_MODE_CIF) { - c.clk_div = 3; - } else if(mode == OV2640_MODE_UXGA) { - c.pclk_div = 12; - } - } - ESP_LOGI(TAG, "Set PLL: clk_2x: %u, clk_div: %u, pclk_auto: %u, pclk_div: %u", c.clk_2x, c.clk_div, c.pclk_auto, c.pclk_div); - - if (mode == OV2640_MODE_CIF) { - regs = ov2640_settings_to_cif; - } else if (mode == OV2640_MODE_SVGA) { - regs = ov2640_settings_to_svga; - } else { - regs = ov2640_settings_to_uxga; - } - - WRITE_REG_OR_RETURN(BANK_DSP, R_BYPASS, R_BYPASS_DSP_BYPAS); - WRITE_REGS_OR_RETURN(regs); - WRITE_REGS_OR_RETURN(win_regs); - WRITE_REG_OR_RETURN(BANK_SENSOR, CLKRC, c.clk); - WRITE_REG_OR_RETURN(BANK_DSP, R_DVP_SP, c.pclk); - WRITE_REG_OR_RETURN(BANK_DSP, R_BYPASS, R_BYPASS_DSP_EN); - - vTaskDelay(10 / portTICK_PERIOD_MS); - //required when changing resolution - set_pixformat(sensor, sensor->pixformat); - - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret = 0; - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - aspect_ratio_t ratio = resolution[framesize].aspect_ratio; - uint16_t max_x = ratio_table[ratio].max_x; - uint16_t max_y = ratio_table[ratio].max_y; - uint16_t offset_x = ratio_table[ratio].offset_x; - uint16_t offset_y = ratio_table[ratio].offset_y; - ov2640_sensor_mode_t mode = OV2640_MODE_UXGA; - - sensor->status.framesize = framesize; - - - - if (framesize <= FRAMESIZE_CIF) { - mode = OV2640_MODE_CIF; - max_x /= 4; - max_y /= 4; - offset_x /= 4; - offset_y /= 4; - if(max_y > 296){ - max_y = 296; - } - } else if (framesize <= FRAMESIZE_SVGA) { - mode = OV2640_MODE_SVGA; - max_x /= 2; - max_y /= 2; - offset_x /= 2; - offset_y /= 2; - } - - ret = set_window(sensor, mode, offset_x, offset_y, max_x, max_y, w, h); - return ret; -} - -static int set_contrast(sensor_t *sensor, int level) -{ - int ret=0; - level += 3; - if (level <= 0 || level > NUM_CONTRAST_LEVELS) { - return -1; - } - sensor->status.contrast = level-3; - for (int i=0; i<7; i++) { - WRITE_REG_OR_RETURN(BANK_DSP, contrast_regs[0][i], contrast_regs[level][i]); - } - return ret; -} - -static int set_brightness(sensor_t *sensor, int level) -{ - int ret=0; - level += 3; - if (level <= 0 || level > NUM_BRIGHTNESS_LEVELS) { - return -1; - } - sensor->status.brightness = level-3; - for (int i=0; i<5; i++) { - WRITE_REG_OR_RETURN(BANK_DSP, brightness_regs[0][i], brightness_regs[level][i]); - } - return ret; -} - -static int set_saturation(sensor_t *sensor, int level) -{ - int ret=0; - level += 3; - if (level <= 0 || level > NUM_SATURATION_LEVELS) { - return -1; - } - sensor->status.saturation = level-3; - for (int i=0; i<5; i++) { - WRITE_REG_OR_RETURN(BANK_DSP, saturation_regs[0][i], saturation_regs[level][i]); - } - return ret; -} - -static int set_special_effect(sensor_t *sensor, int effect) -{ - int ret=0; - effect++; - if (effect <= 0 || effect > NUM_SPECIAL_EFFECTS) { - return -1; - } - sensor->status.special_effect = effect-1; - for (int i=0; i<5; i++) { - WRITE_REG_OR_RETURN(BANK_DSP, special_effects_regs[0][i], special_effects_regs[effect][i]); - } - return ret; -} - -static int set_wb_mode(sensor_t *sensor, int mode) -{ - int ret=0; - if (mode < 0 || mode > NUM_WB_MODES) { - return -1; - } - sensor->status.wb_mode = mode; - SET_REG_BITS_OR_RETURN(BANK_DSP, 0XC7, 6, 1, mode?1:0); - if(mode) { - for (int i=0; i<3; i++) { - WRITE_REG_OR_RETURN(BANK_DSP, wb_modes_regs[0][i], wb_modes_regs[mode][i]); - } - } - return ret; -} - -static int set_ae_level(sensor_t *sensor, int level) -{ - int ret=0; - level += 3; - if (level <= 0 || level > NUM_AE_LEVELS) { - return -1; - } - sensor->status.ae_level = level-3; - for (int i=0; i<3; i++) { - WRITE_REG_OR_RETURN(BANK_SENSOR, ae_levels_regs[0][i], ae_levels_regs[level][i]); - } - return ret; -} - -static int set_quality(sensor_t *sensor, int quality) -{ - if(quality < 0) { - quality = 0; - } else if(quality > 63) { - quality = 63; - } - sensor->status.quality = quality; - return write_reg(sensor, BANK_DSP, QS, quality); -} - -static int set_agc_gain(sensor_t *sensor, int gain) -{ - if(gain < 0) { - gain = 0; - } else if(gain > 30) { - gain = 30; - } - sensor->status.agc_gain = gain; - return write_reg(sensor, BANK_SENSOR, GAIN, agc_gain_tbl[gain]); -} - -static int set_gainceiling_sensor(sensor_t *sensor, gainceiling_t gainceiling) -{ - sensor->status.gainceiling = gainceiling; - //return write_reg(sensor, BANK_SENSOR, COM9, COM9_AGC_SET(gainceiling)); - return set_reg_bits(sensor, BANK_SENSOR, COM9, 5, 7, gainceiling); -} - -static int set_aec_value(sensor_t *sensor, int value) -{ - if(value < 0) { - value = 0; - } else if(value > 1200) { - value = 1200; - } - sensor->status.aec_value = value; - return set_reg_bits(sensor, BANK_SENSOR, REG04, 0, 3, value & 0x3) - || write_reg(sensor, BANK_SENSOR, AEC, (value >> 2) & 0xFF) - || set_reg_bits(sensor, BANK_SENSOR, REG45, 0, 0x3F, value >> 10); -} - -static int set_aec2(sensor_t *sensor, int enable) -{ - sensor->status.aec2 = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL0, 6, 1, enable?0:1); -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - sensor->status.colorbar = enable; - return write_reg_bits(sensor, BANK_SENSOR, COM7, COM7_COLOR_BAR, enable?1:0); -} - -static int set_agc_sensor(sensor_t *sensor, int enable) -{ - sensor->status.agc = enable; - return write_reg_bits(sensor, BANK_SENSOR, COM8, COM8_AGC_EN, enable?1:0); -} - -static int set_aec_sensor(sensor_t *sensor, int enable) -{ - sensor->status.aec = enable; - return write_reg_bits(sensor, BANK_SENSOR, COM8, COM8_AEC_EN, enable?1:0); -} - -static int set_hmirror_sensor(sensor_t *sensor, int enable) -{ - sensor->status.hmirror = enable; - return write_reg_bits(sensor, BANK_SENSOR, REG04, REG04_HFLIP_IMG, enable?1:0); -} - -static int set_vflip_sensor(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = write_reg_bits(sensor, BANK_SENSOR, REG04, REG04_VREF_EN, enable?1:0); - return ret & write_reg_bits(sensor, BANK_SENSOR, REG04, REG04_VFLIP_IMG, enable?1:0); -} - -static int set_raw_gma_dsp(sensor_t *sensor, int enable) -{ - sensor->status.raw_gma = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL1, 5, 1, enable?1:0); -} - -static int set_awb_dsp(sensor_t *sensor, int enable) -{ - sensor->status.awb = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL1, 3, 1, enable?1:0); -} - -static int set_awb_gain_dsp(sensor_t *sensor, int enable) -{ - sensor->status.awb_gain = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL1, 2, 1, enable?1:0); -} - -static int set_lenc_dsp(sensor_t *sensor, int enable) -{ - sensor->status.lenc = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL1, 1, 1, enable?1:0); -} - -static int set_dcw_dsp(sensor_t *sensor, int enable) -{ - sensor->status.dcw = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL2, 5, 1, enable?1:0); -} - -static int set_bpc_dsp(sensor_t *sensor, int enable) -{ - sensor->status.bpc = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL3, 7, 1, enable?1:0); -} - -static int set_wpc_dsp(sensor_t *sensor, int enable) -{ - sensor->status.wpc = enable; - return set_reg_bits(sensor, BANK_DSP, CTRL3, 6, 1, enable?1:0); -} - -//unsupported -static int set_sharpness(sensor_t *sensor, int level) -{ - return -1; -} - -static int set_denoise(sensor_t *sensor, int level) -{ - return -1; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = read_reg(sensor, (reg >> 8) & 0x01, reg & 0xFF); - if(ret > 0){ - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0; - ret = read_reg(sensor, (reg >> 8) & 0x01, reg & 0xFF); - if(ret < 0){ - return ret; - } - value = (ret & ~mask) | (value & mask); - ret = write_reg(sensor, (reg >> 8) & 0x01, reg & 0xFF, value); - return ret; -} - -static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) -{ - return set_window(sensor, (ov2640_sensor_mode_t)startX, offsetX, offsetY, totalX, totalY, outputX, outputY); -} - -static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) -{ - return -1; -} - -static int set_xclk(sensor_t *sensor, int timer, int xclk) -{ - int ret = 0; - sensor->xclk_freq_hz = xclk * 1000000U; - ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); - return ret; -} - -static int init_status(sensor_t *sensor){ - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.ae_level = 0; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - - sensor->status.agc_gain = 30; - int agc_gain = read_reg(sensor, BANK_SENSOR, GAIN); - for (int i=0; i<30; i++){ - if(agc_gain >= agc_gain_tbl[i] && agc_gain < agc_gain_tbl[i+1]){ - sensor->status.agc_gain = i; - break; - } - } - - sensor->status.aec_value = ((uint16_t)get_reg_bits(sensor, BANK_SENSOR, REG45, 0, 0x3F) << 10) - | ((uint16_t)read_reg(sensor, BANK_SENSOR, AEC) << 2) - | get_reg_bits(sensor, BANK_SENSOR, REG04, 0, 3);//0 - 1200 - sensor->status.quality = read_reg(sensor, BANK_DSP, QS); - sensor->status.gainceiling = get_reg_bits(sensor, BANK_SENSOR, COM9, 5, 7); - - sensor->status.awb = get_reg_bits(sensor, BANK_DSP, CTRL1, 3, 1); - sensor->status.awb_gain = get_reg_bits(sensor, BANK_DSP, CTRL1, 2, 1); - sensor->status.aec = get_reg_bits(sensor, BANK_SENSOR, COM8, 0, 1); - sensor->status.aec2 = get_reg_bits(sensor, BANK_DSP, CTRL0, 6, 1); - sensor->status.agc = get_reg_bits(sensor, BANK_SENSOR, COM8, 2, 1); - sensor->status.bpc = get_reg_bits(sensor, BANK_DSP, CTRL3, 7, 1); - sensor->status.wpc = get_reg_bits(sensor, BANK_DSP, CTRL3, 6, 1); - sensor->status.raw_gma = get_reg_bits(sensor, BANK_DSP, CTRL1, 5, 1); - sensor->status.lenc = get_reg_bits(sensor, BANK_DSP, CTRL1, 1, 1); - sensor->status.hmirror = get_reg_bits(sensor, BANK_SENSOR, REG04, 7, 1); - sensor->status.vflip = get_reg_bits(sensor, BANK_SENSOR, REG04, 6, 1); - sensor->status.dcw = get_reg_bits(sensor, BANK_DSP, CTRL2, 5, 1); - sensor->status.colorbar = get_reg_bits(sensor, BANK_SENSOR, COM7, 1, 1); - - sensor->status.sharpness = 0;//not supported - sensor->status.denoise = 0; - return 0; -} - -int ov2640_detect(int slv_addr, sensor_id_t *id) -{ - if (OV2640_SCCB_ADDR == slv_addr) { - SCCB_Write(slv_addr, 0xFF, 0x01);//bank sensor - uint16_t PID = SCCB_Read(slv_addr, 0x0A); - if (OV2640_PID == PID) { - id->PID = PID; - id->VER = SCCB_Read(slv_addr, REG_VER); - id->MIDL = SCCB_Read(slv_addr, REG_MIDL); - id->MIDH = SCCB_Read(slv_addr, REG_MIDH); - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int ov2640_init(sensor_t *sensor) -{ - sensor->reset = reset; - sensor->init_status = init_status; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_contrast; - sensor->set_brightness= set_brightness; - sensor->set_saturation= set_saturation; - - sensor->set_quality = set_quality; - sensor->set_colorbar = set_colorbar; - - sensor->set_gainceiling = set_gainceiling_sensor; - sensor->set_gain_ctrl = set_agc_sensor; - sensor->set_exposure_ctrl = set_aec_sensor; - sensor->set_hmirror = set_hmirror_sensor; - sensor->set_vflip = set_vflip_sensor; - - sensor->set_whitebal = set_awb_dsp; - sensor->set_aec2 = set_aec2; - sensor->set_aec_value = set_aec_value; - sensor->set_special_effect = set_special_effect; - sensor->set_wb_mode = set_wb_mode; - sensor->set_ae_level = set_ae_level; - - sensor->set_dcw = set_dcw_dsp; - sensor->set_bpc = set_bpc_dsp; - sensor->set_wpc = set_wpc_dsp; - sensor->set_awb_gain = set_awb_gain_dsp; - sensor->set_agc_gain = set_agc_gain; - - sensor->set_raw_gma = set_raw_gma_dsp; - sensor->set_lenc = set_lenc_dsp; - - //not supported - sensor->set_sharpness = set_sharpness; - sensor->set_denoise = set_denoise; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = set_res_raw; - sensor->set_pll = _set_pll; - sensor->set_xclk = set_xclk; - ESP_LOGD(TAG, "OV2640 Attached"); - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov3660.c b/lib/libesp32_div/esp32-camera/sensors/ov3660.c deleted file mode 100644 index b9ebdba3b..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/ov3660.c +++ /dev/null @@ -1,1053 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV3660 driver. - * - */ -#include -#include -#include -#include "sccb.h" -#include "xclk.h" -#include "ov3660.h" -#include "ov3660_regs.h" -#include "ov3660_settings.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char *TAG = "ov3660"; -#endif - -//#define REG_DEBUG_ON - -static int read_reg(uint8_t slv_addr, const uint16_t reg){ - int ret = SCCB_Read16(slv_addr, reg); -#ifdef REG_DEBUG_ON - if (ret < 0) { - ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask){ - return (read_reg(slv_addr, reg) & mask) == mask; -} - -static int read_reg16(uint8_t slv_addr, const uint16_t reg){ - int ret = 0, ret2 = 0; - ret = read_reg(slv_addr, reg); - if (ret >= 0) { - ret = (ret & 0xFF) << 8; - ret2 = read_reg(slv_addr, reg+1); - if (ret2 < 0) { - ret = ret2; - } else { - ret |= ret2 & 0xFF; - } - } - return ret; -} - - -static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value){ - int ret = 0; -#ifndef REG_DEBUG_ON - ret = SCCB_Write16(slv_addr, reg, value); -#else - int old_value = read_reg(slv_addr, reg); - if (old_value < 0) { - return old_value; - } - if ((uint8_t)old_value != value) { - ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); - ret = SCCB_Write16(slv_addr, reg, value); - } else { - ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); - ret = SCCB_Write16(slv_addr, reg, value);//maybe not? - } - if (ret < 0) { - ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - ret = read_reg(slv_addr, reg); - if(ret < 0) { - return ret; - } - c_value = ret; - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = write_reg(slv_addr, reg, new_value); - return ret; -} - -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) -{ - int i = 0, ret = 0; - while (!ret && regs[i][0] != REGLIST_TAIL) { - if (regs[i][0] == REG_DLY) { - vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); - } else { - ret = write_reg(slv_addr, regs[i][0], regs[i][1]); - } - i++; - } - return ret; -} - -static int write_reg16(uint8_t slv_addr, const uint16_t reg, uint16_t value) -{ - if (write_reg(slv_addr, reg, value >> 8) || write_reg(slv_addr, reg + 1, value)) { - return -1; - } - return 0; -} - -static int write_addr_reg(uint8_t slv_addr, const uint16_t reg, uint16_t x_value, uint16_t y_value) -{ - if (write_reg16(slv_addr, reg, x_value) || write_reg16(slv_addr, reg + 2, y_value)) { - return -1; - } - return 0; -} - -#define write_reg_bits(slv_addr, reg, mask, enable) set_reg_bits(slv_addr, reg, 0, mask, enable?mask:0) - -static int calc_sysclk(int xclk, bool pll_bypass, int pll_multiplier, int pll_sys_div, int pll_pre_div, bool pll_root_2x, int pll_seld5, bool pclk_manual, int pclk_div) -{ - const int pll_pre_div2x_map[] = { 2, 3, 4, 6 };//values are multiplied by two to avoid floats - const int pll_seld52x_map[] = { 2, 2, 4, 5 }; - - if(!pll_sys_div) { - pll_sys_div = 1; - } - - int pll_pre_div2x = pll_pre_div2x_map[pll_pre_div]; - int pll_root_div = pll_root_2x?2:1; - int pll_seld52x = pll_seld52x_map[pll_seld5]; - - int VCO = (xclk / 1000) * pll_multiplier * pll_root_div * 2 / pll_pre_div2x; - int PLLCLK = pll_bypass?(xclk):(VCO * 1000 * 2 / pll_sys_div / pll_seld52x); - int PCLK = PLLCLK / 2 / ((pclk_manual && pclk_div)?pclk_div:1); - int SYSCLK = PLLCLK / 4; - - ESP_LOGI(TAG, "Calculated VCO: %d Hz, PLLCLK: %d Hz, SYSCLK: %d Hz, PCLK: %d Hz", VCO*1000, PLLCLK, SYSCLK, PCLK); - return SYSCLK; -} - -static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sys_div, uint8_t pre_div, bool root_2x, uint8_t seld5, bool pclk_manual, uint8_t pclk_div){ - int ret = 0; - if(multiplier > 31 || sys_div > 15 || pre_div > 3 || pclk_div > 31 || seld5 > 3){ - ESP_LOGE(TAG, "Invalid arguments"); - return -1; - } - - calc_sysclk(sensor->xclk_freq_hz, bypass, multiplier, sys_div, pre_div, root_2x, seld5, pclk_manual, pclk_div); - - ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL0, bypass?0x80:0x00); - if (ret == 0) { - ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL1, multiplier & 0x1f); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL2, 0x10 | (sys_div & 0x0f)); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, SC_PLLS_CTRL3, (pre_div & 0x3) << 4 | seld5 | (root_2x?0x40:0x00)); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, PCLK_RATIO, pclk_div & 0x1f); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, VFIFO_CTRL0C, pclk_manual?0x22:0x20); - } - if(ret){ - ESP_LOGE(TAG, "set_sensor_pll FAILED!"); - } - return ret; -} - -static int set_ae_level(sensor_t *sensor, int level); - -static int reset(sensor_t *sensor) -{ - int ret = 0; - // Software Reset: clear all registers and reset them to their default values - ret = write_reg(sensor->slv_addr, SYSTEM_CTROL0, 0x82); - if(ret){ - ESP_LOGE(TAG, "Software Reset FAILED!"); - return ret; - } - vTaskDelay(100 / portTICK_PERIOD_MS); - ret = write_regs(sensor->slv_addr, sensor_default_regs); - if (ret == 0) { - ESP_LOGD(TAG, "Camera defaults loaded"); - ret = set_ae_level(sensor, 0); - vTaskDelay(100 / portTICK_PERIOD_MS); - } - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - const uint16_t (*regs)[2]; - - switch (pixformat) { - case PIXFORMAT_YUV422: - regs = sensor_fmt_yuv422; - break; - - case PIXFORMAT_GRAYSCALE: - regs = sensor_fmt_grayscale; - break; - - case PIXFORMAT_RGB565: - case PIXFORMAT_RGB888: - regs = sensor_fmt_rgb565; - break; - - case PIXFORMAT_JPEG: - regs = sensor_fmt_jpeg; - break; - - case PIXFORMAT_RAW: - regs = sensor_fmt_raw; - break; - - default: - ESP_LOGE(TAG, "Unsupported pixformat: %u", pixformat); - return -1; - } - - ret = write_regs(sensor->slv_addr, regs); - if(ret == 0) { - sensor->pixformat = pixformat; - ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); - } - return ret; -} - -static int set_image_options(sensor_t *sensor) -{ - int ret = 0; - uint8_t reg20 = 0; - uint8_t reg21 = 0; - uint8_t reg4514 = 0; - uint8_t reg4514_test = 0; - - // compression - if (sensor->pixformat == PIXFORMAT_JPEG) { - reg21 |= 0x20; - } - - // binning - if (sensor->status.binning) { - reg20 |= 0x01; - reg21 |= 0x01; - reg4514_test |= 4; - } else { - reg20 |= 0x40; - } - - // V-Flip - if (sensor->status.vflip) { - reg20 |= 0x06; - reg4514_test |= 1; - } - - // H-Mirror - if (sensor->status.hmirror) { - reg21 |= 0x06; - reg4514_test |= 2; - } - - switch (reg4514_test) { - //no binning - case 0: reg4514 = 0x88; break;//normal - case 1: reg4514 = 0x88; break;//v-flip - case 2: reg4514 = 0xbb; break;//h-mirror - case 3: reg4514 = 0xbb; break;//v-flip+h-mirror - //binning - case 4: reg4514 = 0xaa; break;//normal - case 5: reg4514 = 0xbb; break;//v-flip - case 6: reg4514 = 0xbb; break;//h-mirror - case 7: reg4514 = 0xaa; break;//v-flip+h-mirror - } - - if(write_reg(sensor->slv_addr, TIMING_TC_REG20, reg20) - || write_reg(sensor->slv_addr, TIMING_TC_REG21, reg21) - || write_reg(sensor->slv_addr, 0x4514, reg4514)){ - ESP_LOGE(TAG, "Setting Image Options Failed"); - ret = -1; - } - - if (sensor->status.binning) { - ret = write_reg(sensor->slv_addr, 0x4520, 0x0b) - || write_reg(sensor->slv_addr, X_INCREMENT, 0x31)//odd:3, even: 1 - || write_reg(sensor->slv_addr, Y_INCREMENT, 0x31);//odd:3, even: 1 - } else { - ret = write_reg(sensor->slv_addr, 0x4520, 0xb0) - || write_reg(sensor->slv_addr, X_INCREMENT, 0x11)//odd:1, even: 1 - || write_reg(sensor->slv_addr, Y_INCREMENT, 0x11);//odd:1, even: 1 - } - - ESP_LOGD(TAG, "Set Image Options: Compression: %u, Binning: %u, V-Flip: %u, H-Mirror: %u, Reg-4514: 0x%02x", - sensor->pixformat == PIXFORMAT_JPEG, sensor->status.binning, sensor->status.vflip, sensor->status.hmirror, reg4514); - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret = 0; - - if(framesize > FRAMESIZE_QXGA){ - ESP_LOGW(TAG, "Invalid framesize: %u", framesize); - framesize = FRAMESIZE_QXGA; - } - framesize_t old_framesize = sensor->status.framesize; - sensor->status.framesize = framesize; - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - aspect_ratio_t ratio = resolution[sensor->status.framesize].aspect_ratio; - ratio_settings_t settings = ratio_table[ratio]; - - sensor->status.binning = (w <= (settings.max_width / 2) && h <= (settings.max_height / 2)); - sensor->status.scale = !((w == settings.max_width && h == settings.max_height) - || (w == (settings.max_width / 2) && h == (settings.max_height / 2))); - - ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, settings.start_x, settings.start_y) - || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, settings.end_x, settings.end_y) - || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, w, h); - - if (ret) { - goto fail; - } - - if (sensor->status.binning) { - ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x, (settings.total_y / 2) + 1) - || write_addr_reg(sensor->slv_addr, X_OFFSET_H, 8, 2); - } else { - ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x, settings.total_y) - || write_addr_reg(sensor->slv_addr, X_OFFSET_H, 16, 6); - } - - if (ret == 0) { - ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, sensor->status.scale); - } - - if (ret == 0) { - ret = set_image_options(sensor); - } - - if (ret) { - goto fail; - } - - if (sensor->pixformat == PIXFORMAT_JPEG) { - if (framesize == FRAMESIZE_QXGA || sensor->xclk_freq_hz == 16000000) { - //40MHz SYSCLK and 10MHz PCLK - ret = set_pll(sensor, false, 24, 1, 3, false, 0, true, 8); - } else { - //50MHz SYSCLK and 10MHz PCLK - ret = set_pll(sensor, false, 30, 1, 3, false, 0, true, 10); - } - } else { - //tuned for 16MHz XCLK and 8MHz PCLK - if (framesize > FRAMESIZE_HVGA) { - //8MHz SYSCLK and 8MHz PCLK (4.44 FPS) - ret = set_pll(sensor, false, 4, 1, 0, false, 2, true, 2); - } else if (framesize >= FRAMESIZE_QVGA) { - //16MHz SYSCLK and 8MHz PCLK (10.25 FPS) - ret = set_pll(sensor, false, 8, 1, 0, false, 2, true, 4); - } else { - //32MHz SYSCLK and 8MHz PCLK (17.77 FPS) - ret = set_pll(sensor, false, 8, 1, 0, false, 0, true, 8); - } - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); - } - return ret; - -fail: - sensor->status.framesize = old_framesize; - ESP_LOGE(TAG, "Setting framesize to: %ux%u failed", w, h); - return ret; -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.hmirror = enable; - ret = set_image_options(sensor); - if (ret == 0) { - ESP_LOGD(TAG, "Set h-mirror to: %d", enable); - } - return ret; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = set_image_options(sensor); - if (ret == 0) { - ESP_LOGD(TAG, "Set v-flip to: %d", enable); - } - return ret; -} - -static int set_quality(sensor_t *sensor, int qs) -{ - int ret = 0; - ret = write_reg(sensor->slv_addr, COMPRESSION_CTRL07, qs & 0x3f); - if (ret == 0) { - sensor->status.quality = qs; - ESP_LOGD(TAG, "Set quality to: %d", qs); - } - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR, enable); - if (ret == 0) { - sensor->status.colorbar = enable; - ESP_LOGD(TAG, "Set colorbar to: %d", enable); - } - return ret; -} - -static int set_gain_ctrl(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set gain_ctrl to: %d", enable); - sensor->status.agc = enable; - } - return ret; -} - -static int set_exposure_ctrl(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set exposure_ctrl to: %d", enable); - sensor->status.aec = enable; - } - return ret; -} - -static int set_whitebal(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x01, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set awb to: %d", enable); - sensor->status.awb = enable; - } - return ret; -} - -//Advanced AWB -static int set_dcw_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5183, 0x80, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set dcw to: %d", enable); - sensor->status.dcw = enable; - } - return ret; -} - -//night mode enable -static int set_aec2(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x3a00, 0x04, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set aec2 to: %d", enable); - sensor->status.aec2 = enable; - } - return ret; -} - -static int set_bpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x04, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set bpc to: %d", enable); - sensor->status.bpc = enable; - } - return ret; -} - -static int set_wpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x02, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set wpc to: %d", enable); - sensor->status.wpc = enable; - } - return ret; -} - -//Gamma enable -static int set_raw_gma_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x20, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set raw_gma to: %d", enable); - sensor->status.raw_gma = enable; - } - return ret; -} - -static int set_lenc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x80, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set lenc to: %d", enable); - sensor->status.lenc = enable; - } - return ret; -} - -static int get_agc_gain(sensor_t *sensor) -{ - int ra = read_reg(sensor->slv_addr, 0x350a); - if (ra < 0) { - return 0; - } - int rb = read_reg(sensor->slv_addr, 0x350b); - if (rb < 0) { - return 0; - } - int res = (rb & 0xF0) >> 4 | (ra & 0x03) << 4; - if (rb & 0x0F) { - res += 1; - } - return res; -} - -//real gain -static int set_agc_gain(sensor_t *sensor, int gain) -{ - int ret = 0; - if(gain < 0) { - gain = 0; - } else if(gain > 64) { - gain = 64; - } - - //gain value is 6.4 bits float - //in order to use the max range, we deduct 1/16 - int gainv = gain << 4; - if(gainv){ - gainv -= 1; - } - - ret = write_reg(sensor->slv_addr, 0x350a, gainv >> 8) || write_reg(sensor->slv_addr, 0x350b, gainv & 0xff); - if (ret == 0) { - ESP_LOGD(TAG, "Set agc_gain to: %d", gain); - sensor->status.agc_gain = gain; - } - return ret; -} - -static int get_aec_value(sensor_t *sensor) -{ - int ra = read_reg(sensor->slv_addr, 0x3500); - if (ra < 0) { - return 0; - } - int rb = read_reg(sensor->slv_addr, 0x3501); - if (rb < 0) { - return 0; - } - int rc = read_reg(sensor->slv_addr, 0x3502); - if (rc < 0) { - return 0; - } - int res = (ra & 0x0F) << 12 | (rb & 0xFF) << 4 | (rc & 0xF0) >> 4; - return res; -} - -static int set_aec_value(sensor_t *sensor, int value) -{ - int ret = 0, max_val = 0; - max_val = read_reg16(sensor->slv_addr, 0x380e); - if (max_val < 0) { - ESP_LOGE(TAG, "Could not read max aec_value"); - return -1; - } - if (value > max_val) { - value =max_val; - } - - ret = write_reg(sensor->slv_addr, 0x3500, (value >> 12) & 0x0F) - || write_reg(sensor->slv_addr, 0x3501, (value >> 4) & 0xFF) - || write_reg(sensor->slv_addr, 0x3502, (value << 4) & 0xF0); - - if (ret == 0) { - ESP_LOGD(TAG, "Set aec_value to: %d / %d", value, max_val); - sensor->status.aec_value = value; - } - return ret; -} - -static int set_ae_level(sensor_t *sensor, int level) -{ - int ret = 0; - if (level < -5 || level > 5) { - return -1; - } - //good targets are between 5 and 115 - int target_level = ((level + 5) * 10) + 5; - - int level_high, level_low; - int fast_high, fast_low; - - level_low = target_level * 23 / 25; //0.92 (0.46) - level_high = target_level * 27 / 25; //1.08 (2.08) - - fast_low = level_low >> 1; - fast_high = level_high << 1; - - if(fast_high>255) { - fast_high = 255; - } - - ret = write_reg(sensor->slv_addr, 0x3a0f, level_high) - || write_reg(sensor->slv_addr, 0x3a10, level_low) - || write_reg(sensor->slv_addr, 0x3a1b, level_high) - || write_reg(sensor->slv_addr, 0x3a1e, level_low) - || write_reg(sensor->slv_addr, 0x3a11, fast_high) - || write_reg(sensor->slv_addr, 0x3a1f, fast_low); - - if (ret == 0) { - ESP_LOGD(TAG, "Set ae_level to: %d", level); - sensor->status.ae_level = level; - } - return ret; -} - -static int set_wb_mode(sensor_t *sensor, int mode) -{ - int ret = 0; - if (mode < 0 || mode > 4) { - return -1; - } - - ret = write_reg(sensor->slv_addr, 0x3406, (mode != 0)); - if (ret) { - return ret; - } - switch (mode) { - case 1://Sunny - ret = write_reg16(sensor->slv_addr, 0x3400, 0x5e0) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x540);//AWB B GAIN - break; - case 2://Cloudy - ret = write_reg16(sensor->slv_addr, 0x3400, 0x650) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x4f0);//AWB B GAIN - break; - case 3://Office - ret = write_reg16(sensor->slv_addr, 0x3400, 0x520) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x660);//AWB B GAIN - break; - case 4://HOME - ret = write_reg16(sensor->slv_addr, 0x3400, 0x420) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x3f0) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x710);//AWB B GAIN - break; - default://AUTO - break; - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set wb_mode to: %d", mode); - sensor->status.wb_mode = mode; - } - return ret; -} - -static int set_awb_gain_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - int old_mode = sensor->status.wb_mode; - int mode = enable?old_mode:0; - - ret = set_wb_mode(sensor, mode); - - if (ret == 0) { - sensor->status.wb_mode = old_mode; - ESP_LOGD(TAG, "Set awb_gain to: %d", enable); - sensor->status.awb_gain = enable; - } - return ret; -} - -static int set_special_effect(sensor_t *sensor, int effect) -{ - int ret=0; - if (effect < 0 || effect > 6) { - return -1; - } - - uint8_t * regs = (uint8_t *)sensor_special_effects[effect]; - ret = write_reg(sensor->slv_addr, 0x5580, regs[0]) - || write_reg(sensor->slv_addr, 0x5583, regs[1]) - || write_reg(sensor->slv_addr, 0x5584, regs[2]) - || write_reg(sensor->slv_addr, 0x5003, regs[3]); - - if (ret == 0) { - ESP_LOGD(TAG, "Set special_effect to: %d", effect); - sensor->status.special_effect = effect; - } - return ret; -} - -static int set_brightness(sensor_t *sensor, int level) -{ - int ret = 0; - uint8_t value = 0; - bool negative = false; - - switch (level) { - case 3: - value = 0x30; - break; - case 2: - value = 0x20; - break; - case 1: - value = 0x10; - break; - case -1: - value = 0x10; - negative = true; - break; - case -2: - value = 0x20; - negative = true; - break; - case -3: - value = 0x30; - negative = true; - break; - default: // 0 - break; - } - - ret = write_reg(sensor->slv_addr, 0x5587, value); - if (ret == 0) { - ret = write_reg_bits(sensor->slv_addr, 0x5588, 0x08, negative); - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set brightness to: %d", level); - sensor->status.brightness = level; - } - return ret; -} - -static int set_contrast(sensor_t *sensor, int level) -{ - int ret = 0; - if(level > 3 || level < -3) { - return -1; - } - ret = write_reg(sensor->slv_addr, 0x5586, (level + 4) << 3); - - if (ret == 0) { - ESP_LOGD(TAG, "Set contrast to: %d", level); - sensor->status.contrast = level; - } - return ret; -} - -static int set_saturation(sensor_t *sensor, int level) -{ - int ret = 0; - if(level > 4 || level < -4) { - return -1; - } - - uint8_t * regs = (uint8_t *)sensor_saturation_levels[level+4]; - for(int i=0; i<11; i++) { - ret = write_reg(sensor->slv_addr, 0x5381 + i, regs[i]); - if (ret) { - break; - } - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set saturation to: %d", level); - sensor->status.saturation = level; - } - return ret; -} - -static int set_sharpness(sensor_t *sensor, int level) -{ - int ret = 0; - if(level > 3 || level < -3) { - return -1; - } - - uint8_t mt_offset_2 = (level + 3) * 8; - uint8_t mt_offset_1 = mt_offset_2 + 1; - - ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x40, false)//0x40 means auto - || write_reg(sensor->slv_addr, 0x5300, 0x10) - || write_reg(sensor->slv_addr, 0x5301, 0x10) - || write_reg(sensor->slv_addr, 0x5302, mt_offset_1) - || write_reg(sensor->slv_addr, 0x5303, mt_offset_2) - || write_reg(sensor->slv_addr, 0x5309, 0x10) - || write_reg(sensor->slv_addr, 0x530a, 0x10) - || write_reg(sensor->slv_addr, 0x530b, 0x04) - || write_reg(sensor->slv_addr, 0x530c, 0x06); - - if (ret == 0) { - ESP_LOGD(TAG, "Set sharpness to: %d", level); - sensor->status.sharpness = level; - } - return ret; -} - -static int set_gainceiling(sensor_t *sensor, gainceiling_t level) -{ - int ret = 0, l = (int)level; - - ret = write_reg(sensor->slv_addr, 0x3A18, (l >> 8) & 3) - || write_reg(sensor->slv_addr, 0x3A19, l & 0xFF); - - if (ret == 0) { - ESP_LOGD(TAG, "Set gainceiling to: %d", l); - sensor->status.gainceiling = l; - } - return ret; -} - -static int get_denoise(sensor_t *sensor) -{ - if (!check_reg_mask(sensor->slv_addr, 0x5308, 0x10)) { - return 0; - } - return (read_reg(sensor->slv_addr, 0x5306) / 4) + 1; -} - -static int set_denoise(sensor_t *sensor, int level) -{ - int ret = 0; - if (level < 0 || level > 8) { - return -1; - } - - ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x10, level > 0); - if (ret == 0 && level > 0) { - ret = write_reg(sensor->slv_addr, 0x5306, (level - 1) * 4); - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set denoise to: %d", level); - sensor->status.denoise = level; - } - return ret; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = 0, ret2 = 0; - if(mask > 0xFF){ - ret = read_reg16(sensor->slv_addr, reg); - if(ret >= 0 && mask > 0xFFFF){ - ret2 = read_reg(sensor->slv_addr, reg+2); - if(ret2 >= 0){ - ret = (ret << 8) | ret2 ; - } else { - ret = ret2; - } - } - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if(ret > 0){ - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0, ret2 = 0; - if(mask > 0xFF){ - ret = read_reg16(sensor->slv_addr, reg); - if(ret >= 0 && mask > 0xFFFF){ - ret2 = read_reg(sensor->slv_addr, reg+2); - if(ret2 >= 0){ - ret = (ret << 8) | ret2 ; - } else { - ret = ret2; - } - } - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if(ret < 0){ - return ret; - } - value = (ret & ~mask) | (value & mask); - if(mask > 0xFFFF){ - ret = write_reg16(sensor->slv_addr, reg, value >> 8); - if(ret >= 0){ - ret = write_reg(sensor->slv_addr, reg+2, value & 0xFF); - } - } else if(mask > 0xFF){ - ret = write_reg16(sensor->slv_addr, reg, value); - } else { - ret = write_reg(sensor->slv_addr, reg, value); - } - return ret; -} - -static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) -{ - int ret = 0; - ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, startX, startY) - || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, endX, endY) - || write_addr_reg(sensor->slv_addr, X_OFFSET_H, offsetX, offsetY) - || write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, totalX, totalY) - || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, outputX, outputY) - || write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, scale); - if(!ret){ - sensor->status.scale = scale; - sensor->status.binning = binning; - ret = set_image_options(sensor); - } - return ret; -} - -static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) -{ - return set_pll(sensor, bypass > 0, multiplier, sys_div, pre_div, root_2x > 0, seld5, pclk_manual > 0, pclk_div); -} - -static int set_xclk(sensor_t *sensor, int timer, int xclk) -{ - int ret = 0; - sensor->xclk_freq_hz = xclk * 1000000U; - ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); - return ret; -} - -static int init_status(sensor_t *sensor) -{ - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.sharpness = (read_reg(sensor->slv_addr, 0x5303) / 8) - 3; - sensor->status.denoise = get_denoise(sensor); - sensor->status.ae_level = 0; - sensor->status.gainceiling = read_reg16(sensor->slv_addr, 0x3A18) & 0x3FF; - sensor->status.awb = check_reg_mask(sensor->slv_addr, ISP_CONTROL_01, 0x01); - sensor->status.dcw = !check_reg_mask(sensor->slv_addr, 0x5183, 0x80); - sensor->status.agc = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN); - sensor->status.aec = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN); - sensor->status.hmirror = check_reg_mask(sensor->slv_addr, TIMING_TC_REG21, TIMING_TC_REG21_HMIRROR); - sensor->status.vflip = check_reg_mask(sensor->slv_addr, TIMING_TC_REG20, TIMING_TC_REG20_VFLIP); - sensor->status.colorbar = check_reg_mask(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR); - sensor->status.bpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x04); - sensor->status.wpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x02); - sensor->status.raw_gma = check_reg_mask(sensor->slv_addr, 0x5000, 0x20); - sensor->status.lenc = check_reg_mask(sensor->slv_addr, 0x5000, 0x80); - sensor->status.quality = read_reg(sensor->slv_addr, COMPRESSION_CTRL07) & 0x3f; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - sensor->status.awb_gain = check_reg_mask(sensor->slv_addr, 0x3406, 0x01); - sensor->status.agc_gain = get_agc_gain(sensor); - sensor->status.aec_value = get_aec_value(sensor); - sensor->status.aec2 = check_reg_mask(sensor->slv_addr, 0x3a00, 0x04); - return 0; -} - -int ov3660_detect(int slv_addr, sensor_id_t *id) -{ - if (OV3660_SCCB_ADDR == slv_addr) { - uint8_t h = SCCB_Read16(slv_addr, 0x300A); - uint8_t l = SCCB_Read16(slv_addr, 0x300B); - uint16_t PID = (h<<8) | l; - if (OV3660_PID == PID) { - id->PID = PID; - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int ov3660_init(sensor_t *sensor) -{ - sensor->reset = reset; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_contrast; - sensor->set_brightness = set_brightness; - sensor->set_saturation = set_saturation; - sensor->set_sharpness = set_sharpness; - sensor->set_gainceiling = set_gainceiling; - sensor->set_quality = set_quality; - sensor->set_colorbar = set_colorbar; - sensor->set_gain_ctrl = set_gain_ctrl; - sensor->set_exposure_ctrl = set_exposure_ctrl; - sensor->set_whitebal = set_whitebal; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - sensor->init_status = init_status; - sensor->set_aec2 = set_aec2; - sensor->set_aec_value = set_aec_value; - sensor->set_special_effect = set_special_effect; - sensor->set_wb_mode = set_wb_mode; - sensor->set_ae_level = set_ae_level; - sensor->set_dcw = set_dcw_dsp; - sensor->set_bpc = set_bpc_dsp; - sensor->set_wpc = set_wpc_dsp; - sensor->set_awb_gain = set_awb_gain_dsp; - sensor->set_agc_gain = set_agc_gain; - sensor->set_raw_gma = set_raw_gma_dsp; - sensor->set_lenc = set_lenc_dsp; - sensor->set_denoise = set_denoise; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = set_res_raw; - sensor->set_pll = _set_pll; - sensor->set_xclk = set_xclk; - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov5640.c b/lib/libesp32_div/esp32-camera/sensors/ov5640.c deleted file mode 100644 index a32b374f5..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/ov5640.c +++ /dev/null @@ -1,1130 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV3660 driver. - * - */ -#include -#include -#include -#include "sccb.h" -#include "xclk.h" -#include "ov5640.h" -#include "ov5640_regs.h" -#include "ov5640_settings.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char *TAG = "ov5640"; -#endif - -//#define REG_DEBUG_ON - -static int read_reg(uint8_t slv_addr, const uint16_t reg){ - int ret = SCCB_Read16(slv_addr, reg); -#ifdef REG_DEBUG_ON - if (ret < 0) { - ESP_LOGE(TAG, "READ REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int check_reg_mask(uint8_t slv_addr, uint16_t reg, uint8_t mask){ - return (read_reg(slv_addr, reg) & mask) == mask; -} - -static int read_reg16(uint8_t slv_addr, const uint16_t reg){ - int ret = 0, ret2 = 0; - ret = read_reg(slv_addr, reg); - if (ret >= 0) { - ret = (ret & 0xFF) << 8; - ret2 = read_reg(slv_addr, reg+1); - if (ret2 < 0) { - ret = ret2; - } else { - ret |= ret2 & 0xFF; - } - } - return ret; -} - -//static void dump_reg(sensor_t *sensor, const uint16_t reg){ -// int v = SCCB_Read16(sensor->slv_addr, reg); -// if(v < 0){ -// ets_printf(" 0x%04x: FAIL[%d]\n", reg, v); -// } else { -// ets_printf(" 0x%04x: 0x%02X\n", reg, v); -// } -//} -// -//static void dump_range(sensor_t *sensor, const char * name, const uint16_t start_reg, const uint16_t end_reg){ -// ets_printf("%s: 0x%04x - 0x%04X\n", name, start_reg, end_reg); -// for(uint16_t reg = start_reg; reg <= end_reg; reg++){ -// dump_reg(sensor, reg); -// } -//} -// -//static void dump_regs(sensor_t *sensor){ -//// dump_range(sensor, "All Regs", 0x3000, 0x6100); -//// dump_range(sensor, "system and IO pad control", 0x3000, 0x3052); -//// dump_range(sensor, "SCCB control", 0x3100, 0x3108); -//// dump_range(sensor, "SRB control", 0x3200, 0x3211); -//// dump_range(sensor, "AWB gain control", 0x3400, 0x3406); -//// dump_range(sensor, "AEC/AGC control", 0x3500, 0x350D); -//// dump_range(sensor, "VCM control", 0x3600, 0x3606); -//// dump_range(sensor, "timing control", 0x3800, 0x3821); -//// dump_range(sensor, "AEC/AGC power down domain control", 0x3A00, 0x3A25); -//// dump_range(sensor, "strobe control", 0x3B00, 0x3B0C); -//// dump_range(sensor, "50/60Hz detector control", 0x3C00, 0x3C1E); -//// dump_range(sensor, "OTP control", 0x3D00, 0x3D21); -//// dump_range(sensor, "MC control", 0x3F00, 0x3F0D); -//// dump_range(sensor, "BLC control", 0x4000, 0x4033); -//// dump_range(sensor, "frame control", 0x4201, 0x4202); -//// dump_range(sensor, "format control", 0x4300, 0x430D); -//// dump_range(sensor, "JPEG control", 0x4400, 0x4431); -//// dump_range(sensor, "VFIFO control", 0x4600, 0x460D); -//// dump_range(sensor, "DVP control", 0x4709, 0x4745); -//// dump_range(sensor, "MIPI control", 0x4800, 0x4837); -//// dump_range(sensor, "ISP frame control", 0x4901, 0x4902); -//// dump_range(sensor, "ISP top control", 0x5000, 0x5063); -//// dump_range(sensor, "AWB control", 0x5180, 0x51D0); -//// dump_range(sensor, "CIP control", 0x5300, 0x530F); -//// dump_range(sensor, "CMX control", 0x5380, 0x538B); -//// dump_range(sensor, "gamma control", 0x5480, 0x5490); -//// dump_range(sensor, "SDE control", 0x5580, 0x558C); -//// dump_range(sensor, "scale control", 0x5600, 0x5606); -//// dump_range(sensor, "AVG control", 0x5680, 0x56A2); -//// dump_range(sensor, "LENC control", 0x5800, 0x5849); -//// dump_range(sensor, "AFC control", 0x6000, 0x603F); -//} - -static int write_reg(uint8_t slv_addr, const uint16_t reg, uint8_t value){ - int ret = 0; -#ifndef REG_DEBUG_ON - ret = SCCB_Write16(slv_addr, reg, value); -#else - int old_value = read_reg(slv_addr, reg); - if (old_value < 0) { - return old_value; - } - if ((uint8_t)old_value != value) { - ESP_LOGI(TAG, "NEW REG 0x%04x: 0x%02x to 0x%02x", reg, (uint8_t)old_value, value); - ret = SCCB_Write16(slv_addr, reg, value); - } else { - ESP_LOGD(TAG, "OLD REG 0x%04x: 0x%02x", reg, (uint8_t)old_value); - ret = SCCB_Write16(slv_addr, reg, value);//maybe not? - } - if (ret < 0) { - ESP_LOGE(TAG, "WRITE REG 0x%04x FAILED: %d", reg, ret); - } -#endif - return ret; -} - -static int set_reg_bits(uint8_t slv_addr, uint16_t reg, uint8_t offset, uint8_t mask, uint8_t value) -{ - int ret = 0; - uint8_t c_value, new_value; - ret = read_reg(slv_addr, reg); - if(ret < 0) { - return ret; - } - c_value = ret; - new_value = (c_value & ~(mask << offset)) | ((value & mask) << offset); - ret = write_reg(slv_addr, reg, new_value); - return ret; -} - -static int write_regs(uint8_t slv_addr, const uint16_t (*regs)[2]) -{ - int i = 0, ret = 0; - while (!ret && regs[i][0] != REGLIST_TAIL) { - if (regs[i][0] == REG_DLY) { - vTaskDelay(regs[i][1] / portTICK_PERIOD_MS); - } else { - ret = write_reg(slv_addr, regs[i][0], regs[i][1]); - } - i++; - } - return ret; -} - -static int write_reg16(uint8_t slv_addr, const uint16_t reg, uint16_t value) -{ - if (write_reg(slv_addr, reg, value >> 8) || write_reg(slv_addr, reg + 1, value)) { - return -1; - } - return 0; -} - -static int write_addr_reg(uint8_t slv_addr, const uint16_t reg, uint16_t x_value, uint16_t y_value) -{ - if (write_reg16(slv_addr, reg, x_value) || write_reg16(slv_addr, reg + 2, y_value)) { - return -1; - } - return 0; -} - -#define write_reg_bits(slv_addr, reg, mask, enable) set_reg_bits(slv_addr, reg, 0, mask, (enable)?(mask):0) - -static int calc_sysclk(int xclk, bool pll_bypass, int pll_multiplier, int pll_sys_div, int pre_div, bool root_2x, int pclk_root_div, bool pclk_manual, int pclk_div) -{ - const float pll_pre_div2x_map[] = { 1, 1, 2, 3, 4, 1.5, 6, 2.5, 8}; - const int pll_pclk_root_div_map[] = { 1, 2, 4, 8 }; - - if(!pll_sys_div) { - pll_sys_div = 1; - } - - float pll_pre_div = pll_pre_div2x_map[pre_div]; - unsigned int root_2x_div = root_2x?2:1; - unsigned int pll_pclk_root_div = pll_pclk_root_div_map[pclk_root_div]; - - unsigned int REFIN = xclk / pll_pre_div; - - unsigned int VCO = REFIN * pll_multiplier / root_2x_div; - - unsigned int PLL_CLK = pll_bypass?(xclk):(VCO / pll_sys_div * 2 / 5);//5 here is 10bit mode / 2, for 8bit it should be 4 (reg 0x3034) - - unsigned int PCLK = PLL_CLK / pll_pclk_root_div / ((pclk_manual && pclk_div)?pclk_div:2); - - unsigned int SYSCLK = PLL_CLK / 4; - - ESP_LOGI(TAG, "Calculated XVCLK: %d Hz, REFIN: %u Hz, VCO: %u Hz, PLL_CLK: %u Hz, SYSCLK: %u Hz, PCLK: %u Hz", xclk, REFIN, VCO, PLL_CLK, SYSCLK, PCLK); - return SYSCLK; -} - -static int set_pll(sensor_t *sensor, bool bypass, uint8_t multiplier, uint8_t sys_div, uint8_t pre_div, bool root_2x, uint8_t pclk_root_div, bool pclk_manual, uint8_t pclk_div){ - int ret = 0; - if(multiplier > 252 || multiplier < 4 || sys_div > 15 || pre_div > 8 || pclk_div > 31 || pclk_root_div > 3){ - ESP_LOGE(TAG, "Invalid arguments"); - return -1; - } - if(multiplier > 127){ - multiplier &= 0xFE;//only even integers above 127 - } - ESP_LOGI(TAG, "Set PLL: bypass: %u, multiplier: %u, sys_div: %u, pre_div: %u, root_2x: %u, pclk_root_div: %u, pclk_manual: %u, pclk_div: %u", bypass, multiplier, sys_div, pre_div, root_2x, pclk_root_div, pclk_manual, pclk_div); - - calc_sysclk(sensor->xclk_freq_hz, bypass, multiplier, sys_div, pre_div, root_2x, pclk_root_div, pclk_manual, pclk_div); - - ret = write_reg(sensor->slv_addr, 0x3039, bypass?0x80:0x00); - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3034, 0x1A);//10bit mode - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3035, 0x01 | ((sys_div & 0x0f) << 4)); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3036, multiplier & 0xff); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3037, (pre_div & 0xf) | (root_2x?0x10:0x00)); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3108, (pclk_root_div & 0x3) << 4 | 0x06); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3824, pclk_div & 0x1f); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x460C, pclk_manual?0x22:0x20); - } - if (ret == 0) { - ret = write_reg(sensor->slv_addr, 0x3103, 0x13);// system clock from pll, bit[1] - } - if(ret){ - ESP_LOGE(TAG, "set_sensor_pll FAILED!"); - } - return ret; -} - -static int set_ae_level(sensor_t *sensor, int level); - -static int reset(sensor_t *sensor) -{ - //dump_regs(sensor); - vTaskDelay(100 / portTICK_PERIOD_MS); - int ret = 0; - // Software Reset: clear all registers and reset them to their default values - ret = write_reg(sensor->slv_addr, SYSTEM_CTROL0, 0x82); - if(ret){ - ESP_LOGE(TAG, "Software Reset FAILED!"); - return ret; - } - vTaskDelay(100 / portTICK_PERIOD_MS); - ret = write_regs(sensor->slv_addr, sensor_default_regs); - if (ret == 0) { - ESP_LOGD(TAG, "Camera defaults loaded"); - vTaskDelay(100 / portTICK_PERIOD_MS); - //write_regs(sensor->slv_addr, sensor_regs_awb0); - //write_regs(sensor->slv_addr, sensor_regs_gamma1); - } - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret = 0; - const uint16_t (*regs)[2]; - - switch (pixformat) { - case PIXFORMAT_YUV422: - regs = sensor_fmt_yuv422; - break; - - case PIXFORMAT_GRAYSCALE: - regs = sensor_fmt_grayscale; - break; - - case PIXFORMAT_RGB565: - case PIXFORMAT_RGB888: - regs = sensor_fmt_rgb565; - break; - - case PIXFORMAT_JPEG: - regs = sensor_fmt_jpeg; - break; - - case PIXFORMAT_RAW: - regs = sensor_fmt_raw; - break; - - default: - ESP_LOGE(TAG, "Unsupported pixformat: %u", pixformat); - return -1; - } - - ret = write_regs(sensor->slv_addr, regs); - if(ret == 0) { - sensor->pixformat = pixformat; - ESP_LOGD(TAG, "Set pixformat to: %u", pixformat); - } - return ret; -} - -static int set_image_options(sensor_t *sensor) -{ - int ret = 0; - uint8_t reg20 = 0; - uint8_t reg21 = 0; - uint8_t reg4514 = 0; - uint8_t reg4514_test = 0; - - // compression - if (sensor->pixformat == PIXFORMAT_JPEG) { - reg21 |= 0x20; - } - - // binning - if (!sensor->status.binning) { - reg20 |= 0x40; - } else { - reg20 |= 0x01; - reg21 |= 0x01; - reg4514_test |= 4; - } - - // V-Flip - if (sensor->status.vflip) { - reg20 |= 0x06; - reg4514_test |= 1; - } - - // H-Mirror - if (sensor->status.hmirror) { - reg21 |= 0x06; - reg4514_test |= 2; - } - - switch (reg4514_test) { - //no binning - case 0: reg4514 = 0x88; break;//normal - case 1: reg4514 = 0x00; break;//v-flip - case 2: reg4514 = 0xbb; break;//h-mirror - case 3: reg4514 = 0x00; break;//v-flip+h-mirror - //binning - case 4: reg4514 = 0xaa; break;//normal - case 5: reg4514 = 0xbb; break;//v-flip - case 6: reg4514 = 0xbb; break;//h-mirror - case 7: reg4514 = 0xaa; break;//v-flip+h-mirror - } - - if(write_reg(sensor->slv_addr, TIMING_TC_REG20, reg20) - || write_reg(sensor->slv_addr, TIMING_TC_REG21, reg21) - || write_reg(sensor->slv_addr, 0x4514, reg4514)){ - ESP_LOGE(TAG, "Setting Image Options Failed"); - return -1; - } - - if (!sensor->status.binning) { - ret = write_reg(sensor->slv_addr, 0x4520, 0x10) - || write_reg(sensor->slv_addr, X_INCREMENT, 0x11)//odd:1, even: 1 - || write_reg(sensor->slv_addr, Y_INCREMENT, 0x11);//odd:1, even: 1 - } else { - ret = write_reg(sensor->slv_addr, 0x4520, 0x0b) - || write_reg(sensor->slv_addr, X_INCREMENT, 0x31)//odd:3, even: 1 - || write_reg(sensor->slv_addr, Y_INCREMENT, 0x31);//odd:3, even: 1 - } - - ESP_LOGD(TAG, "Set Image Options: Compression: %u, Binning: %u, V-Flip: %u, H-Mirror: %u, Reg-4514: 0x%02x", - sensor->pixformat == PIXFORMAT_JPEG, sensor->status.binning, sensor->status.vflip, sensor->status.hmirror, reg4514); - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret = 0; - framesize_t old_framesize = sensor->status.framesize; - sensor->status.framesize = framesize; - - if(framesize > FRAMESIZE_QSXGA){ - ESP_LOGE(TAG, "Invalid framesize: %u", framesize); - return -1; - } - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - aspect_ratio_t ratio = resolution[framesize].aspect_ratio; - ratio_settings_t settings = ratio_table[ratio]; - - sensor->status.binning = (w <= (settings.max_width / 2) && h <= (settings.max_height / 2)); - sensor->status.scale = !((w == settings.max_width && h == settings.max_height) - || (w == (settings.max_width / 2) && h == (settings.max_height / 2))); - - ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, settings.start_x, settings.start_y) - || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, settings.end_x, settings.end_y) - || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, w, h); - - if (ret) { - goto fail; - } - - if (!sensor->status.binning) { - ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x, settings.total_y) - || write_addr_reg(sensor->slv_addr, X_OFFSET_H, settings.offset_x, settings.offset_y); - } else { - if (w > 920) { - ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, settings.total_x - 200, settings.total_y / 2); - } else { - ret = write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, 2060, settings.total_y / 2); - } - if (ret == 0) { - ret = write_addr_reg(sensor->slv_addr, X_OFFSET_H, settings.offset_x / 2, settings.offset_y / 2); - } - } - - if (ret == 0) { - ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, sensor->status.scale); - } - - if (ret == 0) { - ret = set_image_options(sensor); - } - - if (ret) { - goto fail; - } - - if (sensor->pixformat == PIXFORMAT_JPEG) { - //10MHz PCLK - uint8_t sys_mul = 200; - if(framesize < FRAMESIZE_QVGA || sensor->xclk_freq_hz == 16000000){ - sys_mul = 160; - } else if(framesize < FRAMESIZE_XGA){ - sys_mul = 180; - } - ret = set_pll(sensor, false, sys_mul, 4, 2, false, 2, true, 4); - //Set PLL: bypass: 0, multiplier: sys_mul, sys_div: 4, pre_div: 2, root_2x: 0, pclk_root_div: 2, pclk_manual: 1, pclk_div: 4 - } else { - //ret = set_pll(sensor, false, 8, 1, 1, false, 1, true, 4); - if (framesize > FRAMESIZE_HVGA) { - ret = set_pll(sensor, false, 10, 1, 2, false, 1, true, 2); - } else if (framesize >= FRAMESIZE_QVGA) { - ret = set_pll(sensor, false, 8, 1, 1, false, 1, true, 4); - } else { - ret = set_pll(sensor, false, 20, 1, 1, false, 1, true, 8); - } - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set framesize to: %ux%u", w, h); - } - return ret; - -fail: - sensor->status.framesize = old_framesize; - ESP_LOGE(TAG, "Setting framesize to: %ux%u failed", w, h); - return ret; -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.hmirror = enable; - ret = set_image_options(sensor); - if (ret == 0) { - ESP_LOGD(TAG, "Set h-mirror to: %d", enable); - } - return ret; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - int ret = 0; - sensor->status.vflip = enable; - ret = set_image_options(sensor); - if (ret == 0) { - ESP_LOGD(TAG, "Set v-flip to: %d", enable); - } - return ret; -} - -static int set_quality(sensor_t *sensor, int qs) -{ - int ret = 0; - ret = write_reg(sensor->slv_addr, COMPRESSION_CTRL07, qs & 0x3f); - if (ret == 0) { - sensor->status.quality = qs; - ESP_LOGD(TAG, "Set quality to: %d", qs); - } - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR, enable); - if (ret == 0) { - sensor->status.colorbar = enable; - ESP_LOGD(TAG, "Set colorbar to: %d", enable); - } - return ret; -} - -static int set_gain_ctrl(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set gain_ctrl to: %d", enable); - sensor->status.agc = enable; - } - return ret; -} - -static int set_exposure_ctrl(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set exposure_ctrl to: %d", enable); - sensor->status.aec = enable; - } - return ret; -} - -static int set_whitebal(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x01, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set awb to: %d", enable); - sensor->status.awb = enable; - } - return ret; -} - -//Advanced AWB -static int set_dcw_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5183, 0x80, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set dcw to: %d", enable); - sensor->status.dcw = enable; - } - return ret; -} - -//night mode enable -static int set_aec2(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x3a00, 0x04, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set aec2 to: %d", enable); - sensor->status.aec2 = enable; - } - return ret; -} - -static int set_bpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x04, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set bpc to: %d", enable); - sensor->status.bpc = enable; - } - return ret; -} - -static int set_wpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x02, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set wpc to: %d", enable); - sensor->status.wpc = enable; - } - return ret; -} - -//Gamma enable -static int set_raw_gma_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x20, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set raw_gma to: %d", enable); - sensor->status.raw_gma = enable; - } - return ret; -} - -static int set_lenc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = write_reg_bits(sensor->slv_addr, 0x5000, 0x80, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set lenc to: %d", enable); - sensor->status.lenc = enable; - } - return ret; -} - -static int get_agc_gain(sensor_t *sensor) -{ - int ra = read_reg(sensor->slv_addr, 0x350a); - if (ra < 0) { - return 0; - } - int rb = read_reg(sensor->slv_addr, 0x350b); - if (rb < 0) { - return 0; - } - int res = (rb & 0xF0) >> 4 | (ra & 0x03) << 4; - if (rb & 0x0F) { - res += 1; - } - return res; -} - -//real gain -static int set_agc_gain(sensor_t *sensor, int gain) -{ - int ret = 0; - if(gain < 0) { - gain = 0; - } else if(gain > 64) { - gain = 64; - } - - //gain value is 6.4 bits float - //in order to use the max range, we deduct 1/16 - int gainv = gain << 4; - if(gainv){ - gainv -= 1; - } - - ret = write_reg(sensor->slv_addr, 0x350a, gainv >> 8) || write_reg(sensor->slv_addr, 0x350b, gainv & 0xff); - if (ret == 0) { - ESP_LOGD(TAG, "Set agc_gain to: %d", gain); - sensor->status.agc_gain = gain; - } - return ret; -} - -static int get_aec_value(sensor_t *sensor) -{ - int ra = read_reg(sensor->slv_addr, 0x3500); - if (ra < 0) { - return 0; - } - int rb = read_reg(sensor->slv_addr, 0x3501); - if (rb < 0) { - return 0; - } - int rc = read_reg(sensor->slv_addr, 0x3502); - if (rc < 0) { - return 0; - } - int res = (ra & 0x0F) << 12 | (rb & 0xFF) << 4 | (rc & 0xF0) >> 4; - return res; -} - -static int set_aec_value(sensor_t *sensor, int value) -{ - int ret = 0, max_val = 0; - max_val = read_reg16(sensor->slv_addr, 0x380e); - if (max_val < 0) { - ESP_LOGE(TAG, "Could not read max aec_value"); - return -1; - } - if (value > max_val) { - value =max_val; - } - - ret = write_reg(sensor->slv_addr, 0x3500, (value >> 12) & 0x0F) - || write_reg(sensor->slv_addr, 0x3501, (value >> 4) & 0xFF) - || write_reg(sensor->slv_addr, 0x3502, (value << 4) & 0xF0); - - if (ret == 0) { - ESP_LOGD(TAG, "Set aec_value to: %d / %d", value, max_val); - sensor->status.aec_value = value; - } - return ret; -} - -static int set_ae_level(sensor_t *sensor, int level) -{ - int ret = 0; - if (level < -5 || level > 5) { - return -1; - } - //good targets are between 5 and 115 - int target_level = ((level + 5) * 10) + 5; - - int level_high, level_low; - int fast_high, fast_low; - - level_low = target_level * 23 / 25; //0.92 (0.46) - level_high = target_level * 27 / 25; //1.08 (2.08) - - fast_low = level_low >> 1; - fast_high = level_high << 1; - - if(fast_high>255) { - fast_high = 255; - } - - ret = write_reg(sensor->slv_addr, 0x3a0f, level_high) - || write_reg(sensor->slv_addr, 0x3a10, level_low) - || write_reg(sensor->slv_addr, 0x3a1b, level_high) - || write_reg(sensor->slv_addr, 0x3a1e, level_low) - || write_reg(sensor->slv_addr, 0x3a11, fast_high) - || write_reg(sensor->slv_addr, 0x3a1f, fast_low); - - if (ret == 0) { - ESP_LOGD(TAG, "Set ae_level to: %d", level); - sensor->status.ae_level = level; - } - return ret; -} - -static int set_wb_mode(sensor_t *sensor, int mode) -{ - int ret = 0; - if (mode < 0 || mode > 4) { - return -1; - } - - ret = write_reg(sensor->slv_addr, 0x3406, (mode != 0)); - if (ret) { - return ret; - } - switch (mode) { - case 1://Sunny - ret = write_reg16(sensor->slv_addr, 0x3400, 0x5e0) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x540);//AWB B GAIN - break; - case 2://Cloudy - ret = write_reg16(sensor->slv_addr, 0x3400, 0x650) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x4f0);//AWB B GAIN - break; - case 3://Office - ret = write_reg16(sensor->slv_addr, 0x3400, 0x520) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x410) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x660);//AWB B GAIN - break; - case 4://HOME - ret = write_reg16(sensor->slv_addr, 0x3400, 0x420) //AWB R GAIN - || write_reg16(sensor->slv_addr, 0x3402, 0x3f0) //AWB G GAIN - || write_reg16(sensor->slv_addr, 0x3404, 0x710);//AWB B GAIN - break; - default://AUTO - break; - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set wb_mode to: %d", mode); - sensor->status.wb_mode = mode; - } - return ret; -} - -static int set_awb_gain_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - int old_mode = sensor->status.wb_mode; - int mode = enable?old_mode:0; - - ret = set_wb_mode(sensor, mode); - - if (ret == 0) { - sensor->status.wb_mode = old_mode; - ESP_LOGD(TAG, "Set awb_gain to: %d", enable); - sensor->status.awb_gain = enable; - } - return ret; -} - -static int set_special_effect(sensor_t *sensor, int effect) -{ - int ret=0; - if (effect < 0 || effect > 6) { - return -1; - } - - uint8_t * regs = (uint8_t *)sensor_special_effects[effect]; - ret = write_reg(sensor->slv_addr, 0x5580, regs[0]) - || write_reg(sensor->slv_addr, 0x5583, regs[1]) - || write_reg(sensor->slv_addr, 0x5584, regs[2]) - || write_reg(sensor->slv_addr, 0x5003, regs[3]); - - if (ret == 0) { - ESP_LOGD(TAG, "Set special_effect to: %d", effect); - sensor->status.special_effect = effect; - } - return ret; -} - -static int set_brightness(sensor_t *sensor, int level) -{ - int ret = 0; - uint8_t value = 0; - bool negative = false; - - switch (level) { - case 3: - value = 0x30; - break; - case 2: - value = 0x20; - break; - case 1: - value = 0x10; - break; - case -1: - value = 0x10; - negative = true; - break; - case -2: - value = 0x20; - negative = true; - break; - case -3: - value = 0x30; - negative = true; - break; - default: // 0 - break; - } - - ret = write_reg(sensor->slv_addr, 0x5587, value); - if (ret == 0) { - ret = write_reg_bits(sensor->slv_addr, 0x5588, 0x08, negative); - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set brightness to: %d", level); - sensor->status.brightness = level; - } - return ret; -} - -static int set_contrast(sensor_t *sensor, int level) -{ - int ret = 0; - if(level > 3 || level < -3) { - return -1; - } - ret = write_reg(sensor->slv_addr, 0x5586, (level + 4) << 3); - - if (ret == 0) { - ESP_LOGD(TAG, "Set contrast to: %d", level); - sensor->status.contrast = level; - } - return ret; -} - -static int set_saturation(sensor_t *sensor, int level) -{ - int ret = 0; - if(level > 4 || level < -4) { - return -1; - } - - uint8_t * regs = (uint8_t *)sensor_saturation_levels[level+4]; - for(int i=0; i<11; i++) { - ret = write_reg(sensor->slv_addr, 0x5381 + i, regs[i]); - if (ret) { - break; - } - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set saturation to: %d", level); - sensor->status.saturation = level; - } - return ret; -} - -static int set_sharpness(sensor_t *sensor, int level) -{ - int ret = 0; - if(level > 3 || level < -3) { - return -1; - } - - uint8_t mt_offset_2 = (level + 3) * 8; - uint8_t mt_offset_1 = mt_offset_2 + 1; - - ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x40, false)//0x40 means auto - || write_reg(sensor->slv_addr, 0x5300, 0x10) - || write_reg(sensor->slv_addr, 0x5301, 0x10) - || write_reg(sensor->slv_addr, 0x5302, mt_offset_1) - || write_reg(sensor->slv_addr, 0x5303, mt_offset_2) - || write_reg(sensor->slv_addr, 0x5309, 0x10) - || write_reg(sensor->slv_addr, 0x530a, 0x10) - || write_reg(sensor->slv_addr, 0x530b, 0x04) - || write_reg(sensor->slv_addr, 0x530c, 0x06); - - if (ret == 0) { - ESP_LOGD(TAG, "Set sharpness to: %d", level); - sensor->status.sharpness = level; - } - return ret; -} - -static int set_gainceiling(sensor_t *sensor, gainceiling_t level) -{ - int ret = 0, l = (int)level; - - ret = write_reg(sensor->slv_addr, 0x3A18, (l >> 8) & 3) - || write_reg(sensor->slv_addr, 0x3A19, l & 0xFF); - - if (ret == 0) { - ESP_LOGD(TAG, "Set gainceiling to: %d", l); - sensor->status.gainceiling = l; - } - return ret; -} - -static int get_denoise(sensor_t *sensor) -{ - if (!check_reg_mask(sensor->slv_addr, 0x5308, 0x10)) { - return 0; - } - return (read_reg(sensor->slv_addr, 0x5306) / 4) + 1; -} - -static int set_denoise(sensor_t *sensor, int level) -{ - int ret = 0; - if (level < 0 || level > 8) { - return -1; - } - - ret = write_reg_bits(sensor->slv_addr, 0x5308, 0x10, level > 0); - if (ret == 0 && level > 0) { - ret = write_reg(sensor->slv_addr, 0x5306, (level - 1) * 4); - } - - if (ret == 0) { - ESP_LOGD(TAG, "Set denoise to: %d", level); - sensor->status.denoise = level; - } - return ret; -} - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = 0, ret2 = 0; - if(mask > 0xFF){ - ret = read_reg16(sensor->slv_addr, reg); - if(ret >= 0 && mask > 0xFFFF){ - ret2 = read_reg(sensor->slv_addr, reg+2); - if(ret2 >= 0){ - ret = (ret << 8) | ret2 ; - } else { - ret = ret2; - } - } - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if(ret > 0){ - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0, ret2 = 0; - if(mask > 0xFF){ - ret = read_reg16(sensor->slv_addr, reg); - if(ret >= 0 && mask > 0xFFFF){ - ret2 = read_reg(sensor->slv_addr, reg+2); - if(ret2 >= 0){ - ret = (ret << 8) | ret2 ; - } else { - ret = ret2; - } - } - } else { - ret = read_reg(sensor->slv_addr, reg); - } - if(ret < 0){ - return ret; - } - value = (ret & ~mask) | (value & mask); - if(mask > 0xFFFF){ - ret = write_reg16(sensor->slv_addr, reg, value >> 8); - if(ret >= 0){ - ret = write_reg(sensor->slv_addr, reg+2, value & 0xFF); - } - } else if(mask > 0xFF){ - ret = write_reg16(sensor->slv_addr, reg, value); - } else { - ret = write_reg(sensor->slv_addr, reg, value); - } - return ret; -} - -static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning) -{ - int ret = 0; - ret = write_addr_reg(sensor->slv_addr, X_ADDR_ST_H, startX, startY) - || write_addr_reg(sensor->slv_addr, X_ADDR_END_H, endX, endY) - || write_addr_reg(sensor->slv_addr, X_OFFSET_H, offsetX, offsetY) - || write_addr_reg(sensor->slv_addr, X_TOTAL_SIZE_H, totalX, totalY) - || write_addr_reg(sensor->slv_addr, X_OUTPUT_SIZE_H, outputX, outputY) - || write_reg_bits(sensor->slv_addr, ISP_CONTROL_01, 0x20, scale); - if(!ret){ - sensor->status.scale = scale; - sensor->status.binning = binning; - ret = set_image_options(sensor); - } - return ret; -} - -static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div) -{ - int ret = 0; - ret = set_pll(sensor, bypass > 0, multiplier, sys_div, pre_div, root_2x > 0, seld5, pclk_manual > 0, pclk_div); - return ret; -} - -static int set_xclk(sensor_t *sensor, int timer, int xclk) -{ - int ret = 0; - sensor->xclk_freq_hz = xclk * 1000000U; - ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); - return ret; -} - -static int init_status(sensor_t *sensor) -{ - sensor->status.brightness = 0; - sensor->status.contrast = 0; - sensor->status.saturation = 0; - sensor->status.sharpness = (read_reg(sensor->slv_addr, 0x5303) / 8) - 3; - sensor->status.denoise = get_denoise(sensor); - sensor->status.ae_level = 0; - sensor->status.gainceiling = read_reg16(sensor->slv_addr, 0x3A18) & 0x3FF; - sensor->status.awb = check_reg_mask(sensor->slv_addr, ISP_CONTROL_01, 0x01); - sensor->status.dcw = !check_reg_mask(sensor->slv_addr, 0x5183, 0x80); - sensor->status.agc = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AGC_MANUALEN); - sensor->status.aec = !check_reg_mask(sensor->slv_addr, AEC_PK_MANUAL, AEC_PK_MANUAL_AEC_MANUALEN); - sensor->status.hmirror = check_reg_mask(sensor->slv_addr, TIMING_TC_REG21, TIMING_TC_REG21_HMIRROR); - sensor->status.vflip = check_reg_mask(sensor->slv_addr, TIMING_TC_REG20, TIMING_TC_REG20_VFLIP); - sensor->status.colorbar = check_reg_mask(sensor->slv_addr, PRE_ISP_TEST_SETTING_1, TEST_COLOR_BAR); - sensor->status.bpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x04); - sensor->status.wpc = check_reg_mask(sensor->slv_addr, 0x5000, 0x02); - sensor->status.raw_gma = check_reg_mask(sensor->slv_addr, 0x5000, 0x20); - sensor->status.lenc = check_reg_mask(sensor->slv_addr, 0x5000, 0x80); - sensor->status.quality = read_reg(sensor->slv_addr, COMPRESSION_CTRL07) & 0x3f; - sensor->status.special_effect = 0; - sensor->status.wb_mode = 0; - sensor->status.awb_gain = check_reg_mask(sensor->slv_addr, 0x3406, 0x01); - sensor->status.agc_gain = get_agc_gain(sensor); - sensor->status.aec_value = get_aec_value(sensor); - sensor->status.aec2 = check_reg_mask(sensor->slv_addr, 0x3a00, 0x04); - return 0; -} - -int ov5640_detect(int slv_addr, sensor_id_t *id) -{ - if (OV5640_SCCB_ADDR == slv_addr) { - uint8_t h = SCCB_Read16(slv_addr, 0x300A); - uint8_t l = SCCB_Read16(slv_addr, 0x300B); - uint16_t PID = (h<<8) | l; - if (OV5640_PID == PID) { - id->PID = PID; - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int ov5640_init(sensor_t *sensor) -{ - sensor->reset = reset; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_contrast = set_contrast; - sensor->set_brightness = set_brightness; - sensor->set_saturation = set_saturation; - sensor->set_sharpness = set_sharpness; - sensor->set_gainceiling = set_gainceiling; - sensor->set_quality = set_quality; - sensor->set_colorbar = set_colorbar; - sensor->set_gain_ctrl = set_gain_ctrl; - sensor->set_exposure_ctrl = set_exposure_ctrl; - sensor->set_whitebal = set_whitebal; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - sensor->init_status = init_status; - sensor->set_aec2 = set_aec2; - sensor->set_aec_value = set_aec_value; - sensor->set_special_effect = set_special_effect; - sensor->set_wb_mode = set_wb_mode; - sensor->set_ae_level = set_ae_level; - sensor->set_dcw = set_dcw_dsp; - sensor->set_bpc = set_bpc_dsp; - sensor->set_wpc = set_wpc_dsp; - sensor->set_awb_gain = set_awb_gain_dsp; - sensor->set_agc_gain = set_agc_gain; - sensor->set_raw_gma = set_raw_gma_dsp; - sensor->set_lenc = set_lenc_dsp; - sensor->set_denoise = set_denoise; - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = set_res_raw; - sensor->set_pll = _set_pll; - sensor->set_xclk = set_xclk; - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov7670.c b/lib/libesp32_div/esp32-camera/sensors/ov7670.c deleted file mode 100644 index b9dcf2327..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/ov7670.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * This file is part of the OpenMV project. - * author: Juan Schiavoni - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV7725 driver. - * - */ -#include -#include -#include -#include "sccb.h" -#include "ov7670.h" -#include "ov7670_regs.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char* TAG = "ov7760"; -#endif - -static int ov7670_clkrc = 0x01; - -/* - * The default register settings, as obtained from OmniVision. There - * is really no making sense of most of these - lots of "reserved" values - * and such. - * - * These settings give VGA YUYV. - */ -struct regval_list { - uint8_t reg_num; - uint8_t value; -}; - -static struct regval_list ov7670_default_regs[] = { - /* Sensor automatically sets output window when resolution changes. */ - {TSLB, 0x04}, - - /* Frame rate 30 fps at 12 Mhz clock */ - {CLKRC, 0x00}, - {DBLV, 0x4A}, - - {COM10, COM10_VSYNC_NEG | COM10_PCLK_MASK}, - - /* Improve white balance */ - {COM4, 0x40}, - - /* Improve color */ - {RSVD_B0, 0x84}, - - /* Enable 50/60 Hz auto detection */ - {COM11, COM11_EXP|COM11_HZAUTO}, - - /* Disable some delays */ - {HSYST, 0}, - {HSYEN, 0}, - - {MVFP, MVFP_SUN}, - - /* More reserved magic, some of which tweaks white balance */ - {AWBC1, 0x0a}, - {AWBC2, 0xf0}, - {AWBC3, 0x34}, - {AWBC4, 0x58}, - {AWBC5, 0x28}, - {AWBC6, 0x3a}, - - {AWBCTR3, 0x0a}, - {AWBCTR2, 0x55}, - {AWBCTR1, 0x11}, - {AWBCTR0, 0x9e}, - - {COM8, COM8_FAST_AUTO|COM8_STEP_UNLIMIT|COM8_AGC_EN|COM8_AEC_EN|COM8_AWB_EN}, - - /* End marker is FF because in ov7670 the address of GAIN 0 and default value too. */ - {0xFF, 0xFF}, -}; - -static struct regval_list ov7670_fmt_yuv422[] = { - { COM7, 0x0 }, /* Selects YUV mode */ - { RGB444, 0 }, /* No RGB444 please */ - { COM1, 0 }, /* CCIR601 */ - { COM15, COM15_R00FF }, - { MVFP, MVFP_SUN }, - { COM9, 0x6A }, /* 128x gain ceiling; 0x8 is reserved bit */ - { MTX1, 0x80 }, /* "matrix coefficient 1" */ - { MTX2, 0x80 }, /* "matrix coefficient 2" */ - { MTX3, 0 }, /* vb */ - { MTX4, 0x22 }, /* "matrix coefficient 4" */ - { MTX5, 0x5e }, /* "matrix coefficient 5" */ - { MTX6, 0x80 }, /* "matrix coefficient 6" */ - { COM13, COM13_UVSAT }, - { 0xff, 0xff }, /* END MARKER */ -}; - -static struct regval_list ov7670_fmt_rgb565[] = { - { COM7, COM7_FMT_RGB565 }, /* Selects RGB mode */ - { RGB444, 0 }, /* No RGB444 please */ - { COM1, 0x0 }, /* CCIR601 */ - { COM15, COM15_RGB565 |COM15_R00FF }, - { MVFP, MVFP_SUN }, - { COM9, 0x6A }, /* 128x gain ceiling; 0x8 is reserved bit */ - { MTX1, 0xb3 }, /* "matrix coefficient 1" */ - { MTX2, 0xb3 }, /* "matrix coefficient 2" */ - { MTX3, 0 }, /* vb */ - { MTX4, 0x3d }, /* "matrix coefficient 4" */ - { MTX5, 0xa7 }, /* "matrix coefficient 5" */ - { MTX6, 0xe4 }, /* "matrix coefficient 6" */ - { COM13, COM13_UVSAT }, - { 0xff, 0xff }, /* END MARKER */ -}; - - -static struct regval_list ov7670_vga[] = { - { COM3, 0x00 }, - { COM14, 0x00 }, - { SCALING_XSC, 0x3A }, - { SCALING_YSC, 0x35 }, - { SCALING_DCWCTR, 0x11 }, - { SCALING_PCLK_DIV, 0xF0 }, - { SCALING_PCLK_DELAY, 0x02 }, - { 0xff, 0xff }, -}; - -static struct regval_list ov7670_qvga[] = { - { COM3, 0x04 }, - { COM14, 0x19 }, - { SCALING_XSC, 0x3A }, - { SCALING_YSC, 0x35 }, - { SCALING_DCWCTR, 0x11 }, - { SCALING_PCLK_DIV, 0xF1 }, - { SCALING_PCLK_DELAY, 0x02 }, - { 0xff, 0xff }, -}; - -static struct regval_list ov7670_qqvga[] = { - { COM3, 0x04 }, //DCW enable - { COM14, 0x1a }, //pixel clock divided by 4, manual scaling enable, DCW and PCLK controlled by register - { SCALING_XSC, 0x3a }, - { SCALING_YSC, 0x35 }, - { SCALING_DCWCTR, 0x22 }, //downsample by 4 - { SCALING_PCLK_DIV, 0xf2 }, //pixel clock divided by 4 - { SCALING_PCLK_DELAY, 0x02 }, - { 0xff, 0xff }, -}; - -/* - * Write a list of register settings; ff/ff stops the process. - */ -static int ov7670_write_array(sensor_t *sensor, struct regval_list *vals) -{ -int ret = 0; - - while ( (vals->reg_num != 0xff || vals->value != 0xff) && (ret == 0) ) { - ret = SCCB_Write(sensor->slv_addr, vals->reg_num, vals->value); - - ESP_LOGD(TAG, "reset reg %02X, W(%02X) R(%02X)", vals->reg_num, - vals->value, SCCB_Read(sensor->slv_addr, vals->reg_num) ); - - vals++; - } - - return ret; -} - -/* - * Calculate the frame control registers. - */ -static int ov7670_frame_control(sensor_t *sensor, int hstart, int hstop, int vstart, int vstop) -{ -struct regval_list frame[7]; - - frame[0].reg_num = HSTART; - frame[0].value = (hstart >> 3); - - frame[1].reg_num = HSTOP; - frame[1].value = (hstop >> 3); - - frame[2].reg_num = HREF; - frame[2].value = (((hstop & 0x07) << 3) | (hstart & 0x07)); - - frame[3].reg_num = VSTART; - frame[3].value = (vstart >> 2); - - frame[4].reg_num = VSTOP; - frame[4].value = (vstop >> 2); - - frame[5].reg_num = VREF; - frame[5].value = (((vstop & 0x02) << 2) | (vstart & 0x02)); - - /* End mark */ - frame[5].reg_num = 0xFF; - frame[5].value = 0xFF; - - return ov7670_write_array(sensor, frame); -} - -static int reset(sensor_t *sensor) -{ - int ret; - - // Reset all registers - SCCB_Write(sensor->slv_addr, COM7, COM7_RESET); - - // Delay 10 ms - vTaskDelay(10 / portTICK_PERIOD_MS); - - ret = ov7670_write_array(sensor, ov7670_default_regs); - - // Delay - vTaskDelay(30 / portTICK_PERIOD_MS); - - return ret; -} - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ -int ret; - - switch (pixformat) { - case PIXFORMAT_RGB565: - case PIXFORMAT_RGB888: - ret = ov7670_write_array(sensor, ov7670_fmt_rgb565); - break; - - case PIXFORMAT_YUV422: - case PIXFORMAT_GRAYSCALE: - default: - ret = ov7670_write_array(sensor, ov7670_fmt_yuv422); - break; - } - - vTaskDelay(30 / portTICK_PERIOD_MS); - - /* - * If we're running RGB565, we must rewrite clkrc after setting - * the other parameters or the image looks poor. If we're *not* - * doing RGB565, we must not rewrite clkrc or the image looks - * *really* poor. - * - * (Update) Now that we retain clkrc state, we should be able - * to write it unconditionally, and that will make the frame - * rate persistent too. - */ - if (pixformat == PIXFORMAT_RGB565) { - ret = SCCB_Write(sensor->slv_addr, CLKRC, ov7670_clkrc); - } - - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret; - - // store clkrc before changing window settings... - ov7670_clkrc = SCCB_Read(sensor->slv_addr, CLKRC); - - switch (framesize){ - case FRAMESIZE_VGA: - if( (ret = ov7670_write_array(sensor, ov7670_vga)) == 0 ) { - /* These values from Omnivision */ - ret = ov7670_frame_control(sensor, 158, 14, 10, 490); - } - break; - case FRAMESIZE_QVGA: - if( (ret = ov7670_write_array(sensor, ov7670_qvga)) == 0 ) { - /* These values from Omnivision */ - ret = ov7670_frame_control(sensor, 158, 14, 10, 490); - } - break; - case FRAMESIZE_QQVGA: - if( (ret = ov7670_write_array(sensor, ov7670_qqvga)) == 0 ) { - /* These values from Omnivision */ - ret = ov7670_frame_control(sensor, 158, 14, 10, 490); - } - break; - - default: - ret = -1; - } - - vTaskDelay(30 / portTICK_PERIOD_MS); - - if (ret == 0) { - sensor->status.framesize = framesize; - } - - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - uint8_t ret = 0; - // Read register scaling_xsc - uint8_t reg = SCCB_Read(sensor->slv_addr, SCALING_XSC); - - // Pattern to set color bar bit[0]=0 in every case - reg = SCALING_XSC_CBAR(reg); - - // Write pattern to SCALING_XSC - ret = SCCB_Write(sensor->slv_addr, SCALING_XSC, reg); - - // Read register scaling_ysc - reg = SCCB_Read(sensor->slv_addr, SCALING_YSC); - - // Pattern to set color bar bit[0]=0 in every case - reg = SCALING_YSC_CBAR(reg, enable); - - // Write pattern to SCALING_YSC - ret = ret | SCCB_Write(sensor->slv_addr, SCALING_YSC, reg); - - // return 0 or 0xFF - return ret; -} - -static int set_whitebal(sensor_t *sensor, int enable) -{ - // Read register COM8 - uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); - - // Set white bal on/off - reg = COM8_SET_AWB(reg, enable); - - // Write back register COM8 - return SCCB_Write(sensor->slv_addr, COM8, reg); -} - -static int set_gain_ctrl(sensor_t *sensor, int enable) -{ - // Read register COM8 - uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); - - // Set white bal on/off - reg = COM8_SET_AGC(reg, enable); - - // Write back register COM8 - return SCCB_Write(sensor->slv_addr, COM8, reg); -} - -static int set_exposure_ctrl(sensor_t *sensor, int enable) -{ - // Read register COM8 - uint8_t reg = SCCB_Read(sensor->slv_addr, COM8); - - // Set white bal on/off - reg = COM8_SET_AEC(reg, enable); - - // Write back register COM8 - return SCCB_Write(sensor->slv_addr, COM8, reg); -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - // Read register MVFP - uint8_t reg = SCCB_Read(sensor->slv_addr, MVFP); - - // Set mirror on/off - reg = MVFP_SET_MIRROR(reg, enable); - - // Write back register MVFP - return SCCB_Write(sensor->slv_addr, MVFP, reg); -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - // Read register MVFP - uint8_t reg = SCCB_Read(sensor->slv_addr, MVFP); - - // Set mirror on/off - reg = MVFP_SET_FLIP(reg, enable); - - // Write back register MVFP - return SCCB_Write(sensor->slv_addr, MVFP, reg); -} - -static int init_status(sensor_t *sensor) -{ - sensor->status.awb = 0; - sensor->status.aec = 0; - sensor->status.agc = 0; - sensor->status.hmirror = 0; - sensor->status.vflip = 0; - sensor->status.colorbar = 0; - return 0; -} - -static int set_dummy(sensor_t *sensor, int val){ return -1; } -static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val){ return -1; } - -int ov7670_detect(int slv_addr, sensor_id_t *id) -{ - if (OV7670_SCCB_ADDR == slv_addr) { - SCCB_Write(slv_addr, 0xFF, 0x01);//bank sensor - uint16_t PID = SCCB_Read(slv_addr, 0x0A); - if (OV7670_PID == PID) { - id->PID = PID; - id->VER = SCCB_Read(slv_addr, REG_VER); - id->MIDL = SCCB_Read(slv_addr, REG_MIDL); - id->MIDH = SCCB_Read(slv_addr, REG_MIDH); - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int ov7670_init(sensor_t *sensor) -{ - // Set function pointers - sensor->reset = reset; - sensor->init_status = init_status; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_colorbar = set_colorbar; - sensor->set_whitebal = set_whitebal; - sensor->set_gain_ctrl = set_gain_ctrl; - sensor->set_exposure_ctrl = set_exposure_ctrl; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - - //not supported - sensor->set_brightness= set_dummy; - sensor->set_saturation= set_dummy; - sensor->set_quality = set_dummy; - sensor->set_gainceiling = set_gainceiling_dummy; - sensor->set_aec2 = set_dummy; - sensor->set_aec_value = set_dummy; - sensor->set_special_effect = set_dummy; - sensor->set_wb_mode = set_dummy; - sensor->set_ae_level = set_dummy; - sensor->set_dcw = set_dummy; - sensor->set_bpc = set_dummy; - sensor->set_wpc = set_dummy; - sensor->set_awb_gain = set_dummy; - sensor->set_agc_gain = set_dummy; - sensor->set_raw_gma = set_dummy; - sensor->set_lenc = set_dummy; - sensor->set_sharpness = set_dummy; - sensor->set_denoise = set_dummy; - - // Retrieve sensor's signature - sensor->id.MIDH = SCCB_Read(sensor->slv_addr, REG_MIDH); - sensor->id.MIDL = SCCB_Read(sensor->slv_addr, REG_MIDL); - sensor->id.PID = SCCB_Read(sensor->slv_addr, REG_PID); - sensor->id.VER = SCCB_Read(sensor->slv_addr, REG_VER); - - ESP_LOGD(TAG, "OV7670 Attached"); - - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/ov7725.c b/lib/libesp32_div/esp32-camera/sensors/ov7725.c deleted file mode 100644 index ad5d89541..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/ov7725.c +++ /dev/null @@ -1,575 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV7725 driver. - * - */ -#include -#include -#include -#include -#include "sccb.h" -#include "xclk.h" -#include "ov7725.h" -#include "ov7725_regs.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char* TAG = "ov7725"; -#endif - - -static const uint8_t default_regs[][2] = { - {COM3, COM3_SWAP_YUV}, - {COM7, COM7_RES_QVGA | COM7_FMT_YUV}, - - {COM4, 0x01 | 0x00}, /* bypass PLL (0x00:off, 0x40:4x, 0x80:6x, 0xC0:8x) */ - {CLKRC, 0x80 | 0x03}, /* Res/Bypass pre-scalar (0x40:bypass, 0x00-0x3F:prescaler PCLK=XCLK/(prescaler + 1)/2 ) */ - - // QVGA Window Size - {HSTART, 0x3F}, - {HSIZE, 0x50}, - {VSTART, 0x03}, - {VSIZE, 0x78}, - {HREF, 0x00}, - - // Scale down to QVGA Resolution - {HOUTSIZE, 0x50}, - {VOUTSIZE, 0x78}, - {EXHCH, 0x00}, - - {COM12, 0x03}, - {TGT_B, 0x7F}, - {FIXGAIN, 0x09}, - {AWB_CTRL0, 0xE0}, - {DSP_CTRL1, 0xFF}, - - {DSP_CTRL2, DSP_CTRL2_VDCW_EN | DSP_CTRL2_HDCW_EN | DSP_CTRL2_HZOOM_EN | DSP_CTRL2_VZOOM_EN}, - - {DSP_CTRL3, 0x00}, - {DSP_CTRL4, 0x00}, - {DSPAUTO, 0xFF}, - - {COM8, 0xF0}, - {COM6, 0xC5}, - {COM9, 0x11}, - {COM10, COM10_VSYNC_NEG | COM10_PCLK_MASK}, //Invert VSYNC and MASK PCLK - {BDBASE, 0x7F}, - {DBSTEP, 0x03}, - {AEW, 0x96}, - {AEB, 0x64}, - {VPT, 0xA1}, - {EXHCL, 0x00}, - {AWB_CTRL3, 0xAA}, - {COM8, 0xFF}, - - //Gamma - {GAM1, 0x0C}, - {GAM2, 0x16}, - {GAM3, 0x2A}, - {GAM4, 0x4E}, - {GAM5, 0x61}, - {GAM6, 0x6F}, - {GAM7, 0x7B}, - {GAM8, 0x86}, - {GAM9, 0x8E}, - {GAM10, 0x97}, - {GAM11, 0xA4}, - {GAM12, 0xAF}, - {GAM13, 0xC5}, - {GAM14, 0xD7}, - {GAM15, 0xE8}, - - {SLOP, 0x20}, - {EDGE1, 0x05}, - {EDGE2, 0x03}, - {EDGE3, 0x00}, - {DNSOFF, 0x01}, - - {MTX1, 0xB0}, - {MTX2, 0x9D}, - {MTX3, 0x13}, - {MTX4, 0x16}, - {MTX5, 0x7B}, - {MTX6, 0x91}, - {MTX_CTRL, 0x1E}, - - {BRIGHTNESS, 0x08}, - {CONTRAST, 0x30}, - {UVADJ0, 0x81}, - {SDE, (SDE_CONT_BRIGHT_EN | SDE_SATURATION_EN)}, - - // For 30 fps/60Hz - {DM_LNL, 0x00}, - {DM_LNH, 0x00}, - {BDBASE, 0x7F}, - {DBSTEP, 0x03}, - - // Lens Correction, should be tuned with real camera module - {LC_RADI, 0x10}, - {LC_COEF, 0x10}, - {LC_COEFB, 0x14}, - {LC_COEFR, 0x17}, - {LC_CTR, 0x05}, - {COM5, 0xF5}, //0x65 - - {0x00, 0x00}, -}; - -static int get_reg(sensor_t *sensor, int reg, int mask) -{ - int ret = SCCB_Read(sensor->slv_addr, reg & 0xFF); - if(ret > 0){ - ret &= mask; - } - return ret; -} - -static int set_reg(sensor_t *sensor, int reg, int mask, int value) -{ - int ret = 0; - ret = SCCB_Read(sensor->slv_addr, reg & 0xFF); - if(ret < 0){ - return ret; - } - value = (ret & ~mask) | (value & mask); - ret = SCCB_Write(sensor->slv_addr, reg & 0xFF, value); - return ret; -} - -static int set_reg_bits(sensor_t *sensor, uint8_t reg, uint8_t offset, uint8_t length, uint8_t value) -{ - int ret = 0; - ret = SCCB_Read(sensor->slv_addr, reg); - if(ret < 0){ - return ret; - } - uint8_t mask = ((1 << length) - 1) << offset; - value = (ret & ~mask) | ((value << offset) & mask); - ret = SCCB_Write(sensor->slv_addr, reg & 0xFF, value); - return ret; -} - -static int get_reg_bits(sensor_t *sensor, uint8_t reg, uint8_t offset, uint8_t length) -{ - int ret = 0; - ret = SCCB_Read(sensor->slv_addr, reg); - if(ret < 0){ - return ret; - } - uint8_t mask = ((1 << length) - 1) << offset; - return (ret & mask) >> offset; -} - - -static int reset(sensor_t *sensor) -{ - int i=0; - const uint8_t (*regs)[2]; - - // Reset all registers - SCCB_Write(sensor->slv_addr, COM7, COM7_RESET); - - // Delay 10 ms - vTaskDelay(10 / portTICK_PERIOD_MS); - - // Write default regsiters - for (i=0, regs = default_regs; regs[i][0]; i++) { - SCCB_Write(sensor->slv_addr, regs[i][0], regs[i][1]); - } - - // Delay - vTaskDelay(30 / portTICK_PERIOD_MS); - - return 0; -} - - -static int set_pixformat(sensor_t *sensor, pixformat_t pixformat) -{ - int ret=0; - sensor->pixformat = pixformat; - // Read register COM7 - uint8_t reg = SCCB_Read(sensor->slv_addr, COM7); - - switch (pixformat) { - case PIXFORMAT_RGB565: - reg = COM7_SET_RGB(reg, COM7_FMT_RGB565); - break; - case PIXFORMAT_YUV422: - case PIXFORMAT_GRAYSCALE: - reg = COM7_SET_FMT(reg, COM7_FMT_YUV); - break; - default: - return -1; - } - - // Write back register COM7 - ret = SCCB_Write(sensor->slv_addr, COM7, reg); - - // Delay - vTaskDelay(30 / portTICK_PERIOD_MS); - - return ret; -} - -static int set_framesize(sensor_t *sensor, framesize_t framesize) -{ - int ret=0; - if (framesize > FRAMESIZE_VGA) { - return -1; - } - uint16_t w = resolution[framesize].width; - uint16_t h = resolution[framesize].height; - uint8_t reg = SCCB_Read(sensor->slv_addr, COM7); - - sensor->status.framesize = framesize; - - // Write MSBs - ret |= SCCB_Write(sensor->slv_addr, HOUTSIZE, w>>2); - ret |= SCCB_Write(sensor->slv_addr, VOUTSIZE, h>>1); - - ret |= SCCB_Write(sensor->slv_addr, HSIZE, w>>2); - ret |= SCCB_Write(sensor->slv_addr, VSIZE, h>>1); - - // Write LSBs - ret |= SCCB_Write(sensor->slv_addr, HREF, ((w&0x3) | ((h&0x1) << 2))); - - if (framesize < FRAMESIZE_VGA) { - // Enable auto-scaling/zooming factors - ret |= SCCB_Write(sensor->slv_addr, DSPAUTO, 0xFF); - - ret |= SCCB_Write(sensor->slv_addr, HSTART, 0x3F); - ret |= SCCB_Write(sensor->slv_addr, VSTART, 0x03); - - ret |= SCCB_Write(sensor->slv_addr, COM7, reg | COM7_RES_QVGA); - - ret |= SCCB_Write(sensor->slv_addr, CLKRC, 0x80 | 0x01); - - } else { - // Disable auto-scaling/zooming factors - ret |= SCCB_Write(sensor->slv_addr, DSPAUTO, 0xF3); - - // Clear auto-scaling/zooming factors - ret |= SCCB_Write(sensor->slv_addr, SCAL0, 0x00); - ret |= SCCB_Write(sensor->slv_addr, SCAL1, 0x00); - ret |= SCCB_Write(sensor->slv_addr, SCAL2, 0x00); - - ret |= SCCB_Write(sensor->slv_addr, HSTART, 0x23); - ret |= SCCB_Write(sensor->slv_addr, VSTART, 0x07); - - ret |= SCCB_Write(sensor->slv_addr, COM7, reg & ~COM7_RES_QVGA); - - ret |= SCCB_Write(sensor->slv_addr, CLKRC, 0x80 | 0x03); - } - - // Delay - vTaskDelay(30 / portTICK_PERIOD_MS); - - return ret; -} - -static int set_colorbar(sensor_t *sensor, int enable) -{ - int ret=0; - uint8_t reg; - sensor->status.colorbar = enable; - - // Read reg COM3 - reg = SCCB_Read(sensor->slv_addr, COM3); - // Enable colorbar test pattern output - reg = COM3_SET_CBAR(reg, enable); - // Write back COM3 - ret |= SCCB_Write(sensor->slv_addr, COM3, reg); - - // Read reg DSP_CTRL3 - reg = SCCB_Read(sensor->slv_addr, DSP_CTRL3); - // Enable DSP colorbar output - reg = DSP_CTRL3_SET_CBAR(reg, enable); - // Write back DSP_CTRL3 - ret |= SCCB_Write(sensor->slv_addr, DSP_CTRL3, reg); - - return ret; -} - -static int set_whitebal(sensor_t *sensor, int enable) -{ - if(set_reg_bits(sensor, COM8, 1, 1, enable) >= 0){ - sensor->status.awb = !!enable; - } - return sensor->status.awb; -} - -static int set_gain_ctrl(sensor_t *sensor, int enable) -{ - if(set_reg_bits(sensor, COM8, 2, 1, enable) >= 0){ - sensor->status.agc = !!enable; - } - return sensor->status.agc; -} - -static int set_exposure_ctrl(sensor_t *sensor, int enable) -{ - if(set_reg_bits(sensor, COM8, 0, 1, enable) >= 0){ - sensor->status.aec = !!enable; - } - return sensor->status.aec; -} - -static int set_hmirror(sensor_t *sensor, int enable) -{ - if(set_reg_bits(sensor, COM3, 6, 1, enable) >= 0){ - sensor->status.hmirror = !!enable; - } - return sensor->status.hmirror; -} - -static int set_vflip(sensor_t *sensor, int enable) -{ - if(set_reg_bits(sensor, COM3, 7, 1, enable) >= 0){ - sensor->status.vflip = !!enable; - } - return sensor->status.vflip; -} - -static int set_dcw_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, 0x65, 2, 1, !enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set dcw to: %d", enable); - sensor->status.dcw = enable; - } - return ret; -} - -static int set_aec2(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, COM8, 7, 1, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set aec2 to: %d", enable); - sensor->status.aec2 = enable; - } - return ret; -} - -static int set_bpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, 0x64, 1, 1, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set bpc to: %d", enable); - sensor->status.bpc = enable; - } - return ret; -} - -static int set_wpc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, 0x64, 0, 1, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set wpc to: %d", enable); - sensor->status.wpc = enable; - } - return ret; -} - -static int set_raw_gma_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, 0x64, 2, 1, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set raw_gma to: %d", enable); - sensor->status.raw_gma = enable; - } - return ret; -} - -static int set_lenc_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, LC_CTR, 0, 1, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set lenc to: %d", enable); - sensor->status.lenc = enable; - } - return ret; -} - -//real gain -static int set_agc_gain(sensor_t *sensor, int gain) -{ - int ret = 0; - ret = set_reg_bits(sensor, COM9, 4, 3, gain % 5); - if (ret == 0) { - ESP_LOGD(TAG, "Set gain to: %d", gain); - sensor->status.agc_gain = gain; - } - return ret; -} - -static int set_aec_value(sensor_t *sensor, int value) -{ - int ret = 0; - ret = SCCB_Write(sensor->slv_addr, AEC, value & 0xff) | SCCB_Write(sensor->slv_addr, AECH, value >> 8); - if (ret == 0) { - ESP_LOGD(TAG, "Set aec_value to: %d", value); - sensor->status.aec_value = value; - } - return ret; -} - -static int set_awb_gain_dsp(sensor_t *sensor, int enable) -{ - int ret = 0; - ret = set_reg_bits(sensor, 0x63, 7, 1, enable); - if (ret == 0) { - ESP_LOGD(TAG, "Set awb_gain to: %d", enable); - sensor->status.awb_gain = enable; - } - return ret; -} - -static int set_brightness(sensor_t *sensor, int level) -{ - int ret = 0; - ret = SCCB_Write(sensor->slv_addr, 0x9B, level); - if (ret == 0) { - ESP_LOGD(TAG, "Set brightness to: %d", level); - sensor->status.brightness = level; - } - return ret; -} - -static int set_contrast(sensor_t *sensor, int level) -{ - int ret = 0; - ret = SCCB_Write(sensor->slv_addr, 0x9C, level); - if (ret == 0) { - ESP_LOGD(TAG, "Set contrast to: %d", level); - sensor->status.contrast = level; - } - return ret; -} - -static int init_status(sensor_t *sensor) -{ - sensor->status.brightness = SCCB_Read(sensor->slv_addr, 0x9B); - sensor->status.contrast = SCCB_Read(sensor->slv_addr, 0x9C); - sensor->status.saturation = 0; - sensor->status.ae_level = 0; - sensor->status.special_effect = get_reg_bits(sensor, 0x64, 5, 1); - sensor->status.wb_mode = get_reg_bits(sensor, 0x6B, 7, 1); - sensor->status.agc_gain = get_reg_bits(sensor, COM9, 4, 3); - sensor->status.aec_value = SCCB_Read(sensor->slv_addr, AEC) | (SCCB_Read(sensor->slv_addr, AECH) << 8); - sensor->status.gainceiling = SCCB_Read(sensor->slv_addr, 0x00); - sensor->status.awb = get_reg_bits(sensor, COM8, 1, 1); - sensor->status.awb_gain = get_reg_bits(sensor, 0x63, 7, 1); - sensor->status.aec = get_reg_bits(sensor, COM8, 0, 1); - sensor->status.aec2 = get_reg_bits(sensor, COM8, 7, 1); - sensor->status.agc = get_reg_bits(sensor, COM8, 2, 1); - sensor->status.bpc = get_reg_bits(sensor, 0x64, 1, 1); - sensor->status.wpc = get_reg_bits(sensor, 0x64, 0, 1); - sensor->status.raw_gma = get_reg_bits(sensor, 0x64, 2, 1); - sensor->status.lenc = get_reg_bits(sensor, LC_CTR, 0, 1); - sensor->status.hmirror = get_reg_bits(sensor, COM3, 6, 1); - sensor->status.vflip = get_reg_bits(sensor, COM3, 7, 1); - sensor->status.dcw = get_reg_bits(sensor, 0x65, 2, 1); - sensor->status.colorbar = get_reg_bits(sensor, COM3, 0, 1); - sensor->status.sharpness = get_reg_bits(sensor, EDGE0, 0, 5); - sensor->status.denoise = SCCB_Read(sensor->slv_addr, 0x8E); - return 0; -} - -static int set_dummy(sensor_t *sensor, int val){ return -1; } -static int set_gainceiling_dummy(sensor_t *sensor, gainceiling_t val){ return -1; } -static int set_res_raw(sensor_t *sensor, int startX, int startY, int endX, int endY, int offsetX, int offsetY, int totalX, int totalY, int outputX, int outputY, bool scale, bool binning){return -1;} -static int _set_pll(sensor_t *sensor, int bypass, int multiplier, int sys_div, int root_2x, int pre_div, int seld5, int pclk_manual, int pclk_div){return -1;} - -static int set_xclk(sensor_t *sensor, int timer, int xclk) -{ - int ret = 0; - sensor->xclk_freq_hz = xclk * 1000000U; - ret = xclk_timer_conf(timer, sensor->xclk_freq_hz); - return ret; -} - -int ov7725_detect(int slv_addr, sensor_id_t *id) -{ - if (OV7725_SCCB_ADDR == slv_addr) { - SCCB_Write(slv_addr, 0xFF, 0x01);//bank sensor - uint16_t PID = SCCB_Read(slv_addr, 0x0A); - if (OV7725_PID == PID) { - id->PID = PID; - id->VER = SCCB_Read(slv_addr, REG_VER); - id->MIDL = SCCB_Read(slv_addr, REG_MIDL); - id->MIDH = SCCB_Read(slv_addr, REG_MIDH); - return PID; - } else { - ESP_LOGI(TAG, "Mismatch PID=0x%x", PID); - } - } - return 0; -} - -int ov7725_init(sensor_t *sensor) -{ - // Set function pointers - sensor->reset = reset; - sensor->init_status = init_status; - sensor->set_pixformat = set_pixformat; - sensor->set_framesize = set_framesize; - sensor->set_colorbar = set_colorbar; - sensor->set_whitebal = set_whitebal; - sensor->set_gain_ctrl = set_gain_ctrl; - sensor->set_exposure_ctrl = set_exposure_ctrl; - sensor->set_hmirror = set_hmirror; - sensor->set_vflip = set_vflip; - - sensor->set_brightness = set_brightness; - sensor->set_contrast = set_contrast; - sensor->set_aec2 = set_aec2; - sensor->set_aec_value = set_aec_value; - sensor->set_awb_gain = set_awb_gain_dsp; - sensor->set_agc_gain = set_agc_gain; - sensor->set_dcw = set_dcw_dsp; - sensor->set_bpc = set_bpc_dsp; - sensor->set_wpc = set_wpc_dsp; - sensor->set_raw_gma = set_raw_gma_dsp; - sensor->set_lenc = set_lenc_dsp; - - //not supported - sensor->set_saturation= set_dummy; - sensor->set_sharpness = set_dummy; - sensor->set_denoise = set_dummy; - sensor->set_quality = set_dummy; - sensor->set_special_effect = set_dummy; - sensor->set_wb_mode = set_dummy; - sensor->set_ae_level = set_dummy; - sensor->set_gainceiling = set_gainceiling_dummy; - - - sensor->get_reg = get_reg; - sensor->set_reg = set_reg; - sensor->set_res_raw = set_res_raw; - sensor->set_pll = _set_pll; - sensor->set_xclk = set_xclk; - - // Retrieve sensor's signature - sensor->id.MIDH = SCCB_Read(sensor->slv_addr, REG_MIDH); - sensor->id.MIDL = SCCB_Read(sensor->slv_addr, REG_MIDL); - sensor->id.PID = SCCB_Read(sensor->slv_addr, REG_PID); - sensor->id.VER = SCCB_Read(sensor->slv_addr, REG_VER); - - ESP_LOGD(TAG, "OV7725 Attached"); - - return 0; -} diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h deleted file mode 100644 index edffca1e0..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308.h +++ /dev/null @@ -1,31 +0,0 @@ -#pragma once - -#include "sensor.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int gc0308_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int gc0308_init(sensor_t *sensor); - -#ifdef __cplusplus -} -#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h deleted file mode 100644 index f1cb4532b..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_regs.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * GC0308 register definitions. - */ -#ifndef __GC0308_REG_REGS_H__ -#define __GC0308_REG_REGS_H__ - -#define RESET_RELATED 0xfe // Bit[7]: Software reset - // Bit[6:5]: NA - // Bit[4]: CISCTL_restart_n - // Bit[3:1]: NA - // Bit[0]: page select - // 0:page0 - // 1:page1 - - -// page0: - - - -/** - * @brief register value - */ - - -#endif // __GC0308_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h deleted file mode 100644 index 32ef3816a..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc0308_settings.h +++ /dev/null @@ -1,245 +0,0 @@ -#ifndef _GC0308_SETTINGS_H_ -#define _GC0308_SETTINGS_H_ - -#include - -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 /* Array end token */ - -static const uint16_t gc0308_sensor_default_regs[][2] = { - {0xfe, 0x00}, - {0xec, 0x20}, - {0x05, 0x00}, - {0x06, 0x00}, - {0x07, 0x00}, - {0x08, 0x00}, - {0x09, 0x01}, - {0x0a, 0xe8}, - {0x0b, 0x02}, - {0x0c, 0x88}, - {0x0d, 0x02}, - {0x0e, 0x02}, - {0x10, 0x26}, - {0x11, 0x0d}, - {0x12, 0x2a}, - {0x13, 0x00}, - {0x14, 0x11}, - {0x15, 0x0a}, - {0x16, 0x05}, - {0x17, 0x01}, - {0x18, 0x44}, - {0x19, 0x44}, - {0x1a, 0x2a}, - {0x1b, 0x00}, - {0x1c, 0x49}, - {0x1d, 0x9a}, - {0x1e, 0x61}, - {0x1f, 0x00}, //pad drv <=24MHz, use 0x00 is ok - {0x20, 0x7f}, - {0x21, 0xfa}, - {0x22, 0x57}, - {0x24, 0xa2}, //YCbYCr - {0x25, 0x0f}, - {0x26, 0x03}, // 0x01 - {0x28, 0x00}, - {0x2d, 0x0a}, - {0x2f, 0x01}, - {0x30, 0xf7}, - {0x31, 0x50}, - {0x32, 0x00}, - {0x33, 0x28}, - {0x34, 0x2a}, - {0x35, 0x28}, - {0x39, 0x04}, - {0x3a, 0x20}, - {0x3b, 0x20}, - {0x3c, 0x00}, - {0x3d, 0x00}, - {0x3e, 0x00}, - {0x3f, 0x00}, - {0x50, 0x14}, // 0x14 - {0x52, 0x41}, - {0x53, 0x80}, - {0x54, 0x80}, - {0x55, 0x80}, - {0x56, 0x80}, - {0x8b, 0x20}, - {0x8c, 0x20}, - {0x8d, 0x20}, - {0x8e, 0x14}, - {0x8f, 0x10}, - {0x90, 0x14}, - {0x91, 0x3c}, - {0x92, 0x50}, -//{0x8b,0x10}, -//{0x8c,0x10}, -//{0x8d,0x10}, -//{0x8e,0x10}, -//{0x8f,0x10}, -//{0x90,0x10}, -//{0x91,0x3c}, -//{0x92,0x50}, - {0x5d, 0x12}, - {0x5e, 0x1a}, - {0x5f, 0x24}, - {0x60, 0x07}, - {0x61, 0x15}, - {0x62, 0x08}, // 0x08 - {0x64, 0x03}, // 0x03 - {0x66, 0xe8}, - {0x67, 0x86}, - {0x68, 0x82}, - {0x69, 0x18}, - {0x6a, 0x0f}, - {0x6b, 0x00}, - {0x6c, 0x5f}, - {0x6d, 0x8f}, - {0x6e, 0x55}, - {0x6f, 0x38}, - {0x70, 0x15}, - {0x71, 0x33}, - {0x72, 0xdc}, - {0x73, 0x00}, - {0x74, 0x02}, - {0x75, 0x3f}, - {0x76, 0x02}, - {0x77, 0x38}, // 0x47 - {0x78, 0x88}, - {0x79, 0x81}, - {0x7a, 0x81}, - {0x7b, 0x22}, - {0x7c, 0xff}, - {0x93, 0x48}, //color matrix default - {0x94, 0x02}, - {0x95, 0x07}, - {0x96, 0xe0}, - {0x97, 0x40}, - {0x98, 0xf0}, - {0xb1, 0x40}, - {0xb2, 0x40}, - {0xb3, 0x40}, //0x40 - {0xb6, 0xe0}, - {0xbd, 0x38}, - {0xbe, 0x36}, - {0xd0, 0xCB}, - {0xd1, 0x10}, - {0xd2, 0x90}, - {0xd3, 0x48}, - {0xd5, 0xF2}, - {0xd6, 0x16}, - {0xdb, 0x92}, - {0xdc, 0xA5}, - {0xdf, 0x23}, - {0xd9, 0x00}, - {0xda, 0x00}, - {0xe0, 0x09}, - {0xed, 0x04}, - {0xee, 0xa0}, - {0xef, 0x40}, - {0x80, 0x03}, - - {0x9F, 0x10}, - {0xA0, 0x20}, - {0xA1, 0x38}, - {0xA2, 0x4e}, - {0xA3, 0x63}, - {0xA4, 0x76}, - {0xA5, 0x87}, - {0xA6, 0xa2}, - {0xA7, 0xb8}, - {0xA8, 0xca}, - {0xA9, 0xd8}, - {0xAA, 0xe3}, - {0xAB, 0xeb}, - {0xAC, 0xf0}, - {0xAD, 0xF8}, - {0xAE, 0xFd}, - {0xAF, 0xFF}, - - {0xc0, 0x00}, - {0xc1, 0x10}, - {0xc2, 0x1c}, - {0xc3, 0x30}, - {0xc4, 0x43}, - {0xc5, 0x54}, - {0xc6, 0x65}, - {0xc7, 0x75}, - {0xc8, 0x93}, - {0xc9, 0xB0}, - {0xca, 0xCB}, - {0xcb, 0xE6}, - {0xcc, 0xFF}, - {0xf0, 0x02}, - {0xf1, 0x01}, - {0xf2, 0x02}, - {0xf3, 0x30}, - {0xf7, 0x04}, - {0xf8, 0x02}, - {0xf9, 0x9f}, - {0xfa, 0x78}, - {0xfe, 0x01}, - {0x00, 0xf5}, - {0x02, 0x20}, - {0x04, 0x10}, - {0x05, 0x08}, - {0x06, 0x20}, - {0x08, 0x0a}, - {0x0a, 0xa0}, - {0x0b, 0x60}, - {0x0c, 0x08}, - {0x0e, 0x44}, - {0x0f, 0x32}, - {0x10, 0x41}, - {0x11, 0x37}, - {0x12, 0x22}, - {0x13, 0x19}, - {0x14, 0x44}, - {0x15, 0x44}, - {0x16, 0xc2}, - {0x17, 0xA8}, - {0x18, 0x18}, - {0x19, 0x50}, - {0x1a, 0xd8}, - {0x1b, 0xf5}, - {0x70, 0x40}, - {0x71, 0x58}, - {0x72, 0x30}, - {0x73, 0x48}, - {0x74, 0x20}, - {0x75, 0x60}, - {0x77, 0x20}, - {0x78, 0x32}, - {0x30, 0x03}, - {0x31, 0x40}, - {0x32, 0x10}, - {0x33, 0xe0}, - {0x34, 0xe0}, - {0x35, 0x00}, - {0x36, 0x80}, - {0x37, 0x00}, - {0x38, 0x04}, - {0x39, 0x09}, - {0x3a, 0x12}, - {0x3b, 0x1C}, - {0x3c, 0x28}, - {0x3d, 0x31}, - {0x3e, 0x44}, - {0x3f, 0x57}, - {0x40, 0x6C}, - {0x41, 0x81}, - {0x42, 0x94}, - {0x43, 0xA7}, - {0x44, 0xB8}, - {0x45, 0xD6}, - {0x46, 0xEE}, - {0x47, 0x0d}, - {0x62, 0xf7}, - {0x63, 0x68}, - {0x64, 0xd3}, - {0x65, 0xd3}, - {0x66, 0x60}, - {0xfe, 0x00}, - {REGLIST_TAIL, 0x00}, -}; - -#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h deleted file mode 100644 index 7679f0708..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * GC032A driver. - * - */ -#ifndef __GC032A_H__ -#define __GC032A_H__ - -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int gc032a_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int gc032a_init(sensor_t *sensor); - -#endif // __GC032A_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h deleted file mode 100644 index 5de59d1d2..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_regs.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * GC032A register definitions. - */ -#ifndef __GC032A_REG_REGS_H__ -#define __GC032A_REG_REGS_H__ - -#define SENSOR_ID_HIGH 0XF0 -#define SENSOR_ID_LOW 0XF1 -#define PAD_VB_HIZ_MODE 0XF2 -#define SYNC_OUTPUT 0XF3 -#define I2C_CONFIG 0XF4 -#define PLL_MODE1 0XF7 -#define PLL_MODE2 0XF8 -#define CM_MODE 0XF9 -#define ISP_DIV_MODE 0XFA -#define I2C_DEVICE_ID 0XFB -#define ANALOG_PWC 0XFC -#define ISP_DIV_MODE2 0XFD -#define RESET_RELATED 0XFE // Bit[7]: Software reset - // Bit[6]: cm reset - // Bit[5]: spi reset - // Bit[4]: CISCTL_restart_n - // Bit[3]: PLL_rst - // Bit[2:0]: page select - // 000:page0 - // 001:page1 - // 010:page2 - // 011:page3 - -//----page0----------------------------- -#define P0_EXPOSURE_HIGH 0X03 -#define P0_EXPOSURE_LOW 0X04 -#define P0_HB_HIGH 0X05 -#define P0_HB_LOW 0X06 -#define P0_VB_HIGH 0X07 -#define P0_VB_LOW 0X08 -#define P0_ROW_START_HIGH 0X09 -#define P0_ROW_START_LOW 0X0A -#define P0_COLUMN_START_HIGH 0X0B -#define P0_COLUMN_START_LOW 0X0C -#define P0_WINDOW_HEIGHT_HIGH 0X0D -#define P0_WINDOW_HEIGHT_LOW 0X0E -#define P0_WINDOW_WIDTH_HIGH 0X0F -#define P0_WINDOW_WIDTH_LOW 0X10 -#define P0_SH_DELAY 0X11 -#define P0_VS_ST 0X12 -#define P0_VS_ET 0X13 -#define P0_CISCTL_MODE1 0X17 - -#define P0_BLOCK_ENABLE_1 0X40 -#define P0_AAAA_ENABLE 0X42 -#define P0_SPECIAL_EFFECT 0X43 -#define P0_SYNC_MODE 0X46 -#define P0_GAIN_CODE 0X48 -#define P0_DEBUG_MODE2 0X4C -#define P0_WIN_MODE 0X50 -#define P0_OUT_WIN_Y1_HIGH 0X51 -#define P0_OUT_WIN_Y1_LOW 0X52 -#define P0_OUT_WIN_X1_HIGH 0X53 -#define P0_OUT_WIN_X1_LOW 0X54 -#define P0_OUT_WIN_HEIGHT_HIGH 0X55 -#define P0_OUT_WIN_HEIGHT_LOW 0X56 -#define P0_OUT_WIN_WIDTH_HIGH 0X57 -#define P0_OUT_WIN_WIDTH_LOW 0X58 - -#define P0_GLOBAL_SATURATION 0XD0 -#define P0_SATURATION_CB 0XD1 -#define P0_SATURATION_CR 0XD2 -#define P0_LUMA_CONTRAST 0XD3 -#define P0_CONTRAST_CENTER 0XD4 -#define P0_LUMA_OFFSET 0XD5 -#define P0_FIXED_CB 0XDA -#define P0_FIXED_CR 0XDB - -//----page3----------------------------- -#define P3_IMAGE_WIDTH_LOW 0X5B -#define P3_IMAGE_WIDTH_HIGH 0X5C -#define P3_IMAGE_HEIGHT_LOW 0X5D -#define P3_IMAGE_HEIGHT_HIGH 0X5E - - -#endif //__GC032A_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h deleted file mode 100644 index a19ffc7c6..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc032a_settings.h +++ /dev/null @@ -1,401 +0,0 @@ -#ifndef _GC032A_SETTINGS_H_ -#define _GC032A_SETTINGS_H_ - -#include -#include -#include "esp_attr.h" -#include "gc032a_regs.h" - - -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 - - -/* - * The default register settings, as obtained from OmniVision. There - * is really no making sense of most of these - lots of "reserved" values - * and such. - * - */ -static const uint16_t gc032a_default_regs[][2] = { - /*System*/ - {0xf3, 0xff}, - {0xf5, 0x06}, - {0xf7, 0x01}, - {0xf8, 0x03}, - {0xf9, 0xce}, - {0xfa, 0x00}, - {0xfc, 0x02}, - {0xfe, 0x02}, - {0x81, 0x03}, - - {0xfe, 0x00}, - {0x77, 0x64}, - {0x78, 0x40}, - {0x79, 0x60}, - /*ANALOG & CISCTL*/ - {0xfe, 0x00}, - {0x03, 0x01}, - {0x04, 0xce}, - {0x05, 0x01}, - {0x06, 0xad}, - {0x07, 0x00}, - {0x08, 0x10}, - {0x0a, 0x00}, - {0x0c, 0x00}, - {0x0d, 0x01}, - {0x0e, 0xe8}, // height 488 - {0x0f, 0x02}, - {0x10, 0x88}, // width 648 - {0x17, 0x54}, - {0x19, 0x08}, - {0x1a, 0x0a}, - {0x1f, 0x40}, - {0x20, 0x30}, - {0x2e, 0x80}, - {0x2f, 0x2b}, - {0x30, 0x1a}, - {0xfe, 0x02}, - {0x03, 0x02}, - {0x05, 0xd7}, - {0x06, 0x60}, - {0x08, 0x80}, - {0x12, 0x89}, - - /*blk*/ - {0xfe, 0x00}, - {0x18, 0x02}, - {0xfe, 0x02}, - {0x40, 0x22}, - {0x45, 0x00}, - {0x46, 0x00}, - {0x49, 0x20}, - {0x4b, 0x3c}, - {0x50, 0x20}, - {0x42, 0x10}, - - /*isp*/ - {0xfe, 0x01}, - {0x0a, 0xc5}, - {0x45, 0x00}, - {0xfe, 0x00}, - {0x40, 0xff}, - {0x41, 0x25}, - {0x42, 0xcf}, - {0x43, 0x10}, - {0x44, 0x83}, - {0x46, 0x23}, - {0x49, 0x03}, - {0x52, 0x02}, - {0x54, 0x00}, - {0xfe, 0x02}, - {0x22, 0xf6}, - - /*Shading*/ - {0xfe, 0x01}, - {0xc1, 0x38}, - {0xc2, 0x4c}, - {0xc3, 0x00}, - {0xc4, 0x32}, - {0xc5, 0x24}, - {0xc6, 0x16}, - {0xc7, 0x08}, - {0xc8, 0x08}, - {0xc9, 0x00}, - {0xca, 0x20}, - {0xdc, 0x8a}, - {0xdd, 0xa0}, - {0xde, 0xa6}, - {0xdf, 0x75}, - - /*AWB*/ - {0xfe, 0x01}, - {0x7c, 0x09}, - {0x65, 0x06}, - {0x7c, 0x08}, - {0x56, 0xf4}, - {0x66, 0x0f}, - {0x67, 0x84}, - {0x6b, 0x80}, - {0x6d, 0x12}, - {0x6e, 0xb0}, - {0x86, 0x00}, - {0x87, 0x00}, - {0x88, 0x00}, - {0x89, 0x00}, - {0x8a, 0x00}, - {0x8b, 0x00}, - {0x8c, 0x00}, - {0x8d, 0x00}, - {0x8e, 0x00}, - {0x8f, 0x00}, - {0x90, 0x00}, - {0x91, 0x00}, - {0x92, 0xf4}, - {0x93, 0xd5}, - {0x94, 0x50}, - {0x95, 0x0f}, - {0x96, 0xf4}, - {0x97, 0x2d}, - {0x98, 0x0f}, - {0x99, 0xa6}, - {0x9a, 0x2d}, - {0x9b, 0x0f}, - {0x9c, 0x59}, - {0x9d, 0x2d}, - {0x9e, 0xaa}, - {0x9f, 0x67}, - {0xa0, 0x59}, - {0xa1, 0x00}, - {0xa2, 0x00}, - {0xa3, 0x0a}, - {0xa4, 0x00}, - {0xa5, 0x00}, - {0xa6, 0xd4}, - {0xa7, 0x9f}, - {0xa8, 0x55}, - {0xa9, 0xd4}, - {0xaa, 0x9f}, - {0xab, 0xac}, - {0xac, 0x9f}, - {0xad, 0x55}, - {0xae, 0xd4}, - {0xaf, 0xac}, - {0xb0, 0xd4}, - {0xb1, 0xa3}, - {0xb2, 0x55}, - {0xb3, 0xd4}, - {0xb4, 0xac}, - {0xb5, 0x00}, - {0xb6, 0x00}, - {0xb7, 0x05}, - {0xb8, 0xd6}, - {0xb9, 0x8c}, - - /*CC*/ - {0xfe, 0x01}, - {0xd0, 0x40}, - {0xd1, 0xf8}, - {0xd2, 0x00}, - {0xd3, 0xfa}, - {0xd4, 0x45}, - {0xd5, 0x02}, - - {0xd6, 0x30}, - {0xd7, 0xfa}, - {0xd8, 0x08}, - {0xd9, 0x08}, - {0xda, 0x58}, - {0xdb, 0x02}, - {0xfe, 0x00}, - - /*Gamma*/ - {0xfe, 0x00}, - {0xba, 0x00}, - {0xbb, 0x04}, - {0xbc, 0x0a}, - {0xbd, 0x0e}, - {0xbe, 0x22}, - {0xbf, 0x30}, - {0xc0, 0x3d}, - {0xc1, 0x4a}, - {0xc2, 0x5d}, - {0xc3, 0x6b}, - {0xc4, 0x7a}, - {0xc5, 0x85}, - {0xc6, 0x90}, - {0xc7, 0xa5}, - {0xc8, 0xb5}, - {0xc9, 0xc2}, - {0xca, 0xcc}, - {0xcb, 0xd5}, - {0xcc, 0xde}, - {0xcd, 0xea}, - {0xce, 0xf5}, - {0xcf, 0xff}, - - /*Auto Gamma*/ - {0xfe, 0x00}, - {0x5a, 0x08}, - {0x5b, 0x0f}, - {0x5c, 0x15}, - {0x5d, 0x1c}, - {0x5e, 0x28}, - {0x5f, 0x36}, - {0x60, 0x45}, - {0x61, 0x51}, - {0x62, 0x6a}, - {0x63, 0x7d}, - {0x64, 0x8d}, - {0x65, 0x98}, - {0x66, 0xa2}, - {0x67, 0xb5}, - {0x68, 0xc3}, - {0x69, 0xcd}, - {0x6a, 0xd4}, - {0x6b, 0xdc}, - {0x6c, 0xe3}, - {0x6d, 0xf0}, - {0x6e, 0xf9}, - {0x6f, 0xff}, - - /*Gain*/ - {0xfe, 0x00}, - {0x70, 0x50}, - - /*AEC*/ - {0xfe, 0x00}, - {0x4f, 0x01}, - {0xfe, 0x01}, - {0x0d, 0x00}, - {0x12, 0xa0}, - {0x13, 0x3a}, - {0x44, 0x04}, - {0x1f, 0x30}, - {0x20, 0x40}, - {0x26, 0x9a}, - {0x3e, 0x20}, - {0x3f, 0x2d}, - {0x40, 0x40}, - {0x41, 0x5b}, - {0x42, 0x82}, - {0x43, 0xb7}, - {0x04, 0x0a}, - {0x02, 0x79}, - {0x03, 0xc0}, - - /*measure window*/ - {0xfe, 0x01}, - {0xcc, 0x08}, - {0xcd, 0x08}, - {0xce, 0xa4}, - {0xcf, 0xec}, - - /*DNDD*/ - {0xfe, 0x00}, - {0x81, 0xb8}, - {0x82, 0x12}, - {0x83, 0x0a}, - {0x84, 0x01}, - {0x86, 0x50}, - {0x87, 0x18}, - {0x88, 0x10}, - {0x89, 0x70}, - {0x8a, 0x20}, - {0x8b, 0x10}, - {0x8c, 0x08}, - {0x8d, 0x0a}, - - /*Intpee*/ - {0xfe, 0x00}, - {0x8f, 0xaa}, - {0x90, 0x9c}, - {0x91, 0x52}, - {0x92, 0x03}, - {0x93, 0x03}, - {0x94, 0x08}, - {0x95, 0x44}, - {0x97, 0x00}, - {0x98, 0x00}, - - /*ASDE*/ - {0xfe, 0x00}, - {0xa1, 0x30}, - {0xa2, 0x41}, - {0xa4, 0x30}, - {0xa5, 0x20}, - {0xaa, 0x30}, - {0xac, 0x32}, - - /*YCP*/ - {0xfe, 0x00}, - {0xd1, 0x3c}, - {0xd2, 0x3c}, - {0xd3, 0x38}, - {0xd6, 0xf4}, - {0xd7, 0x1d}, - {0xdd, 0x73}, - {0xde, 0x84}, - - /*Banding*/ - {0xfe, 0x00}, - {0x05, 0x01}, - {0x06, 0xad}, - {0x07, 0x00}, - {0x08, 0x10}, - - {0xfe, 0x01}, - {0x25, 0x00}, - {0x26, 0x9a}, - - {0x27, 0x01}, - {0x28, 0xce}, - {0x29, 0x02}, - {0x2a, 0x68}, - {0x2b, 0x02}, - {0x2c, 0x68}, - {0x2d, 0x07}, - {0x2e, 0xd2}, - {0x2f, 0x0b}, - {0x30, 0x6e}, - {0x31, 0x0e}, - {0x32, 0x70}, - {0x33, 0x12}, - {0x34, 0x0c}, - {0x3c, 0x30}, - - /*Analog&Cisctl*/ - {0xfe, 0x00}, - {0x05, 0x01}, - {0x06, 0xa0}, - {0x07, 0x00}, - {0x08, 0x20}, - {0x0a, 0x78}, - {0x0c, 0xa0}, - {0x0d, 0x00}, //window_height [8] - {0x0e, 0xf8}, //window_height [7:0] 248 - {0x0f, 0x01}, //window_width [9:8] - {0x10, 0x48}, //window_width [7:0] 328 - - {0x55, 0x00}, - {0x56, 0xf0}, // 240 - {0x57, 0x01}, - {0x58, 0x40}, // 320 - - /*SPI*/ - {0xfe, 0x03}, - {0x5b, 0x40}, - {0x5c, 0x01}, - {0x5d, 0xf0}, - {0x5e, 0x00}, - - /*AEC*/ - {0xfe, 0x01}, - {0x25, 0x00}, //step - {0x26, 0x63}, - {0x27, 0x01}, - {0x28, 0x29}, - {0x29, 0x01}, - {0x2a, 0x29}, - {0x2b, 0x01}, - {0x2c, 0x29}, - {0x2d, 0x01}, - {0x2e, 0x29}, - {0x2f, 0x01}, - {0x30, 0x29}, - {0x31, 0x01}, - {0x32, 0x29}, - {0x33, 0x01}, - {0x34, 0x29}, - {0x3c, 0x00}, - - /*measure window*/ - {0xfe, 0x01}, - {0xcc, 0x04}, - {0xcd, 0x04}, - {0xce, 0x72}, - {0xcf, 0x52}, - {REGLIST_TAIL, 0x00}, -}; - -#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h deleted file mode 100644 index 6c5b60f70..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef __GC2145_H__ -#define __GC2145_H__ - -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int gc2145_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int gc2145_init(sensor_t *sensor); - -#endif // __GC2145_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h deleted file mode 100644 index b034a1689..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_regs.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - * GC2145 register definitions. - */ -#ifndef __GC2145_REG_REGS_H__ -#define __GC2145_REG_REGS_H__ - -#define CHIP_ID_HIGH 0XF0 -#define CHIP_ID_LOW 0XF1 -#define PLL_MODE1 0XF7 -#define PLL_MODE2 0XF8 -#define CM_MODE 0XF9 -#define CLK_DIV_MODE 0XFA -#define RESET_RELATED 0xfe // Bit[7]: Software reset - // Bit[6]: cm reset - // Bit[5]: mipi reset - // Bit[4]: CISCTL_restart_n - // Bit[3]: NA - // Bit[2:0]: page select - // 000:page0 - // 001:page1 - // 010:page2 - // 011:page3 - -//-page0---------------- - -#define P0_EXPOSURE_HIGH 0X03 -#define P0_EXPOSURE_LOW 0X04 -#define P0_HB_HIGH 0X05 -#define P0_HB_LOW 0X06 -#define P0_VB_HIGH 0X07 -#define P0_VB_LOW 0X08 -#define P0_ROW_START_HIGH 0X09 -#define P0_ROW_START_LOW 0X0A -#define P0_COL_START_HIGH 0X0B -#define P0_COL_START_LOW 0X0C - -#define P0_WIN_HEIGHT_HIGH 0X0D -#define P0_WIN_HEIGHT_LOW 0X0E -#define P0_WIN_WIDTH_HIGH 0X0F -#define P0_WIN_WIDTH_LOW 0X10 -#define P0_ANALOG_MODE1 0X17 -#define P0_ANALOG_MODE2 0X18 - -#define P0_SPECIAL_EFFECT 0X83 -#define P0_OUTPUT_FORMAT 0x84 // Format select - // Bit[7]:YUV420 row switch - // Bit[6]:YUV420 col switch - // Bit[7]:YUV420_legacy - // Bit[4:0]:output data mode - // 5’h00 Cb Y Cr Y - // 5’h01 Cr Y Cb Y - // 5’h02 Y Cb Y Cr - // 5’h03 Y Cr Y Cb - // 5’h04 LSC bypass, C/Y - // 5’h05 LSC bypass, Y/C - // 5’h06 RGB 565 - // 5’h0f bypass 10bits - // 5’h17 switch odd/even column /row to controls output Bayer pattern - // 00 RGBG - // 01 RGGB - // 10 BGGR - // 11 GBRG - // 5'h18 DNDD out mode - // 5'h19 LSC out mode - // 5;h1b EEINTP out mode -#define P0_FRAME_START 0X85 -#define P0_SYNC_MODE 0X86 -#define P0_MODULE_GATING 0X88 -#define P0_BYPASS_MODE 0X89 -#define P0_DEBUG_MODE2 0X8C -#define P0_DEBUG_MODE3 0X8D -#define P0_CROP_ENABLE 0X90 -#define P0_OUT_WIN_Y1_HIGH 0X91 -#define P0_OUT_WIN_Y1_LOW 0X92 -#define P0_OUT_WIN_X1_HIGH 0X93 -#define P0_OUT_WIN_X1_LOW 0X94 -#define P0_OUT_WIN_HEIGHT_HIGH 0X95 -#define P0_OUT_WIN_HEIGHT_LOW 0X96 -#define P0_OUT_WIN_WIDTH_HIGH 0X97 -#define P0_OUT_WIN_WIDTH_LOW 0X98 -#define P0_SUBSAMPLE 0X99 -#define P0_SUBSAMPLE_MODE 0X9A - - -#endif // __GC2145_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h deleted file mode 100644 index 879fd53b3..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/gc2145_settings.h +++ /dev/null @@ -1,719 +0,0 @@ - -#include - -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 /* Array end token */ - -static const uint16_t gc2145_default_init_regs[][2] = { - {0xfe, 0xf0}, - {0xfe, 0xf0}, - {0xfe, 0xf0}, - - {0xfc, 0x06}, - {0xf6, 0x00}, - - {0xf7, 0x1d}, //37 //17 //37 //1d//05 - {0xf8, 0x83}, //87 //83 //82 - {0xfa, 0x00}, - {0xf9, 0xfe}, //ff - {0xfd, 0x00}, - {0xc2, 0x00}, - {0xf2, 0x0f}, -////////////////////////////////////////////////////// -//////////////////// Analog & Cisctl //////////////// -////////////////////////////////////////////////////// - {0xfe, 0x00}, - - {0x03, 0x04}, //exp time - {0x04, 0x62}, //exp time - - {0x05, 0x01}, //00 //hb[11:8] - {0x06, 0x3b}, //0b //hb - - {0x09, 0x00}, //row start - {0x0a, 0x00}, // - {0x0b, 0x00}, //col start - {0x0c, 0x00}, - {0x0d, 0x04}, //height - {0x0e, 0xc0}, - {0x0f, 0x06}, //width - {0x10, 0x52}, - - {0x12, 0x2e}, //sh_delay 太短 YUV出图异常 - {0x17, 0x14}, //CISCTL Mode1 [1:0]mirror flip - {0x18, 0x22}, //sdark mode - {0x19, 0x0f}, // AD pipe number - {0x1a, 0x01}, //AD manual switch mode - - {0x1b, 0x4b}, //48 restg Width,SH width - {0x1c, 0x07}, //06 帧率快后,横条纹 //12 //TX Width,Space Width - {0x1d, 0x10}, //double reset - {0x1e, 0x88}, //90//98 //fix 竖线//Analog Mode1,TX high,Coln_r - {0x1f, 0x78}, //78 //38 //18 //Analog Mode2,txlow - {0x20, 0x03}, //07 //Analog Mode3,comv,ad_clk mode - {0x21, 0x40}, //10//20//40 //fix 灯管横条纹 - {0x22, 0xa0}, //d0//f0 //a2 //Vref vpix FPN严重 - {0x24, 0x1e}, - {0x25, 0x01}, //col sel - {0x26, 0x10}, //Analog PGA gain1 - {0x2d, 0x60}, //40//40 //txl drv mode - {0x30, 0x01}, //Analog Mode4 - {0x31, 0x90}, //b0//70 // Analog Mode7 [7:5]rsgh_r灯管横条纹[4:3]isp_g - {0x33, 0x06}, //03//02//01 //EQ_hstart_width - {0x34, 0x01}, -// -/////////////////////////////////////////////////// -//////////////////// ISP reg ////////////////////// -////////////////////////////////////////////////////// - {0x80, 0xff}, //outdoor gamma_en, GAMMA_en, CC_en, EE_en, INTP_en, DN_en, DD_en,LSC_en - {0x81, 0x24}, //26//24 //BLK dither mode, ll_y_en ,skin_en, edge SA, new_skin_mode, autogray_en,ll_gamma_en,BFF test image - {0x82, 0xfa}, //FA //auto_SA, auto_EE, auto_DN, auto_DD, auto_LSC, ABS_en, AWB_en, NA - {0x83, 0x00}, //special_effect - {0x84, 0x02}, //output format - {0x86, 0x03}, //c2 //46 //c2 //sync mode - {0x88, 0x03}, //[1]ctl_auto_gating [0]out_auto_gating - {0x89, 0x03}, //bypass disable - {0x85, 0x30}, //60//frame start cut - {0x8a, 0x00}, //ISP_quiet_mode,close aaa pclk,BLK gate mode,exception,close first pipe clock,close dndd clock,close intp clock,DIV_gatedclk_en - {0x8b, 0x00}, //[7:6]BFF_gate_mode,[5]BLK switch gain,[4]protect exp,[3:2]pipe gate mode,[1]not split sram,[0]dark current update - - {0xb0, 0x55}, //60 //global gain - {0xc3, 0x00}, //[7:4]auto_exp_gamma_th1[11:8],[3:0]auto_exp_gamma_th2[11:8] - {0xc4, 0x80}, //auto_exp_gamma_th1[7:0] into - {0xc5, 0x90}, //auto_exp_gamma_th2[7:0] out //outdoor gamma - {0xc6, 0x38}, //auto_gamma_th1 - {0xc7, 0x40}, //auto_gamma_th2 - - {0xec, 0x06}, //measure window - {0xed, 0x04}, - {0xee, 0x60}, //16 col - {0xef, 0x90}, //8 row - - {0xb6, 0x01}, //[0]aec en - - {0x90, 0x01}, //crop - {0x91, 0x00}, - {0x92, 0x00}, - {0x93, 0x00}, - {0x94, 0x00}, //08 - {0x95, 0x04}, - {0x96, 0xb0}, - {0x97, 0x06}, - {0x98, 0x40}, - -/////////////////////////////////////////////// -/////////// BLK //////////////////////// -/////////////////////////////////////////////// - {0x18, 0x02}, - {0x40, 0x42}, //2b //27 - {0x41, 0x00}, //80 //dark row sel - {0x43, 0x54}, //[7:4]BLK start not smooth [3:0]output start frame - - {0x5e, 0x00}, //00//10 //18 - {0x5f, 0x00}, //00//10 //18 - {0x60, 0x00}, //00//10 //18 - {0x61, 0x00}, //00///10 //18 - {0x62, 0x00}, //00//10 //18 - {0x63, 0x00}, //00//10 //18 - {0x64, 0x00}, //00/10 //18 - {0x65, 0x00}, //00//10 //18 - {0x66, 0x20}, //1e - {0x67, 0x20}, //1e - {0x68, 0x20}, //1e - {0x69, 0x20}, //1e - - - {0x76, 0x00}, //0f - - {0x6a, 0x00}, //06 - {0x6b, 0x00}, //06 - {0x6c, 0x3e}, //06 - {0x6d, 0x3e}, //06 - {0x6e, 0x3f}, //06 - {0x6f, 0x3f}, //06 - {0x70, 0x00}, //06 - {0x71, 0x00}, //06 //manual offset - - {0x76, 0x00}, //1f//add offset - {0x72, 0xf0}, //[7:4]BLK DD th [3:0]BLK various th - {0x7e, 0x3c}, //ndark - {0x7f, 0x00}, - - {0xfe, 0x02}, - {0x48, 0x15}, - {0x49, 0x00}, //04//04 //ASDE OFFSET SLOPE - {0x4b, 0x0b}, //ASDE y OFFSET SLOPE - {0xfe, 0x00}, - -/////////////////////////////////////////////// -/////////// AEC //////////////////////// -/////////////////////////////////////////////// - {0xfe, 0x01}, - - {0x01, 0x04}, //AEC X1 - {0x02, 0xc0}, //AEC X2 - {0x03, 0x04}, //AEC Y1 - {0x04, 0x90}, //AEC Y2 - {0x05, 0x30}, //20 //AEC center X1 - {0x06, 0x90}, //40 //AEC center X2 - {0x07, 0x20}, //30 //AEC center Y1 - {0x08, 0x70}, //60 //AEC center Y2 - - {0x09, 0x00}, //AEC show mode - {0x0a, 0xc2}, //[7]col gain enable - {0x0b, 0x11}, //AEC every N - {0x0c, 0x10}, //AEC_mode3 center weight - {0x13, 0x40}, //2a //AEC Y target - {0x17, 0x00}, //AEC ignore mode - {0x1c, 0x11}, // - {0x1e, 0x61}, // - {0x1f, 0x30}, //40//50 //max pre gain - {0x20, 0x40}, //60//40 //max post gain - {0x22, 0x80}, //AEC outdoor THD - {0x23, 0x20}, //target_Y_low_limit - {0xfe, 0x02}, - {0x0f, 0x04}, //05 - {0xfe, 0x01}, - - {0x12, 0x35}, //35 //[5:4]group_size [3]slope_disable [2]outdoor_enable [0]histogram_enable - {0x15, 0x50}, //target_Y_high_limit - {0x10, 0x31}, //num_thd_high - {0x3e, 0x28}, //num_thd_low - {0x3f, 0xe0}, //luma_thd - {0x40, 0x20}, //luma_slope - {0x41, 0x0f}, //color_diff - - {0xfe, 0x02}, - {0x0f, 0x05}, //max_col_level -/////////////////////////// -////// INTPEE ///////////// -/////////////////////////// - {0xfe, 0x02}, //page2 - {0x90, 0x6c}, //ac //eeintp mode1 - {0x91, 0x03}, //02 ////eeintp mode2 - {0x92, 0xc8}, //44 //low criteria for direction - {0x94, 0x66}, - {0x95, 0xb5}, - {0x97, 0x64}, //78 ////edge effect - {0xa2, 0x11}, //fix direction - {0xfe, 0x00}, - -///////////////////////////// -//////// DNDD/////////////// -///////////////////////////// - {0xfe, 0x02}, - {0x80, 0xc1}, //c1 //[7]share mode [6]skin mode [5]is 5x5 mode [1:0]noise value select 0:2 1:2.5 2:3 3:4 - {0x81, 0x08}, // - {0x82, 0x08}, //signal a 0.6 - {0x83, 0x08}, //04 //signal b 2.5 - - {0x84, 0x0a}, //10 //05 dark_DD_TH - {0x86, 0xf0}, //a0 Y_value_dd_th2 - {0x87, 0x50}, //90 Y_value_dd_th3 - {0x88, 0x15}, //60 Y_value_dd_th4 - - {0x89, 0x50}, //80 // asde th2 - {0x8a, 0x30}, //60 // asde th3 - {0x8b, 0x10}, //30 // asde th4 - -///////////////////////////////////////////////// -///////////// ASDE //////////////////////// -///////////////////////////////////////////////// - {0xfe, 0x01}, //page 1 - {0x21, 0x14}, //luma_value_div_sel(分频,与0xef呈2倍关系,增大1,0xef的值减小1倍) -//ff ef luma_value read_only - - {0xfe, 0x02}, //page2 - {0xa3, 0x40}, //ASDE_low_luma_value_LSC_th_H - {0xa4, 0x20}, //ASDE_low_luma_value_LSC_th_L - - {0xa5, 0x40}, //80 //ASDE_LSC_gain_dec_slope_H - {0xa6, 0x80}, // 80 //ASDE_LSC_gain_dec_slope_L -//ff a7 ASDE_LSC_gain_dec //read only - - {0xab, 0x40}, //50 //ASDE_low_luma_value_OT_th - - {0xae, 0x0c}, //[3]EE1_effect_inc_or_dec_high,[2]EE2_effect_inc_or_dec_high, - //[1]EE1_effect_inc_or_dec_low,[0]EE2_effect_inc_or_dec_low, 1:inc 0:dec - - {0xb3, 0x34}, //44 //ASDE_EE1_effect_slope_low,ASDE_EE2_effect_slope_low - {0xb4, 0x44}, //12 //ASDE_EE1_effect_slope_high,ASDE_EE2_effect_slope_high - - {0xb6, 0x38}, //40//40 //ASDE_auto_saturation_dec_slope - {0xb7, 0x02}, //04 //ASDE_sub_saturation_slope - {0xb9, 0x30}, //[7:0]ASDE_auto_saturation_low_limit - {0x3c, 0x08}, //[3:0]auto gray_dec_slope - {0x3d, 0x30}, //[7:0]auto gray_dec_th - - - {0x4b, 0x0d}, //y offset slope - {0x4c, 0x20}, //y offset limit - - {0xfe, 0x00}, -// -///////////////////gamma1//////////////////// -////Gamma - {0xfe, 0x02}, - {0x10, 0x10}, - {0x11, 0x15}, - {0x12, 0x1a}, - {0x13, 0x1f}, - {0x14, 0x2c}, - {0x15, 0x39}, - {0x16, 0x45}, - {0x17, 0x54}, - {0x18, 0x69}, - {0x19, 0x7d}, - {0x1a, 0x8f}, - {0x1b, 0x9d}, - {0x1c, 0xa9}, - {0x1d, 0xbd}, - {0x1e, 0xcd}, - {0x1f, 0xd9}, - {0x20, 0xe3}, - {0x21, 0xea}, - {0x22, 0xef}, - {0x23, 0xf5}, - {0x24, 0xf9}, - {0x25, 0xff}, - -/////auto gamma///// - {0xfe, 0x02}, - {0x26, 0x0f}, - {0x27, 0x14}, - {0x28, 0x19}, - {0x29, 0x1e}, - {0x2a, 0x27}, - {0x2b, 0x33}, - {0x2c, 0x3b}, - {0x2d, 0x45}, - {0x2e, 0x59}, - {0x2f, 0x69}, - {0x30, 0x7c}, - {0x31, 0x89}, - {0x32, 0x98}, - {0x33, 0xae}, - {0x34, 0xc0}, - {0x35, 0xcf}, - {0x36, 0xda}, - {0x37, 0xe2}, - {0x38, 0xe9}, - {0x39, 0xf3}, - {0x3a, 0xf9}, - {0x3b, 0xff}, - -/////////////////////////////////////////////// -/////////// YCP /////////////////////// -/////////////////////////////////////////////// - {0xfe, 0x02}, - {0xd1, 0x30}, //32 // - {0xd2, 0x30}, //32 // - {0xd3, 0x45}, - {0xdd, 0x14}, //edge sa - {0xde, 0x86}, //asde auto gray - {0xed, 0x01}, // - {0xee, 0x28}, - {0xef, 0x30}, - {0xd8, 0xd8}, //autogray protecy - -//////////////////////////// -//////// LSC 0.8/////////////// -//////////////////////////// - {0xfe, 0x01}, - {0xa1, 0x80}, // center_row - {0xa2, 0x80}, // center_col - {0xa4, 0x00}, // sign of b1 - {0xa5, 0x00}, // sign of b1 - {0xa6, 0x70}, // sign of b4 - {0xa7, 0x00}, // sign of b4 - {0xa8, 0x77}, // sign of b22 - {0xa9, 0x77}, // sign of b22 - {0xaa, 0x1f}, // Q1_b1 of R - {0xab, 0x0d}, // Q1_b1 of G - {0xac, 0x19}, // Q1_b1 of B - {0xad, 0x24}, // Q2_b1 of R - {0xae, 0x0e}, // Q2_b1 of G - {0xaf, 0x1d}, // Q2_b1 of B - {0xb0, 0x12}, // Q3_b1 of R - {0xb1, 0x0c}, // Q3_b1 of G - {0xb2, 0x06}, // Q3_b1 of B - {0xb3, 0x13}, // Q4_b1 of R - {0xb4, 0x10}, // Q4_b1 of G - {0xb5, 0x0c}, // Q4_b1 of B - {0xb6, 0x6a}, // right_b2 of R - {0xb7, 0x46}, // right_b2 of G - {0xb8, 0x40}, // right_b2 of B - {0xb9, 0x0b}, // right_b4 of R - {0xba, 0x04}, // right_b4 of G - {0xbb, 0x00}, // right_b4 of B - {0xbc, 0x53}, // left_b2 of R - {0xbd, 0x37}, // left_b2 of G - {0xbe, 0x2d}, // left_b2 of B - {0xbf, 0x0a}, // left_b4 of R - {0xc0, 0x0a}, // left_b4 of G - {0xc1, 0x14}, // left_b4 of B - {0xc2, 0x34}, // up_b2 of R - {0xc3, 0x22}, // up_b2 of G - {0xc4, 0x18}, // up_b2 of B - {0xc5, 0x23}, // up_b4 of R - {0xc6, 0x0f}, // up_b4 of G - {0xc7, 0x3c}, // up_b4 of B - {0xc8, 0x20}, // down_b2 of R - {0xc9, 0x1f}, // down_b2 of G - {0xca, 0x17}, // down_b2 of B - {0xcb, 0x2d}, // down_b4 of R - {0xcc, 0x12}, // down_b4 of G - {0xcd, 0x20}, // down_b4 of B - {0xd0, 0x61}, // right_up_b22 of R - {0xd1, 0x2f}, // right_up_b22 of G - {0xd2, 0x39}, // right_up_b22 of B - {0xd3, 0x45}, // right_down_b22 of R - {0xd4, 0x2c}, // right_down_b22 of G - {0xd5, 0x21}, // right_down_b22 of B - {0xd6, 0x64}, // left_up_b22 of R - {0xd7, 0x2d}, // left_up_b22 of G - {0xd8, 0x30}, // left_up_b22 of B - {0xd9, 0x42}, // left_down_b22 of R - {0xda, 0x27}, // left_down_b22 of G - {0xdb, 0x13}, // left_down_b22 of B - {0xfe, 0x00}, - -///////////////////////////////////////////////// -///////////// AWB //////////////////////// -///////////////////////////////////////////////// - {0xfe, 0x01}, - - {0x4f, 0x00}, - {0x4f, 0x00}, - {0x4b, 0x01}, - {0x4f, 0x00}, - - - {0x4c, 0x01}, - {0x4d, 0x6f}, - {0x4e, 0x02}, - {0x4c, 0x01}, - {0x4d, 0x70}, - - {0x4e, 0x02}, - {0x4c, 0x01}, - {0x4d, 0x8f}, - {0x4e, 0x02}, - - {0x4c, 0x01}, - {0x4d, 0x90}, - {0x4e, 0x02}, //light - - - {0x4c, 0x01}, - {0x4d, 0xed}, - {0x4e, 0x33}, //light - {0x4c, 0x01}, - {0x4d, 0xcd}, - {0x4e, 0x33}, //light - {0x4c, 0x01}, - {0x4d, 0xec}, - {0x4e, 0x03}, //light - - {0x4c, 0x01}, - {0x4d, 0x6c}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0x6d}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0x6e}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0x8c}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0x8d}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0x8e}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xab}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xac}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xad}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xae}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xcb}, - {0x4e, 0x03}, - - {0x4c, 0x01}, - {0x4d, 0xcc}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xce}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xeb}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xec}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xee}, - {0x4e, 0x03}, - {0x4c, 0x02}, - {0x4d, 0x0c}, - {0x4e, 0x03}, - {0x4c, 0x02}, - {0x4d, 0x0d}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xea}, - {0x4e, 0x03}, - {0x4c, 0x01}, - {0x4d, 0xaf}, - {0x4e, 0x03}, //dark - {0x4c, 0x01}, - {0x4d, 0xcf}, - {0x4e, 0x03}, //dark - - {0x4c, 0x01}, - {0x4d, 0xca}, - {0x4e, 0x04}, //light - {0x4c, 0x02}, - {0x4d, 0x0b}, - {0x4e, 0x05}, //light - {0x4c, 0x02}, - {0x4d, 0xc8}, - {0x4e, 0x06}, //light 100lux - {0x4c, 0x02}, - {0x4d, 0xa8}, - - {0x4e, 0x06}, //light - {0x4c, 0x02}, - {0x4d, 0xa9}, - {0x4e, 0x06}, //light - - - {0x4c, 0x02}, - {0x4d, 0x89}, - {0x4e, 0x06}, //400lux - {0x4c, 0x02}, - {0x4d, 0x69}, - {0x4e, 0x06}, //f12 - {0x4c, 0x02}, - {0x4d, 0x6a}, - {0x4e, 0x06}, //f12 - {0x4c, 0x02}, - {0x4d, 0xc7}, - {0x4e, 0x07}, - {0x4c, 0x02}, - {0x4d, 0xe7}, - {0x4e, 0x07}, //100lux - {0x4c, 0x03}, - {0x4d, 0x07}, - {0x4e, 0x07}, //light - - {0x4c, 0x02}, - {0x4d, 0xe8}, - {0x4e, 0x07}, - {0x4c, 0x02}, - {0x4d, 0xe9}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x08}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x09}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x27}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x28}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x29}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x47}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x48}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x49}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x67}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x68}, - {0x4e, 0x07}, - {0x4c, 0x03}, - {0x4d, 0x69}, - {0x4e, 0x07}, - - {0x4f, 0x01}, - {0xfe, 0x01}, - {0x50, 0x80}, //AWB_PRE_mode - {0x51, 0xa8}, //AWB_pre_THD_min[7:0] - {0x52, 0x57}, //AWB_pre_THD_min[15:8] Dominiate luma 0.25=639c 0.22=57a8 - {0x53, 0x38}, //AWB_pre_THD_min_MIX[7:0] - {0x54, 0xc7}, //AWB_pre_THD_min_MIX[15:8] Mix luma 0.5 - - {0x56, 0x0e}, //AWB_tone mode - {0x58, 0x08}, //AWB_C_num_sel,AWB_D_num_sel - {0x5b, 0x00}, //AWB_mix_mode - - {0x5c, 0x74}, //green_num0[7:0] - {0x5d, 0x8b}, //green_num0[15:8] 0.35 - - {0x61, 0xd3}, //R2G_stand0 - {0x62, 0xb5}, //B2G_stand0 - {0x63, 0x00}, //88//a4 //AWB gray mode [7]enable - {0x65, 0x04}, //AWB margin - - {0x67, 0xb2}, //R2G_stand3[7:0] FF/CWF - {0x68, 0xac}, //B2G_stand3[7:0] - {0x69, 0x00}, //R2G_stand4[9:8] B2G_stand4[9:8] R2G_stand3[9:8] B2G_stand3[9:8] - {0x6a, 0xb2}, //R2G_stand4[7:0] TL84/TL84&CWF - {0x6b, 0xac}, //B2G_stand4[7:0] - {0x6c, 0xb2}, //R2G_stand5[7:0] A - {0x6d, 0xac}, //B2G_stand5[7:0] - {0x6e, 0x40}, //AWB_skin_weight R2G_stand5[9:8] B2G_stand5[9:8] - {0x6f, 0x18}, //AWB_indoor_THD (0x21=17 caculate) - {0x73, 0x00}, //AWB_indoor_mode - - {0x70, 0x10}, //AWB low luma TH - {0x71, 0xe8}, //AWB outdoor TH - {0x72, 0xc0}, //outdoor mode - {0x74, 0x01}, //[2:0]AWB skip mode 2x2,4x4,4x8,8x8 - {0x75, 0x01}, //[1:0]AWB_every_N - {0x7f, 0x08}, //[3]gray world frame start - - {0x76, 0x70}, //R limit - {0x77, 0x58}, //G limit - {0x78, 0xa0}, //d8 //B limit - - {0xfe, 0x00}, -// -////////////////////////////////////////// -/////////// CC //////////////////////// -////////////////////////////////////////// - {0xfe, 0x02}, - - {0xc0, 0x01}, //[5:4] CC mode [0]CCT enable - - {0xC1, 0x50}, //D50/D65 - {0xc2, 0xF9}, - {0xc3, 0x00}, //0 - {0xc4, 0xe8}, //e0 - {0xc5, 0x48}, - {0xc6, 0xf0}, - - - {0xC7, 0x50}, - {0xc8, 0xf2}, - {0xc9, 0x00}, - {0xcA, 0xE0}, - {0xcB, 0x45}, - {0xcC, 0xec}, - - {0xCd, 0x45}, - {0xce, 0xf0}, - {0xcf, 0x00}, - {0xe3, 0xf0}, - {0xe4, 0x45}, - {0xe5, 0xe8}, - - - {0xfe, 0x00}, - - {0xf2, 0x0f}, - - -//////////////frame rate 50Hz - {0xfe, 0x00}, - - {0xf7, 0x1d}, - {0xf8, 0x84}, - {0xfa, 0x00}, - - {0x05, 0x01}, //hb - {0x06, 0x3b}, - {0x07, 0x01}, //Vb - {0x08, 0x0b}, - - {0xfe, 0x01}, - {0x25, 0x01}, - {0x26, 0x32}, //step - {0x27, 0x03}, //8.15fps - {0x28, 0x96}, - {0x29, 0x03}, //8.15fps - {0x2a, 0x96}, - {0x2b, 0x03}, //8.15fps - {0x2c, 0x96}, - {0x2d, 0x04}, //8.15fps - {0x2e, 0x62}, - {0x3c, 0x00}, - {0xfe, 0x00}, - -/////////dark sun////// - {0xfe, 0x00}, - {0x18, 0x22}, - {0xfe, 0x02}, - {0x40, 0xbf}, - {0x46, 0xcf}, - {0xfe, 0x00}, - - {0xfe, 0x00}, - - {0xf7, 0x1d}, - {0xf8, 0x84}, - {0xfa, 0x10}, - - {0x05, 0x01}, //hb - {0x06, 0x18}, - {0x07, 0x00}, //Vb - {0x08, 0x2e}, - - {0xfe, 0x01}, - {0x25, 0x00}, - {0x26, 0xa2}, //step - {0x27, 0x01}, - {0x28, 0xe6}, - {0x29, 0x01}, - {0x2a, 0xe6}, - {0x2b, 0x01}, - {0x2c, 0xe6}, - {0x2d, 0x04}, // AEC_exp_level4[12:8] - {0x2e, 0x62}, // AEC_exp_level4[7:0] - {0x3c, 0x00}, - {0xfe, 0x00}, - - {0x09, 0x01}, //row start - {0x0a, 0xd0}, // - {0x0b, 0x02}, //col start - {0x0c, 0x70}, - {0x0d, 0x01}, //height - {0x0e, 0x00}, - {0x0f, 0x01}, //width - {0x10, 0x50}, - - {0x90, 0x01}, //crop - {0x91, 0x00}, - {0x92, 0x00}, - {0x93, 0x00}, - {0x94, 0x00}, - {0x95, 0x00}, - {0x96, 0xf0}, - {0x97, 0x01}, - {0x98, 0x40}, - - - {REGLIST_TAIL, 0x00}, -}; diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h deleted file mode 100644 index 8b0c562b9..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * NT99141 driver. - * - */ -#ifndef __NT99141_H__ -#define __NT99141_H__ - -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int nt99141_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int nt99141_init(sensor_t *sensor); - -#endif // __NT99141_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h deleted file mode 100644 index 8301db901..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_regs.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * NT99141 register definitions. - */ -#ifndef __NT99141_REG_REGS_H__ -#define __NT99141_REG_REGS_H__ - -/* system control registers */ -#define SYSTEM_CTROL0 0x3021 // Bit[7]: Software reset - // Bit[6]: Software power down - // Bit[5]: Reserved - // Bit[4]: SRB clock SYNC enable - // Bit[3]: Isolation suspend select - // Bit[2:0]: Not used - -/* output format control registers */ -#define FORMAT_CTRL 0x501F // Format select - // Bit[2:0]: - // 000: YUV422 - // 001: RGB - // 010: Dither - // 011: RAW after DPC - // 101: RAW after CIP - -/* format control registers */ -#define FORMAT_CTRL00 0x4300 - -/* frame control registers */ -#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode - // Bit[7:4]: Not used - // Bit[3:0]: Frame ON number -#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode - // Bit[7:4]: Not used - // BIT[3:0]: Frame OFF number - -/* ISP top control registers */ -#define PRE_ISP_TEST_SETTING_1 0x3025 // Bit[7]: Test enable - // 0: Test disable - // 1: Color bar enable - // Bit[6]: Rolling - // Bit[5]: Transparent - // Bit[4]: Square black and white - // Bit[3:2]: Color bar style - // 00: Standard 8 color bar - // 01: Gradual change at vertical mode 1 - // 10: Gradual change at horizontal - // 11: Gradual change at vertical mode 2 - // Bit[1:0]: Test select - // 00: Color bar - // 01: Random data - // 10: Square data - // 11: Black image - -//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW - -/* AEC/AGC control functions */ -#define AEC_PK_MANUAL 0x3201 // AEC Manual Mode Control - // Bit[7:6]: Reserved - // Bit[5]: Gain delay option - // Valid when 0x3503[4]=1’b0 - // 0: Delay one frame latch - // 1: One frame latch - // Bit[4:2]: Reserved - // Bit[1]: AGC manual - // 0: Auto enable - // 1: Manual enable - // Bit[0]: AEC manual - // 0: Auto enable - // 1: Manual enable - -//gain = {0x350A[1:0], 0x350B[7:0]} / 16 - -/* mirror and flip registers */ -#define TIMING_TC_REG20 0x3022 // Timing Control Register - // Bit[2:1]: Vertical flip enable - // 00: Normal - // 11: Vertical flip - // Bit[0]: Vertical binning enable -#define TIMING_TC_REG21 0x3022 // Timing Control Register - // Bit[5]: Compression Enable - // Bit[2:1]: Horizontal mirror enable - // 00: Normal - // 11: Horizontal mirror - // Bit[0]: Horizontal binning enable - -#define CLOCK_POL_CONTROL 0x3024// Bit[5]: PCLK polarity 0: active low - // 1: active high - // Bit[3]: Gate PCLK under VSYNC - // Bit[2]: Gate PCLK under HREF - // Bit[1]: HREF polarity - // 0: active low - // 1: active high - // Bit[0] VSYNC polarity - // 0: active low - // 1: active high -#define DRIVE_CAPABILITY 0x306a // Bit[7:6]: - // 00: 1x - // 01: 2x - // 10: 3x - // 11: 4x - - -#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8] -#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0] -#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8] -#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0] -#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8] -#define X_ADDR_END_L 0x3805 //Bit[7:0]: -#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8] -#define Y_ADDR_END_L 0x3807 //Bit[7:0]: -// Size after scaling -#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8] -#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]: -#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8] -#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]: -#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8] -#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]: -#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8] -#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]: -#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8] -#define X_OFFSET_L 0x3811 //Bit[7:0]: -#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8] -#define Y_OFFSET_L 0x3813 //Bit[7:0]: -#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment - //Bit[3:0]: Horizontal even subsample increment -#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment - //Bit[3:0]: Vertical even subsample increment -// Size before scaling -//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET)) -//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET)) - -#define ISP_CONTROL_01 0x3021 // Bit[5]: Scale enable - // 0: Disable - // 1: Enable - -#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW - // DCW scale times - // 000: DCW 1 time - // 001: DCW 2 times - // 010: DCW 4 times - // 100: DCW 8 times - // 101: DCW 16 times - // Others: DCW 16 times - // Bit[2:0]: VDIV RW - // DCW scale times - // 000: DCW 1 time - // 001: DCW 2 times - // 010: DCW 4 times - // 100: DCW 8 times - // 101: DCW 16 times - // Others: DCW 16 times - -#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits -#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits -#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits -#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits -#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset - -#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual -#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable - // 0: Auto - // 1: Manual by PCLK_RATIO - -#define VFIFO_X_SIZE_H 0x4602 -#define VFIFO_X_SIZE_L 0x4603 -#define VFIFO_Y_SIZE_H 0x4604 -#define VFIFO_Y_SIZE_L 0x4605 - -#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass -#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier -#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control - // Bit[3:0]: PLLS system divider -#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider - // 00: 1 - // 01: 1.5 - // 10: 2 - // 11: 3 - // Bit[2]: PLLS root-divider - 1 - // Bit[1:0]: PLLS seld5 - // 00: 1 - // 01: 1 - // 10: 2 - // 11: 2.5 - -#define COMPRESSION_CTRL00 0x4400 // -#define COMPRESSION_CTRL01 0x4401 // -#define COMPRESSION_CTRL02 0x4402 // -#define COMPRESSION_CTRL03 0x4403 // -#define COMPRESSION_CTRL04 0x4404 // -#define COMPRESSION_CTRL05 0x4405 // -#define COMPRESSION_CTRL06 0x4406 // -#define COMPRESSION_CTRL07 0x3401 // Bit[5:0]: QS -#define COMPRESSION_ISI_CTRL 0x4408 // -#define COMPRESSION_CTRL09 0x4409 // -#define COMPRESSION_CTRL0a 0x440a // -#define COMPRESSION_CTRL0b 0x440b // -#define COMPRESSION_CTRL0c 0x440c // -#define COMPRESSION_CTRL0d 0x440d // -#define COMPRESSION_CTRL0E 0x440e // - -/** - * @brief register value - */ -#define TEST_COLOR_BAR 0x02 /* Enable Color Bar roling Test */ - -#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */ -#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */ - -#define TIMING_TC_REG20_VFLIP 0x01 /* Vertical flip enable */ -#define TIMING_TC_REG21_HMIRROR 0x02 /* Horizontal mirror enable */ - -#endif // __NT99141_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h deleted file mode 100644 index 1ffec2053..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/nt99141_settings.h +++ /dev/null @@ -1,825 +0,0 @@ -#ifndef _NT99141_SETTINGS_H_ -#define _NT99141_SETTINGS_H_ - -#include -#include -#include "esp_attr.h" -#include "nt99141_regs.h" - -static const ratio_settings_t ratio_table[] = { - // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty - { 1280, 720, 0, 4, 1283, 723, 0, 4, 1660, 963 }, - -}; - -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 - -static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { - //initial -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x3109, 0x04}, -{0x3040, 0x04}, -{0x3041, 0x02}, -{0x3042, 0xFF}, -{0x3043, 0x08}, -{0x3052, 0xE0}, -{0x305F, 0x33}, -{0x3100, 0x07}, -{0x3106, 0x03}, -{0x3105, 0x01}, -{0x3108, 0x05}, -{0x3110, 0x22}, -{0x3111, 0x57}, -{0x3112, 0x22}, -{0x3113, 0x55}, -{0x3114, 0x05}, -{0x3135, 0x00}, -{0x32F0, 0x01}, -{0x3290, 0x01}, -{0x3291, 0x80}, -{0x3296, 0x01}, -{0x3297, 0x73}, -{0x3250, 0x80}, -{0x3251, 0x03}, -{0x3252, 0xFF}, -{0x3253, 0x00}, -{0x3254, 0x03}, -{0x3255, 0xFF}, -{0x3256, 0x00}, -{0x3257, 0x50}, -{0x3270, 0x00}, -{0x3271, 0x0C}, -{0x3272, 0x18}, -{0x3273, 0x32}, -{0x3274, 0x44}, -{0x3275, 0x54}, -{0x3276, 0x70}, -{0x3277, 0x88}, -{0x3278, 0x9D}, -{0x3279, 0xB0}, -{0x327A, 0xCF}, -{0x327B, 0xE2}, -{0x327C, 0xEF}, -{0x327D, 0xF7}, -{0x327E, 0xFF}, -{0x3302, 0x00}, -{0x3303, 0x40}, -{0x3304, 0x00}, -{0x3305, 0x96}, -{0x3306, 0x00}, -{0x3307, 0x29}, -{0x3308, 0x07}, -{0x3309, 0xBA}, -{0x330A, 0x06}, -{0x330B, 0xF5}, -{0x330C, 0x01}, -{0x330D, 0x51}, -{0x330E, 0x01}, -{0x330F, 0x30}, -{0x3310, 0x07}, -{0x3311, 0x16}, -{0x3312, 0x07}, -{0x3313, 0xBA}, -{0x3326, 0x02}, -{0x32F6, 0x0F}, -{0x32F9, 0x42}, -{0x32FA, 0x24}, -{0x3325, 0x4A}, -{0x3330, 0x00}, -{0x3331, 0x0A}, -{0x3332, 0xFF}, -{0x3338, 0x30}, -{0x3339, 0x84}, -{0x333A, 0x48}, -{0x333F, 0x07}, -{0x3360, 0x10}, -{0x3361, 0x18}, -{0x3362, 0x1f}, -{0x3363, 0x37}, -{0x3364, 0x80}, -{0x3365, 0x80}, -{0x3366, 0x68}, -{0x3367, 0x60}, -{0x3368, 0x30}, -{0x3369, 0x28}, -{0x336A, 0x20}, -{0x336B, 0x10}, -{0x336C, 0x00}, -{0x336D, 0x20}, -{0x336E, 0x1C}, -{0x336F, 0x18}, -{0x3370, 0x10}, -{0x3371, 0x38}, -{0x3372, 0x3C}, -{0x3373, 0x3F}, -{0x3374, 0x3F}, -{0x338A, 0x34}, -{0x338B, 0x7F}, -{0x338C, 0x10}, -{0x338D, 0x23}, -{0x338E, 0x7F}, -{0x338F, 0x14}, -{0x3375, 0x08}, -{0x3376, 0x0C}, -{0x3377, 0x18}, -{0x3378, 0x20}, -{0x3012, 0x02}, -{0x3013, 0xD0}, -{0x3025, 0x02}, //colorbar -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_jpeg[][2] = { - {0x32F0, 0x70}, // YUV422 - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_raw[][2] = { - {0x32F0, 0x50}, // RAW - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_grayscale[][2] = { - {0x32F1, 0x01}, - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_yuv422[][2] = { - {0x32F0, 0x00}, // YUV422 - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_rgb565[][2] = { - {0x32F0, 0x01}, // RGB - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint8_t sensor_saturation_levels[9][1] = { - {0x60},//-4 - {0x68},//-3 - {0x70},//-2 - {0x78},//-1 - {0x80},//0 - {0x88},//+1 - {0x90},//+2 - {0x98},//+3 - {0xA0},//+4 -}; - -static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = { - {0x00, 0x80, 0x80, 0x01},//Normal - {0x03, 0x80, 0x80, 0x01},//Negative - {0x01, 0x80, 0x80, 0x01},//Grayscale - {0x05, 0x2A, 0xF0, 0x01},//Red Tint - {0x05, 0x60, 0x20, 0x01},//Green Tint - {0x05, 0xF0, 0x80, 0x01},//Blue Tint - {0x02, 0x80, 0x80, 0x01},//Sepia - -}; - -// AE LEVEL -static const DRAM_ATTR uint16_t sensor_ae_level[][2] = { - -// 1. [AE_Target : 0x24] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x29 }, - {0x32B9, 0x1F }, - {0x32BC, 0x24 }, - {0x32BD, 0x27 }, - {0x32BE, 0x21 }, -//------------------------------------------------------------------------ -// 2. [AE_Target : 0x28] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x2D }, - {0x32B9, 0x23 }, - {0x32BC, 0x28 }, - {0x32BD, 0x2B }, - {0x32BE, 0x25 }, -//------------------------------------------------------------------------ -// 3. [AE_Target : 0x2C] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x32 }, - {0x32B9, 0x26 }, - {0x32BC, 0x2C }, - {0x32BD, 0x2F }, - {0x32BE, 0x29 }, -//------------------------------------------------------------------------ -// 4, [AE_Target : 0x30] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x36 }, - {0x32B9, 0x2A }, - {0x32BC, 0x30 }, - {0x32BD, 0x33 }, - {0x32BE, 0x2D }, -//------------------------------------------------------------------------ -// 5. [AE_Target : 0x34] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x3B }, - {0x32B9, 0x2D }, - {0x32BC, 0x34 }, - {0x32BD, 0x38 }, - {0x32BE, 0x30 }, -//------------------------------------------------------------------------ -// 6. [AE_Target : 0x38] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x3F }, - {0x32B9, 0x31 }, - {0x32BC, 0x38 }, - {0x32BD, 0x3C }, - {0x32BE, 0x34 }, -//------------------------------------------------------------------------ -// 7. [AE_Target : 0x3D] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x44 }, - {0x32B9, 0x34 }, - {0x32BC, 0x3C }, - {0x32BD, 0x40 }, - {0x32BE, 0x38 }, -//------------------------------------------------------------------------ -// 8. [AE_Target : 0x40] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x48 }, - {0x32B9, 0x38 }, - {0x32BC, 0x40 }, - {0x32BD, 0x44 }, - {0x32BE, 0x3C }, -//------------------------------------------------------------------------ -// 9. [AE_Target : 0x44] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 - {0x32B8, 0x4D }, - {0x32B9, 0x3B }, - {0x32BC, 0x44 }, - {0x32BD, 0x49 }, - {0x32BE, 0x3F }, -}; - -static const DRAM_ATTR uint16_t sensor_framesize_HD[][2] = { -//[JPEG_1280x720_8.18_8.18_Fps] -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x3C}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x5E}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x24}, -{0x3002, 0x00}, -{0x3003, 0x04}, -{0x3004, 0x00}, -{0x3005, 0x04}, -{0x3006, 0x05}, -{0x3007, 0x03}, -{0x3008, 0x02}, -{0x3009, 0xD3}, -{0x300A, 0x06}, -{0x300B, 0x7C}, -{0x300C, 0x02}, -{0x300D, 0xE0}, -{0x300E, 0x05}, -{0x300F, 0x00}, -{0x3010, 0x02}, -{0x3011, 0xD0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x3F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_framesize_VGA[][2] = { -//[JPEG_640x480_10.14_10.14_Fps] -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x4B}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x62}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x32E0, 0x02}, -{0x32E1, 0x80}, -{0x32E2, 0x01}, -{0x32E3, 0xE0}, -{0x32E4, 0x00}, -{0x32E5, 0x80}, -{0x32E6, 0x00}, -{0x32E7, 0x80}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x24}, -{0x3002, 0x00}, -{0x3003, 0xA4}, -{0x3004, 0x00}, -{0x3005, 0x04}, -{0x3006, 0x04}, -{0x3007, 0x63}, -{0x3008, 0x02}, -{0x3009, 0xD3}, -{0x300A, 0x05}, -{0x300B, 0x3C}, -{0x300C, 0x02}, -{0x300D, 0xE0}, -{0x300E, 0x03}, -{0x300F, 0xC0}, -{0x3010, 0x02}, -{0x3011, 0xD0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x7F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_framesize_QVGA[][2] = { -//[JPEG_320x240_10.14_10.14_Fps] -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x4B}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x62}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x32E0, 0x01}, -{0x32E1, 0x40}, -{0x32E2, 0x00}, -{0x32E3, 0xF0}, -{0x32E4, 0x02}, -{0x32E5, 0x02}, -{0x32E6, 0x02}, -{0x32E7, 0x03}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x24}, -{0x3002, 0x00}, -{0x3003, 0xA4}, -{0x3004, 0x00}, -{0x3005, 0x04}, -{0x3006, 0x04}, -{0x3007, 0x63}, -{0x3008, 0x02}, -{0x3009, 0xD3}, -{0x300A, 0x05}, -{0x300B, 0x3C}, -{0x300C, 0x02}, -{0x300D, 0xE0}, -{0x300E, 0x03}, -{0x300F, 0xC0}, -{0x3010, 0x02}, -{0x3011, 0xD0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x7F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_framesize_VGA_xyskip[][2] = { -// [JPEG_640x360_20.00_25.01_Fps_XY_Skip] -// Set_Device_Format = FORMAT_16_8 -// SET_Device_Addr = 0x54 -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60 }, -{0x320A, 0xB2 }, -{0x32C0, 0x64 }, -{0x32C1, 0x64 }, -{0x32C2, 0x64 }, -{0x32C3, 0x00 }, -{0x32C4, 0x20 }, -{0x32C5, 0x20 }, -{0x32C6, 0x20 }, -{0x32C7, 0x00 }, -{0x32C8, 0x62 }, -{0x32C9, 0x64 }, -{0x32CA, 0x84 }, -{0x32CB, 0x84 }, -{0x32CC, 0x84 }, -{0x32CD, 0x84 }, -{0x32DB, 0x68 }, -{0x32F0, 0x70 }, -{0x3400, 0x08 }, -{0x3400, 0x00 }, -{0x3401, 0x4E }, -{0x3404, 0x00 }, -{0x3405, 0x00 }, -{0x3410, 0x00 }, -{0x3200, 0x3E }, -{0x3201, 0x0F }, -{0x3028, 0x0F }, -{0x3029, 0x00 }, -{0x302A, 0x08 }, -{0x3022, 0x24 }, -{0x3023, 0x6C }, -{0x3002, 0x00 }, -{0x3003, 0x04 }, -{0x3004, 0x00 }, -{0x3005, 0x04 }, -{0x3006, 0x05 }, -{0x3007, 0x03 }, -{0x3008, 0x02 }, -{0x3009, 0xD3 }, -{0x300A, 0x03 }, -{0x300B, 0xFC }, -{0x300C, 0x01 }, -{0x300D, 0x88 }, -{0x300E, 0x02 }, -{0x300F, 0x80 }, -{0x3010, 0x01 }, -{0x3011, 0x68 }, -{0x32B8, 0x3F }, -{0x32B9, 0x31 }, -{0x32BB, 0x87 }, -{0x32BC, 0x38 }, -{0x32BD, 0x3C }, -{0x32BE, 0x34 }, -{0x3201, 0x3F }, -{0x3025, 0x00 }, //normal -{0x3021, 0x06 }, -{0x3400, 0x01 }, -{0x3060, 0x01 }, -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_framesize_VGA_xskip[][2] = { -//[JPEG_640x480_Xskip_13.32_13.32_Fps] -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x62}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x68}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x32E0, 0x02}, -{0x32E1, 0x80}, -{0x32E2, 0x01}, -{0x32E3, 0xE0}, -{0x32E4, 0x00}, -{0x32E5, 0x00}, -{0x32E6, 0x00}, -{0x32E7, 0x80}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x2C}, -{0x3002, 0x00}, -{0x3003, 0x04}, -{0x3004, 0x00}, -{0x3005, 0x04}, -{0x3006, 0x05}, -{0x3007, 0x03}, -{0x3008, 0x02}, -{0x3009, 0xD3}, -{0x300A, 0x03}, -{0x300B, 0xFC}, -{0x300C, 0x02}, -{0x300D, 0xE0}, -{0x300E, 0x02}, -{0x300F, 0x80}, -{0x3010, 0x02}, -{0x3011, 0xD0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x7F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_framesize_QVGA_xskip[][2] = { -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -//[JPEG_320x240_Xskip_13.32_13.32_Fps] -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x62}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x68}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x32E0, 0x01}, -{0x32E1, 0x40}, -{0x32E2, 0x00}, -{0x32E3, 0xF0}, -{0x32E4, 0x01}, -{0x32E5, 0x01}, -{0x32E6, 0x02}, -{0x32E7, 0x03}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x2C}, -{0x3002, 0x00}, -{0x3003, 0x04}, -{0x3004, 0x00}, -{0x3005, 0x04}, -{0x3006, 0x05}, -{0x3007, 0x03}, -{0x3008, 0x02}, -{0x3009, 0xD3}, -{0x300A, 0x03}, -{0x300B, 0xFC}, -{0x300C, 0x02}, -{0x300D, 0xE0}, -{0x300E, 0x02}, -{0x300F, 0x80}, -{0x3010, 0x02}, -{0x3011, 0xD0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x7F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - - -static const DRAM_ATTR uint16_t sensor_framesize_VGA_crop[][2] = { -//[JPEG_640x480_Crop_19.77_19.77_Fps] -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x62}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x68}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x24}, -{0x3002, 0x01}, -{0x3003, 0x44}, -{0x3004, 0x00}, -{0x3005, 0x7C}, -{0x3006, 0x03}, -{0x3007, 0xC3}, -{0x3008, 0x02}, -{0x3009, 0x5B}, -{0x300A, 0x03}, -{0x300B, 0xFC}, -{0x300C, 0x01}, -{0x300D, 0xF0}, -{0x300E, 0x02}, -{0x300F, 0x80}, -{0x3010, 0x01}, -{0x3011, 0xE0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x3F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_framesize_QVGA_crop[][2] = { -//[JPEG_320x240_Crop_19.77_19.77_Fps] -{0x3021, 0x00}, -{REG_DLY, 100}, // delay 100ms -{0x32BF, 0x60}, -{0x32C0, 0x5A}, -{0x32C1, 0x5A}, -{0x32C2, 0x5A}, -{0x32C3, 0x00}, -{0x32C4, 0x20}, -{0x32C5, 0x20}, -{0x32C6, 0x20}, -{0x32C7, 0x00}, -{0x32C8, 0x62}, -{0x32C9, 0x5A}, -{0x32CA, 0x7A}, -{0x32CB, 0x7A}, -{0x32CC, 0x7A}, -{0x32CD, 0x7A}, -{0x32DB, 0x68}, -{0x32F0, 0x70}, -{0x3400, 0x08}, -{0x3400, 0x00}, -{0x3401, 0x4E}, -{0x3404, 0x00}, -{0x3405, 0x00}, -{0x3410, 0x00}, -{0x32E0, 0x01}, -{0x32E1, 0x40}, -{0x32E2, 0x00}, -{0x32E3, 0xF0}, -{0x32E4, 0x01}, -{0x32E5, 0x01}, -{0x32E6, 0x01}, -{0x32E7, 0x02}, -{0x3200, 0x3E}, -{0x3201, 0x0F}, -{0x3028, 0x0F}, -{0x3029, 0x00}, -{0x302A, 0x08}, -{0x3022, 0x24}, -{0x3023, 0x24}, -{0x3002, 0x01}, -{0x3003, 0x44}, -{0x3004, 0x00}, -{0x3005, 0x7C}, -{0x3006, 0x03}, -{0x3007, 0xC3}, -{0x3008, 0x02}, -{0x3009, 0x5B}, -{0x300A, 0x03}, -{0x300B, 0xFC}, -{0x300C, 0x01}, -{0x300D, 0xF0}, -{0x300E, 0x02}, -{0x300F, 0x80}, -{0x3010, 0x01}, -{0x3011, 0xE0}, -{0x32B8, 0x3F}, -{0x32B9, 0x31}, -{0x32BB, 0x87}, -{0x32BC, 0x38}, -{0x32BD, 0x3C}, -{0x32BE, 0x34}, -{0x3201, 0x7F}, -{0x3021, 0x06}, -{0x3025, 0x00}, //normal -{0x3400, 0x01}, -{0x3060, 0x01}, -{REGLIST_TAIL, 0x00}, // tail -}; - -#endif - - diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h deleted file mode 100644 index 342ab2132..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV2640 driver. - * - */ -#ifndef __OV2640_H__ -#define __OV2640_H__ -#include "sensor.h" -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int ov2640_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int ov2640_init(sensor_t *sensor); - -#endif // __OV2640_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h deleted file mode 100644 index 8f47333fa..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_regs.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV2640 register definitions. - */ -#ifndef __REG_REGS_H__ -#define __REG_REGS_H__ -/* DSP register bank FF=0x00*/ -#define R_BYPASS 0x05 -#define QS 0x44 -#define CTRLI 0x50 -#define HSIZE 0x51 -#define VSIZE 0x52 -#define XOFFL 0x53 -#define YOFFL 0x54 -#define VHYX 0x55 -#define DPRP 0x56 -#define TEST 0x57 -#define ZMOW 0x5A -#define ZMOH 0x5B -#define ZMHH 0x5C -#define BPADDR 0x7C -#define BPDATA 0x7D -#define CTRL2 0x86 -#define CTRL3 0x87 -#define SIZEL 0x8C -#define HSIZE8 0xC0 -#define VSIZE8 0xC1 -#define CTRL0 0xC2 -#define CTRL1 0xC3 -#define R_DVP_SP 0xD3 -#define IMAGE_MODE 0xDA -#define RESET 0xE0 -#define MS_SP 0xF0 -#define SS_ID 0xF7 -#define SS_CTRL 0xF7 -#define MC_BIST 0xF9 -#define MC_AL 0xFA -#define MC_AH 0xFB -#define MC_D 0xFC -#define P_CMD 0xFD -#define P_STATUS 0xFE -#define BANK_SEL 0xFF - -#define CTRLI_LP_DP 0x80 -#define CTRLI_ROUND 0x40 - -#define CTRL0_AEC_EN 0x80 -#define CTRL0_AEC_SEL 0x40 -#define CTRL0_STAT_SEL 0x20 -#define CTRL0_VFIRST 0x10 -#define CTRL0_YUV422 0x08 -#define CTRL0_YUV_EN 0x04 -#define CTRL0_RGB_EN 0x02 -#define CTRL0_RAW_EN 0x01 - -#define CTRL2_DCW_EN 0x20 -#define CTRL2_SDE_EN 0x10 -#define CTRL2_UV_ADJ_EN 0x08 -#define CTRL2_UV_AVG_EN 0x04 -#define CTRL2_CMX_EN 0x01 - -#define CTRL3_BPC_EN 0x80 -#define CTRL3_WPC_EN 0x40 - -#define R_DVP_SP_AUTO_MODE 0x80 - -#define R_BYPASS_DSP_EN 0x00 -#define R_BYPASS_DSP_BYPAS 0x01 - -#define IMAGE_MODE_Y8_DVP_EN 0x40 -#define IMAGE_MODE_JPEG_EN 0x10 -#define IMAGE_MODE_YUV422 0x00 -#define IMAGE_MODE_RAW10 0x04 -#define IMAGE_MODE_RGB565 0x08 -#define IMAGE_MODE_HREF_VSYNC 0x02 -#define IMAGE_MODE_LBYTE_FIRST 0x01 - -#define RESET_MICROC 0x40 -#define RESET_SCCB 0x20 -#define RESET_JPEG 0x10 -#define RESET_DVP 0x04 -#define RESET_IPU 0x02 -#define RESET_CIF 0x01 - -#define MC_BIST_RESET 0x80 -#define MC_BIST_BOOT_ROM_SEL 0x40 -#define MC_BIST_12KB_SEL 0x20 -#define MC_BIST_12KB_MASK 0x30 -#define MC_BIST_512KB_SEL 0x08 -#define MC_BIST_512KB_MASK 0x0C -#define MC_BIST_BUSY_BIT_R 0x02 -#define MC_BIST_MC_RES_ONE_SH_W 0x02 -#define MC_BIST_LAUNCH 0x01 - - -typedef enum { - BANK_DSP, BANK_SENSOR, BANK_MAX -} ov2640_bank_t; - -/* Sensor register bank FF=0x01*/ -#define GAIN 0x00 -#define COM1 0x03 -#define REG04 0x04 -#define REG08 0x08 -#define COM2 0x09 -#define REG_PID 0x0A -#define REG_VER 0x0B -#define COM3 0x0C -#define COM4 0x0D -#define AEC 0x10 -#define CLKRC 0x11 -#define COM7 0x12 -#define COM8 0x13 -#define COM9 0x14 /* AGC gain ceiling */ -#define COM10 0x15 -#define HSTART 0x17 -#define HSTOP 0x18 -#define VSTART 0x19 -#define VSTOP 0x1A -#define REG_MIDH 0x1C -#define REG_MIDL 0x1D -#define AEW 0x24 -#define AEB 0x25 -#define VV 0x26 -#define REG2A 0x2A -#define FRARL 0x2B -#define ADDVSL 0x2D -#define ADDVSH 0x2E -#define YAVG 0x2F -#define HSDY 0x30 -#define HEDY 0x31 -#define REG32 0x32 -#define ARCOM2 0x34 -#define REG45 0x45 -#define FLL 0x46 -#define FLH 0x47 -#define COM19 0x48 -#define ZOOMS 0x49 -#define COM22 0x4B -#define COM25 0x4E -#define BD50 0x4F -#define BD60 0x50 -#define REG5D 0x5D -#define REG5E 0x5E -#define REG5F 0x5F -#define REG60 0x60 -#define HISTO_LOW 0x61 -#define HISTO_HIGH 0x62 - -#define REG04_DEFAULT 0x28 -#define REG04_HFLIP_IMG 0x80 -#define REG04_VFLIP_IMG 0x40 -#define REG04_VREF_EN 0x10 -#define REG04_HREF_EN 0x08 -#define REG04_SET(x) (REG04_DEFAULT|x) - -#define COM2_STDBY 0x10 -#define COM2_OUT_DRIVE_1x 0x00 -#define COM2_OUT_DRIVE_2x 0x01 -#define COM2_OUT_DRIVE_3x 0x02 -#define COM2_OUT_DRIVE_4x 0x03 - -#define COM3_DEFAULT 0x38 -#define COM3_BAND_50Hz 0x04 -#define COM3_BAND_60Hz 0x00 -#define COM3_BAND_AUTO 0x02 -#define COM3_BAND_SET(x) (COM3_DEFAULT|x) - -#define COM7_SRST 0x80 -#define COM7_RES_UXGA 0x00 /* UXGA */ -#define COM7_RES_SVGA 0x40 /* SVGA */ -#define COM7_RES_CIF 0x20 /* CIF */ -#define COM7_ZOOM_EN 0x04 /* Enable Zoom */ -#define COM7_COLOR_BAR 0x02 /* Enable Color Bar Test */ - -#define COM8_DEFAULT 0xC0 -#define COM8_BNDF_EN 0x20 /* Enable Banding filter */ -#define COM8_AGC_EN 0x04 /* AGC Auto/Manual control selection */ -#define COM8_AEC_EN 0x01 /* Auto/Manual Exposure control */ -#define COM8_SET(x) (COM8_DEFAULT|x) - -#define COM9_DEFAULT 0x08 -#define COM9_AGC_GAIN_2x 0x00 /* AGC: 2x */ -#define COM9_AGC_GAIN_4x 0x01 /* AGC: 4x */ -#define COM9_AGC_GAIN_8x 0x02 /* AGC: 8x */ -#define COM9_AGC_GAIN_16x 0x03 /* AGC: 16x */ -#define COM9_AGC_GAIN_32x 0x04 /* AGC: 32x */ -#define COM9_AGC_GAIN_64x 0x05 /* AGC: 64x */ -#define COM9_AGC_GAIN_128x 0x06 /* AGC: 128x */ -#define COM9_AGC_SET(x) (COM9_DEFAULT|(x<<5)) - -#define COM10_HREF_EN 0x80 /* HSYNC changes to HREF */ -#define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ -#define COM10_PCLK_FREE 0x20 /* PCLK output option: free running PCLK */ -#define COM10_PCLK_EDGE 0x10 /* Data is updated at the rising edge of PCLK */ -#define COM10_HREF_NEG 0x08 /* HREF negative */ -#define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ -#define COM10_HSYNC_NEG 0x01 /* HSYNC negative */ - -#define CTRL1_AWB 0x08 /* Enable AWB */ - -#define VV_AGC_TH_SET(h,l) ((h<<4)|(l&0x0F)) - -#define REG32_UXGA 0x36 -#define REG32_SVGA 0x09 -#define REG32_CIF 0x89 - -#define CLKRC_2X 0x80 -#define CLKRC_2X_UXGA (0x01 | CLKRC_2X) -#define CLKRC_2X_SVGA CLKRC_2X -#define CLKRC_2X_CIF CLKRC_2X - -#endif //__REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h deleted file mode 100644 index f151f0a42..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov2640_settings.h +++ /dev/null @@ -1,485 +0,0 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -#ifndef _OV2640_SETTINGS_H_ -#define _OV2640_SETTINGS_H_ - -#include -#include -#include "esp_attr.h" -#include "ov2640_regs.h" - -typedef enum { - OV2640_MODE_UXGA, OV2640_MODE_SVGA, OV2640_MODE_CIF, OV2640_MODE_MAX -} ov2640_sensor_mode_t; - -typedef struct { - union { - struct { - uint8_t pclk_div:7; - uint8_t pclk_auto:1; - }; - uint8_t pclk; - }; - union { - struct { - uint8_t clk_div:6; - uint8_t reserved:1; - uint8_t clk_2x:1; - }; - uint8_t clk; - }; -} ov2640_clk_t; - -typedef struct { - uint16_t offset_x; - uint16_t offset_y; - uint16_t max_x; - uint16_t max_y; -} ov2640_ratio_settings_t; - -static const DRAM_ATTR ov2640_ratio_settings_t ratio_table[] = { - // ox, oy, mx, my - { 0, 0, 1600, 1200 }, //4x3 - { 8, 72, 1584, 1056 }, //3x2 - { 0, 100, 1600, 1000 }, //16x10 - { 0, 120, 1600, 960 }, //5x3 - { 0, 150, 1600, 900 }, //16x9 - { 2, 258, 1596, 684 }, //21x9 - { 50, 0, 1500, 1200 }, //5x4 - { 200, 0, 1200, 1200 }, //1x1 - { 462, 0, 676, 1200 } //9x16 -}; - -// 30fps@24MHz -const DRAM_ATTR uint8_t ov2640_settings_cif[][2] = { - {BANK_SEL, BANK_DSP}, - {0x2c, 0xff}, - {0x2e, 0xdf}, - {BANK_SEL, BANK_SENSOR}, - {0x3c, 0x32}, - {CLKRC, 0x01}, - {COM2, COM2_OUT_DRIVE_3x}, - {REG04, REG04_DEFAULT}, - {COM8, COM8_DEFAULT | COM8_BNDF_EN | COM8_AGC_EN | COM8_AEC_EN}, - {COM9, COM9_AGC_SET(COM9_AGC_GAIN_8x)}, - {0x2c, 0x0c}, - {0x33, 0x78}, - {0x3a, 0x33}, - {0x3b, 0xfB}, - {0x3e, 0x00}, - {0x43, 0x11}, - {0x16, 0x10}, - {0x39, 0x92}, - {0x35, 0xda}, - {0x22, 0x1a}, - {0x37, 0xc3}, - {0x23, 0x00}, - {ARCOM2, 0xc0}, - {0x06, 0x88}, - {0x07, 0xc0}, - {COM4, 0x87}, - {0x0e, 0x41}, - {0x4c, 0x00}, - {0x4a, 0x81}, - {0x21, 0x99}, - {AEW, 0x40}, - {AEB, 0x38}, - {VV, VV_AGC_TH_SET(8,2)}, - {0x5c, 0x00}, - {0x63, 0x00}, - {HISTO_LOW, 0x70}, - {HISTO_HIGH, 0x80}, - {0x7c, 0x05}, - {0x20, 0x80}, - {0x28, 0x30}, - {0x6c, 0x00}, - {0x6d, 0x80}, - {0x6e, 0x00}, - {0x70, 0x02}, - {0x71, 0x94}, - {0x73, 0xc1}, - {0x3d, 0x34}, - {0x5a, 0x57}, - {BD50, 0xbb}, - {BD60, 0x9c}, - {COM7, COM7_RES_CIF}, - {HSTART, 0x11}, - {HSTOP, 0x43}, - {VSTART, 0x00}, - {VSTOP, 0x25}, - {REG32, 0x89}, - {0x37, 0xc0}, - {BD50, 0xca}, - {BD60, 0xa8}, - {0x6d, 0x00}, - {0x3d, 0x38}, - {BANK_SEL, BANK_DSP}, - {0xe5, 0x7f}, - {MC_BIST, MC_BIST_RESET | MC_BIST_BOOT_ROM_SEL}, - {0x41, 0x24}, - {RESET, RESET_JPEG | RESET_DVP}, - {0x76, 0xff}, - {0x33, 0xa0}, - {0x42, 0x20}, - {0x43, 0x18}, - {0x4c, 0x00}, - {CTRL3, CTRL3_WPC_EN | 0x10 }, - {0x88, 0x3f}, - {0xd7, 0x03}, - {0xd9, 0x10}, - {R_DVP_SP, R_DVP_SP_AUTO_MODE | 0x02}, - {0xc8, 0x08}, - {0xc9, 0x80}, - {BPADDR, 0x00}, - {BPDATA, 0x00}, - {BPADDR, 0x03}, - {BPDATA, 0x48}, - {BPDATA, 0x48}, - {BPADDR, 0x08}, - {BPDATA, 0x20}, - {BPDATA, 0x10}, - {BPDATA, 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}, - {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}, - {CTRL1, 0xfd}, - {0x7f, 0x00}, - {0xe5, 0x1f}, - {0xe1, 0x67}, - {0xdd, 0x7f}, - {IMAGE_MODE, 0x00}, - {RESET, 0x00}, - {R_BYPASS, R_BYPASS_DSP_EN}, - {0, 0} -}; - -const DRAM_ATTR uint8_t ov2640_settings_to_cif[][2] = { - {BANK_SEL, BANK_SENSOR}, - {COM7, COM7_RES_CIF}, - - //Set the sensor output window - {COM1, 0x0A}, - {REG32, REG32_CIF}, - {HSTART, 0x11}, - {HSTOP, 0x43}, - {VSTART, 0x00}, - {VSTOP, 0x25}, - - //{CLKRC, 0x00}, - {BD50, 0xca}, - {BD60, 0xa8}, - {0x5a, 0x23}, - {0x6d, 0x00}, - {0x3d, 0x38}, - {0x39, 0x92}, - {0x35, 0xda}, - {0x22, 0x1a}, - {0x37, 0xc3}, - {0x23, 0x00}, - {ARCOM2, 0xc0}, - {0x06, 0x88}, - {0x07, 0xc0}, - {COM4, 0x87}, - {0x0e, 0x41}, - {0x4c, 0x00}, - {BANK_SEL, BANK_DSP}, - {RESET, RESET_DVP}, - - //Set the sensor resolution (UXGA, SVGA, CIF) - {HSIZE8, 0x32}, - {VSIZE8, 0x25}, - {SIZEL, 0x00}, - - //Set the image window size >= output size - {HSIZE, 0x64}, - {VSIZE, 0x4a}, - {XOFFL, 0x00}, - {YOFFL, 0x00}, - {VHYX, 0x00}, - {TEST, 0x00}, - - {CTRL2, CTRL2_DCW_EN | 0x1D}, - {CTRLI, CTRLI_LP_DP | 0x00}, - //{R_DVP_SP, 0x08}, - {0, 0} -}; - -const DRAM_ATTR uint8_t ov2640_settings_to_svga[][2] = { - {BANK_SEL, BANK_SENSOR}, - {COM7, COM7_RES_SVGA}, - - //Set the sensor output window - {COM1, 0x0A}, - {REG32, REG32_SVGA}, - {HSTART, 0x11}, - {HSTOP, 0x43}, - {VSTART, 0x00}, - {VSTOP, 0x4b}, - - //{CLKRC, 0x00}, - {0x37, 0xc0}, - {BD50, 0xca}, - {BD60, 0xa8}, - {0x5a, 0x23}, - {0x6d, 0x00}, - {0x3d, 0x38}, - {0x39, 0x92}, - {0x35, 0xda}, - {0x22, 0x1a}, - {0x37, 0xc3}, - {0x23, 0x00}, - {ARCOM2, 0xc0}, - {0x06, 0x88}, - {0x07, 0xc0}, - {COM4, 0x87}, - {0x0e, 0x41}, - {0x42, 0x03}, - {0x4c, 0x00}, - {BANK_SEL, BANK_DSP}, - {RESET, RESET_DVP}, - - //Set the sensor resolution (UXGA, SVGA, CIF) - {HSIZE8, 0x64}, - {VSIZE8, 0x4B}, - {SIZEL, 0x00}, - - //Set the image window size >= output size - {HSIZE, 0xC8}, - {VSIZE, 0x96}, - {XOFFL, 0x00}, - {YOFFL, 0x00}, - {VHYX, 0x00}, - {TEST, 0x00}, - - {CTRL2, CTRL2_DCW_EN | 0x1D}, - {CTRLI, CTRLI_LP_DP | 0x00}, - //{R_DVP_SP, 0x08}, - {0, 0} -}; - -const DRAM_ATTR uint8_t ov2640_settings_to_uxga[][2] = { - {BANK_SEL, BANK_SENSOR}, - {COM7, COM7_RES_UXGA}, - - //Set the sensor output window - {COM1, 0x0F}, - {REG32, REG32_UXGA}, - {HSTART, 0x11}, - {HSTOP, 0x75}, - {VSTART, 0x01}, - {VSTOP, 0x97}, - - //{CLKRC, 0x00}, - {0x3d, 0x34}, - {BD50, 0xbb}, - {BD60, 0x9c}, - {0x5a, 0x57}, - {0x6d, 0x80}, - {0x39, 0x82}, - {0x23, 0x00}, - {0x07, 0xc0}, - {0x4c, 0x00}, - {0x35, 0x88}, - {0x22, 0x0a}, - {0x37, 0x40}, - {ARCOM2, 0xa0}, - {0x06, 0x02}, - {COM4, 0xb7}, - {0x0e, 0x01}, - {0x42, 0x83}, - {BANK_SEL, BANK_DSP}, - {RESET, RESET_DVP}, - - //Set the sensor resolution (UXGA, SVGA, CIF) - {HSIZE8, 0xc8}, - {VSIZE8, 0x96}, - {SIZEL, 0x00}, - - //Set the image window size >= output size - {HSIZE, 0x90}, - {VSIZE, 0x2c}, - {XOFFL, 0x00}, - {YOFFL, 0x00}, - {VHYX, 0x88}, - {TEST, 0x00}, - - {CTRL2, CTRL2_DCW_EN | 0x1d}, - {CTRLI, 0x00}, - //{R_DVP_SP, 0x06}, - {0, 0} -}; - -const DRAM_ATTR uint8_t ov2640_settings_jpeg3[][2] = { - {BANK_SEL, BANK_DSP}, - {RESET, RESET_JPEG | RESET_DVP}, - {IMAGE_MODE, IMAGE_MODE_JPEG_EN | IMAGE_MODE_HREF_VSYNC}, - {0xD7, 0x03}, - {0xE1, 0x77}, - {0xE5, 0x1F}, - {0xD9, 0x10}, - {0xDF, 0x80}, - {0x33, 0x80}, - {0x3C, 0x10}, - {0xEB, 0x30}, - {0xDD, 0x7F}, - {RESET, 0x00}, - {0, 0} -}; - -static const uint8_t ov2640_settings_yuv422[][2] = { - {BANK_SEL, BANK_DSP}, - {RESET, RESET_DVP}, - {IMAGE_MODE, IMAGE_MODE_YUV422}, - {0xD7, 0x01}, - {0xE1, 0x67}, - {RESET, 0x00}, - {0, 0}, -}; - -static const uint8_t ov2640_settings_rgb565[][2] = { - {BANK_SEL, BANK_DSP}, - {RESET, RESET_DVP}, - {IMAGE_MODE, IMAGE_MODE_RGB565}, - {0xD7, 0x03}, - {0xE1, 0x77}, - {RESET, 0x00}, - {0, 0}, -}; - -#define NUM_BRIGHTNESS_LEVELS (5) -static const uint8_t brightness_regs[NUM_BRIGHTNESS_LEVELS + 1][5] = { - {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA }, - {0x00, 0x04, 0x09, 0x00, 0x00 }, /* -2 */ - {0x00, 0x04, 0x09, 0x10, 0x00 }, /* -1 */ - {0x00, 0x04, 0x09, 0x20, 0x00 }, /* 0 */ - {0x00, 0x04, 0x09, 0x30, 0x00 }, /* +1 */ - {0x00, 0x04, 0x09, 0x40, 0x00 }, /* +2 */ -}; - -#define NUM_CONTRAST_LEVELS (5) -static const uint8_t contrast_regs[NUM_CONTRAST_LEVELS + 1][7] = { - {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA, BPDATA, BPDATA }, - {0x00, 0x04, 0x07, 0x20, 0x18, 0x34, 0x06 }, /* -2 */ - {0x00, 0x04, 0x07, 0x20, 0x1c, 0x2a, 0x06 }, /* -1 */ - {0x00, 0x04, 0x07, 0x20, 0x20, 0x20, 0x06 }, /* 0 */ - {0x00, 0x04, 0x07, 0x20, 0x24, 0x16, 0x06 }, /* +1 */ - {0x00, 0x04, 0x07, 0x20, 0x28, 0x0c, 0x06 }, /* +2 */ -}; - -#define NUM_SATURATION_LEVELS (5) -static const uint8_t saturation_regs[NUM_SATURATION_LEVELS + 1][5] = { - {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA }, - {0x00, 0x02, 0x03, 0x28, 0x28 }, /* -2 */ - {0x00, 0x02, 0x03, 0x38, 0x38 }, /* -1 */ - {0x00, 0x02, 0x03, 0x48, 0x48 }, /* 0 */ - {0x00, 0x02, 0x03, 0x58, 0x58 }, /* +1 */ - {0x00, 0x02, 0x03, 0x68, 0x68 }, /* +2 */ -}; - -#define NUM_SPECIAL_EFFECTS (7) -static const uint8_t special_effects_regs[NUM_SPECIAL_EFFECTS + 1][5] = { - {BPADDR, BPDATA, BPADDR, BPDATA, BPDATA }, - {0x00, 0X00, 0x05, 0X80, 0X80 }, /* no effect */ - {0x00, 0X40, 0x05, 0X80, 0X80 }, /* negative */ - {0x00, 0X18, 0x05, 0X80, 0X80 }, /* black and white */ - {0x00, 0X18, 0x05, 0X40, 0XC0 }, /* reddish */ - {0x00, 0X18, 0x05, 0X40, 0X40 }, /* greenish */ - {0x00, 0X18, 0x05, 0XA0, 0X40 }, /* blue */ - {0x00, 0X18, 0x05, 0X40, 0XA6 }, /* retro */ -}; - -#define NUM_WB_MODES (4) -static const uint8_t wb_modes_regs[NUM_WB_MODES + 1][3] = { - {0XCC, 0XCD, 0XCE }, - {0x5E, 0X41, 0x54 }, /* sunny */ - {0x65, 0X41, 0x4F }, /* cloudy */ - {0x52, 0X41, 0x66 }, /* office */ - {0x42, 0X3F, 0x71 }, /* home */ -}; - -#define NUM_AE_LEVELS (5) -static const uint8_t ae_levels_regs[NUM_AE_LEVELS + 1][3] = { - { AEW, AEB, VV }, - {0x20, 0X18, 0x60 }, - {0x34, 0X1C, 0x00 }, - {0x3E, 0X38, 0x81 }, - {0x48, 0X40, 0x81 }, - {0x58, 0X50, 0x92 }, -}; - -const uint8_t agc_gain_tbl[31] = { - 0x00, 0x10, 0x18, 0x30, 0x34, 0x38, 0x3C, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7A, 0x7C, 0x7E, 0xF0, - 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF -}; - -#endif /* _OV2640_SETTINGS_H_ */ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h deleted file mode 100644 index 341d68861..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV3660 driver. - * - */ -#ifndef __OV3660_H__ -#define __OV3660_H__ - -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int ov3660_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int ov3660_init(sensor_t *sensor); - -#endif // __OV3660_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h deleted file mode 100644 index b5cf30a5b..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_regs.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - * OV3660 register definitions. - */ -#ifndef __OV3660_REG_REGS_H__ -#define __OV3660_REG_REGS_H__ - -/* system control registers */ -#define SYSTEM_CTROL0 0x3008 // Bit[7]: Software reset - // Bit[6]: Software power down - // Bit[5]: Reserved - // Bit[4]: SRB clock SYNC enable - // Bit[3]: Isolation suspend select - // Bit[2:0]: Not used - -/* output format control registers */ -#define FORMAT_CTRL 0x501F // Format select - // Bit[2:0]: - // 000: YUV422 - // 001: RGB - // 010: Dither - // 011: RAW after DPC - // 101: RAW after CIP - -/* format control registers */ -#define FORMAT_CTRL00 0x4300 - -/* frame control registers */ -#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode - // Bit[7:4]: Not used - // Bit[3:0]: Frame ON number -#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode - // Bit[7:4]: Not used - // BIT[3:0]: Frame OFF number - -/* ISP top control registers */ -#define PRE_ISP_TEST_SETTING_1 0x503D // Bit[7]: Test enable - // 0: Test disable - // 1: Color bar enable - // Bit[6]: Rolling - // Bit[5]: Transparent - // Bit[4]: Square black and white - // Bit[3:2]: Color bar style - // 00: Standard 8 color bar - // 01: Gradual change at vertical mode 1 - // 10: Gradual change at horizontal - // 11: Gradual change at vertical mode 2 - // Bit[1:0]: Test select - // 00: Color bar - // 01: Random data - // 10: Square data - // 11: Black image - -//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW - -/* AEC/AGC control functions */ -#define AEC_PK_MANUAL 0x3503 // AEC Manual Mode Control - // Bit[7:6]: Reserved - // Bit[5]: Gain delay option - // Valid when 0x3503[4]=1’b0 - // 0: Delay one frame latch - // 1: One frame latch - // Bit[4:2]: Reserved - // Bit[1]: AGC manual - // 0: Auto enable - // 1: Manual enable - // Bit[0]: AEC manual - // 0: Auto enable - // 1: Manual enable - -//gain = {0x350A[1:0], 0x350B[7:0]} / 16 - -/* mirror and flip registers */ -#define TIMING_TC_REG20 0x3820 // Timing Control Register - // Bit[2:1]: Vertical flip enable - // 00: Normal - // 11: Vertical flip - // Bit[0]: Vertical binning enable -#define TIMING_TC_REG21 0x3821 // Timing Control Register - // Bit[5]: Compression Enable - // Bit[2:1]: Horizontal mirror enable - // 00: Normal - // 11: Horizontal mirror - // Bit[0]: Horizontal binning enable - -#define CLOCK_POL_CONTROL 0x4740// Bit[5]: PCLK polarity 0: active low - // 1: active high - // Bit[3]: Gate PCLK under VSYNC - // Bit[2]: Gate PCLK under HREF - // Bit[1]: HREF polarity - // 0: active low - // 1: active high - // Bit[0] VSYNC polarity - // 0: active low - // 1: active high -#define DRIVE_CAPABILITY 0x302c // Bit[7:6]: - // 00: 1x - // 01: 2x - // 10: 3x - // 11: 4x - - -#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8] -#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0] -#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8] -#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0] -#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8] -#define X_ADDR_END_L 0x3805 //Bit[7:0]: -#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8] -#define Y_ADDR_END_L 0x3807 //Bit[7:0]: -// Size after scaling -#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8] -#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]: -#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8] -#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]: -#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8] -#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]: -#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8] -#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]: -#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8] -#define X_OFFSET_L 0x3811 //Bit[7:0]: -#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8] -#define Y_OFFSET_L 0x3813 //Bit[7:0]: -#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment - //Bit[3:0]: Horizontal even subsample increment -#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment - //Bit[3:0]: Vertical even subsample increment -// Size before scaling -//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET)) -//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET)) - -#define ISP_CONTROL_01 0x5001 // Bit[5]: Scale enable - // 0: Disable - // 1: Enable - -#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW - // DCW scale times - // 000: DCW 1 time - // 001: DCW 2 times - // 010: DCW 4 times - // 100: DCW 8 times - // 101: DCW 16 times - // Others: DCW 16 times - // Bit[2:0]: VDIV RW - // DCW scale times - // 000: DCW 1 time - // 001: DCW 2 times - // 010: DCW 4 times - // 100: DCW 8 times - // 101: DCW 16 times - // Others: DCW 16 times - -#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits -#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits -#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits -#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits -#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset - -#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual -#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable - // 0: Auto - // 1: Manual by PCLK_RATIO - -#define VFIFO_X_SIZE_H 0x4602 -#define VFIFO_X_SIZE_L 0x4603 -#define VFIFO_Y_SIZE_H 0x4604 -#define VFIFO_Y_SIZE_L 0x4605 - -#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass -#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier -#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control - // Bit[3:0]: PLLS system divider -#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider - // 00: 1 - // 01: 1.5 - // 10: 2 - // 11: 3 - // Bit[2]: PLLS root-divider - 1 - // Bit[1:0]: PLLS seld5 - // 00: 1 - // 01: 1 - // 10: 2 - // 11: 2.5 - -#define COMPRESSION_CTRL00 0x4400 // -#define COMPRESSION_CTRL01 0x4401 // -#define COMPRESSION_CTRL02 0x4402 // -#define COMPRESSION_CTRL03 0x4403 // -#define COMPRESSION_CTRL04 0x4404 // -#define COMPRESSION_CTRL05 0x4405 // -#define COMPRESSION_CTRL06 0x4406 // -#define COMPRESSION_CTRL07 0x4407 // Bit[5:0]: QS -#define COMPRESSION_ISI_CTRL 0x4408 // -#define COMPRESSION_CTRL09 0x4409 // -#define COMPRESSION_CTRL0a 0x440a // -#define COMPRESSION_CTRL0b 0x440b // -#define COMPRESSION_CTRL0c 0x440c // -#define COMPRESSION_CTRL0d 0x440d // -#define COMPRESSION_CTRL0E 0x440e // - -/** - * @brief register value - */ -#define TEST_COLOR_BAR 0xC0 /* Enable Color Bar roling Test */ - -#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */ -#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */ - -#define TIMING_TC_REG20_VFLIP 0x06 /* Vertical flip enable */ -#define TIMING_TC_REG21_HMIRROR 0x06 /* Horizontal mirror enable */ - -#endif // __OV3660_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h deleted file mode 100644 index 97c4e03b6..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov3660_settings.h +++ /dev/null @@ -1,318 +0,0 @@ -#ifndef _OV3660_SETTINGS_H_ -#define _OV3660_SETTINGS_H_ - -#include -#include -#include "esp_attr.h" -#include "ov3660_regs.h" - -static const ratio_settings_t ratio_table[] = { - // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty - { 2048, 1536, 0, 0, 2079, 1547, 16, 6, 2300, 1564 }, //4x3 - { 1920, 1280, 64, 128, 2015, 1419, 16, 6, 2172, 1436 }, //3x2 - { 2048, 1280, 0, 128, 2079, 1419, 16, 6, 2300, 1436 }, //16x10 - { 1920, 1152, 64, 192, 2015, 1355, 16, 6, 2172, 1372 }, //5x3 - { 1920, 1080, 64, 242, 2015, 1333, 16, 6, 2172, 1322 }, //16x9 - { 2048, 880, 0, 328, 2079, 1219, 16, 6, 2300, 1236 }, //21x9 - { 1920, 1536, 64, 0, 2015, 1547, 16, 6, 2172, 1564 }, //5x4 - { 1536, 1536, 256, 0, 1823, 1547, 16, 6, 2044, 1564 }, //1x1 - { 864, 1536, 592, 0, 1487, 1547, 16, 6, 2044, 1564 } //9x16 -}; - -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 - -static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { - {SYSTEM_CTROL0, 0x82}, // software reset - {REG_DLY, 10}, // delay 10ms - - {0x3103, 0x13}, - {SYSTEM_CTROL0, 0x42}, - {0x3017, 0xff}, - {0x3018, 0xff}, - {DRIVE_CAPABILITY, 0xc3}, - {CLOCK_POL_CONTROL, 0x21}, - - {0x3611, 0x01}, - {0x3612, 0x2d}, - - {0x3032, 0x00}, - {0x3614, 0x80}, - {0x3618, 0x00}, - {0x3619, 0x75}, - {0x3622, 0x80}, - {0x3623, 0x00}, - {0x3624, 0x03}, - {0x3630, 0x52}, - {0x3632, 0x07}, - {0x3633, 0xd2}, - {0x3704, 0x80}, - {0x3708, 0x66}, - {0x3709, 0x12}, - {0x370b, 0x12}, - {0x3717, 0x00}, - {0x371b, 0x60}, - {0x371c, 0x00}, - {0x3901, 0x13}, - - {0x3600, 0x08}, - {0x3620, 0x43}, - {0x3702, 0x20}, - {0x3739, 0x48}, - {0x3730, 0x20}, - {0x370c, 0x0c}, - - {0x3a18, 0x00}, - {0x3a19, 0xf8}, - - {0x3000, 0x10}, - {0x3004, 0xef}, - - {0x6700, 0x05}, - {0x6701, 0x19}, - {0x6702, 0xfd}, - {0x6703, 0xd1}, - {0x6704, 0xff}, - {0x6705, 0xff}, - - {0x3c01, 0x80}, - {0x3c00, 0x04}, - {0x3a08, 0x00}, {0x3a09, 0x62}, //50Hz Band Width Step (10bit) - {0x3a0e, 0x08}, //50Hz Max Bands in One Frame (6 bit) - {0x3a0a, 0x00}, {0x3a0b, 0x52}, //60Hz Band Width Step (10bit) - {0x3a0d, 0x09}, //60Hz Max Bands in One Frame (6 bit) - - {0x3a00, 0x3a},//night mode off - {0x3a14, 0x09}, - {0x3a15, 0x30}, - {0x3a02, 0x09}, - {0x3a03, 0x30}, - - {COMPRESSION_CTRL0E, 0x08}, - {0x4520, 0x0b}, - {0x460b, 0x37}, - {0x4713, 0x02}, - {0x471c, 0xd0}, - {0x5086, 0x00}, - - {0x5002, 0x00}, - {0x501f, 0x00}, - - {SYSTEM_CTROL0, 0x02}, - - {0x5180, 0xff}, - {0x5181, 0xf2}, - {0x5182, 0x00}, - {0x5183, 0x14}, - {0x5184, 0x25}, - {0x5185, 0x24}, - {0x5186, 0x16}, - {0x5187, 0x16}, - {0x5188, 0x16}, - {0x5189, 0x68}, - {0x518a, 0x60}, - {0x518b, 0xe0}, - {0x518c, 0xb2}, - {0x518d, 0x42}, - {0x518e, 0x35}, - {0x518f, 0x56}, - {0x5190, 0x56}, - {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}, - - {0x5381, 0x1d}, - {0x5382, 0x60}, - {0x5383, 0x03}, - {0x5384, 0x0c}, - {0x5385, 0x78}, - {0x5386, 0x84}, - {0x5387, 0x7d}, - {0x5388, 0x6b}, - {0x5389, 0x12}, - {0x538a, 0x01}, - {0x538b, 0x98}, - - {0x5480, 0x01}, -// {0x5481, 0x05}, -// {0x5482, 0x09}, -// {0x5483, 0x10}, -// {0x5484, 0x3a}, -// {0x5485, 0x4c}, -// {0x5486, 0x5a}, -// {0x5487, 0x68}, -// {0x5488, 0x74}, -// {0x5489, 0x80}, -// {0x548a, 0x8e}, -// {0x548b, 0xa4}, -// {0x548c, 0xb4}, -// {0x548d, 0xc8}, -// {0x548e, 0xde}, -// {0x548f, 0xf0}, -// {0x5490, 0x15}, - - {0x5000, 0xa7}, - {0x5800, 0x0C}, - {0x5801, 0x09}, - {0x5802, 0x0C}, - {0x5803, 0x0C}, - {0x5804, 0x0D}, - {0x5805, 0x17}, - {0x5806, 0x06}, - {0x5807, 0x05}, - {0x5808, 0x04}, - {0x5809, 0x06}, - {0x580a, 0x09}, - {0x580b, 0x0E}, - {0x580c, 0x05}, - {0x580d, 0x01}, - {0x580e, 0x01}, - {0x580f, 0x01}, - {0x5810, 0x05}, - {0x5811, 0x0D}, - {0x5812, 0x05}, - {0x5813, 0x01}, - {0x5814, 0x01}, - {0x5815, 0x01}, - {0x5816, 0x05}, - {0x5817, 0x0D}, - {0x5818, 0x08}, - {0x5819, 0x06}, - {0x581a, 0x05}, - {0x581b, 0x07}, - {0x581c, 0x0B}, - {0x581d, 0x0D}, - {0x581e, 0x12}, - {0x581f, 0x0D}, - {0x5820, 0x0E}, - {0x5821, 0x10}, - {0x5822, 0x10}, - {0x5823, 0x1E}, - {0x5824, 0x53}, - {0x5825, 0x15}, - {0x5826, 0x05}, - {0x5827, 0x14}, - {0x5828, 0x54}, - {0x5829, 0x25}, - {0x582a, 0x33}, - {0x582b, 0x33}, - {0x582c, 0x34}, - {0x582d, 0x16}, - {0x582e, 0x24}, - {0x582f, 0x41}, - {0x5830, 0x50}, - {0x5831, 0x42}, - {0x5832, 0x15}, - {0x5833, 0x25}, - {0x5834, 0x34}, - {0x5835, 0x33}, - {0x5836, 0x24}, - {0x5837, 0x26}, - {0x5838, 0x54}, - {0x5839, 0x25}, - {0x583a, 0x15}, - {0x583b, 0x25}, - {0x583c, 0x53}, - {0x583d, 0xCF}, - - {0x3a0f, 0x30}, - {0x3a10, 0x28}, - {0x3a1b, 0x30}, - {0x3a1e, 0x28}, - {0x3a11, 0x60}, - {0x3a1f, 0x14}, - - {0x5302, 0x28}, - {0x5303, 0x20}, - - {0x5306, 0x1c}, //de-noise offset 1 - {0x5307, 0x28}, //de-noise offset 2 - - {0x4002, 0xc5}, - {0x4003, 0x81}, - {0x4005, 0x12}, - - {0x5688, 0x11}, - {0x5689, 0x11}, - {0x568a, 0x11}, - {0x568b, 0x11}, - {0x568c, 0x11}, - {0x568d, 0x11}, - {0x568e, 0x11}, - {0x568f, 0x11}, - - {0x5580, 0x06}, - {0x5588, 0x00}, - {0x5583, 0x40}, - {0x5584, 0x2c}, - - {ISP_CONTROL_01, 0x83}, // turn color matrix, awb and SDE - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_jpeg[][2] = { - {FORMAT_CTRL, 0x00}, // YUV422 - {FORMAT_CTRL00, 0x30}, // YUYV - {0x3002, 0x00},//0x1c to 0x00 !!! - {0x3006, 0xff},//0xc3 to 0xff !!! - {0x471c, 0x50},//0xd0 to 0x50 !!! - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_raw[][2] = { - {FORMAT_CTRL00, 0x00}, // RAW - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint16_t sensor_fmt_grayscale[][2] = { - {FORMAT_CTRL, 0x00}, // YUV422 - {FORMAT_CTRL00, 0x10}, // Y8 - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint16_t sensor_fmt_yuv422[][2] = { - {FORMAT_CTRL, 0x00}, // YUV422 - {FORMAT_CTRL00, 0x30}, // YUYV - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint16_t sensor_fmt_rgb565[][2] = { - {FORMAT_CTRL, 0x01}, // RGB - {FORMAT_CTRL00, 0x61}, // RGB565 (BGR) - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint8_t sensor_saturation_levels[9][11] = { - {0x1d, 0x60, 0x03, 0x07, 0x48, 0x4f, 0x4b, 0x40, 0x0b, 0x01, 0x98},//-4 - {0x1d, 0x60, 0x03, 0x08, 0x54, 0x5c, 0x58, 0x4b, 0x0d, 0x01, 0x98},//-3 - {0x1d, 0x60, 0x03, 0x0a, 0x60, 0x6a, 0x64, 0x56, 0x0e, 0x01, 0x98},//-2 - {0x1d, 0x60, 0x03, 0x0b, 0x6c, 0x77, 0x70, 0x60, 0x10, 0x01, 0x98},//-1 - {0x1d, 0x60, 0x03, 0x0c, 0x78, 0x84, 0x7d, 0x6b, 0x12, 0x01, 0x98},//0 - {0x1d, 0x60, 0x03, 0x0d, 0x84, 0x91, 0x8a, 0x76, 0x14, 0x01, 0x98},//+1 - {0x1d, 0x60, 0x03, 0x0e, 0x90, 0x9e, 0x96, 0x80, 0x16, 0x01, 0x98},//+2 - {0x1d, 0x60, 0x03, 0x10, 0x9c, 0xac, 0xa2, 0x8b, 0x17, 0x01, 0x98},//+3 - {0x1d, 0x60, 0x03, 0x11, 0xa8, 0xb9, 0xaf, 0x96, 0x19, 0x01, 0x98},//+4 -}; - -static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = { - {0x06, 0x40, 0x2c, 0x08},//Normal - {0x46, 0x40, 0x28, 0x08},//Negative - {0x1e, 0x80, 0x80, 0x08},//Grayscale - {0x1e, 0x80, 0xc0, 0x08},//Red Tint - {0x1e, 0x60, 0x60, 0x08},//Green Tint - {0x1e, 0xa0, 0x40, 0x08},//Blue Tint - {0x1e, 0x40, 0xa0, 0x08},//Sepia -}; - -#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h deleted file mode 100644 index 120ae7205..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640.h +++ /dev/null @@ -1,27 +0,0 @@ - -#ifndef __OV5640_H__ -#define __OV5640_H__ - -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int ov5640_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int ov5640_init(sensor_t *sensor); - -#endif // __OV5640_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h deleted file mode 100644 index c28d80f5b..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_regs.h +++ /dev/null @@ -1,213 +0,0 @@ -/* - * OV5640 register definitions. - */ -#ifndef __OV5640_REG_REGS_H__ -#define __OV5640_REG_REGS_H__ - -/* system control registers */ -#define SYSTEM_CTROL0 0x3008 // Bit[7]: Software reset - // Bit[6]: Software power down - // Bit[5]: Reserved - // Bit[4]: SRB clock SYNC enable - // Bit[3]: Isolation suspend select - // Bit[2:0]: Not used - -#define DRIVE_CAPABILITY 0x302c // Bit[7:6]: - // 00: 1x - // 01: 2x - // 10: 3x - // 11: 4x - -#define SC_PLLS_CTRL0 0x303a // Bit[7]: PLLS bypass -#define SC_PLLS_CTRL1 0x303b // Bit[4:0]: PLLS multiplier -#define SC_PLLS_CTRL2 0x303c // Bit[6:4]: PLLS charge pump control - // Bit[3:0]: PLLS system divider -#define SC_PLLS_CTRL3 0x303d // Bit[5:4]: PLLS pre-divider - // 00: 1 - // 01: 1.5 - // 10: 2 - // 11: 3 - // Bit[2]: PLLS root-divider - 1 - // Bit[1:0]: PLLS seld5 - // 00: 1 - // 01: 1 - // 10: 2 - // 11: 2.5 - -/* AEC/AGC control functions */ -#define AEC_PK_MANUAL 0x3503 // AEC Manual Mode Control - // Bit[7:6]: Reserved - // Bit[5]: Gain delay option - // Valid when 0x3503[4]=1’b0 - // 0: Delay one frame latch - // 1: One frame latch - // Bit[4:2]: Reserved - // Bit[1]: AGC manual - // 0: Auto enable - // 1: Manual enable - // Bit[0]: AEC manual - // 0: Auto enable - // 1: Manual enable - -//gain = {0x350A[1:0], 0x350B[7:0]} / 16 - - -#define X_ADDR_ST_H 0x3800 //Bit[3:0]: X address start[11:8] -#define X_ADDR_ST_L 0x3801 //Bit[7:0]: X address start[7:0] -#define Y_ADDR_ST_H 0x3802 //Bit[2:0]: Y address start[10:8] -#define Y_ADDR_ST_L 0x3803 //Bit[7:0]: Y address start[7:0] -#define X_ADDR_END_H 0x3804 //Bit[3:0]: X address end[11:8] -#define X_ADDR_END_L 0x3805 //Bit[7:0]: -#define Y_ADDR_END_H 0x3806 //Bit[2:0]: Y address end[10:8] -#define Y_ADDR_END_L 0x3807 //Bit[7:0]: -// Size after scaling -#define X_OUTPUT_SIZE_H 0x3808 //Bit[3:0]: DVP output horizontal width[11:8] -#define X_OUTPUT_SIZE_L 0x3809 //Bit[7:0]: -#define Y_OUTPUT_SIZE_H 0x380a //Bit[2:0]: DVP output vertical height[10:8] -#define Y_OUTPUT_SIZE_L 0x380b //Bit[7:0]: -#define X_TOTAL_SIZE_H 0x380c //Bit[3:0]: Total horizontal size[11:8] -#define X_TOTAL_SIZE_L 0x380d //Bit[7:0]: -#define Y_TOTAL_SIZE_H 0x380e //Bit[7:0]: Total vertical size[15:8] -#define Y_TOTAL_SIZE_L 0x380f //Bit[7:0]: -#define X_OFFSET_H 0x3810 //Bit[3:0]: ISP horizontal offset[11:8] -#define X_OFFSET_L 0x3811 //Bit[7:0]: -#define Y_OFFSET_H 0x3812 //Bit[2:0]: ISP vertical offset[10:8] -#define Y_OFFSET_L 0x3813 //Bit[7:0]: -#define X_INCREMENT 0x3814 //Bit[7:4]: Horizontal odd subsample increment - //Bit[3:0]: Horizontal even subsample increment -#define Y_INCREMENT 0x3815 //Bit[7:4]: Vertical odd subsample increment - //Bit[3:0]: Vertical even subsample increment -// Size before scaling -//#define X_INPUT_SIZE (X_ADDR_END - X_ADDR_ST + 1 - (2 * X_OFFSET)) -//#define Y_INPUT_SIZE (Y_ADDR_END - Y_ADDR_ST + 1 - (2 * Y_OFFSET)) - -/* mirror and flip registers */ -#define TIMING_TC_REG20 0x3820 // Timing Control Register - // Bit[2:1]: Vertical flip enable - // 00: Normal - // 11: Vertical flip - // Bit[0]: Vertical binning enable -#define TIMING_TC_REG21 0x3821 // Timing Control Register - // Bit[5]: Compression Enable - // Bit[2:1]: Horizontal mirror enable - // 00: Normal - // 11: Horizontal mirror - // Bit[0]: Horizontal binning enable - -#define PCLK_RATIO 0x3824 // Bit[4:0]: PCLK ratio manual - -/* frame control registers */ -#define FRAME_CTRL01 0x4201 // Control Passed Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode - // Bit[7:4]: Not used - // Bit[3:0]: Frame ON number -#define FRAME_CTRL02 0x4202 // Control Masked Frame Number When both ON and OFF number set to 0x00,frame control is in bypass mode - // Bit[7:4]: Not used - // BIT[3:0]: Frame OFF number - -/* format control registers */ -#define FORMAT_CTRL00 0x4300 - -#define CLOCK_POL_CONTROL 0x4740// Bit[5]: PCLK polarity 0: active low - // 1: active high - // Bit[3]: Gate PCLK under VSYNC - // Bit[2]: Gate PCLK under HREF - // Bit[1]: HREF polarity - // 0: active low - // 1: active high - // Bit[0] VSYNC polarity - // 0: active low - // 1: active high - -#define ISP_CONTROL_01 0x5001 // Bit[5]: Scale enable - // 0: Disable - // 1: Enable - -/* output format control registers */ -#define FORMAT_CTRL 0x501F // Format select - // Bit[2:0]: - // 000: YUV422 - // 001: RGB - // 010: Dither - // 011: RAW after DPC - // 101: RAW after CIP - -/* ISP top control registers */ -#define PRE_ISP_TEST_SETTING_1 0x503D // Bit[7]: Test enable - // 0: Test disable - // 1: Color bar enable - // Bit[6]: Rolling - // Bit[5]: Transparent - // Bit[4]: Square black and white - // Bit[3:2]: Color bar style - // 00: Standard 8 color bar - // 01: Gradual change at vertical mode 1 - // 10: Gradual change at horizontal - // 11: Gradual change at vertical mode 2 - // Bit[1:0]: Test select - // 00: Color bar - // 01: Random data - // 10: Square data - // 11: Black image - -//exposure = {0x3500[3:0], 0x3501[7:0], 0x3502[7:0]} / 16 × tROW - -#define SCALE_CTRL_1 0x5601 // Bit[6:4]: HDIV RW - // DCW scale times - // 000: DCW 1 time - // 001: DCW 2 times - // 010: DCW 4 times - // 100: DCW 8 times - // 101: DCW 16 times - // Others: DCW 16 times - // Bit[2:0]: VDIV RW - // DCW scale times - // 000: DCW 1 time - // 001: DCW 2 times - // 010: DCW 4 times - // 100: DCW 8 times - // 101: DCW 16 times - // Others: DCW 16 times - -#define SCALE_CTRL_2 0x5602 // X_SCALE High Bits -#define SCALE_CTRL_3 0x5603 // X_SCALE Low Bits -#define SCALE_CTRL_4 0x5604 // Y_SCALE High Bits -#define SCALE_CTRL_5 0x5605 // Y_SCALE Low Bits -#define SCALE_CTRL_6 0x5606 // Bit[3:0]: V Offset - -#define VFIFO_CTRL0C 0x460C // Bit[1]: PCLK manual enable - // 0: Auto - // 1: Manual by PCLK_RATIO - -#define VFIFO_X_SIZE_H 0x4602 -#define VFIFO_X_SIZE_L 0x4603 -#define VFIFO_Y_SIZE_H 0x4604 -#define VFIFO_Y_SIZE_L 0x4605 - -#define COMPRESSION_CTRL00 0x4400 // -#define COMPRESSION_CTRL01 0x4401 // -#define COMPRESSION_CTRL02 0x4402 // -#define COMPRESSION_CTRL03 0x4403 // -#define COMPRESSION_CTRL04 0x4404 // -#define COMPRESSION_CTRL05 0x4405 // -#define COMPRESSION_CTRL06 0x4406 // -#define COMPRESSION_CTRL07 0x4407 // Bit[5:0]: QS -#define COMPRESSION_ISI_CTRL 0x4408 // -#define COMPRESSION_CTRL09 0x4409 // -#define COMPRESSION_CTRL0a 0x440a // -#define COMPRESSION_CTRL0b 0x440b // -#define COMPRESSION_CTRL0c 0x440c // -#define COMPRESSION_CTRL0d 0x440d // -#define COMPRESSION_CTRL0E 0x440e // - -/** - * @brief register value - */ -#define TEST_COLOR_BAR 0xC0 /* Enable Color Bar roling Test */ - -#define AEC_PK_MANUAL_AGC_MANUALEN 0x02 /* Enable AGC Manual enable */ -#define AEC_PK_MANUAL_AEC_MANUALEN 0x01 /* Enable AEC Manual enable */ - -#define TIMING_TC_REG20_VFLIP 0x06 /* Vertical flip enable */ -#define TIMING_TC_REG21_HMIRROR 0x06 /* Horizontal mirror enable */ - -#endif // __OV3660_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h deleted file mode 100644 index fec7d679f..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov5640_settings.h +++ /dev/null @@ -1,334 +0,0 @@ -#ifndef _OV5640_SETTINGS_H_ -#define _OV5640_SETTINGS_H_ - -#include -#include -#include "esp_attr.h" -#include "ov5640_regs.h" - -static const ratio_settings_t ratio_table[] = { - // mw, mh, sx, sy, ex, ey, ox, oy, tx, ty - { 2560, 1920, 0, 0, 2623, 1951, 32, 16, 2844, 1968 }, //4x3 - { 2560, 1704, 0, 110, 2623, 1843, 32, 16, 2844, 1752 }, //3x2 - { 2560, 1600, 0, 160, 2623, 1791, 32, 16, 2844, 1648 }, //16x10 - { 2560, 1536, 0, 192, 2623, 1759, 32, 16, 2844, 1584 }, //5x3 - { 2560, 1440, 0, 240, 2623, 1711, 32, 16, 2844, 1488 }, //16x9 - { 2560, 1080, 0, 420, 2623, 1531, 32, 16, 2844, 1128 }, //21x9 - { 2400, 1920, 80, 0, 2543, 1951, 32, 16, 2684, 1968 }, //5x4 - { 1920, 1920, 320, 0, 2543, 1951, 32, 16, 2684, 1968 }, //1x1 - { 1088, 1920, 736, 0, 1887, 1951, 32, 16, 1884, 1968 } //9x16 -}; - -#define REG_DLY 0xffff -#define REGLIST_TAIL 0x0000 - -static const DRAM_ATTR uint16_t sensor_default_regs[][2] = { - {SYSTEM_CTROL0, 0x82}, // software reset - {REG_DLY, 10}, // delay 10ms - {SYSTEM_CTROL0, 0x42}, // power down - - //enable pll - {0x3103, 0x13}, - - //io direction - {0x3017, 0xff}, - {0x3018, 0xff}, - - {DRIVE_CAPABILITY, 0xc3}, - {CLOCK_POL_CONTROL, 0x21}, - - {0x4713, 0x02},//jpg mode select - - {ISP_CONTROL_01, 0x83}, // turn color matrix, awb and SDE - - //sys reset - {0x3000, 0x00}, - {0x3002, 0x1c}, - - //clock enable - {0x3004, 0xff}, - {0x3006, 0xc3}, - - //isp control - {0x5000, 0xa7}, - {ISP_CONTROL_01, 0xa3},//+scaling? - {0x5003, 0x08},//special_effect - - //unknown - {0x370c, 0x02},//!!IMPORTANT - {0x3634, 0x40},//!!IMPORTANT - - //AEC/AGC - {0x3a02, 0x03}, - {0x3a03, 0xd8}, - {0x3a08, 0x01}, - {0x3a09, 0x27}, - {0x3a0a, 0x00}, - {0x3a0b, 0xf6}, - {0x3a0d, 0x04}, - {0x3a0e, 0x03}, - {0x3a0f, 0x30},//ae_level - {0x3a10, 0x28},//ae_level - {0x3a11, 0x60},//ae_level - {0x3a13, 0x43}, - {0x3a14, 0x03}, - {0x3a15, 0xd8}, - {0x3a18, 0x00},//gainceiling - {0x3a19, 0xf8},//gainceiling - {0x3a1b, 0x30},//ae_level - {0x3a1e, 0x26},//ae_level - {0x3a1f, 0x14},//ae_level - - //vcm debug - {0x3600, 0x08}, - {0x3601, 0x33}, - - //50/60Hz - {0x3c01, 0xa4}, - {0x3c04, 0x28}, - {0x3c05, 0x98}, - {0x3c06, 0x00}, - {0x3c07, 0x08}, - {0x3c08, 0x00}, - {0x3c09, 0x1c}, - {0x3c0a, 0x9c}, - {0x3c0b, 0x40}, - - {0x460c, 0x22},//disable jpeg footer - - //BLC - {0x4001, 0x02}, - {0x4004, 0x02}, - - //AWB - {0x5180, 0xff}, - {0x5181, 0xf2}, - {0x5182, 0x00}, - {0x5183, 0x14}, - {0x5184, 0x25}, - {0x5185, 0x24}, - {0x5186, 0x09}, - {0x5187, 0x09}, - {0x5188, 0x09}, - {0x5189, 0x75}, - {0x518a, 0x54}, - {0x518b, 0xe0}, - {0x518c, 0xb2}, - {0x518d, 0x42}, - {0x518e, 0x3d}, - {0x518f, 0x56}, - {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, 0x38}, - - //color matrix (Saturation) - {0x5381, 0x1e}, - {0x5382, 0x5b}, - {0x5383, 0x08}, - {0x5384, 0x0a}, - {0x5385, 0x7e}, - {0x5386, 0x88}, - {0x5387, 0x7c}, - {0x5388, 0x6c}, - {0x5389, 0x10}, - {0x538a, 0x01}, - {0x538b, 0x98}, - - //CIP control (Sharpness) - {0x5300, 0x10},//sharpness - {0x5301, 0x10},//sharpness - {0x5302, 0x18},//sharpness - {0x5303, 0x19},//sharpness - {0x5304, 0x10}, - {0x5305, 0x10}, - {0x5306, 0x08},//denoise - {0x5307, 0x16}, - {0x5308, 0x40}, - {0x5309, 0x10},//sharpness - {0x530a, 0x10},//sharpness - {0x530b, 0x04},//sharpness - {0x530c, 0x06},//sharpness - - //GAMMA - {0x5480, 0x01}, - {0x5481, 0x00}, - {0x5482, 0x1e}, - {0x5483, 0x3b}, - {0x5484, 0x58}, - {0x5485, 0x66}, - {0x5486, 0x71}, - {0x5487, 0x7d}, - {0x5488, 0x83}, - {0x5489, 0x8f}, - {0x548a, 0x98}, - {0x548b, 0xa6}, - {0x548c, 0xb8}, - {0x548d, 0xca}, - {0x548e, 0xd7}, - {0x548f, 0xe3}, - {0x5490, 0x1d}, - - //Special Digital Effects (SDE) (UV adjust) - {0x5580, 0x06},//enable brightness and contrast - {0x5583, 0x40},//special_effect - {0x5584, 0x10},//special_effect - {0x5586, 0x20},//contrast - {0x5587, 0x00},//brightness - {0x5588, 0x00},//brightness - {0x5589, 0x10}, - {0x558a, 0x00}, - {0x558b, 0xf8}, - {0x501d, 0x40},// enable manual offset of contrast - - //power on - {0x3008, 0x02}, - - //50Hz - {0x3c00, 0x04}, - - {REG_DLY, 300}, - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_jpeg[][2] = { - {FORMAT_CTRL, 0x00}, // YUV422 - {FORMAT_CTRL00, 0x30}, // YUYV - {0x3002, 0x00},//0x1c to 0x00 !!! - {0x3006, 0xff},//0xc3 to 0xff !!! - {0x471c, 0x50},//0xd0 to 0x50 !!! - {REGLIST_TAIL, 0x00}, // tail -}; - -static const DRAM_ATTR uint16_t sensor_fmt_raw[][2] = { - {FORMAT_CTRL, 0x03}, // RAW (DPC) - {FORMAT_CTRL00, 0x00}, // RAW - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint16_t sensor_fmt_grayscale[][2] = { - {FORMAT_CTRL, 0x00}, // YUV422 - {FORMAT_CTRL00, 0x10}, // Y8 - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint16_t sensor_fmt_yuv422[][2] = { - {FORMAT_CTRL, 0x00}, // YUV422 - {FORMAT_CTRL00, 0x30}, // YUYV - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint16_t sensor_fmt_rgb565[][2] = { - {FORMAT_CTRL, 0x01}, // RGB - {FORMAT_CTRL00, 0x61}, // RGB565 (BGR) - {REGLIST_TAIL, 0x00} -}; - -static const DRAM_ATTR uint8_t sensor_saturation_levels[9][11] = { - {0x1d, 0x60, 0x03, 0x07, 0x48, 0x4f, 0x4b, 0x40, 0x0b, 0x01, 0x98},//-4 - {0x1d, 0x60, 0x03, 0x08, 0x54, 0x5c, 0x58, 0x4b, 0x0d, 0x01, 0x98},//-3 - {0x1d, 0x60, 0x03, 0x0a, 0x60, 0x6a, 0x64, 0x56, 0x0e, 0x01, 0x98},//-2 - {0x1d, 0x60, 0x03, 0x0b, 0x6c, 0x77, 0x70, 0x60, 0x10, 0x01, 0x98},//-1 - {0x1d, 0x60, 0x03, 0x0c, 0x78, 0x84, 0x7d, 0x6b, 0x12, 0x01, 0x98},//0 - {0x1d, 0x60, 0x03, 0x0d, 0x84, 0x91, 0x8a, 0x76, 0x14, 0x01, 0x98},//+1 - {0x1d, 0x60, 0x03, 0x0e, 0x90, 0x9e, 0x96, 0x80, 0x16, 0x01, 0x98},//+2 - {0x1d, 0x60, 0x03, 0x10, 0x9c, 0xac, 0xa2, 0x8b, 0x17, 0x01, 0x98},//+3 - {0x1d, 0x60, 0x03, 0x11, 0xa8, 0xb9, 0xaf, 0x96, 0x19, 0x01, 0x98},//+4 -}; - -static const DRAM_ATTR uint8_t sensor_special_effects[7][4] = { - {0x06, 0x40, 0x2c, 0x08},//Normal - {0x46, 0x40, 0x28, 0x08},//Negative - {0x1e, 0x80, 0x80, 0x08},//Grayscale - {0x1e, 0x80, 0xc0, 0x08},//Red Tint - {0x1e, 0x60, 0x60, 0x08},//Green Tint - {0x1e, 0xa0, 0x40, 0x08},//Blue Tint - {0x1e, 0x40, 0xa0, 0x08},//Sepia -}; - -static const DRAM_ATTR uint16_t sensor_regs_gamma0[][2] = { - {0x5480, 0x01}, - {0x5481, 0x08}, - {0x5482, 0x14}, - {0x5483, 0x28}, - {0x5484, 0x51}, - {0x5485, 0x65}, - {0x5486, 0x71}, - {0x5487, 0x7d}, - {0x5488, 0x87}, - {0x5489, 0x91}, - {0x548a, 0x9a}, - {0x548b, 0xaa}, - {0x548c, 0xb8}, - {0x548d, 0xcd}, - {0x548e, 0xdd}, - {0x548f, 0xea}, - {0x5490, 0x1d} -}; - -static const DRAM_ATTR uint16_t sensor_regs_gamma1[][2] = { - {0x5480, 0x1}, - {0x5481, 0x0}, - {0x5482, 0x1e}, - {0x5483, 0x3b}, - {0x5484, 0x58}, - {0x5485, 0x66}, - {0x5486, 0x71}, - {0x5487, 0x7d}, - {0x5488, 0x83}, - {0x5489, 0x8f}, - {0x548a, 0x98}, - {0x548b, 0xa6}, - {0x548c, 0xb8}, - {0x548d, 0xca}, - {0x548e, 0xd7}, - {0x548f, 0xe3}, - {0x5490, 0x1d} -}; - -static const DRAM_ATTR uint16_t sensor_regs_awb0[][2] = { - {0x5180, 0xff}, - {0x5181, 0xf2}, - {0x5182, 0x00}, - {0x5183, 0x14}, - {0x5184, 0x25}, - {0x5185, 0x24}, - {0x5186, 0x09}, - {0x5187, 0x09}, - {0x5188, 0x09}, - {0x5189, 0x75}, - {0x518a, 0x54}, - {0x518b, 0xe0}, - {0x518c, 0xb2}, - {0x518d, 0x42}, - {0x518e, 0x3d}, - {0x518f, 0x56}, - {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, 0x38} -}; - -#endif diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h deleted file mode 100644 index b3a645a70..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the OpenMV project. - * author: Juan Schiavoni - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV7670 driver. - * - */ -#ifndef __OV7670_H__ -#define __OV7670_H__ -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int ov7670_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int ov7670_init(sensor_t *sensor); - -#endif // __OV7670_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h deleted file mode 100644 index 699354877..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7670_regs.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * This file is for the OpenMV project so the OV7670 can be used - * author: Juan Schiavoni - * - * OV7670 register definitions. - */ -#ifndef __OV7670_REG_REGS_H__ -#define __OV7670_REG_REGS_H__ -#define GAIN 0x00 /* AGC – Gain control gain setting */ -#define BLUE 0x01 /* AWB – Blue channel gain setting */ -#define RED 0x02 /* AWB – Red channel gain setting */ -#define VREF 0x03 /* AWB – Green channel gain setting */ -#define COM1 0x04 /* Common Control 1 */ -#define BAVG 0x05 /* U/B Average Level */ -#define GAVG 0x06 /* Y/Gb Average Level */ -#define AECH 0x07 /* Exposure VAlue - AEC MSB 5 bits */ -#define RAVG 0x08 /* V/R Average Level */ - -#define COM2 0x09 /* Common Control 2 */ -#define COM2_SOFT_SLEEP 0x10 /* Soft sleep mode */ -#define COM2_OUT_DRIVE_1x 0x00 /* Output drive capability 1x */ -#define COM2_OUT_DRIVE_2x 0x01 /* Output drive capability 2x */ -#define COM2_OUT_DRIVE_3x 0x02 /* Output drive capability 3x */ -#define COM2_OUT_DRIVE_4x 0x03 /* Output drive capability 4x */ - -#define REG_PID 0x0A /* Product ID Number MSB */ -#define REG_VER 0x0B /* Product ID Number LSB */ - -#define COM3 0x0C /* Common Control 3 */ -#define COM3_SWAP_OUT 0x40 /* Output data MSB/LSB swap */ -#define COM3_TRI_CLK 0x20 /* Tri-state output clock */ -#define COM3_TRI_DATA 0x10 /* Tri-state option output */ -#define COM3_SCALE_EN 0x08 /* Scale enable */ -#define COM3_DCW 0x04 /* DCW enable */ - -#define COM4 0x0D /* Common Control 4 */ -#define COM4_PLL_BYPASS 0x00 /* Bypass PLL */ -#define COM4_PLL_4x 0x40 /* PLL frequency 4x */ -#define COM4_PLL_6x 0x80 /* PLL frequency 6x */ -#define COM4_PLL_8x 0xc0 /* PLL frequency 8x */ -#define COM4_AEC_FULL 0x00 /* AEC evaluate full window */ -#define COM4_AEC_1_2 0x10 /* AEC evaluate 1/2 window */ -#define COM4_AEC_1_4 0x20 /* AEC evaluate 1/4 window */ -#define COM4_AEC_2_3 0x30 /* AEC evaluate 2/3 window */ - -#define COM5 0x0E /* Common Control 5 */ -#define COM5_AFR 0x80 /* Auto frame rate control ON/OFF selection (night mode) */ -#define COM5_AFR_SPEED 0x40 /* Auto frame rate control speed selection */ -#define COM5_AFR_0 0x00 /* No reduction of frame rate */ -#define COM5_AFR_1_2 0x10 /* Max reduction to 1/2 frame rate */ -#define COM5_AFR_1_4 0x20 /* Max reduction to 1/4 frame rate */ -#define COM5_AFR_1_8 0x30 /* Max reduction to 1/8 frame rate */ -#define COM5_AFR_4x 0x04 /* Add frame when AGC reaches 4x gain */ -#define COM5_AFR_8x 0x08 /* Add frame when AGC reaches 8x gain */ -#define COM5_AFR_16x 0x0c /* Add frame when AGC reaches 16x gain */ -#define COM5_AEC_NO_LIMIT 0x01 /* No limit to AEC increase step */ - -#define COM6 0x0F /* Common Control 6 */ -#define COM6_AUTO_WINDOW 0x01 /* Auto window setting ON/OFF selection when format changes */ - -#define AEC 0x10 /* AEC[7:0] (see register AECH for AEC[15:8]) */ -#define CLKRC 0x11 /* Internal Clock */ - -#define COM7 0x12 /* Common Control 7 */ -#define COM7_RESET 0x80 /* SCCB Register Reset */ -#define COM7_RES_VGA 0x00 /* Resolution VGA */ -#define COM7_RES_QVGA 0x40 /* Resolution QVGA */ -#define COM7_BT656 0x20 /* BT.656 protocol ON/OFF */ -#define COM7_SENSOR_RAW 0x10 /* Sensor RAW */ -#define COM7_FMT_GBR422 0x00 /* RGB output format GBR422 */ -#define COM7_FMT_RGB565 0x04 /* RGB output format RGB565 */ -#define COM7_FMT_RGB555 0x08 /* RGB output format RGB555 */ -#define COM7_FMT_RGB444 0x0C /* RGB output format RGB444 */ -#define COM7_FMT_YUV 0x00 /* Output format YUV */ -#define COM7_FMT_P_BAYER 0x01 /* Output format Processed Bayer RAW */ -#define COM7_FMT_RGB 0x04 /* Output format RGB */ -#define COM7_FMT_R_BAYER 0x03 /* Output format Bayer RAW */ -#define COM7_SET_FMT(r, x) ((r&0xFC)|((x&0x5)<<0)) - -#define COM8 0x13 /* Common Control 8 */ -#define COM8_FAST_AUTO 0x80 /* Enable fast AGC/AEC algorithm */ -#define COM8_STEP_VSYNC 0x00 /* AEC - Step size limited to vertical blank */ -#define COM8_STEP_UNLIMIT 0x40 /* AEC - Step size unlimited step size */ -#define COM8_BANDF_EN 0x20 /* Banding filter ON/OFF */ -#define COM8_AEC_BANDF 0x10 /* Enable AEC below banding value */ -#define COM8_AEC_FINE_EN 0x08 /* Fine AEC ON/OFF control */ -#define COM8_AGC_EN 0x04 /* AGC Enable */ -#define COM8_AWB_EN 0x02 /* AWB Enable */ -#define COM8_AEC_EN 0x01 /* AEC Enable */ -#define COM8_SET_AGC(r, x) ((r&0xFB)|((x&0x1)<<2)) -#define COM8_SET_AWB(r, x) ((r&0xFD)|((x&0x1)<<1)) -#define COM8_SET_AEC(r, x) ((r&0xFE)|((x&0x1)<<0)) - -#define COM9 0x14 /* Common Control 9 */ -#define COM9_HISTO_AVG 0x80 /* Histogram or average based AEC/AGC selection */ -#define COM9_AGC_GAIN_2x 0x00 /* Automatic Gain Ceiling 2x */ -#define COM9_AGC_GAIN_4x 0x10 /* Automatic Gain Ceiling 4x */ -#define COM9_AGC_GAIN_8x 0x20 /* Automatic Gain Ceiling 8x */ -#define COM9_AGC_GAIN_16x 0x30 /* Automatic Gain Ceiling 16x */ -#define COM9_AGC_GAIN_32x 0x40 /* Automatic Gain Ceiling 32x */ -#define COM9_DROP_VSYNC 0x04 /* Drop VSYNC output of corrupt frame */ -#define COM9_DROP_HREF 0x02 /* Drop HREF output of corrupt frame */ -#define COM9_SET_AGC(r, x) ((r&0x8F)|((x&0x07)<<4)) - -#define COM10 0x15 /* Common Control 10 */ -#define COM10_NEGATIVE 0x80 /* Output negative data */ -#define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ -#define COM10_PCLK_FREE 0x00 /* PCLK output option: free running PCLK */ -#define COM10_PCLK_MASK 0x20 /* PCLK output option: masked during horizontal blank */ -#define COM10_PCLK_REV 0x10 /* PCLK reverse */ -#define COM10_HREF_REV 0x08 /* HREF reverse */ -#define COM10_VSYNC_FALLING 0x00 /* VSYNC changes on falling edge of PCLK */ -#define COM10_VSYNC_RISING 0x04 /* VSYNC changes on rising edge of PCLK */ -#define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ -#define COM10_OUT_RANGE_8 0x01 /* Output data range: Full range */ -#define COM10_OUT_RANGE_10 0x00 /* Output data range: Data from [10] to [F0] (8 MSBs) */ - -#define RSVD_16 0x16 /* Reserved register */ - -#define HSTART 0x17 /* Horizontal Frame (HREF column) Start high 8-bit(low 3 bits are at HREF[2:0]) */ -#define HSTOP 0x18 /* Horizontal Frame (HREF column) end high 8-bit (low 3 bits are at HREF[5:3]) */ -#define VSTART 0x19 /* Vertical Frame (row) Start high 8-bit (low 2 bits are at VREF[1:0]) */ -#define VSTOP 0x1A /* Vertical Frame (row) End high 8-bit (low 2 bits are at VREF[3:2]) */ -#define PSHFT 0x1B /* Data Format - Pixel Delay Select */ -#define REG_MIDH 0x1C /* Manufacturer ID Byte – High */ -#define REG_MIDL 0x1D /* Manufacturer ID Byte – Low */ - -#define MVFP 0x1E /* Mirror/Vflip Enable */ -#define MVFP_MIRROR 0x20 /* Mirror image */ -#define MVFP_FLIP 0x10 /* Vertical flip */ -#define MVFP_SUN 0x02 /* Black sun enable */ -#define MVFP_SET_MIRROR(r,x) ((r&0xDF)|((x&1)<<5)) /* change only bit5 according to x */ -#define MVFP_SET_FLIP(r,x) ((r&0xEF)|((x&1)<<4)) /* change only bit4 according to x */ - -#define LAEC 0x1F /* Fine AEC Value - defines exposure value less than one row period (Reserved?) */ -#define ADCCTR0 0x20 /* ADC control */ -#define ADCCTR1 0x21 /* reserved */ -#define ADCCTR2 0x22 /* reserved */ -#define ADCCTR3 0x23 /* reserved */ -#define AEW 0x24 /* AGC/AEC - Stable Operating Region (Upper Limit) */ -#define AEB 0x25 /* AGC/AEC - Stable Operating Region (Lower Limit) */ -#define VPT 0x26 /* AGC/AEC Fast Mode Operating Region */ -#define BBIAS 0x27 /* B channel signal output bias (effective only when COM6[3]=1) */ -#define GbBIAS 0x28 /* Gb channel signal output bias (effective only when COM6[3]=1) */ -#define RSVD_29 0x29 /* reserved */ -#define EXHCH 0x2A /* Dummy Pixel Insert MSB */ -#define EXHCL 0x2B /* Dummy Pixel Insert LSB */ -#define RBIAS 0x2C /* R channel signal output bias (effective only when COM6[3]=1) */ -#define ADVFL 0x2D /* LSB of Insert Dummy Rows in Vertical Sync (1 bit equals 1 row) */ -#define ADVFH 0x2E /* MSB of Insert Dummy Rows in Vertical Sync */ -#define YAVE 0x2F /* Y/G Channel Average Value */ -#define HSYST 0x30 /* HSync rising edge delay */ -#define HSYEN 0x31 /* HSync falling edge delay */ -#define HREF 0x32 /* Image Start and Size Control DIFFERENT CONTROL SEQUENCE */ -#define CHLF 0x33 /* Array Current control */ -#define ARBLM 0x34 /* Array reference control */ -#define RSVD_35 0x35 /* Reserved */ -#define RSVD_36 0x36 /* Reserved */ -#define ADC 0x37 /* ADC control */ -#define ACOM 0x38 /* ADC and analog common mode control */ -#define OFON 0x39 /* ADC offset control */ -#define TSLB 0x3A /* Line buffer test option */ - -#define COM11 0x3B /* Common control 11 */ -#define COM11_EXP 0x02 -#define COM11_HZAUTO 0x10 /* Auto detect 50/60 Hz */ - -#define COM12 0x3C /* Common control 12 */ - -#define COM13 0x3D /* Common control 13 */ -#define COM13_GAMMA 0x80 /* Gamma enable */ -#define COM13_UVSAT 0x40 /* UV saturation auto adjustment */ - -#define COM14 0x3E /* Common Control 14 */ - -#define EDGE 0x3F /* edge enhancement adjustment */ -#define COM15 0x40 /* Common Control 15 DIFFERENT CONTROLS */ -#define COM15_SET_RGB565(r,x) ((r&0xEF)|((x&1)<<4)) /* set rgb565 mode */ -#define COM15_RGB565 0x10 /* RGB565 output */ -#define COM15_R00FF 0xC0 /* Output range: [00] to [FF] */ - -#define COM16 0x41 /* Common Control 16 DIFFERENT CONTROLS */ -#define COM16_AWBGAIN 0x08 /* AWB gain enable */ -#define COM17 0x42 /* Common Control 17 */ - -#define AWBC1 0x43 /* Reserved */ -#define AWBC2 0x44 /* Reserved */ -#define AWBC3 0x45 /* Reserved */ -#define AWBC4 0x46 /* Reserved */ -#define AWBC5 0x47 /* Reserved */ -#define AWBC6 0x48 /* Reserved */ - -#define RSVD_49 0x49 /* Reserved */ -#define RSVD_4A 0x4A /* Reserved */ - -#define REG4B 0x4B /* Register 4B */ -#define DNSTH 0x4C /* Denoise strength */ - -#define RSVD_4D 0x4D /* Reserved */ -#define RSVD_4E 0x4E /* Reserved */ - -#define MTX1 0x4F /* Matrix coefficient 1 */ -#define MTX2 0x50 /* Matrix coefficient 2 */ -#define MTX3 0x51 /* Matrix coefficient 3 */ -#define MTX4 0x52 /* Matrix coefficient 4 */ -#define MTX5 0x53 /* Matrix coefficient 5 */ -#define MTX6 0x54 /* Matrix coefficient 6 */ -#define BRIGHTNESS 0x55 /* Brightness control */ -#define CONTRAST 0x56 /* Contrast control */ -#define CONTRASCENTER 0x57 /* Contrast center */ -#define MTXS 0x58 /* Matrix coefficient sign for coefficient 5 to 0*/ - -#define RSVD_59 0x59 /* Reserved */ -#define RSVD_5A 0x5A /* Reserved */ -#define RSVD_5B 0x5B /* Reserved */ -#define RSVD_5C 0x5C /* Reserved */ -#define RSVD_5D 0x5D /* Reserved */ -#define RSVD_5E 0x5E /* Reserved */ -#define RSVD_5F 0x5F /* Reserved */ -#define RSVD_60 0x60 /* Reserved */ -#define RSVD_61 0x61 /* Reserved */ - -#define LCC1 0x62 /* Lens correction option 1 */ - -#define LCC2 0x63 /* Lens correction option 2 */ -#define LCC3 0x64 /* Lens correction option 3 */ -#define LCC4 0x65 /* Lens correction option 4 */ -#define LCC5 0x66 /* Lens correction option 5 */ - -#define MANU 0x67 /* Manual U Value */ -#define MANV 0x68 /* Manual V Value */ -#define GFIX 0x69 /* Fix gain control */ -#define GGAIN 0x6A /* G channel AWB gain */ - -#define DBLV 0x6B /* PLL and clock ? */ - -#define AWBCTR3 0x6C /* AWB Control 3 */ -#define AWBCTR2 0x6D /* AWB Control 2 */ -#define AWBCTR1 0x6E /* AWB Control 1 */ -#define AWBCTR0 0x6F /* AWB Control 0 */ -#define SCALING_XSC 0x70 /* test pattern and horizontal scaling factor */ -#define SCALING_XSC_CBAR(r) (r&0x7F) /* make sure bit7 is 0 for color bar */ -#define SCALING_YSC 0x71 /* test pattern and vertical scaling factor */ -#define SCALING_YSC_CBAR(r,x) ((r&0x7F)|((x&1)<<7)) /* change bit7 for color bar on/off */ -#define SCALING_DCWCTR 0x72 /* DCW control */ -#define SCALING_PCLK_DIV 0x73 /* */ -#define REG74 0x74 /* */ -#define REG75 0x75 /* */ -#define REG76 0x76 /* */ -#define REG77 0x77 /* */ - -#define RSVD_78 0x78 /* Reserved */ -#define RSVD_79 0x79 /* Reserved */ - -#define SLOP 0x7A /* Gamma curve highest segment slope */ -#define GAM1 0x7B /* Gamma Curve 1st Segment Input End Point 0x04 Output Value */ -#define GAM2 0x7C /* Gamma Curve 2nd Segment Input End Point 0x08 Output Value */ -#define GAM3 0x7D /* Gamma Curve 3rd Segment Input End Point 0x10 Output Value */ -#define GAM4 0x7E /* Gamma Curve 4th Segment Input End Point 0x20 Output Value */ -#define GAM5 0x7F /* Gamma Curve 5th Segment Input End Point 0x28 Output Value */ -#define GAM6 0x80 /* Gamma Curve 6rd Segment Input End Point 0x30 Output Value */ -#define GAM7 0x81 /* Gamma Curve 7th Segment Input End Point 0x38 Output Value */ -#define GAM8 0x82 /* Gamma Curve 8th Segment Input End Point 0x40 Output Value */ -#define GAM9 0x83 /* Gamma Curve 9th Segment Input End Point 0x48 Output Value */ -#define GAM10 0x84 /* Gamma Curve 10th Segment Input End Point 0x50 Output Value */ -#define GAM11 0x85 /* Gamma Curve 11th Segment Input End Point 0x60 Output Value */ -#define GAM12 0x86 /* Gamma Curve 12th Segment Input End Point 0x70 Output Value */ -#define GAM13 0x87 /* Gamma Curve 13th Segment Input End Point 0x90 Output Value */ -#define GAM14 0x88 /* Gamma Curve 14th Segment Input End Point 0xB0 Output Value */ -#define GAM15 0x89 /* Gamma Curve 15th Segment Input End Point 0xD0 Output Value */ - -#define RSVD_8A 0x8A /* Reserved */ -#define RSVD_8B 0x8B /* Reserved */ - -#define RGB444 0x8C /* */ - -#define RSVD_8D 0x8D /* Reserved */ -#define RSVD_8E 0x8E /* Reserved */ -#define RSVD_8F 0x8F /* Reserved */ -#define RSVD_90 0x90 /* Reserved */ -#define RSVD_91 0x91 /* Reserved */ - -#define DM_LNL 0x92 /* Dummy line low 8 bit */ -#define DM_LNH 0x93 /* Dummy line high 8 bit */ -#define LCC6 0x94 /* Lens correction option 6 */ -#define LCC7 0x95 /* Lens correction option 7 */ - -#define RSVD_96 0x96 /* Reserved */ -#define RSVD_97 0x97 /* Reserved */ -#define RSVD_98 0x98 /* Reserved */ -#define RSVD_99 0x99 /* Reserved */ -#define RSVD_9A 0x9A /* Reserved */ -#define RSVD_9B 0x9B /* Reserved */ -#define RSVD_9C 0x9C /* Reserved */ - -#define BD50ST 0x9D /* 50 Hz banding filter value */ -#define BD60ST 0x9E /* 60 Hz banding filter value */ -#define HAECC1 0x9F /* Histogram-based AEC/AGC control 1 */ -#define HAECC2 0xA0 /* Histogram-based AEC/AGC control 2 */ - -#define RSVD_A1 0xA1 /* Reserved */ - -#define SCALING_PCLK_DELAY 0xA2 /* Pixel clock delay */ - -#define RSVD_A3 0xA3 /* Reserved */ - -#define NT_CNTRL 0xA4 /* */ -#define BD50MAX 0xA5 /* 50 Hz banding step limit */ -#define HAECC3 0xA6 /* Histogram-based AEC/AGC control 3 */ -#define HAECC4 0xA7 /* Histogram-based AEC/AGC control 4 */ -#define HAECC5 0xA8 /* Histogram-based AEC/AGC control 5 */ -#define HAECC6 0xA9 /* Histogram-based AEC/AGC control 6 */ - -#define HAECC7 0xAA /* Histogram-based AEC/AGC control 7 */ -#define HAECC_EN 0x80 /* Histogram-based AEC algorithm enable */ - -#define BD60MAX 0xAB /* 60 Hz banding step limit */ - -#define STR_OPT 0xAC /* Register AC */ -#define STR_R 0xAD /* R gain for led output frame */ -#define STR_G 0xAE /* G gain for led output frame */ -#define STR_B 0xAF /* B gain for led output frame */ -#define RSVD_B0 0xB0 /* Reserved */ -#define ABLC1 0xB1 /* */ -#define RSVD_B2 0xB2 /* Reserved */ -#define THL_ST 0xB3 /* ABLC target */ -#define THL_DLT 0xB5 /* ABLC stable range */ - -#define RSVD_B6 0xB6 /* Reserved */ -#define RSVD_B7 0xB7 /* Reserved */ -#define RSVD_B8 0xB8 /* Reserved */ -#define RSVD_B9 0xB9 /* Reserved */ -#define RSVD_BA 0xBA /* Reserved */ -#define RSVD_BB 0xBB /* Reserved */ -#define RSVD_BC 0xBC /* Reserved */ -#define RSVD_BD 0xBD /* Reserved */ - -#define AD_CHB 0xBE /* blue channel black level compensation */ -#define AD_CHR 0xBF /* Red channel black level compensation */ -#define AD_CHGb 0xC0 /* Gb channel black level compensation */ -#define AD_CHGr 0xC1 /* Gr channel black level compensation */ - -#define RSVD_C2 0xC2 /* Reserved */ -#define RSVD_C3 0xC3 /* Reserved */ -#define RSVD_C4 0xC4 /* Reserved */ -#define RSVD_C5 0xC5 /* Reserved */ -#define RSVD_C6 0xC6 /* Reserved */ -#define RSVD_C7 0xC7 /* Reserved */ -#define RSVD_C8 0xC8 /* Reserved */ - -#define SATCTR 0xC9 /* Saturation control */ -#define SET_REG(reg, x) (##reg_DEFAULT|x) - -#endif //__OV7670_REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h deleted file mode 100644 index 291b26680..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV7725 driver. - * - */ -#ifndef __OV7725_H__ -#define __OV7725_H__ -#include "sensor.h" - -/** - * @brief Detect sensor pid - * - * @param slv_addr SCCB address - * @param id Detection result - * @return - * 0: Can't detect this sensor - * Nonzero: This sensor has been detected - */ -int ov7725_detect(int slv_addr, sensor_id_t *id); - -/** - * @brief initialize sensor function pointers - * - * @param sensor pointer of sensor - * @return - * Always 0 - */ -int ov7725_init(sensor_t *sensor); - -#endif // __OV7725_H__ diff --git a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h b/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h deleted file mode 100644 index 5cb233dc9..000000000 --- a/lib/libesp32_div/esp32-camera/sensors/private_include/ov7725_regs.h +++ /dev/null @@ -1,335 +0,0 @@ -/* - * This file is part of the OpenMV project. - * Copyright (c) 2013/2014 Ibrahim Abdelkader - * This work is licensed under the MIT license, see the file LICENSE for details. - * - * OV2640 register definitions. - */ -#ifndef __REG_REGS_H__ -#define __REG_REGS_H__ -#define GAIN 0x00 /* AGC – Gain control gain setting */ -#define BLUE 0x01 /* AWB – Blue channel gain setting */ -#define RED 0x02 /* AWB – Red channel gain setting */ -#define GREEN 0x03 /* AWB – Green channel gain setting */ -#define BAVG 0x05 /* U/B Average Level */ -#define GAVG 0x06 /* Y/Gb Average Level */ -#define RAVG 0x07 /* V/R Average Level */ -#define AECH 0x08 /* Exposure Value – AEC MSBs */ - -#define COM2 0x09 /* Common Control 2 */ -#define COM2_SOFT_SLEEP 0x10 /* Soft sleep mode */ -#define COM2_OUT_DRIVE_1x 0x00 /* Output drive capability 1x */ -#define COM2_OUT_DRIVE_2x 0x01 /* Output drive capability 2x */ -#define COM2_OUT_DRIVE_3x 0x02 /* Output drive capability 3x */ -#define COM2_OUT_DRIVE_4x 0x03 /* Output drive capability 4x */ - -#define REG_PID 0x0A /* Product ID Number MSB */ -#define REG_VER 0x0B /* Product ID Number LSB */ - -#define COM3 0x0C /* Common Control 3 */ -#define COM3_VFLIP 0x80 /* Vertical flip image ON/OFF selection */ -#define COM3_MIRROR 0x40 /* Horizontal mirror image ON/OFF selection */ -#define COM3_SWAP_BR 0x20 /* Swap B/R output sequence in RGB output mode */ -#define COM3_SWAP_YUV 0x10 /* Swap Y/UV output sequence in YUV output mode */ -#define COM3_SWAP_MSB 0x08 /* Swap output MSB/LSB */ -#define COM3_TRI_CLOCK 0x04 /* Tri-state option for output clock at power-down period */ -#define COM3_TRI_DATA 0x02 /* Tri-state option for output data at power-down period */ -#define COM3_COLOR_BAR 0x01 /* Sensor color bar test pattern output enable */ -#define COM3_SET_CBAR(r, x) ((r&0xFE)|((x&1)<<0)) -#define COM3_SET_MIRROR(r, x) ((r&0xBF)|((x&1)<<6)) -#define COM3_SET_FLIP(r, x) ((r&0x7F)|((x&1)<<7)) - -#define COM4 0x0D /* Common Control 4 */ -#define COM4_PLL_BYPASS 0x00 /* Bypass PLL */ -#define COM4_PLL_4x 0x40 /* PLL frequency 4x */ -#define COM4_PLL_6x 0x80 /* PLL frequency 6x */ -#define COM4_PLL_8x 0xc0 /* PLL frequency 8x */ -#define COM4_AEC_FULL 0x00 /* AEC evaluate full window */ -#define COM4_AEC_1_2 0x10 /* AEC evaluate 1/2 window */ -#define COM4_AEC_1_4 0x20 /* AEC evaluate 1/4 window */ -#define COM4_AEC_2_3 0x30 /* AEC evaluate 2/3 window */ - -#define COM5 0x0E /* Common Control 5 */ -#define COM5_AFR 0x80 /* Auto frame rate control ON/OFF selection (night mode) */ -#define COM5_AFR_SPEED 0x40 /* Auto frame rate control speed selection */ -#define COM5_AFR_0 0x00 /* No reduction of frame rate */ -#define COM5_AFR_1_2 0x10 /* Max reduction to 1/2 frame rate */ -#define COM5_AFR_1_4 0x20 /* Max reduction to 1/4 frame rate */ -#define COM5_AFR_1_8 0x30 /* Max reduction to 1/8 frame rate */ -#define COM5_AFR_4x 0x04 /* Add frame when AGC reaches 4x gain */ -#define COM5_AFR_8x 0x08 /* Add frame when AGC reaches 8x gain */ -#define COM5_AFR_16x 0x0c /* Add frame when AGC reaches 16x gain */ -#define COM5_AEC_NO_LIMIT 0x01 /* No limit to AEC increase step */ - -#define COM6 0x0F /* Common Control 6 */ -#define COM6_AUTO_WINDOW 0x01 /* Auto window setting ON/OFF selection when format changes */ - -#define AEC 0x10 /* AEC[7:0] (see register AECH for AEC[15:8]) */ -#define CLKRC 0x11 /* Internal Clock */ - -#define COM7 0x12 /* Common Control 7 */ -#define COM7_RESET 0x80 /* SCCB Register Reset */ -#define COM7_RES_VGA 0x00 /* Resolution VGA */ -#define COM7_RES_QVGA 0x40 /* Resolution QVGA */ -#define COM7_BT656 0x20 /* BT.656 protocol ON/OFF */ -#define COM7_SENSOR_RAW 0x10 /* Sensor RAW */ -#define COM7_FMT_GBR422 0x00 /* RGB output format GBR422 */ -#define COM7_FMT_RGB565 0x04 /* RGB output format RGB565 */ -#define COM7_FMT_RGB555 0x08 /* RGB output format RGB555 */ -#define COM7_FMT_RGB444 0x0C /* RGB output format RGB444 */ -#define COM7_FMT_YUV 0x00 /* Output format YUV */ -#define COM7_FMT_P_BAYER 0x01 /* Output format Processed Bayer RAW */ -#define COM7_FMT_RGB 0x02 /* Output format RGB */ -#define COM7_FMT_R_BAYER 0x03 /* Output format Bayer RAW */ -#define COM7_SET_FMT(r, x) ((r&0xFC)|((x&0x3)<<0)) -#define COM7_SET_RGB(r, x) ((r&0xF0)|(x&0x0C)|COM7_FMT_RGB) - -#define COM8 0x13 /* Common Control 8 */ -#define COM8_FAST_AUTO 0x80 /* Enable fast AGC/AEC algorithm */ -#define COM8_STEP_VSYNC 0x00 /* AEC - Step size limited to vertical blank */ -#define COM8_STEP_UNLIMIT 0x40 /* AEC - Step size unlimited step size */ -#define COM8_BANDF_EN 0x20 /* Banding filter ON/OFF */ -#define COM8_AEC_BANDF 0x10 /* Enable AEC below banding value */ -#define COM8_AEC_FINE_EN 0x08 /* Fine AEC ON/OFF control */ -#define COM8_AGC_EN 0x04 /* AGC Enable */ -#define COM8_AWB_EN 0x02 /* AWB Enable */ -#define COM8_AEC_EN 0x01 /* AEC Enable */ -#define COM8_SET_AGC(r, x) ((r&0xFB)|((x&0x1)<<2)) -#define COM8_SET_AWB(r, x) ((r&0xFD)|((x&0x1)<<1)) -#define COM8_SET_AEC(r, x) ((r&0xFE)|((x&0x1)<<0)) - -#define COM9 0x14 /* Common Control 9 */ -#define COM9_HISTO_AVG 0x80 /* Histogram or average based AEC/AGC selection */ -#define COM9_AGC_GAIN_2x 0x00 /* Automatic Gain Ceiling 2x */ -#define COM9_AGC_GAIN_4x 0x10 /* Automatic Gain Ceiling 4x */ -#define COM9_AGC_GAIN_8x 0x20 /* Automatic Gain Ceiling 8x */ -#define COM9_AGC_GAIN_16x 0x30 /* Automatic Gain Ceiling 16x */ -#define COM9_AGC_GAIN_32x 0x40 /* Automatic Gain Ceiling 32x */ -#define COM9_DROP_VSYNC 0x04 /* Drop VSYNC output of corrupt frame */ -#define COM9_DROP_HREF 0x02 /* Drop HREF output of corrupt frame */ -#define COM9_SET_AGC(r, x) ((r&0x8F)|((x&0x07)<<4)) - -#define COM10 0x15 /* Common Control 10 */ -#define COM10_NEGATIVE 0x80 /* Output negative data */ -#define COM10_HSYNC_EN 0x40 /* HREF changes to HSYNC */ -#define COM10_PCLK_FREE 0x00 /* PCLK output option: free running PCLK */ -#define COM10_PCLK_MASK 0x20 /* PCLK output option: masked during horizontal blank */ -#define COM10_PCLK_REV 0x10 /* PCLK reverse */ -#define COM10_HREF_REV 0x08 /* HREF reverse */ -#define COM10_VSYNC_FALLING 0x00 /* VSYNC changes on falling edge of PCLK */ -#define COM10_VSYNC_RISING 0x04 /* VSYNC changes on rising edge of PCLK */ -#define COM10_VSYNC_NEG 0x02 /* VSYNC negative */ -#define COM10_OUT_RANGE_8 0x01 /* Output data range: Full range */ -#define COM10_OUT_RANGE_10 0x00 /* Output data range: Data from [10] to [F0] (8 MSBs) */ - -#define REG16 0x16 /* Register 16 */ -#define REG16_BIT_SHIFT 0x80 /* Bit shift test pattern options */ -#define HSTART 0x17 /* Horizontal Frame (HREF column) Start 8 MSBs (2 LSBs are at HREF[5:4]) */ -#define HSIZE 0x18 /* Horizontal Sensor Size (2 LSBs are at HREF[1:0]) */ -#define VSTART 0x19 /* Vertical Frame (row) Start 8 MSBs (1 LSB is at HREF[6]) */ -#define VSIZE 0x1A /* Vertical Sensor Size (1 LSB is at HREF[2]) */ -#define PSHFT 0x1B /* Data Format - Pixel Delay Select */ -#define REG_MIDH 0x1C /* Manufacturer ID Byte – High */ -#define REG_MIDL 0x1D /* Manufacturer ID Byte – Low */ -#define LAEC 0x1F /* Fine AEC Value - defines exposure value less than one row period */ - -#define COM11 0x20 /* Common Control 11 */ -#define COM11_SNGL_FRAME_EN 0x02 /* Single frame ON/OFF selection */ -#define COM11_SNGL_XFR_TRIG 0x01 /* Single frame transfer trigger */ - -#define BDBASE 0x22 /* Banding Filter Minimum AEC Value */ -#define DBSTEP 0x23 /* Banding Filter Maximum Step */ -#define AEW 0x24 /* AGC/AEC - Stable Operating Region (Upper Limit) */ -#define AEB 0x25 /* AGC/AEC - Stable Operating Region (Lower Limit) */ -#define VPT 0x26 /* AGC/AEC Fast Mode Operating Region */ -#define REG28 0x28 /* Selection on the number of dummy rows, N */ -#define HOUTSIZE 0x29 /* Horizontal Data Output Size MSBs (2 LSBs at register EXHCH[1:0]) */ -#define EXHCH 0x2A /* Dummy Pixel Insert MSB */ -#define EXHCL 0x2B /* Dummy Pixel Insert LSB */ -#define VOUTSIZE 0x2C /* Vertical Data Output Size MSBs (LSB at register EXHCH[2]) */ -#define ADVFL 0x2D /* LSB of Insert Dummy Rows in Vertical Sync (1 bit equals 1 row) */ -#define ADVFH 0x2E /* MSB of Insert Dummy Rows in Vertical Sync */ -#define YAVE 0x2F /* Y/G Channel Average Value */ -#define LUMHTH 0x30 /* Histogram AEC/AGC Luminance High Level Threshold */ -#define LUMLTH 0x31 /* Histogram AEC/AGC Luminance Low Level Threshold */ -#define HREF 0x32 /* Image Start and Size Control */ -#define DM_LNL 0x33 /* Dummy Row Low 8 Bits */ -#define DM_LNH 0x34 /* Dummy Row High 8 Bits */ -#define ADOFF_B 0x35 /* AD Offset Compensation Value for B Channel */ -#define ADOFF_R 0x36 /* AD Offset Compensation Value for R Channel */ -#define ADOFF_GB 0x37 /* AD Offset Compensation Value for GB Channel */ -#define ADOFF_GR 0x38 /* AD Offset Compensation Value for GR Channel */ -#define OFF_B 0x39 /* AD Offset Compensation Value for B Channel */ -#define OFF_R 0x3A /* AD Offset Compensation Value for R Channel */ -#define OFF_GB 0x3B /* AD Offset Compensation Value for GB Channel */ -#define OFF_GR 0x3C /* AD Offset Compensation Value for GR Channel */ -#define COM12 0x3D /* DC offset compensation for analog process */ - -#define COM13 0x3E /* Common Control 13 */ -#define COM13_BLC_EN 0x80 /* BLC enable */ -#define COM13_ADC_EN 0x40 /* ADC channel BLC ON/OFF control */ -#define COM13_ANALOG_BLC 0x20 /* Analog processing channel BLC ON/OFF control */ -#define COM13_ABLC_GAIN_EN 0x04 /* ABLC gain trigger enable */ - -#define COM14 0x3F /* Common Control 14 */ -#define COM15 0x40 /* Common Control 15 */ -#define COM16 0x41 /* Common Control 16 */ -#define TGT_B 0x42 /* BLC Blue Channel Target Value */ -#define TGT_R 0x43 /* BLC Red Channel Target Value */ -#define TGT_GB 0x44 /* BLC Gb Channel Target Value */ -#define TGT_GR 0x45 /* BLC Gr Channel Target Value */ - -#define LC_CTR 0x46 /* Lens Correction Control */ -#define LC_CTR_RGB_COMP_1 0x00 /* R, G, and B channel compensation coefficient is set by LC_COEF (0x49) */ -#define LC_CTR_RGB_COMP_3 0x04 /* R, G, and B channel compensation coefficient is set by registers - LC_COEFB (0x4B), LC_COEF (0x49), and LC_COEFR (0x4C), respectively */ -#define LC_CTR_EN 0x01 /* Lens correction enable */ -#define LC_XC 0x47 /* X Coordinate of Lens Correction Center Relative to Array Center */ -#define LC_YC 0x48 /* Y Coordinate of Lens Correction Center Relative to Array Center */ -#define LC_COEF 0x49 /* Lens Correction Coefficient */ -#define LC_RADI 0x4A /* Lens Correction Radius */ -#define LC_COEFB 0x4B /* Lens Correction B Channel Compensation Coefficient */ -#define LC_COEFR 0x4C /* Lens Correction R Channel Compensation Coefficient */ - -#define FIXGAIN 0x4D /* Analog Fix Gain Amplifier */ -#define AREF0 0x4E /* Sensor Reference Control */ -#define AREF1 0x4F /* Sensor Reference Current Control */ -#define AREF2 0x50 /* Analog Reference Control */ -#define AREF3 0x51 /* ADC Reference Control */ -#define AREF4 0x52 /* ADC Reference Control */ -#define AREF5 0x53 /* ADC Reference Control */ -#define AREF6 0x54 /* Analog Reference Control */ -#define AREF7 0x55 /* Analog Reference Control */ -#define UFIX 0x60 /* U Channel Fixed Value Output */ -#define VFIX 0x61 /* V Channel Fixed Value Output */ -#define AWBB_BLK 0x62 /* AWB Option for Advanced AWB */ - -#define AWB_CTRL0 0x63 /* AWB Control Byte 0 */ -#define AWB_CTRL0_GAIN_EN 0x80 /* AWB gain enable */ -#define AWB_CTRL0_CALC_EN 0x40 /* AWB calculate enable */ -#define AWB_CTRL0_WBC_MASK 0x0F /* WBC threshold 2 */ - -#define DSP_CTRL1 0x64 /* DSP Control Byte 1 */ -#define DSP_CTRL1_FIFO_EN 0x80 /* FIFO enable/disable selection */ -#define DSP_CTRL1_UV_EN 0x40 /* UV adjust function ON/OFF selection */ -#define DSP_CTRL1_SDE_EN 0x20 /* SDE enable */ -#define DSP_CTRL1_MTRX_EN 0x10 /* Color matrix ON/OFF selection */ -#define DSP_CTRL1_INTRP_EN 0x08 /* Interpolation ON/OFF selection */ -#define DSP_CTRL1_GAMMA_EN 0x04 /* Gamma function ON/OFF selection */ -#define DSP_CTRL1_BLACK_EN 0x02 /* Black defect auto correction ON/OFF */ -#define DSP_CTRL1_WHITE_EN 0x01 /* White defect auto correction ON/OFF */ - -#define DSP_CTRL2 0x65 /* DSP Control Byte 2 */ -#define DSP_CTRL2_VDCW_EN 0x08 /* Vertical DCW enable */ -#define DSP_CTRL2_HDCW_EN 0x04 /* Horizontal DCW enable */ -#define DSP_CTRL2_VZOOM_EN 0x02 /* Vertical zoom out enable */ -#define DSP_CTRL2_HZOOM_EN 0x01 /* Horizontal zoom out enable */ - -#define DSP_CTRL3 0x66 /* DSP Control Byte 3 */ -#define DSP_CTRL3_UV_EN 0x80 /* UV output sequence option */ -#define DSP_CTRL3_CBAR_EN 0x20 /* DSP color bar ON/OFF selection */ -#define DSP_CTRL3_FIFO_EN 0x08 /* FIFO power down ON/OFF selection */ -#define DSP_CTRL3_SCAL1_PWDN 0x04 /* Scaling module power down control 1 */ -#define DSP_CTRL3_SCAL2_PWDN 0x02 /* Scaling module power down control 2 */ -#define DSP_CTRL3_INTRP_PWDN 0x01 /* Interpolation module power down control */ -#define DSP_CTRL3_SET_CBAR(r, x) ((r&0xDF)|((x&1)<<5)) - - -#define DSP_CTRL4 0x67 /* DSP Control Byte 4 */ -#define DSP_CTRL4_YUV_RGB 0x00 /* Output selection YUV or RGB */ -#define DSP_CTRL4_RAW8 0x02 /* Output selection RAW8 */ -#define DSP_CTRL4_RAW10 0x03 /* Output selection RAW10 */ - - -#define AWB_BIAS 0x68 /* AWB BLC Level Clip */ -#define AWB_CTRL1 0x69 /* AWB Control 1 */ -#define AWB_CTRL2 0x6A /* AWB Control 2 */ - -#define AWB_CTRL3 0x6B /* AWB Control 3 */ -#define AWB_CTRL3_ADVANCED 0x80 /* AWB mode select - Advanced AWB */ -#define AWB_CTRL3_SIMPLE 0x00 /* AWB mode select - Simple AWB */ - -#define AWB_CTRL4 0x6C /* AWB Control 4 */ -#define AWB_CTRL5 0x6D /* AWB Control 5 */ -#define AWB_CTRL6 0x6E /* AWB Control 6 */ -#define AWB_CTRL7 0x6F /* AWB Control 7 */ -#define AWB_CTRL8 0x70 /* AWB Control 8 */ -#define AWB_CTRL9 0x71 /* AWB Control 9 */ -#define AWB_CTRL10 0x72 /* AWB Control 10 */ -#define AWB_CTRL11 0x73 /* AWB Control 11 */ -#define AWB_CTRL12 0x74 /* AWB Control 12 */ -#define AWB_CTRL13 0x75 /* AWB Control 13 */ -#define AWB_CTRL14 0x76 /* AWB Control 14 */ -#define AWB_CTRL15 0x77 /* AWB Control 15 */ -#define AWB_CTRL16 0x78 /* AWB Control 16 */ -#define AWB_CTRL17 0x79 /* AWB Control 17 */ -#define AWB_CTRL18 0x7A /* AWB Control 18 */ -#define AWB_CTRL19 0x7B /* AWB Control 19 */ -#define AWB_CTRL20 0x7C /* AWB Control 20 */ -#define AWB_CTRL21 0x7D /* AWB Control 21 */ -#define GAM1 0x7E /* Gamma Curve 1st Segment Input End Point 0x04 Output Value */ -#define GAM2 0x7F /* Gamma Curve 2nd Segment Input End Point 0x08 Output Value */ -#define GAM3 0x80 /* Gamma Curve 3rd Segment Input End Point 0x10 Output Value */ -#define GAM4 0x81 /* Gamma Curve 4th Segment Input End Point 0x20 Output Value */ -#define GAM5 0x82 /* Gamma Curve 5th Segment Input End Point 0x28 Output Value */ -#define GAM6 0x83 /* Gamma Curve 6th Segment Input End Point 0x30 Output Value */ -#define GAM7 0x84 /* Gamma Curve 7th Segment Input End Point 0x38 Output Value */ -#define GAM8 0x85 /* Gamma Curve 8th Segment Input End Point 0x40 Output Value */ -#define GAM9 0x86 /* Gamma Curve 9th Segment Input End Point 0x48 Output Value */ -#define GAM10 0x87 /* Gamma Curve 10th Segment Input End Point 0x50 Output Value */ -#define GAM11 0x88 /* Gamma Curve 11th Segment Input End Point 0x60 Output Value */ -#define GAM12 0x89 /* Gamma Curve 12th Segment Input End Point 0x70 Output Value */ -#define GAM13 0x8A /* Gamma Curve 13th Segment Input End Point 0x90 Output Value */ -#define GAM14 0x8B /* Gamma Curve 14th Segment Input End Point 0xB0 Output Value */ -#define GAM15 0x8C /* Gamma Curve 15th Segment Input End Point 0xD0 Output Value */ -#define SLOP 0x8D /* Gamma Curve Highest Segment Slope */ -#define DNSTH 0x8E /* De-noise Threshold */ -#define EDGE0 0x8F /* Edge Enhancement Strength Control */ -#define EDGE1 0x90 /* Edge Enhancement Threshold Control */ -#define DNSOFF 0x91 /* Auto De-noise Threshold Control */ -#define EDGE2 0x92 /* Edge Enhancement Strength Upper Limit */ -#define EDGE3 0x93 /* Edge Enhancement Strength Upper Limit */ -#define MTX1 0x94 /* Matrix Coefficient 1 */ -#define MTX2 0x95 /* Matrix Coefficient 2 */ -#define MTX3 0x96 /* Matrix Coefficient 3 */ -#define MTX4 0x97 /* Matrix Coefficient 4 */ -#define MTX5 0x98 /* Matrix Coefficient 5 */ -#define MTX6 0x99 /* Matrix Coefficient 6 */ - -#define MTX_CTRL 0x9A /* Matrix Control */ -#define MTX_CTRL_DBL_EN 0x80 /* Matrix double ON/OFF selection */ - -#define BRIGHTNESS 0x9B /* Brightness Control */ -#define CONTRAST 0x9C /* Contrast Gain */ -#define UVADJ0 0x9E /* Auto UV Adjust Control 0 */ -#define UVADJ1 0x9F /* Auto UV Adjust Control 1 */ -#define SCAL0 0xA0 /* DCW Ratio Control */ -#define SCAL1 0xA1 /* Horizontal Zoom Out Control */ -#define SCAL2 0xA2 /* Vertical Zoom Out Control */ -#define FIFODLYM 0xA3 /* FIFO Manual Mode Delay Control */ -#define FIFODLYA 0xA4 /* FIFO Auto Mode Delay Control */ - -#define SDE 0xA6 /* Special Digital Effect Control */ -#define SDE_NEGATIVE_EN 0x40 /* Negative image enable */ -#define SDE_GRAYSCALE_EN 0x20 /* Gray scale image enable */ -#define SDE_V_FIXED_EN 0x10 /* V fixed value enable */ -#define SDE_U_FIXED_EN 0x08 /* U fixed value enable */ -#define SDE_CONT_BRIGHT_EN 0x04 /* Contrast/Brightness enable */ -#define SDE_SATURATION_EN 0x02 /* Saturation enable */ -#define SDE_HUE_EN 0x01 /* Hue enable */ - -#define USAT 0xA7 /* U Component Saturation Gain */ -#define VSAT 0xA8 /* V Component Saturation Gain */ -#define HUECOS 0xA9 /* Cosine value × 0x80 */ -#define HUESIN 0xAA /* Sine value × 0x80 */ -#define SIGN_BIT 0xAB /* Sign Bit for Hue and Brightness */ - -#define DSPAUTO 0xAC /* DSP Auto Function ON/OFF Control */ -#define DSPAUTO_AWB_EN 0x80 /* AWB auto threshold control */ -#define DSPAUTO_DENOISE_EN 0x40 /* De-noise auto threshold control */ -#define DSPAUTO_EDGE_EN 0x20 /* Sharpness (edge enhancement) auto strength control */ -#define DSPAUTO_UV_EN 0x10 /* UV adjust auto slope control */ -#define DSPAUTO_SCAL0_EN 0x08 /* Auto scaling factor control (register SCAL0 (0xA0)) */ -#define DSPAUTO_SCAL1_EN 0x04 /* Auto scaling factor control (registers SCAL1 (0xA1 and SCAL2 (0xA2))*/ -#define SET_REG(reg, x) (##reg_DEFAULT|x) -#endif //__REG_REGS_H__ diff --git a/lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c b/lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c deleted file mode 100644 index e513205d2..000000000 --- a/lib/libesp32_div/esp32-camera/target/esp32/ll_cam.c +++ /dev/null @@ -1,522 +0,0 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include "soc/i2s_struct.h" -#include "esp_idf_version.h" -#if (ESP_IDF_VERSION_MAJOR >= 4) && (ESP_IDF_VERSION_MINOR > 1) -#include "hal/gpio_ll.h" -#else -#include "soc/gpio_periph.h" -#define esp_rom_delay_us ets_delay_us -static inline int gpio_ll_get_level(gpio_dev_t *hw, int gpio_num) -{ - if (gpio_num < 32) { - return (hw->in >> gpio_num) & 0x1; - } else { - return (hw->in1.data >> (gpio_num - 32)) & 0x1; - } -} -#endif -#include "ll_cam.h" -#include "xclk.h" -#include "cam_hal.h" - -static const char *TAG = "esp32 ll_cam"; - -#define I2S_ISR_ENABLE(i) {I2S0.int_clr.i = 1;I2S0.int_ena.i = 1;} -#define I2S_ISR_DISABLE(i) {I2S0.int_ena.i = 0;I2S0.int_clr.i = 1;} - -typedef union { - struct { - uint32_t sample2:8; - uint32_t unused2:8; - uint32_t sample1:8; - uint32_t unused1:8; - }; - uint32_t val; -} dma_elem_t; - -typedef enum { - /* camera sends byte sequence: s1, s2, s3, s4, ... - * fifo receives: 00 s1 00 s2, 00 s2 00 s3, 00 s3 00 s4, ... - */ - SM_0A0B_0B0C = 0, - /* camera sends byte sequence: s1, s2, s3, s4, ... - * fifo receives: 00 s1 00 s2, 00 s3 00 s4, ... - */ - SM_0A0B_0C0D = 1, - /* camera sends byte sequence: s1, s2, s3, s4, ... - * fifo receives: 00 s1 00 00, 00 s2 00 00, 00 s3 00 00, ... - */ - SM_0A00_0B00 = 3, -} i2s_sampling_mode_t; - -typedef size_t (*dma_filter_t)(uint8_t* dst, const uint8_t* src, size_t len); - -static i2s_sampling_mode_t sampling_mode = SM_0A00_0B00; - -static size_t ll_cam_bytes_per_sample(i2s_sampling_mode_t mode) -{ - switch(mode) { - case SM_0A00_0B00: - return 4; - case SM_0A0B_0B0C: - return 4; - case SM_0A0B_0C0D: - return 2; - default: - assert(0 && "invalid sampling mode"); - return 0; - } -} - -static size_t IRAM_ATTR ll_cam_dma_filter_jpeg(uint8_t* dst, const uint8_t* src, size_t len) -{ - const dma_elem_t* dma_el = (const dma_elem_t*)src; - size_t elements = len / sizeof(dma_elem_t); - size_t end = elements / 4; - // manually unrolling 4 iterations of the loop here - for (size_t i = 0; i < end; ++i) { - dst[0] = dma_el[0].sample1; - dst[1] = dma_el[1].sample1; - dst[2] = dma_el[2].sample1; - dst[3] = dma_el[3].sample1; - dma_el += 4; - dst += 4; - } - return elements; -} - -static size_t IRAM_ATTR ll_cam_dma_filter_grayscale(uint8_t* dst, const uint8_t* src, size_t len) -{ - const dma_elem_t* dma_el = (const dma_elem_t*)src; - size_t elements = len / sizeof(dma_elem_t); - size_t end = elements / 4; - for (size_t i = 0; i < end; ++i) { - // manually unrolling 4 iterations of the loop here - dst[0] = dma_el[0].sample1; - dst[1] = dma_el[1].sample1; - dst[2] = dma_el[2].sample1; - dst[3] = dma_el[3].sample1; - dma_el += 4; - dst += 4; - } - return elements; -} - -static size_t IRAM_ATTR ll_cam_dma_filter_grayscale_highspeed(uint8_t* dst, const uint8_t* src, size_t len) -{ - const dma_elem_t* dma_el = (const dma_elem_t*)src; - size_t elements = len / sizeof(dma_elem_t); - size_t end = elements / 8; - for (size_t i = 0; i < end; ++i) { - // manually unrolling 4 iterations of the loop here - dst[0] = dma_el[0].sample1; - dst[1] = dma_el[2].sample1; - dst[2] = dma_el[4].sample1; - dst[3] = dma_el[6].sample1; - dma_el += 8; - dst += 4; - } - // the final sample of a line in SM_0A0B_0B0C sampling mode needs special handling - if ((elements & 0x7) != 0) { - dst[0] = dma_el[0].sample1; - dst[1] = dma_el[2].sample1; - elements += 1; - } - return elements / 2; -} - -static size_t IRAM_ATTR ll_cam_dma_filter_yuyv(uint8_t* dst, const uint8_t* src, size_t len) -{ - const dma_elem_t* dma_el = (const dma_elem_t*)src; - size_t elements = len / sizeof(dma_elem_t); - size_t end = elements / 4; - for (size_t i = 0; i < end; ++i) { - dst[0] = dma_el[0].sample1;//y0 - dst[1] = dma_el[0].sample2;//u - dst[2] = dma_el[1].sample1;//y1 - dst[3] = dma_el[1].sample2;//v - - dst[4] = dma_el[2].sample1;//y0 - dst[5] = dma_el[2].sample2;//u - dst[6] = dma_el[3].sample1;//y1 - dst[7] = dma_el[3].sample2;//v - dma_el += 4; - dst += 8; - } - return elements * 2; -} - -static size_t IRAM_ATTR ll_cam_dma_filter_yuyv_highspeed(uint8_t* dst, const uint8_t* src, size_t len) -{ - const dma_elem_t* dma_el = (const dma_elem_t*)src; - size_t elements = len / sizeof(dma_elem_t); - size_t end = elements / 8; - for (size_t i = 0; i < end; ++i) { - dst[0] = dma_el[0].sample1;//y0 - dst[1] = dma_el[1].sample1;//u - dst[2] = dma_el[2].sample1;//y1 - dst[3] = dma_el[3].sample1;//v - - dst[4] = dma_el[4].sample1;//y0 - dst[5] = dma_el[5].sample1;//u - dst[6] = dma_el[6].sample1;//y1 - dst[7] = dma_el[7].sample1;//v - dma_el += 8; - dst += 8; - } - if ((elements & 0x7) != 0) { - dst[0] = dma_el[0].sample1;//y0 - dst[1] = dma_el[1].sample1;//u - dst[2] = dma_el[2].sample1;//y1 - dst[3] = dma_el[2].sample2;//v - elements += 4; - } - return elements; -} - -static void IRAM_ATTR ll_cam_vsync_isr(void *arg) -{ - //DBG_PIN_SET(1); - cam_obj_t *cam = (cam_obj_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - // filter - ets_delay_us(1); - if (gpio_ll_get_level(&GPIO, cam->vsync_pin) == !cam->vsync_invert) { - ll_cam_send_event(cam, CAM_VSYNC_EVENT, &HPTaskAwoken); - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } - } - //DBG_PIN_SET(0); -} - -static void IRAM_ATTR ll_cam_dma_isr(void *arg) -{ - //DBG_PIN_SET(1); - cam_obj_t *cam = (cam_obj_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - - typeof(I2S0.int_st) status = I2S0.int_st; - if (status.val == 0) { - return; - } - - I2S0.int_clr.val = status.val; - - if (status.in_suc_eof) { - ll_cam_send_event(cam, CAM_IN_SUC_EOF_EVENT, &HPTaskAwoken); - } - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } - //DBG_PIN_SET(0); -} - -bool ll_cam_stop(cam_obj_t *cam) -{ - I2S0.conf.rx_start = 0; - I2S_ISR_DISABLE(in_suc_eof); - I2S0.in_link.stop = 1; - return true; -} - -esp_err_t ll_cam_deinit(cam_obj_t *cam) -{ - gpio_isr_handler_remove(cam->vsync_pin); - - if (cam->cam_intr_handle) { - esp_intr_free(cam->cam_intr_handle); - cam->cam_intr_handle = NULL; - } - - return ESP_OK; -} - -bool ll_cam_start(cam_obj_t *cam, int frame_pos) -{ - I2S0.conf.rx_start = 0; - - I2S_ISR_ENABLE(in_suc_eof); - - I2S0.conf.rx_reset = 1; - I2S0.conf.rx_reset = 0; - I2S0.conf.rx_fifo_reset = 1; - I2S0.conf.rx_fifo_reset = 0; - I2S0.lc_conf.in_rst = 1; - I2S0.lc_conf.in_rst = 0; - I2S0.lc_conf.ahbm_fifo_rst = 1; - I2S0.lc_conf.ahbm_fifo_rst = 0; - I2S0.lc_conf.ahbm_rst = 1; - I2S0.lc_conf.ahbm_rst = 0; - - I2S0.rx_eof_num = cam->dma_half_buffer_size / sizeof(dma_elem_t); - I2S0.in_link.addr = ((uint32_t)&cam->dma[0]) & 0xfffff; - - I2S0.in_link.start = 1; - I2S0.conf.rx_start = 1; - return true; -} - -esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) -{ - // Enable and configure I2S peripheral - periph_module_enable(PERIPH_I2S0_MODULE); - - I2S0.conf.rx_reset = 1; - I2S0.conf.rx_reset = 0; - I2S0.conf.rx_fifo_reset = 1; - I2S0.conf.rx_fifo_reset = 0; - I2S0.lc_conf.in_rst = 1; - I2S0.lc_conf.in_rst = 0; - I2S0.lc_conf.ahbm_fifo_rst = 1; - I2S0.lc_conf.ahbm_fifo_rst = 0; - I2S0.lc_conf.ahbm_rst = 1; - I2S0.lc_conf.ahbm_rst = 0; - - I2S0.conf.rx_slave_mod = 1; - I2S0.conf.rx_right_first = 0; - I2S0.conf.rx_msb_right = 0; - I2S0.conf.rx_msb_shift = 0; - I2S0.conf.rx_mono = 0; - I2S0.conf.rx_short_sync = 0; - - I2S0.conf2.lcd_en = 1; - I2S0.conf2.camera_en = 1; - - // Configure clock divider - I2S0.clkm_conf.clkm_div_a = 0; - I2S0.clkm_conf.clkm_div_b = 0; - I2S0.clkm_conf.clkm_div_num = 2; - - I2S0.fifo_conf.dscr_en = 1; - I2S0.fifo_conf.rx_fifo_mod = sampling_mode; - I2S0.fifo_conf.rx_fifo_mod_force_en = 1; - - I2S0.conf_chan.rx_chan_mod = 1; - I2S0.sample_rate_conf.rx_bits_mod = 0; - I2S0.timing.val = 0; - I2S0.timing.rx_dsync_sw = 1; - - return ESP_OK; -} - -void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) -{ - if (en) { - gpio_intr_enable(cam->vsync_pin); - } else { - gpio_intr_disable(cam->vsync_pin); - } -} - -esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) -{ - gpio_config_t io_conf = {0}; - io_conf.intr_type = cam->vsync_invert ? GPIO_PIN_INTR_NEGEDGE : GPIO_PIN_INTR_POSEDGE; - io_conf.pin_bit_mask = 1ULL << config->pin_vsync; - io_conf.mode = GPIO_MODE_INPUT; - io_conf.pull_up_en = 1; - io_conf.pull_down_en = 0; - gpio_config(&io_conf); - gpio_install_isr_service(ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM); - gpio_isr_handler_add(config->pin_vsync, ll_cam_vsync_isr, cam); - gpio_intr_disable(config->pin_vsync); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_pclk], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_pclk, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_pclk, GPIO_FLOATING); - gpio_matrix_in(config->pin_pclk, I2S0I_WS_IN_IDX, false); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_vsync], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_vsync, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_vsync, GPIO_FLOATING); - gpio_matrix_in(config->pin_vsync, I2S0I_V_SYNC_IDX, false); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_href], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_href, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_href, GPIO_FLOATING); - gpio_matrix_in(config->pin_href, I2S0I_H_SYNC_IDX, false); - - int data_pins[8] = { - config->pin_d0, config->pin_d1, config->pin_d2, config->pin_d3, config->pin_d4, config->pin_d5, config->pin_d6, config->pin_d7, - }; - for (int i = 0; i < 8; i++) { - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[data_pins[i]], PIN_FUNC_GPIO); - gpio_set_direction(data_pins[i], GPIO_MODE_INPUT); - gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); - gpio_matrix_in(data_pins[i], I2S0I_DATA_IN0_IDX + i, false); - } - - gpio_matrix_in(0x38, I2S0I_H_ENABLE_IDX, false); - return ESP_OK; -} - -esp_err_t ll_cam_init_isr(cam_obj_t *cam) -{ - return esp_intr_alloc(ETS_I2S0_INTR_SOURCE, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, ll_cam_dma_isr, cam, &cam->cam_intr_handle); -} - -void ll_cam_do_vsync(cam_obj_t *cam) -{ -} - -uint8_t ll_cam_get_dma_align(cam_obj_t *cam) -{ - return 0; -} - -static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ - size_t dma_half_buffer_max = CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX / 2 / cam->dma_bytes_per_item; - size_t dma_buffer_max = 2 * dma_half_buffer_max; - size_t node_max = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE / cam->dma_bytes_per_item; - - size_t line_width = cam->width * cam->in_bytes_per_pixel; - size_t image_size = cam->height * line_width; - if (image_size > (4 * 1024 * 1024) || (line_width > dma_half_buffer_max)) { - ESP_LOGE(TAG, "Resolution too high"); - return 0; - } - - size_t node_size = node_max; - size_t nodes_per_line = 1; - size_t lines_per_node = 1; - size_t lines_per_half_buffer = 1; - size_t dma_half_buffer_min = node_max; - size_t dma_half_buffer = dma_half_buffer_max; - size_t dma_buffer_size = dma_buffer_max; - - // Calculate DMA Node Size so that it's divisable by or divisor of the line width - if(line_width >= node_max){ - // One or more nodes will be requied for one line - for(size_t i = node_max; i > 0; i=i-1){ - if ((line_width % i) == 0) { - node_size = i; - nodes_per_line = line_width / node_size; - break; - } - } - } else { - // One or more lines can fit into one node - for(size_t i = node_max; i > 0; i=i-1){ - if ((i % line_width) == 0) { - node_size = i; - lines_per_node = node_size / line_width; - while((cam->height % lines_per_node) != 0){ - lines_per_node = lines_per_node - 1; - node_size = lines_per_node * line_width; - } - break; - } - } - } - // Calculate minimum EOF size = max(mode_size, line_size) - dma_half_buffer_min = node_size * nodes_per_line; - // Calculate max EOF size divisable by node size - dma_half_buffer = (dma_half_buffer_max / dma_half_buffer_min) * dma_half_buffer_min; - // Adjust EOF size so that height will be divisable by the number of lines in each EOF - lines_per_half_buffer = dma_half_buffer / line_width; - while((cam->height % lines_per_half_buffer) != 0){ - dma_half_buffer = dma_half_buffer - dma_half_buffer_min; - lines_per_half_buffer = dma_half_buffer / line_width; - } - // Calculate DMA size - dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; - - ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u, dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u, image_size: %u", - node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node, dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item, image_size); - - cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; - cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; - cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; - cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; - return 1; -} - -bool ll_cam_dma_sizes(cam_obj_t *cam) -{ - cam->dma_bytes_per_item = ll_cam_bytes_per_sample(sampling_mode); - if (cam->jpeg_mode) { - cam->dma_half_buffer_cnt = 8; - cam->dma_node_buffer_size = 2048; - cam->dma_half_buffer_size = cam->dma_node_buffer_size * 2; - cam->dma_buffer_size = cam->dma_half_buffer_cnt * cam->dma_half_buffer_size; - } else { - return ll_cam_calc_rgb_dma(cam); - } - return 1; -} - -static dma_filter_t dma_filter = ll_cam_dma_filter_jpeg; - -size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len) -{ - //DBG_PIN_SET(1); - size_t r = dma_filter(out, in, len); - //DBG_PIN_SET(0); - return r; -} - -esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid) -{ - if (pix_format == PIXFORMAT_GRAYSCALE) { - if (sensor_pid == OV3660_PID || sensor_pid == OV5640_PID || sensor_pid == NT99141_PID) { - if (xclk_freq_hz > 10000000) { - sampling_mode = SM_0A00_0B00; - dma_filter = ll_cam_dma_filter_yuyv_highspeed; - } else { - sampling_mode = SM_0A0B_0C0D; - dma_filter = ll_cam_dma_filter_yuyv; - } - cam->in_bytes_per_pixel = 1; // camera sends Y8 - } else { - if (xclk_freq_hz > 10000000 && sensor_pid != OV7725_PID) { - sampling_mode = SM_0A00_0B00; - dma_filter = ll_cam_dma_filter_grayscale_highspeed; - } else { - sampling_mode = SM_0A0B_0C0D; - dma_filter = ll_cam_dma_filter_grayscale; - } - cam->in_bytes_per_pixel = 2; // camera sends YU/YV - } - cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 - } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { - if (xclk_freq_hz > 10000000 && sensor_pid != OV7725_PID) { - if (sensor_pid == OV7670_PID) { - sampling_mode = SM_0A0B_0B0C; - } else { - sampling_mode = SM_0A00_0B00; - } - dma_filter = ll_cam_dma_filter_yuyv_highspeed; - } else { - sampling_mode = SM_0A0B_0C0D; - dma_filter = ll_cam_dma_filter_yuyv; - } - cam->in_bytes_per_pixel = 2; // camera sends YU/YV - cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 - } else if (pix_format == PIXFORMAT_JPEG) { - cam->in_bytes_per_pixel = 1; - cam->fb_bytes_per_pixel = 1; - dma_filter = ll_cam_dma_filter_jpeg; - sampling_mode = SM_0A00_0B00; - } else { - ESP_LOGE(TAG, "Requested format is not supported"); - return ESP_ERR_NOT_SUPPORTED; - } - I2S0.fifo_conf.rx_fifo_mod = sampling_mode; - return ESP_OK; -} diff --git a/lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c b/lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c deleted file mode 100644 index d3cb5353b..000000000 --- a/lib/libesp32_div/esp32-camera/target/esp32s2/ll_cam.c +++ /dev/null @@ -1,402 +0,0 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include "soc/system_reg.h" -#include "soc/i2s_struct.h" -#include "hal/gpio_ll.h" -#include "ll_cam.h" -#include "xclk.h" -#include "cam_hal.h" - -static const char *TAG = "s2 ll_cam"; - -#define I2S_ISR_ENABLE(i) {I2S0.int_clr.i = 1;I2S0.int_ena.i = 1;} -#define I2S_ISR_DISABLE(i) {I2S0.int_ena.i = 0;I2S0.int_clr.i = 1;} - -static void IRAM_ATTR ll_cam_vsync_isr(void *arg) -{ - //DBG_PIN_SET(1); - cam_obj_t *cam = (cam_obj_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - // filter - ets_delay_us(1); - if (gpio_ll_get_level(&GPIO, cam->vsync_pin) == !cam->vsync_invert) { - ll_cam_send_event(cam, CAM_VSYNC_EVENT, &HPTaskAwoken); - } - - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } - //DBG_PIN_SET(0); -} - -static void IRAM_ATTR ll_cam_dma_isr(void *arg) -{ - cam_obj_t *cam = (cam_obj_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - - typeof(I2S0.int_st) status = I2S0.int_st; - if (status.val == 0) { - return; - } - - I2S0.int_clr.val = status.val; - - if (status.in_suc_eof) { - ll_cam_send_event(cam, CAM_IN_SUC_EOF_EVENT, &HPTaskAwoken); - } - - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } -} - -bool ll_cam_stop(cam_obj_t *cam) -{ - I2S0.conf.rx_start = 0; - - if (cam->jpeg_mode || !cam->psram_mode) { - I2S_ISR_DISABLE(in_suc_eof); - } - - I2S0.in_link.stop = 1; - return true; -} - -esp_err_t ll_cam_deinit(cam_obj_t *cam) -{ - gpio_isr_handler_remove(cam->vsync_pin); - - if (cam->cam_intr_handle) { - esp_intr_free(cam->cam_intr_handle); - cam->cam_intr_handle = NULL; - } - - return ESP_OK; -} - -bool ll_cam_start(cam_obj_t *cam, int frame_pos) -{ - I2S0.conf.rx_start = 0; - - if (cam->jpeg_mode || !cam->psram_mode) { - I2S_ISR_ENABLE(in_suc_eof); - } - - I2S0.conf.rx_reset = 1; - I2S0.conf.rx_reset = 0; - I2S0.conf.rx_fifo_reset = 1; - I2S0.conf.rx_fifo_reset = 0; - I2S0.lc_conf.in_rst = 1; - I2S0.lc_conf.in_rst = 0; - I2S0.lc_conf.ahbm_fifo_rst = 1; - I2S0.lc_conf.ahbm_fifo_rst = 0; - I2S0.lc_conf.ahbm_rst = 1; - I2S0.lc_conf.ahbm_rst = 0; - - I2S0.rx_eof_num = cam->dma_half_buffer_size; // Ping pong operation - if (!cam->psram_mode) { - I2S0.in_link.addr = ((uint32_t)&cam->dma[0]) & 0xfffff; - } else { - I2S0.in_link.addr = ((uint32_t)&cam->frames[frame_pos].dma[0]) & 0xfffff; - } - - I2S0.in_link.start = 1; - I2S0.conf.rx_start = 1; - return true; -} - -esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) -{ - esp_err_t err = camera_enable_out_clock(config); - if(err != ESP_OK) { - return err; - } - periph_module_enable(PERIPH_I2S0_MODULE); - // Configure the clock - I2S0.clkm_conf.clkm_div_num = 2; // 160MHz / 2 = 80MHz - I2S0.clkm_conf.clkm_div_b = 0; - I2S0.clkm_conf.clkm_div_a = 0; - I2S0.clkm_conf.clk_sel = 2; - I2S0.clkm_conf.clk_en = 1; - - - I2S0.conf.val = 0; - I2S0.fifo_conf.val = 0; - I2S0.fifo_conf.dscr_en = 1; - - I2S0.lc_conf.ahbm_fifo_rst = 1; - I2S0.lc_conf.ahbm_fifo_rst = 0; - I2S0.lc_conf.ahbm_rst = 1; - I2S0.lc_conf.ahbm_rst = 0; - I2S0.lc_conf.check_owner = 0; - //I2S0.lc_conf.indscr_burst_en = 1; - //I2S0.lc_conf.ext_mem_bk_size = 0; // DMA access external memory block size. 0: 16 bytes, 1: 32 bytes, 2:64 bytes, 3:reserved - - I2S0.timing.val = 0; - - I2S0.int_ena.val = 0; - I2S0.int_clr.val = ~0; - - I2S0.conf2.lcd_en = 1; - I2S0.conf2.camera_en = 1; - - // Configuration data format - I2S0.conf.rx_slave_mod = 1; - I2S0.conf.rx_right_first = 0; - I2S0.conf.rx_msb_right = cam->swap_data; - I2S0.conf.rx_short_sync = 0; - I2S0.conf.rx_mono = 0; - I2S0.conf.rx_msb_shift = 0; - I2S0.conf.rx_dma_equal = 1; - - // Configure sampling rate - I2S0.sample_rate_conf.rx_bck_div_num = 1; - I2S0.sample_rate_conf.rx_bits_mod = 8; - - I2S0.conf1.rx_pcm_bypass = 1; - - I2S0.conf2.i_v_sync_filter_en = 1; - I2S0.conf2.i_v_sync_filter_thres = 4; - I2S0.conf2.cam_sync_fifo_reset = 1; - I2S0.conf2.cam_sync_fifo_reset = 0; - - I2S0.conf_chan.rx_chan_mod = 1; - - I2S0.fifo_conf.rx_fifo_mod_force_en = 1; - I2S0.fifo_conf.rx_data_num = 32; - I2S0.fifo_conf.rx_fifo_mod = 2; - - I2S0.lc_conf.in_rst = 1; - I2S0.lc_conf.in_rst = 0; - - I2S0.conf.rx_start = 1; - - return ESP_OK; -} - -void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) -{ - if (en) { - gpio_intr_enable(cam->vsync_pin); - } else { - gpio_intr_disable(cam->vsync_pin); - } -} - -esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) -{ - gpio_config_t io_conf = {0}; - io_conf.intr_type = cam->vsync_invert ? GPIO_PIN_INTR_NEGEDGE : GPIO_PIN_INTR_POSEDGE; - io_conf.pin_bit_mask = 1ULL << config->pin_vsync; - io_conf.mode = GPIO_MODE_INPUT; - io_conf.pull_up_en = 1; - io_conf.pull_down_en = 0; - gpio_config(&io_conf); - gpio_install_isr_service(ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM); - gpio_isr_handler_add(config->pin_vsync, ll_cam_vsync_isr, cam); - gpio_intr_disable(config->pin_vsync); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_pclk], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_pclk, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_pclk, GPIO_FLOATING); - gpio_matrix_in(config->pin_pclk, I2S0I_WS_IN_IDX, false); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_vsync], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_vsync, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_vsync, GPIO_FLOATING); - gpio_matrix_in(config->pin_vsync, I2S0I_V_SYNC_IDX, cam->vsync_invert); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_href], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_href, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_href, GPIO_FLOATING); - gpio_matrix_in(config->pin_href, I2S0I_H_SYNC_IDX, false); - - int data_pins[8] = { - config->pin_d0, config->pin_d1, config->pin_d2, config->pin_d3, config->pin_d4, config->pin_d5, config->pin_d6, config->pin_d7, - }; - for (int i = 0; i < 8; i++) { - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[data_pins[i]], PIN_FUNC_GPIO); - gpio_set_direction(data_pins[i], GPIO_MODE_INPUT); - gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); - // High bit alignment, IN16 is always the highest bit - // fifo accesses data by bit, when rx_bits_mod is 8, the data needs to be aligned by 8 bits - gpio_matrix_in(data_pins[i], I2S0I_DATA_IN0_IDX + 8 + i, false); - } - - gpio_matrix_in(0x38, I2S0I_H_ENABLE_IDX, false); - - return ESP_OK; -} - -esp_err_t ll_cam_init_isr(cam_obj_t *cam) -{ - return esp_intr_alloc(ETS_I2S0_INTR_SOURCE, ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM, ll_cam_dma_isr, cam, &cam->cam_intr_handle); -} - -void ll_cam_do_vsync(cam_obj_t *cam) -{ - ll_cam_vsync_intr_enable(cam, false); - gpio_matrix_in(cam->vsync_pin, I2S0I_V_SYNC_IDX, !cam->vsync_invert); - ets_delay_us(10); - gpio_matrix_in(cam->vsync_pin, I2S0I_V_SYNC_IDX, cam->vsync_invert); - ll_cam_vsync_intr_enable(cam, true); -} - -uint8_t ll_cam_get_dma_align(cam_obj_t *cam) -{ - return 64;//16 << I2S0.lc_conf.ext_mem_bk_size; -} - -static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ - size_t node_max = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE / cam->dma_bytes_per_item; - size_t line_width = cam->width * cam->in_bytes_per_pixel; - size_t node_size = node_max; - size_t nodes_per_line = 1; - size_t lines_per_node = 1; - - // Calculate DMA Node Size so that it's divisable by or divisor of the line width - if(line_width >= node_max){ - // One or more nodes will be requied for one line - for(size_t i = node_max; i > 0; i=i-1){ - if ((line_width % i) == 0) { - node_size = i; - nodes_per_line = line_width / node_size; - break; - } - } - } else { - // One or more lines can fit into one node - for(size_t i = node_max; i > 0; i=i-1){ - if ((i % line_width) == 0) { - node_size = i; - lines_per_node = node_size / line_width; - while((cam->height % lines_per_node) != 0){ - lines_per_node = lines_per_node - 1; - node_size = lines_per_node * line_width; - } - break; - } - } - } - - ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", - node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node); - - cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; - - if (cam->psram_mode) { - cam->dma_buffer_size = cam->recv_size * cam->dma_bytes_per_item; - cam->dma_half_buffer_cnt = 2; - cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt; - } else { - size_t dma_half_buffer_max = CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX / 2 / cam->dma_bytes_per_item; - if (line_width > dma_half_buffer_max) { - ESP_LOGE(TAG, "Resolution too high"); - return 0; - } - - // Calculate minimum EOF size = max(mode_size, line_size) - size_t dma_half_buffer_min = node_size * nodes_per_line; - - // Calculate max EOF size divisable by node size - size_t dma_half_buffer = (dma_half_buffer_max / dma_half_buffer_min) * dma_half_buffer_min; - - // Adjust EOF size so that height will be divisable by the number of lines in each EOF - size_t lines_per_half_buffer = dma_half_buffer / line_width; - while((cam->height % lines_per_half_buffer) != 0){ - dma_half_buffer = dma_half_buffer - dma_half_buffer_min; - lines_per_half_buffer = dma_half_buffer / line_width; - } - - // Calculate DMA size - size_t dma_buffer_max = 2 * dma_half_buffer_max; - size_t dma_buffer_size = dma_buffer_max; - dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; - - ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", - dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item); - - cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; - cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; - cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; - } - return 1; -} - -bool ll_cam_dma_sizes(cam_obj_t *cam) -{ - cam->dma_bytes_per_item = 1; - if (cam->jpeg_mode) { - if (cam->psram_mode) { - cam->dma_buffer_size = cam->recv_size; - cam->dma_half_buffer_size = 1024; - cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; - cam->dma_node_buffer_size = cam->dma_half_buffer_size; - } else { - cam->dma_half_buffer_cnt = 16; - cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024; - cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt; - cam->dma_node_buffer_size = cam->dma_half_buffer_size; - } - } else { - return ll_cam_calc_rgb_dma(cam); - } - return 1; -} - -size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len) -{ - // YUV to Grayscale - if (cam->in_bytes_per_pixel == 2 && cam->fb_bytes_per_pixel == 1) { - size_t end = len / 8; - for (size_t i = 0; i < end; ++i) { - out[0] = in[0]; - out[1] = in[2]; - out[2] = in[4]; - out[3] = in[6]; - out += 4; - in += 8; - } - return len / 2; - } - - // just memcpy - memcpy(out, in, len); - return len; -} - -esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid) -{ - if (pix_format == PIXFORMAT_GRAYSCALE) { - if (sensor_pid == OV3660_PID || sensor_pid == OV5640_PID || sensor_pid == NT99141_PID) { - cam->in_bytes_per_pixel = 1; // camera sends Y8 - } else { - cam->in_bytes_per_pixel = 2; // camera sends YU/YV - } - cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 - } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { - cam->in_bytes_per_pixel = 2; // camera sends YU/YV - cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 - } else if (pix_format == PIXFORMAT_JPEG) { - cam->in_bytes_per_pixel = 1; - cam->fb_bytes_per_pixel = 1; - } else { - ESP_LOGE(TAG, "Requested format is not supported"); - return ESP_ERR_NOT_SUPPORTED; - } - return ESP_OK; -} diff --git a/lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h b/lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h deleted file mode 100644 index 31fbc97cc..000000000 --- a/lib/libesp32_div/esp32-camera/target/esp32s2/private_include/tjpgd.h +++ /dev/null @@ -1,99 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ TJpgDec - Tiny JPEG Decompressor include file (C)ChaN, 2012 -/----------------------------------------------------------------------------*/ -#ifndef _TJPGDEC -#define _TJPGDEC -/*---------------------------------------------------------------------------*/ -/* System Configurations */ - -#define JD_SZBUF 512 /* Size of stream input buffer */ -#define JD_FORMAT 0 /* Output pixel format 0:RGB888 (3 BYTE/pix), 1:RGB565 (1 WORD/pix) */ -#define JD_USE_SCALE 1 /* Use descaling feature for output */ -#define JD_TBLCLIP 1 /* Use table for saturation (might be a bit faster but increases 1K bytes of code size) */ - -/*---------------------------------------------------------------------------*/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* These types must be 16-bit, 32-bit or larger integer */ -typedef int INT; -typedef unsigned int UINT; - -/* These types must be 8-bit integer */ -typedef char CHAR; -typedef unsigned char UCHAR; -typedef unsigned char BYTE; - -/* These types must be 16-bit integer */ -typedef short SHORT; -typedef unsigned short USHORT; -typedef unsigned short WORD; -typedef unsigned short WCHAR; - -/* These types must be 32-bit integer */ -typedef long LONG; -typedef unsigned long ULONG; -typedef unsigned long DWORD; - - -/* Error code */ -typedef enum { - JDR_OK = 0, /* 0: Succeeded */ - JDR_INTR, /* 1: Interrupted by output function */ - JDR_INP, /* 2: Device error or wrong termination of input stream */ - JDR_MEM1, /* 3: Insufficient memory pool for the image */ - JDR_MEM2, /* 4: Insufficient stream input buffer */ - JDR_PAR, /* 5: Parameter error */ - JDR_FMT1, /* 6: Data format error (may be damaged data) */ - JDR_FMT2, /* 7: Right format but not supported */ - JDR_FMT3 /* 8: Not supported JPEG standard */ -} JRESULT; - - - -/* Rectangular structure */ -typedef struct { - WORD left, right, top, bottom; -} JRECT; - - - -/* Decompressor object structure */ -typedef struct JDEC JDEC; -struct JDEC { - UINT dctr; /* Number of bytes available in the input buffer */ - BYTE* dptr; /* Current data read ptr */ - BYTE* inbuf; /* Bit stream input buffer */ - BYTE dmsk; /* Current bit in the current read byte */ - BYTE scale; /* Output scaling ratio */ - BYTE msx, msy; /* MCU size in unit of block (width, height) */ - BYTE qtid[3]; /* Quantization table ID of each component */ - SHORT dcv[3]; /* Previous DC element of each component */ - WORD nrst; /* Restart inverval */ - UINT width, height; /* Size of the input image (pixel) */ - BYTE* huffbits[2][2]; /* Huffman bit distribution tables [id][dcac] */ - WORD* huffcode[2][2]; /* Huffman code word tables [id][dcac] */ - BYTE* huffdata[2][2]; /* Huffman decoded data tables [id][dcac] */ - LONG* qttbl[4]; /* Dequaitizer tables [id] */ - void* workbuf; /* Working buffer for IDCT and RGB output */ - BYTE* mcubuf; /* Working buffer for the MCU */ - void* pool; /* Pointer to available memory pool */ - UINT sz_pool; /* Size of momory pool (bytes available) */ - UINT (*infunc)(JDEC*, BYTE*, UINT);/* Pointer to jpeg stream input function */ - void* device; /* Pointer to I/O device identifiler for the session */ -}; - - - -/* TJpgDec API functions */ -JRESULT jd_prepare (JDEC*, UINT(*)(JDEC*,BYTE*,UINT), void*, UINT, void*); -JRESULT jd_decomp (JDEC*, UINT(*)(JDEC*,void*,JRECT*), BYTE); - - -#ifdef __cplusplus -} -#endif - -#endif /* _TJPGDEC */ diff --git a/lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c b/lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c deleted file mode 100644 index 5a983c4c7..000000000 --- a/lib/libesp32_div/esp32-camera/target/esp32s2/tjpgd.c +++ /dev/null @@ -1,970 +0,0 @@ -/*----------------------------------------------------------------------------/ -/ TJpgDec - Tiny JPEG Decompressor R0.01b (C)ChaN, 2012 -/-----------------------------------------------------------------------------/ -/ The TJpgDec is a generic JPEG decompressor module for tiny embedded systems. -/ This is a free software that opened for education, research and commercial -/ developments under license policy of following terms. -/ -/ Copyright (C) 2012, ChaN, all right reserved. -/ -/ * The TJpgDec module is a free software and there is NO WARRANTY. -/ * No restriction on use. You can use, modify and redistribute it for -/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY. -/ * Redistributions of source code must retain the above copyright notice. -/ -/-----------------------------------------------------------------------------/ -/ Oct 04,'11 R0.01 First release. -/ Feb 19,'12 R0.01a Fixed decompression fails when scan starts with an escape seq. -/ Sep 03,'12 R0.01b Added JD_TBLCLIP option. -/----------------------------------------------------------------------------*/ - -#include "tjpgd.h" - -#define SUPPORT_JPEG 1 - -#ifdef SUPPORT_JPEG -/*-----------------------------------------------*/ -/* Zigzag-order to raster-order conversion table */ -/*-----------------------------------------------*/ - -#define ZIG(n) Zig[n] - -static -const BYTE Zig[64] = { /* Zigzag-order to raster-order conversion table */ - 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, - 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, - 35, 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, - 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 -}; - - - -/*-------------------------------------------------*/ -/* Input scale factor of Arai algorithm */ -/* (scaled up 16 bits for fixed point operations) */ -/*-------------------------------------------------*/ - -#define IPSF(n) Ipsf[n] - -static -const WORD Ipsf[64] = { /* See also aa_idct.png */ - (WORD)(1.00000*8192), (WORD)(1.38704*8192), (WORD)(1.30656*8192), (WORD)(1.17588*8192), (WORD)(1.00000*8192), (WORD)(0.78570*8192), (WORD)(0.54120*8192), (WORD)(0.27590*8192), - (WORD)(1.38704*8192), (WORD)(1.92388*8192), (WORD)(1.81226*8192), (WORD)(1.63099*8192), (WORD)(1.38704*8192), (WORD)(1.08979*8192), (WORD)(0.75066*8192), (WORD)(0.38268*8192), - (WORD)(1.30656*8192), (WORD)(1.81226*8192), (WORD)(1.70711*8192), (WORD)(1.53636*8192), (WORD)(1.30656*8192), (WORD)(1.02656*8192), (WORD)(0.70711*8192), (WORD)(0.36048*8192), - (WORD)(1.17588*8192), (WORD)(1.63099*8192), (WORD)(1.53636*8192), (WORD)(1.38268*8192), (WORD)(1.17588*8192), (WORD)(0.92388*8192), (WORD)(0.63638*8192), (WORD)(0.32442*8192), - (WORD)(1.00000*8192), (WORD)(1.38704*8192), (WORD)(1.30656*8192), (WORD)(1.17588*8192), (WORD)(1.00000*8192), (WORD)(0.78570*8192), (WORD)(0.54120*8192), (WORD)(0.27590*8192), - (WORD)(0.78570*8192), (WORD)(1.08979*8192), (WORD)(1.02656*8192), (WORD)(0.92388*8192), (WORD)(0.78570*8192), (WORD)(0.61732*8192), (WORD)(0.42522*8192), (WORD)(0.21677*8192), - (WORD)(0.54120*8192), (WORD)(0.75066*8192), (WORD)(0.70711*8192), (WORD)(0.63638*8192), (WORD)(0.54120*8192), (WORD)(0.42522*8192), (WORD)(0.29290*8192), (WORD)(0.14932*8192), - (WORD)(0.27590*8192), (WORD)(0.38268*8192), (WORD)(0.36048*8192), (WORD)(0.32442*8192), (WORD)(0.27590*8192), (WORD)(0.21678*8192), (WORD)(0.14932*8192), (WORD)(0.07612*8192) -}; - - - -/*---------------------------------------------*/ -/* Conversion table for fast clipping process */ -/*---------------------------------------------*/ - -#if JD_TBLCLIP - -#define BYTECLIP(v) Clip8[(UINT)(v) & 0x3FF] - -static -const BYTE Clip8[1024] = { - /* 0..255 */ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, - 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, - 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, - 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 256..511 */ - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, - /* -512..-257 */ - 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -#else /* JD_TBLCLIP */ - -inline -BYTE BYTECLIP ( - INT val -) -{ - if (val < 0) val = 0; - if (val > 255) val = 255; - - return (BYTE)val; -} - -#endif - - - -/*-----------------------------------------------------------------------*/ -/* Allocate a memory block from memory pool */ -/*-----------------------------------------------------------------------*/ - -static -void* alloc_pool ( /* Pointer to allocated memory block (NULL:no memory available) */ - JDEC* jd, /* Pointer to the decompressor object */ - UINT nd /* Number of bytes to allocate */ -) -{ - char *rp = 0; - - - nd = (nd + 3) & ~3; /* Align block size to the word boundary */ - - if (jd->sz_pool >= nd) { - jd->sz_pool -= nd; - rp = (char*)jd->pool; /* Get start of available memory pool */ - jd->pool = (void*)(rp + nd); /* Allocate requierd bytes */ - } - - return (void*)rp; /* Return allocated memory block (NULL:no memory to allocate) */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create de-quantization and prescaling tables with a DQT segment */ -/*-----------------------------------------------------------------------*/ - -static -UINT create_qt_tbl ( /* 0:OK, !0:Failed */ - JDEC* jd, /* Pointer to the decompressor object */ - const BYTE* data, /* Pointer to the quantizer tables */ - UINT ndata /* Size of input data */ -) -{ - UINT i; - BYTE d, z; - LONG *pb; - - - while (ndata) { /* Process all tables in the segment */ - if (ndata < 65) return JDR_FMT1; /* Err: table size is unaligned */ - ndata -= 65; - d = *data++; /* Get table property */ - if (d & 0xF0) return JDR_FMT1; /* Err: not 8-bit resolution */ - i = d & 3; /* Get table ID */ - pb = alloc_pool(jd, 64 * sizeof (LONG));/* Allocate a memory block for the table */ - if (!pb) return JDR_MEM1; /* Err: not enough memory */ - jd->qttbl[i] = pb; /* Register the table */ - for (i = 0; i < 64; i++) { /* Load the table */ - z = ZIG(i); /* Zigzag-order to raster-order conversion */ - pb[z] = (LONG)((DWORD)*data++ * IPSF(z)); /* Apply scale factor of Arai algorithm to the de-quantizers */ - } - } - - return JDR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Create huffman code tables with a DHT segment */ -/*-----------------------------------------------------------------------*/ - -static -UINT create_huffman_tbl ( /* 0:OK, !0:Failed */ - JDEC* jd, /* Pointer to the decompressor object */ - const BYTE* data, /* Pointer to the packed huffman tables */ - UINT ndata /* Size of input data */ -) -{ - UINT i, j, b, np, cls, num; - BYTE d, *pb, *pd; - WORD hc, *ph; - - - while (ndata) { /* Process all tables in the segment */ - if (ndata < 17) return JDR_FMT1; /* Err: wrong data size */ - ndata -= 17; - d = *data++; /* Get table number and class */ - cls = (d >> 4); num = d & 0x0F; /* class = dc(0)/ac(1), table number = 0/1 */ - if (d & 0xEE) return JDR_FMT1; /* Err: invalid class/number */ - pb = alloc_pool(jd, 16); /* Allocate a memory block for the bit distribution table */ - if (!pb) return JDR_MEM1; /* Err: not enough memory */ - jd->huffbits[num][cls] = pb; - for (np = i = 0; i < 16; i++) { /* Load number of patterns for 1 to 16-bit code */ - pb[i] = b = *data++; - np += b; /* Get sum of code words for each code */ - } - - ph = alloc_pool(jd, np * sizeof (WORD));/* Allocate a memory block for the code word table */ - if (!ph) return JDR_MEM1; /* Err: not enough memory */ - jd->huffcode[num][cls] = ph; - hc = 0; - for (j = i = 0; i < 16; i++) { /* Re-build huffman code word table */ - b = pb[i]; - while (b--) ph[j++] = hc++; - hc <<= 1; - } - - if (ndata < np) return JDR_FMT1; /* Err: wrong data size */ - ndata -= np; - pd = alloc_pool(jd, np); /* Allocate a memory block for the decoded data */ - if (!pd) return JDR_MEM1; /* Err: not enough memory */ - jd->huffdata[num][cls] = pd; - for (i = 0; i < np; i++) { /* Load decoded data corresponds to each code ward */ - d = *data++; - if (!cls && d > 11) return JDR_FMT1; - *pd++ = d; - } - } - - return JDR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Extract N bits from input stream */ -/*-----------------------------------------------------------------------*/ - -static -INT bitext ( /* >=0: extracted data, <0: error code */ - JDEC* jd, /* Pointer to the decompressor object */ - UINT nbit /* Number of bits to extract (1 to 11) */ -) -{ - BYTE msk, s, *dp; - UINT dc, v, f; - - - msk = jd->dmsk; dc = jd->dctr; dp = jd->dptr; /* Bit mask, number of data available, read ptr */ - s = *dp; v = f = 0; - do { - if (!msk) { /* Next byte? */ - if (!dc) { /* No input data is available, re-fill input buffer */ - dp = jd->inbuf; /* Top of input buffer */ - dc = jd->infunc(jd, dp, JD_SZBUF); - if (!dc) return 0 - (INT)JDR_INP; /* Err: read error or wrong stream termination */ - } else { - dp++; /* Next data ptr */ - } - dc--; /* Decrement number of available bytes */ - if (f) { /* In flag sequence? */ - f = 0; /* Exit flag sequence */ - if (*dp != 0) return 0 - (INT)JDR_FMT1; /* Err: unexpected flag is detected (may be collapted data) */ - *dp = s = 0xFF; /* The flag is a data 0xFF */ - } else { - s = *dp; /* Get next data byte */ - if (s == 0xFF) { /* Is start of flag sequence? */ - f = 1; continue; /* Enter flag sequence */ - } - } - msk = 0x80; /* Read from MSB */ - } - v <<= 1; /* Get a bit */ - if (s & msk) v++; - msk >>= 1; - nbit--; - } while (nbit); - jd->dmsk = msk; jd->dctr = dc; jd->dptr = dp; - - return (INT)v; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Extract a huffman decoded data from input stream */ -/*-----------------------------------------------------------------------*/ - -static -INT huffext ( /* >=0: decoded data, <0: error code */ - JDEC* jd, /* Pointer to the decompressor object */ - const BYTE* hbits, /* Pointer to the bit distribution table */ - const WORD* hcode, /* Pointer to the code word table */ - const BYTE* hdata /* Pointer to the data table */ -) -{ - BYTE msk, s, *dp; - UINT dc, v, f, bl, nd; - - - msk = jd->dmsk; dc = jd->dctr; dp = jd->dptr; /* Bit mask, number of data available, read ptr */ - s = *dp; v = f = 0; - bl = 16; /* Max code length */ - do { - if (!msk) { /* Next byte? */ - if (!dc) { /* No input data is available, re-fill input buffer */ - dp = jd->inbuf; /* Top of input buffer */ - dc = jd->infunc(jd, dp, JD_SZBUF); - if (!dc) return 0 - (INT)JDR_INP; /* Err: read error or wrong stream termination */ - } else { - dp++; /* Next data ptr */ - } - dc--; /* Decrement number of available bytes */ - if (f) { /* In flag sequence? */ - f = 0; /* Exit flag sequence */ - if (*dp != 0) - return 0 - (INT)JDR_FMT1; /* Err: unexpected flag is detected (may be collapted data) */ - *dp = s = 0xFF; /* The flag is a data 0xFF */ - } else { - s = *dp; /* Get next data byte */ - if (s == 0xFF) { /* Is start of flag sequence? */ - f = 1; continue; /* Enter flag sequence, get trailing byte */ - } - } - msk = 0x80; /* Read from MSB */ - } - v <<= 1; /* Get a bit */ - if (s & msk) v++; - msk >>= 1; - - for (nd = *hbits++; nd; nd--) { /* Search the code word in this bit length */ - if (v == *hcode++) { /* Matched? */ - jd->dmsk = msk; jd->dctr = dc; jd->dptr = dp; - return *hdata; /* Return the decoded data */ - } - hdata++; - } - bl--; - } while (bl); - - return 0 - (INT)JDR_FMT1; /* Err: code not found (may be collapted data) */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Apply Inverse-DCT in Arai Algorithm (see also aa_idct.png) */ -/*-----------------------------------------------------------------------*/ - -static -void block_idct ( - LONG* src, /* Input block data (de-quantized and pre-scaled for Arai Algorithm) */ - BYTE* dst /* Pointer to the destination to store the block as byte array */ -) -{ - const LONG M13 = (LONG)(1.41421*4096), M2 = (LONG)(1.08239*4096), M4 = (LONG)(2.61313*4096), M5 = (LONG)(1.84776*4096); - LONG v0, v1, v2, v3, v4, v5, v6, v7; - LONG t10, t11, t12, t13; - UINT i; - - /* Process columns */ - for (i = 0; i < 8; i++) { - v0 = src[8 * 0]; /* Get even elements */ - v1 = src[8 * 2]; - v2 = src[8 * 4]; - v3 = src[8 * 6]; - - t10 = v0 + v2; /* Process the even elements */ - t12 = v0 - v2; - t11 = (v1 - v3) * M13 >> 12; - v3 += v1; - t11 -= v3; - v0 = t10 + v3; - v3 = t10 - v3; - v1 = t11 + t12; - v2 = t12 - t11; - - v4 = src[8 * 7]; /* Get odd elements */ - v5 = src[8 * 1]; - v6 = src[8 * 5]; - v7 = src[8 * 3]; - - t10 = v5 - v4; /* Process the odd elements */ - t11 = v5 + v4; - t12 = v6 - v7; - v7 += v6; - v5 = (t11 - v7) * M13 >> 12; - v7 += t11; - t13 = (t10 + t12) * M5 >> 12; - v4 = t13 - (t10 * M2 >> 12); - v6 = t13 - (t12 * M4 >> 12) - v7; - v5 -= v6; - v4 -= v5; - - src[8 * 0] = v0 + v7; /* Write-back transformed values */ - src[8 * 7] = v0 - v7; - src[8 * 1] = v1 + v6; - src[8 * 6] = v1 - v6; - src[8 * 2] = v2 + v5; - src[8 * 5] = v2 - v5; - src[8 * 3] = v3 + v4; - src[8 * 4] = v3 - v4; - - src++; /* Next column */ - } - - /* Process rows */ - src -= 8; - for (i = 0; i < 8; i++) { - v0 = src[0] + (128L << 8); /* Get even elements (remove DC offset (-128) here) */ - v1 = src[2]; - v2 = src[4]; - v3 = src[6]; - - t10 = v0 + v2; /* Process the even elements */ - t12 = v0 - v2; - t11 = (v1 - v3) * M13 >> 12; - v3 += v1; - t11 -= v3; - v0 = t10 + v3; - v3 = t10 - v3; - v1 = t11 + t12; - v2 = t12 - t11; - - v4 = src[7]; /* Get odd elements */ - v5 = src[1]; - v6 = src[5]; - v7 = src[3]; - - t10 = v5 - v4; /* Process the odd elements */ - t11 = v5 + v4; - t12 = v6 - v7; - v7 += v6; - v5 = (t11 - v7) * M13 >> 12; - v7 += t11; - t13 = (t10 + t12) * M5 >> 12; - v4 = t13 - (t10 * M2 >> 12); - v6 = t13 - (t12 * M4 >> 12) - v7; - v5 -= v6; - v4 -= v5; - - dst[0] = BYTECLIP((v0 + v7) >> 8); /* Descale the transformed values 8 bits and output */ - dst[7] = BYTECLIP((v0 - v7) >> 8); - dst[1] = BYTECLIP((v1 + v6) >> 8); - dst[6] = BYTECLIP((v1 - v6) >> 8); - dst[2] = BYTECLIP((v2 + v5) >> 8); - dst[5] = BYTECLIP((v2 - v5) >> 8); - dst[3] = BYTECLIP((v3 + v4) >> 8); - dst[4] = BYTECLIP((v3 - v4) >> 8); - dst += 8; - - src += 8; /* Next row */ - } -} - - - - -/*-----------------------------------------------------------------------*/ -/* Load all blocks in the MCU into working buffer */ -/*-----------------------------------------------------------------------*/ - -static -JRESULT mcu_load ( - JDEC* jd /* Pointer to the decompressor object */ -) -{ - LONG *tmp = (LONG*)jd->workbuf; /* Block working buffer for de-quantize and IDCT */ - UINT blk, nby, nbc, i, z, id, cmp; - INT b, d, e; - BYTE *bp; - const BYTE *hb, *hd; - const WORD *hc; - const LONG *dqf; - - - nby = jd->msx * jd->msy; /* Number of Y blocks (1, 2 or 4) */ - nbc = 2; /* Number of C blocks (2) */ - bp = jd->mcubuf; /* Pointer to the first block */ - - for (blk = 0; blk < nby + nbc; blk++) { - cmp = (blk < nby) ? 0 : blk - nby + 1; /* Component number 0:Y, 1:Cb, 2:Cr */ - id = cmp ? 1 : 0; /* Huffman table ID of the component */ - - /* Extract a DC element from input stream */ - hb = jd->huffbits[id][0]; /* Huffman table for the DC element */ - hc = jd->huffcode[id][0]; - hd = jd->huffdata[id][0]; - b = huffext(jd, hb, hc, hd); /* Extract a huffman coded data (bit length) */ - if (b < 0) return 0 - b; /* Err: invalid code or input */ - d = jd->dcv[cmp]; /* DC value of previous block */ - if (b) { /* If there is any difference from previous block */ - e = bitext(jd, b); /* Extract data bits */ - if (e < 0) return 0 - e; /* Err: input */ - b = 1 << (b - 1); /* MSB position */ - if (!(e & b)) e -= (b << 1) - 1; /* Restore sign if needed */ - d += e; /* Get current value */ - jd->dcv[cmp] = (SHORT)d; /* Save current DC value for next block */ - } - dqf = jd->qttbl[jd->qtid[cmp]]; /* De-quantizer table ID for this component */ - tmp[0] = d * dqf[0] >> 8; /* De-quantize, apply scale factor of Arai algorithm and descale 8 bits */ - - /* Extract following 63 AC elements from input stream */ - for (i = 1; i < 64; i++) tmp[i] = 0; /* Clear rest of elements */ - hb = jd->huffbits[id][1]; /* Huffman table for the AC elements */ - hc = jd->huffcode[id][1]; - hd = jd->huffdata[id][1]; - i = 1; /* Top of the AC elements */ - do { - b = huffext(jd, hb, hc, hd); /* Extract a huffman coded value (zero runs and bit length) */ - if (b == 0) break; /* EOB? */ - if (b < 0) return 0 - b; /* Err: invalid code or input error */ - z = (UINT)b >> 4; /* Number of leading zero elements */ - if (z) { - i += z; /* Skip zero elements */ - if (i >= 64) return JDR_FMT1; /* Too long zero run */ - } - if (b &= 0x0F) { /* Bit length */ - d = bitext(jd, b); /* Extract data bits */ - if (d < 0) return 0 - d; /* Err: input device */ - b = 1 << (b - 1); /* MSB position */ - if (!(d & b)) d -= (b << 1) - 1;/* Restore negative value if needed */ - z = ZIG(i); /* Zigzag-order to raster-order converted index */ - tmp[z] = d * dqf[z] >> 8; /* De-quantize, apply scale factor of Arai algorithm and descale 8 bits */ - } - } while (++i < 64); /* Next AC element */ - - if (JD_USE_SCALE && jd->scale == 3) - *bp = (*tmp / 256) + 128; /* If scale ratio is 1/8, IDCT can be ommited and only DC element is used */ - else - block_idct(tmp, bp); /* Apply IDCT and store the block to the MCU buffer */ - - bp += 64; /* Next block */ - } - - return JDR_OK; /* All blocks have been loaded successfully */ -} - - - - -/*-----------------------------------------------------------------------*/ -/* Output an MCU: Convert YCrCb to RGB and output it in RGB form */ -/*-----------------------------------------------------------------------*/ - -static -JRESULT mcu_output ( - JDEC* jd, /* Pointer to the decompressor object */ - UINT (*outfunc)(JDEC*, void*, JRECT*), /* RGB output function */ - UINT x, /* MCU position in the image (left of the MCU) */ - UINT y /* MCU position in the image (top of the MCU) */ -) -{ - const INT CVACC = (sizeof (INT) > 2) ? 1024 : 128; - UINT ix, iy, mx, my, rx, ry; - INT yy, cb, cr; - BYTE *py, *pc, *rgb24; - JRECT rect; - - - mx = jd->msx * 8; my = jd->msy * 8; /* MCU size (pixel) */ - rx = (x + mx <= jd->width) ? mx : jd->width - x; /* Output rectangular size (it may be clipped at right/bottom end) */ - ry = (y + my <= jd->height) ? my : jd->height - y; - if (JD_USE_SCALE) { - rx >>= jd->scale; ry >>= jd->scale; - if (!rx || !ry) return JDR_OK; /* Skip this MCU if all pixel is to be rounded off */ - x >>= jd->scale; y >>= jd->scale; - } - rect.left = x; rect.right = x + rx - 1; /* Rectangular area in the frame buffer */ - rect.top = y; rect.bottom = y + ry - 1; - - - if (!JD_USE_SCALE || jd->scale != 3) { /* Not for 1/8 scaling */ - - /* Build an RGB MCU from discrete comopnents */ - rgb24 = (BYTE*)jd->workbuf; - for (iy = 0; iy < my; iy++) { - pc = jd->mcubuf; - py = pc + iy * 8; - if (my == 16) { /* Double block height? */ - pc += 64 * 4 + (iy >> 1) * 8; - if (iy >= 8) py += 64; - } else { /* Single block height */ - pc += mx * 8 + iy * 8; - } - for (ix = 0; ix < mx; ix++) { - cb = pc[0] - 128; /* Get Cb/Cr component and restore right level */ - cr = pc[64] - 128; - if (mx == 16) { /* Double block width? */ - if (ix == 8) py += 64 - 8; /* Jump to next block if double block heigt */ - pc += ix & 1; /* Increase chroma pointer every two pixels */ - } else { /* Single block width */ - pc++; /* Increase chroma pointer every pixel */ - } - yy = *py++; /* Get Y component */ - - /* Convert YCbCr to RGB */ - *rgb24++ = /* R */ BYTECLIP(yy + ((INT)(1.402 * CVACC) * cr) / CVACC); - *rgb24++ = /* G */ BYTECLIP(yy - ((INT)(0.344 * CVACC) * cb + (INT)(0.714 * CVACC) * cr) / CVACC); - *rgb24++ = /* B */ BYTECLIP(yy + ((INT)(1.772 * CVACC) * cb) / CVACC); - } - } - - /* Descale the MCU rectangular if needed */ - if (JD_USE_SCALE && jd->scale) { - UINT x, y, r, g, b, s, w, a; - BYTE *op; - - /* Get averaged RGB value of each square correcponds to a pixel */ - s = jd->scale * 2; /* Bumber of shifts for averaging */ - w = 1 << jd->scale; /* Width of square */ - a = (mx - w) * 3; /* Bytes to skip for next line in the square */ - op = (BYTE*)jd->workbuf; - for (iy = 0; iy < my; iy += w) { - for (ix = 0; ix < mx; ix += w) { - rgb24 = (BYTE*)jd->workbuf + (iy * mx + ix) * 3; - r = g = b = 0; - for (y = 0; y < w; y++) { /* Accumulate RGB value in the square */ - for (x = 0; x < w; x++) { - r += *rgb24++; - g += *rgb24++; - b += *rgb24++; - } - rgb24 += a; - } /* Put the averaged RGB value as a pixel */ - *op++ = (BYTE)(r >> s); - *op++ = (BYTE)(g >> s); - *op++ = (BYTE)(b >> s); - } - } - } - - } else { /* For only 1/8 scaling (left-top pixel in each block are the DC value of the block) */ - - /* Build a 1/8 descaled RGB MCU from discrete comopnents */ - rgb24 = (BYTE*)jd->workbuf; - pc = jd->mcubuf + mx * my; - cb = pc[0] - 128; /* Get Cb/Cr component and restore right level */ - cr = pc[64] - 128; - for (iy = 0; iy < my; iy += 8) { - py = jd->mcubuf; - if (iy == 8) py += 64 * 2; - for (ix = 0; ix < mx; ix += 8) { - yy = *py; /* Get Y component */ - py += 64; - - /* Convert YCbCr to RGB */ - *rgb24++ = /* R */ BYTECLIP(yy + ((INT)(1.402 * CVACC) * cr / CVACC)); - *rgb24++ = /* G */ BYTECLIP(yy - ((INT)(0.344 * CVACC) * cb + (INT)(0.714 * CVACC) * cr) / CVACC); - *rgb24++ = /* B */ BYTECLIP(yy + ((INT)(1.772 * CVACC) * cb / CVACC)); - } - } - } - - /* Squeeze up pixel table if a part of MCU is to be truncated */ - mx >>= jd->scale; - if (rx < mx) { - BYTE *s, *d; - UINT x, y; - - s = d = (BYTE*)jd->workbuf; - for (y = 0; y < ry; y++) { - for (x = 0; x < rx; x++) { /* Copy effective pixels */ - *d++ = *s++; - *d++ = *s++; - *d++ = *s++; - } - s += (mx - rx) * 3; /* Skip truncated pixels */ - } - } - - /* Convert RGB888 to RGB565 if needed */ - if (JD_FORMAT == 1) { - BYTE *s = (BYTE*)jd->workbuf; - WORD w, *d = (WORD*)s; - UINT n = rx * ry; - - do { - w = (*s++ & 0xF8) << 8; /* RRRRR----------- */ - w |= (*s++ & 0xFC) << 3; /* -----GGGGGG----- */ - w |= *s++ >> 3; /* -----------BBBBB */ - *d++ = w; - } while (--n); - } - - /* Output the RGB rectangular */ - return outfunc(jd, jd->workbuf, &rect) ? JDR_OK : JDR_INTR; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Process restart interval */ -/*-----------------------------------------------------------------------*/ - -static -JRESULT restart ( - JDEC* jd, /* Pointer to the decompressor object */ - WORD rstn /* Expected restert sequense number */ -) -{ - UINT i, dc; - WORD d; - BYTE *dp; - - - /* Discard padding bits and get two bytes from the input stream */ - dp = jd->dptr; dc = jd->dctr; - d = 0; - for (i = 0; i < 2; i++) { - if (!dc) { /* No input data is available, re-fill input buffer */ - dp = jd->inbuf; - dc = jd->infunc(jd, dp, JD_SZBUF); - if (!dc) return JDR_INP; - } else { - dp++; - } - dc--; - d = (d << 8) | *dp; /* Get a byte */ - } - jd->dptr = dp; jd->dctr = dc; jd->dmsk = 0; - - /* Check the marker */ - if ((d & 0xFFD8) != 0xFFD0 || (d & 7) != (rstn & 7)) - return JDR_FMT1; /* Err: expected RSTn marker is not detected (may be collapted data) */ - - /* Reset DC offset */ - jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; - - return JDR_OK; -} - - - - -/*-----------------------------------------------------------------------*/ -/* Analyze the JPEG image and Initialize decompressor object */ -/*-----------------------------------------------------------------------*/ - -#define LDB_WORD(ptr) (WORD)(((WORD)*((BYTE*)(ptr))<<8)|(WORD)*(BYTE*)((ptr)+1)) - - -JRESULT jd_prepare ( - JDEC* jd, /* Blank decompressor object */ - UINT (*infunc)(JDEC*, BYTE*, UINT), /* JPEG strem input function */ - void* pool, /* Working buffer for the decompression session */ - UINT sz_pool, /* Size of working buffer */ - void* dev /* I/O device identifier for the session */ -) -{ - BYTE *seg, b; - WORD marker; - DWORD ofs; - UINT n, i, j, len; - JRESULT rc; - - - if (!pool) return JDR_PAR; - - jd->pool = pool; /* Work memroy */ - jd->sz_pool = sz_pool; /* Size of given work memory */ - jd->infunc = infunc; /* Stream input function */ - jd->device = dev; /* I/O device identifier */ - jd->nrst = 0; /* No restart interval (default) */ - - for (i = 0; i < 2; i++) { /* Nulls pointers */ - for (j = 0; j < 2; j++) { - jd->huffbits[i][j] = 0; - jd->huffcode[i][j] = 0; - jd->huffdata[i][j] = 0; - } - } - for (i = 0; i < 4; i++) jd->qttbl[i] = 0; - - jd->inbuf = seg = alloc_pool(jd, JD_SZBUF); /* Allocate stream input buffer */ - if (!seg) return JDR_MEM1; - - if (jd->infunc(jd, seg, 2) != 2) return JDR_INP;/* Check SOI marker */ - if (LDB_WORD(seg) != 0xFFD8) return JDR_FMT1; /* Err: SOI is not detected */ - ofs = 2; - - for (;;) { - /* Get a JPEG marker */ - if (jd->infunc(jd, seg, 4) != 4) return JDR_INP; - marker = LDB_WORD(seg); /* Marker */ - len = LDB_WORD(seg + 2); /* Length field */ - if (len <= 2 || (marker >> 8) != 0xFF) return JDR_FMT1; - len -= 2; /* Content size excluding length field */ - ofs += 4 + len; /* Number of bytes loaded */ - - switch (marker & 0xFF) { - case 0xC0: /* SOF0 (baseline JPEG) */ - /* Load segment data */ - if (len > JD_SZBUF) return JDR_MEM2; - if (jd->infunc(jd, seg, len) != len) return JDR_INP; - - jd->width = LDB_WORD(seg+3); /* Image width in unit of pixel */ - jd->height = LDB_WORD(seg+1); /* Image height in unit of pixel */ - if (seg[5] != 3) return JDR_FMT3; /* Err: Supports only Y/Cb/Cr format */ - - /* Check three image components */ - for (i = 0; i < 3; i++) { - b = seg[7 + 3 * i]; /* Get sampling factor */ - if (!i) { /* Y component */ - if (b != 0x11 && b != 0x22 && b != 0x21)/* Check sampling factor */ - return JDR_FMT3; /* Err: Supports only 4:4:4, 4:2:0 or 4:2:2 */ - jd->msx = b >> 4; jd->msy = b & 15; /* Size of MCU [blocks] */ - } else { /* Cb/Cr component */ - if (b != 0x11) return JDR_FMT3; /* Err: Sampling factor of Cr/Cb must be 1 */ - } - b = seg[8 + 3 * i]; /* Get dequantizer table ID for this component */ - if (b > 3) return JDR_FMT3; /* Err: Invalid ID */ - jd->qtid[i] = b; - } - break; - - case 0xDD: /* DRI */ - /* Load segment data */ - if (len > JD_SZBUF) return JDR_MEM2; - if (jd->infunc(jd, seg, len) != len) return JDR_INP; - - /* Get restart interval (MCUs) */ - jd->nrst = LDB_WORD(seg); - break; - - case 0xC4: /* DHT */ - /* Load segment data */ - if (len > JD_SZBUF) return JDR_MEM2; - if (jd->infunc(jd, seg, len) != len) return JDR_INP; - - /* Create huffman tables */ - rc = create_huffman_tbl(jd, seg, len); - if (rc) return rc; - break; - - case 0xDB: /* DQT */ - /* Load segment data */ - if (len > JD_SZBUF) return JDR_MEM2; - if (jd->infunc(jd, seg, len) != len) return JDR_INP; - - /* Create de-quantizer tables */ - rc = create_qt_tbl(jd, seg, len); - if (rc) return rc; - break; - - case 0xDA: /* SOS */ - /* Load segment data */ - if (len > JD_SZBUF) return JDR_MEM2; - if (jd->infunc(jd, seg, len) != len) return JDR_INP; - - if (!jd->width || !jd->height) return JDR_FMT1; /* Err: Invalid image size */ - - if (seg[0] != 3) return JDR_FMT3; /* Err: Supports only three color components format */ - - /* Check if all tables corresponding to each components have been loaded */ - for (i = 0; i < 3; i++) { - b = seg[2 + 2 * i]; /* Get huffman table ID */ - if (b != 0x00 && b != 0x11) return JDR_FMT3; /* Err: Different table number for DC/AC element */ - b = i ? 1 : 0; - if (!jd->huffbits[b][0] || !jd->huffbits[b][1]) /* Check huffman table for this component */ - return JDR_FMT1; /* Err: Huffman table not loaded */ - if (!jd->qttbl[jd->qtid[i]]) return JDR_FMT1; /* Err: Dequantizer table not loaded */ - } - - /* Allocate working buffer for MCU and RGB */ - n = jd->msy * jd->msx; /* Number of Y blocks in the MCU */ - if (!n) return JDR_FMT1; /* Err: SOF0 has not been loaded */ - len = n * 64 * 2 + 64; /* Allocate buffer for IDCT and RGB output */ - if (len < 256) len = 256; /* but at least 256 byte is required for IDCT */ - jd->workbuf = alloc_pool(jd, len); /* and it may occupy a part of following MCU working buffer for RGB output */ - if (!jd->workbuf) return JDR_MEM1; /* Err: not enough memory */ - jd->mcubuf = alloc_pool(jd, (n + 2) * 64); /* Allocate MCU working buffer */ - if (!jd->mcubuf) return JDR_MEM1; /* Err: not enough memory */ - - /* Pre-load the JPEG data to extract it from the bit stream */ - jd->dptr = seg; jd->dctr = 0; jd->dmsk = 0; /* Prepare to read bit stream */ - if (ofs %= JD_SZBUF) { /* Align read offset to JD_SZBUF */ - jd->dctr = jd->infunc(jd, seg + ofs, JD_SZBUF - (UINT)ofs); - jd->dptr = seg + ofs - 1; - } - - return JDR_OK; /* Initialization succeeded. Ready to decompress the JPEG image. */ - - case 0xC1: /* SOF1 */ - case 0xC2: /* SOF2 */ - case 0xC3: /* SOF3 */ - case 0xC5: /* SOF5 */ - case 0xC6: /* SOF6 */ - case 0xC7: /* SOF7 */ - case 0xC9: /* SOF9 */ - case 0xCA: /* SOF10 */ - case 0xCB: /* SOF11 */ - case 0xCD: /* SOF13 */ - case 0xCE: /* SOF14 */ - case 0xCF: /* SOF15 */ - case 0xD9: /* EOI */ - return JDR_FMT3; /* Unsuppoted JPEG standard (may be progressive JPEG) */ - - default: /* Unknown segment (comment, exif or etc..) */ - /* Skip segment data */ - if (jd->infunc(jd, 0, len) != len) /* Null pointer specifies to skip bytes of stream */ - return JDR_INP; - } - } -} - - - - -/*-----------------------------------------------------------------------*/ -/* Start to decompress the JPEG picture */ -/*-----------------------------------------------------------------------*/ - -JRESULT jd_decomp ( - JDEC* jd, /* Initialized decompression object */ - UINT (*outfunc)(JDEC*, void*, JRECT*), /* RGB output function */ - BYTE scale /* Output de-scaling factor (0 to 3) */ -) -{ - UINT x, y, mx, my; - WORD rst, rsc; - JRESULT rc; - - - if (scale > (JD_USE_SCALE ? 3 : 0)) return JDR_PAR; - jd->scale = scale; - - mx = jd->msx * 8; my = jd->msy * 8; /* Size of the MCU (pixel) */ - - jd->dcv[2] = jd->dcv[1] = jd->dcv[0] = 0; /* Initialize DC values */ - rst = rsc = 0; - - rc = JDR_OK; - for (y = 0; y < jd->height; y += my) { /* Vertical loop of MCUs */ - for (x = 0; x < jd->width; x += mx) { /* Horizontal loop of MCUs */ - if (jd->nrst && rst++ == jd->nrst) { /* Process restart interval if enabled */ - rc = restart(jd, rsc++); - if (rc != JDR_OK) return rc; - rst = 1; - } - rc = mcu_load(jd); /* Load an MCU (decompress huffman coded stream and apply IDCT) */ - if (rc != JDR_OK) return rc; - rc = mcu_output(jd, outfunc, x, y); /* Output the MCU (color space conversion, scaling and output) */ - if (rc != JDR_OK) return rc; - } - } - - return rc; -} -#endif//SUPPORT_JPEG - - diff --git a/lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c b/lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c deleted file mode 100644 index 9a1f185c4..000000000 --- a/lib/libesp32_div/esp32-camera/target/esp32s3/ll_cam.c +++ /dev/null @@ -1,452 +0,0 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#include -#include -#include "soc/system_reg.h" -#include "soc/lcd_cam_struct.h" -#include "soc/lcd_cam_reg.h" -#include "soc/gdma_struct.h" -#include "soc/gdma_periph.h" -#include "soc/gdma_reg.h" -#include "ll_cam.h" -#include "cam_hal.h" - -static const char *TAG = "s3 ll_cam"; - -static void IRAM_ATTR ll_cam_vsync_isr(void *arg) -{ - //DBG_PIN_SET(1); - cam_obj_t *cam = (cam_obj_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - - typeof(LCD_CAM.lc_dma_int_st) status = LCD_CAM.lc_dma_int_st; - if (status.val == 0) { - return; - } - - LCD_CAM.lc_dma_int_clr.val = status.val; - - if (status.cam_vsync_int_st) { - ll_cam_send_event(cam, CAM_VSYNC_EVENT, &HPTaskAwoken); - } - - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } - //DBG_PIN_SET(0); -} - -static void IRAM_ATTR ll_cam_dma_isr(void *arg) -{ - cam_obj_t *cam = (cam_obj_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - - typeof(GDMA.channel[cam->dma_num].in.int_st) status = GDMA.channel[cam->dma_num].in.int_st; - if (status.val == 0) { - return; - } - - GDMA.channel[cam->dma_num].in.int_clr.val = status.val; - - if (status.in_suc_eof) { - ll_cam_send_event(cam, CAM_IN_SUC_EOF_EVENT, &HPTaskAwoken); - } - - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } -} - -bool ll_cam_stop(cam_obj_t *cam) -{ - if (cam->jpeg_mode || !cam->psram_mode) { - GDMA.channel[cam->dma_num].in.int_ena.in_suc_eof = 0; - GDMA.channel[cam->dma_num].in.int_clr.in_suc_eof = 1; - } - GDMA.channel[cam->dma_num].in.link.stop = 1; - return true; -} - -esp_err_t ll_cam_deinit(cam_obj_t *cam) -{ - if (cam->cam_intr_handle) { - esp_intr_free(cam->cam_intr_handle); - cam->cam_intr_handle = NULL; - } - - if (cam->dma_intr_handle) { - esp_intr_free(cam->dma_intr_handle); - cam->dma_intr_handle = NULL; - } - GDMA.channel[cam->dma_num].in.link.addr = 0x0; - - LCD_CAM.cam_ctrl1.cam_start = 0; - LCD_CAM.cam_ctrl1.cam_reset = 1; - LCD_CAM.cam_ctrl1.cam_reset = 0; - return ESP_OK; -} - -bool ll_cam_start(cam_obj_t *cam, int frame_pos) -{ - LCD_CAM.cam_ctrl1.cam_start = 0; - - if (cam->jpeg_mode || !cam->psram_mode) { - GDMA.channel[cam->dma_num].in.int_clr.in_suc_eof = 1; - GDMA.channel[cam->dma_num].in.int_ena.in_suc_eof = 1; - } - - LCD_CAM.cam_ctrl1.cam_reset = 1; - LCD_CAM.cam_ctrl1.cam_reset = 0; - LCD_CAM.cam_ctrl1.cam_afifo_reset = 1; - LCD_CAM.cam_ctrl1.cam_afifo_reset = 0; - GDMA.channel[cam->dma_num].in.conf0.in_rst = 1; - GDMA.channel[cam->dma_num].in.conf0.in_rst = 0; - - LCD_CAM.cam_ctrl1.cam_rec_data_bytelen = cam->dma_half_buffer_size - 1; // Ping pong operation - - if (!cam->psram_mode) { - GDMA.channel[cam->dma_num].in.link.addr = ((uint32_t)&cam->dma[0]) & 0xfffff; - } else { - GDMA.channel[cam->dma_num].in.link.addr = ((uint32_t)&cam->frames[frame_pos].dma[0]) & 0xfffff; - } - - GDMA.channel[cam->dma_num].in.link.start = 1; - - LCD_CAM.cam_ctrl.cam_update = 1; - LCD_CAM.cam_ctrl1.cam_start = 1; - return true; -} - -static esp_err_t ll_cam_dma_init(cam_obj_t *cam) -{ - for (int x = (SOC_GDMA_PAIRS_PER_GROUP - 1); x >= 0; x--) { - if (GDMA.channel[x].in.link.addr == 0x0) { - cam->dma_num = x; - ESP_LOGI(TAG, "DMA Channel=%d", cam->dma_num); - break; - } - if (x == 0) { - cam_deinit(); - ESP_LOGE(TAG, "Can't found available GDMA channel"); - return ESP_FAIL; - } - } - - if (REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN) == 0) { - REG_CLR_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN); - REG_SET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_DMA_CLK_EN); - REG_SET_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST); - REG_CLR_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_DMA_RST); - } - - GDMA.channel[cam->dma_num].in.int_clr.val = ~0; - GDMA.channel[cam->dma_num].in.int_ena.val = 0; - - GDMA.channel[cam->dma_num].in.conf0.val = 0; - GDMA.channel[cam->dma_num].in.conf0.in_rst = 1; - GDMA.channel[cam->dma_num].in.conf0.in_rst = 0; - - //internal SRAM only - if (!cam->psram_mode) { - GDMA.channel[cam->dma_num].in.conf0.indscr_burst_en = 1; - GDMA.channel[cam->dma_num].in.conf0.in_data_burst_en = 1; - } - - GDMA.channel[cam->dma_num].in.conf1.in_check_owner = 0; - - GDMA.channel[cam->dma_num].in.peri_sel.sel = 5; - //GDMA.channel[cam->dma_num].in.pri.rx_pri = 1;//rx prio 0-15 - //GDMA.channel[cam->dma_num].in.sram_size.in_size = 6;//This register is used to configure the size of L2 Tx FIFO for Rx channel. 0:16 bytes, 1:24 bytes, 2:32 bytes, 3: 40 bytes, 4: 48 bytes, 5:56 bytes, 6: 64 bytes, 7: 72 bytes, 8: 80 bytes. - //GDMA.channel[cam->dma_num].in.wight.rx_weight = 7;//The weight of Rx channel 0-15 - return ESP_OK; -} - -esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config) -{ - if (REG_GET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN) == 0) { - REG_CLR_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN); - REG_SET_BIT(SYSTEM_PERIP_CLK_EN1_REG, SYSTEM_LCD_CAM_CLK_EN); - REG_SET_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_LCD_CAM_RST); - REG_CLR_BIT(SYSTEM_PERIP_RST_EN1_REG, SYSTEM_LCD_CAM_RST); - } - - LCD_CAM.cam_ctrl.val = 0; - - LCD_CAM.cam_ctrl.cam_clkm_div_b = 0; - LCD_CAM.cam_ctrl.cam_clkm_div_a = 0; - LCD_CAM.cam_ctrl.cam_clkm_div_num = 160000000 / config->xclk_freq_hz; - LCD_CAM.cam_ctrl.cam_clk_sel = 3;//Select Camera module source clock. 0: no clock. 1: APLL. 2: CLK160. 3: no clock. - - LCD_CAM.cam_ctrl.cam_stop_en = 0; - LCD_CAM.cam_ctrl.cam_vsync_filter_thres = 4; // Filter by LCD_CAM clock - LCD_CAM.cam_ctrl.cam_update = 0; - LCD_CAM.cam_ctrl.cam_byte_order = cam->swap_data; - LCD_CAM.cam_ctrl.cam_bit_order = 0; - LCD_CAM.cam_ctrl.cam_line_int_en = 0; - LCD_CAM.cam_ctrl.cam_vs_eof_en = 0; //1: CAM_VSYNC to generate in_suc_eof. 0: in_suc_eof is controlled by reg_cam_rec_data_cyclelen - - LCD_CAM.cam_ctrl1.val = 0; - LCD_CAM.cam_ctrl1.cam_rec_data_bytelen = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE - 1; // Cannot be assigned to 0, and it is easy to overflow - LCD_CAM.cam_ctrl1.cam_line_int_num = 0; // The number of hsyncs that generate hs interrupts - LCD_CAM.cam_ctrl1.cam_clk_inv = 0; - LCD_CAM.cam_ctrl1.cam_vsync_filter_en = 1; - LCD_CAM.cam_ctrl1.cam_2byte_en = 0; - LCD_CAM.cam_ctrl1.cam_de_inv = 0; - LCD_CAM.cam_ctrl1.cam_hsync_inv = 0; - LCD_CAM.cam_ctrl1.cam_vsync_inv = 0; - LCD_CAM.cam_ctrl1.cam_vh_de_mode_en = 0; - - LCD_CAM.cam_rgb_yuv.val = 0; - - LCD_CAM.cam_ctrl.cam_update = 1; - LCD_CAM.cam_ctrl1.cam_start = 1; - - esp_err_t err = ll_cam_dma_init(cam); - if(err != ESP_OK) { - return err; - } - - return ESP_OK; -} - -void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en) -{ - LCD_CAM.lc_dma_int_clr.cam_vsync_int_clr = 1; - if (en) { - LCD_CAM.lc_dma_int_ena.cam_vsync_int_ena = 1; - } else { - LCD_CAM.lc_dma_int_ena.cam_vsync_int_ena = 0; - } -} - -esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config) -{ - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_pclk], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_pclk, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_pclk, GPIO_FLOATING); - gpio_matrix_in(config->pin_pclk, CAM_PCLK_IDX, false); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_vsync], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_vsync, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_vsync, GPIO_FLOATING); - gpio_matrix_in(config->pin_vsync, CAM_V_SYNC_IDX, cam->vsync_invert); - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_href], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_href, GPIO_MODE_INPUT); - gpio_set_pull_mode(config->pin_href, GPIO_FLOATING); - gpio_matrix_in(config->pin_href, CAM_H_ENABLE_IDX, false); - - int data_pins[8] = { - config->pin_d0, config->pin_d1, config->pin_d2, config->pin_d3, config->pin_d4, config->pin_d5, config->pin_d6, config->pin_d7, - }; - for (int i = 0; i < 8; i++) { - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[data_pins[i]], PIN_FUNC_GPIO); - gpio_set_direction(data_pins[i], GPIO_MODE_INPUT); - gpio_set_pull_mode(data_pins[i], GPIO_FLOATING); - gpio_matrix_in(data_pins[i], CAM_DATA_IN0_IDX + i, false); - } - - PIN_FUNC_SELECT(GPIO_PIN_MUX_REG[config->pin_xclk], PIN_FUNC_GPIO); - gpio_set_direction(config->pin_xclk, GPIO_MODE_OUTPUT); - gpio_set_pull_mode(config->pin_xclk, GPIO_FLOATING); - gpio_matrix_out(config->pin_xclk, CAM_CLK_IDX, false, false); - - return ESP_OK; -} - -esp_err_t ll_cam_init_isr(cam_obj_t *cam) -{ - esp_err_t ret = ESP_OK; - ret = esp_intr_alloc_intrstatus(gdma_periph_signals.groups[0].pairs[cam->dma_num].rx_irq_id, - ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_IRAM, - (uint32_t)&GDMA.channel[cam->dma_num].in.int_st, GDMA_IN_SUC_EOF_CH0_INT_ST_M, - ll_cam_dma_isr, cam, &cam->dma_intr_handle); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "DMA interrupt allocation of camera failed"); - return ret; - } - - ret = esp_intr_alloc_intrstatus(ETS_LCD_CAM_INTR_SOURCE, - ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_IRAM, - (uint32_t)&LCD_CAM.lc_dma_int_st.val, LCD_CAM_CAM_VSYNC_INT_ST_M, - ll_cam_vsync_isr, cam, &cam->cam_intr_handle); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "LCD_CAM interrupt allocation of camera failed"); - return ret; - } - return ESP_OK; -} - -void ll_cam_do_vsync(cam_obj_t *cam) -{ - gpio_matrix_in(cam->vsync_pin, CAM_V_SYNC_IDX, !cam->vsync_invert); - ets_delay_us(10); - gpio_matrix_in(cam->vsync_pin, CAM_V_SYNC_IDX, cam->vsync_invert); -} - -uint8_t ll_cam_get_dma_align(cam_obj_t *cam) -{ - return 16 << GDMA.channel[cam->dma_num].in.conf1.in_ext_mem_bk_size; -} - -static bool ll_cam_calc_rgb_dma(cam_obj_t *cam){ - size_t node_max = LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE / cam->dma_bytes_per_item; - size_t line_width = cam->width * cam->in_bytes_per_pixel; - size_t node_size = node_max; - size_t nodes_per_line = 1; - size_t lines_per_node = 1; - - // Calculate DMA Node Size so that it's divisable by or divisor of the line width - if(line_width >= node_max){ - // One or more nodes will be requied for one line - for(size_t i = node_max; i > 0; i=i-1){ - if ((line_width % i) == 0) { - node_size = i; - nodes_per_line = line_width / node_size; - break; - } - } - } else { - // One or more lines can fit into one node - for(size_t i = node_max; i > 0; i=i-1){ - if ((i % line_width) == 0) { - node_size = i; - lines_per_node = node_size / line_width; - while((cam->height % lines_per_node) != 0){ - lines_per_node = lines_per_node - 1; - node_size = lines_per_node * line_width; - } - break; - } - } - } - - ESP_LOGI(TAG, "node_size: %4u, nodes_per_line: %u, lines_per_node: %u", - node_size * cam->dma_bytes_per_item, nodes_per_line, lines_per_node); - - cam->dma_node_buffer_size = node_size * cam->dma_bytes_per_item; - - size_t dma_half_buffer_max = CONFIG_CAMERA_DMA_BUFFER_SIZE_MAX / 2 / cam->dma_bytes_per_item; - if (line_width > dma_half_buffer_max) { - ESP_LOGE(TAG, "Resolution too high"); - return 0; - } - - // Calculate minimum EOF size = max(mode_size, line_size) - size_t dma_half_buffer_min = node_size * nodes_per_line; - - // Calculate max EOF size divisable by node size - size_t dma_half_buffer = (dma_half_buffer_max / dma_half_buffer_min) * dma_half_buffer_min; - - // Adjust EOF size so that height will be divisable by the number of lines in each EOF - size_t lines_per_half_buffer = dma_half_buffer / line_width; - while((cam->height % lines_per_half_buffer) != 0){ - dma_half_buffer = dma_half_buffer - dma_half_buffer_min; - lines_per_half_buffer = dma_half_buffer / line_width; - } - - // Calculate DMA size - size_t dma_buffer_max = 2 * dma_half_buffer_max; - if (cam->psram_mode) { - dma_buffer_max = cam->recv_size / cam->dma_bytes_per_item; - } - size_t dma_buffer_size = dma_buffer_max; - if (!cam->psram_mode) { - dma_buffer_size =(dma_buffer_max / dma_half_buffer) * dma_half_buffer; - } - - ESP_LOGI(TAG, "dma_half_buffer_min: %5u, dma_half_buffer: %5u, lines_per_half_buffer: %2u, dma_buffer_size: %5u", - dma_half_buffer_min * cam->dma_bytes_per_item, dma_half_buffer * cam->dma_bytes_per_item, lines_per_half_buffer, dma_buffer_size * cam->dma_bytes_per_item); - - cam->dma_buffer_size = dma_buffer_size * cam->dma_bytes_per_item; - cam->dma_half_buffer_size = dma_half_buffer * cam->dma_bytes_per_item; - cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; - return 1; -} - -bool ll_cam_dma_sizes(cam_obj_t *cam) -{ - cam->dma_bytes_per_item = 1; - if (cam->jpeg_mode) { - if (cam->psram_mode) { - cam->dma_buffer_size = cam->recv_size; - cam->dma_half_buffer_size = 1024; - cam->dma_half_buffer_cnt = cam->dma_buffer_size / cam->dma_half_buffer_size; - cam->dma_node_buffer_size = cam->dma_half_buffer_size; - } else { - cam->dma_half_buffer_cnt = 16; - cam->dma_buffer_size = cam->dma_half_buffer_cnt * 1024; - cam->dma_half_buffer_size = cam->dma_buffer_size / cam->dma_half_buffer_cnt; - cam->dma_node_buffer_size = cam->dma_half_buffer_size; - } - } else { - return ll_cam_calc_rgb_dma(cam); - } - return 1; -} - -size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len) -{ - // YUV to Grayscale - if (cam->in_bytes_per_pixel == 2 && cam->fb_bytes_per_pixel == 1) { - size_t end = len / 8; - for (size_t i = 0; i < end; ++i) { - out[0] = in[0]; - out[1] = in[2]; - out[2] = in[4]; - out[3] = in[6]; - out += 4; - in += 8; - } - return len / 2; - } - - // just memcpy - memcpy(out, in, len); - return len; -} - -esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid) -{ - if (pix_format == PIXFORMAT_GRAYSCALE) { - if (sensor_pid == OV3660_PID || sensor_pid == OV5640_PID || sensor_pid == NT99141_PID) { - cam->in_bytes_per_pixel = 1; // camera sends Y8 - } else { - cam->in_bytes_per_pixel = 2; // camera sends YU/YV - } - cam->fb_bytes_per_pixel = 1; // frame buffer stores Y8 - } else if (pix_format == PIXFORMAT_YUV422 || pix_format == PIXFORMAT_RGB565) { - cam->in_bytes_per_pixel = 2; // camera sends YU/YV - cam->fb_bytes_per_pixel = 2; // frame buffer stores YU/YV/RGB565 - } else if (pix_format == PIXFORMAT_JPEG) { - cam->in_bytes_per_pixel = 1; - cam->fb_bytes_per_pixel = 1; - } else { - ESP_LOGE(TAG, "Requested format is not supported"); - return ESP_ERR_NOT_SUPPORTED; - } - return ESP_OK; -} - -// implements function from xclk.c to allow dynamic XCLK change -esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz) -{ - LCD_CAM.cam_ctrl.cam_clkm_div_b = 0; - LCD_CAM.cam_ctrl.cam_clkm_div_a = 0; - LCD_CAM.cam_ctrl.cam_clkm_div_num = 160000000 / xclk_freq_hz; - LCD_CAM.cam_ctrl.cam_clk_sel = 3;//Select Camera module source clock. 0: no clock. 1: APLL. 2: CLK160. 3: no clock. - LCD_CAM.cam_ctrl.cam_update = 1; - return ESP_OK; -} diff --git a/lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h b/lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h deleted file mode 100644 index 7d30c370a..000000000 --- a/lib/libesp32_div/esp32-camera/target/private_include/ll_cam.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include -#include "sdkconfig.h" -#include "esp_idf_version.h" -#if CONFIG_IDF_TARGET_ESP32 -#if ESP_IDF_VERSION_MAJOR >= 4 -#include "esp32/rom/lldesc.h" -#else -#include "rom/lldesc.h" -#endif -#elif CONFIG_IDF_TARGET_ESP32S2 -#include "esp32s2/rom/lldesc.h" -#elif CONFIG_IDF_TARGET_ESP32S3 -#include "esp32s3/rom/lldesc.h" -#endif -#include "esp_log.h" -#include "esp_camera.h" -#include "freertos/FreeRTOS.h" -#include "freertos/queue.h" -#include "freertos/task.h" -#include "freertos/semphr.h" - -#if __has_include("esp_private/periph_ctrl.h") -# include "esp_private/periph_ctrl.h" -#endif - -#define CAMERA_DBG_PIN_ENABLE 0 -#if CAMERA_DBG_PIN_ENABLE - #if CONFIG_IDF_TARGET_ESP32 - #define DBG_PIN_NUM 26 - #else - #define DBG_PIN_NUM 7 - #endif - #include "hal/gpio_ll.h" - #define DBG_PIN_SET(v) gpio_ll_set_level(&GPIO, DBG_PIN_NUM, v) -#else - #define DBG_PIN_SET(v) -#endif - -#define CAM_CHECK(a, str, ret) if (!(a)) { \ - ESP_LOGE(TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ - return (ret); \ - } - -#define CAM_CHECK_GOTO(a, str, lab) if (!(a)) { \ - ESP_LOGE(TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \ - goto lab; \ - } - -#define LCD_CAM_DMA_NODE_BUFFER_MAX_SIZE (4092) - -typedef enum { - CAM_IN_SUC_EOF_EVENT = 0, - CAM_VSYNC_EVENT -} cam_event_t; - -typedef enum { - CAM_STATE_IDLE = 0, - CAM_STATE_READ_BUF = 1, -} cam_state_t; - -typedef struct { - camera_fb_t fb; - uint8_t en; - //for RGB/YUV modes - lldesc_t *dma; - size_t fb_offset; -} cam_frame_t; - -typedef struct { - uint32_t dma_bytes_per_item; - uint32_t dma_buffer_size; - uint32_t dma_half_buffer_size; - uint32_t dma_half_buffer_cnt; - uint32_t dma_node_buffer_size; - uint32_t dma_node_cnt; - uint32_t frame_copy_cnt; - - //for JPEG mode - lldesc_t *dma; - uint8_t *dma_buffer; - - cam_frame_t *frames; - - QueueHandle_t event_queue; - QueueHandle_t frame_buffer_queue; - TaskHandle_t task_handle; - intr_handle_t cam_intr_handle; - - uint8_t dma_num;//ESP32-S3 - intr_handle_t dma_intr_handle;//ESP32-S3 - - uint8_t jpeg_mode; - uint8_t vsync_pin; - uint8_t vsync_invert; - uint32_t frame_cnt; - uint32_t recv_size; - bool swap_data; - bool psram_mode; - - //for RGB/YUV modes - uint16_t width; - uint16_t height; - uint8_t in_bytes_per_pixel; - uint8_t fb_bytes_per_pixel; - uint32_t fb_size; - - cam_state_t state; -} cam_obj_t; - - -bool ll_cam_stop(cam_obj_t *cam); -bool ll_cam_start(cam_obj_t *cam, int frame_pos); -esp_err_t ll_cam_config(cam_obj_t *cam, const camera_config_t *config); -esp_err_t ll_cam_deinit(cam_obj_t *cam); -void ll_cam_vsync_intr_enable(cam_obj_t *cam, bool en); -esp_err_t ll_cam_set_pin(cam_obj_t *cam, const camera_config_t *config); -esp_err_t ll_cam_init_isr(cam_obj_t *cam); -void ll_cam_do_vsync(cam_obj_t *cam); -uint8_t ll_cam_get_dma_align(cam_obj_t *cam); -bool ll_cam_dma_sizes(cam_obj_t *cam); -size_t IRAM_ATTR ll_cam_memcpy(cam_obj_t *cam, uint8_t *out, const uint8_t *in, size_t len); -esp_err_t ll_cam_set_sample_mode(cam_obj_t *cam, pixformat_t pix_format, uint32_t xclk_freq_hz, uint16_t sensor_pid); - -// implemented in cam_hal -void ll_cam_send_event(cam_obj_t *cam, cam_event_t cam_event, BaseType_t * HPTaskAwoken); diff --git a/lib/libesp32_div/esp32-camera/target/xclk.c b/lib/libesp32_div/esp32-camera/target/xclk.c deleted file mode 100644 index b5ea53e77..000000000 --- a/lib/libesp32_div/esp32-camera/target/xclk.c +++ /dev/null @@ -1,64 +0,0 @@ -#include "driver/gpio.h" -#include "driver/ledc.h" -#include "esp_err.h" -#include "esp_log.h" -#include "esp_system.h" -#include "xclk.h" -#include "esp_camera.h" - -#if defined(ARDUINO_ARCH_ESP32) && defined(CONFIG_ARDUHAL_ESP_LOG) -#include "esp32-hal-log.h" -#else -#include "esp_log.h" -static const char* TAG = "camera_xclk"; -#endif - -static ledc_channel_t g_ledc_channel = 0; - -esp_err_t xclk_timer_conf(int ledc_timer, int xclk_freq_hz) -{ - ledc_timer_config_t timer_conf; - timer_conf.duty_resolution = LEDC_TIMER_1_BIT; - timer_conf.freq_hz = xclk_freq_hz; - timer_conf.speed_mode = LEDC_LOW_SPEED_MODE; - -#if ESP_IDF_VERSION_MAJOR >= 4 - timer_conf.clk_cfg = LEDC_AUTO_CLK; -#endif - timer_conf.timer_num = (ledc_timer_t)ledc_timer; - esp_err_t err = ledc_timer_config(&timer_conf); - if (err != ESP_OK) { - ESP_LOGE(TAG, "ledc_timer_config failed for freq %d, rc=%x", xclk_freq_hz, err); - } - return err; -} - -esp_err_t camera_enable_out_clock(camera_config_t* config) -{ - esp_err_t err = xclk_timer_conf(config->ledc_timer, config->xclk_freq_hz); - if (err != ESP_OK) { - ESP_LOGE(TAG, "ledc_timer_config failed, rc=%x", err); - return err; - } - - g_ledc_channel = config->ledc_channel; - ledc_channel_config_t ch_conf; - ch_conf.gpio_num = config->pin_xclk; - ch_conf.speed_mode = LEDC_LOW_SPEED_MODE; - ch_conf.channel = config->ledc_channel; - ch_conf.intr_type = LEDC_INTR_DISABLE; - ch_conf.timer_sel = config->ledc_timer; - ch_conf.duty = 1; - ch_conf.hpoint = 0; - err = ledc_channel_config(&ch_conf); - if (err != ESP_OK) { - ESP_LOGE(TAG, "ledc_channel_config failed, rc=%x", err); - return err; - } - return ESP_OK; -} - -void camera_disable_out_clock() -{ - ledc_stop(LEDC_LOW_SPEED_MODE, g_ledc_channel, 0); -} diff --git a/lib/libesp32_div/esp32-camera/test/CMakeLists.txt b/lib/libesp32_div/esp32-camera/test/CMakeLists.txt deleted file mode 100644 index a8c3d16b7..000000000 --- a/lib/libesp32_div/esp32-camera/test/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -idf_component_register(SRC_DIRS . - PRIV_INCLUDE_DIRS . - PRIV_REQUIRES test_utils esp32-camera nvs_flash - EMBED_TXTFILES pictures/testimg.jpeg pictures/test_outside.jpeg pictures/test_inside.jpeg) diff --git a/lib/libesp32_div/esp32-camera/test/component.mk b/lib/libesp32_div/esp32-camera/test/component.mk deleted file mode 100644 index 5fb883650..000000000 --- a/lib/libesp32_div/esp32-camera/test/component.mk +++ /dev/null @@ -1,8 +0,0 @@ -# -#Component Makefile -# - -COMPONENT_SRCDIRS += ./ -COMPONENT_PRIV_INCLUDEDIRS += ./ - -COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive diff --git a/lib/libesp32_div/esp32-camera/test/pictures/test_inside.jpeg b/lib/libesp32_div/esp32-camera/test/pictures/test_inside.jpeg deleted file mode 100644 index 92e7bc3694e8568be514673432c3601a8c1c4126..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 18832 zcmbTdWl&r}*Dg9RxCVj-4MQNfyF;)Lg4bgvmf9O1wEs|v6TL;A1I`Jck8AOa9`(EnTW+6e&s-#YAn8UZiM z04V?v5%E9iRghj2G8!^65)v{7Dk=&Z76uj;CI%)ZHV*z9Y#clsOw2b#Z}8p{5E2q% z;S!S&5s=^$5EA_7B?!RRF-XYh$jImf*qGP^|DWZh3xJ0PfFXzj5oiF2cnCl|gqJ=5 z)hjsU*LC>MQv7d0KzyAe3Mv{p2Igyr`ZoYX1RxL*3HYB`zxMWhZ3iIXA>+U2kU)8> z@*S1Nk$^K0@*52#S=~*jIt8QUGI9z+#~>mmA$|9Oj{YM9BR3B(AHRU0)F){fSvmR7 zYU&!ATG~2bV-r&|a|=r=XBSsDcMngm;2$BOVc`*x35iL`DXD2c({uCw=NFe(*EhF!_y56#0090E ztp9`T|A7nd6&E5B5)cXXKe!MO-Cr{h4+;4_2MWG~3hH;qw=|rAXatgw-__mdATCuH zp^?)R1`#dy#s~O+p#2xw|2tqo|G$v^A7K9%*Af5=i1503KskTa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div/esp32-camera/test/pictures/test_outside.jpeg b/lib/libesp32_div/esp32-camera/test/pictures/test_outside.jpeg deleted file mode 100644 index dcb4bf1b3c82c9aa3858223414be90a54a1ff4c6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 81744 zcmeFYbyQtVlrMO3cX!CeEx0?ug9f*dV8Jc8J0Z9`BzSOwJHb7;y9IZ*IVAaBe?6<$ z%k%6%n=$H^tAP8W5?t~C9zsCsx6aB>t0H*!R0|{VOU@j^! zZUCJPz&OBo3Uqz|QvoA9AP5WcKV)J+voocq5lO72t)%)@%!UxTPP4H z{V#R_@QaW?o&z9=<}Wq^Fw0;3905=i90>ZE#>UP96$J^x2Cxq>0s1eF129DNA07xG z63{V-zpW|&=rA#V)-4AxT+E-fV1W7Xe=z_-2!Am;fD!-l*8%(oMDAoOhj4gxSE z@SG8dR#Xfm2q1xYSwNuZf8m&aVNljzoq+&CWc^w932-xH7Q%1cRsgp{{ly{x#{2q* z=eNDtaKCw;*MRtopQ8i`;OE@d1ayGN`NI!<1VR1_L;VXw=lrqV0N{uDOZNu&VgKT1 znQ;H&hyNEw_!ma}7e@XUeqQ@o#RAP89C?fxSl1c3~~`j>nHz@lf}t^s}`fc`8K7(m4T ziysz5@>d5`fKCcLeCB`dWB|`|tZ)JPi@)^ec!B{sA25;vA1MFISpgSub$G_1 z|I+g_AoKa%5&>)v1F#sd);%yc8o+J<76KNG2W$jLpgJJHi2z+1ptk@x3BVKp9TsqW zG9VKmgZh!?;4%RGoC~x7{VO2-SvQhiXo&28>68DLe&!AW6#+A!=aK`x9FX~Jy8tk^ z;;)|1`qcpRXWL%`^jZLu0$3HmbpS2~uswk50sPGSyqz`v38 z{7?HI5Bwi_fQ5~XJ3|_piIY|(_FQ|#v-y5$+5+MA7lDbSP_( z;8*47;W$$frv9%yDh%A`EXw){;w8(rUIr1y@g7W6exKSBNoVsBx(co=ZXaa|z4L!D zliQb^&?+a>DYKdMUYuXnw&XzVFqolpVf2KL?{l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V z#LoI!)vCcwAY=rGm#PNLCYN(l{{fmkq>*7_=!y3${CEIYB-E`ZwawbFOVpALhSXcu z#WwD-qnWG9-HPC1*y_<^@h)ERS4kad6dUIerZPoGvTmcn^q=X(YvMmT^;@&*v&mU8 zq3!lU{nLGOImt{XFcU{6^}L7Hvdc;0r5}6SG%Q!>R(h4(G$KpSzZ92TSAaRC2c0u+ z6O0+(4vG(M1?sbX?ej-hc77IUAzo~d{pC5O(%w&w&^okE47^IRnxy0%5KBd8$l7_o zYD?>u4IEW9RDjv))Zz>w5L1qF- -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "unity.h" -#include -#include "esp_log.h" - -#include "esp_camera.h" - -#ifdef CONFIG_IDF_TARGET_ESP32 -#define BOARD_WROVER_KIT 1 -#elif defined CONFIG_IDF_TARGET_ESP32S2 -#define BOARD_CAMERA_MODEL_ESP32S2 1 -#elif defined CONFIG_IDF_TARGET_ESP32S3 -#define BOARD_CAMERA_MODEL_ESP32_S3_EYE 1 -#endif - -// WROVER-KIT PIN Map -#if BOARD_WROVER_KIT - -#define PWDN_GPIO_NUM -1 //power down is not used -#define RESET_GPIO_NUM -1 //software reset will be performed -#define XCLK_GPIO_NUM 21 -#define SIOD_GPIO_NUM 26 -#define SIOC_GPIO_NUM 27 - -#define Y9_GPIO_NUM 35 -#define Y8_GPIO_NUM 34 -#define Y7_GPIO_NUM 39 -#define Y6_GPIO_NUM 36 -#define Y5_GPIO_NUM 19 -#define Y4_GPIO_NUM 18 -#define Y3_GPIO_NUM 5 -#define Y2_GPIO_NUM 4 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 23 -#define PCLK_GPIO_NUM 22 - -// ESP32Cam (AiThinker) PIN Map -#elif BOARD_ESP32CAM_AITHINKER - -#define PWDN_GPIO_NUM 32 -#define RESET_GPIO_NUM -1 //software reset will be performed -#define XCLK_GPIO_NUM 0 -#define SIOD_GPIO_NUM 26 -#define SIOC_GPIO_NUM 27 - -#define Y9_GPIO_NUM 35 -#define Y8_GPIO_NUM 34 -#define Y7_GPIO_NUM 39 -#define Y6_GPIO_NUM 36 -#define Y5_GPIO_NUM 21 -#define Y4_GPIO_NUM 19 -#define Y3_GPIO_NUM 18 -#define Y2_GPIO_NUM 5 -#define VSYNC_GPIO_NUM 25 -#define HREF_GPIO_NUM 23 -#define PCLK_GPIO_NUM 22 - -#elif BOARD_CAMERA_MODEL_ESP32S2 - -#define PWDN_GPIO_NUM -1 -#define RESET_GPIO_NUM -1 - -#define VSYNC_GPIO_NUM 21 -#define HREF_GPIO_NUM 38 -#define PCLK_GPIO_NUM 11 -#define XCLK_GPIO_NUM 40 - -#define SIOD_GPIO_NUM 17 -#define SIOC_GPIO_NUM 18 - -#define Y9_GPIO_NUM 39 -#define Y8_GPIO_NUM 41 -#define Y7_GPIO_NUM 42 -#define Y6_GPIO_NUM 12 -#define Y5_GPIO_NUM 3 -#define Y4_GPIO_NUM 14 -#define Y3_GPIO_NUM 37 -#define Y2_GPIO_NUM 13 - -#elif BOARD_CAMERA_MODEL_ESP32_S3_EYE - -#define PWDN_GPIO_NUM 43 -#define RESET_GPIO_NUM 44 - -#define VSYNC_GPIO_NUM 6 -#define HREF_GPIO_NUM 7 -#define PCLK_GPIO_NUM 13 -#define XCLK_GPIO_NUM 15 - -#define SIOD_GPIO_NUM 4 -#define SIOC_GPIO_NUM 5 - -#define Y9_GPIO_NUM 16 -#define Y8_GPIO_NUM 17 -#define Y7_GPIO_NUM 18 -#define Y6_GPIO_NUM 12 -#define Y5_GPIO_NUM 11 -#define Y4_GPIO_NUM 10 -#define Y3_GPIO_NUM 9 -#define Y2_GPIO_NUM 8 - -#endif - -static const char *TAG = "test camera"; - -typedef void (*decode_func_t)(uint8_t *jpegbuffer, uint32_t size, uint8_t *outbuffer); - -static esp_err_t init_camera(uint32_t xclk_freq_hz, pixformat_t pixel_format, framesize_t frame_size, uint8_t fb_count) -{ - framesize_t size_bak = frame_size; - if (PIXFORMAT_JPEG == pixel_format && FRAMESIZE_SVGA > frame_size) { - frame_size = FRAMESIZE_HD; - } - camera_config_t camera_config = { - .pin_pwdn = PWDN_GPIO_NUM, - .pin_reset = RESET_GPIO_NUM, - .pin_xclk = XCLK_GPIO_NUM, - .pin_sscb_sda = SIOD_GPIO_NUM, - .pin_sscb_scl = SIOC_GPIO_NUM, - - .pin_d7 = Y9_GPIO_NUM, - .pin_d6 = Y8_GPIO_NUM, - .pin_d5 = Y7_GPIO_NUM, - .pin_d4 = Y6_GPIO_NUM, - .pin_d3 = Y5_GPIO_NUM, - .pin_d2 = Y4_GPIO_NUM, - .pin_d1 = Y3_GPIO_NUM, - .pin_d0 = Y2_GPIO_NUM, - .pin_vsync = VSYNC_GPIO_NUM, - .pin_href = HREF_GPIO_NUM, - .pin_pclk = PCLK_GPIO_NUM, - - //EXPERIMENTAL: Set to 16MHz on ESP32-S2 or ESP32-S3 to enable EDMA mode - .xclk_freq_hz = xclk_freq_hz, - .ledc_timer = LEDC_TIMER_0, - .ledc_channel = LEDC_CHANNEL_0, - - .pixel_format = pixel_format, //YUV422,GRAYSCALE,RGB565,JPEG - .frame_size = frame_size, //QQVGA-UXGA Do not use sizes above QVGA when not JPEG - - .jpeg_quality = 12, //0-63 lower number means higher quality - .fb_count = fb_count, //if more than one, i2s runs in continuous mode. Use only with JPEG - .grab_mode = CAMERA_GRAB_WHEN_EMPTY - }; - - //initialize the camera - esp_err_t ret = esp_camera_init(&camera_config); - - if (ESP_OK == ret && PIXFORMAT_JPEG == pixel_format && FRAMESIZE_SVGA > size_bak) { - sensor_t *s = esp_camera_sensor_get(); - s->set_framesize(s, size_bak); - } - - return ret; -} - -static bool camera_test_fps(uint16_t times, float *fps, uint32_t *size) -{ - *fps = 0.0f; - *size = 0; - uint32_t s = 0; - uint32_t num = 0; - uint64_t total_time = esp_timer_get_time(); - for (size_t i = 0; i < times; i++) { - camera_fb_t *pic = esp_camera_fb_get(); - if (NULL == pic) { - ESP_LOGW(TAG, "fb get failed"); - return 0; - } else { - s += pic->len; - num++; - } - esp_camera_fb_return(pic); - } - total_time = esp_timer_get_time() - total_time; - if (num) { - *fps = num * 1000000.0f / total_time ; - *size = s / num; - } - return 1; -} - -static const char *get_cam_format_name(pixformat_t pixel_format) -{ - switch (pixel_format) { - case PIXFORMAT_JPEG: return "JPEG"; - case PIXFORMAT_RGB565: return "RGB565"; - case PIXFORMAT_RGB888: return "RGB888"; - case PIXFORMAT_YUV422: return "YUV422"; - default: - break; - } - return "UNKNOW"; -} - -static void printf_img_base64(const camera_fb_t *pic) -{ - uint8_t *outbuffer = NULL; - size_t outsize = 0; - if (PIXFORMAT_JPEG != pic->format) { - fmt2jpg(pic->buf, pic->width * pic->height * 2, pic->width, pic->height, pic->format, 50, &outbuffer, &outsize); - } else { - outbuffer = pic->buf; - outsize = pic->len; - } - - uint8_t *base64_buf = calloc(1, outsize * 4); - if (NULL != base64_buf) { - size_t out_len = 0; - mbedtls_base64_encode(base64_buf, outsize * 4, &out_len, outbuffer, outsize); - printf("%s\n", base64_buf); - free(base64_buf); - if (PIXFORMAT_JPEG != pic->format) { - free(outbuffer); - } - } else { - ESP_LOGE(TAG, "malloc for base64 buffer failed"); - } -} - -static void camera_performance_test(uint32_t xclk_freq, uint32_t pic_num) -{ - esp_err_t ret = ESP_OK; - //detect sensor information - TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); - sensor_t *s = esp_camera_sensor_get(); - camera_sensor_info_t *info = esp_camera_sensor_get_info(&s->id); - TEST_ASSERT_NOT_NULL(info); - TEST_ESP_OK(esp_camera_deinit()); - vTaskDelay(500 / portTICK_RATE_MS); - framesize_t max_size = info->max_size; - pixformat_t all_format[] = {PIXFORMAT_JPEG, PIXFORMAT_RGB565, PIXFORMAT_YUV422, }; - pixformat_t *format_s = &all_format[0]; - pixformat_t *format_e = &all_format[2]; - if (false == info->support_jpeg) { - format_s++; // skip jpeg - } - - struct fps_result { - float fps[FRAMESIZE_INVALID]; - uint32_t size[FRAMESIZE_INVALID]; - }; - struct fps_result results[3] = {0}; - - for (; format_s <= format_e; format_s++) { - for (size_t i = 0; i <= max_size; i++) { - ESP_LOGI(TAG, "\n\n===> Testing format:%s resolution: %d x %d <===", get_cam_format_name(*format_s), resolution[i].width, resolution[i].height); - ret = init_camera(xclk_freq, *format_s, i, 2); - vTaskDelay(100 / portTICK_RATE_MS); - if (ESP_OK != ret) { - ESP_LOGW(TAG, "Testing init failed :-(, skip this item"); - vTaskDelay(500 / portTICK_RATE_MS); - continue; - } - camera_test_fps(pic_num, &results[format_s - all_format].fps[i], &results[format_s - all_format].size[i]); - TEST_ESP_OK(esp_camera_deinit()); - } - } - - printf("FPS Result\n"); - printf("resolution , JPEG fps, JPEG size, RGB565 fps, RGB565 size, YUV422 fps, YUV422 size \n"); - for (size_t i = 0; i <= max_size; i++) { - printf("%4d x %4d , %5.2f, %6d, %5.2f, %7d, %5.2f, %7d \n", - resolution[i].width, resolution[i].height, - results[0].fps[i], results[0].size[i], - results[1].fps[i], results[1].size[i], - results[2].fps[i], results[2].size[i]); - } - printf("----------------------------------------------------------------------------------------\n"); -} - -TEST_CASE("Camera driver init, deinit test", "[camera]") -{ - uint64_t t1 = esp_timer_get_time(); - TEST_ESP_OK(init_camera(20000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); - uint64_t t2 = esp_timer_get_time(); - ESP_LOGI(TAG, "Camera init time %llu ms", (t2 - t1) / 1000); - - TEST_ESP_OK(esp_camera_deinit()); -} - -TEST_CASE("Camera driver take RGB565 picture test", "[camera]") -{ - TEST_ESP_OK(init_camera(10000000, PIXFORMAT_RGB565, FRAMESIZE_QVGA, 2)); - vTaskDelay(500 / portTICK_RATE_MS); - ESP_LOGI(TAG, "Taking picture..."); - camera_fb_t *pic = esp_camera_fb_get(); - if (pic) { - ESP_LOGI(TAG, "picture: %d x %d, size: %u", pic->width, pic->height, pic->len); - printf_img_base64(pic); - esp_camera_fb_return(pic); - } - - TEST_ESP_OK(esp_camera_deinit()); - TEST_ASSERT_NOT_NULL(pic); -} - -TEST_CASE("Camera driver take YUV422 picture test", "[camera]") -{ - TEST_ESP_OK(init_camera(10000000, PIXFORMAT_YUV422, FRAMESIZE_QVGA, 2)); - vTaskDelay(500 / portTICK_RATE_MS); - ESP_LOGI(TAG, "Taking picture..."); - camera_fb_t *pic = esp_camera_fb_get(); - if (pic) { - ESP_LOGI(TAG, "picture: %d x %d, size: %u", pic->width, pic->height, pic->len); - printf_img_base64(pic); - esp_camera_fb_return(pic); - } - - TEST_ESP_OK(esp_camera_deinit()); - TEST_ASSERT_NOT_NULL(pic); -} - -TEST_CASE("Camera driver take JPEG picture test", "[camera]") -{ - TEST_ESP_OK(init_camera(20000000, PIXFORMAT_JPEG, FRAMESIZE_QVGA, 2)); - vTaskDelay(500 / portTICK_RATE_MS); - ESP_LOGI(TAG, "Taking picture..."); - camera_fb_t *pic = esp_camera_fb_get(); - if (pic) { - ESP_LOGI(TAG, "picture: %d x %d, size: %u", pic->width, pic->height, pic->len); - printf_img_base64(pic); - esp_camera_fb_return(pic); - } - - TEST_ESP_OK(esp_camera_deinit()); - TEST_ASSERT_NOT_NULL(pic); -} - -TEST_CASE("Camera driver performance test", "[camera]") -{ - camera_performance_test(20 * 1000000, 16); -} - - -static void print_rgb565_img(uint8_t *img, int width, int height) -{ - uint16_t *p = (uint16_t *)img; - const char temp2char[17] = "@MNHQ&#UJ*x7^i;."; - for (size_t j = 0; j < height; j++) { - for (size_t i = 0; i < width; i++) { - uint32_t c = p[j * width + i]; - uint8_t r = c >> 11; - uint8_t g = (c >> 6) & 0x1f; - uint8_t b = c & 0x1f; - c = (r + g + b) / 3; - c >>= 1; - printf("%c", temp2char[15 - c]); - } - printf("\n"); - } -} - -static void print_rgb888_img(uint8_t *img, int width, int height) -{ - uint8_t *p = (uint8_t *)img; - const char temp2char[17] = "@MNHQ&#UJ*x7^i;."; - for (size_t j = 0; j < height; j++) { - for (size_t i = 0; i < width; i++) { - uint8_t *c = p + 3 * (j * width + i); - uint8_t r = *c++; - uint8_t g = *c++; - uint8_t b = *c; - uint32_t v = (r + g + b) / 3; - v >>= 4; - printf("%c", temp2char[15 - v]); - } - printf("\n"); - } -} - -static void tjpgd_decode_rgb565(uint8_t *mjpegbuffer, uint32_t size, uint8_t *outbuffer) -{ - jpg2rgb565(mjpegbuffer, size, outbuffer, JPG_SCALE_NONE); -} - -static void tjpgd_decode_rgb888(uint8_t *mjpegbuffer, uint32_t size, uint8_t *outbuffer) -{ - fmt2rgb888(mjpegbuffer, size, PIXFORMAT_JPEG, outbuffer); -} - -typedef enum { - DECODE_RGB565, - DECODE_RGB888, -} decode_type_t; - -static const decode_func_t g_decode_func[2][2] = { - {tjpgd_decode_rgb565,}, - {tjpgd_decode_rgb888,}, -}; - - -static float jpg_decode_test(uint8_t decoder_index, decode_type_t type, const uint8_t *jpg, uint32_t length, uint32_t img_w, uint32_t img_h, uint32_t times) -{ - uint8_t *jpg_buf = malloc(length); - if (NULL == jpg_buf) { - ESP_LOGE(TAG, "malloc for jpg buffer failed"); - return 0; - } - memcpy(jpg_buf, jpg, length); - - uint8_t *rgb_buf = heap_caps_malloc(img_w * img_h * 3, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); - if (NULL == rgb_buf) { - free(jpg_buf); - ESP_LOGE(TAG, "malloc for rgb buffer failed"); - return 0; - } - decode_func_t decode = g_decode_func[type][decoder_index]; - decode(jpg_buf, length, rgb_buf); - if (DECODE_RGB565 == type) { - ESP_LOGI(TAG, "jpeg decode to rgb565"); - print_rgb565_img(rgb_buf, img_w, img_h); - } else { - ESP_LOGI(TAG, "jpeg decode to rgb888"); - print_rgb888_img(rgb_buf, img_w, img_h); - } - - uint64_t t_decode[times]; - for (size_t i = 0; i < times; i++) { - uint64_t t1 = esp_timer_get_time(); - decode(jpg_buf, length, rgb_buf); - t_decode[i] = esp_timer_get_time() - t1; - } - - printf("resolution , t \n"); - uint64_t t_total = 0; - for (size_t i = 0; i < times; i++) { - t_total += t_decode[i]; - float t = t_decode[i] / 1000.0f; - printf("%4d x %4d , %5.2f ms \n", img_w, img_h, t); - } - - float fps = times / (t_total / 1000000.0f); - printf("Decode FPS Result\n"); - printf("resolution , fps \n"); - printf("%4d x %4d , %5.2f \n", img_w, img_h, fps); - - free(jpg_buf); - heap_caps_free(rgb_buf); - return fps; -} - -static void img_jpeg_decode_test(uint16_t pic_index, uint16_t lib_index) -{ - extern const uint8_t img1_start[] asm("_binary_testimg_jpeg_start"); - extern const uint8_t img1_end[] asm("_binary_testimg_jpeg_end"); - extern const uint8_t img2_start[] asm("_binary_test_inside_jpeg_start"); - extern const uint8_t img2_end[] asm("_binary_test_inside_jpeg_end"); - extern const uint8_t img3_start[] asm("_binary_test_outside_jpeg_start"); - extern const uint8_t img3_end[] asm("_binary_test_outside_jpeg_end"); - - struct img_t { - const uint8_t *buf; - uint32_t length; - uint16_t w, h; - }; - struct img_t imgs[3] = { - { - .buf = img1_start, - .length = img1_end - img1_start, - .w = 227, - .h = 149, - }, - { - .buf = img2_start, - .length = img2_end - img2_start, - .w = 320, - .h = 240, - }, - { - .buf = img3_start, - .length = img3_end - img3_start, - .w = 480, - .h = 320, - }, - }; - - ESP_LOGI(TAG, "pic_index:%d", pic_index); - ESP_LOGI(TAG, "lib_index:%d", lib_index); - jpg_decode_test(lib_index, DECODE_RGB565, imgs[pic_index].buf, imgs[pic_index].length, imgs[pic_index].w, imgs[pic_index].h, 16); -} - -TEST_CASE("Conversions image 227x149 jpeg decode test", "[camera]") -{ - img_jpeg_decode_test(0, 0); -} - -TEST_CASE("Conversions image 320x240 jpeg decode test", "[camera]") -{ - img_jpeg_decode_test(1, 0); -} - -TEST_CASE("Conversions image 480x320 jpeg decode test", "[camera]") -{ - img_jpeg_decode_test(2, 0); -} diff --git a/platformio_override_sample.ini b/platformio_override.ini similarity index 96% rename from platformio_override_sample.ini rename to platformio_override.ini index b1d7b7eff..816fffe7e 100644 --- a/platformio_override_sample.ini +++ b/platformio_override.ini @@ -16,7 +16,7 @@ extra_configs = platformio_tasmota_cenv.ini ; *** Build/upload environment default_envs = ; *** Uncomment the line(s) below to select version(s) - tasmota +; tasmota ; tasmota-debug ; tasmota-minimal ; tasmota-lite @@ -27,7 +27,7 @@ default_envs = ; tasmota-ir ; tasmota32 ; tasmota32-bluetooth -; tasmota32-webcam + tasmota32-webcam ; tasmota32-knx ; tasmota32-sensors ; tasmota32-display From 3c631c1f0fd598daa0de2d0dbaa1511052ffbfed Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 13:56:06 +0100 Subject: [PATCH 22/31] Update .gitpod.yml --- .gitpod.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitpod.yml b/.gitpod.yml index 7a7300013..50d9a86d9 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,6 +1,6 @@ tasks: - before: platformio upgrade - - command: platformio run -e tasmota32-webcam + - command: platformio run -e tasmota image: file: .gitpod.Dockerfile From 047fd6d05e1d6ad537c561477dff9a3be054f8ae Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 13:59:46 +0100 Subject: [PATCH 23/31] Update and rename platformio_override.ini to platformio_override_sample.ini --- platformio_override.ini => platformio_override_sample.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename platformio_override.ini => platformio_override_sample.ini (96%) diff --git a/platformio_override.ini b/platformio_override_sample.ini similarity index 96% rename from platformio_override.ini rename to platformio_override_sample.ini index 816fffe7e..b1d7b7eff 100644 --- a/platformio_override.ini +++ b/platformio_override_sample.ini @@ -16,7 +16,7 @@ extra_configs = platformio_tasmota_cenv.ini ; *** Build/upload environment default_envs = ; *** Uncomment the line(s) below to select version(s) -; tasmota + tasmota ; tasmota-debug ; tasmota-minimal ; tasmota-lite @@ -27,7 +27,7 @@ default_envs = ; tasmota-ir ; tasmota32 ; tasmota32-bluetooth - tasmota32-webcam +; tasmota32-webcam ; tasmota32-knx ; tasmota32-sensors ; tasmota32-display From e0d9c3dcef7837a0e76768286573eb7c71bd4b01 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 14:04:41 +0100 Subject: [PATCH 24/31] Update platformio_tasmota_env32.ini --- platformio_tasmota_env32.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index 7a686762f..f7558b5c7 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -56,7 +56,7 @@ build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_TASMOTA32 extends = env:tasmota32_base board = esp32-cam build_flags = ${env:tasmota32_base.build_flags} -DFIRMWARE_WEBCAM -lib_extra_dirs = lib/libesp32, lib/libesp32_div +lib_extra_dirs = lib/libesp32 [env:tasmota32-odroidgo] extends = env:tasmota32_base From 81aa57947100f641a350427f0204c1a0bef94a57 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 19 Dec 2021 16:41:10 +0100 Subject: [PATCH 25/31] Refactor Tuya driver to enable ESP32 support Refactor Tuya driver to enable ESP32 support (#14086, #14106) --- tasmota/tasmota_globals.h | 3 - tasmota/xdrv_12_discovery.ino | 6 +- tasmota/xdrv_12_home_assistant.ino | 24 ++++---- tasmota/xdrv_16_tuyamcu.ino | 92 +++++++++++++++++------------- 4 files changed, 69 insertions(+), 56 deletions(-) diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index aa9f97063..b69f1f166 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -133,7 +133,6 @@ String EthernetMacAddress(void); #undef FIRMWARE_MINIMAL // Minimal is not supported as not needed // Hardware has no ESP32 -#undef USE_TUYA_DIMMER #undef USE_PWM_DIMMER #undef USE_EXS_DIMMER #undef USE_ARMTRONIX_DIMMERS @@ -146,9 +145,7 @@ String EthernetMacAddress(void); #undef USE_RF_FLASH // Not ported (yet) - #undef USE_MY92X1 -#undef USE_TUYA_MCU #undef USE_PS_16_DZ #undef USE_HM10 // Disable support for HM-10 as a BLE-bridge as an alternative is using the internal ESP32 BLE diff --git a/tasmota/xdrv_12_discovery.ino b/tasmota/xdrv_12_discovery.ino index da92495d5..112df2387 100644 --- a/tasmota/xdrv_12_discovery.ino +++ b/tasmota/xdrv_12_discovery.ino @@ -48,10 +48,12 @@ void TasDiscoverMessage(void) { } bool TuyaMod = false; +#ifdef USE_TUYA_MCU + TuyaMod = IsModuleTuya(); +#endif bool iFanMod = false; #ifdef ESP8266 - if ((TUYA_DIMMER == TasmotaGlobal.module_type) || (SK03_TUYA == TasmotaGlobal.module_type)) { TuyaMod = true; }; - if ((SONOFF_IFAN02 == TasmotaGlobal.module_type) || (SONOFF_IFAN03 == TasmotaGlobal.module_type)) { iFanMod = true; }; + iFanMod = ((SONOFF_IFAN02 == TasmotaGlobal.module_type) || (SONOFF_IFAN03 == TasmotaGlobal.module_type)); #endif // ESP8266 ResponseAppend_P(PSTR("]," // Friendly Names (end) diff --git a/tasmota/xdrv_12_home_assistant.ino b/tasmota/xdrv_12_home_assistant.ino index a686531f6..e1cdc5179 100644 --- a/tasmota/xdrv_12_home_assistant.ino +++ b/tasmota/xdrv_12_home_assistant.ino @@ -215,10 +215,12 @@ void HassDiscoverMessage(void) { } bool TuyaMod = false; +#ifdef USE_TUYA_MCU + TuyaMod = IsModuleTuya(); +#endif bool iFanMod = false; #ifdef ESP8266 - if ((TUYA_DIMMER == TasmotaGlobal.module_type) || (SK03_TUYA == TasmotaGlobal.module_type)) { TuyaMod = true; }; - if ((SONOFF_IFAN02 == TasmotaGlobal.module_type) || (SONOFF_IFAN03 == TasmotaGlobal.module_type)) { iFanMod = true; }; + iFanMod = ((SONOFF_IFAN02 == TasmotaGlobal.module_type) || (SONOFF_IFAN03 == TasmotaGlobal.module_type)); #endif // ESP8266 ResponseAppend_P(PSTR("]," // Friendly Names (end) @@ -456,12 +458,14 @@ void HAssAnnounceRelayLight(void) uint8_t TuyaDim = 0; power_t shutter_mask = 0; - #ifdef ESP8266 - if (PWM_DIMMER == TasmotaGlobal.module_type ) { PwmMod = true; } // - if (SONOFF_IFAN02 == TasmotaGlobal.module_type || SONOFF_IFAN03 == TasmotaGlobal.module_type) { FanMod = true; } - if (SONOFF_DUAL == TasmotaGlobal.module_type) { valid_relay = 2; } - if (TUYA_DIMMER == TasmotaGlobal.module_type || SK03_TUYA == TasmotaGlobal.module_type) { TuyaMod = true; } - #endif //ESP8266 +#ifdef ESP8266 + PwmMod = (PWM_DIMMER == TasmotaGlobal.module_type); + FanMod = (SONOFF_IFAN02 == TasmotaGlobal.module_type || SONOFF_IFAN03 == TasmotaGlobal.module_type); + if (SONOFF_DUAL == TasmotaGlobal.module_type) { valid_relay = 2; } +#endif //ESP8266 +#ifdef USE_TUYA_MCU + TuyaMod = IsModuleTuya(); +#endif #ifdef USE_LIGHT // If there is a special Light to be enabled and managed with SetOption68 or SetOption37 >= 128, Discovery calculates the maximum number of entities to be generated in advance @@ -1038,10 +1042,10 @@ void HAssAnnounceShutters(void) GetTopic_P(stemp1, STAT, TasmotaGlobal.mqtt_topic, PSTR("SHUTTER")); GetTopic_P(stemp2, CMND, TasmotaGlobal.mqtt_topic, PSTR("ShutterPosition")); TryResponseAppend_P(HASS_DISCOVER_SHUTTER_POS, stemp1, i + 1, stemp2, i + 1); - + GetTopic_P(stemp1, CMND, TasmotaGlobal.mqtt_topic, PSTR("ShutterTilt")); TryResponseAppend_P(HASS_DISCOVER_SHUTTER_TILT, stemp1, i + 1, Settings->shutter_tilt_config[3][i], Settings->shutter_tilt_config[4][i]); - + TryResponseAppend_P(HASS_DISCOVER_DEVICE_INFO_SHORT, unique_id, ESP_getChipId()); TryResponseAppend_P(PSTR("}")); } else { diff --git a/tasmota/xdrv_16_tuyamcu.ino b/tasmota/xdrv_16_tuyamcu.ino index 5750839c5..3c550424f 100644 --- a/tasmota/xdrv_16_tuyamcu.ino +++ b/tasmota/xdrv_16_tuyamcu.ino @@ -81,6 +81,7 @@ struct TUYA { bool send_success_next_second = false; // Second command success in low power mode uint32_t ignore_dimmer_cmd_timeout = 0; // Time until which received dimmer commands should be ignored bool ignore_tuyareceived = false; // When a modeset changes ignore stat + bool active; } Tuya; #define D_JSON_TUYA_MCU_RECEIVED "TuyaReceived" @@ -109,9 +110,16 @@ void (* const TuyaCommand[])(void) PROGMEM = { /*********************************************************************************************\ * Web Interface \*********************************************************************************************/ -bool IsModuleTuya(void) -{ - return ((TUYA_DIMMER == TasmotaGlobal.module_type) || (SK03_TUYA == TasmotaGlobal.module_type)); + +bool IsModuleTuya(void) { + bool is_tuya = Tuya.active; +//#ifdef ESP8266 + // This is not a Tuya driven device. It uses a Tuya provided ESP8266. Why it was here is a mystery to me. +// if (SK03_TUYA == TasmotaGlobal.module_type) { +// is_tuya = true; +// } +//#endif + return is_tuya; } bool AsModuleTuyaMS(void) // ModeSet Layout @@ -123,6 +131,7 @@ bool TuyaModeSet(void) // ModeSet Status { return Tuya.ModeSet; } + /*********************************************************************************************\ * Web Interface \*********************************************************************************************/ @@ -1055,8 +1064,10 @@ void TuyaNormalPowerModePacketProcess(void) * API Functions \*********************************************************************************************/ -bool TuyaModuleSelected(void) -{ +bool TuyaModuleSelected(void) { +#ifdef ESP8266 + if (TUYA_DIMMER != TasmotaGlobal.module_type) { return false; } + if (!PinUsed(GPIO_TUYA_RX) || !PinUsed(GPIO_TUYA_TX)) { // fallback to hardware-serial if not explicitly selected SetPin(1, AGPIO(GPIO_TUYA_TX)); SetPin(3, AGPIO(GPIO_TUYA_RX)); @@ -1064,6 +1075,8 @@ bool TuyaModuleSelected(void) Settings->my_gp.io[3] = AGPIO(GPIO_TUYA_RX); TasmotaGlobal.restart_flag = 2; } +#endif + if (!PinUsed(GPIO_TUYA_RX) || !PinUsed(GPIO_TUYA_TX)) { return false; } if (TuyaGetDpId(TUYA_MCU_FUNC_DIMMER) == 0 && TUYA_DIMMER_ID > 0) { TuyaAddMcuFunc(TUYA_MCU_FUNC_DIMMER, TUYA_DIMMER_ID); @@ -1119,8 +1132,7 @@ bool TuyaModuleSelected(void) return true; } -void TuyaInit(void) -{ +void TuyaInit(void) { int baudrate = 9600; if (Settings->flag4.tuyamcu_baudrate) { baudrate = 115200; } // SetOption97 - Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200) @@ -1134,10 +1146,12 @@ void TuyaInit(void) Tuya.ignore_topic_timeout = millis() + 1000; // suppress /STAT topic for 1000ms to avoid data overflow AddLog(LOG_LEVEL_DEBUG, PSTR("TYA: Request MCU configuration at %d bps"), baudrate); - + Tuya.heartbeat_timer = 0; // init heartbeat timer when dimmer init is done + return; } + free(Tuya.buffer); } - Tuya.heartbeat_timer = 0; // init heartbeat timer when dimmer init is done + Tuya.active = false; } void TuyaSerialInput(void) @@ -1332,33 +1346,6 @@ void TuyaSetTime(void) { } #endif //USE_TUYA_TIME -#ifdef USE_ENERGY_SENSOR - -/*********************************************************************************************\ - * Energy Interface -\*********************************************************************************************/ - -bool Xnrg32(uint8_t function) -{ - bool result = false; - - if (TUYA_DIMMER == TasmotaGlobal.module_type) { - if (FUNC_PRE_INIT == function) { - if (TuyaGetDpId(TUYA_MCU_FUNC_POWER) != 0 || TuyaGetDpId(TUYA_MCU_FUNC_POWER_COMBINED) != 0) { - if (TuyaGetDpId(TUYA_MCU_FUNC_CURRENT) == 0 && TuyaGetDpId(TUYA_MCU_FUNC_POWER_COMBINED) == 0) { - Energy.current_available = false; - } - if (TuyaGetDpId(TUYA_MCU_FUNC_VOLTAGE) == 0 && TuyaGetDpId(TUYA_MCU_FUNC_POWER_COMBINED) == 0) { - Energy.voltage_available = false; - } - TasmotaGlobal.energy_driver = XNRG_32; - } - } - } - return result; -} -#endif // USE_ENERGY_SENSOR - /*********************************************************************************************\ * Sensors \*********************************************************************************************/ @@ -1471,18 +1458,41 @@ void TuyaAddButton(void) { * Interface \*********************************************************************************************/ -bool Xdrv16(uint8_t function) +#ifdef USE_ENERGY_SENSOR + +bool Xnrg32(uint8_t function) { bool result = false; - if (TUYA_DIMMER == TasmotaGlobal.module_type) { + if (Tuya.active) { + if (FUNC_PRE_INIT == function) { + if (TuyaGetDpId(TUYA_MCU_FUNC_POWER) != 0 || TuyaGetDpId(TUYA_MCU_FUNC_POWER_COMBINED) != 0) { + if (TuyaGetDpId(TUYA_MCU_FUNC_CURRENT) == 0 && TuyaGetDpId(TUYA_MCU_FUNC_POWER_COMBINED) == 0) { + Energy.current_available = false; + } + if (TuyaGetDpId(TUYA_MCU_FUNC_VOLTAGE) == 0 && TuyaGetDpId(TUYA_MCU_FUNC_POWER_COMBINED) == 0) { + Energy.voltage_available = false; + } + TasmotaGlobal.energy_driver = XNRG_32; + } + } + } + return result; +} +#endif // USE_ENERGY_SENSOR + +bool Xdrv16(uint8_t function) { + bool result = false; + + if (FUNC_MODULE_INIT == function) { + result = TuyaModuleSelected(); + Tuya.active = result; + } + else if (Tuya.active) { switch (function) { case FUNC_LOOP: if (TuyaSerial) { TuyaSerialInput(); } break; - case FUNC_MODULE_INIT: - result = TuyaModuleSelected(); - break; case FUNC_PRE_INIT: TuyaInit(); break; From 463dd14f901e5c0d68acde5df5ca09413a2c2028 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 19 Dec 2021 16:57:57 +0100 Subject: [PATCH 26/31] Enable My92X1 for ESP32 --- tasmota/tasmota_globals.h | 1 - tasmota/xlgt_02_my92x1.ino | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index b69f1f166..b7067ab94 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -145,7 +145,6 @@ String EthernetMacAddress(void); #undef USE_RF_FLASH // Not ported (yet) -#undef USE_MY92X1 #undef USE_PS_16_DZ #undef USE_HM10 // Disable support for HM-10 as a BLE-bridge as an alternative is using the internal ESP32 BLE diff --git a/tasmota/xlgt_02_my92x1.ino b/tasmota/xlgt_02_my92x1.ino index 2c851a9b1..ef23c3c9c 100644 --- a/tasmota/xlgt_02_my92x1.ino +++ b/tasmota/xlgt_02_my92x1.ino @@ -125,7 +125,8 @@ void My92x1ModuleSelected(void) digitalWrite(My92x1.pdcki_pin, LOW); My92x1.model = 2; - TasmotaGlobal.light_type = LT_RGBW; // RGBW (2 chips) as used in Lohas + TasmotaGlobal.light_type = LT_RGBW; // RGBW (2 chips) as used in Lohas +#ifdef ESP8266 if (AILIGHT == TasmotaGlobal.module_type) { // RGBW (1 chip) as used in Ailight My92x1.model = 0; // TasmotaGlobal.light_type = LT_RGBW; @@ -134,6 +135,7 @@ void My92x1ModuleSelected(void) My92x1.model = 1; TasmotaGlobal.light_type = LT_RGBWC; } +#endif // ESP8266 LightMy92x1Init(); From acb54f99f7eefa40f125462a988291d691da035b Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 17:37:15 +0100 Subject: [PATCH 27/31] Update platformio_tasmota_cenv_sample.ini --- platformio_tasmota_cenv_sample.ini | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/platformio_tasmota_cenv_sample.ini b/platformio_tasmota_cenv_sample.ini index 446f0aaa8..5aad5fecf 100644 --- a/platformio_tasmota_cenv_sample.ini +++ b/platformio_tasmota_cenv_sample.ini @@ -1,17 +1,3 @@ -;*** Beta Tasmota version for ESP32-S2 -[env:tasmota32s2] -extends = env:tasmota32_base -board = esp32s2 -build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32 -lib_ignore = - ESP8266Audio - ESP8266SAM - TTGO TWatch Library - NimBLE-Arduino - epdiy - esp32-camera - Micro-RTSP - [env:tasmota-rangeextender] build_flags = ${env.build_flags} -D FIRMWARE_RANGE_EXTENDER From 02145d59874fc8f591062345d842bbaaa7a95da0 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 17:39:47 +0100 Subject: [PATCH 28/31] mv S2 build to env32 --- platformio_tasmota_env32.ini | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/platformio_tasmota_env32.ini b/platformio_tasmota_env32.ini index f7558b5c7..aa5436e7e 100644 --- a/platformio_tasmota_env32.ini +++ b/platformio_tasmota_env32.ini @@ -102,7 +102,18 @@ lib_ignore = TTGO TWatch Library Micro-RTSP epdiy - esp32-camera + +[env:tasmota32s2] +extends = env:tasmota32_base +board = esp32s2 +build_flags = ${env:tasmota32_base.build_flags} -D FIRMWARE_TASMOTA32 -DUSE_AUTOCONF +lib_ignore = + ESP8266Audio + ESP8266SAM + TTGO TWatch Library + NimBLE-Arduino + Micro-RTSP + epdiy [env:tasmota32-AF] extends = env:tasmota32_base From da01a344ee14bd5afa5735bc49425ee9826c4823 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 19 Dec 2021 23:30:29 +0100 Subject: [PATCH 29/31] add esp32 exception decoder --- platformio_tasmota_cenv_sample.ini | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/platformio_tasmota_cenv_sample.ini b/platformio_tasmota_cenv_sample.ini index 5aad5fecf..864046de2 100644 --- a/platformio_tasmota_cenv_sample.ini +++ b/platformio_tasmota_cenv_sample.ini @@ -24,22 +24,24 @@ extends = env:tasmota32_base build_type = debug build_unflags = ${env:tasmota32_base.build_unflags} build_flags = ${env:tasmota32_base.build_flags} +monitor_filters = esp32_exception_decoder ; -Wstack-usage=300 ; *** JTAG Debug version, needs esp-prog or FT2232H or FT232H ; *** Install howto for Windows https://community.platformio.org/t/esp32-pio-unified-debugger/4541/20 [env:tasmota32-ocd] -;build_type = debug +build_type = debug extends = env:tasmota32_base debug_tool = esp-prog upload_protocol = esp-prog debug_init_break = tbreak setup build_unflags = ${env:tasmota32_base.build_unflags} build_flags = ${env:tasmota32_base.build_flags} +monitor_filters = esp32_exception_decoder ; *** JTAG Debug version, needs esp-prog or FT2232H or FT232H [env:tasmota32solo1-ocd] -;build_type = debug +build_type = debug extends = env:tasmota32_base platform_packages = ${core32solo1.platform_packages} board = esp32_solo1_4M @@ -48,3 +50,4 @@ upload_protocol = esp-prog debug_init_break = tbreak setup build_unflags = ${env:tasmota32_base.build_unflags} build_flags = ${env:tasmota32_base.build_flags} +monitor_filters = esp32_exception_decoder From 38e6a9fdf03ad2ea24e5e39b717b555aeb097225 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Mon, 20 Dec 2021 11:17:11 +0100 Subject: [PATCH 30/31] Berry created separate library `lv_berry` to isolate LVGL-Berry mapping --- lib/libesp32/berry/generate/be_const_strtab.h | 4 + .../berry/generate/be_const_strtab_def.h | 1834 +++++++++-------- lib/libesp32/berry/generate/be_fixed_cb.h | 5 +- lib/libesp32/berry_mapping/src/be_cb_module.c | 130 +- .../berry_mapping/src/be_class_wrapper.c | 59 +- .../lv_berry/generate/be_lvgl_widgets_lib.c | 30 +- lib/libesp32_lvgl/lv_berry/library.json | 6 +- .../lv_berry/src/be_lvgl_glob_lib.c | 911 ++++---- .../lv_berry/src/embedded/lvgl_glob.be | 21 +- lib/libesp32_lvgl/lv_berry/src/lv_berry.c | 287 +++ lib/libesp32_lvgl/lv_berry/src/lv_berry.h | 16 + lib/libesp32_lvgl/lv_berry/tools/convert.py | 30 +- tasmota/berry/lvgl_examples/widget_test.be | 7 +- tasmota/lvgl_berry/be_lv_c_mapping.h | 1097 ---------- tasmota/lvgl_berry/tasmota_lv_stdlib.h | 24 - tasmota/xdrv_52_3_berry_lvgl.ino | 313 --- 16 files changed, 1941 insertions(+), 2833 deletions(-) delete mode 100644 tasmota/lvgl_berry/be_lv_c_mapping.h delete mode 100644 tasmota/lvgl_berry/tasmota_lv_stdlib.h diff --git a/lib/libesp32/berry/generate/be_const_strtab.h b/lib/libesp32/berry/generate/be_const_strtab.h index cdf680ea3..430c08944 100644 --- a/lib/libesp32/berry/generate/be_const_strtab.h +++ b/lib/libesp32/berry/generate/be_const_strtab.h @@ -206,6 +206,7 @@ extern const bcstring be_const_str_add; extern const bcstring be_const_str_add_anim; extern const bcstring be_const_str_add_cmd; extern const bcstring be_const_str_add_driver; +extern const bcstring be_const_str_add_handler; extern const bcstring be_const_str_add_header; extern const bcstring be_const_str_add_rule; extern const bcstring be_const_str_addr; @@ -464,6 +465,7 @@ extern const bcstring be_const_str_length_X20in_X20bits_X20must_X20be_X20between extern const bcstring be_const_str_light; extern const bcstring be_const_str_line_dsc; extern const bcstring be_const_str_list; +extern const bcstring be_const_str_list_handlers; extern const bcstring be_const_str_listdir; extern const bcstring be_const_str_load; extern const bcstring be_const_str_load_templates; @@ -473,11 +475,13 @@ extern const bcstring be_const_str_log10; extern const bcstring be_const_str_loop; extern const bcstring be_const_str_lower; extern const bcstring be_const_str_lv; +extern const bcstring be_const_str_lv_; extern const bcstring be_const_str_lv_event; extern const bcstring be_const_str_lv_event_cb; extern const bcstring be_const_str_lv_obj; extern const bcstring be_const_str_lv_obj_class; extern const bcstring be_const_str_lvgl_event_dispatch; +extern const bcstring be_const_str_make_cb; extern const bcstring be_const_str_map; extern const bcstring be_const_str_math; extern const bcstring be_const_str_matrix; diff --git a/lib/libesp32/berry/generate/be_const_strtab_def.h b/lib/libesp32/berry/generate/be_const_strtab_def.h index cd2198905..822b96cde 100644 --- a/lib/libesp32/berry/generate/be_const_strtab_def.h +++ b/lib/libesp32/berry/generate/be_const_strtab_def.h @@ -1,716 +1,720 @@ -be_define_const_str(, "", 2166136261u, 0, 0, &be_const_str_AudioFileSourceFS); -be_define_const_str(_X0A, "\n", 252472541u, 0, 1, &be_const_str_file_X20extension_X20is_X20not_X20_X27_X2Ebe_X27_X20or_X20_X27_X2Ebec_X27); -be_define_const_str(_X20, " ", 621580159u, 0, 1, &be_const_str_gen_cb); -be_define_const_str(_X21_X3D, "!=", 2428715011u, 0, 2, &be_const_str__X3Cp_X3ECurrent_X20configuration_X3A_X20_X3C_X2Fp_X3E_X3Cp_X3E_X3Cb_X3E_X25s_X3C_X2Fb_X3E_X3C_X2Fp_X3E); -be_define_const_str(_X21_X3D_X3D, "!==", 559817114u, 0, 3, &be_const_str__X3Clegend_X3E_X3Cb_X20title_X3D_X27Autoconfiguration_X27_X3E_X26nbsp_X3BCurrent_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E); -be_define_const_str(_X23, "#", 638357778u, 0, 1, &be_const_str_refr_size); -be_define_const_str(_X23autoexec_X2Ebat, "#autoexec.bat", 3382890497u, 0, 13, &be_const_str_get_option); -be_define_const_str(_X23autoexec_X2Ebe, "#autoexec.be", 1181757091u, 0, 12, &be_const_str_every_second); -be_define_const_str(_X23display_X2Eini, "#display.ini", 182218220u, 0, 12, &be_const_str__X3Cp_X3E_X3Csmall_X3E_X26nbsp_X3B_X28This_X20feature_X20requires_X20an_X20internet_X20connection_X29_X3C_X2Fsmall_X3E_X3C_X2Fp_X3E); -be_define_const_str(_X23init_X2Ebat, "#init.bat", 3297595077u, 0, 9, &be_const_str_real); -be_define_const_str(_X23preinit_X2Ebe, "#preinit.be", 687035716u, 0, 11, &be_const_str_publish_result); -be_define_const_str(_X2502d_X25s_X2502d, "%02d%s%02d", 1587999717u, 0, 10, &be_const_str_last_modified); -be_define_const_str(_X2504d_X2D_X2502d_X2D_X2502dT_X2502d_X3A_X2502d_X3A_X2502d, "%04d-%02d-%02dT%02d:%02d:%02d", 3425528601u, 0, 29, &be_const_str__write); -be_define_const_str(_X25s_X2Eautoconf, "%s.autoconf", 3560383524u, 0, 11, &be_const_str_format); -be_define_const_str(_X26lt_X3BError_X3A_X20apply_X20new_X20or_X20remove_X26gt_X3B, "<Error: apply new or remove>", 2855507949u, 0, 34, &be_const_str___upper__); -be_define_const_str(_X26lt_X3BNone_X26gt_X3B, "<None>", 2602165498u, 0, 12, &be_const_str_SERIAL_7E2); -be_define_const_str(_X28_X29, "()", 685372826u, 0, 2, &be_const_str_get_alternate); -be_define_const_str(_X2B, "+", 772578730u, 0, 1, &be_const_str_area); -be_define_const_str(_X2C, ",", 688690635u, 0, 1, NULL); -be_define_const_str(_X2D_X2D_X3A_X2D_X2D, "--:--", 1370615441u, 0, 5, &be_const_str__X2F_X2Eautoconf); -be_define_const_str(_X2E, ".", 722245873u, 0, 1, &be_const_str__ccmd); -be_define_const_str(_X2E_X2E, "..", 2748622605u, 0, 2, NULL); -be_define_const_str(_X2Eautoconf, ".autoconf", 2524679088u, 0, 9, NULL); -be_define_const_str(_X2Ebe, ".be", 1325797348u, 0, 3, &be_const_str_digital_read); -be_define_const_str(_X2Ebec, ".bec", 3985273221u, 0, 4, &be_const_str_CFG_X3A_X20loading_X20); -be_define_const_str(_X2Elen, ".len", 850842136u, 0, 4, &be_const_str_SERIAL_6N2); -be_define_const_str(_X2Ep, ".p", 1171526419u, 0, 2, &be_const_str_arg_name); -be_define_const_str(_X2Ep1, ".p1", 249175686u, 0, 3, &be_const_str_battery_present); -be_define_const_str(_X2Ep2, ".p2", 232398067u, 0, 3, &be_const_str_b); -be_define_const_str(_X2Esize, ".size", 1965188224u, 0, 5, &be_const_str_CFG_X3A_X20loaded_X20_X27_X25s_X27); -be_define_const_str(_X2Etapp, ".tapp", 1363391594u, 0, 5, &be_const_str_Parameter_X20error); -be_define_const_str(_X2Ew, ".w", 1255414514u, 0, 2, &be_const_str_running); -be_define_const_str(_X2F, "/", 705468254u, 0, 1, &be_const_str__class); -be_define_const_str(_X2F_X2Eautoconf, "/.autoconf", 2212074393u, 0, 10, &be_const_str_connect); -be_define_const_str(_X2F_X3Frst_X3D, "/?rst=", 580074707u, 0, 6, &be_const_str_content_stop); -be_define_const_str(_X2Fac, "/ac", 3904651978u, 0, 3, &be_const_str_ins_ramp); -be_define_const_str(_X3A, ":", 1057798253u, 0, 1, &be_const_str_get_string); -be_define_const_str(_X3C, "<", 957132539u, 0, 1, &be_const_str_set_bri); -be_define_const_str(_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "

", 3546571739u, 0, 11, &be_const_str_remove); -be_define_const_str(_X3C_X2Fselect_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "

", 1863865923u, 0, 16, NULL); -be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_remove_rule); -be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str___lower__); -be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, &be_const_str_content_send_style); -be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "
", 842307168u, 0, 77, &be_const_str_bri); -be_define_const_str(_X3Cinstance_X3A_X20_X25s_X28_X25s_X2C_X20_X25s_X2C_X20_X25s_X29, "Choose a device configuration:
", 1336654704u, 0, 49, &be_const_str_cosh); -be_define_const_str(_X3Clambda_X3E, "", 607256038u, 0, 8, &be_const_str_item); -be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27Autoconfiguration_X27_X3E_X26nbsp_X3BCurrent_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Current auto-configuration", 4212500780u, 0, 82, &be_const_str_AXP192); -be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27New_X20autoconf_X27_X3E_X26nbsp_X3BSelect_X20new_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Select new auto-configuration", 1926223891u, 0, 80, &be_const_str_internal_error); -be_define_const_str(_X3Coption_X20value_X3D_X27_X25s_X27_X3E_X25s_X3C_X2Foption_X3E, "", 510303524u, 0, 30, &be_const_str_enabled); -be_define_const_str(_X3Coption_X20value_X3D_X27reset_X27_X3E_X26lt_X3BRemove_X20autoconf_X26gt_X3B_X3C_X2Foption_X3E, "", 3994619755u, 0, 54, &be_const_str_widget_cb); -be_define_const_str(_X3Cp_X20style_X3D_X27width_X3A340px_X3B_X27_X3E_X3Cb_X3EException_X3A_X3C_X2Fb_X3E_X3Cbr_X3E_X27_X25s_X27_X3Cbr_X3E_X25s_X3C_X2Fp_X3E, "

Exception:
'%s'
%s

", 4252565082u, 0, 59, &be_const_str_EVENT_DRAW_MAIN); -be_define_const_str(_X3Cp_X3E_X3C_X2Fp_X3E_X3C_X2Ffieldset_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "

", 2052843416u, 0, 25, &be_const_str_allocated); -be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3E_X26_X23129668_X3B_X20Auto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "

", 452285201u, 0, 120, &be_const_str_CFG_X3A_X20Exception_X3E_X20_X27_X25s_X27_X20_X2D_X20_X25s); -be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "

 (This feature requires an internet connection)

", 2719266486u, 0, 74, &be_const_str_str); -be_define_const_str(_X3Cp_X3ECurrent_X20configuration_X3A_X20_X3C_X2Fp_X3E_X3Cp_X3E_X3Cb_X3E_X25s_X3C_X2Fb_X3E_X3C_X2Fp_X3E, "

Current configuration:

%s

", 4115655761u, 0, 46, &be_const_str_gc); -be_define_const_str(_X3Cselect_X20name_X3D_X27zip_X27_X3E, "

", 1863865923u, 0, 16, &be_const_str_rule); +be_define_const_str(_X3C_X3D, "<=", 2499223986u, 0, 2, &be_const_str_set_chg_current); +be_define_const_str(_X3Cbutton_X20name_X3D_X27reapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3ERe_X2Dapply_X20current_X20configuration_X3C_X2Fbutton_X3E, "", 3147934216u, 0, 82, &be_const_str_find_op); +be_define_const_str(_X3Cbutton_X20name_X3D_X27zipapply_X27_X20class_X3D_X27button_X20bgrn_X27_X3EApply_X20configuration_X3C_X2Fbutton_X3E, "", 1205771629u, 0, 72, NULL); +be_define_const_str(_X3Cfieldset_X3E_X3Cstyle_X3E_X2Ebdis_X7Bbackground_X3A_X23888_X3B_X7D_X2Ebdis_X3Ahover_X7Bbackground_X3A_X23888_X3B_X7D_X3C_X2Fstyle_X3E, "
", 842307168u, 0, 77, &be_const_str_get_current_module_path); +be_define_const_str(_X3Cinstance_X3A_X20_X25s_X28_X25s_X2C_X20_X25s_X2C_X20_X25s_X29, "Choose a device configuration:
", 1336654704u, 0, 49, &be_const_str_delay); +be_define_const_str(_X3Clambda_X3E, "", 607256038u, 0, 8, &be_const_str__X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20); +be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27Autoconfiguration_X27_X3E_X26nbsp_X3BCurrent_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Current auto-configuration", 4212500780u, 0, 82, &be_const_str_CFG_X3A_X20could_X20not_X20run_X20_X25s_X20_X28_X25s_X20_X2D_X20_X25s_X29); +be_define_const_str(_X3Clegend_X3E_X3Cb_X20title_X3D_X27New_X20autoconf_X27_X3E_X26nbsp_X3BSelect_X20new_X20auto_X2Dconfiguration_X3C_X2Fb_X3E_X3C_X2Flegend_X3E, " Select new auto-configuration", 1926223891u, 0, 80, &be_const_str_CFG_X3A_X20multiple_X20autoconf_X20files_X20found_X2C_X20aborting_X20_X28_X27_X25s_X27_X20_X2B_X20_X27_X25s_X27_X29); +be_define_const_str(_X3Coption_X20value_X3D_X27_X25s_X27_X3E_X25s_X3C_X2Foption_X3E, "", 510303524u, 0, 30, &be_const_str_write); +be_define_const_str(_X3Coption_X20value_X3D_X27reset_X27_X3E_X26lt_X3BRemove_X20autoconf_X26gt_X3B_X3C_X2Foption_X3E, "", 3994619755u, 0, 54, &be_const_str_None); +be_define_const_str(_X3Cp_X20style_X3D_X27width_X3A340px_X3B_X27_X3E_X3Cb_X3EException_X3A_X3C_X2Fb_X3E_X3Cbr_X3E_X27_X25s_X27_X3Cbr_X3E_X25s_X3C_X2Fp_X3E, "

Exception:
'%s'
%s

", 4252565082u, 0, 59, &be_const_str_classof); +be_define_const_str(_X3Cp_X3E_X3C_X2Fp_X3E_X3C_X2Ffieldset_X3E_X3Cp_X3E_X3C_X2Fp_X3E, "

", 2052843416u, 0, 25, &be_const_str_button_pressed); +be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dac_X20action_X3D_X27ac_X27_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20method_X3D_X27get_X27_X3E_X3Cbutton_X3E_X26_X23129668_X3B_X20Auto_X2Dconfiguration_X3C_X2Fbutton_X3E_X3C_X2Fform_X3E_X3C_X2Fp_X3E, "

", 452285201u, 0, 120, NULL); +be_define_const_str(_X3Cp_X3E_X3Cform_X20id_X3Dreapply_X20style_X3D_X27display_X3A_X20block_X3B_X27_X20action_X3D_X27_X2Fac_X27_X20method_X3D_X27post_X27_X20, "

 (This feature requires an internet connection)

", 2719266486u, 0, 74, NULL); +be_define_const_str(_X3Cp_X3ECurrent_X20configuration_X3A_X20_X3C_X2Fp_X3E_X3Cp_X3E_X3Cb_X3E_X25s_X3C_X2Fb_X3E_X3C_X2Fp_X3E, "

Current configuration:

%s

", 4115655761u, 0, 46, &be_const_str_exec_tele); +be_define_const_str(_X3Cselect_X20name_X3D_X27zip_X27_X3E, "