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 18, 2023
1 parent 4fc62a9 commit acab34b
Show file tree
Hide file tree
Showing 11 changed files with 473 additions and 26 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
57 changes: 57 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,60 @@ tools/osx/simulator.xcodeproj/xcuserdata/davehodder.xcuserdatad/xcschemes/xcsche

*.xcbkptlist
tools/osx/simulator.xcodeproj/xcuserdata
# Created by https://www.toptal.com/developers/gitignore/api/vim,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=vim,macos

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### Vim ###
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim
Sessionx.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~

# End of https://www.toptal.com/developers/gitignore/api/vim,macos
Expand Down
Empty file added core
Empty file.
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
18 changes: 9 additions & 9 deletions include/layout.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#ifndef POLYBOARD_LAYOUT_H
#define POLYBOARD_LAYOUT_H
#ifndef LAYOUT_H
#define LAYOUT_H

#include "app.h"
#include "app_defs.h"
#include "colors.h"

// Inner pad indexes
static const u8 PAD_INDEXES[PAD_COUNT] = {
11, 12, 13, 14, 15, 16, 17, 18, 21, 22, 23, 24, 25, 26, 27, 28,
31, 32, 33, 34, 35, 36, 37, 38, 41, 42, 43, 44, 45, 46, 47, 48,
51, 52, 53, 54, 55, 56, 57, 58, 61, 62, 63, 64, 65, 66, 67, 68,
71, 72, 73, 74, 75, 76, 77, 78, 81, 82, 83, 84, 85, 86, 87, 88,
81, 82, 83, 84, 85, 86, 87, 88, 71, 72, 73, 74, 75, 76, 77, 78,
61, 62, 63, 64, 65, 66, 67, 68, 51, 52, 53, 54, 55, 56, 57, 58,
41, 42, 43, 44, 45, 46, 47, 48, 31, 32, 33, 34, 35, 36, 37, 38,
21, 22, 23, 24, 25, 26, 27, 28, 11, 12, 13, 14, 15, 16, 17, 18,
};

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);
}
}
1 change: 1 addition & 0 deletions tools/simulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
void hal_plot_led(u8 type, u8 index, u8 red, u8 green, u8 blue)
{
// wire this up to MIDI out...?
printf("...hsl_plot_led(%d, %d, 0x%2.2x, 0x%2.2x, 0x%2.2x);\n", type, index, red, green, blue);
}

void hal_read_led(u8 type, u8 index, u8 *red, u8 *green, u8 *blue)
Expand Down

0 comments on commit acab34b

Please sign in to comment.