keymap example update and tweak to set_led_bit function
This commit is contained in:
parent
164a6c994b
commit
f54b4771eb
3 changed files with 21 additions and 24 deletions
|
@ -59,7 +59,7 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, \
|
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,KC_RBRC,KC_BSPC, \
|
||||||
TT(_FNAV), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_ENT, \
|
TT(_FNAV), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,KC_ENT, \
|
||||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,F(TILDE),KC_NO, \
|
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,F(TILDE),KC_NO, \
|
||||||
KC_LCTL, KC_LGUI,KC_LALT, KC_SPC, KC_RALT,TG(_NUMPAD),MO(_MEDIA), KC_RCTL \
|
KC_LCTL, KC_LGUI,KC_LALT, LT(_FNAV, KC_SPC), KC_RALT,TG(_NUMPAD),MO(_MEDIA), KC_RCTL \
|
||||||
),
|
),
|
||||||
|
|
||||||
/* numpad */
|
/* numpad */
|
||||||
|
@ -68,7 +68,7 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
_______,_______,_______,_______,_______,_______,_______, KC_P4, KC_P5, KC_P6, KC_PAST, _______,_______,_______, \
|
_______,_______,_______,_______,_______,_______,_______, KC_P4, KC_P5, KC_P6, KC_PAST, _______,_______,_______, \
|
||||||
MO(_FNAV),_______,_______,_______,_______,_______,_______, KC_P1, KC_P2, KC_P3, KC_PMNS, _______,_______, \
|
MO(_FNAV),_______,_______,_______,_______,_______,_______, KC_P1, KC_P2, KC_P3, KC_PMNS, _______,_______, \
|
||||||
_______,_______,_______,_______,_______,_______,_______, KC_P0,KC_COMM,KC_PDOT,KC_PPLS, _______,KC_NO, \
|
_______,_______,_______,_______,_______,_______,_______, KC_P0,KC_COMM,KC_PDOT,KC_PPLS, _______,KC_NO, \
|
||||||
_______,_______,_______, MO(_BASE), _______,_______,_______,_______ \
|
_______,_______,_______, TO(_BASE), _______,_______,_______,_______ \
|
||||||
),
|
),
|
||||||
|
|
||||||
/* F-, arrow, and media keys */
|
/* F-, arrow, and media keys */
|
||||||
|
|
|
@ -16,9 +16,9 @@ digits mean "row" and "col", i.e. 45 means pin 4, column 5 in the IS31 datasheet
|
||||||
```
|
```
|
||||||
*Unused in Alphabet Layout
|
*Unused in Alphabet Layout
|
||||||
|
|
||||||
The IS31 includes 8 pages (or frames) 0-7 and each page consists of 144 bytes
|
The IS31 includes 8 led pages (or frames) 0-7 than can be displayed, and each page consists of 144 bytes.
|
||||||
- **bytes 0 - 17** - LED control (on/off).
|
- **bytes 0 - 17** - LED control (on/off).
|
||||||
* 18 pins which alternate between A and B matrices (CA1, CB1, CA2, CB2, ..).
|
* 18 pins which alternate between A and B matrices (A1, B1, A2, B2, ..).
|
||||||
* Each byte controls the 8 leds on that pin with bits (8 to 1).
|
* Each byte controls the 8 leds on that pin with bits (8 to 1).
|
||||||
- **bytes 8 - 35** - Blink control.
|
- **bytes 8 - 35** - Blink control.
|
||||||
* Same as LED control above, but sets blink on/off.
|
* Same as LED control above, but sets blink on/off.
|
||||||
|
@ -31,7 +31,7 @@ In the Infinity60 project folder, led_controller.c sets up ability to write led
|
||||||
|
|
||||||
One function is available to directly set leds without the mailbox:
|
One function is available to directly set leds without the mailbox:
|
||||||
```
|
```
|
||||||
write_led_page(page#, array of leds by address, # of leds in array)
|
write_led_page(page#, array of leds by address, # of addresses in array)
|
||||||
```
|
```
|
||||||
This function saves a full page to the controller using a supplied array of led locations such as:
|
This function saves a full page to the controller using a supplied array of led locations such as:
|
||||||
```c
|
```c
|
||||||
|
@ -45,7 +45,7 @@ write_led_page(5, led_numpad, 16);
|
||||||
```
|
```
|
||||||
|
|
||||||
Remaining led control is done through the led mailbox using these message types:
|
Remaining led control is done through the led mailbox using these message types:
|
||||||
- **SET_FULL_ROW** (3 bytes) - row#, message type, 8-bit mask. Sets all leds on one pin per the bit mask.
|
- **SET_FULL_ROW** (3 bytes) - message type, 8-bit mask, and row#. Sets all leds on one pin per the bit mask.
|
||||||
- **OFF_LED, ON_LED, TOGGLE_LED** (3 bytes) - message type, led address, and page#. Off/on/toggle specific led.
|
- **OFF_LED, ON_LED, TOGGLE_LED** (3 bytes) - message type, led address, and page#. Off/on/toggle specific led.
|
||||||
- **BLINK_OFF_LED, BLINK_ON_LED, BLINK_OFF_LED** (3 bytes) - message type, led address, and page#. Set blink Off/on/toggle for specific led.
|
- **BLINK_OFF_LED, BLINK_ON_LED, BLINK_OFF_LED** (3 bytes) - message type, led address, and page#. Set blink Off/on/toggle for specific led.
|
||||||
- **TOGGLE_ALL** (1 byte) - Turn on/off full backlight.
|
- **TOGGLE_ALL** (1 byte) - Turn on/off full backlight.
|
||||||
|
@ -68,7 +68,7 @@ chMBPost(&led_mailbox, message, timeout);
|
||||||
An example:
|
An example:
|
||||||
```c
|
```c
|
||||||
//set the message to be sent. First byte (LSB) is the led address, and second is the message type
|
//set the message to be sent. First byte (LSB) is the led address, and second is the message type
|
||||||
msg=(42 << 8) | ON_LED
|
msg=(42 << 8) | ON_LED;
|
||||||
|
|
||||||
//send msg to the led mailbox
|
//send msg to the led mailbox
|
||||||
chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
|
chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
|
||||||
|
@ -76,7 +76,7 @@ chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
|
||||||
|
|
||||||
Another:
|
Another:
|
||||||
```c
|
```c
|
||||||
msg=(46 << 8) | BLINK_TOGGLE_LED
|
msg=(46 << 8) | BLINK_TOGGLE_LED;
|
||||||
chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
|
chMBPost(&led_mailbox, msg, TIME_IMMEDIATE);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "print.h"
|
#include "print.h"
|
||||||
#include "led.h"
|
#include "led.h"
|
||||||
#include "action_layer.h"
|
|
||||||
#include "host.h"
|
#include "host.h"
|
||||||
|
|
||||||
#include "led_controller.h"
|
#include "led_controller.h"
|
||||||
|
@ -199,31 +198,25 @@ static THD_FUNCTION(LEDthread, arg) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OFF_LED:
|
case OFF_LED:
|
||||||
//on/off/toggle single led, msg_args[0] = row/col of led
|
//on/off/toggle single led, msg_args[0] = row/col of led, msg_args[1] = page
|
||||||
set_led_bit(msg_args[1], control_register_word, msg_args[0], 0);
|
set_led_bit(msg_args[1], control_register_word, msg_args[0], 0);
|
||||||
is31_write_data (msg_args[1], control_register_word, 0x02);
|
|
||||||
break;
|
break;
|
||||||
case ON_LED:
|
case ON_LED:
|
||||||
set_led_bit(msg_args[1], control_register_word, msg_args[0], 1);
|
set_led_bit(msg_args[1], control_register_word, msg_args[0], 1);
|
||||||
is31_write_data (msg_args[1], control_register_word, 0x02);
|
|
||||||
break;
|
break;
|
||||||
case TOGGLE_LED:
|
case TOGGLE_LED:
|
||||||
set_led_bit(msg_args[1], control_register_word, msg_args[0], 2);
|
set_led_bit(msg_args[1], control_register_word, msg_args[0], 2);
|
||||||
is31_write_data (msg_args[1], control_register_word, 0x02);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BLINK_OFF_LED:
|
case BLINK_OFF_LED:
|
||||||
//on/off/toggle single led, msg_args[0] = row/col of led
|
//on/off/toggle single led, msg_args[0] = row/col of led
|
||||||
set_led_bit(msg_args[1], control_register_word, msg_args[0], 4);
|
set_led_bit(msg_args[1], control_register_word, msg_args[0], 4);
|
||||||
is31_write_data (msg_args[1], control_register_word, 0x02);
|
|
||||||
break;
|
break;
|
||||||
case BLINK_ON_LED:
|
case BLINK_ON_LED:
|
||||||
set_led_bit(msg_args[1], control_register_word, msg_args[0], 5);
|
set_led_bit(msg_args[1], control_register_word, msg_args[0], 5);
|
||||||
is31_write_data (msg_args[1], control_register_word, 0x02);
|
|
||||||
break;
|
break;
|
||||||
case BLINK_TOGGLE_LED:
|
case BLINK_TOGGLE_LED:
|
||||||
set_led_bit(msg_args[1], control_register_word, msg_args[0], 6);
|
set_led_bit(msg_args[1], control_register_word, msg_args[0], 6);
|
||||||
is31_write_data (msg_args[1], control_register_word, 0x02);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOGGLE_ALL:
|
case TOGGLE_ALL:
|
||||||
|
@ -282,6 +275,10 @@ static THD_FUNCTION(LEDthread, arg) {
|
||||||
led_control_reg[0] = 0;
|
led_control_reg[0] = 0;
|
||||||
__builtin_memset(led_control_reg+1, 0, 0x12);
|
__builtin_memset(led_control_reg+1, 0, 0x12);
|
||||||
is31_write_data(msg_args[0], led_control_reg, 0x13);
|
is31_write_data(msg_args[0], led_control_reg, 0x13);
|
||||||
|
|
||||||
|
//repeat for blink register
|
||||||
|
led_control_reg[0] = 0x12;
|
||||||
|
is31_write_data(msg_args[0], led_control_reg, 0x13);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TOGGLE_NUM_LOCK:
|
case TOGGLE_NUM_LOCK:
|
||||||
|
@ -330,7 +327,7 @@ static THD_FUNCTION(LEDthread, arg) {
|
||||||
* led processing functions
|
* led processing functions
|
||||||
* ============================== */
|
* ============================== */
|
||||||
|
|
||||||
void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint8_t action) {
|
void set_led_bit (uint8_t page, uint8_t *led_control_word, uint8_t led_addr, uint8_t action) {
|
||||||
//returns 2 bytes: led control register address and byte to write
|
//returns 2 bytes: led control register address and byte to write
|
||||||
//action: 0 - off, 1 - on, 2 - toggle, 4 - blink on, 5 - blink off, 6 - toggle blink
|
//action: 0 - off, 1 - on, 2 - toggle, 4 - blink on, 5 - blink off, 6 - toggle blink
|
||||||
|
|
||||||
|
@ -341,11 +338,9 @@ void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for blink bit
|
blink_bit = action>>2;//check for blink bit
|
||||||
blink_bit = action>>2;
|
|
||||||
action &= ~(1<<2); //strip blink bit
|
action &= ~(1<<2); //strip blink bit
|
||||||
|
|
||||||
//first byte is led control register address 0x00
|
|
||||||
//led_addr tens column is pin#, ones column is bit position in 8-bit mask
|
//led_addr tens column is pin#, ones column is bit position in 8-bit mask
|
||||||
control_reg_addr = ((led_addr / 10) % 10 - 1 ) * 0x02;// A-matrix is every other byte
|
control_reg_addr = ((led_addr / 10) % 10 - 1 ) * 0x02;// A-matrix is every other byte
|
||||||
control_reg_addr += blink_bit == 1 ? 0x12 : 0x00;//if blink_bit, shift 12 bytes to blink register
|
control_reg_addr += blink_bit == 1 ? 0x12 : 0x00;//if blink_bit, shift 12 bytes to blink register
|
||||||
|
@ -367,8 +362,9 @@ void set_led_bit (uint8_t page, uint8_t *led_control_reg, uint8_t led_addr, uint
|
||||||
}
|
}
|
||||||
|
|
||||||
//return word to be written in register
|
//return word to be written in register
|
||||||
led_control_reg[0] = control_reg_addr;
|
led_control_word[0] = control_reg_addr;
|
||||||
led_control_reg[1] = column_byte;
|
led_control_word[1] = column_byte;
|
||||||
|
is31_write_data (page, led_control_word, 0x02);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_led_byte (uint8_t page, uint8_t row, uint8_t led_byte) {
|
void write_led_byte (uint8_t page, uint8_t row, uint8_t led_byte) {
|
||||||
|
@ -403,13 +399,14 @@ void set_lock_leds(uint8_t led_addr, uint8_t led_action, uint8_t page) {
|
||||||
//blink if all leds are on
|
//blink if all leds are on
|
||||||
if (page == 0) {
|
if (page == 0) {
|
||||||
is31_read_register(0, 0x00, &temp);
|
is31_read_register(0, 0x00, &temp);
|
||||||
|
chThdSleepMilliseconds(10);
|
||||||
|
|
||||||
if (temp == 0xFF) {
|
if (temp == 0xFF) {
|
||||||
led_action |= (1<<2); //set blink bit
|
led_action |= (1<<2); //set blink bit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
set_led_bit(page,led_control_word,led_addr,led_action);
|
set_led_bit(page,led_control_word,led_addr,led_action);
|
||||||
is31_write_data(page, led_control_word, 0x02);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =====================
|
/* =====================
|
||||||
|
|
Loading…
Reference in a new issue