打印
[学习资料]

C Library for ST7735 1.8 TFT LCD display

[复制链接]
1354|3
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主

ST7735-master.zip (2.6 MB)
/** 
* --------------------------------------------------------------------------------------------+
* [url=home.php?mod=space&uid=139335]@name[/url]        Main example st7735 LCD driver
* --------------------------------------------------------------------------------------------+
*              Copyright (C) 2020 Marian Hrinko.
*              Written by Marian Hrinko (mato.hrinko@gmail.com)
*
* [url=home.php?mod=space&uid=187600]@author[/url]      Marian Hrinko
* @datum       13.10.2020
* [url=home.php?mod=space&uid=391783]@update[/url]      21.06.2021
* [url=home.php?mod=space&uid=288409]@file[/url]        main.c
* [url=home.php?mod=space&uid=895143]@version[/url]     2.0
* @tested      AVR Atmega328
*
* @depend      st7735.h
* --------------------------------------------------------------------------------------------+
* @descr       Version 1.0 -> applicable for 1 display
*              Version 2.0 -> applicable for more than 1 display
*/
#include "lib/st7735.h"

/**
* [url=home.php?mod=space&uid=1170026]@desc[/url]    Main function
*
* @param   Void
*
* [url=home.php?mod=space&uid=266161]@return[/url]  Void
*/
int main (void)
{
  // start
  uint8_t start = 30;
  // end
  uint8_t end = MAX_X - start;

  // LCD 1 - init struct
  // ----------------------------------------------------------
  // Chip Select
  struct signal cs = { .ddr = &DDRB, .port = &PORTB, .pin = 2 };
  // Back Light
  struct signal bl = { .ddr = &DDRB, .port = &PORTB, .pin = 1 };
  // Data / Command
  struct signal dc = { .ddr = &DDRB, .port = &PORTB, .pin = 0 };
  // Reset
  struct signal rs = { .ddr = &DDRD, .port = &PORTD, .pin = 7 };
  // LCD struct
  struct st7735 lcd1 = { .cs = &cs, .bl = &bl, .dc = &dc, .rs = &rs };

  // LCD 2 - init struct
  // ----------------------------------------------------------
  // Chip Select
  struct signal cs2 = { .ddr = &DDRD, .port = &PORTD, .pin = 0 };
  // Back Light
  struct signal bl2 = { .ddr = &DDRD, .port = &PORTD, .pin = 1 };
  // Data / Command
  struct signal dc2 = { .ddr = &DDRB, .port = &PORTB, .pin = 0 };
  // Reset
  struct signal rs2 = { .ddr = &DDRD, .port = &PORTD, .pin = 3 };
  // LCD struct
  struct st7735 lcd2 = { .cs = &cs2, .bl = &bl2, .dc = &dc2, .rs = &rs2 };

  // LCD 1
  // ----------------------------------------------------------
  // init lcd 1
  ST7735_Init (&lcd1);
  // clear screen
  ST7735_ClearScreen (&lcd1, BLACK);
  // set position X, Y
  ST7735_SetPosition (start + 5, 10);  
  // draw string
  ST7735_DrawString (&lcd1, "Loading DATA ...", WHITE, X2);

  // draw Loading
  for (uint8_t i = start; i < end; i++) {
    // draw rectangle
    ST7735_DrawRectangle (&lcd1, start, i, 30, 40, RED);
  }

  // LCD 2
  // ----------------------------------------------------------
  // init lcd 2
  ST7735_Init (&lcd2);
  // clear screen
  ST7735_ClearScreen (&lcd2, BLACK);
  // set position X, Y
  ST7735_SetPosition (17, 10);  
  // draw string
  ST7735_DrawString (&lcd2, "ST7735 LCD 2", WHITE, X3);
  // draw fast horizontal line
  ST7735_DrawLineHorizontal (&lcd2, 5, MAX_X - 5, 27, WHITE);

  // EXIT
  // -------------------------------------------------
  // return & exit
  return 0;
}


使用特权

评论回复
沙发
jiekou001| | 2023-10-27 10:38 | 只看该作者
看起来不错

使用特权

评论回复
板凳
Bowclad| | 2023-11-23 15:59 | 只看该作者
屏幕从哪买的啊

使用特权

评论回复
地板
mintspring| | 2024-7-21 22:40 | 只看该作者
MCC配置的有吗?

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

194

主题

3108

帖子

7

粉丝