anothermist / DISPLAYS

Display libraries for AVR & ARM | Atmel | ESP32 | STM32 HAL and FSMC | 100+ Fonts | XPT2046 SSD1289 SSD1963 HX8357 ST7735 ILI9325 ILI9341 HY32D OLED SSD1306 SSD1331 HD44780
GNU General Public License v3.0
83 stars 28 forks source link

ILI9341_HAL #1

Open Vitalij1967 opened 3 years ago

Vitalij1967 commented 3 years ago

I have a display without a touchscreen, what should I change to make the display work? thanks

Vitalij1967 commented 3 years ago

The library is super!

anothermist commented 3 years ago

Thanks! I will do continue upgrading this repository.

Vitalij1967 commented 3 years ago

It works fine but if you use a dynamic font (for example, a voltmeter, no refresh) Can fix in functions Static Void LCD_Char (int16_t x, int16_t y, const gfxglyph glyph, const gfxfont font, uint8_t size, uint32_t color24) thanks

Vitalij1967 commented 3 years ago

Try LCD_Font(5, 100, "01.23", _64_Segment_7_Num, 1,TFT9341_WHITE); HAL_Delay(1000); LCD_Font(5, 100, "65.32", _64_Segment_7_Num, 1,TFT9341_WHITE); HAL_Delay(1000);

In _64_Segment_7_Num, there is no point(".") Can you add? Which font generator are you using?

anothermist commented 3 years ago

Try LCD_Font(5, 100, "01.23", _64_Segment_7_Num, 1,TFT9341_WHITE); HAL_Delay(1000); LCD_Font(5, 100, "65.32", _64_Segment_7_Num, 1,TFT9341_WHITE); HAL_Delay(1000);

In _64_Segment_7_Num, there is no point(".") Can you add? Which font generator are you using?

Try this font generator http://oleddisplay.squix.ch/#/home Some fonts is ready here https://github.com/anothermist/DISPLAYS/tree/master/0_FONTS

Vitalij1967 commented 3 years ago

Try this font generator http://oleddisplay.squix.ch/#/home Some fonts is ready here https://github.com/anothermist/DISPLAYS/tree/master/0_FONTS

thanks

Static text, excellent. Dynamic does not work. You try this code.

LCD_Font(5, 100, "01.23", _64_Segment_7_Num, 1,WHITE); HAL_Delay(1000); LCD_Font(5, 100, "65.32", _64_Segment_7_Num, 1,WHITE); HAL_Delay(1000);

anothermist commented 3 years ago

Try this font generator http://oleddisplay.squix.ch/#/home Some fonts is ready here https://github.com/anothermist/DISPLAYS/tree/master/0_FONTS

thanks

Static text, excellent. Dynamic does not work. You try this code.

LCD_Font(5, 100, "01.23", _64_Segment_7_Num, 1,WHITE); HAL_Delay(1000); LCD_Font(5, 100, "65.32", _64_Segment_7_Num, 1,WHITE); HAL_Delay(1000);

Sorry, but I don't understand, what you mean "dynamic text". If you want just overwrite old text to new, you must save in variable old value and print this in background colour before printing updated text. Example here https://github.com/anothermist/STATION_SSD1963_F103C8T6/tree/main/00_STATION If you use ONLY(!) monospaced fonts, you can overwrite every symbol with empty space.

Vitalij1967 commented 3 years ago

20210406_084506_001

anothermist commented 3 years ago

You can send me code to gmail (anothermist@...) or telegram @anothermist

Vitalij1967 commented 3 years ago

There is no secret.

//----------------------------- UART -------------------------------------------------
// HAL_UART_Receive_DMA(&huart1, (uint8_t*) "Disconnected!", 14);
//      HAL_Delay(100);
{
        if(hdma_usart1_rx.State==HAL_DMA_STATE_READY)
        HAL_Delay(100);//DelayMicro(100);
        signalUs[13]=0;
        HAL_UART_Receive_DMA(&huart1, (uint8_t*) signalUs, 13);
      HAL_Delay(200);
       if (strcmp ("Connect to PC", signalUs) == 0)
        {
        LCD_Font(50, 20, signalUs, _12_Serif_Bold_Italic, 1,WHITE);
        hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
        }
        else
        {
            LCD_Font(50, 20, signalUs, _12_Serif_Bold_Italic, 1,GREEN); // Disconnected
            hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
        }

}

//------------------------------------------------------------------------------------------

anothermist commented 3 years ago

There is no secret.

//----------------------------- UART -------------------------------------------------
// HAL_UART_Receive_DMA(&huart1, (uint8_t*) "Disconnected!", 14);
//      HAL_Delay(100);
{
      if(hdma_usart1_rx.State==HAL_DMA_STATE_READY)
      HAL_Delay(100);//DelayMicro(100);
      signalUs[13]=0;
          HAL_UART_Receive_DMA(&huart1, (uint8_t*) signalUs, 13);
      HAL_Delay(200);
       if (strcmp ("Connect to PC", signalUs) == 0)
        {
        LCD_Font(50, 20, signalUs, _12_Serif_Bold_Italic, 1,WHITE);
      hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
        }
        else
        {
          LCD_Font(50, 20, signalUs, _12_Serif_Bold_Italic, 1,GREEN); // Disconnected
            hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
        }

}

//------------------------------------------------------------------------------------------

In this code you don’t have any command to clear old text before writing new.

// BLACK – is background color, ORANGE – is text color. Printing float example with overwrite old text

float temperatureLast, temperature;

                                                            if (temperature != temperatureLast && temperature >= -40 && temperature <= 40) {

                                                                            char weatherPrintT[4];

                                                                            if (temperatureLast >= 10 || (temperatureLast < 0 && temperatureLast > -10)) {
                                                                                            sprintf(weatherPrintT, "%.1f", temperatureLast);
                                                                                            LCD_Font(705, 40, weatherPrintT, &DejaVu_Sans_36, 1, BLACK);
                                                                            }
                                                                            else if (temperatureLast < 10 && temperatureLast > 0) {
                                                                                            sprintf(weatherPrintT, "%.1f", temperatureLast);
                                                                                            LCD_Font(731, 40, weatherPrintT, &DejaVu_Sans_36, 1, BLACK);
                                                                            }
                                                                            else if (temperatureLast <= -10) {
                                                                                            sprintf(weatherPrintT, "%2d", (int8_t)temperatureLast);
                                                                                            LCD_Font(705, 40, weatherPrintT, &DejaVu_Sans_36, 1, BLACK);
                                                                            }

                                                                            if (temperature >= 10 || (temperature < 0 && temperature > -10)) {
                                                                                            sprintf(weatherPrintT, "%.1f", temperature);
                                                                                            LCD_Font(705, 40, weatherPrintT, &DejaVu_Sans_36, 1, ORANGE);
                                                                            }
                                                                            else if (temperature < 10 && temperature > 0) {
                                                                                            sprintf(weatherPrintT, "%.1f", temperature);
                                                                                            LCD_Font(731, 40, weatherPrintT, &DejaVu_Sans_36, 1, ORANGE);
                                                                            }
                                                                            else if (temperature <= -10) {
                                                                                            sprintf(weatherPrintT, "%2d", (int8_t)temperature);
                                                                                            LCD_Font(705, 40, weatherPrintT, &DejaVu_Sans_36, 1, ORANGE);
                                                                            }

                                                                            temperatureLast = temperature;
                                                            }
Vitalij1967 commented 3 years ago

I found this code, but I can't figure out how to use it in my code.

Vitalij1967 commented 3 years ago

char signalUs[15];

Vitalij1967 commented 3 years ago

BackColor RED

anothermist commented 3 years ago

I found this code, but I can't figure out how to use it in my code.

In your code you can just override old text with background colour

print Connected: LCD_Font(50, 20, "Disconnected", _12_Serif_Bold_Italic, 1, BACKCOLOR); LCD_Font(50, 20, "Connected", _12_Serif_Bold_Italic, 1, GREEN);

print Disconnected: LCD_Font(50, 20, "Connected", _12_Serif_Bold_Italic, 1, BACKCOLOR); LCD_Font(50, 20, "Disconnected", _12_Serif_Bold_Italic, 1, GREEN);

OR create array and use sprintf (a lot examples here https://github.com/anothermist/STATION_SSD1963_F103C8T6/blob/main/00_STATION/Src/main.c)

Vitalij1967 commented 3 years ago

https://user-images.githubusercontent.com/20482208/113679563-2eeb6c80-96c0-11eb-8666-0d5120a8aaff.mp4

Flicker

anothermist commented 3 years ago

20210406_100752.mp4 Flicker

lol, can you add condition in code "if (printed now != current value) PRINT; else DONOTHING :)

Vitalij1967 commented 3 years ago
        if(hdma_usart1_rx.State==HAL_DMA_STATE_READY)
        HAL_Delay(100);//DelayMicro(100);
        signalUs[13]=0;
        HAL_UART_Receive_DMA(&huart1, (uint8_t*) signalUs, 13);
      HAL_Delay(200);

       if (strcmp ("Connect to PC", signalUs) == 0)
        {
           LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, RED);
           LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, WHITE);
        hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
        }
        else
        {
           LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, RED);
           LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, WHITE);
            hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;

        }

I'm already confused

Vitalij1967 commented 3 years ago
          //   if (strcmp ("Connect to PC", signalUs) == 0)
           if ("Connect to PC"!= signalUs)
    {
       LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, RED);
       LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, WHITE);
    hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
    }
    else
    {
       LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, RED);
       LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, WHITE);
        hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;

    }
Vitalij1967 commented 3 years ago
          //   if (strcmp ("Connect to PC", signalUs) == 0)
           if ("Connect to PC"!= signalUs)
    {
       LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, RED);
       LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, WHITE);
    hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
    }
    else
    {
      /* LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, RED);
       LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, WHITE);
        hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;*/

    }
anothermist commented 3 years ago
          //   if (strcmp ("Connect to PC", signalUs) == 0)
         if ("Connect to PC"!= signalUs)
    {
     LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, RED);
     LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, WHITE);
  hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
    }
    else
    {
    /* LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, RED);
     LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, WHITE);
        hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;*/

    }

if (NEED_UPDATE) {

   if (strcmp ("Connect to PC", signalUs) == 0)
    {
       LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, RED);
       LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, WHITE);
    hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;
    }
    else
    {
       LCD_Font(50, 20, "Connected!", _12_Serif_Bold_Italic, 1, RED);
       LCD_Font(50, 20, "Disconnected!", _12_Serif_Bold_Italic, 1, WHITE);
        hdma_usart1_rx.State=HAL_DMA_STATE_BUSY;

    }

} // else do nothing, don't print every 100ms one text if it's printed!

Vitalij1967 commented 3 years ago

while (1) { // VoltMetter();

  UARTConnect();