My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

fontutils.h 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. *
  5. * Based on Sprinter and grbl.
  6. * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. * @file fontutils.h
  24. * @brief help functions for font and char
  25. * @author Yunhui Fu (yhfudev@gmail.com)
  26. * @version 1.0
  27. * @date 2016-08-19
  28. * @copyright GPL/BSD
  29. */
  30. #pragma once
  31. #include <stdlib.h>
  32. #include <stddef.h> // wchar_t
  33. #include <stdint.h> // uint32_t
  34. #include "../HAL/shared/Marduino.h"
  35. #include "../core/macros.h"
  36. // read a byte from ROM or RAM
  37. typedef uint8_t (*read_byte_cb_t)(const uint8_t * str);
  38. uint8_t read_byte_ram(const uint8_t *str);
  39. uint8_t read_byte_rom(const uint8_t *str);
  40. // there's overflow of the wchar_t due to the 2-byte size in Arduino
  41. // sizeof(wchar_t)=2; sizeof(size_t)=2; sizeof(uint32_t)=4;
  42. // sizeof(int)=2; sizeof(long)=4; sizeof(unsigned)=2;
  43. //#undef wchar_t
  44. #define wchar_t uint32_t
  45. //typedef uint32_t wchar_t;
  46. typedef uint16_t pixel_len_t;
  47. #define PIXEL_LEN_NOLIMIT ((pixel_len_t)(-1))
  48. /* Perform binary search */
  49. typedef int (* pf_bsearch_cb_comp_t)(void *userdata, size_t idx, void * data_pin); /*"data_list[idx] - *data_pin"*/
  50. int pf_bsearch_r(void *userdata, size_t num_data, pf_bsearch_cb_comp_t cb_comp, void *data_pinpoint, size_t *ret_idx);
  51. /* Get the character, decoding multibyte UTF8 characters and returning a pointer to the start of the next UTF8 character */
  52. const uint8_t* get_utf8_value_cb(const uint8_t *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval);
  53. inline const char* get_utf8_value_cb(const char *pstart, read_byte_cb_t cb_read_byte, wchar_t *pval) {
  54. return (const char *)get_utf8_value_cb((const uint8_t *)pstart, cb_read_byte, pval);
  55. }
  56. /* Returns length of string in CHARACTERS, NOT BYTES */
  57. uint8_t utf8_strlen(const char *pstart);
  58. uint8_t utf8_strlen_P(PGM_P pstart);
  59. inline uint8_t utf8_strlen(FSTR_P fstart) { return utf8_strlen_P(FTOP(fstart)); }
  60. /* Returns start byte position of desired char number */
  61. uint8_t utf8_byte_pos_by_char_num(const char *pstart, const uint8_t charnum);
  62. uint8_t utf8_byte_pos_by_char_num_P(PGM_P pstart, const uint8_t charnum);