-
Radio Build Photolog
05/19/2015 at 17:50 • 0 commentsBuild PhotoLog
Speakers and amp that I intended to re-purpose
Parts
Testing serial control of the BT module RN-52
Coding the screen interface and monitoring serial comms.
Taking volume measurement of old speaker enclosure to get an accurate replication.
Speaker enclosure spec'd out.
Fitting printed parts.Right here is where I fried the first amp.
Ordered a replacement class D from adafruit. iz really loud.final components in the cabinetPrinted some translucent buttons to put the LED indicators from the arduino and BT module. -
El Radio Source Code
02/07/2015 at 21:27 • 0 commentsCode dump:
/* El Radio Written by Jeremy Lambert Copyright 2015 All Rights Reserved This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. */ #include "TFTLCD.h" #include "TouchScreen.h" #if not defined USE_ADAFRUIT_SHIELD_PINOUT #error "For use with the shield, make sure to #define USE_ADAFRUIT_SHIELD_PINOUT in the TFTLCD.h library file" #endif // These are the pins for the shield! #define YP A1 // must be an analog pin, use "An" notation! #define XM A2 // must be an analog pin, use "An" notation! #define YM 7 // can be a digital pin #define XP 6 // can be a digital pin #define TS_MINX 150 #define TS_MINY 120 #define TS_MAXX 920 #define TS_MAXY 940 #define MINPRESSURE 10 #define MAXPRESSURE 1000 TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300); #define LCD_CS A3 #define LCD_CD A2 #define LCD_WR A1 #define LCD_RD A0 // Color definitions #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, 0); #define BOXSIZE 80 String inputString = ""; // a string to hold incoming data boolean stringComplete = false; // whether the string is complete void setup(void) { //Serial.println("TOUCHSCREEN::"); tft.reset(); uint16_t identifier = tft.readRegister(0x0); if (identifier == 0x9325) { //Serial.println("Found ILI9325"); } else if (identifier == 0x9328) { //Serial.println("Found ILI9328"); } else { //Serial.print("Unknown driver chip "); //Serial.println(identifier, HEX); while (1); } tft.initDisplay(); tft.fillScreen(BLACK); DrawButtons(); delay(5000); //let the BT module boot inputString.reserve(12); Serial.begin(115200); Serial.println("CMD"); //enter command mode. delay(300); Serial.println("B"); //try to reconnect to the last device pinMode(13, OUTPUT); } void serialEvent() { while (Serial.available()) { // get the new byte: char inChar = (char)Serial.read(); // add it to the inputString: inputString += inChar; // if the incoming character is a newline, set a flag // so the main loop can do something about it: if (inChar == '\n') { if (!inputString.startsWith("AOK")) { stringComplete = true; char output[inputString.length()]; //Serial.println(inputString); inputString.toCharArray(output, inputString.length()); tft.drawString(0,0,output, WHITE, 2); //TODO: need to put this somewhere else on the screen. } } } } void loop() { digitalWrite(13, HIGH); Point p = ts.getPoint(); digitalWrite(13, LOW); // if you're sharing pins, you'll need to fix the directions of the touchscreen pins! //pinMode(XP, OUTPUT); pinMode(XM, OUTPUT); pinMode(YP, OUTPUT); //pinMode(YM, OUTPUT); // we have some minimum pressure we consider 'valid' // pressure of 0 means no pressing! if (p.z > MINPRESSURE && p.z < MAXPRESSURE) { // turn from 0->1023 to tft.width p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0); p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0); /* Serial.print("("); Serial.print(p.x); Serial.print(", "); Serial.print(p.y); Serial.println(")"); */ if (p.x < BOXSIZE) { if (p.y > 240) { //rewind Serial.println("AT-"); blinkButton(0); return; } if (p.y > 80) { //volume - Serial.println("AV-"); blinkButton(4); return; } if (p.y > 0) { //volume + Serial.println("AV+"); blinkButton(3); return; } } if (p.x < BOXSIZE*2) { if (p.y > 240) { //play/pause Serial.println("AP"); blinkButton(1); return; } } if (p.x < BOXSIZE*3) { if (p.y > 240) { //ff Serial.println("AT+"); blinkButton(2); return; } //spare //spare if (p.y > 0) { //if you push the bluetooth button, it goes to discoverable, since it's default //is attempt reconnect. Serial.println("@,1"); blinkButton(5); return; } } } } void drawButton(int buttonID) { switch(buttonID) { case 0: //rewind tft.fillRect(0, 240, BOXSIZE, BOXSIZE, BLACK); tft.drawRect(0, 240, BOXSIZE, BOXSIZE, WHITE); tft.drawString(20, 270, "<<", WHITE, 3); break; case 1: //playpause tft.fillRect(BOXSIZE, 240, BOXSIZE, BOXSIZE, BLACK); tft.drawRect(BOXSIZE, 240, BOXSIZE, BOXSIZE, WHITE); tft.drawString(95, 270, "||>", WHITE, 3); break; case 2: //ffwd tft.fillRect(BOXSIZE*2, 240, BOXSIZE, BOXSIZE, BLACK); tft.drawRect(BOXSIZE*2, 240, BOXSIZE, BOXSIZE, WHITE); tft.drawString(180, 270, ">>", WHITE, 3); break; case 3: //volumeup tft.fillRect(0, 0, BOXSIZE, BOXSIZE, BLACK); tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE); //tft.drawString(35, 35, "^", WHITE, 4); tft.drawTriangle(40, 22, 53, 56, 26, 56, GREEN); tft.drawTriangle(40, 24, 53, 58, 26, 58, GREEN); break; case 4: //volumedown tft.fillRect(0, 80, BOXSIZE, BOXSIZE, BLACK); tft.drawRect(0, 80, BOXSIZE, BOXSIZE, WHITE); //tft.drawString(35, 100, "v", WHITE, 3); tft.drawTriangle(26,101,53,101,40,135,GREEN); tft.drawTriangle(26,103,53,103,40,137,GREEN); break; case 5: //BLUETOOTH tft.fillRect(160, 0, BOXSIZE, BOXSIZE, BLACK); tft.drawRect(160, 0, BOXSIZE, BOXSIZE, WHITE); //tft.drawString(180, 30, "BT", WHITE, 3); tft.drawLine(182, 10, 182, 70, BLUE); tft.drawLine(182, 10, 200, 25, BLUE); tft.drawLine(200,25, 182, 40, BLUE); tft.drawLine(200, 51, 182, 40, BLUE); tft.drawLine(182, 70, 200, 51, BLUE); break; } } void blinkButton(int buttonID) { switch(buttonID) { case 0: tft.fillRect(0, 240, BOXSIZE, BOXSIZE, WHITE); tft.drawString(20, 270, "<<", BLACK, 3); break; case 1: tft.fillRect(BOXSIZE, 240, BOXSIZE, BOXSIZE, WHITE); tft.drawString(95, 270, "||>", BLACK, 3); break; case 2: tft.fillRect(BOXSIZE*2, 240, BOXSIZE, BOXSIZE, WHITE); tft.drawString(180, 270, ">>", BLACK, 3); break; case 3: //volumeup tft.fillRect(0, 0, BOXSIZE, BOXSIZE, WHITE); tft.drawTriangle(40, 22, 53, 56, 26, 56, RED); tft.drawTriangle(40, 24, 53, 58, 26, 58, RED); break; case 4: //volumedown tft.fillRect(0, 80, BOXSIZE, BOXSIZE, WHITE); tft.drawTriangle(26,101,53,101,40,135,RED); tft.drawTriangle(26,103,53,103,40,137,RED); break; case 5: //BLUETOOTH tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, WHITE); //tft.drawString(BOXSIZE*2 + 20, 30, "BT", BLACK, 3); tft.drawLine(182, 10, 182, 70, RED); tft.drawLine(182, 10, 200, 25, RED); tft.drawLine(200,25, 182, 40, RED); tft.drawLine(200, 51, 182, 40, RED); tft.drawLine(182, 70, 200, 51, RED); break; } delay(100); drawButton(buttonID); } void DrawButtons() { for(int i=0; i < 6; i++) { drawButton(i); } tft.drawString(25, 165, "VOL", GREEN, 2); }