Display Class for BaseMachine

Committer:
ryood
Date:
Fri Aug 12 20:42:30 2016 +0000
Revision:
0:9a0f67fe026b
Child:
1:1f6d3e65d946
first commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ryood 0:9a0f67fe026b 1 /*
ryood 0:9a0f67fe026b 2 * ST7565_SequencerDisplay.h
ryood 0:9a0f67fe026b 3 *
ryood 0:9a0f67fe026b 4 * 2016.08.13
ryood 0:9a0f67fe026b 5 *
ryood 0:9a0f67fe026b 6 */
ryood 0:9a0f67fe026b 7 #ifndef _ST7565_SEQUENCE_DISPLAY_H_
ryood 0:9a0f67fe026b 8 #define _ST7565_SEQUENCE_DISPLAY_H_
ryood 0:9a0f67fe026b 9
ryood 0:9a0f67fe026b 10 #include "mbed.h"
ryood 0:9a0f67fe026b 11 #include "SequencerDisplay.h"
ryood 0:9a0f67fe026b 12 #include "st7565LCD.h"
ryood 0:9a0f67fe026b 13
ryood 0:9a0f67fe026b 14 class ST7565_SequencerDisplay : public SequencerDisplay {
ryood 0:9a0f67fe026b 15 public:
ryood 0:9a0f67fe026b 16 ST7565_SequencerDisplay(ST7565* _gLCD, Sequence* _sequences, int _sequenceNum) :
ryood 0:9a0f67fe026b 17 SequencerDisplay(_sequences, _sequenceNum),
ryood 0:9a0f67fe026b 18 gLCD(_gLCD) {};
ryood 0:9a0f67fe026b 19
ryood 0:9a0f67fe026b 20 protected:
ryood 0:9a0f67fe026b 21 virtual void displayWhileRun(int step) {
ryood 0:9a0f67fe026b 22 int x, y;
ryood 0:9a0f67fe026b 23 int i;
ryood 0:9a0f67fe026b 24
ryood 0:9a0f67fe026b 25 gLCD->clear();
ryood 0:9a0f67fe026b 26
ryood 0:9a0f67fe026b 27 // Pos Indicator Grid
ryood 0:9a0f67fe026b 28 for (x = 0; x <= 16; x++) {
ryood 0:9a0f67fe026b 29 gLCD->drawline(x * 7, 0, x * 7, 3, 1);
ryood 0:9a0f67fe026b 30 }
ryood 0:9a0f67fe026b 31 for (y = 0; y <= 1; y++) {
ryood 0:9a0f67fe026b 32 gLCD->drawline(0, y * 3, 112, y * 3, 1);
ryood 0:9a0f67fe026b 33 }
ryood 0:9a0f67fe026b 34
ryood 0:9a0f67fe026b 35 gLCD->fillrect(step * 7, 0, 7, 3, 1);
ryood 0:9a0f67fe026b 36
ryood 0:9a0f67fe026b 37 // Sequence Grid
ryood 0:9a0f67fe026b 38 for (x = 0; x <= 16; x++) {
ryood 0:9a0f67fe026b 39 gLCD->drawline(x * 7, 5, x * 7, 57, 1);
ryood 0:9a0f67fe026b 40 }
ryood 0:9a0f67fe026b 41 for (y = 0; y <= 13; y++) {
ryood 0:9a0f67fe026b 42 gLCD->drawline(0, y * 4 + 5, 112, y * 4 + 5, 1);
ryood 0:9a0f67fe026b 43 }
ryood 0:9a0f67fe026b 44
ryood 0:9a0f67fe026b 45 for (i = 0; i < 16; i++) {
ryood 0:9a0f67fe026b 46 if (this->getOctave() == sequences[i].getOctave()) {
ryood 0:9a0f67fe026b 47 gLCD->fillrect(i * 7, sequences[i].getPitch() * 4 + 5, 7, 4, 1);
ryood 0:9a0f67fe026b 48 }
ryood 0:9a0f67fe026b 49 }
ryood 0:9a0f67fe026b 50
ryood 0:9a0f67fe026b 51 // NoteOn & Tie Grid
ryood 0:9a0f67fe026b 52 for (x = 0; x <= 16; x++) {
ryood 0:9a0f67fe026b 53 gLCD->drawline(x * 7, 57, x * 7, 63, 1);
ryood 0:9a0f67fe026b 54 }
ryood 0:9a0f67fe026b 55 gLCD->drawline(0, 63, 112, 63, 1);
ryood 0:9a0f67fe026b 56
ryood 0:9a0f67fe026b 57 for (i = 0; i < 16; i++) {
ryood 0:9a0f67fe026b 58 if (sequences[i].noteOn) {
ryood 0:9a0f67fe026b 59 if (sequences[i].accent && sequences[i].tie) {
ryood 0:9a0f67fe026b 60 gLCD->fillrect(i * 7, 57, 7, 6, 1);
ryood 0:9a0f67fe026b 61 } else {
ryood 0:9a0f67fe026b 62 gLCD->fillrect(i * 7, 59, 5, 4, 1);
ryood 0:9a0f67fe026b 63 if (sequences[i].accent) {
ryood 0:9a0f67fe026b 64 gLCD->fillrect(i * 7, 57, 5, 4, 1);
ryood 0:9a0f67fe026b 65 }
ryood 0:9a0f67fe026b 66 if (sequences[i].tie) {
ryood 0:9a0f67fe026b 67 gLCD->fillrect(i * 7 + 5, 59, 2, 4, 1);
ryood 0:9a0f67fe026b 68 }
ryood 0:9a0f67fe026b 69 }
ryood 0:9a0f67fe026b 70 }
ryood 0:9a0f67fe026b 71 }
ryood 0:9a0f67fe026b 72
ryood 0:9a0f67fe026b 73 gLCD->display();
ryood 0:9a0f67fe026b 74 };
ryood 0:9a0f67fe026b 75
ryood 0:9a0f67fe026b 76 private:
ryood 0:9a0f67fe026b 77 ST7565* gLCD;
ryood 0:9a0f67fe026b 78
ryood 0:9a0f67fe026b 79 };
ryood 0:9a0f67fe026b 80
ryood 0:9a0f67fe026b 81 #endif //ST7565_SEQUENCE_DISPLAY_H_