From 6f37e29f4deeaf8a7396267e3a7e24f4e77d7967 Mon Sep 17 00:00:00 2001 From: flo Date: Sun, 26 Feb 2017 15:01:53 +0100 Subject: [PATCH] minors modifs --- include/sound4calc.h | 2 +- src/main.c | 11 ++++++----- src/sound4calc.c | 3 ++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/sound4calc.h b/include/sound4calc.h index 9e24e8a..c9d213c 100644 --- a/include/sound4calc.h +++ b/include/sound4calc.h @@ -1,7 +1,7 @@ #ifndef _SOUND4CALC_H #define _SOUND4CALC_H -extern char* wave_signal; // simple waveform* +extern char wave_signal[25]; // simple waveform* extern unsigned short duration; // equivalent as 2000 ms duration sound extern unsigned int freq; diff --git a/src/main.c b/src/main.c index 4b071bb..7aa12c1 100644 --- a/src/main.c +++ b/src/main.c @@ -20,9 +20,11 @@ int main(void) dprint(1, 1, "%d", freq); dprint(1, 10, "%s", wave_signal); - //dprint(1, 20, "%d", place); + dprint(1, 20, "F1:note/F2:sequence", place); dtext(1, 50, "F5 _ F6 -"); + + dupdate(); key = getkey(); @@ -38,12 +40,11 @@ int main(void) case KEY_F6 : *(wave_signal+place++) = '-'; break; case KEY_DEL : place=(place>0 ? place - 1 : 0); *(wave_signal+place) = 0; break; - case KEY_EXE : - CallNote(); - break; + case KEY_F1 : CallNote(); break; + case KEY_F2 : CallSequence(); break; case KEY_EXIT : - //timer_stop(TIMER_USER); + timer_stop(TIMER_USER); return 1; } } diff --git a/src/sound4calc.c b/src/sound4calc.c index 27e9f7e..78e4e3f 100644 --- a/src/sound4calc.c +++ b/src/sound4calc.c @@ -12,7 +12,7 @@ static struct { { -1, -1 } }; -char* wave_signal = "-_"; // simple waveform +char wave_signal[25] = {0}; // simple waveform unsigned short duration = 2000; // equivalent as 2000 ms duration sound unsigned int freq = 440; @@ -45,6 +45,7 @@ void CallSequence() void CallNote() { unsigned int wavelength = strlen(wave_signal); + timer_start(TIMER_USER, freq * wavelength, Clock_Hz, PlayNote, freq * duration / 1000); }