Skip to content

Commit

Permalink
Merge pull request #4 from PharosMarcusB/config_pids
Browse files Browse the repository at this point in the history
Config PIDs
  • Loading branch information
vanvught authored Dec 21, 2023
2 parents de92465 + 885b51b commit 20bb08d
Show file tree
Hide file tree
Showing 37 changed files with 484 additions and 104 deletions.
3 changes: 3 additions & 0 deletions firmware-template-gd32/lib/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ include ../firmware-template-gd32/Includes.mk
DEFINES:=$(addprefix -D,$(DEFINES))
DEFINES+=-D_TIME_STAMP_YEAR_=$(shell date +"%Y") -D_TIME_STAMP_MONTH_=$(shell date +"%-m") -D_TIME_STAMP_DAY_=$(shell date +"%-d")
DEFINES+=-DCONFIG_STORE_USE_ROM
DEFINES+=-DDISABLE_FS
DEFINES+=-DENABLE_RDM_MANUFACTURER_PIDS
DEFINES+=-DENABLE_CONFIG_PIDS

COPS=-DBARE_METAL -DGD32 -DGD32F30X_HD -D$(MCU) -D$(BOARD)
COPS+=$(DEFINES) $(MAKE_FLAGS) $(INCLUDES)
Expand Down
5 changes: 4 additions & 1 deletion gd32_dmx_usb_pro/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1766002374.1447165843.114097098" name="GD32">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-743103399076385512" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_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 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"/>
Expand Down
5 changes: 5 additions & 0 deletions gd32_rdm_responder/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-debug/include}&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.146154615" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" value="true" valueType="boolean"/>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs.1763907850" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs" valueType="definedSymbols"/>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.236787138" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
</tool>
<tool id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.731163045" name="GNU Arm Cross C Compiler" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler">
Expand All @@ -117,6 +118,8 @@
<listOptionValue builtIn="false" value="GD32F30X_HD"/>
<listOptionValue builtIn="false" value="DISABLE_FS"/>
<listOptionValue builtIn="false" value="DISABLE_TFTP"/>
<listOptionValue builtIn="false" value="ENABLE_CONFIG_PIDS"/>
<listOptionValue builtIn="false" value="ENABLE_RDM_MANUFACTURER_PIDS"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.33349665" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
Expand Down Expand Up @@ -153,6 +156,8 @@
<listOptionValue builtIn="false" value="RDM_RESPONDER"/>
<listOptionValue builtIn="false" value="NO_EMAC"/>
<listOptionValue builtIn="false" value="OUTPUT_DMX_PIXEL"/>
<listOptionValue builtIn="false" value="ENABLE_CONFIG_PIDS"/>
<listOptionValue builtIn="false" value="ENABLE_RDM_MANUFACTURER_PIDS"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1276402743" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
</tool>
Expand Down
23 changes: 23 additions & 0 deletions gd32_rdm_responder/.project
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@
<name>gd32_rdm_responder</name>
<comment></comment>
<projects>
<project>lib-c</project>
<project>lib-c++</project>
<project>lib-configstore</project>
<project>lib-debug</project>
<project>lib-device</project>
<project>lib-display</project>
<project>lib-displayudf</project>
<project>lib-dmx</project>
<project>lib-dmxreceiver</project>
<project>lib-flashcode</project>
<project>lib-gd32</project>
<project>lib-hal</project>
<project>lib-lightset</project>
<project>lib-network</project>
<project>lib-properties</project>
<project>lib-rdm</project>
<project>lib-rdmresponder</project>
<project>lib-rdmsensor</project>
<project>lib-rdmsubdevice</project>
<project>lib-usb</project>
<project>lib-widget</project>
<project>lib-ws28xx</project>
<project>lib-ws28xxdmx</project>
</projects>
<buildSpec>
<buildCommand>
Expand Down
5 changes: 4 additions & 1 deletion gd32_rdm_responder/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1766002374.1447165843" name="GD32">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-677151021969962621" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_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 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"/>
Expand Down
2 changes: 2 additions & 0 deletions gd32_rdm_responder/.settings/org.eclipse.cdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ doxygen/doxygen_use_javadoc_tags=true
doxygen/doxygen_use_pre_tag=false
doxygen/doxygen_use_structural_commands=false
eclipse.preferences.version=1
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1766002374.1447165843/append=true
environment/project/cdt.managedbuild.toolchain.gnu.cross.base.1766002374.1447165843/appendContributed=true
3 changes: 3 additions & 0 deletions gd32_rdm_responder/Makefile.GD32
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ DEFINES+=ENABLE_RDM_SELF_TEST
DEFINES+=OUTPUT_DMX_PIXEL
DEFINES+=CONFIG_PIXELDMX_MAX_PORTS=1

DEFINES+=ENABLE_RDM_MANUFACTURER_PIDS
DEFINES+=ENABLE_CONFIG_PIDS

DEFINES+=USE_SPI_DMA

DEFINES+=DISPLAY_UDF
Expand Down
37 changes: 28 additions & 9 deletions gd32_rdm_responder/firmware/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* THE SOFTWARE.
*/

#include <stddef.h>
#include <cstdio>
#include <cstdint>

Expand All @@ -42,6 +43,7 @@
#if defined (ENABLE_RDM_SUBDEVICES)
# include "rdmsubdevicesparams.h"
#endif
#include "personalities.h"

#include "pixeldmxparams.h"
#include "ws28xxdmx.h"
Expand Down Expand Up @@ -97,8 +99,8 @@ void main() {

PixelDmxConfiguration pixelDmxConfiguration;

StorePixelDmx storePixelDmx;
PixelDmxParams pixelDmxParams(&storePixelDmx);
auto storePixelDmx = StorePixelDmx::Get();
PixelDmxParams pixelDmxParams(storePixelDmx);

if (pixelDmxParams.Load()) {
pixelDmxParams.Dump();
Expand All @@ -125,27 +127,39 @@ void main() {
pixelDmxConfiguration.SetCount(nCount);
}

WS28xxDmx pixelDmx(pixelDmxConfiguration);
pixelDmx.SetWS28xxDmxStore(&storePixelDmx);
WS28xxDmx pixelDmx(pixelDmxConfiguration, storePixelDmx);
pixelDmx.SetWS28xxDmxStore(storePixelDmx);

PixelDmxStartStop pixelDmxStartStop;
pixelDmx.SetPixelDmxHandler(&pixelDmxStartStop);

const auto nTestPattern = static_cast<pixelpatterns::Pattern>(pixelDmxParams.GetTestPattern());
PixelTestPattern pixelTestPattern(nTestPattern, 1);

PixelDmxParamsRdm pixelDmxParamsRdm(&storePixelDmx);

PixelDmxParamsRdm pixelDmxParamsRdm(storePixelDmx);

RDMPersonality *personalities[PERSONALITY_COUNT];
#if defined(ENABLE_CONFIG_PIDS)
static_assert(
PERSONALITY_COUNT == static_cast<size_t>(pixel::Type::UNDEFINED),
"Personality Count != Pixel Type Count");
for (auto n = 0; n < PERSONALITY_COUNT; ++n)
{
const auto description = PixelType::GetType(static_cast<pixel::Type>(n));
personalities[n] = new RDMPersonality(description, &pixelDmx);
}
#else
char aDescription[rdm::personality::DESCRIPTION_MAX_LENGTH];
snprintf(aDescription, sizeof(aDescription) - 1U, "%s:%u G%u [%s]",
PixelType::GetType(pixelDmxConfiguration.GetType()),
pixelDmxConfiguration.GetCount(),
pixelDmxConfiguration.GetGroupingCount(),
PixelType::GetMap(pixelDmxConfiguration.GetMap()));

RDMPersonality *personalities[2] = { new RDMPersonality(aDescription, &pixelDmx), new RDMPersonality("Config mode", &pixelDmxParamsRdm) };

RDMResponder rdmResponder(personalities, 2);
personalities[static_cast<uint8_t>(Personalities::DEFAULT)] = new RDMPersonality(aDescription, &pixelDmx);
personalities[static_cast<uint8_t>(Personalities::CONFIG_MODE)] = new RDMPersonality("Config mode", &pixelDmxParamsRdm)
#endif
RDMResponder rdmResponder(personalities, PERSONALITY_COUNT);

rdmResponder.SetProductCategory(E120_PRODUCT_CATEGORY_FIXTURE);
rdmResponder.SetProductDetail(E120_PRODUCT_DETAIL_LED);
Expand Down Expand Up @@ -183,6 +197,11 @@ void main() {
rdmResponder.DmxDisableOutput(!isConfigMode && (nTestPattern != pixelpatterns::Pattern::NONE));
rdmResponder.Print();

#if defined(ENABLE_CONFIG_PIDS)
const auto nPersonality = Personalities::toPersonalityIdx(Personalities::fromPixelType(pixelDmx.GetType()));
rdmResponder.SetPersonalityCurrent(RDM_ROOT_DEVICE, nPersonality);
#endif

if (isConfigMode) {
pixelDmxParamsRdm.Print();
} else {
Expand Down
52 changes: 52 additions & 0 deletions gd32_rdm_responder/include/personalities.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* personalities.h
*
* Created on: 20 Nov 2023
* Author: marcusbirkin
*/

#ifndef INCLUDE_PERSONALITIES_H_
#define INCLUDE_PERSONALITIES_H_

#include <cstdint>
#include <type_traits>

#include "pixeltype.h"

namespace Personalities
{

enum class Personality : uint8_t {
#if defined(ENABLE_CONFIG_PIDS)
WS2801,
WS2811,
WS2812,
WS2812B,
WS2813,
WS2815,
SK6812,
SK6812W,
UCS1903,
UCS2903,
CS8812,
APA102,
SK9822,
P9813,
#else
DEFAULT,
CONFIG_MODE,
#endif
// Last item
COUNT
};
#define PERSONALITY_COUNT static_cast<std::underlying_type<Personalities::Personality>::type>(Personalities::Personality::COUNT)

uint8_t toPersonalityIdx(Personality personality);
Personality fromPersonalityIdx(uint8_t nPersonality);

pixel::Type toPixelType(Personality personality);
Personality fromPixelType(pixel::Type type);

} // namespace Personalities

#endif /* INCLUDE_PERSONALITIES_H_ */
33 changes: 33 additions & 0 deletions gd32_rdm_responder/lib/personalities.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* personalities.h
*
* Created on: 20 Nov 2023
* Author: marcusbirkin
*/

#include "personalities.h"

#include <cassert>

uint8_t Personalities::toPersonalityIdx(Personality personality)
{
return static_cast<uint8_t>(personality) + 1;
}

Personalities::Personality Personalities::fromPersonalityIdx(uint8_t nPersonality)
{
assert(nPersonality >= 1);
return static_cast<Personalities::Personality>(nPersonality - 1);
}

pixel::Type Personalities::toPixelType(Personalities::Personality personality)
{
assert(static_cast<uint8_t>(personality) < static_cast<uint8_t>(pixel::Type::UNDEFINED));
return static_cast<pixel::Type>(personality);
}

Personalities::Personality Personalities::fromPixelType(pixel::Type type)
{
assert(static_cast<uint8_t>(type) < PERSONALITY_COUNT);
return static_cast<Personalities::Personality>(type);
}
48 changes: 33 additions & 15 deletions gd32_rdm_responder/lib/personalityupdate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,27 @@
* THE SOFTWARE.
*/

#include <cassert>
#include <cstdint>

#include "displayudf.h"
#include "personalities.h"
#include "pixelpatterns.h"
#include "pixeltestpattern.h"
#include "rdmresponder.h"

#include "storepixeldmx.h"
#include "ws28xxdmx.h"
#include "pixeltestpattern.h"
#include "pixelpatterns.h"
#include "displayudf.h"

#include "debug.h"

void RDMResponder::PersonalityUpdate(uint32_t nPersonality) {
DEBUG_PRINTF("nPersonality=%u", nPersonality);

#if defined(ENABLE_CONFIG_PIDS)
const auto type = Personalities::toPixelType(Personalities::fromPersonalityIdx(nPersonality));
StorePixelDmx::Get()->SaveType(type);
#endif

DisplayUdf::Get()->ClearLine(7);
DisplayUdf::Get()->Printf(7, "%s:%d G%d %s",
PixelType::GetType(WS28xxDmx::Get()->GetType()),
Expand All @@ -45,18 +52,29 @@ void RDMResponder::PersonalityUpdate(uint32_t nPersonality) {
PixelType::GetMap(WS28xxDmx::Get()->GetMap()));
DisplayUdf::Get()->Show();

if (nPersonality == 1) {
const auto nTestPattern = PixelTestPattern::GetPattern();
assert(nPersonality < PERSONALITY_COUNT);
switch (nPersonality)
{
default:
{
const auto nTestPattern = PixelTestPattern::GetPattern();

if (nTestPattern == pixelpatterns::Pattern::NONE) {
} else {
DisplayUdf::Get()->ClearLine(6);
DisplayUdf::Get()->Printf(6, "%s:%u", PixelPatterns::GetName(nTestPattern), static_cast<uint32_t>(nTestPattern));
if (nTestPattern == pixelpatterns::Pattern::NONE) {
} else {
DisplayUdf::Get()->ClearLine(6);
DisplayUdf::Get()->Printf(6, "%s:%u", PixelPatterns::GetName(nTestPattern), static_cast<uint32_t>(nTestPattern));
}
break;
}
#if !defined(ENABLE_CONFIG_PIDS)
case Personalities::CONFIG_MODE:
{
DisplayUdf::Get()->ClearLine(3);
DisplayUdf::Get()->ClearLine(4);
DisplayUdf::Get()->Write(4, "Config Mode");
DisplayUdf::Get()->ClearLine(5);
break;
}
} else if (nPersonality == 2) {
DisplayUdf::Get()->ClearLine(3);
DisplayUdf::Get()->ClearLine(4);
DisplayUdf::Get()->Write(4, "Config Mode");
DisplayUdf::Get()->ClearLine(5);
#endif
}
}
9 changes: 6 additions & 3 deletions lib-c++/.settings/language.settings.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1040880586.393757927" name="GD32">
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.346413883" 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 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 copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="841808349858342113" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_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-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
Expand Down
9 changes: 6 additions & 3 deletions lib-c/.settings/language.settings.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1805713348" name="GD32">
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1805713348" name="Default">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider-reference id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" ref="shared-provider"/>
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-754483604307944966" id="org.eclipse.embedcdt.managedbuild.cross.arm.core.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Arm Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_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 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 copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
</extension>
</configuration>
Expand Down
Loading

0 comments on commit 20bb08d

Please sign in to comment.