From 3473ad8820fe80c027acfec76f546d321ef01045 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Thu, 4 Apr 2013 21:01:06 +1000 Subject: [PATCH 1/3] file2c copyright and add comment to output --- tools/file2c/Binaries - Win32/file2c.exe | Bin 9216 -> 9728 bytes .../Source/VS 2012 Project/file2c.v11.suo | Bin 25600 -> 25600 bytes tools/file2c/Source/file2c.c | 48 ++++++++++++++++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/tools/file2c/Binaries - Win32/file2c.exe b/tools/file2c/Binaries - Win32/file2c.exe index d1959ad6551c71987cadafc2580bbdea203f4cfa..333b11383dd11ca03c20c72462fb8f7350a34b05 100644 GIT binary patch delta 2852 zcmc&#ZBSI#89sMefrSf~ZxInMxO^G1?(Y3ucCW6L?a)l9TR{jT>u10#Nx*@AG#VH#Cr&+D=U!+ESCwI2kOKVNBFjsL_Vnq#DG)Way97wa}C%)>6ZG`(Bn+I{DEb z{n0Z#d*1WB?|Hw@Ib46W|LLCjB4?B5TWD!aBOR8EB_osyL|&8(u2k}{`qa8&gd7^< zL}(i8EzHE-2u)$IAQ9q~GrD}tsGP&tq^cA!N&}=S53qvNjRp|G1SJ77loDO3BIz=e zUAmm|0$`R6C-^pXG(X?I5202)C?Eie2atm&b;FpiwqBO-2D!k01gn(d0wX$E_%Z23 ztxdJ+t-xqvFzk)%egbTksGSqRnOp_HF*w_3rTaq z`$Vu8bPcjF47At}Ch9Gj>DST^JKgGdU=+XmE?CH4*Mq~53!mu^s#1bH55>&95xhnO zU(>W#p|F{5A8`STdUA_(P}Wym%}6q%1yaXF-sH@V@lTSk6~Lw-m_tIO!QYnn<*k+FDUu%qLb<+A!QBv}@-M`BTq` zI^KPdlm)G5aTdJQgF9CwdVIKB#MdoS(1}_xH!8~>9G1aJDN}ac<8vikcFn`&TVeCe zdbf!cu^owlqqE4HESet?VCd&Hie5(Di&Fd}DmdwdV2;=tmpzdvRrQ#1Ex`SQ^d3{9 zuR5xhU63AJPiZ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<<;2O9ICcz3gmw|hM4G=K3 z9Gin2=*KY6kEaXd`6c^ z4F!6Udlk&}T6dd17Dc*x|M#OZl^W6hklFxh(1GKr@y0fm|UiUxt|F!TbO3% zSw?3LGkwfiW|$dcZZcEM0@lfvvz08**0POkoNZ?hu&=P4>{0d{`y2LZjQx_$vbWef ztd+~-+*~nN&Mo6sbKmD`xy{^mu8G^jJ;Oc6#krqx8rR9a#vS60a7Veb+;wh}v+*vz zkT2oa^AGTw`E7g?-@@%tepP2umtw*v9!_+9=I|7w5G|FFN_f5iWx zzu#XJC=FBxwgh$sb_Zxaj(%*vAsnJ)7vFfcIi1Mz<#nA|9+GP#6#4WsB}MHXX5;mHSC zj5l|%JYi&2D3`>ko_!A|NV6!=5Z=jwEW(_eK$aX33j=w|lekzW%W!Z^KETbgxr5^X zI|mDrWt&R`0+?6?fFhIY#C0}*5qifgXzLmM$Mbgu)1rTj5@%fIi7|l8+{`Bai)oUC z%j6?M2AfMHP&7&LFfLMH+N9vZw%NsQ591;YmPu+ZVCE(r4IaT{py?2xbzlOBvDwn% nIP)X{4>XrJ^)N1qVAw}-Uew>pFnJ)9NFfcIi1Mz<#nA|9+GP#6#4Wry-MHb`9M_5!? zgn?3 + + This file is part of ChibiOS/GFX. + + ChibiOS/GFX 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. + + ChibiOS/GFX 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 . +*/ #include #include #include @@ -26,7 +45,7 @@ static char *filenameof(char *fname) { static char *clean4c(char *fname) { char *p; - while((p = strpbrk(fname, "-+ `~!@#$%^&*(){}[]|:;'\",<>?/|="))) *p = '_'; + while((p = strpbrk(fname, "-+ `~!@#$%^&*(){}[]|:;'\",<>?/|=.\\"))) *p = '_'; return fname; } @@ -46,7 +65,7 @@ size_t len; size_t i; /* Default values for our parameters */ - opt_progname = argv[0]; + opt_progname = filenameof(argv[0]); opt_inputfile = 0; opt_outputfile = 0; opt_arrayname = 0; @@ -59,6 +78,7 @@ size_t i; if (argv[0][0] == '-') { while (*++(argv[0])) { switch(argv[0][0]) { + case '?': case 'h': goto usage; case 'b': opt_breakblocks = 1; break; case 'c': opt_const = "const "; break; case 's': opt_static = "static "; break; @@ -77,6 +97,7 @@ size_t i; fprintf(stderr, "Usage:\n\t%s -?\n" "\t%s [-bs] [-n name] [inputfile] [outputfile]\n" "\t\t-?\tThis help\n" + "\t\t-h\tThis help\n" "\t\t-b\tBreak the arrays for compilers that won't handle large arrays\n" "\t\t-c\tDeclare the arrays as const (useful to ensure they end up in Flash)\n" "\t\t-s\tDeclare the arrays as static\n" @@ -116,14 +137,33 @@ size_t i; } else f_output = stdout; - /* Set the array name */ + /* Print the comment header */ + fprintf(f_output, "/**\n * This file was generated "); + if (opt_inputfile) fprintf(f_output, "from \"%s\" ", opt_inputfile); + fprintf(f_output, "using...\n *\n *\t%s", opt_progname); + if (opt_arrayname || opt_static[0] || opt_const[0] || opt_breakblocks) { + fprintf(f_output, " -"); + if (opt_breakblocks) fprintf(f_output, "b"); + if (opt_const[0]) fprintf(f_output, "c"); + if (opt_static[0]) fprintf(f_output, "s"); + if (opt_arrayname) fprintf(f_output, "n %s", opt_arrayname); + } + if (opt_inputfile) fprintf(f_output, " %s", opt_inputfile); + if (opt_outputfile) fprintf(f_output, " %s", opt_outputfile); + fprintf(f_output, "\n *\n */\n"); + + /* + * Set the array name. + * We do this after printing opt_inputfile for the last time as we + * modify opt_inputfile in place to generate opt_arrayname. + */ if (!opt_arrayname) { if (opt_inputfile) opt_arrayname = filenameof(opt_inputfile); if (!opt_arrayname || !opt_arrayname[0]) opt_arrayname = "filearray"; - opt_arrayname = clean4c(opt_arrayname); } + opt_arrayname = clean4c(opt_arrayname); /* Read the file processing 1K at a time */ blocknum = 0; From 553b3682faea820f95608a0143153d2676ea2046 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Thu, 4 Apr 2013 21:01:49 +1000 Subject: [PATCH 2/3] Change Memory Reader prototype Change Memory Reader prototype to prevent signed, unsigned warning --- include/gdisp/image.h | 2 +- src/gdisp/image.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/gdisp/image.h b/include/gdisp/image.h index 8e71437b..49b10d42 100644 --- a/include/gdisp/image.h +++ b/include/gdisp/image.h @@ -135,7 +135,7 @@ extern "C" { * * @note Always returns TRUE for a Memory Reader */ - bool_t gdispImageSetMemoryReader(gdispImage *img, const char *memimage); + bool_t gdispImageSetMemoryReader(gdispImage *img, const void *memimage); /** * @brief Sets the io fields in the image structure to routines diff --git a/src/gdisp/image.c b/src/gdisp/image.c index 616aab11..3da0844d 100644 --- a/src/gdisp/image.c +++ b/src/gdisp/image.c @@ -88,10 +88,10 @@ static void ImageMemoryClose(struct gdispImageIO *pio) { static const gdispImageIOFunctions ImageMemoryFunctions = { ImageMemoryRead, ImageMemorySeek, ImageMemoryClose }; -bool_t gdispImageSetMemoryReader(gdispImage *img, const char *memimage) { +bool_t gdispImageSetMemoryReader(gdispImage *img, const void *memimage) { img->io.fns = &ImageMemoryFunctions; img->io.pos = 0; - img->io.fd = (void *)memimage; + img->io.fd = memimage; return TRUE; } From 8b15aab802024434bd8565aebb33368e66532a97 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Thu, 4 Apr 2013 21:02:05 +1000 Subject: [PATCH 3/3] Update demo to use Memory Reader for images --- demos/modules/gdisp/gdisp_images/main.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/demos/modules/gdisp/gdisp_images/main.c b/demos/modules/gdisp/gdisp_images/main.c index 6ca5f640..8f14750e 100644 --- a/demos/modules/gdisp/gdisp_images/main.c +++ b/demos/modules/gdisp/gdisp_images/main.c @@ -22,12 +22,22 @@ #include "hal.h" #include "gfx.h" +#ifdef WIN32 + #define USE_MEMORY_FILE FALSE // Can be true or false for Win32 +#else + #define USE_MEMORY_FILE TRUE // Non-Win32 - use the compiled in image +#endif + +#if USE_MEMORY_FILE + #include "test-pal8.h" +#endif + static gdispImage myImage; int main(void) { coord_t swidth, sheight; - halInit(); // Initialise the Hardware + halInit(); // Initialize the Hardware chSysInit(); // Initialize the OS gdispInit(); // Initialize the display @@ -38,7 +48,11 @@ int main(void) { sheight = gdispGetHeight(); // Set up IO for our image +#if USE_MEMORY_FILE + gdispImageSetMemoryReader(&myImage, test_pal8); +#else gdispImageSetSimulFileReader(&myImage, "test-pal8.bmp"); +#endif gdispImageOpen(&myImage); gdispImageDraw(&myImage, 0, 0, swidth, sheight, 0, 0);