1 #if AOS_COMP_CLI
2 #include "aos/cli.h"
3 #endif
4 
5 // example based on haaseduk1
6 #include "hal_iomux_haas1000.h"
7 #include "st7789.h"
8 
9 st7789_dev_t my_st7789 = {0};
10 
11 // 硬件初始化
example_st7789_hw_init(int argc,char ** argv)12 static void example_st7789_hw_init(int argc, char **argv)
13 {
14     my_st7789.spi_port      = 0;
15     my_st7789.spi_freq      = 26000000;
16     my_st7789.gpio_bgl_id   = HAL_GPIO_PIN_P0_6;
17     my_st7789.gpio_dc_id    = HAL_GPIO_PIN_P0_4;
18     my_st7789.gpio_reset_id = HAL_GPIO_PIN_P0_0;
19 
20     st7789_hw_init(&my_st7789);
21     return;
22 }
23 
24 // 绘画随机矩形
example_st7789_draw_ract(int argc,char ** argv)25 static void example_st7789_draw_ract(int argc, char **argv)
26 {
27     int      x0    = rand() % 240;
28     int      x1    = rand() % 240;
29     int      y0    = rand() % 240;
30     int      y1    = rand() % 240;
31     uint16_t color = rand();
32     printf("drawing rectangle at %d %d %d %d in color %04X\n", x0, y0, x1, y1,
33            color);
34     st7789_draw_rect(my_st7789, 0, 0, ST7789_WIDTH, ST7789_HEIGHT, 0xFFFF);
35     st7789_draw_rect(my_st7789, x0, y0, x1, y1, color);
36     return;
37 }
38 
39 #if AOS_COMP_CLI
40 /* reg args: fun, cmd, description*/
41 ALIOS_CLI_CMD_REGISTER(example_st7789_hw_init,
42                        example_st7789_hw_init,
43                        st7789 init test example)
44 ALIOS_CLI_CMD_REGISTER(example_st7789_draw_ract,
45                        example_st7789_draw_ract,
46                        st7789 display test example
47                        : draw random       ract)
48 #endif
49