MausTec / edge-o-matic-3000

Firmware for the Edge-o-Matic 3000
GNU General Public License v3.0
103 stars 29 forks source link

major fix of clench in your new version change post orgasm from ticks to ms #54

Closed B4ben-69 closed 9 months ago

B4ben-69 commented 10 months ago

This fixes a major problem where the clench detector was coupled with the orgasm detector. I created a new variable that is accessible in the config.json but is not in the the menus to not add clutter.

Fixed the post orgasm mode to just work in your new version

B4ben-69 commented 10 months ago

description of the major bug: when clench_threshold_2_orgasm was set to high, the clench detector would stop working. This needed a separate variable.

modified the variables from tick to ms. Since 1 tick equaled 30ms, i multiplied the default values by 30. also created new variables to make sure old systems would not use the tick values when upgrading the fimware.

MauAbata commented 9 months ago

👀 I'll have some commits here in a bit for you to merge in to fix the build issue, but also I'm adding versioning and migrations to the config file, so with a template you can create a migration code to change that value instead of having to make a new one. I'll post again here when that's done, with a sample migration you can put in for this change.

MauAbata commented 9 months ago

Alright, upstream changes (#57 ) will allow for a cleaner migration on that config file. I like having the unit in the name, so you can add in this migration to preserve the user's old value, and then in the code clean out all the uses of the old config entry since it's no longer needed.

In src/config/system/migrate.c you can add:

// this is just an example, review before pasting.
migration_result_t migrate_to_2(cJSON* root) {
    cJSON* old = cJSON_GetObjectItem(root, "clench_threshold_2_orgasm");
    if (old == NULL) return MIGRATION_COMPLETE;

    int value_ms = old->valueint * 60; // i think this was the tick rate?
    cJSON* new = cJSON_AddNumberToObject(root, "clench_time_to_orgasm_ms", value_ms);

    if (new == NULL) return MIGRATION_ERR_BAD_DATA;
    cJSON_DeleteItemFromObject(root, "clench_threshold_2_orgasm");

    return MIGRATION_COMPLETE;
}

I would also prefer if we spelled it "to" orgasm not "2" orgasm, that kinda always bothered me 😰

Hopefully with these migrations we can keep the config struct a bit cleaner. This will become important later when we migrate entirely to grouped configuration/user profiles vs. system config.