Initial commit
This commit is contained in:
File diff suppressed because one or more lines are too long
117
Ecran Lilygot-T-RGB/Code tests/display/XL9535_driver.cpp
Normal file
117
Ecran Lilygot-T-RGB/Code tests/display/XL9535_driver.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
#include "XL9535_driver.h"
|
||||
#include "Wire.h"
|
||||
|
||||
void XL9535::writeRegister(uint8_t reg, uint8_t *data, uint8_t len) {
|
||||
_wire->beginTransmission(_address);
|
||||
_wire->write(reg);
|
||||
for (uint8_t i = 0; i < len; i++) {
|
||||
_wire->write(data[i]);
|
||||
}
|
||||
_wire->endTransmission();
|
||||
}
|
||||
uint8_t XL9535::readRegister(uint8_t reg, uint8_t *data, uint8_t len) {
|
||||
_wire->beginTransmission(_address);
|
||||
_wire->write(reg);
|
||||
_wire->endTransmission();
|
||||
_wire->requestFrom(_address, len);
|
||||
uint8_t index = 0;
|
||||
while (index < len)
|
||||
data[index++] = _wire->read();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XL9535::begin(bool A0, bool A1, bool A2, TwoWire *wire) {
|
||||
_address = XL9535_IIC_ADDRESS | (A2 << 3) | (A1 << 2) | (A0 << 1);
|
||||
_wire = wire;
|
||||
is_found = true;
|
||||
_wire->beginTransmission(_address);
|
||||
if (!_wire->endTransmission()) {
|
||||
Serial.println("Found xl9535");
|
||||
} else {
|
||||
Serial.println("xl9535 not found");
|
||||
is_found = false;
|
||||
}
|
||||
}
|
||||
void XL9535::pinMode(uint8_t pin, uint8_t mode) {
|
||||
if (is_found) {
|
||||
uint8_t port = 0;
|
||||
if (pin > 7) {
|
||||
readRegister(XL9535_CONFIG_PORT_1_REG, &port, 1);
|
||||
if (mode == OUTPUT) {
|
||||
port = port & (~(1 << (pin - 10)));
|
||||
} else {
|
||||
port = port | (1 << (pin - 10));
|
||||
}
|
||||
writeRegister(XL9535_CONFIG_PORT_1_REG, &port, 1);
|
||||
|
||||
} else {
|
||||
readRegister(XL9535_CONFIG_PORT_0_REG, &port, 1);
|
||||
if (mode == OUTPUT) {
|
||||
port = port & (~(1 << pin));
|
||||
} else {
|
||||
port = port | (1 << pin);
|
||||
}
|
||||
writeRegister(XL9535_CONFIG_PORT_0_REG, &port, 1);
|
||||
}
|
||||
} else {
|
||||
Serial.println("xl9535 not found");
|
||||
}
|
||||
}
|
||||
void XL9535::pinMode8(uint8_t port, uint8_t pin, uint8_t mode) {
|
||||
if (is_found) {
|
||||
uint8_t _pin = (mode != OUTPUT) ? pin : ~pin;
|
||||
if (port) {
|
||||
writeRegister(XL9535_CONFIG_PORT_1_REG, &_pin, 1);
|
||||
} else {
|
||||
writeRegister(XL9535_CONFIG_PORT_0_REG, &_pin, 1);
|
||||
}
|
||||
} else {
|
||||
Serial.println("xl9535 not found");
|
||||
}
|
||||
}
|
||||
|
||||
void XL9535::digitalWrite(uint8_t pin, uint8_t val) {
|
||||
if (is_found) {
|
||||
uint8_t port = 0;
|
||||
uint8_t reg_data = 0;
|
||||
if (pin > 7) {
|
||||
readRegister(XL9535_OUTPUT_PORT_1_REG, ®_data, 1);
|
||||
reg_data = reg_data & (~(1 << (pin - 10)));
|
||||
port = reg_data | val << (pin - 10);
|
||||
writeRegister(XL9535_OUTPUT_PORT_1_REG, &port, 1);
|
||||
} else {
|
||||
readRegister(XL9535_OUTPUT_PORT_0_REG, ®_data, 1);
|
||||
reg_data = reg_data & (~(1 << pin));
|
||||
port = reg_data | val << pin;
|
||||
writeRegister(XL9535_OUTPUT_PORT_0_REG, &port, 1);
|
||||
}
|
||||
} else {
|
||||
Serial.println("xl9535 not found");
|
||||
}
|
||||
}
|
||||
|
||||
int XL9535::digitalRead(uint8_t pin) {
|
||||
if (is_found) {
|
||||
int state = 0;
|
||||
uint8_t port = 0;
|
||||
if (pin > 7) {
|
||||
readRegister(XL9535_INPUT_PORT_1_REG, &port, 1);
|
||||
state = port & (pin - 10) ? 1 : 0;
|
||||
} else {
|
||||
readRegister(XL9535_INPUT_PORT_0_REG, &port, 1);
|
||||
state = port & pin ? 1 : 0;
|
||||
}
|
||||
return state;
|
||||
} else {
|
||||
Serial.println("xl9535 not found");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void XL9535::read_all_reg() {
|
||||
uint8_t data;
|
||||
for (uint8_t i = 0; i < 8; i++) {
|
||||
readRegister(i, &data, 1);
|
||||
Serial.printf("0x%02x : 0x%02X \r\n", i, data);
|
||||
}
|
||||
}
|
||||
37
Ecran Lilygot-T-RGB/Code tests/display/XL9535_driver.h
Normal file
37
Ecran Lilygot-T-RGB/Code tests/display/XL9535_driver.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#pragma once
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "Wire.h"
|
||||
|
||||
#define XL9535_IIC_ADDRESS 0X20
|
||||
|
||||
#define XL9535_INPUT_PORT_0_REG 0X00
|
||||
#define XL9535_INPUT_PORT_1_REG 0X01
|
||||
#define XL9535_OUTPUT_PORT_0_REG 0X02
|
||||
#define XL9535_OUTPUT_PORT_1_REG 0X03
|
||||
#define XL9535_INVERSION_PORT_0_REG 0X04
|
||||
#define XL9535_INVERSION_PORT_1_REG 0X05
|
||||
#define XL9535_CONFIG_PORT_0_REG 0X06
|
||||
#define XL9535_CONFIG_PORT_1_REG 0X07
|
||||
|
||||
class XL9535 {
|
||||
public:
|
||||
XL9535(){};
|
||||
~XL9535(){};
|
||||
|
||||
void begin(bool A0 = 0, bool A1 = 0, bool A2 = 0, TwoWire *wire = &Wire);
|
||||
void pinMode(uint8_t pin, uint8_t mode);
|
||||
void pinMode8(uint8_t port, uint8_t pin, uint8_t mode);
|
||||
|
||||
void digitalWrite(uint8_t pin, uint8_t val);
|
||||
int digitalRead(uint8_t pin);
|
||||
void read_all_reg();
|
||||
|
||||
protected:
|
||||
void writeRegister(uint8_t reg, uint8_t *data, uint8_t len);
|
||||
uint8_t readRegister(uint8_t reg, uint8_t *data, uint8_t len);
|
||||
|
||||
uint8_t _address;
|
||||
TwoWire *_wire;
|
||||
bool is_found;
|
||||
};
|
||||
56
Ecran Lilygot-T-RGB/Code tests/display/data/index.html
Normal file
56
Ecran Lilygot-T-RGB/Code tests/display/data/index.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Conversion d'image en C</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Conversion d'image en C</h1>
|
||||
|
||||
<input type="file" id="imageInput" accept="image/*" onchange="convertImage()">
|
||||
|
||||
<div id="result">
|
||||
<!-- L'image convertie sera affichée ici -->
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function convertImage() {
|
||||
const inputElement = document.getElementById("imageInput");
|
||||
const file = inputElement.files[0];
|
||||
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function(event) {
|
||||
const image = new Image();
|
||||
image.src = event.target.result;
|
||||
|
||||
image.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.width = 480;
|
||||
canvas.height = 480;
|
||||
const context = canvas.getContext("2d");
|
||||
|
||||
context.drawImage(image, 0, 0, 480, 480);
|
||||
|
||||
const imageData = context.getImageData(0, 0, 480, 480).data;
|
||||
const outputArray = [];
|
||||
|
||||
for (let i = 0; i < imageData.length; i += 4) {
|
||||
const r = imageData[i];
|
||||
const g = imageData[i + 1];
|
||||
const b = imageData[i + 2];
|
||||
const rgb565 = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);
|
||||
outputArray.push(`0x${rgb565.toString(16).toUpperCase()}, `);
|
||||
}
|
||||
|
||||
const resultDiv = document.getElementById("result");
|
||||
resultDiv.innerHTML = `<h2>Image convertie en tableau C :</h2><pre>const uint16_t image_data[] = {\n${outputArray.join("")}\n};</pre>`;
|
||||
};
|
||||
};
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
310
Ecran Lilygot-T-RGB/Code tests/display/display.ino
Normal file
310
Ecran Lilygot-T-RGB/Code tests/display/display.ino
Normal file
@@ -0,0 +1,310 @@
|
||||
#include "Wire.h"
|
||||
#include "XL9535_driver.h"
|
||||
#include "esp_lcd_panel_io.h"
|
||||
#include "esp_lcd_panel_ops.h"
|
||||
#include "esp_lcd_panel_rgb.h"
|
||||
#include "esp_lcd_panel_vendor.h"
|
||||
#include "250px-Pikachu-DEPS.h"
|
||||
#include "pin_config.h"
|
||||
#include <Arduino.h>
|
||||
#include <SPIFFS.h>
|
||||
|
||||
#define USING_2_1_INC_CST820 1 // Full circle 2.1 inches using CST820 touch screen
|
||||
|
||||
#if !defined(USING_2_1_INC_CST820)
|
||||
#error "Please define the size of the screen and open the macro definition at the top of the sketch"
|
||||
#endif
|
||||
|
||||
void setupSPIFFS1() {
|
||||
if (SPIFFS.begin()) {
|
||||
Serial.println("Système de fichiers SPIFFS monté avec succès");
|
||||
} else {
|
||||
Serial.println("Erreur lors du montage du système de fichiers SPIFFS");
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t lireVariableDepuisSPIFFS(const char* nomFichier, const char* nomVariable) {
|
||||
if (!SPIFFS.begin(true)) {
|
||||
Serial.println("Erreur lors de l'initialisation de SPIFFS");
|
||||
return 0; // Retourner 0 en cas d'erreur
|
||||
}
|
||||
|
||||
File file = SPIFFS.open(nomFichier, "r");
|
||||
if (!file) {
|
||||
Serial.println("Erreur lors de l'ouverture du fichier");
|
||||
return 0; // Retourner 0 en cas d'erreur
|
||||
}
|
||||
|
||||
while (file.available()) {
|
||||
String line = file.readStringUntil('\n');
|
||||
int equalsIndex = line.indexOf('=');
|
||||
if (equalsIndex != -1) {
|
||||
String variableName = line.substring(0, equalsIndex);
|
||||
String variableValue = line.substring(equalsIndex + 1);
|
||||
|
||||
if (variableName == nomVariable) {
|
||||
file.close(); // Fermer le fichier
|
||||
return variableValue.toInt(); // Convertir la valeur en uint16_t et la retourner
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file.close(); // Fermer le fichier
|
||||
return 0; // Retourner 0 si la variable n'a pas été trouvée ou en cas d'erreur
|
||||
}
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint8_t cmd;
|
||||
uint8_t data[16];
|
||||
uint8_t databytes; // No of data in data; bit 7 = delay after set; 0xFF = end of cmds.
|
||||
} lcd_init_cmd_t;
|
||||
|
||||
DRAM_ATTR static const lcd_init_cmd_t st_init_cmds[] = {
|
||||
{0xFF, {0x77, 0x01, 0x00, 0x00, 0x10}, 0x05},
|
||||
{0xC0, {0x3b, 0x00}, 0x02},
|
||||
{0xC1, {0x0b, 0x02}, 0x02},
|
||||
{0xC2, {0x07, 0x02}, 0x02},
|
||||
{0xCC, {0x10}, 0x01},
|
||||
{0xCD, {0x08}, 0x01}, // 用565时屏蔽 666打开
|
||||
{0xb0, {0x00, 0x11, 0x16, 0x0e, 0x11, 0x06, 0x05, 0x09, 0x08, 0x21, 0x06, 0x13, 0x10, 0x29, 0x31, 0x18}, 0x10},
|
||||
{0xb1, {0x00, 0x11, 0x16, 0x0e, 0x11, 0x07, 0x05, 0x09, 0x09, 0x21, 0x05, 0x13, 0x11, 0x2a, 0x31, 0x18}, 0x10},
|
||||
{0xFF, {0x77, 0x01, 0x00, 0x00, 0x11}, 0x05},
|
||||
{0xb0, {0x6d}, 0x01},
|
||||
{0xb1, {0x37}, 0x01},
|
||||
{0xb2, {0x81}, 0x01},
|
||||
{0xb3, {0x80}, 0x01},
|
||||
{0xb5, {0x43}, 0x01},
|
||||
{0xb7, {0x85}, 0x01},
|
||||
{0xb8, {0x20}, 0x01},
|
||||
{0xc1, {0x78}, 0x01},
|
||||
{0xc2, {0x78}, 0x01},
|
||||
{0xc3, {0x8c}, 0x01},
|
||||
{0xd0, {0x88}, 0x01},
|
||||
{0xe0, {0x00, 0x00, 0x02}, 0x03},
|
||||
{0xe1, {0x03, 0xa0, 0x00, 0x00, 0x04, 0xa0, 0x00, 0x00, 0x00, 0x20, 0x20}, 0x0b},
|
||||
{0xe2, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x0d},
|
||||
{0xe3, {0x00, 0x00, 0x11, 0x00}, 0x04},
|
||||
{0xe4, {0x22, 0x00}, 0x02},
|
||||
{0xe5, {0x05, 0xec, 0xa0, 0xa0, 0x07, 0xee, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x10},
|
||||
{0xe6, {0x00, 0x00, 0x11, 0x00}, 0x04},
|
||||
{0xe7, {0x22, 0x00}, 0x02},
|
||||
{0xe8, {0x06, 0xed, 0xa0, 0xa0, 0x08, 0xef, 0xa0, 0xa0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, 0x10},
|
||||
{0xeb, {0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00}, 0x07},
|
||||
{0xed, {0xff, 0xff, 0xff, 0xba, 0x0a, 0xbf, 0x45, 0xff, 0xff, 0x54, 0xfb, 0xa0, 0xab, 0xff, 0xff, 0xff}, 0x10},
|
||||
{0xef, {0x10, 0x0d, 0x04, 0x08, 0x3f, 0x1f}, 0x06},
|
||||
{0xFF, {0x77, 0x01, 0x00, 0x00, 0x13}, 0x05},
|
||||
{0xef, {0x08}, 0x01},
|
||||
{0xFF, {0x77, 0x01, 0x00, 0x00, 0x00}, 0x05},
|
||||
{0x36, {0x08}, 0x01},
|
||||
{0x3a, {0x66}, 0x01},
|
||||
{0x11, {0x00}, 0x80},
|
||||
// {0xFF, {0x77, 0x01, 0x00, 0x00, 0x12}, 0x05},
|
||||
// {0xd1, {0x81}, 0x01},
|
||||
// {0xd2, {0x06}, 0x01},
|
||||
{0x29, {0x00}, 0x80},
|
||||
{0, {0}, 0xff}
|
||||
};
|
||||
|
||||
XL9535 xl;
|
||||
void tft_init(void);
|
||||
void lcd_cmd(const uint8_t cmd);
|
||||
void lcd_data(const uint8_t *data, int len);
|
||||
|
||||
void scan_iic(void)
|
||||
{
|
||||
byte error, address;
|
||||
int nDevices = 0;
|
||||
Serial.println("Scanning for I2C devices ...");
|
||||
for (address = 0x01; address < 0x7f; address++) {
|
||||
Wire.beginTransmission(address);
|
||||
error = Wire.endTransmission();
|
||||
if (error == 0) {
|
||||
Serial.printf("I2C device found at address 0x%02X\n", address);
|
||||
nDevices++;
|
||||
} else if (error != 2) {
|
||||
Serial.printf("Error %d at address 0x%02X\n", error, address);
|
||||
}
|
||||
}
|
||||
if (nDevices == 0) {
|
||||
Serial.println("No I2C devices found");
|
||||
}
|
||||
}
|
||||
|
||||
void print_chip_info(void)
|
||||
{
|
||||
Serial.print("Chip: ");
|
||||
Serial.println(ESP.getChipModel());
|
||||
Serial.print("ChipRevision: ");
|
||||
Serial.println(ESP.getChipRevision());
|
||||
Serial.print("Psram size: ");
|
||||
Serial.print(ESP.getPsramSize() / 1024);
|
||||
Serial.println("KB");
|
||||
Serial.print("Flash size: ");
|
||||
Serial.print(ESP.getFlashChipSize() / 1024);
|
||||
Serial.println("KB");
|
||||
Serial.print("CPU frequency: ");
|
||||
Serial.print(ESP.getCpuFreqMHz());
|
||||
Serial.println("MHz");
|
||||
}
|
||||
|
||||
void reload_screen_and_image(image) {
|
||||
xl.begin();
|
||||
uint8_t pin = (1 << PWR_EN_PIN) | (1 << LCD_CS_PIN) | (1 << TP_RES_PIN) | (1 << LCD_SDA_PIN) | (1 << LCD_CLK_PIN) |
|
||||
(1 << LCD_RST_PIN) | (1 << SD_CS_PIN);
|
||||
|
||||
xl.pinMode8(0, pin, OUTPUT);
|
||||
xl.digitalWrite(PWR_EN_PIN, 1);
|
||||
//print_chip_info();
|
||||
pinMode(EXAMPLE_PIN_NUM_BK_LIGHT, OUTPUT);
|
||||
digitalWrite(EXAMPLE_PIN_NUM_BK_LIGHT, EXAMPLE_LCD_BK_LIGHT_ON_LEVEL);
|
||||
|
||||
tft_init();
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
esp_lcd_rgb_panel_config_t panel_config = {
|
||||
.clk_src = LCD_CLK_SRC_PLL160M,
|
||||
.timings =
|
||||
{
|
||||
.pclk_hz = EXAMPLE_LCD_PIXEL_CLOCK_HZ,
|
||||
.h_res = EXAMPLE_LCD_H_RES,
|
||||
.v_res = EXAMPLE_LCD_V_RES,
|
||||
// The following parameters should refer to LCD spec
|
||||
.hsync_pulse_width = 1,
|
||||
.hsync_back_porch = 30,
|
||||
.hsync_front_porch = 50,
|
||||
.vsync_pulse_width = 1,
|
||||
.vsync_back_porch = 30,
|
||||
.vsync_front_porch = 20,
|
||||
.flags =
|
||||
{
|
||||
.pclk_active_neg = 1,
|
||||
},
|
||||
},
|
||||
.data_width = 16, // RGB565 in parallel mode, thus 16bit in width
|
||||
.psram_trans_align = 64,
|
||||
.hsync_gpio_num = EXAMPLE_PIN_NUM_HSYNC,
|
||||
.vsync_gpio_num = EXAMPLE_PIN_NUM_VSYNC,
|
||||
.de_gpio_num = EXAMPLE_PIN_NUM_DE,
|
||||
.pclk_gpio_num = EXAMPLE_PIN_NUM_PCLK,
|
||||
.data_gpio_nums =
|
||||
{
|
||||
// EXAMPLE_PIN_NUM_DATA0,
|
||||
EXAMPLE_PIN_NUM_DATA13,
|
||||
EXAMPLE_PIN_NUM_DATA14,
|
||||
EXAMPLE_PIN_NUM_DATA15,
|
||||
EXAMPLE_PIN_NUM_DATA16,
|
||||
EXAMPLE_PIN_NUM_DATA17,
|
||||
|
||||
EXAMPLE_PIN_NUM_DATA6,
|
||||
EXAMPLE_PIN_NUM_DATA7,
|
||||
EXAMPLE_PIN_NUM_DATA8,
|
||||
EXAMPLE_PIN_NUM_DATA9,
|
||||
EXAMPLE_PIN_NUM_DATA10,
|
||||
EXAMPLE_PIN_NUM_DATA11,
|
||||
// EXAMPLE_PIN_NUM_DATA12,
|
||||
|
||||
EXAMPLE_PIN_NUM_DATA1,
|
||||
EXAMPLE_PIN_NUM_DATA2,
|
||||
EXAMPLE_PIN_NUM_DATA3,
|
||||
EXAMPLE_PIN_NUM_DATA4,
|
||||
EXAMPLE_PIN_NUM_DATA5,
|
||||
},
|
||||
.disp_gpio_num = EXAMPLE_PIN_NUM_DISP_EN,
|
||||
.on_frame_trans_done = NULL,
|
||||
.user_ctx = NULL,
|
||||
.flags =
|
||||
{
|
||||
.fb_in_psram = 1, // allocate frame buffer in PSRAM
|
||||
},
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(&panel_config, &panel_handle));
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
|
||||
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
|
||||
|
||||
esp_lcd_panel_draw_bitmap(panel_handle, 0, 0, 480, 480, image);
|
||||
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
pinMode(BAT_VOLT_PIN, ANALOG);
|
||||
Serial.begin(115200);
|
||||
|
||||
Wire.begin(IIC_SDA_PIN, IIC_SCL_PIN, (uint32_t)400000);
|
||||
Serial.begin(115200);
|
||||
reload_screen_and_image(image_data);
|
||||
delay(10000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
// put your main code here, to run repeatedly:
|
||||
delay(2);
|
||||
}
|
||||
|
||||
void lcd_send_data(uint8_t data)
|
||||
{
|
||||
uint8_t n;
|
||||
for (n = 0; n < 8; n++) {
|
||||
if (data & 0x80)
|
||||
xl.digitalWrite(LCD_SDA_PIN, 1);
|
||||
else
|
||||
xl.digitalWrite(LCD_SDA_PIN, 0);
|
||||
|
||||
data <<= 1;
|
||||
xl.digitalWrite(LCD_CLK_PIN, 0);
|
||||
xl.digitalWrite(LCD_CLK_PIN, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void lcd_cmd(const uint8_t cmd)
|
||||
{
|
||||
xl.digitalWrite(LCD_CS_PIN, 0);
|
||||
xl.digitalWrite(LCD_SDA_PIN, 0);
|
||||
xl.digitalWrite(LCD_CLK_PIN, 0);
|
||||
xl.digitalWrite(LCD_CLK_PIN, 1);
|
||||
lcd_send_data(cmd);
|
||||
xl.digitalWrite(LCD_CS_PIN, 1);
|
||||
}
|
||||
|
||||
void lcd_data(const uint8_t *data, int len)
|
||||
{
|
||||
uint32_t i = 0;
|
||||
if (len == 0)
|
||||
return; // no need to send anything
|
||||
do {
|
||||
xl.digitalWrite(LCD_CS_PIN, 0);
|
||||
xl.digitalWrite(LCD_SDA_PIN, 1);
|
||||
xl.digitalWrite(LCD_CLK_PIN, 0);
|
||||
xl.digitalWrite(LCD_CLK_PIN, 1);
|
||||
lcd_send_data(*(data + i));
|
||||
xl.digitalWrite(LCD_CS_PIN, 1);
|
||||
i++;
|
||||
} while (len--);
|
||||
}
|
||||
|
||||
void tft_init(void)
|
||||
{
|
||||
xl.digitalWrite(LCD_CS_PIN, 1);
|
||||
xl.digitalWrite(LCD_SDA_PIN, 1);
|
||||
xl.digitalWrite(LCD_CLK_PIN, 1);
|
||||
|
||||
// Reset the display
|
||||
xl.digitalWrite(LCD_RST_PIN, 1);
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
xl.digitalWrite(LCD_RST_PIN, 0);
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
xl.digitalWrite(LCD_RST_PIN, 1);
|
||||
vTaskDelay(200 / portTICK_PERIOD_MS);
|
||||
int cmd = 0;
|
||||
while (st_init_cmds[cmd].databytes != 0xff) {
|
||||
lcd_cmd(st_init_cmds[cmd].cmd);
|
||||
lcd_data(st_init_cmds[cmd].data, st_init_cmds[cmd].databytes & 0x1F);
|
||||
if (st_init_cmds[cmd].databytes & 0x80) {
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
}
|
||||
cmd++;
|
||||
}
|
||||
Serial.println("Register setup complete");
|
||||
}
|
||||
10
Ecran Lilygot-T-RGB/Code tests/display/pikachu_run.h
Normal file
10
Ecran Lilygot-T-RGB/Code tests/display/pikachu_run.h
Normal file
File diff suppressed because one or more lines are too long
57
Ecran Lilygot-T-RGB/Code tests/display/pin_config.h
Normal file
57
Ecran Lilygot-T-RGB/Code tests/display/pin_config.h
Normal file
@@ -0,0 +1,57 @@
|
||||
#pragma once
|
||||
|
||||
#define WIFI_SSID "xinyuandianzi"
|
||||
#define WIFI_PASSWORD "AA15994823428"
|
||||
|
||||
#define EXAMPLE_LCD_PIXEL_CLOCK_HZ (8 * 1000 * 1000)
|
||||
#define EXAMPLE_LCD_BK_LIGHT_ON_LEVEL 1
|
||||
#define EXAMPLE_LCD_BK_LIGHT_OFF_LEVEL !EXAMPLE_LCD_BK_LIGHT_ON_LEVEL
|
||||
#define EXAMPLE_PIN_NUM_BK_LIGHT 46
|
||||
#define EXAMPLE_PIN_NUM_HSYNC 47
|
||||
#define EXAMPLE_PIN_NUM_VSYNC 41
|
||||
#define EXAMPLE_PIN_NUM_DE 45
|
||||
#define EXAMPLE_PIN_NUM_PCLK 42
|
||||
// #define EXAMPLE_PIN_NUM_DATA0 44
|
||||
#define EXAMPLE_PIN_NUM_DATA1 21
|
||||
#define EXAMPLE_PIN_NUM_DATA2 18
|
||||
#define EXAMPLE_PIN_NUM_DATA3 17
|
||||
#define EXAMPLE_PIN_NUM_DATA4 16
|
||||
#define EXAMPLE_PIN_NUM_DATA5 15
|
||||
#define EXAMPLE_PIN_NUM_DATA6 14
|
||||
#define EXAMPLE_PIN_NUM_DATA7 13
|
||||
#define EXAMPLE_PIN_NUM_DATA8 12
|
||||
#define EXAMPLE_PIN_NUM_DATA9 11
|
||||
#define EXAMPLE_PIN_NUM_DATA10 10
|
||||
#define EXAMPLE_PIN_NUM_DATA11 9
|
||||
// #define EXAMPLE_PIN_NUM_DATA12 43
|
||||
#define EXAMPLE_PIN_NUM_DATA13 7
|
||||
#define EXAMPLE_PIN_NUM_DATA14 6
|
||||
#define EXAMPLE_PIN_NUM_DATA15 5
|
||||
#define EXAMPLE_PIN_NUM_DATA16 3
|
||||
#define EXAMPLE_PIN_NUM_DATA17 2
|
||||
#define EXAMPLE_PIN_NUM_DISP_EN -1
|
||||
|
||||
// The pixel number in horizontal and vertical
|
||||
#define EXAMPLE_LCD_H_RES 480
|
||||
#define EXAMPLE_LCD_V_RES 480
|
||||
|
||||
#define IIC_SCL_PIN 48
|
||||
#define IIC_SDA_PIN 8
|
||||
|
||||
#define SD_CLK_PIN 39
|
||||
#define SD_CMD_PIN 40
|
||||
#define SD_D0_PIN 38
|
||||
|
||||
#define BAT_VOLT_PIN 4
|
||||
#define TP_INT_PIN 1
|
||||
|
||||
#define BOOT_BTN_PIN 0
|
||||
|
||||
/* XL9535 --- PIN - P0*/
|
||||
#define TP_RES_PIN 1
|
||||
#define PWR_EN_PIN 2
|
||||
#define LCD_CS_PIN 3
|
||||
#define LCD_SDA_PIN 4
|
||||
#define LCD_CLK_PIN 5
|
||||
#define LCD_RST_PIN 6
|
||||
#define SD_CS_PIN 7
|
||||
Reference in New Issue
Block a user