Commit graph

11 commits

Author SHA1 Message Date
Joel Challis
ea98aa8e5e
Reduce includes for dip_switch header (#18951) 2022-11-04 11:54:35 +00:00
Jeff Epler
9632360caa
Use a macro to compute the size of arrays at compile time (#18044)
* Add ARRAY_SIZE and CEILING utility macros

* Apply a coccinelle patch to use ARRAY_SIZE

* fix up some straggling items

* Fix 'make test:secure'

* Enhance ARRAY_SIZE macro to reject acting on pointers

The previous definition would not produce a diagnostic for
```
int *p;
size_t num_elem = ARRAY_SIZE(p)
```
but the new one will.

* explicitly get definition of ARRAY_SIZE

* Convert to ARRAY_SIZE when const is involved

The following spatch finds additional instances where the array is
const and the division is by the size of the type, not the size of
the first element:
```
@ rule5a using "empty.iso" @
type T;
const T[] E;
@@

- (sizeof(E)/sizeof(T))
+ ARRAY_SIZE(E)

@ rule6a using "empty.iso" @
type T;
const T[] E;
@@

- sizeof(E)/sizeof(T)
+ ARRAY_SIZE(E)
```

* New instances of ARRAY_SIZE added since initial spatch run

* Use `ARRAY_SIZE` in docs (found by grep)

* Manually use ARRAY_SIZE

hs_set is expected to be the same size as uint16_t, though it's made
of two 8-bit integers

* Just like char, sizeof(uint8_t) is guaranteed to be 1

This is at least true on any plausible system where qmk is actually used.

Per my understanding it's universally true, assuming that uint8_t exists:
https://stackoverflow.com/questions/48655310/can-i-assume-that-sizeofuint8-t-1

* Run qmk-format on core C files touched in this branch

Co-authored-by: Stefan Kerkmann <karlk90@pm.me>
2022-08-30 10:20:04 +02:00
QMK Bot
63646e8906
Format code according to conventions (#16322) 2022-02-12 18:29:31 +00:00
Joel Challis
69c71d4843
Align DIP_SWITCH_PINS_RIGHT implementation with encoders (#14079) 2021-08-20 10:15:11 +01:00
XScorpion2
9d1c98c891
Added right vs left specific pin assignments for dip switch (#13074)
* Added right vs left specific pin assignments for dip switch

* Update feature_dip_switch.md

* Ran formatting tools
2021-08-19 18:39:15 +01:00
Drashna Jaelre
0bde920817
Convert Dip Switch callbacks to boolean functions (#13399) 2021-07-01 08:22:21 -07:00
QMK Bot
355f075b57 format code according to conventions [skip ci] 2020-07-04 15:01:25 +00:00
Takeshi ISHII
c2ca57c8f4
add DIP_SWITCH_MATRIX_GRID support (#8772)
* dipsw test on helix/rev2/sc/back:five_rows

* add peek_matrix() to matrix_common.c

* add DIP_SWITCH_MATRIX_GRID support to quantum/dip_switch.c

* update docs/feature_dip_switch.md about DIP_SWITCH_MATRIX_GRID

* Test end. remove test code. Revert "dipsw test on helix/rev2/sc/back:five_rows"

This reverts commit 6d4304c74557597c9fb4d324f79c3ae4793ae874.
2020-07-04 23:20:49 +09:00
Takeshi ISHII
d3c29c9b3c
Bugfix for quantum/dip_switch.c (#8731)
* dipsw test on helix/rev2/sc/back:five_rows

* bug fix quantum/dip_switch.c

* test end. remove test code. Revert "dipsw test on helix/rev2/sc/back:five_rows"

This reverts commit 4b13ebb996.

* dipsw test on helix/rev2/sc/back:five_rows

* update quantum/dip_switch.c

* test end. remove test code. Revert "dipsw test on helix/rev2/sc/back:five_rows"

This reverts commit bf99ace095.
2020-04-12 12:44:24 -07:00
zvecr
a91c0c4765 Run clang-format manually to fix recently changed files 2019-11-17 08:25:58 -08:00
Drashna Jaelre
dab4967f1b
Add Dip Switch as a core feature (#6140)
* Add Dip Switches as a core feature

* Add documentation for Dip Switch feature

* Update Preonic Rev3 to use new feature and remove custom matrix

* Apply suggestions from code review

Co-Authored-By: noroadsleft <18669334+noroadsleft@users.noreply.github.com>

* Remove custom matrix line completely

Rather than just disabling it

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* DIP changes

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* Use better check for DIP Switch configuration

* Add to show features

* Add bitmask callback for dip switch

* Fix OLKB Boards dip switch config

* Update docs to include bitmask example

* Fix comments/documentation

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* Fix issues with docs and use example from @tuzonghua

* Fix wording

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* Fix example to use proper formatting

Bad, BAAAAAAD drashna!!!

* Handle dip switch initialization better
2019-09-03 08:34:31 -07:00