diff --git a/src/main.c b/src/main.c index 39487dd..6ad48db 100644 --- a/src/main.c +++ b/src/main.c @@ -6,7 +6,7 @@ #include "string.h" //#define PI 3.141592653584 -void DrawKeyF(unsigned char* str, unsigned char keyF) +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); @@ -16,30 +16,29 @@ int main(void) { unsigned int key = 0; unsigned short place = 0; - //unsigned int i=0; - note.freq = 440; - note.wave.signal[0] = 0; - note.duration = 2000; +// 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", place); - dprint(1, 30, "F1:note/F2:sequence"); + dprint(1, 20, "%d", note.wave.length); DrawKeyF("not", 1); DrawKeyF("seq", 2); DrawKeyF("_", 5); DrawKeyF("-", 6); - note.wave.length = place; - dupdate(); key = getkey(); @@ -58,9 +57,7 @@ int main(void) case KEY_F1 : CallNote(); break; case KEY_F2 : CallSequence(); break; - case KEY_EXIT : - StopTimer(); - return 1; + case KEY_EXIT : StopTimer(); return 1; } } return 1; // this point is never reached diff --git a/src/sound4calc.c b/src/sound4calc.c index e0a2bfa..2aa5db1 100644 --- a/src/sound4calc.c +++ b/src/sound4calc.c @@ -2,16 +2,14 @@ #include // from Gint #include //from Gint -static int strlen(char* str); - static struct { int freq; int length_ms; } seq[] = { - { 440, 1000 }, - { 392, 1000 }, - { 349, 1000 }, - { -1, -1 } + { 440, 500 }, + { 392, 500 }, + { 349, 1000 }, + { -1, -1 }, }; struct Note note; @@ -48,6 +46,10 @@ void CallSequence() seq_length--; } +/* + CallNote(); + Create a single sound +*/ void CallNote() { timer_start(TIMER_USER, note.freq * note.wave.length, Clock_Hz, PlayNote, note.wave.length * note.freq * note.duration / 1000); @@ -110,9 +112,6 @@ void InitPorts() { if(isSH3()) { -// initialisation of pin -// *(volatile unsigned char*)SH7337_SCPDR |= 0x01; - // SCIF2 clock on (STBCR3.MSTP31) *(volatile unsigned char*)SH7337_STBCR3 &= ~0x02; // switch off SCSMR_2.TE and SCSMR_2.RE @@ -128,9 +127,6 @@ void InitPorts() } else { -// initialisation of pin -// *(volatile unsigned char*)SH7305_PJDR |= 0x04; - // SCIF2 clock on (MSTPCR0.MSTP007) *(volatile unsigned int*)SH7305_MSTPCR0 &= ~0x00000080; // switch off SCSMR_2.TE and SCSMR_2.RE @@ -154,14 +150,3 @@ void InitPorts() */ } } - -/* - Strings functions -*/ - -static int strlen(char *str) -{ - int i = 0; - while(*str++) i++; - return i; -}