Code Monkey home page Code Monkey logo

esp_mipi's Introduction

MIPI DCS Display Driver

Low level driver for display controllers supporting the MIPI Display Command Set. Tested with ST7735S, ST7789V and ILI9341.

Software License

Usage

Display and SPI parameters all the pins can be changed with menuconfig. You can find predefined values for some popular boards in the sdkconfig folder. To use them copy one of the files to your project root before running menuconfig.

$ cp components/esp_mipi/sdkconfig/m5stack.defaults sdkconfig.defaults
$ make menuconfig

If you have already run menuconfig before, do a defconfig first.

$ cp components/esp_mipi/sdkconfig/m5stack.defaults sdkconfig.defaults
$ make defconfig
$ make menuconfig

Note that this is a low level driver. It provides only init, write, ioctl and close functions. It is meant to be used together with hardware agnostic graphics library such as HAGL. For example usage see also MIPI driver speedtest.

#include <driver/spi_master.h>
#include <stdlib.h>

#include "mipi_display.h"

spi_device_handle_t spi;

void *memset16(uint16_t *source, uint16_t value, size_t count)
{
    uint16_t *ptr = source;

    while (count--) {
        *ptr++ = value;
    }
    return source;
}

void app_main()
{
    uint16_t color;
    int16_t x0;
    int16_t y0;

    mipi_display_init(&spi);

    /* Initialise back buffer */
    uint8_t *buffer = (uint8_t *) heap_caps_malloc(
        (DISPLAY_WIDTH * (DISPLAY_DEPTH / 8) * DISPLAY_HEIGHT),
        MALLOC_CAP_DMA | MALLOC_CAP_32BIT
    );

    /* Clear screen with black color */
    memset16((uint16_t *) buffer, 0x0000, DISPLAY_WIDTH * DISPLAY_HEIGHT);
    mipi_display_write(spi, 0, 0, DISPLAY_WIDTH, DISPLAY_HEIGHT, buffer);

    /* Draw a 100 random pixels on the screen. */
    for (uint8_t i = 0; i < 100; i++) {
        x0 = rand() % DISPLAY_WIDTH;
        y0 = rand() % DISPLAY_HEIGHT;
        color = rand() % 0xffff;
        mipi_display_write(spi, x0, y0, 1, 1, (uint8_t *) &color);
    }

    /* Draw 10 random 32x32 rectangles on the screen. */
    for (uint8_t i = 0; i < 10; i++) {
        x0 = rand() % (DISPLAY_WIDTH - 32);
        y0 = rand() % (DISPLAY_HEIGHT - 32);
        color = rand() % 0xffff;
        memset16((uint16_t *) buffer, color, 32 * 32);
        mipi_display_write(spi, x0, y0, 32, 32, buffer);
    }

    /* Clean shutdown */
    mipi_display_close(spi);

}

You can also issue any command defined in mipi_dcs.h. Commands reading from display are untested at the moment. I do not have a board with MISO connected.

#include <driver/spi_master.h>
#include <stdlib.h>

#include "mipi_dcs.h"
#include "mipi_display.h"

spi_device_handle_t spi;

void app_main()
{
    mipi_display_init(&spi);

    /* Turn display inversion on. */
    mipi_display_ioctl(spi, MIPI_DCS_ENTER_INVERT_MODE, 0, 0);

    /* Read display address mode setting. */
    uint8_t buffer[2];
    mipi_display_ioctl(spi, MIPI_DCS_GET_ADDRESS_MODE, buffer, 2);

    /* Clean shutdown */
    mipi_display_close(spi);
}

License

The MIT License (MIT). Please see License File for more information.

Based on Espressif provided SPI Master example which was released to Public Domain: https://goo.gl/ksC2Ln

esp_mipi's People

Contributors

tuupola avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

longnhieu7 eggfly

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.