Skip to content

Commit

Permalink
V0.58
Browse files Browse the repository at this point in the history
- Fixes crashs with lifetime key. closes #84
- Adds dev option to rotate the screen upside down. closes #82
- Allows to play a sound at any time via API
- Adds the possibility to change the textcolor of all native apps individually via settings API. closes #90
- More checks wether to disable automatic transistion. closes #83
  • Loading branch information
Blueforcer committed Apr 27, 2023
1 parent 5b937cd commit d25b432
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 178 deletions.
92 changes: 16 additions & 76 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ With HTTP, make GET request to `http://[IP]/api/stats`
| `[PREFIX]/power` | `http://[IP]/api/power` | true/false or 1/0 | POST |


## Play a sound

Plays a RTTTL sound from the MELODIES folder.

| Topic | URL | Payload/Body | HTTP method |
| --- | --- | --- | --- |
| `[PREFIX]/sound` | `http://[IP]/api/sound` | name of the RTTTL file without extension | POST |


## Colored indicators

A colored indicator is like a small notification sign wich will be shown on the upper right or lower right corner.
Expand Down Expand Up @@ -66,9 +75,8 @@ All keys are optional, so you can send just the properties you want to use.
| `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 |
| `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. This function is experimental | N/A |


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

Expand Down Expand Up @@ -140,78 +148,6 @@ Built-in app names are:
For custom apps, use the name you set in the topic or http request header.
In MQTT for example, if `[PREFIX]/custom/test` is your topic, then `test` is the name.

## Add/remove and rearange apps


| Topic | URL | Payload/Body | HTTP method |
| --- | --- | --- | --- |
| `[PREFIX]/apps`|`http://[IP]/api/apps`| json | POST |

!> This function provides users with the ability to manage the apps on their device by adding, removing, and rearranging them. However, as it is an experimental feature, caution should be exercised, particularly when attempting to rearrange multiple apps at once, as this can lead to unintended consequences due to the resulting shifts in position of other apps.

By using this function, users can add or remove native apps, as well as custom apps, from the device.
However, it is important to note that custom apps are only temporarily loaded into memory and cannot be added again using this function.
To add a custom app again, you must send it to awtrix via mqtt again.

Additionally, you can rearrange the position of all apps on the device by specifying a new position in the JSON array.
This provides flexibility in organizing apps according to personal preference.

The JSON payload is an array of objects, where each object represents an app to be displayed on awtrix. Each app object contains the following fields:

### JSON Properties

| Property | Description |Default |
|----------|-------------|-------------|
| name | The name of the app. If it's a native app, it can be one of "time", "date", "temp", "hum", or "bat". For custom apps, use the name you set in the topic. For example, if `[PREFIX]/custom/test` is your topic, then `test` is the name. | |
| show | A boolean indicating whether the app should be shown on the screen or not. If not present, the app is considered active by default. | true |
| pos | An integer indicating the position of the app in the list. If not present, the app will be added to the end of the list. | Last Item |


> You can also just send the information for one app.
```json
[
{
"name":"time",
"show":true,
"pos":3
},
{
"name":"date",
"pos":0
},
{
"name":"temp",
"pos":2
},
{
"name":"hum",
"show":true,
"pos":0
},
{
"name":"bat",
"show":false
},
{
"name":"github",
"show":true,
"pos":4
}
]
```



In this example,
- The "time" app is active and should be displayed in position 3.
- The "date" app should be displayed in position 0.
- The "temp" app should be displayed in position 2.
- The "hum" app should be displayed at first position.
- The "bat" app is inactive and will be removed,
- and the "github" app is active and should be displayed in position 4.



## Change Settings
Change various settings related to the app display.
Expand All @@ -231,7 +167,7 @@ Each property is optional; you do not need to send all.
| `TCOL` | string / array of ints| Sets the textcolor | an array of RGB values `[255,0,0]` or any valid 6-digit hexadecimal color value, e.g. "#FF0000" for red. | N/A |
| `WD` | bool | Enable or disable the weekday display | true/false | true |
| `WDCA` | string / array of ints| Sets the active weekday color | an array of RGB values `[255,0,0]` or any valid 6-digit hexadecimal color value, e.g. "#FF0000" for red. | N/A |
| `WDCI` | string / array of ints| Sets the inactive weekday color | an array of RGB values `[255,0,0]` or any valid 6-digit hexadecimal color value, e.g. "#FFFF" for red. | N/A |
| `WDCI` | string / array of ints| Sets the inactive weekday color | an array of RGB values `[255,0,0]` or any valid 6-digit hexadecimal color value, e.g. "#FFFF" for white. | N/A |
| `FPS` | number | Determines the frame rate at which the matrix is updated. | Any positive integer value. | 23 |
| `BRI` | number | Determines the brightness of the matrix. | An integer between 0 and 255. | N/A |
| `ABRI` | boolean | Determines if automatic brightness control is active. | `true` or `false`. | N/A |
Expand All @@ -244,7 +180,11 @@ Each property is optional; you do not need to send all.
| `SOM` | bool | Sets the start of the week to monday | true/false | true |
| `BLOCKN` | bool | Blocks temporarily the physical navigation keys, but still sends the input to MQTT | true/false | false |
| `UPPERCASE` | bool | Shows text in uppercase | true/false | true |

| `TIME_COL` | string / array of ints| Sets the textcolor of the time app. Set 0 for global textcolor | an array of RGB values hexadecimal color value | N/A |
| `DATE_COL` | string / array of ints| Sets the textcolor of the date app . Set 0 for global textcolor | an array of RGB values hexadecimal color value | N/A |
| `TEMP_COL` | string / array of ints| Sets the textcolor of the temp app. Set 0 for global textcolor | an array of RGB values hexadecimal color value | N/A |
| `HUM_COL` | string / array of ints| Sets the textcolor of the humidity app. Set 0 for global textcolor | an array of RGB values hexadecimal color value | N/A |
| `BAT_COL` | string / array of ints| Sets the textcolor of the battery app. Set 0 for global textcolor | an array of RGB values hexadecimal color value | N/A |

**Timeformats:**
```bash
Expand Down
1 change: 1 addition & 0 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ The JSON object has the following properties:
| `gamma` |float | Sets the gamma of the matrix | `2.5` |
| `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` |
| `rotate_screen` | boolean | Rotates the screen upside down | `false` |
52 changes: 45 additions & 7 deletions src/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,16 @@ void TimeApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x,
if (notify.flag)
return;
CURRENT_APP = "Time";
DisplayManager.getInstance().resetTextColor();

if (TIME_COLOR > 0)
{
matrix->setTextColor(TIME_COLOR);
}
else
{
DisplayManager.getInstance().resetTextColor();
}

time_t now = time(nullptr);
struct tm *timeInfo;
timeInfo = localtime(&now);
Expand Down Expand Up @@ -179,7 +188,14 @@ void DateApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x,
if (notify.flag)
return;
CURRENT_APP = "Date";
DisplayManager.getInstance().resetTextColor();
if (DATE_COLOR > 0)
{
matrix->setTextColor(DATE_COLOR);
}
else
{
DisplayManager.getInstance().resetTextColor();
}
time_t now = time(nullptr);
struct tm *timeInfo;
timeInfo = localtime(&now);
Expand Down Expand Up @@ -207,7 +223,14 @@ void TempApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x,
if (notify.flag)
return;
CURRENT_APP = "Temperature";
DisplayManager.getInstance().resetTextColor();
if (TEMP_COLOR > 0)
{
matrix->setTextColor(TEMP_COLOR);
}
else
{
DisplayManager.getInstance().resetTextColor();
}
matrix->drawRGBBitmap(x, y, icon_234, 8, 8);

if (TEMP_DECIMAL_PLACES > 0)
Expand All @@ -233,11 +256,18 @@ void HumApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, i
if (notify.flag)
return;
CURRENT_APP = "Humidity";
DisplayManager.getInstance().resetTextColor();
if (HUM_COLOR > 0)
{
matrix->setTextColor(HUM_COLOR);
}
else
{
DisplayManager.getInstance().resetTextColor();
}
matrix->drawRGBBitmap(x, y + 1, icon_2075, 8, 8);
matrix->setCursor(14 + x, 6 + y);
int humidity = CURRENT_HUM; // Humidity without decimal places
matrix->print(humidity); // Output humidity
int humidity = CURRENT_HUM;
matrix->print(humidity);
matrix->print("%");
}

Expand All @@ -247,7 +277,14 @@ void BatApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, i
if (notify.flag)
return;
CURRENT_APP = "Battery";
DisplayManager.getInstance().resetTextColor();
if (BAT_COLOR > 0)
{
matrix->setTextColor(BAT_COLOR);
}
else
{
DisplayManager.getInstance().resetTextColor();
}
matrix->drawRGBBitmap(x, y, icon_1486, 8, 8);
matrix->setCursor(14 + x, 6 + y);
matrix->print(BATTERY_PERCENT); // Ausgabe des Ladezustands
Expand Down Expand Up @@ -899,4 +936,5 @@ void CApp20(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, i
}

OverlayCallback overlays[] = {MenuApp, NotifyApp, AlarmApp, TimerApp};
void (*customAppCallbacks[20])(FastLED_NeoMatrix *, MatrixDisplayUiState *, int16_t, int16_t, bool, bool, 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 d25b432

Please sign in to comment.