NanoLux (Device) 3.0
Codebase for the open-source AudioLux device.
Loading...
Searching...
No Matches
nanolux_util.h
1#ifndef NANOLUX_UTIL_H
2#define NANOLUX_UTIL_H
3
4#include <AiEsp32RotaryEncoder.h>
5
6// Uncomment this macro if using the new hardware
7// with the rotary encoder.
8
9#define VERSION_2_HARDWARE
10
11void IRAM_ATTR buttonISR();
13int remap( double x,double oMin,double oMax,double nMin,double nMax );
14int largest(double arr[], int n);
15void IRAM_ATTR button_down();
16void IRAM_ATTR button_up();
17void begin_loop_timer(long ms);
18long timer_overrun();
19void bound_byte(uint8_t * val, int lower, int upper);
20void process_reset_button(int button_value);
21void nanolux_serial_print(char * msg);
22void IRAM_ATTR readEncoderISR();
26
27#endif
void IRAM_ATTR buttonISR()
A debounced interrupt to set the button state.
Definition nanolux_util.cpp:165
int remap(double x, double oMin, double oMax, double nMin, double nMax)
Remaps a value in one range to another range.
Definition nanolux_util.cpp:88
long timer_overrun()
Returns the amount of time since expected loop termination.
Definition nanolux_util.cpp:271
int calculate_pattern_index()
Calculates the pattern index the rotary encoder currently corresponds to.
Definition nanolux_util.cpp:299
void begin_loop_timer(long ms)
Logs the current program loop start time and the expected loop end time.
Definition nanolux_util.cpp:256
void bound_byte(uint8_t *val, int lower, int upper)
Bounds a byte between an upper and a lower value.
Definition nanolux_util.cpp:71
void nanolux_serial_print(char *msg)
Prints a character array message if allowed to.
Definition nanolux_util.cpp:61
bool isEncoderButtonPressed()
Returns the current state of the rotary encoder button.
Definition nanolux_util.cpp:305
int largest(double arr[], int n)
Returns the index of the largest array element.
Definition nanolux_util.cpp:132
void IRAM_ATTR readEncoderISR()
Processes the interrupt for the rotary encoder on 2.0 hardware.
Definition nanolux_util.cpp:284
void setup_rotary_encoder()
Performs initial setup for the rotary encoder.
Definition nanolux_util.cpp:289
void reset_button_state()
Resets the button state to false.
Definition nanolux_util.cpp:156
void process_reset_button(int button_value)
If the hardware button is held for RESET_TIME, clear the list of saves and call led_on_forever().
Definition nanolux_util.cpp:215