Change analogWrite to ledcWrite, configuration improvements
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#pragma once
|
||||
|
||||
#include <Preferences.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <variant>
|
||||
@@ -45,8 +44,8 @@ static const ConfigDef configdefs[] = {
|
||||
{"apMask", ConfigType::STRING, String("255.255.255.0")},
|
||||
{"stopApTime", ConfigType::SHORT, int16_t(0)},
|
||||
{"cpuSpeed", ConfigType::SHORT, int16_t(160)},
|
||||
{"ledBrightness", ConfigType::BYTE, uint8_t(96)},
|
||||
{"ledRgbBrightness", ConfigType::BYTE, uint8_t(96)},
|
||||
{"ledBrightness", ConfigType::SHORT, int16_t(96)},
|
||||
{"ledRgbBrightness", ConfigType::SHORT, int16_t(96)},
|
||||
{"tempFormat", ConfigType::CHAR, 'C'},
|
||||
{"switchBank", ConfigType::BYTE, uint8_t(0)},
|
||||
{"key1", ConfigType::BYTE, uint8_t(1)},
|
||||
@@ -76,6 +75,7 @@ private:
|
||||
Preferences& prefs;
|
||||
std::map<String, ConfigValue> values;
|
||||
std::map<String, const ConfigDef*> defs;
|
||||
[[noreturn]] void error_abort() const;
|
||||
public:
|
||||
explicit Config(Preferences& prefs);
|
||||
void load();
|
||||
@@ -92,4 +92,8 @@ public:
|
||||
float getFloat(const char* key) const;
|
||||
char getChar(const char* key) const;
|
||||
const String& getString(const char* key) const;
|
||||
const char* getCString(const char* key) const;
|
||||
|
||||
};
|
||||
|
||||
extern Config config;
|
||||
|
||||
4
include/hash.h
Normal file
4
include/hash.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
|
||||
String get_sha256(String payload);
|
||||
8
include/led.h
Normal file
8
include/led.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
extern int16_t led_brightness;
|
||||
extern int16_t rgb_brightness;
|
||||
|
||||
void led_init();
|
||||
void led_test();
|
||||
void led_blink(uint8_t channel, uint8_t count, int16_t brightness, uint32_t interval_ms);
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include "Nmea2kTwai.h"
|
||||
#include "N2kDeviceList.h"
|
||||
|
||||
#define STRINGIFY_IMPL(x) #x
|
||||
#define STRINGIFY(x) STRINGIFY_IMPL(x)
|
||||
@@ -40,11 +42,23 @@
|
||||
#define KEY_6 GPIO_NUM_10 // D7
|
||||
#define KEY_DST GPIO_NUM_17 // D8
|
||||
|
||||
// LEDC / PWM channels
|
||||
#define LEDC_BUZZER 0
|
||||
#define LEDC_LED_A 1
|
||||
#define LEDC_LED_B 2
|
||||
#define LEDC_LED_C 3
|
||||
#define LEDC_RGBLED_R 4
|
||||
#define LEDC_RGBLED_G 5
|
||||
#define LEDC_RGBLED_B 6
|
||||
|
||||
#define LEDC_BASE_FREQ 5000
|
||||
#define LEDC_RES_BUZZER 8 // 8bit: 0..255
|
||||
#define LEDC_RES_LED 12 // 12bit: 0..4095
|
||||
|
||||
// #define LEDC_TIMER_8_BIT 8
|
||||
|
||||
// Buzzer
|
||||
#define BUZZER GPIO_NUM_43 // TX
|
||||
#define LEDC_CHANNEL 0
|
||||
#define LEDC_TIMER_8_BIT 8
|
||||
#define LEDC_BASE_FREQ 5000
|
||||
|
||||
// LEDS
|
||||
#define LED_A GPIO_NUM_3 // A2
|
||||
@@ -99,13 +113,17 @@ struct ButtonEvent {
|
||||
ButtonPressType pressType;
|
||||
};
|
||||
|
||||
extern Nmea2kTwai &NMEA2000;
|
||||
extern tN2kDeviceList *pN2kDeviceList;
|
||||
|
||||
extern char globalmode;
|
||||
|
||||
extern uint64_t chipid;
|
||||
extern uint8_t led_brightness;
|
||||
extern uint8_t rgb_brightness;
|
||||
extern int16_t led_brightness;
|
||||
extern int16_t rgb_brightness;
|
||||
extern uint8_t keycode[6];
|
||||
extern uint8_t longcode[6];
|
||||
|
||||
extern float temp;
|
||||
extern float hum;
|
||||
|
||||
String uptime_with_unit();
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
extern AsyncWebServer server;
|
||||
|
||||
Reference in New Issue
Block a user