Skip to content

Commit

Permalink
Small fix: kb and user level functions updated, also eeprom functiona…
Browse files Browse the repository at this point in the history
…lity moved from "user" to "kb"
  • Loading branch information
Prens282 committed Jun 10, 2024
1 parent 07b64a6 commit 9be5f0e
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 73 deletions.
58 changes: 30 additions & 28 deletions keyboards/nuphy/air60_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "usb_main.h"
#include "rf_driver.h"

user_config_t user_config;
kb_config_t kb_config;
DEV_INFO_STRUCT dev_info =
{
.rf_baterry = 100,
Expand Down Expand Up @@ -400,7 +400,7 @@ void m_power_on_dial_sw_scan(void)
/**
* @brief qmk process record
*/
bool process_record_user(uint16_t keycode, keyrecord_t *record)
bool process_record_kb(uint16_t keycode, keyrecord_t *record)
{
switch (keycode) {
case RF_DFU:
Expand Down Expand Up @@ -615,10 +615,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record)

case SLEEP_MODE:
if (record->event.pressed) {
if(user_config.sleep_enable) user_config.sleep_enable = false;
else user_config.sleep_enable = true;
if(kb_config.sleep_enable) kb_config.sleep_enable = false;
else kb_config.sleep_enable = true;
f_sleep_show = 1;
eeconfig_update_user_datablock(&user_config);
eeconfig_update_kb_datablock(&kb_config);
}
return false;

Expand Down Expand Up @@ -656,7 +656,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record)
return false;

default:
return true;
return process_record_user(keycode, record);
}
}

Expand Down Expand Up @@ -699,31 +699,31 @@ void timer_pro(void)
*/
void m_londing_eeprom_data(void)
{
eeconfig_read_user_datablock(&user_config);
if (user_config.default_brightness_flag != 0xA5) {
eeconfig_read_kb_datablock(&kb_config);
if (kb_config.default_brightness_flag != 0xA5) {
rgb_matrix_sethsv(255, 255, RGB_MATRIX_MAXIMUM_BRIGHTNESS - RGB_MATRIX_VAL_STEP * 2);
user_config.default_brightness_flag = 0xA5;
user_config.ee_side_mode = side_mode;
user_config.ee_side_light = side_light;
user_config.ee_side_speed = side_speed;
user_config.ee_side_rgb = side_rgb;
user_config.ee_side_colour = side_colour;
user_config.sleep_enable = true;
eeconfig_update_user_datablock(&user_config);
kb_config.default_brightness_flag = 0xA5;
kb_config.ee_side_mode = side_mode;
kb_config.ee_side_light = side_light;
kb_config.ee_side_speed = side_speed;
kb_config.ee_side_rgb = side_rgb;
kb_config.ee_side_colour = side_colour;
kb_config.sleep_enable = true;
eeconfig_update_kb_datablock(&kb_config);
} else {
side_mode = user_config.ee_side_mode;
side_light = user_config.ee_side_light;
side_speed = user_config.ee_side_speed;
side_rgb = user_config.ee_side_rgb;
side_colour = user_config.ee_side_colour;
side_mode = kb_config.ee_side_mode;
side_light = kb_config.ee_side_light;
side_speed = kb_config.ee_side_speed;
side_rgb = kb_config.ee_side_rgb;
side_colour = kb_config.ee_side_colour;
}
}


/**
qmk keyboard post init
qmk keyboard post init kb
*/
void keyboard_post_init_user(void)
void keyboard_post_init_kb(void)
{
m_gpio_init();
rf_uart_init();
Expand All @@ -733,23 +733,25 @@ void keyboard_post_init_user(void)
m_break_all_key();
m_londing_eeprom_data();
m_power_on_dial_sw_scan();

keyboard_post_init_user();
}

/**
rgb_matrix_indicators_user
rgb_matrix_indicators_kb
*/
bool rgb_matrix_indicators_user(void)
bool rgb_matrix_indicators_kb(void)
{
if(f_bat_num_show) {
num_led_show();
}
return true;
return rgb_matrix_indicators_user();
}

/**
housekeeping_task_user
housekeeping_task_kb
*/
void housekeeping_task_user(void)
void housekeeping_task_kb(void)
{
timer_pro();

Expand Down
2 changes: 1 addition & 1 deletion keyboards/nuphy/air60_v2/ansi/ansi.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,4 @@ typedef struct
uint8_t ee_side_colour;
uint8_t sleep_enable;
uint8_t retain2;
} user_config_t;
} kb_config_t;
2 changes: 1 addition & 1 deletion keyboards/nuphy/air60_v2/ansi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#define TAP_CODE_DELAY 8
#define DYNAMIC_KEYMAP_MACRO_DELAY 8
#define EECONFIG_USER_DATA_SIZE 8
#define EECONFIG_KB_DATA_SIZE 8

#define DEV_MODE_PIN C0
#define SYS_MODE_PIN C1
Expand Down
38 changes: 19 additions & 19 deletions keyboards/nuphy/air60_v2/ansi/side.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ uint8_t r_temp, g_temp, b_temp;

extern bool f_bat_hold;
extern DEV_INFO_STRUCT dev_info;
extern user_config_t user_config;
extern kb_config_t kb_config;
extern uint8_t rf_blink_cnt;
extern uint16_t rf_link_show_time;

Expand Down Expand Up @@ -142,8 +142,8 @@ void light_level_control(uint8_t brighten)
} else
side_light--;
}
user_config.ee_side_light = side_light;
eeconfig_update_user_datablock(&user_config);
kb_config.ee_side_light = side_light;
eeconfig_update_kb_datablock(&kb_config);
}

/**
Expand All @@ -161,8 +161,8 @@ void light_speed_contol(uint8_t fast)
} else {
if ((side_speed) < LIGHT_SPEED_MAX) side_speed++;
}
user_config.ee_side_speed = side_speed;
eeconfig_update_user_datablock(&user_config);
kb_config.ee_side_speed = side_speed;
eeconfig_update_kb_datablock(&kb_config);
}

/**
Expand Down Expand Up @@ -202,9 +202,9 @@ void side_colour_control(uint8_t dir)
}
}
}
user_config.ee_side_rgb = side_rgb;
user_config.ee_side_colour = side_colour;
eeconfig_update_user_datablock(&user_config);
kb_config.ee_side_rgb = side_rgb;
kb_config.ee_side_colour = side_colour;
eeconfig_update_kb_datablock(&kb_config);
}

/**
Expand All @@ -227,8 +227,8 @@ void side_mode_control(uint8_t dir)
}
}
side_play_point = 0;
user_config.ee_side_mode = side_mode;
eeconfig_update_user_datablock(&user_config);
kb_config.ee_side_mode = side_mode;
eeconfig_update_kb_datablock(&kb_config);
}

/**
Expand Down Expand Up @@ -303,7 +303,7 @@ void sleep_sw_led_show(void)
}

if (sleep_show_flag) {
if (user_config.sleep_enable) {
if (kb_config.sleep_enable) {
r_temp = 0x00;
g_temp = SIDE_BLINK_LIGHT;
b_temp = 0x00;
Expand Down Expand Up @@ -811,14 +811,14 @@ void device_reset_init(void)
rgb_matrix_set_speed(255 - RGB_MATRIX_SPD_STEP * 2);
rgb_matrix_sethsv(255, 255, RGB_MATRIX_MAXIMUM_BRIGHTNESS - RGB_MATRIX_VAL_STEP * 2);

user_config.default_brightness_flag = 0xA5;
user_config.ee_side_mode = side_mode;
user_config.ee_side_light = side_light;
user_config.ee_side_speed = side_speed;
user_config.ee_side_rgb = side_rgb;
user_config.ee_side_colour = side_colour;
user_config.sleep_enable = true;
eeconfig_update_user_datablock(&user_config);
kb_config.default_brightness_flag = 0xA5;
kb_config.ee_side_mode = side_mode;
kb_config.ee_side_light = side_light;
kb_config.ee_side_speed = side_speed;
kb_config.ee_side_rgb = side_rgb;
kb_config.ee_side_colour = side_colour;
kb_config.sleep_enable = true;
eeconfig_update_kb_datablock(&kb_config);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions keyboards/nuphy/air60_v2/ansi/sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "hal_usb.h"
#include "usb_main.h"

extern user_config_t user_config;
extern kb_config_t kb_config;
extern DEV_INFO_STRUCT dev_info;
extern uint16_t rf_linking_time;
extern uint16_t no_act_time;
Expand All @@ -46,7 +46,7 @@ void Sleep_Handle(void) {
if (f_goto_sleep) {
f_goto_sleep = 0;

if(user_config.sleep_enable) {
if(kb_config.sleep_enable) {
if (dev_info.rf_state == RF_CONNECT)
uart_send_cmd(CMD_SET_CONFIG, 5, 5);
else
Expand Down
14 changes: 8 additions & 6 deletions keyboards/nuphy/air75_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ void londing_eeprom_data(void) {
}

/* qmk process record */
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
no_act_time = 0;
switch (keycode) {
case RF_DFU:
Expand Down Expand Up @@ -682,22 +682,22 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false;

default:
return true;
return process_record_user(keycode, record)
}
}


bool rgb_matrix_indicators_user(void)
bool rgb_matrix_indicators_kb(void)
{
if(f_bat_num_show) {
num_led_show();
}
rgb_matrix_set_color(RGB_MATRIX_LED_COUNT-1, 0, 0, 0);
return true;
return rgb_matrix_indicators_user();
}

/* qmk keyboard post init */
void keyboard_post_init_user(void) {
void keyboard_post_init_kb(void) {
gpio_init();
rf_uart_init();
wait_ms(500);
Expand All @@ -706,10 +706,12 @@ void keyboard_post_init_user(void) {
break_all_key();
dial_sw_fast_scan();
londing_eeprom_data();

keyboard_post_init_user();
}

/* qmk housekeeping task */
void housekeeping_task_user(void) {
void housekeeping_task_kb(void) {
timer_pro();

uart_receive_pro();
Expand Down
18 changes: 10 additions & 8 deletions keyboards/nuphy/air96_v2/ansi/ansi.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ void m_power_on_dial_sw_scan(void)
/**
* @brief qmk process record
*/
bool process_record_user(uint16_t keycode, keyrecord_t *record)
bool process_record_kb(uint16_t keycode, keyrecord_t *record)
{
switch (keycode) {
case RF_DFU:
Expand Down Expand Up @@ -642,7 +642,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record)
return false;

default:
return true;
return process_record_user(keycode, record)
}
}

Expand Down Expand Up @@ -709,7 +709,7 @@ void m_londing_eeprom_data(void)
/**
* qmk keyboard post init
*/
void keyboard_post_init_user(void)
void keyboard_post_init_kb(void)
{
m_gpio_init();
rf_uart_init();
Expand All @@ -719,23 +719,25 @@ void keyboard_post_init_user(void)
m_break_all_key();
m_londing_eeprom_data();
m_power_on_dial_sw_scan();

keyboard_post_init_user();
}

/**
rgb_matrix_indicators_user
rgb_matrix_indicators_kb
*/
bool rgb_matrix_indicators_user(void)
bool rgb_matrix_indicators_kb(void)
{
if(f_bat_num_show) {
num_led_show();
}
return true;
return rgb_matrix_indicators_user();
}

/**
housekeeping_task_user
housekeeping_task_kb
*/
void housekeeping_task_user(void)
void housekeeping_task_kb(void)
{
timer_pro();

Expand Down
Loading

0 comments on commit 9be5f0e

Please sign in to comment.