0

MPR121 compile error 'SPISettings' does not name. a type
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MPR121 compile error 'SPISettings' does not name. a type

by dcool on Tue Jan 19, 2021 10:16 pm

Hello,
For clarification, I've used this code and method for several years with no problems, but as operating systems and software keep updating I now get a compile error.

I'm using the MPR121 touch sensor with and Arduino Pro Micro 32U4 and a modified / forked Arduino ARcore: https://github.com/rkistner/arcore
This allows me to use USBMIDI with the Pro Micro.

I'm compiling on MacOS 10.14 Mojave because it will do 32bit.
Here is a link to my Github: https://github.com/davidcool/Mr-Touch-Key
Here is the code I'm trying to compile:
Code: Select all | TOGGLE FULL SIZE
// ---------------------------------------------------------------------------
// Mr. Touch Key
// MIDI Capacitive Touch Keyboard Firmware
// Basic v0.0
// David Cool
// http://davidcool.com
//
// Project archive: https://github.com/davidcool/Mr-Touch-Key
//
// Firmware for a MIDI (Musical Instrument Digital Interface) keyboard using an MPR121 touch sensor breakout
// and Arduino Pro Micro 32u4 (Leonardo)
//
// The callback to send MIDI commands is designed to be
// used with an arduino leonardo or micro and the arcore midi
// usb modifications
//
// for more info on arcore:
// https://github.com/rkistner/arcore
// ---------------------------------------------------------------------------

#include "Wire.h"             // I2C data bus library
#include "Adafruit_MPR121.h"  // touch sensor library

#define BUTTONS  12
#define IRQ_PIN  9            // The MPR121 will use the IRQ to let the controller know something has changed

// mpr121 init
Adafruit_MPR121 cap = Adafruit_MPR121();

// keep track of touched keys
uint16_t lasttouched = 0;
uint16_t currtouched = 0;

// MIDI note mapping
// Octave   Note Numbers
//          C   C#  D   D#  E   F   F#  G   G#  A   A#  B
//    0     0   1   2   3   4   5   6   7   8   9   10  11
//    1     12  13  14  15  16  17  18  19  20  21  22  23
//    2     24  25  26  27  28  29  30  31  32  33  34  35
//    3     36  37  38  39  40  41  42  43  44  45  46  47
//    4     48  49  50  51  52  53  54  55  56  57  58  59
//    5     60  61  62  63  64  65  66  67  68  69  70  71
//    6     72  73  74  75  76  77  78  79  80  81  82  83
//    7     84  85  86  87  88  89  90  91  92  93  94  95
//    8     96  97  98  99  100 101 102 103 104 105 106 107
//    9     108 109 110 111 112 113 114 115 116 117 118 119
//    10    120 121 122 123 124 125 126 127

// prime dynamic values
int channel = 0;

// C3 major
//int pitch[] = {36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 53, 55};

// F# / Gb Major ( F#, G#, A#, B, C#, D#, F, F# )
//int pitch[] = {66, 68, 70, 71, 73, 75, 77, 78, 80, 82, 83, 85};

// E4 major ( E, F#, G#, A, B, C#, D#, E )
//int pitch[] = {52, 54, 56, 57, 59, 61, 63, 64, 66, 68, 69, 71};

// Dm Pentatonic Scale ( D, F, G, A, C, D )
int pitch[] = {38, 41, 43, 45, 48, 50, 53, 55, 57, 60, 62, 65};

int vel[] = {80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80};

void setup() {

  // set mpr121 IRQ pin to input
  pinMode(IRQ_PIN, INPUT);

  // endless loop if the mpr121 init fails
  if (! cap.begin(0x5A))
    while (1);

  // set sensitivity of touch surface, lower numbers increase sensitivity
  cap.setThreshholds(12, 1);
}

void loop() {

  // if mpr121 irq goes low, there have been
  // changes to the button states, so read the values
  if (digitalRead(IRQ_PIN) == LOW)
    readButtons();

}

///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//                       BUTTON PRESS AND MIDI FUNCTIONS                     //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////

// read the currently touched buttons
void readButtons() {

  // read current values
  currtouched = cap.touched();

  handle_note();

  // save current values to compare against in the next loop
  lasttouched = currtouched;

}

// deal with note on and off presses
void handle_note() {

  for (uint8_t i = 0; i < BUTTONS; i++) {

    // note on check
    if ((currtouched & _BV(i)) && !(lasttouched & _BV(i))) {

      // play pressed note
      midi(channel, 0x9, pitch[i], vel[i]);

    }

    // note off check
    if ( !(currtouched & _BV(i)) && (lasttouched & _BV(i)) ) {

      // play note off
      midi(channel, 0x8, pitch[i], 0x0);

    }

  }

}

// the callback to send midi commands. this specific callback is designed to be
// used with an arduino leonardo or micro and the arcore midi
// usb modifications
//
// for more info on arcore:
// https://github.com/rkistner/arcore

void midi(byte channel, byte command, byte arg1, byte arg2) {

  // init combined byte
  byte combined = command;

  // shift if necessary and add MIDI channel
  if (combined < 128) {
    combined <<= 4;
    combined |= channel;
  }

  // send midi message
  MIDIEvent event = {command, combined, arg1, arg2};
  MIDIUSB.write(event);
  MIDIUSB.flush();

}


Here is the error I'm getting:
Code: Select all | TOGGLE FULL SIZE
Arduino: 1.8.13 (Mac OS X), Board: "Arduino Leonardo (arcore, iPad compatible)"
Warning: platform.txt from core 'Arduino AVR Boards (arcore)' contains deprecated compiler.path={runtime.ide.path}/hardware/tools/avr/bin/, automatically converted to compiler.path={runtime.tools.avr-gcc.path}/bin/. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards (arcore)' contains deprecated tools.avrdude.cmd.path={runtime.ide.path}/hardware/tools/avr/bin/avrdude, automatically converted to tools.avrdude.cmd.path={path}/bin/avrdude. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards (arcore)' contains deprecated tools.avrdude.config.path={runtime.ide.path}/hardware/tools/avr/etc/avrdude.conf, automatically converted to tools.avrdude.config.path={path}/etc/avrdude.conf. Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards (arcore)' contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{build.path}/{archive_file}" "{object_file}", automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} "{archive_file_path}" "{object_file}". Consider upgrading this core.
Warning: platform.txt from core 'Arduino AVR Boards (arcore)' contains deprecated recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} -o "{build.path}/{build.project_name}.elf" {object_files} "{build.path}/{archive_file}" "-L{build.path}" -lm, automatically converted to recipe.c.combine.pattern="{compiler.path}{compiler.c.elf.cmd}" {compiler.c.elf.flags} -mmcu={build.mcu} -o "{build.path}/{build.project_name}.elf" {object_files} "{archive_file_path}" "-L{build.path}" -lm. Consider upgrading this core.
In file included from /Users/davidcool/Documents/Arduino/hardware/hardware/avr/libraries/Adafruit_BusIO/Adafruit_BusIO_Register.h:2:0,
                 from /Users/davidcool/Documents/Arduino/hardware/hardware/avr/libraries/Adafruit_MPR121/Adafruit_MPR121.h:26,
                 from /Users/davidcool/Desktop/mr_touch_key_basic_v0/mr_touch_key_basic_v0.ino:22:
/Users/davidcool/Documents/Arduino/hardware/hardware/avr/libraries/Adafruit_BusIO/Adafruit_SPIDevice.h:86:3: error: 'SPISettings' does not name a type
   SPISettings *_spiSetting;
   ^~~~~~~~~~~
exit status 1
Error compiling for board Arduino Leonardo (arcore, iPad compatible).

I can compile other ARcore programs so I don't think that's the issure. It seems like something with the Adafruit SPI?
Is there a way to fix this?
Many thanks!
David

dcool
 
Posts: 3
Joined: Wed Nov 30, 2016 9:21 am

Re: MPR121 compile error 'SPISettings' does not name. a type

by dcool on Tue Jan 19, 2021 11:32 pm

I solved my own problem. I ended up just installing version 1.0.0 (an older version!) of the Adafruit_BusIO library and the problem vanished.
Now I just have to get my VMWare Fusion install of Mojave to actually upload to my Arduino... :-(

Anyway, hopefully this helps someone else out in the future!

David

dcool
 
Posts: 3
Joined: Wed Nov 30, 2016 9:21 am

Please be positive and constructive with your questions and comments.