Skip to content

Commit

Permalink
Reformating
Browse files Browse the repository at this point in the history
  • Loading branch information
FredM67 committed May 13, 2023
1 parent ca16002 commit 995b88b
Show file tree
Hide file tree
Showing 12 changed files with 525 additions and 444 deletions.
192 changes: 187 additions & 5 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,8 +1,190 @@
# Format Style Options - Created with Clang Power Tools
# Source: https://github.com/arduino/tooling-project-assets/tree/main/other/clang-format-configuration
---
BasedOnStyle: Microsoft
ConstructorInitializerAllOnOneLineOrOnePerLine: true
NamespaceIndentation: All
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignConsecutiveMacros: None
AlignEscapedNewlines: DontAlign
AlignOperands: Align
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: No
AttributeMacros:
- __capability
BasedOnStyle: LLVM
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterJavaFieldAnnotations: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Attach
BreakBeforeConceptDeclarations: false
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakConstructorInitializersBeforeComma: false
BreakInheritanceList: BeforeColon
BreakStringLiterals: false
ColumnLimit: 0
CommentPragmas: ''
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DeriveLineEnding: true
DerivePointerAlignment: true
DisableFormat: false
EmptyLineAfterAccessModifier: Leave
EmptyLineBeforeAccessModifier: Leave
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: false
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: ''
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: true
IndentCaseLabels: true
IndentExternBlock: Indent
IndentGotoLabels: false
IndentPPDirectives: None
IndentRequires: true
IndentWidth: 2
...
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
Language: Cpp
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 100000
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PPIndentWidth: -1
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 1
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 1
PenaltyBreakFirstLessLess: 1
PenaltyBreakOpenParenthesis: 1
PenaltyBreakString: 1
PenaltyBreakTemplateDeclaration: 1
PenaltyExcessCharacter: 1
PenaltyIndentedWhitespace: 1
PenaltyReturnTypeOnItsOwnLine: 1
PointerAlignment: Right
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: false
RemoveBracesLLVM: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 0
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Leave
SpacesInCStyleCastParentheses: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInLineCommentPrefix:
Minimum: 0
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 2
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
28 changes: 14 additions & 14 deletions Mk2_3phase_RFdatalog_temp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,32 @@ inline constexpr bool DUAL_TARIFF{ false }; /**< set it to 'true' if th
// D12 is MISO
// D13 is SCK

inline constexpr uint8_t physicalLoadPin[NO_OF_DUMPLOADS]{ 5, 6, 7 }; /**< for 3-phase PCB, Load #1/#2/#3 (Rev 2 PCB) */
inline uint8_t loadPrioritiesAndState[NO_OF_DUMPLOADS]{ 0, 1, 2 }; /**< load priorities and states at startup */
inline constexpr uint8_t physicalLoadPin[NO_OF_DUMPLOADS]{ 5, 6, 7 }; /**< for 3-phase PCB, Load #1/#2/#3 (Rev 2 PCB) */
inline uint8_t loadPrioritiesAndState[NO_OF_DUMPLOADS]{ 0, 1, 2 }; /**< load priorities and states at startup */

inline constexpr uint8_t relayPin{ 0xff }; /**< for 3-phase PCB, relay trigger */
inline constexpr uint8_t dualTariffPin{ 0xff }; /**< for 3-phase PCB, off-peak trigger */
inline constexpr uint8_t diversionPin{ 0xff }; /**< if LOW, set diversion on standby */
inline constexpr uint8_t rotationPin{ 0xff }; /**< if LOW, trigger a load priority rotation */
inline constexpr uint8_t forcePin{ 0xff }; /**< for 3-phase PCB, force pin */
inline constexpr uint8_t watchDogPin{ 0xff }; /**< watch dog LED */
inline constexpr uint8_t relayPin{ 0xff }; /**< for 3-phase PCB, relay trigger */
inline constexpr uint8_t dualTariffPin{ 0xff }; /**< for 3-phase PCB, off-peak trigger */
inline constexpr uint8_t diversionPin{ 0xff }; /**< if LOW, set diversion on standby */
inline constexpr uint8_t rotationPin{ 0xff }; /**< if LOW, trigger a load priority rotation */
inline constexpr uint8_t forcePin{ 0xff }; /**< for 3-phase PCB, force pin */
inline constexpr uint8_t watchDogPin{ 0xff }; /**< watch dog LED */

inline constexpr uint8_t tempSensorPin{ 0xff }; /**< for 3-phase PCB, sensor pin */
inline constexpr uint8_t tempSensorPin{ 0xff }; /**< for 3-phase PCB, sensor pin */

inline relayOutput relay_Output{ relayPin }; /**< config for relay diversion, see class definition for defaults */
inline relayOutput relay_Output{ relayPin }; /**< config for relay diversion, see class definition for defaults */

inline constexpr uint8_t ul_OFF_PEAK_DURATION{ 8 }; /**< Duration of the off-peak period in hours */
inline constexpr pairForceLoad rg_ForceLoad[NO_OF_DUMPLOADS]{ { -3, 2 } }; /**< force config for load #1 ONLY for dual tariff */

inline constexpr int16_t iTemperatureThreshold{ 100 }; /**< the temperature threshold to stop overriding in °C */
inline constexpr int16_t iTemperatureThreshold{ 100 }; /**< the temperature threshold to stop overriding in °C */

inline constexpr DeviceAddress sensorAddrs[]{ { 0x28, 0xBE, 0x41, 0x6B, 0x09, 0x00, 0x00, 0xA4 },
{ 0x28, 0xED, 0x5B, 0x6A, 0x09, 0x00, 0x00, 0x9D },
{ 0x28, 0xDB, 0x6D, 0x6A, 0x09, 0x00, 0x00, 0xDA },
{ 0x28, 0x59, 0x1F, 0x6A, 0x09, 0x00, 0x00, 0xB0 },
{ 0x28, 0x1B, 0xD7, 0x6A, 0x09, 0x00, 0x00, 0xB7 } }; /**< list of temperature sensor Addresses */

inline constexpr uint32_t ROTATION_AFTER_CYCLES{ 8UL * 3600UL * SUPPLY_FREQUENCY }; /**< rotates load priorities after this period of inactivity */
inline constexpr uint32_t ROTATION_AFTER_CYCLES{ 8UL * 3600UL * SUPPLY_FREQUENCY }; /**< rotates load priorities after this period of inactivity */

/* --------------------------------------
RF configuration (for the RFM12B module)
Expand All @@ -114,6 +114,6 @@ inline constexpr int nodeID{ 10 }; /**< RFM12B node ID */
inline constexpr int networkGroup{ 210 }; /**< wireless network group - needs to be same for all nodes */
inline constexpr int UNO{ 1 }; /**< for when the processor contains the UNO bootloader. */

#endif // RF_PRESENT
#endif // RF_PRESENT

#endif // _CONFIG_H
#endif // _CONFIG_H
4 changes: 2 additions & 2 deletions Mk2_3phase_RFdatalog_temp/config_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ inline constexpr int16_t REQUIRED_EXPORT_IN_WATTS{ 20 }; /**< when set to a nega

//--------------------------------------------------------------------------------------------------
// other system constants, should match most of installations
inline constexpr uint8_t SUPPLY_FREQUENCY{ 50 }; /**< number of cycles/s of the grid power supply */
inline constexpr uint8_t SUPPLY_FREQUENCY{ 50 }; /**< number of cycles/s of the grid power supply */

inline constexpr uint8_t DATALOG_PERIOD_IN_SECONDS{ 5 }; /**< Period of datalogging in seconds */
inline constexpr uint16_t DATALOG_PERIOD_IN_MAINS_CYCLES{ DATALOG_PERIOD_IN_SECONDS * SUPPLY_FREQUENCY }; /**< Period of datalogging in cycles */
//--------------------------------------------------------------------------------------------------

#endif // __CONFIG_SYSTEM_H__
#endif // __CONFIG_SYSTEM_H__
2 changes: 1 addition & 1 deletion Mk2_3phase_RFdatalog_temp/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void loop()
static bool bOffPeak{ false };
static int16_t iTemperature_x100{ 0 };

if (b_newMainsCycle) // flag is set after every pair of ADC conversions
if (b_newMainsCycle) // flag is set after every pair of ADC conversions
{
b_newMainsCycle = false; // reset the flag
++perSecondTimer;
Expand Down
2 changes: 1 addition & 1 deletion Mk2_3phase_RFdatalog_temp/processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include <Arduino.h>

#include "calibration.h"
#include "dualtariff.h"
#include "processing.h"
#include "utils_pins.h"
#include "dualtariff.h"

/*!
* @defgroup TimeCritical Time critical functions Group
Expand Down
4 changes: 2 additions & 2 deletions Mk2_3phase_RFdatalog_temp/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ template< uint8_t N = 3, uint8_t S = 0 > class PayloadTx_struct
* @tparam _Tp elements type
* @tparam _Nm dimension
*/
template< typename _Tp, size_t _Nm > constexpr size_t size(const _Tp (& /*__array*/)[_Nm]) noexcept
template< typename _Tp, size_t _Nm > constexpr size_t size(const _Tp (&/*__array*/)[_Nm]) noexcept
{
return _Nm;
}
Expand All @@ -83,7 +83,7 @@ template< typename _Tp, size_t _Nm > constexpr size_t size(const _Tp (& /*__arra
*
* @tparam _Tp elements type
*/
template< typename _Tp > constexpr size_t size(const _Tp (& /*__array*/)[0]) noexcept
template< typename _Tp > constexpr size_t size(const _Tp (&/*__array*/)[0]) noexcept
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion Mk2_3phase_RFdatalog_temp/utils_dualtariff.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ class pairForceLoad
uint16_t uiDuration{ UINT16_MAX }; /**< the duration for overriding the load in hours or minutes */
};

#endif // __UTILS_DUALTARIFF_H__
#endif // __UTILS_DUALTARIFF_H__
2 changes: 1 addition & 1 deletion Mk2_3phase_RFdatalog_temp/utils_pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,4 @@ inline bool getPinState(const uint8_t pin)
return (pin < 8) ? bitRead(PIND, pin) : bitRead(PINB, pin - 8);
}

#endif // __UTILS_PINS_H__
#endif // __UTILS_PINS_H__
4 changes: 2 additions & 2 deletions Mk2_3phase_RFdatalog_temp/utils_relay.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ template< uint8_t T = 1 > class relayOutput
const uint16_t minON{ 5 * 60 }; /**< Minimum duration in seconds the relay is turned ON */
const uint16_t minOFF{ 5 * 60 }; /**< Minimum duration in seconds the relay is turned OFF */

uint16_t duration{ 0 }; /**< Duration of the current state */
bool relayState{ false }; /**< State of the relay */
uint16_t duration{ 0 }; /**< Duration of the current state */
bool relayState{ false }; /**< State of the relay */

static inline movingAvg< int16_t, T * 60 / DATALOG_PERIOD_IN_SECONDS > sliding_Average;
};
Expand Down
Loading

0 comments on commit 995b88b

Please sign in to comment.