Hi there,
Just swapped out a nano 33 iot board for a nano 33 BLE board in a project as I'm only using Bluetooth and not wifi. Having trouble compiling the sketch that involves the vs1053.h library. When I try to compile I get this message:
Arduino: 1.8.15 (Linux), Board: "Arduino Nano 33 BLE"
/home/mike/Arduino/libraries/Adafruit_VS1053_Library/Adafruit_VS1053.cpp: In constructor 'Adafruit_VS1053::Adafruit_VS1053(int8_t, int8_t, int8_t, int8_t, int8_t, int8_t, int8_t)':
/home/mike/Arduino/libraries/Adafruit_VS1053_Library/Adafruit_VS1053.cpp:334:16: error: 'portOutputRegister' was not declared in this scope
clkportreg = portOutputRegister(digitalPinToPort(_clk));
^~~~~~~~~~~~~~~~~~
/home/mike/Arduino/libraries/Adafruit_VS1053_Library/Adafruit_VS1053.cpp:335:12: error: 'digitalPinToBitMask' was not declared in this scope
clkpin = digitalPinToBitMask(_clk);
^~~~~~~~~~~~~~~~~~~
/home/mike/Arduino/libraries/Adafruit_VS1053_Library/Adafruit_VS1053.cpp:335:12: note: suggested alternative: 'digitalPinToPinName'
clkpin = digitalPinToBitMask(_clk);
^~~~~~~~~~~~~~~~~~~
digitalPinToPinName
/home/mike/Arduino/libraries/Adafruit_VS1053_Library/Adafruit_VS1053.cpp:336:17: error: 'portInputRegister' was not declared in this scope
misoportreg = portInputRegister(digitalPinToPort(_miso));
^~~~~~~~~~~~~~~~~
exit status 1
Error compiling for board Arduino Nano 33 BLE.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I get the same message if I try to compile the simpl_player sketch example that comes with the library. The Arduino IDE recognizes my nano 33 BLE board and successfully compiles and uploads sketches that don't contain the VS1053.h library.
I'm noticing that other people are having problems compiling sketches with other libraries with this board. Is there a fix for this?
Many thanks for your time.
Mike
sketchs using vs1053 don't seem to compile or upload onto a
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- mikeraffone
- Posts: 6
- Joined: Sat May 22, 2021 2:42 pm
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
It looks as though the work around is to resolve the portOutputRegister() / portInputRegister() with custom macros in the variant.h file.
https://forum.arduino.cc/t/portoutputre ... -it/674775
https://github.com/arduino/ArduinoCore- ... /variant.h
Code: Select all
#if !defined(portOutputRegister)
#define digitalPinToBitMask(P) (1uL<<(digitalPinToPinName(P)&31))
#define portOutputRegister(port) (port ? &NRF_P1->OUT : &NRF_P0->OUT)
#define portInputRegister(port) (port ? &NRF_P1->IN : &NRF_P0->IN)
#endif
https://github.com/arduino/ArduinoCore- ... /variant.h
- mikeraffone
- Posts: 6
- Joined: Sat May 22, 2021 2:42 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
Many thanks for your reply.
Forgive me, I'm quite new to programming microcontrollers so not sure what you mean. I've tried looking for a variant.h file on my hard drive (including hidden files from the root) but cannot find one.
I've also tried putting the code before the void setup() and before the #include <Adafruit_VS1053> command. Still unable to compile the library.
Am I doing the right thing?
Forgive me, I'm quite new to programming microcontrollers so not sure what you mean. I've tried looking for a variant.h file on my hard drive (including hidden files from the root) but cannot find one.
I've also tried putting the code before the void setup() and before the #include <Adafruit_VS1053> command. Still unable to compile the library.
Am I doing the right thing?
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
The variants.h I had linked to is the ArduinoCore-samd/variants a library that you would normally use. However, I don't like that they only have the IoT board listed and not the BLE version of the Nano 33.
Let's backup a step and can you confirm that you have installed the Arduino Mbed OS Nano Boards from Tools --> Boards --> Board Manager. You should be able to try and compile the blink example and make sure you are selecting Nano 33 BLE for your board. Details here:
https://www.arduino.cc/en/Guide/NANO33BLE
Let's backup a step and can you confirm that you have installed the Arduino Mbed OS Nano Boards from Tools --> Boards --> Board Manager. You should be able to try and compile the blink example and make sure you are selecting Nano 33 BLE for your board. Details here:
https://www.arduino.cc/en/Guide/NANO33BLE
- mikeraffone
- Posts: 6
- Joined: Sat May 22, 2021 2:42 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
Yes, I've installed the ble using the boards manager, so now it's listed under arduino mbed os nano boards in the boards manager. I can compile sketches that don't use the vs1053.h library,
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
Good to know all your non VS1053 code is building.
Can you try installing the VS1053 library that was released this week v1.2.1:
https://github.com/adafruit/Adafruit_VS1053_Library
You might have to use add .zip file manually through the Arduino IDE library manager.
If you are still getting the errors around the SPI pins please link me or paste in CODE tabs the failed example you are using.
Can you try installing the VS1053 library that was released this week v1.2.1:
https://github.com/adafruit/Adafruit_VS1053_Library
You might have to use add .zip file manually through the Arduino IDE library manager.
If you are still getting the errors around the SPI pins please link me or paste in CODE tabs the failed example you are using.
- mikeraffone
- Posts: 6
- Joined: Sat May 22, 2021 2:42 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
Thanks again for your response. I've installed the latest version of vs1053.h to the libraries manager and I'm still failing to compile and getting the same error message when the the board is set to the nano 33 BLE. Works fine, as before with the 33 iot. Here is the code.
Thanks again.
Code: Select all
// go to line 507 to continue (this is a note to me to find where I left off in the code)
//include relevent librairies
#include <ArduinoBLE.h> //for bluetooth
#include <SPI.h> //for mp3 player spi connection
#include <Adafruit_VS1053.h> //for mp3 player
#include <SD.h> //for SD card on mp3 player
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Wire.h>
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// These are the pins used for the mp3 player
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
#define CARDCS 7 // Card chip select pin
#define DREQ A1 // VS1053 Data request, ideally an Interrupt pin
//define universal constants
byte cue=0;
byte oldIncoming = 0;
byte oldIncoming2 = 0;
volatile bool bleOn = true;
byte lastPlayed = 1;
String trackLabel[99];
byte labelMode = 1;
byte rfn = 15;
byte capn = 0;
byte ssn = 0;
byte dsn = 0;
byte i2cn = 0;
byte usn = 0;
byte rfCueMode = 2;
//bool pdOn;
// Define Connections to 74HC165
// PL pin 1
const byte load = 2;
// CE pin 15
const byte clockEnablePin = 4;
// Q7 pin 7
const byte dataIn = 5;
// CP pin 2
const byte clockIn = 3;
const int bleStatPin = A7;
//create mp3 player object
Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // BLE LED Service
// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEByteCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);
void setup() {
Serial.begin(115200); //uncomment for debugging info
//(!Serial); //uncomment to run the Serial port in setup
// Setup 74HC165 connections
pinMode(load, OUTPUT);
pinMode(clockEnablePin, OUTPUT);
pinMode(clockIn, OUTPUT);
pinMode(dataIn, INPUT);
pinMode(bleStatPin,INPUT_PULLUP); //bluetooth status button
attachInterrupt(digitalPinToInterrupt(bleStatPin), ISR_bleStatOn, CHANGE);
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
display.display();
display.setTextColor(WHITE); //set default screen colour to white
// begin initialization of bluetooth
if (!BLE.begin()) {
Serial.println("starting BLE failed!");
while (1);
}
// set advertised local name and service UUID:
BLE.setLocalName("LED");
BLE.setAdvertisedService(ledService);
// add the characteristic to the service
ledService.addCharacteristic(switchCharacteristic);
// add service
BLE.addService(ledService);
// set the initial value for the characeristic:
switchCharacteristic.writeValue(0);
// start advertising
BLE.advertise();
Serial.println("BLE LED Peripheral");
//initialisations for mp3 player
musicPlayer.begin();
musicPlayer.sineTest(0x44, 500);
if (!SD.begin(CARDCS)) {
Serial.println(F("SD failed, or not present"));
display.clearDisplay();
display.setTextSize(1);
display.setCursor(27,0);
display.print("Please insert");
display.setCursor(28,12);
display.print("your SD card");
display.setCursor(22,24);
display.print("and press reset");
display.display();
while (1); // don't do anything more
}
musicPlayer.setVolume(1,1); //set output volume of mp3 player to max (lower numbers = higher volume)
if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT))
Serial.println(F("DREQ pin is not an interrupt pin"));
//Load track label info from SD card
File dataFile = SD.open("info.txt");
if (dataFile) {
while (dataFile.available()) {
for (byte i=0; i<99; i++) {
String buffer = dataFile.readStringUntil('\n');
trackLabel[i] = buffer;
Serial.println(trackLabel[i]);
if (!dataFile.available()) break;
}
}
dataFile.close();
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening info.txt");
}
}
void loop() {
// listen for BLE peripherals to connect:
BLEDevice central = BLE.central();
// if a central is connected to peripheral:
if (central) {
Serial.print("Connected to central: ");
// print the central's MAC address:
Serial.println(central.address());
bleOnDisplay();
delay(1200);
display.clearDisplay();
display.display();
// while the central is still connected to peripheral:
while (central.connected()) {
setRfFlag();
// if the remote BLE device wrote to the characteristic,
// use the value to set a cue flag
if (switchCharacteristic.written()) {
cue=switchCharacteristic.value()+17;
}
if (rfCueMode == 1) playRfTrack1();
if (rfCueMode == 2) playRfTrack2();
trackEndDisplay(); //clear display if track reaches the end
}
// when the central disconnects, print it out:
Serial.print(F("Disconnected from central: "));
Serial.println(central.address());
}
setRfFlag();
if (rfCueMode == 1) playRfTrack1();
if (rfCueMode == 2) playRfTrack2();
trackEndDisplay();
}
void playRfTrack1() {
if (cue != 0 && cue<=16) {
String tName;
if (cue>0 && cue<10) tName = ("track0" + String (cue) +".mp3");
else tName = ("track" + String (cue) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
displayTrack();
lastPlayed = cue;
cue = 0;
}
}
void playRfTrack2() {
if (musicPlayer.paused()) {
if (musicPlayer.paused()) {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(30,0);
display.print("Track " + String(lastPlayed));
display.setCursor(37,19);
display.print("PAUSED");
display.display();
display.stopscroll();
}
}
if (cue !=0 && cue <=16) {
if (cue == 14) {
musicPlayer.stopPlaying();
Serial.println("stopped");
}
if (cue == 13) {
if (!musicPlayer.paused()) {
if (!musicPlayer.playingMusic) {
String tName;
if (lastPlayed>0 && lastPlayed<10) tName = ("track0" + String (lastPlayed) + ".mp3");
else tName = ("track" + String (lastPlayed) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
displayResume();
Serial.println(tName);
}
else {
musicPlayer.pausePlaying(true);
Serial.println("Pause");
}
}
else {
musicPlayer.pausePlaying(false);
displayResume();
//bool pdOn = true;
Serial.println("Resume");
}
}
if (cue == 15) {
if (lastPlayed == rfn && capn != 0) {
musicPlayer.startPlayingFile("track17.mp3");
lastPlayed = 17;
displayResume();
}
if (lastPlayed == rfn && capn == 0 && ssn != 0) {
musicPlayer.startPlayingFile("track41.mp3");
lastPlayed = 41;
displayResume();
}
if (lastPlayed == rfn && capn == 0 && ssn == 0 && dsn != 0) {
musicPlayer.startPlayingFile("track65.mp3");
lastPlayed = 65;
displayResume();
}
if (lastPlayed == rfn && capn == 0 && ssn == 0 && dsn == 0 && i2cn != 0) {
musicPlayer.startPlayingFile("track69.mp3");
lastPlayed = 69;
displayResume();
}
if (lastPlayed == rfn && capn == 0 && ssn == 0 && dsn == 0 && i2cn == 0 && usn != 0) {
musicPlayer.startPlayingFile("track73.mp3");
lastPlayed = 73;
displayResume();
}
if (lastPlayed == rfn && capn == 0 && ssn == 0 && dsn == 0 && i2cn == 0 && usn == 0) {
musicPlayer.startPlayingFile("track01.mp3");
lastPlayed = 1;
displayResume();
}
if (lastPlayed == (capn + 16) && ssn == 0 && dsn ==0 && i2cn == 0 && usn == 0 && rfn == 0) {
musicPlayer.startPlayingFile("track17.mp3");
lastPlayed = 17;
displayResume();
}
if (lastPlayed == (capn + 16) && ssn != 0) {
musicPlayer.startPlayingFile("track41.mp3");
lastPlayed = 41;
displayResume();
}
if (lastPlayed == (capn + 16) && ssn == 0 && dsn != 0) {
musicPlayer.startPlayingFile("track65.mp3");
lastPlayed = 65;
displayResume();
}
if (lastPlayed == (capn + 16) && ssn == 0 && dsn == 0 && i2cn != 0) {
musicPlayer.startPlayingFile("track69.mp3");
lastPlayed = 69;
displayResume();
}
if (lastPlayed == (capn + 16) && ssn == 0 && dsn == 0 && i2cn == 0 && usn != 0) {
musicPlayer.startPlayingFile("track73.mp3");
lastPlayed = 73;
displayResume();
}
if (lastPlayed == (capn + 16) && ssn == 0 && dsn == 0 && i2cn == 0 && usn == 0 && rfn !=0) {
musicPlayer.startPlayingFile("track01.mp3");
lastPlayed = 1;
displayResume();
}
if (lastPlayed == (ssn + 40) && dsn == 0 && i2cn == 0 && usn == 0 && rfn == 0 && capn !=0) {
musicPlayer.startPlayingFile("track17.mp3");
lastPlayed = 17;
displayResume();
}
if (lastPlayed == (ssn + 40) && dsn == 0 && i2cn == 0 && usn == 0 && rfn == 0 && capn == 0) {
musicPlayer.startPlayingFile("track41.mp3");
lastPlayed = 41;
displayResume();
}
if (lastPlayed == (ssn + 40) && dsn != 0) {
musicPlayer.startPlayingFile("track65.mp3");
lastPlayed = 65;
displayResume();
}
if (lastPlayed == (ssn + 40) && dsn == 0 && i2cn != 0) {
musicPlayer.startPlayingFile("track69.mp3");
lastPlayed = 69;
displayResume();
}
if (lastPlayed == (ssn + 40) && dsn == 0 && i2cn == 0 && usn != 0) {
musicPlayer.startPlayingFile("track73.mp3");
lastPlayed = 73;
displayResume();
}
if (lastPlayed == (ssn + 40) && dsn == 0 && i2cn == 0 && usn == 0 && rfn !=0) {
musicPlayer.startPlayingFile("track01.mp3");
lastPlayed = 1;
displayResume();
}
if (lastPlayed == (dsn + 64) && i2cn == 0 && usn == 0 && rfn == 0 && capn !=0) {
musicPlayer.startPlayingFile("track17.mp3");
lastPlayed = 17;
displayResume();
}
if (lastPlayed == (dsn + 64) && i2cn == 0 && usn == 0 && rfn == 0 && capn == 0 && ssn !=0) {
musicPlayer.startPlayingFile("track41.mp3");
lastPlayed = 41;
displayResume();
}
if (lastPlayed == (dsn + 64) && i2cn == 0 && usn == 0 && rfn == 0 && capn == 0 && ssn == 0) {
musicPlayer.startPlayingFile("track65.mp3");
lastPlayed = 65;
displayResume();
}
if (lastPlayed == (dsn + 64) && i2cn != 0) {
musicPlayer.startPlayingFile("track69.mp3");
lastPlayed = 69;
displayResume();
}
if (lastPlayed == (dsn + 64) && i2cn == 0 && usn != 0) {
musicPlayer.startPlayingFile("track73.mp3");
lastPlayed = 73;
displayResume();
}
if (lastPlayed == (dsn + 64) && i2cn == 0 && usn == 0 && rfn !=0) {
musicPlayer.startPlayingFile("track01.mp3");
lastPlayed = 1;
displayResume();
}
if (lastPlayed == (i2cn + 68) && usn == 0 && rfn == 0 && capn !=0) {
musicPlayer.startPlayingFile("track17.mp3");
lastPlayed = 17;
displayResume();
}
if (lastPlayed == (i2cn + 68) && usn == 0 && rfn == 0 && capn == 0 && ssn !=0) {
musicPlayer.startPlayingFile("track41.mp3");
lastPlayed = 41;
displayResume();
}
if (lastPlayed == (i2cn + 68) && usn == 0 && rfn == 0 && capn == 0 && ssn == 0 && dsn !=0) {
musicPlayer.startPlayingFile("track65.mp3");
lastPlayed = 65;
displayResume();
}
if (lastPlayed == (i2cn + 68) && usn == 0 && rfn == 0 && capn == 0 && ssn == 0 && dsn == 0) {
musicPlayer.startPlayingFile("track69.mp3");
lastPlayed = 69;
displayResume();
}
if (lastPlayed == (i2cn + 68) && usn != 0) {
musicPlayer.startPlayingFile("track73.mp3");
lastPlayed = 73;
displayResume();
}
if (lastPlayed == (i2cn + 68) && usn == 0 && rfn !=0) {
musicPlayer.startPlayingFile("track01.mp3");
lastPlayed = 1;
displayResume();
}
if (lastPlayed == (usn + 72) && rfn == 0 && capn !=0) {
musicPlayer.startPlayingFile("track17.mp3");
lastPlayed = 17;
displayResume();
}
if (lastPlayed == (usn + 72) && rfn == 0 && capn == 0 && ssn !=0) {
musicPlayer.startPlayingFile("track41.mp3");
lastPlayed = 41;
displayResume();
}
if (lastPlayed == (usn + 72) && rfn == 0 && capn == 0 && ssn == 0 && dsn !=0) {
musicPlayer.startPlayingFile("track65.mp3");
lastPlayed = 65;
displayResume();
}
if (lastPlayed == (usn + 72) && rfn == 0 && capn == 0 && ssn == 0 && dsn == 0 && i2cn != 0) {
musicPlayer.startPlayingFile("track69.mp3");
lastPlayed = 69;
displayResume();
}
if (lastPlayed == (usn + 72) && rfn == 0 && capn == 0 && ssn == 0 && dsn == 0 && i2cn == 0) {
musicPlayer.startPlayingFile("track73.mp3");
lastPlayed = 73;
displayResume();
}
if (lastPlayed == (usn + 72) && rfn !=0) {
musicPlayer.startPlayingFile("track01.mp3");
lastPlayed = 1;
displayResume();
}
else {
String tName;
if (lastPlayed>0 && lastPlayed<10) tName = ("track0" + String (lastPlayed + 1) +".mp3");
else tName = ("track" + String (lastPlayed + 1) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
Serial.println(tName);
lastPlayed = lastPlayed + 1;
displayResume();
Serial.println(lastPlayed);
}
}
if (cue == 16) {
if (lastPlayed == 1 && usn != 0) {
String tName;
tName = ("track" + String (usn + 72) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
lastPlayed = usn + 72;
displayResume();
}
if (lastPlayed == 1 && usn == 0 && i2cn != 0) {
String tName;
tName = ("track" + String (i2cn + 68) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
lastPlayed = i2cn + 68;
displayResume();
}
if (lastPlayed == 1 && usn == 0 && i2cn == 0 && dsn != 0) {
String tName;
tName = ("track" + String (dsn + 64) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
lastPlayed = dsn + 64;
displayResume();
}
if (lastPlayed == 1 && usn == 0 && i2cn == 0 && dsn == 0 && ssn !=0) {
String tName;
tName = ("track" + String (ssn + 40) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
lastPlayed = ssn + 40;
displayResume();
}
if (lastPlayed == 1 && usn == 0 && i2cn == 0 && dsn == 0 && ssn == 0 && capn !=0) {
String tName;
tName = ("track" + String (capn + 16) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
lastPlayed = capn + 16;
displayResume();
}
if (lastPlayed == 1 && usn == 0 && i2cn == 0 && dsn == 0 && ssn == 0 && capn == 0 && rfn != 0) {
String tName;
tName = ("track" + String (rfn) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
lastPlayed = rfn;
displayResume();
}
//continue here, just five more sets to go. lastPlayed == 17, 41, 65, 69 and 73.
else {
String tName;
if (lastPlayed>1 && lastPlayed<11) tName = ("track0" + String (lastPlayed - 1) +".mp3");
else tName = ("track" + String (lastPlayed - 1) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
Serial.println(tName);
lastPlayed = lastPlayed - 1;
displayResume();
Serial.println(lastPlayed);
}
}
if (cue > 0 && cue < 13) {
String tName;
if (cue>0 && cue<10) tName = ("track0" + String (cue) +".mp3");
else tName = ("track" + String (cue) +".mp3");
musicPlayer.startPlayingFile(tName.c_str());
displayTrack();
Serial.println(tName);
lastPlayed = cue;
}
cue = 0;
}
}
void displayTrack() {
if (labelMode == 1) {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,10);
display.print("Track " + String(cue));
display.display();
display.startscrollleft(0x00, 0x0F);
}
else {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,10);
display.print(trackLabel[cue-1]);
display.display();
display.startscrollleft(0x00, 0x0F);
}
}
void displayResume() {
if (labelMode == 1) {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,10);
display.print("Track " + String(lastPlayed));
display.display();
display.startscrollleft(0x00, 0x0F);
}
else {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,10);
display.print(trackLabel[lastPlayed-1]);
display.display();
display.startscrollleft(0x00, 0x0F);
}
}
void bleOnDisplay() {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(11,0);
display.print("Bluetooth");
display.setCursor(52,19);
display.print("ON");
display.display();
display.stopscroll();
}
void bleOffDisplay() {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(11,0);
display.print("Bluetooth");
display.setCursor(52,19);
display.print("OFF");
display.display();
display.stopscroll();
}
void setRfFlag() {
// Write pulse to load pin
digitalWrite(load, LOW);
digitalWrite(load, HIGH);
// Get data from 74HC165
digitalWrite(clockIn, HIGH);
digitalWrite(clockEnablePin, LOW);
byte incoming = shiftIn(dataIn, clockIn, MSBFIRST);
byte incoming2 = shiftIn(dataIn, clockIn, MSBFIRST);
digitalWrite(clockEnablePin,HIGH);
digitalWrite(clockIn,LOW);
if (incoming != oldIncoming) {
switch (incoming) {
case B10000000:
cue = 1;
break;
case B1000000:
cue = 2;
break;
case B100000:
cue = 3;
break;
case B10000:
cue = 4;
break;
case B1000:
cue = 5;
break;
case B100:
cue = 6;
break;
case B10:
cue = 7;
break;
case B1:
cue = 8;
break;
}
oldIncoming = incoming;
}
if (incoming2 != oldIncoming2) {
switch (incoming2) {
case B10000000:
cue = 9;
break;
case B1000000:
cue = 10;
break;
case B100000:
cue = 11;
break;
case B10000:
cue = 12;
break;
case B1000:
cue = 13;
break;
case B100:
cue = 14;
break;
case B10:
cue = 15;
break;
case B1:
cue = 16;
break;
}
oldIncoming2 = incoming2;
}
}
void trackEndDisplay() {
if (!musicPlayer.playingMusic) {
display.clearDisplay();
display.display();
}
}
void ISR_bleStatOn() {
BLEDevice central = BLE.central();
if (bleOn == true) {
bleOn = false;
if (central.connected()) {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(11,0);
display.print("Bluetooth");
display.setCursor(52,19);
display.print("ON");
display.display();
display.stopscroll();
}
else {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(11,0);
display.print("Bluetooth");
display.setCursor(52,19);
display.print("OFF");
display.display();
display.stopscroll();
}
}
else {
bleOn = true;
if (!musicPlayer.playingMusic) {
display.clearDisplay();
display.display();
}
else {
resumeDisplay();
}
}
}
void resumeDisplay() {
if (labelMode == 1) {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,10);
display.print("Track " + String(lastPlayed));
display.display();
display.startscrollleft(0x00, 0x0F);
}
else {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0,10);
display.print(trackLabel[lastPlayed-1]);
display.display();
display.startscrollleft(0x00, 0x0F);
}
}
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
Switching from the Nano 33 IOT to the Nano 33 BLE is a significant change between processor types M0 vs nRF52840 . The VS1053 library cares about the pins being used for chip select, data/command and interrupts.
Have you reviewed the pins you are using comparing the Nano 33 IOT and Nano 33 BLE?
An example of how we define the different pin types for our feathers is here. There will not apply to you since the Nano's have their own non-feather compliant pinout.
https://github.com/adafruit/Adafruit_VS ... player.ino
Your example code is using:
So pins A1, 7, 8, 9 and 10 are of interest. Try verifying the pin functionality is fully compatible on the selected pins between the IoT and BLE.
https://content.arduino.cc/assets/Pinou ... latest.pdf
https://content.arduino.cc/assets/Pinou ... latest.pdf
Have you reviewed the pins you are using comparing the Nano 33 IOT and Nano 33 BLE?
An example of how we define the different pin types for our feathers is here. There will not apply to you since the Nano's have their own non-feather compliant pinout.
https://github.com/adafruit/Adafruit_VS ... player.ino
Your example code is using:
Code: Select all
// These are the pins used for the mp3 player
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
#define CARDCS 7 // Card chip select pin
#define DREQ A1 // VS1053 Data request, ideally an Interrupt pin
https://content.arduino.cc/assets/Pinou ... latest.pdf
https://content.arduino.cc/assets/Pinou ... latest.pdf
- mikeraffone
- Posts: 6
- Joined: Sat May 22, 2021 2:42 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
OK, so
The above pinout compiles with the 33iot and doesn't with the 33 BLE. Pins 8, 9, 10, 11, 12, and 13 are used the same as the simple player example sketch with the sd card chip select changed to 7 and the dreq to A1 (this is one of the few interrupt enabled pins I have left on the 33 iot)
I originally had the dreq set to 6 as this is an interrupt pin on the BLE.
I also tried to upload the simple player with the pinout that you suggest which is
Even is a uncomment the definintions of the miso, mosi and clock pins at 11, 12, and 13 it still will not compile with the 33 BLE.
Many thanks again for your time on this problem. I may have to go ahead and use the 33 iot, but want to avoid this as I was going to use them for other projects. I've also spent money getting pcbs printed with a different pinout for the BLE interrupts pins.
The above pinout compiles with the 33iot and doesn't with the 33 BLE. Pins 8, 9, 10, 11, 12, and 13 are used the same as the simple player example sketch with the sd card chip select changed to 7 and the dreq to A1 (this is one of the few interrupt enabled pins I have left on the 33 iot)
I originally had the dreq set to 6 as this is an interrupt pin on the BLE.
I also tried to upload the simple player with the pinout that you suggest which is
Code: Select all
// define the pins used
#define CLK 13 // SPI Clock, shared with SD card
#define MISO 12 // Input data, from VS1053/SD card
#define MOSI 11 // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins.
// See http://arduino.cc/en/Reference/SPI "Connections"
// These are the pins used for the breakout example
#define BREAKOUT_RESET 9 // VS1053 reset pin (output)
#define BREAKOUT_CS 10 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 8 // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET -1 // VS1053 reset pin (unused!)
#define SHIELD_CS 7 // VS1053 chip select pin (output)
#define SHIELD_DCS 6 // VS1053 Data/command select pin (output)
// These are common pins between breakout and shield
#define CARDCS 4 // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3 // VS1053 Data request, ideally an Interrupt pin
Many thanks again for your time on this problem. I may have to go ahead and use the 33 iot, but want to avoid this as I was going to use them for other projects. I've also spent money getting pcbs printed with a different pinout for the BLE interrupts pins.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
Yeah, this is frustrating.
It probably makes more sense to go with the Nano 33 IoT at this point.
If you were to troubleshoot it further I would continue working with the player_simple.ino and keep trying pin combinations (just compiler wise) to see what the the Nano 33 needs to be happy. Pretty much just moving the RESET/CS/DCS around to free pins. maybe turn off the DREQ for now.
It probably makes more sense to go with the Nano 33 IoT at this point.
If you were to troubleshoot it further I would continue working with the player_simple.ino and keep trying pin combinations (just compiler wise) to see what the the Nano 33 needs to be happy. Pretty much just moving the RESET/CS/DCS around to free pins. maybe turn off the DREQ for now.
- mikeraffone
- Posts: 6
- Joined: Sat May 22, 2021 2:42 pm
Re: sketchs using vs1053 don't seem to compile or upload ont
will do, thanks
Please be positive and constructive with your questions and comments.