Skip to content

Commit

Permalink
ci(push): add lint and tidy steps
Browse files Browse the repository at this point in the history
  • Loading branch information
b4nst committed Aug 17, 2023
1 parent 4fc62a9 commit f3d03cb
Show file tree
Hide file tree
Showing 8 changed files with 411 additions and 22 deletions.
366 changes: 366 additions & 0 deletions .clang-tidy

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ jobs:
run: make
- name: test
run: test -f build/polyboard.syx
- name: lint
run: make lint
- name: tidy
run: make tidy
7 changes: 5 additions & 2 deletions include/app.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef LAUNCHPAD_APP_H
#define LAUNCHPAD_APP_H
#ifndef APP_H
#define APP_H

/******************************************************************************
Expand Down Expand Up @@ -33,6 +33,8 @@
*****************************************************************************/

// NOLINTBEGIN

// ____________________________________________________________________________
//
// Don't modify this file! This declares the binary interface to the library,
Expand Down Expand Up @@ -249,4 +251,5 @@ void app_surface_event(u8 type, u8 index, u8 value);
*/
void app_aftertouch_event(u8 index, u8 value);

// NOLINTEND
#endif
4 changes: 2 additions & 2 deletions include/app_defs.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

#ifndef APP_TYPES_H
#define APP_TYPES_H
#ifndef APP_DEFS_H
#define APP_DEFS_H

/******************************************************************************
Expand Down
22 changes: 15 additions & 7 deletions include/colors.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#ifndef POLYBOARD_COLORS_H
#define POLYBOARD_COLORS_H
#ifndef COLORS_H
#define COLORS_H

// Predefined colors
#define COLOR_BLACK 0x000000
#define COLOR_WHITE 0xFFFFFF
#define COLOR_MAGENTA 0x9F2B68
#define COLOR_TEAL 0x008080
#define COLOR_BLACK 0x000000U
#define COLOR_WHITE 0xFFFFFFU
#define COLOR_RED 0xFF0000U
#define COLOR_GREEN 0x00FF00U
#define COLOR_BLUE 0x0000FFU
#define COLOR_MAGENTA 0x9F2B68U
#define COLOR_TEAL 0x008080U

#endif // POLYBOARD_COLORS_H
// Shifts to extract color components
#define COLOR_RED_SHIFT 16U
#define COLOR_GREEN_SHIFT 8U
#define COLOR_BLUE_SHIFT 0U

#endif // COLORS_H
10 changes: 5 additions & 5 deletions include/layout.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef POLYBOARD_LAYOUT_H
#define POLYBOARD_LAYOUT_H
#ifndef LAYOUT_H
#define LAYOUT_H

#include "app.h"
#include "app_defs.h"
Expand All @@ -13,7 +13,7 @@ static const u8 PAD_INDEXES[PAD_COUNT] = {
71, 72, 73, 74, 75, 76, 77, 78, 81, 82, 83, 84, 85, 86, 87, 88,
};

static const int LAYOUT_LOGO[PAD_COUNT] = {
static const u32 LAYOUT_LOGO[PAD_COUNT] = {
COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE,
COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE,
COLOR_TEAL, COLOR_TEAL, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE,
Expand All @@ -34,6 +34,6 @@ static const int LAYOUT_LOGO[PAD_COUNT] = {
*
* @param layout The layout to render.
*/
void render_layout(const int layout[PAD_COUNT]);
void render_layout(const u32 layout[PAD_COUNT]);

#endif // POLYBOARD_LAYOUT_H
#endif // LAYOUT_H
6 changes: 6 additions & 0 deletions src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,22 +38,27 @@
#include "app.h"
#include "layout.h"

// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
void app_surface_event(u8 type, u8 index, u8 value) {}

//______________________________________________________________________________

// NOLINTNEXTLINE
void app_midi_event(u8 port, u8 status, u8 d1, u8 d2) {}

//______________________________________________________________________________

// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
void app_sysex_event(u8 port, u8 *data, u16 count) {}

//______________________________________________________________________________

// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
void app_aftertouch_event(u8 index, u8 value) {}

//______________________________________________________________________________

// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
void app_cable_event(u8 type, u8 value) {
// example - light the Setup LED to indicate cable connections
if (type == MIDI_IN_CABLE) {
Expand All @@ -69,4 +74,5 @@ void app_timer_event() {}

//______________________________________________________________________________

// NOLINTNEXTLINE(misc-unused-parameters)
void app_init(const u16 *adc_raw) { render_layout(LAYOUT_LOGO); }
14 changes: 8 additions & 6 deletions src/layout.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#include "layout.h"

void render_layout(const int layout[PAD_COUNT]) {
int r, g, b;
void render_layout(const u32 layout[PAD_COUNT]) {
u8 red = 0;
u8 green = 0;
u8 blue = 0;

for (int i = 0; i < PAD_COUNT; i++) {
r = (layout[i] & 0xFF0000) >> 16;
g = (layout[i] & 0x00FF00) >> 8;
b = (layout[i] & 0x0000FF);
hal_plot_led(TYPEPAD, PAD_INDEXES[i], r, g, b);
red = (layout[i] & COLOR_RED) >> COLOR_RED_SHIFT;
green = (layout[i] & COLOR_GREEN) >> COLOR_GREEN_SHIFT;
blue = (layout[i] & COLOR_BLUE) >> COLOR_BLUE_SHIFT;
hal_plot_led(TYPEPAD, PAD_INDEXES[i], red, green, blue);
}
}

0 comments on commit f3d03cb

Please sign in to comment.