working backlight support, need to figure out why BACKLIGHT_ENABLE crashes.

clueboard_arm
skullY 8 years ago
parent f27a4af3fb
commit bef43993ed

@ -1,4 +1,4 @@
/* Copyright 2017 REPLACE_WITH_YOUR_NAME
/* Copyright 2017 skully <skullydazed@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#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;
}
}
}

@ -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);

@ -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<<col))
xprintf("1");
printf("1");
else
xprintf("0");
printf("0");
}
xprintf("\n");
printf("\n");
}
}

Loading…
Cancel
Save