Jump to content

sabrat

Members
  • Posts

    4
  • Joined

  • Last visited

About sabrat

  • Birthday 05/30/1984

Recent Profile Visitors

390 profile views
  1. Thanks! I`ll try to update the display as you advise. When is release 3.0 expected?
  2. Thanks for answer. I have my embed library. SPI speed there is much slower than in the project with uGFX. And there are no blinks. Drawing there is different. The text box is drawn completely at the same time - pixels of the symbol color and background color pixels. In uGFX, first the field is drawn with the background color, and then the pixels are drawn with the color of the characters. Therefore, I see "blinking." I can not raise the SPI frequency anymore - this is the maximum for the STM32F103C8. Can I change the drawing method?
  3. Hi to all. Sorry my eanglish, i`m from Ukraine. I was porting uGFX to STM32F103C8T6, but i have a problem. Image is blinking. I use SPI connection. Maybe I'm using the wrong text output function? Why is the entire text field redrawn? Please, help me. Here is a video of what is happening /* * This file is subject to the terms of the GFX License. If a copy of * the license was not distributed with this file, you can obtain one at: * * http://ugfx.io/license.html */ #ifndef _GDISP_LLD_BOARD_H #define _GDISP_LLD_BOARD_H #include "gfx.h" #include "spi.h" #include "gpio.h" #include "stm32f1xx_hal.h" #include "main.h" #define LCD_PORT GPIOB #define LCD_MOSI GPIO_PIN_15 #define LCD_MISO GPIO_PIN_14 #define LCD_SCK GPIO_PIN_13 #define LCD_CS GPIO_PIN_12 #define LCD_DC GPIO_PIN_10 #define LCD_RES GPIO_PIN_11 extern SPI_HandleTypeDef hspi2; static GFXINLINE void init_board(GDisplay *g) { (void) g; // As we are not using multiple displays we set g->board to NULL as we don't use it. hspi2.Instance = SPI2; hspi2.Init.Mode = SPI_MODE_MASTER; hspi2.Init.Direction = SPI_DIRECTION_2LINES; hspi2.Init.DataSize = SPI_DATASIZE_8BIT; hspi2.Init.CLKPolarity = SPI_POLARITY_LOW; hspi2.Init.CLKPhase = SPI_PHASE_1EDGE; hspi2.Init.NSS = SPI_NSS_SOFT; hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_2; hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB; hspi2.Init.TIMode = SPI_TIMODE_DISABLE; hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; hspi2.Init.CRCPolynomial = 10; if (HAL_SPI_Init(&hspi2) != HAL_OK) { Error_Handler(); } } static GFXINLINE void post_init_board(GDisplay *g) { (void) g; } static GFXINLINE void setpin_reset(GDisplay *g, gBool state) { (void) g; if(state == 1){ HAL_GPIO_WritePin(GPIOB, LCD_RES, GPIO_PIN_RESET);} else { HAL_GPIO_WritePin(LCD_PORT, LCD_RES, GPIO_PIN_SET);} } static GFXINLINE void set_backlight(GDisplay *g, gU8 percent) { (void) g; if (percent > 0) { HAL_GPIO_WritePin(GPIOB, LCD_BL_Pin, GPIO_PIN_SET); } else { HAL_GPIO_WritePin(GPIOB, LCD_BL_Pin, GPIO_PIN_RESET); } } static GFXINLINE void acquire_bus(GDisplay *g) { (void) g; } static GFXINLINE void release_bus(GDisplay *g) { (void) g; } static GFXINLINE void write_index(GDisplay *g, gU16 index) { (void) g; HAL_GPIO_WritePin(LCD_PORT, LCD_DC_Pin, GPIO_PIN_RESET); HAL_SPI_Transmit(&hspi2, (gU8*)&index, 1, 1); } static GFXINLINE void write_data(GDisplay *g, gU16 data) { (void) g; HAL_GPIO_WritePin(LCD_PORT, LCD_DC_Pin, GPIO_PIN_SET); //GPIOB->BRR=GPIO_BRR_BR10 ; //HAL_SPI_Transmit(&hspi2, (gU8*)&data, 1, 1);//Медленно работает while (!(SPI2->SR & SPI_SR_TXE)){}; // при входе на отправку проверяем - а пустой ли SPI_DR SPI2->DR = data; } static GFXINLINE void setreadmode(GDisplay *g) { (void) g; } static GFXINLINE void setwritemode(GDisplay *g) { (void) g; } static GFXINLINE gU16 read_data(GDisplay *g) { (void) g; uint8_t buffer[4]; //buffer: [0]R, [1]dummy,[2]B, [3]G HAL_GPIO_WritePin(LCD_PORT, LCD_DC_Pin, GPIO_PIN_SET); HAL_SPI_Receive(&hspi2, buffer+0, 1, 1); HAL_SPI_Receive(&hspi2, buffer+2, 1, 1); return RGB2COLOR(buffer[0], buffer[3], buffer[2]); } #endif /* _GDISP_LLD_BOARD_H */ int main(void) { /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration--------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ //____________________________ОБЯЗАТЕЛЬНО ДЛЯ ЗАПУСКА I2C на STM32F1XX______// __HAL_RCC_I2C1_CLK_ENABLE(); HAL_Delay(100); __HAL_RCC_I2C1_FORCE_RESET(); HAL_Delay(100); __HAL_RCC_I2C1_RELEASE_RESET(); HAL_Delay(100); //__________________________________________________________________________// /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_SPI2_Init(); MX_I2C1_Init(); MX_USART1_UART_Init(); /* USER CODE BEGIN 2 */ while(SysTick_Config(SystemCoreClock / 1000)); gfxInit(); HAL_Delay(100); font1 = gdispOpenFont("DejaVuSans32_aa"); //gdispDrawString(0, 0, "HELLO uGFX 2.9!", font1, GFX_WHITE); //gdispFillArea(50,50,100,100, Blue); //gdispFillCircle(100, 100, 30, Yellow); BME280_Init(); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ //HAL_Delay(1000); tf = BME280_ReadTemperature(); sprintf(str1, "Temperature: %.3f *C\r\n", tf); HAL_UART_Transmit(&huart1,(uint8_t*)str1,strlen(str1),0x1000); sprintf(str1, "%11.3f *C", tf); pf = BME280_ReadPressure(); sprintf(str1, "Pressure: %.3f Pa; %.3f hPa; %.3f mmHg\r\n", pf, pf/1000.0f, pf * 0.000750061683f); HAL_UART_Transmit(&huart1,(uint8_t*)str1,strlen(str1),0x1000); sprintf(str1, "%11.3f hPa", pf/1000.0f); sprintf(str1, "%11.3f mmHg", pf * 0.000750061683f); af = BME280_ReadAltitude(SEALEVELPRESSURE_PA); sprintf(str1, "Altitude: %.3f m\r\n", af); HAL_UART_Transmit(&huart1,(uint8_t*)str1,strlen(str1),0x1000); hf = BME280_ReadHumidity(); sprintf(str1, "Humidity: %.3f %%\r\n", hf); HAL_UART_Transmit(&huart1,(uint8_t*)str1,strlen(str1),0x1000); sprintf(str1, "%7.3f %% %4.1f m", hf, af); sprintf(temper, "Temperature: %.1f C", tf); sprintf(pressure, "Pressure: %.1f mm", pf * 0.000750061683f); sprintf(humidity, "Humidity: %.1f %%", hf); //gdispClear(GFX_BLACK); gdispFillString(0, 0, temper, font1, GFX_WHITE, GFX_BLACK); gdispFillString(0, 50, pressure, font1, GFX_WHITE, GFX_BLACK ); gdispFillString(0, 100, humidity, font1, GFX_WHITE, GFX_BLACK); //HAL_Delay(1000); //gfxMillisecondsToTicks(1000); //gdispGFlush(0); HAL_GPIO_TogglePin(GPIOC, LED_Pin); } /* USER CODE END 3 */ }
×
×
  • Create New...