第 x 层水平位置参数寄存器(TLI_LxHPOS)(x = 0, 1)
第 x 层垂直位置参数寄存器(TLI_LxVPOS)(x = 0, 1)
先来看看TLI_LxHPOS
从上面的说明中我们得知,把WRP写入右则的位置值,把WLP写入左则值,这样就可以把图像水平移动到指定的位置。
同理我们再看看垂直位置寄存器的说明:
他与水平位的写入是一样的。所以我们创建如下代码,来实现图像的移动:
- void offset_laye(uint16_t xpos, uint16_t ypos)
- {
- tli_layer_parameter_struct tli_layer_init_struct;
- /* TLI layer configuration 层初始化配置 */
- tli_layer_init_struct.layer_window_leftpos = xpos + HORIZONTAL_SYNCHRONOUS_PULSE +
- HORIZONTAL_BACK_PORCH + 2;
- tli_layer_init_struct.layer_window_rightpos = (xpos + 320 + HORIZONTAL_SYNCHRONOUS_PULSE +
- HORIZONTAL_BACK_PORCH -1);
- tli_layer_init_struct.layer_window_toppos = ypos + VERTICAL_SYNCHRONOUS_PULSE + VERTICAL_BACK_PORCH;
- tli_layer_init_struct.layer_window_bottompos = (ypos + 100 + VERTICAL_SYNCHRONOUS_PULSE +
- VERTICAL_BACK_PORCH -1);
- TLI_LXHPOS(LAYER0) &= ~(TLI_LXHPOS_WLP | (TLI_LXHPOS_WRP));
- TLI_LXHPOS(LAYER0) = (uint32_t)((uint32_t)tli_layer_init_struct.layer_window_leftpos | ((uint32_t)tli_layer_init_struct.layer_window_rightpos << 16U));
- /* configure layer window vertical position */
- TLI_LXVPOS(LAYER0) &= ~(TLI_LXVPOS_WTP | (TLI_LXVPOS_WBP));
- TLI_LXVPOS(LAYER0) = (uint32_t)((uint32_t)tli_layer_init_struct.layer_window_toppos | ((uint32_t)tli_layer_init_struct.layer_window_bottompos << 16U));
- }
然后在主程序中,我们添加一些测试代码来验证:
- xpos = 0;
- ypos =0;
- while(1) {
- delay_1ms(10);
- ypos ++;
- if(ypos > 170)
- {
- ypos = 0;
- }
- xpos ++;
- if(xpos > 100)
- {
- xpos = 0;
- }
- offset_laye(xpos,ypos);
- tli_layer_enable(LAYER0);
- tli_reload_config(TLI_FRAME_BLANK_RELOAD_EN);
- /* enable TLI */
- tli_enable();
- }