cancel
Showing results for 
Search instead for 
Did you mean: 

Displaying two animations simultaneously on ssd1306 oled display

ssena.1514
Associate III

Dear Sir/Madam,

Currently I am doing a project called "Displaying two animations simultaneously on ssd1306 oled display".

Problem :- For this I am using cmsis rtos v1 to create two separate tasks. One task handles one animation frames & the other task handles the other animation frames. But this is not achievable as expected.

So am I doing any mistakes?

 

/* USER CODE BEGIN Header */
/**
  ******************************************************************************
  * @file           : main.c
  * @brief          : Main program body
  ******************************************************************************
  * @attention
  *
  * Copyright (c) 2024 STMicroelectronics.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "cmsis_os.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "fonts.h"
#include "ssd1306.h"
#include "animation.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/
I2C_HandleTypeDef hi2c1;

osThreadId Task1Handle;
osThreadId Task2Handle;
/* USER CODE BEGIN PV */

/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_I2C1_Init(void);
void StartTask1(void const * argument);
void StartTask2(void const * argument);

/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

/**
  * @brief  The application entry point.
  * @retval int
  */
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 */

  /* USER CODE END SysInit */

  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_I2C1_Init();
  /* USER CODE BEGIN 2 */
  SSD1306_Init();





   SSD1306_GotoXY (0,0);
   SSD1306_Puts ("SATYABRATA", &Font_11x18, 1);
   SSD1306_GotoXY (0, 30);
   SSD1306_Puts ("SENAPATI", &Font_11x18, 1);
   SSD1306_UpdateScreen();
   HAL_Delay (1000);

   SSD1306_ScrollRight(0,7);
   HAL_Delay(10000);
   SSD1306_ScrollLeft(0,7);
   HAL_Delay(10000);
   SSD1306_Stopscroll();





  /* USER CODE END 2 */

  /* USER CODE BEGIN RTOS_MUTEX */
  /* add mutexes, ... */
  /* USER CODE END RTOS_MUTEX */

  /* USER CODE BEGIN RTOS_SEMAPHORES */
  /* add semaphores, ... */
  /* USER CODE END RTOS_SEMAPHORES */

  /* USER CODE BEGIN RTOS_TIMERS */
  /* start timers, add new ones, ... */
  /* USER CODE END RTOS_TIMERS */

  /* USER CODE BEGIN RTOS_QUEUES */
  /* add queues, ... */
  /* USER CODE END RTOS_QUEUES */

  /* Create the thread(s) */
  /* definition and creation of Task1 */
  osThreadDef(Task1, StartTask1, osPriorityBelowNormal, 0, 128);
  Task1Handle = osThreadCreate(osThread(Task1), NULL);

  /* definition and creation of Task2 */
  osThreadDef(Task2, StartTask2, osPriorityNormal, 0, 128);
  Task2Handle = osThreadCreate(osThread(Task2), NULL);

  /* USER CODE BEGIN RTOS_THREADS */
  /* add threads, ... */
  /* USER CODE END RTOS_THREADS */

  /* Start scheduler */
  osKernelStart();

  /* We should never get here as control is now taken by the scheduler */

  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */

    /* USER CODE BEGIN 3 */
 }
  /* USER CODE END 3 */
}

/**
  * @brief System Clock Configuration
  * @retval None
  */
void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
  RCC_OscInitStruct.HSIState = RCC_HSI_ON;
  RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
  RCC_OscInitStruct.PLL.PLLM = 8;
  RCC_OscInitStruct.PLL.PLLN = 84;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 4;
  if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
  {
    Error_Handler();
  }

  /** Initializes the CPU, AHB and APB buses clocks
  */
  RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
                              |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
  RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
  RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
  RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
  RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

/**
  * @brief I2C1 Initialization Function
  *  None
  * @retval None
  */
static void MX_I2C1_Init(void)
{

  /* USER CODE BEGIN I2C1_Init 0 */

  /* USER CODE END I2C1_Init 0 */

  /* USER CODE BEGIN I2C1_Init 1 */

  /* USER CODE END I2C1_Init 1 */
  hi2c1.Instance = I2C1;
  hi2c1.Init.ClockSpeed = 400000;
  hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;
  hi2c1.Init.OwnAddress1 = 0;
  hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c1.Init.OwnAddress2 = 0;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
  if (HAL_I2C_Init(&hi2c1) != HAL_OK)
  {
    Error_Handler();
  }
  /* USER CODE BEGIN I2C1_Init 2 */

  /* USER CODE END I2C1_Init 2 */

}

/**
  * @brief GPIO Initialization Function
  *  None
  * @retval None
  */
static void MX_GPIO_Init(void)
{
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */

  /* GPIO Ports Clock Enable */
  __HAL_RCC_GPIOH_CLK_ENABLE();
  __HAL_RCC_GPIOA_CLK_ENABLE();
  __HAL_RCC_GPIOB_CLK_ENABLE();

/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/* USER CODE BEGIN Header_StartTask1 */
/**
  * @brief  Function implementing the Task1 thread.
  *   argument: Not used
  * @retval None
  */
/* USER CODE END Header_StartTask1 */
void StartTask1(void const * argument)
{
  /* USER CODE BEGIN 5 */
  /* Infinite loop */
  for(;;)
  {
	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame1,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame2,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame3,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame4,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame5,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame6,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame7,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame8,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame9,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame10,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame11,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame12,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame13,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame14,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame15,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	        SSD1306_DrawBitmap(60,0,animation_frame16,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame17,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame18,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame19,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame20,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame21,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	        SSD1306_DrawBitmap(60,0,animation_frame22,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame23,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame24,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame25,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame26,64,64,1);
	  	  SSD1306_UpdateScreen();

	        SSD1306_Clear ();
	  	  SSD1306_DrawBitmap(60,0,animation_frame27,64,64,1);
	  	  SSD1306_UpdateScreen();

	  	  SSD1306_Clear ();
	        SSD1306_DrawBitmap(60,0,animation_frame28,64,64,1);
	  	  SSD1306_UpdateScreen();
    osDelay(1);
  }
  /* USER CODE END 5 */
}

/* USER CODE BEGIN Header_StartTask2 */
/**
* @brief Function implementing the Task2 thread.
*  argument: Not used
* @retval None
*/
/* USER CODE END Header_StartTask2 */
void StartTask2(void const * argument)
{
  /* USER CODE BEGIN StartTask2 */
  /* Infinite loop */
  for(;;)
  {
	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame1,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame2,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame3,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame4,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame5,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame6,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame7,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame8,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame9,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame10,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame11,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame12,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame13,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame14,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame15,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	      SSD1306_DrawBitmap(0,0,weather_frame16,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame17,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame18,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame19,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame20,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame21,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	        SSD1306_DrawBitmap(0,0,weather_frame22,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame23,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame24,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame25,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame26,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	      SSD1306_Clear ();
	 	  	  SSD1306_DrawBitmap(0,0,weather_frame27,64,64,1);
	 	  	  SSD1306_UpdateScreen();

	 	  	  SSD1306_Clear ();
	 	      SSD1306_DrawBitmap(0,0,weather_frame28,64,64,1);
	 	  	  SSD1306_UpdateScreen();

    osDelay(1);
  }
  /* USER CODE END StartTask2 */
}

/**
  * @brief  Period elapsed callback in non blocking mode
  * @note   This function is called  when TIM1 interrupt took place, inside
  * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
  * a global variable "uwTick" used as application time base.
  *   htim : TIM handle
  * @retval None
  */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{
  /* USER CODE BEGIN Callback 0 */

  /* USER CODE END Callback 0 */
  if (htim->Instance == TIM1) {
    HAL_IncTick();
  }
  /* USER CODE BEGIN Callback 1 */

  /* USER CODE END Callback 1 */
}

/**
  * @brief  This function is executed in case of error occurrence.
  * @retval None
  */
void Error_Handler(void)
{
  /* USER CODE BEGIN Error_Handler_Debug */
  /* User can add his own implementation to report the HAL error return state */
  __disable_irq();
  while (1)
  {
  }
  /* USER CODE END Error_Handler_Debug */
}

#ifdef  USE_FULL_ASSERT
/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  *   file: pointer to the source file name
  *   line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t *file, uint32_t line)
{
  /* USER CODE BEGIN 6 */
  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */

 

Please inform me if possible.

I am attaching the main.c file kindly check it.

IDE - STM32cubeIDE 1.15.0

Board - STM32F401VC Discovery Kit

 

Thanks & Regards

Satyabrata Senapati(Firmware Engineer)

1 ACCEPTED SOLUTION

Accepted Solutions
nouirakh
ST Employee

Hello @ssena.1514 

When attempting to display two animations simultaneously on an SSD1306 OLED display using CMSIS RTOS v1, there are several factors to consider that may affect the performance and outcome of your project.
In the first place, can you verify the priority of both tasks, If one task has a significantly higher priority than the other, it may hog the CPU time, causing the lower priority task to be starved and not run as expected. Also, updating the OLED display takes time, especially if you're using I2C communication. If you attempt to update the display too frequently, the display may not have enough time to complete the update before the next update is requested.
Another interesting point, using osDelay(1) will only delay the task for 1 tick. Depending on your RTOS configuration, this could be too short to see the animation. You may need to adjust the delay to match the frame rate you want for your animations.
One other possible solution you can take in consideration, Buffer splitting where you divide the display buffer into separate regions, each managed by a different task. This allows multiple animations to be displayed simultaneously without interfering with each other.
For example, let's assume you want to split the display in half horizontally. Task1 will handle the top half, and Task2 will handle the bottom half.

void StartTask1(void const * argument)
{
  /* Infinite loop */
  for(;;)
  {
    // Clear only the top half of the display
    SSD1306_ClearRegion(0, 0, 128, 32); // Clear region function to be implemented

    // Draw animation frames for Task 1 in the top half
    SSD1306_DrawBitmap(0, 0, animation_frame1, 128, 32, 1);
    // ... other frames

    // Update only the top half of the display
    SSD1306_UpdateRegion(0, 0, 128, 32); // Update region function to be implemented

    osDelay(frame_delay);
  }
}

void StartTask2(void const * argument)
{
  /* Infinite loop */
  for(;;)
  {
    // Clear only the bottom half of the display
    SSD1306_ClearRegion(0, 32, 128, 32); // Clear region function to be implemented

    // Draw animation frames for Task 2 in the bottom half
    SSD1306_DrawBitmap(0, 32, weather_frame1, 128, 32, 1);
    // ... other frames

    // Update only the bottom half of the display
    SSD1306_UpdateRegion(0, 32, 128, 32); // Update region function to be implemented

    osDelay(frame_delay);
  }
}

In this example, SSD1306_ClearRegion and SSD1306_UpdateRegion are hypothetical functions that you would need to implement based on your SSD1306 library. These functions should clear and update only the specified region of the display, respectively.

 

View solution in original post

2 REPLIES 2
nouirakh
ST Employee

Hello @ssena.1514 

When attempting to display two animations simultaneously on an SSD1306 OLED display using CMSIS RTOS v1, there are several factors to consider that may affect the performance and outcome of your project.
In the first place, can you verify the priority of both tasks, If one task has a significantly higher priority than the other, it may hog the CPU time, causing the lower priority task to be starved and not run as expected. Also, updating the OLED display takes time, especially if you're using I2C communication. If you attempt to update the display too frequently, the display may not have enough time to complete the update before the next update is requested.
Another interesting point, using osDelay(1) will only delay the task for 1 tick. Depending on your RTOS configuration, this could be too short to see the animation. You may need to adjust the delay to match the frame rate you want for your animations.
One other possible solution you can take in consideration, Buffer splitting where you divide the display buffer into separate regions, each managed by a different task. This allows multiple animations to be displayed simultaneously without interfering with each other.
For example, let's assume you want to split the display in half horizontally. Task1 will handle the top half, and Task2 will handle the bottom half.

void StartTask1(void const * argument)
{
  /* Infinite loop */
  for(;;)
  {
    // Clear only the top half of the display
    SSD1306_ClearRegion(0, 0, 128, 32); // Clear region function to be implemented

    // Draw animation frames for Task 1 in the top half
    SSD1306_DrawBitmap(0, 0, animation_frame1, 128, 32, 1);
    // ... other frames

    // Update only the top half of the display
    SSD1306_UpdateRegion(0, 0, 128, 32); // Update region function to be implemented

    osDelay(frame_delay);
  }
}

void StartTask2(void const * argument)
{
  /* Infinite loop */
  for(;;)
  {
    // Clear only the bottom half of the display
    SSD1306_ClearRegion(0, 32, 128, 32); // Clear region function to be implemented

    // Draw animation frames for Task 2 in the bottom half
    SSD1306_DrawBitmap(0, 32, weather_frame1, 128, 32, 1);
    // ... other frames

    // Update only the bottom half of the display
    SSD1306_UpdateRegion(0, 32, 128, 32); // Update region function to be implemented

    osDelay(frame_delay);
  }
}

In this example, SSD1306_ClearRegion and SSD1306_UpdateRegion are hypothetical functions that you would need to implement based on your SSD1306 library. These functions should clear and update only the specified region of the display, respectively.

 

Thank you sir for your kind information. 

 

Regards 

Satyabrata Senapati