update

update

update

reset submodule
This commit is contained in:
nuphy-src 2024-07-02 18:26:17 +08:00
parent 00bc5afdd0
commit a4f5754d1f
10 changed files with 116 additions and 118 deletions

View File

@ -15,7 +15,7 @@ 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 "user_kb.h"
#include "kb_util.h"
#include "ansi.h"
#include "usb_main.h"
@ -152,13 +152,13 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
case SIDE_VAI:
if (record->event.pressed) {
side_light_contol(1);
side_light_control(1);
}
return false;
case SIDE_VAD:
if (record->event.pressed) {
side_light_contol(0);
side_light_control(0);
}
return false;
@ -176,13 +176,13 @@ bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
case SIDE_SPI:
if (record->event.pressed) {
side_speed_contol(1);
side_speed_control(1);
}
return false;
case SIDE_SPD:
if (record->event.pressed) {
side_speed_contol(0);
side_speed_control(0);
}
return false;
@ -271,6 +271,4 @@ void housekeeping_task_kb(void) {
side_led_show();
sleep_handle();
housekeeping_task_user();
}

View File

@ -3,7 +3,7 @@
"manufacturer": "NuPhy",
"usb":{
"vid": "0x19F5",
"pid": "0x3245",
"pid": "0x3246",
"device_version": "0.0.1",
"no_startup_check": true
},
@ -131,32 +131,32 @@
{"matrix": [2, 16], "x": 150, "y": 20, "flags": 4},
{"matrix": [1, 15], "x": 150, "y": 30, "flags": 4},
{"matrix": [3, 13], "x": 127.5, "y": 30, "flags": 4},
{"matrix": [3, 11], "x": 117.5, "y": 30, "flags": 4},
{"matrix": [3, 10], "x": 107.5, "y": 30, "flags": 4},
{"matrix": [3, 9], "x": 97.5, "y": 30, "flags": 4},
{"matrix": [3, 8], "x": 87.5, "y": 30, "flags": 4},
{"matrix": [3, 7], "x": 77.5, "y": 30, "flags": 4},
{"matrix": [3, 6], "x": 67.5, "y": 30, "flags": 4},
{"matrix": [3, 5], "x": 57.5, "y": 30, "flags": 4},
{"matrix": [3, 4], "x": 47.5, "y": 30, "flags": 4},
{"matrix": [3, 3], "x": 37.5, "y": 30, "flags": 4},
{"matrix": [3, 2], "x": 27.5, "y": 30, "flags": 4},
{"matrix": [3, 1], "x": 17.5, "y": 30, "flags": 4},
{"matrix": [3, 13], "x": 127, "y": 30, "flags": 4},
{"matrix": [3, 11], "x": 117, "y": 30, "flags": 4},
{"matrix": [3, 10], "x": 107, "y": 30, "flags": 4},
{"matrix": [3, 9], "x": 97, "y": 30, "flags": 4},
{"matrix": [3, 8], "x": 87, "y": 30, "flags": 4},
{"matrix": [3, 7], "x": 77, "y": 30, "flags": 4},
{"matrix": [3, 6], "x": 67, "y": 30, "flags": 4},
{"matrix": [3, 5], "x": 57, "y": 30, "flags": 4},
{"matrix": [3, 4], "x": 47, "y": 30, "flags": 4},
{"matrix": [3, 3], "x": 37, "y": 30, "flags": 4},
{"matrix": [3, 2], "x": 27, "y": 30, "flags": 4},
{"matrix": [3, 1], "x": 17, "y": 30, "flags": 4},
{"matrix": [3, 0], "x": 0, "y": 30, "flags": 4},
{"matrix": [4, 0], "x": 0, "y": 40, "flags": 4},
{"matrix": [4, 2], "x": 22.5, "y": 40, "flags": 4},
{"matrix": [4, 3], "x": 32.5, "y": 40, "flags": 4},
{"matrix": [4, 4], "x": 42.5, "y": 40, "flags": 4},
{"matrix": [4, 5], "x": 52.5, "y": 40, "flags": 4},
{"matrix": [4, 6], "x": 62.5, "y": 40, "flags": 4},
{"matrix": [4, 7], "x": 72.5, "y": 40, "flags": 4},
{"matrix": [4, 8], "x": 82.5, "y": 40, "flags": 4},
{"matrix": [4, 9], "x": 92.5, "y": 40, "flags": 4},
{"matrix": [4, 10], "x": 102.5, "y": 40, "flags": 4},
{"matrix": [4, 11], "x": 112.5, "y": 40, "flags": 4},
{"matrix": [4, 13], "x": 122.5, "y": 40, "flags": 4},
{"matrix": [4, 2], "x": 22, "y": 40, "flags": 4},
{"matrix": [4, 3], "x": 32, "y": 40, "flags": 4},
{"matrix": [4, 4], "x": 42, "y": 40, "flags": 4},
{"matrix": [4, 5], "x": 52, "y": 40, "flags": 4},
{"matrix": [4, 6], "x": 62, "y": 40, "flags": 4},
{"matrix": [4, 7], "x": 72, "y": 40, "flags": 4},
{"matrix": [4, 8], "x": 82, "y": 40, "flags": 4},
{"matrix": [4, 9], "x": 92, "y": 40, "flags": 4},
{"matrix": [4, 10], "x": 102, "y": 40, "flags": 4},
{"matrix": [4, 11], "x": 112, "y": 40, "flags": 4},
{"matrix": [4, 13], "x": 122, "y": 40, "flags": 4},
{"matrix": [4, 14], "x": 140, "y": 40, "flags": 4},
{"matrix": [2, 15], "x": 150, "y": 40, "flags": 4},
@ -166,9 +166,9 @@
{"matrix": [3, 14], "x": 120, "y": 50, "flags": 4},
{"matrix": [5, 10], "x": 110, "y": 50, "flags": 4},
{"matrix": [5, 9], "x": 100, "y": 50, "flags": 4},
{"matrix": [5, 6], "x": 37.5, "y": 50, "flags": 4},
{"matrix": [5, 6], "x": 37, "y": 50, "flags": 4},
{"matrix": [5, 2], "x": 25, "y": 50, "flags": 4},
{"matrix": [5, 1], "x": 12.5, "y": 50, "flags": 4},
{"matrix": [5, 1], "x": 12, "y": 50, "flags": 4},
{"matrix": [5, 0], "x": 0, "y": 50, "flags": 4},
{"flags": 4}
]

View File

@ -15,14 +15,14 @@ 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 "user_kb.h"
#include "kb_util.h"
#include "ansi.h"
#include "usb_main.h"
#include "rf_driver.h"
kb_config_t kb_config;
DEV_INFO_STRUCT dev_info = {
.rf_baterry = 100,
.rf_battery = 100,
.link_mode = LINK_USB,
.rf_state = RF_IDLE,
};
@ -59,32 +59,32 @@ extern uint8_t side_rgb;
extern uint8_t side_colour;
/**
* @brief gpio initial.
* @brief Initialize GPIO.
*/
void gpio_init(void) {
/* enable led power driver */
setPinOutput(DRIVER_LED_CS_PIN);
setPinOutput(DRIVER_SIDE_CS_PIN);
writePinLow(DRIVER_LED_CS_PIN);
writePinLow(DRIVER_SIDE_CS_PIN);
/* set side led pin output low */
setPinOutput(DRIVER_SIDE_PIN);
writePinLow(DRIVER_SIDE_PIN);
/* enable LED power driver */
gpio_set_pin_output_push_pull(DRIVER_LED_CS_PIN);
gpio_set_pin_output_push_pull(DRIVER_SIDE_CS_PIN);
gpio_write_pin_low(DRIVER_LED_CS_PIN);
gpio_write_pin_low(DRIVER_SIDE_CS_PIN);
/* set side LED pin output low */
gpio_set_pin_output_push_pull(DRIVER_SIDE_PIN);
gpio_write_pin_low(DRIVER_SIDE_PIN);
/* config RF module pin */
setPinOutput(NRF_WAKEUP_PIN);
writePinHigh(NRF_WAKEUP_PIN);
setPinInputHigh(NRF_TEST_PIN);
gpio_set_pin_output_push_pull(NRF_WAKEUP_PIN);
gpio_write_pin_high(NRF_WAKEUP_PIN);
gpio_set_pin_input_high(NRF_TEST_PIN);
/* reset RF module */
setPinOutput(NRF_RESET_PIN);
writePinLow(NRF_RESET_PIN);
gpio_set_pin_output_push_pull(NRF_RESET_PIN);
gpio_write_pin_low(NRF_RESET_PIN);
wait_ms(50);
writePinHigh(NRF_RESET_PIN);
gpio_write_pin_high(NRF_RESET_PIN);
/* config dial switch pin */
setPinInputHigh(DEV_MODE_PIN);
setPinInputHigh(SYS_MODE_PIN);
/* open led DC driver */
setPinOutput(DC_BOOST_PIN);
writePinHigh(DC_BOOST_PIN);
gpio_set_pin_input_high(DEV_MODE_PIN);
gpio_set_pin_input_high(SYS_MODE_PIN);
/* open LED DC driver */
gpio_set_pin_output_push_pull(DC_BOOST_PIN);
gpio_write_pin_high(DC_BOOST_PIN);
}
/**
@ -118,7 +118,7 @@ void long_press_key(void) {
rf_sw_press_delay = 0;
}
// The device is restored to factory Settings
// The device is restored to factory settings
if (f_dev_reset_press) {
dev_reset_press_delay++;
if (dev_reset_press_delay >= DEV_RESET_PRESS_DELAY) {
@ -246,11 +246,11 @@ void dial_sw_scan(void) {
}
dial_scan_timer = timer_read32();
setPinInputHigh(DEV_MODE_PIN);
setPinInputHigh(SYS_MODE_PIN);
gpio_set_pin_input_high(DEV_MODE_PIN);
gpio_set_pin_input_high(SYS_MODE_PIN);
if (readPin(DEV_MODE_PIN)) dial_scan |= 0X01;
if (readPin(SYS_MODE_PIN)) dial_scan |= 0X02;
if (gpio_read_pin(DEV_MODE_PIN)) dial_scan |= 0X01;
if (gpio_read_pin(SYS_MODE_PIN)) dial_scan |= 0X02;
if (dial_save != dial_scan) {
break_all_key();
@ -316,16 +316,16 @@ void dial_sw_fast_scan(void) {
uint8_t dial_check_sys = 0;
uint8_t debounce = 0;
setPinInputHigh(DEV_MODE_PIN);
setPinInputHigh(SYS_MODE_PIN);
gpio_set_pin_input_high(DEV_MODE_PIN);
gpio_set_pin_input_high(SYS_MODE_PIN);
// Debounce to get a stable state
for(debounce=0; debounce<10; debounce++) {
dial_scan_dev = 0;
dial_scan_sys = 0;
if (readPin(DEV_MODE_PIN)) dial_scan_dev = 0x01;
if (gpio_read_pin(DEV_MODE_PIN)) dial_scan_dev = 0x01;
else dial_scan_dev = 0;
if (readPin(SYS_MODE_PIN)) dial_scan_sys = 0x01;
if (gpio_read_pin(SYS_MODE_PIN)) dial_scan_sys = 0x01;
else dial_scan_sys = 0;
if((dial_scan_dev != dial_check_dev)||(dial_scan_sys != dial_check_sys))
{
@ -399,7 +399,7 @@ void timer_pro(void) {
void londing_eeprom_data(void) {
eeconfig_read_kb_datablock(&kb_config);
if (kb_config.default_brightness_flag != 0xA5) {
/* first power on, set rgb matrix brightness at middle level*/
/* upon first power on, set RGB matrix brightness to middle level */
rgb_matrix_sethsv(255, 255, RGB_MATRIX_MAXIMUM_BRIGHTNESS - RGB_MATRIX_VAL_STEP * 2);
kb_config.default_brightness_flag = 0xA5;
kb_config.ee_side_mode = side_mode;

View File

@ -47,7 +47,7 @@ typedef enum {
#define RF_DISCONNECT 4
#define RF_SLEEP 5
#define RF_SNIF 6
#define RF_INVAILD 0XFE
#define RF_INVALID 0XFE
#define RF_ERR_STATE 0XFF
#define CMD_POWER_UP 0XF0
@ -124,7 +124,7 @@ typedef struct
uint8_t rf_state;
uint8_t rf_charge;
uint8_t rf_led;
uint8_t rf_baterry;
uint8_t rf_battery;
uint8_t sys_sw_state;
} DEV_INFO_STRUCT;
@ -147,8 +147,8 @@ void rf_device_init(void);
void uart_send_report_repeat(void);
void uart_receive_pro(void);
void uart_send_report(uint8_t report_type, uint8_t *report_buf, uint8_t report_size);
void side_speed_contol(uint8_t dir);
void side_light_contol(uint8_t dir);
void side_speed_control(uint8_t dir);
void side_light_control(uint8_t dir);
void side_colour_control(uint8_t dir);
void side_mode_control(uint8_t dir);
void side_led_show(void);

View File

@ -15,7 +15,7 @@ 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 "user_kb.h"
#include "kb_util.h"
#include "uart.h" // qmk uart.h
#include "ansi.h"
#include "rf_driver.h"
@ -146,7 +146,7 @@ void uart_send_report_repeat(void)
wait_us(200);
if(f_bit_kb_act)
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
uart_send_report(CMD_RPT_BIT_KB, uart_bit_report_buf, 16);
}
else {
f_bit_kb_act = 0;
@ -256,11 +256,11 @@ void RF_Protocol_Receive(void) {
dev_info.rf_charge = Usart_Mgr.RXDBuf[7];
if (Usart_Mgr.RXDBuf[8] <= 100) dev_info.rf_baterry = Usart_Mgr.RXDBuf[8];
if (dev_info.rf_charge & 0x01) dev_info.rf_baterry = 100;
if (Usart_Mgr.RXDBuf[8] <= 100) dev_info.rf_battery = Usart_Mgr.RXDBuf[8];
if (dev_info.rf_charge & 0x01) dev_info.rf_battery = 100;
}
else {
if (dev_info.rf_state != RF_INVAILD) {
if (dev_info.rf_state != RF_INVALID) {
if (error_cnt >= 5) {
error_cnt = 0;
f_send_channel = 1;
@ -447,9 +447,9 @@ void dev_sts_sync(void) {
if (f_rf_reset) {
f_rf_reset = 0;
wait_ms(100);
writePinLow(NRF_RESET_PIN);
gpio_write_pin_low(NRF_RESET_PIN);
wait_ms(50);
writePinHigh(NRF_RESET_PIN);
gpio_write_pin_high(NRF_RESET_PIN);
wait_ms(50);
}
else if (f_send_channel) {
@ -506,22 +506,22 @@ void dev_sts_sync(void) {
/**
* @brief Uart send bytes.
* @param Buffer data buf
* @param Length data lenght
* @param Length data length
*/
void UART_Send_Bytes(uint8_t *Buffer, uint32_t Length) {
writePinLow(NRF_WAKEUP_PIN);
gpio_write_pin_low(NRF_WAKEUP_PIN);
wait_us(50);
uart_transmit(Buffer, Length);
wait_us(50 + Length * 30);
writePinHigh(NRF_WAKEUP_PIN);
gpio_write_pin_high(NRF_WAKEUP_PIN);
}
/**
* @brief get checksum.
* @param buf data buf
* @param len data lenght
* @param len data length
*/
uint8_t get_checksum(uint8_t *buf, uint8_t len) {
uint8_t i;
@ -560,7 +560,7 @@ void uart_send_report(uint8_t report_type, uint8_t *report_buf, uint8_t report_s
}
/**
* @brief Uart receives data and processes it after completion,.
* @brief Uart receives data and processes it after completion.
*/
void uart_receive_pro(void) {
static bool rcv_start = false;

View File

@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "host_driver.h"
#include "rf_driver.h"
#include "host.h"
#include "user_kb.h"
#include "kb_util.h"
/* Variable declaration */
extern DEV_INFO_STRUCT dev_info;

View File

@ -1,3 +1,3 @@
SRC += side.c rf.c sleep.c rf_driver.c user_kb.c side_driver.c
SRC += side.c rf.c sleep.c rf_driver.c kb_util.c side_driver.c
UART_DRIVER_REQUIRED = yes

View File

@ -15,7 +15,7 @@ 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 "user_kb.h"
#include "kb_util.h"
#include "ansi.h"
#include "side_table.h"
#include "ws2812.h"
@ -89,7 +89,7 @@ void side_ws2812_setleds(rgb_led_t *ledarray, uint16_t leds);
void rgb_matrix_update_pwm_buffers(void);
/**
* @brief side leds set color vaule.
* @brief side leds set color value.
* @param index: index of side_leds[].
* @param ...
*/
@ -111,7 +111,7 @@ void side_rgb_refresh(void) {
* @param dir: 0 - decrease, 1 - increase.
* @note save to eeprom.
*/
void side_light_contol(uint8_t dir) {
void side_light_control(uint8_t dir) {
if (dir) {
if (side_light > SIDE_BRIGHT_MAX) {
return;
@ -132,7 +132,7 @@ void side_light_contol(uint8_t dir) {
* @param dir: 0 - decrease, 1 - increase.
* @note save to eeprom.
*/
void side_speed_contol(uint8_t dir) {
void side_speed_control(uint8_t dir) {
if ((side_speed) > SIDE_SPEED_MAX) (side_speed) = SIDE_SPEED_MAX / 2;
if (dir) {
@ -588,7 +588,7 @@ void bat_num_led(uint8_t bat_percent)
void num_led_show(void)
{
static uint8_t num_bat_temp = 0;
num_bat_temp = dev_info.rf_baterry;
num_bat_temp = dev_info.rf_battery;
bat_num_led(num_bat_temp);
}
@ -659,7 +659,7 @@ void bat_led_show(void) {
f_init = 0;
bat_show_time = timer_read32();
charge_state = dev_info.rf_charge;
bat_percent = dev_info.rf_baterry;
bat_percent = dev_info.rf_battery;
}
if (charge_state != dev_info.rf_charge) {
@ -680,13 +680,13 @@ void bat_led_show(void) {
if (charge_state == 0x03) {
bat_show_breath = true;
} else if (charge_state & 0x01) {
dev_info.rf_baterry = 100;
dev_info.rf_battery = 100;
}
}
if (bat_percent != dev_info.rf_baterry) {
if (bat_percent != dev_info.rf_battery) {
if (timer_elapsed32(bat_per_debounce) > 1000) {
bat_percent = dev_info.rf_baterry;
bat_percent = dev_info.rf_battery;
}
} else {
bat_per_debounce = timer_read32();
@ -718,11 +718,11 @@ void bat_led_show(void) {
*/
void device_reset_show(void) {
writePinHigh(DC_BOOST_PIN);
setPinOutput(DRIVER_SIDE_CS_PIN);
setPinOutput(DRIVER_LED_CS_PIN);
writePinLow(DRIVER_SIDE_CS_PIN);
writePinLow(DRIVER_LED_CS_PIN);
gpio_write_pin_high(DC_BOOST_PIN);
gpio_set_pin_output_push_pull(DRIVER_SIDE_CS_PIN);
gpio_set_pin_output_push_pull(DRIVER_LED_CS_PIN);
gpio_write_pin_low(DRIVER_SIDE_CS_PIN);
gpio_write_pin_low(DRIVER_LED_CS_PIN);
for (int blink_cnt = 0; blink_cnt < 3; blink_cnt++) {
rgb_matrix_set_color_all(0x10, 0x10, 0x10);
@ -778,11 +778,11 @@ void device_reset_init(void) {
void rgb_test_show(void)
{
// open power control
writePinHigh(DC_BOOST_PIN);
setPinOutput(DRIVER_LED_CS_PIN);
writePinLow(DRIVER_LED_CS_PIN);
setPinOutput(DRIVER_SIDE_CS_PIN);
writePinLow(DRIVER_SIDE_CS_PIN);
gpio_write_pin_high(DC_BOOST_PIN);
gpio_set_pin_output_push_pull(DRIVER_LED_CS_PIN);
gpio_write_pin_low(DRIVER_LED_CS_PIN);
gpio_set_pin_output_push_pull(DRIVER_SIDE_CS_PIN);
gpio_write_pin_low(DRIVER_SIDE_CS_PIN);
// set test color
rgb_matrix_set_color_all(0xFF, 0x00, 0x00);

View File

@ -28,7 +28,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define NOP_FUDGE 0.4
#else
#error("NOP_FUDGE configuration required")
#define NOP_FUDGE 1 // this just pleases the compile so the above error is easier to spot
#define NOP_FUDGE 1 // this just pleases the compiler so the above error is easier to spot
#endif
#endif
@ -73,15 +73,15 @@ void side_sendByte(uint8_t byte)
// using something like wait_ns(is_one ? T1L : T0L) here throws off timings
if (is_one) {
// 1
writePinHigh(DRIVER_SIDE_PIN);
gpio_write_pin_high(DRIVER_SIDE_PIN);
wait_ns(WS2812_T1H);
writePinLow(DRIVER_SIDE_PIN);
gpio_write_pin_low(DRIVER_SIDE_PIN);
wait_ns(WS2812_T1L);
} else {
// 0
writePinHigh(DRIVER_SIDE_PIN);
gpio_write_pin_high(DRIVER_SIDE_PIN);
wait_ns(WS2812_T0H);
writePinLow(DRIVER_SIDE_PIN);
gpio_write_pin_low(DRIVER_SIDE_PIN);
wait_ns(WS2812_T0L);
}
}

View File

@ -15,7 +15,7 @@ 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 "user_kb.h"
#include "kb_util.h"
#include "ansi.h"
#include "hal_usb.h"
#include "usb_main.h"
@ -51,12 +51,12 @@ void sleep_handle(void) {
else
uart_send_cmd(CMD_SLEEP, 5, 5);
// power off led
setPinOutput(DC_BOOST_PIN);
writePinLow(DC_BOOST_PIN);
// power off LED
gpio_set_pin_output_push_pull(DC_BOOST_PIN);
gpio_write_pin_low(DC_BOOST_PIN);
setPinInput(DRIVER_LED_CS_PIN);
setPinInput(DRIVER_SIDE_CS_PIN);
gpio_set_pin_input(DRIVER_LED_CS_PIN);
gpio_set_pin_input(DRIVER_SIDE_CS_PIN);
}
f_wakeup_prepare = 1;
@ -66,12 +66,12 @@ void sleep_handle(void) {
if (f_wakeup_prepare && (no_act_time < 10)) {
f_wakeup_prepare = 0;
writePinHigh(DC_BOOST_PIN);
gpio_write_pin_high(DC_BOOST_PIN);
setPinOutput(DRIVER_LED_CS_PIN);
writePinLow(DRIVER_LED_CS_PIN);
setPinOutput(DRIVER_SIDE_CS_PIN);
writePinLow(DRIVER_SIDE_CS_PIN);
gpio_set_pin_output_push_pull(DRIVER_LED_CS_PIN);
gpio_write_pin_low(DRIVER_LED_CS_PIN);
gpio_set_pin_output_push_pull(DRIVER_SIDE_CS_PIN);
gpio_write_pin_low(DRIVER_SIDE_CS_PIN);
uart_send_cmd(CMD_HAND, 0, 1);