Cleaned up some of the DUE/Mega conditions; shuffled around sd card code a little bit
This commit is contained in:
parent
ee83891f34
commit
bdf9408a5d
|
@ -14,10 +14,11 @@
|
||||||
#ifndef Project_h
|
#ifndef Project_h
|
||||||
#define Project_h
|
#define Project_h
|
||||||
|
|
||||||
#define DEBUG 2 // NONE = 0; MINIMAL = 1; FULL = 2;
|
#define DEBUG 1 // NONE = 0; MINIMAL = 1; FULL = 2;
|
||||||
|
|
||||||
// Whether or not the Arduino Mega 2560 is used as the base board
|
// Whether or not the Arduino DUE is used as the base board
|
||||||
#define ARD_MEGA_2560 true
|
// Assume Mega 2560 otherwise
|
||||||
|
#define ARD_DUE false
|
||||||
|
|
||||||
// Buttons / Joystick / Input Hardware Pinouts
|
// Buttons / Joystick / Input Hardware Pinouts
|
||||||
#define okButtonPin 22
|
#define okButtonPin 22
|
||||||
|
@ -57,22 +58,23 @@
|
||||||
// Don't change anything below here
|
// Don't change anything below here
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Global SD card so LCD / config can read/write files
|
||||||
extern SdFat sd;
|
extern SdFat sd;
|
||||||
|
|
||||||
#define FONT_WIDTH 6
|
#define FONT_WIDTH 6
|
||||||
#define FONT_HEIGHT 8
|
#define FONT_HEIGHT 8
|
||||||
|
|
||||||
// Serial ports
|
// Serial ports
|
||||||
#if ARD_MEGA_2560
|
#if ARD_DUE
|
||||||
extern SerialPort<0, 512, 512> serialPort0;
|
|
||||||
extern SerialPort<1, 512, 512> serialPort1;
|
|
||||||
extern SerialPort<2, 512, 512> serialPort2;
|
|
||||||
extern SerialPort<3, 512, 512> serialPort3;
|
|
||||||
#else
|
|
||||||
extern SerialPort<0, 4096, 4096> serialPort0;
|
extern SerialPort<0, 4096, 4096> serialPort0;
|
||||||
extern SerialPort<1, 4096, 4096> serialPort1;
|
extern SerialPort<1, 4096, 4096> serialPort1;
|
||||||
extern SerialPort<2, 4096, 4096> serialPort2;
|
extern SerialPort<2, 4096, 4096> serialPort2;
|
||||||
extern SerialPort<3, 4096, 4096> serialPort3;
|
extern SerialPort<3, 4096, 4096> serialPort3;
|
||||||
|
#else
|
||||||
|
extern SerialPort<0, 512, 512> serialPort0;
|
||||||
|
extern SerialPort<1, 512, 512> serialPort1;
|
||||||
|
extern SerialPort<2, 512, 512> serialPort2;
|
||||||
|
extern SerialPort<3, 512, 512> serialPort3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Serial modes supported
|
// Serial modes supported
|
||||||
|
|
|
@ -480,7 +480,6 @@ void UILCD::bmpDraw(char *filename, uint8_t x, uint8_t y) {
|
||||||
serialPort0.println("UILCD::bmpDraw()");
|
serialPort0.println("UILCD::bmpDraw()");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SdFat sd;
|
|
||||||
SdFile bmpFile;
|
SdFile bmpFile;
|
||||||
int bmpWidth, bmpHeight; // W+H in pixels
|
int bmpWidth, bmpHeight; // W+H in pixels
|
||||||
uint8_t bmpDepth; // Bit depth (currently must be 24)
|
uint8_t bmpDepth; // Bit depth (currently must be 24)
|
||||||
|
@ -498,13 +497,6 @@ void UILCD::bmpDraw(char *filename, uint8_t x, uint8_t y) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
serialPort0.println("Starting SD card");
|
|
||||||
// Start the SD Card -- FIXME: This should likely get moved to config
|
|
||||||
if (!sd.begin(SD_CS, SPI_PROJECT_SPEED )) {
|
|
||||||
serialPort0.println("SD.begin(SD_CS, SPI_HALF_SPEED ) -- failed!");
|
|
||||||
sd.initErrorHalt();
|
|
||||||
}
|
|
||||||
|
|
||||||
#if DEBUG >= 1
|
#if DEBUG >= 1
|
||||||
serialPort0.println();
|
serialPort0.println();
|
||||||
serialPort0.print("Loading image '");
|
serialPort0.print("Loading image '");
|
||||||
|
|
|
@ -28,20 +28,23 @@
|
||||||
#include <Metro.h>
|
#include <Metro.h>
|
||||||
#include "RTClib.h"
|
#include "RTClib.h"
|
||||||
|
|
||||||
|
// Globals used by main classes
|
||||||
UI* ui;
|
UI* ui;
|
||||||
Config* config;
|
Config* config;
|
||||||
RTC_DS1307 rtc;
|
RTC_DS1307 rtc;
|
||||||
//SdFile dataFile;
|
SdFile dataFile;
|
||||||
#if ARD_MEGA_2560
|
SdFat sd;
|
||||||
SerialPort<0, 512, 512> serialPort0;
|
|
||||||
SerialPort<1, 512, 512> serialPort1;
|
#if ARD_DUE
|
||||||
SerialPort<2, 512, 512> serialPort2;
|
|
||||||
SerialPort<3, 512, 512> serialPort3;
|
|
||||||
#else
|
|
||||||
SerialPort<0, 4096, 4096> serialPort0;
|
SerialPort<0, 4096, 4096> serialPort0;
|
||||||
SerialPort<1, 4096, 4096> serialPort1;
|
SerialPort<1, 4096, 4096> serialPort1;
|
||||||
SerialPort<2, 4096, 4096> serialPort2;
|
SerialPort<2, 4096, 4096> serialPort2;
|
||||||
SerialPort<3, 4096, 4096> serialPort3;
|
SerialPort<3, 4096, 4096> serialPort3;
|
||||||
|
#else
|
||||||
|
SerialPort<0, 512, 512> serialPort0;
|
||||||
|
SerialPort<1, 512, 512> serialPort1;
|
||||||
|
SerialPort<2, 512, 512> serialPort2;
|
||||||
|
SerialPort<3, 512, 512> serialPort3;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// helper for interrupt method call
|
// helper for interrupt method call
|
||||||
|
@ -54,6 +57,14 @@ void setup() {
|
||||||
serialPort0.begin(115200);
|
serialPort0.begin(115200);
|
||||||
Wire.begin();
|
Wire.begin();
|
||||||
|
|
||||||
|
// Start the SD Card -- This should come very early
|
||||||
|
// Not in config to guarantee it comes online very very early
|
||||||
|
serialPort0.println("Starting SD card");
|
||||||
|
if (!sd.begin(SD_CS, SPI_PROJECT_SPEED )) {
|
||||||
|
serialPort0.println("SD.begin(SD_CS, SPI_SPEED ) -- failed!");
|
||||||
|
sd.initErrorHalt();
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure RTC is set to run on battery
|
// Ensure RTC is set to run on battery
|
||||||
// clear /EOSC bit
|
// clear /EOSC bit
|
||||||
// Sometimes necessary to ensure that the clock
|
// Sometimes necessary to ensure that the clock
|
||||||
|
|
Reference in a new issue