Skip to content

Commit

Permalink
Fix automatic restart issue, made post orgasm optional again.
Browse files Browse the repository at this point in the history
  • Loading branch information
MauAbata committed May 2, 2023
1 parent 5be8a96 commit 58bf1c3
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 18 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
50 changes: 49 additions & 1 deletion bin/config_lint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

###
Expand Down
7 changes: 7 additions & 0 deletions include/assets/config_help.h
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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")
Expand Down
2 changes: 2 additions & 0 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion include/vibration_mode_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/menus/orgasm_settings_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
Expand Down
11 changes: 10 additions & 1 deletion src/orgasm_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down
24 changes: 16 additions & 8 deletions src/pages/edging_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand All @@ -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
);
}

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
9 changes: 6 additions & 3 deletions src/vibration_modes/depletion_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand Down
15 changes: 11 additions & 4 deletions src/vibration_modes/ramp_stop_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down

0 comments on commit 58bf1c3

Please sign in to comment.