Updated gen_blumen_lumen to be able to output both UART and SACN variants
This commit is contained in:
parent
f261cbd55a
commit
9a643cd5b6
|
@ -61,7 +61,10 @@ BuildLoop(gs_string* OutputBuffer, loop_desc Desc)
|
|||
Channel = Desc.ChannelStart + i;
|
||||
}
|
||||
|
||||
WriteLedStripOpen(OutputBuffer, Channel, Desc.ComPort);
|
||||
u32 SACNUniverseStart = 0;
|
||||
u32 SACNChannelStart = 0;
|
||||
WriteLedStripOpen(OutputBuffer, Channel, Desc.ComPort,
|
||||
SACNUniverseStart, SACNChannelStart);
|
||||
WriteSegmentSequenceOpen(OutputBuffer, Desc.SubsegmentsCount);
|
||||
|
||||
for (u32 j = 0; j < Desc.SubsegmentsCount; j++)
|
||||
|
@ -184,6 +187,7 @@ int main(int ArgCount, char** Args)
|
|||
gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4));
|
||||
gs_string OutputBuffer2 = PushString(Ctx.Transient, MB(4));
|
||||
|
||||
#if 0
|
||||
WriteAssemblyUARTOpen(&OutputBuffer0,
|
||||
"Blumen Lumen - Silver Spring - 00",
|
||||
100,
|
||||
|
@ -202,6 +206,23 @@ int main(int ArgCount, char** Args)
|
|||
v3{1, 0, 0},
|
||||
21,
|
||||
"");
|
||||
#else
|
||||
WriteAssemblySACNOpen(&OutputBuffer0,
|
||||
"Blumen Lumen - Silver Spring - 00",
|
||||
100,
|
||||
v3{-1, 0, 0},
|
||||
21);
|
||||
WriteAssemblySACNOpen(&OutputBuffer1,
|
||||
"Blumen Lumen - Silver Spring - 01",
|
||||
100,
|
||||
v3{0, 0, 0},
|
||||
21);
|
||||
WriteAssemblySACNOpen(&OutputBuffer2,
|
||||
"Blumen Lumen - Silver Spring - 02",
|
||||
100,
|
||||
v3{1, 0, 0},
|
||||
21);
|
||||
#endif
|
||||
|
||||
u32 StripCount = 0;
|
||||
|
||||
|
|
|
@ -8,86 +8,108 @@
|
|||
internal void
|
||||
WriteIndented(gs_string* Buffer, u32 Indent, char* Format, ...)
|
||||
{
|
||||
va_list Args;
|
||||
va_start(Args, Format);
|
||||
va_list Args;
|
||||
va_start(Args, Format);
|
||||
|
||||
for (u32 i = 0; i < Indent; i++)
|
||||
{
|
||||
OutChar(Buffer, '\t');
|
||||
}
|
||||
for (u32 i = 0; i < Indent; i++)
|
||||
{
|
||||
OutChar(Buffer, '\t');
|
||||
}
|
||||
|
||||
PrintFArgsList(Buffer, Format, Args);
|
||||
va_end(Args);
|
||||
PrintFArgsList(Buffer, Format, Args);
|
||||
va_end(Args);
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteAssemblyCommonOpen(gs_string* Buffer, char* Name, u32 Scale, v3 Center, u32 StripCount)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "assembly_name: \"%s\";\n", Name);
|
||||
WriteIndented(Buffer, 0, "assembly_scale: %d;\n", Scale);
|
||||
WriteIndented(Buffer, 0, "assembly_center: (%f, %f, %f);\n", Center.x, Center.y, Center.z);
|
||||
WriteIndented(Buffer, 0, "led_strip_count: %d;\n", StripCount);
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteAssemblyUARTOpen(gs_string* Buffer, char* Name, u32 Scale, v3 Center, u32 StripCount, char* ComPort)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "assembly_name: \"%s\";\n", Name);
|
||||
WriteIndented(Buffer, 0, "assembly_scale: %d;\n", Scale);
|
||||
WriteIndented(Buffer, 0, "assembly_center: (%f, %f, %f);\n", Center.x, Center.y, Center.z);
|
||||
WriteIndented(Buffer, 0, "led_strip_count: %d;\n", StripCount);
|
||||
WriteIndented(Buffer, 0, "output_mode: \"UART\";\n");
|
||||
WriteAssemblyCommonOpen(Buffer, Name, Scale, Center, StripCount);
|
||||
WriteIndented(Buffer, 0, "output_mode: \"UART\";\n");
|
||||
|
||||
if (ComPort)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "com_port: \"%s\";\n", ComPort);
|
||||
}
|
||||
if (ComPort)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "com_port: \"%s\";\n", ComPort);
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteLedStripOpen(gs_string* Buffer, u32 Channel, char* ComPort)
|
||||
WriteAssemblySACNOpen(gs_string* Buffer, char* Name, u32 Scale, v3 Center, u32 StripCount)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "led_strip:\n{\n");
|
||||
WriteIndented(Buffer, 1, "output_uart: {\n");
|
||||
WriteIndented(Buffer, 2, "channel: %d;\n", Channel);
|
||||
WriteIndented(Buffer, 2, "com_port: \"%s\";\n", ComPort);
|
||||
WriteIndented(Buffer, 1, "};\n\n");
|
||||
WriteAssemblyCommonOpen(Buffer, Name, Scale, Center, StripCount);
|
||||
WriteIndented(Buffer, 0, "output_mode: \"SACN\";\n");
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteLedStripOpen(gs_string* Buffer, u32 UARTChannel, char* UARTComPort, u32 SACNStartUniverse, u32 SACNStartChannel)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "led_strip:\n{\n");
|
||||
|
||||
// SACN
|
||||
WriteIndented(Buffer, 1, "output_sacn: {\n");
|
||||
WriteIndented(Buffer, 2, "start_universe: %d;\n", SACNStartUniverse);
|
||||
WriteIndented(Buffer, 2, "start_channel: %d;\n", SACNStartChannel);
|
||||
WriteIndented(Buffer, 1, "};\n\n");
|
||||
|
||||
// UART
|
||||
WriteIndented(Buffer, 1, "output_uart: {\n");
|
||||
WriteIndented(Buffer, 2, "channel: %d;\n", UARTChannel);
|
||||
WriteIndented(Buffer, 2, "com_port: \"%s\";\n", UARTComPort);
|
||||
WriteIndented(Buffer, 1, "};\n\n");
|
||||
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteSegmentSequenceOpen(gs_string* Buffer, u32 SegmentCount)
|
||||
{
|
||||
WriteIndented(Buffer, 1, "segment: {\n");
|
||||
WriteIndented(Buffer, 2, "point_placement_type: \"SegmentSequence\";\n");
|
||||
WriteIndented(Buffer, 2, "segment_sequence:\n");
|
||||
WriteIndented(Buffer, 2, "{\n");
|
||||
WriteIndented(Buffer, 3, "segment_count: %d;\n", SegmentCount);
|
||||
WriteIndented(Buffer, 1, "segment: {\n");
|
||||
WriteIndented(Buffer, 2, "point_placement_type: \"SegmentSequence\";\n");
|
||||
WriteIndented(Buffer, 2, "segment_sequence:\n");
|
||||
WriteIndented(Buffer, 2, "{\n");
|
||||
WriteIndented(Buffer, 3, "segment_count: %d;\n", SegmentCount);
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteSegmentSequenceSegment(gs_string* Buffer, v3 P0, v3 P1, u32 LedCount)
|
||||
{
|
||||
WriteIndented(Buffer, 3, "segment: {\n");
|
||||
WriteIndented(Buffer, 4, "point_placement_type: \"InterpolatePoints\";\n");
|
||||
WriteIndented(Buffer, 4, "interpolate_points: {\n");
|
||||
WriteIndented(Buffer, 5, "start: (%f, %f, %f);\n", P0.x, P0.y, P0.z);
|
||||
WriteIndented(Buffer, 5, "end: (%f, %f, %f);\n", P1.x, P1.y, P1.z);
|
||||
WriteIndented(Buffer, 5, "led_count: %d;\n", LedCount);
|
||||
WriteIndented(Buffer, 4, "};\n");
|
||||
WriteIndented(Buffer, 3, "};\n");
|
||||
WriteIndented(Buffer, 3, "segment: {\n");
|
||||
WriteIndented(Buffer, 4, "point_placement_type: \"InterpolatePoints\";\n");
|
||||
WriteIndented(Buffer, 4, "interpolate_points: {\n");
|
||||
WriteIndented(Buffer, 5, "start: (%f, %f, %f);\n", P0.x, P0.y, P0.z);
|
||||
WriteIndented(Buffer, 5, "end: (%f, %f, %f);\n", P1.x, P1.y, P1.z);
|
||||
WriteIndented(Buffer, 5, "led_count: %d;\n", LedCount);
|
||||
WriteIndented(Buffer, 4, "};\n");
|
||||
WriteIndented(Buffer, 3, "};\n");
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteSegmentSequenceClose(gs_string* Buffer)
|
||||
{
|
||||
WriteIndented(Buffer, 2, "};\n");
|
||||
WriteIndented(Buffer, 1, "};\n");
|
||||
WriteIndented(Buffer, 2, "};\n");
|
||||
WriteIndented(Buffer, 1, "};\n");
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteSegmentTagsOpen(gs_string* Buffer, u32 TagCount)
|
||||
{
|
||||
WriteIndented(Buffer, 1, "tags_count: %d;\n", TagCount);
|
||||
WriteIndented(Buffer, 1, "tags_count: %d;\n", TagCount);
|
||||
}
|
||||
|
||||
internal void
|
||||
WriteSegmentTag(gs_string* Buffer, char* TagName, char* TagValue)
|
||||
{
|
||||
WriteIndented(Buffer, 1, "tag: {\n");
|
||||
WriteIndented(Buffer, 2, "name: \"%s\";\n", TagName);
|
||||
WriteIndented(Buffer, 2, "value: \"%s\";\n", TagValue);
|
||||
WriteIndented(Buffer, 1, "};\n");
|
||||
WriteIndented(Buffer, 1, "tag: {\n");
|
||||
WriteIndented(Buffer, 2, "name: \"%s\";\n", TagName);
|
||||
WriteIndented(Buffer, 2, "value: \"%s\";\n", TagValue);
|
||||
WriteIndented(Buffer, 1, "};\n");
|
||||
|
||||
}
|
||||
|
||||
|
@ -99,7 +121,7 @@ WriteSegmentTagsClose(gs_string* Buffer)
|
|||
internal void
|
||||
WriteLedStripClose(gs_string* Buffer)
|
||||
{
|
||||
WriteIndented(Buffer, 0, "};\n");
|
||||
WriteIndented(Buffer, 0, "};\n");
|
||||
}
|
||||
|
||||
#define SCULPTURE_GEN_H
|
||||
|
|
Loading…
Reference in New Issue