Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TS_DISCO_F746NG mbed LCD_DISCO_F746NG BSP_DISCO_F746NG
Revision 2:58378cb7e76f, committed 2019-05-04
- Comitter:
- chana_jo
- Date:
- Sat May 04 08:46:30 2019 +0000
- Parent:
- 1:19138bfe23c9
- Child:
- 3:3a2c11f459c4
- Commit message:
- vv
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri May 03 13:27:39 2019 +0000
+++ b/main.cpp Sat May 04 08:46:30 2019 +0000
@@ -15,25 +15,29 @@
AnalogIn volumeknob(A0);
PwmOut speaker(D1);
Serial pc(USBTX, USBRX);
-Ticker re,er,rr,ee,sn44tick,cl44tick,clhh44tick,ophh44tick,kick44tick;//timer ไว้ attach ตอนplay audio กับไว้รับปุ่ม
+Ticker re,er,rr,ee,sn44tick,cl44tick,clhh44tick,ophh44tick,kick44tick,testprint;//timer ไว้ attach ตอนplay audio กับไว้รับปุ่ม
int checkplay=1,beat[5][8],page=1;
+int tracking;
char currentpage[50],volumechar[50],strvolume[50],strtempo[50],tempostr[50]; //สร้างไว้ให้เขียนอักษรได้เฉยๆ
float volume,tempo;
-int i=0;
+float speed; //tempo converted to sec
+int h,i,j,k,l;
void test(void); //function for touchscreen
void play(void);// function for play
void screen(void);//function for display
void knob(void);// read knob
+void testbeat1(void);
+void testbeat2(void);
int main()
{
lcd.Clear(LCD_COLOR_BLUE);
ee.attach(&screen, 0.03);
- re.attach(&play, 0.1);//เล่นตามsamplerate
+ re.attach(&play, 0.5);//เล่นตามtempo
er.attach(&test, 0.25);//กดช้ากดเร็วแล้วแต่
- rr.attach(&knob,0.5);//readknob ทุก0.5
-
+ //rr.attach(&knob,0.5);//readknob ทุก0.5
+
}
@@ -43,12 +47,12 @@
void sn44_sample ()
{
- speaker = sn44_data[i]/16777215.0;//scale to 0.0 to 1.0 for PWM
- i++;
- if (i>= num_sn44) {
- i = 0;
+ speaker = sn44_data[h]/16777215.0;//scale to 0.0 to 1.0 for PWM
+ h++;
+ if (h>= num_sn44) {
+ h = 0;
sn44tick.detach();
- led = 0;
+ //led = 0;
}
}
void cl44_sample ()
@@ -59,40 +63,40 @@
if (i>= num_cl44) {
i = 0;
cl44tick.detach();
- led = 0;
+ //led = 0;
}
}
void clhh44_sample ()
{
- speaker = clhh44_data[i]/16777215.0;//scale to 0.0 to 1.0 for PWM
- i++;
- if (i>= num_clhh44) {
- i = 0;
+ speaker = clhh44_data[j]/16777215.0;//scale to 0.0 to 1.0 for PWM
+ j++;
+ if (j>= num_clhh44) {
+ j = 0;
clhh44tick.detach();
- led = 0;
+ //led = 0;
}
}
void ophh44_sample ()
{
- speaker = ophh44_data[i]/16777215.0;//scale to 0.0 to 1.0 for PWM
- i++;
- if (i>= num_ophh44) {
- i = 0;
+ speaker = ophh44_data[k]/16777215.0;//scale to 0.0 to 1.0 for PWM
+ k++;
+ if (k>= num_ophh44) {
+ k = 0;
ophh44tick.detach();
- led = 0;
+ //led = 0;
}
}
void kick44_sample ()
{
- speaker = kick44_data[i]/16777215.0;//scale to 0.0 to 1.0 for PWM
- i++;
- if (i>= num_kick44) {
- i = 0;
+ speaker = kick44_data[l]/16777215.0;//scale to 0.0 to 1.0 for PWM
+ l++;
+ if (l>= num_kick44) {
+ l = 0;
kick44tick.detach();
- led = 0;
+ //led = 0;
}
}
@@ -143,17 +147,65 @@
wait(0.2);
}
-////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void play()
{
- if(checkplay==1)//led blink when button play is on
- {
+ if(checkplay==1)//led blink when button play is on
+ {
+ pc.printf("current beat : %d ",tracking);
+ if(tracking<8)
+ tracking=tracking+1;
+ else if(tracking==8)
+ tracking=1;
led=!led;
+
+ if(tracking==1)
+ {
+
+
+ }
+ else if(tracking==2)
+ {
+
+
+ }
+ else if(tracking==3)
+ {
+
+
+ }
+ else if(tracking==4)
+ {
+
+
+ }
+ else if(tracking==5)
+ {
+
+
+ }
+ else if(tracking==6)
+ {
+
+
+ }
+ else if(tracking==7)
+ {
+
+
+ }
+ else if(tracking==8)
+ {
+
+
+ }
+
}
- else if(checkplay==0)//led off
- {
- led=0;
- }
+ else if(checkplay==0)//led off
+ {
+ led=0;
+ tracking=1;
+ }
}
@@ -469,4 +521,5 @@
}
}
-
\ No newline at end of file
+
+