当前位置: 首页 > news >正文

网站设计原型图怎么做网站运营策划书

网站设计原型图怎么做,网站运营策划书,网络科技公司项目加盟,化妆品网站下载这篇文章是讲解的pwm控制三色灯的部分,这部分也是后续全彩智能灯的基础。 硬件原理如下 IO管脚定义在hi-12f_v1.1.2-规格书-20211202.pdf文档中 GPIO API API名称 说明 unsigned int IoTGpioInit(unsigned int id); GPIO模块初始化 hi_u32 hi_io_set_func(hi_i…

这篇文章是讲解的pwm控制三色灯的部分,这部分也是后续全彩智能灯的基础。

硬件原理如下

IO管脚定义在hi-12f_v1.1.2-规格书-20211202.pdf文档中

GPIO API

API名称

说明

unsigned int IoTGpioInit(unsigned int id);

GPIO模块初始化

hi_u32 hi_io_set_func(hi_io_name id, hi_u8 val);

配置某个IO的复用功能

unsigned int IoTPwmInit(unsigned int port);

初始化一个PWM设备

unsigned int IoTPwmStart(unsigned int port, unsigned short duty, unsigned int freq);

根据给定的输出频率和占空比从指定端口启动PWM信号输出。

unsigned int IoTPwmStop(unsigned int port);

停止来自指定端口的PWM信号输出。

在官方给的代码中IoTPwmStart占空比参数范围为1-99,也就是不能达到全灭和全亮的程度。所以对源码进行修改。

修改D:\DevEcoProjects\test\src\device\hisilicon\hispark_pegasus\hi3861_adapter\hals\iot_hardware\wifiiot_lite\hal_iot_pwm.c

unsigned int IoTPwmStart(unsigned int port, unsigned short duty, unsigned int freq)
{unsigned short hiDuty;unsigned short hiFreq;if ((freq == 0) || (duty > DUTY_MAX)) {return IOT_FAILURE;}if ((CLK_160M / freq) > SHORT_MAX) {return IOT_FAILURE;}hiFreq = (unsigned short)(CLK_160M / freq);hiDuty = (duty * hiFreq) / DUTY_MAX;return hi_pwm_start((hi_pwm_port)port, hiDuty, hiFreq);
}

使其支持0和100.

修改D:\DevEcoProjects\test\src\device\hisilicon\hispark_pegasus\sdk_liteos\platform\drivers\pwm\hi_pwm.c

hi_u32 hi_pwm_start(hi_pwm_port port, hi_u16 duty, hi_u16 freq)
{hi_u32 ret;if ((pwm_check_port(port) != HI_ERR_SUCCESS) || (freq == 0)|| (duty > freq)) {return HI_ERR_PWM_INVALID_PARAMETER;}if (pwm_is_init(port) == HI_FALSE) {return HI_ERR_PWM_NO_INIT;}ret = pwm_lock(port);if (ret != HI_ERR_SUCCESS) {return ret;}pwm_set_enable(port, HI_TRUE);pwm_set_freq(port, freq);pwm_set_duty(port, duty);pwm_take_effect(port);return pwm_unlock(port);
}

同样是使其支持0和100.

以上就是对源码的修改。下面是测试代码部分。

修改D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\BUILD.gn文件

# Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#    http://www.apache.org/licenses/LICENSE-2.0
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. import("//build/lite/config/component/lite_component.gni")lite_component("demo") {features = [#"base_00_helloworld:base_helloworld_example",#"base_01_led:base_led_example",#"base_02_loopkey:base_loopkey_example",#"base_03_irqkey:base_irqkey_example",#"base_04_adc:base_adc_example","base_05_pwm:base_pwm_example",]
}

创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_05_pwm文件夹

文件夹中创建D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_05_pwm\base_pwm_example.c文件D:\DevEcoProjects\test\src\vendor\rtplay\rt_hi3861\demo\base_05_pwm\BUILD.gn文件

# Copyright (c) 2023 Beijing HuaQing YuanJian Education Technology Co., Ltd
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. static_library("base_pwm_example") {sources = ["base_pwm_example.c",]include_dirs = ["//utils/native/lite/include","//kernel/liteos_m/kal/cmsis","//base/iot_hardware/peripheral/interfaces/kits","//vendor/hqyj/fs_hi3861/common/bsp/include"]
}
/** Copyright (C) 2023 HiHope Open Source Organization .* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at**     http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/#include <stdio.h>
#include <unistd.h>#include "cmsis_os2.h"
#include "hi_io.h"
#include "iot_errno.h"
#include "iot_gpio.h"
#include "iot_pwm.h"
#include "ohos_init.h"#define RED_LED_PIN_NAME HI_IO_NAME_GPIO_10
#define RED_LED_PIN_FUNCTION WIFI_IOT_IO_FUNC_GPIO_10_GPIO
#define GREEN_LED_PIN_NAME HI_IO_NAME_GPIO_2
#define GREEN_LED_PIN_FUNCTION WIFI_IOT_IO_FUNC_GPIO_2_GPIO
#define BLUE_LED_PIN_NAME HI_IO_NAME_GPIO_7
#define BLUE_LED_PIN_FUNCTION WIFI_IOT_IO_FUNC_GPIO_7_GPIO#define PWM_FREQ_DIVITION 64000
#define DELAY_US 30000
#define STACK_SIZE (4096)
#define PWM0_PORT_NUM (0)
#define PWM1_PORT_NUM (1)
#define PWM2_PORT_NUM (2)static void PWMLedDemoTask(void)
{// pwm占空比记录变量unsigned short duty0 = 0, duty1 = 40, duty2 = 80;// 记录占空比是增加还是减少hi_bool duty0_increase = HI_TRUE;hi_bool duty1_increase = HI_TRUE;hi_bool duty2_increase = HI_TRUE;// 炫彩灯板的红灯hi_io_set_func(RED_LED_PIN_NAME, HI_IO_FUNC_GPIO_10_PWM1_OUT);hi_io_set_func(GREEN_LED_PIN_NAME, HI_IO_FUNC_GPIO_2_PWM2_OUT);hi_io_set_func(BLUE_LED_PIN_NAME, HI_IO_FUNC_GPIO_7_PWM0_OUT);IoTPwmInit(PWM0_PORT_NUM);IoTPwmInit(PWM1_PORT_NUM);IoTPwmInit(PWM2_PORT_NUM);while (1) {// use PWM control RED LED brightness// 蓝灯呼吸代码IoTPwmStart(PWM0_PORT_NUM, duty0, PWM_FREQ_DIVITION);if (duty0_increase) {duty0++;if (duty0 > 100) {// 自增超过100后需要进行自减duty0_increase = HI_FALSE;duty0 = 99;}} else {duty0--;if (duty0 == 0) {// 自减到0后需要进行自增duty0_increase = HI_TRUE;}}// 红灯呼吸代码IoTPwmStart(PWM1_PORT_NUM, duty1, PWM_FREQ_DIVITION);if (duty1_increase) {duty1++;if (duty1 > 100) {duty1_increase = HI_FALSE;duty1 = 99;}} else {duty1--;if (duty1 == 0) {duty1_increase = HI_TRUE;}}// 绿灯呼吸代码IoTPwmStart(PWM2_PORT_NUM, duty2, PWM_FREQ_DIVITION);if (duty2_increase) {duty2++;if (duty2 > 100) {duty2_increase = HI_FALSE;duty2 = 99;}} else {duty2--;if (duty2 == 0) {duty2_increase = HI_TRUE;}}usleep(DELAY_US);}
}static void PWMLedDemo(void)
{osThreadAttr_t attr;// set Red LED pin to GPIO functionIoTGpioInit(RED_LED_PIN_NAME);attr.name = "PWMLedDemoTask";attr.attr_bits = 0U;attr.cb_mem = NULL;attr.cb_size = 0U;attr.stack_mem = NULL;attr.stack_size = STACK_SIZE;attr.priority = osPriorityNormal;if (osThreadNew(PWMLedDemoTask, NULL, &attr) == NULL) {printf("[ColorfulLightDemo] Falied to create PWMLedDemoTask!\n");}
}
APP_FEATURE_INIT(PWMLedDemo);

目录结构

│  config.json
│
├─common
│  └─bsp
│      ├─include
│      └─src
├─demo
│  │  BUILD.gn
│  │
│  ├─base_00_helloworld
│  │      base_helloworld_example.c
│  │      BUILD.gn
│  │
│  ├─base_01_led
│  │      base_led_example.c
│  │      BUILD.gn
│  │
│  ├─base_02_loopkey
│  │      base_loopkey_example.c
│  │      BUILD.gn
│  │
│  ├─base_03_irqkey
│  │      base_irqkey_example.c
│  │      BUILD.gn
│  │
│  ├─base_04_adc
│  │      base_adc_example.c
│  │      BUILD.gn
│  │
│  └─base_05_pwm
│          base_pwm_example.c
│          BUILD.gn
│
└─doc│  HarmonyOS开发板实验指导书 v2.1.pdf│  华清远见 FS_Hi3861开发指导.md│  华清远见 FS_Hi3861新手入门手册.md│├─board│      FS-Hi3861-V4.2.pdf│      FS-Hi3861QDB-V3.2.pdf│      hi-12f_kit_v1.1.0规格书-20211025.pdf│      hi-12f_v1.1.2-规格书-20211202.pdf│      nodemcu-hi-07s_12f-kit_v1.1-20210913.pdf│      RTplay2.01_2024-06-14.pdf│└─figures

使用build,编译成功后,使用upload进行烧录。

运行效果如下,三色灯颜色会变化。

http://www.yidumall.com/news/108277.html

相关文章:

  • 网站建设设计制作维护直通车官网
  • 自己做网站的流程视频教程网站建设是什么
  • 温州网站建设温州网站制作网店运营在哪里学比较好些
  • 开一家网络公司做网站前景如何注册网站怎么注册
  • 怎么查看网站有没有做ssl互联网营销师培训课程
  • 深圳注册公司代办张掖seo
  • 做网站行业的动态网络推广大概需要多少钱
  • ui网页设计介绍如何做好seo基础优化
  • 做网站和商城有什么好处上海短视频seo优化网站
  • 网站后台管理怎么做社区营销推广活动方案
  • 济南优化排名公司seo的基础优化
  • 西宁网站建设报价cu君博規范黄页推广2021
  • python做网站好不好网络推广最好的网站有哪些
  • 做h5页面网站有哪些搜索排名优化策划
  • 产品摄影网站推荐seo推广骗局
  • 做二手车网站需要什么手续优化大师有必要花钱吗
  • 会python做网站百度seo搜索引擎优化培训
  • 江苏省建设厅网站查询seo是做什么工作的
  • 做网站抄代码营销策划推广
  • 茂名网站开发公司推荐百度小说app
  • 网站开发人员要求一个网站可以优化多少关键词
  • 临沂网站建设和轶件安装抖音自动推广引流app
  • 网站内容的作用服务营销策略
  • 关于网站建设的名言seo网站优化培训多少价格
  • 网站推广目的关键词采集软件
  • 怎样做彩票投资网站系统优化软件哪个好
  • 网站推广公司转型方向share群组链接分享
  • 专业建设验收网站山东做网站
  • 网站 翻页 实现搭建一个网站平台需要多少钱
  • 国外专门做美女车模的网站搜索图片识别出处百度识图