libraries
Paul - Really dumb question from the n00b (I'll try not to ask too many).
I've installed the Arduino tools (1.8.5) and then the Teensy add ons (1.4.2). When I verify, I get compilation errors around each of the following: Adafruit_MCP23017.h. ILI9341_due_config.h. ILI9341_due.h.
Do I have to manually find and download these resources from the web and if so, where do I put them?
Thought I'd try to carefully understand and compile your code, before stripping out the things I don't need- I might end up needing 1 MCP23017, but not three.
Aye, need to download them, but they're fairly well known and documented libraries - they're all available on github, I put links at the end of the pdf to the relevant pages. Can download them as zip files, no need to unpack them, just add zip file in library manager. They have good examples, too. The MCP23017 is very useful, and easy to use, but do take a look at the datasheet - if you want to use say a lot of LEDs, need to be a bit careful of the maximum current the chip can source or sink. The main reason I used 3 of them was so that I could spread out the LEDs, and so I could add a ps/2 keyboard. By using the 8 pin parallel output of a keyboard encoder board to 8 inputs on a MCP23017, I could read each pin in turn then bitwrite to make the ps/2 scancode byte. I was running out of pins on the teensy
For the three address pins, all grounded is address 0, and all VCC is address 7, so 8 addresses are available. Don't forget that the reset needs VCC, and the two I2C lines both need 4.7K resistors to VCC, though.
As for the coding, the mcp.digitalRead /Write is easy enough to get your head round, and the reading of button switches/writing of the LEDs is essentially a state machine - read data, if its on, turn it off, if its off, turn it on, send data. The incremental encoders just count up and down, with a change in count sending MIDI data and updating the screen. The thing that's really useful in the encoder library is the encoder.Write(value), so that the starting value of an encoder count variable can be changed at any time - this makes it pretty straightforward to enable MIDI in to update it too. The LCD is really graph paper, drawing rectangles, arcs and text - the MarekBuriak due library has some excellent documentation of the functions available, and is really very impressive indeed. The eeprom is essentially 32k of static memory, and can read/write each byte by individual address, so I thought it was ideal for saving of presets - I made each preset 64 bytes long, so can just multiply the preset number by 64 to get the start address to read/write the preset. I used arrays for the presets with a fixed format, so that the byte order from the start of the preset updates the same variables. I think the muddiest part of my coding is probably in the preset naming - this is the first thing I've done where I've used string/char variables and arrays, and I found it a little tricky, tied myself up in knots a few times, especially for trying to read characters from 3 potential sources - buttons, encoder and keyboard. Greedy....
I tried to document the sketch as much as I could, and hopefully used names for variables/voids that weren't too cryptic to follow - this is the first project I've put online, so feel free to ask away
I put the functions on tabs in the sketch, to hopefully try and make it easier to break down. There are a lot of variables for the MIDI functions, but most of these can be broken down into sets fairly easily. 3 sets of controllers for left,stereo, right. Each of these sets has 9 controllers each, 3 cut/boosts, 3 frequency ranges, and 3 in/out states. After that, there is 1 overall output gain, 1 power and 1 bypass state. These all need more than 1 variable, to allow for comparisons of old values/states to new values/states, so the number of variables needed racks up pretty quick
Makes it look far more complex than what it is, though, which is really just simple ideas repeated.
I'm fairly new to all this, too, but its been an entertaining learning curve.
Paul.
Paul.