<commit_before>/*
 * LiquidMenu library - functions_menu.ino
 *
 * This example demonstrates how to attach functions to the
 * "lines" in the menu.
 *
 * Attaching functions to the different "lines" in the menu makes it
 * possible to execute an action while browsing the menu (e.g. dimming
 * an LED, adjusting preferences...). To attach a function to a line
 * you need to create with signature "void functionName(void)". After
 * creating it, the function is ready to be attached to a line. To do
 * that call bool LiquidLine::attach_function(uint8_t number, void (*function)(void)).
 * LiquidLine is the line object you wish to attach the function to,
 * number is the "id" of the function for that line, void (*function)(void)
 * is just the name of the function without the "()". The "id" of the function
 * makes possible attaching multiple functions to a single line. An example use
 * of multiple functions on a single line is for incrementing or decrementing
 * some value (e.g. dimming an LED). It is convenient to attach all the different
 * incrementing functions (e.g. increase_brightness(), increase_volume()) to the
 * different lines (e.g. LED brightness: 5, Sound volume: 10) using the same id
 * (e.g. 1). Same goes for the decrementing functions (e.g. LED brightness: 5 (line)
 * with attached function decrease_brightness() (function) with id 2,
 * Sound volume: 10 (line) with attached function decrease_volume() (function) with id 2).
 * Similar functions should be attached to their corresponding lines with the same "id",
 * because then they can be called from the same event (e.g. pressing button "UP"
 * calls the incrementing function of whatever the focused line is).
 * This example has a line that shows the current PWM of the LED and lines
 * that allow a fade or blink loop to be turned ON/OFF and configured.
 *
 * The circuit:
 * https://github.com/VasilKalchev/LiquidMenu/blob/master/examples/functions_menu/functions_menu.png
 * - LCD RS pin to Arduino pin 12
 * - LCD E pin to Arduino pin 11
 * - LCD D4 pin to Arduino pin 5
 * - LCD D5 pin to Arduino pin 4
 * - LCD D6 pin to Arduino pin 3
 * - LCD D7 pin to Arduino pin 2
 * - LCD R/W pin to ground
 * - LCD VSS pin to ground
 * - LCD VCC pin to 5V
 * - 10k ohm potentiometer: ends to 5V and ground, wiper to LCD V0
 * - 150 ohm resistor from 5V to LCD Anode
 * - LCD Cathode to ground
 * - ----
 * - Button (left) to Arduino pin A0 and ground
 * - Button (right) to Arduino pin 7 and ground
 * - Button (up) to Arduino pin 8 and ground
 * - Button (down) to Arduino pin 9 and ground
 * - Button (enter) to Arduino pin 10 and ground
 * - A PWM controlled device (LED...) to Arduino pin 6
 *
 * Created July 24, 2016
 * by <NAME>
 *
 * https://github.com/VasilKalchev/LiquidMenu
 *
 */

#include <LiquidCrystal.h>
#include <LiquidMenu.h>
#include "Button.h"

// // An array holding linearized 8bit PWM values.
// const uint8_t log_8bit[11] PROGMEM = {0, 1, 2, 3, 6, 12, 22, 40, 74, 138, 255};

// // PWM function using the above array.
// void PWM_log(uint8_t pin, uint8_t level) {
// 	analogWrite(pin, pgm_read_byte_near(log_8bit + level));
// }

// Pin mapping for the display
const byte LCD_RS = 12;
const byte LCD_E = 11;
const byte LCD_D4 = 5;
const byte LCD_D5 = 4;
const byte LCD_D6 = 3;
const byte LCD_D7 = 2;
//LCD R/W pin to ground
//10K potentiometer to VO
LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);

// This variable can be passed to the LiquidMenu object to set the starting screen.
const byte startingScreen = 2;

// Button objects instantiation
const bool pullup = true;
Button left(A0, pullup);
Button right(7, pullup);
Button up(8, pullup);
Button down(9, pullup);
Button enter(10, pullup);

/*
 * An enumerator can be used for the callback functions. It sets the number
 * for similar functions. Later when a function is attached it can be passed
 * with this enum rather than a magic number.
 */
// There are two types of functions for this example, one that increases some
// value and one that decreases it.
enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

// These are the pin definitions and variables for their PWM state.
const byte led = 6;
byte led_level = 0;

// Variables used for setting "preferences".
bool isFading = false;
char* isFading_text;
unsigned int fadePeriod = 100;
bool isBlinking = false;
char* isBlinking_text;
unsigned int blinkPeriod = 1000;
<commit_msg>Added comment before the Button class<commit_after>/*
 * LiquidMenu library - functions_menu.ino
 *
 * This example demonstrates how to attach functions to the
 * "lines" in the menu.
 *
 * Attaching functions to the different "lines" in the menu makes it
 * possible to execute an action through the menu (e.g. dimming an LED,
 * adjusting preferences...). To attach a function to a line you need
 * to create with signature "void functionName(void)". After creating it,
 * the function is ready to be attached to a line. To dothat call bool
 * LiquidLine::attach_function(uint8_t number, void (*function)(void)).
 * LiquidLine is the line object you wish to attach the function to,
 * number is the "id" of the function for that line, void (*function)(void)
 * is just the name of the function without the "()". The "id" of the function
 * makes possible attaching multiple functions to a single line. An example use
 * of multiple functions on a single line is for incrementing or decrementing
 * some value (e.g. dimming an LED). It is convenient to attach all the different
 * incrementing functions (e.g. increase_brightness(), increase_volume()) to the
 * different lines (e.g. LED brightness: 5, Sound volume: 10) using the same id
 * (e.g. 1). Same goes for the decrementing functions (e.g. LED brightness: 5 (line)
 * with attached function decrease_brightness() (function) with id 2,
 * Sound volume: 10 (line) with attached function decrease_volume() (function) with id 2).
 * Similar functions should be attached to their corresponding lines with the same "id",
 * because then they can be called from the same event (e.g. pressing button "UP"
 * calls the incrementing function of whatever the focused line is).
 * This example has a line that shows the current PWM of the LED and lines
 * that allow a fade or blink loop to be turned ON/OFF and configured.
 *
 * The circuit:
 * https://github.com/VasilKalchev/LiquidMenu/blob/master/examples/functions_menu/functions_menu.png
 * - LCD RS pin to Arduino pin 12
 * - LCD E pin to Arduino pin 11
 * - LCD D4 pin to Arduino pin 5
 * - LCD D5 pin to Arduino pin 4
 * - LCD D6 pin to Arduino pin 3
 * - LCD D7 pin to Arduino pin 2
 * - LCD R/W pin to ground
 * - LCD VSS pin to ground
 * - LCD VCC pin to 5V
 * - 10k ohm potentiometer: ends to 5V and ground, wiper to LCD V0
 * - 150 ohm resistor from 5V to LCD Anode
 * - LCD Cathode to ground
 * - ----
 * - Button (left) to Arduino pin A0 and ground
 * - Button (right) to Arduino pin 7 and ground
 * - Button (up) to Arduino pin 8 and ground
 * - Button (down) to Arduino pin 9 and ground
 * - Button (enter) to Arduino pin 10 and ground
 * - A PWM controlled device (LED...) to Arduino pin 6
 *
 * Created July 24, 2016
 * by <NAME>
 *
 * https://github.com/VasilKalchev/LiquidMenu
 *
 */

#include <LiquidCrystal.h>
#include <LiquidMenu.h>
#include "Button.h"

// Pin mapping for the display
const byte LCD_RS = 12;
const byte LCD_E = 11;
const byte LCD_D4 = 5;
const byte LCD_D5 = 4;
const byte LCD_D6 = 3;
const byte LCD_D7 = 2;
//LCD R/W pin to ground
//10K potentiometer wiper to VO
LiquidCrystal lcd(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7);

// This variable can be passed to the LiquidMenu object to set the starting screen.
const byte startingScreen = 2;

// Button objects instantiation
/*
 * The Button class is not a part of the LiquidMenu library. The first
 * parameter is the button's pin, the second enables or disables the
 * internal pullup resistor (not required) and the third is the debounce
 * time (not required).
 */
const bool pullup = true;
Button left(A0, pullup);
Button right(7, pullup);
Button up(8, pullup);
Button down(9, pullup);
Button enter(10, pullup);

/*
 * An enumerator can be used for the callback functions. It sets the number
 * for similar functions. Later when a function is attached it can be passed
 * with this enum rather than a magic number.
 */
// There are two types of functions for this example, one that increases some
// value and one that decreases it.
enum FunctionTypes {
	increase = 1,
	decrease = 2,
};

// These are the pin definitions and variables for their PWM state.
const byte led = 6;
byte led_level = 0;

// Variables used for setting "preferences".
bool isFading = false;
char* isFading_text;
unsigned int fadePeriod = 100;
bool isBlinking = false;
char* isBlinking_text;
unsigned int blinkPeriod = 1000;

{'fraction_non_alphanumeric': 0.08621667612024958, 'fraction_numerical': 0.021213840045377196, 'mean_word_length': 3.622968012585212, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '515915', 'n_tokens_mistral': 2893, 'n_tokens_neox': 2613, 'n_words': 1288}