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
Revision 1:f5b8687f67b8, committed 2014-10-12
- Comitter:
- danielashercohen
- Date:
- Sun Oct 12 04:48:34 2014 +0000
- Parent:
- 0:36eee45709c8
- Child:
- 2:2b0cf4d80668
- Commit message:
- Buttons and Adafruit 128x64 OLED display working
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_GFX.lib Sun Oct 12 04:48:34 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/danielashercohen/code/Adafruit_GFX/#232e3d1d47bc
--- a/SSD1306.lib Fri Oct 10 04:58:19 2014 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/masato/code/SSD1306/#ec5add86f335
--- a/main.cpp Fri Oct 10 04:58:19 2014 +0000
+++ b/main.cpp Sun Oct 12 04:48:34 2014 +0000
@@ -1,26 +1,46 @@
#include "mbed.h"
#include "PinDetect.h"
-#include "ssd1306.h"
-#include "standard_font.h"
-#include "bold_font.h"
+#include "Adafruit_SSD1306.h"
PinDetect PinUp ( PTA1 );
PinDetect PinLeft ( PTD4 );
PinDetect PinRight ( PTA2 );
PinDetect PinDown ( PTA12 );
-DigitalOut led1( LED1 );
-DigitalOut led2( LED2 );
-DigitalOut led3( LED3 );
+class SPI2 : public SPI
+{
+public:
+ SPI2(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk)
+ {
+ format(8,3);
+ frequency(2000000);
+ };
+};
-SSD1306 display (PTA13 /* cs */, PTD5 /* reset */, PTD0 /* dc */, PTD1 /* clock */, PTD2 /* data */); // KL25Z
+SPI2 gSpi(PTD2,NC,PTD1);
+Adafruit_SSD1306 display (gSpi, PTD0, PTD5, PTA13); // SPI obect, DC, RST, CS
+
+void testfillrect(void) {
+ uint8_t color = 1;
+ for (int16_t i=0; i<display.height()/2; i+=3) {
+ // alternate colors
+ wait(0.05);
+ display.fillRect(i, i, display.width()-i*2, display.height()-i*2, color%2);
+ display.display();
+ color++;
+ }
+}
void displayWrite(char firstLine[], int value)
{
- display.clear();
- display.printf("%s\r\n", firstLine);
- display.printf("%d", value);
- display.update();
+ display.clearDisplay();
+ display.setCursor(0,0);
+ display.setTextSize(2);
+ display.printf("%s\r\n", firstLine);
+ display.setCursor(0,30);
+ display.setTextSize(5);
+ display.printf(" %d\r\n", value);
+ display.display();
}
///////////////////////////
@@ -399,49 +419,28 @@
updateReg(); // update the TDA7419 registers to reflect any values changed above
}
-
-
-
void UpPressed( void )
{
- led1 = 1;
- led2 = 0;
- led3 = 0;
- displayWrite("Up", 1);
processButtonPress(0);
}
void LeftPressed( void )
{
- led1 = 0;
- led2 = 1;
- led3 = 0;
- displayWrite("Left", 1);
processButtonPress(2);
-
}
void RightPressed( void )
{
- led1 = 0;
- led2 = 0;
- led3 = 1;
- displayWrite("Right", 1);
processButtonPress(3);
}
void DownPressed( void )
{
- led1 = 1;
- led2 = 0;
- led3 = 1;
- displayWrite("Down", 1);
processButtonPress(1);
}
int main()
{
-
PinUp .mode( PullUp );
PinLeft .mode( PullUp );
PinRight.mode( PullUp );
@@ -452,14 +451,14 @@
PinRight.attach_asserted( &RightPressed );
PinDown .attach_asserted( &DownPressed );
-
- display.initialise();
- display.clear();
- display.set_contrast(255); // max contrast
- display.update();
- display.set_font(standard_font, 6);
- display.printf("mbed audio!\r\n");
- display.update();
+ display.clearDisplay();
+ // draw multiple rectangles
+ testfillrect();
+ wait(0.5);
+ display.display();
+ display.clearDisplay();
+ display.display();
+
// Sampling does not begin until you set a frequency.
// The default is 20ms. If you want a different frequency
@@ -471,12 +470,12 @@
PinRight.setSampleFrequency(); // Defaults to 20ms.
PinDown .setSampleFrequency(); // Defaults to 20ms.
+ processButtonPress(0);
+
while (1) {
- wait(5);
+ wait(1);
}
}
-
-
// EOF
\ No newline at end of file