Skip to content

Commit bcdd181

Browse files
committed
v0.6.278
1 parent f084e56 commit bcdd181

File tree

8 files changed

+115
-31
lines changed

8 files changed

+115
-31
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,15 @@ https://aliexpress.com/item/32965676064.html
3939
- or **Nokia5110** 84x48 SPI https://aliexpress.com/item/1005001621837569.html
4040
- or **ST7789** 2.4' 320x240 SPI https://aliexpress.com/item/32960241206.html
4141
- or **SH1106** 1.3' 128x64 I2C https://aliexpress.com/item/32683094040.html
42-
- or **1602** 16x2 I2C https://aliexpress.com/item/32305776560.html
43-
- or **1602** 16x2 without I2C https://aliexpress.com/item/32305776560.html
42+
- or **LCD1602** 16x2 I2C https://aliexpress.com/item/32305776560.html
43+
- or **LCD1602** 16x2 without I2C https://aliexpress.com/item/32305776560.html
4444
- or **SSD1327** 1.5' 128x128 I2C https://aliexpress.com/item/1005001414175498.html
4545
- or **ILI9341** 3.2'320x240 SPI https://aliexpress.com/item/33048191074.html
46-
- or **SSD1305 (SSD1309)** 2.4' 128x64 SPI https://aliexpress.com/item/32950307344.html
46+
- or **SSD1305 (SSD1309)** 2.4' 128x64 SPI/I2C https://aliexpress.com/item/32950307344.html
4747
- or **SH1107** 0.96' 128x64 I2C https://aliexpress.com/item/4000551696674.html
4848
- or **GC9106** 0.96' 160x80 SPI (looks like ST7735S, but it's not him) https://aliexpress.com/item/32947890530.html
49+
- or **LCD2004** 20x4 I2C https://aliexpress.com/item/32783128355.html
50+
- or **LCD2004** 20x4 without I2C https://aliexpress.com/item/32783128355.html
4951

5052
##### Controls
5153
- Three tact buttons https://www.aliexpress.com/item/32907144687.html
@@ -291,6 +293,11 @@ Work is in progress...
291293

292294
---
293295
## Version history
296+
#### v0.6.278
297+
- added support for LCD2004 displays
298+
- added support for SSD1305/SSD1309 I2C displays
299+
- fixed rotation of SH1106 display
300+
294301
#### v0.6.263
295302
- fixed encoder internal pullup
296303

yoRadio/display.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
#include "src/displays/displayST7789.h"
1919
#elif DSP_MODEL==DSP_SH1106
2020
#include "src/displays/displaySH1106.h"
21-
#elif DSP_MODEL==DSP_1602I2C
21+
#elif DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C
2222
#include "src/displays/displayLC1602.h"
2323
#elif DSP_MODEL==DSP_SSD1327
2424
#include "src/displays/displaySSD1327.h"
2525
#elif DSP_MODEL==DSP_ILI9341
2626
#include "src/displays/displayILI9341.h"
27-
#elif DSP_MODEL==DSP_SSD1305
27+
#elif DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C
2828
#include "src/displays/displaySSD1305.h"
2929
#elif DSP_MODEL==DSP_SH1107
3030
#include "src/displays/displaySH1106.h"
31-
#elif DSP_MODEL==DSP_1602
31+
#elif DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004
3232
#include "src/displays/displayLC1602.h"
3333
#elif DSP_MODEL==DSP_GC9106
3434
#include "src/displays/displayGC9106.h"

yoRadio/options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef options_h
22
#define options_h
33

4-
#define VERSION "0.6.263"
4+
#define VERSION "0.6.278"
55

66
/*******************************************************
77
DO NOT EDIT THIS FILE.
@@ -33,6 +33,9 @@ The connection tables are located here https://github.com/e2002/yoradio#connecti
3333
#define DSP_SH1107 11 // https://aliexpress.com/item/4000551696674.html
3434
#define DSP_1602 12 // https://aliexpress.com/item/32685016568.html
3535
#define DSP_GC9106 13 // 0.96' 160x80 (looks like ST7735S, but it's not him) https://aliexpress.com/item/32947890530.html
36+
#define DSP_2004I2C 14 // https://aliexpress.com/item/32783128355.html
37+
#define DSP_2004 15 // https://aliexpress.com/item/32783128355.html
38+
#define DSP_SSD1305I2C 16 // SSD1305 and SSD1309 128x64 I2C https://aliexpress.com/item/32950307344.html
3639
#define DSP_CUSTOM 101 // your display
3740

3841
#ifndef DSP_MODEL

yoRadio/src/LiquidCrystalI2C/LiquidCrystalI2CEx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Based on the work by DFRobot
22
// Based on the LiquidCrystal_I2C library https://github.com/johnrickman/LiquidCrystal_I2C
33
#include "../../options.h"
4-
#if DSP_MODEL==DSP_1602I2C
4+
#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C
55

66
#include "LiquidCrystalI2CEx.h"
77
#include <inttypes.h>

yoRadio/src/displays/displayLC1602.cpp

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../../options.h"
22

3-
#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_1602
3+
#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_1602 || DSP_MODEL==DSP_2004 || DSP_MODEL==DSP_2004I2C
44

55
#include "displayLC1602.h"
66
#include "../../player.h"
@@ -13,31 +13,43 @@
1313

1414
const byte controlspaces[] = { CLOCK_SPACE, VOL_SPACE };
1515

16-
#ifdef LCD_I2C
17-
DspCore::DspCore(): LiquidCrystal_I2C(SCREEN_ADDRESS, 16, 2, I2C_SDA, I2C_SCL) {
18-
19-
}
20-
#else
21-
DspCore::DspCore(): LiquidCrystal(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7) {
16+
DspCore::DspCore(): DSP_INIT {}
2217

23-
}
24-
#endif
2518
void DspCore::apScreen() {
2619
setCursor(0,0);
2720
print("YORADIO AP MODE");
2821
setCursor(0,1);
2922
print(WiFi.softAPIP().toString().c_str());
23+
#ifdef LCD_2004
24+
setCursor(0, 2);
25+
print("AP NAME: ");
26+
print(apSsid);
27+
setCursor(0, 3);
28+
print("PASSWORD: ");
29+
print(apPassword);
30+
#endif
3031
}
3132

3233
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
3334
#ifdef LCD_I2C
3435
init();
3536
backlight();
37+
#else
38+
#ifdef LCD_2004
39+
begin(20, 4);
3640
#else
3741
begin(16, 2);
3842
#endif
43+
#endif
44+
45+
#ifdef LCD_2004
46+
screenwidth = 20;
47+
screenheight = 4;
48+
#else
3949
screenwidth = 16;
4050
screenheight = 2;
51+
#endif
52+
4153
swidth = screenwidth;
4254
sheight = screenheight;
4355
fillSpaces = true;
@@ -52,11 +64,27 @@ void DspCore::drawPlaylist(uint16_t currentItem, char* currentItemText) {
5264
for (byte i = 0; i < PLMITEMS; i++) {
5365
plMenu[i][0] = '\0';
5466
}
55-
67+
#ifdef LCD_2004
68+
config.fillPlMenu(plMenu, currentItem-1, PLMITEMS);
69+
for (byte i = 0; i < PLMITEMS; i++) {
70+
if (i == 1) {
71+
strlcpy(currentItemText, ">", 2);
72+
//strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
73+
strlcat(currentItemText, plMenu[i], PLMITEMLENGHT - 2);
74+
} else {
75+
char tmp[swidth+1] = {0};
76+
strlcpy(tmp, utf8Rus(plMenu[i], true), swidth);
77+
clearScroll(1 + i, 0, 0);
78+
setCursor(1, 1 + i);
79+
print(tmp);
80+
}
81+
}
82+
#else
5683
config.fillPlMenu(plMenu, currentItem, PLMITEMS);
5784
for (byte i = 0; i < PLMITEMS; i++) {
5885
strlcpy(currentItemText, plMenu[i], PLMITEMLENGHT - 1);
5986
}
87+
#endif
6088
}
6189

6290
void DspCore::clearDsp() {
@@ -113,8 +141,13 @@ void DspCore::drawVolumeBar(bool withNumber) {
113141
centerText(" ", 1, 0, 0);
114142
centerText(volstr, 1, TFT_LOGO, TFT_BG);
115143
}else{
144+
#ifdef LCD_2004
145+
rightText(" ", 3, 0, 0);
146+
rightText(volstr, 3, TFT_LOGO, TFT_BG);
147+
#else
116148
rightText(" ", 1, 0, 0);
117149
rightText(volstr, 1, TFT_LOGO, TFT_BG);
150+
#endif
118151
}
119152
}
120153

@@ -134,7 +167,10 @@ void DspCore::rssi(const char* str) {
134167
}
135168

136169
void DspCore::ip(const char* str) {
137-
170+
#ifdef LCD_2004
171+
setCursor(0, 3);
172+
print(str);
173+
#endif
138174
}
139175

140176
void DspCore::set_TextSize(uint8_t s) {

yoRadio/src/displays/displayLC1602.h

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,58 @@
22
#define displayLC1602_h
33

44
#include "Arduino.h"
5-
#if DSP_MODEL==DSP_1602I2C
5+
6+
#if DSP_MODEL==DSP_2004 || DSP_MODEL==DSP_2004I2C
7+
#define LCD_2004
8+
#endif
9+
10+
#if DSP_MODEL==DSP_1602I2C || DSP_MODEL==DSP_2004I2C
611
#define LCD_I2C
712
#include "../LiquidCrystalI2C/LiquidCrystalI2CEx.h"
813
#else
914
#include <LiquidCrystal.h>
1015
#endif
16+
17+
#ifdef LCD_I2C
18+
#ifdef LCD_2004
19+
#define DSP_INIT LiquidCrystal_I2C(SCREEN_ADDRESS, 20, 4, I2C_SDA, I2C_SCL)
20+
#else
21+
#define DSP_INIT LiquidCrystal_I2C(SCREEN_ADDRESS, 16, 2, I2C_SDA, I2C_SCL)
22+
#endif
23+
#else
24+
#define DSP_INIT LiquidCrystal(LCD_RS, LCD_E, LCD_D4, LCD_D5, LCD_D6, LCD_D7)
25+
#endif
26+
27+
1128
#define TFT_LINEHGHT 1
1229
#define TFT_FRAMEWDT 0
1330

14-
#define PLMITEMS 1
31+
1532
#define PLMITEMLENGHT 40
1633
#define PLMITEMHEIGHT 9
1734
#define TITLE_TOP1 1
35+
#ifdef LCD_2004
36+
#define PLMITEMS 3
37+
#define TITLE_TOP2 2
38+
#define PL_TOP 2
39+
#define BOOTSTR_TOP2 1
40+
#define BOOTSTR_TOP1 2
41+
#else
42+
#define PLMITEMS 1
1843
#define TITLE_SIZE2 0
44+
#define IP_INST_VOL
1945
#define PL_TOP 1
46+
#define BOOTSTR_TOP2 0
47+
#define BOOTSTR_TOP1 1
48+
#endif
49+
2050
#define PLCURRENT_SIZE 1
2151

2252
#define SCROLLDELTA 1
2353
#define SCROLLTIME 250
2454

25-
#define BOOTSTR_TOP2 0
26-
#define BOOTSTR_TOP1 1
27-
#define STARTTIME_PL 2000
2855

29-
#define IP_INST_VOL
56+
#define STARTTIME_PL 2000
3057

3158
#ifdef LCD_I2C
3259
class DspCore: public LiquidCrystal_I2C {
@@ -75,7 +102,11 @@ extern DspCore dsp;
75102
* TFT COLORS
76103
*/
77104
#define CLOCK_SPACE 6
105+
#ifdef LCD_2004
106+
#define VOL_SPACE 0
107+
#else
78108
#define VOL_SPACE 3
109+
#endif
79110
#define SILVER 0
80111
#define TFT_BG 0
81112
#define TFT_FG CLOCK_SPACE

yoRadio/src/displays/displaySH1106.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
143143
cp437(true);
144144
fillScreen(TFT_BG);
145145
byte tftRotate = TFT_ROTATE;
146-
#if DSP_MODEL==DSP_SH1106
147-
if(tftRotate>2) tftRotate=2;
148-
if(tftRotate==1) tftRotate=0;
149-
#else
146+
#if DSP_MODEL==DSP_SH1107
150147
if(tftRotate>=2) tftRotate=3;
151148
if(tftRotate==0) tftRotate=1;
152149
#endif

yoRadio/src/displays/displaySSD1305.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "../../options.h"
2-
#if DSP_MODEL==DSP_SSD1305
2+
#if DSP_MODEL==DSP_SSD1305 || DSP_MODEL==DSP_SSD1305I2C
33

44
#include "displaySSD1305.h"
55
#include "../../player.h"
@@ -31,10 +31,17 @@ const unsigned char logo [] PROGMEM=
3131
0x1f, 0xff, 0xe0, 0x0f, 0xff, 0xe0, 0x03, 0xff, 0xc0, 0x00, 0xfe, 0x00
3232
};
3333

34+
#if DSP_MODEL==DSP_SSD1305
3435
DspCore::DspCore(): Adafruit_SSD1305(128, 64, &SPI, TFT_DC, TFT_RST, TFT_CS, DEF_SPI_FREQ) {
3536

3637
}
38+
#else
39+
#include <Wire.h>
40+
TwoWire I2CSSD1305 = TwoWire(0);
41+
DspCore::DspCore(): Adafruit_SSD1305(128, 64, &I2CSSD1305, -1){
3742

43+
}
44+
#endif
3845
char* DspCore::utf8Rus(const char* str, bool uppercase) {
3946
int index = 0;
4047
static char strn[BUFLEN];
@@ -128,8 +135,11 @@ void DspCore::apScreen() {
128135
}
129136

130137
void DspCore::initD(uint16_t &screenwidth, uint16_t &screenheight) {
138+
#if DSP_MODEL==DSP_SSD1305I2C
139+
I2CSSD1305.begin(I2C_SDA, I2C_SCL);
140+
#endif
131141
if (!begin(SCREEN_ADDRESS)) {
132-
Serial.println(F("SH1106 allocation failed"));
142+
Serial.println(F("SSD1305 allocation failed"));
133143
for (;;); // Don't proceed, loop forever
134144
}
135145
cp437(true);

0 commit comments

Comments
 (0)