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: mbed
Diff: Front/Front.cpp
- Revision:
- 25:f230af268e8b
- Parent:
- 24:c3bb1b0b2207
- Child:
- 26:a6033830d01c
--- a/Front/Front.cpp Sun May 24 15:20:31 2020 +0000
+++ b/Front/Front.cpp Sun May 24 17:10:27 2020 +0000
@@ -69,6 +69,73 @@
{ 0,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0 },
{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
};
+
+const int Low_pass[19][29]= {//LPF plot
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0 },
+ { 0,0,0,0,0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,1,0,0 },
+};
+
//Gloabal Variables
volatile int g_isr_flag; //used for sound generation
volatile extern int silent_flag; //used for note release
@@ -86,13 +153,13 @@
void Front::frontrun(N5110 &lcd, Gamepad &pad, int submenu)
{
//printf("G_ISR_FLAG= %d\n",g_isr_flag); //DEBUG
- frontsetup(lcd, pad, submenu, true); //Initialises front pannel display
+ frontsetup(lcd, pad, submenu,0, true); //Initialises front pannel display
initialise(pad,lcd,submenu);
frequency=frequency_convert(pad);
menuflag=1; //sets up flags
release_flag=silent_flag=0;
used=1; //initialises vairables
- envelope_in=0;
+ filter_type=envelope_in=0;
a=d=s=r=17; //starting adsr values (1->35)
noteon=false;
#ifdef CSV
@@ -129,10 +196,11 @@
dir=pad.get_direction();
if (dir!=dir_1) {
printf("dir =%d\n",dir); //debug
+ //used=parameter_manager(pad,dir,a,d,s,r);
if(dir==3) {
used++;
- if (used>4) {
- used=4;
+ if (used>5) {
+ used=5;
}
}
if (dir==7) {
@@ -170,7 +238,7 @@
r=incrament_adsr(used,r,-1);
}
}
- frontsetup(lcd,pad,submenu,false);
+ frontsetup(lcd,pad,submenu,filter_type,false);
printsliders(lcd,a,d,s,r,used);
wait_ms(50);
} //END if DIR
@@ -200,11 +268,12 @@
//PRIVATE-----------------------------------------------------------------------
-void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu, bool initial)
+void Front::frontsetup(N5110 &lcd, Gamepad &pad, int submenu, int filter_type, bool initial)
{
if (initial==true) {
printsliders(lcd,17,17,17,17,1);
printf("front setup complete\n\n");
+
}
lcd.clear();
lcd.printString("A D S R",3,5);
@@ -214,6 +283,7 @@
printfader(lcd,39,3);
lcd.drawRect(50,3,30,8,FILL_TRANSPARENT);
printwav(lcd,submenu);
+ printfilter(lcd, 3);
lcd.refresh();
}
@@ -259,6 +329,12 @@
printslider(lcd,27,s,false);
printslider(lcd,39,r,true);
}
+ if(used>=5) {
+ printslider(lcd,3,a,false);
+ printslider(lcd,15,d,false);
+ printslider(lcd,27,s,false);
+ printslider(lcd,39,r,false);
+ }
lcd.refresh();
}
@@ -295,18 +371,46 @@
}
}
+void Front::printfilter(N5110 &lcd, int filter_type)
+{
+ if (filter_type>=1) {
+ lcd.drawLine(51,32,51,12,1); //y axis
+ lcd.drawLine(51,32,81,32,1); //x axis
+ if (filter_type==1) {
+ lcd.drawSprite(52,13,19,29,(int *)Low_pass);
+ lcd.printString("L",45,2);
+ }
+ if (filter_type==2) {
+ lcd.drawSprite(52,13,19,29,(int *)High_pass);
+ lcd.printString("H",45,2);
+ }
+ if (filter_type==3) {
+ lcd.drawSprite(52,13,19,29,(int *)Band_pass);
+ lcd.printString("B",45,2);
+ }
+ }
+}
+
+int Front::parameter_manager(Gamepad &pad, int dir, int a, int d, int s, int r)
+{
+
+ return(used);
+}
+
int Front::incrament_adsr(int used, int adsr, int ud)
{
- if (ud==1) {
- adsr++;
- if (adsr>35) {
- adsr--;
+ if (used<=4) {
+ if (ud==1) {
+ adsr++;
+ if (adsr>35) {
+ adsr--;
+ }
}
- }
- if (ud==-1) {
- adsr--;
- if (adsr<1) {
- adsr++;
+ if (ud==-1) {
+ adsr--;
+ if (adsr<1) {
+ adsr++;
+ }
}
}
return(adsr);