Move all the LED things to a separate file, as mentioned in comments
This commit is contained in:
parent
3903ec7b98
commit
3ae4147d7e
7 changed files with 76 additions and 56 deletions
|
@ -11,6 +11,7 @@
|
|||
#include "menu.h"
|
||||
#include "config.h"
|
||||
#include "settings.h"
|
||||
#include "led.h"
|
||||
|
||||
/*
|
||||
NAME: NuEVI
|
||||
|
@ -233,9 +234,6 @@ byte slurSustain = 0;
|
|||
byte parallelChord = 0;
|
||||
byte subOctaveDouble = 0;
|
||||
|
||||
const int breathLedBrightness = 500; // up to 4095, PWM
|
||||
const int portamLedBrightness = 500; // up to 4095, PWM
|
||||
|
||||
Adafruit_MPR121 touchSensor = Adafruit_MPR121(); // This is the 12-input touch sensor
|
||||
FilterOnePole breathFilter;
|
||||
|
||||
|
@ -291,7 +289,7 @@ void setup() {
|
|||
vibZero += touchRead(vibratoPin);
|
||||
breathCalZero += analogRead(breathSensorPin);
|
||||
if (biteJumper) vibZeroBite += analogRead(A7); else vibZeroBite += touchRead(bitePin);
|
||||
digitalWrite( statusLedPin, i&1 );
|
||||
statusLed(i&1);
|
||||
delay(fastBoot?75:250); //Shorter delay for fastboot
|
||||
}
|
||||
|
||||
|
@ -687,7 +685,7 @@ void loop() {
|
|||
} else {
|
||||
if (slowMidi) breath();
|
||||
extraController();
|
||||
statusLEDs();
|
||||
updateSensorLEDs();
|
||||
doorKnobCheck();
|
||||
}
|
||||
ccSendTime = millis();
|
||||
|
@ -778,23 +776,6 @@ int patchLimit(int value) {
|
|||
|
||||
//**************************************************************
|
||||
|
||||
void statusLEDs() {
|
||||
if (breathLevel > breathThrVal) { // breath indicator LED, labeled "B" on PCB
|
||||
//analogWrite(bLedPin, map(breathLevel,0,4096,5,breathLedBrightness));
|
||||
analogWrite(bLedPin, map(constrain(breathLevel, breathThrVal, breathMaxVal), breathThrVal, breathMaxVal, 5, breathLedBrightness));
|
||||
} else {
|
||||
analogWrite(bLedPin, 0);
|
||||
}
|
||||
if (portIsOn) { // portamento indicator LED, labeled "P" on PCB
|
||||
//analogWrite(pLedPin, map(biteSensor,0,4096,5,portamLedBrightness));
|
||||
analogWrite(pLedPin, map(constrain(oldport, 0, 127), 0, 127, 5, portamLedBrightness));
|
||||
} else {
|
||||
analogWrite(pLedPin, 0);
|
||||
}
|
||||
}
|
||||
|
||||
//**************************************************************
|
||||
|
||||
void breath() {
|
||||
int breathCCval, breathCCvalFine,breathCC2val;
|
||||
unsigned int breathCCvalHires;
|
||||
|
@ -1170,24 +1151,3 @@ void readSwitches() {
|
|||
}
|
||||
lastFingering = fingeredNoteRead;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void statusLedOn() {
|
||||
digitalWrite(statusLedPin, HIGH);
|
||||
}
|
||||
|
||||
void statusLedOff() {
|
||||
digitalWrite(statusLedPin, LOW);
|
||||
}
|
||||
|
||||
void statusLedFlip() {
|
||||
digitalWrite(statusLedPin, !digitalRead(statusLedPin));
|
||||
}
|
||||
|
||||
void statusLedFlash(uint16_t delayTime) {
|
||||
statusLedOff();
|
||||
delay(delayTime/2);
|
||||
statusLedOn();
|
||||
delay(delayTime/2);
|
||||
}
|
||||
|
|
|
@ -30,4 +30,9 @@
|
|||
#define ttouchHiLimit 1900
|
||||
|
||||
|
||||
#define MIN_LED_BRIGHTNESS 5 // lowest PWM value that still is visible
|
||||
#define BREATH_LED_BRIGHTNESS 500 // up to 4095, PWM
|
||||
#define PORTAM_LED_BRIGHTNESS 500 // up to 4095, PWM
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -116,6 +116,10 @@ extern int vibZeroBite;
|
|||
extern int vibThrBite;
|
||||
extern int vibThrBiteLo;
|
||||
|
||||
extern int breathLevel;
|
||||
extern byte portIsOn;
|
||||
extern int oldport;
|
||||
|
||||
// Key variables, TRUE (1) for pressed, FALSE (0) for not pressed
|
||||
extern byte K1; // Valve 1 (pitch change -2)
|
||||
extern byte K2; // Valve 2 (pitch change -1)
|
||||
|
|
48
NuEVI/led.cpp
Normal file
48
NuEVI/led.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include <Arduino.h>
|
||||
#include "hardware.h"
|
||||
#include "globals.h"
|
||||
#include "config.h"
|
||||
|
||||
// Do things with status LED.
|
||||
void statusLedOn() {
|
||||
digitalWrite(statusLedPin, HIGH);
|
||||
}
|
||||
|
||||
void statusLedOff() {
|
||||
digitalWrite(statusLedPin, LOW);
|
||||
}
|
||||
|
||||
void statusLed(bool state) {
|
||||
digitalWrite(statusLedPin, state);
|
||||
}
|
||||
|
||||
void statusLedFlip() {
|
||||
digitalWrite(statusLedPin, !digitalRead(statusLedPin));
|
||||
}
|
||||
|
||||
void statusLedFlash(uint16_t delayTime) {
|
||||
statusLedOff();
|
||||
delay(delayTime/2);
|
||||
statusLedOn();
|
||||
delay(delayTime/2);
|
||||
}
|
||||
|
||||
void statusLedBlink() {
|
||||
statusLedFlash(300);
|
||||
statusLedFlash(300);
|
||||
}
|
||||
|
||||
void updateSensorLEDs() {
|
||||
if (breathLevel > breathThrVal) { // breath indicator LED, labeled "B" on PCB
|
||||
//analogWrite(bLedPin, map(breathLevel,0,4096,5,breathLedBrightness));
|
||||
analogWrite(bLedPin, map(constrain(breathLevel, breathThrVal, breathMaxVal), breathThrVal, breathMaxVal, MIN_LED_BRIGHTNESS, BREATH_LED_BRIGHTNESS));
|
||||
} else {
|
||||
analogWrite(bLedPin, 0);
|
||||
}
|
||||
if (portIsOn) { // portamento indicator LED, labeled "P" on PCB
|
||||
//analogWrite(pLedPin, map(biteSensor,0,4096,5,portamLedBrightness));
|
||||
analogWrite(pLedPin, map(constrain(oldport, 0, 127), 0, 127, MIN_LED_BRIGHTNESS, PORTAM_LED_BRIGHTNESS));
|
||||
} else {
|
||||
analogWrite(pLedPin, 0);
|
||||
}
|
||||
}
|
12
NuEVI/led.h
Normal file
12
NuEVI/led.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef __LED_H
|
||||
#define __LED_H
|
||||
|
||||
void statusLedOn();
|
||||
void statusLedOff();
|
||||
void statusLedFlip();
|
||||
void statusLed(bool state);
|
||||
void statusLedFlash(uint16_t delayTime);
|
||||
void statusLedBlink();
|
||||
void updateSensorLEDs();
|
||||
|
||||
#endif
|
|
@ -10,6 +10,7 @@
|
|||
#include "globals.h"
|
||||
#include "midi.h"
|
||||
#include "numenu.h"
|
||||
#include "led.h"
|
||||
|
||||
enum CursorIdx {
|
||||
EMain,
|
||||
|
@ -1228,17 +1229,6 @@ static bool updatePage(const MenuPage *page, KeyState &input, uint32_t timeNow)
|
|||
return redraw;
|
||||
}
|
||||
|
||||
//***********************************************************
|
||||
// This should be moved to a separate file/process that handles only led
|
||||
static void statusBlink() {
|
||||
digitalWrite(statusLedPin,LOW);
|
||||
delay(150);
|
||||
digitalWrite(statusLedPin,HIGH);
|
||||
delay(150);
|
||||
digitalWrite(statusLedPin,LOW);
|
||||
delay(150);
|
||||
digitalWrite(statusLedPin,HIGH);
|
||||
}
|
||||
|
||||
//***********************************************************
|
||||
|
||||
|
@ -1391,12 +1381,12 @@ static bool idlePageUpdate(KeyState& __unused input, uint32_t __unused timeNow)
|
|||
legacyBrAct = !legacyBrAct;
|
||||
dipSwBits = dipSwBits ^ (1<<2);
|
||||
writeSetting(DIPSW_BITS_ADDR,dipSwBits);
|
||||
statusBlink();
|
||||
statusLedBlink();
|
||||
} else if ((exSensor >= ((extracThrVal+extracMaxVal)/2))) { // switch pb pad activated legacy settings control on/off
|
||||
legacy = !legacy;
|
||||
dipSwBits = dipSwBits ^ (1<<1);
|
||||
writeSetting(DIPSW_BITS_ADDR,dipSwBits);
|
||||
statusBlink();
|
||||
statusLedBlink();
|
||||
} else if (pinkyKey && !specialKey){ //hold pinky key for rotator menu, and if too high touch sensing blocks regular menu, touching special key helps
|
||||
display.ssd1306_command(SSD1306_DISPLAYON);
|
||||
menuState= ROTATOR_MENU;
|
||||
|
|
|
@ -30,6 +30,7 @@ CXXFILES= ../NuEVI/menu.cpp \
|
|||
../NuEVI/adjustmenu.cpp \
|
||||
../NuEVI/midi.cpp \
|
||||
../NuEVI/settings.cpp \
|
||||
../NuEVI/led.cpp \
|
||||
src/nuevisim.cpp \
|
||||
src/simeeprom.cpp \
|
||||
src/Print.cpp \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue