Skip to content

Commit

Permalink
0.75
Browse files Browse the repository at this point in the history
AWTRIX Light app for iOS is now in open beta test [See discord](https://discord.com/channels/546407049148366859/591248067735322624/1142077243145855036)

- Implements logarithmic gamma control for better colors. This gives more saturation in normal brightness and while in the past youre loosing pixels completely in low brightness, the new mechanism tries to lower the gamma in that lower range. You doesnt get the colors right in low brightness, but at least you see the pixel.
Best colors are at 30-60% brightness
- Decreases the Brightness range
- Awtrix webinterface now supports reverse proxy. closes #236
- Notification icon object will be destroyed in RAM after showing, so youre able to delete it
- Allow to set lowest brightness via menu
  • Loading branch information
Blueforcer committed Aug 18, 2023
1 parent ea2ead2 commit 05ed3ca
Show file tree
Hide file tree
Showing 10 changed files with 807 additions and 776 deletions.
3 changes: 1 addition & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,10 @@ Each property is optional; you do not need to send all.
| `ATRANS` | boolean | Determines if automatic switching to the next app is active. | `true` or `false`. | N/A |
| `CCORRECTION` | array of ints | Sets the color correction for the matrix | an array of RGB values | N/A |
| `CTEMP` | array of ints | Sets the color temperature for the matrix | an array of RGB values | N/A |
| `GAMMA` | float | Sets the gamma for the matrix | 2.5 | N/A |
| `TFORMAT` | string | Sets the timeformat for the TimeApp | see below | N/A |
| `DFORMAT` | string | Sets the dateformat for the DateApp | see below | N/A |
| `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 |
| `BLOCKN` | bool | Blocks 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 |
Expand Down
1 change: 0 additions & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ The JSON object has the following properties:
| `matrix` | integer | Changes the matrix layout (0,1 or 2) | `0` |
| `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 searchfunction for new version every 1 hour. This could cause in loop stack overflow! | `false` |
| `rotate_screen` | boolean | Rotates the screen upside down | `false` |
| `temp_dec_places` | integer | Number of decimal places for temperature measurements | `0` |
Expand Down
13 changes: 10 additions & 3 deletions lib/webserver/esp-fs-webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void FSWebServer::run()
webserver->handleClient();
if (m_apmode)
m_dnsServer.processNextRequest();


}

void FSWebServer::addHandler(const Uri &uri, HTTPMethod method, WebServerClass::THandlerFunction fn)
Expand Down Expand Up @@ -169,9 +171,9 @@ IPAddress FSWebServer::startWiFi(uint32_t timeout, const char *apSSID, const cha
Serial.print(".");
if (WiFi.status() == WL_CONNECTED)
{
ip = WiFi.localIP();
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
ip = WiFi.localIP();
return ip;
}
// If no connection after a while go in Access Point mode
Expand Down Expand Up @@ -897,19 +899,24 @@ void FSWebServer::handleStatus()
totalBytes = fs_info.totalBytes;
usedBytes = fs_info.usedBytes;
#elif defined(ESP32)
totalBytes = LittleFS.totalBytes();
usedBytes = LittleFS.usedBytes();
// totalBytes = m_filesystem->totalBytes();
// usedBytes = m_filesystem->usedBytes();
#endif

String json;
json.reserve(128);
json = "{\"type\":\"Filesystem\", \"isOk\":";
if (m_fsOK)
{
uint32_t ip = (WiFi.status() == WL_CONNECTED) ? WiFi.localIP() : WiFi.softAPIP();
json += PSTR("\"true\", \"totalBytes\":\"");
json += totalBytes;
json += PSTR("\", \"usedBytes\":\"");
json += usedBytes;
json += PSTR("\", \"mode\":\"");
json += WiFi.status() == WL_CONNECTED ? "Station" : "Access Point";
json += PSTR("\", \"ip\":\"");
json += ip;
json += "\"";
}
else
Expand Down
1,513 changes: 761 additions & 752 deletions lib/webserver/setup_htm.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ void NotifyApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, GifPlayer
{
notifications[1].startime = millis();
}
notifications[0].icon.close();
notifications.erase(notifications.begin());
if (notifications[0].wakeup && MATRIX_OFF)
{
Expand Down
43 changes: 29 additions & 14 deletions src/DisplayManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ GifPlayer gif;

uint16_t gifX, gifY;
CRGB leds[MATRIX_WIDTH * MATRIX_HEIGHT];

CRGB ledsCopy[MATRIX_WIDTH * MATRIX_HEIGHT];
float actualBri;
// BMP Creation
const int w = 32; // image width in pixels
const int h = 8; // " height
Expand Down Expand Up @@ -80,6 +81,8 @@ void DisplayManager_::setBrightness(int bri)
{

matrix->setBrightness(bri);
actualBri = bri;
Serial.println(actualBri);
}
}

Expand Down Expand Up @@ -1011,8 +1014,7 @@ void DisplayManager_::setup()
FastLED.addLeds<NEOPIXEL, MATRIX_PIN>(leds, MATRIX_WIDTH * MATRIX_HEIGHT);
setMatrixLayout(MATRIX_LAYOUT);
matrix->setRotation(ROTATE_SCREEN ? 90 : 0);
// FastLED.setTemperature(16752790);
// FastLED.setCorrection(0xC8FFFF);
GAMMA = 1.9;
if (COLOR_CORRECTION)
{
FastLED.setCorrection(COLOR_CORRECTION);
Expand Down Expand Up @@ -1265,6 +1267,7 @@ void DisplayManager_::dismissNotify()
if (!notifications.empty())
{
wakeup = notifications[0].wakeup;
notifications[0].icon.close();
notifications.erase(notifications.begin());
PeripheryManager.stopSound();
}
Expand Down Expand Up @@ -1361,7 +1364,7 @@ void DisplayManager_::drawMenuIndicator(int cur, int total, uint16_t color)
}
else
{
matrix->drawLine(x, 7, x + menuItemWidth - 1, 7, matrix->Color(100, 100, 100));
matrix->drawLine(x, 7, x + menuItemWidth - 1, 7, 0x6B6D);
}
}
}
Expand Down Expand Up @@ -1542,7 +1545,7 @@ String DisplayManager_::getStats()
doc[F("indicator2")] = ui->indicator2State;
doc[F("indicator3")] = ui->indicator3State;
doc[F("app")] = CURRENT_APP;
// doc[F("freeFlash")] = LittleFS.totalBytes() - LittleFS.usedBytes();
// doc[F("freeFlash")] = LittleFS.totalBytes() - LittleFS.usedBytes();
String jsonString;
serializeJson(doc, jsonString);
return jsonString;
Expand Down Expand Up @@ -1779,14 +1782,29 @@ bool DisplayManager_::indicatorParser(uint8_t indicator, const char *json)
return true;
}

float logMap(float x, float in_min, float in_max, float out_min, float out_max, float mid_point_out)
{
if (x<in_min) return out_min;
if (x>in_max) return out_max;
float scale = (mid_point_out - out_min) / log(in_max - in_min + 1);
if (x <= (in_max + in_min) / 2.0)
{
return scale * log(x - in_min + 1) + out_min;
}
else
{
float upper_scale = (out_max - mid_point_out) / log(in_max - (in_max + in_min) / 2.0 + 1);
return upper_scale * log(x - (in_max + in_min) / 2.0 + 1) + mid_point_out;
}
}

void DisplayManager_::gammaCorrection()
{
if (GAMMA > 0)
float gamma = logMap(actualBri, 2, 180, 0.535, 2.3, 1.9);
memcpy(ledsCopy, leds, sizeof(leds));
for (int i = 0; i < 256; i++)
{
for (int i = 0; i < 256; i++)
{
leds[i] = applyGamma_video(leds[i], GAMMA);
}
leds[i] = applyGamma_video(leds[i], gamma);
}
}

Expand Down Expand Up @@ -2009,10 +2027,7 @@ String DisplayManager_::ledsAsJson()
for (int x = 0; x < MATRIX_WIDTH; x++)
{
int index = matrix->XY(x, y);
int r = leds[index].r;
int g = leds[index].g;
int b = leds[index].b;
int color = (r << 16) | (g << 8) | b;
int color = (ledsCopy[index].r << 16) | (ledsCopy[index].g << 8) | ledsCopy[index].b;
jsonColors.add(color);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ IPAddress gateway;
IPAddress subnet;
IPAddress primaryDNS;
IPAddress secondaryDNS;
const char *VERSION = "0.74";
const char *VERSION = "0.75";

String MQTT_HOST = "";
uint16_t MQTT_PORT = 1883;
Expand Down
2 changes: 1 addition & 1 deletion src/MenuManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void MenuManager_::selectButtonLong()
switch (currentState)
{
case BrightnessMenu:
BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
//BRIGHTNESS = map(BRIGHTNESS_PERCENT, 0, 100, 0, 255);
saveSettings();
break;
case ColorMenu:
Expand Down
4 changes: 2 additions & 2 deletions src/PeripheryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ void PeripheryManager_::tick()
if (AUTO_BRIGHTNESS && !MATRIX_OFF)
{
brightnessPercent = sampleAverage / 4095.0 * 100.0;
int brightness = map(brightnessPercent, 0, 100, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
DisplayManager.setBrightness(brightness);
BRIGHTNESS = map(brightnessPercent, 0, 100, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
DisplayManager.setBrightness(BRIGHTNESS);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void setup()
pinMode(15, OUTPUT);
digitalWrite(15, LOW);
delay(5000);
Serial.begin(115200);
loadSettings();
PeripheryManager.setup();
ServerManager.loadSettings();
Expand Down

0 comments on commit 05ed3ca

Please sign in to comment.