diff --git a/.vscode/settings.json b/.vscode/settings.json index 724841c..1be854f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,5 @@ { "files.associations": { - "cmath": "cpp", - "__locale": "cpp", - "string": "cpp", - "string_view": "cpp" + "cmath": "cpp" } } \ No newline at end of file diff --git a/main/main.ino b/main/main.ino index 2b14852..1b9bea6 100644 --- a/main/main.ino +++ b/main/main.ino @@ -16,7 +16,6 @@ #include "ext_analysis.h" #include "storage.h" #include "globals.h" -#include "AiEsp32RotaryEncoder.h" FASTLED_USING_NAMESPACE @@ -76,8 +75,6 @@ uint8_t manual_pattern_idx = 0; /// Contains if manual control is enabled or not. volatile bool manual_control_enabled = false; -uint8_t rotary_encoder_pattern_idx = 0; - /// History of all currently-running patterns. Strip_Buffer histories[PATTERN_LIMIT]; @@ -94,8 +91,6 @@ extern Pattern mainPatterns[]; #include "api.h" #endif -AiEsp32RotaryEncoder rotaryEncoder = AiEsp32RotaryEncoder(ROTARY_ENCODER_A_PIN, ROTARY_ENCODER_B_PIN, ROTARY_ENCODER_BUTTON_PIN, ROTARY_ENCODER_VCC_PIN, ROTARY_ENCODER_STEPS); - void setup(); void loop(); void audio_analysis(); @@ -112,21 +107,6 @@ void setup() { Serial.begin(115200); while (!Serial) { ; } - //Initialize rotary encoder - rotaryEncoder.begin(); - rotaryEncoder.setup(readEncoderISR); - bool circleValues = true; - rotaryEncoder.setBoundaries(0, 12, circleValues); //minValue, maxValue, circleValues true|false (when max go to min and vice versa) - - /*Rotary acceleration introduced 25.2.2021. - in case range to select is huge, for example - select a value between 0 and 1000 and we want 785 - without accelerateion you need long time to get to that number - Using acceleration, faster you turn, faster will the value raise. - For fine tuning slow down. - */ - //rotaryEncoder.disableAcceleration(); //acceleration is now enabled by default - disable if you dont need it - rotaryEncoder.setAcceleration(250); //or set the value - larger number = more accelearation; 0 or 1 means disabled acceleration - // Reindex mainPatterns, to make sure it is consistent. for (int i = 0; i < NUM_PATTERNS; i++) { mainPatterns[i].index = i; @@ -379,8 +359,6 @@ void print_buffer(CRGB *buf, uint8_t len) { /// LED strip. void loop() { begin_loop_timer(config.loop_ms); // Begin timing this loop - rotary_loop(); - delay(50); // Reset buffers if pattern settings were changed since // last program loop. diff --git a/main/nanolux_types.h b/main/nanolux_types.h index 36d2c80..43852a2 100755 --- a/main/nanolux_types.h +++ b/main/nanolux_types.h @@ -57,13 +57,6 @@ typedef void (*SimplePatternList[])(); // Button Input #define BUTTON_PIN 33 -// Rotary Encoder -#define ROTARY_ENCODER_A_PIN 23 -#define ROTARY_ENCODER_B_PIN 22 -#define ROTARY_ENCODER_BUTTON_PIN 33 -#define ROTARY_ENCODER_VCC_PIN -1 -#define ROTARY_ENCODER_STEPS 4 - // MAX - MIN | Freq Volume #define MAX_FREQUENCY 4000.0 #define MIN_FREQUENCY 50.0 diff --git a/main/nanolux_util.cpp b/main/nanolux_util.cpp index aef56b9..133f06c 100755 --- a/main/nanolux_util.cpp +++ b/main/nanolux_util.cpp @@ -15,7 +15,6 @@ #include "nanolux_types.h" #include "nanolux_util.h" #include "storage.h" -#include "AiEsp32RotaryEncoder.h" /// The current config of the device, defined in main.ino. /// Used to check if serial printing is allowed. @@ -35,9 +34,6 @@ long loop_start_time = 0; /// Holds the expected end time of the current program loop. long loop_end_time = 0; -extern uint8_t rotary_encoder_pattern_idx; -extern AiEsp32RotaryEncoder rotaryEncoder; - /************************************************ * @@ -270,31 +266,3 @@ long timer_overrun(){ // the expected loop end time. return (millis() < loop_end_time) ? 0 : millis() - loop_end_time + 1; } - -void rotary_onButtonClick() { - static unsigned long lastTimePressed = 0; // Soft debouncing - if (millis() - lastTimePressed < 500){ - return; - } - lastTimePressed = millis(); - Serial.print("button pressed "); - Serial.print(millis()); - Serial.println(" milliseconds after restart"); -} - -void rotary_loop() { - //dont print anything unless value changed - if (rotaryEncoder.encoderChanged()){ - Serial.print("Value: "); - rotary_encoder_pattern_idx = rotaryEncoder.readEncoder(); - Serial.println(rotaryEncoder.readEncoder()); - nextPattern(); - } - if (rotaryEncoder.isEncoderButtonClicked()) { - rotary_onButtonClick(); - } -} - -void IRAM_ATTR readEncoderISR() { - rotaryEncoder.readEncoder_ISR(); -} \ No newline at end of file diff --git a/main/nanolux_util.h b/main/nanolux_util.h index fa629a8..945c593 100755 --- a/main/nanolux_util.h +++ b/main/nanolux_util.h @@ -13,8 +13,4 @@ void bound_byte(uint8_t * val, int lower, int upper); void process_reset_button(); void nanolux_serial_print(char * msg); -// Rotary encoder codes -void rotary_onButtonClick(); -void rotary_loop(); -void IRAM_ATTR readEncoderISR(); #endif \ No newline at end of file