Skip to content

Commit

Permalink
V0.61
Browse files Browse the repository at this point in the history
- Support uploads from AWTRIX flows
- Allows to send multiple custompages in one json
- Adds moodlight api
- Slightly better gif loading performance
- Power API now handles json OR true/false OR 0/1, also  Sound API can use json OR strings
  • Loading branch information
Blueforcer committed May 9, 2023
1 parent 19743f1 commit dc3f124
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 178 deletions.
87 changes: 42 additions & 45 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ Plays a RTTTL sound from the MELODIES folder.
| --- | --- | --- | --- |
| `[PREFIX]/sound` | `http://[IP]/api/sound` | {"sound":"alarm"} | POST |

## Moodlight
Allows to set the whole matrix to a custom color.

| Topic | URL | Payload/Body | HTTP method |
| --- | --- | --- | --- |
| `[PREFIX]/moodlight` | `http://[IP]/api/moodlight` | see below | POST |

Possible moodlight options:
```json
{"brightness":200,"kelvin":2300}
```
```json
{"brightness":200,"color":[155,38,182]}
```
```json
{"brightness":200,"color":"#FF00FF"}
```


## Colored indicators

Expand Down Expand Up @@ -93,58 +111,37 @@ Here's an example JSON object to display the text "Hello, AWTRIX Light!" with th
}
```

### Drawing Instructions
!> Pease note: Depending on the amount of objects, the RAM usage can be very high. This could cause freezes or reboots.
It's important to be mindful of the number of objects and the complexity of the drawing instructions to avoid performance issues.
### Drawing Instructions
!> Please note: Depending on the number of objects, the RAM usage can be very high. This could cause freezes or reboots.
It's important to be mindful of the number of objects and the complexity of the drawing instructions to avoid performance issues.

Each drawing instruction is an object with a required command key `c` and additional keys depending on the command:
Each drawing instruction is an object with a required command key and an array of values depending on the command:

| Command | Additional Keys | Description |
| ------- | --------------- | ----------- |
| `dp` | `x`, `y`, `cl` | Draw a pixel at position (`x`, `y`) with color `cl` |
| `dl` | `x0`, `y0`, `x1`, `y1`, `cl` | Draw a line from (`x0`, `y0`) to (`x1`, `y1`) with color `cl` |
| `dr` | `x`, `y`, `w`, `h`, `cl` | Draw a rectangle with top-left corner at (`x`, `y`), width `w`, height `h`, and color `cl` |
| `df` | `x`, `y`, `w`, `h`, `cl` | Draw a filled rectangle with top-left corner at (`x`, `y`), width `w`, height `h`, and color `cl` |
| `dc` | `x`, `y`, `r`, `cl` | Draw a circle with center at (`x`, `y`), radius `r`, and color `cl` |
| `dfc` | `x`, `y`, `r`, `cl` | Draw a filled circle with center at (`x`, `y`), radius `r`, and color `cl` |
| `dt` | `x`, `y`, `t`, `cl` | Draw text `t` with top-left corner at (`x`, `y`) and color `cl` |

| Command | Array Values | Description |
| ------- | -------------------- | ----------- |
| `dp` | `[x, y, cl]` | Draw a pixel at position (`x`, `y`) with color `cl` |
| `dl` | `[x0, y0, x1, y1, cl]` | Draw a line from (`x0`, `y0`) to (`x1`, `y1`) with color `cl` |
| `dr` | `[x, y, w, h, cl]` | Draw a rectangle with top-left corner at (`x`, `y`), width `w`, height `h`, and color `cl` |
| `df` | `[x, y, w, h, cl]` | Draw a filled rectangle with top-left corner at (`x`, `y`), width `w`, height `h`, and color `cl` |
| `dc` | `[x, y, r, cl]` | Draw a circle with center at (`x`, `y`), radius `r`, and color `cl` |
| `dfc` | `[x, y, r, cl]` | Draw a filled circle with center at (`x`, `y`), radius `r`, and color `cl` |
| `dt` | `[x, y, t, cl]` | Draw text `t` with top-left corner at (`x`, `y`) and color `cl` |

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

### Example
### Example

Here's an example JSON object to draw a red circle, a blue rectangle, and the text "Hello" in green:

```json
{ "draw": [
{
"c": "dc",
"x": 28,
"y": 4,
"r": 3,
"cl": "#FF0000"
},
{
"c": "dr",
"x": 20,
"y": 4,
"w": 4,
"h": 4,
"cl": "#0000FF"
},
{
"c": "dt",
"x": 0,
"y": 0,
"t": "Hello",
"cl": "#00FF00"
}
]
}
```

```json
{"draw":[
{"dc": [28, 4, 3, "#FF0000"]},
{"dr": [20, 4, 4, 4, "#0000FF"]},
{"dt": [0, 0, "Hello", "#00FF00"]}
]}
```

### Display a text in colored fragments
You can display a text where you allowed to colorize fragments of the text.
Simply send an array of your fragments, containing `"t"` as your textfragment and `"c"` for the color hex value`.
Expand Down
4 changes: 2 additions & 2 deletions lib/webserver/src/esp-fs-webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool FSWebServer::begin(const char *path)
// OTA update via webbrowser
m_httpUpdater.setup(webserver);

webserver->enableCrossOrigin(true);

webserver->enableCORS(true);

webserver->setContentLength(1024);
Expand Down Expand Up @@ -605,7 +605,7 @@ void FSWebServer::replyOK()

void FSWebServer::replyToCLient(int msg_type = 0, const char *msg = "")
{
webserver->sendHeader("Access-Control-Allow-Origin", "*");
//webserver->sendHeader("Access-Control-Allow-Origin", "*");
switch (msg_type)
{
case OK:
Expand Down
10 changes: 5 additions & 5 deletions src/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ String WEATHER_HUM;

struct CustomApp
{
std::vector<String> drawInstructions;
String drawInstructions;
int16_t scrollposition = 0;
int16_t scrollDelay = 0;
String text;
Expand Down Expand Up @@ -66,7 +66,7 @@ std::map<String, CustomApp> customApps;

struct Notification
{
std::vector<String> drawInstructions;
String drawInstructions;
int16_t scrollposition = 34;
int16_t scrollDelay = 0;
String text;
Expand Down Expand Up @@ -300,7 +300,7 @@ void MenuApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer *
if (!MenuManager.inMenu)
return;
matrix->fillScreen(0);
DisplayManager.printText(0, 6, utf8ascii(MenuManager.menutext()).c_str(), true, true);
DisplayManager.printText(0, 6, utf8ascii(MenuManager.menutext()).c_str(), true, 2);
}

void AlarmApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer *gifPlayer)
Expand Down Expand Up @@ -571,7 +571,7 @@ void ShowCustomApp(String name, FastLED_NeoMatrix *matrix, MatrixDisplayUiState
}
}

if (ca->drawInstructions.size() > 0)
if (ca->drawInstructions.length() > 0)
{
DisplayManager.processDrawInstructions(x, y, ca->drawInstructions);
}
Expand Down Expand Up @@ -811,7 +811,7 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer
DisplayManager.drawProgressBar((hasIcon ? 9 : 0), 7, notify.progress, notify.pColor, notify.pbColor);
}

if (notify.drawInstructions.size() > 0)
if (notify.drawInstructions.length() > 0)
{
DisplayManager.processDrawInstructions(0, 0, notify.drawInstructions);
}
Expand Down
Loading

0 comments on commit dc3f124

Please sign in to comment.