Skip to content

Commit

Permalink
Fix clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierBrassoud committed Mar 7, 2024
1 parent d1240c6 commit 256c769
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 34 deletions.
46 changes: 30 additions & 16 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
---
Checks: "
Checks: >
-*,
clang-diagnostic-*,
clang-analyzer-*,
bugprone-*,
google-*,
cert-*-c,
misc-*,
performance-*,
portability-*,
readability-*,
modernize-*,
-modernize-use-trailing-return-type
"
WarningsAsErrors: ''
AnalyzeTemporaryDtors: false
FormatStyle: file

HeaderFilterRegex: ''
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.UnionCase, value: CamelCase }
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: camelBack }
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ }
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
- { key: readability-identifier-naming.ConstantCase, value: UPPER_CASE }
- { key: readability-identifier-naming.PointerParameterCase, value: CamelCase }
- { key: readability-identifier-naming.PointerParameterPrefix, value: p }
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.UnionCase
value: CamelCase
- key: readability-identifier-naming.TemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.VariableCase
value: camelBack
- key: readability-identifier-naming.PrivateMemberSuffix
value: _
- key: readability-identifier-naming.ProtectedMemberSuffix
value: _
- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
- key: readability-identifier-naming.ConstantCase
value: UPPER_CASE
- key: readability-identifier-naming.PointerParameterCase
value: CamelCase
- key: readability-identifier-naming.PointerParameterPrefix
value: p
1 change: 0 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ platform = atmelavr
board = megaatmega2560
framework = arduino
check_tool = cppcheck, clangtidy
;check_tool = clangtidy
check_flags =
clangtidy: --config-file=.clang-tidy
monitor_speed = 115200
Expand Down
26 changes: 14 additions & 12 deletions src/Epson_PNL_CE02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,29 @@ const char *buttonName(ButtonMask mask)
// cppcheck-suppress unusedFunction
bool isButtonPressed(byte sequence, ButtonMask mask)
{
return (sequence & (byte)mask) != 0; // Check if key pressed 0000{key}000, key>0 if set
return (sequence & static_cast<byte>(mask)) != 0; // Check if key pressed 0000{key}000, key>0 if set
}

// CTOR
Epson_PNL_CE02::Epson_PNL_CE02(Epson_PNL_CE02_Pinout *pPinout) : pins(pPinout) {}
Epson_PNL_CE02::Epson_PNL_CE02(Epson_PNL_CE02_Pinout *pPinout) : pins(pPinout)
{
}

// PUBLICS
void Epson_PNL_CE02::begin() const
{
pinMode(pins->power_button, INPUT);
pinMode(pins->POWER_BUTTON, INPUT);

pinMode(pins->extender_oe, OUTPUT);
pinMode(pins->latch, OUTPUT);
pinMode(pins->clock, OUTPUT);
pinMode(pins->serial_in, OUTPUT);
pinMode(pins->serial_out, INPUT);
pinMode(pins->EXTENDER_OE, OUTPUT);
pinMode(pins->LATCH, OUTPUT);
pinMode(pins->CLOCK, OUTPUT);
pinMode(pins->SERIAL_IN, OUTPUT);
pinMode(pins->SERIAL_OUT, INPUT);

SPIClass::begin();
SPIClass::beginTransaction(SPISettings(F_CPU / 2, MSBFIRST, SPI_MODE0)); // Max SPI speed

digitalWrite(pins->extender_oe, LOW);
digitalWrite(pins->EXTENDER_OE, LOW);
}

// cppcheck-suppress unusedFunction
Expand All @@ -114,17 +116,17 @@ byte Epson_PNL_CE02::readButtons()
// cppcheck-suppress unusedFunction
bool Epson_PNL_CE02::isPowerButtonPressed() const
{
return digitalRead(pins->power_button) == LOW;
return digitalRead(pins->POWER_BUTTON) == LOW;
}

// PRIVATES
byte Epson_PNL_CE02::synchronize() const
{
// STEP 1: Send control information (Power LED, LCD backlight, LCD CS, LCD D/C) through 74HC595
digitalWrite(pins->latch, LOW); // enables parallel inputs
digitalWrite(pins->LATCH, LOW); // enables parallel inputs
SPIClass::transfer(buffer);
// STEP 2: Receive buttons inputs through 74LV165A
digitalWrite(pins->latch, HIGH); // disable parallel inputs and enable serial output
digitalWrite(pins->LATCH, HIGH); // disable parallel inputs and enable serial output

const byte FULL_MASK = 0b11111111;
return FULL_MASK ^ SPIClass::transfer(FULL_MASK); // read buttons (invert cause output is HIGH)
Expand Down
11 changes: 6 additions & 5 deletions src/Epson_PNL_CE02.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/**
* @brief Buttons 8-bit mapping.
*/
enum class ButtonMask : byte
enum class ButtonMask : byte // NOLINT(readability-identifier-naming): Bug clangtidy v15: enum detected as variable
{
RIGHT = 0b10000000, // 0b11111110
OK = 0b01000000, // 0b11111101
Expand All @@ -60,7 +60,7 @@ enum class ButtonMask : byte
/**
* @brief Shift register pins (VHC595)
*/
enum class ExtenderPin : byte
enum class ExtenderPin : byte // NOLINT(readability-identifier-naming): Bug clangtidy v15: enum detected as variable
{
/**
* @brief Control the state of the power led (active LOW).
Expand Down Expand Up @@ -103,9 +103,10 @@ bool isButtonPressed(byte sequence, ButtonMask mask);

/**
* @brief Control panel to Arduino pinout.
*
*
*/
struct Epson_PNL_CE02_Pinout {
struct Epson_PNL_CE02_Pinout
{

/**
* @brief [UNUSED] Extender output enable pin.
Expand Down Expand Up @@ -172,7 +173,7 @@ struct Epson_PNL_CE02_Pinout {
* }
* ```
*/
class Epson_PNL_CE02
class Epson_PNL_CE02 // NOLINT(readability-identifier-naming): Exception to follow common Arduino Library style naming
{

public:
Expand Down

0 comments on commit 256c769

Please sign in to comment.