Working leds
This commit is contained in:
@@ -24,7 +24,8 @@
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
// #include "ws2812b-dma-driver.h"
|
||||
#include <stdlib.h>
|
||||
#include "ws2812.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -94,12 +95,9 @@ int main(void)
|
||||
|
||||
HAL_TIM_Base_Start(&htim2);
|
||||
|
||||
int8_t test[] = { 0, 4, 7, 10, 14, 17 };
|
||||
|
||||
HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_1, test, sizeof(test));
|
||||
//HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_1);
|
||||
ws2812_Init();
|
||||
|
||||
uint8_t data[] = {0xff, 0x00, 0xff, 0x00, 0xFF, 0x00, 0xfF, 0x00};
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@@ -110,8 +108,25 @@ int main(void)
|
||||
/* USER CODE END WHILE */
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin);
|
||||
HAL_Delay(500);
|
||||
|
||||
uint8_t r = rand();
|
||||
uint8_t g = rand();
|
||||
uint8_t b = rand();
|
||||
|
||||
for (uint8_t led = 0; led < 24; led++) {
|
||||
|
||||
uint8_t r = rand();
|
||||
uint8_t g = rand();
|
||||
uint8_t b = rand();
|
||||
|
||||
ws2812_reset();
|
||||
|
||||
ws2812_set_colour(led, r, g, b);
|
||||
ws2812_update();
|
||||
HAL_Delay(20);
|
||||
}
|
||||
|
||||
HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin);
|
||||
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
@@ -135,7 +150,7 @@ void SystemClock_Config(void)
|
||||
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL5;
|
||||
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
|
||||
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
@@ -150,7 +165,7 @@ void SystemClock_Config(void)
|
||||
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
|
||||
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
|
||||
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
|
||||
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
|
||||
{
|
||||
Error_Handler();
|
||||
}
|
||||
@@ -158,6 +173,7 @@ void SystemClock_Config(void)
|
||||
|
||||
/* USER CODE BEGIN 4 */
|
||||
|
||||
|
||||
/* USER CODE END 4 */
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ void MX_TIM2_Init(void)
|
||||
htim2.Instance = TIM2;
|
||||
htim2.Init.Prescaler = 0;
|
||||
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||
htim2.Init.Period = 19;
|
||||
htim2.Init.Period = 90;
|
||||
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
||||
|
||||
Reference in New Issue
Block a user