I am trying to build a project that would use both the audio design tool to make sine waves and a UI created using Stan Reifel's TeensyUserInterface library.
I managed to get the TeensyUserInterface library to work with the audio board connections.
I had to make a small change to the "TeensyUserInterface.cpp":
The problem I am having is that if I disable the UI, by commenting out the "ui.begin", my sound works but display is blank.
If I enable the UI, then the display works but no sound. Am I asking too much of the Teensy to do both of these things at once? Or am I just doing something wrong?
Here is my code:
I managed to get the TeensyUserInterface library to work with the audio board connections.
I had to make a small change to the "TeensyUserInterface.cpp":
Code:
const byte LCD_DC_PIN = 20; ///AUDIO BOARD CONNECTIONS///
const byte LCD_CS_PIN = 21; ///AUDIO BOARD CONNECTIONS///
//const byte LCD_DC_PIN = 9; ///ORIGINAL CONNECTIONS///
//const byte LCD_CS_PIN = 10; ///ORIGINAL CONNECTIONS///
const byte TOUCH_CS_PIN = 8;
The problem I am having is that if I disable the UI, by commenting out the "ui.begin", my sound works but display is blank.
If I enable the UI, then the display works but no sound. Am I asking too much of the Teensy to do both of these things at once? Or am I just doing something wrong?
Here is my code:
Code:
#include "ILI9341_t3.h"
#include <TeensyUserInterface.h>
#include <font_Arial.h>
#include <font_ArialBold.h>
// Alternate Connections with Teensy Audio Shield
#define TFT_DC 20
#define TFT_CS 21
#define TFT_RST 255 // 255 = unused, connect to 3.3V
#define TFT_MOSI 7
#define TFT_SCLK 14
#define TFT_MISO 12
// Normal Connections
//#define TFT_DC 9
//#define TFT_CS 10
//#define TFT_RST 255 // 255 = unused, connect to 3.3V
//#define TFT_MOSI 11
//#define TFT_SCLK 13
//#define TFT_MISO 12
ILI9341_t3 tft = ILI9341_t3(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO);
//
// create the user interface object
//
TeensyUserInterface ui;
///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine4; //xy=335,289
AudioSynthWaveformSine sine1; //xy=336,171
AudioSynthWaveformSine sine2; //xy=336,210
AudioSynthWaveformSine sine3; //xy=336,250
AudioMixer4 mixer1; //xy=588,232
AudioOutputI2S i2s1; //xy=795,232
AudioConnection patchCord1(sine4, 0, mixer1, 3);
AudioConnection patchCord2(sine1, 0, mixer1, 0);
AudioConnection patchCord3(sine2, 0, mixer1, 1);
AudioConnection patchCord4(sine3, 0, mixer1, 2);
AudioConnection patchCord5(mixer1, 0, i2s1, 0);
AudioConnection patchCord6(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=813,126
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(1);
sgtl5000_1.lineOutLevel(13);
sine1.frequency(500);
sine2.frequency(1000);
sine3.frequency(1500);
sine4.frequency(2000);
//
// initialize the user interface, including setting the screen orientation and font
//
//ui.begin(LCD_ORIENTATION_LANDSCAPE_4PIN_RIGHT, Arial_10_Bold);
//
// use a blue color palette
//
ui.setColorPaletteBlue();
tft.begin();
tft.setRotation(3);
}
char SinePick = 1;
char SineLevel = 25;
void setSineWaveLevels(void)
{
//
// draw the title bar and clear the screen
//
ui.drawTitleBar("Set Sine Wave Levels");
ui.clearDisplaySpace();
//
// set the size and initial value of the number box
//
const int numberBoxWidth = 200;
const int numberBoxAndButtonsHeight = 35;
extern char SinePick;
extern char SineLevel;
//
// define a Number Box so the user can select a numeric value, specify the initial value,
// max and min values, and step up/down amount
//
NUMBER_BOX sineSelect_NumberBox;
sineSelect_NumberBox.labelText = "Select sine wave to adjust";
sineSelect_NumberBox.value = SinePick;
sineSelect_NumberBox.minimumValue = 1;
sineSelect_NumberBox.maximumValue = 4;
sineSelect_NumberBox.stepAmount = 1;
sineSelect_NumberBox.centerX = ui.displaySpaceCenterX;
sineSelect_NumberBox.centerY = ui.displaySpaceCenterY - 35;
sineSelect_NumberBox.width = numberBoxWidth;
sineSelect_NumberBox.height = numberBoxAndButtonsHeight;
ui.drawNumberBox(sineSelect_NumberBox);
NUMBER_BOX sineLevel_NumberBox;
sineLevel_NumberBox.labelText = "Set level";
sineLevel_NumberBox.value = SineLevel;
sineLevel_NumberBox.minimumValue = 0;
sineLevel_NumberBox.maximumValue = 25;
sineLevel_NumberBox.stepAmount = 1;
sineLevel_NumberBox.centerX = ui.displaySpaceCenterX;
sineLevel_NumberBox.centerY = ui.displaySpaceCenterY + 55;
sineLevel_NumberBox.width = numberBoxWidth;
sineLevel_NumberBox.height = numberBoxAndButtonsHeight;
ui.drawNumberBox(sineLevel_NumberBox);
//
// process touch events
//
while(true)
{
ui.getTouchEvents();
//
// process touch events on the Number Box
//
ui.checkForNumberBoxTouched(sineSelect_NumberBox);
ui.checkForNumberBoxTouched(sineLevel_NumberBox);
}
}
void loop() {
setSineWaveLevels();
}