Sound4Calc/src/main.c

65 lines
1.6 KiB
C

#include "main.h"
#include "sound4calc.h"
#include <timer.h>
#include <display.h>
#include <keyboard.h>
#include "string.h"
//#define PI 3.141592653584
void DrawKeyF(char* str, unsigned char keyF)
{
dprint((keyF-1)*22 + 8 - 2*strlen(str), 55, "%s", str);
dreverse_area((keyF-1)*22 - 2 , 54, keyF * 21, 64);
}
int main(void)
{
unsigned int key = 0;
unsigned short place = 0;
// initialisation to play
note.freq = 440;
note.wave.signal[0] = 0;
note.duration = 2000;
InitPorts();
while(1)
{
note.wave.length = place;
dclear();
dprint(1, 1, "%d", note.freq);
dprint(1, 10, "%s", note.wave.signal);
dprint(1, 20, "%d", note.wave.length);
DrawKeyF("not", 1);
DrawKeyF("seq", 2);
DrawKeyF("_", 5);
DrawKeyF("-", 6);
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++) = '_'; *(note.wave.signal+place) = 0; break;
case KEY_F6 : *(note.wave.signal+place++) = '-'; *(note.wave.signal+place) = 0; 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_EXIT : StopTimer(); return 1;
}
}
return 1; // this point is never reached
}