Commit Graph

105 Commits

Author SHA1 Message Date
zhiayang cc3d5529fd
feat(drivers): Driver for MAX7318 GPIO expander (#1295)
Add driver for max7318 i2c gpio expander

Co-authored-by: Pete Johanson <peter@peterjohanson.com>
2022-09-29 21:22:01 -04:00
Peter Johanson 9782518397 feature(drivers): Option for read wait on matrix.
* Add a new Kconfig option, `ZMK_KSCAN_MATRIX_WAIT_BEFORE_INPUTS`
  to delay reading inputs after setting an output active.
2022-09-29 01:06:54 -04:00
Peter Johanson e3efffa9a8 refactor(display): Move clear to unblank for EPD driver. 2022-07-26 14:12:38 -04:00
Peter Johanson 08c43feaaf feat(kscan): Kconfig for optional scan delay.
Add optional Kconfig setting to delay scanning after each
output column is set, and inputs are read, to allow inputs
to "settle" after the last column is set back to inactive.
2022-07-15 11:07:08 -04:00
Peter Johanson b5e73204e8 fix(drivers): Avoid build failures for GPIO driver
* Avoid defining the ZMK GPIO drivers lib if none of the drivers  are
  selected.
2022-06-05 17:57:35 -04:00
Peter Johanson 6a86cd0547 feat(gpio): Add 595 shift register driver.
* Use SPI for sending serial data.
* Supports 1-4 shift registers chained together by
  setting `ngios` property appropriately.
2022-06-03 22:45:04 -04:00
Kurtis Lew 0bde987ae2 Update kscan_gpio_get_extra_flags 2022-05-19 11:24:01 -04:00
Kurtis Lew 6f1adfbe14 Address further review by @petejohanson 2022-05-19 11:24:01 -04:00
Kurtis Lew 4dfcadb1ed Remove unnecessary LOG_DBG 2022-05-19 11:24:01 -04:00
Kurtis Lew fec99c7d5e Update kscan_direct_gpio.c
- Fix logic in getting pulls from ACTIVE_LOW vs. ACTIVE_HIGH DT flags
- Add pulls on init
2022-05-19 11:24:01 -04:00
Kurtis Lew f39c821d19 Simplify kscan_gpio_get_flags
Co-authored-by: Pete Johanson <peter@peterjohanson.com>
2022-05-19 11:24:01 -04:00
Kurtis Lew f369f2cc46 feat(kscan): Add toggle-mode to updated direct-wire kscan 2022-05-19 11:24:01 -04:00
Joel Spadin 0738b4b2b0 refactor(kscan): Match direct GPIO driver to matrix driver
Rewrote the direct GPIO kscan driver to match the improvements made to
the matrix driver in 82cb762698 and
f946dc6893. It now uses the same
debouncing system as the matrix driver.
2022-05-17 01:20:20 -04:00
Joel Spadin 11ab52582c refactor(battery): Auto enable battery drivers
CONFIG_ZMK_BATTERY_NRF_VDDH and CONFIG_ZMK_BATTERY_VOLTAGE_DIVIDER are
now automatically enabled if a DT node with the matching "compatible"
property is present and enabled, so they no longer need to be manually
set for each board.
2022-04-25 22:34:04 -04:00
Joel Spadin 6d6efa32f5 refactor(kscan): Auto enable kscan drivers
The key scanning drivers are now automatically enabled when a DT node
with the matching "compatible" property is present and enabled, so they
no longer need to be manually set for each board.
2022-04-25 22:28:53 -04:00
Joel Spadin a3a9510e47 refactor(kscan): Use GPIO DT spec macros in matrix driver 2022-04-25 22:28:53 -04:00
Peter Johanson 4df83a9c0d refactor: Move away from deprecated PM callback. 2022-04-03 00:10:29 -04:00
Peter Johanson 3528e1b497 refactor: Move to newer API for IO channels.
See: https://docs.zephyrproject.org/latest/releases/release-notes-2.6.html#api-changes
2022-04-03 00:10:29 -04:00
Peter Johanson 53dae35710 refactor: Move to `k_work_delayable` API.
* Move to new `k_work_delayable` APIs introduced in Zephyr 2.6.

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.6.html#api-changes
2022-04-03 00:10:29 -04:00
Joel Spadin f946dc6893 feat(kscan): Improve matrix debouncing
Switched the GPIO matrix driver to debouncing using a simple integrator
algorithm. Whenever a key is pressed, we now scan at a rate controlled
by debounce-scan-period-ms (default 1 ms) until all keys are released,
then return to either waiting for an interrupt or polling more slowly.

The timers for key press and release can now be controlled separately,
so debounce-period is deprecated in favor of debounce-press-ms and
debounce-release-ms. Global Kconfig options
ZMK_KSCAN_DEBOUNCE_PRESS_MS and ZMK_KSCAN_DEBOUNCE_RELEASE_MS are also
added to make these easier to set.

Added documentation for debouncing options.
2021-10-26 23:52:13 -04:00
Pete Johanson c9a671d8d5 fix(kscan): Allow composite driver to handle missing children.
For split keyboards using an IO expander over TRRS/i2c, if the
right half isn't connected, we should be able to gracefully
fallback to the left side still working.
2021-09-14 20:48:28 -04:00
Pete Johanson 647110e5e5 feat(drivers): Add mcp23017 driver based on upstream mcp23s17 one.
* Upstream Zephyr has in progress driver, so doing this locally here,
  until we can move over to that driver.
2021-09-14 20:48:28 -04:00
Joel Spadin 82cb762698 refactor(kscan): Demacroify GPIO matrix driver
Refactored the GPIO matrix kscan driver so that only the data and config
structures are defined in the foreach macro. Functionality is unchanged
except for the addition of DT properties to adjust polling speed.

This should make it easier to add other enhancements later, like
improved and customizable debounce behavior.
2021-09-08 14:34:28 -04:00
Darryldh a124eb9f9e feat(display): IL0323 driver for EPD displays.
* Basic driver, using the GD7965 driver as a basis, since the ICs
  are very similar.
2021-08-24 22:15:42 -04:00
Joel Spadin a6de43e665 feat: Add nrf VDDH battery driver
Added a driver which uses the nRF52's ADC channel on the VDDH pin to
read the battery voltage when using high voltage mode.
2021-07-24 23:39:13 -05:00
Pete Johanson 2a69f31eb0 refactor(core): Move away from deprecated DT API.
* Move to `DEVICE_DT_INST_DEFINE` everywhere.

See: https://docs.zephyrproject.org/2.5.0/releases/release-notes-2.5.html#deprecated-in-this-release
PR: https://github.com/zmkfirmware/zmk/pull/736
2021-07-17 17:04:25 -04:00
Jay Greco f3bb90f9e1
fix(kscan): Fix nibble demux scan errors on encoder row
+ Add a 1us sleep to let the column selection settle in order to avoid spurious keypresses when row capacitance is high (like on the encoder row)
2021-06-08 20:59:35 -04:00
Pete Johanson 27c89e69c1 fix(kscan): Proper direct wire warning message. 2021-03-15 00:39:29 -04:00
Okke Formsma c01243d1c6 fix(logging): remove unnecessary newline 2021-03-10 18:08:22 -05:00
Pete Johanson 0f9fff7554 Fix the label for the GPIO kscan driver. 2021-02-27 14:32:42 -05:00
jrhrsmit e40ca1eb7c
fix(power): Add support for capacitors on ADC for BVD
Add a little delay so any capacitors connected to the ADC for the BVD can charge up when using power_gpios

Co-authored-by: Jasper Smit <jrhrsmit@gmail.com>
2021-02-04 07:56:27 -05:00
Pete Johanson 6c7ab0ce53 refactor(kscan): Fix polling of GPIO matrices.
* Add easier macros for conditional polling/interrupt code.
* Properly continue polling on intervals, without extra
  enable/disable code for pins that is superfluous when not trying to
  deal with interupts firing.
* Fix to allow multiple GPIO drivers when doing splits w/ IO expanders
2021-02-02 14:04:10 -05:00
Pete Johanson 2f352788c1 refactor(kscan): Remove explicit default n from kscan configs.
* Actually allow defaulting yes in other places.
2021-02-02 14:04:10 -05:00
innovaker 61893e453b
refactor(app): format with prettier (#563)
prettier --write .

PR: #563
2021-01-01 22:55:52 -05:00
innovaker 842aa5a842 refactor: replace filename hyphens with underscores
Aligns *.h and *.c to underscore naming convention.

These were kept (with warnings) for backwards compatibility with external boards/shields:
- kscan-mock.h
- matrix-transform.h
They should be removed in the future.

PR: #523
2020-12-28 01:15:35 -05:00
innovaker f7d9d52221 refactor(app): replace `void` with `const struct device *dev` in ISR CBs
See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
2020-12-14 12:41:25 -05:00
innovaker 00ca0d2f1c refactor(app): replace `struct device *` with `const struct device *`
Replaced with RegExp: /(?<!const )(struct device \*)/g

See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
2020-12-14 12:41:25 -05:00
innovaker 1411092a7b refactor(app): replace `driver_data` with `data`
See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
2020-12-14 12:41:25 -05:00
innovaker 3d7376d2e5 refactor(app): replace `config_info` with `config`
See: https://docs.zephyrproject.org/latest/releases/release-notes-2.4.html
PR: #467
2020-12-14 12:41:25 -05:00
innovaker bac1f17cf6 refactor(app): replace Zephyr integer types with C99 integer types
u8_t → uint8_t
u16_t → uint16_t
u32_t → uint32_t
u64_t → uint64_t
s8_t → int8_t
s16_t → int16_t
s32_t → int32_t
s64_t → int64_t

Prerequisite for #223
See: https://github.com/zephyrproject-rtos/zephyr/releases/tag/zephyr-v2.4.0
PR: #467
2020-12-14 12:41:25 -05:00
Pete Johanson e6a27b15c1 fix(kscan): Fix building kscan for tests. 2020-12-08 22:20:12 -05:00
Pete Johanson ca38894e07 fix(drivers): Remove conditional from directories. 2020-12-04 16:25:32 -05:00
innovaker 8d9ae1fdf3 refactor: Align drivers with Zephyr file system conventions
PR: #400
2020-12-03 21:06:01 -05:00
Pete Johanson e0fede4aa5 refactor(kscan): Use PORT events for direct driver
* Switch interrupt configuration so nRF52 uses
  PORT events for lower power use, and wake
  from deep sleep.
* Closes #272
2020-12-02 16:46:05 -05:00
4pplet 924a598920 Updated function calls with missing reference. GPIO missing.
Updated function calls with missing reference. GPIO missing.

To my understanding:
DT_INST_GPIO_PIN() should be called instead if DT_INST_PIN()
DT_INST_GPIO_FLAGS() should be called instead if DT_INST_GPIO_FLAGS()

Current implementation does not compile when using control pin.
2020-11-29 21:12:26 -05:00
innovaker 67a6646cd7 chore: add copyright to core Kconfig 2020-11-20 22:25:28 -05:00
innovaker 1c8321566a fix(drivers): rename module.yaml to module.yml
module.yaml is not a valid module filename.

See Zephyr `scripts/zephyr_module.py`
2020-11-20 22:23:20 -05:00
Nick 8779563896 fix(bvd): Add SENSOR_CHAN_ALL support 2020-11-01 23:00:54 -05:00
Jay Greco 8a98212a02 Update demux kscan driver as per PR feedback
- Remove kscan_gpio_irq_callback
- Remove kscan_gpio_irq_callback_handler
- Remove irq_callbacks
+ Add TODO noting timer and sleep state interactions
2020-10-27 12:44:59 -07:00
Jay Greco 1522c91d73 Add new kscan_gpio_demux driver
+ zmk,kscan_gpio_demux is now a compatible kscan option
+ kscan_gpio_demux is based heavily off of the implementation of
kscan_gpio_matrix, modified to address cols using an n-to-1
demultiplexer chip instead of discrete IO
+ Added zmk,kscan_gpio_demux.yaml file
* modified CMakeLists to include new source files
2020-10-27 18:58:58 +00:00