-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
61 lines (50 loc) · 1.31 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <Arduino.h>
#include <EEPROM.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "input.h"
#include "lcd.h"
#include "setting.h"
#include "midi.h"
#include "serial.h"
#include "shiftRegister.h"
// set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// pinout:
// Shift register:
// latch:9 data:7 clock:8
// buttons:
// up:15 down:14 left:20 right:16 reset:17 volume:22
// lcd (i2c):
// sda:18 scl:19
extern const bool DEBUG_MODE = false;
int ledPin = 13;
void setup() {
if (DEBUG_MODE) Serial.begin(38400);
pinMode(ledPin, OUTPUT);
usbMIDI.setHandleNoteOff(onNoteOff);
usbMIDI.setHandleNoteOn(onNoteOn);
usbMIDI.setHandleControlChange(onControlChange);
initializeSettings();
initializeInputs();
initializeLCD();
printHomeScreen();
intitializeRegisters();
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
if (DEBUG_MODE) Serial.println("Ready");
}
void loop() {
checkForInput();
checkDisplay();
checkForMidiUSB();
checkSchedule();
if (DEBUG_MODE) checkSerial();
// handle reset
if (millis() >= nextReset) {
if (DEBUG_MODE) Serial.printf("[%u] Resetting\n", millis());
resetNotes();
nextReset = millis() + Setting::autoReset * 1000;
}
}