Skip to content

Commit

Permalink
Sync with local development
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Dec 2, 2023
1 parent 5417cc0 commit a042b1a
Show file tree
Hide file tree
Showing 74 changed files with 222 additions and 3,931 deletions.
44 changes: 9 additions & 35 deletions firmware-template/libs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,11 @@ ifeq ($(findstring NODE_DDP_DISPLAY,$(DEFINES)),NODE_DDP_DISPLAY)
endif

RDM=

ifeq ($(findstring RDM_CONTROLLER,$(DEFINES)),RDM_CONTROLLER)
RDM=1
ifeq ($(findstring NO_EMAC,$(DEFINES)),NO_EMAC)
else
LIBS+=rdmdiscovery
endif
endif

ifeq ($(findstring RDM_RESPONDER,$(DEFINES)),RDM_RESPONDER)
ifneq ($(findstring rdmresponder,$(LIBS)),rdmresponder)
LIBS+=rdmresponder
endif
ifneq ($(findstring rdmsensor,$(LIBS)),rdmsensor)
LIBS+=rdmsensor device
endif
ifneq ($(findstring rdmsubdevice,$(LIBS)),rdmsubdevice)
LIBS+=rdmsubdevice
endif
ifneq ($(findstring NODE_ARTNET,$(DEFINES)),NODE_ARTNET)
ifneq ($(findstring dmxreceiver,$(LIBS)),dmxreceiver)
LIBS+=dmxreceiver
endif
endif
RDM=1
LIBS+=dmx
endif
DMX=

ifeq ($(findstring NODE_DMX,$(DEFINES)),NODE_DMX)
LIBS+=dmxreceiver dmx
LIBS+=dmxreceiver
DMX=1
endif

ifeq ($(findstring NODE_RDMNET_LLRP_ONLY,$(DEFINES)),NODE_RDMNET_LLRP_ONLY)
Expand All @@ -63,12 +38,6 @@ ifeq ($(findstring NODE_RDMNET_LLRP_ONLY,$(DEFINES)),NODE_RDMNET_LLRP_ONLY)
ifneq ($(findstring e131,$(LIBS)),e131)
LIBS+=e131
endif
ifneq ($(findstring rdmsensor,$(LIBS)),rdmsensor)
LIBS+=rdmsensor
endif
ifneq ($(findstring rdmsubdevice,$(LIBS)),rdmsubdevice)
LIBS+=rdmsubdevice
endif
RDM=1
endif

Expand All @@ -85,7 +54,12 @@ ifeq ($(findstring OUTPUT_DMX_MONITOR,$(DEFINES)),OUTPUT_DMX_MONITOR)
endif

ifeq ($(findstring OUTPUT_DMX_SEND,$(DEFINES)),OUTPUT_DMX_SEND)
LIBS+=dmxsend dmx
LIBS+=dmxsend
DMX=1
endif

ifdef DMX
LIBS+=dmx
endif

ifeq ($(findstring OUTPUT_DDP_PIXEL_MULTI,$(DEFINES)),OUTPUT_DDP_PIXEL_MULTI)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1701537095;
// Generated do 14 sep 2023 12:39:29 CEST
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1694687969;
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-987082377398814242" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-959551752169384322" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 1 addition & 1 deletion gd32_emac_ddp_pixel_multi/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-987082377398814242" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-959551752169384322" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
2 changes: 2 additions & 0 deletions gd32_emac_e131_pixel_dmx_multi/include/sofware_version_id.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Generated do 14 sep 2023 12:39:45 CEST
constexpr uint32_t DEVICE_SOFTWARE_VERSION_ID=1694687985;
9 changes: 3 additions & 6 deletions lib-c++/.settings/language.settings.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.346413883" name="GD32">
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1040880586.393757927" name="GD32">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-987082377398814242" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
Expand Down
8 changes: 7 additions & 1 deletion lib-configstore/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ ifneq ($(MAKE_FLAGS),)
RDM=1
endif
EXTRA_INCLUDES+=../lib-rdmresponder/include
EXTRA_INCLUDES+=../lib-rdmsensor/include
EXTRA_SRCDIR+=src/rdm/sensors
ifeq ($(findstring ENABLE_RDM_SUBDEVICES,$(MAKE_FLAGS)), ENABLE_RDM_SUBDEVICES)
EXTRA_SRCDIR+=src/rdm/subdevices
EXTRA_INCLUDES+=../lib-rdmsubdevice/include
endif
endif

ifeq ($(findstring NODE_RDMNET_LLRP_ONLY,$(MAKE_FLAGS)), NODE_RDMNET_LLRP_ONLY)
Expand All @@ -151,7 +157,7 @@ ifneq ($(MAKE_FLAGS),)

ifdef RDM
EXTRA_SRCDIR+=src/rdm
EXTRA_INCLUDES+=../lib-rdm/include ../lib-rdmsensor/include ../lib-rdmsubdevice/include
EXTRA_INCLUDES+=../lib-rdm/include
endif
else
ifneq (, $(shell test -d '../lib-network/src/noemac' && echo -n yes))
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib-hal/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.999241968" name="GD32">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="true" env-hash="-1001195730784049762" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="arm-none-eabi-gcc -nostartfiles -ffreestanding -nostdlib -mcpu=cortex-m3 -mthumb -DBARE_METAL -DGD32 -DGD32F20X_CL ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="true" env-hash="-960065744326087874" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="arm-none-eabi-gcc -nostartfiles -ffreestanding -nostdlib -mcpu=cortex-m3 -mthumb -DBARE_METAL -DGD32 -DGD32F20X_CL ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
Expand Down
123 changes: 94 additions & 29 deletions lib-rdm/include/rdmsensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file rdmsensor.h
*
*/
/* Copyright (C) 2018-2021 by Arjan van Vught mailto:info@orangepi-dmx.nl
/* Copyright (C) 2018-2023 by Arjan van Vught mailto:info@gd32-dmx.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -27,6 +27,11 @@
#define RDMSENSOR_H_

#include <cstdint>
#include <cstdio>
#include <cassert>
#include <algorithm>

#include "debug.h"

namespace rdm {
namespace sensor {
Expand All @@ -51,69 +56,99 @@ struct Values {
int16_t recorded;
uint8_t sensor_requested;
};
static constexpr int16_t RANGE_MIN = -32768;
static constexpr int16_t RANGE_MAX = +32767;
static constexpr int16_t NORMAL_MIN = -32768;

static constexpr int16_t RANGE_MIN = -32768;
static constexpr int16_t RANGE_MAX = +32767;
static constexpr int16_t NORMAL_MIN = -32768;
static constexpr int16_t NORMAL_MAX = +32767;
static constexpr int16_t TEMPERATURE_ABS_ZERO = -273;
static constexpr int16_t TEMPERATURE_ABS_ZERO = -273;

template<class T>
constexpr int16_t safe_range_max(const T& a)
{
static_assert(sizeof(int16_t) <= sizeof(T), "T");
static constexpr uint8_t RECORDED_SUPPORTED = (1U << 0);
static constexpr uint8_t LOW_HIGH_DETECT = (1U << 1);

return (a > static_cast<T>(INT16_MAX)) ? INT16_MAX : static_cast<int16_t>(a);
template<class T>
constexpr int16_t safe_range_max(const T &a) {
static_assert(sizeof(int16_t) <= sizeof(T), "T");
return (a > static_cast<T>(INT16_MAX)) ? INT16_MAX : static_cast<int16_t>(a);
}

template<class T>
constexpr int16_t safe_range_min(const T& a)
{
static_assert(sizeof(int16_t) <= sizeof(T), "T");

return (a < static_cast<T>(INT16_MIN)) ? INT16_MIN : static_cast<int16_t>(a);
constexpr int16_t safe_range_min(const T &a) {
static_assert(sizeof(int16_t) <= sizeof(T), "T");
return (a < static_cast<T>(INT16_MIN)) ? INT16_MIN : static_cast<int16_t>(a);
}

} // namespace rdm
} // namespace sensor


class RDMSensor {
public:
RDMSensor(uint8_t nSensor);
RDMSensor(const uint8_t nSensor) : m_nSensor(nSensor) {
DEBUG_ENTRY

m_tRDMSensorDefintion.sensor = m_nSensor;
m_tRDMSensorDefintion.recorded_supported = rdm::sensor::RECORDED_SUPPORTED | rdm::sensor::LOW_HIGH_DETECT;

m_tRDMSensorValues.sensor_requested = m_nSensor;
m_tRDMSensorValues.lowest_detected = rdm::sensor::RANGE_MAX;
m_tRDMSensorValues.highest_detected = rdm::sensor::RANGE_MIN;

DEBUG_EXIT
}

virtual ~RDMSensor() {}

public:
void SetType(uint8_t nType) {
void SetType(const uint8_t nType) {
m_tRDMSensorDefintion.type = nType;
}

void SetUnit(uint8_t nUnit) {
void SetUnit(const uint8_t nUnit) {
m_tRDMSensorDefintion.unit = nUnit;
}

void SetPrefix(uint8_t nPrefix) {
void SetPrefix(const uint8_t nPrefix) {
m_tRDMSensorDefintion.prefix = nPrefix;
}

void SetRangeMin(int16_t nRangeMin) {
void SetRangeMin(const int16_t nRangeMin) {
m_tRDMSensorDefintion.range_min = nRangeMin;
}

void SetRangeMax(int16_t nRangeMax) {
void SetRangeMax(const int16_t nRangeMax) {
m_tRDMSensorDefintion.range_max = nRangeMax;
}

void SetNormalMin(int16_t nNormalMin) {
void SetNormalMin(const int16_t nNormalMin) {
m_tRDMSensorDefintion.normal_min = nNormalMin;
}

void SetNormalMax(int16_t nNormalMax) {
void SetNormalMax(const int16_t nNormalMax) {
m_tRDMSensorDefintion.normal_max = nNormalMax;
}

void SetDescription(const char *pDescription);
void SetDescription(const char *pDescription) {
DEBUG_ENTRY

assert(pDescription != nullptr);
uint32_t i;

for (i = 0; i < 32 && pDescription[i] != 0; i++) {
m_tRDMSensorDefintion.description[i] = pDescription[i];
}

void Print();
m_tRDMSensorDefintion.nLength = static_cast<uint8_t>(i);

DEBUG_EXIT
}

void Print() {
printf("%d [%.*s]\n", m_tRDMSensorDefintion.sensor, m_tRDMSensorDefintion.nLength, m_tRDMSensorDefintion.description);
printf(" RangeMin %d\n", m_tRDMSensorDefintion.range_min);
printf(" RangeMax %d\n", m_tRDMSensorDefintion.range_max);
printf(" NormalMin %d\n", m_tRDMSensorDefintion.normal_min);
printf(" NormalMax %d\n", m_tRDMSensorDefintion.normal_max);
}

uint8_t GetSensor() const {
return m_nSensor;
Expand All @@ -123,11 +158,41 @@ class RDMSensor {
return &m_tRDMSensorDefintion;
}

const struct rdm::sensor::Values* GetValues();
const struct rdm::sensor::Values *GetValues() {
DEBUG_ENTRY
const auto nValue = this->GetValue();

m_tRDMSensorValues.present = nValue;
m_tRDMSensorValues.lowest_detected = std::min(m_tRDMSensorValues.lowest_detected, nValue);
m_tRDMSensorValues.highest_detected = std::max(m_tRDMSensorValues.highest_detected, nValue);

DEBUG_EXIT
return &m_tRDMSensorValues;
}

void SetValues();
void SetValues() {
DEBUG_ENTRY
const auto nValue = this->GetValue();

void Record();
m_tRDMSensorValues.present = nValue;
m_tRDMSensorValues.lowest_detected = nValue;
m_tRDMSensorValues.highest_detected = nValue;
m_tRDMSensorValues.recorded = nValue;

DEBUG_EXIT
}

void Record() {
DEBUG_ENTRY
const auto nValue = this->GetValue();

m_tRDMSensorValues.present = nValue;
m_tRDMSensorValues.recorded = nValue;
m_tRDMSensorValues.lowest_detected = std::min(m_tRDMSensorValues.lowest_detected, nValue);
m_tRDMSensorValues.highest_detected = std::max(m_tRDMSensorValues.highest_detected, nValue);

DEBUG_EXIT
}

virtual bool Initialize()=0;
virtual int16_t GetValue()=0;
Expand Down
Loading

0 comments on commit a042b1a

Please sign in to comment.