📄 voice_task.c
字号:
case KEY_PREV:
voc_play_stop(); /* stop playing */
disp_clock_stop(); /* suspend clock timer */
Fclose();
file_seek_prev(FILE_WAV); /* select previous message */
voice_state = VOICE_PLAY_NEW;
break;
case KEY_INC:
voc_inc_volume(); /* increment volume */
print_voice_vol(Voc_get_volume()); /* display new level */
break;
case KEY_DEC:
voc_dec_volume(); /* decrement volume */
print_voice_vol(Voc_get_volume()); /* display new level */
break;
case KEY_DEL:
voc_play_stop(); /* stop playing */
Fclose();
voice_state = VOICE_DELETE; /* remove file from FAT */
break;
case KEY_STOP:
voc_play_stop(); /* stop playing */
Fclose();
voice_state = VOICE_PLAY_STOP;
break;
case KEY_LOCK:
print_kbd_lock(); /* print keyboard status */
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
case VOICE_PLAY_PAUSE: /* one file openned */
{
if (gl_key_press) /* a key is pressed? */
{
switch (gl_key)
{
case KEY_PLAY:
disp_clock_start(); /* restart clock timer */
voc_play_start(); /* restart sample request */
print_state_play(); /* display play icon */
voice_state = VOICE_PLAY;
break;
case KEY_NEXT:
voc_play_stop();
Fclose();
file_seek_next(FILE_WAV, TRUE); /* select next message with loop */
print_file_name(); /* display file name */
voice_state = VOICE_IDLE;
break;
case KEY_PREV:
voc_play_stop();
Fclose();
file_seek_prev(FILE_WAV); /* select previous message */
print_file_name(); /* display file name */
voice_state = VOICE_IDLE;
break;
case KEY_INC:
voc_inc_volume(); /* increment volume */
print_voice_vol(Voc_get_volume()); /* display new level */
break;
case KEY_DEC:
voc_dec_volume(); /* decrement volume */
print_voice_vol(Voc_get_volume()); /* display new level */
break;
case KEY_STOP:
voc_play_stop(); /* stop playing */
Fclose();
voice_state = VOICE_PLAY_STOP;
break;
case KEY_LOCK:
print_kbd_lock(); /* print keyboard status */
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
case VOICE_PLAY_NEW:
{
voice_state = VOICE_PLAY_INIT; /* new message */
print_file_name(); /* display file name */
break;
}
case VOICE_PLAY_STOP:
{
disp_clock_reset(); /* reset clock timer */
print_file_type(); /* display wav icon */
voice_state = VOICE_IDLE;
break;
}
case VOICE_NO_MSG:
{
if (gl_key_press) /* a key is pressed? */
{
switch (gl_key)
{
case KEY_MEM:
mem_select_next(); /* select next memory */
voice_state = VOICE_START;
break;
case KEY_REC:
voice_state = VOICE_REC_INIT;
break;
case KEY_MODE:
mode_set_init(); /* exit from voice task */
voice_state = VOICE_START;
break;
case KEY_LOCK:
print_kbd_lock(); /* print keyboard status */
break;
}
gl_key_press = FALSE; /* ack key usage */
}
else
{ /* check card presence */
if (mem_check_card() == KO)
{
mem_select_next();
voice_state = VOICE_START; /* card has been unplugged */
}
}
break;
}
case VOICE_REC_INIT:
{
disp_clock_reset(); /* reset clock timer */
if (Fcreate() != OK)
{
voice_state = VOICE_ERROR;
}
else
{
print_file_name(); /* display new file name */
voc_cpt = 0;
print_state_record(); /* display record icon */
voc_rec_init();
disp_clock_start(); /* start clock timer */
voice_state = VOICE_RECORD;
}
break;
}
case VOICE_RECORD:
{
while ((Byte)voc_cpt != gl_pointer)
{
Fputc(voice_buffer[(Byte)voc_cpt]);
if (Feod()) /* check end of disk */
{
Voc_rec_stop(); /* stop voice sampling */
voice_state = VOICE_REC_STOP;
break; /* exit while loop */
}
voc_cpt++;
}
if (gl_key_press) /* a key is pressed? */
{
switch (gl_key)
{
case KEY_PAUSE:
disp_clock_stop(); /* suspend clock timer */
Voc_rec_pause();
print_state_pause(); /* display pause icon */
voice_state = VOICE_REC_PAUSE;
break;
case KEY_STOP:
Voc_rec_stop(); /* stop voice sampling */
voice_state = VOICE_REC_STOP;
break;
case KEY_LOCK:
print_kbd_lock(); /* print keyboard status */
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
case VOICE_REC_PAUSE:
{
if (gl_key_press) /* a key is pressed? */
{
switch (gl_key)
{
case KEY_REC:
disp_clock_start(); /* restart clock timer */
print_state_record(); /* display record icon */
Voc_rec_start(); /* restart sampling */
voice_state = VOICE_RECORD;
break;
case KEY_STOP:
Voc_rec_stop(); /* stop voice sampling */
voice_state = VOICE_REC_STOP;
break;
case KEY_LOCK:
print_kbd_lock(); /* print keyboard status */
break;
default:
break;
}
gl_key_press = FALSE; /* ack key usage */
}
break;
}
case VOICE_REC_STOP:
{
/* update wave header */
Fseek(-voc_cpt); /* beginning of file */
Fputc(((Byte*)&gl_wav_header)[0]); /* 'R' */
Fputc(((Byte*)&gl_wav_header)[1]); /* 'I' */
Fputc(((Byte*)&gl_wav_header)[2]); /* 'F' */
Fputc(((Byte*)&gl_wav_header)[3]); /* 'F' */
// voc_cpt += 36;
voc_cpt -= 8;
Fputc(((Byte*)&voc_cpt)[3]); /* wave length */
Fputc(((Byte*)&voc_cpt)[2]);
Fputc(((Byte*)&voc_cpt)[1]);
Fputc(((Byte*)&voc_cpt)[0]);
for (i = 8; i != WAV_HEADER_SIZE-4; i++)
{
Fputc(((Byte code *)&gl_wav_header)[i]);
}
voc_cpt -= 36;
Fputc(((Byte*)&voc_cpt)[3]); /* data length */
Fputc(((Byte*)&voc_cpt)[2]);
Fputc(((Byte*)&voc_cpt)[1]);
Fputc(((Byte*)&voc_cpt)[0]);
for (i = 255; i != 0; i--)
{
Fputc(0x80); /* fill first sector data */
}
for (i = 257 - WAV_HEADER_SIZE; i != 0; i--)
{
Fputc(0x80); /* fill first sector data */
}
Fclose();
disp_clock_reset(); /* reset clock timer */
print_file_type(); /* display wav icon */
voice_state = VOICE_IDLE;
break;
}
case VOICE_ERROR:
{
disp_clock_reset(); /* reset clock timer */
print_state_error(); /* display error icon */
disp_name_stop();
voice_state = VOICE_IDLE;
break;
}
case VOICE_DELETE:
{
Fdelete();
disp_clock_reset(); /* reset clock timer */
if (File_entry_root(FILE_WAV) == OK)/* WAV file in root dir? */
{
print_file_name(); /* display file name */
voice_state = VOICE_IDLE;
}
else
{ /* no *.wav file in root */
voice_state = VOICE_NO_MSG;
}
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -