Effects added :-)
This commit is contained in:
@@ -5,8 +5,10 @@
|
||||
* Author: ewars
|
||||
*/
|
||||
|
||||
#ifndef STM32F1XX_HAL_DRIVER_INC_WS2812_H_
|
||||
#define STM32F1XX_HAL_DRIVER_INC_WS2812_H_
|
||||
#ifndef INC_WS2812_DRV_H_
|
||||
#define INC_WS2812_DRV_H_
|
||||
|
||||
#include "stdint-gcc.h"
|
||||
|
||||
|
||||
#define LED_N 24
|
||||
@@ -23,4 +25,4 @@ void ws2812_wait(void);
|
||||
void ws2812_reset(void);
|
||||
|
||||
|
||||
#endif /* STM32F1XX_HAL_DRIVER_INC_WS2812_H_ */
|
||||
#endif /* INC_WS2812_DRV_H_ */
|
||||
18
Core/Inc/ws2812_effect.h
Normal file
18
Core/Inc/ws2812_effect.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* ws2812_effect.h
|
||||
*
|
||||
* Created on: Mar 25, 2026
|
||||
* Author: ewars
|
||||
*/
|
||||
|
||||
#ifndef INC_WS2812_EFFECT_H_
|
||||
#define INC_WS2812_EFFECT_H_
|
||||
|
||||
|
||||
void ws_Effect_RoudTheClock(void);
|
||||
void ws_Effect_RandRound(void);
|
||||
void ws_Effect_RandRand(void);
|
||||
|
||||
|
||||
|
||||
#endif /* INC_WS2812_EFFECT_H_ */
|
||||
@@ -24,8 +24,7 @@
|
||||
|
||||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include <stdlib.h>
|
||||
#include "ws2812.h"
|
||||
#include "ws2812_effect.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
@@ -98,6 +97,8 @@ int main(void)
|
||||
|
||||
ws2812_Init();
|
||||
|
||||
uint32_t mytimer = 0;
|
||||
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
@@ -109,24 +110,27 @@ int main(void)
|
||||
|
||||
/* USER CODE BEGIN 3 */
|
||||
|
||||
uint8_t r = rand();
|
||||
uint8_t g = rand();
|
||||
uint8_t b = rand();
|
||||
#define EFFECT_TIME 5000
|
||||
|
||||
for (uint8_t led = 0; led < 24; led++) {
|
||||
mytimer = HAL_GetTick();
|
||||
while(mytimer + EFFECT_TIME > HAL_GetTick()){
|
||||
ws_Effect_RoudTheClock();
|
||||
}
|
||||
|
||||
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);
|
||||
mytimer = HAL_GetTick();
|
||||
while(mytimer + EFFECT_TIME > HAL_GetTick()){
|
||||
ws_Effect_RandRound();
|
||||
}
|
||||
|
||||
HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin);
|
||||
|
||||
mytimer = HAL_GetTick();
|
||||
while(mytimer + EFFECT_TIME > HAL_GetTick()){
|
||||
ws_Effect_RandRand();
|
||||
}
|
||||
|
||||
|
||||
//HAL_GPIO_TogglePin(LED_Green_GPIO_Port, LED_Green_Pin);
|
||||
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
* Author: ewars
|
||||
*/
|
||||
|
||||
#include "stdint-gcc.h"
|
||||
|
||||
#include "ws2812.h"
|
||||
#include <ws2812_drv.h>
|
||||
#include "stm32f1xx_hal.h"
|
||||
|
||||
extern htim2;
|
||||
60
Core/Src/ws2812_effect.c
Normal file
60
Core/Src/ws2812_effect.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* ws2812_effect.c
|
||||
*
|
||||
* Created on: Mar 25, 2026
|
||||
* Author: ewars
|
||||
*/
|
||||
|
||||
|
||||
#include "ws2812_effect.h"
|
||||
#include "ws2812_drv.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
void ws_Effect_RoudTheClock(void){
|
||||
|
||||
uint8_t r = rand();
|
||||
uint8_t g = rand();
|
||||
uint8_t b = rand();
|
||||
|
||||
for (uint8_t led = 0; led < 24; led++) {
|
||||
|
||||
ws2812_reset();
|
||||
|
||||
ws2812_set_colour(led, r, g, b);
|
||||
ws2812_update();
|
||||
HAL_Delay(20);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ws_Effect_RandRound(void){
|
||||
|
||||
uint8_t r = rand();
|
||||
uint8_t g = rand();
|
||||
uint8_t b = rand();
|
||||
|
||||
for (uint8_t led = 0; led < 24; led++) {
|
||||
|
||||
|
||||
ws2812_set_colour(led, r, g, b);
|
||||
ws2812_update();
|
||||
HAL_Delay(20);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ws_Effect_RandRand(void){
|
||||
|
||||
#define RAND_MAX 255
|
||||
uint8_t r = rand();
|
||||
uint8_t g = rand();
|
||||
uint8_t b = rand();
|
||||
|
||||
#define RAND_MAX 24
|
||||
uint8_t led = rand();
|
||||
|
||||
ws2812_set_colour(led, r, g, b);
|
||||
ws2812_update();
|
||||
HAL_Delay(1);
|
||||
}
|
||||
@@ -83,5 +83,6 @@
|
||||
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
|
||||
<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
|
||||
</listAttribute>
|
||||
<stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><memoryBlockExpressionList context="reserved-for-future-use"/>"/>
|
||||
<stringAttribute key="process_factory_id" value="com.st.stm32cube.ide.mcu.debug.launch.HardwareDebugProcessFactory"/>
|
||||
</launchConfiguration>
|
||||
|
||||
Reference in New Issue
Block a user