Skip to content
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
11 changes: 9 additions & 2 deletions include/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define PREFERENCES_FRIENDLY_ID "friendly_id"
#define PREFERENCES_FRIENDLY_ID_DEFAULT ""
#define PREFERENCES_SLEEP_TIME_KEY "refresh_rate"
#define PREFERENCES_TEMP_PROFILE "temp_profile"
#define PREFERENCES_LOG_KEY "log_"
#define PREFERENCES_LOG_BUFFER_HEAD_KEY "log_head"
#define PREFERENCES_LOG_ID_KEY "log_id"
Expand All @@ -44,6 +45,12 @@
#define SLEEP_TIME_WHILE_NOT_CONNECTED 5 /* Time ESP32 will go to sleep (in seconds) */
#define SLEEP_TIME_WHILE_PLUGIN_NOT_ATTACHED 5 /* Time ESP32 will go to sleep (in seconds) */

// Different display profiles
#define TEMP_PROFILE_DEFAULT 0
#define TEMP_PROFILE_A 1
#define TEMP_PROFILE_B 2
#define TEMP_PROFILE_C 3

#define MS_TO_S_FACTOR 1000 /* Conversion factor for milliseconds to seconds */

enum API_CONNECT_RETRY_TIME // Time to sleep before trying to connect to the API (in seconds)
Expand Down Expand Up @@ -103,7 +110,7 @@ enum WIFI_CONNECT_RETRY_TIME // Time to sleep before trying to connect to the Wi
#define BUTTON_SOFT_RESET_TIME 15000

#define SERVER_MAX_RETRIES 3

#define API_BASE_URL "https://trmnl.app"
#define API_BASE_URL "https://usetrmnl.com"
//#define API_BASE_URL "https://trmnl.app"

#endif
5 changes: 5 additions & 0 deletions include/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ enum MSG
TEST,
};

typedef struct dp_tag
{
uint32_t OneBit, TwoBit; // profiles for 1 and 2-bit modes
} DISPLAY_PROFILE;

/**
* @brief Function to init the display
* @param none
Expand Down
113 changes: 109 additions & 4 deletions lib/bb_epaper/src/bb_ep.inl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ BBEP_GRAY3, BBEP_GRAY2, BBEP_GRAY1, BBEP_GRAY0, BBEP_GRAY3, BBEP_GRAY2, BBEP_GRA
BBEP_GRAY3, BBEP_GRAY2, BBEP_GRAY1, BBEP_GRAY0, BBEP_GRAY3, BBEP_GRAY2, BBEP_GRAY1, BBEP_GRAY0
};

// 2-bit grayscale mode (some swapped)
const uint8_t u8Colors_4gray_v2[16] = {
BBEP_GRAY3, BBEP_GRAY1, BBEP_GRAY2, BBEP_GRAY0, BBEP_GRAY3, BBEP_GRAY1, BBEP_GRAY2, BBEP_GRAY0,
BBEP_GRAY3, BBEP_GRAY2, BBEP_GRAY1, BBEP_GRAY0, BBEP_GRAY3, BBEP_GRAY1, BBEP_GRAY2, BBEP_GRAY0
};

// the 4-color mode
const uint8_t u8Colors_4clr[16] = { // black white red yellow
BBEP_BLACK, BBEP_WHITE, BBEP_RED, BBEP_YELLOW, BBEP_BLACK, BBEP_WHITE, BBEP_RED, BBEP_YELLOW,
Expand Down Expand Up @@ -644,6 +650,32 @@ const uint8_t epd75_init_sequence_partial[] PROGMEM = {
//#endif // FUTURE
0x00 // end of table
};
const uint8_t epd75_init_fast_gen2[] PROGMEM = {
0x02, 0x00, 0x1f, // panel setting
0x03, 0x50, 0x21, 0x07,
0x01, 0x04, // power on
BUSY_WAIT,
0x05, 0x06, 0x27, 0x27, 0x18, 0x17,
0x02, 0xe0, 0x02,
0x02, 0xe5, 0x5a,
0
};

const uint8_t epd75_init_partial_gen2[] PROGMEM = {
0x01, 0x04, // power on
BUSY_WAIT,
0x02, 0xe0, 0x02,
0x02, 0xe5, 0x5a,
0x02, 0x00, 0x1f, // panel setting
0x03, 0x50, 0x21, 0x07,
0x01, 0x04, // power on
BUSY_WAIT,
0x05, 0x06, 0x27, 0x27, 0x18, 0x17,
0x02, 0xe0, 0x02,
0x02, 0xe5, 0x6e,
0
};

const uint8_t epd75_init_sequence_fast[] PROGMEM = {
0x06, UC8151_PWR, 0x07, 0x07, 0x3f, 0x3f, 0x03,
// 0x02, 0x82, 0x26, // VCOM DC
Expand Down Expand Up @@ -1783,10 +1815,77 @@ const uint8_t epd75_old_gray_init[] PROGMEM = {
0 // end
};

// 2-bit (4 grayscale mode) for GDEY075T7 (older model with too light output)
const uint8_t epd75_old_gray_init2[] PROGMEM = {
6, UC8151_PWR, 0x07, 0x07, 0x3f, 0x3f, 0x03,
1, UC8151_PON,
BUSY_WAIT,
2, UC8151_PSR, 0x3f,
5, UC8151_TRES, 0x03, 0x20, 0x01, 0xe0,
2, 0x15, 0x00,
3, UC8151_CDI, 0x00, 0x07,
2, UC8151_TCON, 0x22,
3, 0x50, 0x00, 0x07, // VCOM LUTBD (00=white border, 30=black border)
2, UC8151_VDCS, 0x12, // VCOM DC
43, 0x20, // LUT 0~3 gray
0x00, 0x0A, 0x00, 0x00, 0x00, 0x01,
0x00, 0x14, 0x14, 0x0a, 0x00, 0x01,
0x00, 0x19, 0x0f, 0x00, 0x00, 0x01,
0x00, 0x20, 0x01, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43, 0x21, // WW
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
0x90, 0x14, 0x14, 0x0a, 0x00, 0x01,
0x20, 0x14, 0x0A, 0x0a, 0x00, 0x01,
0xA0, 0x13, 0x0A, 0x04, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43, 0x22, // BW
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
0x90, 0x19, 0x19, 0x00, 0x00, 0x01,
0x10, 0x19, 0x0F, 0x00, 0x00, 0x01,
0x99, 0x11, 0x04, 0x06, 0x06, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43, 0x23, // WB
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
0x90, 0x19, 0x19, 0x00, 0x00, 0x01,
0x10, 0x19, 0x0F, 0x00, 0x00, 0x01,
0x99, 0x06, 0x10, 0x08, 0x03, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43, 0x24, // BB
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
0x00, 0x12, 0x12, 0x0e, 0x00, 0x01,
0x40, 0x12, 0x16, 0x00, 0x00, 0x01,
0x50, 0x23, 0x01, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43, 0x25, // Border LUT
0x40, 0x0A, 0x00, 0x00, 0x00, 0x01,
0x90, 0x14, 0x14, 0x00, 0x00, 0x01,
0x10, 0x14, 0x0A, 0x00, 0x00, 0x01,
0xA0, 0x13, 0x0A, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2, 0xe0, 0x00, // CCSET
2, 0x41, 0x00, // TSE
1, 0x04, // Power on
BUSY_WAIT,
0 // end
};

// 2-bit (4 grayscale mode)
const uint8_t epd75_gray_init[] PROGMEM = {
2, 0x00, 0x1f, // panel setting
3, 0x50, 0x10, 0x07, // VCOM
3, 0x50, 0x90, 0x07, // VCOM (bit 7 set disables the border color - stays white in our case)
1, UC8151_PON, // power on
BUSY_WAIT,
5, 0x06, 0x27, 0x27, 0x18, 0x17, // booster soft start
Expand Down Expand Up @@ -2005,8 +2104,10 @@ const EPD_PANEL panelDefs[] PROGMEM = {
{240, 416, 0, epd37_init_sequence_full, NULL, epd37_init_sequence_part, 0, BBEP_CHIP_UC81xx, u8Colors_2clr}, // EP37_240x416
{104, 212, 0, epd213_inky_init_sequence_full, NULL, NULL, 0, BBEP_CHIP_UC81xx, u8Colors_2clr}, // EP213_104x212, older InkyPHAT black and white
{800, 480, 0, epd75_init_sequence_full, epd75_init_sequence_fast, epd75_init_sequence_partial, 0, BBEP_CHIP_UC81xx, u8Colors_2clr}, // EP75_800x480
{800, 480, 0, epd75_gray_init, NULL, NULL, BBEP_4GRAY, BBEP_CHIP_UC81xx, u8Colors_4gray}, // EP75_800x480_4GRAY
{800, 480, 0, epd75_old_gray_init, NULL, NULL, BBEP_4GRAY, BBEP_CHIP_UC81xx, u8Colors_4gray}, // EP75_800x480_4GRAY_OLD
{800, 480, 0, epd75_init_sequence_full, epd75_init_fast_gen2, epd75_init_partial_gen2, 0, BBEP_CHIP_UC81xx, u8Colors_2clr}, // EP75_800x480_GEN2
{800, 480, 0, epd75_gray_init, NULL, NULL, BBEP_4GRAY, BBEP_CHIP_UC81xx, u8Colors_4gray_v2}, // EP75_800x480_4GRAY_GEN2
{800, 480, 0, epd75_old_gray_init, NULL, NULL, BBEP_4GRAY, BBEP_CHIP_UC81xx, u8Colors_4gray}, // EP75_800x480_4GRAY
{800, 480, 0, epd75_old_gray_init2, NULL, NULL, BBEP_4GRAY, BBEP_CHIP_UC81xx, u8Colors_4gray}, // EP75_800x480_4GRAY_V2
{128, 296, 0, epd29_init_sequence_full, epd29_init_sequence_fast, epd29_init_sequence_part, 0, BBEP_CHIP_UC81xx, u8Colors_2clr}, // Badger 2040
{128, 296, 0, epd29_init_sequence_gray, NULL, NULL, BBEP_4GRAY, BBEP_CHIP_UC81xx, u8Colors_4gray}, // Badger 2040 4Gray mode
{122, 250, 1, epd213r_inky_init_sequence_full, NULL, NULL, BBEP_3COLOR, BBEP_CHIP_SSD16xx, u8Colors_3clr}, // EP213R_122x250 Inky phat 2.13" B/W/R
Expand Down Expand Up @@ -3017,7 +3118,7 @@ int bbepWritePlane(BBEPDISP *pBBEP, int iPlane, int bInvert)
uint8_t ucCMD1, ucCMD2;
int iOffset;

if (pBBEP == NULL || pBBEP->ucScreen == NULL || iPlane < PLANE_0 || iPlane > PLANE_DUPLICATE) {
if (pBBEP == NULL || pBBEP->ucScreen == NULL || iPlane < PLANE_0 || iPlane > PLANE_FALSE_DIFF) {
return BBEP_ERROR_BAD_PARAMETER;
}
bbepSetAddrWindow(pBBEP, 0,0, pBBEP->native_width, pBBEP->native_height);
Expand Down Expand Up @@ -3078,6 +3179,10 @@ int bbepWritePlane(BBEPDISP *pBBEP, int iPlane, int bInvert)
bbepWriteImage(pBBEP, ucCMD1, pBBEP->ucScreen, bInvert);
bbepWriteImage(pBBEP, ucCMD2, pBBEP->ucScreen, bInvert);
break;
case PLANE_FALSE_DIFF: // send inverted image to 'old' plane
bbepWriteImage(pBBEP, ucCMD1, pBBEP->ucScreen, 0);
bbepWriteImage(pBBEP, ucCMD2, pBBEP->ucScreen, 1);
break;
}
return BBEP_SUCCESS;
} /* bbepWritePlane() */
Expand Down
11 changes: 7 additions & 4 deletions lib/bb_epaper/src/bb_epaper.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ enum {
PLANE_1,
PLANE_BOTH,
PLANE_DUPLICATE, // duplicate 0 to both 0 and 1
PLANE_0_TO_1 // send plane 0 to plane 1 memory
PLANE_0_TO_1, // send plane 0 to plane 1 memory
PLANE_FALSE_DIFF // use 'partial' mode to force all pixels to update
};
#ifndef __ONEBITDISPLAY__
// 5 possible font sizes: 8x8, 16x32, 6x8, 12x16 (stretched from 6x8 with smoothing), 16x16 (stretched from 8x8)
Expand Down Expand Up @@ -131,9 +132,11 @@ enum {
EP42R2_400x300, // GDEQ042Z21
EP37_240x416, // GDEY037T03
EP213_104x212, // InkyPHAT 2.13 black and white
EP75_800x480, // GDEY075T7
EP75_800x480_4GRAY, // GDEW075T7 in 4 grayscale mode
EP75_800x480_4GRAY_OLD, // GDEY075T7 in 4 grayscale mode
EP75_800x480, // GDEY075T7 (original TRMNL panel)
EP75_800x480_GEN2, // GEDY075-D2 (TRMNL gen2 panel)
EP75_800x480_4GRAY_GEN2, // GDEW075T7 in 4 grayscale mode
EP75_800x480_4GRAY, // GDEY075T7 in 4 grayscale mode
EP75_800x480_4GRAY_V2, // GDEY075T7 in 4 grayscale mode, panel which produces too light output
EP29_128x296, // Pimoroni Badger2040
EP213R_122x250, // Inky phat 2.13 B/W/R
EP154_200x200, // waveshare
Expand Down
1 change: 1 addition & 0 deletions lib/trmnl/include/api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct ApiDisplayResponse
bool maximum_compatibility;
String firmware_url;
uint64_t refresh_rate;
uint32_t temp_profile;
bool reset_firmware;
SPECIAL_FUNCTION special_function;
String action;
Expand Down
10 changes: 10 additions & 0 deletions lib/trmnl/src/parse_response_api_display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ ApiDisplayResponse parseResponse_apiDisplay(String &payload)
JsonDocument doc;
DeserializationError error = deserializeJson(doc, payload);

Serial.print(payload);

if (error)
{
Log_error("JSON deserialization error.");
Expand All @@ -17,6 +19,13 @@ ApiDisplayResponse parseResponse_apiDisplay(String &payload)
.error_detail = error.c_str()};
}
String special_function_str = doc["special_function"];
// Convert the temperature profile ("default", "a", "b", "c")
// into an integer value (0,1,2,3)
String tp = doc["temperature_profile"];
uint32_t u32TP = 0; // default
if (tp == "a") u32TP = 1;
else if (tp == "b") u32TP = 2;
// else if (tp == "c") u32TP = 3;

return ApiDisplayResponse{
.outcome = ApiDisplayOutcome::Ok,
Expand All @@ -29,6 +38,7 @@ ApiDisplayResponse parseResponse_apiDisplay(String &payload)
.maximum_compatibility = doc["maximum_compatibility"] | false, // server doesn't return this flag if device.firmware_version <= 1.6.2
.firmware_url = doc["firmware_url"] | "",
.refresh_rate = doc["refresh_rate"],
.temp_profile = u32TP,
.reset_firmware = doc["reset_firmware"],
.special_function = parseSpecialFunction(special_function_str),
.action = doc["action"] | "",
Expand Down
4 changes: 3 additions & 1 deletion src/api-client/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ void addHeaders(HTTPClient &https, ApiDisplayInputs &inputs)
"Battery-Voltage: %s\n\r"
"FW-Version: %s\r\n"
"Model: %s\r\n"
"RSSI: %s\r\n",
"RSSI: %s\r\n"
"temperature-profile:true\r\n",
inputs.macAddress.c_str(),
inputs.specialFunction,
inputs.apiKey.c_str(),
Expand All @@ -34,6 +35,7 @@ void addHeaders(HTTPClient &https, ApiDisplayInputs &inputs)
https.addHeader("FW-Version", inputs.firmwareVersion);
https.addHeader("Model", String(inputs.model));
https.addHeader("RSSI", String(inputs.rssi));
https.addHeader("temperature-profile", "true");
https.addHeader("Width", String(inputs.displayWidth));
https.addHeader("Height", String(inputs.displayHeight));

Expand Down
2 changes: 1 addition & 1 deletion src/bl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void bl_init(void)

WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP

// uncomment this to hardcode WiFi credentials (useful for testing wifi errors, etc.)
// uncdcomment this to hardcode WiFi credentials (useful for testing wifi errors, etc.)
// #define HARDCODED_WIFI
#ifdef HARDCODED_WIFI
WifiCredentials hardcodedCreds = {.ssid = "ssid-goes-here", .pswd = "password-goes-here"};
Expand Down
Loading
Loading