Skip to content

Instantly share code, notes, and snippets.

@bengtmartensson
Created January 27, 2017 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bengtmartensson/36f8abe3a2951e3f45eb9cc8f567271f to your computer and use it in GitHub Desktop.
Save bengtmartensson/36f8abe3a2951e3f45eb9cc8f567271f to your computer and use it in GitHub Desktop.
Export format for IrScrutinizer using raw format in multiples of tick
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 Bengt Martensson
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<exportformats:exportformat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:exportformats="http://www.harctoolbox.org/exportformats"
xsi:schemaLocation="http://www.harctoolbox.org/exportformats http://www.harctoolbox.org/schemas/exportformats.xsd"
name="C raw ticks" extension="c" multiSignal="true" simpleSequence="false">
<xsl:stylesheet xmlns:girr="http://www.harctoolbox.org/Girr"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
<xsl:param name="tick">50</xsl:param>
<xsl:template match="/girr:remotes">
<xsl:text>/* This file was automatically generated by IrScrutinizer */
const int frequency = </xsl:text>
<xsl:value-of select="girr:remote/girr:commandSet/girr:command/girr:raw/@frequency"/><xsl:text>;
</xsl:text>
<xsl:text>const char *protocol = "</xsl:text><xsl:value-of select="girr:remote/girr:commandSet/girr:command/girr:parameters/@protocol"/><xsl:text>";
</xsl:text>
<xsl:text>const int intro_burst_length = </xsl:text><xsl:value-of select="count(girr:remote/girr:commandSet/girr:command[1]/girr:raw/girr:intro/girr:flash)"/>
<xsl:text>;
const int repeat_burst_length = </xsl:text><xsl:value-of select="count(girr:remote/girr:commandSet/girr:command[1]/girr:raw/girr:repeat/girr:flash)"/>
<xsl:text>;
const int ending_burst_length = </xsl:text><xsl:value-of select="count(girr:remote/girr:commandSet/girr:command[1]/girr:raw/girr:ending/girr:flash)"/>
<xsl:text>;
const int tick = </xsl:text><xsl:value-of select="$tick"/>
<xsl:text>;
</xsl:text>
<xsl:apply-templates select="//girr:command" mode="raw"/>
</xsl:template>
<xsl:template match="girr:command" mode="raw">
<xsl:text>const int raw_</xsl:text>
<xsl:value-of select="girr:parameters/@protocol"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="girr:parameters/girr:parameter[@name='D']/@value"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="girr:parameters/girr:parameter[@name='S']/@value"/>
<xsl:text>_</xsl:text>
<xsl:value-of select="girr:parameters/girr:parameter[@name='F']/@value"/>
<xsl:text>[] = { </xsl:text>
<xsl:apply-templates select="girr:raw[1]"/>
<xsl:text> };
</xsl:text>
</xsl:template>
<xsl:template match="girr:raw">
<xsl:apply-templates select="*/*"/>
</xsl:template>
<xsl:template match="girr:flash|girr:gap"><xsl:value-of select="round(. div $tick)"/><xsl:text>,</xsl:text></xsl:template>
<xsl:template match="girr:raw/*[position()=last()]/girr:gap[position()=last()]"><xsl:value-of select="round(. div $tick)"/></xsl:template>
</xsl:stylesheet>
</exportformats:exportformat>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment