Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Node: C++ & VsCode Support #51

Merged
merged 13 commits into from
Apr 30, 2024
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
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "RIOT"]
path = node/src/RIOT
url = https://github.com/RIOT-OS/RIOT.git
[submodule "node/code/RIOT"]
path = node/code/RIOT
url = https://github.com/RIOT-OS/RIOT.git
11 changes: 11 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"configurations": [
{
"name": "Teamagochi",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "${workspaceFolder}/node/code/compile_commands.json"
}
],
"version": 4
}
27 changes: 21 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
"**/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,
},
}
3 changes: 2 additions & 1 deletion node/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
src/bin/**
.venv
code/bin/**
*.json
43 changes: 43 additions & 0 deletions node/code/Makefile
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions node/code/RIOT
Submodule RIOT added at f6e63d
11 changes: 11 additions & 0 deletions node/code/inc/init_display.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

int init_display(void);

#ifdef __cplusplus
}
#endif
File renamed without changes.
32 changes: 7 additions & 25 deletions node/src/main.c → node/code/init_display.c
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*
* Copyright (C) 2018 Koen Zandberg <[email protected]>
*
* 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 <[email protected]>
*
* @}
*/
#include "init_display.h"

#include <stdio.h>
#include "timex.h"
Expand All @@ -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;
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
22 changes: 22 additions & 0 deletions node/code/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include "architecture.h"
#include "thread.h"

#include "init_display.h"

#include <cstdio>
#include <vector>

using namespace std;

/* main */
int main()
{
printf("\n************ We are in C++ 😎 ***********\n");
printf("\n");

init_display();

puts("{\"result\": \"PASS\"}");

return 0;
}
File renamed without changes.
File renamed without changes.
25 changes: 0 additions & 25 deletions node/src/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion node/src/RIOT
Submodule RIOT deleted from 680c5a