mirror of
https://github.com/xoseperez/espurna.git
synced 2026-02-20 09:41:35 +01:00
Page:
CodingStyle
Pages
3rd Party Plugins
Adding Custom IR Codes
Alexa
ArduinoIDE
Arilux LC12
Avatar Controls Smart Stecker EU
Backup
Binaries
Build and update from Visual Studio Code using PlatformIO
Buttons and switches
CodingStyle
Configuration
Contributions
Domoticz
Espurna OTA Manager
Firmware
Geiger Counter
Hardware AG L4
Hardware AI Thinker AI Light
Hardware Arilux AL LC06
Hardware Arilux AL LCxx
Hardware Arilux E27
Hardware Arniex Swifitch
Hardware Autohometion LYT8266
Hardware BLITZWOLF BW SHP2
Hardware Bakibo 9W E27 RGB CCT bulb
Hardware Bestek MRJ1011
Hardware EXS WiFi Relay v3.1
Hardware Electrodragon ESP Relay Board
Hardware Generic DHT11 v10
Hardware Generic DS18B20 v10
Hardware Generic ECH1560
Hardware Generic RGBLed v10
Hardware Generic Relay v40
Hardware Generic V9261F
Hardware Gosund SP111
Hardware Gosund WP3
Hardware Green ESP8266 Relay
Hardware HEYGO HY02
Hardware Hama WiFi Steckdose, 3.500W, 16A (Article Number 00176533)
Hardware Heltec Touch Relay
Hardware Huacanxing H80x
Hardware IKE ESPike
Hardware IWOOLE_LED_TABLE_LAMP
Hardware Itead 1CH
Hardware Itead BN SZ01
Hardware Itead Motor
Hardware Itead S20
Hardware Itead S26
Hardware Itead SV
Hardware Itead Slampher v2
Hardware Itead Slampher
Hardware Itead Sonoff 4CH Pro R2
Hardware Itead Sonoff 4CH
Hardware Itead Sonoff B1
Hardware Itead Sonoff Basic
Hardware Itead Sonoff Dual
Hardware Itead Sonoff LED
Hardware Itead Sonoff POW R2
Hardware Itead Sonoff POW
Hardware Itead Sonoff RF Bridge Direct Hack
Hardware Itead Sonoff RF Bridge
Hardware Itead Sonoff RF
Hardware Itead Sonoff S31
Hardware Itead Sonoff T1
Hardware Itead Sonoff TH
Hardware Itead Sonoff Touch
Hardware JINVOO VALVE SM AW713
Hardware Jan Goedeke Wifi Relay Board
Hardware Jorge Garcia Wifi Relay Board
Hardware KMC 70011
Hardware LINGAN SWA1
Hardware LSC Smart LED Light Strip
Hardware Lampi RGBWW Battery Powered Smart Light
Hardware Linksprite Linknode R4
Hardware Litesun LA WF7
Hardware Lombex Lux Nova
Hardware Magic Home LED Controller
Hardware Magic Home Light bulbs
Hardware ManCaveMade ESPLive
Hardware Maxcio W DE004
Hardware Maxcio W US002S
Hardware Muvit IO miobulb001
Hardware NEO COOLCAM NAS WR01W
Hardware NodeMCU Lolin
Hardware OBI Euromate Wifi Plug v2
Hardware OBI Euromate Wifi Plug
Hardware OpenEnergyMonitor Wifi MQTT Relay
Hardware Orvibo B25
Hardware QuinLED
Hardware TUYA in line dimmer
Hardware Teckin SP22 v1.4 and v1.6
Hardware Tinkerman ESPurna H
Hardware Tonbux Mosquito Killer
Hardware Tonbux Powerstrip02
Hardware Tonbux XS SSA06
Hardware Twakie Smart Plug
Hardware Wemos D1 Mini Relay Shield
Hardware WiOn 50055
Hardware Witty Cloud
Hardware WorkChoice EcoPlug
Hardware Xenon SM PW 702U
Hardware YT E002
Hardware YiDian XS SSA05
Hardware Zhilde ZLD 44EU W
Hardware Zhilde ZLD 64EU W
Hardware
Home
HomeAssistant
IR
InfluxDB
LED
Lights
MQTT
NTP
OTA TUYA
OTA flashing of virgin Itead Sonoff devices
OTA
Other Devices Unsupported
PWM
PlatformIO
Posts & Videos
Prometheus
PullRequests
RESTAPI
RFBRIDGE
RPN Rules
SCHEDULER
Sensor PZEM004T
Sensors
SensorsConfiguration
Software features
Telnet
Terminal
Thingspeak
Troubleshooting
TwoStepUpdates
WebInterface
WiFi
mDNS
Clone
3
CodingStyle
Maxim Prokhorov edited this page 2020-06-18 20:27:04 +03:00
Table of Contents
Coding style
- Current style follows closely (but not fully) the WebKitCode Style Guidelines
- This project uses 4 space indentation, not tabs.
- Function definitions and
if/for/whilestarting bracket is in the same line:
int _domoticzRelay(unsigned int idx) {
[...]
}
- One-line control clauses should use braces:
do {
if (something) {
break;
}
[...]
} while (blah);
if (...) return; can sometimes be an exception, where it is the only expression.
- Class names are UpperCamelCased
class DigitalSensor : public BaseSensor {
[...]
}
- Method names are lowerCamelCased:
int buttonFromRelay(unsigned int relay_id) {
[...]
}
- Constants (Enumerations,
const,constexpr const) should be UpperCamelCased:
constexpr const size_t ValuesMax = 5;
enum class Colors {
Red,
Green,
Blue
};
- Variables should be underscored_lower_case (I know, I don't always follow this rule myself - in many cases they are also lowerCamelCased):
// Preferred:
bool delete_flag = false;
// Less preferred:
unsigned long rfCodeON = 0;
- Private methods and variables (even if private to the module they are declared on) are prefixed with an underscore (
_):
bool _dcz_enabled = false;
int _domoticzRelay(unsigned int idx) {
[...]
}
- Prefer
static_cast<T>(...)andreinterpret_cast<T>(...)over C-style casts. - When creating a new subclass of a class that contains virtual methods (like
BaseSensor,BasePinetc.), it should specifyoverridekeyword when overriding virtual methods.
TODO: clang-format
Current style does not always match what .clang-format might generate.
Linting
Code is checked using cppcheck.
I know current code does not always follow these rules. I'm fixing it as I rework each of the modules.
Getting started
- Backup the stock firmware
- Flash a pre-built binary image
- Flash a virgin Itead Sonoff device without opening
- Flash TUYA-based device without opening
- Flash Shelly device without opening
- Using PlatformIO
- from Visual Studio Code
- Using Arduino IDE
- Build the Web Interface
- Over-the-air updates
- Two-step updates
- ESPurna OTA Manager
- NoFUSS
- Troubleshooting
Supported hardware and options
Configuration
Integrations
- MQTT
- REST API
- Domoticz
- Home Assistant
- InfluxDB
- Prometheus metrics
- Thingspeak
- Alexa
- Google Home
Network
Developers
- Architecture
- 3rd Party Plugins
- Coding style
- Pull Requests
More around ESPurna
Support
If you're looking for support:
- Issues: this is the most dynamic channel at the moment, you might find an answer to your question by searching open or closed issues.
- Wiki pages: might not be as up-to-date as we all would like (hey, you can also contribute in the documentation!).
- Gitter channel: you have better chances to get fast answers from project contributors or other ESPurna users. (also available with any Matrix client!)
- Issue a question: as a last resort, you can open new question issue on GitHub. Just remember: the more info you provide the more chances you'll have to get an accurate answer.