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.
main.cpp
00001 /*******************************************************************/ 00002 /************* Dec 22 2010 ************************/ 00003 /************* V.1a ************************/ 00004 /************* Balanced Stereo Pre-amplifer Control Program ********/ 00005 #include "mbed.h" 00006 #include "system_defines.h" 00007 #include "stdlib.h" 00008 #include "font_1.h" 00009 #include "stdlib.h" 00010 #include "string.h" 00011 #include "math.h" 00012 /* global defines */ 00013 int volume; 00014 int balance_left =0; 00015 int balance_right=0; 00016 int bright=8; /* this is the backlight brightness */ 00017 int relay=0; /* this is just a counter */ 00018 unsigned int control = 0; /* for the control outputs on the CPU board. This is the intial setting */ 00019 unsigned int controls = 0; /* this is temporary storage value for control above used in power up and power down */ 00020 int unsigned inputrelay=1; /* inputrelay holds the bit position of the selected relay */ 00021 int pwrupvol=1; 00022 int power=0; /* set to 64 to turn it ON */ 00023 int loopgain=0; /*set to 32 to turn it ON */ 00024 int trigger=0; /* set to 16 to turn it ON */ 00025 int mutebit=0; /* set to 1 to turn it ON */ 00026 int hpmutebit=0; /* set to 127 to turn it ON */ 00027 int recloop1bit=0; /*set to 2 to turn it ON */ 00028 char remcon[6], ch[6];//were 10 00029 int remcontoken; 00030 int remaction; 00031 int rctimeoutflag; 00032 int r=0, k=0; /* these are counters used in the remote control routine */ 00033 int flag=0; /* this fetches the command control code - remote or via f/panel PB's */ 00034 float lightlevel; 00035 /********************** system constants ********************/ 00036 // baclight bit position defines 00037 #define stripbacklight ~61440 00038 #define HIGH 1; 00039 #define LOW 0; 00040 //#define TRUE 1; 00041 #define FALSE 0; 00042 #define incdec 1; 00043 #define VOLA(p21); 00044 #define VOLB(p22); 00045 #define VOLPB(p23); 00046 #define IPSELA(p24); 00047 #define IPSELB(p25); 00048 #define IPSELPB(p26); 00049 #define SERIN(p27); 00050 #define STR_LENGTH 7 00051 #define STR_LENGTH_1 5 00052 char temp_string[STR_LENGTH_1 ]; 00053 /*********** these are the input select relay bit position assignments **********/ 00054 #define Aux2 4 00055 #define Aux1 8 00056 #define Recorder 16 00057 #define CD 32 00058 #define Phono 64 00059 /********************** declare all Graphic.h here AFTER the global defines**********************/ 00060 #include "Graphic.h" 00061 00062 /********************** declare all interrupt input pins here**********************/ 00063 InterruptIn volumein(p21); /* interuppt from the volume control encoder */ 00064 InterruptIn inputsel(p24); /* for the input select encoder */ 00065 InterruptIn mutesw(p26); /* this mutes the output - pb att to the sel encoder */ 00066 InterruptIn powersw(p23); /* this turns the main power on-off. Att. to the vol control encoder */ 00067 Timeout timeout; /* remote control timeout */ 00068 00069 /********************** mbed HALT mode (from Igor Skochinsky) ****************************/ 00070 /* note: this will not work if the usb is connected, if local files, */ 00071 /* or printf statements are used. Disconnect USB to get this to work */ 00072 void halt() { 00073 #if defined(TARGET_LPC1768) 00074 __wfi(); // (enter sleep mode and) wait for interrupt 00075 #else 00076 LPC_SC->PCON |= 1; // set PM0 = 1: enter idle mode (assuming PM1 and PM2 are 0) 00077 #endif 00078 } 00079 /********************** how to disable interrupts ****************************/ 00080 //__disable_irq(); // Disable Interrupts 00081 //__enable_irq(); // Enable Interrupts 00082 /************************* read the light sensor *****************************/ 00083 void lightsensor() { 00084 AnalogIn light(p20); /* fetch the light intensity */ 00085 lightlevel=light.read(); /* fetch the light intensity */ 00086 //printf("\n\rlight level= (%f)",light.read()); 00087 } 00088 00089 /**************************** remote control IRQ ****************************/ 00090 void remotecontrol(void) { 00091 int q=0; 00092 int z=0; 00093 myled=!myled; /* just to let us know we are looping through here */ 00094 00095 do { 00096 remcon[z]=getc(remote); 00097 //printf("%c\n\r",remcon[z]); 00098 z++; 00099 } while (z<6); 00100 flag=atoi(remcon); 00101 //flag=remaction; //flag is either a valid command, or its a zero which means no valid command 00102 //printf("%d\n\r", flag); 00103 //printf("%d\n\r", remaction); 00104 /* here we flush everything to make sure that any garbage entries do not remain */ 00105 /* because what we got in from the serial link was not a valid string */ 00106 for (q=0;q<6;q++) { //flush the uart buffer which is 16 bytes deep (was originally set to 8) 00107 remcon[q]=(' '); //* clean it up for the next cycle */ 00108 } 00109 remcontoken=1; 00110 myled=!myled; 00111 00112 } 00113 /*********** Power ON/OFF IRQ **********/ 00114 void power1() { 00115 wait_ms(10); //was 10ms 00116 flag=9261; 00117 remcontoken=0; 00118 } 00119 /*************** Mute IRQ **************/ 00120 void mute1() { 00121 wait_ms(10); //was 10ms 00122 flag=9241; 00123 remcontoken=0; 00124 } 00125 /************ Input Select IRQ ********/ 00126 void inputsel1() { 00127 wait_ms(10); 00128 flag=9231; 00129 remcontoken=0; 00130 } 00131 /*************** Volume IRQ ***********/ 00132 void volume1() { 00133 00134 wait_ms(5); /* wait for contact bounce to subside */ 00135 PortIn encoder(Port2, 48); /* extract data on mbed pins 21 and 22 - bit positions 8 and 16 on p2 */ 00136 switch (encoder) { 00137 case 32: 00138 break; 00139 case 48: 00140 break; 00141 00142 case 0: { 00143 volume--; 00144 flag=9211; 00145 } 00146 break; /* rotary encoder was turned clockwise */ 00147 case 16: { 00148 volume++; 00149 flag=9221; 00150 } 00151 break; 00152 } 00153 remcontoken=0; 00154 } 00155 /******************* volume control write routine **********************/ 00156 /* this routine writes the volume control data out to the PGA2320 */ 00157 void volumecontrol(void) { 00158 int lrvol =0; /* lrvol (i.e. left and right volume) is the concatenated left & right volume setting */ 00159 int gain; 00160 int vol_shift_bit=0; 00161 int volshift=0; 00162 int voltemp=0; 00163 int SCOUNT=1; 00164 int k = 32768; /* k is now located at bit position 15 */ 00165 //if the volume up/down comes in through the remote control, it comes directly here from the R/C 00166 //IRQ handler. If it comes in via the rotarty encoder, it skips this part 00167 if (remcontoken==1) { /* command came in through the IRC */ 00168 if (flag==9221) { 00169 volume=volume+4; /* volume up and down is a bit quicker via the IRC */ 00170 } 00171 if (flag==9211) { 00172 volume=volume-4; 00173 } 00174 } 00175 /******* check here that it is within range 0 to +255 ********/ 00176 // entry point is HERE if coming in via rotary encoder 00177 if (volume>=222) 00178 volume=222; 00179 if (volume <=1) // check this - can it not be 0? 00180 volume=0; 00181 volume_slider(volume); 00182 gain= 31.5-(0.5*(255-volume)); 00183 if (((gain >-10)&&(gain<10))==TRUE) { 00184 LCDSetRect(265,379,460,475,1,BLACK); //clear the volume area 00185 snprintf( temp_string, STR_LENGTH_1, " "); //flush the print area 00186 snprintf( temp_string, STR_LENGTH_1, "%+ddB",gain); 00187 } 00188 char temp_string[ STR_LENGTH ]; 00189 snprintf( temp_string, STR_LENGTH, " "); //flush the print area 00190 snprintf( temp_string, STR_LENGTH, "%+ddB",gain); 00191 FontDrawString( temp_string, 185, 380, WHITE, BLACK, &Calibri72 ); 00192 00193 /************************ Write the data out to the PGA2320 ************************/ 00194 /* for the PGA2320, data is clocked out MSB first, starting with the Right channel */ 00195 00196 volshift=volume; 00197 voltemp=volume; /* save volume and leave it untouched */ 00198 lrvol = (voltemp<<8); /* volume value now occupies bits 8-16 with bits 0-7 filled with 0's */ 00199 lrvol = (lrvol|volshift); /* now have a copy of volume in botton 8 LSB's - so 16 bits of data in total*/ 00200 pga2320=LOW; /* make sure the PGA2320 is de-selected */ 00201 RD=LOW; /* ASTROBE - we do NOT use STROBE when writing the volume to the PGA2320 */ 00202 WR=LOW; /* MDATA in low state*/ 00203 RS=HIGH; /* ACLK - it is now LOW on the isolated side*/ 00204 SBUSON=HIGH; /* turn the SBUS on */ 00205 wait_us(50); //was 50 00206 pga2320=HIGH; /* chip select the PGA2320-so it goes LOW on the analog board */ 00207 do { 00208 vol_shift_bit = (lrvol&k); /* ADATA = the MSB (k=1) */ 00209 WR=!vol_shift_bit; /* put the 1st bit to be written on the WR pin AFTER INVERTING IT */ 00210 wait_us(10); 00211 RS=LOW; /* clock it out */ 00212 wait_us(10); 00213 RS=HIGH; 00214 SCOUNT=SCOUNT+1; /* increment the bit counter */ 00215 k=(k>>1); /* shift bit mask up one position towards the LSB */ 00216 } while (SCOUNT<16); /* send all 16 bits for L & R channel */ 00217 /* note that it is 15 bit positions and NOT 16! */ 00218 wait_us(10);//was 10 00219 pga2320=LOW; /* deselect PGA2320 */ 00220 wait_us(10); //was 10 00221 SBUSON=LOW; 00222 flag=0; /* clear the flag since the command is now completed */ 00223 remcontoken=0; /* we have executed the request, now clear the token */ 00224 wait_us(10); //was 20 00225 00226 } 00227 /*************** Serial bus routine for control relays and digital I/O ***************/ 00228 /* this routine takes the 8 bit relay data and the 8 bit control data and joins them */ 00229 /* and writes 16 bits out on the serial bus */ 00230 /* it is called by the relay function or the control function */ 00231 00232 void serialout(void) { 00233 unsigned int serialdata=0;/* the 16 bits of serial data to go out to the analog board - flush it so its clean */ 00234 unsigned int shift_out_bit=0; 00235 long int stor_relay=0; 00236 int m=1; 00237 int SCOUNT=0; 00238 00239 __disable_irq(); /* disable Interrupts - no interference while we send the data out */ 00240 00241 stor_relay=(255-inputrelay); /* get the complement */ 00242 serialdata = (control | stor_relay); 00243 00244 RD=LOW; /* ASTROBE - it must be LOW on the analog board intitially */ 00245 WR=HIGH; /* MDATA */ 00246 RS=HIGH; /* ACLK - so the clock line on the analog board is now LOW*/ 00247 SBUSON=HIGH; /* turn the SBUS on */ 00248 wait_us(100); //was 100 00249 do { 00250 shift_out_bit = (serialdata & m); /* ADATA = the LSB (k=1) */ 00251 if (shift_out_bit!=0) { /* if it evaluates as TRUE, WR=HIGH */ 00252 WR=1; 00253 } else { /* it must have evaluated as FALSE */ 00254 WR=0; 00255 } 00256 wait_us(100); //was 100 00257 RS=LOW; /* clock goes high on main board - data latches */ 00258 wait_us(100); //was 100 00259 RS=HIGH; /* clock goes low */ 00260 SCOUNT++; /* increment the bit counter */ 00261 m=(m<<1); /* shift bit mask up one position towards the MSB */ 00262 } while (SCOUNT<16); 00263 wait_us(100); //was 100 00264 RD=HIGH; /* Strobe the data into the A6821*/ 00265 wait_us(100); //was 100 00266 RD=LOW; /* Strobe now goes LOW again on the main board */ 00267 wait_us(100); //was 100 00268 SBUSON=LOW; /* remember to enable the outputs after intial set-up */ 00269 wait_us(100); //was 100 00270 __enable_irq(); // Enable Interrupts 00271 } 00272 /******************************* Play ****************************/ 00273 void play(void) { 00274 //myled=!myled; 00275 flag=0; 00276 remcontoken=0; 00277 } 00278 /******************************* Input Selector Encoder Routine ****************************/ 00279 /* this function controls which relays are energized on the main analog board */ 00280 /* It calls the serialout function to send the data */ 00281 00282 void inputselect(void) { 00283 00284 int source=0; /* temporary storage */ 00285 wait_ms(10); /*wait for contact bounce to subside */ 00286 // __disable_irq(); // Disable Interrupts 00287 00288 if (remcontoken==0) { /* so it must have come in from the rotary encoder */ 00289 PortIn select(Port2, 6); /* fetch data on mbed pins 24 and 25 - bit positions 2 and 4 on p2 */ 00290 switch (select) { 00291 case 0: 00292 relay++; 00293 break; /* rotary encoder was turned clockwise */ 00294 case 2: 00295 relay--; 00296 break; /* increment the selection */ 00297 00298 case 4: {} break; /* fall through values - ignore */ 00299 case 6: {} break; 00300 } 00301 } else { 00302 relay++; /* and here because it came in from the remote */ 00303 } /* because it must have equaled 1 to have got here */ 00304 /* because you can only go round select in one direction via the remote */ 00305 00306 if (relay>=6) /* here we make sure the select knob rotates from 1-6 to again */ 00307 relay=1; 00308 if (relay<=0) 00309 relay=5; 00310 /* set the correct value in the serial bit position */ 00311 clear_input_select(); 00312 switch (relay) { 00313 case 1: 00314 source=32;//~125;//~125;//~(2&127); 00315 AUX2(1); 00316 //printf("\n\rAux2"); 00317 break; /* this is Aux2*/ 00318 case 2: 00319 source=16;//~123;//~(4&127); 00320 AUX1(1); 00321 //printf("\n\raux1"); 00322 break; /*aux1 */ 00323 case 3: 00324 source=8;//~127;~(8&127); 00325 Recorder_d(1); 00326 //printf("\n\recorder"); 00327 00328 break; /*recorder */ 00329 case 4: 00330 source=4;//~111;//~(16&127); 00331 //printf("\n\rCD"); 00332 // 00333 CD_d(1); 00334 break; /*CD*/ 00335 case 5: 00336 source=2;;//~95;//~(32&127); 00337 //printf("\n\rphono"); 00338 phono_d(1); 00339 break; /*phono*/ 00340 } 00341 00342 inputrelay=(hpmutebit|mutebit|recloop1bit);/* save the non input select data */ 00343 00344 inputrelay=(inputrelay&193); /*strip out the old input select, leaving HPMUTE, recloop1bit and mutebit intact */ 00345 00346 inputrelay=(inputrelay|source); /* add in the new input selection back in*/ 00347 00348 flag=0; 00349 remcontoken=0; 00350 00351 serialout(); /* send it out */ 00352 // __enable_irq(); // Enable Interrupts 00353 } 00354 /*****************************************record loop ***********************************************/ 00355 void recloop(void) { 00356 00357 if (recloop1bit==0) {//so it must have been OFF so we need to turn it on 00358 recloop1bit=64; 00359 record(1); 00360 inputrelay=(inputrelay|64); 00361 } 00362 else if (recloop1bit!=0) { // it was ON so turn it OFF 00363 recloop1bit=0; 00364 record(0); 00365 inputrelay=inputrelay & (~64); 00366 } 00367 flag=0; 00368 //remcontoken=0; 00369 serialout(); 00370 } 00371 /**************************** output mute via front panel push button********************************/ 00372 void mute_output(void) { /* this is the interrupt handler routine */ 00373 00374 unsigned int timecountrec=0; 00375 //__disable_irq(); // Disable Interrupts 00376 wait_ms(10); 00377 do { 00378 timecountrec++; 00379 wait_us(10); 00380 if (timecountrec>110000) 00381 timecountrec=110000; //just make sure if the buttin is depressed for too long, it 00382 //record(1); // it does not wrap around bacj to 0 again 00383 } while (IPSELPB==0); 00384 //printf("timecountrec=%d\n\r",timecountrec); 00385 if (timecountrec>100000) { 00386 recloop(); 00387 goto SKIP; 00388 } 00389 if (mutebit==0) { /* it must have been off */ 00390 mutebit=128; //was 128 /* so turn it ON - this is a FLAG */ 00391 inputrelay=(inputrelay|128); //was 128 00392 mute(0); 00393 } 00394 else if (mutebit==128) { /* it currently ON */ 00395 mutebit=0; /* so turn the output OFF - this is a FLAG */ 00396 inputrelay=(inputrelay&127); //so bit 128 is set to 0 00397 mute(1); 00398 } 00399 SKIP: 00400 flag=0; 00401 remcontoken=0; 00402 //__enable_irq(); // Enable Interrupts 00403 serialout(); 00404 00405 } 00406 /**********************************initialize *****************************************/ 00407 /* this routine sets up the pre-amp at initial power-up. all relays on the main board */ 00408 /* are de-energized, volume is set to 0, display off, system in standby */ 00409 00410 void initialize(void) { 00411 00412 int SCOUNT=0; 00413 int k=1; /*this is the bit place holder that gets shifted through the data to be sent */ 00414 int flushit=0; /* flushit explicitly declared since we may want a setting other than all OFF */ 00415 int shift_flush =0; 00416 00417 RD=LOW; /* ASTROBE */ 00418 WR=LOW; /* MDATA */ 00419 RS=LOW; /* ACLK */ 00420 SBUSON=HIGH; /* turn the SBUS on */ 00421 do { 00422 shift_flush=(flushit&k); /* ADATA = the LSB (k=1) */ 00423 WR=shift_flush; 00424 wait_ms(1); 00425 RS=HIGH; /* clock it out */ 00426 wait_ms(1); 00427 RS=LOW; 00428 SCOUNT=SCOUNT+1; /* increment the bit counter */ 00429 k=(k<<1); /* shift bit mask up one position towards the MSB */ 00430 } while (SCOUNT<8); /* counting starts from 0! */ 00431 wait_ms(1); 00432 RD=HIGH; /* Strobe the data into the A6821*/ 00433 wait_ms(1); 00434 RD=LOW; /* Strobe now goes HIGH again on the main board */ 00435 wait_ms(1); 00436 SBUSON=LOW; /* remember to enable the outputs after intial set-up */ 00437 power=0; 00438 wait_ms(10); //was 100 00439 } 00440 /******************** ON-OFF Push button input *******************************************/ 00441 void power_on_off(void) { 00442 // 00443 00444 //int inputstate = 0; /* where we temporarily store the input relay status */ 00445 //int b=5; 00446 //__disable_irq(); // Disable Interrupts 00447 //__enable_irq(); // Enable Interrupts 00448 wait_ms(10); /* debounce time NOTE IF ITS MUCH LONGER THAN 10mS THERE ARE RE-ENTRY PROBLEMS*/ 00449 00450 if (power == 0) { /* it must have been off so turn it ON */ 00451 //__disable_irq(); // Disable Interrupts 00452 00453 //Write_Command(DISON); 00454 //clear_to_color(BLACK); //clear the screen 00455 /* clean everything up first */ 00456 inputrelay = 0; /* all input relays are DESELECTED */ 00457 mute(1); 00458 00459 volume = 0; /* set the volume to 0 to make sure there are no blasts from the headphone or output */ 00460 volumecontrol(); 00461 control = 0; 00462 wait_ms(100); /* initial wait period after power on - lets relays and electronics settle */ 00463 serialout(); 00464 00465 NAOE = HIGH; /* enable outputs of A6281's */ 00466 wait_ms(100); 00467 inputrelay = 4;//32; /* select CD input always on power up */ 00468 CD_d(1); 00469 control = 33280; /* power to main board on and LCD brightness set to 50% */ 00470 serialout(); 00471 00472 wait(2); 00473 inputrelay = 5;// 161; /* unmute the headphone amp */ 00474 control = 33280; /* stays the same power to main board on and LCD brightness set to 50% */ 00475 serialout(); 00476 00477 wait(2); /* let the power amp settle */ 00478 control=35328; /* turn power amp on */ 00479 pwramp(1); 00480 inputrelay = 133; /* unmute the pre-amp output */ 00481 mute(0); 00482 serialout(); 00483 00484 mutebit = 128; /* set to 1 to turn it ON - THIS IS A FLAG!! */ 00485 hpmutebit = 1; /* set to 127 to turn it ON - THIS IS THE FLAG!!*/ 00486 //serialout(); 00487 power = 64; /* this is the power ON/OFF FLAG */ 00488 volume=95; 00489 volumecontrol(); 00490 00491 /* re-enable the mute, volumecontrol and input selection interrupts */ 00492 wait_ms(1); 00493 00494 mutesw.fall(&mute1); 00495 volumein.fall(&volume1); 00496 inputsel.fall(&inputsel1); 00497 // __enable_irq(); // Enable Interrupts 00498 } 00499 00500 else if (power == 64) { /* it currently ON, so turn it OFF */ 00501 /* disable the mute, columecontrol and input selection interrupts - leave power ON/OFF enabled though */ 00502 // __disable_irq(); // Disable Interrupts 00503 volume = 0; 00504 volumecontrol(); 00505 mutesw.fall(NULL); 00506 volumein.fall(NULL); 00507 inputsel.fall(NULL); 00508 control= (control & 62332); /*turn power amp off */ 00509 pwramp(0); 00510 serialout(); 00511 wait(2); /* wait for the power-amp to power down and spkr relay to open */ 00512 inputrelay = (inputrelay & 126); /* mute the pre-amp output */ 00513 serialout(); /* note we did not change anything on the control side */ 00514 wait(1); 00515 control=(control & 768); /* turn the display off and set the zero loop gain off */ 00516 inputrelay = (inputrelay & 127); /* mute headphone output */ 00517 serialout(); 00518 wait(1); 00519 /*here we flush the A6821 registers */ 00520 control = 0; /* turn everthing off */ 00521 inputrelay = 0; 00522 serialout(); 00523 wait(1); 00524 NAOE=LOW; /* disable the A6281's */ 00525 00526 mutebit = 0; /* set to 1 to turn it ON - this is a FLAG */ 00527 hpmutebit = 128; /* set to 127 to turn it ON - this is a FLAG */ 00528 power = 0; /* this is the power FLAG */ 00529 //Write_Command(DISOFF); 00530 //clear_to_color(BLACK); //clear the screen 00531 00532 //__enable_irq(); // Enable Interrupts again 00533 } 00534 flag = 0; 00535 remcontoken = 0; 00536 } 00537 /******************** backlight controller *****************************************/ 00538 void backlight (void) { 00539 00540 float loglight; 00541 int lightadjust; 00542 00543 lightsensor(); 00544 //loglight = (lightlevel * lightlevel) * 14.0 + 1.0; 00545 loglight = (lightlevel * 14)+1; 00546 lightadjust = ((int)loglight) << 12; 00547 control=(control & stripbacklight)|lightadjust; 00548 serialout(); 00549 //printf("%d\n\r",control); 00550 } 00551 /******************** Test Mode Pushbutton input *******************************************/ 00552 /* in this mode, both volume and select pushbuttons must be depressed for 5 seconds */ 00553 /* the pre-amp then enters the test mode where all the relays are cycled continuosly */ 00554 /* and the volume is ramped up and down. To exit, depress any push button. */ 00555 00556 /**********************************main program*****************************************/ 00557 int main () { 00558 int l=0; 00559 //int loopcnt=0; 00560 __disable_irq(); // Disable Interrupts 00561 NAOE=LOW; // make sure the A6821's are disabled 00562 Init_SSD1963(); // set up he graphics controller 00563 Write_Command(DISOFF); // make sure the display is off while we set it up 00564 clear_to_color(BLACK); //clear the screen 00565 wait_ms(5); 00566 initialize(); // call the SBUS routine to clean things up 00567 powersw.fall(&power1); 00568 Serial remote(NC, p27); 00569 remote.baud(1200); 00570 remote.format(8, Serial::None, 1); 00571 remote.attach(&remotecontrol); /* set up serial port via USB connector */ 00572 __enable_irq(); // Enable Interrupts 00573 wait_us(10); 00574 00575 /**************************************************************************************/ 00576 // graphics set up 00577 // sett up graphics to write the data 00578 FontDrawInit(); 00579 FontDraw_SetInterCharSpace( 0 ); 00580 FontDraw_SetForegroundColor(WHITE); 00581 FontDraw_SetBackgroundColor(BLACK); 00582 FontDraw_SetFont(Calibri28); 00583 //big_button(); 00584 Control_buttons(); 00585 input_buttons(); 00586 slider_bar(); 00587 Write_Command(DISON); 00588 00589 /************************ this is the main operating loop ************************/ 00590 00591 LOOP: 00592 //if ((flag>=9000)&&(flag<=9999)){ 00593 //printf("%d\n\r",flag); 00594 //__disable_irq(); // Disable Interrupts 00595 //__enable_irq(); // Enable Interrupts 00596 if (flag!=0) { //so assume it lies between 9000 and 9999 00597 switch (flag) { 00598 00599 case 9211: 00600 volumecontrol(); 00601 break; /* volume UP */ 00602 case 9221: 00603 volumecontrol(); 00604 break; /* volume DOWN */ 00605 case 9231: 00606 inputselect(); 00607 break; /* Input Select */ 00608 case 9241: 00609 mute_output(); 00610 break; /* Mute */ 00611 case 9251: 00612 play(); 00613 break; /* Play */ 00614 case 9261: 00615 power_on_off(); 00616 break; /* power ON/OFF */ 00617 //case 9200: 00618 //recloop(); 00619 } 00620 } 00621 00622 myled=!myled; 00623 __disable_irq(); // Disable Interrupts - this forces us to wait here for 10mS 00624 flag=0; /* flush the flag since we finished the task */ 00625 wait_ms(10); // 00626 __enable_irq(); // Enable Interrupts 00627 backlight(); 00628 halt(); /* shut processor down and wait for interrupt */ 00629 myled=!myled; 00630 goto LOOP; 00631 }
Generated on Tue Jul 12 2022 23:07:04 by
1.7.2