| | |
| | | /* Includes ------------------------------------------------------------------*/ |
| | | #include "main.h" |
| | | #include "adc.h" |
| | | #include "tim.h" |
| | | #include "usart.h" |
| | | #include "gpio.h" |
| | | |
| | | /* Private includes ----------------------------------------------------------*/ |
| | | /* USER CODE BEGIN Includes */ |
| | | #include "miscdev.h" |
| | | #include "ws2812b.h" |
| | | /* USER CODE END Includes */ |
| | | |
| | | /* Private typedef -----------------------------------------------------------*/ |
| | |
| | | { |
| | | |
| | | /* USER CODE BEGIN 1 */ |
| | | uint32_t lux, noisy; |
| | | |
| | | /* USER CODE END 1 */ |
| | | |
| | | /* MCU Configuration--------------------------------------------------------*/ |
| | |
| | | MX_GPIO_Init(); |
| | | MX_USART1_UART_Init(); |
| | | MX_ADC1_Init(); |
| | | MX_TIM6_Init(); |
| | | MX_TIM1_Init(); |
| | | /* USER CODE BEGIN 2 */ |
| | | |
| | | init_relay(); |
| | | init_led(); |
| | | ws2812b_init(); |
| | | beep_start(2, 300); |
| | | |
| | | /* Turn on relay after 1 second */ |
| | | HAL_Delay(1000); |
| | | turn_relay(Relay1, ON); |
| | | /* USER CODE END 2 */ |
| | | |
| | | /* Infinite loop */ |
| | | /* USER CODE BEGIN WHILE */ |
| | | while (1) |
| | | { |
| | | adc_sample_lux_noisy(&lux, &noisy); |
| | | printf("Lux:%lu Noisy:%lu\r\n", lux, noisy); |
| | | |
| | | HAL_Delay(5000); |
| | | /* Blink WS2812B strip lights */ |
| | | ws2812b_blink(); |
| | | |
| | | /* USER CODE END WHILE */ |
| | | |