diff --git a/README.md b/README.md index d1b4fc65..02196c74 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ and is automatically generated. Here is a quick summary of config variables: |`sensor_sensitivity`|Byte|128|Analog pressure prescaling. Adjust this until the pressure is ~60-70%| |`use_average_values`|Boolean|false|Use average values when calculating arousal. This smooths noisy data.| |`vibration_mode`|VibrationMode|RampStop|Vibration Mode for main vibrator control.| +|`use_post_orgasm`|Boolean|false|Use post-orgasm torture mode and functionality.| |`clench_pressure_sensitivity`|Int|200|Threshold over arousal to detect a clench : Lower values increase sensitivity| |`clench_threshold_2_orgasm`|Int|35|Threshold variable that is tick counts of clench to detect orgasm| |`clench_detector_in_edging`|Boolean|false|Use the clench detector to adjust Arousal| diff --git a/bin/config_lint.rb b/bin/config_lint.rb index 9a12bfbc..77dad068 100644 --- a/bin/config_lint.rb +++ b/bin/config_lint.rb @@ -65,8 +65,56 @@ def error(file, line, message, fixed) ### +help_file = <<-CC +// clang-format off + +/** + * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MANUALLY EDIT THIS FILE. + * + * Run config_lint.rb --fix to update this file. + */ + +#ifndef __assets__config_help_h +#define __assets__config_help_h + +#ifdef __cplusplus +extern "C" { +#endif + +#define INCLUDE_HELP 1 + +#ifdef INCLUDE_HELP +#define _HELPSTR(str) str +#else +#define _HELPSTR(str) NULL +#endif + +CC + $config_values.each do |cfg| - puts "#define #{cfg[:key].upcase}_HELP _HELPSTR(\"#{cfg[:note]}\")" + help_file << "#define #{cfg[:key].upcase}_HELP _HELPSTR(\"#{cfg[:note]}\")\n" +end + +help_file << <<-CC + +#ifdef __cplusplus +} +#endif + +#endif +CC + +help_file_path = File.join("include", "assets", "config_help.h"); +current_help = File.read(help_file_path) + +if help_file != current_help + if opts[:fix] + File.write(help_file_path, help_file) + else + puts "Help file mismatch, please run with --fix" + end + + error help_file_path, 0, "Help file mismatch.", opts[:fix] end ### diff --git a/include/assets/config_help.h b/include/assets/config_help.h index bbb58eb8..f341987d 100644 --- a/include/assets/config_help.h +++ b/include/assets/config_help.h @@ -1,5 +1,11 @@ // clang-format off +/** + * THIS FILE IS AUTOMATICALLY GENERATED. DO NOT MANUALLY EDIT THIS FILE. + * + * Run config_lint.rb --fix to update this file. + */ + #ifndef __assets__config_help_h #define __assets__config_help_h @@ -40,6 +46,7 @@ extern "C" { #define SENSOR_SENSITIVITY_HELP _HELPSTR("Analog pressure prescaling. Adjust this until the pressure is ~60-70%") #define USE_AVERAGE_VALUES_HELP _HELPSTR("Use average values when calculating arousal. This smooths noisy data.") #define VIBRATION_MODE_HELP _HELPSTR("Vibration Mode for main vibrator control.") +#define USE_POST_ORGASM_HELP _HELPSTR("Use post-orgasm torture mode and functionality.") #define CLENCH_PRESSURE_SENSITIVITY_HELP _HELPSTR("Threshold over arousal to detect a clench : Lower values increase sensitivity") #define CLENCH_THRESHOLD_2_ORGASM_HELP _HELPSTR("Threshold variable that is tick counts of clench to detect orgasm") #define CLENCH_DETECTOR_IN_EDGING_HELP _HELPSTR("Use the clench detector to adjust Arousal") diff --git a/include/config.h b/include/config.h index 7ca3c7a3..31b6ba1a 100644 --- a/include/config.h +++ b/include/config.h @@ -118,6 +118,8 @@ struct config { //= Post orgasm torure stuff + // Use post-orgasm torture mode and functionality. + bool use_post_orgasm; // Threshold over arousal to detect a clench : Lower values increase sensitivity int clench_pressure_sensitivity; // Duration the clench detector can raise arousal if clench detector turned on in edging session diff --git a/include/vibration_mode_controller.h b/include/vibration_mode_controller.h index 0dedc5df..9edff62e 100644 --- a/include/vibration_mode_controller.h +++ b/include/vibration_mode_controller.h @@ -29,8 +29,15 @@ typedef struct vibration_mode_controller { } vibration_mode_controller_t; // Helper Functions + +// Returns the increment per tick of a given span: +// increment_per_second = (target - start) / time_s +// increment_per_tick = increment_per_second / ticks_per_second +// #define calculate_increment(start, target, time_s) \ - ((time_s > 0) ? ((float)(target - start) / ((float)Config.update_frequency_hz)) : 0) + ((time_s > 0 && Config.update_frequency_hz > 0) \ + ? ((float)(target - start) / ((float)time_s)) / Config.update_frequency_hz \ + : 0) // Vibration Modes extern const vibration_mode_controller_t RampStopController; diff --git a/src/config.c b/src/config.c index 7b3bd350..bd5cfecb 100644 --- a/src/config.c +++ b/src/config.c @@ -52,6 +52,7 @@ CONFIG_DEFS { CFG_ENUM(vibration_mode, vibration_mode_t, RampStop); // Post-Orgasm Torture + CFG_BOOL(use_post_orgasm, false); CFG_NUMBER(clench_pressure_sensitivity, 200); CFG_NUMBER(clench_threshold_2_orgasm, 35); CFG_BOOL(clench_detector_in_edging, false); diff --git a/src/menus/orgasm_settings_menu.c b/src/menus/orgasm_settings_menu.c index 34d13fa6..12dae844 100644 --- a/src/menus/orgasm_settings_menu.c +++ b/src/menus/orgasm_settings_menu.c @@ -31,6 +31,11 @@ static const ui_input_numeric_t POST_ORGASM_DURATION_SECONDS_INPUT = { .input.help = POST_ORGASM_DURATION_SECONDS_HELP }; +static const ui_input_toggle_t USE_POST_ORGASM_INPUT = { + ToggleInputValues("Use Post Orgasm Mode", &Config.use_post_orgasm, on_config_save), + .input.help = USE_POST_ORGASM_HELP +}; + static const ui_input_toggle_t EDGE_MENU_LOCK_INPUT = { ToggleInputValues("Menu Lock - Edge", &Config.edge_menu_lock, on_config_save), .input.help = EDGE_MENU_LOCK_HELP @@ -57,6 +62,7 @@ static const ui_input_numeric_t CLENCH_PRESSURE_SENSITIVITY_INPUT = { static void on_open(const ui_menu_t* m, UI_MENU_ARG_TYPE arg) { ui_menu_add_input(m, (ui_input_t*)&EDGING_DURATION_INPUT); ui_menu_add_input(m, (ui_input_t*)&CLENCH_ORGASM_TIME_THRESHOLD_INPUT); + ui_menu_add_input(m, (ui_input_t*)&USE_POST_ORGASM_INPUT); ui_menu_add_input(m, (ui_input_t*)&POST_ORGASM_DURATION_SECONDS_INPUT); ui_menu_add_input(m, (ui_input_t*)&EDGE_MENU_LOCK_INPUT); ui_menu_add_input(m, (ui_input_t*)&POST_ORGASM_MENU_LOCK_INPUT); diff --git a/src/orgasm_control.c b/src/orgasm_control.c index 3b37d60a..854a94f5 100644 --- a/src/orgasm_control.c +++ b/src/orgasm_control.c @@ -394,7 +394,7 @@ oc_bool_t orgasm_control_isRecording() { void orgasm_control_tick() { unsigned long millis = esp_timer_get_time() / 1000UL; - unsigned long update_frequency_ms = (1.0f / Config.update_frequency_hz) * 1000.0f; + unsigned long update_frequency_ms = 1000UL / Config.update_frequency_hz; if (millis - arousal_state.last_update_ms > update_frequency_ms) { orgasm_control_updateArousal(); @@ -495,8 +495,17 @@ void orgasm_control_controlMotor(orgasm_output_mode_t control) { } void orgasm_control_set_output_mode(orgasm_output_mode_t control) { + orgasm_output_mode_t old = output_state.output_mode; output_state.output_mode = control; output_state.control_motor = control != OC_MANUAL_CONTROL; + + if (old == OC_MANUAL_CONTROL) { + const vibration_mode_controller_t* controller = orgasm_control_getVibrationMode(); + controller->start(); + } else if (control == OC_MANUAL_CONTROL) { + const vibration_mode_controller_t* controller = orgasm_control_getVibrationMode(); + controller->stop(); + } } void orgasm_control_pauseControl() { diff --git a/src/pages/edging_stats.c b/src/pages/edging_stats.c index ba6c5277..a647a8dd 100644 --- a/src/pages/edging_stats.c +++ b/src/pages/edging_stats.c @@ -70,10 +70,14 @@ static void _draw_buttons(u8g2_t* d, orgasm_output_mode_t mode) { if (orgasm_control_isMenuLocked()) { ui_draw_button_labels(d, btn1, _("LOCKED"), _("LOCKED")); ui_draw_button_disable(d, 0b011); - } else if (mode == OC_AUTOMAITC_CONTROL) { - ui_draw_button_labels(d, btn1, btn2, _("POST")); } else if (mode == OC_MANUAL_CONTROL) { ui_draw_button_labels(d, btn1, btn2, _("AUTO")); + } else if (mode == OC_AUTOMAITC_CONTROL) { + if (Config.use_post_orgasm == true) { + ui_draw_button_labels(d, btn1, btn2, _("POST")); + } else { + ui_draw_button_labels(d, btn1, btn2, _("MANUAL")); + } } else if (mode == OC_LOCKOUT_POST_MODE) { ui_draw_button_labels(d, btn1, btn2, _("MANUAL")); } @@ -93,10 +97,10 @@ static void _draw_status(u8g2_t* d, orgasm_output_mode_t mode) { static void _draw_meters(u8g2_t* d, orgasm_output_mode_t mode) { if (mode == OC_MANUAL_CONTROL) { - ui_draw_bar_graph(d, 10, 'M', eom_hal_get_motor_speed(), 255); + ui_draw_bar_graph(d, 10, 'S', eom_hal_get_motor_speed(), 255); } else { ui_draw_shaded_bar_graph( - d, 10, 'M', eom_hal_get_motor_speed(), 255, Config.motor_max_speed + d, 10, 'S', eom_hal_get_motor_speed(), 255, Config.motor_max_speed ); } @@ -246,7 +250,7 @@ on_button(eom_hal_button_t button, eom_hal_button_event_t event, void* arg) { } else if (button == EOM_HAL_BUTTON_MID) { if (locked) return NORENDER; - orgasm_control_controlMotor(OC_MANUAL_CONTROL); + orgasm_control_set_output_mode(OC_MANUAL_CONTROL); eom_hal_set_motor_speed(0x00); accessory_driver_broadcast_speed(0x00); bluetooth_driver_broadcast_speed(0x00); @@ -257,11 +261,15 @@ on_button(eom_hal_button_t button, eom_hal_button_event_t event, void* arg) { orgasm_output_mode_t mode = orgasm_control_get_output_mode(); if (mode == OC_MANUAL_CONTROL) { - orgasm_control_controlMotor(OC_AUTOMAITC_CONTROL); + orgasm_control_set_output_mode(OC_AUTOMAITC_CONTROL); } else if (mode == OC_AUTOMAITC_CONTROL) { - orgasm_control_controlMotor(OC_LOCKOUT_POST_MODE); + if (Config.use_post_orgasm == true) { + orgasm_control_set_output_mode(OC_LOCKOUT_POST_MODE); + } else { + orgasm_control_set_output_mode(OC_MANUAL_CONTROL); + } } else { - orgasm_control_controlMotor(OC_MANUAL_CONTROL); + orgasm_control_set_output_mode(OC_MANUAL_CONTROL); } } else { return PASS; diff --git a/src/vibration_modes/depletion_controller.c b/src/vibration_modes/depletion_controller.c index 70c29a3e..d34ca88b 100644 --- a/src/vibration_modes/depletion_controller.c +++ b/src/vibration_modes/depletion_controller.c @@ -18,8 +18,9 @@ static float start(void) { static float increment(void) { if (state.base_speed < Config.motor_max_speed) { - state.base_speed += calculate_increment(Config.motor_start_speed, Config.motor_max_speed, - Config.motor_ramp_time_s); + state.base_speed += calculate_increment( + Config.motor_start_speed, Config.motor_max_speed, Config.motor_ramp_time_s + ); } float alter_perc = ((float)state.arousal / Config.sensitivity_threshold); @@ -39,7 +40,9 @@ static void tick(float motor_speed, uint16_t arousal) { state.arousal = arousal; } -static float stop(void) { return 0; } +static float stop(void) { + return 0; +} const vibration_mode_controller_t DepletionController = { .start = start, diff --git a/src/vibration_modes/ramp_stop_controller.c b/src/vibration_modes/ramp_stop_controller.c index f8a80011..80ad2242 100644 --- a/src/vibration_modes/ramp_stop_controller.c +++ b/src/vibration_modes/ramp_stop_controller.c @@ -9,11 +9,15 @@ static struct { uint16_t arousal; } state; -static float start(void) { return Config.motor_start_speed; } +static float start(void) { + state.motor_speed = Config.motor_start_speed; + return Config.motor_start_speed; +} static float increment(void) { - float motor_increment = calculate_increment(Config.motor_start_speed, Config.motor_max_speed, - Config.motor_ramp_time_s); + float motor_increment = calculate_increment( + Config.motor_start_speed, Config.motor_max_speed, Config.motor_ramp_time_s + ); if (state.motor_speed < (Config.motor_max_speed - motor_increment)) { return state.motor_speed + motor_increment; @@ -27,7 +31,10 @@ static void tick(float motor_speed, uint16_t arousal) { state.arousal = arousal; } -static float stop(void) { return 0.0f; } +static float stop(void) { + state.motor_speed = 0.0f; + return 0.0f; +} const vibration_mode_controller_t RampStopController = { .start = start,