Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // use C++ with ESP-IDF:
- extern "C" { void app_main(); }
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_system.h"
- #include "esp_spiffs.h"
- #include "drivers/ili9341.hpp"
- #include "gfx_cpp14.hpp"
- #define LCD_HOST VSPI_HOST
- #define DMA_CHAN 2
- #define PIN_NUM_MISO GPIO_NUM_19
- #define PIN_NUM_MOSI GPIO_NUM_23
- #define PIN_NUM_CLK GPIO_NUM_18
- #define PIN_NUM_CS GPIO_NUM_5
- #define PIN_NUM_DC GPIO_NUM_2
- #define PIN_NUM_RST GPIO_NUM_4
- #define PIN_NUM_BCKL GPIO_NUM_15
- // configure the spi bus. Must be done before the driver
- spi_master spi_host(nullptr,
- LCD_HOST,
- PIN_NUM_CLK,
- PIN_NUM_MISO,
- PIN_NUM_MOSI,
- GPIO_NUM_NC,
- GPIO_NUM_NC,
- 320*240+8,
- DMA_CHAN);
- // we use the default, modest buffer - it makes things slower but uses less
- // memory. it usually works fine at default but you can change it for performance
- // tuning. It's the final parameter: Note that it shouldn't be any bigger than
- // the DMA size
- using lcd_type = ili9341<LCD_HOST,
- PIN_NUM_CS,
- PIN_NUM_DC,
- PIN_NUM_RST,
- PIN_NUM_BCKL>;
- lcd_type lcd;
- using lcd_color = color<typename lcd_type::pixel_type>;
- void app_main(void)
- {
- // we'll be loading the font from SPIFFs.
- // To embed the font instead, run the lib/gfx/tools/fontgen tool to create a header.
- // then include that header. The font will be precreated with the same name as the header
- // sans extension.
- // check to make sure SPI was initialized successfully
- if(!spi_host.initialized()) {
- printf("SPI host initialization error.\r\n");
- abort();
- }
- // mount SPIFFS
- esp_err_t ret;
- esp_vfs_spiffs_conf_t conf = {};
- conf.base_path="/spiffs";
- conf.format_if_mount_failed=false;
- conf.max_files=5;
- conf.partition_label="storage";
- ret=esp_vfs_spiffs_register(&conf);
- ESP_ERROR_CHECK(ret);
- file_stream fs("/spiffs/Bm437_Verite_9x16.FON");
- font my_font;
- if(gfx::font::result::success!=font::read(&fs,&my_font)) {
- fs.close();
- printf("Error loading font");
- return;
- }
- fs.close();
- const char* sz="test!";
- for(int i = 0;i<200;++i) {
- // drawing with a non-transparent background is significantly faster
- draw::text(lcd,{0,0,lcd.bounds().x2,lcd.bounds().y2},sz,my_font,lcd_color::white,lcd_color::black,false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement