【RVB2601调试记录2】+ uGUI移植
<h1 cid="n0" mdtype="heading">调试记录2</h1><h2 cid="n2" mdtype="heading">使用硬件SPI</h2>
<p cid="n13" mdtype="paragraph">上次的模拟SPI速度有些感人,这次使用硬件SPI</p>
<pre>
<code class="language-cpp">csi_gpio_pin_t pin_clk;
csi_gpio_pin_t pin_mosi;
csi_gpio_pin_t pin_cs;
csi_gpio_pin_t pin_miso;
static void oled_pinmux_init()
{
csi_pin_set_mux(PA28, PA28_SPI1_SCK); //clk
csi_pin_set_mux(PA29, PA29_SPI1_MOSI); //mosi
csi_pin_set_mux(PA27, PIN_FUNC_GPIO); //cs
csi_pin_set_mux(PA30, PIN_FUNC_GPIO); //miso
}
static void oled_gpio_init()
{
csi_gpio_pin_init(&pin_cs, PA27);
csi_gpio_pin_dir(&pin_cs, GPIO_DIRECTION_OUTPUT);
csi_gpio_pin_init(&pin_miso, PA30); //dc
csi_gpio_pin_dir(&pin_miso, GPIO_DIRECTION_OUTPUT);
int32_t ret = csi_spi_init(&spi_handle, 1);
if (ret < 0) {
printf("csi spi init failed\r\n");
return NULL;
}
csi_spi_mode(&spi_handle, SPI_MASTER);
ret = csi_spi_baud(&spi_handle, 20000000);
csi_spi_cp_format(&spi_handle, SPI_FORMAT_CPOL0_CPHA0);
csi_spi_frame_len(&spi_handle, SPI_FRAME_LEN_8);
csi_spi_select_slave(&spi_handle, 1);
#ifdef SPI_USE_DMA
csi_spi_attach_callback(&spi_handle, spi_event_cb, NULL);
csi_spi_link_dma(&spi_handle, NULL, &spi_recv_dma);
#endif
}</code></pre>
<p cid="n39" mdtype="paragraph"> </p>
<h2 cid="n14" mdtype="heading">移植uGUI</h2>
<p cid="n25" mdtype="paragraph"><a href="http://embeddedlightning.com/ugui/" spellcheck="false">μGUI - free Open Source GUI module for embedded systems | Embedded Lightning</a></p>
<blockquote cid="n50" mdtype="blockquote">
<p cid="n45" mdtype="paragraph">µGUI is a free and open source graphic library for embedded systems. It is platform-independent and can be easily ported to almost any microcontroller system. As long as the display is capable of showing graphics, µGUI is not restricted to a certain display technology. Therefore, display technologies such as LCD, TFT, E-Paper, LED or OLED are supported. The whole module consists of two files: <strong>ugui.c</strong> and <strong>ugui.h</strong>.</p>
</blockquote>
<p cid="n46" mdtype="paragraph">采用<a href="https://github.com/achimdoebler/UGUI" spellcheck="false">仓库</a>里的文件</p>
<p cid="n54" mdtype="paragraph"> </p>
<p cid="n55" mdtype="paragraph">需要提供以下驱动,主要是画点函数</p>
<pre>
<code class="language-cpp">UG_GUI gui;
static UG_RESULT HW_FillFrame ( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c)
{
LCD_Fill(x1,y1,x2,y2,c);
return UG_RESULT_OK;
}
static UG_RESULT HW_DrawLine ( UG_S16 x1, UG_S16 y1, UG_S16 x2, UG_S16 y2, UG_COLOR c)
{
return UG_RESULT_OK;
}
static void pset(UG_S16 x,UG_S16 y,UG_COLOR c)
{
LCD_DrawPoint(x,y,c);
}
void gui_ugui_init()
{
oled_hard_init();
UG_Init(&gui, pset, 160 , 80 ) ;
//UG_DriverRegister( DRIVER_DRAW_LINE,HW_DrawLine ) ;
UG_DriverRegister( DRIVER_FILL_FRAME, HW_FillFrame ) ;
//UG_DriverEnable ( DRIVER_DRAW_LINE ) ;
UG_DriverEnable ( DRIVER_FILL_FRAME ) ;
}</code></pre>
<p cid="n58" mdtype="paragraph">这样就可以直接调用其丰富的绘图函数了</p>
<p cid="n61" mdtype="paragraph"></p>
<p>这是外接了一个彩屏了吧?</p>
wangerxian 发表于 2022-3-16 11:59
这是外接了一个彩屏了吧?
<p>是的</p>
页:
[1]