summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Regel <andreas.regel@gmx.de>2015-04-26 09:27:25 +0200
committerAndreas Regel <andreas.regel@gmx.de>2016-04-01 23:47:51 +0200
commitd4622366d9886fcb62a74507af362dbe73573bcc (patch)
treeb9145559f0c6e8a7f05e3d7b05ffca4ffa538ec0
parent110dc03d98ecbb873d399c75e221a8b0e27f060a (diff)
downloadgraphlcd-base-d4622366d9886fcb62a74507af362dbe73573bcc.tar.gz
graphlcd-base-d4622366d9886fcb62a74507af362dbe73573bcc.tar.bz2
Add skintest tool.
-rw-r--r--tools/Makefile4
-rw-r--r--tools/skintest/DejaVuSans.ttfbin0 -> 720012 bytes
-rw-r--r--tools/skintest/Makefile42
-rw-r--r--tools/skintest/skintest.c190
-rw-r--r--tools/skintest/test.skin50
5 files changed, 286 insertions, 0 deletions
diff --git a/tools/Makefile b/tools/Makefile
index 572067b..d923139 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -16,6 +16,7 @@ endif
@$(MAKE) -C showpic all
@$(MAKE) -C showtext all
@$(MAKE) -C lcdtestpattern all
+ @$(MAKE) -C skintest all
install:
@$(MAKE) -C convpic install
@@ -26,6 +27,7 @@ endif
@$(MAKE) -C showpic install
@$(MAKE) -C showtext install
@$(MAKE) -C lcdtestpattern install
+ @$(MAKE) -C skintest install
uninstall:
@$(MAKE) -C convpic uninstall
@@ -36,6 +38,7 @@ endif
@$(MAKE) -C showpic uninstall
@$(MAKE) -C showtext uninstall
@$(MAKE) -C lcdtestpattern uninstall
+ @$(MAKE) -C skintest uninstall
clean:
@$(MAKE) -C convpic clean
@@ -44,4 +47,5 @@ clean:
@$(MAKE) -C showpic clean
@$(MAKE) -C showtext clean
@$(MAKE) -C lcdtestpattern clean
+ @$(MAKE) -C skintest clean
diff --git a/tools/skintest/DejaVuSans.ttf b/tools/skintest/DejaVuSans.ttf
new file mode 100644
index 0000000..2375915
--- /dev/null
+++ b/tools/skintest/DejaVuSans.ttf
Binary files differ
diff --git a/tools/skintest/Makefile b/tools/skintest/Makefile
new file mode 100644
index 0000000..fe73388
--- /dev/null
+++ b/tools/skintest/Makefile
@@ -0,0 +1,42 @@
+#
+# Makefile for the GraphLCD tool showtext
+#
+
+-include ../../Make.config
+
+PRGNAME = skintest
+
+OBJS = skintest.o
+
+INCLUDES += -I../../
+LIBDIRS += -L../../glcdgraphics/ -L../../glcddrivers/ -L../../glcdskin/
+
+
+all: $(PRGNAME)
+.PHONY: all
+
+# Implicit rules:
+
+%.o: %.c
+ $(CXX) $(CXXEXTRA) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
+
+# Dependencies:
+
+DEPFILE = $(OBJS:%.o=%.d)
+
+-include $(DEPFILE)
+
+# The main program:
+
+$(PRGNAME): $(OBJS)
+ $(CXX) $(CXXFLAGS) $(LDFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lglcddrivers -lglcdskin -lstdc++ -o $(PRGNAME)
+
+install: $(PRGNAME)
+ install -d $(BINDIR)
+ install -m 755 -o root -g root $(HAVE_STRIP) $(PRGNAME) $(BINDIR)
+
+uninstall:
+ rm -f $(BINDIR)/$(PRGNAME)
+
+clean:
+ @-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
diff --git a/tools/skintest/skintest.c b/tools/skintest/skintest.c
new file mode 100644
index 0000000..747dd91
--- /dev/null
+++ b/tools/skintest/skintest.c
@@ -0,0 +1,190 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <unistd.h>
+
+#include <string>
+
+#include <glcdgraphics/bitmap.h>
+#include <glcdgraphics/font.h>
+#include <glcddrivers/config.h>
+#include <glcddrivers/driver.h>
+#include <glcddrivers/drivers.h>
+#include <glcdskin/parser.h>
+#include <glcdskin/skin.h>
+#include <glcdskin/config.h>
+#include <glcdskin/string.h>
+
+class cMySkinConfig : public GLCD::cSkinConfig
+{
+private:
+ GLCD::cDriver * mDriver;
+public:
+ cMySkinConfig(GLCD::cDriver * Driver);
+ virtual std::string SkinPath(void);
+ virtual std::string CharSet(void);
+ virtual std::string Translate(const std::string & Text);
+ virtual GLCD::cType GetToken(const GLCD::tSkinToken & Token);
+ virtual GLCD::cDriver * GetDriver(void) const { return mDriver; }
+};
+
+cMySkinConfig::cMySkinConfig(GLCD::cDriver * Driver)
+: mDriver(Driver)
+{
+}
+
+std::string cMySkinConfig::SkinPath(void)
+{
+ return ".";
+}
+
+std::string cMySkinConfig::CharSet(void)
+{
+ return "iso8859-15";
+}
+
+std::string cMySkinConfig::Translate(const std::string & Text)
+{
+ return Text;
+}
+
+GLCD::cType cMySkinConfig::GetToken(const GLCD::tSkinToken & Token)
+{
+ return 10;
+}
+
+
+static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
+
+int main(int argc, char ** argv)
+{
+ static struct option long_options[] =
+ {
+ {"config", required_argument, NULL, 'c'},
+ {"display", required_argument, NULL, 'd'},
+ {"skin", required_argument, NULL, 's'},
+ {"upsidedown", no_argument, NULL, 'u'},
+ {"invert", no_argument, NULL, 'i'},
+ {"brightness", required_argument, NULL, 'b'},
+ {NULL}
+ };
+
+ std::string configName = "";
+ std::string displayName = "";
+ std::string skinFileName = "";
+ bool upsideDown = false;
+ bool invert = false;
+ int brightness = -1;
+ unsigned int displayNumber = 0;
+
+ int c, option_index = 0;
+ while ((c = getopt_long(argc, argv, "c:d:s:uib:", long_options, &option_index)) != -1)
+ {
+ switch (c)
+ {
+ case 'c':
+ configName = optarg;
+ break;
+
+ case 'd':
+ displayName = optarg;
+ break;
+
+ case 's':
+ skinFileName = optarg;
+ break;
+
+ case 'u':
+ upsideDown = true;
+ break;
+
+ case 'i':
+ invert = true;
+ break;
+
+ case 'b':
+ brightness = atoi(optarg);
+ if (brightness < 0) brightness = 0;
+ if (brightness > 100) brightness = 100;
+ break;
+
+ default:
+ //usage();
+ return 1;
+ }
+ }
+
+ if (configName.length() == 0)
+ {
+ configName = kDefaultConfigFile;
+ fprintf(stdout, "WARNING: No config file specified, using default (%s).\n", configName.c_str());
+ }
+
+ if (GLCD::Config.Load(configName) == false)
+ {
+ fprintf(stderr, "Error loading config file!\n");
+ return 1;
+ }
+ if (GLCD::Config.driverConfigs.size() > 0)
+ {
+ if (displayName.length() > 0)
+ {
+ for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
+ {
+ if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
+ break;
+ }
+ if (displayNumber == GLCD::Config.driverConfigs.size())
+ {
+ fprintf(stderr, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
+ return 1;
+ }
+ }
+ else
+ {
+ fprintf(stdout, "WARNING: No display specified, using first one.\n");
+ displayNumber = 0;
+ }
+ }
+ else
+ {
+ fprintf(stderr, "ERROR: No displays specified in config file!\n");
+ return 1;
+ }
+
+ GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
+ GLCD::Config.driverConfigs[displayNumber].invert ^= invert;
+ if (brightness != -1)
+ GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
+
+ GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
+ if (!lcd)
+ {
+ fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
+ return 9;
+ }
+ if (lcd->Init() != 0)
+ {
+ fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
+ delete lcd;
+ return 10;
+ }
+
+ GLCD::cBitmap * screen = new GLCD::cBitmap(lcd->Width(), lcd->Height());
+ screen->Clear();
+
+ cMySkinConfig skinConfig(lcd);
+ GLCD::cSkin * skin = GLCD::XmlParse(skinConfig, "test", skinFileName);
+ skin->SetBaseSize(screen->Width(), screen->Height());
+ GLCD::cSkinDisplay * display = skin->GetDisplay("normal");
+
+ display->Render(screen);
+ lcd->SetScreen(screen->Data(), screen->Width(), screen->Height());
+ lcd->Refresh(true);
+
+ lcd->DeInit();
+ delete lcd;
+
+ return 0;
+}
diff --git a/tools/skintest/test.skin b/tools/skintest/test.skin
new file mode 100644
index 0000000..1632b03
--- /dev/null
+++ b/tools/skintest/test.skin
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<skin version="1.0" name="Demo">
+ <font id="small" url="ft2:DejaVuSans.ttf:10"/>
+ <font id="medium" url="ft2:DejaVuSans.ttf:20"/>
+ <font id="large" url="ft2:DejaVuSans.ttf:20"/>
+
+ <display id="normal">
+ <rectangle x1="0" x2="-1" y1="0" y2="-1" color="black" filled="yes"/>
+<!--
+ <rectangle x1="0" x2="100" y1="5" y2="25" color="white" filled="yes"/>
+ <rectangle x1="10" x2="20" y1="10" y2="20" color="black"/>
+ <rectangle x1="30" x2="40" y1="10" y2="20" color="black" filled="yes"/>
+ <rectangle x1="50" x2="60" y1="10" y2="20" color="black" radius="1"/>
+ <rectangle x1="70" x2="80" y1="10" y2="20" color="black" filled="yes" radius="1"/>
+ <rectangle x1="10" x2="20" y1="30" y2="40" color="white"/>
+ <rectangle x1="30" x2="40" y1="30" y2="40" color="white" filled="yes"/>
+ <rectangle x1="50" x2="60" y1="30" y2="40" color="white" radius="3"/>
+ <rectangle x1="70" x2="80" y1="30" y2="40" color="white" filled="yes" radius="1"/>
+ <line x1="10" x2="40" y1="50" y2="70" color="white" filled="yes" arc="0"/>
+ <line x1="50" x2="80" y1="50" y2="50" color="white" filled="yes" arc="1"/>
+ <line x1="90" x2="90" y1="50" y2="70" color="white" filled="yes" arc="2"/>
+ <slope x1="130" x2="160" y1="50" y2="70" color="white" filled="yes" arc="3"/>
+ <slope x1="170" x2="200" y1="50" y2="70" color="white" filled="yes" arc="4"/>
+ <slope x1="50" x2="80" y1="80" y2="100" color="white" filled="yes" arc="5"/>
+ <slope x1="90" x2="120" y1="80" y2="100" color="white" filled="yes" arc="6"/>
+ <slope x1="130" x2="160" y1="80" y2="100" color="white" filled="yes" arc="7"/>
+
+ <image x="100" y="60" color="white" path="ARTE_l.glcd"/>
+ <image x="100" y="50" color="white" path="ARTE_m.glcd"/>
+ <image x="50" y="50" color="white" condition="or(file('ARTE_m.glcd'),file('ARTE_l.glcd'))" path="ARTE_l.glcd"/>
+-->
+
+ <text x1="0" x2="-1" y1="0" y2="-1" color="white" align="left" font="medium">
+ This is a left aligned text.
+ </text>
+ <text x1="0" x2="-1" y1="20" y2="-1" color="blue" align="right" font="medium">
+ This is a right aligned text.
+ </text>
+ <text x1="0" x2="-1" y1="40" y2="-1" color="red" align="center" font="medium">
+ This is a centered text.
+ </text>
+ <text x1="0" x2="-1" y1="60" y2="-1" color="green" align="left" multiline="yes" font="medium">
+ This is a longer text that should be wrapped. It really works!
+ </text>
+<!--
+-->
+ <rectangle x1="10" x2="-10" y1="-30" y2="-10" color="white"/>
+ <progress x1="12" x2="-12" y1="-28" y2="-12" color="white" direction="0" current="{CurrentProgress}" total="20"/>
+ </display>
+</skin>