Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ILI9341_HAL #1

Open
Vitalij1967 opened this issue Dec 10, 2020 · 22 comments
Open

ILI9341_HAL #1

Vitalij1967 opened this issue Dec 10, 2020 · 22 comments

Comments

@Vitalij1967
Copy link

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

@Vitalij1967
Copy link
Author

The library is super!

@anothermist
Copy link
Owner

Thanks! I will do continue upgrading this repository.

@Vitalij1967
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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
Copy link
Author

20210406_084506_001

@anothermist
Copy link
Owner

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

@Vitalij1967
Copy link
Author

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
Copy link
Owner

anothermist commented Apr 6, 2021

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
Copy link
Author

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

@Vitalij1967
Copy link
Author

char signalUs[15];

@Vitalij1967
Copy link
Author

BackColor RED

@anothermist
Copy link
Owner

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
Copy link
Author

20210406_100752.mp4

Flicker

@anothermist
Copy link
Owner

anothermist commented Apr 6, 2021

20210406_100752.mp4
Flicker

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

@Vitalij1967
Copy link
Author

       	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
Copy link
Author

          //   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
Copy link
Author

          //   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
Copy link
Owner

          //   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
Copy link
Author

while (1)
{
// VoltMetter();

  UARTConnect();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants