Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for ST7735 display driver #51

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 44 additions & 14 deletions Esp32_radio.ino
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,33 @@
#include <PubSubClient.h>
#include <WiFiMulti.h>
#include <ESPmDNS.h>
#include <TFT_ILI9163C.h>
#include <stdio.h>
#include <string.h>
#include <FS.h>
#include <SD.h>
#include <ArduinoOTA.h>
#include <time.h>

// Color definitions for the TFT screen (if used)
//available display drivers for TFT
#define ILI9163C 0
#define ST7735 1
// set DISP to one of the display drivers defined above
#define DISP ILI9163C
// Library include and color definitions for the TFT screen (if used)
// TFT has bits 6 bits (0..5) for RED, 6 bits (6..11) for GREEN and 4 bits (12..15) for BLUE.
#define BLACK 0x0000
#define BLUE 0xF800
#define RED 0x001F
#define GREEN 0x07E0
#if DISP == ILI9163C
#include <TFT_ILI9163C.h>
#define BLACK 0x0000
#define BLUE 0xF800
#define RED 0x001F
#define GREEN 0x07E0
#else
#include <Adafruit_ST7735.h>
#define BLACK ST7735_BLACK
#define BLUE ST7735_BLUE
#define RED ST7735_RED
#define GREEN ST7735_GREEN
#endif
#define CYAN GREEN | BLUE
#define MAGENTA RED | BLUE
#define YELLOW RED | GREEN
Expand Down Expand Up @@ -221,7 +234,11 @@ WiFiClient wmqttclient ; // An instance for mq
PubSubClient mqttclient ( wmqttclient ) ; // Client for MQTT subscriber
hw_timer_t* timer = NULL ; // For timer
char cmd[130] ; // Command from MQTT or Serial
TFT_ILI9163C* tft = NULL ; // For instance of TFT driver
#if DISP == ILI9163C
TFT_ILI9163C* tft = NULL ; // For instance of TFT driver
#else
Adafruit_ST7735* tft = NULL ;
#endif
uint32_t totalcount = 0 ; // Counter mp3 data
datamode_t datamode ; // State of datastream
int metacount ; // Number of bytes in metadata
Expand Down Expand Up @@ -1418,7 +1435,9 @@ void listNetworks()
int i ; // Loop control
String sassid ; // Search string in anetworks

dbgprint ( "Scan Networks" ) ; // Scan for nearby networks
WiFi.begin("ThisIsJustADummy","notApassword"); // Workaround for issue #27

dbgprint ( "Scan Networks" ) ; // Scan for nearby networks
int numSsid = WiFi.scanNetworks() ;
dbgprint ( "Scan completed" ) ;
if ( numSsid <= 0 )
Expand Down Expand Up @@ -1947,6 +1966,9 @@ bool connectwifi()

WiFi.disconnect() ; // After restart the router could
WiFi.softAPdisconnect(true) ; // still keep the old connection

WiFi.begin("ThisIsJustADummy","notApassword"); // Workaround for issue #27

pfs = "IP = 192.168.4.1" ; // Default IP address (no AP found)
if ( num_an ) // Any AP defined?
{
Expand Down Expand Up @@ -2760,12 +2782,21 @@ void setup()
if ( ini_block.tft_cs_pin >= 0 )
{
dbgprint ( "Start TFT" ) ;
tft = new TFT_ILI9163C ( ini_block.tft_cs_pin,
ini_block.tft_dc_pin ) ; // Create an instant for TFT
tft->begin() ; // Init TFT interface
tft->fillRect ( 0, 0, 160, 128, BLACK ) ; // Clear screen does not work when rotated
#if DISP == ILI9163C
tft = new TFT_ILI9163C ( ini_block.tft_cs_pin,
ini_block.tft_dc_pin ) ; // Create an instant for TFT
tft->begin() ; // Init TFT interface
tft->fillRect ( 0, 0, 160, 128, BLACK ) ; // Clear screen does not work when rotated
#else
tft = new Adafruit_ST7735 ( ini_block.tft_cs_pin,
ini_block.tft_dc_pin,0 ) ; // Create an instant for TFT
tft->initR(INITR_BLACKTAB); // Init TFT interface
tft->fillScreen(BLACK); // Clear screen
#endif
tft->setRotation ( 3 ) ; // Use landscape format (1 for upside down)
tft->clearScreen() ; // Clear screen
#if DISP == ILI9163C
tft->clearScreen() ; // Clear screen
#endif
tft->setTextSize ( 1 ) ; // Small character font
tft->setTextColor ( WHITE ) ; // Info in white
tft->println ( "Starting..." ) ;
Expand Down Expand Up @@ -4462,4 +4493,3 @@ String httpheader ( String contentstype )
"Cache-Control: " "max-age=3600\n"
"Last-Modified: " VERSION "\n\n" ) ;
}

Binary file modified doc/ESP32-radio.pdf
Binary file not shown.