diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d085109..e6424b7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log +## 0.9.16 on 2022/07/20 + +### Improvement +- [Experimental] Startup time reduced⌨💨 + We really hope all guys try this version and report to us if there's a problem of any kind🙏 + ## 0.9.15 on 2022/07/19 ### Joystick🕹 diff --git a/src/main.c b/src/main.c index 3ba26e95..7c3b89c7 100644 --- a/src/main.c +++ b/src/main.c @@ -84,34 +84,36 @@ char const *string_desc_arr[STRING_DESC_ARR_SIZE] = * 0x1234:0xABCD:productName * ^^^^^^ ^^^^^^ ^^^^^^^^^^^ * VID PID Name - * - IDs' prefix should be `0x`, should NOT be `0X` * - Length of productName should be less than or equal 32 bytes * and any other letter must not be included in the file. */ -#define PRK_CONF_LENGTH (7 + 7 + 32) +#define PRK_CONF_MAX_LENGTH (7 + 7 + 33 + 2) static void configure_prk(void) { + static char prk_conf[PRK_CONF_MAX_LENGTH] = {0}; DirEnt entry; - uint8_t buf[PRK_CONF_LENGTH + 1] = {0}; - uint8_t vid[7] = {0}; - uint8_t pid[7] = {0}; - static char name[PRK_CONF_LENGTH - 14] = {0}; msc_findDirEnt("PRK-CONFTXT", &entry); if (entry.Name[0] != '\0') { - if (entry.FileSize > PRK_CONF_LENGTH) return; - msc_loadFile(buf, &entry); - if (strncmp("0x", buf, 2) || strncmp(":0x", buf + 6, 3)) return; - memcpy(vid, buf , 6); - memcpy(pid, buf + 7, 6); - memcpy(name, buf + 14, strlen(buf) - 14); - for (int i = 0; ; i++) { - if (name[i] == '\r' || name[i] == '\n') name[i] = '\0'; - if (name[i] == '\0') break; + if (entry.FileSize > PRK_CONF_MAX_LENGTH) return; + msc_loadFile(prk_conf, &entry); + char *tok = strtok(prk_conf, ":"); + for (int i = 0; i < 3; i++) { + if (tok == NULL) break; + switch (i) { + case 0: + desc_device.idVendor = (uint16_t)strtol(tok, NULL, 16); + tok = strtok(NULL, ":"); + break; + case 1: + desc_device.idProduct = (uint16_t)strtol(tok, NULL, 16); + tok = strtok(NULL, ": \t\n\r"); + break; + case 2: + string_desc_arr[2] = (const char *)tok; + break; + } } - desc_device.idVendor = (uint16_t)strtol(vid, NULL, 16); - desc_device.idProduct = (uint16_t)strtol(pid, NULL, 16); - string_desc_arr[2] = (const char *)name; } } @@ -210,7 +212,7 @@ create_keymap_task(mrbc_tcb *tcb) if (entry.Name[0] != '\0') { RotaryEncoder_reset(); uint32_t fileSize = entry.FileSize; - console_printf("Size of keymap.rb: %u\n", fileSize); + console_printf("keymap.rb size: %u\n", fileSize); if (fileSize < MAX_KEYMAP_SIZE) { keymap_rb = malloc(KEYMAP_PREFIX_SIZE + fileSize + 1); keymap_rb[KEYMAP_PREFIX_SIZE + fileSize] = '\0'; @@ -222,7 +224,7 @@ create_keymap_task(mrbc_tcb *tcb) si = StreamInterface_new(NULL, SUSPEND_TASK, STREAM_TYPE_MEMORY); } } else { - console_printf("No keymap.rb found.\n"); + console_printf("No keymap.rb found!\n"); si = StreamInterface_new(NULL, SUSPEND_TASK, STREAM_TYPE_MEMORY); } if (!Compiler_compile(p, si, NULL)) { diff --git a/src/ruby/app/models/debounce.rb b/src/ruby/app/models/debounce.rb index 361be988..fdad4cbb 100644 --- a/src/ruby/app/models/debounce.rb +++ b/src/ruby/app/models/debounce.rb @@ -4,7 +4,7 @@ class DebounceBase DEFAULT_THRESHOLD = 40 def initialize - puts "Initializing #{self.class}." + puts "Init #{self.class}" @threshold = DEFAULT_THRESHOLD @now = 0 end diff --git a/src/ruby/app/models/keyboard.rb b/src/ruby/app/models/keyboard.rb index b4355a8e..d50a0882 100644 --- a/src/ruby/app/models/keyboard.rb +++ b/src/ruby/app/models/keyboard.rb @@ -443,7 +443,7 @@ class Keyboard class Keyboard def initialize - puts "Initializing Keyboard." + puts "Init Keyboard" # mruby/c VM doesn't work with a CONSTANT to make another CONSTANT # steep doesn't allow dynamic assignment of CONSTANT @SHIFT_LETTER_THRESHOLD_A = LETTER.index('A').to_i @@ -595,7 +595,7 @@ def init_uart end def init_matrix_pins(matrix) - puts "Initializing GPIO." + puts "Init GPIO" init_uart @cols_size = 0 @rows_size = matrix.size @@ -980,7 +980,7 @@ def start! # default debounce algorithm will be applied self.set_debounce(@scan_mode == :direct ? :per_key : :per_row) unless @debouncer - puts "Keyboard task started." + puts "Keyboard started" # To avoid unintentional report on startup # which happens only on Sparkfun Pro Micro RP2040 diff --git a/src/ruby/app/models/rgb.rb b/src/ruby/app/models/rgb.rb index 4e1df876..743b59d8 100644 --- a/src/ruby/app/models/rgb.rb +++ b/src/ruby/app/models/rgb.rb @@ -1,6 +1,6 @@ class RGB def initialize(pin, underglow_size, backlight_size, is_rgbw = false) - puts "Initializing RGB." + puts "Init RGB" turn_off @fifo = Array.new # TODO: @underglow_size, @backlight_size diff --git a/src/ruby/app/models/rotary_encoder.rb b/src/ruby/app/models/rotary_encoder.rb index 715dafd8..65655cde 100644 --- a/src/ruby/app/models/rotary_encoder.rb +++ b/src/ruby/app/models/rotary_encoder.rb @@ -1,6 +1,6 @@ class RotaryEncoder def initialize(pin_a, pin_b) - puts "Initializing RotaryEncoder ..." + puts "Init RotaryEncoder" @pin_a = pin_a @pin_b = pin_b @partner_keycode_cw = 0 diff --git a/src/ruby/app/models/via.rb b/src/ruby/app/models/via.rb index 7731b80a..f855fe9a 100644 --- a/src/ruby/app/models/via.rb +++ b/src/ruby/app/models/via.rb @@ -33,7 +33,7 @@ class VIA VIA_FILENAME = "VIA_MAP TXT" def initialize - puts "Initializing VIA." + puts "Init VIA" @layer_count = 5 @mode_keys = Hash.new @keymap_saved = true diff --git a/src/ruby/app/tasks/rgb_task.rb b/src/ruby/app/tasks/rgb_task.rb index 9add0a75..7d355ee5 100644 --- a/src/ruby/app/tasks/rgb_task.rb +++ b/src/ruby/app/tasks/rgb_task.rb @@ -1,6 +1,6 @@ -puts "RGB task started." +puts "RGB started" -3.times { sleep 1 } +sleep 0.5 while true unless $rgb diff --git a/src/ruby/app/tasks/usb_task.rb b/src/ruby/app/tasks/usb_task.rb index c44e0a54..f2ccd917 100644 --- a/src/ruby/app/tasks/usb_task.rb +++ b/src/ruby/app/tasks/usb_task.rb @@ -1,10 +1,10 @@ -2000.times do +200.times do tud_task cdc_task sleep_ms 2 end print "\e[2J\e[1;1H" # clear all & home -puts "Welcome to PRK Firmware!\n\nTUD task started.\n" +puts "PRK Firmware started!\n\n" autoreload_tick = 0 $mutex = false @@ -14,16 +14,14 @@ cdc_task if autoreload_ready? if autoreload_tick == 0 - puts "Autoreload is ready." + puts "Reloading keymap" $rgb.turn_off if $rgb - puts "Suspending keymap." suspend_keymap report_hid(0, "\000\000\000\000\000\000") - autoreload_tick = 500 + autoreload_tick = 200 elsif autoreload_tick == 1 - puts "Trying to reload keymap." reload_keymap - 500.times do + 10.times do tud_task cdc_task sleep_ms 2