我试图在我的 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) 您好,我正在使用模型类来提供列表和组合框的项目。问题是我每次都对每个元素使用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)