Skip to content

Commit 088f2dd

Browse files
committed
Minor docs changes, removal of old functions
1 parent 1e0cf9a commit 088f2dd

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

main/main.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ extern Pattern mainPatterns[];
8181
volatile bool manual_control_enabled = false;
8282
Strip_Buffer manual_strip_buffer;
8383
Pattern_Data manual_pattern;
84+
85+
/// Stores the last state of the rotary encoder button.
8486
bool lastEncoderBtnPressed = false;
8587

8688
/**********************************************************
@@ -210,6 +212,11 @@ void unfold_buffer(CRGB* buf, uint8_t len, bool even){
210212
}
211213
}
212214

215+
/// @brief Runs a specified pattern and performs postprocessing effects on it.
216+
///
217+
/// @param p The pattern to run.
218+
/// @param buf The buffer to read/write to/from.
219+
/// @param len How many pixels this pattern can run on.
213220
void process_pattern(Pattern_Data * p, Strip_Buffer * buf, uint8_t len){
214221

215222
// Pull the current postprocessing effects from the struct integer.
@@ -239,7 +246,6 @@ void process_pattern(Pattern_Data * p, Strip_Buffer * buf, uint8_t len){
239246
unfold_buffer(buf->leds, processed_len, (len == processed_len * 2));
240247
}
241248

242-
243249
/// @brief Runs the strip splitting LED strip mode
244250
///
245251
/// This function allocates a number of LEDs per pattern, then

main/nanolux_util.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ long loop_start_time = 0;
3939
/// Holds the expected end time of the current program loop.
4040
long loop_end_time = 0;
4141

42+
/// Defines the rotary encoder object for the 2.0 boards
43+
AiEsp32RotaryEncoder rotaryEncoder = AiEsp32RotaryEncoder(
44+
ROTARY_ENCODER_A_PIN,
45+
ROTARY_ENCODER_B_PIN,
46+
ROTARY_ENCODER_BUTTON_PIN,
47+
ROTARY_ENCODER_VCC_PIN,
48+
ROTARY_ENCODER_STEPS
49+
);
50+
4251
/************************************************
4352
*
4453
* HELPERS:
@@ -271,28 +280,28 @@ long timer_overrun(){
271280
return (millis() < loop_end_time) ? 0 : millis() - loop_end_time + 1;
272281
}
273282

274-
AiEsp32RotaryEncoder rotaryEncoder = AiEsp32RotaryEncoder(ROTARY_ENCODER_A_PIN, ROTARY_ENCODER_B_PIN, ROTARY_ENCODER_BUTTON_PIN, ROTARY_ENCODER_VCC_PIN, ROTARY_ENCODER_STEPS);
275-
283+
/// @brief Processes the interrupt for the rotary encoder on 2.0 hardware
276284
void IRAM_ATTR readEncoderISR(){
277285
rotaryEncoder.readEncoder_ISR();
278286
}
279287

288+
/// @brief Performs initial setup for the rotary encoder
280289
void setup_rotary_encoder(){
281290
rotaryEncoder.begin();
282291
rotaryEncoder.setup(readEncoderISR);
283292
rotaryEncoder.setBoundaries(0, 1000, true); //minValue, maxValue, circleValues true|false (when max go to min and vice versa)
284293
rotaryEncoder.setAcceleration(250);
285294
}
286-
int calculate_pattern_index(){
287-
int index = static_cast<int>(floor(rotaryEncoder.readEncoder() / ROTARY_ENCODER_STEPS)) % NUM_PATTERNS;
288295

289-
return index;
296+
/// @brief Calculates the pattern index the rotary encoder currently
297+
/// corresponds to.
298+
/// @returns The pattern index the encoder is set to.
299+
int calculate_pattern_index(){
300+
return static_cast<int>(floor(rotaryEncoder.readEncoder() / ROTARY_ENCODER_STEPS)) % NUM_PATTERNS;
290301
}
291302

303+
/// @brief Returns the current state of the rotary encoder button.
304+
/// @returns True if pressed, false if not.
292305
bool isEncoderButtonPressed(){
293306
return rotaryEncoder.isEncoderButtonClicked();
294-
}
295-
296-
bool isEncoderBtnDown() {
297-
return rotaryEncoder.isEncoderButtonDown();
298307
}

main/nanolux_util.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ long timer_overrun();
1919
void bound_byte(uint8_t * val, int lower, int upper);
2020
void process_reset_button(int button_value);
2121
void nanolux_serial_print(char * msg);
22-
2322
void IRAM_ATTR readEncoderISR();
2423
void setup_rotary_encoder();
2524
int calculate_pattern_index();
2625
bool isEncoderButtonPressed();
27-
bool isEncoderBtnDown();
28-
2926

3027
#endif

0 commit comments

Comments
 (0)