小编Rea*_*nic的帖子

HAL 库中的延迟 (HAL_Delay())

我试图在我的 stm32f4 发现中闪烁 LED。不知何故,它停留在延迟功能上。我已将 SysTick 中断优先级更改为 0 并添加了IncTick(),GetTick()功能。我错过了什么?

#include "stm32f4xx.h"                  // Device header
#include "stm32f4xx_hal.h"              // Keil::Device:STM32Cube HAL:Common


int main(){
    HAL_Init();

    __HAL_RCC_GPIOD_CLK_ENABLE();

    GPIO_InitTypeDef GPIO_InitStruct;

    GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;

    HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);

    HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15, GPIO_PIN_SET);

    HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);   
    HAL_IncTick();
    HAL_GetTick();
    HAL_Delay(100);

    HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15, GPIO_PIN_RESET);
}
Run Code Online (Sandbox Code Playgroud)

arm hal keil stm32f4discovery

4
推荐指数
1
解决办法
5万
查看次数

PySide6 中 QML 的后端是否有更干净的方法?

您好,我正在使用模型类来提供列表和组合框的项目。问题是我每次都对每个元素使用setContextProperty() 函数。我正在寻找一种解决方案,其中所有元素(列表和组合框)都使用相同的 ContextProperty。此外,通过这种方式,我猜想 JSON 文件可以动态加载,而不是在开始时加载所有文件。

主要.py

class Model(QAbstractListModel, QObject):
    """ it reads JSON file, that is given as argument,
    and creates the model"""

if __name__ == "__main__":
    app = QGuiApplication(sys.argv)
    engine = QQmlApplicationEngine()

    model1 = Model("file1.json")
    model2 = Model("file2.json")
    model3 = Model("file3.json")
    model4 = Model("file4.json")
    model5 = Model("file5.json")

    engine.rootContext().setContextProperty("model1", model1)
    engine.rootContext().setContextProperty("model2", model2)
    engine.rootContext().setContextProperty("model3", model3)
    engine.rootContext().setContextProperty("model4", model4)
    engine.rootContext().setContextProperty("model5", model5)

    engine.rootContext().setContextProperty("applicationDirPath", os.path.dirname(__file__))
    engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec())
Run Code Online (Sandbox Code Playgroud)

python qt qml pyside6

4
推荐指数
1
解决办法
1637
查看次数

标签 统计

arm ×1

hal ×1

keil ×1

pyside6 ×1

python ×1

qml ×1

qt ×1

stm32f4discovery ×1