quantum.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. /* Copyright 2016-2017 Jack Humbert
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "quantum.h"
  17. #include "magic.h"
  18. #ifdef BLUETOOTH_ENABLE
  19. # include "outputselect.h"
  20. #endif
  21. #ifdef BACKLIGHT_ENABLE
  22. # include "backlight.h"
  23. #endif
  24. #ifdef MIDI_ENABLE
  25. # include "process_midi.h"
  26. #endif
  27. #ifdef VELOCIKEY_ENABLE
  28. # include "velocikey.h"
  29. #endif
  30. #ifdef HAPTIC_ENABLE
  31. # include "haptic.h"
  32. #endif
  33. #ifdef AUDIO_ENABLE
  34. # ifndef GOODBYE_SONG
  35. # define GOODBYE_SONG SONG(GOODBYE_SOUND)
  36. # endif
  37. float goodbye_song[][2] = GOODBYE_SONG;
  38. # ifdef DEFAULT_LAYER_SONGS
  39. float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
  40. # endif
  41. #endif
  42. #ifdef AUTO_SHIFT_ENABLE
  43. # include "process_auto_shift.h"
  44. #endif
  45. uint8_t extract_mod_bits(uint16_t code) {
  46. switch (code) {
  47. case QK_MODS ... QK_MODS_MAX:
  48. break;
  49. default:
  50. return 0;
  51. }
  52. uint8_t mods_to_send = 0;
  53. if (code & QK_RMODS_MIN) { // Right mod flag is set
  54. if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL);
  55. if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT);
  56. if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT);
  57. if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RIGHT_GUI);
  58. } else {
  59. if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LEFT_CTRL);
  60. if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LEFT_SHIFT);
  61. if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LEFT_ALT);
  62. if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LEFT_GUI);
  63. }
  64. return mods_to_send;
  65. }
  66. static void do_code16(uint16_t code, void (*f)(uint8_t)) { f(extract_mod_bits(code)); }
  67. void register_code16(uint16_t code) {
  68. if (IS_MOD(code) || code == KC_NO) {
  69. do_code16(code, register_mods);
  70. } else {
  71. do_code16(code, register_weak_mods);
  72. }
  73. register_code(code);
  74. }
  75. void unregister_code16(uint16_t code) {
  76. unregister_code(code);
  77. if (IS_MOD(code) || code == KC_NO) {
  78. do_code16(code, unregister_mods);
  79. } else {
  80. do_code16(code, unregister_weak_mods);
  81. }
  82. }
  83. void tap_code16(uint16_t code) {
  84. register_code16(code);
  85. #if TAP_CODE_DELAY > 0
  86. wait_ms(TAP_CODE_DELAY);
  87. #endif
  88. unregister_code16(code);
  89. }
  90. __attribute__((weak)) bool process_action_kb(keyrecord_t *record) { return true; }
  91. __attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); }
  92. __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; }
  93. __attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) { post_process_record_user(keycode, record); }
  94. __attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {}
  95. void reset_keyboard(void) {
  96. clear_keyboard();
  97. #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
  98. process_midi_all_notes_off();
  99. #endif
  100. #ifdef AUDIO_ENABLE
  101. # ifndef NO_MUSIC_MODE
  102. music_all_notes_off();
  103. # endif
  104. uint16_t timer_start = timer_read();
  105. PLAY_SONG(goodbye_song);
  106. shutdown_user();
  107. while (timer_elapsed(timer_start) < 250) wait_ms(1);
  108. stop_all_notes();
  109. #else
  110. shutdown_user();
  111. wait_ms(250);
  112. #endif
  113. #ifdef HAPTIC_ENABLE
  114. haptic_shutdown();
  115. #endif
  116. bootloader_jump();
  117. }
  118. /* Convert record into usable keycode via the contained event. */
  119. uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
  120. #ifdef COMBO_ENABLE
  121. if (record->keycode) {
  122. return record->keycode;
  123. }
  124. #endif
  125. return get_event_keycode(record->event, update_layer_cache);
  126. }
  127. /* Convert event into usable keycode. Checks the layer cache to ensure that it
  128. * retains the correct keycode after a layer change, if the key is still pressed.
  129. * "update_layer_cache" is to ensure that it only updates the layer cache when
  130. * appropriate, otherwise, it will update it and cause layer tap (and other keys)
  131. * from triggering properly.
  132. */
  133. uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
  134. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  135. /* TODO: Use store_or_get_action() or a similar function. */
  136. if (!disable_action_cache) {
  137. uint8_t layer;
  138. if (event.pressed && update_layer_cache) {
  139. layer = layer_switch_get_layer(event.key);
  140. update_source_layers_cache(event.key, layer);
  141. } else {
  142. layer = read_source_layers_cache(event.key);
  143. }
  144. return keymap_key_to_keycode(layer, event.key);
  145. } else
  146. #endif
  147. return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
  148. }
  149. /* Get keycode, and then process pre tapping functionality */
  150. bool pre_process_record_quantum(keyrecord_t *record) {
  151. if (!(
  152. #ifdef COMBO_ENABLE
  153. process_combo(get_record_keycode(record, true), record) &&
  154. #endif
  155. true)) {
  156. return false;
  157. }
  158. return true; // continue processing
  159. }
  160. /* Get keycode, and then call keyboard function */
  161. void post_process_record_quantum(keyrecord_t *record) {
  162. uint16_t keycode = get_record_keycode(record, false);
  163. post_process_record_kb(keycode, record);
  164. }
  165. /* Core keycode function, hands off handling to other functions,
  166. then processes internal quantum keycodes, and then processes
  167. ACTIONs. */
  168. bool process_record_quantum(keyrecord_t *record) {
  169. uint16_t keycode = get_record_keycode(record, true);
  170. // This is how you use actions here
  171. // if (keycode == KC_LEAD) {
  172. // action_t action;
  173. // action.code = ACTION_DEFAULT_LAYER_SET(0);
  174. // process_action(record, action);
  175. // return false;
  176. // }
  177. #ifdef VELOCIKEY_ENABLE
  178. if (velocikey_enabled() && record->event.pressed) {
  179. velocikey_accelerate();
  180. }
  181. #endif
  182. #ifdef WPM_ENABLE
  183. if (record->event.pressed) {
  184. update_wpm(keycode);
  185. }
  186. #endif
  187. #ifdef TAP_DANCE_ENABLE
  188. preprocess_tap_dance(keycode, record);
  189. #endif
  190. if (!(
  191. #if defined(KEY_LOCK_ENABLE)
  192. // Must run first to be able to mask key_up events.
  193. process_key_lock(&keycode, record) &&
  194. #endif
  195. #if defined(DYNAMIC_MACRO_ENABLE) && !defined(DYNAMIC_MACRO_USER_CALL)
  196. // Must run asap to ensure all keypresses are recorded.
  197. process_dynamic_macro(keycode, record) &&
  198. #endif
  199. #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
  200. process_clicky(keycode, record) &&
  201. #endif
  202. #ifdef HAPTIC_ENABLE
  203. process_haptic(keycode, record) &&
  204. #endif
  205. #if defined(VIA_ENABLE)
  206. process_record_via(keycode, record) &&
  207. #endif
  208. process_record_kb(keycode, record) &&
  209. #if defined(SEQUENCER_ENABLE)
  210. process_sequencer(keycode, record) &&
  211. #endif
  212. #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
  213. process_midi(keycode, record) &&
  214. #endif
  215. #ifdef AUDIO_ENABLE
  216. process_audio(keycode, record) &&
  217. #endif
  218. #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
  219. process_backlight(keycode, record) &&
  220. #endif
  221. #ifdef STENO_ENABLE
  222. process_steno(keycode, record) &&
  223. #endif
  224. #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
  225. process_music(keycode, record) &&
  226. #endif
  227. #ifdef KEY_OVERRIDE_ENABLE
  228. process_key_override(keycode, record) &&
  229. #endif
  230. #ifdef TAP_DANCE_ENABLE
  231. process_tap_dance(keycode, record) &&
  232. #endif
  233. #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
  234. process_unicode_common(keycode, record) &&
  235. #endif
  236. #ifdef LEADER_ENABLE
  237. process_leader(keycode, record) &&
  238. #endif
  239. #ifdef PRINTING_ENABLE
  240. process_printer(keycode, record) &&
  241. #endif
  242. #ifdef AUTO_SHIFT_ENABLE
  243. process_auto_shift(keycode, record) &&
  244. #endif
  245. #ifdef DYNAMIC_TAPPING_TERM_ENABLE
  246. process_dynamic_tapping_term(keycode, record) &&
  247. #endif
  248. #ifdef TERMINAL_ENABLE
  249. process_terminal(keycode, record) &&
  250. #endif
  251. #ifdef SPACE_CADET_ENABLE
  252. process_space_cadet(keycode, record) &&
  253. #endif
  254. #ifdef MAGIC_KEYCODE_ENABLE
  255. process_magic(keycode, record) &&
  256. #endif
  257. #ifdef GRAVE_ESC_ENABLE
  258. process_grave_esc(keycode, record) &&
  259. #endif
  260. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  261. process_rgb(keycode, record) &&
  262. #endif
  263. #ifdef JOYSTICK_ENABLE
  264. process_joystick(keycode, record) &&
  265. #endif
  266. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  267. process_programmable_button(keycode, record) &&
  268. #endif
  269. true)) {
  270. return false;
  271. }
  272. if (record->event.pressed) {
  273. switch (keycode) {
  274. #ifndef NO_RESET
  275. case RESET:
  276. reset_keyboard();
  277. return false;
  278. #endif
  279. #ifndef NO_DEBUG
  280. case DEBUG:
  281. debug_enable ^= 1;
  282. if (debug_enable) {
  283. print("DEBUG: enabled.\n");
  284. } else {
  285. print("DEBUG: disabled.\n");
  286. }
  287. #endif
  288. return false;
  289. case EEPROM_RESET:
  290. eeconfig_init();
  291. return false;
  292. #ifdef VELOCIKEY_ENABLE
  293. case VLK_TOG:
  294. velocikey_toggle();
  295. return false;
  296. #endif
  297. #ifdef BLUETOOTH_ENABLE
  298. case OUT_AUTO:
  299. set_output(OUTPUT_AUTO);
  300. return false;
  301. case OUT_USB:
  302. set_output(OUTPUT_USB);
  303. return false;
  304. case OUT_BT:
  305. set_output(OUTPUT_BLUETOOTH);
  306. return false;
  307. #endif
  308. #ifndef NO_ACTION_ONESHOT
  309. case ONESHOT_TOGGLE:
  310. oneshot_toggle();
  311. break;
  312. case ONESHOT_ENABLE:
  313. oneshot_enable();
  314. break;
  315. case ONESHOT_DISABLE:
  316. oneshot_disable();
  317. break;
  318. #endif
  319. }
  320. }
  321. return process_action_kb(record);
  322. }
  323. void set_single_persistent_default_layer(uint8_t default_layer) {
  324. #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
  325. PLAY_SONG(default_layer_songs[default_layer]);
  326. #endif
  327. eeconfig_update_default_layer((layer_state_t)1 << default_layer);
  328. default_layer_set((layer_state_t)1 << default_layer);
  329. }
  330. layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  331. layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2);
  332. layer_state_t mask3 = (layer_state_t)1 << layer3;
  333. return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3);
  334. }
  335. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) { layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3)); }
  336. void matrix_init_quantum() {
  337. magic();
  338. led_init_ports();
  339. #ifdef BACKLIGHT_ENABLE
  340. backlight_init_ports();
  341. #endif
  342. #ifdef AUDIO_ENABLE
  343. audio_init();
  344. #endif
  345. #ifdef LED_MATRIX_ENABLE
  346. led_matrix_init();
  347. #endif
  348. #ifdef RGB_MATRIX_ENABLE
  349. rgb_matrix_init();
  350. #endif
  351. #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
  352. unicode_input_mode_init();
  353. #endif
  354. #ifdef HAPTIC_ENABLE
  355. haptic_init();
  356. #endif
  357. #if defined(BLUETOOTH_ENABLE) && defined(OUTPUT_AUTO_ENABLE)
  358. set_output(OUTPUT_AUTO);
  359. #endif
  360. matrix_init_kb();
  361. }
  362. void matrix_scan_quantum() {
  363. #if defined(AUDIO_ENABLE) && defined(AUDIO_INIT_DELAY)
  364. // There are some tasks that need to be run a little bit
  365. // after keyboard startup, or else they will not work correctly
  366. // because of interaction with the USB device state, which
  367. // may still be in flux...
  368. //
  369. // At the moment the only feature that needs this is the
  370. // startup song.
  371. static bool delayed_tasks_run = false;
  372. static uint16_t delayed_task_timer = 0;
  373. if (!delayed_tasks_run) {
  374. if (!delayed_task_timer) {
  375. delayed_task_timer = timer_read();
  376. } else if (timer_elapsed(delayed_task_timer) > 300) {
  377. audio_startup();
  378. delayed_tasks_run = true;
  379. }
  380. }
  381. #endif
  382. #if defined(AUDIO_ENABLE) && !defined(NO_MUSIC_MODE)
  383. music_task();
  384. #endif
  385. #ifdef KEY_OVERRIDE_ENABLE
  386. key_override_task();
  387. #endif
  388. #ifdef SEQUENCER_ENABLE
  389. sequencer_task();
  390. #endif
  391. #ifdef TAP_DANCE_ENABLE
  392. tap_dance_task();
  393. #endif
  394. #ifdef COMBO_ENABLE
  395. combo_task();
  396. #endif
  397. #ifdef LED_MATRIX_ENABLE
  398. led_matrix_task();
  399. #endif
  400. #ifdef WPM_ENABLE
  401. decay_wpm();
  402. #endif
  403. #ifdef HAPTIC_ENABLE
  404. haptic_task();
  405. #endif
  406. #ifdef DIP_SWITCH_ENABLE
  407. dip_switch_read(false);
  408. #endif
  409. #ifdef AUTO_SHIFT_ENABLE
  410. autoshift_matrix_scan();
  411. #endif
  412. matrix_scan_kb();
  413. }
  414. #ifdef HD44780_ENABLED
  415. # include "hd44780.h"
  416. #endif
  417. //------------------------------------------------------------------------------
  418. // Override these functions in your keymap file to play different tunes on
  419. // different events such as startup and bootloader jump
  420. __attribute__((weak)) void startup_user() {}
  421. __attribute__((weak)) void shutdown_user() {}
  422. /** \brief Run keyboard level Power down
  423. *
  424. * FIXME: needs doc
  425. */
  426. __attribute__((weak)) void suspend_power_down_user(void) {}
  427. /** \brief Run keyboard level Power down
  428. *
  429. * FIXME: needs doc
  430. */
  431. __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); }
  432. void suspend_power_down_quantum(void) {
  433. #ifndef NO_SUSPEND_POWER_DOWN
  434. // Turn off backlight
  435. # ifdef BACKLIGHT_ENABLE
  436. backlight_set(0);
  437. # endif
  438. # ifdef LED_MATRIX_ENABLE
  439. led_matrix_task();
  440. # endif
  441. # ifdef RGB_MATRIX_ENABLE
  442. rgb_matrix_task();
  443. # endif
  444. // Turn off LED indicators
  445. uint8_t leds_off = 0;
  446. # if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE)
  447. if (is_backlight_enabled()) {
  448. // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off
  449. leds_off |= (1 << USB_LED_CAPS_LOCK);
  450. }
  451. # endif
  452. led_set(leds_off);
  453. // Turn off audio
  454. # ifdef AUDIO_ENABLE
  455. stop_all_notes();
  456. # endif
  457. // Turn off underglow
  458. # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
  459. rgblight_suspend();
  460. # endif
  461. # if defined(LED_MATRIX_ENABLE)
  462. led_matrix_set_suspend_state(true);
  463. # endif
  464. # if defined(RGB_MATRIX_ENABLE)
  465. rgb_matrix_set_suspend_state(true);
  466. # endif
  467. # ifdef OLED_ENABLE
  468. oled_off();
  469. # endif
  470. # ifdef ST7565_ENABLE
  471. st7565_off();
  472. # endif
  473. # if defined(POINTING_DEVICE_ENABLE)
  474. // run to ensure scanning occurs while suspended
  475. pointing_device_task();
  476. # endif
  477. #endif
  478. }
  479. /** \brief run user level code immediately after wakeup
  480. *
  481. * FIXME: needs doc
  482. */
  483. __attribute__((weak)) void suspend_wakeup_init_user(void) {}
  484. /** \brief run keyboard level code immediately after wakeup
  485. *
  486. * FIXME: needs doc
  487. */
  488. __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); }
  489. __attribute__((weak)) void suspend_wakeup_init_quantum(void) {
  490. // Turn on backlight
  491. #ifdef BACKLIGHT_ENABLE
  492. backlight_init();
  493. #endif
  494. // Restore LED indicators
  495. led_set(host_keyboard_leds());
  496. // Wake up underglow
  497. #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
  498. rgblight_wakeup();
  499. #endif
  500. #if defined(LED_MATRIX_ENABLE)
  501. led_matrix_set_suspend_state(false);
  502. #endif
  503. #if defined(RGB_MATRIX_ENABLE)
  504. rgb_matrix_set_suspend_state(false);
  505. #endif
  506. suspend_wakeup_init_kb();
  507. }
  508. /** \brief converts unsigned integers into char arrays
  509. *
  510. * Takes an unsigned integer and converts that value into an equivalent char array
  511. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  512. */
  513. const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad) {
  514. buf[buf_len - 1] = '\0';
  515. for (size_t i = 0; i < buf_len - 1; ++i) {
  516. char c = '0' + curr_num % 10;
  517. buf[buf_len - 2 - i] = (c == '0' && i == 0) ? '0' : (curr_num > 0 ? c : curr_pad);
  518. curr_num /= 10;
  519. }
  520. return buf;
  521. }
  522. /** \brief converts uint8_t into char array
  523. *
  524. * Takes an uint8_t, and uses an internal static buffer to render that value into a char array
  525. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  526. *
  527. * NOTE: Subsequent invocations will reuse the same static buffer and overwrite the previous
  528. * contents. Use the result immediately, instead of caching it.
  529. */
  530. const char *get_u8_str(uint8_t curr_num, char curr_pad) {
  531. static char buf[4] = {0};
  532. static uint8_t last_num = 0xFF;
  533. static char last_pad = '\0';
  534. if (last_num == curr_num && last_pad == curr_pad) {
  535. return buf;
  536. }
  537. last_num = curr_num;
  538. last_pad = curr_pad;
  539. return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
  540. }
  541. /** \brief converts uint16_t into char array
  542. *
  543. * Takes an uint16_t, and uses an internal static buffer to render that value into a char array
  544. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  545. *
  546. * NOTE: Subsequent invocations will reuse the same static buffer and overwrite the previous
  547. * contents. Use the result immediately, instead of caching it.
  548. */
  549. const char *get_u16_str(uint16_t curr_num, char curr_pad) {
  550. static char buf[6] = {0};
  551. static uint16_t last_num = 0xFF;
  552. static char last_pad = '\0';
  553. if (last_num == curr_num && last_pad == curr_pad) {
  554. return buf;
  555. }
  556. last_num = curr_num;
  557. last_pad = curr_pad;
  558. return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
  559. }