qmk_firmware/drivers/haptic/solenoid.h
Purdea Andrei c904520f72
Haptic and solenoid cleanup (#9700)
* solenoid: remove two functions that do nothing.

These functions modify the argument, and so they do nothing.

Note: versions of these functions exist in mtdjr's user folder,
however to core solenoid support and mtdjr user-specific solenoid
support are exclusive (only one can be used at a time).

So removing these confusing functions does no harm.

* solenoid: bugfix: don't allow dwell time to go 1ms below minimum time.

The previous code allowed dwell time to go 1ms below the configured minimum.
This change corrects it.

* solenoid: bugfix: when incrementing above maximum dwell time, jump back to minimum, not to 1

The previous code used to jump back to 1, which might be way under the configured minimum setting.

* solenoid: bugfix: on startup actually use the eeprom-stored dwell-time

This is because the dwell time is stored in two variables.

* solenoid: bugfix: on haptic_reset, actually use the newly set default dwell time.

This is needed because dwell time is configured in two variables.

* solenoid: on HPT_RST set buzz to a default value

* solenoid: buzz: reworked to make more configurable. Previous behaviour maintained.

* solenoid: documentation: clarify meaning of dwell time

* solenoid: add feature SOLENOID_DWELL_STEP_SIZE

* solenoid: documentation: added note about the precision of the solenoid time settings

* haptic: Correctly call haptic_reset when eeprom is corrupt.

* haptic: improve what happens if haptic is enabled without erasing eeprom

* haptic: improve what happens if solenoid is enabled without erasing eeprom

* drivers/haptic: fix compilation issue, when haptic is enabled, but solenoid isn't
2020-10-30 13:15:50 -07:00

64 lines
1.6 KiB
C

/* Copyright 2018 mtdjr - modified by ishtob
* Driver for solenoid written for QMK
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#ifndef SOLENOID_DEFAULT_DWELL
# define SOLENOID_DEFAULT_DWELL 12
#endif
#ifndef SOLENOID_MAX_DWELL
# define SOLENOID_MAX_DWELL 100
#endif
#ifndef SOLENOID_MIN_DWELL
# define SOLENOID_MIN_DWELL 4
#endif
#ifndef SOLENOID_DWELL_STEP_SIZE
# define SOLENOID_DWELL_STEP_SIZE 1
#endif
#ifndef SOLENOID_DEFAULT_BUZZ
# define SOLENOID_DEFAULT_BUZZ 0
#endif
#ifndef SOLENOID_BUZZ_ACTUATED
# define SOLENOID_BUZZ_ACTUATED SOLENOID_MIN_DWELL
#endif
#ifndef SOLENOID_BUZZ_NONACTUATED
# define SOLENOID_BUZZ_NONACTUATED SOLENOID_MIN_DWELL
#endif
#ifndef SOLENOID_PIN
# error SOLENOID_PIN not defined
#endif
void solenoid_buzz_on(void);
void solenoid_buzz_off(void);
void solenoid_set_buzz(int buzz);
void solenoid_set_dwell(uint8_t dwell);
void solenoid_stop(void);
void solenoid_fire(void);
void solenoid_check(void);
void solenoid_setup(void);
void solenoid_shutdown(void);