lcd_sample.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-05-26 Chushicheng the first version
  9. */
  10. /*
  11. * Program Checklist: This is an LCD device usage routine
  12. * The routine exports lcd_sample commands to the control terminal
  13. * Command invocation format: lcd_sample
  14. * Program function: Full screen refresh display
  15. */
  16. #include <rtdevice.h>
  17. #include "drv_st7796.h"
  18. static void lcd_sample(void)
  19. {
  20. static rt_uint16_t orange[319*2];
  21. static rt_uint16_t green[319*2];
  22. static rt_uint16_t blue[319*2];
  23. st7796_t *lcd_obj = (st7796_t *)rt_device_find("lcd");
  24. for (rt_uint32_t i = 0; i < 319*2; i++)
  25. {
  26. orange[i] = 0xFD;
  27. }
  28. for (rt_uint32_t i = 0; i < 319*2; i++)
  29. {
  30. green[i] = 0x07;
  31. }
  32. for (rt_uint32_t i = 0; i < 319*2; i++)
  33. {
  34. blue[i] = 0xFF1F;
  35. }
  36. while (1)
  37. {
  38. for (rt_uint16_t i = 0; i < 159; i++)
  39. {
  40. lcd_load(i, i, 0, 319, orange);
  41. }
  42. for (rt_uint16_t i = 159; i < 318; i++)
  43. {
  44. lcd_load(i, i, 0, 319, blue);
  45. }
  46. for (rt_uint16_t i = 318; i < 479; i++)
  47. {
  48. lcd_load(i, i, 0, 319, green);
  49. }
  50. for (rt_uint16_t i = 479; i > 318; i--)
  51. {
  52. lcd_load(i, i, 0, 319, blue);
  53. }
  54. for (rt_uint16_t i = 318; i > 159; i--)
  55. {
  56. lcd_load(i, i, 0, 319, orange);
  57. }
  58. for (rt_uint16_t i = 159; i > 0; i--)
  59. {
  60. lcd_load(i, i, 0, 319, green);
  61. }
  62. }
  63. }
  64. MSH_CMD_EXPORT(lcd_sample, lcd sample);