-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenericOutputGenerator.cpp
More file actions
45 lines (39 loc) · 1.26 KB
/
GenericOutputGenerator.cpp
File metadata and controls
45 lines (39 loc) · 1.26 KB
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
//
// Created by me on 26/04/2023.
//
#include "GenericOutputGenerator.h"
#include "PilotCore.h"
GenericOutputGenerator::GenericOutputGenerator(AnalogInputs input, PilotCore *pilotCore) : BaseOutputGenerator(pilotCore) {
this->input = input;
}
GenericOutputGenerator::~GenericOutputGenerator() {
}
void GenericOutputGenerator::loop() {
if(getCore()->getAnalogChanged(input)) {
int voltageValue = getCore()->getAnalog(input);
send(voltageValue);
}
}
void GenericOutputGenerator::send(int voltageValue) {
switch(outputType) {
case OutputType::OUTPUT_TYPE_CC:
SendCC(outputAddress, voltageValue);
break;
case OutputType::OUTPUT_TYPE_NRPN:
SendNRPN(outputAddress, voltageValue);
break;
case OutputType::OUTPUT_TYPE_PITCH_BEND:
SendPitchBend(voltageValue);
break;
case OutputType::OUTPUT_TYPE_SERIAL:
Serial.print("Input ");
Serial.print(input);
Serial.print(" value: ");
Serial.println(voltageValue);
}
}
GenericOutputGenerator* GenericOutputGenerator::setOutput(OutputType outputType, int outputAddress) {
this->outputType = outputType;
this->outputAddress = outputAddress;
return this;
}