Skip to content

Commit

Permalink
V0.79
Browse files Browse the repository at this point in the history
### 📈 New Features
- Allows to fade the indicators on and off in an given interval, blinking still works. closes #266
- Adds new Notify and CustomApp key "center" wich allows to turn centering of short, non-scrollable text on or off.

### 🐞 Bug Fixes and Optimizations
- Announced in v0.71 Timer and Alarm finally removed from code.
- Fixes a bug where special characters doesnt show right in notifications. close #267
- Settings API now return correct CTEMP and CCORRECTION colors as HEX.
  • Loading branch information
Blueforcer committed Aug 20, 2023
1 parent 6ca7d59 commit e03ed26
Show file tree
Hide file tree
Showing 12 changed files with 186 additions and 261 deletions.
4 changes: 3 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ A colored indicator is like a small notification sign wich will be shown on the

Instead of a RGB array you can also sent HEX color strings like `{"color":"#32a852"}`
Send the color black `{"color":[0,0,0]}` or `{"color":"0"}` or a empty payload/body to hide the indicators.
Optionally you can make the indicator blinking by adding the key `"blink"` with a value of the blinking interval in milliseconds.
Optionally you can make the indicator blinking by adding the key `"blink"` with a value of the blinking interval in milliseconds **or**
you can make the indicator fading on and off by adding the key `"fade"` with a value of the fade interval in milliseconds.

## Custom Apps and Notifications
With AWTRIX Light, you can create custom apps or notifications to display your own text and icons.
Expand Down Expand Up @@ -101,6 +102,7 @@ The JSON object has the following properties,
| `textCase` | integer | Changes the Uppercase setting. 0=global setting, 1=forces uppercase; 2=shows as it sent. | 0 | X | X |
| `topText` | boolean | Draw the text on top | false | X | X |
| `textOffset` | integer | Sets an offset for the x position of a starting text. | 0 | X | X |
| `center` | boolean | Centers a short, non-scrollable text. | true | X | X |
| `color` | string or array of integers | The text, bar or line color | N/A | X | X |
| `background` | string or array of integers | Sets a background color | N/A | X | X |
| `rainbow` | boolean | Fades each letter in the text differently through the entire RGB spectrum. | false | X | X |
Expand Down
93 changes: 31 additions & 62 deletions src/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct CustomApp
File icon;
bool isGif;
bool rainbow;
bool center;
int effect = -1;
long duration = 0;
byte textCase = 0;
Expand All @@ -55,6 +56,7 @@ struct CustomApp
std::vector<uint16_t> colors;
std::vector<String> fragments;
int textOffset;
int iconOffset;
int progress = -1;
uint16_t pColor;
uint16_t background = 0;
Expand All @@ -69,6 +71,7 @@ std::map<String, CustomApp> customApps;

struct Notification
{
bool center;
String drawInstructions;
float scrollposition = 34;
int16_t scrollDelay = 0;
Expand All @@ -78,6 +81,7 @@ struct Notification
File icon;
bool rainbow;
bool isGif;
int iconOffset;
unsigned long startime = 0;
long duration = 0;
int16_t repeat = -1;
Expand Down Expand Up @@ -383,57 +387,6 @@ void MenuApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer *
DisplayManager.printText(0, 6, utf8ascii(MenuManager.menutext()).c_str(), true, 2);
}

void AlarmApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer *gifPlayer)
{
if (ALARM_ACTIVE)
{
matrix->fillScreen(matrix->Color(255, 0, 0));
CURRENT_APP = "Alarm";
uint16_t textWidth = getTextWidth("ALARM", 0);
int16_t textX = ((32 - textWidth) / 2);
matrix->setTextColor(0);
matrix->setCursor(textX, 6);
matrix->print("ALARM");
if (ALARM_SOUND != "")
{
if (!PeripheryManager.isPlaying())
{
#ifdef ULANZI
PeripheryManager.playFromFile(ALARM_SOUND);
#else
PeripheryManager.playFromFile(DFMINI_MP3_ALARM);
#endif
}
}
}
}

void TimerApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer *gifPlayer)
{
if (TIMER_ACTIVE)
{
matrix->fillScreen(matrix->Color(0, 255, 0));
CURRENT_APP = "Timer";
String menuText = "TIMER";
uint16_t textWidth = getTextWidth(menuText.c_str(), 0);
int16_t textX = ((32 - textWidth) / 2);
matrix->setTextColor(0);
matrix->setCursor(textX, 6);
matrix->print(menuText);
if (TIMER_SOUND != "")
{
if (!PeripheryManager.isPlaying())
{
#ifdef ULANZI
PeripheryManager.playFromFile(TIMER_SOUND);
#else
PeripheryManager.playFromFile(DFMINI_MP3_TIMER);
#endif
}
}
}
}

void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, int16_t y, GifPlayer *gifPlayer)
{
// Abort if notifyFlag is set
Expand Down Expand Up @@ -512,11 +465,11 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
}
if (ca->isGif)
{
gifPlayer->playGif(x + ca->iconPosition, y, &ca->icon);
gifPlayer->playGif(x + ca->iconPosition + ca->iconOffset, y, &ca->icon);
}
else
{
DisplayManager.drawJPG(x + ca->iconPosition, y, ca->icon);
DisplayManager.drawJPG(x + ca->iconPosition + ca->iconOffset, y, ca->icon);
}
if (!noScrolling)
{
Expand Down Expand Up @@ -612,7 +565,16 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
}
}

int16_t textX = hasIcon ? ((24 - textWidth) / 2) + 9 : ((32 - textWidth) / 2);
int16_t textX;
if (ca->center)
{
textX = hasIcon ? ((24 - textWidth) / 2) + 9 : ((32 - textWidth) / 2);
}
else
{
textX = hasIcon ? 9 : 0;
}

if (noScrolling)
{
ca->repeat = -1; // Disable repeat if text is too short for scrolling
Expand All @@ -631,13 +593,13 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
{
if (ca->rainbow)
{
DisplayManager.HSVtext(x + textX+ca->textOffset, 6 + y, ca->text.c_str(), false, ca->textCase);
DisplayManager.HSVtext(x + textX + ca->textOffset, 6 + y, ca->text.c_str(), false, ca->textCase);
}
else
{
// Display text
matrix->setTextColor(ca->color);
DisplayManager.printText(x + textX+ca->textOffset, y + 6, ca->text.c_str(), false, ca->textCase);
DisplayManager.printText(x + textX + ca->textOffset, y + 6, ca->text.c_str(), false, ca->textCase);
}
}
}
Expand Down Expand Up @@ -785,18 +747,18 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer
{
// Display GIF if present

gifPlayer->playGif(notifications[0].iconPosition, 0, &notifications[0].icon);
gifPlayer->playGif(notifications[0].iconPosition + notifications[0].iconOffset, 0, &notifications[0].icon);
}
else
{
// Display JPG image if present
DisplayManager.drawJPG(notifications[0].iconPosition, 0, notifications[0].icon);
DisplayManager.drawJPG(notifications[0].iconPosition + notifications[0].iconOffset, 0, notifications[0].icon);
}

// Display icon divider line if text is scrolling
if (!noScrolling)
{
matrix->drawLine(8 + notifications[0].iconPosition, 0, 8 + notifications[0].iconPosition, 7, 0);
matrix->drawLine(8 + notifications[0].iconPosition + notifications[0].iconOffset, 0, 8 + notifications[0].iconPosition, 7, 0);
}
};

Expand Down Expand Up @@ -872,8 +834,15 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer
}
}

// Calculate text X position based on icon presence
int16_t textX = hasIcon ? ((24 - textWidth) / 2) + 9 : ((32 - textWidth) / 2);
int16_t textX;
if (notifications[0].center)
{
textX = hasIcon ? ((24 - textWidth) / 2) + 9 : ((32 - textWidth) / 2);
}
else
{
textX = hasIcon ? 9 : 0;
}

// Set text color
matrix->setTextColor(notifications[0].color);
Expand Down Expand Up @@ -1107,6 +1076,6 @@ void CApp20(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, i
ShowCustomApp(name, matrix, state, x, y, gifPlayer);
}

OverlayCallback overlays[] = {MenuApp, NotifyApp, AlarmApp, TimerApp};
OverlayCallback overlays[] = {MenuApp, NotifyApp};
void (*customAppCallbacks[20])(FastLED_NeoMatrix *, MatrixDisplayUiState *, int16_t, int16_t, GifPlayer *) = {CApp1, CApp2, CApp3, CApp4, CApp5, CApp6, CApp7, CApp8, CApp9, CApp10, CApp11, CApp12, CApp13, CApp14, CApp15, CApp16, CApp17, CApp18, CApp19, CApp20};
#endif
Loading

0 comments on commit e03ed26

Please sign in to comment.