Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: CMake

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

env:
BUILD_TYPE: Release

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt install cmake gcc-13 g++-13

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 60
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 60
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

- name: Linting
run: find -name "*.cc" -o -name "*.c" -o -name "*.hh" -o -name "*.h" | xargs clang-format -n

- name: Build
run: |
cmake -B build -S ./ && cmake --build build

- name: Run st7735_driver_test
run: |
./build/tests/st7735_driver_test

16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.13)

project(display_drivers LANGUAGES C CXX)

# Set the C++ standard to C++20
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# For lsp
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)


set(NAME st7735_driver)

add_subdirectory(src)
add_subdirectory(tests)
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ void main(void){

lcd_st7735_init(&ctx, &interface);
lcd_st7735_startup(&ctx);
lcd_st7735_fill_rectangle(&ctx, (LCD_rectangle){.origin = {.x = 0, .y = 0},
.end = {.x = 160, .y = 128}}, 0x00FF00);
lcd_st7735_fill_rectangle(
&ctx_, (LCD_rectangle){.origin = {.x = 0, .y = 0}, .width = 160, .height = 128}, 0x00FF00);
}
```

Expand Down Expand Up @@ -86,3 +86,18 @@ void main(void){
}
```

## Running unittests
Start nix development environment
```sh
nix develop
```
Build using Cmake
```sh
cmake -S . -B ./build/. && cmake --build ./build/.
```
Run the test
```sh
./build/tests/st7735_driver_test
```


61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
description = "C/C++ environment";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
in
{
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
cmake
clang-tools_18
gdb
python310
];
shellHook = ''
echo "C++ dev environment ready!"
'';
};
}
);
}
Loading