change TFT display lib
This commit is contained in:
		
							parent
							
								
									67350647c1
								
							
						
					
					
						commit
						0519bdc81d
					
				@ -9,8 +9,10 @@
 | 
			
		||||
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
#include <OneBitDisplay.h>
 | 
			
		||||
extern ONE_BIT_DISPLAY *dp;
 | 
			
		||||
#elif (HAS_DISPLAY) == 2
 | 
			
		||||
#include <TFT_eSPI.h>
 | 
			
		||||
extern TFT_eSPI *dp;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#define DISPLAY_PAGES (7) // number of paxcounter display pages
 | 
			
		||||
@ -22,7 +24,6 @@
 | 
			
		||||
#define MY_FONT_NORMAL FONT_8x8
 | 
			
		||||
#define MY_FONT_LARGE FONT_16x32
 | 
			
		||||
#define MY_FONT_STRETCHED FONT_12x16
 | 
			
		||||
 | 
			
		||||
#define MY_DISPLAY_FIRSTLINE 30
 | 
			
		||||
 | 
			
		||||
#ifndef MY_DISPLAY_RST
 | 
			
		||||
@ -49,18 +50,21 @@
 | 
			
		||||
// settings for TFT display library
 | 
			
		||||
#elif (HAS_DISPLAY == 2)
 | 
			
		||||
 | 
			
		||||
#define MY_FONT_SMALL 1
 | 
			
		||||
#define MY_FONT_SMALL 2
 | 
			
		||||
#define MY_FONT_NORMAL 2
 | 
			
		||||
#define MY_FONT_LARGE 4
 | 
			
		||||
#define MY_FONT_STRETCHED 6
 | 
			
		||||
 | 
			
		||||
#define MY_FONT_LARGE 2
 | 
			
		||||
#define MY_FONT_STRETCHED 2
 | 
			
		||||
#define MY_DISPLAY_FIRSTLINE 30
 | 
			
		||||
 | 
			
		||||
#ifndef TFT_FREQUENCY
 | 
			
		||||
#define TFT_FREQUENCY 400000L
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef MY_DISPLAY_FGCOLOR
 | 
			
		||||
#define MY_DISPLAY_FGCOLOR TFT_WHITE
 | 
			
		||||
#define MY_DISPLAY_FGCOLOR 0xFFFF // TFT_WHITE
 | 
			
		||||
#endif
 | 
			
		||||
#ifndef MY_DISPLAY_BGCOLOR
 | 
			
		||||
#define MY_DISPLAY_BGCOLOR TFT_BLACK
 | 
			
		||||
#define MY_DISPLAY_BGCOLOR 0x0000 // TFT_BLACK
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef TOUCH_CS
 | 
			
		||||
 | 
			
		||||
@ -46,7 +46,7 @@ description = Paxcounter is a device for metering passenger flows in realtime. I
 | 
			
		||||
 | 
			
		||||
[common]
 | 
			
		||||
; for release_version use max. 10 chars total, use any decimal format like "a.b.c"
 | 
			
		||||
release_version = 3.3.0
 | 
			
		||||
release_version = 3.3.1
 | 
			
		||||
; DEBUG LEVEL: For production run set to 0, otherwise device will leak RAM while running!
 | 
			
		||||
; 0=None, 1=Error, 2=Warn, 3=Info, 4=Debug, 5=Verbose
 | 
			
		||||
debug_level = 3
 | 
			
		||||
@ -54,17 +54,18 @@ extra_scripts = pre:build.py
 | 
			
		||||
otakeyfile = ota.conf
 | 
			
		||||
lorakeyfile = loraconf.h
 | 
			
		||||
lmicconfigfile = lmic_config.h
 | 
			
		||||
platform_espressif32 = espressif32@5.0.0
 | 
			
		||||
platform_espressif32 = espressif32@5.1.0
 | 
			
		||||
monitor_speed = 115200
 | 
			
		||||
upload_speed = 115200 ; set by build.py and taken from hal file
 | 
			
		||||
display_library = ; set by build.py and taken from hal file
 | 
			
		||||
lib_deps_lora =
 | 
			
		||||
    mcci-catena/MCCI LoRaWAN LMIC library @ ^4.1.1
 | 
			
		||||
lib_deps_display =
 | 
			
		||||
    https://github.com/bitbank2/OneBitDisplay#8d4ab34
 | 
			
		||||
    https://github.com/bitbank2/OneBitDisplay.git
 | 
			
		||||
    ;bitbank2/OneBitDisplay @ ^2.1.0
 | 
			
		||||
    https://github.com/bitbank2/bb_spi_lcd.git
 | 
			
		||||
    ;bitbank2/bb_spi_lcd @ ^2.3.0
 | 
			
		||||
    ricmoo/QRCode @ ^0.0.1
 | 
			
		||||
    bodmer/TFT_eSPI @ ^2.3.84
 | 
			
		||||
lib_deps_ledmatrix =
 | 
			
		||||
    seeed-studio/Ultrathin_LED_Matrix @ ^1.0.0
 | 
			
		||||
lib_deps_rgbled =
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										168
									
								
								src/display.cpp
									
									
									
									
									
								
							
							
						
						
									
										168
									
								
								src/display.cpp
									
									
									
									
									
								
							@ -13,7 +13,7 @@ Display-Mask (128 x 64 pixel):
 | 
			
		||||
2|
 | 
			
		||||
3|WIFI:abcde BLTH:abcde   SMALL
 | 
			
		||||
4|Batt:abc% chan:ab       SMALL
 | 
			
		||||
5|RLIM:abcd  Mem:abcdKB   SMALL
 | 
			
		||||
5|RLIM:abcd Mem:abcdeKB   SMALL
 | 
			
		||||
6|27.Feb 2019 20:27:00*   SMALL
 | 
			
		||||
7|yyyyyyyyyyyyy xx SFab   SMALL
 | 
			
		||||
 | 
			
		||||
@ -49,60 +49,54 @@ static QRCode qrcode;
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
static ONE_BIT_DISPLAY oled;
 | 
			
		||||
#elif (HAS_DISPLAY) == 2
 | 
			
		||||
static TFT_eSPI tft = TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT);
 | 
			
		||||
TFT_eSPI *dp = NULL;
 | 
			
		||||
#else
 | 
			
		||||
#error Unknown display type specified in hal file
 | 
			
		||||
#endif
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
void dp_setup(int contrast) {
 | 
			
		||||
 | 
			
		||||
#if (HAS_DISPLAY) == 1 // I2C OLED
 | 
			
		||||
  oled.setI2CPins(MY_DISPLAY_SDA, MY_DISPLAY_SCL, MY_DISPLAY_RST);
 | 
			
		||||
  oled.setBitBang(false);
 | 
			
		||||
  oled.I2Cbegin(OLED_TYPE, OLED_ADDR, OLED_FREQUENCY);
 | 
			
		||||
  oled.allocBuffer(); // render all outputs to lib internal backbuffer
 | 
			
		||||
  oled.setTextWrap(false);
 | 
			
		||||
  oled.setRotation(
 | 
			
		||||
  dp = new ONE_BIT_DISPLAY;
 | 
			
		||||
  dp->setI2CPins(MY_DISPLAY_SDA, MY_DISPLAY_SCL, MY_DISPLAY_RST);
 | 
			
		||||
  dp->setBitBang(false);
 | 
			
		||||
  dp->I2Cbegin(OLED_TYPE, OLED_ADDR, OLED_FREQUENCY);
 | 
			
		||||
  dp->allocBuffer(); // render all outputs to lib internal backbuffer
 | 
			
		||||
  dp->setTextWrap(false);
 | 
			
		||||
  dp->setRotation(
 | 
			
		||||
      MY_DISPLAY_FLIP ? 2 : 0); // 0 = no rotation, 1 = 90°, 2 = 180°, 3 = 280°
 | 
			
		||||
 | 
			
		||||
#elif (HAS_DISPLAY) == 2 // SPI TFT
 | 
			
		||||
 | 
			
		||||
  tft.init();
 | 
			
		||||
  tft.setRotation(MY_DISPLAY_FLIP ? 3 : 1);
 | 
			
		||||
  tft.invertDisplay(MY_DISPLAY_INVERT ? true : false);
 | 
			
		||||
  tft.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
 | 
			
		||||
  dp = new TFT_eSPI(MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT);
 | 
			
		||||
  dp->init();
 | 
			
		||||
  dp->setRotation(MY_DISPLAY_FLIP ? 3 : 1);
 | 
			
		||||
  dp->invertDisplay(MY_DISPLAY_INVERT ? true : false);
 | 
			
		||||
  dp->setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  // clear display
 | 
			
		||||
  dp_clear();
 | 
			
		||||
  if (contrast)
 | 
			
		||||
    dp_contrast(contrast);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dp_init(bool verbose) {
 | 
			
		||||
 | 
			
		||||
  dp_setup(DISPLAYCONTRAST);
 | 
			
		||||
 | 
			
		||||
  // show chip information
 | 
			
		||||
  if (verbose) {
 | 
			
		||||
 | 
			
		||||
    // show startup screen
 | 
			
		||||
    // to come -> display .bmp file with logo
 | 
			
		||||
 | 
			
		||||
// show chip information
 | 
			
		||||
#if (VERBOSE)
 | 
			
		||||
    esp_chip_info_t chip_info;
 | 
			
		||||
    esp_chip_info(&chip_info);
 | 
			
		||||
 | 
			
		||||
    dp_setFont(MY_FONT_NORMAL);
 | 
			
		||||
    dp_printf("** PAXCOUNTER **\r\n");
 | 
			
		||||
    dp_printf("Software v%s\r\n", PROGVERSION);
 | 
			
		||||
    dp_printf("ESP32 %d cores\r\n", chip_info.cores);
 | 
			
		||||
    dp_printf("Chip Rev.%d\r\n", chip_info.revision);
 | 
			
		||||
    dp_printf("WiFi%s%s\r\n", (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
 | 
			
		||||
    dp->printf("** PAXCOUNTER **\r\n");
 | 
			
		||||
    dp->printf("Software v%s\r\n", PROGVERSION);
 | 
			
		||||
    dp->printf("ESP32 %d cores\r\n", chip_info.cores);
 | 
			
		||||
    dp->printf("Chip Rev.%d\r\n", chip_info.revision);
 | 
			
		||||
    dp->printf("WiFi%s%s\r\n",
 | 
			
		||||
               (chip_info.features & CHIP_FEATURE_BT) ? "/BT" : "",
 | 
			
		||||
               (chip_info.features & CHIP_FEATURE_BLE) ? "/BLE" : "");
 | 
			
		||||
    dp_printf("%dMB %s Flash", spi_flash_get_chip_size() / (1024 * 1024),
 | 
			
		||||
    dp->printf("%dMB %s Flash", spi_flash_get_chip_size() / (1024 * 1024),
 | 
			
		||||
               (chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "int." : "ext.");
 | 
			
		||||
 | 
			
		||||
    // give user some time to read or take picture
 | 
			
		||||
@ -143,11 +137,15 @@ void dp_init(bool verbose) {
 | 
			
		||||
  } // verbose
 | 
			
		||||
 | 
			
		||||
  dp_power(cfg.screenon); // set display off if disabled
 | 
			
		||||
 | 
			
		||||
} // dp_init
 | 
			
		||||
 | 
			
		||||
void dp_refresh(bool nextPage) {
 | 
			
		||||
 | 
			
		||||
  struct count_payload_t count; // libpax count storage
 | 
			
		||||
  static uint8_t DisplayPage = 0;
 | 
			
		||||
  char timeState, strftime_buf[64];
 | 
			
		||||
  time_t now;
 | 
			
		||||
  struct tm timeinfo = {0};
 | 
			
		||||
#ifndef HAS_BUTTON
 | 
			
		||||
  static uint32_t framecounter = 0;
 | 
			
		||||
#endif
 | 
			
		||||
@ -216,6 +214,11 @@ void dp_drawPage(bool nextpage) {
 | 
			
		||||
    // ---------- page 0: parameters overview ----------
 | 
			
		||||
  case 0:
 | 
			
		||||
 | 
			
		||||
    // show pax
 | 
			
		||||
    libpax_counter_count(&count);
 | 
			
		||||
    dp_setFont(MY_FONT_LARGE);
 | 
			
		||||
    dp->printf("%-8d", count.pax);
 | 
			
		||||
 | 
			
		||||
    dp_setFont(MY_FONT_SMALL);
 | 
			
		||||
    dp_setTextCursor();
 | 
			
		||||
 | 
			
		||||
@ -224,22 +227,22 @@ void dp_drawPage(bool nextpage) {
 | 
			
		||||
 | 
			
		||||
#if ((WIFICOUNTER) && (BLECOUNTER))
 | 
			
		||||
    if (cfg.wifiscan)
 | 
			
		||||
      dp_printf("WIFI:%-5d", count.wifi_count);
 | 
			
		||||
      dp->printf("WIFI:%-5d", count.wifi_count);
 | 
			
		||||
    else
 | 
			
		||||
      dp_printf("WIFI:off");
 | 
			
		||||
    if (cfg.blescan)
 | 
			
		||||
      dp_printf("BLTH:%-5d", count.ble_count);
 | 
			
		||||
      dp->printf("BLTH:%-5d", count.ble_count);
 | 
			
		||||
    else
 | 
			
		||||
      dp_printf(" BLTH:off");
 | 
			
		||||
#elif ((WIFICOUNTER) && (!BLECOUNTER))
 | 
			
		||||
    if (cfg.wifiscan)
 | 
			
		||||
      dp_printf("WIFI:%-5d", count.wifi_count);
 | 
			
		||||
      dp->printf("WIFI:%-5d", count.wifi_count);
 | 
			
		||||
    else
 | 
			
		||||
      dp_printf("WIFI:off");
 | 
			
		||||
#elif ((!WIFICOUNTER) && (BLECOUNTER))
 | 
			
		||||
    if (cfg.blescan)
 | 
			
		||||
      dp_printf("BLTH:%-5d", count.ble_count);
 | 
			
		||||
    dp_printf("BLTH:off");
 | 
			
		||||
      dp->printf("BLTH:%-5d", count.ble_count);
 | 
			
		||||
    dp->printf("BLTH:off");
 | 
			
		||||
#else
 | 
			
		||||
    dp_printf("Sniffer disabled");
 | 
			
		||||
#endif
 | 
			
		||||
@ -259,8 +262,8 @@ void dp_drawPage(bool nextpage) {
 | 
			
		||||
 | 
			
		||||
    // line 5: RSSI limiter + free memory
 | 
			
		||||
    // RLIM:abcd  Mem:abcdKB
 | 
			
		||||
    dp_printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit);
 | 
			
		||||
    dp_printf("  Mem:%4dKB\r\n", getFreeRAM() / 1024);
 | 
			
		||||
    dp->printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit);
 | 
			
		||||
    dp->printf("  Mem:%4dKB\r\n", getFreeRAM() / 1024);
 | 
			
		||||
 | 
			
		||||
    // line 6: time + date
 | 
			
		||||
    // Wed Jan 12 21:49:08 *
 | 
			
		||||
@ -308,14 +311,20 @@ void dp_drawPage(bool nextpage) {
 | 
			
		||||
    // 6|fUp:000000 fDn:000000
 | 
			
		||||
    // 7|SNR:-0000  RSSI:-0000
 | 
			
		||||
 | 
			
		||||
    // show pax
 | 
			
		||||
    libpax_counter_count(&count);
 | 
			
		||||
    dp_setFont(MY_FONT_LARGE);
 | 
			
		||||
    dp->printf("%-8d", count.pax);
 | 
			
		||||
 | 
			
		||||
    dp_setFont(MY_FONT_SMALL);
 | 
			
		||||
    dp_setTextCursor();
 | 
			
		||||
    dp_printf("Net:%06X   Pwr:%-2d\r\n", LMIC.netid & 0x001FFFFF, LMIC.radio_txpow);
 | 
			
		||||
    dp_printf("Dev:%08X DR:%1d\r\n", LMIC.devaddr, LMIC.datarate);
 | 
			
		||||
    dp_printf("ChMsk:%04X Nonce:%04X\r\n", LMIC.channelMap, LMIC.devNonce);
 | 
			
		||||
    dp_printf("fUp:%-6d fDn:%-6d\r\n", LMIC.seqnoUp ? LMIC.seqnoUp - 1 : 0,
 | 
			
		||||
    dp->setCursor(0, MY_DISPLAY_FIRSTLINE);
 | 
			
		||||
    dp->printf("Net:%06X   Pwr:%-2d\r\n", LMIC.netid & 0x001FFFFF,
 | 
			
		||||
               LMIC.radio_txpow);
 | 
			
		||||
    dp->printf("Dev:%08X DR:%1d\r\n", LMIC.devaddr, LMIC.datarate);
 | 
			
		||||
    dp->printf("ChMsk:%04X Nonce:%04X\r\n", LMIC.channelMap, LMIC.devNonce);
 | 
			
		||||
    dp->printf("fUp:%-6d fDn:%-6d\r\n", LMIC.seqnoUp ? LMIC.seqnoUp - 1 : 0,
 | 
			
		||||
               LMIC.seqnoDn ? LMIC.seqnoDn - 1 : 0);
 | 
			
		||||
    dp_printf("SNR:%-5d  RSSI:%-5d", (LMIC.snr + 2) / 4, LMIC.rssi);
 | 
			
		||||
    dp->printf("SNR:%-5d  RSSI:%-5d", (LMIC.snr + 2) / 4, LMIC.rssi);
 | 
			
		||||
 | 
			
		||||
    dp_dump();
 | 
			
		||||
    break;
 | 
			
		||||
@ -328,6 +337,11 @@ void dp_drawPage(bool nextpage) {
 | 
			
		||||
 | 
			
		||||
#if (HAS_GPS)
 | 
			
		||||
 | 
			
		||||
    // show pax
 | 
			
		||||
    libpax_counter_count(&count);
 | 
			
		||||
    dp_setFont(MY_FONT_LARGE);
 | 
			
		||||
    dp->printf("%-8d", count.pax);
 | 
			
		||||
 | 
			
		||||
    // show satellite status at bottom line
 | 
			
		||||
    dp_setFont(MY_FONT_SMALL);
 | 
			
		||||
    dp_setTextCursor(0, 56);
 | 
			
		||||
@ -379,7 +393,7 @@ void dp_drawPage(bool nextpage) {
 | 
			
		||||
    dp_setFont(MY_FONT_LARGE);
 | 
			
		||||
    dp_printf("%.8s\r\n", strftime_buf);
 | 
			
		||||
    dp_setFont(MY_FONT_SMALL);
 | 
			
		||||
    dp_printf("%21.1f", uptime() / 1000.0);
 | 
			
		||||
    dp->printf("%21.1f", uptime() / 1000.0);
 | 
			
		||||
    dp_dump();
 | 
			
		||||
    break;
 | 
			
		||||
 | 
			
		||||
@ -416,91 +430,51 @@ void dp_setTextCursor(int x, int y) {
 | 
			
		||||
 | 
			
		||||
void dp_setFont(int font, int inv) {
 | 
			
		||||
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
  // handle invers printing
 | 
			
		||||
  if (inv)
 | 
			
		||||
    oled.setTextColor(MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR);
 | 
			
		||||
  else
 | 
			
		||||
    oled.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
 | 
			
		||||
    dp->setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
 | 
			
		||||
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
  // set desired font
 | 
			
		||||
  oled.setFont(font);
 | 
			
		||||
 | 
			
		||||
  dp->setFont(font);
 | 
			
		||||
#elif (HAS_DISPLAY) == 2
 | 
			
		||||
  // handle invers printing
 | 
			
		||||
  if (inv)
 | 
			
		||||
    tft.setTextColor(MY_DISPLAY_BGCOLOR, MY_DISPLAY_FGCOLOR);
 | 
			
		||||
  else
 | 
			
		||||
    tft.setTextColor(MY_DISPLAY_FGCOLOR, MY_DISPLAY_BGCOLOR);
 | 
			
		||||
 | 
			
		||||
  // map desired oled font to tft font
 | 
			
		||||
  switch (font) {
 | 
			
		||||
  case MY_FONT_STRETCHED: // 16x16 on OLED
 | 
			
		||||
  case MY_FONT_LARGE:     // 16x32 on OLED
 | 
			
		||||
    tft.setTextFont(4);   // 26px
 | 
			
		||||
    dp->setTextFont(4);   // 26px
 | 
			
		||||
    break;
 | 
			
		||||
  case MY_FONT_SMALL:  // 6x8 on OLED
 | 
			
		||||
  case MY_FONT_NORMAL: // 8x8 on OLED
 | 
			
		||||
  default:
 | 
			
		||||
    tft.setTextFont(2); // 16px
 | 
			
		||||
    dp->setTextFont(2); // 16px
 | 
			
		||||
    break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dp_printf(const char *format, ...) {
 | 
			
		||||
  char loc_buf[64];
 | 
			
		||||
  char *temp = loc_buf;
 | 
			
		||||
  va_list arg;
 | 
			
		||||
  va_list copy;
 | 
			
		||||
  va_start(arg, format);
 | 
			
		||||
  va_copy(copy, arg);
 | 
			
		||||
  int len = vsnprintf(temp, sizeof(loc_buf), format, copy);
 | 
			
		||||
  va_end(copy);
 | 
			
		||||
  if (len < 0) {
 | 
			
		||||
    va_end(arg);
 | 
			
		||||
    return;
 | 
			
		||||
  };
 | 
			
		||||
  if (len >= sizeof(loc_buf)) {
 | 
			
		||||
    temp = (char *)malloc(len + 1);
 | 
			
		||||
    if (temp == NULL) {
 | 
			
		||||
      va_end(arg);
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
    vsnprintf(temp, len + 1, format, arg);
 | 
			
		||||
  }
 | 
			
		||||
  va_end(arg);
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
  oled.write(temp);
 | 
			
		||||
#elif (HAS_DISPLAY) == 2
 | 
			
		||||
  tft.printf(temp);
 | 
			
		||||
#endif
 | 
			
		||||
  if (temp != loc_buf) {
 | 
			
		||||
    free(temp);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dp_dump(uint8_t *pBuffer) {
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
  if (pBuffer)
 | 
			
		||||
    memcpy(oled.getBuffer(), pBuffer, PLOTBUFFERSIZE);
 | 
			
		||||
  oled.display();
 | 
			
		||||
    memcpy(dp->getBuffer(), pBuffer, PLOTBUFFERSIZE);
 | 
			
		||||
  dp->display();
 | 
			
		||||
#elif (HAS_DISPLAY) == 2
 | 
			
		||||
  if (pBuffer)
 | 
			
		||||
    tft.drawBitmap(0, 0, pBuffer, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT,
 | 
			
		||||
    dp->drawBitmap(0, 0, pBuffer, MY_DISPLAY_WIDTH, MY_DISPLAY_HEIGHT,
 | 
			
		||||
                   MY_DISPLAY_FGCOLOR);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dp_clear(void) {
 | 
			
		||||
#if (HAS_DISPLAY) == 1
 | 
			
		||||
  oled.fillScreen(MY_DISPLAY_BGCOLOR);
 | 
			
		||||
  oled.display();
 | 
			
		||||
  dp->fillScreen(MY_DISPLAY_BGCOLOR);
 | 
			
		||||
  dp->display();
 | 
			
		||||
#elif (HAS_DISPLAY) == 2
 | 
			
		||||
  tft.fillScreen(MY_DISPLAY_BGCOLOR);
 | 
			
		||||
  dp->fillScreen(MY_DISPLAY_BGCOLOR);
 | 
			
		||||
#endif
 | 
			
		||||
  dp_setTextCursor(0, 0);
 | 
			
		||||
  dp->setCursor(0, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void dp_contrast(uint8_t contrast) {
 | 
			
		||||
@ -574,7 +548,6 @@ void dp_fillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height,
 | 
			
		||||
 | 
			
		||||
int dp_drawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
 | 
			
		||||
                 const uint8_t dot) {
 | 
			
		||||
 | 
			
		||||
  if (x > MY_DISPLAY_WIDTH || y > MY_DISPLAY_HEIGHT)
 | 
			
		||||
    return -1;
 | 
			
		||||
 | 
			
		||||
@ -592,7 +565,6 @@ int dp_drawPixel(uint8_t *buf, const uint16_t x, const uint16_t y,
 | 
			
		||||
 | 
			
		||||
void dp_scrollHorizontal(uint8_t *buf, const uint16_t width,
 | 
			
		||||
                         const uint16_t height, bool left) {
 | 
			
		||||
 | 
			
		||||
  uint16_t col, page, idx = 0;
 | 
			
		||||
 | 
			
		||||
  for (page = 0; page < height / 8; page++) {
 | 
			
		||||
@ -615,7 +587,6 @@ void dp_scrollHorizontal(uint8_t *buf, const uint16_t width,
 | 
			
		||||
 | 
			
		||||
void dp_scrollVertical(uint8_t *buf, const uint16_t width,
 | 
			
		||||
                       const uint16_t height, int offset) {
 | 
			
		||||
 | 
			
		||||
  uint64_t buf_col;
 | 
			
		||||
 | 
			
		||||
  if (!offset)
 | 
			
		||||
@ -638,7 +609,6 @@ void dp_scrollVertical(uint8_t *buf, const uint16_t width,
 | 
			
		||||
// ------------- curve plotter -----------------
 | 
			
		||||
 | 
			
		||||
void dp_plotCurve(uint16_t count, bool reset) {
 | 
			
		||||
 | 
			
		||||
  static uint16_t last_count = 0, col = 0, row = 0;
 | 
			
		||||
  uint16_t v_scroll = 0;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -28,9 +28,6 @@
 | 
			
		||||
#define CFG_sx1276_radio 1 // select LoRa chip
 | 
			
		||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
 | 
			
		||||
 | 
			
		||||
#define HAS_DISPLAY 2 // TFT-LCD, support work in progess, not ready yet
 | 
			
		||||
//#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
 | 
			
		||||
#define HAS_LED NOT_A_PIN // no on board LED (?)
 | 
			
		||||
#define HAS_BUTTON (39) // on board button A
 | 
			
		||||
 | 
			
		||||
@ -44,38 +41,22 @@
 | 
			
		||||
// GPS settings
 | 
			
		||||
#define HAS_GPS 1 // use on board GPS
 | 
			
		||||
#define GPS_SERIAL 9600, SERIAL_8N1, RXD2, TXD2 // UBlox NEO 6M RX, TX
 | 
			
		||||
#define GPS_INT GPIO_NUM_35 // 30ns accurary timepulse, to be external wired on pcb: shorten R12!
 | 
			
		||||
#define GPS_INT 
 | 
			
		||||
 | 
			
		||||
// Display Settings
 | 
			
		||||
#define HAS_DISPLAY 2   // TFT-LCD
 | 
			
		||||
//#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
#define MY_DISPLAY_WIDTH 320
 | 
			
		||||
#define MY_DISPLAY_HEIGHT 240
 | 
			
		||||
#define MY_DISPLAY_INVERT 1
 | 
			
		||||
 | 
			
		||||
// setting for M5 display
 | 
			
		||||
#define USER_SETUP_LOADED 1
 | 
			
		||||
#define ILI9341_DRIVER 1
 | 
			
		||||
#define M5STACK // needed for TFT driver
 | 
			
		||||
 | 
			
		||||
#define TFT_MISO MISO  // SPI
 | 
			
		||||
#define TFT_TYPE LCD_ILI9341
 | 
			
		||||
#define TFT_MOSI MOSI   // SPI
 | 
			
		||||
#define TFT_MISO MISO   // SPI
 | 
			
		||||
#define TFT_SCLK SCK    // SPI
 | 
			
		||||
#define TFT_CS   GPIO_NUM_14    // Chip select control
 | 
			
		||||
#define TFT_DC   GPIO_NUM_27    // Data Command control
 | 
			
		||||
#define TFT_RST  GPIO_NUM_33    // Reset
 | 
			
		||||
#define TFT_BL   GPIO_NUM_32    // LED back-light
 | 
			
		||||
 | 
			
		||||
#define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
 | 
			
		||||
 | 
			
		||||
//#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
 | 
			
		||||
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
 | 
			
		||||
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
 | 
			
		||||
//#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
 | 
			
		||||
//#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
//#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
 | 
			
		||||
//#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
 | 
			
		||||
#define SMOOTH_FONT
 | 
			
		||||
 | 
			
		||||
#define SPI_FREQUENCY  40000000
 | 
			
		||||
#define TFT_FREQUENCY 40000000
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,6 @@
 | 
			
		||||
#define LORA_IO1  GPIO_NUM_34 // must be wired by you on PCB!
 | 
			
		||||
#define LORA_IO2  LMIC_UNUSED_PIN
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// enable only if you want to store a local paxcount table on the device
 | 
			
		||||
#define HAS_SDCARD  1      // this board has an SD-card-reader/writer
 | 
			
		||||
#define SDCARD_CS    GPIO_NUM_4
 | 
			
		||||
@ -31,9 +30,6 @@
 | 
			
		||||
#define CFG_sx1276_radio 1 // select LoRa chip
 | 
			
		||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
 | 
			
		||||
 | 
			
		||||
#define HAS_DISPLAY 2 // TFT-LCD, support work in progess, not ready yet
 | 
			
		||||
//#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
 | 
			
		||||
#define HAS_LED NOT_A_PIN // no on board LED (?)
 | 
			
		||||
#define RGB_LED_COUNT 10
 | 
			
		||||
 | 
			
		||||
@ -53,35 +49,19 @@
 | 
			
		||||
// #define GPS_INT GPIO_NUM_35 // 30ns accurary timepulse, to be external wired on pcb: shorten R12!
 | 
			
		||||
 | 
			
		||||
// Display Settings
 | 
			
		||||
#define HAS_DISPLAY 2   // TFT-LCD
 | 
			
		||||
//#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
#define MY_DISPLAY_WIDTH 320
 | 
			
		||||
#define MY_DISPLAY_HEIGHT 240
 | 
			
		||||
#define MY_DISPLAY_INVERT 1
 | 
			
		||||
 | 
			
		||||
// setting for M5 display
 | 
			
		||||
#define USER_SETUP_LOADED 1
 | 
			
		||||
#define ILI9341_DRIVER 1
 | 
			
		||||
#define M5STACK // needed for TFT driver
 | 
			
		||||
 | 
			
		||||
#define TFT_MISO MISO  // SPI
 | 
			
		||||
#define TFT_TYPE LCD_ILI9341
 | 
			
		||||
#define TFT_MOSI MOSI   // SPI
 | 
			
		||||
#define TFT_MISO MISO   // SPI
 | 
			
		||||
#define TFT_SCLK SCK    // SPI
 | 
			
		||||
#define TFT_CS   GPIO_NUM_14    // Chip select control
 | 
			
		||||
#define TFT_DC   GPIO_NUM_27    // Data Command control
 | 
			
		||||
#define TFT_RST  GPIO_NUM_33    // Reset
 | 
			
		||||
#define TFT_BL   GPIO_NUM_32    // LED back-light
 | 
			
		||||
 | 
			
		||||
#define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
 | 
			
		||||
 | 
			
		||||
//#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
 | 
			
		||||
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
 | 
			
		||||
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
 | 
			
		||||
//#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
 | 
			
		||||
//#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
//#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
 | 
			
		||||
//#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
 | 
			
		||||
#define SMOOTH_FONT
 | 
			
		||||
 | 
			
		||||
#define SPI_FREQUENCY  40000000
 | 
			
		||||
#define TFT_FREQUENCY 40000000
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@ -9,9 +9,6 @@
 | 
			
		||||
 | 
			
		||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
 | 
			
		||||
 | 
			
		||||
#define HAS_DISPLAY 2      // TFT-LCD, support work in progess, not ready yet
 | 
			
		||||
#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
 | 
			
		||||
#define HAS_LED NOT_A_PIN  // no on board LED (?)
 | 
			
		||||
#define HAS_BUTTON (35)    // on board button A
 | 
			
		||||
 | 
			
		||||
@ -20,36 +17,19 @@
 | 
			
		||||
#define BAT_VOLTAGE_DIVIDER 2.605f           // voltage divider
 | 
			
		||||
 | 
			
		||||
// Display Settings
 | 
			
		||||
#define HAS_DISPLAY 2       // TFT-LCD
 | 
			
		||||
#define MY_DISPLAY_FLIP  1  // use if display is rotated
 | 
			
		||||
#define MY_DISPLAY_WIDTH 135
 | 
			
		||||
#define MY_DISPLAY_HEIGHT 240
 | 
			
		||||
#define MY_DISPLAY_INVERT 1
 | 
			
		||||
 | 
			
		||||
// setting for TTGO T-display
 | 
			
		||||
#define USER_SETUP_LOADED 1
 | 
			
		||||
#define ST7789_DRIVER 1
 | 
			
		||||
 | 
			
		||||
#define CGRAM_OFFSET
 | 
			
		||||
 | 
			
		||||
#define TFT_TYPE LCD_ST7789_135 // size 135x240 px
 | 
			
		||||
#define TFT_MOSI GPIO_NUM_19 // SPI
 | 
			
		||||
#define TFT_MISO NOT_A_PIN   // SPI
 | 
			
		||||
#define TFT_SCLK GPIO_NUM_18 // SPI
 | 
			
		||||
#define TFT_CS   GPIO_NUM_5  // Chip select control
 | 
			
		||||
#define TFT_DC   GPIO_NUM_16 // Data Command control
 | 
			
		||||
#define TFT_RST  GPIO_NUM_23 // Reset
 | 
			
		||||
#define TFT_BL   GPIO_NUM_4  // LED back-light
 | 
			
		||||
 | 
			
		||||
#define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
 | 
			
		||||
 | 
			
		||||
#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
 | 
			
		||||
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
 | 
			
		||||
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
 | 
			
		||||
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
 | 
			
		||||
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
//#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT
 | 
			
		||||
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
 | 
			
		||||
#define SMOOTH_FONT
 | 
			
		||||
 | 
			
		||||
#define SPI_FREQUENCY  40000000
 | 
			
		||||
#define SPI_READ_FREQUENCY 6000000
 | 
			
		||||
#define TFT_FREQUENCY 40000000
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@ -9,9 +9,6 @@
 | 
			
		||||
 | 
			
		||||
#define DISABLE_BROWNOUT 1 // comment out if you want to keep brownout feature
 | 
			
		||||
 | 
			
		||||
#define HAS_DISPLAY 2      // TFT-LCD, support work in progess, not ready yet
 | 
			
		||||
#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
 | 
			
		||||
#define HAS_LED NOT_A_PIN  // no on board LED (?)
 | 
			
		||||
#define HAS_BUTTON (33)    // on board button A
 | 
			
		||||
 | 
			
		||||
@ -20,39 +17,20 @@
 | 
			
		||||
#define BAT_VOLTAGE_DIVIDER 2.605f           // voltage divider
 | 
			
		||||
 | 
			
		||||
// Display Settings
 | 
			
		||||
#define HAS_DISPLAY 2      // TFT-LCD
 | 
			
		||||
#define MY_DISPLAY_FLIP  1 // use if display is rotated
 | 
			
		||||
#define MY_DISPLAY_WIDTH 80
 | 
			
		||||
#define MY_DISPLAY_HEIGHT 160
 | 
			
		||||
#define MY_DISPLAY_INVERT 1
 | 
			
		||||
 | 
			
		||||
// setting for TTGO T-display
 | 
			
		||||
#define USER_SETUP_LOADED 1
 | 
			
		||||
#define ST7735_DRIVER 1
 | 
			
		||||
 | 
			
		||||
#define CGRAM_OFFSET
 | 
			
		||||
 | 
			
		||||
#define TFT_MISO -1
 | 
			
		||||
#define TFT_TYPE LCD_ST7735S
 | 
			
		||||
#define TFT_MOSI GPIO_NUM_19 // SPI
 | 
			
		||||
#define TFT_MISO NOT_A_PIN   // SPI
 | 
			
		||||
#define TFT_SCLK GPIO_NUM_18 // SPI
 | 
			
		||||
#define TFT_CS   GPIO_NUM_5  // Chip select control
 | 
			
		||||
#define TFT_DC   GPIO_NUM_23 // Data Command control
 | 
			
		||||
#define TFT_RST  GPIO_NUM_26 // Reset
 | 
			
		||||
#define TFT_BL   GPIO_NUM_27 // LED back-light
 | 
			
		||||
#define TFT_BACKLIGHT_ON 1
 | 
			
		||||
#define ST7735_GREENTAB160x80
 | 
			
		||||
 | 
			
		||||
#define TFT_RGB_ORDER TFT_BGR  // Colour order Blue-Green-Red
 | 
			
		||||
 | 
			
		||||
#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
 | 
			
		||||
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
 | 
			
		||||
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
 | 
			
		||||
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
 | 
			
		||||
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
 | 
			
		||||
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
 | 
			
		||||
#define SMOOTH_FONT
 | 
			
		||||
 | 
			
		||||
#define SPI_FREQUENCY  27000000
 | 
			
		||||
#define SPI_READ_FREQUENCY 6000000
 | 
			
		||||
#define TFT_FREQUENCY 27000000
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user