Skip to content

Commit

Permalink
v0.56
Browse files Browse the repository at this point in the history
- Better bar- and linegraph drawing algorithm
- Allows to draw a progressbar in notifications and Custom Apps
- Allows to disable the Temp&Hum senor via dev.json
  • Loading branch information
Blueforcer committed Apr 17, 2023
1 parent 3193986 commit 7cc1ca1
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 186 deletions.
20 changes: 13 additions & 7 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,28 @@ All keys are optional, so you can send just the properties you want to use.
| Key | Type | Description | Default |
| --- | ---- | ----------- | ------- |
| `text` | string | The text to display on the app. | N/A |
| `textCase` | integer | Changes the Uppercase setting. 0=global setting, 1=forces uppercase; 2=shows as it sent. | 0 |
| `textOffset` | integer | Sets an offset for the x position of a starting text. | 0 |
| `color` | string or array of integers | The text, bar or line color | |
| `rainbow` | boolean | Fades each letter in the text differently through the entire RGB spectrum. | false |
| `icon` | string | The icon ID or filename (without extension) to display on the app. | N/A |
| `pushIcon` | number | 0 = Icon doesn't move. 1 = Icon moves with text and will not appear again. 2 = Icon moves with text but appears again when the text starts to scroll again. | 0 |
| `repeat` | number | Sets how many times the text should be scrolled through the matrix before the app ends. | 1 |
| `rainbow` | boolean | Fades each letter in the text differently through the entire RGB spectrum. | false |
| `duration` | number | Sets how long the app or notification should be displayed. | 5 |
| `color` | string | A color hex string for the text color, or an array of R,G,B values | "#FFFFFF" or [255,255,0] |
| `lifetime` | integer | Removes the custom app when there is no update after the given time in seconds | 0 |
| `hold` | boolean | Set it to true, to hold your **notification** on top until you press the middle button or dismiss it via HomeAssistant. This key only belongs to notification. | false |
| `sound` | string | The filename of your RTTTL ringtone file (without extension). | N/A |
| `pushIcon` | number | 0 = Icon doesn't move. 1 = Icon moves with text and will not appear again. 2 = Icon moves with text but appears again when the text starts to scroll again. | 0 |
| `bar` | array of integers | draws a bargraph. Without icon maximum 16 values, with icon 11 values | N/A |
| `line` | array of integers | draws a linechart. Without icon maximum 16 values, with icon 11 values | N/A |
| `autoscale` | boolean | enables or disables autoscaling for bar and linechart | true |
| `lifetime` | integer | Removes the custom app when there is no update after the given time in seconds | 0 |
| `textCase` | integer | Changes the Uppercase setting. 0=global setting, 1=forces uppercase; 2=shows as it sent. | 0 |
| `textOffset` | integer | Sets an offset for the x position of a starting text. | 0 |
| `progress` | integer | Shows a progressbar. Value can be 0-100 | -1 |
| `progressC` | string or array of integers | The color of the progressbar | -1 |
| `progressBC` | string or array of integers | The color of the progressbar background | -1 |
| `pos` | number | defines the position of your custompage in the loop, starting at 0 for the first position. This will only apply with your first push. You cant change the position afterwards with [this function](api?id=addremove-and-rearange-apps) | N/A |


Color values can have a hex string or an array of R,G,B values:
`"#FFFFFF" or [255,255,0]`

### Example

Here's an example JSON object to display the text "Hello, AWTRIX Light!" with the icon name "1", in rainbow colors, for 10 seconds:
Expand Down
3 changes: 2 additions & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ The JSON object has the following properties:
| `color_correction` | array of int | Sets the colorcorrection of the matrix | `[255,255,255]` |
| `color_temperature` | array of int | Sets the colortemperature of the matrix | `[255,255,255]` |
| `gamma` |float | Sets the gamma of the matrix | `2.5` |
| `update_check` | boolean | Enables searchf or new version every 1 hour. This could cause in loop stack overflow! | `false` |
| `update_check` | boolean | Enables searchfunction for new version every 1 hour. This could cause in loop stack overflow! | `false` |
| `sensor_reading` | boolean | Enables or disables the reading of the Temp&Hum sensor | `true` |
19 changes: 18 additions & 1 deletion src/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ struct CustomApp
std::vector<uint16_t> colors;
std::vector<String> fragments;
uint8_t textOffset;
int progress = -1;
uint16_t pColor;
uint16_t pbColor;
};

String currentCustomApp;
Expand Down Expand Up @@ -84,6 +87,9 @@ struct Notification
std::vector<uint16_t> colors;
std::vector<String> fragments;
uint8_t textOffset;
int progress = -1;
uint16_t pColor;
uint16_t pbColor;
};

Notification notify;
Expand Down Expand Up @@ -451,7 +457,7 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
}
else
{

if (ca->rainbow)
{
DisplayManager.HSVtext(x + textX, 6 + y, ca->text.c_str(), false, ca->textCase);
Expand Down Expand Up @@ -530,6 +536,12 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
// matrix->drawLine(8 + x + ca->iconPosition, 0 + y, 8 + x + ca->iconPosition, 7 + y, 0);
}
}

if (ca->progress > -1)
{
DisplayManager.drawProgressBar((hasIcon ? 9 : 0), 7 + y, ca->progress, ca->pColor, ca->pbColor);
}

// Reset text color
DisplayManager.getInstance().resetTextColor();
}
Expand Down Expand Up @@ -746,6 +758,11 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer
}
}

if (notify.progress > -1)
{
DisplayManager.drawProgressBar((hasIcon ? 9 : 0), 7, notify.progress, notify.pColor, notify.pbColor);
}

// Reset text color after displaying notification
DisplayManager.getInstance().resetTextColor();
}
Expand Down
Loading

0 comments on commit 7cc1ca1

Please sign in to comment.