Code Monkey home page Code Monkey logo

spi_tft_ili9341's Introduction

SPI TFT ILI9341

Library for driving a ILI9341 TFT display with a SPI interface on Mbed OS 6.

Display

Original library by Peter Drescher. Forked from edit by Michael Ammann.

Minor change of wait_ms to ThisThread::sleep_for to work with Mbed OS 6.

I will add various graphics components and examples in the future.

Graphics components

* = from original library

  • Line*
  • Rectangle/Filled Rectangle*
  • Circle/Filled Circle*
  • Text*
  • Bitmap*
  • Progress Bar

Examples

Setup

#include "mbed.h"
#include "SPI_TFT_ILI9341.h"
#include "ProgressBar.h"

PinName csPin(ARDUINO_UNO_D9);
PinName resetPin(ARDUINO_UNO_D1);
PinName dcPin(ARDUINO_UNO_D10);
PinName mosiPin(ARDUINO_UNO_D11);
PinName sckPin(ARDUINO_UNO_D13);
PinName misoPin(ARDUINO_UNO_D12);

SPI_TFT_ILI9341 display(mosiPin, misoPin, sckPin, csPin, resetPin, dcPin);

Progress Bar

/// ...setup first

// Using display.height() since display is rotated
ProgressBar bar(display, 5, 5, display.height() - 5, 16);

// Get a random float between 0.0 and 1.0
float getRandomFloat() {
    return static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
}

// main() runs in its own thread in the OS
int main()
{
    // Setup display
    display.set_orientation(1);
    display.foreground(White);
    display.background(Black);
    display.cls();

    // Setup progress bar
    bar.setup();
    // Randomly set progress bar percentage
    while (true) {
        bar.setProgressPercentage(getRandomFloat());
        ThisThread::sleep_for(500ms);
    }
}

spi_tft_ili9341's People

Contributors

dreschpe avatar mazgch avatar mitgobla avatar screamerbg avatar

Watchers

 avatar

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.