keep the hardcoded pin configurations in one place
This commit is contained in:
parent
d3b4d794c4
commit
8c7e48c856
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
|
||||
#include "wiflash_configure.h"
|
||||
#include "wiflash_pins.h"
|
||||
#include <Preferences.h>
|
||||
|
||||
// ESP logging module
|
||||
|
@ -48,11 +49,11 @@ settings_t settings;
|
|||
*/
|
||||
bool loadConfig() {
|
||||
prefs_.begin("wiflash", false); // open RW;
|
||||
ESP_LOGI(TAG, "Jump pin# %u to GROUND to reset settings.", reset_button);
|
||||
ESP_LOGI(TAG, "Jump pin# %u to GROUND to reset settings.", pin_reset_button);
|
||||
|
||||
pinMode(reset_button, INPUT_PULLUP);
|
||||
pinMode(pin_reset_button, INPUT_PULLUP);
|
||||
if (prefs_.getBool("reset_on_reboot") ||
|
||||
!digitalRead(reset_button)) {
|
||||
!digitalRead(pin_reset_button)) {
|
||||
ESP_LOGI(TAG, "**Reset to default configuration**");
|
||||
prefs_.clear();
|
||||
}
|
||||
|
|
|
@ -28,12 +28,6 @@
|
|||
|
||||
namespace config {
|
||||
|
||||
/*
|
||||
If this pin is tied LOW at setup(), settings will be defaulted
|
||||
*/
|
||||
const uint8_t reset_button = A1; // tie A1 to ground to reset preferances
|
||||
|
||||
|
||||
/*
|
||||
device configuration
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
wiflash_pins.h
|
||||
|
||||
Copyright (c) 2021 Kevin Matz (kevin.matz@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
Hazzah32 battery connected to A13
|
||||
*/
|
||||
const uint8_t pin_battery_sense = A13;
|
||||
|
||||
/*
|
||||
If this pin is tied LOW at setup(), settings will be defaulted
|
||||
*/
|
||||
const uint8_t pin_reset_button = A1; // tie A1 to ground to reset preferances
|
||||
|
||||
/*
|
||||
Attach this pin to an LED for a heartbeat indicator.
|
||||
*/
|
||||
const uint8_t pin_heartbeat_led = LED_BUILTIN;
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "wiflash_status.h"
|
||||
#include "wiflash_configure.h"
|
||||
#include "wiflash_pins.h"
|
||||
|
||||
#include <SPIFFS.h>
|
||||
#include <WiFi.h>
|
||||
|
@ -40,7 +41,7 @@ namespace status {
|
|||
*/
|
||||
float batteryVoltage() {
|
||||
float v;
|
||||
v = analogRead(battery_sense); // 12bit reading
|
||||
v = analogRead(pin_battery_sense); // 12bit reading
|
||||
v /= 4095.0f; // percent of range
|
||||
v *= 2.0f; // doubled
|
||||
v *= 3.3f; // percent of referance voltage
|
||||
|
|
|
@ -26,10 +26,6 @@
|
|||
#include <Arduino.h>
|
||||
|
||||
namespace status {
|
||||
/*
|
||||
Hazzah32 battery connected to A13
|
||||
*/
|
||||
const uint8_t battery_sense = A13;
|
||||
|
||||
String getString(const String& key);
|
||||
float batteryVoltage();
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <ESPAsyncWebServer.h>
|
||||
#include "src/wiflash_configure.h"
|
||||
#include "src/wiflash_status.h"
|
||||
#include "src/wiflash_pins.h"
|
||||
#include "src/lib/libESTA/sacn/receiver-esp.h"
|
||||
#include "src/lib/libESTA/fixture/EspStrobe.h"
|
||||
#include "src/lib/libESTA/fixture/EspRgbStrip.h"
|
||||
|
@ -177,7 +178,7 @@ void setup() {
|
|||
|
||||
//// start fixtures hardware:
|
||||
// battery monitor
|
||||
pinMode(status::battery_sense, INPUT);
|
||||
pinMode(pin_battery_sense, INPUT);
|
||||
|
||||
// button
|
||||
if (config::settings.button_enable) {
|
||||
|
|
Loading…
Reference in New Issue