四、关键代码:
play.c
int player_next(player_t player)
{
uint16_t len;
rt_uint32_t level;
/* 关闭全局中断 */
level = rt_hw_interrupt_disable();
/* 将当前播放歌曲的序号 加一 */
if (player-》song_current 《 player-》song_num)
{
player-》song_current ++;
}
else
{
player-》song_current = 1;
}
g_songnum = player-》song_current;
/* 更新播放器的当前歌曲的播放时间以及总时间 */
player-》song_
time_pass = 0;
/* 打开全局中断 */
rt_hw_interrupt_enable(level);
player-》decode-》control(player-》song_sheet[player-》song_current - 1], DECODE_OPS_CMD_GET_LEN, &len);
/* 关闭全局中断 */
level = rt_hw_interrupt_disable();
player-》song_time_all = len;
/* 打开全局中断 */
rt_hw_interrupt_enable(level);
if (player-》status != PLAYER_RUNNING)
{
player_play(player);
}
return 0;
}
LCD.c
void lcd_thread_handler(void *parameter)
{
rt_uint8_t temp = 0;
rt_kprintf(“lcd thread handler!”);
LCD_Init();
LCD_Fill(0,0,LCD_W,LCD_H,WHITE);
lcd_show_menu();
while(1)
{
rt_kprintf(“lcd thread running!”);
if(temp != g_songnum)
{
rt_kprintf(“lcd,temp = %d,g_songnum = %d”,temp,g_songnum);
temp = g_songnum;
LCD_Fill(1,128+8,LCD_W,LCD_H,WHITE);
}
lcd_show_pic1();
rt_thread_mdelay(500);
}
}
void lcd_show_menu(void)
{
LCD_ShowPicture(0,0,127,128,gImage_music);
LCD_ShowChinese(30,128-10,“正在播放”,RED,WHITE,16,0);
LCD_ShowChinese(1,128+8,“快乐父子俩”,RED,WHITE,16,0);
}
void lcd_show_pic1(void)
{
switch (g_songnum){
case 1 :LCD_ShowChinese(1,128+8,“快乐父子俩”,RED,WHITE,16,0);break;
case 2 :LCD_ShowChinese(1,128+8,“葫芦娃”,RED,WHITE,16,0);break;
case 3 :LCD_ShowChinese(1,128+8,“送别”,RED,WHITE,16,0);break;
case 4 :LCD_ShowChinese(1,128+8,“两只老虎”,RED,WHITE,16,0);break;
default: break;
}
}
key.h
#define KEY_NEXT_PIN 4
key.c
int key_init(void)
{
btn_last.press_logic_level = KEY_PRESS_LEVEL;
btn_last.hold_cyc_period = 100;
btn_last.cb = (my_button_callback)btn_cb;
btn_next = btn_play = btn_last;
btn_last.pin = KEY_PLAY_PIN;
btn_play.pin = KEY_LAST_PIN;
btn_next.pin = KEY_NEXT_PIN;
my_button_register(&btn_last);
my_button_register(&btn_play);
my_button_register(&btn_next);
my_button_start();
return 0;
}
原作者:当字符爱上音符