diff options
Diffstat (limited to 'src/DisplayApp/DisplayApp.cpp')
| -rw-r--r-- | src/DisplayApp/DisplayApp.cpp | 180 |
1 files changed, 30 insertions, 150 deletions
diff --git a/src/DisplayApp/DisplayApp.cpp b/src/DisplayApp/DisplayApp.cpp index 36302a2..6dc31bc 100644 --- a/src/DisplayApp/DisplayApp.cpp +++ b/src/DisplayApp/DisplayApp.cpp @@ -3,57 +3,11 @@ #include <task.h> #include <libraries/log/nrf_log.h> #include <boards.h> -#include <libraries/gfx/nrf_gfx.h> +#include <nrf_font.h> +#include "Components/Gfx/Gfx.h" using namespace Pinetime::Applications; -Pinetime::Drivers::st7789 lcd; -ret_code_t lcd_init() { - return lcd.Init(); -} - -void lcd_dummy() { - -}; - -void lcd_pixel_draw(uint16_t x, uint16_t y, uint32_t color) { - lcd.DrawPixel(x, y, color); -} - - -void lcd_rectangle_draw(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t color) { - lcd.FillRectangle(x, y, width, height, color); -} - -void lcd_rotation_set(nrf_lcd_rotation_t rotation) { - -} - -void lcd_display_invert(bool invert) { - -} - -static lcd_cb_t st7789_cb = { - .height = 240, - .width = 240 -}; - -static const nrf_lcd_t nrf_lcd_st7789 = { - .lcd_init = lcd_init, - .lcd_uninit = lcd_dummy, - .lcd_pixel_draw = lcd_pixel_draw, - .lcd_rect_draw = lcd_rectangle_draw, - .lcd_display = lcd_dummy, - .lcd_rotation_set = lcd_rotation_set, - .lcd_display_invert = lcd_display_invert, - .p_lcd_cb = &st7789_cb -}; - -//extern const FONT_INFO orkney_24ptFontInfo; -//extern const uint_8 lCD_30ptBitmaps[]; -extern const FONT_INFO lCD_70ptFontInfo; -//extern const FONT_CHAR_INFO lCD_30ptDescriptors[]; - void DisplayApp::Start() { if (pdPASS != xTaskCreate(DisplayApp::Process, "DisplayApp", 256, this, 0, &taskHandle)) APP_ERROR_HANDLER(NRF_ERROR_NO_MEM); @@ -62,123 +16,49 @@ void DisplayApp::Start() { void DisplayApp::Process(void *instance) { auto* app = static_cast<DisplayApp*>(instance); - NRF_LOG_INFO("DisplayApp task started!"); - app->gfx_initialization(); - uint8_t hour = 0; - uint8_t minute = 1; + app->InitHw(); + while (1) { NRF_LOG_INFO("BlinkApp task running!"); - - nrf_gfx_rect_t rect; - rect.height = 74; - rect.width = 52; - rect.x = 7; - rect.y = 78; - nrf_gfx_rect_draw(&nrf_lcd_st7789, &rect, 2, 0x00000000, true); - - - - nrf_gfx_font_desc_t font; - font.charInfo = lCD_70ptFontInfo.charInfo; - font.data = lCD_70ptFontInfo.data; - font.endChar = lCD_70ptFontInfo.endChar; - font.height = lCD_70ptFontInfo.height; - font.spacePixels = lCD_70ptFontInfo.spacePixels; - font.startChar = lCD_70ptFontInfo.startChar; - - - char t[2]; - sprintf(t, "%1d", hour); - - nrf_gfx_point_t point; - point.x = 7; - point.y = 78; - nrf_gfx_print(&nrf_lcd_st7789, - &point, - 0xffff, - t, - &font, - true); - -// point.x = 61; -// point.y = 78; -// nrf_gfx_print(&nrf_lcd_st7789, -// &point, -// 0xffff, -// "2", -// &font, -// true); -// -// point.x = 115; -// point.y = 78; -// nrf_gfx_print(&nrf_lcd_st7789, -// &point, -// 0xffff, -// ":", -// &font, -// true); -// -// point.x = 127; -// point.y = 78; -// nrf_gfx_print(&nrf_lcd_st7789, -// &point, -// 0xffff, -// "3", -// &font, -// true); -// -// point.x = 181; -// point.y = 78; -// nrf_gfx_print(&nrf_lcd_st7789, -// &point, -// 0xffff, -// "4", -// &font, -// true); - - if(hour < 9) - hour++; - else hour = 0; vTaskDelay(1000); } } -void DisplayApp::gfx_initialization(void) -{ +void DisplayApp::InitHw() { nrf_gpio_cfg_output(14); nrf_gpio_cfg_output(22); nrf_gpio_cfg_output(23); nrf_gpio_pin_clear(14); - nrf_gpio_pin_set(22); - nrf_gpio_pin_set(23); + nrf_gpio_pin_clear(22); + nrf_gpio_pin_clear(23); + + Drivers::SpiMaster::Parameters params; + params.bitOrder = Drivers::SpiMaster::BitOrder::Msb_Lsb; + params.mode = Drivers::SpiMaster::Modes::Mode3; + params.Frequency = Drivers::SpiMaster::Frequencies::Freq8Mhz; + params.pinCSN = 25; + params.pinMISO = 4; + params.pinMOSI = 3; + params.pinSCK = 2; + spi.Init(Drivers::SpiMaster::SpiModule::SPI0, params); - APP_ERROR_CHECK(nrf_gfx_init(&nrf_lcd_st7789)); - nrf_gfx_rect_t rect; - rect.height = 240; - rect.width = 240; - rect.x = 0; - rect.y = 0; - nrf_gfx_rect_draw(&nrf_lcd_st7789, &rect, 2, 0x00000000, true); + lcd.reset(new Drivers::St7789(spi, 18)); + gfx.reset(new Components::Gfx(*lcd.get())); + gfx->ClearScreen(); - nrf_gfx_point_t point; - point.x = 7; - point.y = 78; + uint8_t x = 7; + gfx->DrawChar(&largeFont , '0', &x, 78, 0x0); - nrf_gfx_font_desc_t font; - font.charInfo = lCD_70ptFontInfo.charInfo; - font.data = lCD_70ptFontInfo.data; - font.endChar = lCD_70ptFontInfo.endChar; - font.height = lCD_70ptFontInfo.height; - font.spacePixels = lCD_70ptFontInfo.spacePixels; - font.startChar = lCD_70ptFontInfo.startChar; + x = 61; + gfx->DrawChar(&largeFont, '1', &x, 78, 0x0); + x = 115; + gfx->DrawChar(&largeFont, ':', &x, 78, 0x0); - nrf_gfx_print(&nrf_lcd_st7789, - &point, - 0xffff, - "20:45", - &font, - true); + x = 127; + gfx->DrawChar(&largeFont, '2', &x, 78, 0x0); + x = 181; + gfx->DrawChar(&largeFont, '3', &x, 78, 0x0); } |
