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
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ You can adjust each property in the JSON object according to your preferences. I
| `CBCOL` | string/array of ints | Calendar body color of the time app. | RGB array or hex color |`#FFFFFF`|
| `CTCOL` | string/array of ints | Calendar text color in the time app. | RGB array or hex color |`#000000` |
| `WD` | boolean | Enable or disable the weekday display. | `true`/`false` | true |
| `MP` | boolean | Enable or disable the minute progress bar (ignored if WD is active) display. | `true`/`false` | true |
| `WDCA` | string/array of ints | Active weekday color. | RGB array or hex color | N/A |
| `WDCI` | string/array of ints | Inactive weekday color. | RGB array or hex color | N/A |
| `BRI` | number | Matrix brightness. | 0-255 | N/A |
Expand Down
60 changes: 42 additions & 18 deletions src/Apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,50 @@ void TimeApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x,
DisplayManager.matrixPrint(day_str);
}

if (!SHOW_WEEKDAY)
return;

// line of week days
uint8_t LINE_WIDTH = TIME_MODE > 0 ? 2 : 3;
uint8_t LINE_SPACING = 1;
uint8_t LINE_START = TIME_MODE > 0 ? 10 : 2;
uint8_t dayOffset = START_ON_MONDAY ? 0 : 1;
for (int i = 0; i <= 6; i++)
{
int lineStart = LINE_START + i * (LINE_WIDTH + LINE_SPACING);
int lineEnd = lineStart + LINE_WIDTH - 1;
if (SHOW_WEEKDAY) {
// line of week days
uint8_t LINE_WIDTH = TIME_MODE > 0 ? 2 : 3;
uint8_t LINE_SPACING = 1;
uint8_t LINE_START = TIME_MODE > 0 ? 10 : 2;
uint8_t dayOffset = START_ON_MONDAY ? 0 : 1;
for (int i = 0; i <= 6; i++)
{
int lineStart = LINE_START + i * (LINE_WIDTH + LINE_SPACING);
int lineEnd = lineStart + LINE_WIDTH - 1;

uint32_t color;
if (i == (timer_localtime()->tm_wday + 6 + dayOffset) % 7)
color = WDC_ACTIVE; // current day
else
color = WDC_INACTIVE; // other days
uint32_t color;
if (i == (timer_localtime()->tm_wday + 6 + dayOffset) % 7)
color = WDC_ACTIVE; // current day
else
color = WDC_INACTIVE; // other days

DisplayManager.drawLine(lineStart + x, wdPosY + y, lineEnd + x, wdPosY + y, color);
DisplayManager.drawLine(lineStart + x, wdPosY + y, lineEnd + x, wdPosY + y, color);
}
} else if (SHOW_MINUTEPROGRESS) {
const uint8_t spaceStart = (TIME_MODE > 0 ? 10 : 0) + x;
const uint8_t spaceWidth = TIME_MODE > 0 ? 22 : 32;
const uint8_t secondsPerPixel = TIME_MODE > 0 ? 5 : 3;
const uint8_t segments = 4;
const uint8_t totalPixels = 60 / secondsPerPixel;
const uint8_t pixelsPerSegment = totalPixels / segments;

uint8_t lineX = spaceStart + spaceWidth / 2 - (totalPixels + segments) / 2;
const uint8_t lineEnd = lineX + totalPixels + segments - 1;
uint8_t coloredPixels = timer_localtime()->tm_sec / secondsPerPixel;
while (coloredPixels >= pixelsPerSegment) {
DisplayManager.drawLine(lineX, wdPosY + y, lineX + pixelsPerSegment - 1, wdPosY + y, WDC_ACTIVE);
coloredPixels -= pixelsPerSegment;
lineX += pixelsPerSegment + 1;
}
if (coloredPixels > 0) {
DisplayManager.drawLine(lineX + coloredPixels, wdPosY + y, lineX + pixelsPerSegment - 1, wdPosY + y, WDC_INACTIVE);
DisplayManager.drawLine(lineX, wdPosY + y, lineX + coloredPixels - 1, wdPosY + y, WDC_ACTIVE);
lineX += pixelsPerSegment + 1;
}
while (lineX < lineEnd) {
DisplayManager.drawLine(lineX, wdPosY + y, lineX + pixelsPerSegment - 1, wdPosY + y, WDC_INACTIVE);
lineX += pixelsPerSegment + 1;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/DisplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2041,6 +2041,7 @@ String DisplayManager_::getSettings()
doc["CCORRECTION"] = CRGBtoHex(COLOR_CORRECTION);
doc["CTEMP"] = CRGBtoHex(COLOR_TEMPERATURE);
doc["WD"] = SHOW_WEEKDAY;
doc["MP"] = SHOW_MINUTEPROGRESS;
doc["TEFF"] = TRANS_EFFECT;
doc["WDCA"] = WDC_ACTIVE;
doc["WDCI"] = WDC_INACTIVE;
Expand Down Expand Up @@ -2109,6 +2110,7 @@ void DisplayManager_::setNewSettings(const char *json)
AUTO_TRANSITION = doc.containsKey("ATRANS") ? doc["ATRANS"].as<bool>() : AUTO_TRANSITION;
UPPERCASE_LETTERS = doc.containsKey("UPPERCASE") ? doc["UPPERCASE"].as<bool>() : UPPERCASE_LETTERS;
SHOW_WEEKDAY = doc.containsKey("WD") ? doc["WD"].as<bool>() : SHOW_WEEKDAY;
SHOW_MINUTEPROGRESS = doc.containsKey("MP") ? doc["MP"].as<bool>() : SHOW_MINUTEPROGRESS;
BLOCK_NAVIGATION = doc.containsKey("BLOCKN") ? doc["BLOCKN"].as<bool>() : BLOCK_NAVIGATION;
SHOW_TIME = doc.containsKey("TIM") ? doc["TIM"].as<bool>() : SHOW_TIME;
SHOW_DATE = doc.containsKey("DAT") ? doc["DAT"].as<bool>() : SHOW_DATE;
Expand Down
3 changes: 3 additions & 0 deletions src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ void loadSettings()
WDC_INACTIVE = Settings.getUInt("WDCI", 0x666666);
AUTO_TRANSITION = Settings.getBool("ATRANS", true);
SHOW_WEEKDAY = Settings.getBool("WD", true);
SHOW_MINUTEPROGRESS = Settings.getBool("MP", false);
TIME_PER_TRANSITION = Settings.getUInt("TSPEED", 400);
TIME_PER_APP = Settings.getUInt("ATIME", 7000);
TIME_FORMAT = Settings.getString("TFORMAT", "%H %M");
Expand Down Expand Up @@ -298,6 +299,7 @@ void saveSettings()
Settings.putUInt("TEFF", TRANS_EFFECT);
Settings.putUInt("BRI", BRIGHTNESS);
Settings.putBool("WD", SHOW_WEEKDAY);
Settings.putBool("MP", SHOW_MINUTEPROGRESS);
Settings.putBool("ABRI", AUTO_BRIGHTNESS);
Settings.putBool("BLOCKN", BLOCK_NAVIGATION);
Settings.putBool("ATRANS", AUTO_TRANSITION);
Expand Down Expand Up @@ -356,6 +358,7 @@ bool SHOW_TEMP = true;
bool SHOW_HUM = true;
bool SHOW_SECONDS = true;
bool SHOW_WEEKDAY = true;
bool SHOW_MINUTEPROGRESS = true;
String NET_IP = "192.168.178.10";
String NET_GW = "192.168.178.1";
String NET_SN = "255.255.255.0";
Expand Down
1 change: 1 addition & 0 deletions src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ extern bool SHOW_TEMP;
extern bool SHOW_HUM;
extern bool SHOW_SECONDS;
extern bool SHOW_WEEKDAY;
extern bool SHOW_MINUTEPROGRESS;
extern int8_t TRANS_EFFECT;
extern String NET_IP;
extern String NET_GW;
Expand Down