赛车模拟控制程序头文件
更多...
#include "def.h"
#include "consol.h"
#include "S3c2410x.h"
#include "INT.h"
#include "2410lib.h"
#include "lcdlib.h"
#include <stdio.h>
#include <math.h>
浏览源代码.
赛车模拟控制程序头文件
- 作者
- Gump, LDR
- 版本
- V0.1
- 日期
- 2019-12-08
#define COVER_BUF 0x32000000 |
#define BACKGROUND_BUF 0x31000000 |
#define TRACK_CENTRE_X 200.0f |
#define TRACK_CENTRE_Y 120.0f |
#define TRACK_WIDTH_HALF 17.0f |
赛道宽度的一半,实际长度 34 (赛车方块的对角线长度)
#define TRACK_COLOR 0x000000 |
#define VEHICLE_WIDTH_HALF 11 |
#define VEHICLE_COLOR 0xffff00 |
void VehicleInit |
( |
void |
| ) |
|
赛车程序初始化函数
31 ShowImage(ptr, 0, 0, 1);
void DrawVehicle(float p, COLOR c)
绘制赛车,即一个小矩形
Definition: vehicle.c:234
#define VEHICLE_COLOR
Definition: vehicle.h:53
#define BACKGROUND_BUF
Definition: vehicle.h:39
void DrawTrack(void)
绘制圆形赛道
Definition: vehicle.c:204
void VehicleStatusUpdate |
( |
void |
| ) |
|
更新赛车数据
- 待办事项:
- 根据为赛车增加加速度属性值,使得赛车速度切换更加真实
47 static int led_counter;
48 static unsigned char led_status = 0;
89 LED_Display(led_status);
98 led_status = (led_status == 1) ? 0 : 1;
unsigned char display_flag
Definition: vehicle.c:20
unsigned char speed
Definition: vehicle.h:30
Vehicle vehicle
Definition: vehicle.c:16
void DrawVehicle(float p, COLOR c)
绘制赛车,即一个小矩形
Definition: vehicle.c:234
float position
Definition: vehicle.h:29
volatile unsigned char gear
Definition: vehicle.h:32
unsigned char laps
Definition: vehicle.h:31
char speed[10]
Definition: vehicle.c:19
void VehicleDisplays |
( |
void |
| ) |
|
显示赛车状态
112 drawascii168(12, 220,
speed, 1, 1, 0xffffff);
unsigned char display_flag
Definition: vehicle.c:20
Vehicle vehicle
Definition: vehicle.c:16
void DisplaySMG(void)
数码管显示函数 在左边两位显示当前已走圈数
Definition: vehicle.c:126
void DrawVehicle(float p, COLOR c)
绘制赛车,即一个小矩形
Definition: vehicle.c:234
float position
Definition: vehicle.h:29
#define VEHICLE_COLOR
Definition: vehicle.h:53
void DrawRect(void)
绘制蓝色矩形方块
Definition: vehicle.c:254
char speed[10]
Definition: vehicle.c:19
数码管显示函数 在左边两位显示当前已走圈数
130 for (i = 0; i < 100; i++)
void delay(int time)
简单的延时函数
Definition: vehicle.c:303
Vehicle vehicle
Definition: vehicle.c:16
void DisplayOneSMG(int p, int num, int dot)
数码管显示函数
Definition: vehicle.c:154
unsigned char laps
Definition: vehicle.h:31
void DisplayLED |
( |
int |
flag | ) |
|
LED 显示函数
- 参数
-
190 rGPFDAT &= ~(1 << 7);
191 rGPFDAT &= ~(1 << 4);
void DisplayOneSMG |
( |
int |
p, |
|
|
int |
num, |
|
|
int |
dot |
|
) |
| |
数码管显示函数
- 参数
-
p | 数字在数码管中的位置
|
num | 要显示的数字 |
dot | 是否显示小数点
|
159 rGPGDAT &= ~(1 << 2);
160 rGPEDAT &= ~(1 << 9);
164 rGPEDAT &= ~(1 << 9);
167 rGPGDAT &= ~(1 << 2);
176 rGPEDAT = (rGPEDAT & ~(0x3C00)) | (num << 10);
177 rGPHDAT = (rGPHDAT & ~(1 << 8)) | (dot << 8);
void DrawVehicle |
( |
float |
p, |
|
|
COLOR |
c |
|
) |
| |
绘制赛车,即一个小矩形
- 参数
-
#define TRACK_CENTRE_X
Definition: vehicle.h:47
#define PI
Definition: vehicle.h:36
#define TRACK_CENTRE_Y
Definition: vehicle.h:48
#define VEHICLE_WIDTH_HALF
Definition: vehicle.h:52
#define TRACK_RADIUS
Definition: vehicle.h:46
绘制圆形赛道
208 for (i = 0; i <= 360; i++)
#define TRACK_CENTRE_X
Definition: vehicle.h:47
#define TRACK_WIDTH_HALF
Definition: vehicle.h:49
#define TRACK_COLOR
Definition: vehicle.h:50
#define PI
Definition: vehicle.h:36
#define TRACK_CENTRE_Y
Definition: vehicle.h:48
#define TRACK_RADIUS
Definition: vehicle.h:46
绘制蓝色矩形方块
#define SPEED_X
Definition: vehicle.h:41
#define SPEED_H
Definition: vehicle.h:44
#define SPEED_Y
Definition: vehicle.h:42
#define SPEED_W
Definition: vehicle.h:43
简单的延时函数
- 参数
-
306 for (i = 0; i < time; i++)
307 for (j = 0; j < 1000; j++)
void __irq INT0_Handler |
( |
void |
| ) |
|
按键1中断处理函数 每按一次“档位”成员变量自减一
Vehicle vehicle
Definition: vehicle.c:16
volatile unsigned char gear
Definition: vehicle.h:32
void __irq INT2_Handler |
( |
void |
| ) |
|
按键2中断处理函数 每按一次“档位”成员变量自增一
Vehicle vehicle
Definition: vehicle.c:16
volatile unsigned char gear
Definition: vehicle.h:32