1.操作环境
Ubuntu 18.04
WMware
嵌入式开发板
2.功能描述:
1)相册:点击”相册“按钮,循环展示相册里的图片,每个图片之间间隔5s,播放图片的过程中伴随着音乐的播放,图片展示完毕自动返回主菜单;
2)音乐:点击”音乐“按钮,展示分菜单,上面有”从头播放“、”结束播放“、”暂停“、”播放“、”上一首“、”下一首“,”返回上一级菜单“几个按钮,按下的对应按钮做出相关反应。
3.实物展示
4.代码
head.h
#ifndef _HEAD_H_
#define _HEAD_H_
//头文件
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/input.h>
#include <strings.h>
#include <sys/mman.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <linux/fb.h>
#include <stdbool.h>
#include <stdio.h>
//全局变量
#define BMP_SIZE 800*480*3 //图片像素大小
#define LCD_SIZE 800*480*4 //LCD像素大小
#define TS_PATH "/dev/input/event0"
#define LCD_WIDTH 800
#define LCD_HEIGHT 480
#define FB_SIZE (LCD_WIDTH * LCD_HEIGHT * 4)
#define Music_count sizeof(musics)/sizeof(musics[0])
int x;
int y;
int wy;
static int Cur_Idx=0;
static int bIsPlaying=0;
//结构体
enum
{
ACTION_START,
ACTION_STOP,
ACTION_PAUSE,
ACTION_PLAY,
ACTION_NEXT,
ACTION_PREV,
ACTION_EXIT,
};
//函数声明
int Get_Action();
void Music_Start(const char* Music);
void Music_Pause();
void Music_Play();
void Music_Stop();
void Action_handler();
int show_bmp();
int touch();
int color();
void Music_criclePlay();
#endif
main.c
#include "head.h"
int main(){
//color();
while(1){
wy=1;
show_bmp("./menu0.bmp");
touch();
if(x>89 &&x<373 &&y>31 &&y<205){
//相册
Music_criclePlay();
show_bmp("./1.bmp");
sleep(5);
show_bmp("./2.bmp");
sleep(5);
show_bmp("./3.bmp"