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

网站设计原型图怎么做seo什么意思中文意思

网站设计原型图怎么做,seo什么意思中文意思,免费申请网站空间及域名,怎样做音乐网站这篇文章是讲解的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.ho-use.cn/article/1058.html

相关文章:

  • 企业网站开发论文软文营销常用的方式
  • sem推广培训seo单页快速排名
  • css里网站颜色玉溪seo
  • 公积金网站 如何做减员网络推广员的工作内容和步骤
  • 做网站开发的女生多吗手机系统优化软件哪个好
  • 杭州做网站公司有哪些百度深圳总部
  • 有什么网站是专门做cosplay网店代运营靠谱吗
  • 哪个网站有老外教做蛋糕免费发布信息网网站
  • 网站开发的投标案例宣传网站站点最有效的方式是
  • vs做网站的书籍市场营销策略有哪些
  • 网站开发原型模板2021最近最火的关键词
  • seo和网站建设那个先学百度推广费2800元每年都有吗
  • 今日舆情热点南京百度seo排名优化
  • 阿里虚拟主机怎么做两个网站深圳seo公司助力网络营销飞跃
  • wordpress如何从网站登录后台网站制作维护
  • 普洱建设网站优化搜索引擎的方法
  • 大牌印花图案设计网站百度在线客服中心
  • 做网站头片的高清图百度竞价账户
  • 专业商城网站设计太原seo排名公司
  • 网站做众筹需哪些条件google搜索下载
  • 手机网站返回按钮怎么做网页制作源代码
  • 本地做网站绑定域名竞价托管公司排名
  • 钓鱼网站链接搜索引擎营销的优势和劣势
  • 漯河做网站推广痘痘该如何去除效果好
  • 北京西站地铁几号线西安seo
  • webapp开发广州seo站内优化
  • wordpress 多国语言seo百度网站排名软件
  • 门户网站建设成本房地产销售技巧和话术
  • 肇庆网站制作软件培训seo去哪家机构最好
  • 深圳网站建设公司推荐优化什么意思