aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2026-01-31 17:35:51 +0530
committerAkshay Nair <phenax5@gmail.com>2026-01-31 17:36:10 +0530
commit7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a (patch)
treeb85f49881f843f1765f2ec0a3899cdb1b5253e3b
downloaddaft-watch-7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a.tar.gz
daft-watch-7224fce49e4fa8c0b966dcc8d4f9b1d12b02f66a.zip
Init commit with blink shit
-rw-r--r--.clangd2
-rw-r--r--.envrc1
-rw-r--r--.gitignore7
-rw-r--r--LICENSE21
-rw-r--r--flake.lock61
-rw-r--r--flake.nix50
-rw-r--r--justfile28
-rw-r--r--platformio.ini43
-rwxr-xr-xsetup_compiledb.sh30
-rw-r--r--src/main.cpp16
10 files changed, 259 insertions, 0 deletions
diff --git a/.clangd b/.clangd
new file mode 100644
index 0000000..f7f6556
--- /dev/null
+++ b/.clangd
@@ -0,0 +1,2 @@
+CompileFlags:
+ Remove: [-mlongcalls, -free, -mtext-section-literals, -fipa-pta, -fno-tree-switch-conversion, -fstrict-volatile-bitfields]
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..3550a30
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use flake
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..1628473
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+.pio
+.clang_complete
+.gcc-flags.json
+.ccls
+.cache/
+compile_commands.json
+compiler_defines.h
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..713d8cf
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 Akshay Nair
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..90a6f4d
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1769461804,
+ "narHash": "sha256-msG8SU5WsBUfVVa/9RPLaymvi5bI8edTavbIq3vRlhI=",
+ "owner": "nixos",
+ "repo": "nixpkgs",
+ "rev": "bfc1b8a4574108ceef22f02bafcf6611380c100d",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nixos",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..b947856
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,50 @@
+{
+ inputs = {
+ nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ flake-utils,
+ ...
+ }:
+ let
+ shell =
+ { pkgs }:
+ pkgs.buildFHSEnv {
+ name = "daft-watch-env";
+ targetPkgs =
+ pkgs: with pkgs; [
+ (lib.hiPrio gcc)
+ platformio-core
+ avrdude
+ openocd
+ glibc
+
+ # dev
+ clang-tools
+ unixtools.xxd
+ just
+ ];
+ multiPkgs = pkgs: (with pkgs; [ udev ]);
+
+ runScript = "zsh";
+ profile = ''
+ export DIRENV_DISABLE_HOOK=1; # Dont recursively load direnv inside shell
+ export WITH_NIX_PREFIX="fhs";
+ '';
+ };
+ in
+ flake-utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+ in
+ {
+ devShells.default = (shell { inherit pkgs; }).env;
+ }
+ );
+}
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..749fde6
--- /dev/null
+++ b/justfile
@@ -0,0 +1,28 @@
+build:
+ pio run -e attiny84;
+
+check:
+ pio check --skip-packages
+
+upload:
+ pio run -e attiny84 -t upload
+
+clean:
+ pio run -t clean
+
+update:
+ pio pkg update
+
+monitor:
+ pio device monitor
+
+test:
+ pio test -e test
+
+format:
+ find include/ src/ -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i
+
+devsetup:
+ # COMPILATIONDB_INCLUDE_TOOLCHAIN=true pio run -t compiledb
+ ./setup_compiledb.sh
+
diff --git a/platformio.ini b/platformio.ini
new file mode 100644
index 0000000..1fab521
--- /dev/null
+++ b/platformio.ini
@@ -0,0 +1,43 @@
+; PlatformIO Project Configuration File
+;
+; Build options: build flags, source filter
+; Upload options: custom upload port, speed and extra flags
+; Library options: dependencies, extra library storages
+; Advanced options: extra scripting
+;
+; Please visit documentation for the other options and examples
+; https://docs.platformio.org/page/projectconf.html
+
+[cfg]
+build_flags =
+ -Ilib -Isrc
+ -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-format-extra-args
+ -std=gnu++2a
+build_unflags = -Os -std=gnu++14
+monitor_filters =
+ time
+ colorize
+ send_on_enter
+ esp32_exception_decoder
+
+[env:attiny84]
+platform = atmelavr
+board = attiny84
+framework = arduino
+board_build.mcu = attiny84
+board_build.f_cpu = 1000000L
+upload_protocol = arduino
+upload_speed = 19200
+upload_port = /dev/ttyUSB0
+upload_flags =
+ -C
+ $PROJECT_PACKAGES_DIR/tool-avrdude/avrdude.conf
+ -p
+ $BOARD_MCU
+ -P
+ $UPLOAD_PORT
+ -b
+ $UPLOAD_SPEED
+ -c
+ $UPLOAD_PROTOCOL
+
diff --git a/setup_compiledb.sh b/setup_compiledb.sh
new file mode 100755
index 0000000..9233bb1
--- /dev/null
+++ b/setup_compiledb.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+export COMPILATIONDB_INCLUDE_TOOLCHAIN=true
+
+# Compile the project
+pio run -t compiledb
+
+# Clean up existing define files
+rm -f _compiler_defines.h compiler_defines.h clang_defines.h
+
+# Generate defines for clang
+gcc -dM -xc++ /dev/null -c -v -E 2>/dev/null | sed "s/\([^[:space:]]\+[[:space:]]\+[^[:space:]]\+\)\(.*\)/\1/;s/#define/#undef/" >clang_defines.h
+
+# Iterate through compile_commands.json and extract compiler defines
+for comp in $(cat compile_commands.json | grep -E "\"command\": \"[^[:space:]]* -o" | sed 's:"command"\: "::g; s:-o.*::g' | sort | uniq); do
+ set -x
+ $comp -dM -E -xc++ /dev/null >>_compiler_defines.h
+ set +x
+done
+
+# Combine defines from clang and extracted defines
+cat clang_defines.h > compiler_defines.h
+cat _compiler_defines.h | sort | uniq >> compiler_defines.h
+
+# Clean up temporary define files
+rm -f _compiler_defines.h clang_defines.h
+
+# Update compile_commands.json with additional include flags
+sed -i "s:.cpp\",:.cpp -include $${PWD}/compiler_defines.h\",:" compile_commands.json
+sed -i "s:.c\",:.c -include $${PWD}/compiler_defines.h\",:" compile_commands.json
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..6226244
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,16 @@
+#include <Arduino.h>
+
+// Physical Pin 2 on the ATtiny84a is Arduino Digital Pin 0
+#define LED_PIN 0
+
+void setup() {
+ // Initialize the digital pin as an output.
+ pinMode(LED_PIN, OUTPUT);
+}
+
+void loop() {
+ digitalWrite(LED_PIN, HIGH); // Turn the LED on
+ delay(1000); // Wait for a second
+ digitalWrite(LED_PIN, LOW); // Turn the LED off
+ delay(1000); // Wait for a second
+}