From 7f214ffbb039232109bd7e1757017958b0cd0898 Mon Sep 17 00:00:00 2001 From: geeksville Date: Fri, 28 Aug 2020 15:33:33 -0700 Subject: [PATCH] TFT kinda correct now - but slow because of bit banging --- src/graphics/TFT.cpp | 20 ++++++++++++++------ src/mesh/SX1262Interface.cpp | 4 ++-- variants/lora_relay_v1/variant.h | 6 ++++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/graphics/TFT.cpp b/src/graphics/TFT.cpp index 9acd81e6..ed367990 100644 --- a/src/graphics/TFT.cpp +++ b/src/graphics/TFT.cpp @@ -1,25 +1,33 @@ #include "configuration.h" #ifdef ST7735_CS - #include "TFT.h" +#include "graphics/configs.h" #include #include // Graphics and font library for ST7735 driver chip TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h - TFTDisplay::TFTDisplay(uint8_t address, int sda, int scl) { - setGeometry( - GEOMETRY_128_64); // FIXME - currently we lie and claim 128x64 because I'm not yet sure other resolutions will work + setGeometry(GEOMETRY_128_64); // FIXME - currently we lie and claim 128x64 because I'm not yet sure other resolutions will + // work ie GEOMETRY_RAWMODE } // Write the buffer to the display memory void TFTDisplay::display(void) { // FIXME - only draw bits have changed (use backbuf similar to the other displays) - tft.drawBitmap(0, 0, buffer, 128, 64, TFT_YELLOW, TFT_BLACK); + // tft.drawBitmap(0, 0, buffer, 128, 64, TFT_YELLOW, TFT_BLACK); + for (uint8_t y = 0; y < SCREEN_HEIGHT; y++) { + for (uint8_t x = 0; x < SCREEN_WIDTH; x++) { + + // get src pixel in the page based ordering the OLED lib uses FIXME, super inefficent + auto b = buffer[x + (y / 8) * SCREEN_WIDTH]; + auto isset = b & (1 << (y & 7)); + tft.drawPixel(x, y, isset ? TFT_WHITE : TFT_BLACK); + } + } } // Send a command to the display (low level function) @@ -41,7 +49,7 @@ bool TFTDisplay::connect() tft.init(); tft.setRotation(3); // Orient horizontal and wide underneath the silkscreen name label - tft.fillScreen(TFT_BLUE); + // tft.fillScreen(TFT_BLUE); // tft.drawRect(0, 0, 40, 10, TFT_PURPLE); // wide rectangle in upper left return true; diff --git a/src/mesh/SX1262Interface.cpp b/src/mesh/SX1262Interface.cpp index b7fe422f..f581cdb1 100644 --- a/src/mesh/SX1262Interface.cpp +++ b/src/mesh/SX1262Interface.cpp @@ -75,8 +75,8 @@ bool SX1262Interface::reconfigure() assert(err == ERR_NONE); // Hmm - seems to lower SNR when the signal levels are high. Leaving off for now... - //err = lora.setRxGain(true); - //assert(err == ERR_NONE); + // err = lora.setRxGain(true); + // assert(err == ERR_NONE); err = lora.setSyncWord(syncWord); assert(err == ERR_NONE); diff --git a/variants/lora_relay_v1/variant.h b/variants/lora_relay_v1/variant.h index 0f4ac488..3562724f 100644 --- a/variants/lora_relay_v1/variant.h +++ b/variants/lora_relay_v1/variant.h @@ -117,7 +117,9 @@ static const uint8_t SCK = PIN_SPI_SCK; #define I2C_ADDR_BQ27441 0x55 // Battery gauge // CUSTOM GPIOs the SX1262 -#define SX1262_CS (32) +// #define SX1262_CS (32) +#define USE_SIM_RADIO +#define USE_SEGGER #define SX1262_DIO1 (29) #define SX1262_DIO2 (30) #define SX1262_BUSY (33) // Supposed to be P0.18 but because of reworks, now on P0.31 (18) @@ -130,7 +132,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #define SX1262_E22 // Indicates this SX1262 is inside of an ebyte E22 module and special config should be done for that #define ST7735_RESET (11) // Output -#define ST7735_CS (12) +#define ST7735_CS (12) #define ST7735_BACKLIGHT_EN (13) #define ST7735_RS (9)