Skip to content

Commit

Permalink
update to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
adi4086 committed Jun 25, 2024
1 parent cd6ffeb commit 70af472
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 3 deletions.
43 changes: 43 additions & 0 deletions keyboards/nuphy/air60_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {

case RGB_VAI:
case RGB_VAD:
case RGB_SAI:
case RGB_SAD:
case RGB_TOG:
if (game_mode_enable) { break; }
call_update_eeprom_data(&rgb_update);
break;

case RGB_MOD:
case RGB_RMOD:
case RGB_HUI:
case RGB_HUD:
case RGB_SPI:
case RGB_SPD:
case RGB_M_P:
if (game_mode_enable) { return false; }
call_update_eeprom_data(&rgb_update);
break;
Expand Down Expand Up @@ -285,12 +291,24 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
}
return false;

case RGB_RMOD:
if (record->event.pressed) {
rgb_matrix_step_reverse_noeeprom();
}
return false;

case RGB_HUI:
if (record->event.pressed) {
rgb_matrix_increase_hue_noeeprom();
}
return false;

case RGB_HUD:
if (record->event.pressed) {
rgb_matrix_decrease_hue_noeeprom();
}
return false;

case RGB_SPI:
if (record->event.pressed) {
rgb_matrix_increase_speed_noeeprom();
Expand All @@ -303,6 +321,30 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
}
return false;

case RGB_SAI:
if (record->event.pressed) {
rgb_matrix_increase_sat_noeeprom();
}
return false;

case RGB_SAD:
if (record->event.pressed) {
rgb_matrix_decrease_sat_noeeprom();
}
return false;

case RGB_M_P:
if (record->event.pressed) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
}
return false;

case RGB_TOG:
if (record->event.pressed) {
rgb_matrix_toggle_noeeprom();
}
return false;

case DEV_RESET:
if (record->event.pressed) {
f_dev_reset_press = 1;
Expand Down Expand Up @@ -359,6 +401,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
return false;

case SLEEP_NOW:
if (USB_ACTIVE) { return false; }
if (record->event.pressed) {
wait_ms(100);
} else {
Expand Down
67 changes: 65 additions & 2 deletions keyboards/nuphy/air60_v2/ansi/rf.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void rf_protocol_receive(void) {
bat_per_debounce = 0;
}
bat_per_debounce++;
if (dev_info.rf_charge & 0x01) { dev_info.rf_battery = 100; }
// if (dev_info.rf_charge & 0x01) { dev_info.rf_battery = 100; }
} else {
if (dev_info.rf_state != RF_INVAILD) {
if (error_cnt >= 5) {
Expand Down Expand Up @@ -272,6 +272,20 @@ uint8_t uart_send_cmd(uint8_t cmd, uint8_t wait_ack, uint8_t delayms) {
Usart_Mgr.TXDBuf[2] = 0x00;

switch (cmd) {
case CMD_POWER_UP: {
Usart_Mgr.TXDBuf[3] = 1;
Usart_Mgr.TXDBuf[4] = 0;
Usart_Mgr.TXDBuf[5] = 0;
break;
}

case CMD_SNIF: {
Usart_Mgr.TXDBuf[3] = 1;
Usart_Mgr.TXDBuf[4] = 0;
Usart_Mgr.TXDBuf[5] = 0;
break;
}

case CMD_SLEEP: {
Usart_Mgr.TXDBuf[3] = 1;
Usart_Mgr.TXDBuf[4] = 0;
Expand Down Expand Up @@ -354,6 +368,34 @@ uint8_t uart_send_cmd(uint8_t cmd, uint8_t wait_ack, uint8_t delayms) {
break;
}

case CMD_SET_24G_NAME: {
Usart_Mgr.TXDBuf[3] = 42;
Usart_Mgr.TXDBuf[4] = 42;
Usart_Mgr.TXDBuf[5] = 3;
Usart_Mgr.TXDBuf[6] = 'N';
Usart_Mgr.TXDBuf[8] = 'u';
Usart_Mgr.TXDBuf[10] = 'P';
Usart_Mgr.TXDBuf[12] = 'h';
Usart_Mgr.TXDBuf[14] = 'y';
Usart_Mgr.TXDBuf[16] = ' ';
Usart_Mgr.TXDBuf[18] = 'A';
Usart_Mgr.TXDBuf[20] = 'i';
Usart_Mgr.TXDBuf[22] = 'r';
Usart_Mgr.TXDBuf[24] = '6';
Usart_Mgr.TXDBuf[26] = '0';
Usart_Mgr.TXDBuf[28] = 'v';
Usart_Mgr.TXDBuf[30] = '2';
Usart_Mgr.TXDBuf[32] = ' ';
Usart_Mgr.TXDBuf[34] = 'D';
Usart_Mgr.TXDBuf[36] = 'o';
Usart_Mgr.TXDBuf[38] = 'n';
Usart_Mgr.TXDBuf[40] = 'g';
Usart_Mgr.TXDBuf[42] = 'l';
Usart_Mgr.TXDBuf[44] = 'e';
Usart_Mgr.TXDBuf[46] = get_checksum(Usart_Mgr.TXDBuf + 4, Usart_Mgr.TXDBuf[3]); // sum
break;
}

case CMD_READ_DATA: {
Usart_Mgr.TXDBuf[3] = 2;
Usart_Mgr.TXDBuf[4] = 0x00;
Expand All @@ -362,6 +404,25 @@ uint8_t uart_send_cmd(uint8_t cmd, uint8_t wait_ack, uint8_t delayms) {
break;
}

case CMD_WRITE_DATA: {
uint8_t i;
func_tab[4] = dev_info.link_mode;
func_tab[5] = dev_info.rf_channel;
func_tab[6] = dev_info.ble_channel;

Usart_Mgr.TXDBuf[3] = FUNC_VALID_LEN + 2;
Usart_Mgr.TXDBuf[4] = 0;
Usart_Mgr.TXDBuf[5] = FUNC_VALID_LEN;

for (i = 0; i < FUNC_VALID_LEN; i++) {
Usart_Mgr.TXDBuf[6 + i] = func_tab[i];
}
Usart_Mgr.TXDBuf[6 + i] = get_checksum(func_tab, FUNC_VALID_LEN);
Usart_Mgr.TXDBuf[6 + i] += 0;
Usart_Mgr.TXDBuf[6 + i] += FUNC_VALID_LEN;
break;
}

case CMD_RF_DFU: {
Usart_Mgr.TXDBuf[3] = 1;
Usart_Mgr.TXDBuf[4] = 0;
Expand Down Expand Up @@ -476,7 +537,8 @@ void uart_send_bytes(uint8_t *Buffer, uint32_t Length) {
wait_us(50 + Length * 30);
gpio_write_pin_high(NRF_WAKEUP_PIN);

wait_us(800 - Length * 30);
// wait_us(800 - Length * 30);
wait_us(400);
}

/**
Expand Down Expand Up @@ -615,4 +677,5 @@ void rf_device_init(void) {
}

uart_send_cmd(CMD_SET_NAME, 10, 20);
uart_send_cmd(CMD_SET_24G_NAME, 10, 20);
}
2 changes: 1 addition & 1 deletion keyboards/nuphy/air60_v2/ansi/user_kb.c
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void led_power_handle(void) {
return;
}

if ((rgb_matrix_is_enabled() && rgb_matrix_get_val() != 0) || !is_side_rgb_off() || rgb_required > 0) {
if (rgb_matrix_is_enabled() && (rgb_matrix_get_val() != 0 || !is_side_rgb_off() || rgb_required > 0)) {
rgb_required = 0;
led_debounce = 4;
pwr_led_on();
Expand Down

0 comments on commit 70af472

Please sign in to comment.