Skip to content

Commit

Permalink
Removed dmxreceiver.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Mar 20, 2024
1 parent ae2fc15 commit 145c0a5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 57 deletions.
2 changes: 1 addition & 1 deletion lib-dmxreceiver/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project>
<configuration id="cdt.managedbuild.toolchain.gnu.cross.base.1431542031.377307313.771496257.224943085" name="GD32">
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-663718690343041925" 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">
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="745319254816438599" 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>
Expand Down
52 changes: 26 additions & 26 deletions lib-dmxreceiver/include/dmxreceiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file dmxreceiver.h
*
*/
/* Copyright (C) 2017-2023 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2017-2024 by Arjan van Vught mailto:[email protected]
*
* 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 Down Expand Up @@ -39,12 +39,12 @@
class DMXReceiver: Dmx {
public:
DMXReceiver(LightSet *pLightSet) {
s_pLightSet = pLightSet;
m_pLightSet = pLightSet;
}

~DMXReceiver() {
DMXReceiver::Stop();
s_IsActive = false;
m_IsActive = false;
}

void Start() {
Expand All @@ -53,28 +53,28 @@ class DMXReceiver: Dmx {

void Stop() {
Dmx::SetPortDirection(0, dmx::PortDirection::INP, false);
s_pLightSet->Stop(0);
m_pLightSet->Stop(0);
}

void SetLightSet(LightSet *pLightSet) {
if (pLightSet != s_pLightSet) {
s_pLightSet->Stop(0);
s_pLightSet = pLightSet;
s_IsActive = false;
if (pLightSet != m_pLightSet) {
m_pLightSet->Stop(0);
m_pLightSet = pLightSet;
m_IsActive = false;
}

}

const uint8_t* Run(int16_t &nLength) {
if (__builtin_expect((s_bDisableOutput), 0)) {
const uint8_t *Run(int16_t &nLength) {
if (__builtin_expect((m_bDisableOutput), 0)) {
nLength = 0;
return nullptr;
}

if (Dmx::GetDmxUpdatesPerSecond(0) == 0) {
if (s_IsActive) {
s_pLightSet->Stop(0);
s_IsActive = false;
if (m_IsActive) {
m_pLightSet->Stop(0);
m_IsActive = false;
Hardware::Get()->SetMode(hardware::ledblink::Mode::NORMAL);
}

Expand All @@ -83,21 +83,21 @@ class DMXReceiver: Dmx {
} else {
const auto *pDmx = Dmx::GetDmxAvailable(0);

if (pDmx != nullptr) {
const auto *pDmxStatistics = reinterpret_cast<const struct Data*>(pDmx);
if (__builtin_expect((pDmx != nullptr), 0)) {
const auto *pDmxStatistics = reinterpret_cast<const struct Data *>(pDmx);
nLength = static_cast<int16_t>(pDmxStatistics->Statistics.nSlotsInPacket);

++pDmx;

s_pLightSet->SetData(0, pDmx, static_cast<uint16_t>(nLength));
m_pLightSet->SetData(0, pDmx, static_cast<uint16_t>(nLength));

if (!s_IsActive) {
s_pLightSet->Start(0);
s_IsActive = true;
if (!m_IsActive) {
m_pLightSet->Start(0);
m_IsActive = true;
Hardware::Get()->SetMode(hardware::ledblink::Mode::DATA);
}

return const_cast<uint8_t*>(pDmx);
return const_cast<uint8_t *>(pDmx);
}
}

Expand All @@ -106,25 +106,25 @@ class DMXReceiver: Dmx {
}

void SetDisableOutput(const bool bDisable = true) {
s_bDisableOutput = bDisable;
m_bDisableOutput = bDisable;
}

uint32_t GetUpdatesPerSecond(const uint32_t nPortIndex) {
return Dmx::GetDmxUpdatesPerSecond(nPortIndex);
}

const uint8_t* GetDmxCurrentData(const uint32_t nPortIndex) {
const uint8_t *GetDmxCurrentData(const uint32_t nPortIndex) {
return Dmx::GetDmxCurrentData(nPortIndex);
}

void Print() {
printf(" Output %s\n", s_bDisableOutput ? "disabled" : "enabled");
printf(" Output %s\n", m_bDisableOutput ? "disabled" : "enabled");
}

private:
static LightSet *s_pLightSet;
static bool s_IsActive;
static bool s_bDisableOutput;
LightSet *m_pLightSet { nullptr };
bool m_IsActive { false };
bool m_bDisableOutput { false };
};

#endif /* DMXRECEIVER_H */
30 changes: 0 additions & 30 deletions lib-dmxreceiver/src/dmxreceiver.cpp

This file was deleted.

0 comments on commit 145c0a5

Please sign in to comment.