/* * adc.c: reacting when you fiddle with buttons, switches, and knobs * * mode switch: modes are changed only when the button is not being * pushed, as button being pushed negates the mode switch response. * for the mode to change, the mode switch must be in the new position * without wavering for at least 3 rounds. this will prevent the * mode from changing by someone fucking around with the button or * when the button is used normally. * * button: is connected to mode switch ADC. if below threshold, then * we can be certain button is pushed. we still wait a debounce * round to ensure button is pushed. our code can fire events on * either button being held or button being released. the actual * push event does not do anything with this code. * * settings knobs: these are used by the settings module which works * with the other modules and the button for setting user settings. * the values are scaled from the ADC value, with bounds being set * on the low and high ends and further scaled for usability. * please read the manual if you want to know what settings do. * * file creation: 20231015 0122 */ #include #define MODE_CONT 0 #define MODE_CONT_TARGET 0x46d #define MODE_FUN 1 #define MODE_FUN_TARGET 0xa2b #define MODE_DIODE 2 #define MODE_DIODE_TARGET 0xf80 #define MODE_HYSTERESIS 20 #define MODE_ANALOG_MIN 0x80 uint8_t modesw; uint8_t modesw_next; uint8_t modesw_count; uint8_t knob[2]; uint8_t btn = 0; uint16_t btn_held = 0; void userio_parse() { }