diff options
| author | yiancar <yiangosyiangou@cytanet.com.cy> | 2018-08-28 16:03:11 +0300 |
|---|---|---|
| committer | Jack Humbert <jack.humb@gmail.com> | 2018-08-28 09:03:11 -0400 |
| commit | fdd0f915271f79b104aa5d216566bcc3fd134e85 (patch) | |
| tree | 42656e9ebd132461b99d7b037563374e575053ae /quantum | |
| parent | 2410f023598af65a551b42f569a2703a5621bdca (diff) | |
| download | qmk_firmware-fdd0f915271f79b104aa5d216566bcc3fd134e85.tar.gz qmk_firmware-fdd0f915271f79b104aa5d216566bcc3fd134e85.zip | |
ISSI31FL3733 driver (#3679)
* ISSI31FL3733 driver
- Addapted IS31 driver for the above driver
* fix my branch
* ISSI31FL3733 driver
- Inclusion of above ISSI led driver
* IS31fl3733 driver
- Added correct function for control registers
* Finalized support for ISSI31fl3733 led driver
- Finalized and tested driver.
- Modified i2c_master for arm due to declaration mistake.
- Fixed spaces/tabs in quantum.h file.
- Fixed spaces/tabs in common_features.mk file.
- Removed unnecessary includes from rgb_matrix.c file.
- Added local definitions for MIN and MAX macros in rgb_matrix.c file.
- Adjusted chevron effect.
- Added necessary define (RGB_3733_MATRIX_ENABLE) for makefile.
- Added necessary C define (ISSI3733) to aid with inclusion of the correct header file.
- Added documentation for the new driver.
* Driver structure update
- Changed rule includes to be more condensed (RGB_MATRIX_ENABLE = IS31FL3731) and (RGB_MATRIX_ENABLE = IS31FL3733)
- Updated documentation
- Reverted to the use of differently named functions for each driver and selecting the needed ones within rgb_matrix.c
* ISSI Drivers refractoring
- Moved issi drivers in a dedicated folder
- Updated documentation
* I2C library fix
I released the special pins incorrectly before. It is now fixed.
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/quantum.h | 40 | ||||
| -rw-r--r-- | quantum/rgb_matrix.c | 68 | ||||
| -rw-r--r-- | quantum/rgb_matrix.h | 8 |
3 files changed, 80 insertions, 36 deletions
diff --git a/quantum/quantum.h b/quantum/quantum.h index 1db9846f0..b4e4de174 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | #include "backlight.h" | 28 | #include "backlight.h" |
| 29 | #endif | 29 | #endif |
| 30 | #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE) | 30 | #if !defined(RGBLIGHT_ENABLE) && !defined(RGB_MATRIX_ENABLE) |
| 31 | #include "rgb.h" | 31 | #include "rgb.h" |
| 32 | #endif | 32 | #endif |
| 33 | #ifdef RGBLIGHT_ENABLE | 33 | #ifdef RGBLIGHT_ENABLE |
| 34 | #include "rgblight.h" | 34 | #include "rgblight.h" |
| @@ -39,7 +39,7 @@ | |||
| 39 | #endif | 39 | #endif |
| 40 | 40 | ||
| 41 | #ifdef RGB_MATRIX_ENABLE | 41 | #ifdef RGB_MATRIX_ENABLE |
| 42 | #include "rgb_matrix.h" | 42 | #include "rgb_matrix.h" |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| 45 | #include "action_layer.h" | 45 | #include "action_layer.h" |
| @@ -58,78 +58,78 @@ | |||
| 58 | extern uint32_t default_layer_state; | 58 | extern uint32_t default_layer_state; |
| 59 | 59 | ||
| 60 | #ifndef NO_ACTION_LAYER | 60 | #ifndef NO_ACTION_LAYER |
| 61 | extern uint32_t layer_state; | 61 | extern uint32_t layer_state; |
| 62 | #endif | 62 | #endif |
| 63 | 63 | ||
| 64 | #ifdef MIDI_ENABLE | 64 | #ifdef MIDI_ENABLE |
| 65 | #ifdef MIDI_ADVANCED | 65 | #ifdef MIDI_ADVANCED |
| 66 | #include "process_midi.h" | 66 | #include "process_midi.h" |
| 67 | #endif | 67 | #endif |
| 68 | #endif // MIDI_ENABLE | 68 | #endif // MIDI_ENABLE |
| 69 | 69 | ||
| 70 | #ifdef AUDIO_ENABLE | 70 | #ifdef AUDIO_ENABLE |
| 71 | #include "audio.h" | 71 | #include "audio.h" |
| 72 | #include "process_audio.h" | 72 | #include "process_audio.h" |
| 73 | #ifdef AUDIO_CLICKY | 73 | #ifdef AUDIO_CLICKY |
| 74 | #include "process_clicky.h" | 74 | #include "process_clicky.h" |
| 75 | #endif // AUDIO_CLICKY | 75 | #endif // AUDIO_CLICKY |
| 76 | #endif | 76 | #endif |
| 77 | 77 | ||
| 78 | #ifdef STENO_ENABLE | 78 | #ifdef STENO_ENABLE |
| 79 | #include "process_steno.h" | 79 | #include "process_steno.h" |
| 80 | #endif | 80 | #endif |
| 81 | 81 | ||
| 82 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) | 82 | #if defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC)) |
| 83 | #include "process_music.h" | 83 | #include "process_music.h" |
| 84 | #endif | 84 | #endif |
| 85 | 85 | ||
| 86 | #ifndef DISABLE_LEADER | 86 | #ifndef DISABLE_LEADER |
| 87 | #include "process_leader.h" | 87 | #include "process_leader.h" |
| 88 | #endif | 88 | #endif |
| 89 | 89 | ||
| 90 | #define DISABLE_CHORDING | 90 | #define DISABLE_CHORDING |
| 91 | #ifndef DISABLE_CHORDING | 91 | #ifndef DISABLE_CHORDING |
| 92 | #include "process_chording.h" | 92 | #include "process_chording.h" |
| 93 | #endif | 93 | #endif |
| 94 | 94 | ||
| 95 | #ifdef UNICODE_ENABLE | 95 | #ifdef UNICODE_ENABLE |
| 96 | #include "process_unicode.h" | 96 | #include "process_unicode.h" |
| 97 | #endif | 97 | #endif |
| 98 | 98 | ||
| 99 | #ifdef UCIS_ENABLE | 99 | #ifdef UCIS_ENABLE |
| 100 | #include "process_ucis.h" | 100 | #include "process_ucis.h" |
| 101 | #endif | 101 | #endif |
| 102 | 102 | ||
| 103 | #ifdef UNICODEMAP_ENABLE | 103 | #ifdef UNICODEMAP_ENABLE |
| 104 | #include "process_unicodemap.h" | 104 | #include "process_unicodemap.h" |
| 105 | #endif | 105 | #endif |
| 106 | 106 | ||
| 107 | #include "process_tap_dance.h" | 107 | #include "process_tap_dance.h" |
| 108 | 108 | ||
| 109 | #ifdef PRINTING_ENABLE | 109 | #ifdef PRINTING_ENABLE |
| 110 | #include "process_printer.h" | 110 | #include "process_printer.h" |
| 111 | #endif | 111 | #endif |
| 112 | 112 | ||
| 113 | #ifdef AUTO_SHIFT_ENABLE | 113 | #ifdef AUTO_SHIFT_ENABLE |
| 114 | #include "process_auto_shift.h" | 114 | #include "process_auto_shift.h" |
| 115 | #endif | 115 | #endif |
| 116 | 116 | ||
| 117 | #ifdef COMBO_ENABLE | 117 | #ifdef COMBO_ENABLE |
| 118 | #include "process_combo.h" | 118 | #include "process_combo.h" |
| 119 | #endif | 119 | #endif |
| 120 | 120 | ||
| 121 | #ifdef KEY_LOCK_ENABLE | 121 | #ifdef KEY_LOCK_ENABLE |
| 122 | #include "process_key_lock.h" | 122 | #include "process_key_lock.h" |
| 123 | #endif | 123 | #endif |
| 124 | 124 | ||
| 125 | #ifdef TERMINAL_ENABLE | 125 | #ifdef TERMINAL_ENABLE |
| 126 | #include "process_terminal.h" | 126 | #include "process_terminal.h" |
| 127 | #else | 127 | #else |
| 128 | #include "process_terminal_nop.h" | 128 | #include "process_terminal_nop.h" |
| 129 | #endif | 129 | #endif |
| 130 | 130 | ||
| 131 | #ifdef HD44780_ENABLE | 131 | #ifdef HD44780_ENABLE |
| 132 | #include "hd44780.h" | 132 | #include "hd44780.h" |
| 133 | #endif | 133 | #endif |
| 134 | 134 | ||
| 135 | #define STRINGIZE(z) #z | 135 | #define STRINGIZE(z) #z |
diff --git a/quantum/rgb_matrix.c b/quantum/rgb_matrix.c index 70ad1a178..197bc1ac5 100644 --- a/quantum/rgb_matrix.c +++ b/quantum/rgb_matrix.c | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* Copyright 2017 Jason Williams | 1 | /* Copyright 2017 Jason Williams |
| 2 | * Copyright 2017 Jack Humbert | 2 | * Copyright 2017 Jack Humbert |
| 3 | * Copyright 2018 Yiancar | ||
| 3 | * | 4 | * |
| 4 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
| @@ -17,18 +18,22 @@ | |||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | #include "rgb_matrix.h" | 20 | #include "rgb_matrix.h" |
| 20 | #include <avr/io.h> | ||
| 21 | #include "i2c_master.h" | 21 | #include "i2c_master.h" |
| 22 | #include <util/delay.h> | ||
| 23 | #include <avr/interrupt.h> | ||
| 24 | #include "progmem.h" | 22 | #include "progmem.h" |
| 25 | #include "config.h" | 23 | #include "config.h" |
| 26 | #include "eeprom.h" | 24 | #include "eeprom.h" |
| 27 | #include "lufa.h" | ||
| 28 | #include <math.h> | 25 | #include <math.h> |
| 29 | 26 | ||
| 30 | rgb_config_t rgb_matrix_config; | 27 | rgb_config_t rgb_matrix_config; |
| 31 | 28 | ||
| 29 | #ifndef MAX | ||
| 30 | #define MAX(X, Y) ((X) > (Y) ? (X) : (Y)) | ||
| 31 | #endif | ||
| 32 | |||
| 33 | #ifndef MIN | ||
| 34 | #define MIN(a,b) ((a) < (b)? (a): (b)) | ||
| 35 | #endif | ||
| 36 | |||
| 32 | #ifndef RGB_DISABLE_AFTER_TIMEOUT | 37 | #ifndef RGB_DISABLE_AFTER_TIMEOUT |
| 33 | #define RGB_DISABLE_AFTER_TIMEOUT 0 | 38 | #define RGB_DISABLE_AFTER_TIMEOUT 0 |
| 34 | #endif | 39 | #endif |
| @@ -106,16 +111,29 @@ void map_row_column_to_led( uint8_t row, uint8_t column, uint8_t *led_i, uint8_t | |||
| 106 | } | 111 | } |
| 107 | 112 | ||
| 108 | void rgb_matrix_update_pwm_buffers(void) { | 113 | void rgb_matrix_update_pwm_buffers(void) { |
| 109 | IS31_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | 114 | #ifdef IS31FL3731 |
| 110 | IS31_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | 115 | IS31FL3731_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); |
| 116 | IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 117 | #elif defined(IS31FL3733) | ||
| 118 | IS31FL3733_update_pwm_buffers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 119 | IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 120 | #endif | ||
| 111 | } | 121 | } |
| 112 | 122 | ||
| 113 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { | 123 | void rgb_matrix_set_color( int index, uint8_t red, uint8_t green, uint8_t blue ) { |
| 114 | IS31_set_color( index, red, green, blue ); | 124 | #ifdef IS31FL3731 |
| 125 | IS31FL3731_set_color( index, red, green, blue ); | ||
| 126 | #elif defined(IS31FL3733) | ||
| 127 | IS31FL3733_set_color( index, red, green, blue ); | ||
| 128 | #endif | ||
| 115 | } | 129 | } |
| 116 | 130 | ||
| 117 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { | 131 | void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ) { |
| 118 | IS31_set_color_all( red, green, blue ); | 132 | #ifdef IS31FL3731 |
| 133 | IS31FL3731_set_color_all( red, green, blue ); | ||
| 134 | #elif defined(IS31FL3733) | ||
| 135 | IS31FL3733_set_color_all( red, green, blue ); | ||
| 136 | #endif | ||
| 119 | } | 137 | } |
| 120 | 138 | ||
| 121 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { | 139 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { |
| @@ -460,7 +478,7 @@ void rgb_matrix_rainbow_moving_chevron(void) { | |||
| 460 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { | 478 | for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { |
| 461 | led = g_rgb_leds[i]; | 479 | led = g_rgb_leds[i]; |
| 462 | // uint8_t r = g_tick; | 480 | // uint8_t r = g_tick; |
| 463 | uint8_t r = 32; | 481 | uint8_t r = 128; |
| 464 | hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(led.point.y - 32.0)* sin(r * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue; | 482 | hsv.h = (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * abs(led.point.y - 32.0)* sin(r * PI / 128) + (1.5 * (rgb_matrix_config.speed == 0 ? 1 : rgb_matrix_config.speed)) * (led.point.x - (g_tick / 256.0 * 224)) * cos(r * PI / 128) + rgb_matrix_config.hue; |
| 465 | rgb = hsv_to_rgb( hsv ); | 483 | rgb = hsv_to_rgb( hsv ); |
| 466 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); | 484 | rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b ); |
| @@ -752,16 +770,28 @@ void rgb_matrix_init(void) { | |||
| 752 | void rgb_matrix_setup_drivers(void) { | 770 | void rgb_matrix_setup_drivers(void) { |
| 753 | // Initialize TWI | 771 | // Initialize TWI |
| 754 | i2c_init(); | 772 | i2c_init(); |
| 755 | IS31_init( DRIVER_ADDR_1 ); | 773 | #ifdef IS31FL3731 |
| 756 | IS31_init( DRIVER_ADDR_2 ); | 774 | IS31FL3731_init( DRIVER_ADDR_1 ); |
| 775 | IS31FL3731_init( DRIVER_ADDR_2 ); | ||
| 776 | #elif defined (IS31FL3733) | ||
| 777 | IS31FL3733_init( DRIVER_ADDR_1 ); | ||
| 778 | #endif | ||
| 757 | 779 | ||
| 758 | for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { | 780 | for ( int index = 0; index < DRIVER_LED_TOTAL; index++ ) { |
| 759 | bool enabled = true; | 781 | bool enabled = true; |
| 760 | // This only caches it for later | 782 | // This only caches it for later |
| 761 | IS31_set_led_control_register( index, enabled, enabled, enabled ); | 783 | #ifdef IS31FL3731 |
| 784 | IS31FL3731_set_led_control_register( index, enabled, enabled, enabled ); | ||
| 785 | #elif defined (IS31FL3733) | ||
| 786 | IS31FL3733_set_led_control_register( index, enabled, enabled, enabled ); | ||
| 787 | #endif | ||
| 762 | } | 788 | } |
| 763 | // This actually updates the LED drivers | 789 | // This actually updates the LED drivers |
| 764 | IS31_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | 790 | #ifdef IS31FL3731 |
| 791 | IS31FL3731_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 792 | #elif defined (IS31FL3733) | ||
| 793 | IS31FL3733_update_led_control_registers( DRIVER_ADDR_1, DRIVER_ADDR_2 ); | ||
| 794 | #endif | ||
| 765 | } | 795 | } |
| 766 | 796 | ||
| 767 | // Deals with the messy details of incrementing an integer | 797 | // Deals with the messy details of incrementing an integer |
| @@ -811,11 +841,19 @@ void rgb_matrix_test_led( uint8_t index, bool red, bool green, bool blue ) { | |||
| 811 | { | 841 | { |
| 812 | if ( i == index ) | 842 | if ( i == index ) |
| 813 | { | 843 | { |
| 814 | IS31_set_led_control_register( i, red, green, blue ); | 844 | #ifdef IS31FL3731 |
| 845 | IS31FL3731_set_led_control_register( i, red, green, blue ); | ||
| 846 | #elif defined (IS31FL3733) | ||
| 847 | IS31FL3733_set_led_control_register( i, red, green, blue ); | ||
| 848 | #endif | ||
| 815 | } | 849 | } |
| 816 | else | 850 | else |
| 817 | { | 851 | { |
| 818 | IS31_set_led_control_register( i, false, false, false ); | 852 | #ifdef IS31FL3731 |
| 853 | IS31FL3731_set_led_control_register( i, false, false, false ); | ||
| 854 | #elif defined (IS31FL3733) | ||
| 855 | IS31FL3733_set_led_control_register( i, false, false, false ); | ||
| 856 | #endif | ||
| 819 | } | 857 | } |
| 820 | } | 858 | } |
| 821 | } | 859 | } |
diff --git a/quantum/rgb_matrix.h b/quantum/rgb_matrix.h index 576931400..b91c9fba5 100644 --- a/quantum/rgb_matrix.h +++ b/quantum/rgb_matrix.h | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | /* Copyright 2017 Jason Williams | 1 | /* Copyright 2017 Jason Williams |
| 2 | * Copyright 2017 Jack Humbert | 2 | * Copyright 2017 Jack Humbert |
| 3 | * Copyright 2018 Yiancar | ||
| 3 | * | 4 | * |
| 4 | * This program is free software: you can redistribute it and/or modify | 5 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by | 6 | * it under the terms of the GNU General Public License as published by |
| @@ -21,9 +22,14 @@ | |||
| 21 | #include <stdint.h> | 22 | #include <stdint.h> |
| 22 | #include <stdbool.h> | 23 | #include <stdbool.h> |
| 23 | #include "color.h" | 24 | #include "color.h" |
| 24 | #include "is31fl3731.h" | ||
| 25 | #include "quantum.h" | 25 | #include "quantum.h" |
| 26 | 26 | ||
| 27 | #ifdef IS31FL3731 | ||
| 28 | #include "is31fl3731.h" | ||
| 29 | #elif defined (IS31FL3733) | ||
| 30 | #include "is31fl3733.h" | ||
| 31 | #endif | ||
| 32 | |||
| 27 | typedef struct Point { | 33 | typedef struct Point { |
| 28 | uint8_t x; | 34 | uint8_t x; |
| 29 | uint8_t y; | 35 | uint8_t y; |
