diff --git a/README.md b/README.md index 0b15adf..f89ff58 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,15 @@ https://aliexpress.com/item/32965676064.html - or **Nokia5110** 84x48 SPI https://aliexpress.com/item/1005001621837569.html - or **ST7789** 2.4' 320x240 SPI https://aliexpress.com/item/32960241206.html - or **SH1106** 1.3' 128x64 I2C https://aliexpress.com/item/32683094040.html -- or **1602** 16x2 I2C https://aliexpress.com/item/32305776560.html -- or **1602** 16x2 without I2C https://aliexpress.com/item/32305776560.html +- or **LCD1602** 16x2 I2C https://aliexpress.com/item/32305776560.html +- or **LCD1602** 16x2 without I2C https://aliexpress.com/item/32305776560.html - or **SSD1327** 1.5' 128x128 I2C https://aliexpress.com/item/1005001414175498.html - or **ILI9341** 3.2'320x240 SPI https://aliexpress.com/item/33048191074.html -- or **SSD1305 (SSD1309)** 2.4' 128x64 SPI https://aliexpress.com/item/32950307344.html +- or **SSD1305 (SSD1309)** 2.4' 128x64 SPI/I2C https://aliexpress.com/item/32950307344.html - or **SH1107** 0.96' 128x64 I2C https://aliexpress.com/item/4000551696674.html - or **GC9106** 0.96' 160x80 SPI (looks like ST7735S, but it's not him) https://aliexpress.com/item/32947890530.html +- or **LCD2004** 20x4 I2C https://aliexpress.com/item/32783128355.html +- or **LCD2004** 20x4 without I2C https://aliexpress.com/item/32783128355.html ##### Controls - Three tact buttons https://www.aliexpress.com/item/32907144687.html @@ -291,6 +293,11 @@ Work is in progress... --- ## Version history +#### v0.6.278 +- added support for LCD2004 displays +- added support for SSD1305/SSD1309 I2C displays +- fixed rotation of SH1106 display + #### v0.6.263 - fixed encoder internal pullup diff --git a/yoRadio/display.h b/yoRadio/display.h index a3a2c1a..bf623fe 100644 --- a/yoRadio/display.h +++ b/yoRadio/display.h @@ -18,17 +18,17 @@ #include "src/displays/displayST7789.h" #elif DSP_MODEL==DSP_SH1106 #include "src/displays/displaySH1106.h" -#elif DSP_MODEL==DSP_1602I2C +#elif DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C #include "src/displays/displayLC1602.h" #elif DSP_MODEL==DSP_SSD1327 #include "src/displays/displaySSD1327.h" #elif DSP_MODEL==DSP_ILI9341 #include "src/displays/displayILI9341.h" -#elif DSP_MODEL==DSP_SSD1305 +#elif DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C #include "src/displays/displaySSD1305.h" #elif DSP_MODEL==DSP_SH1107 #include "src/displays/displaySH1106.h" -#elif DSP_MODEL==DSP_1602 +#elif DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004 #include "src/displays/displayLC1602.h" #elif DSP_MODEL==DSP_GC9106 #include "src/displays/displayGC9106.h" diff --git a/yoRadio/options.h b/yoRadio/options.h index 7aa14b5..29d475f 100644 --- a/yoRadio/options.h +++ b/yoRadio/options.h @@ -1,7 +1,7 @@ #ifndef options_h #define options_h -#define VERSION "0.6.263" +#define VERSION "0.6.278" /******************************************************* DO NOT EDIT THIS FILE. @@ -33,6 +33,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti #define DSP_SH1107 11 // https://aliexpress.com/item/4000551696674.html #define DSP_1602 12 // https://aliexpress.com/item/32685016568.html #define DSP_GC9106 13 // 0.96' 160x80 (looks like ST7735S, but it's not him) https://aliexpress.com/item/32947890530.html +#define DSP_2004I2C 14 // https://aliexpress.com/item/32783128355.html +#define DSP_2004 15 // https://aliexpress.com/item/32783128355.html +#define DSP_SSD1305I2C 16 // SSD1305 and SSD1309 128x64 I2C https://aliexpress.com/item/32950307344.html #define DSP_CUSTOM 101 // your display #ifndef DSP_MODEL diff --git a/yoRadio/src/LiquidCrystalI2C/LiquidCrystalI2CEx.cpp b/yoRadio/src/LiquidCrystalI2C/LiquidCrystalI2CEx.cpp index 1699b2c..6a76554 100644 --- a/yoRadio/src/LiquidCrystalI2C/LiquidCrystalI2CEx.cpp +++ b/yoRadio/src/LiquidCrystalI2C/LiquidCrystalI2CEx.cpp @@ -1,7 +1,7 @@ // Based on the work by DFRobot // Based on the LiquidCrystal_I2C library https://github.com/johnrickman/LiquidCrystal_I2C #include "../../options.h" -#if DSP_MODEL==DSP_1602I2C +#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C #include "LiquidCrystalI2CEx.h" #include diff --git a/yoRadio/src/displays/displayLC1602.cpp b/yoRadio/src/displays/displayLC1602.cpp index a444e30..75b224c 100644 --- a/yoRadio/src/displays/displayLC1602.cpp +++ b/yoRadio/src/displays/displayLC1602.cpp @@ -1,6 +1,6 @@ #include "../../options.h" -#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_1602 +#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004 || DSP_MODEL==DSP_2004I2C #include "displayLC1602.h" #include "../../player.h" @@ -13,31 +13,43 @@ const byte controlspaces[] = { CLOCK_SPACE, VOL_SPACE }; -#ifdef LCD_I2C -DspCore::DspCore(): LiquidCrystal_I2C(SCREEN_ADDRESS, 16, 2, I2C_SDA, I2C_SCL) { +DspCore::DspCore(): DSP_INIT {} -} -#else -DspCore::DspCore(): LiquidCrystal(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7) { - -} -#endif void DspCore::apScreen() { setCursor(0,0); print("YORADIO AP MODE"); setCursor(0,1); print(WiFi.softAPIP().toString().c_str()); +#ifdef LCD_2004 + setCursor(0, 2); + print("AP NAME: "); + print(apSsid); + setCursor(0, 3); + print("PASSWORD: "); + print(apPassword); +#endif } void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { #ifdef LCD_I2C init(); backlight(); +#else +#ifdef LCD_2004 + begin(20, 4); #else begin(16, 2); #endif +#endif + +#ifdef LCD_2004 + screenwidth = 20; + screenheight = 4; +#else screenwidth = 16; screenheight = 2; +#endif + swidth = screenwidth; sheight = screenheight; fillSpaces = true; @@ -52,11 +64,27 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) { for (byte i = 0; i < PLMITEMS; i++) { plMenu[i][0] = '\0'; } - +#ifdef LCD_2004 + config.fillPlMenu(plMenu, currentItem-1, PLMITEMS); + for (byte i = 0; i < PLMITEMS; i++) { + if (i == 1) { + strlcpy(currentItemText, ">", 2); + //strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); + strlcat(currentItemText, plMenu[i], PLMITEMLENGHT - 2); + } else { + char tmp[swidth+1] = {0}; + strlcpy(tmp, utf8Rus(plMenu[i], true), swidth); + clearScroll(1 + i, 0, 0); + setCursor(1, 1 + i); + print(tmp); + } + } +#else config.fillPlMenu(plMenu, currentItem, PLMITEMS); for (byte i = 0; i < PLMITEMS; i++) { strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1); } +#endif } void DspCore::clearDsp() { @@ -113,8 +141,13 @@ void DspCore::drawVolumeBar(bool withNumber) { centerText(" ", 1, 0, 0); centerText(volstr, 1, TFT_LOGO, TFT_BG); }else{ +#ifdef LCD_2004 + rightText(" ", 3, 0, 0); + rightText(volstr, 3, TFT_LOGO, TFT_BG); +#else rightText(" ", 1, 0, 0); rightText(volstr, 1, TFT_LOGO, TFT_BG); +#endif } } @@ -134,7 +167,10 @@ void DspCore::rssi(const char* str) { } void DspCore::ip(const char* str) { - +#ifdef LCD_2004 + setCursor(0, 3); + print(str); +#endif } void DspCore::set_TextSize(uint8_t s) { diff --git a/yoRadio/src/displays/displayLC1602.h b/yoRadio/src/displays/displayLC1602.h index 42c5675..3d7b872 100644 --- a/yoRadio/src/displays/displayLC1602.h +++ b/yoRadio/src/displays/displayLC1602.h @@ -2,31 +2,58 @@ #define displayLC1602_h #include "Arduino.h" -#if DSP_MODEL==DSP_1602I2C + +#if DSP_MODEL==DSP_2004 || DSP_MODEL==DSP_2004I2C +#define LCD_2004 +#endif + +#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C #define LCD_I2C #include "../LiquidCrystalI2C/LiquidCrystalI2CEx.h" #else #include #endif + +#ifdef LCD_I2C +#ifdef LCD_2004 +#define DSP_INIT LiquidCrystal_I2C(SCREEN_ADDRESS, 20, 4, I2C_SDA, I2C_SCL) +#else +#define DSP_INIT LiquidCrystal_I2C(SCREEN_ADDRESS, 16, 2, I2C_SDA, I2C_SCL) +#endif +#else +#define DSP_INIT LiquidCrystal(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7) +#endif + + #define TFT_LINEHGHT 1 #define TFT_FRAMEWDT 0 -#define PLMITEMS 1 + #define PLMITEMLENGHT 40 #define PLMITEMHEIGHT 9 #define TITLE_TOP1 1 +#ifdef LCD_2004 +#define PLMITEMS 3 +#define TITLE_TOP2 2 +#define PL_TOP 2 +#define BOOTSTR_TOP2 1 +#define BOOTSTR_TOP1 2 +#else +#define PLMITEMS 1 #define TITLE_SIZE2 0 +#define IP_INST_VOL #define PL_TOP 1 +#define BOOTSTR_TOP2 0 +#define BOOTSTR_TOP1 1 +#endif + #define PLCURRENT_SIZE 1 #define SCROLLDELTA 1 #define SCROLLTIME 250 -#define BOOTSTR_TOP2 0 -#define BOOTSTR_TOP1 1 -#define STARTTIME_PL 2000 -#define IP_INST_VOL +#define STARTTIME_PL 2000 #ifdef LCD_I2C class DspCore: public LiquidCrystal_I2C { @@ -75,7 +102,11 @@ extern DspCore dsp; * TFT COLORS */ #define CLOCK_SPACE 6 +#ifdef LCD_2004 +#define VOL_SPACE 0 +#else #define VOL_SPACE 3 +#endif #define SILVER 0 #define TFT_BG 0 #define TFT_FG CLOCK_SPACE diff --git a/yoRadio/src/displays/displaySH1106.cpp b/yoRadio/src/displays/displaySH1106.cpp index d262f37..81d9847 100644 --- a/yoRadio/src/displays/displaySH1106.cpp +++ b/yoRadio/src/displays/displaySH1106.cpp @@ -143,10 +143,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { cp437(true); fillScreen(TFT_BG); byte tftRotate = TFT_ROTATE; -#if DSP_MODEL==DSP_SH1106 - if(tftRotate>2) tftRotate=2; - if(tftRotate==1) tftRotate=0; -#else +#if DSP_MODEL==DSP_SH1107 if(tftRotate>=2) tftRotate=3; if(tftRotate==0) tftRotate=1; #endif diff --git a/yoRadio/src/displays/displaySSD1305.cpp b/yoRadio/src/displays/displaySSD1305.cpp index f1eb691..a7e55e3 100644 --- a/yoRadio/src/displays/displaySSD1305.cpp +++ b/yoRadio/src/displays/displaySSD1305.cpp @@ -1,5 +1,5 @@ #include "../../options.h" -#if DSP_MODEL==DSP_SSD1305 +#if DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C #include "displaySSD1305.h" #include "../../player.h" @@ -31,10 +31,17 @@ const unsigned char logo [] PROGMEM= 0x1f, 0xff, 0xe0, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xc0, 0x00, 0xfe, 0x00 }; +#if DSP_MODEL==DSP_SSD1305 DspCore::DspCore(): Adafruit_SSD1305(128, 64, &SPI, TFT_DC, TFT_RST, TFT_CS, DEF_SPI_FREQ) { } +#else +#include +TwoWire I2CSSD1305 = TwoWire(0); +DspCore::DspCore(): Adafruit_SSD1305(128, 64, &I2CSSD1305, -1){ +} +#endif char* DspCore::utf8Rus(const char* str, bool uppercase) { int index = 0; static char strn[BUFLEN]; @@ -128,8 +135,11 @@ void DspCore::apScreen() { } void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) { +#if DSP_MODEL==DSP_SSD1305I2C + I2CSSD1305.begin(I2C_SDA, I2C_SCL); +#endif if (!begin(SCREEN_ADDRESS)) { - Serial.println(F("SH1106 allocation failed")); + Serial.println(F("SSD1305 allocation failed")); for (;;); // Don't proceed, loop forever } cp437(true);