#define LCD_AC_UP 0x02 #define LCD_AC_DOWN 0x00 // default #define LCD_MOVE 0x01 // 画面可平移 #define LCD_NO_MOVE 0x00 //default void LCD_SetInput(unsigned char InputMode) { LCD_Write(LCD_COMMAND, 0x04|InputMode); }

时间: 2023-06-15 20:04:39 浏览: 64
这段代码是关于LCD控制器的一些定义和函数的实现。具体来说,它定义了一些常量,如LCD_AC_UP和LCD_AC_DOWN,用于控制液晶屏的方向,以及LCD_MOVE和LCD_NO_MOVE,用于控制画面是否可平移。此外,该代码还实现了一个名为LCD_SetInput的函数,该函数用于设置LCD输入模式,其实现方式是通过调用LCD_Write函数向LCD控制器写入相应的命令和参数。需要注意的是,该代码并未提供LCD_Write函数的实现,因此无法确定具体的实现细节。
相关问题

stm32f10x_gpio.h代码

以下是`stm32f10x_gpio.h`的代码: ```c /** ****************************************************************************** * @file stm32f10x_gpio.h * @author MCD Application Team * @version V3.5.0 * @date 09-March-2012 * @brief This file contains all the functions prototypes for the GPIO * firmware library. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2> * * Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2 * * 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. * ****************************************************************************** */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32F10x_GPIO_H #define __STM32F10x_GPIO_H #ifdef __cplusplus extern "C" { #endif /* Includes ------------------------------------------------------------------*/ #include "stm32f10x.h" /** @addtogroup STM32F10x_StdPeriph_Driver * @{ */ /** @addtogroup GPIO * @{ */ /* Exported types ------------------------------------------------------------*/ /* Exported constants --------------------------------------------------------*/ /** @defgroup GPIO_Exported_Constants * @{ */ /** @defgroup GPIO_pins_define * @{ */ #define GPIO_Pin_0 ((uint16_t)0x0001) /*!< Pin 0 selected */ #define GPIO_Pin_1 ((uint16_t)0x0002) /*!< Pin 1 selected */ #define GPIO_Pin_2 ((uint16_t)0x0004) /*!< Pin 2 selected */ #define GPIO_Pin_3 ((uint16_t)0x0008) /*!< Pin 3 selected */ #define GPIO_Pin_4 ((uint16_t)0x0010) /*!< Pin 4 selected */ #define GPIO_Pin_5 ((uint16_t)0x0020) /*!< Pin 5 selected */ #define GPIO_Pin_6 ((uint16_t)0x0040) /*!< Pin 6 selected */ #define GPIO_Pin_7 ((uint16_t)0x0080) /*!< Pin 7 selected */ #define GPIO_Pin_8 ((uint16_t)0x0100) /*!< Pin 8 selected */ #define GPIO_Pin_9 ((uint16_t)0x0200) /*!< Pin 9 selected */ #define GPIO_Pin_10 ((uint16_t)0x0400) /*!< Pin 10 selected */ #define GPIO_Pin_11 ((uint16_t)0x0800) /*!< Pin 11 selected */ #define GPIO_Pin_12 ((uint16_t)0x1000) /*!< Pin 12 selected */ #define GPIO_Pin_13 ((uint16_t)0x2000) /*!< Pin 13 selected */ #define GPIO_Pin_14 ((uint16_t)0x4000) /*!< Pin 14 selected */ #define GPIO_Pin_15 ((uint16_t)0x8000) /*!< Pin 15 selected */ #define GPIO_Pin_All ((uint16_t)0xFFFF) /*!< All pins selected */ /** * @} */ /** @defgroup GPIO_Speed_Legacy * @{ */ #define GPIO_Speed_10MHz GPIO_Speed_Level_1 /*!< I/O output speed: Low 2 MHz */ #define GPIO_Speed_2MHz GPIO_Speed_Level_2 /*!< I/O output speed: Medium 10 MHz */ #define GPIO_Speed_50MHz GPIO_Speed_Level_3 /*!< I/O output speed: Fast 50 MHz */ /** * @} */ /** @defgroup GPIO_Mode_define * @{ */ #define GPIO_Mode_AIN ((uint32_t)0x00000000) /*!< Analog mode */ #define GPIO_Mode_IN_FLOATING ((uint32_t)0x04) /*!< Input floating mode */ #define GPIO_Mode_IPD ((uint32_t)0x28) /*!< Input pull-down mode */ #define GPIO_Mode_IPU ((uint32_t)0x48) /*!< Input pull-up mode */ #define GPIO_Mode_Out_OD ((uint32_t)0x14) /*!< Output open-drain mode */ #define GPIO_Mode_Out_PP ((uint32_t)0x10) /*!< Output push-pull mode */ #define GPIO_Mode_AF_OD ((uint32_t)0x1C) /*!< Alternate function output open-drain mode */ #define GPIO_Mode_AF_PP ((uint32_t)0x18) /*!< Alternate function output push-pull mode */ /** * @} */ /** @defgroup GPIO_OType_define * @{ */ #define GPIO_OType_PP ((uint16_t)0x0000) /*!< Output push-pull */ #define GPIO_OType_OD ((uint16_t)0x0010) /*!< Output open-drain */ /** * @} */ /** @defgroup GPIO_PuPd_define * @{ */ #define GPIO_PuPd_NOPULL ((uint32_t)0x00000000) /*!< No pull-up or pull-down */ #define GPIO_PuPd_UP ((uint32_t)0x08) /*!< Pull-up */ #define GPIO_PuPd_DOWN ((uint32_t)0x18) /*!< Pull-down */ /** * @} */ /** @defgroup GPIO_Pin_sources * @{ */ #define GPIO_PinSource0 ((uint8_t)0x00) #define GPIO_PinSource1 ((uint8_t)0x01) #define GPIO_PinSource2 ((uint8_t)0x02) #define GPIO_PinSource3 ((uint8_t)0x03) #define GPIO_PinSource4 ((uint8_t)0x04) #define GPIO_PinSource5 ((uint8_t)0x05) #define GPIO_PinSource6 ((uint8_t)0x06) #define GPIO_PinSource7 ((uint8_t)0x07) #define GPIO_PinSource8 ((uint8_t)0x08) #define GPIO_PinSource9 ((uint8_t)0x09) #define GPIO_PinSource10 ((uint8_t)0x0A) #define GPIO_PinSource11 ((uint8_t)0x0B) #define GPIO_PinSource12 ((uint8_t)0x0C) #define GPIO_PinSource13 ((uint8_t)0x0D) #define GPIO_PinSource14 ((uint8_t)0x0E) #define GPIO_PinSource15 ((uint8_t)0x0F) /** * @} */ /** @defgroup GPIO_Alternate_function_selection_define * @{ */ #define GPIO_AF_0 ((uint8_t)0x00) /*!< Alternate function 0 */ #define GPIO_AF_1 ((uint8_t)0x01) /*!< Alternate function 1 */ #define GPIO_AF_2 ((uint8_t)0x02) /*!< Alternate function 2 */ #define GPIO_AF_3 ((uint8_t)0x03) /*!< Alternate function 3 */ #define GPIO_AF_4 ((uint8_t)0x04) /*!< Alternate function 4 */ #define GPIO_AF_5 ((uint8_t)0x05) /*!< Alternate function 5 */ #define GPIO_AF_6 ((uint8_t)0x06) /*!< Alternate function 6 */ #define GPIO_AF_7 ((uint8_t)0x07) /*!< Alternate function 7 */ #define GPIO_AF_8 ((uint8_t)0x08) /*!< Alternate function 8 */ #define GPIO_AF_9 ((uint8_t)0x09) /*!< Alternate function 9 */ #define GPIO_AF_10 ((uint8_t)0x0A) /*!< Alternate function 10 */ #define GPIO_AF_11 ((uint8_t)0x0B) /*!< Alternate function 11 */ #define GPIO_AF_12 ((uint8_t)0x0C) /*!< Alternate function 12 */ #define GPIO_AF_13 ((uint8_t)0x0D) /*!< Alternate function 13 */ #define GPIO_AF_14 ((uint8_t)0x0E) /*!< Alternate function 14 */ #define GPIO_AF_15 ((uint8_t)0x0F) /*!< Alternate function 15 */ /** * @} */ /** @defgroup GPIO_interrupt_sources * @{ */ #define GPIO_IT_Edge ((uint16_t)0x0001) /*!< Interrupt mode is enabled on rising edge */ #define GPIO_IT_Rising ((uint16_t)0x0002) /*!< Interrupt mode is enabled on rising edge */ #define GPIO_IT_Falling ((uint16_t)0x0004) /*!< Interrupt mode is enabled on falling edge */ #define GPIO_IT_High ((uint16_t)0x0008) /*!< Interrupt mode is enabled on high level */ #define GPIO_IT_Low ((uint16_t)0x0010) /*!< Interrupt mode is enabled on low level */ #define GPIO_IT_Port_Source ((uint16_t)0x0020) /*!< Interrupt mode is enabled on pin event */ /** * @} */ /** @defgroup GPIO_Legacy * @{ */ #define GPIO_Mode_Out_Slow GPIO_Mode_Out_PP #define GPIO_Mode_In_Floating GPIO_Mode_IN_FLOATING #define GPIO_Mode_In_PU GPIO_Mode_IPU #define GPIO_Mode_In_PD GPIO_Mode_IPD #define GPIO_Mode_Out_OD GPIO_Mode_Out_OD #define GPIO_Mode_Af_OD GPIO_Mode_AF_OD #define GPIO_Mode_Af_PP GPIO_Mode_AF_PP /** * @} */ /** * @} */ /* Exported macro ------------------------------------------------------------*/ /* Exported functions ------------------------------------------------------- */ /* Function used to set the GPIO configuration to the default reset state ****/ void GPIO_DeInit(GPIO_TypeDef* GPIOx); /* Initialization and Configuration functions *********************************/ void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct); void GPIO_PinLockConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); /* GPIO Read and Write functions **********************************************/ uint8_t GPIO_ReadInputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); uint16_t GPIO_ReadInputData(GPIO_TypeDef* GPIOx); uint8_t GPIO_ReadOutputDataBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); uint16_t GPIO_ReadOutputData(GPIO_TypeDef* GPIOx); void GPIO_SetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); void GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal); void GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal); /* GPIO Alternate functions configuration functions ***************************/ void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF); /* GPIO Interrupts configuration functions ************************************/ void GPIO_ITConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, FunctionalState NewState); void GPIO_EXTILineConfig(uint8_t GPIO_PortSource, uint8_t GPIO_PinSource); /* GPIO Low Level Interrupt management ***************************************/ void GPIO_SetInterrupt(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, Exti_TypeDef PortSource); void GPIO_ClearInterrupt(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin); #ifdef __cplusplus } #endif #endif /* __STM32F10x_GPIO_H */ /** * @} */ /** * @} */ /******************* (C) COPYRIGHT 2012 STMicroelectronics *****END OF FILE****/ ```

工作环境为#include "stdAfx.h" #include "circle.h" /*以下常量定义鼠标状态,目前之后两个状态,分别是鼠标左键被按下, 和默认正常状态,没有任何按键被按下 */ #define MOUSE_LEFT_BUTTION_DOWN 0X0001 //定义鼠标状 #define MOUSE_NORMAL 0x0000 //定义鼠标状态 int mouse_state = MOUSE_NORMAL; //定义2维空间内的点(x,y) typedef struct Point2D { int x; int y; }Point2D; //定义鼠标开始位置和结束位置 Point2D mouseStartPos,mouseEndPos; //定义显示函数 void display() { glClearColor(1.0f,1.0f,1.0f,0.0f); glClear(GL_COLOR_BUFFER_BIT); printf("%d\n",mouse_state); if(mouse_state == MOUSE_LEFT_BUTTION_DOWN) { float r = sqrt((mouseEndPos.x-mouseStartPos.x)*(mouseEndPos.x-mouseStartPos.x) + (mouseEndPos.y-mouseStartPos.y)*(mouseEndPos.y-mouseStartPos.y)); drawCircleBresenham(mouseStartPos.x,mouseStartPos.y,r); } glFlush(); printf("call display\n"); } //鼠标处理函数 void mouseHandler(int button,int state,int x,int y) { switch(button) { case GLUT_LEFT_BUTTON: switch(state) { case GLUT_UP: mouse_state = MOUSE_NORMAL; break; case GLUT_DOWN: printf("mosue down\n"); mouseStartPos.x = x; //记录鼠标开始位置 mouseStartPos.y = y; mouse_state = MOUSE_LEFT_BUTTION_DOWN; break; default: break; } break; case GLUT_RIGHT_BUTTON: break; case GLUT_MIDDLE_BUTTON: break; default: break; } } //鼠标按下并且移动时候,调用此函数 void mouseMotionHandler(int x,int y) { //记录鼠标结束位置 mouseEndPos.x = x; mouseEndPos.y = y; if(mouse_state == MOUSE_LEFT_BUTTION_DOWN) { float r = sqrt((mouseEndPos.x-mouseStartPos.x)*(mouseEndPos.x-mouseStartPos.x) + (mouseEndPos.y-mouseStartPos.y)*(mouseEndPos.y-mouseStartPos.y)); drawCircleBresenham(mouseStartPos.x,mouseStartPos.y,r); } } void main () { glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE); glutInitWindowPosition(600,400); glutInitWindowSize(400,400); glutCreateWindow("OpenGL"); glutDisplayFunc(display); //设置显示函数 glutMouseFunc(mouseHandler); //设置鼠标处理函数 glutMotionFunc(mouseMotionHandler);//当鼠标按下并移动时候,会调用此函数 gluOrtho2D(0.0f,400.0f,400.0f,0.0f); glutMainLoop(); }

这段代码是用 OpenGL 实现的一个画圆程序,可以通过鼠标左键按下并拖动来画圆。其中用到了 Bresenham 算法来绘制圆。代码中定义了鼠标状态常量和结构体来记录鼠标位置,以及鼠标处理函数和鼠标移动处理函数来处理鼠标事件。在主函数中,设置了显示函数、鼠标处理函数和鼠标移动处理函数,并使用 gluOrtho2D 函数设置了视口大小。最后通过调用 glutMainLoop 函数进入事件循环,等待用户输入。

相关推荐

代码解释#include <reg51.h> #define uchar unsigned char #define uint unsigned int // c0de for 7Seg MPX CA, from 0 to 9 and A to F and - // if want to use in CC, add ~ uchar code numberDisplayTable[] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90, 0x88, 0x83, 0xc6, 0xa1, 0x86, 0x8e, 0xbf}; // delay time for notes uint code noteDelayTime[] = {64021, 64103, 64260, 64400, 64524, 64580, 64684, 64777, 64820, 64898, 64968, 65030, 65058, 65110, 65157, 65178}; sbit BEEP = P3 ^ 0; uchar keyNumber; void delay(uchar x) { uchar i; while (x--) for(i = 0; i < 120; i++); } void scanKey() { uchar tmp, k; P1 = 0x0f; delay(2); tmp = P1 ^ 0x0f; switch (tmp) { case 1: k = 0; break; case 2: k = 1; break; case 4: k = 2; break; case 8: k = 3; break; default:// no key down? return; } // set low 4 bits to 0, so place in 4 rows P1 = 0xf0; delay(2); // after button push, 11110000 will turned into XXXX0000, 1 0 in X, 3 1 in X // so we extract the 0 out tmp = (P1 >> 4) ^ 0x0f; // set 0,4,8,12 for row 0 ~ 3 switch (tmp) { case 1: k += 0; break; case 2: k += 4; break; case 4: k += 8; break; case 8: k += 12; break; default: return; } keyNumber = k; } // play sound via int0 void playNote() interrupt 1 { TH0 = noteDelayTime[keyNumber] / 256; TL0 = noteDelayTime[keyNumber] % 256; BEEP = ~BEEP; } void main() { // display - at start P0 = 0xbf; TMOD = 0x01; IE = 0x82; while (1) { // send scanner P1 = 0xf0; // if button down if (P1 != 0xf0) { scanKey(); P0 = ~numberDisplayTable[keyNumber]; // enable timer TR0 = 1; } else { // stop timer TR0 = 0; } delay(2); } }

最新推荐

recommend-type

微软内部资料-SQL性能优化3

It is up to the application to define what consistency means, and isolation in some form is needed to achieve consistent results. SQL Server uses locking to achieve isolation. Definition of ...
recommend-type

计算机应用技术(实用手册)

进入后,你可以用方向键移动光标选择CMOS设置界面上的选项,然后按Enter进入副选单,用ESC键来返回上一级菜单,用PAGE UP和PAGE DOWN键来选择具体选项,F10键保留并退出BIOS设置。 1.STANDARD CMOS SETUP(标准...
recommend-type

软考-考生常见操作说明-202405101400-纯图版.pdf

软考官网--2024常见操作说明:包括如何绘制网络图、UML图、表格等 模拟作答系统是计算机技术与软件专业技术资格(水平)考试的电子化考试系统界面、作答过程的仿真系统,为各级别、各资格涉及输入和页面显示的部分题型提供体验性练习。
recommend-type

setuptools-34.0.3.zip

Node.js,简称Node,是一个开源且跨平台的JavaScript运行时环境,它允许在浏览器外运行JavaScript代码。Node.js于2009年由Ryan Dahl创立,旨在创建高性能的Web服务器和网络应用程序。它基于Google Chrome的V8 JavaScript引擎,可以在Windows、Linux、Unix、Mac OS X等操作系统上运行。 Node.js的特点之一是事件驱动和非阻塞I/O模型,这使得它非常适合处理大量并发连接,从而在构建实时应用程序如在线游戏、聊天应用以及实时通讯服务时表现卓越。此外,Node.js使用了模块化的架构,通过npm(Node package manager,Node包管理器),社区成员可以共享和复用代码,极大地促进了Node.js生态系统的发展和扩张。 Node.js不仅用于服务器端开发。随着技术的发展,它也被用于构建工具链、开发桌面应用程序、物联网设备等。Node.js能够处理文件系统、操作数据库、处理网络请求等,因此,开发者可以用JavaScript编写全栈应用程序,这一点大大提高了开发效率和便捷性。 在实践中,许多大型企业和组织已经采用Node.js作为其Web应用程序的开发平台,如Netflix、PayPal和Walmart等。它们利用Node.js提高了应用性能,简化了开发流程,并且能更快地响应市场需求。
recommend-type

基于遗传优化GA的三目标优化仿真【包括程序,注释,操作步骤】

1.版本:matlab2022A。 2.包含:程序,中文注释,仿真操作步骤(使用windows media player播放)。 3.领域:遗传优化 4.仿真效果:仿真效果可以参考博客同名文章《基于遗传优化GA的三目标优化仿真》 5.内容:基于遗传优化GA的三目标优化仿真。遗传算法(Genetic Algorithm, GA)是一种模拟自然选择和遗传机制的全局搜索优化方法,广泛应用于解决复杂优化问题,包括具有多个目标的优化问题,即多目标遗传算法(Multi-Objective Genetic Algorithm, MOGA)。在这里,将三个目标函数进行统一的编码,通过单目标遗传优化的方式,同步求解三个目标函数的最优值。 6.注意事项:注意MATLAB左侧当前文件夹路径,必须是程序所在文件夹位置,具体可以参考视频录。
recommend-type

zigbee-cluster-library-specification

最新的zigbee-cluster-library-specification说明文档。
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

实现实时数据湖架构:Kafka与Hive集成

![实现实时数据湖架构:Kafka与Hive集成](https://img-blog.csdnimg.cn/img_convert/10eb2e6972b3b6086286fc64c0b3ee41.jpeg) # 1. 实时数据湖架构概述** 实时数据湖是一种现代数据管理架构,它允许企业以低延迟的方式收集、存储和处理大量数据。与传统数据仓库不同,实时数据湖不依赖于预先定义的模式,而是采用灵活的架构,可以处理各种数据类型和格式。这种架构为企业提供了以下优势: - **实时洞察:**实时数据湖允许企业访问最新的数据,从而做出更明智的决策。 - **数据民主化:**实时数据湖使各种利益相关者都可
recommend-type

解释minorization-maximization (MM) algorithm,并给出matlab代码编写的例子

Minorization-maximization (MM) algorithm是一种常用的优化算法,用于求解非凸问题或含有约束的优化问题。该算法的基本思想是通过构造一个凸下界函数来逼近原问题,然后通过求解凸下界函数的最优解来逼近原问题的最优解。具体步骤如下: 1. 初始化参数 $\theta_0$,设 $k=0$; 2. 构造一个凸下界函数 $Q(\theta|\theta_k)$,使其满足 $Q(\theta_k|\theta_k)=f(\theta_k)$; 3. 求解 $Q(\theta|\theta_k)$ 的最优值 $\theta_{k+1}=\arg\min_\theta Q(
recommend-type

JSBSim Reference Manual

JSBSim参考手册,其中包含JSBSim简介,JSBSim配置文件xml的编写语法,编程手册以及一些应用实例等。其中有部分内容还没有写完,估计有生之年很难看到完整版了,但是内容还是很有参考价值的。