QMK Discussion Thread

That should be possible. But you want to call layer_on(x) or the like.

https://github.com/qmk/qmk_firmware/blob/master/tmk_core/common/action_layer.h#L59-L66

1 Like

Is there any reason Timer 4 on the atmega32u4 isn’t supported for backlighting? Pins D6/D7 support a hardware PWM from it.

I ask because I’ve got a YD68 which uses D6 as the backlight pin. I took a stab at it over the weekend, but didn’t get far. Of course, I’m not neither a C nor firmware developer, so there’s a lot of parts I didn’t understand.

Probably because the backlight is written to support Timer 1, I think you’d have to rewrite a bunch of the code to support timer 4.

It may be worth opening an issue on github.

Does QMK support “IO Expander” ?

I plan to use a Pro Micro with this MCP23018T-E/SS

I want a relatively cheap “controller board” with QMK support because I can’t directly use an ATMega32u4, I just don’t get the stuffs about “bootloader” :frowning_face:

Yes. The ErgoDox EZ (and Dactyl) uses an IO Expander, actually. And uses the “MCP23018-E/SP” specifically. And both use QMK. So I think you should be fine with the expander that you’ve listed.

1 Like

Just in addition to @drashna’s reply: according to the datasheet, the SP version of the MCP23018 is the through hole, DIP version, while the SS version is a SMD version in SSOP package.

Both versions will work, but the SP version is easier to deal with.

2 Likes

Hello!
I need help with customizing the leds.

I have two leds connected to D0 and D4, I use D4 for Capslock.
here is what I want with the D0:

  • if default layer is “normal layer” (index is 0) - I use keycode DF(0) to switch
    • turn D0 led off
  • if default layer is “numpad layer” (index is 4) - I use keycode DF(4) to switch
    • num lock is off: blink the D0 led ( turn it on/off every 0.1s )
    • num lock is on: turn D0 led on

C is not my strong programing language,
I put together some code I found after searching,

Here is the code I have currently
#include "tnm40.h"

static uint16_t led_timer;
static bool isNumLockOn = false;
static bool ledOn = false;
static uint8_t default_layer = 0;

void led_set_user(uint8_t usb_led) {
	isNumLockOn = usb_led & (1<<USB_LED_NUM_LOCK);
	
    if (usb_led & (1<<USB_LED_CAPS_LOCK)) {
        PORTD |= (1<<4);
    } else {
        PORTD &= ~(1<<4);
    }
}

void matrix_scan_user(void) {
	default_layer = eeconfig_read_default_layer();
	if (default_layer & (1 << 4)) { // index 4: numpad layer
		if (isNumLockOn) {
			PORTD |= (1<<0);
		} else {
			led_timer = timer_read();
			
			if (timer_elapsed(led_timer) >= 100) {
				if (ledOn) {
					PORTD &= ~(1<<0);
				} else {
					PORTD |= (1<<0);
				}
				ledOn = !ledOn;
			}
		}
	} else {
		PORTD &= ~(1<<0);
	}
}

the D0 led is off even if I have switched default layer to the “numpad layer”.

any help is appreciated! :blush:

EDIT: the “hidden tag” is a bit subtle, isn’t it? :thinking:

Are you sure you want DF here? This changes the base layer. Depending on what you’re doing, a normal layer change (like TG or MO) mya work better here.

But what I’d do is…

void matrix_scan_user(void) {
  static uint16_t led_timer = timer_read();
  static bool is_led_on = false;
  
  PORTD &= ~(1<<0);
  
  if (biton32(default_layer_state) == 4) {
    if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) {
      is_led_on == true;
    } else {
      if (timer_elapsed(led_timer) > 100) {
        is_led_on ^= 1;
        led_timer = read_timer();
      }
    }
    if (is_led_on) { PORTD |= (1<<0); }
  }

  if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
      PORTD |= (1<<4);
  } else {
      PORTD &= ~(1<<4);
  }

}
1 Like

thank you very much!
it is working! :grin:

Are you sure you want DF here? This changes the base layer. Depending on what you’re doing, a normal layer change (like TG or MO) mya work better here.

hmm… it’s just my assumption. While in the “numpad” layer, I won’t be using other layers so I think DF or TG would be the same. :thinking: I did use MO in layer 0, though.

I will try using TG instead of DF. :smiley:

I’m glad to hear it! :slight_smile:

And yeah, DF is for changing the base layer. It’s best for stuff like qwerty vs colemak vs, etc. You can use it other ways, but other layer codes are probably better to use. (and if you do change it, then change the default_layer_state to just layer_state)

1 Like

Hello!
I want to ask about RGB underglow, I plan to use WS2812B (it is supported by QMK)
Do I need to add individual resistor for each led?

I assume that I need to connect a ProMicro pin to “DIN” of WS2812B, is there any specific ProMicro pin I have to use? or any pins is fine? :thinking:

I’m assuming that you’re using WS2182 strips. If so, that’s all you need. Only the backlighting feature needs resisters. The underglow just needs the strip, usually.

If this is for “on the PCB”, then I’m not as sure.

yes, I want to put these WS2182 “on the PCB”.
I will do more research on these then :grinning:

You don’t need resistors, according to the datasheet. However, it do recommend using a 100nF bypass capacitor per LED.

1 Like

Hello!
I need help about flashing ps2avrGB board.

after finish flashing, there is no sound of usb unplug/plug.

if I physically unplug/plug the board, the usb is not recognized:
image

if I reflash with default firmware (from winkeyless.kr) the board works.

I have no problems with other 4 (same) boards I have.

have anyone encountered this problem before? :thinking:

maybe this specific board is faulty? :cry:

Hello!
Is there any option to increase led level of indicator led?

I have wired the indicator leds as below:
image

and here is my code:

Summary

void led_set_kb(uint8_t usb_led) {

// Capslock led
if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
PORTB |= (1<<1);
} else {
PORTB &= ~(1<<1);
}

// lower layer led
if (biton32(layer_state) == 1) {
PORTB |= (1<<2);
} else {
PORTB &= ~(1<<2);
}

// raise layer led
if (biton32(layer_state) == 2) {
PORTB |= (1<<3);
} else {
PORTB &= ~(1<<3);
}

led_set_user(usb_led);
}

they work but they’re pretty dim

There are a lot of ways to drive LEDs and ways to adjust brightness, and most of them aren’t related to firmware. I’d start here.

1 Like

Hello Jack,

Navigating layers is a concept I’m confused with so I setup a 2 row, 3 column macropad to understand. In this example I’m, using TT() to navigate from layer to layer.

#define TAPPING_TOGGLE 3 is set.

Starting from [BASE], when I triple tap on TT(LOAD) etc., as expected, the layer changes all the way through to [OPEN]. This will climb right up layer stack.

But when triple tapping on TT(BASE) while in the [OPEN] layer nothing happens. The [OPEN] layer remains active.

I’m reading the QMK docs but it’s obvious I’m not understanding a basic layer navigation fundamental.

The docs say that navigating to a lower number layer can be problematic but if a keymap has more than a single layer, eventually the user will have to navigate to a lower numbered layer.

Can you help please? Thank you.

Here’s the keymap:

	[BASE] = KEYMAP(
		KC_0, XXXXXXX, TT(LOAD), 
		WPLOAD, CAB, ALTTAB),

	[LOAD] = KEYMAP(
		KC_1, _______, TT(CREATE), 
		WPLOAD, CAB, ALTTAB),

    [CREATE] = KEYMAP(
		KC_2, _______, TT(OPEN), 
		_______, _______, ALTTAB),

	[OPEN] = KEYMAP(
		KC_3, _______, TT(BASE), 
		_______, _______, _______)

Would like to point out that it may be out of date, but at least it’s simple to use it with custom stuff by just importing layouts from kle and has macro support, neither of which configurator has that I’m aware of.

The TT keycode enables the target layer, but doesn’t turn any other layers off. When you hit in, QMK turns BASE on (though it’s actually already on), but OPEN is also still on, so repeated uses are always the TT(BASE) keycode.

Easiest fix would be to use TO(BASE) instead of TT(BASE), but TO doesn’t use the tapping toggle functionality.