I recently bought a MKRZero, impressed with its speed, memory, and the built-in SD Reader. It is fun to work with (even if a bit finicky). I am building a TOS tricorder simulation to insert inside a MARKO tricorder case. There is very limited space.
I am using the Adafruit_ILI9341 library with the TFT is hooked up through the default SPI:
#define TFT_DC 6 // DC and CS seem to be swappable without change in speed
#define TFT_CS 7 // DC and CS seem to be swappable without change in speed
#define TFT_RS 4 // Labelled as "#define PIN_SPI_SS (4u)" in "github.com/.../variants/mkrzero/variant.h"
// PIN_SPI_MISO (10u)
// PIN_SPI_MOSI (8u)
// PIN_SPI_SCK (9u)
Adafruit_ILI9341 myTft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RS);
I can swap DC and CS with little effect on the speed. I originally had RS running through a resistor to Vcc, but I much prefer it software wired in.
To engage the SD reader, I just used the code:
if (!SD.begin(SDCARD_SS_PIN)) {
Serial.println("failed!");
}
The documentation indicates it has its very own SPI, and it works wonderfully. I use it to store and read my 16-byte, 565 RAW bitmaps (using BITMAP3HEADER). I wrote code (with the assistance of Bodmer and Prentice) that employs tft.pushColor to draw the RAW images from the SD reader to the screen. Because they are 16-byte, 565 RAW files, the read time is much faster than reading BMP files. The average time is around 1580 ms for a full 320×240 screen image. I would like to reduce the time. More on that later.
I hooked up an MP3Player through Serial1 using the built in RX and TX lines (pins 13 and 14):
#include <DFRobotDFPlayerMini.h> // MP3 player
// extern Uart Serial1;
// PIN_SERIAL1_RX (13ul)
// PIN_SERIAL1_TX (14ul)
DFRobotDFPlayerMini myDFPlayer; // Creates player object
Serial1.begin(9600);
if (!myDFPlayer.begin(Serial1)) {
Serial.println(F("Unable to begin:"));
}
I did this (rather than having the MKRZero play the music) because I wanted the music playing while, for example, reading a RAW image to the screen. I send a quick code through TX, and the MP3Player happily plays that track to its end. I did have to set up a logic shifter for TX and RX because the MP3Player prefers 5V rather than 3V3.
I used CapacitiveSensor.h to set up three capacitive touch buttons that control the functions of the tricorder.
I also have three LEDs that signal at various times.
All of these things work together quite nicely with, seemingly, no conflicts. It's quite a tricked out MKRZero! I even have a few pins (A0, A4, A5, A6, D0, D11, and D12) left for future expansion. It seems as though the MKRZero has slipped under the radar a bit. It would be nice to see more people have success with it.
My next step is to try to augment a library (I have never tried that before) to pushColor more than one piece of data at a time. I think that could dramatically improve the read time of the RAW images from the SD reader. Wish me luck!
I have one question for anyone familiar with the Adafruit_GFX and Adafruit_ILI9341 libraries: Is there a way to tft.pushColor a BMP (or RAW image in my case) to the screen without first having to call the tft.fillScreen or tft.fillRect command? Or the question may be better phrased: What happens in the tft.fillScreen and tft.fillRect commands that allows a RAW image to be loaded? Any help would be appreciated.
Minimal.zip (353 KB)