Display Class for BaseMachine
Diff: ST7565_SequencerDisplay.h
- Revision:
- 0:9a0f67fe026b
- Child:
- 1:1f6d3e65d946
diff -r 000000000000 -r 9a0f67fe026b ST7565_SequencerDisplay.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ST7565_SequencerDisplay.h Fri Aug 12 20:42:30 2016 +0000 @@ -0,0 +1,81 @@ +/* + * ST7565_SequencerDisplay.h + * + * 2016.08.13 + * + */ +#ifndef _ST7565_SEQUENCE_DISPLAY_H_ +#define _ST7565_SEQUENCE_DISPLAY_H_ + +#include "mbed.h" +#include "SequencerDisplay.h" +#include "st7565LCD.h" + +class ST7565_SequencerDisplay : public SequencerDisplay { +public: + ST7565_SequencerDisplay(ST7565* _gLCD, Sequence* _sequences, int _sequenceNum) : + SequencerDisplay(_sequences, _sequenceNum), + gLCD(_gLCD) {}; + +protected: + virtual void displayWhileRun(int step) { + int x, y; + int i; + + gLCD->clear(); + + // Pos Indicator Grid + for (x = 0; x <= 16; x++) { + gLCD->drawline(x * 7, 0, x * 7, 3, 1); + } + for (y = 0; y <= 1; y++) { + gLCD->drawline(0, y * 3, 112, y * 3, 1); + } + + gLCD->fillrect(step * 7, 0, 7, 3, 1); + + // Sequence Grid + for (x = 0; x <= 16; x++) { + gLCD->drawline(x * 7, 5, x * 7, 57, 1); + } + for (y = 0; y <= 13; y++) { + gLCD->drawline(0, y * 4 + 5, 112, y * 4 + 5, 1); + } + + for (i = 0; i < 16; i++) { + if (this->getOctave() == sequences[i].getOctave()) { + gLCD->fillrect(i * 7, sequences[i].getPitch() * 4 + 5, 7, 4, 1); + } + } + + // NoteOn & Tie Grid + for (x = 0; x <= 16; x++) { + gLCD->drawline(x * 7, 57, x * 7, 63, 1); + } + gLCD->drawline(0, 63, 112, 63, 1); + + for (i = 0; i < 16; i++) { + if (sequences[i].noteOn) { + if (sequences[i].accent && sequences[i].tie) { + gLCD->fillrect(i * 7, 57, 7, 6, 1); + } else { + gLCD->fillrect(i * 7, 59, 5, 4, 1); + if (sequences[i].accent) { + gLCD->fillrect(i * 7, 57, 5, 4, 1); + } + if (sequences[i].tie) { + gLCD->fillrect(i * 7 + 5, 59, 2, 4, 1); + } + } + } + } + + gLCD->display(); + }; + +private: + ST7565* gLCD; + +}; + +#endif //ST7565_SEQUENCE_DISPLAY_H_