Splitting the validator into multiple files.
This commit is contained in:
parent
347e55bf32
commit
39a9c3eb2d
|
|
@ -3,44 +3,24 @@
|
|||
#include <MIDI.h>
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
#include "midi_ValidatorLCD.h"
|
||||
#include "midi_ValidatorLEDs.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define LCD_D4 8
|
||||
#define LCD_D5 9
|
||||
#define LCD_D6 10
|
||||
#define LCD_D7 11
|
||||
#define LCD_RS 12
|
||||
#define LCD_EN 13
|
||||
|
||||
#define LED_PASS 4
|
||||
#define LED_FAIL 5
|
||||
|
||||
#define NUM_TESTS 1
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
byte progressChar[6][8] =
|
||||
{
|
||||
{ B00000, B00000, B00000, B00000, B00000, B00000, B00000, B00000 },
|
||||
{ B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000 },
|
||||
{ B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000 },
|
||||
{ B11100, B11100, B11100, B11100, B11100, B11100, B11100, B11100 },
|
||||
{ B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110 },
|
||||
{ B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 },
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
SoftwareSerial softSerial(2, 3);
|
||||
|
||||
MIDI_CREATE_INSTANCE(HardwareSerial, Serial, midiHW);
|
||||
MIDI_CREATE_INSTANCE(SoftwareSerial, softSerial, midiSW);
|
||||
// \todo Create instance for USB if available
|
||||
|
||||
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
BEGIN_MIDI_NAMESPACE
|
||||
|
||||
template<class SerialClass>
|
||||
|
|
@ -153,7 +133,7 @@ END_MIDI_NAMESPACE
|
|||
|
||||
midi::MidiTester<HardwareSerial> testerHW(midiHW);
|
||||
midi::MidiTester<SoftwareSerial> testerSW(midiSW);
|
||||
|
||||
*/
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
template<class SerialClass>
|
||||
|
|
@ -163,20 +143,7 @@ void setupMidiInstance(midi::MidiInterface<SerialClass>& inInstance)
|
|||
inInstance.turnThruOff();
|
||||
}
|
||||
|
||||
void setupLCD()
|
||||
{
|
||||
for (byte i = 0; i < 6; ++i)
|
||||
lcd.createChar(i, progressChar[i]);
|
||||
|
||||
lcd.begin(16,2);
|
||||
}
|
||||
|
||||
void setupLEDs()
|
||||
{
|
||||
pinMode(LED_PASS, OUTPUT);
|
||||
pinMode(LED_FAIL, OUTPUT);
|
||||
}
|
||||
|
||||
/*
|
||||
template<class SerialClass>
|
||||
void setupTester(midi::MidiTester<SerialClass>& inTester)
|
||||
{
|
||||
|
|
@ -188,53 +155,7 @@ void setupTesters()
|
|||
setupTester<HardwareSerial>(testerHW);
|
||||
setupTester<SoftwareSerial>(testerSW);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setProgressBar(unsigned inProgress, unsigned inTotal)
|
||||
{
|
||||
const byte numCols = 16;
|
||||
const byte numPix = 5;
|
||||
const unsigned progress = (inProgress * numCols* numPix) / inTotal;
|
||||
const byte cursorX = progress / numPix;
|
||||
const byte charIndex = progress % numPix;
|
||||
|
||||
lcd.setCursor(cursorX, 1);
|
||||
lcd.write(charIndex);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
inline void blinkLed(byte inLedNum)
|
||||
{
|
||||
digitalWrite(inLedNum, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(inLedNum, LOW);
|
||||
}
|
||||
|
||||
inline void blinkPass()
|
||||
{
|
||||
blinkLed(LED_PASS);
|
||||
}
|
||||
|
||||
inline void blinkFail()
|
||||
{
|
||||
blinkLed(LED_FAIL);
|
||||
}
|
||||
|
||||
inline void setLedsFinal(bool inSuccess)
|
||||
{
|
||||
if (inSuccess)
|
||||
{
|
||||
digitalWrite(LED_PASS, HIGH);
|
||||
digitalWrite(LED_FAIL, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(LED_FAIL, HIGH);
|
||||
digitalWrite(LED_PASS, LOW);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -244,13 +165,13 @@ void setup()
|
|||
setupMidiInstance<SoftwareSerial>(midiSW);
|
||||
setupLCD();
|
||||
setupLEDs();
|
||||
setupTesters();
|
||||
//setupTesters();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void loop()
|
||||
{
|
||||
testerHW.runTests();
|
||||
testerSW.runTests();
|
||||
//testerHW.runTests();
|
||||
//testerSW.runTests();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
#pragma once
|
||||
#include <LiquidCrystal.h>
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
extern LiquidCrystal lcd;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setupLCD();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setProgressBar(unsigned inProgress, unsigned inTotal);
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
#include "midi_ValidatorLCD.h"
|
||||
|
||||
#define LCD_D4 8
|
||||
#define LCD_D5 9
|
||||
#define LCD_D6 10
|
||||
#define LCD_D7 11
|
||||
#define LCD_RS 12
|
||||
#define LCD_EN 13
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
byte progressChar[6][8] =
|
||||
{
|
||||
{ B00000, B00000, B00000, B00000, B00000, B00000, B00000, B00000 },
|
||||
{ B10000, B10000, B10000, B10000, B10000, B10000, B10000, B10000 },
|
||||
{ B11000, B11000, B11000, B11000, B11000, B11000, B11000, B11000 },
|
||||
{ B11100, B11100, B11100, B11100, B11100, B11100, B11100, B11100 },
|
||||
{ B11110, B11110, B11110, B11110, B11110, B11110, B11110, B11110 },
|
||||
{ B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 },
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);
|
||||
|
||||
void setupLCD()
|
||||
{
|
||||
for (byte i = 0; i < 6; ++i)
|
||||
lcd.createChar(i, progressChar[i]);
|
||||
|
||||
lcd.begin(16,2);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setProgressBar(unsigned inProgress, unsigned inTotal)
|
||||
{
|
||||
const byte numCols = 16;
|
||||
const byte numPix = 5;
|
||||
const unsigned progress = (inProgress * numCols* numPix) / inTotal;
|
||||
const byte cursorX = progress / numPix;
|
||||
const byte charIndex = progress % numPix;
|
||||
|
||||
lcd.setCursor(cursorX, 1);
|
||||
lcd.write(charIndex);
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
|
||||
#define LED_PASS 4
|
||||
#define LED_FAIL 5
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setupLEDs();
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
inline void blinkLed(byte inLedNum)
|
||||
{
|
||||
digitalWrite(inLedNum, HIGH);
|
||||
delay(100);
|
||||
digitalWrite(inLedNum, LOW);
|
||||
}
|
||||
|
||||
inline void blinkPass()
|
||||
{
|
||||
blinkLed(LED_PASS);
|
||||
}
|
||||
|
||||
inline void blinkFail()
|
||||
{
|
||||
blinkLed(LED_FAIL);
|
||||
}
|
||||
|
||||
inline void setLedsFinal(bool inSuccess)
|
||||
{
|
||||
if (inSuccess)
|
||||
{
|
||||
digitalWrite(LED_PASS, HIGH);
|
||||
digitalWrite(LED_FAIL, LOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
digitalWrite(LED_FAIL, HIGH);
|
||||
digitalWrite(LED_PASS, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#include "midi_ValidatorLEDs.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void setupLEDs()
|
||||
{
|
||||
pinMode(LED_PASS, OUTPUT);
|
||||
pinMode(LED_FAIL, OUTPUT);
|
||||
}
|
||||
Loading…
Reference in New Issue