Skip to content

Commit

Permalink
refactoring complete, first hsm, input broken
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzholzer committed May 31, 2024
1 parent 57bcd26 commit c2e1c93
Show file tree
Hide file tree
Showing 34 changed files with 921 additions and 1,179 deletions.
16 changes: 7 additions & 9 deletions node/code/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ TEAMAGOTCHI_NODES_BASE = $(CURDIR)
DEVELHELP ?= 1

# Include test_folder example to showcase directories being included
DIR += test_folder
# DIR += test_folder

FEATURES_REQUIRED += cpp
FEATURES_REQUIRED += libstdcpp
# FEATURES_REQUIRED += cpp
# FEATURES_REQUIRED += libstdcpp
FEATURES_REQUIRED += periph_gpio_irq

# Internal Modules
# Teamagotchi MODULES
#USEMODULE += lwm2m_handler
#USEMODULE += io_handler
USEMODULE += io_handler
USEMODULE += display_handler
USEMODULE += lwm2m_handler
EXTERNAL_MODULE_DIRS += modules

# External modules
USEMODULE += cpp11-compat
# USEMODULE += cpp11-compat
USEMODULE += ztimer
USEMODULE += ztimer_msec
USEMODULE += shell
Expand All @@ -45,12 +44,12 @@ CFLAGS += -std=c17 -Wall -Wextra

# Set the C++ standard to C++20 [C++23 with all the cool stuff is not yet supported]
# and enable all warnings
CXXEXFLAGS += -std=c++20 -Wall -Wextra
# CXXEXFLAGS += -std=c++20 -Wall -Wextra

# Disable volatile warnings
# C++20 introduced a deprecation for this, which was then
# reverted in C++23 because it wasn't thought through
CXXEXFLAGS += -Wno-volatile
# CXXEXFLAGS += -Wno-volatile

BOARD_BLACKLIST += native64

Expand Down Expand Up @@ -79,7 +78,6 @@ endif

include $(RIOTBASE)/Makefile.include


CFLAGS += -DDISPLAY_STACKSIZE=2*1024

# SDL requires more stack
Expand Down
104 changes: 104 additions & 0 deletions node/code/Makefile.bakold
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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

# Internal Modules
# Teamagotchi MODULES
#USEMODULE += lwm2m_handler
USEMODULE += io_handler
USEMODULE += display_handler
EXTERNAL_MODULE_DIRS += modules

# External modules
USEMODULE += cpp11-compat
USEMODULE += ztimer
USEMODULE += ztimer_msec
USEMODULE += shell
USEMODULE += xtimer

# 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

# Set the C standard to C17 [C23 (even experimental) is not yet supported]
# and enable all warnings
CFLAGS += -std=c17 -Wall -Wextra

# Set the C++ standard to C++20 [C++23 with all the cool stuff is not yet supported]
# and enable all warnings
CXXEXFLAGS += -std=c++20 -Wall -Wextra

# Disable volatile warnings
# C++20 introduced a deprecation for this, which was then
# reverted in C++23 because it wasn't thought through
CXXEXFLAGS += -Wno-volatile


#include $(CURDIR)/modules/lwm2m/Makefile.include
include $(RIOTBASE)/Makefile.include


BOARD_BLACKLIST += native64

## DEBUG
CFLAGS += -DDEBUG_ASSERT_VERBOSE

##### LWM2M #####
#SERVER_URI = '"coap://[2001:db8:1::1]:5684"'
LWM2M_SERVER_SHORT_ID ?= 1
CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE='(3*1024)'
# Uncomment to enable Wakaama debug log
#CFLAGS += -DCONFIG_LWM2M_WITH_LOGS=1
# Specific the server URI address (NOTE: Domain names not supported yet)
LWM2M_SERVER_URI ?= '"coap://[fd00:dead:beef::1]:5683"'
# Configure via CFLAGS only if not done via Kconfig
ifndef CONFIG_LWM2M_SERVER_URI
CFLAGS += -DCONFIG_LWM2M_SERVER_URI=$(LWM2M_SERVER_URI)
CFLAGS += -DCONFIG_LWM2M_SERVER_SHORT_ID=$(LWM2M_SERVER_SHORT_ID)
CFLAGS += -DCONFIG_DTLS_PEER_MAX=2
CFLAGS += -DCONFIG_MAX_BUF=1024
# Uncomment to enable Wakaama debug log
CFLAGS += -DCONFIG_LWM2M_WITH_LOGS=1
endif
##### /LWM2M #####


# SDL requires more stack
ifneq (,$(filter native native64,$(BOARD)))
CFLAGS += -DTHREAD_STACKSIZE_MAIN=64*1024
else ifneq (,$(filter esp%,$(CPU_FAM)))
CFLAGS += -DTHREAD_STACKSIZE_MAIN=4*1024
else
CFLAGS += -DTHREAD_STACKSIZE_MAIN=2*1024
endif


# 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



32 changes: 0 additions & 32 deletions node/code/dispatcher.cpp

This file was deleted.

32 changes: 32 additions & 0 deletions node/code/events.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include "events.h"
#include "event.h"

static event_queue_t queues[2];
static event_handler_t handler_fn;

event_queue_t * get_queue_standard(void){
return &queues[1];
// return &queues[1];
}

void trigger_event_input(EVENT_T event){
team_event_t t_event = {.super.handler = handler_fn, .event = event};
event_post(&queues[0],&t_event.super);
}


void trigger_event(EVENT_T event){
team_event_t t_event = {.super.handler = handler_fn, .event = event};
event_post(&queues[1],&t_event.super);
}


void events_handler_init(event_handler_t handlerfn){
handler_fn = handlerfn;
event_queues_init(queues,2);
}


void events_start(void){
event_loop_multi(queues,2);
}
Loading

0 comments on commit c2e1c93

Please sign in to comment.