Skip to content

Commit

Permalink
Refactor: clang-tidy compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierBrassoud committed Mar 7, 2024
1 parent 542ff89 commit 24ca8df
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 183 deletions.
32 changes: 32 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
Checks: "
-*,
clang-diagnostic-*,
clang-analyzer-*,
bugprone-*,
cert-*-c,
misc-*,
performance-*,
portability-*,
readability-*,
modernize-*,
-modernize-use-trailing-return-type
"
WarningsAsErrors: ''
AnalyzeTemporaryDtors: false
FormatStyle: file

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 }
3 changes: 2 additions & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ jobs:

- uses: cpp-linter/cpp-linter-action@v2
with:
style: file
style: 'file' # Use .clang-format config file
tidy-checks: '' # Use .clang-tidy config file
files-changed-only: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78 changes: 41 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Library to repurposing the control panel (PNL CE02) of EPSON XP 520/530/540 prin
- [Let's play!](#lets-play)
- [Using display](#using-display)
- [Library documentation](#library-documentation)
- [Epson\_PNL\_CE02\_Pinout Struct](#epson_pnl_ce02_pinout-struct)
- [Epson\_PNL\_CE02 Class](#epson_pnl_ce02-class)
- [Constructor](#constructor)
- [Functions](#functions)
Expand Down Expand Up @@ -81,20 +82,19 @@ Happy hacking!
``` c++
#include <Epson_PNL_CE02.h>

enum
{
Epson_PNL_CE02_Pinout pinout = {
/* Control panel to Arduino pinout */
EXTENDER_OE = 45, // FFC 1
SERIAL_OUT = 50, // SPI MISO / FFC 2
POWER_BUTTON = 46, // FFC 4
LCD_RESET = 47, // FFC 6
CLOCK = 52, // SPI SCK / FFC 9
SERIAL_IN = 51, // SPI MOSI / FFC 10
LATCH = 48, // FFC 11
LCD_WRITE = 49, // FFC 13
.EXTENDER_OE = 45, // FFC 1
.SERIAL_OUT = 50, // SPI MISO / FFC 2
.POWER_BUTTON = 46, // FFC 4
.LCD_RESET = 47, // FFC 6
.CLOCK = 52, // SPI SCK / FFC 9
.SERIAL_IN = 51, // SPI MOSI / FFC 10
.LATCH = 48, // FFC 11
.LCD_WRITE = 49, // FFC 13
};

Epson_PNL_CE02 controlPanel(EXTENDER_OE, SERIAL_OUT, POWER_BUTTON, LCD_RESET, CLOCK, SERIAL_IN, LATCH, LCD_WRITE);
Epson_PNL_CE02 controlPanel(&pinout);

void setup()
{
Expand All @@ -106,11 +106,11 @@ void loop()
{
switch (controlPanel.readButtons())
{
case OK:
case ButtonMask::OK:
Serial.println("Button OK pressed!");
break;
case OK | HOME:
Serial.println("Button OK and button LEFT pressed!");
case ButtonMask::OK | ButtonMask::HOME:
Serial.println("Button OK and button HOME pressed!");
break;
}

Expand Down Expand Up @@ -161,20 +161,19 @@ Here is an adaptation using [MCUFRIEND_kbv](https://github.com/prenticedavid/MCU
#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>

enum
{
Epson_PNL_CE02_Pinout pinout = {
/* Control panel to Arduino pinout */
EXTENDER_OE = 45, // FFC 1
SERIAL_OUT = 50, // SPI MISO / FFC 2
POWER_BUTTON = 46, // FFC 4
LCD_RESET = 47, // FFC 6
CLOCK = 52, // SPI SCK / FFC 9
SERIAL_IN = 51, // SPI MOSI / FFC 10
LATCH = 48, // FFC 11
LCD_WRITE = 49, // FFC 13
.EXTENDER_OE = 45, // FFC 1
.SERIAL_OUT = 50, // SPI MISO / FFC 2
.POWER_BUTTON = 46, // FFC 4
.LCD_RESET = 47, // FFC 6
.CLOCK = 52, // SPI SCK / FFC 9
.SERIAL_IN = 51, // SPI MOSI / FFC 10
.LATCH = 48, // FFC 11
.LCD_WRITE = 49, // FFC 13
};

Epson_PNL_CE02 controlPanel(EXTENDER_OE, SERIAL_OUT, POWER_BUTTON, LCD_RESET, CLOCK, SERIAL_IN, LATCH, LCD_WRITE);
Epson_PNL_CE02 controlPanel(&pinout);

MCUFRIEND_kbv tft;

Expand All @@ -183,10 +182,10 @@ void setup()
controlPanel.begin();

// STEP 1: Turn display ON
controlPanel.extenderWrite(LCD_BACKLIGHT, HIGH);
controlPanel.extenderWrite(ExtenderPin::LCD_BACKLIGHT, HIGH);

// STEP 2: INIT display
tft.begin(0x9163); // ILI9163C
tft.begin(0x9163); // Force ILI9163C as the control panel wired the display in write-only mode

// STEP 3: Use display
tft.fillScreen(TFT_RED);
Expand All @@ -204,21 +203,26 @@ void loop()
## Library documentation
### Epson_PNL_CE02_Pinout Struct
| Member | Pin | Description |
| ---------------- | --- | ---------------------------------------------------------------------- |
| `EXTENDER_OE` | #1 | Extender output enable pin. Unused. |
| `SERIAL_OUT` | #2 | Serial output pin. Read value for buttons. (SPI MISO) |
| `POWER_BUTTON` | #4 | Dedicated pin for the power button. |
| `LCD_RESET` | #6 | Display reset pin. Refer to ["Using display"](#using-display) section. |
| `CLOCK` | #9 | Shared clock pin for extender, buttons and display. (SPI SCK) |
| `SERIAL_IN` | #10 | Serial input pin. Write value in extender. (SPI MOSI) |
| `LATCH` | #11 | Write extender selector. |
| `LCD_WRITE` | #13 | Display write pin. Refer to ["Using display"](#using-display) section. |
### Epson_PNL_CE02 Class
#### Constructor
| Parameter | Description |
| ---------------- | ------------------------------------------------------------- |
| `oePin` | Extender output enable pin. Unused. |
| `serOutPin` | Serial output pin. Read value for buttons. (SPI MISO) |
| `powerButtonPin` | Dedicated pin for the power button. |
| `lcdResetPin` | Display reset pin. |
| `clockPin` | Shared clock pin for extender, buttons and display. (SPI SCK) |
| `serInPin` | Serial input pin. Write value in extender. (SPI MOSI) |
| `latchPin` | Write extender selector. |
| `lcdWritePin` | Display write pin. |
| Parameter | Description |
| ---------------- | ---------------------------------------------------------------------- |
| `pPinout` | Reference to [`Epson_PNL_CE02_Pinout`](#epson_pnl_ce02_pinout-struct). |
#### Functions
Expand Down
2 changes: 1 addition & 1 deletion REVERSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ We can identify 3 components, from left to right:

## Identifying display

This was the hard part of this project. The only reference was GIANTPLUS printed on the flex ribbon cable of the screen. After hours of searching, I can't identify this screen.
This was the hard part of this project. The only reference was "307328101 GIANTPLUS 1526" printed on the flex ribbon cable of the screen. After hours of searching, I can't identify this screen.

The deducted information was:
* the 8-bit parallel interface wired through the VHC164
Expand Down
Binary file modified docs/pcb_layers.xcf
Binary file not shown.
25 changes: 12 additions & 13 deletions examples/blink/blink.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@

#include <Epson_PNL_CE02.h>

enum
{
Epson_PNL_CE02_Pinout pinout = {
/* Control panel to Arduino pinout */
EXTENDER_OE = 45, // FFC 1
SERIAL_OUT = 50, // SPI MISO / FFC 2
POWER_BUTTON = 46, // FFC 4
LCD_RESET = 47, // FFC 6
CLOCK = 52, // SPI SCK / FFC 9
SERIAL_IN = 51, // SPI MOSI / FFC 10
LATCH = 48, // FFC 11
LCD_WRITE = 49, // FFC 13
.EXTENDER_OE = 45, // FFC 1
.SERIAL_OUT = 50, // SPI MISO / FFC 2
.POWER_BUTTON = 46, // FFC 4
.LCD_RESET = 47, // FFC 6
.CLOCK = 52, // SPI SCK / FFC 9
.SERIAL_IN = 51, // SPI MOSI / FFC 10
.LATCH = 48, // FFC 11
.LCD_WRITE = 49, // FFC 13
};

Epson_PNL_CE02 controlPanel(EXTENDER_OE, SERIAL_OUT, POWER_BUTTON, LCD_RESET, CLOCK, SERIAL_IN, LATCH, LCD_WRITE);
Epson_PNL_CE02 controlPanel(&pinout);

void setup()
{
Expand All @@ -52,12 +51,12 @@ void setup()
void loop()
{
// turns ON power LED (active LOW)
controlPanel.extenderWrite(POWER_LED, LOW);
controlPanel.extenderWrite(ExtenderPin::POWER_LED, LOW);

delay(1000);

// turns OFF power LED
controlPanel.extenderWrite(POWER_LED, HIGH);
controlPanel.extenderWrite(ExtenderPin::POWER_LED, HIGH);

delay(1000);
}
25 changes: 12 additions & 13 deletions examples/buttons/buttons.ino
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,19 @@

#include <Epson_PNL_CE02.h>

enum
{
Epson_PNL_CE02_Pinout pinout = {
/* Control panel to Arduino pinout */
EXTENDER_OE = 45, // FFC 1
SERIAL_OUT = 50, // SPI MISO / FFC 2
POWER_BUTTON = 46, // FFC 4
LCD_RESET = 47, // FFC 6
CLOCK = 52, // SPI SCK / FFC 9
SERIAL_IN = 51, // SPI MOSI / FFC 10
LATCH = 48, // FFC 11
LCD_WRITE = 49, // FFC 13
.EXTENDER_OE = 45, // FFC 1
.SERIAL_OUT = 50, // SPI MISO / FFC 2
.POWER_BUTTON = 46, // FFC 4
.LCD_RESET = 47, // FFC 6
.CLOCK = 52, // SPI SCK / FFC 9
.SERIAL_IN = 51, // SPI MOSI / FFC 10
.LATCH = 48, // FFC 11
.LCD_WRITE = 49, // FFC 13
};

Epson_PNL_CE02 controlPanel(EXTENDER_OE, SERIAL_OUT, POWER_BUTTON, LCD_RESET, CLOCK, SERIAL_IN, LATCH, LCD_WRITE);
Epson_PNL_CE02 controlPanel(&pinout);

void setup()
{
Expand All @@ -61,10 +60,10 @@ void loop()
{
switch (controlPanel.readButtons())
{
case OK:
case ButtonMask::OK:
Serial.println("Button OK pressed!");
break;
case OK | HOME:
case ButtonMask::OK | ButtonMask::HOME:
Serial.println("Button OK and button HOME pressed!");
break;
}
Expand Down
23 changes: 11 additions & 12 deletions examples/display/display.ino
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,19 @@
#include <Epson_PNL_CE02.h>

/****************************** Epson_PNL_CE02 *******************************/
enum
{
Epson_PNL_CE02_Pinout pinout = {
/* Control panel to Arduino pinout */
EXTENDER_OE = 45, // FFC 1
SERIAL_OUT = 50, // SPI MISO / FFC 2
POWER_BUTTON = 46, // FFC 4
LCD_RESET = 47, // FFC 6
CLOCK = 52, // SPI SCK / FFC 9
SERIAL_IN = 51, // SPI MOSI / FFC 10
LATCH = 48, // FFC 11
LCD_WRITE = 49, // FFC 13
.EXTENDER_OE = 45, // FFC 1
.SERIAL_OUT = 50, // SPI MISO / FFC 2
.POWER_BUTTON = 46, // FFC 4
.LCD_RESET = 47, // FFC 6
.CLOCK = 52, // SPI SCK / FFC 9
.SERIAL_IN = 51, // SPI MOSI / FFC 10
.LATCH = 48, // FFC 11
.LCD_WRITE = 49, // FFC 13
};

Epson_PNL_CE02 controlPanel(EXTENDER_OE, SERIAL_OUT, POWER_BUTTON, LCD_RESET, CLOCK, SERIAL_IN, LATCH, LCD_WRITE);
Epson_PNL_CE02 controlPanel(&pinout);

/******************************* MCUFRIEND_kbv *******************************/

Expand All @@ -88,7 +87,7 @@ void setup()
controlPanel.begin();

// STEP 1: Turn display ON
controlPanel.extenderWrite(LCD_BACKLIGHT, HIGH);
controlPanel.extenderWrite(ExtenderPin::LCD_BACKLIGHT, HIGH);

// STEP 2: INIT display
tft.begin(0x9163); // Force ILI9163C as the control panel wired the display in write-only mode
Expand Down
Loading

0 comments on commit 24ca8df

Please sign in to comment.