Тип принтера по умолчанию
This commit is contained in:
31
ili9341.cpp
31
ili9341.cpp
@@ -3,10 +3,7 @@
|
||||
#include "stm32f7xx_ll_spi.h"
|
||||
|
||||
ILI9341::ILI9341(PinName MOSI, PinName MISO, PinName SCK, PinName DC, PinName RST)
|
||||
: dispPort(MOSI, MISO, SCK)
|
||||
, rst(RST)
|
||||
, dc(DC)
|
||||
{
|
||||
: dispPort(MOSI, MISO, SCK), rst(RST), dc(DC) {
|
||||
// dispPort = new SPI(MOSI, MISO, SCK);
|
||||
dispPort.frequency(27000000);
|
||||
dispPort.format(8, 3);
|
||||
@@ -69,6 +66,7 @@ ILI9341::ILI9341(PinName MOSI, PinName MISO, PinName SCK, PinName DC, PinName RS
|
||||
// LCD_WR_Data(0x28); //Поворот экрана на 180 градусов
|
||||
LCD_WR_REG(0x3a); // pixel format set
|
||||
LCD_WR_Data(0x55); //16bit /pixel
|
||||
|
||||
//----------------- frame rate------------------------------
|
||||
LCD_WR_REG(0xb1);
|
||||
// frame rate
|
||||
@@ -147,19 +145,18 @@ ILI9341::ILI9341(PinName MOSI, PinName MISO, PinName SCK, PinName DC, PinName RS
|
||||
LCD_WR_REG(0x29); // display on
|
||||
}
|
||||
|
||||
void ILI9341::LCD_WR_Data(uint8_t Data)
|
||||
{
|
||||
void ILI9341::LCD_WR_Data(uint8_t Data) {
|
||||
dc = 1;
|
||||
dispPort.write(Data);
|
||||
}
|
||||
|
||||
void ILI9341::LCD_WR_REG(uint8_t Reg)
|
||||
{
|
||||
void ILI9341::LCD_WR_REG(uint8_t Reg) {
|
||||
dc = 0;
|
||||
dispPort.write(Reg);
|
||||
}
|
||||
|
||||
void ILI9341::LCD_setaddress(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) //set coordinate for print or other function
|
||||
void
|
||||
ILI9341::LCD_setaddress(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) //set coordinate for print or other function
|
||||
{
|
||||
LCD_WR_REG(0x2A);
|
||||
LCD_WR_Data(x1 >> 8);
|
||||
@@ -176,30 +173,20 @@ void ILI9341::LCD_setaddress(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
|
||||
LCD_WR_REG(0x2C); //memory write
|
||||
}
|
||||
|
||||
void ILI9341::transmitData(const uint8_t* pixels, uint16_t x, uint16_t y, uint16_t w, uint16_t h)
|
||||
{
|
||||
void ILI9341::transmitData(const uint8_t *pixels, uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
uint32_t n_bytes = w * h;
|
||||
// uint8_t lo = 0, hi = 0;
|
||||
|
||||
LCD_setaddress(x, y, x + w - 1, y + h - 1);
|
||||
|
||||
// while (LL_SPI_IsActiveFlag_BSY(SPI1)) {
|
||||
// }
|
||||
LCD_setaddress(x, y, x + w - 1U, y + h - 1U);
|
||||
dc = 1;
|
||||
|
||||
// LL_SPI_SetDataWidth((SPI_TypeDef*)SPIx, LL_SPI_DATAWIDTH_16BIT);
|
||||
dispPort.format(16, 3);
|
||||
while (n_bytes) {
|
||||
uint8_t lo = *pixels++;
|
||||
uint8_t hi = *pixels++;
|
||||
// dispPort->write(hi << 8 | lo);
|
||||
// dispPort->write(lo);
|
||||
while (!LL_SPI_IsActiveFlag_TXE(SPI1)) {
|
||||
}
|
||||
LL_SPI_TransmitData16((SPI_TypeDef*)SPIx, hi << 8 | lo);
|
||||
LL_SPI_TransmitData16(reinterpret_cast<SPI_TypeDef *>(SPIx), hi << 8 | lo);
|
||||
|
||||
n_bytes--;
|
||||
}
|
||||
// LL_SPI_SetDataWidth((SPI_TypeDef*)SPIx, LL_SPI_DATAWIDTH_8BIT);
|
||||
dispPort.format(8, 3);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,17 @@
|
||||
class ILI9341 {
|
||||
public:
|
||||
ILI9341(PinName MOSI, PinName MISO, PinName SCK, PinName DC, PinName RST);
|
||||
void transmitData(const uint8_t* pixels, uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
||||
|
||||
void transmitData(const uint8_t *pixels, uint16_t x, uint16_t y, uint16_t w, uint16_t h);
|
||||
|
||||
private:
|
||||
SPI dispPort;
|
||||
SPIName SPIx;
|
||||
|
||||
void LCD_WR_Data(uint8_t Data);
|
||||
|
||||
void LCD_WR_REG(uint8_t Reg);
|
||||
|
||||
void LCD_setaddress(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
|
||||
DigitalOut rst; //(PB_1);
|
||||
|
||||
Reference in New Issue
Block a user