diff --git a/.gitmodules b/.gitmodules index bf4ef4ee..349de54c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "RIOT"] - path = node/src/RIOT - url = https://github.com/RIOT-OS/RIOT.git \ No newline at end of file +[submodule "node/code/RIOT"] + path = node/code/RIOT + url = https://github.com/RIOT-OS/RIOT.git diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..4f689ea9 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,11 @@ +{ + "configurations": [ + { + "name": "Teamagochi", + "cStandard": "c11", + "cppStandard": "c++17", + "compileCommands": "${workspaceFolder}/node/code/compile_commands.json" + } + ], + "version": 4 +} diff --git a/.vscode/settings.json b/.vscode/settings.json index a12aa931..b83acabb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,23 @@ { + "editor.rulers": [ + 80, + 100 + ], + "editor.detectIndentation": false, + "files.insertFinalNewline": true, "files.associations": { - "board.h": "c", - "cpu.h": "c", - "riot_logo.h": "c", - "ili9341_params.h": "c" - } -} \ No newline at end of file + "**/frontmatter.json": "jsonc", + "**/.frontmatter/config/*.json": "jsonc", + "Makefile.*": "makefile", + "*.mk": "makefile", + "timex.h": "c" + }, + "[shellscript][c][cpp]": { + "editor.tabSize": 4, + "editor.insertSpaces": true, + }, + "[makefile]": { + "editor.tabSize": 2, + "editor.insertSpaces": true, + }, +} diff --git a/node/.gitignore b/node/.gitignore index 0ba4b467..df4ed245 100644 --- a/node/.gitignore +++ b/node/.gitignore @@ -1,2 +1,3 @@ -src/bin/** .venv +code/bin/** +*.json \ No newline at end of file diff --git a/node/code/Makefile b/node/code/Makefile new file mode 100644 index 00000000..0fe192ad --- /dev/null +++ b/node/code/Makefile @@ -0,0 +1,43 @@ +APPLICATION = teamagotchi +BOARD = feather-nrf52840-sense + +# This has to be the absolute path to the RIOT base directory: +RIOTBASE ?= $(CURDIR)/RIOT + +# Comment this out to disable code in RIOT that does safety checking +# which is not needed in a production environment but helps in the +# development process: +DEVELHELP ?= 1 + +FEATURES_REQUIRED += cpp +FEATURES_REQUIRED += libstdcpp + +#Hardware specific configs +USEMODULE += ili9341 +USEMODULE += ztimer +USEMODULE += ztimer_msec + +# As there is an 'Kconfig' we want to explicitly disable Kconfig by setting +# the variable to empty +SHOULD_RUN_KCONFIG ?= + +# Include "inc" directory for the header files +INCLUDES += -I$(CURDIR)/inc + +CXXEXFLAGS += + +include $(RIOTBASE)/Makefile.include + +# Note that this will probably only work for me <3 +windows: all + @echo "Creating UF2" + @python RIOT/dist/tools/uf2/uf2conv.py -f 0xADA52840 bin/feather-nrf52840-sense/teamagotchi.hex --base 0x1000 -c + @echo "Flashing UF2 via Windows (Make sure your device is actually at D)" + @powershell.exe -command "cp ./flash.uf2 d:/flash.uf2" + @echo "Connecting COM via USBIPD (Make sure you have the USBIPD installed + your device bound to the WSL)" + @sleep 3 + @usbipd.exe attach --wsl -i 1209:7d00 + @sleep 3 + @echo "Connected :D" + @echo "Cleaning up uf2 flash file" + @rm flash.uf2 diff --git a/node/code/RIOT b/node/code/RIOT new file mode 160000 index 00000000..f6e63d2b --- /dev/null +++ b/node/code/RIOT @@ -0,0 +1 @@ +Subproject commit f6e63d2bb379e2b537c4fc011c5fdbf2e1922c88 diff --git a/node/src/inc/ili9341_params.h b/node/code/inc/ili9341_params.h similarity index 100% rename from node/src/inc/ili9341_params.h rename to node/code/inc/ili9341_params.h diff --git a/node/code/inc/init_display.h b/node/code/inc/init_display.h new file mode 100644 index 00000000..3d9f85eb --- /dev/null +++ b/node/code/inc/init_display.h @@ -0,0 +1,11 @@ +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +int init_display(void); + +#ifdef __cplusplus +} +#endif \ No newline at end of file diff --git a/node/src/inc/riot_logo.h b/node/code/inc/riot_logo.h similarity index 100% rename from node/src/inc/riot_logo.h rename to node/code/inc/riot_logo.h diff --git a/node/src/main.c b/node/code/init_display.c similarity index 75% rename from node/src/main.c rename to node/code/init_display.c index 2257f221..3d8a6222 100644 --- a/node/src/main.c +++ b/node/code/init_display.c @@ -1,22 +1,4 @@ -/* - * Copyright (C) 2018 Koen Zandberg - * - * This file is subject to the terms and conditions of the GNU Lesser - * General Public License v2.1. See the file LICENSE in the top level - * directory for more details. - */ - -/** - * @ingroup tests - * @{ - * - * @file - * @brief Test application for lcd tft displays - * - * @author Koen Zandberg - * - * @} - */ +#include "init_display.h" #include #include "timex.h" @@ -29,8 +11,7 @@ #include "ili9341.h" #include "ili9341_params.h" - -int main(void) +int init_display(void) { lcd_t dev; dev.driver = &lcd_ili9341_driver; @@ -45,10 +26,12 @@ int main(void) BACKLIGHT_ON; #endif - if (lcd_init(&dev, &ili9341_params[0]) == 0) { + if (lcd_init(&dev, &ili9341_params[0]) == 0) + { puts("[OK]"); } - else { + else + { puts("[Failed]"); return 1; } @@ -84,10 +67,9 @@ int main(void) /* Approximate middle of the display */ uint8_t x1 = (dev.params->lines / 2) - (RIOT_LOGO_WIDTH / 2); uint8_t y1 = (dev.params->rgb_channels / 2) - (RIOT_LOGO_HEIGHT / 2); - lcd_pixmap(&dev, x1, x1 + RIOT_LOGO_WIDTH - 1, y1, y1 + RIOT_LOGO_HEIGHT - 1, + lcd_pixmap(&dev, x1, x1 + RIOT_LOGO_WIDTH - 1, y1, y1 + RIOT_LOGO_HEIGHT - 1, (const uint16_t *)picture); #endif - puts("{\"result\": \"PASS\"}"); return 0; } diff --git a/node/code/main.cpp b/node/code/main.cpp new file mode 100644 index 00000000..332080fa --- /dev/null +++ b/node/code/main.cpp @@ -0,0 +1,22 @@ +#include "architecture.h" +#include "thread.h" + +#include "init_display.h" + +#include +#include + +using namespace std; + +/* main */ +int main() +{ + printf("\n************ We are in C++ 😎 ***********\n"); + printf("\n"); + + init_display(); + + puts("{\"result\": \"PASS\"}"); + + return 0; +} diff --git a/node/src/requirements.txt b/node/code/requirements.txt similarity index 100% rename from node/src/requirements.txt rename to node/code/requirements.txt diff --git a/node/src/tests/01-run.py b/node/code/tests/01-run.py similarity index 100% rename from node/src/tests/01-run.py rename to node/code/tests/01-run.py diff --git a/node/src/Makefile b/node/src/Makefile deleted file mode 100644 index 0b1a03a4..00000000 --- a/node/src/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -APPLICATION = teamagotchi -BOARD = feather-nrf52840-sense - -# This has to be the absolute path to the RIOT base directory: -RIOTBASE ?= $(CURDIR)/RIOT - -# Comment this out to disable code in RIOT that does safety checking -# which is not needed in a production environment but helps in the -# development process: -DEVELHELP ?= 1 - -#include ../Makefile.drivers_common - -#Hardware specific configs -USEMODULE += ili9341 -USEMODULE += ztimer -USEMODULE += ztimer_msec - -# As there is an 'Kconfig' we want to explicitly disable Kconfig by setting -# the variable to empty -SHOULD_RUN_KCONFIG ?= - -INCLUDES += -I$(CURDIR)/inc - -include $(RIOTBASE)/Makefile.include \ No newline at end of file diff --git a/node/src/RIOT b/node/src/RIOT deleted file mode 160000 index 680c5aa2..00000000 --- a/node/src/RIOT +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 680c5aa23f84feba6999bf41f4642aef7825cb86