Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Dec 22, 2024
1 parent 3688d5f commit 187223e
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 48 deletions.
3 changes: 3 additions & 0 deletions lib-ltc/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-h3/CMSIS/Core_A/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-tcnet/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-display/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-ws28xx/include}&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.1264361509" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
</tool>
Expand All @@ -133,6 +134,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-h3/CMSIS/Core_A/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-tcnet/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-display/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-ws28xx/include}&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1174771911" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
Expand All @@ -158,6 +160,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-h3/CMSIS/Core_A/Include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-tcnet/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-display/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/lib-ws28xx/include}&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input.1243873717" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.cpp.compiler.input"/>
</tool>
Expand Down
2 changes: 1 addition & 1 deletion lib-ltc/.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.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1369530006503225333" 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="1419596018413518453" 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
19 changes: 13 additions & 6 deletions lib-ltc/include/arm/ltcgenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ enum class Pitch {

class LtcGenerator {
public:
LtcGenerator(const struct ltc::TimeCode *pStartLtcTimeCode, const struct ltc::TimeCode *pStopLtcTimeCode, bool bSkipFree = false);
LtcGenerator(const struct ltc::TimeCode *pStartLtcTimeCode, const struct ltc::TimeCode *pStopLtcTimeCode, bool bSkipFree = false, bool bIgnoreStart = false, bool bIgnoreStop = false);

~LtcGenerator() {
Stop();
Expand Down Expand Up @@ -115,18 +115,25 @@ class LtcGenerator {
ltc::TimeCode *m_pStartLtcTimeCode;
ltc::TimeCode *m_pStopLtcTimeCode;
bool m_bSkipFree;
bool m_bIgnoreStart;
bool m_bIgnoreStop;
int32_t m_nStartSeconds;
int32_t m_nStopSeconds;
uint8_t m_nFps { 0 };
ltcgenerator::Direction m_tDirection { ltcgenerator::Direction::DIRECTION_FORWARD };
float m_fPitchControl { 0 };

uint32_t m_nPitchTicker { 1 };
uint32_t m_nPitchPrevious { 0 };
ltcgenerator::Pitch m_tPitch { ltcgenerator::Pitch::PITCH_FASTER };
float m_fPitchControl { 0 };
uint32_t m_nButtons { 0 };
int m_nHandle { -1 };
int32_t m_nHandle { -1 };
uint32_t m_nBytesReceived { 0 };

char *m_pUdpBuffer { nullptr };

uint8_t m_nFps { 0 };

ltcgenerator::Direction m_tDirection { ltcgenerator::Direction::DIRECTION_FORWARD };
ltcgenerator::Pitch m_tPitch { ltcgenerator::Pitch::PITCH_FASTER };

enum {
STOPPED, STARTED, LIMIT
} m_State { STOPPED };
Expand Down
10 changes: 10 additions & 0 deletions lib-ltc/include/ltcparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ struct Mask {
static constexpr auto SKIP_FREE = (1U << 25);
static constexpr auto TIMECODE_IP = (1U << 26);
static constexpr auto GPS_START = (1U << 27);
static constexpr auto IGNORE_START = (1U << 28);
static constexpr auto IGNORE_STOP = (1U << 29);
};

struct RgbLedType {
Expand Down Expand Up @@ -176,6 +178,14 @@ class LtcParams {
return isMaskSet(ltcparams::Mask::SET_DATE);
}

bool IsIgnoreStart() const {
return isMaskSet(ltcparams::Mask::IGNORE_START);
}

bool IsIgnoreStop() const {
return isMaskSet(ltcparams::Mask::IGNORE_STOP);
}

uint16_t GetOscPort(bool &bIsSet) {
bIsSet = isMaskSet(ltcparams::Mask::OSC_PORT);
return m_Params.nOscPort;
Expand Down
2 changes: 2 additions & 0 deletions lib-ltc/include/ltcparamsconst.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ struct LtcParamsConst {
static inline const char START_SECOND[] = "start_second";
static inline const char START_MINUTE[] = "start_minute";
static inline const char START_HOUR[] = "start_hour";
static inline const char IGNORE_START[] = "ignore_start";
static inline const char STOP_FRAME[] = "stop_frame";
static inline const char STOP_SECOND[] = "stop_second";
static inline const char STOP_MINUTE[] = "stop_minute";
static inline const char STOP_HOUR[] = "stop_hour";
static inline const char IGNORE_STOP[] = "ignore_stop";
static inline const char ALT_FUNCTION[] = "alt_function";
static inline const char SKIP_SECONDS[] = "skip_seconds";
static inline const char SKIP_FREE[] = "skip_free";
Expand Down
26 changes: 11 additions & 15 deletions lib-ltc/src/arm/ltcgenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

// Output
#include "artnetnode.h"
#include "rtpmidi.h"
#include "ltcetc.h"
#include "ltcsender.h"
#include "arm/ltcoutputs.h"
Expand Down Expand Up @@ -122,10 +121,12 @@ static int32_t atoi(const char *pBuffer, uint32_t nSize) {
return sign * res;
}

LtcGenerator::LtcGenerator(const struct ltc::TimeCode* pStartLtcTimeCode, const struct ltc::TimeCode* pStopLtcTimeCode, bool bSkipFree):
LtcGenerator::LtcGenerator(const struct ltc::TimeCode* pStartLtcTimeCode, const struct ltc::TimeCode* pStopLtcTimeCode, bool bSkipFree, bool bIgnoreStart, bool bIgnoreStop):
m_pStartLtcTimeCode(const_cast<struct ltc::TimeCode*>(pStartLtcTimeCode)),
m_pStopLtcTimeCode(const_cast<struct ltc::TimeCode*>(pStopLtcTimeCode)),
m_bSkipFree(bSkipFree),
m_bIgnoreStart(bIgnoreStart),
m_bIgnoreStop(bIgnoreStop),
m_nStartSeconds(GetSeconds(*m_pStartLtcTimeCode)),
m_nStopSeconds(GetSeconds(*m_pStopLtcTimeCode))
{
Expand Down Expand Up @@ -204,10 +205,6 @@ void LtcGenerator::Start() {
ArtNetNode::Get()->SendTimeCode(reinterpret_cast<const struct artnet::TimeCode*>(&g_ltc_LtcTimeCode));
}

if (!ltc::g_DisabledOutputs.bRtpMidi) {
RtpMidi::Get()->SendTimeCode(reinterpret_cast<const struct midi::Timecode *>(&g_ltc_LtcTimeCode));
}

if (!ltc::g_DisabledOutputs.bEtc) {
LtcEtc::Get()->Send(reinterpret_cast<const struct midi::Timecode *>(&g_ltc_LtcTimeCode));
}
Expand Down Expand Up @@ -360,19 +357,22 @@ void LtcGenerator::ActionSetRate(const char *pTimeCodeRate) {
if ((m_State == STOPPED) && (ltc::parse_timecode_rate(pTimeCodeRate, nFps))) {
if (nFps != m_nFps) {
m_nFps = nFps;
//

const auto nType = static_cast<uint8_t>(ltc::g_Type);
g_ltc_LtcTimeCode.nType = nType;
//

m_pStartLtcTimeCode->nType = nType;

if (m_pStartLtcTimeCode->nFrames >= m_nFps) {
m_pStartLtcTimeCode->nFrames = static_cast<uint8_t>(m_nFps - 1);
}

m_pStopLtcTimeCode->nType = nType;

if (m_pStopLtcTimeCode->nFrames >= m_nFps) {
m_pStopLtcTimeCode->nFrames = static_cast<uint8_t>(m_nFps - 1);
}
//

const auto nTimerInterval = TimeCodeConst::TMR_INTV[nType];
#if defined (H3)
H3_TIMER->TMR0_INTV = nTimerInterval;
Expand All @@ -391,10 +391,6 @@ void LtcGenerator::ActionSetRate(const char *pTimeCodeRate) {
ArtNetNode::Get()->SendTimeCode(reinterpret_cast<const struct artnet::TimeCode*>(&g_ltc_LtcTimeCode));
}

if (!ltc::g_DisabledOutputs.bRtpMidi) {
RtpMidi::Get()->SendTimeCode(reinterpret_cast<const struct midi::Timecode *>(&g_ltc_LtcTimeCode));
}

if (!ltc::g_DisabledOutputs.bEtc) {
LtcEtc::Get()->Send(reinterpret_cast<const struct midi::Timecode *>(&g_ltc_LtcTimeCode));
}
Expand Down Expand Up @@ -634,7 +630,7 @@ void LtcGenerator::Print() {
}

void LtcGenerator::Increment() {
if (__builtin_expect((memcmp(&g_ltc_LtcTimeCode, m_pStopLtcTimeCode, sizeof(struct ltc::TimeCode)) == 0), 0)) {
if ((!m_bIgnoreStop) && (__builtin_expect((memcmp(&g_ltc_LtcTimeCode, m_pStopLtcTimeCode, sizeof(struct ltc::TimeCode)) == 0), 0))) {
if (m_State == STARTED) {
m_State = LIMIT;
}
Expand Down Expand Up @@ -669,7 +665,7 @@ void LtcGenerator::Increment() {
}

void LtcGenerator::Decrement() {
if (__builtin_expect((memcmp(&g_ltc_LtcTimeCode, m_pStartLtcTimeCode, sizeof(struct ltc::TimeCode)) == 0), 0)) {
if ((!m_bIgnoreStart) && (__builtin_expect((memcmp(&g_ltc_LtcTimeCode, m_pStartLtcTimeCode, sizeof(struct ltc::TimeCode)) == 0), 0))) {
if (m_State == STARTED) {
m_State = LIMIT;
}
Expand Down
74 changes: 48 additions & 26 deletions lib-ltc/src/ltcparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
* THE SOFTWARE.
*/

#if !defined(__clang__) // Needed for compiling on MacOS
# pragma GCC push_options
# pragma GCC optimize ("Os")
#if defined (DEBUG_LTCPARAMS)
# undef NDEBUG
#endif

#include <cstdint>
Expand Down Expand Up @@ -328,6 +327,24 @@ void LtcParams::callbackFunction(const char* pLine) {
return;
}

if (Sscan::Uint8(pLine, LtcParamsConst::IGNORE_START, nValue8) == Sscan::OK) {
if (nValue8 != 0) {
m_Params.nSetList |= ltcparams::Mask::IGNORE_START;
} else {
m_Params.nSetList &= ~ltcparams::Mask::IGNORE_START;
}
return;
}

if (Sscan::Uint8(pLine, LtcParamsConst::IGNORE_STOP, nValue8) == Sscan::OK) {
if (nValue8 != 0) {
m_Params.nSetList |= ltcparams::Mask::IGNORE_STOP;
} else {
m_Params.nSetList &= ~ltcparams::Mask::IGNORE_STOP;
}
return;
}

if (Sscan::Uint8(pLine, LtcParamsConst::OSC_ENABLE, nValue8) == Sscan::OK) {
if (nValue8 != 0) {
m_Params.nSetList |= ltcparams::Mask::OSC_ENABLE;
Expand Down Expand Up @@ -392,7 +409,7 @@ void LtcParams::callbackFunction(const char* pLine) {
}
}

void LtcParams::Set(struct ltc::TimeCode *ptStartTimeCode, struct ltc::TimeCode *ptStopTimeCode) {
void LtcParams::Set(struct ltc::TimeCode *pStartTimeCode, struct ltc::TimeCode *pStopTimeCode) {
ltc::g_DisabledOutputs.bOled = isDisabledOutputMaskSet(LtcParamsMaskDisabledOutputs::DISPLAY);
ltc::g_DisabledOutputs.bMax7219 = isDisabledOutputMaskSet(LtcParamsMaskDisabledOutputs::MAX7219);
ltc::g_DisabledOutputs.bMidi = isDisabledOutputMaskSet(LtcParamsMaskDisabledOutputs::MIDI);
Expand All @@ -412,63 +429,63 @@ void LtcParams::Set(struct ltc::TimeCode *ptStartTimeCode, struct ltc::TimeCode
ltc::g_DisabledOutputs.bRgbPanel = true;
#endif

assert(ptStartTimeCode != nullptr);
assert(pStartTimeCode != nullptr);

if ((isMaskSet(ltcparams::Mask::START_FRAME)) || (isMaskSet(ltcparams::Mask::START_SECOND)) || (isMaskSet(ltcparams::Mask::START_MINUTE)) || (isMaskSet(ltcparams::Mask::START_HOUR)) ) {
memset(ptStartTimeCode, 0, sizeof(struct ltc::TimeCode));
memset(pStartTimeCode, 0, sizeof(struct ltc::TimeCode));

if (isMaskSet(ltcparams::Mask::START_FRAME)) {
ptStartTimeCode->nFrames = m_Params.nStartFrame;
pStartTimeCode->nFrames = m_Params.nStartFrame;
}

if (isMaskSet(ltcparams::Mask::START_SECOND)) {
ptStartTimeCode->nSeconds = m_Params.nStartSecond;
pStartTimeCode->nSeconds = m_Params.nStartSecond;
}

if (isMaskSet(ltcparams::Mask::START_MINUTE)) {
ptStartTimeCode->nMinutes = m_Params.nStartMinute;
pStartTimeCode->nMinutes = m_Params.nStartMinute;
}

if (isMaskSet(ltcparams::Mask::START_HOUR)) {
ptStartTimeCode->nHours = m_Params.nStartHour;
pStartTimeCode->nHours = m_Params.nStartHour;
}
} else {
ptStartTimeCode->nFrames = m_Params.nStartFrame;
ptStartTimeCode->nSeconds = m_Params.nStartSecond;
ptStartTimeCode->nMinutes = m_Params.nStartMinute;
ptStartTimeCode->nHours = m_Params.nStartHour;
pStartTimeCode->nFrames = m_Params.nStartFrame;
pStartTimeCode->nSeconds = m_Params.nStartSecond;
pStartTimeCode->nMinutes = m_Params.nStartMinute;
pStartTimeCode->nHours = m_Params.nStartHour;
}

ptStartTimeCode->nType = static_cast<uint8_t>(ltc::g_Type);
pStartTimeCode->nType = static_cast<uint8_t>(ltc::g_Type);

assert(ptStopTimeCode != nullptr);
assert(pStopTimeCode != nullptr);

if ((isMaskSet(ltcparams::Mask::STOP_FRAME)) || (isMaskSet(ltcparams::Mask::STOP_SECOND)) || (isMaskSet(ltcparams::Mask::STOP_MINUTE)) || (isMaskSet(ltcparams::Mask::STOP_HOUR)) ) {
memset(ptStopTimeCode, 0, sizeof(struct ltc::TimeCode));
memset(pStopTimeCode, 0, sizeof(struct ltc::TimeCode));

if (isMaskSet(ltcparams::Mask::STOP_FRAME)) {
ptStopTimeCode->nFrames = m_Params.nStopFrame;
pStopTimeCode->nFrames = m_Params.nStopFrame;
}

if (isMaskSet(ltcparams::Mask::STOP_SECOND)) {
ptStopTimeCode->nSeconds = m_Params.nStopSecond;
pStopTimeCode->nSeconds = m_Params.nStopSecond;
}

if (isMaskSet(ltcparams::Mask::STOP_MINUTE)) {
ptStopTimeCode->nMinutes = m_Params.nStopMinute;
pStopTimeCode->nMinutes = m_Params.nStopMinute;
}

if (isMaskSet(ltcparams::Mask::STOP_HOUR)) {
ptStopTimeCode->nHours = m_Params.nStopHour;
pStopTimeCode->nHours = m_Params.nStopHour;
}
} else {
ptStopTimeCode->nFrames = m_Params.nStopFrame;
ptStopTimeCode->nSeconds = m_Params.nStopSecond;
ptStopTimeCode->nMinutes = m_Params.nStopMinute;
ptStopTimeCode->nHours = m_Params.nStopHour;
pStopTimeCode->nFrames = m_Params.nStopFrame;
pStopTimeCode->nSeconds = m_Params.nStopSecond;
pStopTimeCode->nMinutes = m_Params.nStopMinute;
pStopTimeCode->nHours = m_Params.nStopHour;
}

ptStopTimeCode->nType = static_cast<uint8_t>(ltc::g_Type);
pStopTimeCode->nType = static_cast<uint8_t>(ltc::g_Type);
}

void LtcParams::staticCallbackFunction(void *p, const char *s) {
Expand Down Expand Up @@ -522,6 +539,8 @@ void LtcParams::Builder(const struct ltcparams::Params *ptLtcParams, char *pBuff
builder.Add(LtcParamsConst::STOP_SECOND, m_Params.nStopSecond, isMaskSet(ltcparams::Mask::STOP_SECOND));
builder.Add(LtcParamsConst::STOP_FRAME, m_Params.nStopFrame, isMaskSet(ltcparams::Mask::STOP_FRAME));
builder.Add(LtcParamsConst::SKIP_FREE, m_Params.nSkipFree, isMaskSet(ltcparams::Mask::SKIP_FREE));
builder.Add(LtcParamsConst::IGNORE_START, isMaskSet(ltcparams::Mask::IGNORE_START));
builder.Add(LtcParamsConst::IGNORE_STOP, isMaskSet(ltcparams::Mask::IGNORE_STOP));
builder.AddComment("MCP buttons");
builder.Add(LtcParamsConst::ALT_FUNCTION, isMaskSet(ltcparams::Mask::ALT_FUNCTION));
builder.Add(LtcParamsConst::SKIP_SECONDS, m_Params.nSkipSeconds, isMaskSet(ltcparams::Mask::SKIP_SECONDS));
Expand Down Expand Up @@ -664,6 +683,9 @@ void LtcParams::Dump() {
printf(" %s=%d\n", LtcParamsConst::SKIP_SECONDS, m_Params.nSkipSeconds);
}

printf(" %s=%d\n", LtcParamsConst::IGNORE_START, isMaskSet(ltcparams::Mask::IGNORE_START));
printf(" %s=%d\n", LtcParamsConst::IGNORE_STOP, isMaskSet(ltcparams::Mask::IGNORE_STOP));

#if 0
if (isMaskSet(ltcparams::Mask::SET_DATE)) {
printf(" %s=%d\n", LtcParamsConst::SET_DATE, m_Params.nSetDate);
Expand Down

0 comments on commit 187223e

Please sign in to comment.