標題:
基于ARM平臺的鋼琴游戲 實現(xiàn)琴鍵按下效果
[打印本頁]
作者:
why684700
時間:
2017-7-25 15:29
標題:
基于ARM平臺的鋼琴游戲 實現(xiàn)琴鍵按下效果
效果文件都在文件里,可以下載看看。很全,有興趣就了解下。。
本階段任務與步驟
================
1,設置好共享文件夾
2,編譯這些代碼:
make
3,將編譯好的示例程序piano丟到開發(fā)板,觀察運行效果
注意:要將所有的bmp文件也要上傳到開發(fā)板(已經(jīng)上傳過了就不用重復上傳了)
4,修改piano.c,使得鋼琴12個琴鍵均能按下去。
0.png
(47.88 KB, 下載次數(shù): 173)
下載附件
2017-7-25 16:55 上傳
單片機源程序如下:
/***********************************************
//
// Copyright(C), 2013-2016, GEC Tech. Co., Ltd.
//
// 作者: 林世霖
// 微信公眾號:秘籍酷
// 日期: 2016-6
//
// 描述: 在LCD上顯示音樂鋼琴的界面
//
// GitHub: github.com/vincent040
// Bug Report: 2437231462@qq.com
//
***********************************************/
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <linux/input.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <stdbool.h>
#include <linux/fb.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include "bmp.h"
#include "ts.h"
int main(int argc, char const *argv[])
{
// 1,打開LCD設備
int lcd = open("/dev/fb0", O_RDWR);
// 2,獲取LCD設備的參數(shù)
struct fb_var_screeninfo vinfo;
ioctl(lcd, FBIOGET_VSCREENINFO, &vinfo);
// 3,為該LCD設備映射顯存
unsigned char *FB;
FB = mmap(NULL, vinfo.xres * vinfo.yres * vinfo.bits_per_pixel/8,
PROT_READ|PROT_WRITE, MAP_SHARED, lcd, 0);
// 4,顯示整個鋼琴的界面
// 4.1 顯示背景(background.bmp)
bmp2lcd("background.bmp", FB, &vinfo, 0, 0);
// 4.2 顯示標題欄(bar.bmp)
bmp2lcd("bar.bmp", FB, &vinfo, 0, 0);
// 4.3 顯示12個琴鍵(bar.bmp)
int i;
for(i=0; i<12; i++)
{
bmp2lcd("key_off.bmp", FB, &vinfo, 10+65*i, 47);
}
// 4.4 顯示LOGO(logo.bmp)
bmp2lcd("logo.bmp", FB, &vinfo, 214, 355);
// 5,打開觸摸屏設備,開始音樂鋼琴
int ts = open("/dev/event0", O_RDWR);
struct coordinate coor;
while(1)
{
// 5.1 等待手指觸碰,并順便獲取觸碰點坐標(coor.x和coor.y)
wait4touch(ts, &coor);
// 5.2 根據(jù)coor的坐標信息來更新琴鍵的狀態(tài)
bmp2lcd("key_on.bmp", FB, &vinfo,(coor.x-10)/65*65+10, 47);
// 5.3 根據(jù)coor的坐標信息播放相應的琴鍵聲音(暫時不做)
// 5.4 等待手指的松開
wait4leave(ts);
// 5.5 將相應的琴鍵恢復彈起的狀態(tài)
bmp2lcd("key_off.bmp", FB, &vinfo,(coor.x-10)/65*65+10, 47);
}
return 0;
}
// int ts = open("/dev/event0", O_RDWR);
// struct coordinate coor;
// while(1)
// {
// // 5.1 等待手指觸碰,并順便獲取觸碰點坐標(coor.x和coor.y)
……………………
…………限于本文篇幅 余下代碼請從51黑下載附件…………
復制代碼
所有資料51hei提供下載:
06實現(xiàn)琴鍵按下效果.rar
(10.25 KB, 下載次數(shù): 38)
2017-7-25 15:28 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
作者:
zzjay
時間:
2019-7-4 13:00
最好把仿真文件,程序文件都上傳,文檔中寫的都不全
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1