https://youtu.be/2yn_j_dLoy4
https://youtu.be/wYmzSF-hkl0
https://youtu.be/OnpP7y9HBw4
https://youtu.be/nulBXs08cjs
https://youtu.be/G_QIx3eDdDc
https://youtu.be/oycXAoZCJm4
How do you synchronize the two DMAs? Triggered by the same counter?
How do you synchronize the two DMAs? Triggered by the same counter?
And it will be memory mapped. Then you can use DMA.
There are examples somewhere, afaik.
Search “stm32 FSMC TFT display” on the web..
How do you synchronize the two DMAs? Triggered by the same counter?
QVGA TFT-LCD signal interfacing with STM32F10xx FSMC
The TFT-LCD synchronization signals VSYNC and HSYNC are managed through STM32 GPIOs.
The FSMC memory interface Write-enable signal is used in inverted configuration as a DCLK (pixel clock) for the TFT,
and the FSMC chip-select signal acts as a TFT-enable signal.
When data is transferred to the FSMC bus, the chip-select is first asserted low to enable the TFT-LCD.
Then the write-enable signal is asserted low to allow 16-bit data transfer to the TFT RGB line on its low level which results in a single pixel display:
■ TFT-Enable: FSMC chip select (pin PG12)
■ VSYNC: GPIO - pin PA8
■ HSYNC: GPIO - pin PC6
■ DCLK: FSMC WE in inverted mode - pin PD5
■ Data Bus: FSMC[D0:D15]
■ SPI1: used for LCD configuration
Russian is not my specialty
But thanks for the sharing!
Russian is not my specialty
But thanks for the sharing!
https://youtu.be/U4Ci-gbDWQM
void Sort (uint16_t *mas)
{
uint8_t i,j;
uint16_t k;
for(i=1;i<10;i++)
for(j=0;j<9;j++)
if(mas[i]>mas[j])
{
k=mas[i];
mas[i]=mas[j];
mas[j]=k;
}
}
//-------------------------------------------------------------------------------
bool IsTouch(void)
{
if(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_8) == RESET)
return true;
return false;
}
//-------------------------------------------------------------------------------
bool Get_Touch_xy(__IO uint16_t *x_kor, __IO uint16_t *y_kor)
{
__IO uint16_t touch_x = 0;
__IO uint16_t touch_y = 0;
uint16_t touch_X[10]={0}, touch_Y[10]={0}, touch_avg;
uint8_t i, flag;
flag = IsTouch();
//press = IsTouch_XY();
if(flag) //Есть касание //There is a touch
{
for(i=0;i<10;i++) //Считываем десять измерений x и y в точке касания //Read ten dimensions x and y at the point of tangency
{
touch_X[i] = Get_Touch(chx);
touch_Y[i] = Get_Touch(chy);
}
Sort(touch_X); //Сортируем измерения по нарастающей //We sort the measurements by increasing
Sort(touch_Y);
touch_avg=0; //Расчитываем среднее арифметическое измерений отбросив два наименьших и два наибольших
for(i=2;i<6;i++) //We calculate the average of the arithmetic measurements by discarding the two smallest and two largest
touch_avg+=touch_X[i];
touch_x=touch_avg/4;
touch_avg=0;
for(i=2;i<6;i++)
touch_avg+=touch_Y[i];
touch_y=touch_avg/4;
touch_x -= Xmin;
touch_x = 240 - touch_x/((Xmax-Xmin)/240);
touch_y -= Ymin;
touch_y = 320 - touch_y/((Ymax-Ymin)/320);
if(touch_x > 240)
touch_x = 240;
if(touch_y > 320)
touch_y = 320;
init_XPT2046();
// *x_kor = touch_x;
// *y_kor = touch_y;
*y_kor = touch_x;
*x_kor = touch_y;
}
return flag;
}
void touchSetCoef(int16_t _ax, int16_t _bx, int16_t _ay, int16_t _by, bool colibrate)
{
I2CBuff[0] = _ax>>8; //hight byte
I2CBuff[1] = _ax; //low byte
I2CBuff[2] = _bx>>8;
I2CBuff[3] = _bx;
I2CBuff[4] = _ay>>8;
I2CBuff[5] = _ay;
I2CBuff[6] = _by>>8;
I2CBuff[7] = _by;
I2CBuff[8] = colibrate;
I2cWriteBuffer(hi2c1, EEPROM_HW_ADDRESS, 0, 8);
}
//------------------------------------------------------------------------------
void touchGetCoef(int16_t *_ax, int16_t *_bx, int16_t *_ay, int16_t *_by)
{
I2cReadBuffer(hi2c1, EEPROM_HW_ADDRESS, 0, 8);
*_ax = I2CBuff[0]<<8; //hight byte
*_ax |= I2CBuff[1]; //low byte
*_bx = I2CBuff[2]<<8;
*_bx |= I2CBuff[3];
*_ay = I2CBuff[4]<<8;
*_ay |= I2CBuff[5];
*_by = I2CBuff[6]<<8;
*_by |= I2CBuff[7];
}
//------------------------------------------------------------------------------
void TouchColibrate(void)
{
uint16_t x, y;
static Text_TypeDef text0;
static Text_TypeDef text1;
// if(!ReadStatusCalibrate())
// return;
init_text(&text0, 50, 100, BLACK, CYAN, 2, 2, MANUAL);
init_text(&text1, 50, 120, BLACK, CYAN, 2, 2, MANUAL);
sprintf(text0.text1, "%s", "Калибровка");
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (10, 10+25, 10+50, 10+25, BLACK);
drawLine (10+25, 10, 10+25, 10+50, BLACK);
DrawCircle(35, 35, 4, BLACK);
SetCursor(50, 120);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[0] = x;
yPos[0] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();
while (IsTouch());
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (LCD_PIXEL_WIDTH-10-50, 10+25, LCD_PIXEL_WIDTH-10-50+50, 10+25, BLACK);
drawLine (LCD_PIXEL_WIDTH-10-25, 10, LCD_PIXEL_WIDTH-10-25, 10+50, BLACK);
DrawCircle(285, 35, 4, BLACK);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[1] = x;
yPos[1] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();
while (IsTouch());
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (10, LCD_PIXEL_HEIGHT-10-25, 10+50, LCD_PIXEL_HEIGHT-10-25, BLACK); // hor
drawLine (10+25, LCD_PIXEL_HEIGHT-10-50, 10+25, LCD_PIXEL_HEIGHT-10-50+50, BLACK); // vert
DrawCircle(35, 205, 4, BLACK);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[2] = x;
yPos[2] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();
while (IsTouch());
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
tft_text(&text0, &text0.textvar);
drawLine (LCD_PIXEL_WIDTH-10-50, LCD_PIXEL_HEIGHT-10-25, LCD_PIXEL_WIDTH-10-50+50, LCD_PIXEL_HEIGHT-10-25, BLACK); // hor
drawLine (LCD_PIXEL_WIDTH-10-25, LCD_PIXEL_HEIGHT-10-50, LCD_PIXEL_WIDTH-10-25, LCD_PIXEL_HEIGHT-10-50+50, BLACK); // vert
DrawCircle(285, 205, 4, BLACK);
sprintf(text1.text1, "%s", "Нажимайте ");
tft_text(&text1, &text1.textvar);
tft();
while (1)
{
// ждать нажатия
while (!IsTouch());
Get_Touch_xy (&x, &y, false);
if (x < 4090 && y < 4090)
{
xPos[3] = x;
yPos[3] = y;
break;
} // if
} // while
sprintf(text1.text1, "%s", "Отпускайте");
tft_text(&text1, &text1.textvar);
tft();
while (IsTouch());
sprintf(text1.text1, "%s", " ");
tft_text(&text1, &text1.textvar);
tft();
// Расчёт коэффициентов
if(xPos[0]>xPos[3])
{
swap(xPos[0],xPos[3]);
}
axc[0] = (xPos[3] - xPos[0])/(xCenter[3] - xCenter[0]);
bxc[0] = xCenter[0] - xPos[0]/axc[0];
if(yPos[0]>yPos[3])
{
swap(yPos[0],yPos[3]);
}
ayc[0] = (yPos[3] - yPos[0])/(yCenter[3] - yCenter[0]);
byc[0] = yCenter[0] - yPos[0]/ayc[0];
touchSetCoef (axc[0], bxc[0], ayc[0], byc[0], true);
ram_bg_to_screen(SCREEN_BASE_ADDR_1);
text0.y0 = 110;
text0.text_poz = CENTER;
touchGetCoef(&ax, &bx, &ay, &by);
sprintf(text0.text1, "%s", "Калибровка завершена");
tft_text(&text0, &text0.textvar);
tft();
HAL_Delay(2000);
}




