Skip to content

Commit

Permalink
Basic IR remote configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dspverden committed May 16, 2020
1 parent d4bd718 commit 2c50d9b
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 2 deletions.
85 changes: 83 additions & 2 deletions SOURCES/WEBAPP/ESP32/aurora/aurora.ino
Expand Up @@ -20,6 +20,10 @@
#include "rotaryencoder.h"
#endif

#if HAVE_IRRECEIVER
#include <IRremote.h>
#endif

#define VERSION_STR "v2.1.0"

#define MAX_NUM_INPUTS 8
Expand Down Expand Up @@ -223,6 +227,15 @@ long int lastREval = 0;
long int lastREsw = 0;
#endif

//------------------------------------------------------------------------------
//
// IR Receiver
//
//------------------------------------------------------------------------------
#if HAVE_IRRECEIVER
IRrecv irReceiver( IR_RECEIVER_PIN );
#endif

int editMode = 0;


Expand Down Expand Up @@ -4016,12 +4029,12 @@ void setup()
//----------------------------------------------------------------------------
//--- Upload program to DSP
//----------------------------------------------------------------------------
//uploadDspFirmware();
uploadDspFirmware();

//----------------------------------------------------------------------------
//--- Upload user parameters to DSP
//----------------------------------------------------------------------------
//uploadUserParams();
uploadUserParams();

//----------------------------------------------------------------------------
//--- Configure Webserver
Expand Down Expand Up @@ -4205,6 +4218,13 @@ void setup()
lastREval = rotaryEncoder.getRotationValue();
#endif

//----------------------------------------------------------------------------
//--- Init IR Receiver
//----------------------------------------------------------------------------
#if HAVE_IRRECEIVER
irReceiver.enableIRIn();
#endif

resetDAC( false );

updateUI();
Expand Down Expand Up @@ -4297,6 +4317,67 @@ void loop()
}
#endif

#if HAVE_IRRECEIVER
decode_results irResults;
if( irReceiver.decode( &irResults ) )
{
if( irResults.value == APPLE_REMOTE_UP )
{
masterVolume.val += 0.5f;
if( masterVolume.val > 0.f )
masterVolume.val = 0.f;
setMasterVolume();
needUpdateUI = true;
}
else if( irResults.value == APPLE_REMOTE_DOWN )
{
masterVolume.val -= 0.5f;
if( masterVolume.val <= -80.f )
masterVolume.val = -80.f;
setMasterVolume();
needUpdateUI = true;
}
else if( irResults.value == APPLE_REMOTE_LEFT )
{
myDisplay.drawSwitchingPreset();

if( currentPreset == 0 )
currentPreset = MAX_NUM_PRESETS - 1;
else
currentPreset--;

softMuteDAC();
delay(500);
initUserParams();
uploadUserParams();
updateAddOn();
softUnmuteDAC();

needUpdateUI = true;
}
else if( irResults.value == APPLE_REMOTE_RIGHT )
{
myDisplay.drawSwitchingPreset();

currentPreset++;
if( currentPreset >= MAX_NUM_PRESETS )
currentPreset = 0;

softMuteDAC();
delay(500);
initUserParams();
uploadUserParams();
updateAddOn();
softUnmuteDAC();

needUpdateUI = true;
}
//else
// Serial.println(irResults.value, HEX);
irReceiver.resume();
}
#endif

if( needUpdateUI )
{
updateUI();
Expand Down
15 changes: 15 additions & 0 deletions SOURCES/WEBAPP/ESP32/aurora/hwconfig.h
Expand Up @@ -26,4 +26,19 @@
#define ROTARYENCODER_PINB 19 // CLK Pin
#define ROTARYENCODER_PINSW 18 // SW Pin

// KY-022 IR Receiver Module
#define HAVE_IRRECEIVER (1)
#define IR_RECEIVER_PIN 5

#define APPLE_REMOTE_UP 0x77E1D047
#define APPLE_REMOTE_DOWN 0x77E1B047
#define APPLE_REMOTE_LEFT 0x77E11047
#define APPLE_REMOTE_RIGHT 0x77E1E047
#define APPLE_REMOTE_CENTER_DOWN 0x77E1BA47
#define APPLE_REMOTE_CENTER_UP 0x77E12047
#define APPLE_REMOTE_MENU 0x77E14047
#define APPLE_REMOTE_PLAY_DOWN 0x77E17A47
#define APPLE_REMOTE_PLAY_UP 0x77E12047


#endif

0 comments on commit 2c50d9b

Please sign in to comment.