#include "pff.h"
#include "lib.h"
-#define AUDIO_CMD_PULSE 'p'
-#define AUDIO_CMD_PLAY 'd'
-
-void audio_pulse(void)
-{
- char *p;
- p = kz_kmalloc(1);
- p[0] = AUDIO_CMD_PULSE;
- kz_send(MSGBOX_ID_AUDIO, 1, p);
-}
+#define AUDIO_CMD_PLAY 'd'
+#define AUDIO_CMD_VOLUME 'v'
int audio_play(int (*readfunc)(void *buf, int siz))
{
return (siz == cnt) ? 1 : 0;
}
+int audio_volume(const int left, const int right)
+{
+ char *p;
+ p = kz_kmalloc(4);
+ p[0] = AUDIO_CMD_VOLUME;
+ p[1] = 0;
+ p[2] = 255 - left;
+ p[3] = 255 - right;
+ if ((0 <= left) && (left <= 255) && (0 <= right) && (right <= 255)) {
+ kz_send(MSGBOX_ID_AUDIO, 4, p);
+ return 1;
+ }
+ return 0;
+}
+
static int waitfunc(void)
{
kz_wait();
static int audio_cmdproc(char *p)
{
int cmd = p[0];
- volatile int i;
-
switch (cmd) {
- case AUDIO_CMD_PULSE:
- vs1011e_sinetest_init();
- for (i = 0; i < 2000; i++) { }
- vs1011e_sinetest_fini();
- break;
case AUDIO_CMD_PLAY:
vs1011e_play_with_data(
&p[8],
((unsigned char)p[4] << 8) | ((unsigned char)p[5] << 0),
waitfunc);
break;
+ case AUDIO_CMD_VOLUME:
+ puts("L:"); putxval(p[2], 2); puts("\n");
+ puts("R:"); putxval(p[3], 2); puts("\n");
+ vs1011e_volume_write(p[2], p[3]);
+ break;
default:
break;
}
#ifndef TASK_AUDIO_H
#define TASK_AUDIO_H
-void audio_pulse(void);
int audio_play(int (*readfunc)(void *buf, int siz));
+int audio_volume(const int left, const int right);
+
int task_audio(int argc, char *argv[]);
#endif
display_led_write(1, 0);
display_led_toggle(0);
}
- if (40 < nx) {
+ if (0 < nx) {
nx--;
}
} else {
putxval(data[2], 2);
putxval(data[3], 2);
puts("\n");
- audio_pulse();
display_led_toggle(2);
}
bitcnt = 0;
#include "kozos.h"
#include "lib.h"
+FATFS fatfs;
+DIR dir;
+FILINFO filinfo;
+
static int readfunc(void *buf, int siz)
{
WORD cnt;
if (r != FR_OK) {
return 1;
}
+ int cnt = 0;
while (audio_play(readfunc)) {
+ if (((cnt++) % 32) == 0) {
+ display_draw_progressbar(5, 20, 121 - 5, 25, 0, 100, fatfs.fptr * 100 / fatfs.fsize);
+ }
kz_wait();
}
+ display_draw_progressbar(5, 20, 121 - 5, 25, 0, 100, fatfs.fptr * 100 / fatfs.fsize);
return 0;
}
int task_menu(int argc, char *argv[])
{
#if 0
- FATFS fatfs;
- DIR dir;
- FILINFO filinfo;
-
display_clear();
display_draw_logo( 0, 0, 2);
display_draw_box(0, 0, 121, 31, 1);
display_draw_text(40, 4, "KOZOS EXPBRD #00");
+ audio_volume(250, 250);
+
while (1) {
if (pf_mount(&fatfs)) {
continue;
display_draw_box(0, 0, 121, 31, 1);
display_draw_text(40, 4, "KOZOS EXPBRD #00");
- kz_sleep();
+ while (1) {
+ kz_sleep();
+ }
#endif
return 0;