diff options
| author | skullY <skullydazed@gmail.com> | 2019-08-30 11:19:03 -0700 |
|---|---|---|
| committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-30 15:01:52 -0700 |
| commit | b624f32f944acdc59dcb130674c09090c5c404cb (patch) | |
| tree | bc13adbba137d122d9a2c2fb2fafcbb08ac10e25 /quantum/audio/muse.c | |
| parent | 61af76a10d00aba185b8338604171de490a13e3b (diff) | |
| download | qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.tar.gz qmk_firmware-b624f32f944acdc59dcb130674c09090c5c404cb.zip | |
clang-format changes
Diffstat (limited to 'quantum/audio/muse.c')
| -rw-r--r-- | quantum/audio/muse.c | 137 |
1 files changed, 41 insertions, 96 deletions
diff --git a/quantum/audio/muse.c b/quantum/audio/muse.c index f3cb592d8..01b95671f 100644 --- a/quantum/audio/muse.c +++ b/quantum/audio/muse.c | |||
| @@ -1,111 +1,56 @@ | |||
| 1 | #include "muse.h" | 1 | #include "muse.h" |
| 2 | 2 | ||
| 3 | enum { | 3 | enum { MUSE_OFF, MUSE_ON, MUSE_C_1_2, MUSE_C1, MUSE_C2, MUSE_C4, MUSE_C8, MUSE_C3, MUSE_C6, MUSE_B1, MUSE_B2, MUSE_B3, MUSE_B4, MUSE_B5, MUSE_B6, MUSE_B7, MUSE_B8, MUSE_B9, MUSE_B10, MUSE_B11, MUSE_B12, MUSE_B13, MUSE_B14, MUSE_B15, MUSE_B16, MUSE_B17, MUSE_B18, MUSE_B19, MUSE_B20, MUSE_B21, MUSE_B22, MUSE_B23, MUSE_B24, MUSE_B25, MUSE_B26, MUSE_B27, MUSE_B28, MUSE_B29, MUSE_B30, MUSE_B31 }; |
| 4 | MUSE_OFF, | ||
| 5 | MUSE_ON, | ||
| 6 | MUSE_C_1_2, | ||
| 7 | MUSE_C1, | ||
| 8 | MUSE_C2, | ||
| 9 | MUSE_C4, | ||
| 10 | MUSE_C8, | ||
| 11 | MUSE_C3, | ||
| 12 | MUSE_C6, | ||
| 13 | MUSE_B1, | ||
| 14 | MUSE_B2, | ||
| 15 | MUSE_B3, | ||
| 16 | MUSE_B4, | ||
| 17 | MUSE_B5, | ||
| 18 | MUSE_B6, | ||
| 19 | MUSE_B7, | ||
| 20 | MUSE_B8, | ||
| 21 | MUSE_B9, | ||
| 22 | MUSE_B10, | ||
| 23 | MUSE_B11, | ||
| 24 | MUSE_B12, | ||
| 25 | MUSE_B13, | ||
| 26 | MUSE_B14, | ||
| 27 | MUSE_B15, | ||
| 28 | MUSE_B16, | ||
| 29 | MUSE_B17, | ||
| 30 | MUSE_B18, | ||
| 31 | MUSE_B19, | ||
| 32 | MUSE_B20, | ||
| 33 | MUSE_B21, | ||
| 34 | MUSE_B22, | ||
| 35 | MUSE_B23, | ||
| 36 | MUSE_B24, | ||
| 37 | MUSE_B25, | ||
| 38 | MUSE_B26, | ||
| 39 | MUSE_B27, | ||
| 40 | MUSE_B28, | ||
| 41 | MUSE_B29, | ||
| 42 | MUSE_B30, | ||
| 43 | MUSE_B31 | ||
| 44 | }; | ||
| 45 | 4 | ||
| 46 | bool number_of_ones_to_bool[16] = { | 5 | bool number_of_ones_to_bool[16] = {1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1}; |
| 47 | 1, 0, 0, 1, 0, 1, 1, 0, | ||
| 48 | 0, 1, 1, 0, 1, 0, 0, 1 | ||
| 49 | }; | ||
| 50 | 6 | ||
| 51 | uint8_t muse_interval[4] = {MUSE_B7, MUSE_B19, MUSE_B3, MUSE_B28}; | 7 | uint8_t muse_interval[4] = {MUSE_B7, MUSE_B19, MUSE_B3, MUSE_B28}; |
| 52 | uint8_t muse_theme[4] = {MUSE_B8, MUSE_B23, MUSE_B18, MUSE_B17}; | 8 | uint8_t muse_theme[4] = {MUSE_B8, MUSE_B23, MUSE_B18, MUSE_B17}; |
| 53 | 9 | ||
| 54 | bool muse_timer_1bit = 0; | 10 | bool muse_timer_1bit = 0; |
| 55 | uint8_t muse_timer_2bit = 0; | 11 | uint8_t muse_timer_2bit = 0; |
| 56 | uint8_t muse_timer_2bit_counter = 0; | 12 | uint8_t muse_timer_2bit_counter = 0; |
| 57 | uint8_t muse_timer_4bit = 0; | 13 | uint8_t muse_timer_4bit = 0; |
| 58 | uint32_t muse_timer_31bit = 0; | 14 | uint32_t muse_timer_31bit = 0; |
| 59 | 15 | ||
| 60 | bool bit_for_value(uint8_t value) { | 16 | bool bit_for_value(uint8_t value) { |
| 61 | switch (value) { | 17 | switch (value) { |
| 62 | case MUSE_OFF: | 18 | case MUSE_OFF: |
| 63 | return 0; | 19 | return 0; |
| 64 | case MUSE_ON: | 20 | case MUSE_ON: |
| 65 | return 1; | 21 | return 1; |
| 66 | case MUSE_C_1_2: | 22 | case MUSE_C_1_2: |
| 67 | return muse_timer_1bit; | 23 | return muse_timer_1bit; |
| 68 | case MUSE_C1: | 24 | case MUSE_C1: |
| 69 | return (muse_timer_4bit & 1); | 25 | return (muse_timer_4bit & 1); |
| 70 | case MUSE_C2: | 26 | case MUSE_C2: |
| 71 | return (muse_timer_4bit & 2); | 27 | return (muse_timer_4bit & 2); |
| 72 | case MUSE_C4: | 28 | case MUSE_C4: |
| 73 | return (muse_timer_4bit & 4); | 29 | return (muse_timer_4bit & 4); |
| 74 | case MUSE_C8: | 30 | case MUSE_C8: |
| 75 | return (muse_timer_4bit & 8); | 31 | return (muse_timer_4bit & 8); |
| 76 | case MUSE_C3: | 32 | case MUSE_C3: |
| 77 | return (muse_timer_2bit & 1); | 33 | return (muse_timer_2bit & 1); |
| 78 | case MUSE_C6: | 34 | case MUSE_C6: |
| 79 | return (muse_timer_2bit & 2); | 35 | return (muse_timer_2bit & 2); |
| 80 | default: | 36 | default: |
| 81 | return muse_timer_31bit & (1UL << (value - MUSE_B1)); | 37 | return muse_timer_31bit & (1UL << (value - MUSE_B1)); |
| 82 | } | 38 | } |
| 83 | } | 39 | } |
| 84 | 40 | ||
| 85 | uint8_t muse_clock_pulse(void) { | 41 | uint8_t muse_clock_pulse(void) { |
| 86 | 42 | bool top = number_of_ones_to_bool[bit_for_value(muse_theme[0]) + (bit_for_value(muse_theme[1]) << 1) + (bit_for_value(muse_theme[2]) << 2) + (bit_for_value(muse_theme[3]) << 3)]; | |
| 87 | bool top = number_of_ones_to_bool[ | 43 | |
| 88 | bit_for_value(muse_theme[0]) + | 44 | if (muse_timer_1bit == 0) { |
| 89 | (bit_for_value(muse_theme[1]) << 1) + | 45 | if (muse_timer_2bit_counter == 0) { |
| 90 | (bit_for_value(muse_theme[2]) << 2) + | 46 | muse_timer_2bit = (muse_timer_2bit + 1) % 4; |
| 91 | (bit_for_value(muse_theme[3]) << 3) | 47 | } |
| 92 | ]; | 48 | muse_timer_2bit_counter = (muse_timer_2bit_counter + 1) % 3; |
| 93 | 49 | muse_timer_4bit = (muse_timer_4bit + 1) % 16; | |
| 94 | if (muse_timer_1bit == 0) { | 50 | muse_timer_31bit = (muse_timer_31bit << 1) + top; |
| 95 | if (muse_timer_2bit_counter == 0) { | ||
| 96 | muse_timer_2bit = (muse_timer_2bit + 1) % 4; | ||
| 97 | } | 51 | } |
| 98 | muse_timer_2bit_counter = (muse_timer_2bit_counter + 1) % 3; | ||
| 99 | muse_timer_4bit = (muse_timer_4bit + 1) % 16; | ||
| 100 | muse_timer_31bit = (muse_timer_31bit << 1) + top; | ||
| 101 | } | ||
| 102 | |||
| 103 | muse_timer_1bit = (muse_timer_1bit + 1) % 2; | ||
| 104 | 52 | ||
| 105 | return | 53 | muse_timer_1bit = (muse_timer_1bit + 1) % 2; |
| 106 | bit_for_value(muse_interval[0]) + | ||
| 107 | (bit_for_value(muse_interval[1]) << 1) + | ||
| 108 | (bit_for_value(muse_interval[2]) << 2) + | ||
| 109 | (bit_for_value(muse_interval[3]) << 3); | ||
| 110 | 54 | ||
| 55 | return bit_for_value(muse_interval[0]) + (bit_for_value(muse_interval[1]) << 1) + (bit_for_value(muse_interval[2]) << 2) + (bit_for_value(muse_interval[3]) << 3); | ||
| 111 | } | 56 | } |
