HZK16.ino 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. *******************************************************************************
  3. * Copyright (c) 2022 by M5Stack
  4. * Equipped with M5Core sample source code
  5. * 配套 M5Core 示例源代码
  6. * Visit for more information: https://docs.m5stack.com/en/core/gray
  7. * 获取更多资料请访问: https://docs.m5stack.com/zh_CN/core/gray
  8. *
  9. * Describe: Character library. 字库
  10. * Date: 2021/7/28
  11. *******************************************************************************
  12. -----PLEASE SEE THE README----
  13. ------请在使用前看README文件----*/
  14. #include <M5Stack.h>
  15. #include "display_ch.h"
  16. #include "str.h"
  17. DisplayCh displaych;
  18. void setup() {
  19. M5.begin(); // Init M5Stack. 初始化M5Stack
  20. M5.Power.begin(); // Init power 初始化电源模块
  21. displaych.loadHzk16(); // Load the Chinese character library (be sure to
  22. // load before using the Chinese character library).
  23. // 加载汉字库(务必在使用汉字库前加载)
  24. displaych.setTextColor(
  25. WHITE, BLACK); // Set the text color to white and the text background
  26. // color to black (mandatory).
  27. // 设置文字颜色为白色,文字背景颜色为黑色(必加)
  28. // Set text with red highlight color
  29. displaych.setHighlightColor(
  30. RED); // Set the text highlight color to red. 设置文字高亮颜色为红色
  31. displaych.setTextSize(
  32. 1); // Set text size to 1. 设置字号大小为1 Set text size to 1(必加)
  33. }
  34. void loop() {
  35. displaych.setCursor(
  36. 0, 0, 1); // Set the cursor at (0,0) and the size to 1(mandatory).
  37. // 将光标设置在(0,0)处,并设置字号为1(必加)
  38. displaych.writeHzk(
  39. AscStr); // Display the contents of AscStr here (which can be changed
  40. // in str.h). 在此处显示AscStr中的内容(可在str.h中更改)
  41. delay(1000); // delay 1000ms. 延迟1000ms
  42. displaych.setCursor(0, 45);
  43. displaych.writeHzk(
  44. GbkStr); // Display the contents of GbkStr here (which can be changed
  45. // in str.h). 在此处显示GbkStr中的内容(可在str.h中更改)
  46. delay(1000);
  47. // Highlight the text. 高亮显示文本
  48. displaych.highlight(true); // Turn on highlight. 开启高亮显示
  49. displaych.setCursor(0, 65);
  50. displaych.writeHzk(GbkStr);
  51. delay(1000);
  52. displaych.fillScreen(
  53. BLACK); // Fill the screen with black color, equivalent to empty the
  54. // screen. 填充屏幕颜色为黑色,等效于清空屏幕
  55. displaych.highlight(false); // Turn off highlight. 关闭高亮显示
  56. delay(500);
  57. }