Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'swap_buttons' and 'ldr_on_ground' settings for dev.json #493

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ The JSON object has the following properties:
| `button_callback` | string | http callback url for button presses. | - |
| `let_it_snow` | boolean | Let it snow as a global Overlay. | true for christmastime |
| `new_year` | boolean | Displays fireworks and plays a jingle at newyear. | false |
| `swap_buttons` | boolean | Swaps the left and right hardware button. | false |
| `ldr_on_ground` | boolean | Sets the LDR configuration to LDR-on-ground. | false |

#### Example:
```json
{
"temp_dec_places":1,
"bootsound":true,
"hum_offset":-2,
"let_it_snow": true
"let_it_snow":true
}
```
12 changes: 12 additions & 0 deletions src/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ void loadDevSettings()
NEWYEAR = doc["new_year"].as<bool>();
}

if (doc.containsKey("swap_buttons"))
{
SWAP_BUTTONS = doc["swap_buttons"].as<bool>();
}

if (doc.containsKey("ldr_on_ground"))
{
LDR_ON_GROUND = doc["ldr_on_ground"].as<bool>();
}

if (doc.containsKey("button_callback"))
{
BUTTON_CALLBACK = doc["button_callback"].as<String>();
Expand Down Expand Up @@ -436,6 +446,8 @@ String AUTH_PASS = "awtrix";
String BUTTON_CALLBACK = "";
bool SNOW = false;
bool NEWYEAR = false;
bool SWAP_BUTTONS = false;
bool LDR_ON_GROUND = false;
float LDR_GAMMA = 3.0;
float LDR_FACTOR = 1.0;
bool GAME_ACTIVE = false;
2 changes: 2 additions & 0 deletions src/Globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,7 @@ extern String AUTH_PASS;
extern String BUTTON_CALLBACK;
extern bool SNOW;
extern bool NEWYEAR;
extern bool SWAP_BUTTONS;
extern bool LDR_ON_GROUND;
extern bool GAME_ACTIVE;
#endif // Globals_H
7 changes: 5 additions & 2 deletions src/PeripheryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void PeripheryManager_::setup()
button_right.begin();
button_select.begin();

if (ROTATE_SCREEN)
if ((ROTATE_SCREEN && !SWAP_BUTTONS) || (!ROTATE_SCREEN && SWAP_BUTTONS))
{
Serial.println("Button rotation");
button_left.onPressed(right_button_pressed);
Expand Down Expand Up @@ -402,7 +402,8 @@ void PeripheryManager_::setup()
sht31.begin(0x44);

#endif
photocell.setPhotocellPositionOnGround(false);
if (!LDR_ON_GROUND)
photocell.setPhotocellPositionOnGround(false);
}

void PeripheryManager_::tick()
Expand Down Expand Up @@ -500,6 +501,8 @@ void PeripheryManager_::tick()
sampleSum += TotalLDRReadings[i];
}
sampleAverage = sampleSum / (float)LDRReadings;
if (LDR_ON_GROUND)
sampleAverage = 1023.0 - sampleAverage;
LDR_RAW = sampleAverage;
CURRENT_LUX = (roundf(photocell.getSmoothedLux() * 1000) / 1000);
if (AUTO_BRIGHTNESS && !MATRIX_OFF)
Expand Down