Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jminjares4/esp32-lcd-1602-driver

ESP32 LCD device driver using esp-idf
https://github.com/jminjares4/esp32-lcd-1602-driver

esp32 esp32-idf lcd-display lcd1602

Last synced: about 1 month ago
JSON representation

ESP32 LCD device driver using esp-idf

Awesome Lists containing this project

README

        





[![esp-idf build](https://github.com/jminjares4/ESP32-LCD-1602-Driver/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/jminjares4/ESP32-LCD-1602-Driver/actions/workflows/build.yml)[![Documentation](https://github.com/jminjares4/ESP32-LCD-1602-Driver/actions/workflows/documentation.yml/badge.svg)](https://github.com/jminjares4/ESP32-LCD-1602-Driver/actions/workflows/documentation.yml)
[![pages-build-deployment](https://github.com/jminjares4/ESP32-LCD-1602-Driver/actions/workflows/pages/pages-build-deployment/badge.svg)](https://github.com/jminjares4/ESP32-LCD-1602-Driver/actions/workflows/pages/pages-build-deployment)[![GitHub Page](https://img.shields.io/badge/active-34c855.svg?style=flat&logo=github&logoColor=949da5&label=GitHub%20Page&labelColor=3f4851)](https://jminjares4.github.io/ESP32-LCD-1602-Driver/)

## **Description**
This repository contains a custom lcd driver for *16x02 lcd*. The driver has the most common function calls
that are use for LCDs. ESP32 have limited GPIO pins, therefore **4-bit mode** was use as it requires a total of **6** `GPIO` pins. However, there are two configurations for the driver: default and custom. The default configurations uses [this](#lcd-16x02-pinout) pinout while the custom allows the user to select whichever `GPIO` are avaiable simple by using `lcdCtor()`.

### **ESP32 Pinout**
~~~
+-----------------------+
| O | USB | O |
| ------- |
3V3 | [ ] [ ] | VIN
GND | [ ] [ ] | GND
Touch3 / HSPI_CS0 / ADC2_3 / GPIO15 | [ ] [ ] | GPIO13 / ADC2_4 / HSPI_ID / Touch4
CS / Touch2 / HSPI_WP / ADC2_2 / GPIO2 | [ ] [ ] | GPIO12 / ADC2_5 / HSPI_Q / Touch5
Touch0 / HSPI_HD / ADC2_0 / GPIO4 | [ ] [ ] | GPIO14 / ADC2_6 / HSPI_CLK / Touch6
U2_RXD / GPIO16 | [ ] [ ] | GPIO27 / ADC2_7 / Touch7
U2_TXD / GPIO17 | [ ] [ ] | GPIO26 / ADC2_9 / DAC2
V_SPI_CS0 / GPIO5 | [ ] ___________ [ ] | GPIO25 / ADC2_8 / DAC1
SCK / V_SPI_CLK / GPIO18 | [ ] | | [ ] | GPIO33 / ADC1_5 / Touch8 / XTAL32
U0_CTS / MSIO / V_SPI_Q / GPIO19 | [ ] | | [ ] | GPIO32 / ADC1_4 / Touch9 / XTAL32
SDA / V_SPI_HD / GPIO21 | [ ] | | [ ] | GPIO35 / ADC1_7
CLK2 / U0_RXD / GPIO3 | [ ] | | [ ] | GPIO34 / ADC1_6
CLK3 / U0_TXD / GPIO1 | [ ] | | [ ] | GPIO39 / ADC1_3 / SensVN
SCL / U0_RTS / V_SPI_WP / GPIO22 | [ ] | | [ ] | GPIO36 / ADC1_0 / SensVP
MOSI / V_SPI_WP / GPIO23 | [ ] |___________| [ ] | EN
| |
| | | ____ ____ | |
| | | | | | | | |
| |__|__| |__| |__| |
| O O |
+-----------------------+
~~~

## **LCD 16x02 Pinout**

The following pinout is the default configuration of the ESP-LCD driver. However, the driver
is customizable to allow users to change GPIO pins if necessary.

| **ESP32 Pins** | **LCD Pin** | **Description** |
| :---: | :--: | :---: |
| `GND`, 10k Potentiometer Output (V±) | 1 | GND |
| `VCC`, 10k Potentiometer Output (V±) | 2 | VCC |
| 10k Potentiometer Output (Vo) | 3 | Contrast |
| `GPIO23` | 4 | RS (Register Select): 0–Command, 1-Data |
| `GND` | 5 | R/W (Read/Write): 0 – Write, 1 - Read |
| `GPIO22` | 6 | Clock Enable |
| `NC` | 7 | Data 0 |
| `NC` | 8 | Data 1 |
| `NC` | 9 | Data 2 |
| `NC` | 10 | Data 3 |
| `GPIO19` | 11 | Data 4 |
| `GPIO18` | 12 | Data 5 |
| `GPIO17` | 13 | Data 6 |
| `GPIO16` | 14 | Data 7 |
| 100Ω to `VCC` | 15 | Backlight Anode (+) |
| `GND` | 16 | Backlight Cathode (-)|
* LCD default pin configuration

## **LCD Main Functions**

| **Function** | **Description** |
| :--- | :--- |
| lcdDefault | Default pinout |
| lcdCtor | Customizable pinout constructor |
| lcdSetText | Set text |
| lcdSetInt | Set integer |
| lcdClear | Clear previous data |
| lcdFree | Free LCD pins |
| assert_lcd | Check lcd status |

## **Simple Example Code**
The follow section of code demostrate how to use the lcd driver with default configuration.
~~~c
#include
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/esp_lcd.h"

/* LCD task */
void lcd_task(void *pvParameters){

/* Create LCD object */
lcd_t lcd;

/* Set lcd to default pins */
lcdDefault(&lcd);

/* Initialize LCD object */
lcdInit(&lcd);

/* Clear previous data on LCD */
lcdClear(&lcd);

while(1){
/* Display text */
lcdSetText(&lcd,"Hello World!", 0,0);
/* 1 second delay */
vTaskDelay(1000 / portTICK_PERIOD_MS);
}

}

void app_main(void)
{

/* Create LCD task */
xTaskCreate(lcd_task, "LCD task", 2048, NULL, 4, NULL);

}
~~~

## **ESP32 LCD Driver Test**



## **Add ESP-LCD to ESP32 Project**
1) Copy driver folder
2) Paste into esp project
3) Edit project CMakeLists.txt to use esp_lcd:
```cmake
idf_component_register(SRCS "main.c"
"driver/esp_lcd.c"
INCLUDE_DIRS ".")
```

## **Development**
|Microcontroller|Software|Enviroment|Operating System|
| :---| :---| :---| :---|
| ![ESP32](https://img.shields.io/static/v1?label=&logo=espressif&message=Espressif+ESP32&&color=000000) | ![C Language](https://img.shields.io/badge/Code-C-informational?style=flat&logo=C&color=003B57)| ![Visual Studio Code](https://img.shields.io/badge/Visual_Studio_Code-0078D4?style=flat&logo=visual%20studio%20code&logoColor=white&logoHeight=50&logoWidht=50) | ![FreeRTOS](https://img.shields.io/static/v1?label=OS&message=FreeRTOS&color=white&labelColor=green&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AA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zBJtG5QLKAU2DEK0kyNaqA6LE4ao3SeS5VPVOizi3qz6s4pG3gSfuxH%2FiDMf8Crk0xuAyS03KMeziowIkjXfCLm87cBN6A81D%2BZbAaJRblATgKYHtnpV3itha96a7BJ4l4KqZyb%2F%2FmirVzLQE%2FhZZf3iR9f0tMglIVdaHVWWdVCUZuYyj1709oNSjolpjQIk%2BZEUfFKMPu%2F6BfS9oYO9AsJkna%2BrQ2hI%2BdYg%2BOfFPf05n4fU%2FmeU4udThUscAAAAASUVORK5CYII%3D)|

# **License and Release**

| **License** | **Release** |
| :--- | :--- |
| [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) | [![Release](https://img.shields.io/github/v/release/jminjares4/ESP32-LCD-1602-Driver)](https://github.com/jminjares4/ESP32-LCD-1602-Driver/releases) |

## **Author**
* [**Jesus Minjares** :zap:](https://github.com/jminjares4)

* Master of Science in Computer Engineering

[![Outlook](https://img.shields.io/badge/Microsoft_Outlook-0078D4?style=for-the-badge&logo=microsoft-outlook&logoColor=white&style=flat)](mailto:[email protected])
[![LinkedIn](https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white&style=flat)](https://www.linkedin.com/in/jesusminjares/) [![GitHub](https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white&style=flat)](https://github.com/jminjares4)