• Radio Build Photolog

    Jeremy Lambert05/19/2015 at 17:50 0 comments

    Build 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

    Jeremy Lambert02/07/2015 at 21:27 0 comments

    Code 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);
    ...
    Read more »