Main.c
资源名称:str711USB.rar [点击查看]
上传用户:yyyd609
上传日期:2022-07-18
资源大小:183k
文件大小:1k
源码类别:
微处理器开发
开发平台:
C/C++
- #include "71x_lib.h"
- #include "LED.h"
- #include "Key.h"
- #include "mouse.h"
- #include "USB_lib.h"
- #define SPEED_P 10
- #define MAX_SPEED (20 << SPEED_P)
- int main(void)
- {
- int dx, dy;
- #ifdef DEBUG
- debug();
- #endif
- LED_Init();
- Key_Init();
- Mouse_Init();
- while(1)
- {
- int kLeft,kUp,kDown,kRight;
- kLeft = Key_State(KEY3,GPIO1);
- kRight= Key_State(KEY4,GPIO0);
- kUp=Key_State(KEY5,GPIO0);
- kDown= Key_State(KEY6,GPIO0);
- //LED_Set(0, Device_Info.Current_Configuration ? LED_ON : LED_OFF);
- LED_Set(LED3,GPIO1, Device_Info.Current_Configuration ? LED_ON : LED_OFF);
- if(kLeft | kUp | kDown | kRight) // need not to use "||"
- {
- if(kLeft && dx > -MAX_SPEED)
- dx--;
- if(kUp && dy > -MAX_SPEED)
- dy--;
- if(kDown && dy < MAX_SPEED)
- dy++;
- if(kRight && dx < MAX_SPEED)
- dx++;
- }
- else
- dx = 0, dy = 0;
- Mouse_Action(dx >> SPEED_P, dy >> SPEED_P, (kLeft & kRight) | (kUp & kDown) << 1);
- }
- }