From bef43993edd8f94ba8ecc06950e5c81932648d09 Mon Sep 17 00:00:00 2001 From: skullY Date: Sun, 23 Apr 2017 14:42:20 -0700 Subject: [PATCH] working backlight support, need to figure out why BACKLIGHT_ENABLE crashes. --- .../simontester/keymaps/default/keymap.c | 34 ++++++++----------- keyboards/simontester/led.c | 4 +-- keyboards/simontester/matrix.c | 18 +++++----- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/keyboards/simontester/keymaps/default/keymap.c b/keyboards/simontester/keymaps/default/keymap.c index f6b754e248..677ed501c8 100644 --- a/keyboards/simontester/keymaps/default/keymap.c +++ b/keyboards/simontester/keymaps/default/keymap.c @@ -1,4 +1,4 @@ -/* Copyright 2017 REPLACE_WITH_YOUR_NAME +/* Copyright 2017 skully * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,45 +14,39 @@ * along with this program. If not, see . */ #include "simontester.h" +#include "printf.h" const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [0] = KEYMAP( - KC_1, F(2), \ - F(0), F(1) \ + KC_1, KC_2, \ + F(0), F(1) \ ), }; +const uint16_t PROGMEM fn_actions[] = { + [0] = ACTION_FUNCTION(0), + [1] = ACTION_FUNCTION(1), +}; + void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) { - static bool backlight; + if (!record->event.pressed) { + return; + } switch (id) { case 0: + print("Turning backlight off.\n"); palSetPad(GPIOA, 6); palSetPad(GPIOA, 3); palSetPad(GPIOA, 15); palSetPad(GPIOB, 5); - backlight = false; break; case 1: + print("Turning backlight on.\n"); palClearPad(GPIOA, 6); palClearPad(GPIOA, 3); palClearPad(GPIOA, 15); palClearPad(GPIOB, 5); - backlight = true; break; - case 2: - if (backlight) { - palSetPad(GPIOA, 6); - palSetPad(GPIOA, 3); - palSetPad(GPIOA, 15); - palSetPad(GPIOB, 5); - backlight = false; - } else { - palClearPad(GPIOA, 6); - palClearPad(GPIOA, 3); - palClearPad(GPIOA, 15); - palClearPad(GPIOB, 5); - backlight = true; - } } } diff --git a/keyboards/simontester/led.c b/keyboards/simontester/led.c index cce90ea627..a3e12fa714 100644 --- a/keyboards/simontester/led.c +++ b/keyboards/simontester/led.c @@ -18,10 +18,10 @@ #include "hal.h" #include "backlight.h" #include "led.h" -#include "print.h" +#include "printf.h" void backlight_init_ports(void) { - print("backlight_init_ports()\n"); + printf("backlight_init_ports()\n"); /* palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOA, 3, PAL_MODE_OUTPUT_PUSHPULL); diff --git a/keyboards/simontester/matrix.c b/keyboards/simontester/matrix.c index 9989e2a39d..a28f5fc4ef 100644 --- a/keyboards/simontester/matrix.c +++ b/keyboards/simontester/matrix.c @@ -4,7 +4,7 @@ #include "hal.h" #include "timer.h" #include "wait.h" -#include "print.h" +#include "printf.h" #include "backlight.h" #include "matrix.h" @@ -26,6 +26,7 @@ static uint16_t debouncing_time = 0; void matrix_init(void) { + printf("matrix init\n"); //debug_matrix = true; /* Column(sense) */ @@ -44,18 +45,16 @@ void matrix_init(void) { memset(matrix_debouncing, 0, MATRIX_ROWS); /* Setup the backlight */ -/* palSetPadMode(GPIOA, 6, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOA, 3, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOA, 15, PAL_MODE_OUTPUT_PUSHPULL); palSetPadMode(GPIOB, 5, PAL_MODE_OUTPUT_PUSHPULL); // Set them high to turn off the LEDs - palSetPad(GPIOA, 6); + palClearPad(GPIOA, 6); palSetPad(GPIOA, 3); palSetPad(GPIOA, 15); palSetPad(GPIOB, 5); -*/ } uint8_t matrix_scan(void) { @@ -77,6 +76,7 @@ uint8_t matrix_scan(void) { matrix[0] = matrix_debouncing[0]; debouncing = false; } + return 1; } @@ -89,16 +89,16 @@ matrix_row_t matrix_get_row(uint8_t row) { } void matrix_print(void) { - xprintf("\nr/c 01234567\n"); + printf("\nr/c 01234567\n"); for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - xprintf("%X0: ", row); + printf("%X0: ", row); matrix_row_t data = matrix_get_row(row); for (int col = 0; col < MATRIX_COLS; col++) { if (data & (1<