Author Topic: Questions about writing with tmk code (Added the LibrePCB Source design file)  (Read 296 times)

0 Members and 1 Guest are viewing this topic.

Offline 243750496

  • Thread Starter
  • Posts: 4
uint8_t matrix_scan(void)
{
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
select_row(i);
_delay_us(30); // without this wait read unstable value.
matrix_row_t cols = read_cols();
if (matrix_debouncing != cols) {
matrix_debouncing = cols;
if (debouncing) {
debug("bounce!: "); debug_hex(debouncing); debug("\n");
}
debouncing = DEBOUNCE;
}
unselect_rows();
}

if (debouncing) {
if (--debouncing) {
_delay_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix = matrix_debouncing;
}
}
}
--------------------------------------------------------------------------------------------------------------------------------------
Q1:the code if (debouncing) {seems not an if witch contain the judge condition, how could it working ??
Q2:if (--debouncing) {is this code correct? and why?
Q3:also , how can this code working to judge whether it's debounced
if (matrix_debouncing != cols) {
matrix_debouncing = cols;
-------------------------------------------------------------------------------------------------------------------------------------

/*
Copyright 2012 Jun Wako <wakojun@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
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <avr/io.h>
#include "stdint.h"
#include "led.h"
/*
LED Col 1:PB0
LED Col 2:PB1
LED Col 3:PB2
LED Col 4:PB3
LED Col 5:PB4
LED Col 6:PB5
LED Col 7:PB6
LED Col 8:PB7
LED Col 9:PF0
LED Col 10:PF1
LED Col 11:PF2
LED Col 12:PF3
LED Col 13:PF4
LED Col 14:PF5
*/

/*
LED Row 1:PA1
LED Row 2:PA2
LED Row 3:PA3
*/

void led_set(uint8_t usb_led)
{
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        // output low
        DDRB |= (1<<2);
        PORTB &= ~(1<<2);
    } else {
        // Hi-Z
        DDRB &= ~(1<<2);
        PORTB &= ~(1<<2);
    }
}
---------------------------------------------------------------------------------------------------------------------------------------------------------
Q4:how to make it lighting all the time ? the code is?
(i just ask for a tutorial as an example , i will try to write advance code by myself , maybe like flashing LED light with some key pressed ).BTW:the tutorial for led.c writing is so less, so i hope you can help me(give me an example as tutorial ), thx in advance! :)

because i have designed the keyboard with 3 controller , the reason is simple is that usb only can provide a limited current so that i need for 3 to afford full led and the keys,
it's used librepcb (like Kicad)to produce
Q5:as said previous i have 3 controller :
1 for keys and core leds
2 for Other Leds
so , if i can not get single led fuction compiled , i will not be able to use the other leds, so i hope to get a way to slove the problem
--------------------------------------------------------------------------------------------------------------------------------------------------------------

BTW:you can use the source design file in any ways if you like(modify produce sell and republish and etc)
« Last Edit: Wed, 11 April 2018, 07:50:03 by 243750496 »