mirror of
https://github.com/goldenfishs/MRobot.git
synced 2025-11-02 04:23:10 +08:00
修改led
This commit is contained in:
parent
d7a56e656b
commit
92bb89124b
Binary file not shown.
@ -8,7 +8,7 @@ from qfluentwidgets import InfoBar, InfoBarPosition, SubtitleLabel
|
|||||||
from .function_fit_interface import FunctionFitInterface
|
from .function_fit_interface import FunctionFitInterface
|
||||||
from app.tools.check_update import check_update
|
from app.tools.check_update import check_update
|
||||||
|
|
||||||
__version__ = "1.0.4"
|
__version__ = "1.0.5"
|
||||||
|
|
||||||
class AboutInterface(QWidget):
|
class AboutInterface(QWidget):
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
|
|||||||
@ -7,45 +7,32 @@
|
|||||||
#include "bsp/pwm.h"
|
#include "bsp/pwm.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
|
|
||||||
/* USER INCLUDE BEGIN */
|
|
||||||
|
|
||||||
/* USER INCLUDE END */
|
|
||||||
|
|
||||||
/* Private define ----------------------------------------------------------- */
|
/* Private define ----------------------------------------------------------- */
|
||||||
/* USER DEFINE BEGIN */
|
|
||||||
|
|
||||||
/* USER DEFINE END */
|
|
||||||
|
|
||||||
/* Private macro ------------------------------------------------------------ */
|
/* Private macro ------------------------------------------------------------ */
|
||||||
/* Private typedef ---------------------------------------------------------- */
|
/* Private typedef ---------------------------------------------------------- */
|
||||||
/* USER STRUCT BEGIN */
|
|
||||||
|
|
||||||
/* USER STRUCT END */
|
|
||||||
|
|
||||||
/* USER FUNCTION BEGIN */
|
|
||||||
|
|
||||||
/* USER FUNCTION END */
|
int8_t DEVICE_LED_PWM_Set(BSP_PWM_Channel_t channel, float duty_cycle)
|
||||||
|
|
||||||
int8_t LED_PWMSet(BSP_PWM_Channel_t channel,float duty_cycle)
|
|
||||||
{
|
{
|
||||||
|
if (duty_cycle < 0.0f || duty_cycle > 1.0f) {
|
||||||
if (duty_cycle < 0.0f || duty_cycle > 1.0f) {
|
return DEVICE_ERR_NULL; // 错误:占空比超出范围
|
||||||
return DEVICE_ERR_NULL; // 错误:占空比超出范围
|
}
|
||||||
}
|
uint16_t pulse = (uint16_t)(duty_cycle * (float)UINT16_MAX);
|
||||||
uint16_t pulse = (uint16_t)(duty_cycle * (float)UINT16_MAX);
|
BSP_PWM_Start(channel);
|
||||||
BSP_PWM_Start(channel);
|
BSP_PWM_SetComp(channel, pulse);
|
||||||
BSP_PWM_SetComp(channel, pulse);
|
return DEVICE_OK;
|
||||||
return DEVICE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t LED_GPIOSet(BSP_GPIO_t gpio,bool value)
|
int8_t DEVICE_LED_GPIO_Set(BSP_GPIO_t gpio, bool value)
|
||||||
{
|
{
|
||||||
BSP_GPIO_WritePin(gpio,value);
|
if (value) {
|
||||||
|
BSP_GPIO_WritePin(gpio, true);
|
||||||
|
} else {
|
||||||
|
BSP_GPIO_WritePin(gpio, false);
|
||||||
|
}
|
||||||
return DEVICE_OK;
|
return DEVICE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -14,14 +14,18 @@ extern "C" {
|
|||||||
/* Exported macro ----------------------------------------------------------- */
|
/* Exported macro ----------------------------------------------------------- */
|
||||||
/* Exported types ----------------------------------------------------------- */
|
/* Exported types ----------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
BSP_GPIO_t gpio;
|
BSP_GPIO_t gpio;
|
||||||
BSP_PWM_Channel_t channel;
|
BSP_PWM_Channel_t channel;
|
||||||
} DEVICE_LED_t;
|
} DEVICE_LED_t;
|
||||||
|
|
||||||
|
|
||||||
|
extern DEVICE_LED_t LED_Map;
|
||||||
/* Exported functions prototypes -------------------------------------------- */
|
/* Exported functions prototypes -------------------------------------------- */
|
||||||
int8_t LED_PWMSet(BSP_PWM_Channel_t channel,float duty_cycle);
|
|
||||||
int8_t LED_GPIOSet(BSP_GPIO_t gpio,bool value);
|
|
||||||
|
int8_t BSP_LED_Set(char sign,DEVICE_LED_t ch,bool value,float duty_cycle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user