Sound4Calc/src/main.c

58 lines
1.4 KiB
C

#include "main.h"
#include "sound4calc.h"
#include <timer.h>
#include <display.h>
#include <keyboard.h>
#include "string.h"
//#define PI 3.141592653584
int main(void)
{
unsigned int key = 0;
unsigned short place = 0;
//unsigned int i=0;
InitPorts();
while(1)
{
dclear();
dprint(1, 1, "%d", note.freq);
dprint(1, 10, "%s", note.wave.signal);
dprint(1, 20, "%d", place);
dprint(1, 30, "F1:note/F2:sequence");
dtext(1, 50, "F5 _ F6 -");
note.wave.length = place;
dupdate();
key = getkey();
switch(key)
{
case KEY_RIGHT : note.freq+=1; break;
case KEY_LEFT : note.freq-=1; break;
case KEY_UP : note.freq+=10; break;
case KEY_DOWN : note.freq-=10; break;
case KEY_F5 : *(note.wave.signal+place++) = '_'; break;
case KEY_F6 : *(note.wave.signal+place++) = '-'; break;
case KEY_DEL : place=(place>0 ? place - 1 : 0); *(note.wave.signal+place) = 0; break;
case KEY_F1 : CallNote(); break;
case KEY_F2 : CallSequence(); break;
case KEY_EXE :
timer_start(TIMER_USER, note.freq * place, Clock_Hz, PlayNote, place * note.freq * note.duration / 1000);
break;
case KEY_EXIT :
StopTimer();
return 1;
}
}
return 1; // this point is never reached
}