// RBPXPLRTERM I2C SSD1306 OLED Display interface - HEADERs

#ifndef _display_h
#define _display_h

#include "RBPXPLRTERM_base.h"
#include "RBPXPLRTERM_config.h"

#if defined(DSP_SSD1306I2C)
#include <SSD1306.h>
#elif defined(DSP_ST7735)
#include <Adafruit_GFX.h>               // Adafruit LCD Graphics library
#include <Adafruit_ST7735.h>            // ST7735 LCD Display library
#include <SPI.h>                        // Arduino SPI and I2C library
#elif defined(DSP_ST7735_eSPI)          // accelerated ST7735 using Bodmer's TFT_eSPI
#include <TFT_eSPI.h>
#include <SPI.h>
#else
#error unrecognized DSP for display_h
#endif 

#if defined(DSP_SSD1306I2C)

#define SSD1306_ADDRESS 0x3c  // I2C address of SSD1306 OLED display

#elif defined(DSP_ST7735)

//
// standard SPI interface (Raspberry Pi Pico SPI0)
//
#define SPI_SCK_PIN       18
#define SPI_MOSI_PIN      19
#define SPI_MISO_PIN      16
//
// the ST7735 LCD
//
// the LCD is connected to the common SPI interface 
#define LCD_CS_PIN        17    // LCD SPI chip select line
#define LCD_DC_PIN        3
#define LCD_RES_PIN       6     // LCD reset line
#define LCD_BL_PIN        2

#elif defined(DSP_ST7735_eSPI)

//
// ST7735 based TFT using Bodmers TFT_eSPI driver 

// #define XSTR(x) STR(x)
// #define STR(x) #x

//
// standard SPI interface (Raspberry Pi Pico SPI0)
//
// #define SPI_SCK_PIN       18
// #define SPI_MOSI_PIN      19
// #define SPI_MISO_PIN      16
//
// the ST7735 LCD
//
// the LCD is connected to the common SPI interface 
// #define LCD_CS_PIN        17    // LCD SPI chip select line
// #define LCD_DC_PIN        3
// #define LCD_RES_PIN       6     // LCD reset line
#define LCD_BL_PIN        2

// #pragma message "TFT_eSPI user setup info is: " XSTR(USER_SETUP_INFO)

#else
#error unrecognized DSP at display definitions
#endif

#define EVT_POPUP_DISPLAY 3301
#define EVT_DISPLAY_SAVER 3302

void enableDisplay();
void disableDisplay();
bool isDisplayEnabled();
void popUpTimeout(int p);
void stopPopUpTimeout();
void startPopUpTimeout();
void startDisplaySaverTimeout();
void stopDisplaySaverTimeout();
void restartDisplaySaverTimeout();
extern void initDisplay();
extern void paintLine(String ddata, int* yposptr);  // paint one line on the display at Y-position yposptr*
extern void paintDisplay();                         // repaint the display after a series of paintXXX() operation
extern boolean isPopUpDisplayActive();              // returns true if there is an active pop-Up display
extern void displayPopUp(String data);              // display a string for a certain time
extern void activateDisplay();                      // (re)activate display, suspend display saver
extern void deactivateDisplay();                    // deactivate display
extern void displayFolded(String data);             // display string data using full display, optionally folding lines to fit in display
extern void displayRunningSketch();                 // display sketch information

// end of _display_h
#endif
