Car stereo control using TDA7419 for input select, audio control. Adafruit 96x64 monochrome 0.96" display to show the audio selections four buttons to control selections. Next steps: take input from the car steering wheel controls!

Dependencies:   Adafruit_GFX PinDetect_KL25Z PreampTDA7419 mbed

Files at this revision

API Documentation at this revision

Comitter:
danielashercohen
Date:
Sun Oct 26 22:53:27 2014 +0000
Parent:
3:8d3cc3488cd8
Child:
5:28533591b528
Commit message:
Basic audio functions (balance, fade, tone, mix, input select) all working. Display working.

Changed in this revision

PreampTDA7419.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/PreampTDA7419.lib	Mon Oct 20 05:55:05 2014 +0000
+++ b/PreampTDA7419.lib	Sun Oct 26 22:53:27 2014 +0000
@@ -1,1 +1,1 @@
-PreampTDA7419#69c37f1ab7df
+http://developer.mbed.org/users/danielashercohen/code/PreampTDA7419/#34a58356394c
--- a/main.cpp	Mon Oct 20 05:55:05 2014 +0000
+++ b/main.cpp	Sun Oct 26 22:53:27 2014 +0000
@@ -25,6 +25,9 @@
 Adafruit_SSD1306 display (gSpi, PTD0, PTD5, PTA13);  // SPI obect, DC, RST, CS
 PreampTDA7419    Preamp  (PTE0, PTE1);
 
+/////////////////////////////////////////////
+// Helper functions for the serial display // 
+/////////////////////////////////////////////
 void testfillrect(void) {
   uint8_t color = 1;
   for (int16_t i=0; i<display.height()/2; i+=3) {
@@ -48,9 +51,16 @@
   display.display();    
 }
 
-/////////////////////////////////////////////
-// Helper functions for the serial display // 
-/////////////////////////////////////////////
+void displayWrite(char firstLine[], char secondLine[])
+{
+  display.clearDisplay();
+  display.setCursor(0,0);
+  display.setTextSize(2);
+  display.printf("%s\r\n", firstLine);
+  display.printf("%s\r\n", secondLine);  
+  display.display();    
+}
+
 void processButtonPress (int button) {
 
   if (button == 0) {
@@ -99,131 +109,106 @@
     }
     displayWrite("Treble", Preamp.readTreble());
   break;
-  case (3):  // manage the middle value
-    displayWrite("Middle", 42);
-  break;
-  }
-}
-/*
-  case (3):  // manage the middle value
+  case (3):  // manage the treble value
     if (button == 2) {
-      if (middle > -5) {
-        middle--;
-      }
+      Preamp.decreaseMiddle();
     }
     if (button == 3) {
-      if (middle < 5) {
-        middle++;
-      }
+      Preamp.increaseMiddle();
     }
-    displayWrite("Middle",  middle );
-    break;
-  case (4):  // manage the bass value
+    displayWrite("Middle", Preamp.readMiddle());
+  break;
+  case (4):  // manage the treble value
     if (button == 2) {
-      if (bass > -5) {
-        bass--;
-      }
+      Preamp.decreaseBass();
     }
     if (button == 3) {
-      if (bass < 5) {
-        bass++;
-      }
+      Preamp.increaseBass();
     }
-    displayWrite("Bass",  bass );
+    displayWrite("Bass", Preamp.readBass());
   break;
 
   // Manage the attenuators
   case (5):  // manage the atten_lf value
     if (button == 2) {
-      if (atten_lf > 0) {
-        atten_lf--;
-      }
+        displayWrite("LF",   Preamp.decreaseSpeaker(1) );
+    } 
+    else if (button == 3) {
+        displayWrite("LF",   Preamp.increaseSpeaker(1) );
+    } 
+    else {
+        displayWrite("LF",   Preamp.readSpeaker(1) );
     }
-    if (button == 3) {
-      if (atten_lf < 11) {
-        atten_lf++;
-      }
-    }
-    displayWrite("LF",  atten_lf );
   break;
   case (6):  // manage the atten_rf value
     if (button == 2) {
-      if (atten_rf > 0) {
-        atten_rf--;
-      }
+        displayWrite("RF",   Preamp.decreaseSpeaker(2) );
+    } 
+    else if (button == 3) {
+        displayWrite("RF",   Preamp.increaseSpeaker(2) );
     }
-    if (button == 3) {
-      if (atten_rf < 11) {
-        atten_rf++;
-      }
-    }
-    displayWrite("RF",  atten_rf );
+    else {
+        displayWrite("RF",   Preamp.readSpeaker(2) );
+    }   
   break;
   case (7):  // manage the atten_lr value
     if (button == 2) {
-      if (atten_lr > 0) {
-        atten_lr--;
-      }
+        displayWrite("LR",   Preamp.decreaseSpeaker(3) );
     }
-    if (button == 3) {
-      if (atten_lr < 11) {
-        atten_lr++;
-      }
-    }
-    displayWrite("LR",  atten_lr );
+    else if (button == 3) {
+        displayWrite("LR",   Preamp.increaseSpeaker(3) );
+    } 
+    else {
+        displayWrite("LR",   Preamp.readSpeaker(3) );
+    }           
   break;
   case (8):  // manage the atten_rr value
     if (button == 2) {
-      if (atten_rr > 0) {
-        atten_rr--;
-      }
+        displayWrite("RR",   Preamp.decreaseSpeaker(4) );
+    } 
+    else if (button == 3) {
+        displayWrite("RR",   Preamp.increaseSpeaker(4) );
     }
-    if (button == 3) {
-      if (atten_rr < 11) {
-        atten_rr++;
-      }
-    }
-    displayWrite("RR",  atten_rr );
+    else {
+        displayWrite("RR",   Preamp.readSpeaker(4) );
+    }     
   break;
-  case (9):  // manage the atten_mix value
+  case (9):  // manage the atten_sub value
     if (button == 2) {
-      if (atten_mix > 0) {
-        atten_mix--;
-      }
+        displayWrite("SUB",  Preamp.decreaseSpeaker(5) );
     }
-    if (button == 3) {
-      if (atten_mix < 11) {
-        atten_mix++;
-      }
+    else if (button == 3) {
+        displayWrite("SUB",  Preamp.increaseSpeaker(5) );
     }
-    displayWrite("Mix",  atten_mix );
+    else {
+        displayWrite("SUB",   Preamp.readSpeaker(5) );
+    }      
   break;
-  case (10):  // manage the atten_sub value
+  case (10):  // manage the atten_mix value
     if (button == 2) {
-      if (atten_sub > 0) {
-        atten_sub--;
-      }
+        displayWrite("Mix Level",  Preamp.decreaseSpeaker(6) );
     }
-    if (button == 3) {
-      if (atten_sub < 11) {
-        atten_sub++;
-      }
+    else if (button == 3) {
+        displayWrite("Mix Level",  Preamp.increaseSpeaker(6) );
     }
-    displayWrite("SUB",  atten_sub );
+    else {
+        displayWrite("Mix Level",   Preamp.readSpeaker(6) );
+    }         
   break;
   case (11):  // manage the atten_sub value
-    if (button == 2) {
-      mix = 0;
+    if ( (button == 2) || (button == 3) ) {
+      Preamp.toggleMix();
+    } 
+    if (Preamp.readMix()) {
+      displayWrite("Mix",  "Enabled");
     }
-    if (button == 3) {
-      mix = 1;
+    else {
+      displayWrite("Mix", "Disabled");
     }
-    displayWrite("Mix",  mix );
-  break;
-
+  break;  
+  
   }
 }
-*/
 
 void UpPressed( void )
 {
@@ -260,7 +245,7 @@
     display.clearDisplay();
     // draw multiple rectangles
     testfillrect();
-    wait(0.5);
+    wait(0.3);
     display.display();
     display.clearDisplay();
     display.display();