added graphlcd-base
authorroot@rika
Wed, 06 Feb 2008 17:32:55 +0000
changeset 4df6a40031aa5
parent 3 d0e62fc47285
child 5 37602e25a04a
added graphlcd-base
graphlcd-base/COPYING
graphlcd-base/HISTORY
graphlcd-base/Make.config
graphlcd-base/Makefile
graphlcd-base/README
graphlcd-base/docs/DRIVER.framebuffer
graphlcd-base/docs/DRIVER.gu126x64D-K610A4
graphlcd-base/docs/DRIVER.gu140x32f
graphlcd-base/docs/DRIVER.gu256x64-372
graphlcd-base/docs/DRIVER.gu256x64-3900
graphlcd-base/docs/DRIVER.hd61830
graphlcd-base/docs/DRIVER.image
graphlcd-base/docs/DRIVER.ks0108
graphlcd-base/docs/DRIVER.noritake800
graphlcd-base/docs/DRIVER.sed1330
graphlcd-base/docs/DRIVER.sed1520
graphlcd-base/docs/DRIVER.serdisp
graphlcd-base/docs/DRIVER.simlcd
graphlcd-base/docs/DRIVER.t6963c
graphlcd-base/docs/README.convpic
graphlcd-base/docs/README.crtfont
graphlcd-base/docs/README.showpic
graphlcd-base/docs/README.showtext
graphlcd-base/glcddrivers/Makefile
graphlcd-base/glcddrivers/avrctl.c
graphlcd-base/glcddrivers/avrctl.h
graphlcd-base/glcddrivers/common.c
graphlcd-base/glcddrivers/common.h
graphlcd-base/glcddrivers/config.c
graphlcd-base/glcddrivers/config.h
graphlcd-base/glcddrivers/driver.c
graphlcd-base/glcddrivers/driver.h
graphlcd-base/glcddrivers/drivers.c
graphlcd-base/glcddrivers/drivers.h
graphlcd-base/glcddrivers/framebuffer.c
graphlcd-base/glcddrivers/framebuffer.h
graphlcd-base/glcddrivers/g15daemon.c
graphlcd-base/glcddrivers/g15daemon.h
graphlcd-base/glcddrivers/gu126x64D-K610A4.c
graphlcd-base/glcddrivers/gu126x64D-K610A4.h
graphlcd-base/glcddrivers/gu140x32f.c
graphlcd-base/glcddrivers/gu140x32f.h
graphlcd-base/glcddrivers/gu256x64-372.c
graphlcd-base/glcddrivers/gu256x64-372.h
graphlcd-base/glcddrivers/gu256x64-3900.c
graphlcd-base/glcddrivers/gu256x64-3900.h
graphlcd-base/glcddrivers/hd61830.c
graphlcd-base/glcddrivers/hd61830.h
graphlcd-base/glcddrivers/image.c
graphlcd-base/glcddrivers/image.h
graphlcd-base/glcddrivers/ks0108.c
graphlcd-base/glcddrivers/ks0108.h
graphlcd-base/glcddrivers/network.c
graphlcd-base/glcddrivers/network.h
graphlcd-base/glcddrivers/noritake800.c
graphlcd-base/glcddrivers/noritake800.h
graphlcd-base/glcddrivers/port.c
graphlcd-base/glcddrivers/port.h
graphlcd-base/glcddrivers/sed1330.c
graphlcd-base/glcddrivers/sed1330.h
graphlcd-base/glcddrivers/sed1520.c
graphlcd-base/glcddrivers/sed1520.h
graphlcd-base/glcddrivers/serdisp.c
graphlcd-base/glcddrivers/serdisp.h
graphlcd-base/glcddrivers/simlcd.c
graphlcd-base/glcddrivers/simlcd.h
graphlcd-base/glcddrivers/t6963c.c
graphlcd-base/glcddrivers/t6963c.h
graphlcd-base/glcdgraphics/Makefile
graphlcd-base/glcdgraphics/bitmap.c
graphlcd-base/glcdgraphics/bitmap.h
graphlcd-base/glcdgraphics/common.c
graphlcd-base/glcdgraphics/common.h
graphlcd-base/glcdgraphics/font.c
graphlcd-base/glcdgraphics/font.h
graphlcd-base/glcdgraphics/glcd.c
graphlcd-base/glcdgraphics/glcd.h
graphlcd-base/glcdgraphics/image.c
graphlcd-base/glcdgraphics/image.h
graphlcd-base/glcdgraphics/imagefile.c
graphlcd-base/glcdgraphics/imagefile.h
graphlcd-base/glcdgraphics/pbm.c
graphlcd-base/glcdgraphics/pbm.h
graphlcd-base/graphlcd.conf
graphlcd-base/tools/Makefile
graphlcd-base/tools/convpic/Makefile
graphlcd-base/tools/convpic/bmp.c
graphlcd-base/tools/convpic/bmp.h
graphlcd-base/tools/convpic/c_bmp2glcd
graphlcd-base/tools/convpic/c_tif2glcd
graphlcd-base/tools/convpic/convall
graphlcd-base/tools/convpic/convpic.c
graphlcd-base/tools/convpic/formats.txt
graphlcd-base/tools/convpic/tiff.c
graphlcd-base/tools/convpic/tiff.h
graphlcd-base/tools/convpic/tuxbox.c
graphlcd-base/tools/convpic/tuxbox.h
graphlcd-base/tools/crtfont/Makefile
graphlcd-base/tools/crtfont/crtfont.c
graphlcd-base/tools/genfont/Makefile
graphlcd-base/tools/genfont/genfont.c
graphlcd-base/tools/lcdtestpattern/Makefile
graphlcd-base/tools/lcdtestpattern/lcdtestpattern.c
graphlcd-base/tools/showpic/Makefile
graphlcd-base/tools/showpic/showpic.c
graphlcd-base/tools/showtext/Makefile
graphlcd-base/tools/showtext/showtext.c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/graphlcd-base/COPYING	Wed Feb 06 17:32:55 2008 +0000
     1.3 @@ -0,0 +1,340 @@
     1.4 +		    GNU GENERAL PUBLIC LICENSE
     1.5 +		       Version 2, June 1991
     1.6 +
     1.7 + Copyright (C) 1989, 1991 Free Software Foundation, Inc.
     1.8 +                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     1.9 + Everyone is permitted to copy and distribute verbatim copies
    1.10 + of this license document, but changing it is not allowed.
    1.11 +
    1.12 +			    Preamble
    1.13 +
    1.14 +  The licenses for most software are designed to take away your
    1.15 +freedom to share and change it.  By contrast, the GNU General Public
    1.16 +License is intended to guarantee your freedom to share and change free
    1.17 +software--to make sure the software is free for all its users.  This
    1.18 +General Public License applies to most of the Free Software
    1.19 +Foundation's software and to any other program whose authors commit to
    1.20 +using it.  (Some other Free Software Foundation software is covered by
    1.21 +the GNU Library General Public License instead.)  You can apply it to
    1.22 +your programs, too.
    1.23 +
    1.24 +  When we speak of free software, we are referring to freedom, not
    1.25 +price.  Our General Public Licenses are designed to make sure that you
    1.26 +have the freedom to distribute copies of free software (and charge for
    1.27 +this service if you wish), that you receive source code or can get it
    1.28 +if you want it, that you can change the software or use pieces of it
    1.29 +in new free programs; and that you know you can do these things.
    1.30 +
    1.31 +  To protect your rights, we need to make restrictions that forbid
    1.32 +anyone to deny you these rights or to ask you to surrender the rights.
    1.33 +These restrictions translate to certain responsibilities for you if you
    1.34 +distribute copies of the software, or if you modify it.
    1.35 +
    1.36 +  For example, if you distribute copies of such a program, whether
    1.37 +gratis or for a fee, you must give the recipients all the rights that
    1.38 +you have.  You must make sure that they, too, receive or can get the
    1.39 +source code.  And you must show them these terms so they know their
    1.40 +rights.
    1.41 +
    1.42 +  We protect your rights with two steps: (1) copyright the software, and
    1.43 +(2) offer you this license which gives you legal permission to copy,
    1.44 +distribute and/or modify the software.
    1.45 +
    1.46 +  Also, for each author's protection and ours, we want to make certain
    1.47 +that everyone understands that there is no warranty for this free
    1.48 +software.  If the software is modified by someone else and passed on, we
    1.49 +want its recipients to know that what they have is not the original, so
    1.50 +that any problems introduced by others will not reflect on the original
    1.51 +authors' reputations.
    1.52 +
    1.53 +  Finally, any free program is threatened constantly by software
    1.54 +patents.  We wish to avoid the danger that redistributors of a free
    1.55 +program will individually obtain patent licenses, in effect making the
    1.56 +program proprietary.  To prevent this, we have made it clear that any
    1.57 +patent must be licensed for everyone's free use or not licensed at all.
    1.58 +
    1.59 +  The precise terms and conditions for copying, distribution and
    1.60 +modification follow.
    1.61 +
    1.62 +		    GNU GENERAL PUBLIC LICENSE
    1.63 +   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
    1.64 +
    1.65 +  0. This License applies to any program or other work which contains
    1.66 +a notice placed by the copyright holder saying it may be distributed
    1.67 +under the terms of this General Public License.  The "Program", below,
    1.68 +refers to any such program or work, and a "work based on the Program"
    1.69 +means either the Program or any derivative work under copyright law:
    1.70 +that is to say, a work containing the Program or a portion of it,
    1.71 +either verbatim or with modifications and/or translated into another
    1.72 +language.  (Hereinafter, translation is included without limitation in
    1.73 +the term "modification".)  Each licensee is addressed as "you".
    1.74 +
    1.75 +Activities other than copying, distribution and modification are not
    1.76 +covered by this License; they are outside its scope.  The act of
    1.77 +running the Program is not restricted, and the output from the Program
    1.78 +is covered only if its contents constitute a work based on the
    1.79 +Program (independent of having been made by running the Program).
    1.80 +Whether that is true depends on what the Program does.
    1.81 +
    1.82 +  1. You may copy and distribute verbatim copies of the Program's
    1.83 +source code as you receive it, in any medium, provided that you
    1.84 +conspicuously and appropriately publish on each copy an appropriate
    1.85 +copyright notice and disclaimer of warranty; keep intact all the
    1.86 +notices that refer to this License and to the absence of any warranty;
    1.87 +and give any other recipients of the Program a copy of this License
    1.88 +along with the Program.
    1.89 +
    1.90 +You may charge a fee for the physical act of transferring a copy, and
    1.91 +you may at your option offer warranty protection in exchange for a fee.
    1.92 +
    1.93 +  2. You may modify your copy or copies of the Program or any portion
    1.94 +of it, thus forming a work based on the Program, and copy and
    1.95 +distribute such modifications or work under the terms of Section 1
    1.96 +above, provided that you also meet all of these conditions:
    1.97 +
    1.98 +    a) You must cause the modified files to carry prominent notices
    1.99 +    stating that you changed the files and the date of any change.
   1.100 +
   1.101 +    b) You must cause any work that you distribute or publish, that in
   1.102 +    whole or in part contains or is derived from the Program or any
   1.103 +    part thereof, to be licensed as a whole at no charge to all third
   1.104 +    parties under the terms of this License.
   1.105 +
   1.106 +    c) If the modified program normally reads commands interactively
   1.107 +    when run, you must cause it, when started running for such
   1.108 +    interactive use in the most ordinary way, to print or display an
   1.109 +    announcement including an appropriate copyright notice and a
   1.110 +    notice that there is no warranty (or else, saying that you provide
   1.111 +    a warranty) and that users may redistribute the program under
   1.112 +    these conditions, and telling the user how to view a copy of this
   1.113 +    License.  (Exception: if the Program itself is interactive but
   1.114 +    does not normally print such an announcement, your work based on
   1.115 +    the Program is not required to print an announcement.)
   1.116 +
   1.117 +These requirements apply to the modified work as a whole.  If
   1.118 +identifiable sections of that work are not derived from the Program,
   1.119 +and can be reasonably considered independent and separate works in
   1.120 +themselves, then this License, and its terms, do not apply to those
   1.121 +sections when you distribute them as separate works.  But when you
   1.122 +distribute the same sections as part of a whole which is a work based
   1.123 +on the Program, the distribution of the whole must be on the terms of
   1.124 +this License, whose permissions for other licensees extend to the
   1.125 +entire whole, and thus to each and every part regardless of who wrote it.
   1.126 +
   1.127 +Thus, it is not the intent of this section to claim rights or contest
   1.128 +your rights to work written entirely by you; rather, the intent is to
   1.129 +exercise the right to control the distribution of derivative or
   1.130 +collective works based on the Program.
   1.131 +
   1.132 +In addition, mere aggregation of another work not based on the Program
   1.133 +with the Program (or with a work based on the Program) on a volume of
   1.134 +a storage or distribution medium does not bring the other work under
   1.135 +the scope of this License.
   1.136 +
   1.137 +  3. You may copy and distribute the Program (or a work based on it,
   1.138 +under Section 2) in object code or executable form under the terms of
   1.139 +Sections 1 and 2 above provided that you also do one of the following:
   1.140 +
   1.141 +    a) Accompany it with the complete corresponding machine-readable
   1.142 +    source code, which must be distributed under the terms of Sections
   1.143 +    1 and 2 above on a medium customarily used for software interchange; or,
   1.144 +
   1.145 +    b) Accompany it with a written offer, valid for at least three
   1.146 +    years, to give any third party, for a charge no more than your
   1.147 +    cost of physically performing source distribution, a complete
   1.148 +    machine-readable copy of the corresponding source code, to be
   1.149 +    distributed under the terms of Sections 1 and 2 above on a medium
   1.150 +    customarily used for software interchange; or,
   1.151 +
   1.152 +    c) Accompany it with the information you received as to the offer
   1.153 +    to distribute corresponding source code.  (This alternative is
   1.154 +    allowed only for noncommercial distribution and only if you
   1.155 +    received the program in object code or executable form with such
   1.156 +    an offer, in accord with Subsection b above.)
   1.157 +
   1.158 +The source code for a work means the preferred form of the work for
   1.159 +making modifications to it.  For an executable work, complete source
   1.160 +code means all the source code for all modules it contains, plus any
   1.161 +associated interface definition files, plus the scripts used to
   1.162 +control compilation and installation of the executable.  However, as a
   1.163 +special exception, the source code distributed need not include
   1.164 +anything that is normally distributed (in either source or binary
   1.165 +form) with the major components (compiler, kernel, and so on) of the
   1.166 +operating system on which the executable runs, unless that component
   1.167 +itself accompanies the executable.
   1.168 +
   1.169 +If distribution of executable or object code is made by offering
   1.170 +access to copy from a designated place, then offering equivalent
   1.171 +access to copy the source code from the same place counts as
   1.172 +distribution of the source code, even though third parties are not
   1.173 +compelled to copy the source along with the object code.
   1.174 +
   1.175 +  4. You may not copy, modify, sublicense, or distribute the Program
   1.176 +except as expressly provided under this License.  Any attempt
   1.177 +otherwise to copy, modify, sublicense or distribute the Program is
   1.178 +void, and will automatically terminate your rights under this License.
   1.179 +However, parties who have received copies, or rights, from you under
   1.180 +this License will not have their licenses terminated so long as such
   1.181 +parties remain in full compliance.
   1.182 +
   1.183 +  5. You are not required to accept this License, since you have not
   1.184 +signed it.  However, nothing else grants you permission to modify or
   1.185 +distribute the Program or its derivative works.  These actions are
   1.186 +prohibited by law if you do not accept this License.  Therefore, by
   1.187 +modifying or distributing the Program (or any work based on the
   1.188 +Program), you indicate your acceptance of this License to do so, and
   1.189 +all its terms and conditions for copying, distributing or modifying
   1.190 +the Program or works based on it.
   1.191 +
   1.192 +  6. Each time you redistribute the Program (or any work based on the
   1.193 +Program), the recipient automatically receives a license from the
   1.194 +original licensor to copy, distribute or modify the Program subject to
   1.195 +these terms and conditions.  You may not impose any further
   1.196 +restrictions on the recipients' exercise of the rights granted herein.
   1.197 +You are not responsible for enforcing compliance by third parties to
   1.198 +this License.
   1.199 +
   1.200 +  7. If, as a consequence of a court judgment or allegation of patent
   1.201 +infringement or for any other reason (not limited to patent issues),
   1.202 +conditions are imposed on you (whether by court order, agreement or
   1.203 +otherwise) that contradict the conditions of this License, they do not
   1.204 +excuse you from the conditions of this License.  If you cannot
   1.205 +distribute so as to satisfy simultaneously your obligations under this
   1.206 +License and any other pertinent obligations, then as a consequence you
   1.207 +may not distribute the Program at all.  For example, if a patent
   1.208 +license would not permit royalty-free redistribution of the Program by
   1.209 +all those who receive copies directly or indirectly through you, then
   1.210 +the only way you could satisfy both it and this License would be to
   1.211 +refrain entirely from distribution of the Program.
   1.212 +
   1.213 +If any portion of this section is held invalid or unenforceable under
   1.214 +any particular circumstance, the balance of the section is intended to
   1.215 +apply and the section as a whole is intended to apply in other
   1.216 +circumstances.
   1.217 +
   1.218 +It is not the purpose of this section to induce you to infringe any
   1.219 +patents or other property right claims or to contest validity of any
   1.220 +such claims; this section has the sole purpose of protecting the
   1.221 +integrity of the free software distribution system, which is
   1.222 +implemented by public license practices.  Many people have made
   1.223 +generous contributions to the wide range of software distributed
   1.224 +through that system in reliance on consistent application of that
   1.225 +system; it is up to the author/donor to decide if he or she is willing
   1.226 +to distribute software through any other system and a licensee cannot
   1.227 +impose that choice.
   1.228 +
   1.229 +This section is intended to make thoroughly clear what is believed to
   1.230 +be a consequence of the rest of this License.
   1.231 +
   1.232 +  8. If the distribution and/or use of the Program is restricted in
   1.233 +certain countries either by patents or by copyrighted interfaces, the
   1.234 +original copyright holder who places the Program under this License
   1.235 +may add an explicit geographical distribution limitation excluding
   1.236 +those countries, so that distribution is permitted only in or among
   1.237 +countries not thus excluded.  In such case, this License incorporates
   1.238 +the limitation as if written in the body of this License.
   1.239 +
   1.240 +  9. The Free Software Foundation may publish revised and/or new versions
   1.241 +of the General Public License from time to time.  Such new versions will
   1.242 +be similar in spirit to the present version, but may differ in detail to
   1.243 +address new problems or concerns.
   1.244 +
   1.245 +Each version is given a distinguishing version number.  If the Program
   1.246 +specifies a version number of this License which applies to it and "any
   1.247 +later version", you have the option of following the terms and conditions
   1.248 +either of that version or of any later version published by the Free
   1.249 +Software Foundation.  If the Program does not specify a version number of
   1.250 +this License, you may choose any version ever published by the Free Software
   1.251 +Foundation.
   1.252 +
   1.253 +  10. If you wish to incorporate parts of the Program into other free
   1.254 +programs whose distribution conditions are different, write to the author
   1.255 +to ask for permission.  For software which is copyrighted by the Free
   1.256 +Software Foundation, write to the Free Software Foundation; we sometimes
   1.257 +make exceptions for this.  Our decision will be guided by the two goals
   1.258 +of preserving the free status of all derivatives of our free software and
   1.259 +of promoting the sharing and reuse of software generally.
   1.260 +
   1.261 +			    NO WARRANTY
   1.262 +
   1.263 +  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
   1.264 +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
   1.265 +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
   1.266 +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
   1.267 +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
   1.268 +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
   1.269 +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
   1.270 +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
   1.271 +REPAIR OR CORRECTION.
   1.272 +
   1.273 +  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
   1.274 +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
   1.275 +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
   1.276 +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
   1.277 +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
   1.278 +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
   1.279 +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
   1.280 +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
   1.281 +POSSIBILITY OF SUCH DAMAGES.
   1.282 +
   1.283 +		     END OF TERMS AND CONDITIONS
   1.284 +
   1.285 +	    How to Apply These Terms to Your New Programs
   1.286 +
   1.287 +  If you develop a new program, and you want it to be of the greatest
   1.288 +possible use to the public, the best way to achieve this is to make it
   1.289 +free software which everyone can redistribute and change under these terms.
   1.290 +
   1.291 +  To do so, attach the following notices to the program.  It is safest
   1.292 +to attach them to the start of each source file to most effectively
   1.293 +convey the exclusion of warranty; and each file should have at least
   1.294 +the "copyright" line and a pointer to where the full notice is found.
   1.295 +
   1.296 +    <one line to give the program's name and a brief idea of what it does.>
   1.297 +    Copyright (C) <year>  <name of author>
   1.298 +
   1.299 +    This program is free software; you can redistribute it and/or modify
   1.300 +    it under the terms of the GNU General Public License as published by
   1.301 +    the Free Software Foundation; either version 2 of the License, or
   1.302 +    (at your option) any later version.
   1.303 +
   1.304 +    This program is distributed in the hope that it will be useful,
   1.305 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   1.306 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   1.307 +    GNU General Public License for more details.
   1.308 +
   1.309 +    You should have received a copy of the GNU General Public License
   1.310 +    along with this program; if not, write to the Free Software
   1.311 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   1.312 +
   1.313 +
   1.314 +Also add information on how to contact you by electronic and paper mail.
   1.315 +
   1.316 +If the program is interactive, make it output a short notice like this
   1.317 +when it starts in an interactive mode:
   1.318 +
   1.319 +    Gnomovision version 69, Copyright (C) year name of author
   1.320 +    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
   1.321 +    This is free software, and you are welcome to redistribute it
   1.322 +    under certain conditions; type `show c' for details.
   1.323 +
   1.324 +The hypothetical commands `show w' and `show c' should show the appropriate
   1.325 +parts of the General Public License.  Of course, the commands you use may
   1.326 +be called something other than `show w' and `show c'; they could even be
   1.327 +mouse-clicks or menu items--whatever suits your program.
   1.328 +
   1.329 +You should also get your employer (if you work as a programmer) or your
   1.330 +school, if any, to sign a "copyright disclaimer" for the program, if
   1.331 +necessary.  Here is a sample; alter the names:
   1.332 +
   1.333 +  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
   1.334 +  `Gnomovision' (which makes passes at compilers) written by James Hacker.
   1.335 +
   1.336 +  <signature of Ty Coon>, 1 April 1989
   1.337 +  Ty Coon, President of Vice
   1.338 +
   1.339 +This General Public License does not permit incorporating your program into
   1.340 +proprietary programs.  If your program is a subroutine library, you may
   1.341 +consider it more useful to permit linking proprietary applications with the
   1.342 +library.  If this is what you want to do, use the GNU Library General
   1.343 +Public License instead of this License.
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/graphlcd-base/HISTORY	Wed Feb 06 17:32:55 2008 +0000
     2.3 @@ -0,0 +1,151 @@
     2.4 +GraphLCD base package Revision History
     2.5 +--------------------------------------
     2.6 +
     2.7 +2007-02-25: Version 0.1.5
     2.8 +- added missing include path definition (thanks to Wolfgang Astleitner)
     2.9 +- replaced unsigned long long with uint64_t
    2.10 +- added missing includes
    2.11 +- increased VER_MAJOR for glcdgraphics library as interface changed in an incompatible way (thanks to Tobias Grimm)
    2.12 +- changed type of fbp (framebuffer pointer) to void*. Compare fbp against MAP_FAILED to test for success of mmap. This should fix a x86_64 compile error.
    2.13 +- ks0108: clear data lines after display refresh to fix problems with display contrast that occur under some conditions.
    2.14 +
    2.15 +
    2.16 +2007-02-04: Version 0.1.4
    2.17 +- added missing include of stdint.h in several files
    2.18 +- added -fPIC compiler option to library Makefiles
    2.19 +- graphlcd.conf: added missing "Driver=serdisp" in serdisp section (thanks to Jörn Hermann)
    2.20 +- graphlcd.conf: changed default value for sleep method to gettimeofday
    2.21 +- glcdgraphics library changes:
    2.22 +  - Added cBitmap::DrawSlope function that draws a slope of the given type
    2.23 +  - added class for loading and saving PBM (portable bitmap) files
    2.24 +  - made loading of GLCD files platform independent (hopefully)
    2.25 +  - added copy constructor to cBitmap class
    2.26 +  - removed the friend class stuff from cImage, instead added some functions to set members
    2.27 +  - new class cImageFile that acts as a base class for image format load/save classes like cGLCDFile or cPBMFile
    2.28 +  - removed const qualifier from cImage::GetBitmap
    2.29 +  - added added Invert method to cBitmap
    2.30 +  - added methods to set font parameter (height, ascent, ...) to cFont class
    2.31 +  - made loading of FNT files platform independent (hopefully)
    2.32 +  - return false in cGLCDFile::Open and ::Save when opening of file failed
    2.33 +  - added trim function to cut leading and trailing spaces from strings
    2.34 +  - added WrapText method to cFont class
    2.35 +  - fixed missing last line in cFont::WrapText
    2.36 +  - fixed WrapText when Height is zero
    2.37 +  - fixed font loading bug for graphlcd's FNT format
    2.38 +  - fixed missing addition of spaceBetween in cFont::WrapText that caused too long lines with some fonts
    2.39 +  - fixed loading of GLCD animations (thanks to Malte Schröder)
    2.40 +- glcddrivers library changes:
    2.41 +  - only config.h, driver.h and drivers.h are needed for applications
    2.42 +  - added driver for g15daemon (thanks to Mike)
    2.43 +  - added driver for noritake gu126x64D-K610A4 display (thanks to Alexander Rieger)
    2.44 +  - gu140x32: fix seqfault if fonts.conf missed (thanks to Andreas Brachold)
    2.45 +  - t6963c: added support for Serial wiring using an industry version with a serial to parallel converter (thanks to Torsten Lang)
    2.46 +  - avrctl: adapted to changed commands PC -> AVR
    2.47 +  - avrctl: implemented SetBrightness method
    2.48 +  - avrctl: changed type of some parameters to SetColData to uint16_t
    2.49 +  - avrctl: allow sizes below 256x128. Buffer sent to controller is still 256x128.
    2.50 +  - framebuffer: fixed compiler error on 64bit systems (thanks to Malte Schröder)
    2.51 +	- serdisp: updated serdisplib driver (thanks to Wolfgang Astleitner)
    2.52 +  - added simple network driver (not complete) that sends the current display content as and hey string to connected clients
    2.53 +	- link against libpthread
    2.54 +	- fixed some default values to be consistent with comments in graphlcd.conf
    2.55 +- tools changes:
    2.56 +  - convpic: adapted to changes related to new base class cImageFile
    2.57 +  - convpic: use classes from glcdgraphics lib for glcd file conversion
    2.58 +  - convpic: added pbm support
    2.59 +  - crtfont: use cFont class methods to save in FNT format
    2.60 +  - genfont: use cFont class methods to load freetype2 supported fonts
    2.61 +  - genfont: use cFont class methods to save in FNT format
    2.62 +  - showpic: call SetBrightness method
    2.63 +  - showpic: changed setting of brightness to use value from config structure
    2.64 +  - new tool lcdtestpattern to display a test pattern on a LCD (thanks to Alexander Rieger)
    2.65 +
    2.66 +
    2.67 +2006-01-15: Version 0.1.3
    2.68 +- Added a major.minor.micro version to the libraries starting with 1.0.0
    2.69 +- Moved usage of DESTDIR from serveral Makefiles to Make.config (thanks to
    2.70 +  Lucian Muresan).
    2.71 +- Moved Freetype2 dependency from Make.config to Makefile of libglcdgraphics
    2.72 +  (thanks to Tobias Grimm).
    2.73 +- Creating an additional symlink for the library files to be found during
    2.74 +  making the tools that need them (thanks to Tobias Grimm).
    2.75 +- Updated serdisplib driver (thanks to Wolfgang Astleitner).
    2.76 +- KS0108 driver: Added an alternative way of setting the display control lines
    2.77 +  (same as in old versions). It is selectable through graphlcd configfile
    2.78 +  parameter "Control".
    2.79 +- Using default values for width and height in case they are zero, too
    2.80 +  (thanks to Tobias Grimm).
    2.81 +- Added cSerialPort class.
    2.82 +- Added driver for my AVR controlled display.
    2.83 +
    2.84 +
    2.85 +2005-09-17: Version 0.1.2
    2.86 +- split off drivers from graphlcd plugin to GraphLCD driver library
    2.87 +  (libglcddrivers)
    2.88 +- split off graphics and font handling from graphlcd plugin to GraphLCD
    2.89 +  graphics library (libglcdgraphics)
    2.90 +- split off tools from graphlcd plugin to GraphLCD base package
    2.91 +- almost completely rewritten graphics and font handling
    2.92 +- added configuration file to hold the driver-specific options
    2.93 +- changed driver interface
    2.94 +- adopted the tools' code to use the new driver and graphics API
    2.95 +- glcddrivers: new driver noritake800 for Noritake 800(A) series
    2.96 +  displays (thanks to Lucian Muresan)
    2.97 +- glcdgraphics: fixed a NULL-pointer exception in cBitmap::DrawCharacter
    2.98 +  when skipPixels is equal to width of the character and SubBitmap
    2.99 +  returns NULL, which was not tested for (thanks to Malte Schröder for
   2.100 +  reporting this one)
   2.101 +- glcdgraphics: fixed a wrong return value in cBitmap::DrawCharacter in
   2.102 +  case skipPixels > 0 which prevented scrolling from working right.
   2.103 +- now compiles with gcc 2.95 and gcc 3.x
   2.104 +- added missing #includes
   2.105 +- new tool showtext: allows showing a text on the LCD, see
   2.106 +  README.showtext for details.
   2.107 +- glcddrivers: fixed a too early port release in sed1330 driver (thanks
   2.108 +  to Matthias Huber)
   2.109 +- glcddrivers: sed1330: added missing horizontal scrolling
   2.110 +  initialization. Now, there should be no displaced display any longer.
   2.111 +  (thanks to Wolfgang Astleitner)
   2.112 +- glcddrivers: Now serdisplib is loaded dynamically using libdl. So, no
   2.113 +  INCLUDE_SERDISPLIB define is needed any longer (thanks to Wolfgang
   2.114 +  Astleitner)
   2.115 +- glcddrivers: fixed gu256x64-3900 driver: Now sizes other than 256x64
   2.116 +  should work. (thanks to Detlef Ruge and Ralf Müller)
   2.117 +- glcdgraphics: fixed a bug in cBitmap::DrawText that prevented scrolling
   2.118 +  from working.
   2.119 +- glcdgraphics: fixed a bug in cBitmap::SubBitmap.
   2.120 +- glcdgraphics: changed the interface of DrawText and DrawCharacter of
   2.121 +  cBitmap class.
   2.122 +- glcdgraphics: extended font attributes to better support converted true
   2.123 +  type fonts. Also changed font file format to support this attributes.
   2.124 +- glcdgraphics: the lastChange attribute of cImage now is 64 bits wide.
   2.125 +- crtfont: extended it to support the new font attributes
   2.126 +- crtfont: changed file format of description files. Now the font
   2.127 +  attributes are given by its names, p. e. lineheight:20. Look in
   2.128 +  README.crtfont for details.
   2.129 +- new tool genfont: allows converting of true type fonts to GraphLCD
   2.130 +  fonts using freetype2 library. You have to uncomment HAVE_FREETYPE2 in
   2.131 +  Make.config to use it.
   2.132 +- added new fonts verdana and verdana bold in sizes 9 to 29 converted by
   2.133 +  genfont.
   2.134 +- glcdgraphics: Added additional type casts to std::min calls to make it
   2.135 +  compile on x86-64 (thanks to Stefan Bergler).
   2.136 +- glcddrivers: fixed a bug in serdisp.c. When using direct IO the port
   2.137 +  string was truncated (thanks to Stefan Bergler).
   2.138 +- glcddrivers: Added method cConfig::GetConfigIndex for getting a
   2.139 +  configuration by its name (thanks to Lucian Muresan).
   2.140 +- Added some $(DESTDIR) all over the Makefiles (thanks to Lucian Muresan).
   2.141 +- glcddrivers: sed1330: Added setting of CS line in 6800 mode (thanks to
   2.142 +  Wolfgang Astleitner).
   2.143 +- glcdgraphics: Added FreeType2 support based on patch by Lucian Muresan.
   2.144 +  - You have to set HAVE_FREETYPE2 in Make.config to enable this
   2.145 +  - Added some helper functions to GLCD::cFont class
   2.146 +- glcddrivers: ks0108: Improved timings: Made setting of display control
   2.147 +  lines like defined in the controller's data sheet. This fixes problems
   2.148 +  with some display types. Thanks to Matthias Breitbach for providing a
   2.149 +  LCD of that type.
   2.150 +- glcddrivers: gu256x64-3900:
   2.151 +  - Corrected calculation of m_nTimingAdjustCmd.
   2.152 +  - Added a test for RefreshDisplay config value to prevent a floating
   2.153 +    point exception to occur when it is set to zero.
   2.154 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/graphlcd-base/Make.config	Wed Feb 06 17:32:55 2008 +0000
     3.3 @@ -0,0 +1,36 @@
     3.4 +#
     3.5 +# User defined Makefile options for graphlcd daemon and tools
     3.6 +
     3.7 +### The C compiler and options:
     3.8 +
     3.9 +CC       = gcc
    3.10 +CFLAGS   = -O2
    3.11 +
    3.12 +CXX      = g++
    3.13 +CXXFLAGS = -g -O2 -Wall -Woverloaded-virtual
    3.14 +#CXXFLAGS = -g -ggdb -O0 -Wall -Woverloaded-virtual
    3.15 +
    3.16 +#LDFLAGS  = -g -ggdb -O0
    3.17 +
    3.18 +LDCONFIG = ldconfig
    3.19 +
    3.20 +### The directory environment:
    3.21 +
    3.22 +ifndef $(DESTDIR)
    3.23 +DESTDIR = /usr/local
    3.24 +endif
    3.25 +
    3.26 +BINDIR = $(DESTDIR)/bin
    3.27 +LIBDIR = $(DESTDIR)/lib
    3.28 +INCDIR = $(DESTDIR)/include
    3.29 +MANDIR = $(DESTDIR)/man
    3.30 +
    3.31 +### Includes and defines
    3.32 +
    3.33 +#INCLUDES += -I
    3.34 +
    3.35 +DEFINES += -D_GNU_SOURCE
    3.36 +
    3.37 +# comment this variable out if you don't want to use FreeType2 font rendering
    3.38 +HAVE_FREETYPE2=1
    3.39 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/graphlcd-base/Makefile	Wed Feb 06 17:32:55 2008 +0000
     4.3 @@ -0,0 +1,41 @@
     4.4 +#
     4.5 +# Makefile for the GraphLCD driver library, graphics library and tools
     4.6 +#
     4.7 +
     4.8 +PROJECT = graphlcd-base
     4.9 +VERSION = 0.1.5
    4.10 +ARCHIVE = $(PROJECT)-$(VERSION)
    4.11 +PACKAGE = $(ARCHIVE)
    4.12 +TMPDIR = /tmp
    4.13 +
    4.14 +### Targets:
    4.15 +
    4.16 +all:
    4.17 +	@$(MAKE) -C glcdgraphics all
    4.18 +	@$(MAKE) -C glcddrivers all
    4.19 +	@$(MAKE) -C tools all
    4.20 +
    4.21 +install:
    4.22 +	@$(MAKE) -C glcdgraphics install
    4.23 +	@$(MAKE) -C glcddrivers install
    4.24 +	@$(MAKE) -C tools install
    4.25 +
    4.26 +uninstall:
    4.27 +	@$(MAKE) -C glcdgraphics uninstall
    4.28 +	@$(MAKE) -C glcddrivers uninstall
    4.29 +	@$(MAKE) -C tools uninstall
    4.30 +  
    4.31 +clean:
    4.32 +	@-rm -f *.tgz
    4.33 +	@$(MAKE) -C glcdgraphics clean
    4.34 +	@$(MAKE) -C glcddrivers clean
    4.35 +	@$(MAKE) -C tools clean
    4.36 +
    4.37 +dist: clean
    4.38 +	@-rm -rf $(TMPDIR)/$(ARCHIVE)
    4.39 +	@mkdir $(TMPDIR)/$(ARCHIVE)
    4.40 +	@cp -a * $(TMPDIR)/$(ARCHIVE)
    4.41 +	@tar czf $(PACKAGE).tgz --exclude .svn --exclude *.cbp --exclude *.layout -C $(TMPDIR) $(ARCHIVE)
    4.42 +	@-rm -rf $(TMPDIR)/$(ARCHIVE)
    4.43 +	@echo Distribution package created as $(PACKAGE).tgz
    4.44 +
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/graphlcd-base/README	Wed Feb 06 17:32:55 2008 +0000
     5.3 @@ -0,0 +1,97 @@
     5.4 +This is the base package of the GraphLCD project. It contains
     5.5 + - GraphLCD driver library - libglcddrivers
     5.6 + - GraphLCD graphics library - libglcdgraphics
     5.7 + - GraphLCD tools (crtfont, convpic, showpic, showtext)
     5.8 + - GraphLCD media files (pictures and splash screens in GLCD format, fonts)
     5.9 +
    5.10 +written by Andreas Regel (andreas.regel AT powarman.de)
    5.11 +
    5.12 +based on the graphlcd plugin for the Video Disc Recorder
    5.13 +  written by                   Carsten Siebholz (c.siebholz AT t-online.de)
    5.14 +  from 0.0.8 on maintained by  Andreas Regel (andreas.regel AT powarman.de)
    5.15 +    gu140x32f driver by        Andreas Brachold (vdr04 AT deltab.de)
    5.16 +    gu256x64-372 driver by     Andreas Weinberger (vdr AT smue.org)
    5.17 +    gu256x64-3xx0 driver by    Ralf Mueller (ralf AT bj-ig.de)
    5.18 +    gu126x64D-K610A4 driver by Alexander Rieger (Alexander.Rieger AT inka.de)
    5.19 +    image driver by            Andreas Regel (andreas.regel AT powarman.de)
    5.20 +    ks0108 driver by           Andreas Weinberger (vdr AT smue.org)
    5.21 +    sed1330 driver by          Roland Praml (praml.roland AT t-online.de)
    5.22 +                               Heinz Gressenberger (heinz.gressenberger AT stmk.gv.at)
    5.23 +    sed1520 driver by          Andreas Weinberger (vdr AT smue.org)
    5.24 +    framebuffer driver by      Stephan Skrodzki (skrodzki AT stevekist.de)
    5.25 +    serdisplib driver by       Wolfgang Astleitner (mrwastl AT users.sourceforge.net)
    5.26 +    t6963c driver by           Andreas Regel (andreas.regel AT powarman.de)
    5.27 +    noritake800 drider by      Lucian Muresan (lucianm AT users.sourceforge.net)
    5.28 +
    5.29 +
    5.30 +Project's homepage: http://graphlcd.berlios.de/
    5.31 +
    5.32 +
    5.33 +See the file COPYING for license information.
    5.34 +
    5.35 +
    5.36 +Description
    5.37 +-----------
    5.38 +The GraphLCD base is a project to support graphical LC displays. It is
    5.39 +mainly used by the graphlcd plugin for the Video Disc Recorder to
    5.40 +display its information.
    5.41 +
    5.42 +The GraphLCD driver library supports the following LCD
    5.43 +controllers/modules:
    5.44 + - Hitachi HD61830
    5.45 + - Toshiba T6963
    5.46 + - Samsung KS0108
    5.47 + - Epson SED1520 (only tested with DIP122 lcd module)
    5.48 + - Epson SED1330
    5.49 + - Noritake GU140X32F-7806
    5.50 + - Noritake GU256X64-372
    5.51 + - Noritake GU256X64-3XX0 (serial or parallel)
    5.52 + - Noritake GU126x64D-K610A4 displays (parallel)
    5.53 + - Noritake 800 series displays
    5.54 + - all controllers supported by serdisplib (http://serdisplib.sourceforge.net)
    5.55 +
    5.56 +Other controllers might be supported in the future.
    5.57 +
    5.58 +Additionally the GraphLCD driver library includes some special drivers:
    5.59 + - framebuffer, for devices that are connected to the VGA connector
    5.60 + - image, for writing image sequences in PBM (Portable Bit Map) format that
    5.61 +   show the plugin's output.
    5.62 +
    5.63 +
    5.64 +Installation and Configuration:
    5.65 +-------------------------------
    5.66 +1. Unpack the tarball to an arbitrary directory.
    5.67 +
    5.68 +  tar xzf graphlcd-base-0.1.2.tgz
    5.69 +
    5.70 +2. Configure if you want FreeType2 support by commenting/uncommenting
    5.71 +   HAVE_FREETYPE2 in Make.config.
    5.72 +
    5.73 +3. Compile the libraries and tools.
    5.74 +
    5.75 +  make all (from the package's directory)
    5.76 +
    5.77 +4. Install the libraries and tools.
    5.78 +
    5.79 +  make install (from the package's directory)
    5.80 +
    5.81 +5. Edit the configuration file graphlcd.conf to fit your needs.
    5.82 +
    5.83 +6. Copy it to the GraphLCD's default configuration search path (/etc).
    5.84 +
    5.85 +  cp graphlcd.conf /etc
    5.86 +
    5.87 +
    5.88 +Notes about FreeType2:
    5.89 +----------------------
    5.90 +If the HAVE_FREETYPE2 variable is defined, then the new method
    5.91 +cFont::LoadFT2(..) from the graphics library will load a FreeType2-supported
    5.92 +font (only TTFs tested so far) and render it into the raster font structure
    5.93 +that cFont uses normally. The method is also defined if no FT2 support is
    5.94 +compiled in, only then it will return false afer logging an error message in
    5.95 +the system log, telling that graphlcd-base has been compiled without FT2
    5.96 +support. This way, applications using this library (vdrplugin-graphlcd, or the
    5.97 +wrapper LCDproc "meta-driver" glcdprocdriver for example, can treat this case
    5.98 +and have a fallback to the glcdraphics-native raster font if FT2 is not
    5.99 +supported, or the TTF font could not be loaded for some reason.
   5.100 +
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/graphlcd-base/docs/DRIVER.framebuffer	Wed Feb 06 17:32:55 2008 +0000
     6.3 @@ -0,0 +1,44 @@
     6.4 +---------------------------------------------------------------------
     6.5 +GraphLCD driver library
     6.6 +
     6.7 +The Framebuffer driver
     6.8 +---------------------------------------------------------------------
     6.9 +
    6.10 +Description
    6.11 +-----------
    6.12 +The Framebuffer driver writes the output to the framebuffer device at
    6.13 +/dev/fb0.
    6.14 +
    6.15 +The driver is optimized for a 640x480x16 framebuffer. To use it, have
    6.16 +a kernel with a framebuffer device (e.g. vesa fb) and add e.g.
    6.17 +vga=0311 to the kernel init parameters (e.g. in lilo.conf).
    6.18 +
    6.19 +
    6.20 +Configuration Parameters
    6.21 +------------------------
    6.22 +The Framebuffer driver supports the following parameters in config
    6.23 +file:
    6.24 +
    6.25 +Width
    6.26 + Sets the horizontal size of the display. If this parameter is not
    6.27 + given, a default value of 320 pixels is used.
    6.28 +
    6.29 +Height
    6.30 + Sets the vertical size of the display. If this parameter is not
    6.31 + given, a default value of 240 pixels is used.
    6.32 +
    6.33 +UpsideDown
    6.34 + Rotates the display output by 180 degrees. This might be useful, if
    6.35 + the LCD is mounted upside-down.
    6.36 + Possible values: 'yes', 'no'
    6.37 + Default value: 'no'
    6.38 +
    6.39 +Invert
    6.40 + Inverts the display.
    6.41 + Possible values: 'yes', 'no'
    6.42 + Default value: 'no'
    6.43 +
    6.44 +Zoom
    6.45 + Determines if pixels should be drawn double sized.
    6.46 + Possible values: 0, 1
    6.47 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/graphlcd-base/docs/DRIVER.gu126x64D-K610A4	Wed Feb 06 17:32:55 2008 +0000
     7.3 @@ -0,0 +1,111 @@
     7.4 +---------------------------------------------------------------------
     7.5 +GraphLCD driver library
     7.6 +
     7.7 +The GU126X64-K610A4 driver
     7.8 +---------------------------------------------------------------------
     7.9 +
    7.10 +Description
    7.11 +-----------
    7.12 +The GU126X64-K610A4 driver supports Noritake GU126X64D-K610A4 VFD 
    7.13 +display.
    7.14 +
    7.15 +The VFD is connected to a single PC parallel port.
    7.16 +
    7.17 +Wirings
    7.18 +-------
    7.19 +The GU126X64-K610A4 driver supports the following connections on a
    7.20 +parallel port:
    7.21 +
    7.22 +
    7.23 +  printerport   LCD                 other
    7.24 +  -----------   ----------------    -------
    7.25 +                5V     (Con1.1)     VCC        (Power supply 5V)
    7.26 +  ACK    (10)   MB     (Con1.9)                (Module Busy)
    7.27 +                0V     (Con1.5)     GND        (Ground)
    7.28 +
    7.29 +  GND    (18)   0V     (Con2.1)                (Ground)
    7.30 +  INIT   (16)   ENABLE (Con2.2)                (ENABLE)
    7.31 +  D0     (02)   PA0    (Con2.3)                (DataBit 0)
    7.32 +  D1     (03)   PA1    (Con2.4)                (DataBit 1)
    7.33 +  D2     (04)   PA2    (Con2.5)                (DataBit 2)
    7.34 +  D3     (05)   PA3    (Con2.6)                (DataBit 3)
    7.35 +  D4     (06)   PA4    (Con2.7)                (DataBit 4)
    7.36 +  D5     (07)   PA5    (Con2.8)                (DataBit 5)
    7.37 +  D6     (08)   PA6    (Con2.9)                (DataBit 6)
    7.38 +  D7     (09)   PA7    (Con2.10)               (DataBit 7)
    7.39 +
    7.40 +The Display is configured to parallel port mode with "Clock Input"
    7.41 +to "Falling Edge".
    7.42 +
    7.43 +================================================================
    7.44 +   
    7.45 +Configuration Parameters
    7.46 +------------------------
    7.47 +The GU126X64-K610A4 driver supports the following parameters in 
    7.48 +config file:
    7.49 +
    7.50 +Device
    7.51 + Instead of using the direct output via port address (see Port), you
    7.52 + can use the parport device (/dev/parportX). The advantage over the
    7.53 + direct output via port address is that this works for non-root users
    7.54 + also. But it's a little bit slower. The modules ppdev.o, parport.o
    7.55 + and parport_pc.o must be loaded or compiled into the kernel.
    7.56 +
    7.57 +Port
    7.58 + Sets the port address of the parallel port. If this parameter is not
    7.59 + given, 0x378 is used. To use this direct output, the program that
    7.60 + uses the driver library has to be started with user 'root'.
    7.61 +
    7.62 +Width
    7.63 + Sets the horizontal size of the display. If this parameter is not
    7.64 + given, a default value of 256 pixels is used.
    7.65 +
    7.66 +Height
    7.67 + Sets the vertical size of the display. If this parameter is not
    7.68 + given, a default value of 64 pixels is used.
    7.69 +
    7.70 +UpsideDown
    7.71 + Rotates the display output by 180 degrees. This might be useful, if
    7.72 + the LCD is mounted upside-down.
    7.73 + Possible values: 'yes', 'no'
    7.74 + Default value: 'no'
    7.75 +
    7.76 +Invert
    7.77 + Inverts the display.
    7.78 + Possible values: 'yes', 'no'
    7.79 + Default value: 'no'
    7.80 +
    7.81 +Brightness
    7.82 + Sets the brightness of your display's backlight.
    7.83 + Possible values: 0 <= x <= 100)
    7.84 + Default value: 100
    7.85 +
    7.86 +AdjustTiming
    7.87 + To get a timing that is as accurate as possible, the drivers measure
    7.88 + the time for port commands (see: benchmark in syslog). You might
    7.89 + decrease or increase the time to wait after port commands with this
    7.90 + parameter. Normally, there is no need to change this parameter.
    7.91 + Possible values: -50 <= x <= 50
    7.92 + Default value: 0
    7.93 +
    7.94 +RefreshDisplay
    7.95 + Normally, most of the drivers do not update the whole display, but
    7.96 + only the areas that have changed since last update. So it might be,
    7.97 + that some faulty pixels would stay a longer time. To avoid this, the
    7.98 + plugin makes a complete refresh from time to time. This parameter
    7.99 + defines how often a complete refresh will be done.
   7.100 + e.g.: A value of 5 means, that the plugin will make a complete
   7.101 +       refresh on every 5th update.
   7.102 + A value of 0 completely disables complete refreshs. 
   7.103 + Possible values: 0 <= x <= 50
   7.104 + Default value: 0
   7.105 +
   7.106 +Debug
   7.107 + Prints debugging information of some methods of the driver.
   7.108 + (add the values of interest)
   7.109 +
   7.110 +  1: show a log at the start of a refresh
   7.111 +  2: show a log at the end of a refresh with timing information
   7.112 +  4: show the rows (8 pixel) refreshed
   7.113 +  8: show every commands/bytes sent to the display
   7.114 + 16: log every unsuccessful waiting for display acknowledge
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/graphlcd-base/docs/DRIVER.gu140x32f	Wed Feb 06 17:32:55 2008 +0000
     8.3 @@ -0,0 +1,126 @@
     8.4 +---------------------------------------------------------------------
     8.5 +GraphLCD driver library
     8.6 +
     8.7 +The GU140X32F driver
     8.8 +---------------------------------------------------------------------
     8.9 +
    8.10 +Description
    8.11 +-----------
    8.12 +The GU140X32F driver supports Noritake GU140x32-F7806 VFD displays.
    8.13 +The VFD is operating in its 8 bit-mode connected to a PC's parallel
    8.14 +port.
    8.15 +
    8.16 +
    8.17 +Wirings
    8.18 +-------
    8.19 +The GU140x32F driver supports the following connections on a parallel
    8.20 +port:
    8.21 + - Standard
    8.22 + - Windows
    8.23 +
    8.24 +Standard wiring:
    8.25 +
    8.26 +  printerport   LCD          other
    8.27 +  -----------   ----------   ----------
    8.28 +                GND   (01)   GND          (Ground)
    8.29 +                VCC   (02)   VCC          (+5VDC 500mA)
    8.30 +                NC    (03)
    8.31 +  nSTRB  (01)   RS    (04)                (Register Select)
    8.32 +  nAUTO  (14)   RW    (05)                (Read/Write)
    8.33 +  INIT   (16)   EN    (06)                (Chip Enable)
    8.34 +  D0     (02)   D0    (07)                (Data Bit 0)
    8.35 +  D1     (03)   D1    (08)                (Data Bit 1)
    8.36 +  D2     (04)   D2    (09)                (Data Bit 2)
    8.37 +  D3     (05)   D3    (10)                (Data Bit 3)
    8.38 +  D4     (06)   D4    (11)                (Data Bit 4)
    8.39 +  D5     (07)   D5    (12)                (Data Bit 5)
    8.40 +  D6     (08)   D6    (13)                (Data Bit 6)
    8.41 +  D7     (09)   D7    (14)                (Data Bit 7)
    8.42 +
    8.43 +Windows wiring:
    8.44 +
    8.45 +  printerport   LCD          other
    8.46 +  -----------   ----------   ----------
    8.47 +                GND   (01)   GND          (Ground)
    8.48 +                VCC   (02)   VCC          (+5VDC 500mA)
    8.49 +                NC    (03)
    8.50 +  INIT   (16)   RS    (04)                (Register Select)
    8.51 +  nAUTO  (14)   RW    (05)                (Read/Write)
    8.52 +  nSTRB  (01)   EN    (06)                (Chip Enable)
    8.53 +  D0     (02)   D0    (07)                (Data Bit 0)
    8.54 +  D1     (03)   D1    (08)                (Data Bit 1)
    8.55 +  D2     (04)   D2    (09)                (Data Bit 2)
    8.56 +  D3     (05)   D3    (10)                (Data Bit 3)
    8.57 +  D4     (06)   D4    (11)                (Data Bit 4)
    8.58 +  D5     (07)   D5    (12)                (Data Bit 5)
    8.59 +  D6     (08)   D6    (13)                (Data Bit 6)
    8.60 +  D7     (09)   D7    (14)                (Data Bit 7)
    8.61 +
    8.62 +Note: The pin numbering may vary with other displays.
    8.63 +
    8.64 +
    8.65 +Configuration Parameters
    8.66 +------------------------
    8.67 +The GU140x32F driver supports the following parameters in config file:
    8.68 +
    8.69 +Device
    8.70 + Instead of using the direct output via port address (see Port), you
    8.71 + can use the parport device (/dev/parportX). The advantage over the
    8.72 + direct output via port address is that this works for non-root users
    8.73 + also. But it's a little bit slower. The modules ppdev.o, parport.o
    8.74 + and parport_pc.o must be loaded or compiled into the kernel.
    8.75 +
    8.76 +Port
    8.77 + Sets the port address of the parallel port. If this parameter is not
    8.78 + given, 0x378 is used. To use this direct output, the program that
    8.79 + uses the driver library has to be started with user 'root'.
    8.80 +
    8.81 +Width
    8.82 + Sets the horizontal size of the display. If this parameter is not
    8.83 + given, a default value of 140 pixels is used.
    8.84 +
    8.85 +Height
    8.86 + Sets the vertical size of the display. If this parameter is not
    8.87 + given, a default value of 32 pixels is used.
    8.88 +
    8.89 +UpsideDown
    8.90 + Rotates the display output by 180 degrees. This might be useful, if
    8.91 + the LCD is mounted upside-down.
    8.92 + Possible values: 'yes', 'no'
    8.93 + Default value: 'no'
    8.94 +
    8.95 +Invert
    8.96 + Inverts the display.
    8.97 + Possible values: 'yes', 'no'
    8.98 + Default value: 'no'
    8.99 +
   8.100 +Brightness
   8.101 + Sets the brightness of your display's backlight.
   8.102 + Possible values: 0 <= x <= 100)
   8.103 + Default value: 100
   8.104 +
   8.105 +AdjustTiming
   8.106 + To get a timing that is as accurate as possible, the drivers measure
   8.107 + the time for port commands (see: benchmark in syslog). You might
   8.108 + decrease or increase the time to wait after port commands with this
   8.109 + parameter. Normally, there is no need to change this parameter.
   8.110 + Possible values: -50 <= x <= 50
   8.111 + Default value: 0
   8.112 +
   8.113 +RefreshDisplay
   8.114 + Normally, most of the drivers do not update the whole display, but
   8.115 + only the areas that have changed since last update. So it might be,
   8.116 + that some faulty pixels would stay a longer time. To avoid this, the
   8.117 + plugin makes a complete refresh from time to time. This parameter
   8.118 + defines how often a complete refresh will be done.
   8.119 + e.g.: A value of 5 means, that the plugin will make a complete
   8.120 +       refresh on every 5th update.
   8.121 + A value of 0 completely disables complete refreshs. 
   8.122 + Possible values: 0 <= x <= 50
   8.123 + Default value: 5
   8.124 +
   8.125 +Wiring
   8.126 + Select the type of wiring your display is connected with.
   8.127 + Possible values: 'Standard', 'Windows'
   8.128 + Default value: 'Standard'
   8.129 +
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/graphlcd-base/docs/DRIVER.gu256x64-372	Wed Feb 06 17:32:55 2008 +0000
     9.3 @@ -0,0 +1,96 @@
     9.4 +---------------------------------------------------------------------
     9.5 +GraphLCD driver library
     9.6 +
     9.7 +The GU256X64-372 driver
     9.8 +---------------------------------------------------------------------
     9.9 +
    9.10 +Description
    9.11 +-----------
    9.12 +The GU256X64-372 driver supports Noritake GU256x64-372 VFD displays.
    9.13 +The VFD is operating in its 8 bit-mode connected to a PC's parallel
    9.14 +port.
    9.15 +
    9.16 +
    9.17 +Wiring
    9.18 +------
    9.19 +The GU256x64-372 driver supports the following connection on a parallel
    9.20 +port:
    9.21 +
    9.22 +  printerport   LCD          other
    9.23 +  -----------   ----------   ----------
    9.24 +  D0     (02)   D0    (15)                (Data Bit 0)
    9.25 +  D1     (03)   D1    (13)                (Data Bit 1)
    9.26 +  D2     (04)   D2    (11)                (Data Bit 2)
    9.27 +  D3     (05)   D3    (09)                (Data Bit 3)
    9.28 +  D4     (06)   D4    (07)                (Data Bit 4)
    9.29 +  D5     (07)   D5    (05)                (Data Bit 5)
    9.30 +  D6     (08)   D6    (03)                (Data Bit 6)
    9.31 +  D7     (09)   D7    (01)                (Data Bit 7)
    9.32 +  INIT   (16)   nWR   (17)                (Write)
    9.33 +  nSEL   (17)   R/S   (19)                (Register Select, C/D)
    9.34 +  GND    (18)   nRD   (21)                (Read)
    9.35 +  GND    (18)   CSS   (23)                (Chip Select)
    9.36 +  GND    (18)   GND   (02)                (Ground)
    9.37 +
    9.38 +
    9.39 +Configuration Parameters
    9.40 +------------------------
    9.41 +The GU256x64-372 driver supports the following parameters in config
    9.42 +file:
    9.43 +
    9.44 +Device
    9.45 + Instead of using the direct output via port address (see Port), you
    9.46 + can use the parport device (/dev/parportX). The advantage over the
    9.47 + direct output via port address is that this works for non-root users
    9.48 + also. But it's a little bit slower. The modules ppdev.o, parport.o
    9.49 + and parport_pc.o must be loaded or compiled into the kernel.
    9.50 +
    9.51 +Port
    9.52 + Sets the port address of the parallel port. If this parameter is not
    9.53 + given, 0x378 is used. To use this direct output, the program that
    9.54 + uses the driver library has to be started with user 'root'.
    9.55 +
    9.56 +Width
    9.57 + Sets the horizontal size of the display. If this parameter is not
    9.58 + given, a default value of 256 pixels is used.
    9.59 +
    9.60 +Height
    9.61 + Sets the vertical size of the display. If this parameter is not
    9.62 + given, a default value of 64 pixels is used.
    9.63 +
    9.64 +UpsideDown
    9.65 + Rotates the display output by 180 degrees. This might be useful, if
    9.66 + the LCD is mounted upside-down.
    9.67 + Possible values: 'yes', 'no'
    9.68 + Default value: 'no'
    9.69 +
    9.70 +Invert
    9.71 + Inverts the display.
    9.72 + Possible values: 'yes', 'no'
    9.73 + Default value: 'no'
    9.74 +
    9.75 +Brightness
    9.76 + Sets the brightness of your display's backlight.
    9.77 + Possible values: 0 <= x <= 100)
    9.78 + Default value: 100
    9.79 +
    9.80 +AdjustTiming
    9.81 + To get a timing that is as accurate as possible, the drivers measure
    9.82 + the time for port commands (see: benchmark in syslog). You might
    9.83 + decrease or increase the time to wait after port commands with this
    9.84 + parameter. Normally, there is no need to change this parameter.
    9.85 + Possible values: -50 <= x <= 50
    9.86 + Default value: 0
    9.87 +
    9.88 +RefreshDisplay
    9.89 + Normally, most of the drivers do not update the whole display, but
    9.90 + only the areas that have changed since last update. So it might be,
    9.91 + that some faulty pixels would stay a longer time. To avoid this, the
    9.92 + plugin makes a complete refresh from time to time. This parameter
    9.93 + defines how often a complete refresh will be done.
    9.94 + e.g.: A value of 5 means, that the plugin will make a complete
    9.95 +       refresh on every 5th update.
    9.96 + A value of 0 completely disables complete refreshs. 
    9.97 + Possible values: 0 <= x <= 50
    9.98 + Default value: 5
    9.99 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/graphlcd-base/docs/DRIVER.gu256x64-3900	Wed Feb 06 17:32:55 2008 +0000
    10.3 @@ -0,0 +1,176 @@
    10.4 +---------------------------------------------------------------------
    10.5 +GraphLCD driver library
    10.6 +
    10.7 +The GU256X64-3900 driver
    10.8 +---------------------------------------------------------------------
    10.9 +
   10.10 +Description
   10.11 +-----------
   10.12 +The GU256X64-3900 driver supports Noritake GU256X64-3900 VFD displays.
   10.13 +The VFD is either operating in 8 bit-mode connected to a single PC
   10.14 +parallel port or in serial mode connected to a single PC serial port.
   10.15 +
   10.16 +
   10.17 +Wirings
   10.18 +-------
   10.19 +The GU256X64-3900 driver supports the following connections on a
   10.20 +parallel port:
   10.21 + - Standard
   10.22 + - Satyr
   10.23 +
   10.24 +Standard wiring:
   10.25 +
   10.26 +  printerport   LCD          other
   10.27 +  -----------   ----------   ----------
   10.28 +  D0     (02)   DB0   (08)                (DataBit 0)
   10.29 +  D1     (03)   DB1   (07)                (DataBit 1)
   10.30 +  D2     (04)   DB2   (06)                (DataBit 2)
   10.31 +  D3     (05)   DB3   (05)                (DataBit 3)
   10.32 +  D4     (06)   DB4   (04)                (DataBit 4)
   10.33 +  D5     (07)   DB5   (03)                (DataBit 5)
   10.34 +  D6     (08)   DB6   (02)                (DataBit 6)
   10.35 +  D7     (09)   DB7   (01)                (DataBit 7)
   10.36 +  ACK    (10)   RDY   (12)                (Display Ready)
   10.37 +  INIT   (16)   nWR   (10)                (Write)
   10.38 +  GND    (18)   GND   (09)   GND          (Ground)
   10.39 +  GND    (19)   GND   (11)   GND          (Ground)
   10.40 +  GND    (20)   GND   (13)   GND          (Ground)
   10.41 +  GND    (21)   GND   (14)   GND          (Ground)
   10.42 +                VCC   (15)   VCC          (Power supply 5V)
   10.43 +                VCC   (16)   VCC          (Power supply 5V)
   10.44 +
   10.45 +Satyr Wiring:
   10.46 +
   10.47 +  printerport   LCD          other
   10.48 +  -----------   ----------   ----------
   10.49 +  nSTRB  (01)   nWR   (10)                (Write)
   10.50 +  D0     (02)   DB0   (08)                (DataBit 0)
   10.51 +  D1     (03)   DB1   (07)                (DataBit 1)
   10.52 +  D2     (04)   DB2   (06)                (DataBit 2)
   10.53 +  D3     (05)   DB3   (05)                (DataBit 3)
   10.54 +  D4     (06)   DB4   (04)                (DataBit 4)
   10.55 +  D5     (07)   DB5   (03)                (DataBit 5)
   10.56 +  D6     (08)   DB6   (02)                (DataBit 6)
   10.57 +  D7     (09)   DB7   (01)                (DataBit 7)
   10.58 +  BUSY   (11)   RDY   (12)                (Display Ready)
   10.59 +  GND    (18)   GND   (09)   GND          (Ground)
   10.60 +  GND    (19)   GND   (11)   GND          (Ground)
   10.61 +  GND    (20)   GND   (13)   GND          (Ground)
   10.62 +  GND    (21)   GND   (14)   GND          (Ground)
   10.63 +                VCC   (15)   VCC          (Power supply 5V)
   10.64 +                VCC   (16)   VCC          (Power supply 5V)
   10.65 +
   10.66 +Note: The pin numbering may vary with other displays.
   10.67 +
   10.68 +
   10.69 +The GU256X64-3900 driver supports the following connection on a
   10.70 +serial port:
   10.71 +
   10.72 +  serialport   LCD          other
   10.73 +  ----------   ----------   ----------
   10.74 +  DCD   (01)   DTR   (02)
   10.75 +  RxD   (02)   TxD   (04)
   10.76 +  TxD   (03)   RxD   (01)
   10.77 +  DTR   (04)   DSR   (03)
   10.78 +  GND   (05)   GND   (07)   GND          (Ground)
   10.79 +  DSR   (06)   DTR   (02)
   10.80 +               VCC   (06)   VCC          (Power supply 5V)
   10.81 +
   10.82 +Note: The pin numbering may vary with other displays.
   10.83 +
   10.84 +On display switches:
   10.85 + SW No.   Function                 Default
   10.86 + ------   --------                 -------
   10.87 +   1      Display address select   Off
   10.88 +   2      Display address select   Off
   10.89 +   3      Display address select   Off
   10.90 +   4      Display address select   Off
   10.91 +   5      Baud rate select         Off
   10.92 +   6      Command mode select      Off      switch DMA On/Off
   10.93 +   7      Operating mode select    Off
   10.94 +   8      Protocol Select          Off
   10.95 +
   10.96 +Serial access to GU256X64C-3xx0 is nearly as fast as normal parallel
   10.97 +access but doesn't create the high system load of the parallel
   10.98 +approach. So for me serial access is preferred over normal parallel
   10.99 +mode. Even better is the DMA parallel mode. For DMA mode you have to
  10.100 +switch SW6 on the display to ON.
  10.101 +
  10.102 +
  10.103 +Configuration Parameters
  10.104 +------------------------
  10.105 +The GU256X64-3900 driver supports the following parameters in config
  10.106 +file:
  10.107 +
  10.108 +Device
  10.109 + Instead of using the direct output via port address (see Port), you
  10.110 + can use the parport device (/dev/parportX). The advantage over the
  10.111 + direct output via port address is that this works for non-root users
  10.112 + also. But it's a little bit slower. The modules ppdev.o, parport.o
  10.113 + and parport_pc.o must be loaded or compiled into the kernel.
  10.114 +
  10.115 +Port
  10.116 + Sets the port address of the parallel port. If this parameter is not
  10.117 + given, 0x378 is used. To use this direct output, the program that
  10.118 + uses the driver library has to be started with user 'root'.
  10.119 +
  10.120 +Width
  10.121 + Sets the horizontal size of the display. If this parameter is not
  10.122 + given, a default value of 256 pixels is used.
  10.123 +
  10.124 +Height
  10.125 + Sets the vertical size of the display. If this parameter is not
  10.126 + given, a default value of 64 pixels is used.
  10.127 +
  10.128 +UpsideDown
  10.129 + Rotates the display output by 180 degrees. This might be useful, if
  10.130 + the LCD is mounted upside-down.
  10.131 + Possible values: 'yes', 'no'
  10.132 + Default value: 'no'
  10.133 +
  10.134 +Invert
  10.135 + Inverts the display.
  10.136 + Possible values: 'yes', 'no'
  10.137 + Default value: 'no'
  10.138 +
  10.139 +Brightness
  10.140 + Sets the brightness of your display's backlight.
  10.141 + Possible values: 0 <= x <= 100)
  10.142 + Default value: 100
  10.143 +
  10.144 +AdjustTiming
  10.145 + To get a timing that is as accurate as possible, the drivers measure
  10.146 + the time for port commands (see: benchmark in syslog). You might
  10.147 + decrease or increase the time to wait after port commands with this
  10.148 + parameter. Normally, there is no need to change this parameter.
  10.149 + Possible values: -50 <= x <= 50
  10.150 + Default value: 0
  10.151 +
  10.152 +RefreshDisplay
  10.153 + Normally, most of the drivers do not update the whole display, but
  10.154 + only the areas that have changed since last update. So it might be,
  10.155 + that some faulty pixels would stay a longer time. To avoid this, the
  10.156 + plugin makes a complete refresh from time to time. This parameter
  10.157 + defines how often a complete refresh will be done.
  10.158 + e.g.: A value of 5 means, that the plugin will make a complete
  10.159 +       refresh on every 5th update.
  10.160 + A value of 0 completely disables complete refreshs. 
  10.161 + Possible values: 0 <= x <= 50
  10.162 + Default value: 5
  10.163 +
  10.164 +Wiring
  10.165 + Select the type of wiring your display is connected with.
  10.166 + Possible values: 'Standard', 'Satyr'
  10.167 + Default value: 'Standard'
  10.168 +
  10.169 +Interface
  10.170 + Select the interface your display is connnected to.
  10.171 + Possible values: 'Parallel', 'Serial'
  10.172 + Default value: 'Parallel'
  10.173 +
  10.174 +DMA
  10.175 + Enables/disables the usage of the controller's DMA mode which
  10.176 + increases writing speed. This only works in parallel interface mode.
  10.177 + Possible values: 'yes', 'no'
  10.178 + Default value: 'yes'
  10.179 +
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/graphlcd-base/docs/DRIVER.hd61830	Wed Feb 06 17:32:55 2008 +0000
    11.3 @@ -0,0 +1,96 @@
    11.4 +---------------------------------------------------------------------
    11.5 +GraphLCD driver library
    11.6 +
    11.7 +The HD61830 driver
    11.8 +---------------------------------------------------------------------
    11.9 +
   11.10 +Description
   11.11 +-----------
   11.12 +The HD61830 driver supports LC displays that use the Hitachi HD61830
   11.13 +controller, connected to the parallel port of your PC.
   11.14 +
   11.15 +
   11.16 +Wirings
   11.17 +-------
   11.18 +The HD61830 driver supports the following connection on a parallel
   11.19 +port:
   11.20 +
   11.21 +  printerport   LCD          other
   11.22 +  -----------   ----------   ----------
   11.23 +  GND    (18)   GND   (01)   GND          (Ground)
   11.24 +                VDD   (02)   +5V          (V Controller)
   11.25 +                V0    (03)   +5V..-15V    (Contrast)
   11.26 +  INIT   (16)   RS    (04)                (Register Select)
   11.27 +  nAUTO  (14)   R/W   (05)                (Read 1/Write 0)
   11.28 +  nSTRB  (01)   EN    (06)                (Enable)
   11.29 +  D0     (02)   D0    (07)                (DataBit0)
   11.30 +  D1     (03)   D1    (08)                (DataBit1)
   11.31 +  D2     (04)   D2    (09)                (DataBit2)
   11.32 +  D3     (05)   D3    (10)                (DataBit3)
   11.33 +  D4     (06)   D4    (11)                (DataBit4)
   11.34 +  D5     (07)   D5    (12)                (DataBit5)
   11.35 +  D6     (08)   D6    (13)                (DataBit6)
   11.36 +  D7     (09)   D7    (14)                (DataBit7)
   11.37 +                nCS   (15)   GND          (Chip Select)
   11.38 +                nRES  (16)   +5V          (Reset)
   11.39 +                VEE   (17)   -12V         (V LCD)
   11.40 +                nDO   (18)                (not connected)
   11.41 +
   11.42 +Note: The pin numbering may vary with other displays.
   11.43 +
   11.44 +
   11.45 +Configuration Parameters
   11.46 +------------------------
   11.47 +The HD61830 driver supports the following parameters in config file:
   11.48 +
   11.49 +Device
   11.50 + Instead of using the direct output via port address (see Port), you
   11.51 + can use the parport device (/dev/parportX). The advantage over the
   11.52 + direct output via port address is that this works for non-root users
   11.53 + also. But it's a little bit slower. The modules ppdev.o, parport.o
   11.54 + and parport_pc.o must be loaded or compiled into the kernel.
   11.55 +
   11.56 +Port
   11.57 + Sets the port address of the parallel port. If this parameter is not
   11.58 + given, 0x378 is used. To use this direct output, the program that
   11.59 + uses the driver library has to be started with user 'root'.
   11.60 +
   11.61 +Width
   11.62 + Sets the horizontal size of the display. If this parameter is not
   11.63 + given, a default value of 240 pixels is used.
   11.64 +
   11.65 +Height
   11.66 + Sets the vertical size of the display. If this parameter is not
   11.67 + given, a default value of 128 pixels is used.
   11.68 +
   11.69 +UpsideDown
   11.70 + Rotates the display output by 180 degrees. This might be useful, if
   11.71 + the LCD is mounted upside-down.
   11.72 + Possible values: 'yes', 'no'
   11.73 + Default value: 'no'
   11.74 +
   11.75 +Invert
   11.76 + Inverts the display.
   11.77 + Possible values: 'yes', 'no'
   11.78 + Default value: 'no'
   11.79 +
   11.80 +AdjustTiming
   11.81 + To get a timing that is as accurate as possible, the drivers measure
   11.82 + the time for port commands (see: benchmark in syslog). You might
   11.83 + decrease or increase the time to wait after port commands with this
   11.84 + parameter. Normally, there is no need to change this parameter.
   11.85 + Possible values: -50 <= x <= 50
   11.86 + Default value: 0
   11.87 +
   11.88 +RefreshDisplay
   11.89 + Normally, most of the drivers do not update the whole display, but
   11.90 + only the areas that have changed since last update. So it might be,
   11.91 + that some faulty pixels would stay a longer time. To avoid this, the
   11.92 + plugin makes a complete refresh from time to time. This parameter
   11.93 + defines how often a complete refresh will be done.
   11.94 + e.g.: A value of 5 means, that the plugin will make a complete
   11.95 +       refresh on every 5th update.
   11.96 + A value of 0 completely disables complete refreshs. 
   11.97 + Possible values: 0 <= x <= 50
   11.98 + Default value: 5
   11.99 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/graphlcd-base/docs/DRIVER.image	Wed Feb 06 17:32:55 2008 +0000
    12.3 @@ -0,0 +1,36 @@
    12.4 +---------------------------------------------------------------------
    12.5 +GraphLCD driver library
    12.6 +
    12.7 +The Image driver
    12.8 +---------------------------------------------------------------------
    12.9 +
   12.10 +Description
   12.11 +-----------
   12.12 +The Image driver writes image sequences in PBM (Portable Bit Map)
   12.13 +format showing the output that you would normally see on a LCD e.g.
   12.14 +from the graphlcd plugin.
   12.15 +
   12.16 +
   12.17 +Configuration Parameters
   12.18 +------------------------
   12.19 +The Image driver supports the following parameters in config file:
   12.20 +
   12.21 +Width
   12.22 + Sets the horizontal size of the display. If this parameter is not
   12.23 + given, a default value of 240 pixels is used.
   12.24 +
   12.25 +Height
   12.26 + Sets the vertical size of the display. If this parameter is not
   12.27 + given, a default value of 128 pixels is used.
   12.28 +
   12.29 +UpsideDown
   12.30 + Rotates the display output by 180 degrees. This might be useful, if
   12.31 + the LCD is mounted upside-down.
   12.32 + Possible values: 'yes', 'no'
   12.33 + Default value: 'no'
   12.34 +
   12.35 +Invert
   12.36 + Inverts the display.
   12.37 + Possible values: 'yes', 'no'
   12.38 + Default value: 'no'
   12.39 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/graphlcd-base/docs/DRIVER.ks0108	Wed Feb 06 17:32:55 2008 +0000
    13.3 @@ -0,0 +1,124 @@
    13.4 +---------------------------------------------------------------------
    13.5 +GraphLCD driver library
    13.6 +
    13.7 +The KS0108 driver
    13.8 +---------------------------------------------------------------------
    13.9 +
   13.10 +Description
   13.11 +-----------
   13.12 +The KS0108 driver supports LC displays that use the Samsung KS0108
   13.13 +controller, connected to the parallel port of your PC.
   13.14 +
   13.15 +
   13.16 +Wirings
   13.17 +-------
   13.18 +The KS0108 driver supports the following connection on a parallel
   13.19 +port:
   13.20 +
   13.21 +  printerport   LCD          other
   13.22 +  -----------   ----------   ----------
   13.23 +  GND    (18)   GND   (01)   GND          (Ground)
   13.24 +                Vdd   (02)   +5V
   13.25 +                Vo    (03)                (LCD Contrast In)
   13.26 +  nSEL   (17)   R/S   (04)                (Register Select)
   13.27 +                R/W   (05)   GND          (Read/Write)
   13.28 +  nSTRB  (01)   EN    (06)                (Enable)
   13.29 +  D0     (02)   D0    (07)                (DataBit0)
   13.30 +  D1     (03)   D1    (08)                (DataBit1)
   13.31 +  D2     (04)   D2    (09)                (DataBit2)
   13.32 +  D3     (05)   D3    (10)                (DataBit3)
   13.33 +  D4     (06)   D4    (11)                (DataBit4)
   13.34 +  D5     (07)   D5    (12)                (DataBit5)
   13.35 +  D6     (08)   D6    (13)                (DataBit6)
   13.36 +  D7     (09)   D7    (14)                (DataBit7)
   13.37 +  nAUTO  (14)   CS1   (15)                (ChipSelect Controller 1)
   13.38 +  INIT   (16)   CS2   (16)                (ChipSelect Controller 2)
   13.39 +                RESET (17)   +5V          (Controller Reset)
   13.40 +                Vout  (18)                (Contrast Out)
   13.41 +                LED+  (19)   +4V          (Backlight)
   13.42 +                LED-  (20)   GND          (Backlight GND)
   13.43 +
   13.44 +Note: The pin numbering may vary with other displays.
   13.45 +
   13.46 +If you want to connect a 192x64 or 256x64 display (with 3 or 4
   13.47 +ChipSelects) or two 128x64 displays, you must add a binary decoder for
   13.48 +the ChipSelect lines. The mode ist auto-selected based on the width and
   13.49 +height parameters.
   13.50 +
   13.51 +        nAUTO (14)
   13.52 +        |   INIT (16)
   13.53 +    Vdd |   |   GND GND
   13.54 +    |   |   |   |   |
   13.55 +    16  15  14  13  12  11  10  09
   13.56 +   --------------------------------
   13.57 +  |                                |
   13.58 +   >                               |
   13.59 +  |                                |
   13.60 +   --------------------------------
   13.61 +    01  02  03  04  05  06  07  08
   13.62 +    |   |   |   |               |
   13.63 +    CS1 |   |   |               GND
   13.64 +        CS2 |   CS4 (CS2 second LCD)
   13.65 +            CS3 (CS1 second LCD)
   13.66 +
   13.67 +
   13.68 +Configuration Parameters
   13.69 +------------------------
   13.70 +The KS0108 driver supports the following parameters in config file:
   13.71 +
   13.72 +Device
   13.73 + Instead of using the direct output via port address (see Port), you
   13.74 + can use the parport device (/dev/parportX). The advantage over the
   13.75 + direct output via port address is that this works for non-root users
   13.76 + also. But it's a little bit slower. The modules ppdev.o, parport.o
   13.77 + and parport_pc.o must be loaded or compiled into the kernel.
   13.78 +
   13.79 +Port
   13.80 + Sets the port address of the parallel port. If this parameter is not
   13.81 + given, 0x378 is used. To use this direct output, the program that
   13.82 + uses the driver library has to be started with user 'root'.
   13.83 +
   13.84 +Width
   13.85 + Sets the horizontal size of the display. If this parameter is not
   13.86 + given, a default value of 128 pixels is used.
   13.87 +
   13.88 +Height
   13.89 + Sets the vertical size of the display. If this parameter is not
   13.90 + given, a default value of 64 pixels is used.
   13.91 +
   13.92 +UpsideDown
   13.93 + Rotates the display output by 180 degrees. This might be useful, if
   13.94 + the LCD is mounted upside-down.
   13.95 + Possible values: 'yes', 'no'
   13.96 + Default value: 'no'
   13.97 +
   13.98 +Invert
   13.99 + Inverts the display.
  13.100 + Possible values: 'yes', 'no'
  13.101 + Default value: 'no'
  13.102 +
  13.103 +AdjustTiming
  13.104 + To get a timing that is as accurate as possible, the drivers measure
  13.105 + the time for port commands (see: benchmark in syslog). You might
  13.106 + decrease or increase the time to wait after port commands with this
  13.107 + parameter. Normally, there is no need to change this parameter.
  13.108 + Possible values: -50 <= x <= 50
  13.109 + Default value: 0
  13.110 +
  13.111 +RefreshDisplay
  13.112 + Normally, most of the drivers do not update the whole display, but
  13.113 + only the areas that have changed since last update. So it might be,
  13.114 + that some faulty pixels would stay a longer time. To avoid this, the
  13.115 + plugin makes a complete refresh from time to time. This parameter
  13.116 + defines how often a complete refresh will be done.
  13.117 + e.g.: A value of 5 means, that the plugin will make a complete
  13.118 +       refresh on every 5th update.
  13.119 + A value of 0 completely disables complete refreshs. 
  13.120 + Possible values: 0 <= x <= 50
  13.121 + Default value: 5
  13.122 +
  13.123 +Control
  13.124 + Sets the variant of setting the display control lines.
  13.125 + Possible values: 0, 1
  13.126 + Default value: 1
  13.127 + 
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/graphlcd-base/docs/DRIVER.noritake800	Wed Feb 06 17:32:55 2008 +0000
    14.3 @@ -0,0 +1,115 @@
    14.4 +---------------------------------------------------------------------
    14.5 +GraphLCD driver library
    14.6 +
    14.7 +The Noritake 800(A) series driver
    14.8 +---------------------------------------------------------------------
    14.9 +
   14.10 +Description
   14.11 +-----------
   14.12 +The Noritake 800(A) series driver supports following VFD displays manufactured
   14.13 +by Noritake (see http://www.noritake-itron.com on the link "Medium 0.6 dot"):
   14.14 + - GU128X64-800A;
   14.15 + - GU256X32-800A;
   14.16 + - GU128X32-800A;
   14.17 + - GU160X16-800A;
   14.18 + - GU160X32-800A;
   14.19 + - GU192X16-800A.
   14.20 +
   14.21 +Wirings
   14.22 +-------
   14.23 +The VFD should be connected to a parallel port of the PC
   14.24 +
   14.25 +printer port      LIQUIDMP3        MZ            other?
   14.26 +---------------------------------------------
   14.27 +
   14.28 +Data lines D0...D7 connected straight in all wirings
   14.29 +
   14.30 +Strobe (1)         CSS (23)      WR (17)
   14.31 +Linefeed (14)      RD (21)       RD (21)
   14.32 +Init (16)          WR (17)       CSS (23)
   14.33 +Select (17)        C/D (19)      C/D (19)
   14.34 +
   14.35 +Printer port pins 18 .... 25 connected to GND;
   14.36 +VFD *ONLY EVEN* pins 2 .... 24 connected to GND
   14.37 +Everything else is *NOT CONNECTED*
   14.38 +
   14.39 +Further wirings might work and then for sure very easyly added to the code.
   14.40 +Just extend N800LptWiringMask(..) accordingly. This method is called in a
   14.41 +loop over all 16 (4 wires for now) possibilities in the constructor, so the
   14.42 +results are cached for the actual writes to the LPT control port, very
   14.43 +similar to ReverseBits(..) for data.
   14.44 +
   14.45 +The driver should also work for "WIRING_MZ", just report if there are
   14.46 +problems.
   14.47 +Feel free to add support for "Parallel #2 Interface" or "Serial interface".
   14.48 +
   14.49 +Tested only on my own GU128x64-800(A) so far, just with the default 8-bit
   14.50 +mode parallel wiring (referred as WIRING_LIQUIDMP3 or "0" in this code, or
   14.51 +"Parallel #1 Interface"in the data sheet). I can't actually test the other
   14.52 +wiring (as the display is already mounted in my HTPC, and the cable soldered),
   14.53 +or even the other modes from the datasheet ("Parallel #2 Interface", or
   14.54 +"Serial interface"), for those, my display lacks the necessary jumpers on
   14.55 +it's PCB)
   14.56 +  
   14.57 +  
   14.58 +Configuration Parameters
   14.59 +------------------------
   14.60 +The Noritake 800(A) series driver supports the following parameters in config
   14.61 +file:
   14.62 +
   14.63 +Device
   14.64 + Instead of using the direct output via port address (see Port), you
   14.65 + can use the parport device (/dev/parportX). The advantage over the
   14.66 + direct output via port address is that this works for non-root users
   14.67 + also. But it's a little bit slower. The modules ppdev.o, parport.o
   14.68 + and parport_pc.o must be loaded or compiled into the kernel.
   14.69 +
   14.70 +Port
   14.71 + Sets the port address of the parallel port. If this parameter is not
   14.72 + given, 0x378 is used. To use this direct output, the program that
   14.73 + uses the driver library has to be started with user 'root'.
   14.74 +
   14.75 +Width
   14.76 + Sets the horizontal size of the display. If this parameter is not
   14.77 + given, a default value of 256 pixels is used.
   14.78 +
   14.79 +Height
   14.80 + Sets the vertical size of the display. If this parameter is not
   14.81 + given, a default value of 64 pixels is used.
   14.82 +
   14.83 +UpsideDown
   14.84 + Rotates the display output by 180 degrees. This might be useful, if
   14.85 + the LCD is mounted upside-down.
   14.86 + Possible values: 'yes', 'no'
   14.87 + Default value: 'no'
   14.88 +
   14.89 +Invert
   14.90 + Inverts the display.
   14.91 + Possible values: 'yes', 'no'
   14.92 + Default value: 'no'
   14.93 +
   14.94 +Brightness
   14.95 + Sets the brightness of your display's backlight.
   14.96 + Possible values: 0 <= x <= 100)
   14.97 + Default value: 100
   14.98 +
   14.99 +AdjustTiming ---> not used in this driver (if there are problems, please report)
  14.100 + To get a timing that is as accurate as possible, the drivers measure
  14.101 + the time for port commands (see: benchmark in syslog). You might
  14.102 + decrease or increase the time to wait after port commands with this
  14.103 + parameter. Normally, there is no need to change this parameter.
  14.104 + Possible values: -50 <= x <= 50
  14.105 + Default value: 0
  14.106 +
  14.107 +RefreshDisplay ---> not used in this driver (if there are problems, please report)
  14.108 + Normally, most of the drivers do not update the whole display, but
  14.109 + only the areas that have changed since last update. So it might be,
  14.110 + that some faulty pixels would stay a longer time. To avoid this, the
  14.111 + plugin makes a complete refresh from time to time. This parameter
  14.112 + defines how often a complete refresh will be done.
  14.113 + e.g.: A value of 5 means, that the plugin will make a complete
  14.114 +       refresh on every 5th update.
  14.115 + A value of 0 completely disables complete refreshs. 
  14.116 + Possible values: 0 <= x <= 50
  14.117 + Default value: 5
  14.118 +
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/graphlcd-base/docs/DRIVER.sed1330	Wed Feb 06 17:32:55 2008 +0000
    15.3 @@ -0,0 +1,223 @@
    15.4 +---------------------------------------------------------------------
    15.5 +GraphLCD driver library
    15.6 +
    15.7 +The SED1330 driver
    15.8 +---------------------------------------------------------------------
    15.9 +
   15.10 +Description
   15.11 +-----------
   15.12 +The SED1330 driver supports LC displays that use the Epson
   15.13 +SED1330/1335 controller, connected to the parallel port of your PC.
   15.14 +
   15.15 +
   15.16 +Wirings
   15.17 +-------
   15.18 +The SED1330 driver supports the following connections on a parallel
   15.19 +port:
   15.20 + - Original
   15.21 + - PowerLCD
   15.22 + - LCDProc
   15.23 + - Tweakers
   15.24 + - YASEDW
   15.25 +
   15.26 +Original wiring:
   15.27 +
   15.28 +  printerport   LCD          other        function in 6800 mode   8080 mode
   15.29 +  -----------   ----------   ----------   ---------------------   -----------
   15.30 +                /RES  (01)   +5V          /RES (Reset)
   15.31 +  nSTRB  (01)   /RD   (02)                E (Enable)              /RD (Read)
   15.32 +  nAUTO  (14)   /WR   (03)                R/W (Read/Write)        /WR (Write)
   15.33 +                SEL2  (04)   GND          Interface select 2
   15.34 +                SEL1  (05)   +5V          Interface select 1
   15.35 +  nSEL   (17)   /CS   (06)   GND          /CS (Chip select)
   15.36 +  INIT   (16)   A0    (07)                A0 (Access type)
   15.37 +  D0     (02)   DB0   (08)                D0 (Data bus 0)
   15.38 +  D1     (03)   DB1   (09)                D1 (Data bus 1)
   15.39 +  D2     (04)   DB2   (10)                D2 (Data bus 2)
   15.40 +  D3     (05)   DB3   (11)                D3 (Data bus 3)
   15.41 +  D4     (06)   DB4   (12)                D4 (Data bus 4)
   15.42 +  D5     (07)   DB5   (13)                D5 (Data bus 5)
   15.43 +  D6     (08)   DB6   (14)                D6 (Data bus 6)
   15.44 +  D7     (09)   DB7   (15)                D7 (Data bus 7)
   15.45 +                VDD   (16)   +5V          VDD (Logic power supply)
   15.46 +  GND    (18)   VSS   (17)   GND          GND (Ground)
   15.47 +                V0    (18)   +5V..-22V    V0 (LCD contrast)
   15.48 +                VLC   (19)   -22V         VEE (LCD drive voltage)
   15.49 +                FGND  (20)   GND          Frame ground
   15.50 +
   15.51 +PowerLCD wiring:
   15.52 +
   15.53 +  printerport   LCD          other        function in 6800 mode   8080 mode
   15.54 +  -----------   ----------   ----------   ---------------------   -----------
   15.55 +                /RES  (01)   +5V          /RES (Reset)
   15.56 +  nSEL   (17)   /RD   (02)                E (Enable)              /RD (Read)
   15.57 +  nSTRB  (01)   /WR   (03)                R/W (Read/Write)        /WR (Write)
   15.58 +                SEL2  (04)   GND          Interface select 2
   15.59 +                SEL1  (05)   +5V          Interface select 1
   15.60 +  nAUTO  (14)   /CS   (06)   GND          /CS (Chip select)
   15.61 +  INIT   (16)   A0    (07)                A0 (Access type)
   15.62 +  D0     (02)   DB0   (08)                D0 (Data bus 0)
   15.63 +  D1     (03)   DB1   (09)                D1 (Data bus 1)
   15.64 +  D2     (04)   DB2   (10)                D2 (Data bus 2)
   15.65 +  D3     (05)   DB3   (11)                D3 (Data bus 3)
   15.66 +  D4     (06)   DB4   (12)                D4 (Data bus 4)
   15.67 +  D5     (07)   DB5   (13)                D5 (Data bus 5)
   15.68 +  D6     (08)   DB6   (14)                D6 (Data bus 6)
   15.69 +  D7     (09)   DB7   (15)                D7 (Data bus 7)
   15.70 +                VDD   (16)   +5V          VDD (Logic power supply)
   15.71 +  GND    (18)   VSS   (17)   GND          GND (Ground)
   15.72 +                V0    (18)   +5V..-22V    V0 (LCD contrast)
   15.73 +                VLC   (19)   -22V         VEE (LCD drive voltage)
   15.74 +                FGND  (20)   GND          Frame ground
   15.75 +
   15.76 +LCDProc wiring:
   15.77 +
   15.78 +  printerport   LCD          other        function in 6800 mode   8080 mode
   15.79 +  -----------   ----------   ----------   ---------------------   -----------
   15.80 +                /RES  (01)   +5V          /RES (Reset)
   15.81 +  INIT   (16)   /RD   (02)                E (Enable)              /RD (Read)
   15.82 +  nAUTO  (14)   /WR   (03)                R/W (Read/Write)        /WR (Write)
   15.83 +                SEL2  (04)   GND          Interface select 2
   15.84 +                SEL1  (05)   +5V          Interface select 1
   15.85 +  nSTRB  (01)   /CS   (06)   GND          /CS (Chip select)
   15.86 +  nSEL   (17)   A0    (07)                A0 (Access type)
   15.87 +  D0     (02)   DB0   (08)                D0 (Data bus 0)
   15.88 +  D1     (03)   DB1   (09)                D1 (Data bus 1)
   15.89 +  D2     (04)   DB2   (10)                D2 (Data bus 2)
   15.90 +  D3     (05)   DB3   (11)                D3 (Data bus 3)
   15.91 +  D4     (06)   DB4   (12)                D4 (Data bus 4)
   15.92 +  D5     (07)   DB5   (13)                D5 (Data bus 5)
   15.93 +  D6     (08)   DB6   (14)                D6 (Data bus 6)
   15.94 +  D7     (09)   DB7   (15)                D7 (Data bus 7)
   15.95 +                VDD   (16)   +5V          VDD (Logic power supply)
   15.96 +  GND    (18)   VSS   (17)   GND          GND (Ground)
   15.97 +                V0    (18)   +5V..-22V    V0 (LCD contrast)
   15.98 +                VLC   (19)   -22V         VEE (LCD drive voltage)
   15.99 +                FGND  (20)   GND          Frame ground
  15.100 +
  15.101 +Tweakers wiring:
  15.102 +
  15.103 +  printerport   LCD          other        function in 6800 mode   8080 mode
  15.104 +  -----------   ----------   ----------   ---------------------   -----------
  15.105 +                /RES  (01)   +5V          /RES (Reset)
  15.106 +  nAUTO  (14)   /RD   (02)                E (Enable)              /RD (Read)
  15.107 +  INIT   (16)   /WR   (03)                R/W (Read/Write)        /WR (Write)
  15.108 +                SEL2  (04)   GND          Interface select 2
  15.109 +                SEL1  (05)   +5V          Interface select 1
  15.110 +  nSTRB  (01)   /CS   (06)   GND          /CS (Chip select)
  15.111 +  nSEL   (17)   A0    (07)                A0 (Access type)
  15.112 +  D0     (02)   DB0   (08)                D0 (Data bus 0)
  15.113 +  D1     (03)   DB1   (09)                D1 (Data bus 1)
  15.114 +  D2     (04)   DB2   (10)                D2 (Data bus 2)
  15.115 +  D3     (05)   DB3   (11)                D3 (Data bus 3)
  15.116 +  D4     (06)   DB4   (12)                D4 (Data bus 4)
  15.117 +  D5     (07)   DB5   (13)                D5 (Data bus 5)
  15.118 +  D6     (08)   DB6   (14)                D6 (Data bus 6)
  15.119 +  D7     (09)   DB7   (15)                D7 (Data bus 7)
  15.120 +                VDD   (16)   +5V          VDD (Logic power supply)
  15.121 +  GND    (18)   VSS   (17)   GND          GND (Ground)
  15.122 +                V0    (18)   +5V..-22V    V0 (LCD contrast)
  15.123 +                VLC   (19)   -22V         VEE (LCD drive voltage)
  15.124 +                FGND  (20)   GND          Frame ground
  15.125 +
  15.126 +YASEDW wiring:
  15.127 +
  15.128 +  printerport   LCD          other        function in 6800 mode   8080 mode
  15.129 +  -----------   ----------   ----------   ---------------------   -----------
  15.130 +                /RES  (01)   +5V          /RES (Reset)
  15.131 +  INIT   (16)   /RD   (02)                E (Enable)              /RD (Read)
  15.132 +  nSTRB  (01)   /WR   (03)                R/W (Read/Write)        /WR (Write)
  15.133 +                SEL2  (04)   GND          Interface select 2
  15.134 +                SEL1  (05)   +5V          Interface select 1
  15.135 +  nSEL   (17)   /CS   (06)   GND          /CS (Chip select)
  15.136 +  nAUTO  (14)   A0    (07)                A0 (Access type)
  15.137 +  D0     (02)   DB0   (08)                D0 (Data bus 0)
  15.138 +  D1     (03)   DB1   (09)                D1 (Data bus 1)
  15.139 +  D2     (04)   DB2   (10)                D2 (Data bus 2)
  15.140 +  D3     (05)   DB3   (11)                D3 (Data bus 3)
  15.141 +  D4     (06)   DB4   (12)                D4 (Data bus 4)
  15.142 +  D5     (07)   DB5   (13)                D5 (Data bus 5)
  15.143 +  D6     (08)   DB6   (14)                D6 (Data bus 6)
  15.144 +  D7     (09)   DB7   (15)                D7 (Data bus 7)
  15.145 +                VDD   (16)   +5V          VDD (Logic power supply)
  15.146 +  GND    (18)   VSS   (17)   GND          GND (Ground)
  15.147 +                V0    (18)   +5V..-22V    V0 (LCD contrast)
  15.148 +                VLC   (19)   -22V         VEE (LCD drive voltage)
  15.149 +                FGND  (20)   GND          Frame ground
  15.150 +
  15.151 +Note: The pin numbering may vary with other displays.
  15.152 +
  15.153 +SEL1 on GND selects 8080 mode, SEL1 on VDD selects 6800 mode.
  15.154 +
  15.155 +
  15.156 +Configuration Parameters
  15.157 +------------------------
  15.158 +The SED1330 driver supports the following parameters in config file:
  15.159 +
  15.160 +Device
  15.161 + Instead of using the direct output via port address (see Port), you
  15.162 + can use the parport device (/dev/parportX). The advantage over the
  15.163 + direct output via port address is that this works for non-root users
  15.164 + also. But it's a little bit slower. The modules ppdev.o, parport.o
  15.165 + and parport_pc.o must be loaded or compiled into the kernel.
  15.166 +
  15.167 +Port
  15.168 + Sets the port address of the parallel port. If this parameter is not
  15.169 + given, 0x378 is used. To use this direct output, the program that
  15.170 + uses the driver library has to be started with user 'root'.
  15.171 +
  15.172 +Width
  15.173 + Sets the horizontal size of the display. If this parameter is not
  15.174 + given, a default value of 320 pixels is used.
  15.175 +
  15.176 +Height
  15.177 + Sets the vertical size of the display. If this parameter is not
  15.178 + given, a default value of 240 pixels is used.
  15.179 +
  15.180 +UpsideDown
  15.181 + Rotates the display output by 180 degrees. This might be useful, if
  15.182 + the LCD is mounted upside-down.
  15.183 + Possible values: 'yes', 'no'
  15.184 + Default value: 'no'
  15.185 +
  15.186 +Invert
  15.187 + Inverts the display.
  15.188 + Possible values: 'yes', 'no'
  15.189 + Default value: 'no'
  15.190 +
  15.191 +AdjustTiming
  15.192 + To get a timing that is as accurate as possible, the drivers measure
  15.193 + the time for port commands (see: benchmark in syslog). You might
  15.194 + decrease or increase the time to wait after port commands with this
  15.195 + parameter. Normally, there is no need to change this parameter.
  15.196 + Possible values: -50 <= x <= 50
  15.197 + Default value: 0
  15.198 +
  15.199 +RefreshDisplay
  15.200 + Normally, most of the drivers do not update the whole display, but
  15.201 + only the areas that have changed since last update. So it might be,
  15.202 + that some faulty pixels would stay a longer time. To avoid this, the
  15.203 + plugin makes a complete refresh from time to time. This parameter
  15.204 + defines how often a complete refresh will be done.
  15.205 + e.g.: A value of 5 means, that the plugin will make a complete
  15.206 +       refresh on every 5th update.
  15.207 + A value of 0 completely disables complete refreshs. 
  15.208 + Possible values: 0 <= x <= 50
  15.209 + Default value: 5
  15.210 +
  15.211 +Wiring
  15.212 + Select the type of wiring your display is connected with.
  15.213 + Possible values: 'Original', 'PowerLCD', 'LCDProc', 'Tweakers',
  15.214 +                  'YASEDW'
  15.215 + Default value: 'Original'
  15.216 +
  15.217 +OscillatorFrequency
  15.218 + Select the frequency the oscillator on your LCD board uses in kHz.
  15.219 + Possible values: 1000 <= x <= 15000)
  15.220 + Default value: 9600
  15.221 +
  15.222 +Interface
  15.223 + Select the interface mode your display is connected with.
  15.224 + Possible values: '6800', '8080'
  15.225 + Default value: '6800'
  15.226 +
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/graphlcd-base/docs/DRIVER.sed1520	Wed Feb 06 17:32:55 2008 +0000
    16.3 @@ -0,0 +1,98 @@
    16.4 +---------------------------------------------------------------------
    16.5 +GraphLCD driver library
    16.6 +
    16.7 +The SED1520 driver
    16.8 +---------------------------------------------------------------------
    16.9 +
   16.10 +Description
   16.11 +-----------
   16.12 +The SED1520 driver supports LC displays that use the Epson SED1520
   16.13 +controller, connected to the parallel port of your PC.
   16.14 +
   16.15 +
   16.16 +Wirings
   16.17 +-------
   16.18 +The SED1520 driver supports the following connection on a parallel
   16.19 +port:
   16.20 +
   16.21 +  printerport   LCD          other
   16.22 +  -----------   ----------   ----------
   16.23 +  GND    (18)   GND   (01)   GND          (Ground)
   16.24 +                Vdd   (02)   +5V
   16.25 +                Vo    (03)                (LCD Contrast In -4V)
   16.26 +  nSEL   (17)   R/S   (04)                (Register Select)
   16.27 +                R/W   (05)   GND          (Read/Write)
   16.28 +  nSTRB  (01)   EN1   (06)                (Enable Left)
   16.29 +  D0     (02)   D0    (07)                (DataBit0)
   16.30 +  D1     (03)   D1    (08)                (DataBit1)
   16.31 +  D2     (04)   D2    (09)                (DataBit2)
   16.32 +  D3     (05)   D3    (10)                (DataBit3)
   16.33 +  D4     (06)   D4    (11)                (DataBit4)
   16.34 +  D5     (07)   D5    (12)                (DataBit5)
   16.35 +  D6     (08)   D6    (13)                (DataBit6)
   16.36 +  D7     (09)   D7    (14)                (DataBit7)
   16.37 +  INIT   (16)   EN2   (15)                (Enable Right)
   16.38 +                RESET (16)   +5V          (Controller Reset)
   16.39 +                LED+  (17)   +4V/150mA    (Backlight with 6,4Ohm Resistor to +5V)
   16.40 +  nAUTO  (14)   LED-  (18)   GND          (Backlight GND [via BS170])
   16.41 +
   16.42 +  See also http://www.usblcd.de/lcdproc/sed1520-dip.php4 ...
   16.43 +
   16.44 +Note: The pin numbering may vary with other displays.
   16.45 +
   16.46 +
   16.47 +Configuration Parameters
   16.48 +------------------------
   16.49 +The SED1520 driver supports the following parameters in config file:
   16.50 +
   16.51 +Device
   16.52 + Instead of using the direct output via port address (see Port), you
   16.53 + can use the parport device (/dev/parportX). The advantage over the
   16.54 + direct output via port address is that this works for non-root users
   16.55 + also. But it's a little bit slower. The modules ppdev.o, parport.o
   16.56 + and parport_pc.o must be loaded or compiled into the kernel.
   16.57 +
   16.58 +Port
   16.59 + Sets the port address of the parallel port. If this parameter is not
   16.60 + given, 0x378 is used. To use this direct output, the program that
   16.61 + uses the driver library has to be started with user 'root'.
   16.62 +
   16.63 +Width
   16.64 + Sets the horizontal size of the display. If this parameter is not
   16.65 + given, a default value of 120 pixels is used.
   16.66 +
   16.67 +Height
   16.68 + Sets the vertical size of the display. If this parameter is not
   16.69 + given, a default value of 32 pixels is used.
   16.70 +
   16.71 +UpsideDown
   16.72 + Rotates the display output by 180 degrees. This might be useful, if
   16.73 + the LCD is mounted upside-down.
   16.74 + Possible values: 'yes', 'no'
   16.75 + Default value: 'no'
   16.76 +
   16.77 +Invert
   16.78 + Inverts the display.
   16.79 + Possible values: 'yes', 'no'
   16.80 + Default value: 'no'
   16.81 +
   16.82 +AdjustTiming
   16.83 + To get a timing that is as accurate as possible, the drivers measure
   16.84 + the time for port commands (see: benchmark in syslog). You might
   16.85 + decrease or increase the time to wait after port commands with this
   16.86 + parameter. Normally, there is no need to change this parameter.
   16.87 + Possible values: -50 <= x <= 50
   16.88 + Default value: 0
   16.89 +
   16.90 +RefreshDisplay
   16.91 + Normally, most of the drivers do not update the whole display, but
   16.92 + only the areas that have changed since last update. So it might be,
   16.93 + that some faulty pixels would stay a longer time. To avoid this, the
   16.94 + plugin makes a complete refresh from time to time. This parameter
   16.95 + defines how often a complete refresh will be done.
   16.96 + e.g.: A value of 5 means, that the plugin will make a complete
   16.97 +       refresh on every 5th update.
   16.98 + A value of 0 completely disables complete refreshs. 
   16.99 + Possible values: 0 <= x <= 50
  16.100 + Default value: 5
  16.101 +
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/graphlcd-base/docs/DRIVER.serdisp	Wed Feb 06 17:32:55 2008 +0000
    17.3 @@ -0,0 +1,61 @@
    17.4 +---------------------------------------------------------------------
    17.5 +GraphLCD driver library
    17.6 +
    17.7 +The serdisp driver
    17.8 +---------------------------------------------------------------------
    17.9 +
   17.10 +Description
   17.11 +-----------
   17.12 +The serdisp driver supports LC displays that are supported by
   17.13 +serdisplib (http://serdisplib.sourceforge.net).
   17.14 +
   17.15 +
   17.16 +Configuration Parameters
   17.17 +------------------------
   17.18 +The serdisp driver supports the following parameters in config file:
   17.19 +
   17.20 +Controller
   17.21 + Select the controller your LCD uses named like in serdisplib.
   17.22 + Possible values: See README in serdisplib package
   17.23 +
   17.24 +Device
   17.25 + Instead of using the direct output via port address (see Port), you
   17.26 + can use the parport device (/dev/parportX). The advantage over the
   17.27 + direct output via port address is that this works for non-root users
   17.28 + also. But it's a little bit slower. The modules ppdev.o, parport.o
   17.29 + and parport_pc.o must be loaded or compiled into the kernel.
   17.30 +
   17.31 +Port
   17.32 + Sets the port address of the parallel port. If this parameter is not
   17.33 + given, 0x378 is used. To use this direct output, the program that
   17.34 + uses the driver library has to be started with user 'root'.
   17.35 +
   17.36 +Width
   17.37 + Sets the horizontal size of the display. If this parameter is not
   17.38 + given, a default value according to the selected controller is used.
   17.39 +
   17.40 +Height
   17.41 + Sets the vertical size of the display. If this parameter is not
   17.42 + given, a default value according to the selected controller is used.
   17.43 +
   17.44 +UpsideDown
   17.45 + Rotates the display output by 180 degrees. This might be useful, if
   17.46 + the LCD is mounted upside-down.
   17.47 + Possible values: 'yes', 'no'
   17.48 + Default value: 'no'
   17.49 +
   17.50 +Invert
   17.51 + Inverts the display.
   17.52 + Possible values: 'yes', 'no'
   17.53 + Default value: 'no'
   17.54 +
   17.55 +Contrast
   17.56 + Sets the contrast of your display.
   17.57 + Possible values: 0 <= x <= 10
   17.58 + Default value: 5
   17.59 +
   17.60 +Backlight
   17.61 + Switches the backlight of your display on and off.
   17.62 + Possible values: 'yes', 'no'
   17.63 + Default value: 'yes'
   17.64 +
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/graphlcd-base/docs/DRIVER.simlcd	Wed Feb 06 17:32:55 2008 +0000
    18.3 @@ -0,0 +1,36 @@
    18.4 +---------------------------------------------------------------------
    18.5 +GraphLCD driver library
    18.6 +
    18.7 +The SimLCD driver
    18.8 +---------------------------------------------------------------------
    18.9 +
   18.10 +Description
   18.11 +-----------
   18.12 +The Image driver writes a file including the output that you would
   18.13 +normally see on a LCD e.g. from the graphlcd plugin. You can use the
   18.14 +SimLCD tool to view this file.
   18.15 +
   18.16 +
   18.17 +Configuration Parameters
   18.18 +------------------------
   18.19 +The SimLCD driver supports the following parameters in config file:
   18.20 +
   18.21 +Width
   18.22 + Sets the horizontal size of the display. If this parameter is not
   18.23 + given, a default value of 240 pixels is used.
   18.24 +
   18.25 +Height
   18.26 + Sets the vertical size of the display. If this parameter is not
   18.27 + given, a default value of 128 pixels is used.
   18.28 +
   18.29 +UpsideDown
   18.30 + Rotates the display output by 180 degrees. This might be useful, if
   18.31 + the LCD is mounted upside-down.
   18.32 + Possible values: 'yes', 'no'
   18.33 + Default value: 'no'
   18.34 +
   18.35 +Invert
   18.36 + Inverts the display.
   18.37 + Possible values: 'yes', 'no'
   18.38 + Default value: 'no'
   18.39 +
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/graphlcd-base/docs/DRIVER.t6963c	Wed Feb 06 17:32:55 2008 +0000
    19.3 @@ -0,0 +1,159 @@
    19.4 +---------------------------------------------------------------------
    19.5 +GraphLCD driver library
    19.6 +
    19.7 +The T6963C driver
    19.8 +---------------------------------------------------------------------
    19.9 +
   19.10 +Description
   19.11 +-----------
   19.12 +The T6963C driver supports LC displays that use the Toshiba T6963C
   19.13 +controller, connected to the parallel port of your PC.
   19.14 +
   19.15 +
   19.16 +Wirings
   19.17 +-------
   19.18 +The T6963C driver supports the following connections on a parallel
   19.19 +port:
   19.20 + - Standard (used by LCDproc)
   19.21 + - Windows (used by many windows programs)
   19.22 +
   19.23 +Standard wiring:
   19.24 +
   19.25 +  printerport   LCD          other
   19.26 +  -----------   ----------   ----------
   19.27 +  GND    (18)   GND   (01)   GND          (Ground)
   19.28 +  nSTRB  (01)   WR    (06)                (Write)
   19.29 +  nAUTO  (14)   CE    (15)                (Chip Enable)
   19.30 +  INIT   (16)   C/D   (04)                (Command/Data)
   19.31 +  nSEL   (17)   RD    (05)                (Read)
   19.32 +  D0     (02)   D0    (07)                (Data Bit 0)
   19.33 +  D1     (03)   D1    (08)                (Data Bit 1)
   19.34 +  D2     (04)   D2    (09)                (Data Bit 2)
   19.35 +  D3     (05)   D3    (10)                (Data Bit 3)
   19.36 +  D4     (06)   D4    (11)                (Data Bit 4)
   19.37 +  D5     (07)   D5    (12)                (Data Bit 5)
   19.38 +  D6     (08)   D6    (13)                (Data Bit 6)
   19.39 +  D7     (09)   D7    (14)                (Data Bit 7)
   19.40 +
   19.41 +Windows wiring:
   19.42 +
   19.43 +  printerport   LCD          other
   19.44 +  -----------   ----------   ----------
   19.45 +  GND    (18)   GND   (01)   GND          (Ground)
   19.46 +  nSTRB  (01)   CE    (15)                (Chip Enable)
   19.47 +  nAUTO  (14)   RD    (05)                (Read)
   19.48 +  INIT   (16)   WR    (06)                (Write)
   19.49 +  nSEL   (17)   C/D   (04)                (Command/Data)
   19.50 +  D0     (02)   D0    (07)                (Data Bit 0)
   19.51 +  D1     (03)   D1    (08)                (Data Bit 1)
   19.52 +  D2     (04)   D2    (09)                (Data Bit 2)
   19.53 +  D3     (05)   D3    (10)                (Data Bit 3)
   19.54 +  D4     (06)   D4    (11)                (Data Bit 4)
   19.55 +  D5     (07)   D5    (12)                (Data Bit 5)
   19.56 +  D6     (08)   D6    (13)                (Data Bit 6)
   19.57 +  D7     (09)   D7    (14)                (Data Bit 7)
   19.58 +
   19.59 +Serial wiring using a industry version with a serial to parallel
   19.60 +converter:
   19.61 +
   19.62 +  printerport   LCD
   19.63 +  -----------   ----------
   19.64 +  nAuto  (14)   nCE   (03)
   19.65 +  nSTRB  (01)   nSCK  (07)
   19.66 +  INIT   (16)   nC/D  (08)
   19.67 +  INIT   (16)   nSDAT (08)
   19.68 +  GND    (25)   GND   (01)
   19.69 +
   19.70 +
   19.71 +Note: The pin numbering may vary with other displays.
   19.72 +
   19.73 +The LCD must operate in the 6x8 or 8x8 font mode. Usually, there is a
   19.74 +pin to choose 6x8 or 8x8 font mode.
   19.75 +
   19.76 +There are Displays that have a pin to select the number of characters
   19.77 +per line. In that case, you have to select (width (in pixels) / 6) or
   19.78 +(width (in pixels) / 8) characters per line.
   19.79 +
   19.80 +Attention: You have to tie these pins to +5V or GND. Don't leave them
   19.81 +open circuit or you will get unpredictable results.
   19.82 +
   19.83 +Because the T6963 driver reads the status of the display, it might be
   19.84 +neccessary to enable the bidirectional mode in the BIOS and to enable
   19.85 +bidirectional mode in the Linux kernel:
   19.86 + <*> Parallel port support
   19.87 +  <*>   PC-style hardware
   19.88 +  [*]   IEEE 1284 transfer modes
   19.89 +
   19.90 +
   19.91 +Configuration Parameters
   19.92 +------------------------
   19.93 +The T6963C driver supports the following parameters in config file:
   19.94 +
   19.95 +Device
   19.96 + Instead of using the direct output via port address (see Port), you
   19.97 + can use the parport device (/dev/parportX). The advantage over the
   19.98 + direct output via port address is that this works for non-root users
   19.99 + also. But it's a little bit slower. The modules ppdev.o, parport.o
  19.100 + and parport_pc.o must be loaded or compiled into the kernel.
  19.101 +
  19.102 +Port
  19.103 + Sets the port address of the parallel port. If this parameter is not
  19.104 + given, 0x378 is used. To use this direct output, the program that
  19.105 + uses the driver library has to be started with user 'root'.
  19.106 +
  19.107 +Width
  19.108 + Sets the horizontal size of the display. If this parameter is not
  19.109 + given, a default value of 240 pixels is used.
  19.110 +
  19.111 +Height
  19.112 + Sets the vertical size of the display. If this parameter is not
  19.113 + given, a default value of 128 pixels is used.
  19.114 +
  19.115 +UpsideDown
  19.116 + Rotates the display output by 180 degrees. This might be useful, if
  19.117 + the LCD is mounted upside-down.
  19.118 + Possible values: 'yes', 'no'
  19.119 + Default value: 'no'
  19.120 +
  19.121 +Invert
  19.122 + Inverts the display.
  19.123 + Possible values: 'yes', 'no'
  19.124 + Default value: 'no'
  19.125 +
  19.126 +RefreshDisplay
  19.127 + Normally, most of the drivers do not update the whole display, but
  19.128 + only the areas that have changed since last update. So it might be,
  19.129 + that some faulty pixels would stay a longer time. To avoid this, the
  19.130 + plugin makes a complete refresh from time to time. This parameter
  19.131 + defines how often a complete refresh will be done.
  19.132 + e.g.: A value of 5 means, that the plugin will make a complete
  19.133 +       refresh on every 5th update.
  19.134 + A value of 0 completely disables complete refreshs. 
  19.135 + Possible values: 0 <= x <= 50
  19.136 + Default value: 5
  19.137 +
  19.138 +Wiring
  19.139 + Select the type of wiring your display is connected with.
  19.140 + Possible values: 'Standard', 'Windows'
  19.141 + Default value: 'Standard'
  19.142 +
  19.143 +FontSelect
  19.144 + Select the font width your display uses for text mode. In most cases
  19.145 + this is selectable through one of the pins of your LCD board
  19.146 + Possible values: '6', '8'
  19.147 + Default value: '6'
  19.148 +
  19.149 +AutoMode
  19.150 + Enables or disables the usage of T6963C's auto mode which doubles
  19.151 + writing speed when enabled.
  19.152 + Possible values: 'yes', 'no'
  19.153 + Default value: 'yes'
  19.154 +
  19.155 +StatusCheck
  19.156 + Enables or disables the usage of T6963C's status check. When using a
  19.157 + shielded cable for connecting your display, the disabling may be
  19.158 + possible. This results in doubling the speed of writing data to the
  19.159 + LCD.
  19.160 + Possible values: 'yes', 'no'
  19.161 + Default value: 'yes'
  19.162 +
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/graphlcd-base/docs/README.convpic	Wed Feb 06 17:32:55 2008 +0000
    20.3 @@ -0,0 +1,42 @@
    20.4 +This is the README of the crtfont tool, which is part of the GraphLCD
    20.5 +base package.
    20.6 +
    20.7 +written by Carsten Siebholz <c.siebholz AT t-online.de>
    20.8 +           Andreas Brachold <vdr04 AT deltab de>
    20.9 +
   20.10 +See the file COPYING for license information.
   20.11 +
   20.12 +
   20.13 +Description:
   20.14 +------------
   20.15 +convpic is a program to convert images to an own simple format (*.glcd)
   20.16 +that is used by the GraphLCD graphics library.
   20.17 +
   20.18 +
   20.19 +Installation and Configuration:
   20.20 +-------------------------------
   20.21 +see the file README in the base package's root directory.
   20.22 +
   20.23 +
   20.24 +Using convpic:
   20.25 +--------------
   20.26 +Usage: convpic [-n] [-d x] -i infile [more files] -o outfile
   20.27 +
   20.28 +  -n  --invert   inverts the output (default: no)
   20.29 +  -i  --infile   specifies the name of the input file
   20.30 +  -o  --outfile  specifies the name of the output file
   20.31 +  -d  --delay    specifies the delay delay between multiple images
   20.32 +
   20.33 +supported formats:
   20.34 +  TIFF: file is an uncompressed RGB-encoded 2-color TIFF
   20.35 +  BMP : file is an uncompressed RGB-encoded 2-color Windows BMP
   20.36 +  ANI : file is an uncompressed multi-frame from tuxbox-aniplay
   20.37 +  GLCD: file is the own format used by the GraphLCD graphics library
   20.38 +
   20.39 +example: convpic -i vdr-logo.bmp -o vdr-logo.glcd
   20.40 +
   20.41 +
   20.42 +Known Problems:
   20.43 +---------------
   20.44 +  Export of TIFF isn't supported.
   20.45 +
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/graphlcd-base/docs/README.crtfont	Wed Feb 06 17:32:55 2008 +0000
    21.3 @@ -0,0 +1,61 @@
    21.4 +This is the README of the crtfont tool, which is part of the GraphLCD
    21.5 +base package.
    21.6 +
    21.7 +written by Andreas Regel (andreas.regel AT powarman.de)
    21.8 +
    21.9 +based on crtfont from the graphlcd plugin for the Video Disc Recorder
   21.10 +written by Carsten Siebholz (c.siebholz AT t-online.de)
   21.11 +
   21.12 +See the file COPYING for license information.
   21.13 +
   21.14 +
   21.15 +Description:
   21.16 +------------
   21.17 +crtfont is a program to create fonts for the GraphLCD graphics library.
   21.18 +
   21.19 +
   21.20 +Installation and Configuration:
   21.21 +-------------------------------
   21.22 +see the file README in the base package's root directory.
   21.23 +
   21.24 +
   21.25 +Using crtfont:
   21.26 +--------------
   21.27 +To create a font, 2 source files are required:
   21.28 +- an image, that contains the characters as a bitmap. This image might
   21.29 +  be in:
   21.30 +  - Portable Bit Map (PBM) format.
   21.31 +- a description file (*.desc), that contains informations about the
   21.32 +  positions of each character in the image.
   21.33 +  The format of the description file:
   21.34 +  - The first line contains the version of the description file format:
   21.35 +      version:1
   21.36 +  - The next lines contain the font attributes in the format
   21.37 +    <attribute>:<value>, one attribute per line. Possible attributes
   21.38 +	are:
   21.39 +      fontheight: the total height of the font
   21.40 +      fontascent: the vertical distance from the horizontal baseline to
   21.41 +                  the highest character coordinate.
   21.42 +      lineheight: the baseline-to-baseline distance
   21.43 +      spacebetween: additional space between characters in a text
   21.44 +      spacewidth: the width of the space character. If this value is
   21.45 +                  greater than zero, all characters will be compressed
   21.46 +                  horizontally to their active pixels.
   21.47 +  - All other lines define the characters and their positions in the
   21.48 +    image. The syntax is like:
   21.49 +      PosX_1 Char_1 PosX_2 Char_2 PosX_3  ... PosX_n Char_n EndX
   21.50 +    where PosX_x specifies the horizontal position of the leftmost
   21.51 +    pixel of the character. Char_x might be the character itself
   21.52 +    (A, B, ...) or it's decimal ASCII value (65, 66, ...)
   21.53 +
   21.54 +Usage: crtfont -f <format> -b <bmpfile> -d <descfile> -o <outfile>
   21.55 +
   21.56 +  -f  --format    specifies the format of the bitmap. Possible values
   21.57 +                  are:
   21.58 +                    PBM: file is an Portable Bit Map
   21.59 +  -b  --bmpfile   specifies the name of the bitmap file (*.pbm)
   21.60 +  -d  --descfile  specifies the name of the description file (*.desc)
   21.61 +  -o  --outfile   specifies the name of the output file (*.fnt)
   21.62 +
   21.63 +  example: crtfont -f PBM -b f12.pbm -d f12.desc -o f12.fnt
   21.64 +
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/graphlcd-base/docs/README.showpic	Wed Feb 06 17:32:55 2008 +0000
    22.3 @@ -0,0 +1,38 @@
    22.4 +This is the README of the showpic tool, which is part of the GraphLCD
    22.5 +base package.
    22.6 +
    22.7 +written by Andreas Regel (andreas.regel AT powarman.de)
    22.8 +
    22.9 +based on showpic from the graphlcd plugin for the Video Disc Recorder
   22.10 +written by Carsten Siebholz (c.siebholz AT t-online.de)
   22.11 +
   22.12 +See the file COPYING for license information.
   22.13 +
   22.14 +
   22.15 +Description:
   22.16 +------------
   22.17 +showpic is a program to show an image on a graphical LC Display. It
   22.18 +support all controller the GraphLCD driver library supports.
   22.19 +
   22.20 +The images must be in an own format (*.glcd), which can be created with
   22.21 +the convpic tool.
   22.22 +
   22.23 +
   22.24 +Using showpic:
   22.25 +--------------
   22.26 +  showpic [-c CONFIGFILE] [-d DISPLAY] [-s SLEEP] [-uie] file [more files]
   22.27 +
   22.28 +  -c  --config      specifies the location of the config file
   22.29 +                    (default: /etc/graphlcd.conf)
   22.30 +  -d  --display     specifies the output display
   22.31 +                    (default: the first one in config file)
   22.32 +  -u  --upsidedown  rotates the output by 180 degrees (default: no)
   22.33 +  -i  --invert      inverts the output (default: no)
   22.34 +  -e  --endless     show all images in endless loop (default: no)
   22.35 +  -s  --sleep       set sleeptime between two images [ms]
   22.36 +  -b  --brightness  set brightness for display if driver support it
   22.37 +                    (default: config file value)
   22.38 +
   22.39 +examples: showpic -c /etc/graphlcd.conf vdr-logo.glcd
   22.40 +          showpic -c /etc/graphlcd.conf -d LCD_T6963 -u -i vdr-logo.glcd
   22.41 +
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/graphlcd-base/docs/README.showtext	Wed Feb 06 17:32:55 2008 +0000
    23.3 @@ -0,0 +1,35 @@
    23.4 +This is the README of the showtext tool, which is part of the GraphLCD
    23.5 +base package.
    23.6 +
    23.7 +written by Andreas Regel (andreas.regel AT powarman.de)
    23.8 +
    23.9 +See the file COPYING for license information.
   23.10 +
   23.11 +
   23.12 +Description:
   23.13 +------------
   23.14 +showtext is a program to show a user defined text with a user defined
   23.15 +font on a graphical LC Display. It supports all controllers the GraphLCD
   23.16 +driver library supports.
   23.17 +
   23.18 +The font must be in a special format (*.fnt), which can be created with
   23.19 +the crtfont tool.
   23.20 +
   23.21 +
   23.22 +Using showtext:
   23.23 +--------------
   23.24 +  showtext [-c CONFIGFILE] [-d DISPLAY] [-f FONT] [-x XPOS] [-y YPOS] [-uib] text [more text]
   23.25 +
   23.26 +  -c  --config      specifies the location of the config file
   23.27 +                    (default: /etc/graphlcd.conf)
   23.28 +  -d  --display     specifies the output display
   23.29 +                    (default: the first one in config file)
   23.30 +  -f  --font        specifies the font that is used for the text output
   23.31 +  -x  --xpos        specifies the x-position where the text starts
   23.32 +  -y  --ypos        specifies the y-position where the text starts
   23.33 +  -u  --upsidedown  rotates the output by 180 degrees (default: no)
   23.34 +  -i  --invert      inverts the output (default: no)
   23.35 +  -b  --brightness  set brightness for display if driver support it [%]
   23.36 +                    (default: config file value)
   23.37 +
   23.38 +  example: showtext -c /etc/graphlcd.conf -f f17.fnt "Line1" "Line2"
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/graphlcd-base/glcddrivers/Makefile	Wed Feb 06 17:32:55 2008 +0000
    24.3 @@ -0,0 +1,60 @@
    24.4 +#
    24.5 +# Makefile for the GraphLCD driver library
    24.6 +#
    24.7 +
    24.8 +-include ../Make.config
    24.9 +
   24.10 +CXXFLAGS += -fPIC
   24.11 +
   24.12 +VERMAJOR = 1
   24.13 +VERMINOR = 0
   24.14 +VERMICRO = 0
   24.15 +
   24.16 +BASENAME = libglcddrivers.so
   24.17 +
   24.18 +LIBNAME = $(BASENAME).$(VERMAJOR).$(VERMINOR).$(VERMICRO)
   24.19 +
   24.20 +OBJS = common.o config.o driver.o drivers.o port.o simlcd.o framebuffer.o gu140x32f.o gu256x64-372.o gu256x64-3900.o hd61830.o ks0108.o image.o sed1330.o sed1520.o t6963c.o noritake800.o serdisp.o avrctl.o g15daemon.o network.o gu126x64D-K610A4.o
   24.21 +
   24.22 +HEADERS = config.h driver.h drivers.h
   24.23 +
   24.24 +
   24.25 +### Implicit rules:
   24.26 +
   24.27 +%.o: %.c
   24.28 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
   24.29 +
   24.30 +# Dependencies:
   24.31 +
   24.32 +MAKEDEP = g++ -MM -MG
   24.33 +DEPFILE = .dependencies
   24.34 +$(DEPFILE): Makefile
   24.35 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
   24.36 +
   24.37 +-include $(DEPFILE)
   24.38 +
   24.39 +### Targets:
   24.40 +
   24.41 +all: $(LIBNAME)
   24.42 +
   24.43 +$(LIBNAME): $(OBJS)
   24.44 +	$(CXX) $(CXXFLAGS) -shared $(OBJS) $(LIBS) -ldl -lpthread -Wl,-soname="$(BASENAME).$(VERMAJOR)" -o $@
   24.45 +	ln -sf $(LIBNAME) $(BASENAME)
   24.46 +
   24.47 +install: all
   24.48 +	install -d $(LIBDIR)
   24.49 +	install -m 755 $(LIBNAME) $(LIBDIR)/
   24.50 +	install -d $(INCDIR)/glcddrivers
   24.51 +	install -m 644 $(HEADERS) $(INCDIR)/glcddrivers/
   24.52 +	( cd $(LIBDIR); ln -sf $(LIBNAME) $(BASENAME).$(VERMAJOR); ln -sf $(LIBNAME) $(BASENAME) )
   24.53 +
   24.54 +uninstall:
   24.55 +	rm -f $(LIBDIR)/$(BASENAME)
   24.56 +	rm -f $(LIBDIR)/$(BASENAME).$(VERMAJOR)
   24.57 +	rm -f $(LIBDIR)/$(LIBNAME)
   24.58 +	(for i in $(HEADERS); do rm -f $(INCDIR)/glcddrivers/$$i; done)
   24.59 +	rmdir $(INCDIR)/glcddrivers
   24.60 +
   24.61 +clean:
   24.62 +	rm -f $(OBJS) $(DEPFILE) $(LIBNAME) $(BASENAME) *~
   24.63 +
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/graphlcd-base/glcddrivers/avrctl.c	Wed Feb 06 17:32:55 2008 +0000
    25.3 @@ -0,0 +1,355 @@
    25.4 +/*
    25.5 + * GraphLCD driver library
    25.6 + *
    25.7 + * avrctl.c  -  AVR controlled LCD driver class
    25.8 + *
    25.9 + * This file is released under the GNU General Public License. Refer
   25.10 + * to the COPYING file distributed with this package.
   25.11 + *
   25.12 + * (c) 2005 Andreas Regel <andreas.regel AT powarman.de>
   25.13 + */
   25.14 +
   25.15 +#include <stdint.h>
   25.16 +#include <syslog.h>
   25.17 +
   25.18 +#include "common.h"
   25.19 +#include "config.h"
   25.20 +#include "port.h"
   25.21 +#include "avrctl.h"
   25.22 +
   25.23 +
   25.24 +namespace GLCD
   25.25 +{
   25.26 +
   25.27 +/* command header:
   25.28 +**  8 bits  sync byte (0xAA for sent commands, 0x55 for received commands)
   25.29 +**  8 bits  command id
   25.30 +** 16 bits  command length (excluding header)
   25.31 +*/
   25.32 +const unsigned char CMD_HDR_SYNC    = 0;
   25.33 +const unsigned char CMD_HDR_COMMAND = 1;
   25.34 +const unsigned char CMD_HDR_LENGTH  = 2;
   25.35 +const unsigned char CMD_DATA_START  = 4;
   25.36 +
   25.37 +const unsigned char CMD_SYNC_SEND = 0xAA;
   25.38 +const unsigned char CMD_SYNC_RECV = 0x55;
   25.39 +
   25.40 +const unsigned char CMD_SYS_SYNC = 0x00;
   25.41 +const unsigned char CMD_SYS_ACK  = 0x01;
   25.42 +
   25.43 +const unsigned char CMD_DISP_CLEAR_SCREEN   = 0x10;
   25.44 +const unsigned char CMD_DISP_SWITCH_SCREEN  = 0x11;
   25.45 +const unsigned char CMD_DISP_SET_BRIGHTNESS = 0x12;
   25.46 +const unsigned char CMD_DISP_SET_COL_DATA   = 0x13;
   25.47 +const unsigned char CMD_DISP_SET_ROW_DATA   = 0x14;
   25.48 +const unsigned char CMD_DISP_UPDATE         = 0x15;
   25.49 +
   25.50 +const int kBufferWidth  = 256;
   25.51 +const int kBufferHeight = 128;
   25.52 +
   25.53 +
   25.54 +cDriverAvrCtl::cDriverAvrCtl(cDriverConfig * config)
   25.55 +:   config(config)
   25.56 +{
   25.57 +    oldConfig = new cDriverConfig(*config);
   25.58 +
   25.59 +    port = new cSerialPort();
   25.60 +
   25.61 +    //width = config->width;
   25.62 +    //height = config->height;
   25.63 +    refreshCounter = 0;
   25.64 +}
   25.65 +
   25.66 +cDriverAvrCtl::~cDriverAvrCtl()
   25.67 +{
   25.68 +    delete port;
   25.69 +    delete oldConfig;
   25.70 +}
   25.71 +
   25.72 +int cDriverAvrCtl::Init()
   25.73 +{
   25.74 +    int x;
   25.75 +
   25.76 +    width = config->width;
   25.77 +    if (width <= 0)
   25.78 +        width = 256;
   25.79 +    height = config->height;
   25.80 +    if (height <= 0)
   25.81 +        height = 128;
   25.82 +
   25.83 +    for (unsigned int i = 0; i < config->options.size(); i++)
   25.84 +    {
   25.85 +        if (config->options[i].name == "")
   25.86 +        {
   25.87 +        }
   25.88 +    }
   25.89 +
   25.90 +    // setup lcd array (wanted state)
   25.91 +    newLCD = new unsigned char*[kBufferWidth];
   25.92 +    if (newLCD)
   25.93 +    {
   25.94 +        for (x = 0; x < kBufferWidth; x++)
   25.95 +        {
   25.96 +            newLCD[x] = new unsigned char[(kBufferHeight + 7) / 8];
   25.97 +            memset(newLCD[x], 0, (kBufferHeight + 7) / 8);
   25.98 +        }
   25.99 +    }
  25.100 +    // setup lcd array (current state)
  25.101 +    oldLCD = new unsigned char*[kBufferWidth];
  25.102 +    if (oldLCD)
  25.103 +    {
  25.104 +        for (x = 0; x < kBufferWidth; x++)
  25.105 +        {
  25.106 +            oldLCD[x] = new unsigned char[(kBufferHeight + 7) / 8];
  25.107 +            memset(oldLCD[x], 0, (kBufferHeight + 7) / 8);
  25.108 +        }
  25.109 +    }
  25.110 +
  25.111 +    if (config->device == "")
  25.112 +    {
  25.113 +        return -1;
  25.114 +    }
  25.115 +    if (port->Open(config->device.c_str()) != 0)
  25.116 +        return -1;
  25.117 +
  25.118 +    *oldConfig = *config;
  25.119 +
  25.120 +    // clear display
  25.121 +    Clear();
  25.122 +
  25.123 +    syslog(LOG_INFO, "%s: AvrCtl initialized.\n", config->name.c_str());
  25.124 +    return 0;
  25.125 +}
  25.126 +
  25.127 +int cDriverAvrCtl::DeInit()
  25.128 +{
  25.129 +    int x;
  25.130 +    // free lcd array (wanted state)
  25.131 +    if (newLCD)
  25.132 +    {
  25.133 +        for (x = 0; x < kBufferWidth; x++)
  25.134 +        {
  25.135 +            delete[] newLCD[x];
  25.136 +        }
  25.137 +        delete[] newLCD;
  25.138 +    }
  25.139 +    // free lcd array (current state)
  25.140 +    if (oldLCD)
  25.141 +    {
  25.142 +        for (x = 0; x < kBufferWidth; x++)
  25.143 +        {
  25.144 +            delete[] oldLCD[x];
  25.145 +        }
  25.146 +        delete[] oldLCD;
  25.147 +    }
  25.148 +
  25.149 +    if (port->Close() != 0)
  25.150 +        return -1;
  25.151 +    return 0;
  25.152 +}
  25.153 +
  25.154 +int cDriverAvrCtl::CheckSetup()
  25.155 +{
  25.156 +    if (config->device != oldConfig->device ||
  25.157 +        config->width != oldConfig->width ||
  25.158 +        config->height != oldConfig->height)
  25.159 +    {
  25.160 +        DeInit();
  25.161 +        Init();
  25.162 +        return 0;
  25.163 +    }
  25.164 +
  25.165 +    if (config->upsideDown != oldConfig->upsideDown ||
  25.166 +        config->invert != oldConfig->invert)
  25.167 +    {
  25.168 +        oldConfig->upsideDown = config->upsideDown;
  25.169 +        oldConfig->invert = config->invert;
  25.170 +        return 1;
  25.171 +    }
  25.172 +    return 0;
  25.173 +}
  25.174 +
  25.175 +void cDriverAvrCtl::Clear()
  25.176 +{
  25.177 +    for (int x = 0; x < kBufferWidth; x++)
  25.178 +        memset(newLCD[x], 0, (kBufferHeight + 7) / 8);
  25.179 +}
  25.180 +
  25.181 +void cDriverAvrCtl::Set8Pixels(int x, int y, unsigned char data)
  25.182 +{
  25.183 +    if (x >= width || y >= height)
  25.184 +        return;
  25.185 +
  25.186 +    if (!config->upsideDown)
  25.187 +    {
  25.188 +        int offset = 7 - (y % 8);
  25.189 +        for (int i = 0; i < 8; i++)
  25.190 +        {
  25.191 +            newLCD[x + i][y / 8] |= ((data >> (7 - i)) << offset) & (1 << offset);
  25.192 +        }
  25.193 +    }
  25.194 +    else
  25.195 +    {
  25.196 +        x = width - 1 - x;
  25.197 +        y = height - 1 - y;
  25.198 +        int offset = 7 - (y % 8);
  25.199 +        for (int i = 0; i < 8; i++)
  25.200 +        {
  25.201 +            newLCD[x - i][y / 8] |= ((data >> (7 - i)) << offset) & (1 << offset);
  25.202 +        }
  25.203 +    }
  25.204 +}
  25.205 +
  25.206 +void cDriverAvrCtl::Refresh(bool refreshAll)
  25.207 +{
  25.208 +    int x;
  25.209 +    int y;
  25.210 +    int i;
  25.211 +    int num = kBufferWidth / 2;
  25.212 +    unsigned char data[16*num];
  25.213 +
  25.214 +    if (CheckSetup() == 1)
  25.215 +        refreshAll = true;
  25.216 +
  25.217 +    if (config->refreshDisplay > 0)
  25.218 +    {
  25.219 +        refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
  25.220 +        if (!refreshAll && !refreshCounter)
  25.221 +            refreshAll = true;
  25.222 +    }
  25.223 +
  25.224 +    refreshAll = true;
  25.225 +    if (refreshAll)
  25.226 +    {
  25.227 +        for (x = 0; x < kBufferWidth; x += num)
  25.228 +        {
  25.229 +            for (i = 0; i < num; i++)
  25.230 +            {
  25.231 +                for (y = 0; y < (kBufferHeight + 7) / 8; y++)
  25.232 +                {
  25.233 +                    data[i * ((kBufferHeight + 7) / 8) + y] = (newLCD[x + i][y]) ^ (config->invert ? 0xff : 0x00);
  25.234 +                }
  25.235 +                memcpy(oldLCD[x + i], newLCD[x + i], (kBufferHeight + 7) / 8);
  25.236 +            }
  25.237 +            CmdDispSetColData(x, 0, 16 * num, data);
  25.238 +        }
  25.239 +        CmdDispUpdate();
  25.240 +        CmdDispSwitchScreen();
  25.241 +        // and reset RefreshCounter
  25.242 +        refreshCounter = 0;
  25.243 +    }
  25.244 +    else
  25.245 +    {
  25.246 +        // draw only the changed bytes
  25.247 +    }
  25.248 +}
  25.249 +
  25.250 +void cDriverAvrCtl::SetBrightness(unsigned int percent)
  25.251 +{
  25.252 +  CmdDispSetBrightness(percent);
  25.253 +}
  25.254 +
  25.255 +int cDriverAvrCtl::WaitForAck(void)
  25.256 +{
  25.257 +    uint8_t cmd[4];
  25.258 +    int len;
  25.259 +    int timeout = 10000;
  25.260 +
  25.261 +    len = 0;
  25.262 +    while (len < 4 && timeout > 0)
  25.263 +    {
  25.264 +        len += port->ReadData(&cmd[len]);
  25.265 +        timeout--;
  25.266 +    }
  25.267 +    if (timeout == 0)
  25.268 +        return 0;
  25.269 +    return 1;
  25.270 +}
  25.271 +
  25.272 +void cDriverAvrCtl::CmdSysSync(void)
  25.273 +{
  25.274 +    uint8_t cmd[4];
  25.275 +
  25.276 +    cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
  25.277 +    cmd[CMD_HDR_COMMAND] = CMD_SYS_SYNC;
  25.278 +    cmd[CMD_HDR_LENGTH] = 0;
  25.279 +    cmd[CMD_HDR_LENGTH+1] = 0;
  25.280 +
  25.281 +    port->WriteData(cmd, 4);
  25.282 +    WaitForAck();
  25.283 +}
  25.284 +
  25.285 +void cDriverAvrCtl::CmdDispClearScreen(void)
  25.286 +{
  25.287 +    uint8_t cmd[4];
  25.288 +
  25.289 +    cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
  25.290 +    cmd[CMD_HDR_COMMAND] = CMD_DISP_CLEAR_SCREEN;
  25.291 +    cmd[CMD_HDR_LENGTH] = 0;
  25.292 +    cmd[CMD_HDR_LENGTH+1] = 0;
  25.293 +
  25.294 +    port->WriteData(cmd, 4);
  25.295 +    WaitForAck();
  25.296 +}
  25.297 +
  25.298 +void cDriverAvrCtl::CmdDispSwitchScreen(void)
  25.299 +{
  25.300 +    uint8_t cmd[4];
  25.301 +
  25.302 +    cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
  25.303 +    cmd[CMD_HDR_COMMAND] = CMD_DISP_SWITCH_SCREEN;
  25.304 +    cmd[CMD_HDR_LENGTH] = 0;
  25.305 +    cmd[CMD_HDR_LENGTH+1] = 0;
  25.306 +
  25.307 +    port->WriteData(cmd, 4);
  25.308 +    WaitForAck();
  25.309 +}
  25.310 +
  25.311 +void cDriverAvrCtl::CmdDispSetBrightness(uint8_t percent)
  25.312 +{
  25.313 +    uint8_t cmd[5];
  25.314 +
  25.315 +    cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
  25.316 +    cmd[CMD_HDR_COMMAND] = CMD_DISP_SET_BRIGHTNESS;
  25.317 +    cmd[CMD_HDR_LENGTH] = 0;
  25.318 +    cmd[CMD_HDR_LENGTH+1] = 1;
  25.319 +    cmd[CMD_DATA_START] = percent;
  25.320 +
  25.321 +    port->WriteData(cmd, 5);
  25.322 +    WaitForAck();
  25.323 +}
  25.324 +
  25.325 +void cDriverAvrCtl::CmdDispSetColData(uint16_t column, uint16_t offset, uint16_t length, uint8_t * data)
  25.326 +{
  25.327 +    uint8_t cmd[2560];
  25.328 +
  25.329 +    cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
  25.330 +    cmd[CMD_HDR_COMMAND] = CMD_DISP_SET_COL_DATA;
  25.331 +    cmd[CMD_HDR_LENGTH] = (length + 6) >> 8;
  25.332 +    cmd[CMD_HDR_LENGTH+1] = (length + 6);
  25.333 +    cmd[CMD_DATA_START] = column >> 8;
  25.334 +    cmd[CMD_DATA_START+1] = column;
  25.335 +    cmd[CMD_DATA_START+2] = offset >> 8;
  25.336 +    cmd[CMD_DATA_START+3] = offset;
  25.337 +    cmd[CMD_DATA_START+4] = length >> 8;
  25.338 +    cmd[CMD_DATA_START+5] = length;
  25.339 +    memcpy(&cmd[CMD_DATA_START+6], data, length);
  25.340 +
  25.341 +    port->WriteData(cmd, length+10);
  25.342 +    WaitForAck();
  25.343 +}
  25.344 +
  25.345 +void cDriverAvrCtl::CmdDispUpdate(void)
  25.346 +{
  25.347 +    uint8_t cmd[4];
  25.348 +
  25.349 +    cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
  25.350 +    cmd[CMD_HDR_COMMAND] = CMD_DISP_UPDATE;
  25.351 +    cmd[CMD_HDR_LENGTH] = 0;
  25.352 +    cmd[CMD_HDR_LENGTH+1] = 0;
  25.353 +
  25.354 +    port->WriteData(cmd, 4);
  25.355 +    WaitForAck();
  25.356 +}
  25.357 +
  25.358 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/graphlcd-base/glcddrivers/avrctl.h	Wed Feb 06 17:32:55 2008 +0000
    26.3 @@ -0,0 +1,58 @@
    26.4 +/*
    26.5 + * GraphLCD driver library
    26.6 + *
    26.7 + * avrctl.h  -  AVR controlled LCD driver class
    26.8 + *
    26.9 + * This file is released under the GNU General Public License. Refer
   26.10 + * to the COPYING file distributed with this package.
   26.11 + *
   26.12 + * (c) 2005 Andreas Regel <andreas.regel AT powarman.de>
   26.13 + */
   26.14 +
   26.15 +#ifndef _GLCDDRIVERS_AVRCTL_H_
   26.16 +#define _GLCDDRIVERS_AVRCTL_H_
   26.17 +
   26.18 +#include "driver.h"
   26.19 +
   26.20 +namespace GLCD
   26.21 +{
   26.22 +
   26.23 +class cDriverConfig;
   26.24 +class cSerialPort;
   26.25 +
   26.26 +class cDriverAvrCtl : public cDriver
   26.27 +{
   26.28 +private:
   26.29 +    cSerialPort * port;
   26.30 +    unsigned char ** newLCD; // wanted state
   26.31 +    unsigned char ** oldLCD; // current state
   26.32 +    cDriverConfig * config;
   26.33 +    cDriverConfig * oldConfig;
   26.34 +    int refreshCounter;
   26.35 +
   26.36 +    int WaitForAck(void);
   26.37 +    void CmdSysSync(void);
   26.38 +    void CmdDispClearScreen(void);
   26.39 +    void CmdDispSwitchScreen(void);
   26.40 +    void CmdDispSetBrightness(unsigned char percent);
   26.41 +    void CmdDispSetColData(uint16_t column, uint16_t offset, uint16_t length, uint8_t * data);
   26.42 +    void CmdDispUpdate(void);
   26.43 +
   26.44 +    int CheckSetup();
   26.45 +
   26.46 +public:
   26.47 +    cDriverAvrCtl(cDriverConfig * config);
   26.48 +    virtual ~cDriverAvrCtl();
   26.49 +
   26.50 +    virtual int Init();
   26.51 +    virtual int DeInit();
   26.52 +
   26.53 +    virtual void Clear();
   26.54 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   26.55 +    virtual void Refresh(bool refreshAll = false);
   26.56 +    virtual void SetBrightness(unsigned int percent);
   26.57 +};
   26.58 +
   26.59 +} // end of namespace
   26.60 +
   26.61 +#endif
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/graphlcd-base/glcddrivers/common.c	Wed Feb 06 17:32:55 2008 +0000
    27.3 @@ -0,0 +1,231 @@
    27.4 +/*
    27.5 + * GraphLCD driver library
    27.6 + *
    27.7 + * common.c  -  various functions
    27.8 + *
    27.9 + * parts were taken from graphlcd plugin for the Video Disc Recorder
   27.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   27.11 + *
   27.12 + * This file is released under the GNU General Public License. Refer
   27.13 + * to the COPYING file distributed with this package.
   27.14 + *
   27.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   27.16 + */
   27.17 +
   27.18 +#include <ctype.h>
   27.19 +#include <sched.h>
   27.20 +#include <time.h>
   27.21 +#include <unistd.h>
   27.22 +#include <sys/time.h>
   27.23 +#include <sys/resource.h>
   27.24 +
   27.25 +#include "common.h"
   27.26 +#include "config.h"
   27.27 +
   27.28 +
   27.29 +namespace GLCD
   27.30 +{
   27.31 +
   27.32 +static const int BitReverseTable[256] =
   27.33 +{
   27.34 +    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
   27.35 +    0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
   27.36 +    0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
   27.37 +    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
   27.38 +    0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
   27.39 +    0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
   27.40 +    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
   27.41 +    0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
   27.42 +    0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
   27.43 +    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
   27.44 +    0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
   27.45 +    0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
   27.46 +    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
   27.47 +    0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
   27.48 +    0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
   27.49 +    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
   27.50 +    0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
   27.51 +    0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
   27.52 +    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
   27.53 +    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
   27.54 +    0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
   27.55 +    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
   27.56 +    0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
   27.57 +    0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
   27.58 +    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
   27.59 +    0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
   27.60 +    0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
   27.61 +    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
   27.62 +    0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
   27.63 +    0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
   27.64 +    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
   27.65 +    0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
   27.66 +};
   27.67 +
   27.68 +int nSleepInit()
   27.69 +{
   27.70 +    int ret = 0;
   27.71 +
   27.72 +    if (Config.waitPriority != 0)
   27.73 +    {
   27.74 +        ret = setpriority(PRIO_PROCESS, 0, Config.waitPriority);
   27.75 +    }
   27.76 +
   27.77 +    if (!ret)
   27.78 +    {
   27.79 +        switch (Config.waitMethod)
   27.80 +        {
   27.81 +            case kWaitUsleep: // usleep
   27.82 +                break;
   27.83 +            case kWaitNanosleep: // nanosleep
   27.84 +                break;
   27.85 +            case kWaitNanosleepRR: // nanosleep (sched_rr)
   27.86 +                // set sched algorithm
   27.87 +                struct sched_param param;
   27.88 +
   27.89 +                param.sched_priority=1;
   27.90 +                ret = sched_setscheduler(0, SCHED_RR, &param);
   27.91 +                break;
   27.92 +            case kWaitGettimeofday: // gettimeofday
   27.93 +                break;
   27.94 +        }
   27.95 +    }
   27.96 +    return ret;
   27.97 +}
   27.98 +
   27.99 +int nSleepDeInit()
  27.100 +{
  27.101 +    int ret = 0;
  27.102 +
  27.103 +    if (Config.waitPriority != 0)
  27.104 +    {
  27.105 +        ret = setpriority(PRIO_PROCESS, 0, 0);
  27.106 +    }
  27.107 +
  27.108 +    if (!ret)
  27.109 +    {
  27.110 +        switch (Config.waitMethod)
  27.111 +        {
  27.112 +            case kWaitUsleep: // usleep
  27.113 +                break;
  27.114 +            case kWaitNanosleep: // nanosleep
  27.115 +                break;
  27.116 +            case kWaitNanosleepRR: // nanosleep (sched_rr)
  27.117 +                // set sched algorithm
  27.118 +                struct sched_param param;
  27.119 +
  27.120 +                param.sched_priority=0;
  27.121 +                ret = sched_setscheduler(0, SCHED_OTHER, &param);
  27.122 +                break;
  27.123 +            case kWaitGettimeofday: // gettimeofday
  27.124 +                break;
  27.125 +        }
  27.126 +    }
  27.127 +    return ret;
  27.128 +}
  27.129 +
  27.130 +void nSleep(long ns)
  27.131 +{
  27.132 +    switch (Config.waitMethod)
  27.133 +    {
  27.134 +        case kWaitUsleep: // usleep
  27.135 +            if (ns > 0)
  27.136 +            {
  27.137 +                usleep(std::max(1L, ns/1000));
  27.138 +            }
  27.139 +            break;
  27.140 +        case kWaitNanosleep: // nanosleep
  27.141 +        case kWaitNanosleepRR: // nanosleep(sched_rr)
  27.142 +            struct timespec delay, remaining;
  27.143 +            if (ns > 0)
  27.144 +            {
  27.145 +                delay.tv_sec = ns/1000000000;
  27.146 +                delay.tv_nsec = ns%1000000000;
  27.147 +                while (nanosleep(&delay, &remaining) == -1)
  27.148 +                {
  27.149 +                    delay.tv_sec  = remaining.tv_sec;
  27.150 +                    delay.tv_nsec = remaining.tv_nsec;
  27.151 +                }
  27.152 +            }
  27.153 +            break;
  27.154 +        case kWaitGettimeofday: //getTimeofday for Kernel 2.6
  27.155 +            long us;
  27.156 +            struct timeval tv1, tv2;
  27.157 +            suseconds_t us2;
  27.158 +            if (ns > 0)
  27.159 +            {
  27.160 +                us = ns / 1000;
  27.161 +                if (us == 0)
  27.162 +                    us = 1;
  27.163 +                gettimeofday(&tv1, 0);
  27.164 +                do
  27.165 +                {
  27.166 +                    gettimeofday(&tv2, 0);
  27.167 +                    us2 = tv2.tv_usec + ((tv2.tv_sec - tv1.tv_sec) * 1000000);
  27.168 +                } while (us2 - tv1.tv_usec < us);
  27.169 +            }
  27.170 +    }
  27.171 +}
  27.172 +
  27.173 +void uSleep(long us)
  27.174 +{
  27.175 +    if (Config.waitMethod == kWaitUsleep)
  27.176 +    {
  27.177 +        // usleep
  27.178 +        if (us > 0)
  27.179 +            usleep(std::max(1L, us));
  27.180 +    }
  27.181 +    else
  27.182 +    {
  27.183 +        nSleep(us * 1000);
  27.184 +    }
  27.185 +}
  27.186 +
  27.187 +
  27.188 +
  27.189 +unsigned char ReverseBits(unsigned char value)
  27.190 +{
  27.191 +    return BitReverseTable[value];
  27.192 +}
  27.193 +
  27.194 +void clip(int & value, int min, int max)
  27.195 +{
  27.196 +    if (value < min)
  27.197 +        value = min;
  27.198 +    if (value > max)
  27.199 +        value = max;
  27.200 +}
  27.201 +
  27.202 +void sort(int & value1, int & value2)
  27.203 +{
  27.204 +    if (value2 < value1)
  27.205 +    {
  27.206 +        int tmp;
  27.207 +        tmp = value2;
  27.208 +        value2 = value1;
  27.209 +        value1 = tmp;
  27.210 +    }
  27.211 +}
  27.212 +
  27.213 +std::string trim(const std::string & s)
  27.214 +{
  27.215 +    std::string::size_type start, end;
  27.216 +
  27.217 +    start = 0;
  27.218 +    while (start < s.length())
  27.219 +    {
  27.220 +        if (!isspace(s[start]))
  27.221 +            break;
  27.222 +        start++;
  27.223 +    }
  27.224 +    end = s.length() - 1;
  27.225 +    while (end >= 0)
  27.226 +    {
  27.227 +        if (!isspace(s[end]))
  27.228 +            break;
  27.229 +        end--;
  27.230 +    }
  27.231 +    return s.substr(start, end - start + 1);
  27.232 +}
  27.233 +
  27.234 +} // end of namespace
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/graphlcd-base/glcddrivers/common.h	Wed Feb 06 17:32:55 2008 +0000
    28.3 @@ -0,0 +1,42 @@
    28.4 +/*
    28.5 + * GraphLCD driver library
    28.6 + *
    28.7 + * common.c  -  various functions
    28.8 + *
    28.9 + * parts were taken from graphlcd plugin for the Video Disc Recorder
   28.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   28.11 + *
   28.12 + * This file is released under the GNU General Public License. Refer
   28.13 + * to the COPYING file distributed with this package.
   28.14 + *
   28.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   28.16 + */
   28.17 +
   28.18 +#ifndef _GLCDDRIVERS_COMMON_H_
   28.19 +#define _GLCDDRIVERS_COMMON_H_
   28.20 +
   28.21 +#include <string>
   28.22 +
   28.23 +namespace GLCD
   28.24 +{
   28.25 +
   28.26 +const unsigned char bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
   28.27 +const unsigned char bitmaskl[8] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
   28.28 +const unsigned char bitmaskr[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
   28.29 +
   28.30 +// functions to enable/disable very short sleeps.
   28.31 +// Therefore, the priority will be changed. => use with care !
   28.32 +int nSleepInit(void);
   28.33 +int nSleepDeInit(void);
   28.34 +
   28.35 +void nSleep(long ns);
   28.36 +void uSleep(long us);
   28.37 +
   28.38 +unsigned char ReverseBits(unsigned char value);
   28.39 +void clip(int & value, int min, int max);
   28.40 +void sort(int & value1, int & value2);
   28.41 +std::string trim(const std::string & s);
   28.42 +
   28.43 +} // end of namespace
   28.44 +
   28.45 +#endif
    29.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    29.2 +++ b/graphlcd-base/glcddrivers/config.c	Wed Feb 06 17:32:55 2008 +0000
    29.3 @@ -0,0 +1,286 @@
    29.4 +/*
    29.5 + * GraphLCD driver library
    29.6 + *
    29.7 + * config.c  -  config file classes
    29.8 + *
    29.9 + * This file is released under the GNU General Public License. Refer
   29.10 + * to the COPYING file distributed with this package.
   29.11 + *
   29.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   29.13 + */
   29.14 +
   29.15 +#include <syslog.h>
   29.16 +#include <fstream>
   29.17 +
   29.18 +#include "common.h"
   29.19 +#include "config.h"
   29.20 +#include "drivers.h"
   29.21 +
   29.22 +
   29.23 +namespace GLCD
   29.24 +{
   29.25 +
   29.26 +cDriverConfig::cDriverConfig()
   29.27 +:   name(""),
   29.28 +    driver(""),
   29.29 +    id(kDriverUnknown),
   29.30 +    device(""),
   29.31 +    port(0),
   29.32 +    width(0),
   29.33 +    height(0),
   29.34 +    upsideDown(false),
   29.35 +    invert(false),
   29.36 +    brightness(100),
   29.37 +    contrast(5),
   29.38 +    backlight(true),
   29.39 +    adjustTiming(0),
   29.40 +    refreshDisplay(5)
   29.41 +{
   29.42 +}
   29.43 +
   29.44 +cDriverConfig::cDriverConfig(const cDriverConfig & rhs)
   29.45 +{
   29.46 +    name = rhs.name;
   29.47 +    driver = rhs.driver;
   29.48 +    id = rhs.id;
   29.49 +    device = rhs.device;
   29.50 +    port = rhs.port;
   29.51 +    width = rhs.width;
   29.52 +    height = rhs.height;
   29.53 +    upsideDown = rhs.upsideDown;
   29.54 +    invert = rhs.invert;
   29.55 +    brightness = rhs.brightness;
   29.56 +    contrast = rhs.contrast;
   29.57 +    backlight = rhs.backlight;
   29.58 +    adjustTiming = rhs.adjustTiming;
   29.59 +    refreshDisplay = rhs.refreshDisplay;
   29.60 +    for (unsigned int i = 0; i < rhs.options.size(); i++)
   29.61 +        options.push_back(rhs.options[i]);
   29.62 +}
   29.63 +
   29.64 +cDriverConfig::~cDriverConfig()
   29.65 +{
   29.66 +}
   29.67 +
   29.68 +cDriverConfig & cDriverConfig::operator=(const cDriverConfig & rhs)
   29.69 +{
   29.70 +    if (this == &rhs)
   29.71 +        return *this;
   29.72 +
   29.73 +    name = rhs.name;
   29.74 +    driver = rhs.driver;
   29.75 +    id = rhs.id;
   29.76 +    device = rhs.device;
   29.77 +    port = rhs.port;
   29.78 +    width = rhs.width;
   29.79 +    height = rhs.height;
   29.80 +    upsideDown = rhs.upsideDown;
   29.81 +    invert = rhs.invert;
   29.82 +    brightness = rhs.brightness;
   29.83 +    contrast = rhs.contrast;
   29.84 +    backlight = rhs.backlight;
   29.85 +    adjustTiming = rhs.adjustTiming;
   29.86 +    refreshDisplay = rhs.refreshDisplay;
   29.87 +    options.clear();
   29.88 +    for (unsigned int i = 0; i < rhs.options.size(); i++)
   29.89 +        options.push_back(rhs.options[i]);
   29.90 +
   29.91 +    return *this;
   29.92 +}
   29.93 +
   29.94 +bool cDriverConfig::Parse(const std::string & line)
   29.95 +{
   29.96 +    std::string::size_type pos;
   29.97 +    tOption option;
   29.98 +
   29.99 +    pos = line.find("=");
  29.100 +    if (pos == std::string::npos)
  29.101 +        return false;
  29.102 +    option.name = trim(line.substr(0, pos));
  29.103 +    option.value = trim(line.substr(pos + 1));
  29.104 +    //printf("D %s = %s\n", option.name.c_str(), option.value.c_str());
  29.105 +
  29.106 +    if (option.name == "Driver")
  29.107 +    {
  29.108 +        int driverCount;
  29.109 +        tDriver * drivers = GetAvailableDrivers(driverCount);
  29.110 +        for (int i = 0; i < driverCount; i++)
  29.111 +        {
  29.112 +            if (option.value == drivers[i].name)
  29.113 +            {
  29.114 +                driver = drivers[i].name;
  29.115 +                id = drivers[i].id;
  29.116 +                break;
  29.117 +            }
  29.118 +        }
  29.119 +    }
  29.120 +    else if (option.name == "Device")
  29.121 +    {
  29.122 +        device = option.value;
  29.123 +    }
  29.124 +    else if (option.name == "Port")
  29.125 +    {
  29.126 +        port = GetInt(option.value);
  29.127 +    }
  29.128 +    else if (option.name == "Width")
  29.129 +    {
  29.130 +        width = GetInt(option.value);
  29.131 +    }
  29.132 +    else if (option.name == "Height")
  29.133 +    {
  29.134 +        height = GetInt(option.value);
  29.135 +    }
  29.136 +    else if (option.name == "UpsideDown")
  29.137 +    {
  29.138 +        upsideDown = GetBool(option.value);
  29.139 +    }
  29.140 +    else if (option.name == "Invert")
  29.141 +    {
  29.142 +        invert = GetBool(option.value);
  29.143 +    }
  29.144 +    else if (option.name == "Brightness")
  29.145 +    {
  29.146 +        brightness = GetInt(option.value);
  29.147 +    }
  29.148 +    else if (option.name == "Contrast")
  29.149 +    {
  29.150 +        contrast = GetInt(option.value);
  29.151 +    }
  29.152 +    else if (option.name == "Backlight")
  29.153 +    {
  29.154 +        backlight = GetBool(option.value);
  29.155 +    }
  29.156 +    else if (option.name == "AdjustTiming")
  29.157 +    {
  29.158 +        adjustTiming = GetInt(option.value);
  29.159 +    }
  29.160 +    else if (option.name == "RefreshDisplay")
  29.161 +    {
  29.162 +        refreshDisplay = GetInt(option.value);
  29.163 +    }
  29.164 +    else
  29.165 +    {
  29.166 +        options.push_back(option);
  29.167 +    }
  29.168 +    return true;
  29.169 +}
  29.170 +
  29.171 +int cDriverConfig::GetInt(const std::string & value)
  29.172 +{
  29.173 +    return strtol(value.c_str(), NULL, 0);
  29.174 +}
  29.175 +
  29.176 +bool cDriverConfig::GetBool(const std::string & value)
  29.177 +{
  29.178 +    return value == "yes";
  29.179 +}
  29.180 +
  29.181 +
  29.182 +cConfig::cConfig()
  29.183 +:   waitMethod(kWaitGettimeofday),
  29.184 +    waitPriority(0)
  29.185 +{
  29.186 +}
  29.187 +
  29.188 +cConfig::~cConfig()
  29.189 +{
  29.190 +}
  29.191 +
  29.192 +bool cConfig::Load(const std::string & filename)
  29.193 +{
  29.194 +    std::fstream file;
  29.195 +    char readLine[1000];
  29.196 +    std::string line;
  29.197 +    bool inSections = false;
  29.198 +    int section = 0;
  29.199 +
  29.200 +#if (__GNUC__ < 3)
  29.201 +    file.open(filename.c_str(), std::ios::in);
  29.202 +#else
  29.203 +    file.open(filename.c_str(), std::ios_base::in);
  29.204 +#endif
  29.205 +    if (!file.is_open())
  29.206 +        return false;
  29.207 +
  29.208 +    while (!file.eof())
  29.209 +    {
  29.210 +        file.getline(readLine, 1000);
  29.211 +        line = trim(readLine);
  29.212 +        if (line.length() == 0)
  29.213 +            continue;
  29.214 +        if (line[0] == '#')
  29.215 +            continue;
  29.216 +        if (line[0] == '[' && line[line.length() - 1] == ']')
  29.217 +        {
  29.218 +            if (!inSections)
  29.219 +                inSections = true;
  29.220 +            else
  29.221 +                section++;
  29.222 +            driverConfigs.resize(section + 1);
  29.223 +            driverConfigs[section].name = line.substr(1, line.length() - 2);
  29.224 +            continue;
  29.225 +        }
  29.226 +        if (!inSections)
  29.227 +        {
  29.228 +            Parse(line);
  29.229 +        }
  29.230 +        else
  29.231 +        {
  29.232 +            driverConfigs[section].Parse(line);
  29.233 +        }
  29.234 +    }
  29.235 +
  29.236 +    file.close();
  29.237 +    return true;
  29.238 +}
  29.239 +
  29.240 +bool cConfig::Parse(const std::string & line)
  29.241 +{
  29.242 +    std::string::size_type pos;
  29.243 +    tOption option;
  29.244 +
  29.245 +    pos = line.find("=");
  29.246 +    if (pos == std::string::npos)
  29.247 +        return false;
  29.248 +    option.name = trim(line.substr(0, pos));
  29.249 +    option.value = trim(line.substr(pos + 1));
  29.250 +    //printf("%s = %s\n", option.name.c_str(), option.value.c_str());
  29.251 +
  29.252 +    if (option.name == "WaitMethod")
  29.253 +    {
  29.254 +        waitMethod = GetInt(option.value);
  29.255 +    }
  29.256 +    else if (option.name == "WaitPriority")
  29.257 +    {
  29.258 +        waitPriority = GetInt(option.value);
  29.259 +    }
  29.260 +    else
  29.261 +    {
  29.262 +        syslog(LOG_ERR, "Config error: unknown option %s given!\n", option.value.c_str());
  29.263 +        return false;
  29.264 +    }
  29.265 +    return true;
  29.266 +}
  29.267 +
  29.268 +int cConfig::GetInt(const std::string & value)
  29.269 +{
  29.270 +    return strtol(value.c_str(), NULL, 0);
  29.271 +}
  29.272 +
  29.273 +bool cConfig::GetBool(const std::string & value)
  29.274 +{
  29.275 +    return value == "yes";
  29.276 +}
  29.277 +
  29.278 +int cConfig::GetConfigIndex(const std::string & name)
  29.279 +{
  29.280 +    for (int i = 0; i < (int)driverConfigs.size(); i++)
  29.281 +        if (driverConfigs[i].name == name)
  29.282 +            return i;
  29.283 +    syslog(LOG_ERR, "Config error: configuration %s not found!\n", name.c_str());
  29.284 +    return -1;
  29.285 +}
  29.286 +
  29.287 +cConfig Config;
  29.288 +
  29.289 +} // end of namespace
    30.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    30.2 +++ b/graphlcd-base/glcddrivers/config.h	Wed Feb 06 17:32:55 2008 +0000
    30.3 @@ -0,0 +1,85 @@
    30.4 +/*
    30.5 + * GraphLCD driver library
    30.6 + *
    30.7 + * config.h  -  config file classes
    30.8 + *
    30.9 + * This file is released under the GNU General Public License. Refer
   30.10 + * to the COPYING file distributed with this package.
   30.11 + *
   30.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   30.13 + */
   30.14 +
   30.15 +#ifndef _GLCDDRIVERS_CONFIG_H_
   30.16 +#define _GLCDDRIVERS_CONFIG_H_
   30.17 +
   30.18 +#include <string>
   30.19 +#include <vector>
   30.20 +
   30.21 +
   30.22 +namespace GLCD
   30.23 +{
   30.24 +
   30.25 +const int kWaitUsleep       = 0;
   30.26 +const int kWaitNanosleep    = 1;
   30.27 +const int kWaitNanosleepRR  = 2;
   30.28 +const int kWaitGettimeofday = 3;
   30.29 +
   30.30 +
   30.31 +struct tOption
   30.32 +{
   30.33 +    std::string name;
   30.34 +    std::string value;
   30.35 +};
   30.36 +
   30.37 +class cDriverConfig
   30.38 +{
   30.39 +public:
   30.40 +    std::string name;
   30.41 +    std::string driver;
   30.42 +    int id;
   30.43 +    std::string device;
   30.44 +    int port;
   30.45 +    int width;
   30.46 +    int height;
   30.47 +    bool upsideDown;
   30.48 +    bool invert;
   30.49 +    int brightness;
   30.50 +    int contrast;
   30.51 +    bool backlight;
   30.52 +    int adjustTiming;
   30.53 +    int refreshDisplay;
   30.54 +    std::vector <tOption> options;
   30.55 +
   30.56 +public:
   30.57 +    cDriverConfig();
   30.58 +    cDriverConfig(const cDriverConfig & rhs);
   30.59 +    ~cDriverConfig();
   30.60 +    cDriverConfig & operator=(const cDriverConfig & rhs);
   30.61 +    bool Parse(const std::string & line);
   30.62 +    int GetInt(const std::string & value);
   30.63 +    bool GetBool(const std::string & value);
   30.64 +};
   30.65 +
   30.66 +class cConfig
   30.67 +{
   30.68 +public:
   30.69 +    int waitMethod;
   30.70 +    int waitPriority;
   30.71 +    std::vector <cDriverConfig> driverConfigs;
   30.72 +
   30.73 +public:
   30.74 +    cConfig();
   30.75 +    ~cConfig();
   30.76 +    bool Load(const std::string & filename);
   30.77 +    bool Save(const std::string & filename);
   30.78 +    bool Parse(const std::string & line);
   30.79 +    int GetInt(const std::string & value);
   30.80 +    bool GetBool(const std::string & value);
   30.81 +    int GetConfigIndex(const std::string & name);
   30.82 +};
   30.83 +
   30.84 +extern cConfig Config;
   30.85 +
   30.86 +} // end of namespace
   30.87 +
   30.88 +#endif
    31.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    31.2 +++ b/graphlcd-base/glcddrivers/driver.c	Wed Feb 06 17:32:55 2008 +0000
    31.3 @@ -0,0 +1,54 @@
    31.4 +/*
    31.5 + * GraphLCD driver library
    31.6 + *
    31.7 + * driver.c  -  driver base class
    31.8 + *
    31.9 + * parts were taken from graphlcd plugin for the Video Disc Recorder
   31.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   31.11 + *
   31.12 + * This file is released under the GNU General Public License. Refer
   31.13 + * to the COPYING file distributed with this package.
   31.14 + *
   31.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   31.16 + */
   31.17 +
   31.18 +#include "common.h"
   31.19 +#include "driver.h"
   31.20 +
   31.21 +
   31.22 +namespace GLCD
   31.23 +{
   31.24 +
   31.25 +cDriver::cDriver()
   31.26 +:   width(0),
   31.27 +    height(0)
   31.28 +{
   31.29 +}
   31.30 +
   31.31 +void cDriver::SetScreen(const unsigned char * data, int wid, int hgt, int lineSize)
   31.32 +{
   31.33 +    int x, y;
   31.34 +
   31.35 +    if (wid > width)
   31.36 +        wid = width;
   31.37 +    if (hgt > height)
   31.38 +        hgt = height;
   31.39 +
   31.40 +    Clear();
   31.41 +    if (data)
   31.42 +    {
   31.43 +        for (y = 0; y < hgt; y++)
   31.44 +        {
   31.45 +            for (x = 0; x < (wid / 8); x++)
   31.46 +            {
   31.47 +                Set8Pixels(x * 8, y, data[y * lineSize + x]);
   31.48 +            }
   31.49 +            if (width % 8)
   31.50 +            {
   31.51 +                Set8Pixels((wid / 8) * 8, y, data[y * lineSize + wid / 8] & bitmaskl[wid % 8 - 1]);
   31.52 +            }
   31.53 +        }
   31.54 +    }
   31.55 +}
   31.56 +
   31.57 +} // end of namespace
    32.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    32.2 +++ b/graphlcd-base/glcddrivers/driver.h	Wed Feb 06 17:32:55 2008 +0000
    32.3 @@ -0,0 +1,48 @@
    32.4 +/*
    32.5 + * GraphLCD driver library
    32.6 + *
    32.7 + * driver.h  -  driver base class
    32.8 + *
    32.9 + * parts were taken from graphlcd plugin for the Video Disc Recorder
   32.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   32.11 + *
   32.12 + * This file is released under the GNU General Public License. Refer
   32.13 + * to the COPYING file distributed with this package.
   32.14 + *
   32.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   32.16 + */
   32.17 +
   32.18 +#ifndef _GLCDDRIVERS_DRIVER_H_
   32.19 +#define _GLCDDRIVERS_DRIVER_H_
   32.20 +
   32.21 +#include <stdint.h>
   32.22 +
   32.23 +namespace GLCD
   32.24 +{
   32.25 +
   32.26 +class cDriver
   32.27 +{
   32.28 +protected:
   32.29 +    int width;
   32.30 +    int height;
   32.31 +public:
   32.32 +    cDriver();
   32.33 +    virtual ~cDriver() {}
   32.34 +
   32.35 +    int Width() const { return width; }
   32.36 +    int Height() const { return height; }
   32.37 +
   32.38 +    virtual int Init() { return 0; }
   32.39 +    virtual int DeInit() { return 0; }
   32.40 +
   32.41 +    virtual void Clear() {}
   32.42 +    virtual void Set8Pixels(int x, int y, unsigned char data) {}
   32.43 +    virtual void SetScreen(const unsigned char * data, int width, int height, int lineSize);
   32.44 +    virtual void Refresh(bool refreshAll = false) {}
   32.45 +
   32.46 +    virtual void SetBrightness(unsigned int percent) {}
   32.47 +};
   32.48 +
   32.49 +} // end of namespace
   32.50 +
   32.51 +#endif
    33.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    33.2 +++ b/graphlcd-base/glcddrivers/drivers.c	Wed Feb 06 17:32:55 2008 +0000
    33.3 @@ -0,0 +1,117 @@
    33.4 +/*
    33.5 + * GraphLCD driver library
    33.6 + *
    33.7 + * drivers.c  -  global driver constants and functions
    33.8 + *
    33.9 + * This file is released under the GNU General Public License. Refer
   33.10 + * to the COPYING file distributed with this package.
   33.11 + *
   33.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   33.13 + */
   33.14 +
   33.15 +#include <string.h>
   33.16 +
   33.17 +#include "drivers.h"
   33.18 +#include "simlcd.h"
   33.19 +#include "gu140x32f.h"
   33.20 +#include "gu256x64-372.h"
   33.21 +#include "gu256x64-3900.h"
   33.22 +#include "hd61830.h"
   33.23 +#include "ks0108.h"
   33.24 +#include "sed1330.h"
   33.25 +#include "sed1520.h"
   33.26 +#include "t6963c.h"
   33.27 +#include "framebuffer.h"
   33.28 +#include "image.h"
   33.29 +#include "noritake800.h"
   33.30 +#include "avrctl.h"
   33.31 +#include "network.h"
   33.32 +#include "gu126x64D-K610A4.h"
   33.33 +#include "serdisp.h"
   33.34 +#include "g15daemon.h"
   33.35 +
   33.36 +namespace GLCD
   33.37 +{
   33.38 +
   33.39 +tDriver drivers[] =
   33.40 +{
   33.41 +    {"simlcd",        kDriverSimLCD},
   33.42 +    {"gu140x32f",     kDriverGU140X32F},
   33.43 +    {"gu256x64-372",  kDriverGU256X64_372},
   33.44 +    {"gu256x64-3900", kDriverGU256X64_3900},
   33.45 +    {"hd61830",       kDriverHD61830},
   33.46 +    {"ks0108",        kDriverKS0108},
   33.47 +    {"sed1330",       kDriverSED1330},
   33.48 +    {"sed1520",       kDriverSED1520},
   33.49 +    {"t6963c",        kDriverT6963C},
   33.50 +    {"framebuffer",   kDriverFramebuffer},
   33.51 +    {"image",         kDriverImage},
   33.52 +    {"noritake800",   kDriverNoritake800},
   33.53 +    {"avrctl",        kDriverAvrCtl},
   33.54 +    {"network",       kDriverNetwork},
   33.55 +    {"gu126x64D-K610A4", kDriverGU126X64D_K610A4},
   33.56 +    {"serdisp",       kDriverSerDisp},
   33.57 +    {"g15daemon",     kDriverG15daemon},
   33.58 +    {"",              kDriverUnknown}
   33.59 +};
   33.60 +
   33.61 +tDriver * GetAvailableDrivers(int & count)
   33.62 +{
   33.63 +    for (count = 0; drivers[count].name.length() > 0; count++)
   33.64 +        ;
   33.65 +    return drivers;
   33.66 +}
   33.67 +
   33.68 +int GetDriverID(const std::string & driver)
   33.69 +{
   33.70 +    for (int i = 0; drivers[i].name.length() > 0; i++)
   33.71 +        if (drivers[i].name == driver)
   33.72 +            return drivers[i].id;
   33.73 +    return kDriverUnknown;
   33.74 +}
   33.75 +
   33.76 +cDriver * CreateDriver(int driverID, cDriverConfig * config)
   33.77 +{
   33.78 +    switch (driverID)
   33.79 +    {
   33.80 +        case kDriverSimLCD:
   33.81 +            return new cDriverSimLCD(config);
   33.82 +        case kDriverGU140X32F:
   33.83 +            return new cDriverGU140X32F(config);
   33.84 +        case kDriverGU256X64_372:
   33.85 +            return new cDriverGU256X64_372(config);
   33.86 +        case kDriverGU256X64_3900:
   33.87 +            return new cDriverGU256X64_3900(config);
   33.88 +        case kDriverHD61830:
   33.89 +            return new cDriverHD61830(config);
   33.90 +        case kDriverKS0108:
   33.91 +            return new cDriverKS0108(config);
   33.92 +        case kDriverSED1330:
   33.93 +            return new cDriverSED1330(config);
   33.94 +        case kDriverSED1520:
   33.95 +            return new cDriverSED1520(config);
   33.96 +        case kDriverT6963C:
   33.97 +            return new cDriverT6963C(config);
   33.98 +        case kDriverFramebuffer:
   33.99 +            return new cDriverFramebuffer(config);
  33.100 +        case kDriverImage:
  33.101 +            return new cDriverImage(config);
  33.102 +        case kDriverNoritake800:
  33.103 +            return new cDriverNoritake800(config);
  33.104 +        case kDriverAvrCtl:
  33.105 +            return new cDriverAvrCtl(config);
  33.106 +        case kDriverNetwork:
  33.107 +            return new cDriverNetwork(config);
  33.108 +        case kDriverGU126X64D_K610A4:
  33.109 +            return new cDriverGU126X64D_K610A4(config);
  33.110 +        case kDriverSerDisp:
  33.111 +            return new cDriverSerDisp(config);
  33.112 +        case kDriverG15daemon:
  33.113 +            return new cDriverG15daemon(config);
  33.114 +        case kDriverUnknown:
  33.115 +        default:
  33.116 +            return NULL;
  33.117 +    }
  33.118 +}
  33.119 +
  33.120 +} // end of namespace
    34.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    34.2 +++ b/graphlcd-base/glcddrivers/drivers.h	Wed Feb 06 17:32:55 2008 +0000
    34.3 @@ -0,0 +1,58 @@
    34.4 +/*
    34.5 + * GraphLCD driver library
    34.6 + *
    34.7 + * drivers.h  -  global driver constants and functions
    34.8 + *
    34.9 + * This file is released under the GNU General Public License. Refer
   34.10 + * to the COPYING file distributed with this package.
   34.11 + *
   34.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   34.13 + */
   34.14 +
   34.15 +#ifndef _GLCDDRIVERS_DRIVERS_H_
   34.16 +#define _GLCDDRIVERS_DRIVERS_H_
   34.17 +
   34.18 +#include <string>
   34.19 +
   34.20 +
   34.21 +namespace GLCD
   34.22 +{
   34.23 +
   34.24 +class cDriverConfig;
   34.25 +class cDriver;
   34.26 +
   34.27 +enum eDriver
   34.28 +{
   34.29 +    kDriverUnknown       = 0,
   34.30 +    kDriverSimLCD        = 1,
   34.31 +    kDriverGU140X32F     = 2,
   34.32 +    kDriverGU256X64_372  = 3,
   34.33 +    kDriverGU256X64_3900 = 4,
   34.34 +    kDriverHD61830       = 5,
   34.35 +    kDriverKS0108        = 6,
   34.36 +    kDriverSED1330       = 7,
   34.37 +    kDriverSED1520       = 8,
   34.38 +    kDriverT6963C        = 9,
   34.39 +    kDriverFramebuffer   = 10,
   34.40 +    kDriverImage         = 11,
   34.41 +    kDriverNoritake800   = 12,
   34.42 +    kDriverAvrCtl        = 13,
   34.43 +    kDriverNetwork       = 14,
   34.44 +    kDriverGU126X64D_K610A4 = 15,
   34.45 +    kDriverSerDisp       = 100,
   34.46 +    kDriverG15daemon     = 200
   34.47 +};
   34.48 +
   34.49 +struct tDriver
   34.50 +{
   34.51 +    std::string name;
   34.52 +    eDriver id;
   34.53 +};
   34.54 +
   34.55 +tDriver * GetAvailableDrivers(int & count);
   34.56 +int GetDriverID(const std::string & driver);
   34.57 +cDriver * CreateDriver(int driverID, cDriverConfig * config);
   34.58 +
   34.59 +} // end of namespace
   34.60 +
   34.61 +#endif
    35.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    35.2 +++ b/graphlcd-base/glcddrivers/framebuffer.c	Wed Feb 06 17:32:55 2008 +0000
    35.3 @@ -0,0 +1,249 @@
    35.4 +/*
    35.5 + * GraphLCD driver library
    35.6 + *
    35.7 + * framebuffer.h  -  framebuffer device
    35.8 + *                   Output goes to a framebuffer device
    35.9 + *
   35.10 + * This file is released under the GNU General Public License. Refer
   35.11 + * to the COPYING file distributed with this package.
   35.12 + *
   35.13 + * (c) 2004 Stephan Skrodzki
   35.14 + */
   35.15 +
   35.16 +#include <fcntl.h>
   35.17 +#include <stdio.h>
   35.18 +#include <syslog.h>
   35.19 +#include <unistd.h>
   35.20 +#include <sys/mman.h>
   35.21 +#include <sys/ioctl.h>
   35.22 +
   35.23 +#include "common.h"
   35.24 +#include "config.h"
   35.25 +#include "framebuffer.h"
   35.26 +
   35.27 +
   35.28 +namespace GLCD
   35.29 +{
   35.30 +
   35.31 +cDriverFramebuffer::cDriverFramebuffer(cDriverConfig * config)
   35.32 +:   config(config),
   35.33 +    offbuff(0),
   35.34 +    fbfd(-1)
   35.35 +{
   35.36 +    oldConfig = new cDriverConfig(*config);
   35.37 +}
   35.38 +
   35.39 +cDriverFramebuffer::~cDriverFramebuffer()
   35.40 +{
   35.41 +    delete oldConfig;
   35.42 +}
   35.43 +
   35.44 +int cDriverFramebuffer::Init()
   35.45 +{
   35.46 +    // default values
   35.47 +    width = config->width;
   35.48 +    if (width <= 0)
   35.49 +        width = 320;
   35.50 +    height = config->height;
   35.51 +    if (height <= 0)
   35.52 +        height = 240;
   35.53 +    zoom = 1;
   35.54 +
   35.55 +    for (unsigned int i = 0; i < config->options.size(); i++)
   35.56 +    {
   35.57 +        if (config->options[i].name == "Zoom")
   35.58 +        {
   35.59 +            int z = atoi(config->options[i].value.c_str());
   35.60 +            if (z == 0 || z == 1)
   35.61 +                zoom = z;
   35.62 +            else
   35.63 +                syslog(LOG_ERR, "%s error: zoom %d not supported, using default (%d)!\n",
   35.64 +                       config->name.c_str(), z, zoom);
   35.65 +        }
   35.66 +    }
   35.67 +
   35.68 +    // Open the file for reading and writing
   35.69 +    fbfd = open("/dev/fb0", O_RDWR);
   35.70 +    if (1 == fbfd)
   35.71 +    {
   35.72 +        syslog(LOG_ERR, "%s: cannot open framebuffer device.\n", config->name.c_str());
   35.73 +        return -1;
   35.74 +    }
   35.75 +    syslog(LOG_INFO, "%s: The framebuffer device was opened successfully.\n", config->name.c_str());
   35.76 +
   35.77 +    // Get fixed screen information
   35.78 +    if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo))
   35.79 +    {
   35.80 +        syslog(LOG_ERR, "%s: Error reading fixed information.\n", config->name.c_str());
   35.81 +        return -1;
   35.82 +    }
   35.83 +
   35.84 +    // Get variable screen information
   35.85 +    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo))
   35.86 +    {
   35.87 +        syslog(LOG_ERR, "%s: Error reading variable information.\n", config->name.c_str());
   35.88 +        return -1;
   35.89 +    }
   35.90 +
   35.91 +    // Figure out the size of the screen in bytes
   35.92 +    screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8;
   35.93 +
   35.94 +    syslog(LOG_INFO, "%s: V01: xres: %d, yres %d, vyres: %d, bpp: %d, linelenght: %d\n", config->name.c_str(),vinfo.xres,vinfo.yres,vinfo.yres_virtual,vinfo.bits_per_pixel,finfo.line_length);
   35.95 +
   35.96 +    // reserve another memory to draw into
   35.97 +    offbuff = new char[screensize];
   35.98 +    if (!offbuff)
   35.99 +    {
  35.100 +        syslog(LOG_ERR, "%s: failed to alloc memory for framebuffer device.\n", config->name.c_str());
  35.101 +        return -1;
  35.102 +    }
  35.103 +
  35.104 +    // Map the device to memory
  35.105 +    fbp = mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0);
  35.106 +    if (fbp == MAP_FAILED)
  35.107 +    {
  35.108 +        syslog(LOG_ERR, "%s: failed to map framebuffer device to memory.\n", config->name.c_str());
  35.109 +        return -1;
  35.110 +    }
  35.111 +    syslog(LOG_INFO, "%s: The framebuffer device was mapped to memory successfully.\n", config->name.c_str());
  35.112 +
  35.113 +    *oldConfig = *config;
  35.114 +
  35.115 +    // clear display
  35.116 +    Refresh(true);
  35.117 +
  35.118 +    syslog(LOG_INFO, "%s: Framebuffer initialized.\n", config->name.c_str());
  35.119 +    return 0;
  35.120 +}
  35.121 +
  35.122 +int cDriverFramebuffer::DeInit()
  35.123 +{
  35.124 +    if (offbuff)
  35.125 +        delete[] offbuff;
  35.126 +    munmap(fbp, screensize);
  35.127 +    if (-1 != fbfd)
  35.128 +        close(fbfd);
  35.129 +    return 0;
  35.130 +}
  35.131 +
  35.132 +int cDriverFramebuffer::CheckSetup()
  35.133 +{
  35.134 +    if (config->device != oldConfig->device ||
  35.135 +        config->port != oldConfig->port ||
  35.136 +        config->width != oldConfig->width ||
  35.137 +        config->height != oldConfig->height)
  35.138 +    {
  35.139 +        DeInit();
  35.140 +        Init();
  35.141 +        return 0;
  35.142 +    }
  35.143 +
  35.144 +    if (config->upsideDown != oldConfig->upsideDown ||
  35.145 +        config->invert != oldConfig->invert)
  35.146 +    {
  35.147 +        oldConfig->upsideDown = config->upsideDown;
  35.148 +        oldConfig->invert = config->invert;
  35.149 +        return 1;
  35.150 +    }
  35.151 +    return 0;
  35.152 +}
  35.153 +
  35.154 +void cDriverFramebuffer::SetPixel(int x, int y)
  35.155 +{
  35.156 +    int location;
  35.157 +    int outcol;
  35.158 +
  35.159 +    if (x >= width || y >= height)
  35.160 +        return;
  35.161 +
  35.162 +    if (config->upsideDown)
  35.163 +    {
  35.164 +        x = width - 1 - x;
  35.165 +        y = height - 1 - y;
  35.166 +    }
  35.167 +
  35.168 +    // Figure out where in memory to put the pixel
  35.169 +    location = (x*(1+zoom)+vinfo.xoffset) * (vinfo.bits_per_pixel/8) +
  35.170 +               (y*(1+zoom)+vinfo.yoffset) * finfo.line_length;
  35.171 +
  35.172 +    if (vinfo.bits_per_pixel <= 8)
  35.173 +    {
  35.174 +        outcol = 15;
  35.175 +    }
  35.176 +    else
  35.177 +    {
  35.178 +        outcol = 255;
  35.179 +    }
  35.180 +
  35.181 +    if (vinfo.bits_per_pixel <= 8)
  35.182 +    {
  35.183 +        *(offbuff + location) = outcol;
  35.184 +        if (zoom == 1)
  35.185 +        {
  35.186 +            *(offbuff + location + 1) = outcol;
  35.187 +            *(offbuff + location + finfo.line_length) = outcol;
  35.188 +            *(offbuff + location + finfo.line_length + 1) = outcol;
  35.189 +        }
  35.190 +    }
  35.191 +    else if (vinfo.bits_per_pixel <= 16)
  35.192 +    {
  35.193 +        *(offbuff + location) = outcol;
  35.194 +        *(offbuff + location + 1) = outcol;
  35.195 +        if (zoom == 1)
  35.196 +        {
  35.197 +            *(offbuff + location + 2) = outcol;
  35.198 +            *(offbuff + location + 3) = outcol;
  35.199 +            *(offbuff + location + finfo.line_length) = outcol;
  35.200 +            *(offbuff + location + finfo.line_length + 1) = outcol;
  35.201 +            *(offbuff + location + finfo.line_length + 2) = outcol;
  35.202 +            *(offbuff + location + finfo.line_length + 3) = outcol;
  35.203 +        }
  35.204 +    }
  35.205 +    else
  35.206 +    {
  35.207 +        *(offbuff + location) = outcol;
  35.208 +        *(offbuff + location + 1) = outcol;
  35.209 +        *(offbuff + location + 2) = outcol;
  35.210 +        *(offbuff + location + 3) = 0;     /* should be transparency */
  35.211 +        if (zoom == 1)
  35.212 +        {
  35.213 +            *(offbuff + location + 4) = outcol;
  35.214 +            *(offbuff + location + 5) = outcol;
  35.215 +            *(offbuff + location + 6) = outcol;
  35.216 +            *(offbuff + location + 7) = 0;
  35.217 +            *(offbuff + location + finfo.line_length) = outcol;
  35.218 +            *(offbuff + location + finfo.line_length + 1) = outcol;
  35.219 +            *(offbuff + location + finfo.line_length + 2) = outcol;
  35.220 +            *(offbuff + location + finfo.line_length + 3) = 0;
  35.221 +            *(offbuff + location + finfo.line_length + 4) = outcol;
  35.222 +            *(offbuff + location + finfo.line_length + 5) = outcol;
  35.223 +            *(offbuff + location + finfo.line_length + 6) = outcol;
  35.224 +            *(offbuff + location + finfo.line_length + 7) = 0;
  35.225 +        }
  35.226 +    }
  35.227 +}
  35.228 +
  35.229 +void cDriverFramebuffer::Clear()
  35.230 +{
  35.231 +    memset(offbuff, 0, screensize);
  35.232 +}
  35.233 +
  35.234 +void cDriverFramebuffer::Set8Pixels(int x, int y, unsigned char data)
  35.235 +{
  35.236 +    int n;
  35.237 +
  35.238 +    x &= 0xFFF8;
  35.239 +
  35.240 +    for (n = 0; n < 8; ++n)
  35.241 +    {
  35.242 +        if (data & (0x80 >> n))      // if bit is set
  35.243 +            SetPixel(x + n, y);
  35.244 +    }
  35.245 +}
  35.246 +
  35.247 +void cDriverFramebuffer::Refresh(bool refreshAll)
  35.248 +{
  35.249 +    memcpy(fbp, offbuff, screensize);
  35.250 +}
  35.251 +
  35.252 +} // end of namespace
    36.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    36.2 +++ b/graphlcd-base/glcddrivers/framebuffer.h	Wed Feb 06 17:32:55 2008 +0000
    36.3 @@ -0,0 +1,56 @@
    36.4 +/*
    36.5 + * GraphLCD driver library
    36.6 + *
    36.7 + * framebuffer.h  -  framebuffer device
    36.8 + *                   Output goes to a framebuffer device
    36.9 + *
   36.10 + * This file is released under the GNU General Public License. Refer
   36.11 + * to the COPYING file distributed with this package.
   36.12 + *
   36.13 + * (c) 2004 Stephan Skrodzki
   36.14 + */
   36.15 +
   36.16 +#ifndef _GLCDDRIVERS_FRAMEBUFFER_H_
   36.17 +#define _GLCDDRIVERS_FRAMEBUFFER_H_
   36.18 +
   36.19 +#include "driver.h"
   36.20 +#include <linux/fb.h>
   36.21 +
   36.22 +
   36.23 +namespace GLCD
   36.24 +{
   36.25 +
   36.26 +class cDriverConfig;
   36.27 +
   36.28 +class cDriverFramebuffer : public cDriver
   36.29 +{
   36.30 +private:
   36.31 +    unsigned char ** LCD;
   36.32 +    cDriverConfig * config;
   36.33 +    cDriverConfig * oldConfig;
   36.34 +    char *offbuff;
   36.35 +    int fbfd;
   36.36 +    struct fb_var_screeninfo vinfo;
   36.37 +    struct fb_fix_screeninfo finfo;
   36.38 +    long int screensize;
   36.39 +    void *fbp;
   36.40 +    int zoom;
   36.41 +
   36.42 +    int CheckSetup();
   36.43 +    void SetPixel(int x, int y);
   36.44 +
   36.45 +public:
   36.46 +    cDriverFramebuffer(cDriverConfig * config);
   36.47 +    virtual ~cDriverFramebuffer();
   36.48 +
   36.49 +    virtual int Init();
   36.50 +    virtual int DeInit();
   36.51 +
   36.52 +    virtual void Clear();
   36.53 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   36.54 +    virtual void Refresh(bool refreshAll = false);
   36.55 +};
   36.56 +
   36.57 +} // end of namespace
   36.58 +
   36.59 +#endif
    37.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    37.2 +++ b/graphlcd-base/glcddrivers/g15daemon.c	Wed Feb 06 17:32:55 2008 +0000
    37.3 @@ -0,0 +1,219 @@
    37.4 +/*
    37.5 +* GraphLCD driver library
    37.6 +*
    37.7 +* g15daemon.c  -  pseudo device for the g15daemon meta driver
    37.8 +*                   Output goes to the g15daemon which then displays it
    37.9 +*
   37.10 +* This file is released under the GNU General Public License. Refer
   37.11 +* to the COPYING file distributed with this package.
   37.12 +*
   37.13 +*/
   37.14 +
   37.15 +#include <fcntl.h>
   37.16 +#include <stdio.h>
   37.17 +#include <syslog.h>
   37.18 +#include <unistd.h>
   37.19 +#include <sys/mman.h>
   37.20 +#include <sys/ioctl.h>
   37.21 +#include <sys/socket.h>
   37.22 +#include <poll.h>
   37.23 +#include <arpa/inet.h>
   37.24 +#include <unistd.h>
   37.25 +
   37.26 +#include "common.h"
   37.27 +#include "config.h"
   37.28 +
   37.29 +#include "g15daemon.h"
   37.30 +
   37.31 +#define G15SERVER_PORT 15550
   37.32 +#define G15SERVER_ADDR "127.0.0.1"
   37.33 +
   37.34 +#define G15_WIDTH 160
   37.35 +#define G15_HEIGHT 43
   37.36 +
   37.37 +
   37.38 +static int g15_send(int sock, char *buf, int len)
   37.39 +{
   37.40 +    int total = 0;
   37.41 +    int retval = 0;
   37.42 +    int bytesleft = len;
   37.43 +
   37.44 +    while (total < len) {
   37.45 +        retval = send(sock, buf+total, bytesleft, 0);
   37.46 +        if (retval == -1) {
   37.47 +            break;
   37.48 +        }
   37.49 +        bytesleft -= retval;
   37.50 +        total += retval;
   37.51 +    }
   37.52 +    return retval==-1?-1:0;
   37.53 +}
   37.54 +
   37.55 +static int g15_recv(int sock, char *buf, int len)
   37.56 +{
   37.57 +    int total = 0;
   37.58 +    int retval = 0;
   37.59 +    int bytesleft = len;
   37.60 +
   37.61 +    while (total < len) {
   37.62 +        retval = recv(sock, buf+total, bytesleft, 0);
   37.63 +        if (retval < 1) {
   37.64 +            break;
   37.65 +        }
   37.66 +        total += retval;
   37.67 +        bytesleft -= retval;
   37.68 +    }
   37.69 +    return total;
   37.70 +}
   37.71 +
   37.72 +static int open_g15_daemon()
   37.73 +{
   37.74 +    int g15screen_fd;
   37.75 +    struct sockaddr_in serv_addr;
   37.76 +
   37.77 +    char buffer[256];
   37.78 +
   37.79 +    g15screen_fd = socket(AF_INET, SOCK_STREAM, 0);
   37.80 +    if (g15screen_fd < 0)
   37.81 +        return -1;
   37.82 +
   37.83 +    memset(&serv_addr, 0, sizeof(serv_addr));
   37.84 +    serv_addr.sin_family      = AF_INET;
   37.85 +    inet_aton (G15SERVER_ADDR, &serv_addr.sin_addr);
   37.86 +    serv_addr.sin_port        = htons(G15SERVER_PORT);
   37.87 +
   37.88 +    if (connect(g15screen_fd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) < 0)
   37.89 +        return -1;
   37.90 +
   37.91 +    memset(buffer,0,256);
   37.92 +    if (g15_recv(g15screen_fd, buffer, 16)<0)
   37.93 +        return -1;
   37.94 +
   37.95 +    /* here we check that we're really talking to the g15daemon */
   37.96 +    if (strcmp(buffer,"G15 daemon HELLO") != 0)
   37.97 +        return -1;
   37.98 +
   37.99 +    /* we want to use a pixelbuffer */
  37.100 +    g15_send(g15screen_fd,"GBUF",4);
  37.101 +
  37.102 +    return g15screen_fd;
  37.103 +}
  37.104 +
  37.105 +
  37.106 +namespace GLCD
  37.107 +{
  37.108 +
  37.109 +cDriverG15daemon::cDriverG15daemon(cDriverConfig * config)
  37.110 +:   config(config),
  37.111 +    offbuff(0),
  37.112 +    sockfd(-1)
  37.113 +{
  37.114 +    oldConfig = new cDriverConfig(*config);
  37.115 +}
  37.116 +
  37.117 +cDriverG15daemon::~cDriverG15daemon()
  37.118 +{
  37.119 +    delete oldConfig;
  37.120 +}
  37.121 +
  37.122 +int cDriverG15daemon::Init()
  37.123 +{
  37.124 +    // default values
  37.125 +    width = config->width;
  37.126 +    if (width !=G15_WIDTH)
  37.127 +        width = G15_WIDTH;
  37.128 +    height = config->height;
  37.129 +    if (height !=G15_HEIGHT)
  37.130 +        height = G15_HEIGHT;
  37.131 +
  37.132 +    for (unsigned int i = 0; i < config->options.size(); i++) {
  37.133 +        if (config->options[i].name == "") {
  37.134 +        }
  37.135 +    }
  37.136 +
  37.137 +    screensize = 6880;
  37.138 +
  37.139 +    if ((sockfd = open_g15_daemon())<0)
  37.140 +        return -1;
  37.141 +    // reserve memory to draw into
  37.142 +    offbuff = new char[6880];
  37.143 +
  37.144 +    *oldConfig = *config;
  37.145 +
  37.146 +    // clear display
  37.147 +    Refresh(true);
  37.148 +
  37.149 +    syslog(LOG_INFO, "%s: g15daemon initialized.\n", config->name.c_str());
  37.150 +    return 0;
  37.151 +}
  37.152 +
  37.153 +int cDriverG15daemon::DeInit()
  37.154 +{
  37.155 +    if (offbuff);
  37.156 +    delete[] offbuff;
  37.157 +    if (-1 != sockfd)
  37.158 +        close(sockfd);
  37.159 +
  37.160 +    return 0;
  37.161 +}
  37.162 +
  37.163 +int cDriverG15daemon::CheckSetup()
  37.164 +{
  37.165 +    if (config->device != oldConfig->device ||
  37.166 +        config->port != oldConfig->port ||
  37.167 +        config->width != oldConfig->width ||
  37.168 +        config->height != oldConfig->height)
  37.169 +    {
  37.170 +        DeInit();
  37.171 +        Init();
  37.172 +        return 0;
  37.173 +    }
  37.174 +
  37.175 +    if (config->upsideDown != oldConfig->upsideDown ||
  37.176 +        config->invert != oldConfig->invert)
  37.177 +    {
  37.178 +        oldConfig->upsideDown = config->upsideDown;
  37.179 +        oldConfig->invert = config->invert;
  37.180 +        return 1;
  37.181 +    }
  37.182 +    return 0;
  37.183 +}
  37.184 +
  37.185 +void cDriverG15daemon::SetPixel(int x, int y)
  37.186 +{
  37.187 +    if (x >= width || y >= height)
  37.188 +        return;
  37.189 +
  37.190 +    if (config->upsideDown)
  37.191 +    {
  37.192 +        x = width - 1 - x;
  37.193 +        y = height - 1 - y;
  37.194 +    }
  37.195 +
  37.196 +    offbuff[x + (width * y)] = 1;
  37.197 +}
  37.198 +
  37.199 +void cDriverG15daemon::Clear()
  37.200 +{
  37.201 +    memset(offbuff, 0, screensize);
  37.202 +}
  37.203 +
  37.204 +void cDriverG15daemon::Set8Pixels(int x, int y, unsigned char data)
  37.205 +{
  37.206 +    int n;
  37.207 +
  37.208 +    x &= 0xFFF8;
  37.209 +
  37.210 +    for (n = 0; n < 8; ++n)
  37.211 +    {
  37.212 +        if (data & (0x80 >> n))      // if bit is set
  37.213 +            SetPixel(x + n, y);
  37.214 +    }
  37.215 +}
  37.216 +
  37.217 +void cDriverG15daemon::Refresh(bool refreshAll)
  37.218 +{
  37.219 +    g15_send(sockfd, offbuff, screensize);
  37.220 +}
  37.221 +
  37.222 +} // end of namespace
    38.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    38.2 +++ b/graphlcd-base/glcddrivers/g15daemon.h	Wed Feb 06 17:32:55 2008 +0000
    38.3 @@ -0,0 +1,49 @@
    38.4 +/*
    38.5 + * GraphLCD driver library
    38.6 + *
    38.7 + * g15daemon.h  -  pseudo device for the g15daemon
    38.8 + *                   Output goes to the g15daemon which then displays it
    38.9 + *
   38.10 + */
   38.11 +
   38.12 +#ifndef _GLCDDRIVERS_G15DAEMON_H_
   38.13 +#define _GLCDDRIVERS_G15DAEMON_H_
   38.14 +
   38.15 +#include "driver.h"
   38.16 +
   38.17 +
   38.18 +namespace GLCD
   38.19 +{
   38.20 +
   38.21 +class cDriverConfig;
   38.22 +
   38.23 +class cDriverG15daemon : public cDriver
   38.24 +{
   38.25 +private:
   38.26 +    unsigned char ** LCD;
   38.27 +    cDriverConfig * config;
   38.28 +    cDriverConfig * oldConfig;
   38.29 +    char *offbuff;
   38.30 +    int sockfd;
   38.31 +    long int screensize;
   38.32 +    char *fbp;
   38.33 +    int zoom;
   38.34 +
   38.35 +    int CheckSetup();
   38.36 +    void SetPixel(int x, int y);
   38.37 +
   38.38 +public:
   38.39 +    cDriverG15daemon(cDriverConfig * config);
   38.40 +    virtual ~cDriverG15daemon();
   38.41 +
   38.42 +    virtual int Init();
   38.43 +    virtual int DeInit();
   38.44 +
   38.45 +    virtual void Clear();
   38.46 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   38.47 +    virtual void Refresh(bool refreshAll = false);
   38.48 +};
   38.49 +
   38.50 +} // end of namespace
   38.51 +
   38.52 +#endif
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/graphlcd-base/glcddrivers/gu126x64D-K610A4.c	Wed Feb 06 17:32:55 2008 +0000
    39.3 @@ -0,0 +1,967 @@
    39.4 +/*
    39.5 + * GraphLCD driver library
    39.6 + *
    39.7 + * gu126x64D-K610A4.c -  8-bit driver module for Noritake GU126x64D-K610A4 VFD
    39.8 + *                       displays. The VFD is operating in its 8 bit-mode
    39.9 + *                       connected to a single PC parallel port.
   39.10 + *
   39.11 + * based on: 
   39.12 + *   gu256x64-372 driver module for graphlcd
   39.13 + *     (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
   39.14 + *   gu256x64-3900 driver module for graphlcd
   39.15 + *     (c) 2004 Ralf Mueller (ralf AT bj-ig.de)
   39.16 + *   gu140x32f driver module for graphlcd
   39.17 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   39.18 + *   ks0108 driver module for graphlcd
   39.19 + *     (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
   39.20 + *  
   39.21 + * This file is released under the GNU General Public License. Refer
   39.22 + * to the COPYING file distributed with this package.
   39.23 + *
   39.24 + * (c) 2007 Alexander Rieger (Alexander.Rieger AT inka.de)
   39.25 + */
   39.26 +
   39.27 +#include <errno.h>
   39.28 +#include <syslog.h>
   39.29 +#include <unistd.h>
   39.30 +#include <sys/time.h>
   39.31 +
   39.32 +#include "common.h"
   39.33 +#include "config.h"
   39.34 +#include "gu126x64D-K610A4.h"
   39.35 +#include "port.h"
   39.36 +
   39.37 +namespace GLCD
   39.38 +{
   39.39 +//----- commands to the display -----------------------------------------------
   39.40 +static const unsigned char CMD_RUN_MACRO_01  = 0x01; // run macro 1
   39.41 +static const unsigned char CMD_RUN_MACRO_02  = 0x02; // run macro 2
   39.42 +static const unsigned char CMD_RUN_MACRO_03  = 0x03; // run macro 3
   39.43 +static const unsigned char CMD_RUN_MACRO_04  = 0x04; // run macro 4
   39.44 +static const unsigned char CMD_RUN_MACRO_05  = 0x05; // run macro 5
   39.45 +static const unsigned char CMD_RUN_MACRO_06  = 0x06; // run macro 6
   39.46 +static const unsigned char CMD_RUN_MACRO_07  = 0x07; // run macro 7
   39.47 +
   39.48 +static const unsigned char CMD_CURSOR_POS    = 0x10; // Set cursor position
   39.49 +static const unsigned char CMD_BOX_SET       = 0x11; // Set area
   39.50 +static const unsigned char CMD_BOX_CLEAR     = 0x12; // Clear area
   39.51 +static const unsigned char CMD_BOX_INVERT    = 0x13; // Invert area
   39.52 +static const unsigned char CMD_RECT_SET      = 0x14; // Set outline
   39.53 +static const unsigned char CMD_RECT_CLEAR    = 0x15; // Clear outline
   39.54 +
   39.55 +static const unsigned char CMD_PIXEL_SET     = 0x16; // Set pixel at current pos
   39.56 +static const unsigned char CMD_PIXEL_CLEAR   = 0x17; // Clear pixel at current pos
   39.57 +
   39.58 +static const unsigned char CMD_GRAPHIC_WRITE = 0x18; // Write graphics data (args: len, data)
   39.59 +static const unsigned char CMD_RESET         = 0x19; // Reset display
   39.60 +static const unsigned char CMD_WRITE_MODE    = 0x1A; // Write mode 
   39.61 +static const unsigned char CMD_INTRO         = 0x1B; // Intro for other commands (see CMA_*)
   39.62 +static const unsigned char CMD_FONT_PROP_SML = 0x1C; // Select font: proportional mini
   39.63 +static const unsigned char CMD_FONT_FIX_MED  = 0x1D; // Select font: fixed spaced 5x7
   39.64 +static const unsigned char CMD_FONT_FIX_BIG  = 0x1E; // Select font: fixed spaced 10x14
   39.65 +
   39.66 +static const unsigned char CMA_MACROS_ERASE  = 0x4D; // Erase Macros  (usage: CMD_INTRO + this)
   39.67 +static const unsigned char CMA_EPROM_LOCK    = 0x4C; // Lock EEPROM   (usage: CMD_INTRO + this)
   39.68 +static const unsigned char CMA_EPROM_UNLOCK  = 0x55; // Unlock EEPROM (usage: CMD_INTRO + this)
   39.69 +
   39.70 +static const unsigned char CMA_POWER_OFF     = 0x46; // Power off     (usage: CMD_INTRO + this)
   39.71 +static const unsigned char CMA_POWER_ON      = 0x50; // Power on      (usage: CMD_INTRO + this)
   39.72 +
   39.73 +//----- signal lines ----------------------------------------------------------
   39.74 +static const unsigned char OUT_EN_HI         = kAutoLow ;
   39.75 +static const unsigned char OUT_EN_LO         = kAutoHigh;
   39.76 +static const unsigned char OUT_EN_MASK       = OUT_EN_HI;
   39.77 +
   39.78 +static const unsigned char IN_MB_HI          = 0x40;
   39.79 +static const unsigned char IN_MB_LO          = 0x00;
   39.80 +static const unsigned char IN_MB_MASK        = IN_MB_HI;
   39.81 +
   39.82 +//----- log flags -------------------------------------------------------------
   39.83 +static const unsigned int  LL_REFRESH_START  = 0x0001;  //  1
   39.84 +static const unsigned int  LL_REFRESH_END    = 0x0002;  //  2
   39.85 +static const unsigned int  LL_REFRESH_MED    = 0x0004;  //  4
   39.86 +static const unsigned int  LL_VFD_CMD        = 0x0008;  //  8
   39.87 +static const unsigned int  LL_MAX_WAIT       = 0x0010;  // 16
   39.88 +
   39.89 +//----- mixed consts ----------------------------------------------------------
   39.90 +static const long          ADJUST_FACTOR     =  100;    // used to adjust timing
   39.91 +
   39.92 +//-----------------------------------------------------------------------------
   39.93 +cDriverGU126X64D_K610A4::cDriverGU126X64D_K610A4(cDriverConfig * config)
   39.94 +                       : port                (0)
   39.95 +                       , config              (config)
   39.96 +                       , oldConfig           (0)
   39.97 +                       , myNumRows           (0)
   39.98 +                       , myDrawMem           (0)
   39.99 +                       , myVFDMem            (0)
  39.100 +                       , myUseSleepInit      (false)
  39.101 +                       , myPortDelayNS       (0)
  39.102 +                       , myDelay125NS        (0)
  39.103 +                       , myRefreshCounter    (0)
  39.104 +                       , myClaimCounter      (0)
  39.105 +                       , myDataPendingCounter(0)
  39.106 +                       , myLogFlags          (0)
  39.107 +{
  39.108 +    oldConfig = new cDriverConfig(*config);
  39.109 +} // cDriverGU126X64D_K610A4::cDriverGU126X64D_K610A4()
  39.110 +
  39.111 +//-----------------------------------------------------------------------------
  39.112 +cDriverGU126X64D_K610A4::~cDriverGU126X64D_K610A4()
  39.113 +{
  39.114 +    delete oldConfig;
  39.115 +} // cDriverGU126X64D_K610A4::cDriverGU126X64D_K610A4()
  39.116 +
  39.117 +//-----------------------------------------------------------------------------
  39.118 +int cDriverGU126X64D_K610A4::Init()
  39.119 +{
  39.120 +    width = config->width;
  39.121 +    if (width <= 0 || width > 256)   // don't allow unreasonable big sizes from config
  39.122 +    {
  39.123 +        width = 126;
  39.124 +    } // if
  39.125 +
  39.126 +    height = config->height;
  39.127 +    if (height <= 0 || height > 256) // don't allow unreasonable big sizes from config
  39.128 +    {
  39.129 +        height = 64;
  39.130 +    } // if
  39.131 +
  39.132 +    //----- parse config -----
  39.133 +    for (unsigned int i = 0; i < config->options.size(); i++)
  39.134 +    {
  39.135 +        if (config->options[i].name == "Debug")
  39.136 +        {
  39.137 +            myLogFlags = atoi(config->options[i].value.c_str());
  39.138 +        } // if
  39.139 +    } // for
  39.140 +
  39.141 +    myNumRows = ((height + 7) / 8);
  39.142 +    port      = new cParallelPort();
  39.143 +
  39.144 +    // setup drawing memory
  39.145 +    myDrawMem = new unsigned char *[width];
  39.146 +    for (int x = 0; x < width; x++)
  39.147 +    {
  39.148 +        myDrawMem[x] = new unsigned char[myNumRows];
  39.149 +        memset(myDrawMem[x], 0, myNumRows);
  39.150 +    } // for
  39.151 +
  39.152 +    // setup vfd memory
  39.153 +    myVFDMem = new unsigned char *[width];
  39.154 +    for (int x = 0; x < width; x++)
  39.155 +    {
  39.156 +        myVFDMem[x] = new unsigned char[myNumRows];
  39.157 +        memset(myVFDMem[x], 0, myNumRows);
  39.158 +    } // for
  39.159 +
  39.160 +    if (initParallelPort() < 0)
  39.161 +    {
  39.162 +        return -1;
  39.163 +    } // if
  39.164 +
  39.165 +    initDisplay();
  39.166 +
  39.167 +    *oldConfig = *config;
  39.168 +
  39.169 +    // Set Display SetBrightness
  39.170 +    SetBrightness(config->brightness);
  39.171 +
  39.172 +    // clear display
  39.173 +    Clear();
  39.174 +    clearVFDMem();
  39.175 +
  39.176 +    syslog( LOG_INFO, "%s: initialized (width: %d  height: %d)"
  39.177 +          , config->name.c_str(), width, height
  39.178 +          );
  39.179 +
  39.180 +    return 0;
  39.181 +} // cDriverGU126X64D_K610A4::Init()
  39.182 +
  39.183 +//-----------------------------------------------------------------------------
  39.184 +int cDriverGU126X64D_K610A4::DeInit()
  39.185 +{
  39.186 +    if (myVFDMem)
  39.187 +    {
  39.188 +        for (int x = 0; x < width; x++)
  39.189 +        {
  39.190 +            delete[] myVFDMem[x];
  39.191 +        } // for
  39.192 +        delete[] myVFDMem;
  39.193 +        myVFDMem = 0;
  39.194 +    } // if
  39.195 +
  39.196 +    if (myDrawMem)
  39.197 +    {
  39.198 +        for(int x = 0; x < width; x++)
  39.199 +        {
  39.200 +            delete[] myDrawMem[x];
  39.201 +        } // for
  39.202 +        delete[] myDrawMem;
  39.203 +        myDrawMem = 0;
  39.204 +    } // if
  39.205 +
  39.206 +    if (port)
  39.207 +    {
  39.208 +        // claim port to avoid msg when closing the port
  39.209 +        port->Claim();
  39.210 +        if (port->Close() != 0)
  39.211 +        {
  39.212 +            return -1;
  39.213 +        } // if
  39.214 +        delete port;
  39.215 +        port = 0;
  39.216 +    } // if
  39.217 +
  39.218 +    return 0;
  39.219 +} // cDriverGU126X64D_K610A4::DeInit()
  39.220 +
  39.221 +//-----------------------------------------------------------------------------
  39.222 +int cDriverGU126X64D_K610A4::checkSetup()
  39.223 +{
  39.224 +    if ( config->device != oldConfig->device
  39.225 +      || config->port   != oldConfig->port
  39.226 +      || config->width  != oldConfig->width
  39.227 +      || config->height != oldConfig->height
  39.228 +       )
  39.229 +    {
  39.230 +        DeInit();
  39.231 +        Init();
  39.232 +        return 0;
  39.233 +    } // if
  39.234 +
  39.235 +    if (config->brightness != oldConfig->brightness)
  39.236 +    {
  39.237 +        oldConfig->brightness = config->brightness;
  39.238 +        SetBrightness(config->brightness);
  39.239 +    } // if
  39.240 +
  39.241 +    if ( config->upsideDown != oldConfig->upsideDown 
  39.242 +      || config->invert     != oldConfig->invert
  39.243 +       )
  39.244 +    {
  39.245 +        oldConfig->upsideDown = config->upsideDown;
  39.246 +        oldConfig->invert     = config->invert;
  39.247 +
  39.248 +        return 1;
  39.249 +    } // if
  39.250 +
  39.251 +    return 0;
  39.252 +} // cDriverGU126X64D_K610A4::checkSetup()
  39.253 +
  39.254 +//-----------------------------------------------------------------------------
  39.255 +int cDriverGU126X64D_K610A4::initParallelPort()
  39.256 +{
  39.257 +    struct timeval tv1, tv2;
  39.258 +
  39.259 +    if (config->device == "")
  39.260 +    {
  39.261 +        // use DirectIO
  39.262 +        if (port->Open(config->port) != 0)
  39.263 +        {
  39.264 +            syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!", config->name.c_str());
  39.265 +            return -1;
  39.266 +        } // if
  39.267 +        syslog(LOG_INFO, "%s: using direct IO!", config->name.c_str());
  39.268 +        uSleep(10);
  39.269 +    }
  39.270 +    else
  39.271 +    {
  39.272 +        // use ppdev
  39.273 +        if (port->Open(config->device.c_str()) != 0)
  39.274 +        {
  39.275 +            syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!", config->name.c_str());
  39.276 +            return -1;
  39.277 +        } // if
  39.278 +        syslog(LOG_INFO, "%s: using ppdev!", config->name.c_str());
  39.279 +    } // if
  39.280 +
  39.281 +    if (nSleepInit() != 0)
  39.282 +    {
  39.283 +        syslog(LOG_ERR, "%s: INFO: cannot change wait parameters  Err: %s (cDriver::Init)", config->name.c_str(), strerror(errno));
  39.284 +        myUseSleepInit = false;
  39.285 +    }
  39.286 +    else
  39.287 +    {
  39.288 +        myUseSleepInit = true;
  39.289 +    } // if
  39.290 +
  39.291 +    //----- measure the time to write to the port -----
  39.292 +    syslog(LOG_DEBUG, "%s: benchmark started.", config->name.c_str());
  39.293 +    gettimeofday(&tv1, 0);
  39.294 +
  39.295 +    const int aBenchCount = 1000; // don't change this!
  39.296 +    for (int x = 0; x < aBenchCount; x++)
  39.297 +    {
  39.298 +        port->WriteData(x % 0x100);
  39.299 +    } // for
  39.300 +
  39.301 +    gettimeofday(&tv2, 0);
  39.302 +
  39.303 +    // release the port, which was implicitely claimed by open
  39.304 +    port->Release();
  39.305 +
  39.306 +    if (myUseSleepInit) nSleepDeInit();
  39.307 +
  39.308 +    myPortDelayNS  = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  39.309 +
  39.310 +    myDelay125NS = std::max(125 + (ADJUST_FACTOR * config->adjustTiming) - myPortDelayNS, 0L);
  39.311 +
  39.312 +    syslog( LOG_DEBUG, "%s: benchmark stopped. Time for Port Command: %ldns, delay: %ldns"
  39.313 +          , config->name.c_str(), myPortDelayNS, myDelay125NS
  39.314 +          );
  39.315 +
  39.316 +    return 0;
  39.317 +} // cDriverGU126X64D_K610A4::initParallelPort()
  39.318 +
  39.319 +//-----------------------------------------------------------------------------
  39.320 +void cDriverGU126X64D_K610A4::initDisplay()
  39.321 +{
  39.322 +    claimPort();
  39.323 +    cmdReset();
  39.324 +    releasePort();
  39.325 +} // cDriverGU126X64D_K610A4::initDisplay()
  39.326 +
  39.327 +//-----------------------------------------------------------------------------
  39.328 +void cDriverGU126X64D_K610A4::clearVFDMem()
  39.329 +{
  39.330 +    for (int x = 0; x < width; x++)
  39.331 +    {
  39.332 +        memset(myVFDMem[x], 0, myNumRows);
  39.333 +    } // for
  39.334 +} // cDriverGU126X64D_K610A4::clearVFDMem()
  39.335 +
  39.336 +//-----------------------------------------------------------------------------
  39.337 +void cDriverGU126X64D_K610A4::Clear()
  39.338 +{
  39.339 +    for (int x = 0; x < width; x++)
  39.340 +    {
  39.341 +        memset(myDrawMem[x], 0, myNumRows);
  39.342 +    } // for
  39.343 +} // cDriverGU126X64D_K610A4::Clear()
  39.344 +
  39.345 +//-----------------------------------------------------------------------------
  39.346 +void cDriverGU126X64D_K610A4::SetBrightness(unsigned int percent)
  39.347 +{
  39.348 +    claimPort();
  39.349 +    cmdSetBrightness(percent);
  39.350 +    releasePort();
  39.351 +} // cDriverGU126X64D_K610A4::SetBrightness()
  39.352 +
  39.353 +//-----------------------------------------------------------------------------
  39.354 +bool cDriverGU126X64D_K610A4::waitForStatus(unsigned char theMask, unsigned char theValue, int theMaxWait)
  39.355 +{
  39.356 +    theValue = theValue & theMask;
  39.357 +
  39.358 +    int status = port->ReadStatus();
  39.359 +
  39.360 +    if ((status & theMask) != theValue)
  39.361 +    {
  39.362 +        // wait some time for MB go HI/LO but not forever
  39.363 +        int i = 0;
  39.364 +        for(i = 0; ((status & theMask) != theValue) && i < theMaxWait; i++)
  39.365 +        {
  39.366 +            status = port->ReadStatus();
  39.367 +        } // for
  39.368 +
  39.369 +        if (isLogEnabled(LL_MAX_WAIT) && i >= theMaxWait)
  39.370 +        {
  39.371 +            syslog( LOG_INFO, "%s: slept for %5d times while waiting for MB = %d"
  39.372 +                  , config->name.c_str(), i, ((theMask & theValue) == 0 ? 0 : 1)
  39.373 +                  );
  39.374 +        } // 
  39.375 +    } // if
  39.376 +
  39.377 +    return ((status & theMask) == theValue);
  39.378 +} // cDriverGU126X64D_K610A4::waitForStatus()
  39.379 +
  39.380 +//-----------------------------------------------------------------------------
  39.381 +void cDriverGU126X64D_K610A4::writeParallel(unsigned char data)
  39.382 +{
  39.383 +    if (myUseSleepInit) nSleepInit();
  39.384 +
  39.385 +    waitForStatus(IN_MB_MASK, IN_MB_LO, 500);                  // wait for MB == LO
  39.386 +
  39.387 +    port->WriteData(data);                                     // write data
  39.388 +    nSleep(myDelay125NS);                                      // - sleep
  39.389 +
  39.390 +    port->WriteControl(OUT_EN_LO & OUT_EN_MASK);               // set ENABLE to LO
  39.391 +    nSleep(myDelay125NS);                                      // - sleep
  39.392 +
  39.393 +    port->WriteControl(OUT_EN_HI & OUT_EN_MASK);               // set ENABLE to HI
  39.394 +
  39.395 +    waitForStatus(IN_MB_MASK, IN_MB_HI, 50);                   // wait for MB == HI
  39.396 +
  39.397 +//  the other drivers don't do this neither
  39.398 +//  if (myUseSleepInit) nSleepDeInit();
  39.399 +} // cDriverGU126X64D_K610A4::writeParallel()
  39.400 +
  39.401 +//-----------------------------------------------------------------------------
  39.402 +int cDriverGU126X64D_K610A4::write(unsigned char data)
  39.403 +{
  39.404 +    int b = 0;
  39.405 +
  39.406 +    writeParallel(data);
  39.407 +    ++b; 
  39.408 +
  39.409 +    // if data == 0x60 -> send 0x60 twice 
  39.410 +    // (0x60 switches to hex-mode)
  39.411 +    if (data == 0x60)
  39.412 +    {
  39.413 +        writeParallel(data);
  39.414 +        ++b;
  39.415 +    } // if
  39.416 +
  39.417 +    return b;
  39.418 +} // cDriverGU126X64D_K610A4::write()
  39.419 +
  39.420 +//-----------------------------------------------------------------------------
  39.421 +void cDriverGU126X64D_K610A4::setPixel(int x, int y)
  39.422 +{
  39.423 +    if (!myDrawMem          ) return;
  39.424 +    if (x >= width  || x < 0) return;
  39.425 +    if (y >= height || y < 0) return;
  39.426 +
  39.427 +    if (config->upsideDown)
  39.428 +    {
  39.429 +        x = width  - 1 - x;
  39.430 +        y = height - 1 - y;
  39.431 +    } // if
  39.432 +
  39.433 +    unsigned char c = 0x80 >> (y % 8);
  39.434 +
  39.435 +    myDrawMem[x][y/8] = myDrawMem[x][y/8] | c;
  39.436 +} // cDriverGU126X64D_K610A4::setPixel()
  39.437 +
  39.438 +//-----------------------------------------------------------------------------
  39.439 +void cDriverGU126X64D_K610A4::Set8Pixels(int x, int y, unsigned char data)
  39.440 +{
  39.441 +    // x - pos isn't maybe align to 8
  39.442 +    x &= 0xFFF8;
  39.443 +
  39.444 +    for (int n = 0; n < 8; ++n)
  39.445 +    {
  39.446 +        if ((data & (0x80 >> n)) != 0) // if bit is set
  39.447 +        {
  39.448 +            setPixel(x + n, y);
  39.449 +        } // if
  39.450 +    } // for
  39.451 +} // cDriverGU126X64D_K610A4::Set8Pixels()
  39.452 +
  39.453 +//-----------------------------------------------------------------------------
  39.454 +void cDriverGU126X64D_K610A4::Refresh(bool refreshAll)
  39.455 +{
  39.456 +    // no mem present -> return
  39.457 +    if (!myVFDMem || !myDrawMem)
  39.458 +    {
  39.459 +        return;
  39.460 +    } // if
  39.461 +
  39.462 +    // create log
  39.463 +    if (isLogEnabled(LL_REFRESH_START))
  39.464 +    {
  39.465 +        syslog( LOG_INFO, "%s: > Refresh()  all = %d  RefreshDisplay = %d  RefreshCtr  = %d  Delay = %ld"
  39.466 +              , config->name.c_str()
  39.467 +              , refreshAll
  39.468 +              , config->refreshDisplay
  39.469 +              , myRefreshCounter
  39.470 +              , myDelay125NS
  39.471 +              );
  39.472 +    } // if
  39.473 +
  39.474 +    // setup changed -> refresh all
  39.475 +    if (checkSetup() > 0)
  39.476 +    {
  39.477 +        syslog(LOG_DEBUG, "%s:   Refresh() checkSetup() returned != 0 -> refreshAll = true", config->name.c_str());
  39.478 +        refreshAll = true;
  39.479 +    } // if
  39.480 +
  39.481 +    // refresh-counter exceeded -> refresh all
  39.482 +    if (!refreshAll && config->refreshDisplay != 0)
  39.483 +    {
  39.484 +        myRefreshCounter = (myRefreshCounter + 1) % config->refreshDisplay;
  39.485 +        refreshAll = myRefreshCounter == 0;
  39.486 +
  39.487 +        if (refreshAll && isLogEnabled(LL_REFRESH_START))
  39.488 +        {
  39.489 +          syslog(LOG_DEBUG, "%s:   Refresh() refresh-count reached -> refreshAll = true", config->name.c_str());
  39.490 +        } // if
  39.491 +    } // if
  39.492 +
  39.493 +    if (isLogEnabled(LL_REFRESH_START))
  39.494 +    {
  39.495 +        syslog( LOG_INFO, "%s:   Refresh()  all = %d  RefreshDisplay = %d  RefreshCtr  = %d  Delay = %ld"
  39.496 +              , config->name.c_str()
  39.497 +              , refreshAll
  39.498 +              , config->refreshDisplay
  39.499 +              , myRefreshCounter
  39.500 +              , myDelay125NS
  39.501 +              );
  39.502 +    } // if
  39.503 +
  39.504 +    // time for logs
  39.505 +    struct timeval tv1, tv2;
  39.506 +    gettimeofday(&tv1, 0);
  39.507 +
  39.508 +    claimPort();
  39.509 +
  39.510 +    int  chunk = 128; // displays with more than 128 pixels width are written in chunks
  39.511 +                      // note: this driver isn't really prepared to handle displays
  39.512 +                      //       with other dimensions than 126x64
  39.513 +    int  xb    = 0;
  39.514 +    int  yb    = 0;
  39.515 +    long bc    = 0;
  39.516 +
  39.517 +    for (yb = 0; yb < myNumRows; ++yb)
  39.518 +    {
  39.519 +        int  minX  = width;
  39.520 +        int  maxX  = 0;
  39.521 +
  39.522 +        //----- if !refreshAll -> check modified bytes
  39.523 +        if (!refreshAll)
  39.524 +        {
  39.525 +            for (xb = 0; xb < width; ++xb)
  39.526 +            {
  39.527 +                if (myVFDMem[xb][yb] != myDrawMem[xb][yb])
  39.528 +                {
  39.529 +                    minX = std::min(minX, xb);
  39.530 +                    maxX = std::max(maxX, xb);
  39.531 +                } // if
  39.532 +            } // for
  39.533 +        }
  39.534 +        else
  39.535 +        {
  39.536 +            minX = 0;
  39.537 +            maxX = width - 1;
  39.538 +        } // if
  39.539 +
  39.540 +        // create log
  39.541 +        if (isLogEnabled(LL_REFRESH_MED))
  39.542 +        {
  39.543 +            if (minX <= maxX)
  39.544 +            {
  39.545 +                syslog( LOG_INFO, "%s: Row[%d] %3d - %3d : %3d"
  39.546 +                      , config->name.c_str(), yb
  39.547 +                      , minX, maxX
  39.548 +                      , maxX - minX + 1
  39.549 +                      );
  39.550 +            }
  39.551 +            else
  39.552 +            {
  39.553 +                syslog( LOG_INFO, "%s: Row[%d] --- - --- : ---"
  39.554 +                      , config->name.c_str(), yb
  39.555 +                      );
  39.556 +            } // if
  39.557 +        } // if
  39.558 +
  39.559 +        // perform refresh
  39.560 +        if (minX <= maxX)
  39.561 +        {
  39.562 +            bc += cmdSetCursorPos(minX, yb * 8);
  39.563 +
  39.564 +            for (xb = minX; xb <= maxX; ++xb)
  39.565 +            {
  39.566 +                if ((xb - minX) % chunk == 0)
  39.567 +                {
  39.568 +                    bc += cmdGraphicWrite(std::min((maxX - xb + 1), chunk));
  39.569 +                } // if
  39.570 +
  39.571 +                bc += cmdGraphicData(myDrawMem[xb][yb]);
  39.572 +                myVFDMem[xb][yb] = myDrawMem[xb][yb];
  39.573 +            } // for
  39.574 +        } // if
  39.575 +    } // for
  39.576 +
  39.577 +    releasePort();
  39.578 +
  39.579 +    // create log
  39.580 +    if (isLogEnabled(LL_REFRESH_END))
  39.581 +    {
  39.582 +        gettimeofday(&tv2, 0);
  39.583 +
  39.584 +        long duration_ms = ((tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec)) 
  39.585 +                        / 1000 /* us -> ms */
  39.586 +                        ;
  39.587 +
  39.588 +        syslog( LOG_INFO, "%s: < Refresh()  all = %d  took %3ld ms  %5ld bytes = %5ld bytes/sec = %5ld ns/byte"
  39.589 +              , config->name.c_str()
  39.590 +              , refreshAll
  39.591 +              , duration_ms
  39.592 +              , bc
  39.593 +              , duration_ms == 0 ? -1 : bc * 1000 / duration_ms
  39.594 +              , bc          == 0 ? -1 : duration_ms * 1000000 / bc
  39.595 +              );
  39.596 +    } // if
  39.597 +} // cDriverGU126X64D_K610A4::Refresh()
  39.598 +
  39.599 +//-----------------------------------------------------------------------------
  39.600 +int cDriverGU126X64D_K610A4::cmdReset()
  39.601 +{
  39.602 +    ensureNotInGraphics();
  39.603 +    int b = 0;
  39.604 +
  39.605 +    if (isLogEnabled(LL_VFD_CMD))
  39.606 +    {
  39.607 +        syslog(LOG_INFO, "- 1B: CMD_RESET        : 0x%02X ", int(CMD_RESET));
  39.608 +    } // if
  39.609 +
  39.610 +    b += write(CMD_RESET);
  39.611 +
  39.612 +    unsigned char aMode = 1 << 7  // data orientation : 0: horizontal, 1: vertical , default: 0
  39.613 +                        | 0 << 6  // cursor movement  : 0: horizontal, 1: vertical , default: 0
  39.614 +                        | 0 << 5  // cursor direction : 0: forwards  , 1: backwards, default: 0
  39.615 +                        | 0 << 4  // underscore cursor: 0: off       , 1: on       , default: 0
  39.616 +                        | 0 << 3  // underscore cursor: 0: static    , 1: flash    , default: 0
  39.617 +                        | 0 << 2  // not in documentation
  39.618 +                        | 0 << 0  // pen type: 0: overwrite, 1: AND, 2: OR, 3: XOR , default: 0
  39.619 +                        ;
  39.620 +
  39.621 +    if (isLogEnabled(LL_VFD_CMD))
  39.622 +    {
  39.623 +        syslog(LOG_INFO, "- 2B: CMD_WRITE_MODE   : 0x%02X 0x%02X", int(CMD_RESET), int(aMode));
  39.624 +    } // if
  39.625 +
  39.626 +    b += write(CMD_WRITE_MODE);
  39.627 +    b += write(aMode);
  39.628 +
  39.629 +    return b;
  39.630 +} // cDriverGU126X64D_K610A4::cmdReset()
  39.631 +
  39.632 +//-----------------------------------------------------------------------------
  39.633 +int cDriverGU126X64D_K610A4::cmdPower(bool fOn)
  39.634 +{
  39.635 +    ensureNotInGraphics();
  39.636 +    int b = 0;
  39.637 +
  39.638 +    if (isLogEnabled(LL_VFD_CMD))
  39.639 +    {
  39.640 +        syslog( LOG_INFO, "- 2B: CMD_POWER        : 0x%02X 0x%02X"
  39.641 +              , int(CMD_INTRO), int(fOn ? CMA_POWER_ON : CMA_POWER_OFF)
  39.642 +              );
  39.643 +    } // if
  39.644 +
  39.645 +    b += write(CMD_INTRO);
  39.646 +    b += write(fOn ? CMA_POWER_ON : CMA_POWER_OFF);
  39.647 +
  39.648 +    return b;
  39.649 +} // cDriverGU126X64D_K610A4::cmdPower()
  39.650 +
  39.651 +//-----------------------------------------------------------------------------
  39.652 +int cDriverGU126X64D_K610A4::cmdLock(bool fLock)
  39.653 +{
  39.654 +    ensureNotInGraphics();
  39.655 +    int b = 0;
  39.656 +
  39.657 +    if (isLogEnabled(LL_VFD_CMD))
  39.658 +    {
  39.659 +        syslog( LOG_INFO, "- 2B: CMD_LOCK         : 0x%02X 0x%02X"
  39.660 +              , int(CMD_INTRO), int(fLock ? CMA_EPROM_LOCK : CMA_EPROM_UNLOCK)
  39.661 +              );
  39.662 +    } // if
  39.663 +
  39.664 +    b += write(CMD_INTRO);
  39.665 +    b += write(fLock ? CMA_EPROM_LOCK : CMA_EPROM_UNLOCK);
  39.666 +
  39.667 +    return b;
  39.668 +} // cDriverGU126X64D_K610A4::cmdPower()
  39.669 +
  39.670 +//-----------------------------------------------------------------------------
  39.671 +int cDriverGU126X64D_K610A4::cmdSetCursorPos(unsigned char x, unsigned char y)
  39.672 +{
  39.673 +    ensureNotInGraphics();
  39.674 +    int b = 0;
  39.675 +
  39.676 +    if (isLogEnabled(LL_VFD_CMD))
  39.677 +    {
  39.678 +        syslog( LOG_INFO, "- 3B: CMD_CURSOR_POS   : 0x%02X 0x%02X 0x%02X  (x = %3d, y = %3d)"
  39.679 +              , int(CMD_CURSOR_POS), int(x), int(y), int(x), int(y)
  39.680 +              );
  39.681 +    } // if
  39.682 +
  39.683 +    b += write(CMD_CURSOR_POS); // cmd
  39.684 +    b += write(x             ); // xpos
  39.685 +    b += write(y             ); // ypos
  39.686 +
  39.687 +    return b;
  39.688 +} // cDriverGU126X64D_K610A4::cmdSetCursorPos();
  39.689 +
  39.690 +//-----------------------------------------------------------------------------
  39.691 +int cDriverGU126X64D_K610A4::cmdGraphicWrite(unsigned char count)
  39.692 +{
  39.693 +    ensureNotInGraphics();
  39.694 +    int b = 0;
  39.695 +
  39.696 +    if (isLogEnabled(LL_VFD_CMD))
  39.697 +    {
  39.698 +        syslog( LOG_INFO, "- 2B: CMD_GRAPHIC_WRITE: 0x%02X 0x%02X (%d bytes)"
  39.699 +              , int(CMD_GRAPHIC_WRITE), int(count), int(count)
  39.700 +              );
  39.701 +    } // if
  39.702 +
  39.703 +    b += write(CMD_GRAPHIC_WRITE); // cmd
  39.704 +    b += write(count            ); // len
  39.705 +
  39.706 +    myDataPendingCounter = count;
  39.707 +
  39.708 +    return b;
  39.709 +} // cDriverGU126X64D_K610A4::cmdGraphicWrite()
  39.710 +
  39.711 +//-----------------------------------------------------------------------------
  39.712 +int cDriverGU126X64D_K610A4::cmdGraphicData(unsigned char data)
  39.713 +{
  39.714 +    int b = 0;
  39.715 +
  39.716 +    myDataPendingCounter--;
  39.717 +    if (myDataPendingCounter < 0)
  39.718 +    {
  39.719 +        syslog( LOG_WARNING, "%s error: more graphic data written than announced -> ignored"
  39.720 +              , config->name.c_str()
  39.721 +              );
  39.722 +    }
  39.723 +    else
  39.724 +    {
  39.725 +        if (isLogEnabled(LL_VFD_CMD))
  39.726 +        {
  39.727 +            syslog( LOG_INFO, "- 1B: CMD_GRAPHIC_DATA : 0x%02X  (expecting another %d bytes)"
  39.728 +                  , int(data), myDataPendingCounter
  39.729 +                  );
  39.730 +        } // if
  39.731 +
  39.732 +        b += write(data ^ (config->invert ? 0xFF : 0x00));
  39.733 +    } // if
  39.734 +
  39.735 +    return b;
  39.736 +} // cDriverGU126X64D_K610A4::cmdGraphicData()
  39.737 +
  39.738 +//-----------------------------------------------------------------------------
  39.739 +int cDriverGU126X64D_K610A4::cmdSetBrightness(unsigned int percent)
  39.740 +{
  39.741 +    ensureNotInGraphics();
  39.742 +    int b = 0;
  39.743 +
  39.744 +    unsigned char bright = 0;
  39.745 +    if      (percent >= 85) bright = 0xFF;
  39.746 +    else if (percent >= 71) bright = 0xFE;
  39.747 +    else if (percent >= 57) bright = 0xFD;
  39.748 +    else if (percent >= 43) bright = 0xFC;
  39.749 +    else if (percent >= 29) bright = 0xFB;
  39.750 +    else if (percent >= 15) bright = 0xFA;
  39.751 +    else if (percent >=  1) bright = 0xF9;
  39.752 +    else                    bright = 0xF8;
  39.753 +
  39.754 +    if (isLogEnabled(LL_VFD_CMD))
  39.755 +    {
  39.756 +        syslog( LOG_INFO, "- 2B: CMD_INTRO        : 0x%02X 0x%02X = set brightness"
  39.757 +              , int(CMD_INTRO), int(bright)
  39.758 +              );
  39.759 +    } // if
  39.760 +
  39.761 +    b += write(CMD_INTRO);
  39.762 +    b += write(bright);
  39.763 +
  39.764 +    return b;
  39.765 +} // cDriverGU126X64D_K610A4::cmdSetBrightness()
  39.766 +
  39.767 +//-----------------------------------------------------------------------------
  39.768 +int cDriverGU126X64D_K610A4::cmdSetFont(FontType theFont)
  39.769 +{
  39.770 +    ensureNotInGraphics();
  39.771 +    int b = 0;
  39.772 +
  39.773 +    unsigned char aCmd = 0;
  39.774 +    switch (theFont)
  39.775 +    {
  39.776 +        case FONT_PROP_SML: aCmd = CMD_FONT_PROP_SML; break;
  39.777 +        case FONT_FIX_BIG : aCmd = CMD_FONT_FIX_BIG ; break;
  39.778 +        case FONT_FIX_MED : 
  39.779 +        default           : aCmd = CMD_FONT_FIX_MED ; break;
  39.780 +    } // switch
  39.781 +
  39.782 +    if (isLogEnabled(LL_VFD_CMD))
  39.783 +    {
  39.784 +        syslog(LOG_INFO, "- 1B: CMD_SET_FONT     : 0x%02X", int(aCmd));
  39.785 +    } // if
  39.786 +
  39.787 +    b += write(aCmd);
  39.788 +
  39.789 +    return b;
  39.790 +} // cDriverGU126X64D_K610A4::cmdSetFont()
  39.791 +
  39.792 +//-----------------------------------------------------------------------------
  39.793 +int cDriverGU126X64D_K610A4::cmdWriteText(const char *theText)
  39.794 +{
  39.795 +    ensureNotInGraphics();
  39.796 +    int b = 0;
  39.797 +
  39.798 +    if (isLogEnabled(LL_VFD_CMD))
  39.799 +    {
  39.800 +        syslog(LOG_INFO, "-%2dB: WRITE_TEXT       : '%s'", strlen(theText), theText);
  39.801 +    } // if
  39.802 +
  39.803 +    for (const char *p = theText; *p != '\0'; ++p)
  39.804 +    {
  39.805 +        b += write(*p);
  39.806 +    } // for
  39.807 +
  39.808 +    return b;
  39.809 +} // cDriverGU126X64D_K610A4::cmdWriteText()
  39.810 +
  39.811 +//-----------------------------------------------------------------------------
  39.812 +int cDriverGU126X64D_K610A4::cmdDrawRect(unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2)
  39.813 +{
  39.814 +    ensureNotInGraphics();
  39.815 +    int b = 0;
  39.816 +
  39.817 +    if (isLogEnabled(LL_VFD_CMD))
  39.818 +    {
  39.819 +        syslog( LOG_INFO, "- 5B: CMD_SET_OUTLINE  : 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X  (x1 = %3d, y1 = %3d, x2 = %3d, y2 = %3d)"
  39.820 +              , int(CMD_CURSOR_POS)
  39.821 +              , int(x1), int(y1), int(x2), int(y2)
  39.822 +              , int(x1), int(y1), int(x2), int(y2)
  39.823 +              );
  39.824 +    } // if
  39.825 +
  39.826 +    b += write(CMD_RECT_SET  );
  39.827 +    b += write(x1            );
  39.828 +    b += write(y1            );
  39.829 +    b += write(x2            );
  39.830 +    b += write(y2            );
  39.831 +
  39.832 +    return b;
  39.833 +} // cDriverGU126X64D_K610A4::cmdDrawRect()
  39.834 +
  39.835 +//-----------------------------------------------------------------------------
  39.836 +int cDriverGU126X64D_K610A4::cmdSetMacro(unsigned char theMacroNum, unsigned char theCountBytes)
  39.837 +{
  39.838 +    if (theMacroNum > 7)
  39.839 +    {
  39.840 +        return 0;
  39.841 +    } // if
  39.842 +
  39.843 +    ensureNotInGraphics();
  39.844 +    int b = 0;
  39.845 +
  39.846 +    if (isLogEnabled(LL_VFD_CMD))
  39.847 +    {
  39.848 +        syslog( LOG_INFO, "- 3B: CMD_INTRO        : 0x%02X 0x%02X 0x%02X (define macro %d with length %d)"
  39.849 +              , int(CMD_INTRO)
  39.850 +              , int(theMacroNum), int(theCountBytes)
  39.851 +              , int(theMacroNum), int(theCountBytes)
  39.852 +              );
  39.853 +    } // if
  39.854 +
  39.855 +    b += write(CMD_INTRO     );
  39.856 +    b += write(theMacroNum   );
  39.857 +    b += write(theCountBytes );
  39.858 +
  39.859 +    return b;
  39.860 +} // cDriverGU126X64D_K610A4::cmdSetMacro()
  39.861 +
  39.862 +//-----------------------------------------------------------------------------
  39.863 +int cDriverGU126X64D_K610A4::cmdSetPixel(bool fSet)
  39.864 +{
  39.865 +    int b = 0;
  39.866 +
  39.867 +    if (fSet)
  39.868 +    {
  39.869 +        ensureNotInGraphics();
  39.870 +
  39.871 +        if (isLogEnabled(LL_VFD_CMD))
  39.872 +        {
  39.873 +            syslog(LOG_INFO, "- 1B: SET_PIXEL        : 0x%02X", 0x16);
  39.874 +        } // if
  39.875 +
  39.876 +        b += write(CMD_PIXEL_SET);
  39.877 +    }
  39.878 +    else
  39.879 +    {
  39.880 +        b = cmdClrPixel();
  39.881 +    } // if
  39.882 +
  39.883 +    return b;
  39.884 +} // cDriverGU126X64D_K610A4::cmdSetPixel()
  39.885 +
  39.886 +//-----------------------------------------------------------------------------
  39.887 +int cDriverGU126X64D_K610A4::cmdClrPixel()
  39.888 +{
  39.889 +    ensureNotInGraphics();
  39.890 +    int b = 0;
  39.891 +
  39.892 +    if (isLogEnabled(LL_VFD_CMD))
  39.893 +    {
  39.894 +        syslog(LOG_INFO, "- 1B: CLR_PIXEL        : 0x%02X", 0x17);
  39.895 +    } // if
  39.896 +
  39.897 +    b += write(CMD_PIXEL_CLEAR);
  39.898 +
  39.899 +    return b;
  39.900 +} // cDriverGU126X64D_K610A4::cmdClrPixel()
  39.901 +
  39.902 +//-----------------------------------------------------------------------------
  39.903 +void cDriverGU126X64D_K610A4::ensureNotInGraphics()
  39.904 +{
  39.905 +    if (myClaimCounter <= 0)
  39.906 +    {
  39.907 +        syslog(LOG_ERR, "%s: ERROR: port not claimed (%d)", config->name.c_str(), myClaimCounter);
  39.908 +    } // if
  39.909 +
  39.910 +    if (myDataPendingCounter > 0)
  39.911 +    {
  39.912 +        syslog( LOG_WARNING, "%s error: expected another %d bytes graphic data, filling with 0x00"
  39.913 +              , config->name.c_str(), myDataPendingCounter
  39.914 +              );
  39.915 +    } // if
  39.916 +    while (myDataPendingCounter > 0)
  39.917 +    {
  39.918 +        cmdGraphicData(0);
  39.919 +    } // while
  39.920 +} // cDriverGU126X64D_K610A4::ensureNotInGraphics()
  39.921 +
  39.922 +
  39.923 +//-----------------------------------------------------------------------------
  39.924 +void cDriverGU126X64D_K610A4::claimPort()
  39.925 +{
  39.926 +    if (myClaimCounter == 0) 
  39.927 +    {
  39.928 +        port->Claim();
  39.929 +    } // if
  39.930 +
  39.931 +    myClaimCounter++;
  39.932 +
  39.933 +    if (myClaimCounter > 1)
  39.934 +    {
  39.935 +        syslog( LOG_WARNING, "%s: port claimed more than once (%d)"
  39.936 +              , config->name.c_str(), myClaimCounter
  39.937 +              );
  39.938 +    } // if
  39.939 +
  39.940 +} // cDriverGU126X64D_K610A4::claimPort()
  39.941 +
  39.942 +//-----------------------------------------------------------------------------
  39.943 +void cDriverGU126X64D_K610A4::releasePort()
  39.944 +{
  39.945 +    if (myClaimCounter == 1) 
  39.946 +    {
  39.947 +        port->Release();
  39.948 +    } // if
  39.949 +
  39.950 +    myClaimCounter--;
  39.951 +
  39.952 +    if (myClaimCounter < 0)
  39.953 +    {
  39.954 +        syslog( LOG_WARNING, "%s: port released more often than claimed"
  39.955 +              , config->name.c_str()
  39.956 +              );
  39.957 +        myClaimCounter = 0;
  39.958 +    } // if
  39.959 +
  39.960 +} // cDriverGU126X64D_K610A4::releasePort()
  39.961 +
  39.962 +//-----------------------------------------------------------------------------
  39.963 +bool cDriverGU126X64D_K610A4::isLogEnabled(int theLevel) const
  39.964 +{
  39.965 +    return (theLevel & myLogFlags) != 0;
  39.966 +} // cDriverGU126X64D_K610A4::isLogEnabled()
  39.967 +
  39.968 +//-----------------------------------------------------------------------------
  39.969 +} // end of namespace
  39.970 +
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/graphlcd-base/glcddrivers/gu126x64D-K610A4.h	Wed Feb 06 17:32:55 2008 +0000
    40.3 @@ -0,0 +1,130 @@
    40.4 +/*
    40.5 + * GraphLCD driver library
    40.6 + *
    40.7 + * gu126x64D-K610A4.h -  8-bit driver module for Noritake GU126x64D-K610A4 VFD
    40.8 + *                       displays. The VFD is operating in its 8 bit-mode
    40.9 + *                       connected to a single PC parallel port.
   40.10 + *
   40.11 + * based on:
   40.12 + *   gu256x64-372 driver module for graphlcd
   40.13 + *     (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
   40.14 + *   gu256x64-3900 driver module for graphlcd
   40.15 + *     (c) 2004 Ralf Mueller (ralf AT bj-ig.de)
   40.16 + *   gu140x32f driver module for graphlcd
   40.17 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   40.18 + *   ks0108 driver module for graphlcd
   40.19 + *     (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
   40.20 + *
   40.21 + * This file is released under the GNU General Public License. Refer
   40.22 + * to the COPYING file distributed with this package.
   40.23 + *
   40.24 + * (c) 2007 Alexander Rieger (Alexander.Rieger AT inka.de)
   40.25 + */
   40.26 +
   40.27 +#ifndef _GLCDDRIVERS_GU126X64D_K610A4_H_
   40.28 +#define _GLCDDRIVERS_GU126X64D_K610A4_H_
   40.29 +
   40.30 +#include "driver.h"
   40.31 +
   40.32 +//===============================================================================
   40.33 +//     namespace GLCD
   40.34 +//===============================================================================
   40.35 +namespace GLCD
   40.36 +{
   40.37 +
   40.38 +class cDriverConfig;
   40.39 +class cParallelPort;
   40.40 +
   40.41 +//===============================================================================
   40.42 +//     class cDriverGU126X64D_K610A4
   40.43 +//===============================================================================
   40.44 +class cDriverGU126X64D_K610A4 : public cDriver
   40.45 +{
   40.46 +public:
   40.47 +    //---------------------------------------------------------------------------
   40.48 +    //     constructor/destructor
   40.49 +    //---------------------------------------------------------------------------
   40.50 +    cDriverGU126X64D_K610A4(cDriverConfig * config);
   40.51 +    virtual ~cDriverGU126X64D_K610A4();
   40.52 +
   40.53 +    //---------------------------------------------------------------------------
   40.54 +    //     from cDriver
   40.55 +    //---------------------------------------------------------------------------
   40.56 +    virtual int Init();
   40.57 +    virtual int DeInit();
   40.58 +
   40.59 +    virtual void Clear();
   40.60 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   40.61 +    virtual void Refresh(bool refreshAll = false);
   40.62 +    virtual void SetBrightness(unsigned int percent);
   40.63 +
   40.64 +    //---------------------------------------------------------------------------
   40.65 +    //     display-specific enums/methods/etc.
   40.66 +    //---------------------------------------------------------------------------
   40.67 +    enum FontType
   40.68 +    {
   40.69 +        FONT_PROP_SML
   40.70 +    ,   FONT_FIX_MED
   40.71 +    ,   FONT_FIX_BIG
   40.72 +    };
   40.73 +
   40.74 +    void setPixel        (int x, int y);
   40.75 +
   40.76 +    int  cmdReset        ();
   40.77 +    int  cmdPower        (bool fOn);
   40.78 +    int  cmdLock         (bool fLock);
   40.79 +    int  cmdSetCursorPos (unsigned char x, unsigned char y);
   40.80 +    int  cmdGraphicWrite (unsigned char count);
   40.81 +    int  cmdGraphicData  (unsigned char data);
   40.82 +    int  cmdSetBrightness(unsigned int  percent);
   40.83 +    int  cmdSetFont      (FontType);
   40.84 +    int  cmdWriteText    (const char *theText);
   40.85 +    int  cmdDrawRect     (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2);
   40.86 +    int  cmdSetMacro     (unsigned char theMacroNum, unsigned char theCountBytes);
   40.87 +    int  cmdSetPixel     (bool fSet = true);
   40.88 +    int  cmdClrPixel     ();
   40.89 +
   40.90 +    void claimPort();
   40.91 +    void releasePort();
   40.92 +
   40.93 +private:
   40.94 +    //---------------------------------------------------------------------------
   40.95 +    //     helper methods
   40.96 +    //---------------------------------------------------------------------------
   40.97 +    void clearVFDMem();
   40.98 +    int  checkSetup();
   40.99 +    int  initParallelPort();
  40.100 +    void initDisplay();
  40.101 +
  40.102 +    bool waitForStatus(unsigned char theMask, unsigned char theValue, int theMaxWait);
  40.103 +    void writeParallel(unsigned char data);
  40.104 +    int  write(unsigned char data);
  40.105 +
  40.106 +    void ensureNotInGraphics();
  40.107 +    bool isLogEnabled(int theLevel) const;
  40.108 +
  40.109 +    //---------------------------------------------------------------------------
  40.110 +    //     attributes
  40.111 +    //---------------------------------------------------------------------------
  40.112 +    cParallelPort  *port;
  40.113 +
  40.114 +    cDriverConfig  *config;
  40.115 +    cDriverConfig  *oldConfig;
  40.116 +
  40.117 +    int             myNumRows;
  40.118 +    unsigned char **myDrawMem;
  40.119 +    unsigned char **myVFDMem;
  40.120 +
  40.121 +    bool            myUseSleepInit;
  40.122 +    long            myPortDelayNS;
  40.123 +    long            myDelay125NS;
  40.124 +    int             myRefreshCounter;
  40.125 +    int             myClaimCounter;
  40.126 +    int             myDataPendingCounter;
  40.127 +    unsigned int    myLogFlags;
  40.128 +
  40.129 +}; // class cDriverGU126X64D_K610A4
  40.130 +
  40.131 +} // namespace GLCD
  40.132 +
  40.133 +#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/graphlcd-base/glcddrivers/gu140x32f.c	Wed Feb 06 17:32:55 2008 +0000
    41.3 @@ -0,0 +1,443 @@
    41.4 +/*
    41.5 + * GraphLCD driver library
    41.6 + *
    41.7 + * gu140x32f.c  -  8-bit driver module for Noritake GU140x32-F7806 VFD
    41.8 + *                 displays. The VFD is operating in its 8 bit-mode
    41.9 + *                 connected to a single PC parallel port.
   41.10 + *
   41.11 + * based on:
   41.12 + *   HD61830 device
   41.13 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   41.14 + *   lcdproc 0.4 driver hd44780-ext8bit
   41.15 + *     (c) 1999, 1995 Benjamin Tse <blt AT Comports com>
   41.16 + *
   41.17 + * This file is released under the GNU General Public License. Refer
   41.18 + * to the COPYING file distributed with this package.
   41.19 + *
   41.20 + * (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   41.21 + */
   41.22 +
   41.23 +#include <errno.h>
   41.24 +#include <syslog.h>
   41.25 +#include <unistd.h>
   41.26 +#include <sys/time.h>
   41.27 +
   41.28 +#include "common.h"
   41.29 +#include "config.h"
   41.30 +#include "gu140x32f.h"
   41.31 +#include "port.h"
   41.32 +
   41.33 +
   41.34 +namespace GLCD
   41.35 +{
   41.36 +
   41.37 +// Defines for hd44780 Displays
   41.38 +#define RS_DAT      0x00
   41.39 +#define RS_CMD      0x01
   41.40 +
   41.41 +#define CLEAR       0x01
   41.42 +
   41.43 +#define HOMECURSOR  0x02
   41.44 +
   41.45 +#define ENTRYMODE   0x04
   41.46 +#define E_MOVERIGHT 0x02
   41.47 +#define E_MOVELEFT  0x00
   41.48 +#define EDGESCROLL  0x01
   41.49 +#define NOSCROLL    0x00
   41.50 +
   41.51 +#define ONOFFCTRL   0x08
   41.52 +#define DISPON      0x04
   41.53 +#define DISPOFF     0x00
   41.54 +#define CURSORON    0x02
   41.55 +#define CURSOROFF   0x00
   41.56 +#define CURSORBLINK 0x01
   41.57 +#define CURSORNOBLINK 0x00
   41.58 +
   41.59 +#define CURSORSHIFT 0x10
   41.60 +#define SCROLLDISP  0x08
   41.61 +#define MOVECURSOR  0x00
   41.62 +#define MOVERIGHT   0x04
   41.63 +#define MOVELEFT    0x00
   41.64 +
   41.65 +#define FUNCSET     0x20
   41.66 +#define IF_8BIT     0x10
   41.67 +#define IF_4BIT     0x00
   41.68 +
   41.69 +// Control output lines
   41.70 +// Write to baseaddress+2
   41.71 +#define nSTRB       0x01    // pin 1; negative logic
   41.72 +#define nLF         0x02    // pin 14
   41.73 +#define nINIT       0x04    // pin 16; the only positive logic output line
   41.74 +#define nSEL        0x08    // pin 17
   41.75 +#define ENIRQ       0x10    // Enable IRQ via ACK line (don't enable this withouT
   41.76 +                            // setting up interrupt stuff too)
   41.77 +#define ENBI        0x20    // Enable bi-directional port (is nice to play with!
   41.78 +                            // I first didn't know a SPP could do this)
   41.79 +
   41.80 +#define OUTMASK     0x0B    // SEL, LF and STRB are hardware inverted
   41.81 +                            // Use this mask only for the control output lines
   41.82 +                            // XOR with this mask ( ^ OUTMASK )
   41.83 +
   41.84 +static const std::string kWiringStandard = "Standard";
   41.85 +static const std::string kWiringWindows  = "Windows";
   41.86 +
   41.87 +// standard wiring
   41.88 +// #define RS        nSTRB
   41.89 +// #define RW        nLF
   41.90 +// #define EN1       nINIT
   41.91 +// #define BL        nSEL
   41.92 +
   41.93 +// windows wiring
   41.94 +// #define RS        nINIT
   41.95 +// #define RW        nLF
   41.96 +// #define EN1       nSTRB
   41.97 +// #define BL        nSEL
   41.98 +
   41.99 +
  41.100 +cDriverGU140X32F::cDriverGU140X32F(cDriverConfig * config)
  41.101 +:   config(config),
  41.102 +    m_pDrawMem(0),
  41.103 +    m_pVFDMem(0)
  41.104 +{
  41.105 +    oldConfig = new cDriverConfig(*config);
  41.106 +
  41.107 +    port = new cParallelPort();
  41.108 +
  41.109 +    m_nRefreshCounter = 0;
  41.110 +}
  41.111 +
  41.112 +cDriverGU140X32F::~cDriverGU140X32F()
  41.113 +{
  41.114 +    delete port;
  41.115 +    delete oldConfig;
  41.116 +}
  41.117 +
  41.118 +int cDriverGU140X32F::Init()
  41.119 +{
  41.120 +    int x;
  41.121 +    struct timeval tv1, tv2;
  41.122 +
  41.123 +    // default values
  41.124 +    width = config->width;
  41.125 +    if (width <= 0)
  41.126 +        width = 140;
  41.127 +    height = config->height;
  41.128 +    if (height <= 0)
  41.129 +        height = 32;
  41.130 +    m_iSizeYb = ((height + 7) / 8); // 4
  41.131 +    m_WiringRS = nSTRB;
  41.132 +    m_WiringEN1 = nINIT;
  41.133 +
  41.134 +    for (unsigned int i = 0; i < config->options.size(); i++)
  41.135 +    {
  41.136 +        if (config->options[i].name == "Wiring")
  41.137 +        {
  41.138 +            if (config->options[i].value == kWiringStandard)
  41.139 +            {
  41.140 +                m_WiringRS = nSTRB;
  41.141 +                m_WiringEN1 = nINIT;
  41.142 +            }
  41.143 +            else if (config->options[i].value == kWiringWindows)
  41.144 +            {
  41.145 +                m_WiringRS = nINIT;
  41.146 +                m_WiringEN1 = nSTRB;
  41.147 +            }
  41.148 +            else
  41.149 +                syslog(LOG_ERR, "%s error: wiring %s not supported, using default (Standard)!\n",
  41.150 +                       config->name.c_str(), config->options[i].value.c_str());
  41.151 +        }
  41.152 +    }
  41.153 +
  41.154 +    // setup the memory array for the drawing array gu140x32f
  41.155 +    m_pDrawMem = new unsigned char[width * m_iSizeYb];
  41.156 +    Clear();
  41.157 +
  41.158 +    // setup the memory array for the display array gu140x32f
  41.159 +    m_pVFDMem = new unsigned char[width * m_iSizeYb];
  41.160 +    ClearVFDMem();
  41.161 +
  41.162 +    if (config->device == "")
  41.163 +    {
  41.164 +        // use DirectIO
  41.165 +        if (port->Open(config->port) != 0)
  41.166 +            return -1;
  41.167 +        uSleep(10);
  41.168 +    }
  41.169 +    else
  41.170 +    {
  41.171 +        // use ppdev
  41.172 +        if (port->Open(config->device.c_str()) != 0)
  41.173 +            return -1;
  41.174 +    }
  41.175 +
  41.176 +    if (nSleepInit() != 0)
  41.177 +    {
  41.178 +        syslog(LOG_ERR, "%s: INFO: cannot change wait parameters  Err: %s (cDriver::Init)\n", config->name.c_str(), strerror(errno));
  41.179 +        m_bSleepIsInit = false;
  41.180 +    }
  41.181 +    else
  41.182 +    {
  41.183 +        m_bSleepIsInit = true;
  41.184 +    }
  41.185 +
  41.186 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  41.187 +    gettimeofday(&tv1, 0);
  41.188 +    for (x = 0; x < 10000; x++)
  41.189 +    {
  41.190 +        port->WriteData(x % 0x100);
  41.191 +    }
  41.192 +    gettimeofday(&tv2, 0);
  41.193 +    nSleepDeInit();
  41.194 +    m_nTimingAdjustCmd = ((tv2.tv_sec - tv1.tv_sec) * 10000 + (tv2.tv_usec - tv1.tv_usec)) / 1000;
  41.195 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Port Command: %ldns\n", config->name.c_str(), m_nTimingAdjustCmd);
  41.196 +
  41.197 +
  41.198 +    // setup the lcd in 8 bit mode
  41.199 +    Write(RS_CMD, FUNCSET | IF_8BIT, 4100);
  41.200 +    Write(RS_CMD, FUNCSET | IF_8BIT, 100);
  41.201 +    Write(RS_CMD, FUNCSET | IF_8BIT, 40);
  41.202 +
  41.203 +    Write(RS_CMD, ONOFFCTRL | DISPON | CURSOROFF | CURSORNOBLINK, 40);
  41.204 +    Write(RS_CMD, CLEAR, 1600);
  41.205 +    Write(RS_CMD, HOMECURSOR, 1600);
  41.206 +
  41.207 +    port->Release();
  41.208 +
  41.209 +    *oldConfig = *config;
  41.210 +
  41.211 +    // Set Display SetBrightness
  41.212 +    SetBrightness(config->brightness);
  41.213 +    // clear display
  41.214 +    ClearVFDMem();
  41.215 +    Clear();
  41.216 +
  41.217 +    syslog(LOG_INFO, "%s: gu140x32f initialized.\n", config->name.c_str());
  41.218 +    return 0;
  41.219 +}
  41.220 +
  41.221 +int cDriverGU140X32F::DeInit()
  41.222 +{
  41.223 +    if (m_pVFDMem)
  41.224 +        delete[] m_pVFDMem;
  41.225 +    if (m_pDrawMem)
  41.226 +        delete[] m_pDrawMem;
  41.227 +
  41.228 +    if (port->Close() != 0)
  41.229 +        return -1;
  41.230 +    return 0;
  41.231 +}
  41.232 +
  41.233 +int cDriverGU140X32F::CheckSetup()
  41.234 +{
  41.235 +    if (config->device != oldConfig->device ||
  41.236 +        config->port != oldConfig->port ||
  41.237 +        config->width != oldConfig->width ||
  41.238 +        config->height != oldConfig->height)
  41.239 +    {
  41.240 +        DeInit();
  41.241 +        Init();
  41.242 +        return 0;
  41.243 +    }
  41.244 +
  41.245 +    if (config->brightness != oldConfig->brightness)
  41.246 +    {
  41.247 +        oldConfig->brightness = config->brightness;
  41.248 +        SetBrightness(config->brightness);
  41.249 +    }
  41.250 +
  41.251 +    if (config->upsideDown != oldConfig->upsideDown ||
  41.252 +        config->invert != oldConfig->invert)
  41.253 +    {
  41.254 +        oldConfig->upsideDown = config->upsideDown;
  41.255 +        oldConfig->invert = config->invert;
  41.256 +        return 1;
  41.257 +    }
  41.258 +    return 0;
  41.259 +}
  41.260 +
  41.261 +void cDriverGU140X32F::ClearVFDMem()
  41.262 +{
  41.263 +    for (int n = 0; m_pVFDMem && n < (width * m_iSizeYb); n++)
  41.264 +        m_pVFDMem[n] = 0x00;
  41.265 +}
  41.266 +
  41.267 +void cDriverGU140X32F::Clear()
  41.268 +{
  41.269 +    for (int n = 0; m_pDrawMem && n < (width * m_iSizeYb); n++)
  41.270 +        m_pDrawMem[n] = 0x00;
  41.271 +}
  41.272 +
  41.273 +void cDriverGU140X32F::SetBrightness(unsigned int percent)
  41.274 +{
  41.275 +    port->Claim();
  41.276 +
  41.277 +    unsigned char level;
  41.278 +    if (percent > 100)
  41.279 +        percent = 100;
  41.280 +    level = percent / 25;
  41.281 +    if (level < 1)
  41.282 +        level = 1;
  41.283 +    level = (4 - level) & 0x03;
  41.284 +    // Set Brightness
  41.285 +    // 00 - 100%
  41.286 +    // 01 -  75%
  41.287 +    // 02 -  50%
  41.288 +    // 03 -  25%
  41.289 +    Write(RS_CMD, FUNCSET | IF_8BIT, 40);
  41.290 +    Write(RS_DAT, level, 40);
  41.291 +
  41.292 +    port->Release();
  41.293 +}
  41.294 +
  41.295 +void cDriverGU140X32F::Write(unsigned char nFlags, unsigned char bData, unsigned int nMicroSecBusyTime)
  41.296 +{
  41.297 +    if (m_bSleepIsInit)
  41.298 +        nSleepInit();
  41.299 +
  41.300 +    unsigned char enableLines = 0, portControl;
  41.301 +
  41.302 +    // Only one controller is supported
  41.303 +    enableLines = m_WiringEN1;
  41.304 +
  41.305 +    if (nFlags == RS_CMD)
  41.306 +        portControl = 0;
  41.307 +    else // if (nFlags == RS_DAT)
  41.308 +        portControl = m_WiringRS;
  41.309 +
  41.310 +    // portControl |= m_WiringBL;
  41.311 +
  41.312 +    port->WriteControl(portControl ^ OUTMASK);                  //Reset controlbits
  41.313 +    port->WriteData(bData);                                     //Set data
  41.314 +    port->WriteControl((enableLines | portControl) ^ OUTMASK);  //Set controlbits
  41.315 +
  41.316 +    // How long hold the data active
  41.317 +    if (m_bSleepIsInit && (25 + (100 * config->adjustTiming) - m_nTimingAdjustCmd > 0))
  41.318 +    {
  41.319 +        // Wait 50ns
  41.320 +        nSleep(std::max(25L, 50 + (100 * config->adjustTiming) - m_nTimingAdjustCmd));
  41.321 +    }
  41.322 +
  41.323 +    port->WriteControl(portControl ^ OUTMASK);                  //Reset controlbits
  41.324 +
  41.325 +    nSleep((nMicroSecBusyTime * 1000) + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  41.326 +
  41.327 +    if (m_bSleepIsInit)
  41.328 +        nSleepDeInit();
  41.329 +}
  41.330 +
  41.331 +void cDriverGU140X32F::SetPixel(int x, int y)
  41.332 +{
  41.333 +    unsigned char c;
  41.334 +    int n;
  41.335 +
  41.336 +    if (!m_pDrawMem)
  41.337 +        return;
  41.338 +
  41.339 +    if (x >= width || x < 0)
  41.340 +        return;
  41.341 +    if (y >= height || y < 0)
  41.342 +        return;
  41.343 +
  41.344 +    if (config->upsideDown)
  41.345 +    {
  41.346 +        x = width - 1 - x;
  41.347 +        y = height - 1 - y;
  41.348 +    }
  41.349 +
  41.350 +    n = x + ((y / 8) * width);
  41.351 +    c = 0x80 >> (y % 8);
  41.352 +
  41.353 +    m_pDrawMem[n] |= c;
  41.354 +}
  41.355 +
  41.356 +void cDriverGU140X32F::Set8Pixels(int x, int y, unsigned char data)
  41.357 +{
  41.358 +    int n;
  41.359 +
  41.360 +    // x - pos is'nt mayby align to 8
  41.361 +    x &= 0xFFF8;
  41.362 +
  41.363 +    for (n = 0; n < 8; ++n)
  41.364 +    {
  41.365 +        if (data & (0x80 >> n))      // if bit is set
  41.366 +            SetPixel(x + n, y);
  41.367 +    }
  41.368 +}
  41.369 +
  41.370 +void cDriverGU140X32F::Refresh(bool refreshAll)
  41.371 +{
  41.372 +    int n, x, yb;
  41.373 +
  41.374 +    if (!m_pVFDMem || !m_pDrawMem)
  41.375 +        return;
  41.376 +
  41.377 +    bool doRefresh = false;
  41.378 +    int minX = width;
  41.379 +    int maxX = 0;
  41.380 +    int minYb = m_iSizeYb;
  41.381 +    int maxYb = 0;
  41.382 +
  41.383 +    if (CheckSetup() > 0)
  41.384 +        refreshAll = true;
  41.385 +
  41.386 +    for (yb = 0; yb < m_iSizeYb; ++yb)
  41.387 +        for (x = 0; x < width; ++x)
  41.388 +        {
  41.389 +            n = x + (yb * width);
  41.390 +            if (m_pVFDMem[n] != m_pDrawMem[n])
  41.391 +            {
  41.392 +                m_pVFDMem[n] = m_pDrawMem[n];
  41.393 +                minX = std::min(minX, x);
  41.394 +                maxX = std::max(maxX, x);
  41.395 +                minYb = std::min(minYb, yb);
  41.396 +                maxYb = std::max(maxYb, yb + 1);
  41.397 +                doRefresh = true;
  41.398 +            }
  41.399 +        }
  41.400 +
  41.401 +    m_nRefreshCounter = (m_nRefreshCounter + 1) % config->refreshDisplay;
  41.402 +
  41.403 +    if (!refreshAll && !m_nRefreshCounter)
  41.404 +        refreshAll = true;
  41.405 +
  41.406 +    if (refreshAll || doRefresh)
  41.407 +    {
  41.408 +        if (refreshAll)
  41.409 +        {
  41.410 +            minX = 0;
  41.411 +            maxX = width;
  41.412 +            minYb = 0;
  41.413 +            maxYb = m_iSizeYb;
  41.414 +            // and reset RefreshCounter
  41.415 +            m_nRefreshCounter = 0;
  41.416 +        }
  41.417 +
  41.418 +        minX = std::max(minX, 0);
  41.419 +        maxX = std::min(maxX, width - 1);
  41.420 +        minYb = std::max(minYb, 0);
  41.421 +        maxYb = std::min(maxYb, m_iSizeYb);
  41.422 +
  41.423 +        port->Claim();
  41.424 +        // send lcd data to display, controller
  41.425 +        Write(RS_CMD, 0xF1, 40);
  41.426 +        Write(RS_DAT, minX, 40);
  41.427 +        Write(RS_DAT, (minYb * 8) & 0xFFF8, 40);
  41.428 +        Write(RS_DAT, maxX, 40);
  41.429 +        Write(RS_DAT, (maxYb * 8), 40);
  41.430 +
  41.431 +        Write(RS_DAT, 'v', 500);
  41.432 +
  41.433 +        for (yb = minYb; yb <= maxYb; ++yb)
  41.434 +            for (x = minX; x <= maxX; ++x)
  41.435 +            {
  41.436 +                n = x + (yb * width);
  41.437 +
  41.438 +                if (n >= (width * m_iSizeYb))
  41.439 +                    break;
  41.440 +                Write(RS_DAT, (m_pVFDMem[n]) ^ (config->invert ? 0xff : 0x00), 40);
  41.441 +            }
  41.442 +        port->Release();
  41.443 +    }
  41.444 +}
  41.445 +
  41.446 +} // end of namespace
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/graphlcd-base/glcddrivers/gu140x32f.h	Wed Feb 06 17:32:55 2008 +0000
    42.3 @@ -0,0 +1,73 @@
    42.4 +/*
    42.5 + * GraphLCD driver library
    42.6 + *
    42.7 + * gu140x32f.h  -  8-bit driver module for Noritake GU140x32-F7806 VFD
    42.8 + *                 displays. The VFD is operating in its 8 bit-mode
    42.9 + *                 connected to a single PC parallel port.
   42.10 + *
   42.11 + * based on:
   42.12 + *   HD61830 device
   42.13 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   42.14 + *   lcdproc 0.4 driver hd44780-ext8bit
   42.15 + *     (c) 1999, 1995 Benjamin Tse <blt AT Comports com>
   42.16 + *
   42.17 + * This file is released under the GNU General Public License. Refer
   42.18 + * to the COPYING file distributed with this package.
   42.19 + *
   42.20 + * (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   42.21 + */
   42.22 +
   42.23 +#ifndef _GLCDDRIVERS_GU140X32F_H_
   42.24 +#define _GLCDDRIVERS_GU140X32F_H_
   42.25 +
   42.26 +#include "driver.h"
   42.27 +
   42.28 +
   42.29 +namespace GLCD
   42.30 +{
   42.31 +
   42.32 +class cDriverConfig;
   42.33 +class cParallelPort;
   42.34 +
   42.35 +
   42.36 +class cDriverGU140X32F : public cDriver
   42.37 +{
   42.38 +    unsigned char m_WiringRS;
   42.39 +    unsigned char m_WiringEN1;
   42.40 +
   42.41 +    cParallelPort * port;
   42.42 +
   42.43 +    cDriverConfig * config;
   42.44 +    cDriverConfig * oldConfig;
   42.45 +
   42.46 +    int m_iSizeYb;
   42.47 +    int m_nRefreshCounter;
   42.48 +    unsigned char *m_pDrawMem; // the draw "memory"
   42.49 +    unsigned char *m_pVFDMem;  // the double buffed display "memory"
   42.50 +    long m_nTimingAdjustCmd;
   42.51 +    bool m_bSleepIsInit;
   42.52 +
   42.53 +    int CheckSetup();
   42.54 +
   42.55 +protected:
   42.56 +    void ClearVFDMem();
   42.57 +    void SetPixel(int x, int y);
   42.58 +    void Write(unsigned char nFlags, unsigned char bData, unsigned int nMicroSecBusyTime);
   42.59 +
   42.60 +public:
   42.61 +    cDriverGU140X32F(cDriverConfig * config);
   42.62 +    virtual ~cDriverGU140X32F();
   42.63 +
   42.64 +    virtual int Init();
   42.65 +    virtual int DeInit();
   42.66 +
   42.67 +    virtual void Clear();
   42.68 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   42.69 +    virtual void Refresh(bool refreshAll = false);
   42.70 +
   42.71 +    virtual void SetBrightness(unsigned int percent);
   42.72 +};
   42.73 +
   42.74 +} // end of namespace
   42.75 +
   42.76 +#endif
    43.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    43.2 +++ b/graphlcd-base/glcddrivers/gu256x64-372.c	Wed Feb 06 17:32:55 2008 +0000
    43.3 @@ -0,0 +1,408 @@
    43.4 +/*
    43.5 + * GraphLCD driver library
    43.6 + *
    43.7 + * gu256x64-372.c  -  8-bit driver module for Noritake GU256x64-372
    43.8 + *                    VFD displays. The VFD is operating in its 8-bit
    43.9 + *                    mode connected to a single PC parallel port.
   43.10 + *
   43.11 + * based on:
   43.12 + *   gu256x32f driver module for graphlcd
   43.13 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   43.14 + *   HD61830 device
   43.15 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   43.16 + *   lcdproc 0.4 driver hd44780-ext8bit
   43.17 + *     (c) 1999, 1995 Benjamin Tse <blt AT comports.com>
   43.18 + *
   43.19 + * This file is released under the GNU General Public License. Refer
   43.20 + * to the COPYING file distributed with this package.
   43.21 + *
   43.22 + * (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
   43.23 + */
   43.24 +
   43.25 +#include <errno.h>
   43.26 +#include <syslog.h>
   43.27 +#include <unistd.h>
   43.28 +#include <sys/time.h>
   43.29 +
   43.30 +#include "common.h"
   43.31 +#include "config.h"
   43.32 +#include "gu256x64-372.h"
   43.33 +#include "port.h"
   43.34 +
   43.35 +
   43.36 +namespace GLCD
   43.37 +{
   43.38 +
   43.39 +#define SCREENSOFF      0x00 // both screens are off
   43.40 +#define SCREEN1ON       0x01 // only screen #1 is on (graphic screen)
   43.41 +#define SCREEN2ON       0x02 // only screen #2 is on (graphic/character screen)
   43.42 +#define SCREENSON       0x03 // both screens are on
   43.43 +
   43.44 +#define CURS_AUTOINC    0x04 // cursor increments automatically
   43.45 +#define CURS_HOLD       0x05 // cursor holds
   43.46 +
   43.47 +#define SCREEN2CHAR     0x06 // screen #2 sets to "character" display
   43.48 +#define SCREEN2GRAPH    0x07 // screen #2 sets to "graphic" display
   43.49 +
   43.50 +#define DATA_WRITE      0x08 // data write mode
   43.51 +#define DATA_READ       0x09 // data read mode
   43.52 +
   43.53 +#define DISP_LOSTA1     0x0A // lower addr. of display start of screen #1
   43.54 +#define DISP_HISTA1     0x0B // upper addr. of display start of screen #1
   43.55 +#define DISP_LOSTA2     0x0C // lower addr. of display start of screen #2
   43.56 +#define DISP_HISTA2     0x0D // upper addr. of display start of screen #2
   43.57 +#define CURS_LOADDR     0x0E // lower addr. of cursor of screen #1 & #2
   43.58 +#define CURS_HIADDR     0x0F // upper addr. of cursor start of screen #1 & #2
   43.59 +
   43.60 +#define DISP_OR         0x10 // or display of screen #1 & #2
   43.61 +#define DISP_EXOR       0x11 // ex-or display of screen #1 & #2
   43.62 +#define DISP_AND        0x12 // and display of screen #1 & #2
   43.63 +
   43.64 +#define BRIGHT_1        0x18 // luminance level 1 100.0%
   43.65 +#define BRIGHT_2        0x19 // luminance level 2  87.5%
   43.66 +#define BRIGHT_3        0x1A // luminance level 3  75.0%
   43.67 +#define BRIGHT_4        0x1B // luminance level 4  62.5%
   43.68 +
   43.69 +#define WRHI            0x04  // INIT
   43.70 +#define WRLO            0x00
   43.71 +#define CDHI            0x00 // nSEL
   43.72 +#define CDLO            0x08
   43.73 +
   43.74 +
   43.75 +cDriverGU256X64_372::cDriverGU256X64_372(cDriverConfig * config)
   43.76 +:   config(config)
   43.77 +{
   43.78 +    oldConfig = new cDriverConfig(*config);
   43.79 +
   43.80 +    port = new cParallelPort();
   43.81 +
   43.82 +    m_nRefreshCounter = 0;
   43.83 +}
   43.84 +
   43.85 +cDriverGU256X64_372::~cDriverGU256X64_372()
   43.86 +{
   43.87 +    delete oldConfig;
   43.88 +    delete port;
   43.89 +}
   43.90 +
   43.91 +int cDriverGU256X64_372::Init()
   43.92 +{
   43.93 +    int x;
   43.94 +    struct timeval tv1, tv2;
   43.95 +
   43.96 +    width = config->width;
   43.97 +    if (width <= 0)
   43.98 +        width = 256;
   43.99 +    height = config->height;
  43.100 +    if (height <= 0)
  43.101 +        height = 64;
  43.102 +    m_iSizeYb = (height + 7) / 8;
  43.103 +
  43.104 +    for (unsigned int i = 0; i < config->options.size(); i++)
  43.105 +    {
  43.106 +        if (config->options[i].name == "")
  43.107 +        {
  43.108 +        }
  43.109 +    }
  43.110 +
  43.111 +    // setup linear lcd array
  43.112 +    m_pDrawMem = new unsigned char *[width];
  43.113 +    if (m_pDrawMem)
  43.114 +    {
  43.115 +        for (x = 0; x < width; x++)
  43.116 +        {
  43.117 +            m_pDrawMem[x] = new unsigned char[m_iSizeYb];
  43.118 +            memset(m_pDrawMem[x], 0, m_iSizeYb);
  43.119 +        }
  43.120 +    }
  43.121 +    Clear();
  43.122 +
  43.123 +    // setup the lcd array for the "vertical" mem
  43.124 +    m_pVFDMem = new unsigned char *[width];
  43.125 +    if (m_pVFDMem)
  43.126 +    {
  43.127 +        for (x = 0; x < width; x++)
  43.128 +        {
  43.129 +            m_pVFDMem[x] = new unsigned char[m_iSizeYb];
  43.130 +            memset(m_pVFDMem[x], 0, m_iSizeYb);
  43.131 +        }
  43.132 +    }
  43.133 +    ClearVFDMem();
  43.134 +
  43.135 +    if (config->device == "")
  43.136 +    {
  43.137 +        // use DirectIO
  43.138 +        if (port->Open(config->port) != 0)
  43.139 +            return -1;
  43.140 +        uSleep(10);
  43.141 +    }
  43.142 +    else
  43.143 +    {
  43.144 +        // use ppdev
  43.145 +        if (port->Open(config->device.c_str()) != 0)
  43.146 +            return -1;
  43.147 +    }
  43.148 +
  43.149 +    if (nSleepInit() != 0)
  43.150 +    {
  43.151 +        syslog(LOG_ERR, "%s: INFO: cannot change wait parameters  Err: %s (cDriver::Init)\n", config->name.c_str(), strerror(errno));
  43.152 +        m_bSleepIsInit = false;
  43.153 +    }
  43.154 +    else
  43.155 +    {
  43.156 +        m_bSleepIsInit = true;
  43.157 +    }
  43.158 +
  43.159 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  43.160 +    gettimeofday(&tv1, 0);
  43.161 +    for (x = 0; x < 10000; x++)
  43.162 +    {
  43.163 +        port->WriteData(x % 0x100);
  43.164 +    }
  43.165 +    gettimeofday(&tv2, 0);
  43.166 +    nSleepDeInit();
  43.167 +    m_nTimingAdjustCmd = ((tv2.tv_sec - tv1.tv_sec) * 10000 + (tv2.tv_usec - tv1.tv_usec)) / 1000;
  43.168 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Port Command: %ldns\n", config->name.c_str(), m_nTimingAdjustCmd);
  43.169 +
  43.170 +    GU256X64Cmd(SCREEN1ON);
  43.171 +    GU256X64Cmd(CURS_AUTOINC);
  43.172 +    GU256X64Cmd(SCREEN2CHAR);
  43.173 +
  43.174 +    GU256X64Cmd(DISP_LOSTA1); GU256X64Data(0x00);
  43.175 +    GU256X64Cmd(DISP_HISTA1); GU256X64Data(0x00);
  43.176 +    GU256X64Cmd(DISP_LOSTA2); GU256X64Data(0x00);
  43.177 +    GU256X64Cmd(DISP_HISTA2); GU256X64Data(0x10);
  43.178 +    GU256X64Cmd(CURS_LOADDR); GU256X64Data(0x00);
  43.179 +    GU256X64Cmd(CURS_HIADDR); GU256X64Data(0x00);
  43.180 +
  43.181 +    GU256X64Cmd(DISP_OR);
  43.182 +
  43.183 +    port->Release();
  43.184 +
  43.185 +    *oldConfig = *config;
  43.186 +
  43.187 +    // Set Display SetBrightness
  43.188 +    SetBrightness(config->brightness);
  43.189 +    // clear display
  43.190 +    Clear();
  43.191 +    ClearVFDMem();
  43.192 +
  43.193 +    syslog(LOG_INFO, "%s: gu256x64-372 initialized.\n", config->name.c_str());
  43.194 +    return 0;
  43.195 +}
  43.196 +
  43.197 +int cDriverGU256X64_372::DeInit()
  43.198 +{
  43.199 +    int x;
  43.200 +
  43.201 +    if (m_pVFDMem)
  43.202 +        for (x = 0; x < width; x++)
  43.203 +        {
  43.204 +            delete[] m_pVFDMem[x];
  43.205 +        }
  43.206 +    delete[] m_pVFDMem;
  43.207 +
  43.208 +    if (m_pDrawMem)
  43.209 +        for (x = 0; x < width; x++)
  43.210 +        {
  43.211 +            delete[] m_pDrawMem[x];
  43.212 +        }
  43.213 +    delete[] m_pDrawMem;
  43.214 +
  43.215 +    if (port->Close() != 0)
  43.216 +        return -1;
  43.217 +    return 0;
  43.218 +}
  43.219 +
  43.220 +int cDriverGU256X64_372::CheckSetup()
  43.221 +{
  43.222 +    if (config->device != oldConfig->device ||
  43.223 +        config->port != oldConfig->port ||
  43.224 +        config->width != oldConfig->width ||
  43.225 +        config->height != oldConfig->height)
  43.226 +    {
  43.227 +        DeInit();
  43.228 +        Init();
  43.229 +        return 0;
  43.230 +    }
  43.231 +
  43.232 +    if (config->brightness != oldConfig->brightness)
  43.233 +    {
  43.234 +        oldConfig->brightness = config->brightness;
  43.235 +        SetBrightness(config->brightness);
  43.236 +    }
  43.237 +    if (config->upsideDown != oldConfig->upsideDown ||
  43.238 +        config->invert != oldConfig->invert)
  43.239 +    {
  43.240 +        oldConfig->upsideDown = config->upsideDown;
  43.241 +        oldConfig->invert = config->invert;
  43.242 +        return 1;
  43.243 +    }
  43.244 +    return 0;
  43.245 +}
  43.246 +
  43.247 +void cDriverGU256X64_372::ClearVFDMem()
  43.248 +{
  43.249 +    for (int x = 0; x < width; x++)
  43.250 +        memset(m_pVFDMem[x], 0, m_iSizeYb);
  43.251 +}
  43.252 +
  43.253 +void cDriverGU256X64_372::Clear()
  43.254 +{
  43.255 +    for (int x = 0; x < width; x++)
  43.256 +        memset(m_pDrawMem[x], 0, m_iSizeYb);
  43.257 +}
  43.258 +
  43.259 +void cDriverGU256X64_372::SetBrightness(unsigned int percent)
  43.260 +{
  43.261 +    port->Claim();
  43.262 +
  43.263 +    if (percent > 88) {
  43.264 +        GU256X64Cmd(BRIGHT_1);
  43.265 +    } else if (percent > 75) {
  43.266 +        GU256X64Cmd(BRIGHT_2);
  43.267 +    } else if (percent > 66) {
  43.268 +        GU256X64Cmd(BRIGHT_3);
  43.269 +    } else if (percent > 0 ) {
  43.270 +        GU256X64Cmd(BRIGHT_4);
  43.271 +    } else {
  43.272 +        GU256X64Cmd(SCREENSOFF);
  43.273 +    }
  43.274 +    port->Release();
  43.275 +}
  43.276 +
  43.277 +void cDriverGU256X64_372::GU256X64Cmd(unsigned char data)
  43.278 +{
  43.279 +    if (m_bSleepIsInit)
  43.280 +        nSleepInit();
  43.281 +
  43.282 +    port->WriteControl(CDHI | WRHI);
  43.283 +    port->WriteData(data);
  43.284 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  43.285 +    port->WriteControl(CDHI | WRLO);
  43.286 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  43.287 +    port->WriteControl(CDHI | WRHI);
  43.288 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  43.289 +}
  43.290 +
  43.291 +void cDriverGU256X64_372::GU256X64Data(unsigned char data)
  43.292 +{
  43.293 +    if (m_bSleepIsInit)
  43.294 +        nSleepInit();
  43.295 +
  43.296 +    port->WriteControl(CDLO | WRHI);
  43.297 +    port->WriteData(data);
  43.298 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  43.299 +    port->WriteControl(CDLO | WRLO);
  43.300 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  43.301 +    port->WriteControl(CDLO | WRHI);
  43.302 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  43.303 +}
  43.304 +
  43.305 +void cDriverGU256X64_372::SetPixel(int x, int y)
  43.306 +{
  43.307 +    unsigned char c;
  43.308 +
  43.309 +    if (!m_pDrawMem)
  43.310 +        return;
  43.311 +
  43.312 +    if (x >= width || x < 0)
  43.313 +        return;
  43.314 +    if (y >= height || y < 0)
  43.315 +        return;
  43.316 +
  43.317 +    if (config->upsideDown)
  43.318 +    {
  43.319 +        x = width - 1 - x;
  43.320 +        y = height - 1 - y;
  43.321 +    }
  43.322 +
  43.323 +    c = 0x80 >> (y % 8);
  43.324 +
  43.325 +    m_pDrawMem[x][y/8] = m_pDrawMem[x][y/8] | c;
  43.326 +}
  43.327 +
  43.328 +void cDriverGU256X64_372::Set8Pixels(int x, int y, unsigned char data)
  43.329 +{
  43.330 +    int n;
  43.331 +
  43.332 +    // x - pos is'nt mayby align to 8
  43.333 +    x &= 0xFFF8;
  43.334 +
  43.335 +    for (n = 0; n < 8; ++n)
  43.336 +    {
  43.337 +        if (data & (0x80 >> n)) // if bit is set
  43.338 +            SetPixel(x + n, y);
  43.339 +    }
  43.340 +}
  43.341 +
  43.342 +void cDriverGU256X64_372::Refresh(bool refreshAll)
  43.343 +{
  43.344 +    int xb, yb;
  43.345 +
  43.346 +    if (!m_pVFDMem || !m_pDrawMem)
  43.347 +        return;
  43.348 +
  43.349 +    bool doRefresh = false;
  43.350 +    int minX = width;
  43.351 +    int maxX = 0;
  43.352 +    int minYb = m_iSizeYb;
  43.353 +    int maxYb = 0;
  43.354 +
  43.355 +    if (CheckSetup() > 0)
  43.356 +        refreshAll = true;
  43.357 +
  43.358 +    for (xb = 0; xb < width; ++xb)
  43.359 +    {
  43.360 +        for (yb = 0; yb < m_iSizeYb; ++yb)
  43.361 +        {
  43.362 +            if (m_pVFDMem[xb][yb] != m_pDrawMem[xb][yb])
  43.363 +            {
  43.364 +                m_pVFDMem[xb][yb] = m_pDrawMem[xb][yb];
  43.365 +                minX = std::min(minX, xb);
  43.366 +                maxX = std::max(maxX, xb);
  43.367 +                minYb = std::min(minYb, yb);
  43.368 +                maxYb = std::max(maxYb, yb + 1);
  43.369 +                doRefresh = true;
  43.370 +            }
  43.371 +        }
  43.372 +    }
  43.373 +
  43.374 +    m_nRefreshCounter = (m_nRefreshCounter + 1) % config->refreshDisplay;
  43.375 +    if (!refreshAll && !m_nRefreshCounter)
  43.376 +        refreshAll = true;
  43.377 +
  43.378 +    if (refreshAll || doRefresh)
  43.379 +    {
  43.380 +        if (refreshAll) {
  43.381 +            minX = 0;
  43.382 +            maxX = width;
  43.383 +            minYb = 0;
  43.384 +            maxYb = m_iSizeYb;
  43.385 +            // and reset RefreshCounter
  43.386 +            m_nRefreshCounter = 0;
  43.387 +        }
  43.388 +
  43.389 +        minX = std::max(minX, 0);
  43.390 +        maxX = std::min(maxX, width - 1);
  43.391 +        minYb = std::max(minYb, 0);
  43.392 +        maxYb = std::min(maxYb, m_iSizeYb);
  43.393 +
  43.394 +        port->Claim();
  43.395 +
  43.396 +        GU256X64Cmd(CURS_LOADDR); GU256X64Data(0x00);
  43.397 +        GU256X64Cmd(CURS_HIADDR); GU256X64Data(0x00);
  43.398 +        GU256X64Cmd(DATA_WRITE);
  43.399 +
  43.400 +        for (xb = 0; xb < width; xb++)
  43.401 +        {
  43.402 +            for (yb = 0; yb < m_iSizeYb; yb++)
  43.403 +            {
  43.404 +                GU256X64Data((m_pVFDMem[xb][yb]) ^ (config->invert ? 0xff : 0x00));
  43.405 +            }
  43.406 +        }
  43.407 +        port->Release();
  43.408 +    }
  43.409 +}
  43.410 +
  43.411 +} // end of namespace
    44.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    44.2 +++ b/graphlcd-base/glcddrivers/gu256x64-372.h	Wed Feb 06 17:32:55 2008 +0000
    44.3 @@ -0,0 +1,73 @@
    44.4 +/*
    44.5 + * GraphLCD driver library
    44.6 + *
    44.7 + * gu256x64-372.h  -  8-bit driver module for Noritake GU256x64-372
    44.8 + *                    VFD displays. The VFD is operating in its 8-bit
    44.9 + *                    mode connected to a single PC parallel port.
   44.10 + *
   44.11 + * based on:
   44.12 + *   gu256x32f driver module for graphlcd
   44.13 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   44.14 + *   HD61830 device
   44.15 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   44.16 + *   lcdproc 0.4 driver hd44780-ext8bit
   44.17 + *     (c) 1999, 1995 Benjamin Tse <blt AT comports.com>
   44.18 + *
   44.19 + * This file is released under the GNU General Public License. Refer
   44.20 + * to the COPYING file distributed with this package.
   44.21 + *
   44.22 + * (c) 2004 Andreas 'randy' Weinberger (randy AT smue.org)
   44.23 + */
   44.24 +
   44.25 +#ifndef _GLCDDRIVERS_GU256X64_372_H_
   44.26 +#define _GLCDDRIVERS_GU256X64_372_H_
   44.27 +
   44.28 +#include "driver.h"
   44.29 +
   44.30 +namespace GLCD
   44.31 +{
   44.32 +
   44.33 +class cDriverConfig;
   44.34 +class cParallelPort;
   44.35 +
   44.36 +class cDriverGU256X64_372 : public cDriver
   44.37 +{
   44.38 +    cParallelPort * port;
   44.39 +
   44.40 +    cDriverConfig * config;
   44.41 +    cDriverConfig * oldConfig;
   44.42 +
   44.43 +    int m_iSizeYb;
   44.44 +    int m_nRefreshCounter;
   44.45 +
   44.46 +    unsigned char ** m_pDrawMem; // the draw "memory"
   44.47 +    unsigned char ** m_pVFDMem; // the double buffed display "memory"
   44.48 +
   44.49 +    long m_nTimingAdjustCmd;
   44.50 +    bool m_bSleepIsInit;
   44.51 +
   44.52 +    int CheckSetup();
   44.53 +
   44.54 +protected:
   44.55 +    void ClearVFDMem();
   44.56 +    void SetPixel(int x, int y);
   44.57 +    void GU256X64Cmd(unsigned char data);
   44.58 +    void GU256X64Data(unsigned char data);
   44.59 +
   44.60 +public:
   44.61 +    cDriverGU256X64_372(cDriverConfig * config);
   44.62 +    virtual ~cDriverGU256X64_372();
   44.63 +
   44.64 +    virtual int Init();
   44.65 +    virtual int DeInit();
   44.66 +
   44.67 +    virtual void Clear();
   44.68 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   44.69 +    virtual void Refresh(bool refreshAll = false);
   44.70 +
   44.71 +    virtual void SetBrightness(unsigned int percent);
   44.72 +};
   44.73 +
   44.74 +} // end of namespace
   44.75 +
   44.76 +#endif
    45.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    45.2 +++ b/graphlcd-base/glcddrivers/gu256x64-3900.c	Wed Feb 06 17:32:55 2008 +0000
    45.3 @@ -0,0 +1,651 @@
    45.4 +/*
    45.5 + * GraphLCD driver library
    45.6 + *
    45.7 + * gu256x64-3900.c  -  8-bit driver module for Noritake GU256X64x-3900
    45.8 + *                     VFD displays. The VFD is either operating in
    45.9 + *                     8-bit mode connected to a single PC parallel
   45.10 + *                     port or in serial mode connected to a single PC
   45.11 + *                     serial port.
   45.12 + *
   45.13 + * based on:
   45.14 + *   gu256x64-372 driver module for graphlcd
   45.15 + *     (c) 2004 Andreas 'randy' Weinberger <randy AT smue.org>
   45.16 + *   gu256x32f driver module for graphlcd
   45.17 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   45.18 + *   HD61830 device
   45.19 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   45.20 + *   lcdproc 0.4 driver hd44780-ext8bit
   45.21 + *     (c) 1999, 1995 Benjamin Tse <blt AT comports.com>
   45.22 + *
   45.23 + * This file is released under the GNU General Public License. Refer
   45.24 + * to the COPYING file distributed with this package.
   45.25 + *
   45.26 + * (c) 2004 Ralf Mueller (ralf AT bj-ig.de)
   45.27 + */
   45.28 +
   45.29 +#include <errno.h>
   45.30 +#include <fcntl.h>
   45.31 +#include <syslog.h>
   45.32 +#include <unistd.h>
   45.33 +#include <termios.h>
   45.34 +#include <sys/time.h>
   45.35 +
   45.36 +#include "common.h"
   45.37 +#include "config.h"
   45.38 +#include "gu256x64-3900.h"
   45.39 +#include "port.h"
   45.40 +
   45.41 +
   45.42 +namespace GLCD
   45.43 +{
   45.44 +
   45.45 +static const unsigned char dSETSTART0      = 0x02;    // Set display start address (CMD prefix)
   45.46 +static const unsigned char dSETSTART1      = 0x44;    // Set display start address (CMD)
   45.47 +static const unsigned char dSETSTART2      = 0x00;    // Set display start address
   45.48 +static const unsigned char dSETSTART3      = 0x53;    // Set display start address
   45.49 +
   45.50 +static const unsigned char nINITDISPLAY0   = 0x1b;    // Initialize display (CMD prefix)
   45.51 +static const unsigned char nINITDISPLAY1   = 0x40;    // Initialize display (CMD)
   45.52 +
   45.53 +static const unsigned char nPOWER0         = 0x1f;    // Power on/off
   45.54 +static const unsigned char nPOWER1         = 0x28;    // Power on/off
   45.55 +static const unsigned char nPOWER2         = 0x61;    // Power on/off
   45.56 +static const unsigned char nPOWER3         = 0x40;    // Power on/off
   45.57 +
   45.58 +static const unsigned char nSETBRIGHT0     = 0x1f;    // Set brightness (CMD prefix)
   45.59 +static const unsigned char nSETBRIGHT1     = 0x58;    // Set brightness (CMD)
   45.60 +
   45.61 +static const unsigned char dSETBRIGHT0     = 0x02;    // Set brightness (CMD prefix)
   45.62 +static const unsigned char dSETBRIGHT1     = 0x44;    // Set brightness (CMD)
   45.63 +static const unsigned char dSETBRIGHT2     = 0x00;    // Set brightness
   45.64 +static const unsigned char dSETBRIGHT3     = 0x58;    // Set brightness
   45.65 +
   45.66 +static const unsigned char BRIGHT_000      = 0x10;    // Brightness 0%
   45.67 +static const unsigned char BRIGHT_012      = 0x11;    // Brightness 12.5%
   45.68 +static const unsigned char BRIGHT_025      = 0x12;    // Brightness 25%
   45.69 +static const unsigned char BRIGHT_037      = 0x13;    // Brightness 37.5%
   45.70 +static const unsigned char BRIGHT_050      = 0x14;    // Brightness 50%
   45.71 +static const unsigned char BRIGHT_062      = 0x15;    // Brightness 62.5%
   45.72 +static const unsigned char BRIGHT_075      = 0x16;    // Brightness 75%
   45.73 +static const unsigned char BRIGHT_087      = 0x17;    // Brightness 87.5%
   45.74 +static const unsigned char BRIGHT_100      = 0x18;    // Brightness 100%
   45.75 +
   45.76 +static const unsigned char nSETCURSOR0     = 0x1f;    // Set cursor (CMD prefix)
   45.77 +static const unsigned char nSETCURSOR1     = 0x24;    // Set cursor (CMD)
   45.78 +
   45.79 +static const unsigned char nDISPLAYCURSOR0 = 0x1f;    // display cursor
   45.80 +static const unsigned char nDISPLAYCURSOR1 = 0x43;    // display cursor
   45.81 +
   45.82 +static const unsigned char nBLITIMAGE0     = 0x1f;    // Display image
   45.83 +static const unsigned char nBLITIMAGE1     = 0x28;    // Display image
   45.84 +static const unsigned char nBLITIMAGE2     = 0x66;    // Display image
   45.85 +static const unsigned char nBLITIMAGE3     = 0x11;    // Display image
   45.86 +
   45.87 +static const unsigned char dBLITIMAGE0     = 0x02;    // Image write
   45.88 +static const unsigned char dBLITIMAGE1     = 0x44;    // Image write
   45.89 +static const unsigned char dBLITIMAGE2     = 0x00;    // Image write
   45.90 +static const unsigned char dBLITIMAGE3     = 0x46;    // Image write
   45.91 +
   45.92 +
   45.93 +static const unsigned char WRHI            = 0x0f;    // any control pin to high
   45.94 +static const unsigned char WRLO            = 0x00;
   45.95 +static const unsigned char RDYHI           = 0x40;    // RDY
   45.96 +static const unsigned char RDYHIALT        = 0x80;    // RDY satyr wiring
   45.97 +static const unsigned char RDYLO           = 0x00;
   45.98 +
   45.99 +static const std::string kWiringStandard = "Standard";
  45.100 +static const std::string kWiringSatyr    = "Satyr";
  45.101 +
  45.102 +static const int kInterfaceParallel = 0; // parallel mode
  45.103 +static const int kInterfaceSerial   = 1; // serial mode
  45.104 +
  45.105 +
  45.106 +cDriverGU256X64_3900::cDriverGU256X64_3900(cDriverConfig * config)
  45.107 +:   config(config)
  45.108 +{
  45.109 +    oldConfig = new cDriverConfig(*config);
  45.110 +
  45.111 +    portFd = -1;
  45.112 +    m_nRefreshCounter = 0;
  45.113 +}
  45.114 +
  45.115 +cDriverGU256X64_3900::~cDriverGU256X64_3900()
  45.116 +{
  45.117 +    delete oldConfig;
  45.118 +}
  45.119 +
  45.120 +int cDriverGU256X64_3900::Init()
  45.121 +{
  45.122 +    int x;
  45.123 +
  45.124 +    width = config->width;
  45.125 +    if (width <= 0)
  45.126 +        width = 256;
  45.127 +    height = config->height;
  45.128 +    if (height <= 0)
  45.129 +        height = 64;
  45.130 +    m_iSizeYb = ((height + 7) / 8);
  45.131 +
  45.132 +    // default values
  45.133 +    readyMask = RDYHI;
  45.134 +    readyHi = RDYHI;
  45.135 +    interface = kInterfaceParallel;
  45.136 +    useDMA = true;
  45.137 +
  45.138 +    for (unsigned int i = 0; i < config->options.size(); i++)
  45.139 +    {
  45.140 +        if (config->options[i].name == "Wiring")
  45.141 +        {
  45.142 +            if (config->options[i].value == kWiringStandard)
  45.143 +            {
  45.144 +                readyMask = RDYHI;
  45.145 +                readyHi = RDYHI;
  45.146 +            }
  45.147 +            else if (config->options[i].value == kWiringSatyr)
  45.148 +            {
  45.149 +                readyMask = RDYHIALT;
  45.150 +                readyHi = RDYLO;
  45.151 +            }
  45.152 +            else
  45.153 +                syslog(LOG_ERR, "%s error: wiring %s not supported, using default (Standard)!\n",
  45.154 +                       config->name.c_str(), config->options[i].value.c_str());
  45.155 +        }
  45.156 +        if (config->options[i].name == "Interface")
  45.157 +        {
  45.158 +            if (config->options[i].value == "Parallel")
  45.159 +                interface = kInterfaceParallel;
  45.160 +            else if (config->options[i].value == "Serial")
  45.161 +                interface = kInterfaceSerial;
  45.162 +            else
  45.163 +                syslog(LOG_ERR, "%s error: interface %s not supported, using default (Parallel)!\n",
  45.164 +                       config->name.c_str(), config->options[i].value.c_str());
  45.165 +        }
  45.166 +        else if (config->options[i].name == "DMA")
  45.167 +        {
  45.168 +            if (config->options[i].value == "yes")
  45.169 +                useDMA = true;
  45.170 +            else if (config->options[i].value == "no")
  45.171 +                useDMA = false;
  45.172 +            else
  45.173 +                syslog(LOG_ERR, "%s error: unknown DMA setting %s, using default (%s)!\n",
  45.174 +                       config->name.c_str(), config->options[i].value.c_str(), useDMA ? "yes" : "no");
  45.175 +        }
  45.176 +    }
  45.177 +
  45.178 +    if (interface == kInterfaceParallel)
  45.179 +        port = new cParallelPort();
  45.180 +    else
  45.181 +        port = NULL;
  45.182 +
  45.183 +    // setup linear lcd array
  45.184 +    m_pDrawMem = new unsigned char *[width];
  45.185 +    if (m_pDrawMem)
  45.186 +    {
  45.187 +        for (x = 0; x < width; x++)
  45.188 +        {
  45.189 +            m_pDrawMem[x] = new unsigned char[m_iSizeYb];
  45.190 +            memset(m_pDrawMem[x], 0, m_iSizeYb);
  45.191 +        }
  45.192 +    }
  45.193 +    Clear();
  45.194 +
  45.195 +    // setup the lcd array for the "vertical" mem
  45.196 +    m_pVFDMem = new unsigned char *[width];
  45.197 +    if (m_pVFDMem)
  45.198 +    {
  45.199 +        for (x = 0; x < width; x++)
  45.200 +        {
  45.201 +            m_pVFDMem[x] = new unsigned char[m_iSizeYb];
  45.202 +            memset(m_pVFDMem[x], 0, m_iSizeYb);
  45.203 +        }
  45.204 +    }
  45.205 +    ClearVFDMem();
  45.206 +
  45.207 +    if (interface == kInterfaceSerial)
  45.208 +    {
  45.209 +        if (InitSerialPort() < 0)
  45.210 +            return -1;
  45.211 +    }
  45.212 +    else
  45.213 +    {
  45.214 +        if (InitParallelPort() < 0)
  45.215 +            return -1;
  45.216 +    }
  45.217 +
  45.218 +    if (useDMA)
  45.219 +        InitDMADisplay();
  45.220 +    else
  45.221 +        InitNormalDisplay();
  45.222 +
  45.223 +    if (interface == kInterfaceParallel)
  45.224 +    {
  45.225 +        // claim is in InitParallelPort
  45.226 +        port->Release();
  45.227 +    }
  45.228 +
  45.229 +    *oldConfig = *config;
  45.230 +
  45.231 +    // Set Display SetBrightness
  45.232 +    SetBrightness(config->brightness);
  45.233 +    // clear display
  45.234 +    Clear();
  45.235 +    ClearVFDMem();
  45.236 +
  45.237 +    syslog(LOG_INFO, "%s: gu256x64-3900 initialized.\n", config->name.c_str());
  45.238 +    return 0;
  45.239 +}
  45.240 +
  45.241 +int cDriverGU256X64_3900::DeInit()
  45.242 +{
  45.243 +    int x;
  45.244 +
  45.245 +    if (m_pVFDMem)
  45.246 +    {
  45.247 +        for (x = 0; x < width; x++)
  45.248 +        {
  45.249 +            delete[] m_pVFDMem[x];
  45.250 +        }
  45.251 +        delete[] m_pVFDMem;
  45.252 +    }
  45.253 +    if (m_pDrawMem)
  45.254 +    {
  45.255 +        for (x = 0; x < width; x++)
  45.256 +        {
  45.257 +            delete[] m_pDrawMem[x];
  45.258 +        }
  45.259 +        delete[] m_pDrawMem;
  45.260 +    }
  45.261 +
  45.262 +    if (interface == kInterfaceSerial)
  45.263 +    {
  45.264 +        if (portFd >= 0)
  45.265 +        {
  45.266 +            close(portFd);
  45.267 +            portFd =- 1;
  45.268 +        }
  45.269 +    }
  45.270 +    if (port)
  45.271 +    {
  45.272 +        if (port->Close() != 0)
  45.273 +        {
  45.274 +            return -1;
  45.275 +        }
  45.276 +        delete port;
  45.277 +        port = NULL;
  45.278 +    }
  45.279 +    return 0;
  45.280 +}
  45.281 +
  45.282 +int cDriverGU256X64_3900::CheckSetup()
  45.283 +{
  45.284 +    if (config->device != oldConfig->device ||
  45.285 +        config->port != oldConfig->port ||
  45.286 +        config->width != oldConfig->width ||
  45.287 +        config->height != oldConfig->height)
  45.288 +    {
  45.289 +        DeInit();
  45.290 +        Init();
  45.291 +        return 0;
  45.292 +    }
  45.293 +
  45.294 +    if (config->brightness != oldConfig->brightness)
  45.295 +    {
  45.296 +        oldConfig->brightness = config->brightness;
  45.297 +        SetBrightness(config->brightness);
  45.298 +    }
  45.299 +    if (config->upsideDown != oldConfig->upsideDown ||
  45.300 +        config->invert != oldConfig->invert)
  45.301 +    {
  45.302 +        oldConfig->upsideDown = config->upsideDown;
  45.303 +        oldConfig->invert = config->invert;
  45.304 +        return 1;
  45.305 +    }
  45.306 +    return 0;
  45.307 +}
  45.308 +
  45.309 +int cDriverGU256X64_3900::InitSerialPort()
  45.310 +{
  45.311 +    if (config->device == "")
  45.312 +    {
  45.313 +        syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!\n", config->name.c_str());
  45.314 +        return -1;
  45.315 +    }
  45.316 +
  45.317 +    portFd = open(config->device.c_str(), O_RDWR | O_NOCTTY);
  45.318 +    if (portFd >= 0)
  45.319 +    {
  45.320 +        struct termios options;
  45.321 +        tcgetattr(portFd, &options);
  45.322 +        cfsetispeed(&options, B38400);
  45.323 +        cfsetospeed(&options, B38400);
  45.324 +        options.c_cflag &= ~CSIZE;
  45.325 +        options.c_cflag &= ~PARENB;
  45.326 +        options.c_cflag &= ~CSTOPB;
  45.327 +        options.c_cflag |= CS8;
  45.328 +        tcsetattr(portFd, TCSANOW, &options);
  45.329 +    }
  45.330 +    else
  45.331 +    {
  45.332 +        syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!\n", config->name.c_str());
  45.333 +        return -1;
  45.334 +    }
  45.335 +    return 0;
  45.336 +}
  45.337 +
  45.338 +int cDriverGU256X64_3900::InitParallelPort()
  45.339 +{
  45.340 +    struct timeval tv1, tv2;
  45.341 +
  45.342 +    if (config->device == "")
  45.343 +    {
  45.344 +        // use DirectIO
  45.345 +        if (port->Open(config->port) != 0)
  45.346 +        {
  45.347 +            syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!\n", config->name.c_str());
  45.348 +            return -1;
  45.349 +        }
  45.350 +        uSleep(10);
  45.351 +    }
  45.352 +    else
  45.353 +    {
  45.354 +        // use ppdev
  45.355 +        if (port->Open(config->device.c_str()) != 0)
  45.356 +        {
  45.357 +            syslog(LOG_ERR, "%s: unable to initialize gu256x64-3900!\n", config->name.c_str());
  45.358 +            return -1;
  45.359 +        }
  45.360 +    }
  45.361 +
  45.362 +    if (nSleepInit() != 0)
  45.363 +    {
  45.364 +        syslog(LOG_ERR, "%s: INFO: cannot change wait parameters  Err: %s (cDriver::Init)\n", config->name.c_str(), strerror(errno));
  45.365 +        m_bSleepIsInit = false;
  45.366 +    }
  45.367 +    else
  45.368 +    {
  45.369 +        m_bSleepIsInit = true;
  45.370 +    }
  45.371 +
  45.372 +    port->Claim();
  45.373 +
  45.374 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  45.375 +    gettimeofday(&tv1, 0);
  45.376 +    for (int x = 0; x < 1000; x++)
  45.377 +    {
  45.378 +        port->WriteData(x % 0x100);
  45.379 +    }
  45.380 +    gettimeofday(&tv2, 0);
  45.381 +    nSleepDeInit();
  45.382 +    m_nTimingAdjustCmd = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  45.383 +    syslog(LOG_INFO, "%s: benchmark stopped. Time for Port Command: %ldns\n", config->name.c_str(), m_nTimingAdjustCmd);
  45.384 +
  45.385 +    return 0;
  45.386 +}
  45.387 +
  45.388 +void cDriverGU256X64_3900::InitNormalDisplay()
  45.389 +{
  45.390 +    Write(nPOWER0);
  45.391 +    Write(nPOWER1);
  45.392 +    Write(nPOWER2);
  45.393 +    Write(nPOWER3);
  45.394 +    Write(1); // power on
  45.395 +
  45.396 +    Write(nINITDISPLAY0);
  45.397 +    Write(nINITDISPLAY1);
  45.398 +
  45.399 +    Write(nDISPLAYCURSOR0);
  45.400 +    Write(nDISPLAYCURSOR1);
  45.401 +    Write(0); // off
  45.402 +
  45.403 +    Write(nSETCURSOR0);
  45.404 +    Write(nSETCURSOR1);
  45.405 +    Write(0); // low byte x
  45.406 +    Write(0); // high byte x
  45.407 +    Write(0); // low byte y
  45.408 +    Write(0); // high byte y
  45.409 +}
  45.410 +
  45.411 +void cDriverGU256X64_3900::InitDMADisplay()
  45.412 +{
  45.413 +    Write(dSETSTART0);
  45.414 +    Write(dSETSTART1);
  45.415 +    Write(dSETSTART2);
  45.416 +    Write(dSETSTART3);
  45.417 +    Write(0);
  45.418 +    Write(0);
  45.419 +}
  45.420 +
  45.421 +void cDriverGU256X64_3900::ClearVFDMem()
  45.422 +{
  45.423 +    for (int x = 0; x < width; x++)
  45.424 +        memset(m_pVFDMem[x], 0, m_iSizeYb);
  45.425 +}
  45.426 +
  45.427 +void cDriverGU256X64_3900::Clear()
  45.428 +{
  45.429 +    for (int x = 0; x < width; x++)
  45.430 +        memset(m_pDrawMem[x], 0, m_iSizeYb);
  45.431 +}
  45.432 +
  45.433 +void cDriverGU256X64_3900::SetBrightness(unsigned int percent)
  45.434 +{
  45.435 +    if (interface == kInterfaceParallel)
  45.436 +        port->Claim();
  45.437 +
  45.438 +    if (interface == kInterfaceParallel && useDMA)
  45.439 +    {
  45.440 +        Write(dSETBRIGHT0);
  45.441 +        Write(dSETBRIGHT1);
  45.442 +        Write(dSETBRIGHT2);
  45.443 +        Write(dSETBRIGHT3);
  45.444 +    }
  45.445 +    else
  45.446 +    {
  45.447 +        Write(nSETBRIGHT0);
  45.448 +        Write(nSETBRIGHT1);
  45.449 +    }
  45.450 +    if (percent > 87) {
  45.451 +        Write(BRIGHT_100);
  45.452 +    } else if (percent > 75) {
  45.453 +        Write(BRIGHT_087);
  45.454 +    } else if (percent > 62) {
  45.455 +        Write(BRIGHT_075);
  45.456 +    } else if (percent > 50) {
  45.457 +        Write(BRIGHT_062);
  45.458 +    } else if (percent > 37) {
  45.459 +        Write(BRIGHT_050);
  45.460 +    } else if (percent > 25) {
  45.461 +        Write(BRIGHT_037);
  45.462 +    } else if (percent > 12) {
  45.463 +        Write(BRIGHT_025);
  45.464 +    } else if (percent > 1) {
  45.465 +        Write(BRIGHT_012);
  45.466 +    } else {
  45.467 +        Write(BRIGHT_000);
  45.468 +    }
  45.469 +    if (interface == kInterfaceParallel)
  45.470 +        port->Release();
  45.471 +}
  45.472 +
  45.473 +void cDriverGU256X64_3900::WriteParallel(unsigned char data)
  45.474 +{
  45.475 +    if (m_bSleepIsInit)
  45.476 +        nSleepInit();
  45.477 +    if ((port->ReadStatus() & readyMask) != readyHi)
  45.478 +    {
  45.479 +        int i = 0;
  45.480 +        int status = port->ReadStatus();
  45.481 +        for (; ((status&readyMask) != readyHi) && i < 1000; i++)
  45.482 +        {
  45.483 +            // wait until display ack's write but not forever
  45.484 +            status=port->ReadStatus();
  45.485 +        }
  45.486 +    }
  45.487 +
  45.488 +    port->WriteControl(WRLO);
  45.489 +    port->WriteData(data);
  45.490 +    nSleep(100 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  45.491 +    port->WriteControl(WRHI);
  45.492 +    nSleep(500 + (100 * config->adjustTiming) - m_nTimingAdjustCmd);
  45.493 +}
  45.494 +
  45.495 +void cDriverGU256X64_3900::WriteSerial(unsigned char data)
  45.496 +{
  45.497 +    write(portFd, &data, 1);
  45.498 +}
  45.499 +
  45.500 +void cDriverGU256X64_3900::Write(unsigned char data)
  45.501 +{
  45.502 +    if (interface == kInterfaceSerial)
  45.503 +        WriteSerial(data);
  45.504 +    else
  45.505 +        WriteParallel(data);
  45.506 +}
  45.507 +
  45.508 +void cDriverGU256X64_3900::SetPixel(int x, int y)
  45.509 +{
  45.510 +    unsigned char c;
  45.511 +
  45.512 +    if (!m_pDrawMem)
  45.513 +        return;
  45.514 +
  45.515 +    if (x >= width || x < 0)
  45.516 +        return;
  45.517 +    if (y >= height || y < 0)
  45.518 +        return;
  45.519 +
  45.520 +    if (config->upsideDown)
  45.521 +    {
  45.522 +        x = width - 1 - x;
  45.523 +        y = height - 1 - y;
  45.524 +    }
  45.525 +
  45.526 +    c = 0x80 >> (y % 8);
  45.527 +
  45.528 +    m_pDrawMem[x][y/8] = m_pDrawMem[x][y/8] | c;
  45.529 +}
  45.530 +
  45.531 +void cDriverGU256X64_3900::Set8Pixels(int x, int y, unsigned char data)
  45.532 +{
  45.533 +    int n;
  45.534 +
  45.535 +    // x - pos is'nt maybe align to 8
  45.536 +    x &= 0xFFF8;
  45.537 +
  45.538 +    for (n = 0; n < 8; ++n)
  45.539 +    {
  45.540 +        if (data & (0x80 >> n)) // if bit is set
  45.541 +            SetPixel(x + n, y);
  45.542 +    }
  45.543 +}
  45.544 +
  45.545 +void cDriverGU256X64_3900::Refresh(bool refreshAll)
  45.546 +{
  45.547 +    int xb, yb;
  45.548 +
  45.549 +    if (!m_pVFDMem || !m_pDrawMem)
  45.550 +        return;
  45.551 +
  45.552 +    bool doRefresh = false;
  45.553 +    int minX = width;
  45.554 +    int maxX = 0;
  45.555 +    int minYb = m_iSizeYb;
  45.556 +    int maxYb = 0;
  45.557 +
  45.558 +    if (CheckSetup() > 0)
  45.559 +        refreshAll = true;
  45.560 +
  45.561 +    for (xb = 0; xb < width; ++xb)
  45.562 +    {
  45.563 +        for (yb = 0; yb < m_iSizeYb; ++yb)
  45.564 +        {
  45.565 +            if (m_pVFDMem[xb][yb] != m_pDrawMem[xb][yb])
  45.566 +            {
  45.567 +                m_pVFDMem[xb][yb] = m_pDrawMem[xb][yb];
  45.568 +                minX = std::min(minX, xb);
  45.569 +                maxX = std::max(maxX, xb);
  45.570 +                minYb = std::min(minYb, yb);
  45.571 +                maxYb = std::max(maxYb, yb + 1);
  45.572 +                doRefresh = true;
  45.573 +            }
  45.574 +        }
  45.575 +    }
  45.576 +
  45.577 +    if (config->refreshDisplay > 0)
  45.578 +    {
  45.579 +        m_nRefreshCounter = (m_nRefreshCounter + 1) % config->refreshDisplay;
  45.580 +        if (!refreshAll && !m_nRefreshCounter)
  45.581 +            refreshAll = true;
  45.582 +    }
  45.583 +
  45.584 +    if (refreshAll || doRefresh)
  45.585 +    {
  45.586 +        if (refreshAll)
  45.587 +        {
  45.588 +            minX = 0;
  45.589 +            maxX = width;
  45.590 +            minYb = 0;
  45.591 +            maxYb = m_iSizeYb;
  45.592 +            // and reset RefreshCounter
  45.593 +            m_nRefreshCounter = 0;
  45.594 +        }
  45.595 +
  45.596 +        minX = std::max(minX, 0);
  45.597 +        maxX = std::min(maxX, width - 1);
  45.598 +        minYb = std::max(minYb, 0);
  45.599 +        maxYb = std::min(maxYb, m_iSizeYb);
  45.600 +
  45.601 +        if (interface == kInterfaceParallel)
  45.602 +            port->Claim();
  45.603 +
  45.604 +        if (interface == kInterfaceParallel && useDMA)
  45.605 +        {
  45.606 +            Write(dBLITIMAGE0);
  45.607 +            Write(dBLITIMAGE1);
  45.608 +            Write(dBLITIMAGE2);
  45.609 +            Write(dBLITIMAGE3);
  45.610 +            Write(0); // low byte address
  45.611 +            Write(0); // high byte address
  45.612 +            Write((m_iSizeYb*width)&0xff); // low byte size
  45.613 +            Write((m_iSizeYb*width)>>8); // high byte size
  45.614 +        }
  45.615 +        else
  45.616 +        {
  45.617 +            Write(nSETCURSOR0);
  45.618 +            Write(nSETCURSOR1);
  45.619 +            Write(0); // low byte x
  45.620 +            Write(0); // high byte x
  45.621 +            Write(0); // low byte y
  45.622 +            Write(0); // high byte y
  45.623 +
  45.624 +            Write(nBLITIMAGE0);
  45.625 +            Write(nBLITIMAGE1);
  45.626 +            Write(nBLITIMAGE2);
  45.627 +            Write(nBLITIMAGE3);
  45.628 +            Write(width&0xff); // low byte width
  45.629 +            Write(width>>8); // high byte width
  45.630 +            Write(m_iSizeYb); // low byte height
  45.631 +            Write(0); // high byte height
  45.632 +            Write(1); // end header
  45.633 +        }
  45.634 +
  45.635 +        for (xb = 0; xb < width; xb++)
  45.636 +        {
  45.637 +            for (yb = 0; yb < m_iSizeYb; yb++)
  45.638 +            {
  45.639 +                Write((m_pVFDMem[xb][yb]) ^ (config->invert ? 0xff : 0x00));
  45.640 +            }
  45.641 +            // parallel port writing is busy waiting - with realtime priority you
  45.642 +            // can lock the system - so don't be so greedy ;)
  45.643 +            if ((xb % 32) == 31)
  45.644 +            {
  45.645 +                uSleep(1000);
  45.646 +            }
  45.647 +        }
  45.648 +
  45.649 +        if (interface == kInterfaceParallel)
  45.650 +            port->Release();
  45.651 +    }
  45.652 +}
  45.653 +
  45.654 +} // end of namespace
    46.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    46.2 +++ b/graphlcd-base/glcddrivers/gu256x64-3900.h	Wed Feb 06 17:32:55 2008 +0000
    46.3 @@ -0,0 +1,87 @@
    46.4 +/*
    46.5 + * GraphLCD driver library
    46.6 + *
    46.7 + * gu256x64-3900.h  -  8-bit driver module for Noritake GU256X64x-3900
    46.8 + *                     VFD displays. The VFD is either operating in
    46.9 + *                     8-bit mode connected to a single PC parallel
   46.10 + *                     port or in serial mode connected to a single PC
   46.11 + *                     serial port.
   46.12 + *
   46.13 + * based on:
   46.14 + *   gu256x64-372 driver module for graphlcd
   46.15 + *     (c) 2004 Andreas 'randy' Weinberger <randy AT smue.org>
   46.16 + *   gu140x32f driver module for graphlcd
   46.17 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab.de>
   46.18 + *   HD61830 device
   46.19 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   46.20 + *   lcdproc 0.4 driver hd44780-ext8bit
   46.21 + *     (c) 1999, 1995 Benjamin Tse <blt AT comports.com>
   46.22 + *
   46.23 + * This file is released under the GNU General Public License. Refer
   46.24 + * to the COPYING file distributed with this package.
   46.25 + *
   46.26 + * (c) 2004 Ralf Mueller (ralf AT bj-ig.de)
   46.27 + */
   46.28 +
   46.29 +#ifndef _GLCDDRIVERS_GU256X64_3900_H_
   46.30 +#define _GLCDDRIVERS_GU256X64_3900_H_
   46.31 +
   46.32 +#include "driver.h"
   46.33 +
   46.34 +namespace GLCD
   46.35 +{
   46.36 +
   46.37 +class cDriverConfig;
   46.38 +class cParallelPort;
   46.39 +
   46.40 +class cDriverGU256X64_3900 : public cDriver
   46.41 +{
   46.42 +    cParallelPort * port;
   46.43 +    int portFd;
   46.44 +
   46.45 +    cDriverConfig * config;
   46.46 +    cDriverConfig * oldConfig;
   46.47 +
   46.48 +    int m_iSizeYb;
   46.49 +    int m_nRefreshCounter;
   46.50 +    int interface;
   46.51 +    bool useDMA;
   46.52 +    unsigned char readyMask;
   46.53 +    unsigned char readyHi;
   46.54 +
   46.55 +    unsigned char ** m_pDrawMem; // the draw "memory"
   46.56 +    unsigned char ** m_pVFDMem; // the double buffed display "memory"
   46.57 +
   46.58 +    long m_nTimingAdjustCmd;
   46.59 +    bool m_bSleepIsInit;
   46.60 +
   46.61 +    int CheckSetup();
   46.62 +
   46.63 +protected:
   46.64 +    void ClearVFDMem();
   46.65 +    void SetPixel(int x, int y);
   46.66 +    int InitSerialPort();
   46.67 +    int InitParallelPort();
   46.68 +    void InitNormalDisplay();
   46.69 +    void InitDMADisplay();
   46.70 +
   46.71 +    void WriteSerial(unsigned char data);
   46.72 +    void WriteParallel(unsigned char data);
   46.73 +    void Write(unsigned char data);
   46.74 +public:
   46.75 +    cDriverGU256X64_3900(cDriverConfig * config);
   46.76 +    virtual ~cDriverGU256X64_3900();
   46.77 +
   46.78 +    virtual int Init();
   46.79 +    virtual int DeInit();
   46.80 +
   46.81 +    virtual void Clear();
   46.82 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   46.83 +    virtual void Refresh(bool refreshAll = false);
   46.84 +
   46.85 +    virtual void SetBrightness(unsigned int percent);
   46.86 +};
   46.87 +
   46.88 +} // end of namespace
   46.89 +
   46.90 +#endif
    47.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    47.2 +++ b/graphlcd-base/glcddrivers/hd61830.c	Wed Feb 06 17:32:55 2008 +0000
    47.3 @@ -0,0 +1,391 @@
    47.4 +/*
    47.5 + * GraphLCD driver library
    47.6 + *
    47.7 + * hd61830.c  -  HD61830 driver class
    47.8 + *
    47.9 + * This file is released under the GNU General Public License. Refer
   47.10 + * to the COPYING file distributed with this package.
   47.11 + *
   47.12 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   47.13 + */
   47.14 +
   47.15 +#include <syslog.h>
   47.16 +#include <sys/time.h>
   47.17 +
   47.18 +#include "common.h"
   47.19 +#include "config.h"
   47.20 +#include "hd61830.h"
   47.21 +#include "port.h"
   47.22 +
   47.23 +
   47.24 +namespace GLCD
   47.25 +{
   47.26 +
   47.27 +// commands
   47.28 +#define MCNT    0x00
   47.29 +#define CPIT    0x01
   47.30 +#define NOCH    0x02
   47.31 +#define NOTD    0x03
   47.32 +#define CPOS    0x04
   47.33 +
   47.34 +#define DSAL    0x08
   47.35 +#define DSAH    0x09
   47.36 +#define CACL    0x0A
   47.37 +#define CACH    0x0B
   47.38 +
   47.39 +#define WDDI    0x0C
   47.40 +#define RDDI    0x0D
   47.41 +
   47.42 +#define CBIT    0x0E
   47.43 +#define SBIT    0x0F
   47.44 +
   47.45 +// control bits for DirectIO
   47.46 +#define EN      0x01
   47.47 +#define ENHI    0x00
   47.48 +#define ENLO    0x01
   47.49 +
   47.50 +#define RW      0x02
   47.51 +#define RWHI    0x00
   47.52 +#define RWLO    0x02
   47.53 +
   47.54 +#define RS      0x04
   47.55 +#define RSHI    0x04
   47.56 +#define RSLO    0x00
   47.57 +
   47.58 +
   47.59 +cDriverHD61830::cDriverHD61830(cDriverConfig * config)
   47.60 +:   config(config)
   47.61 +{
   47.62 +    oldConfig = new cDriverConfig(*config);
   47.63 +
   47.64 +    port = new cParallelPort();
   47.65 +
   47.66 +    useSleepInit = false;
   47.67 +
   47.68 +    refreshCounter = 0;
   47.69 +    timeForPortCmdInNs = 0;
   47.70 +}
   47.71 +
   47.72 +cDriverHD61830::~cDriverHD61830()
   47.73 +{
   47.74 +    delete port;
   47.75 +    delete oldConfig;
   47.76 +}
   47.77 +
   47.78 +int cDriverHD61830::Init()
   47.79 +{
   47.80 +    int i;
   47.81 +    int x;
   47.82 +    struct timeval tv1, tv2;
   47.83 +
   47.84 +    width = config->width;
   47.85 +    if (width <= 0)
   47.86 +        width = 240;
   47.87 +    height = config->height;
   47.88 +    if (height <= 0)
   47.89 +        height = 128;
   47.90 +
   47.91 +    for (unsigned int i = 0; i < config->options.size(); i++)
   47.92 +    {
   47.93 +        if (config->options[i].name == "")
   47.94 +        {
   47.95 +        }
   47.96 +    }
   47.97 +
   47.98 +    // setup lcd array (wanted state)
   47.99 +    newLCD = new unsigned char *[(width + 7) / 8];
  47.100 +    if (newLCD)
  47.101 +    {
  47.102 +        for (x = 0; x < (width + 7) / 8; x++)
  47.103 +        {
  47.104 +            newLCD[x] = new unsigned char[height];
  47.105 +            memset(newLCD[x], 0, height);
  47.106 +        }
  47.107 +    }
  47.108 +    // setup lcd array (current state)
  47.109 +    oldLCD = new unsigned char*[(width + 7) / 8];
  47.110 +    if (oldLCD)
  47.111 +    {
  47.112 +        for (x = 0; x < (width + 7) / 8; x++)
  47.113 +        {
  47.114 +            oldLCD[x] = new unsigned char[height];
  47.115 +            memset(oldLCD[x], 0, height);
  47.116 +        }
  47.117 +    }
  47.118 +
  47.119 +    if (config->device == "")
  47.120 +    {
  47.121 +        // use DirectIO
  47.122 +        if (port->Open(config->port) != 0)
  47.123 +            return -1;
  47.124 +        uSleep(10);
  47.125 +    }
  47.126 +    else
  47.127 +    {
  47.128 +        // use ppdev
  47.129 +        if (port->Open(config->device.c_str()) != 0)
  47.130 +            return -1;
  47.131 +    }
  47.132 +
  47.133 +    if (nSleepInit() != 0)
  47.134 +    {
  47.135 +        syslog(LOG_DEBUG, "%s: INFO: cannot change wait parameters (cDriver::Init)\n", config->name.c_str());
  47.136 +        useSleepInit = false;
  47.137 +    }
  47.138 +    else
  47.139 +    {
  47.140 +        useSleepInit = true;
  47.141 +    }
  47.142 +
  47.143 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  47.144 +    gettimeofday(&tv1, 0);
  47.145 +    for (i = 0; i < 1000; i++)
  47.146 +    {
  47.147 +        port->WriteData(1 % 0x100);
  47.148 +    }
  47.149 +    gettimeofday(&tv2, 0);
  47.150 +    if (useSleepInit)
  47.151 +        nSleepDeInit();
  47.152 +    timeForPortCmdInNs = (tv2.tv_sec-tv1.tv_sec) * 1000000 + (tv2.tv_usec-tv1.tv_usec);
  47.153 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Port Command: %ldns\n", config->name.c_str(), timeForPortCmdInNs);
  47.154 +
  47.155 +    // initialize graphic mode
  47.156 +    InitGraphic();
  47.157 +
  47.158 +    port->Release();
  47.159 +
  47.160 +    *oldConfig = *config;
  47.161 +
  47.162 +    // clear display
  47.163 +    Clear();
  47.164 +
  47.165 +    syslog(LOG_INFO, "%s: HD61830 initialized.\n", config->name.c_str());
  47.166 +    return 0;
  47.167 +}
  47.168 +
  47.169 +int cDriverHD61830::DeInit()
  47.170 +{
  47.171 +    int x;
  47.172 +
  47.173 +    // free lcd array (wanted state)
  47.174 +    if (newLCD)
  47.175 +    {
  47.176 +        for (x = 0; x < (width + 7) / 8; x++)
  47.177 +        {
  47.178 +            delete[] newLCD[x];
  47.179 +        }
  47.180 +        delete[] newLCD;
  47.181 +    }
  47.182 +    // free lcd array (current state)
  47.183 +    if (oldLCD)
  47.184 +    {
  47.185 +        for (x = 0; x < (width + 7) / 8; x++)
  47.186 +        {
  47.187 +            delete[] oldLCD[x];
  47.188 +        }
  47.189 +        delete[] oldLCD;
  47.190 +    }
  47.191 +    if (port->Close() != 0)
  47.192 +        return -1;
  47.193 +    return 0;
  47.194 +}
  47.195 +
  47.196 +int cDriverHD61830::CheckSetup()
  47.197 +{
  47.198 +    if (config->device != oldConfig->device ||
  47.199 +        config->port != oldConfig->port ||
  47.200 +        config->width != oldConfig->width ||
  47.201 +        config->height != oldConfig->height)
  47.202 +    {
  47.203 +        DeInit();
  47.204 +        Init();
  47.205 +        return 0;
  47.206 +    }
  47.207 +
  47.208 +    if (config->upsideDown != oldConfig->upsideDown ||
  47.209 +        config->invert != oldConfig->invert)
  47.210 +    {
  47.211 +        oldConfig->upsideDown = config->upsideDown;
  47.212 +        oldConfig->invert = config->invert;
  47.213 +        return 1;
  47.214 +    }
  47.215 +    return 0;
  47.216 +}
  47.217 +
  47.218 +int cDriverHD61830::InitGraphic()
  47.219 +{
  47.220 +    Write(MCNT, 0x32); // set Mode Control Register
  47.221 +    // DISP ON, MASTER ON, BLINK OFF, CURSOR OFF, GRAPHIC-Mode, int.Clock
  47.222 +    Write(CPIT, 0x07); // set Character Pitch Register
  47.223 +    // 8 pixels per byte
  47.224 +    Write(NOCH, std::max(1, (width + 7) / 8 - 1)); // set Number-Of-Characters Register
  47.225 +    // (width - 1) / 8 bytes per line horizontally
  47.226 +    Write(NOTD, std::max(1, height - 1)); // set Number-Of-Time-Divisions Register
  47.227 +    // height - 1
  47.228 +    Write(CPOS, 0x00); // set Cursor Position Register
  47.229 +    // optional, because we havn't enabled a cursor
  47.230 +    Write(DSAL, 0x00); // set Display Start Address Register (Low Order Byte)
  47.231 +    Write(DSAH, 0x00); // set Display Start Address Register (High Order Byte)
  47.232 +    Write(CACL, 0x00); // set Cursor Address Counter Register (Low Order Byte)
  47.233 +    Write(CACH, 0x00); // set Cursor Address Counter Register (High Order Byte)
  47.234 +
  47.235 +    return 0;
  47.236 +}
  47.237 +
  47.238 +void cDriverHD61830::Write(unsigned char cmd, unsigned char data)
  47.239 +{
  47.240 +    if (useSleepInit)
  47.241 +        nSleepInit();
  47.242 +
  47.243 +    // set RS high (instruction), RW low (write) and E low
  47.244 +    port->WriteControl(RSHI | RWLO | ENLO);
  47.245 +    nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  47.246 +
  47.247 +    // Output the actual command
  47.248 +    port->WriteData(cmd);
  47.249 +
  47.250 +    // set E high
  47.251 +    port->WriteControl(RSHI | RWLO | ENHI);
  47.252 +    nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  47.253 +
  47.254 +    // set E low
  47.255 +    port->WriteControl(RSHI | RWLO | ENLO);
  47.256 +    nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  47.257 +
  47.258 +
  47.259 +    // set RS low (data), RW low (write) and E low
  47.260 +    port->WriteControl(RSLO | RWLO | ENLO);
  47.261 +    nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  47.262 +
  47.263 +    // Output the actual data
  47.264 +    port->WriteData(data);
  47.265 +
  47.266 +    // set E high
  47.267 +    port->WriteControl(RSLO | RWLO | ENHI);
  47.268 +    nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  47.269 +
  47.270 +    // set E low
  47.271 +    port->WriteControl(RSLO | RWLO | ENLO);
  47.272 +    nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  47.273 +
  47.274 +    switch (cmd)
  47.275 +    {
  47.276 +        case MCNT:
  47.277 +        case CPIT:
  47.278 +        case NOCH:
  47.279 +        case NOTD:
  47.280 +        case CPOS:
  47.281 +        case DSAL:
  47.282 +        case DSAH:
  47.283 +        case CACL:
  47.284 +        case CACH:
  47.285 +            nSleep(4000 - std::max(450l, timeForPortCmdInNs) + 100 * config->adjustTiming);
  47.286 +            break;
  47.287 +        case WDDI:
  47.288 +        case RDDI:
  47.289 +            nSleep(6000 - std::max(450l, timeForPortCmdInNs) + 100 * config->adjustTiming);
  47.290 +            break;
  47.291 +        case CBIT:
  47.292 +        case SBIT:
  47.293 +            nSleep(36000 - std::max(450l, timeForPortCmdInNs) + 100 * config->adjustTiming);
  47.294 +            break;
  47.295 +    }
  47.296 +    if (useSleepInit)
  47.297 +        nSleepDeInit();
  47.298 +}
  47.299 +
  47.300 +void cDriverHD61830::Clear()
  47.301 +{
  47.302 +    for (int x = 0; x < (width + 7) / 8; x++)
  47.303 +        memset(newLCD[x], 0, height);
  47.304 +}
  47.305 +
  47.306 +void cDriverHD61830::Set8Pixels(int x, int y, unsigned char data)
  47.307 +{
  47.308 +    if (x >= width || y >= height)
  47.309 +        return;
  47.310 +
  47.311 +    if (!config->upsideDown)
  47.312 +    {
  47.313 +        // normal orientation
  47.314 +        newLCD[x / 8][y] = newLCD[x / 8][y] | ReverseBits(data);
  47.315 +    }
  47.316 +    else
  47.317 +    {
  47.318 +        // upside down orientation
  47.319 +        x = width - 1 - x;
  47.320 +        y = height - 1 - y;
  47.321 +        newLCD[x / 8][y] = newLCD[x / 8][y] | data;
  47.322 +    }
  47.323 +}
  47.324 +
  47.325 +void cDriverHD61830::Refresh(bool refreshAll)
  47.326 +{
  47.327 +    int x;
  47.328 +    int y;
  47.329 +    int pos = 0;
  47.330 +
  47.331 +    if (CheckSetup() > 0)
  47.332 +        refreshAll = true;
  47.333 +
  47.334 +    if (config->refreshDisplay > 0)
  47.335 +    {
  47.336 +        refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
  47.337 +        if (!refreshAll && !refreshCounter)
  47.338 +            refreshAll = true;
  47.339 +    }
  47.340 +
  47.341 +    port->Claim();
  47.342 +
  47.343 +    if (refreshAll)
  47.344 +    {
  47.345 +        // draw all
  47.346 +
  47.347 +        for (y = 0; y < height; y++)
  47.348 +        {
  47.349 +            for (x = 0; x < (width + 7) / 8; x++)
  47.350 +            {
  47.351 +                // (re-setting the cursor position
  47.352 +                //  might be removed, when the graphic glitches are solved)
  47.353 +                Write(CACL, (pos % 0x100));
  47.354 +                Write(CACH, (pos / 0x100));
  47.355 +                Write(WDDI, (newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
  47.356 +                oldLCD[x][y] = newLCD[x][y];
  47.357 +                pos++;
  47.358 +            }
  47.359 +        }
  47.360 +        // and reset RefreshCounter
  47.361 +        refreshCounter = 0;
  47.362 +    }
  47.363 +    else
  47.364 +    {
  47.365 +        // draw only the changed bytes
  47.366 +
  47.367 +        bool cs = false;
  47.368 +        for (y = 0; y < height; y++)
  47.369 +        {
  47.370 +            for (x = 0; x < (width + 7) / 8; x++)
  47.371 +            {
  47.372 +                if (newLCD[x][y] != oldLCD[x][y])
  47.373 +                {
  47.374 +                    if (!cs)
  47.375 +                    {
  47.376 +                        Write(CACL, (pos % 0x100));
  47.377 +                        Write(CACH, (pos / 0x100));
  47.378 +                        cs = true;
  47.379 +                    }
  47.380 +                    Write(WDDI, (newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
  47.381 +                    oldLCD[x][y] = newLCD[x][y];
  47.382 +                }
  47.383 +                else
  47.384 +                {
  47.385 +                    cs = false;
  47.386 +                }
  47.387 +                pos++;
  47.388 +            }
  47.389 +        }
  47.390 +    }
  47.391 +    port->Release();
  47.392 +}
  47.393 +
  47.394 +} // end of namespace
    48.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    48.2 +++ b/graphlcd-base/glcddrivers/hd61830.h	Wed Feb 06 17:32:55 2008 +0000
    48.3 @@ -0,0 +1,54 @@
    48.4 +/*
    48.5 + * GraphLCD driver library
    48.6 + *
    48.7 + * hd61830.h  -  HD61830 driver class
    48.8 + *
    48.9 + * This file is released under the GNU General Public License. Refer
   48.10 + * to the COPYING file distributed with this package.
   48.11 + *
   48.12 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   48.13 + */
   48.14 +
   48.15 +#ifndef _GLCDDRIVERS_HD61830_H_
   48.16 +#define _GLCDDRIVERS_HD61830_H_
   48.17 +
   48.18 +#include "driver.h"
   48.19 +
   48.20 +namespace GLCD
   48.21 +{
   48.22 +
   48.23 +class cDriverConfig;
   48.24 +class cParallelPort;
   48.25 +
   48.26 +class cDriverHD61830 : public cDriver
   48.27 +{
   48.28 +private:
   48.29 +    cParallelPort * port;
   48.30 +
   48.31 +    unsigned char ** newLCD; // wanted state
   48.32 +    unsigned char ** oldLCD; // current state
   48.33 +    cDriverConfig * config;
   48.34 +    cDriverConfig * oldConfig;
   48.35 +    int refreshCounter;
   48.36 +    long timeForPortCmdInNs;
   48.37 +    bool useSleepInit;
   48.38 +
   48.39 +    int CheckSetup();
   48.40 +    int InitGraphic();
   48.41 +    void Write(unsigned char cmd, unsigned char data);
   48.42 +
   48.43 +public:
   48.44 +    cDriverHD61830(cDriverConfig * config);
   48.45 +    virtual ~cDriverHD61830();
   48.46 +
   48.47 +    virtual int Init();
   48.48 +    virtual int DeInit();
   48.49 +
   48.50 +    virtual void Clear();
   48.51 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   48.52 +    virtual void Refresh(bool refreshAll = false);
   48.53 +};
   48.54 +
   48.55 +} // end of namespace
   48.56 +
   48.57 +#endif
    49.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    49.2 +++ b/graphlcd-base/glcddrivers/image.c	Wed Feb 06 17:32:55 2008 +0000
    49.3 @@ -0,0 +1,167 @@
    49.4 +/*
    49.5 + * GraphLCD driver library
    49.6 + *
    49.7 + * image.c  -  Image output device
    49.8 + *             Output goes to a image file instead of LCD.
    49.9 + *
   49.10 + * This file is released under the GNU General Public License. Refer
   49.11 + * to the COPYING file distributed with this package.
   49.12 + *
   49.13 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   49.14 + */
   49.15 +
   49.16 +#include <stdio.h>
   49.17 +#include <syslog.h>
   49.18 +
   49.19 +#include "common.h"
   49.20 +#include "config.h"
   49.21 +#include "image.h"
   49.22 +
   49.23 +
   49.24 +namespace GLCD
   49.25 +{
   49.26 +
   49.27 +cDriverImage::cDriverImage(cDriverConfig * config)
   49.28 +:   config(config)
   49.29 +{
   49.30 +    oldConfig = new cDriverConfig(*config);
   49.31 +}
   49.32 +
   49.33 +cDriverImage::~cDriverImage()
   49.34 +{
   49.35 +    delete oldConfig;
   49.36 +}
   49.37 +
   49.38 +int cDriverImage::Init()
   49.39 +{
   49.40 +    width = config->width;
   49.41 +    if (width <= 0)
   49.42 +        width = 240;
   49.43 +    height = config->height;
   49.44 +    if (height <= 0)
   49.45 +        height = 128;
   49.46 +    lineSize = (width + 7) / 8;
   49.47 +
   49.48 +    for (unsigned int i = 0; i < config->options.size(); i++)
   49.49 +    {
   49.50 +        if (config->options[i].name == "")
   49.51 +        {
   49.52 +        }
   49.53 +    }
   49.54 +
   49.55 +    newLCD = new unsigned char[lineSize * height];
   49.56 +    if (newLCD)
   49.57 +        memset(newLCD, 0, lineSize * height);
   49.58 +    oldLCD = new unsigned char[lineSize * height];
   49.59 +    if (oldLCD)
   49.60 +        memset(oldLCD, 0, lineSize * height);
   49.61 +
   49.62 +    counter = 0;
   49.63 +
   49.64 +    *oldConfig = *config;
   49.65 +
   49.66 +    // clear display
   49.67 +    Clear();
   49.68 +
   49.69 +    syslog(LOG_INFO, "%s: image driver initialized.\n", config->name.c_str());
   49.70 +    return 0;
   49.71 +}
   49.72 +
   49.73 +int cDriverImage::DeInit()
   49.74 +{
   49.75 +    if (newLCD)
   49.76 +        delete[] newLCD;
   49.77 +    if (oldLCD)
   49.78 +        delete[] oldLCD;
   49.79 +    return 0;
   49.80 +}
   49.81 +
   49.82 +int cDriverImage::CheckSetup()
   49.83 +{
   49.84 +    if (config->width != oldConfig->width ||
   49.85 +        config->height != oldConfig->height)
   49.86 +    {
   49.87 +        DeInit();
   49.88 +        Init();
   49.89 +        return 0;
   49.90 +    }
   49.91 +
   49.92 +    if (config->upsideDown != oldConfig->upsideDown ||
   49.93 +        config->invert != oldConfig->invert)
   49.94 +    {
   49.95 +        oldConfig->upsideDown = config->upsideDown;
   49.96 +        oldConfig->invert = config->invert;
   49.97 +        return 1;
   49.98 +    }
   49.99 +    return 0;
  49.100 +}
  49.101 +
  49.102 +void cDriverImage::Clear()
  49.103 +{
  49.104 +    memset(newLCD, 0, lineSize * height);
  49.105 +}
  49.106 +
  49.107 +void cDriverImage::Set8Pixels(int x, int y, unsigned char data)
  49.108 +{
  49.109 +    if (x >= width || y >= height)
  49.110 +        return;
  49.111 +
  49.112 +    if (!config->upsideDown)
  49.113 +    {
  49.114 +        // normal orientation
  49.115 +        newLCD[lineSize * y + x / 8] |= data;
  49.116 +    }
  49.117 +    else
  49.118 +    {
  49.119 +        // upside down orientation
  49.120 +        x = width - 1 - x;
  49.121 +        y = height - 1 - y;
  49.122 +        newLCD[lineSize * y + x / 8] |= ReverseBits(data);
  49.123 +    }
  49.124 +}
  49.125 +
  49.126 +void cDriverImage::Refresh(bool refreshAll)
  49.127 +{
  49.128 +    int i;
  49.129 +    bool refresh;
  49.130 +    char fileName[256];
  49.131 +    char str[32];
  49.132 +    FILE * fp;
  49.133 +    unsigned char c;
  49.134 +
  49.135 +    refresh = false;
  49.136 +    if (CheckSetup() > 0)
  49.137 +        refresh = true;
  49.138 +
  49.139 +    for (i = 0; i < lineSize * height; i++)
  49.140 +    {
  49.141 +        if (newLCD[i] != oldLCD[i])
  49.142 +        {
  49.143 +            refresh = true;
  49.144 +            break;
  49.145 +        }
  49.146 +    }
  49.147 +
  49.148 +    if (refresh)
  49.149 +    {
  49.150 +        sprintf(fileName, "%s/%s%05d.%s", "/tmp", "lcd", counter, "pbm");
  49.151 +        fp = fopen(fileName, "wb");
  49.152 +        if (fp)
  49.153 +        {
  49.154 +            sprintf(str, "P4\n%d %d\n", width, height);
  49.155 +            fwrite(str, strlen(str), 1, fp);
  49.156 +            for (i = 0; i < lineSize * height; i++)
  49.157 +            {
  49.158 +                c = newLCD[i] ^ (config->invert ? 0xff : 0x00);
  49.159 +                fwrite(&c, 1, 1, fp);
  49.160 +                oldLCD[i] = newLCD[i];
  49.161 +            }
  49.162 +            fclose(fp);
  49.163 +        }
  49.164 +        counter++;
  49.165 +        if (counter > 99999)
  49.166 +            counter = 0;
  49.167 +    }
  49.168 +}
  49.169 +
  49.170 +} // end of namespace
    50.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    50.2 +++ b/graphlcd-base/glcddrivers/image.h	Wed Feb 06 17:32:55 2008 +0000
    50.3 @@ -0,0 +1,50 @@
    50.4 +/*
    50.5 + * GraphLCD driver library
    50.6 + *
    50.7 + * image.h  -  Image output device
    50.8 + *             Output goes to a image file instead of LCD.
    50.9 + *
   50.10 + * This file is released under the GNU General Public License. Refer
   50.11 + * to the COPYING file distributed with this package.
   50.12 + *
   50.13 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   50.14 + */
   50.15 +
   50.16 +#ifndef _GLCDDRIVERS_IMAGE_H_
   50.17 +#define _GLCDDRIVERS_IMAGE_H_
   50.18 +
   50.19 +#include "driver.h"
   50.20 +
   50.21 +
   50.22 +namespace GLCD
   50.23 +{
   50.24 +
   50.25 +class cDriverConfig;
   50.26 +
   50.27 +class cDriverImage : public cDriver
   50.28 +{
   50.29 +private:
   50.30 +    unsigned char * newLCD;
   50.31 +    unsigned char * oldLCD;
   50.32 +    cDriverConfig * config;
   50.33 +    cDriverConfig * oldConfig;
   50.34 +    int lineSize;
   50.35 +    int counter;
   50.36 +
   50.37 +    int CheckSetup();
   50.38 +
   50.39 +public:
   50.40 +    cDriverImage(cDriverConfig * config);
   50.41 +    virtual ~cDriverImage();
   50.42 +
   50.43 +    virtual int Init();
   50.44 +    virtual int DeInit();
   50.45 +
   50.46 +    virtual void Clear();
   50.47 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   50.48 +    virtual void Refresh(bool refreshAll = false);
   50.49 +};
   50.50 +
   50.51 +} // end of namespace
   50.52 +
   50.53 +#endif
    51.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    51.2 +++ b/graphlcd-base/glcddrivers/ks0108.c	Wed Feb 06 17:32:55 2008 +0000
    51.3 @@ -0,0 +1,593 @@
    51.4 +/*
    51.5 + * GraphLCD driver library
    51.6 + *
    51.7 + * ks0108.c  -  KS0108 driver class
    51.8 + *
    51.9 + * This file is released under the GNU General Public License. Refer
   51.10 + * to the COPYING file distributed with this package.
   51.11 + *
   51.12 + * (c) 2003 Andreas 'randy' Weinberger <vdr AT smue.org>
   51.13 + */
   51.14 +
   51.15 +#include <syslog.h>
   51.16 +#include <sys/time.h>
   51.17 +
   51.18 +#include "common.h"
   51.19 +#include "config.h"
   51.20 +#include "ks0108.h"
   51.21 +#include "port.h"
   51.22 +
   51.23 +
   51.24 +namespace GLCD
   51.25 +{
   51.26 +
   51.27 +// commands
   51.28 +const unsigned char kSEAD = 0x40; // Set (X) Address
   51.29 +const unsigned char kSEPA = 0xb8; // Set (Y) Page
   51.30 +const unsigned char kSEDS = 0xc0; // Set Display Start Line
   51.31 +const unsigned char kDIOF = 0x3e; // Display off
   51.32 +const unsigned char kDION = 0x3f; // Display on
   51.33 +
   51.34 +const unsigned char kCEHI = 0x01; // Chip Enable on
   51.35 +const unsigned char kCELO = 0x00;
   51.36 +const unsigned char kCDHI = 0x08; // Command/Data Register Select
   51.37 +const unsigned char kCDLO = 0x00;
   51.38 +
   51.39 +const unsigned char kCS1HI = 0x02; // ChipSelect 1
   51.40 +const unsigned char kCS1LO = 0x00;
   51.41 +const unsigned char kCS2HI = 0x00; // ChipSelect 2
   51.42 +const unsigned char kCS2LO = 0x04;
   51.43 +
   51.44 +
   51.45 +cDriverKS0108::cDriverKS0108(cDriverConfig * config)
   51.46 +:   config(config)
   51.47 +{
   51.48 +    oldConfig = new cDriverConfig(*config);
   51.49 +
   51.50 +    port = new cParallelPort();
   51.51 +
   51.52 +    refreshCounter = 0;
   51.53 +    timeForLCDInNs = 50;
   51.54 +    control = 1;
   51.55 +}
   51.56 +
   51.57 +cDriverKS0108::~cDriverKS0108()
   51.58 +{
   51.59 +    delete port;
   51.60 +    delete oldConfig;
   51.61 +}
   51.62 +
   51.63 +int cDriverKS0108::Init()
   51.64 +{
   51.65 +    int x;
   51.66 +    int i;
   51.67 +    struct timeval tv1, tv2;
   51.68 +
   51.69 +    if (config->width <= 128) {
   51.70 +        width = 128;
   51.71 +    } else if (config->width > 192) {
   51.72 +        width = 256;
   51.73 +    } else if (config->width > 128) {
   51.74 +        width = 192;
   51.75 +    }
   51.76 +
   51.77 +    if (config->height <= 64) {
   51.78 +        height = 64;
   51.79 +    } else if (config->height > 64) {
   51.80 +        height = 128;
   51.81 +        width = 128; // force 2* 128x64 display
   51.82 +    }
   51.83 +
   51.84 +    if (width == 128 && height == 64) {
   51.85 +        CS1 = kCS2HI | kCS1LO;
   51.86 +        CS2 = kCS2LO | kCS1HI;
   51.87 +        CS3 = -1; // invalid
   51.88 +        CS4 = -1;
   51.89 +    } else { // multiplexed via 74LS42
   51.90 +        CS1 = kCS2HI | kCS1HI;
   51.91 +        CS2 = kCS2HI | kCS1LO;
   51.92 +        CS3 = kCS2LO | kCS1HI;
   51.93 +        CS4 = kCS2LO | kCS1LO;
   51.94 +    }
   51.95 +
   51.96 +    SEAD = kSEAD;
   51.97 +    SEPA = kSEPA;
   51.98 +    SEDS = kSEDS;
   51.99 +    DIOF = kDIOF;
  51.100 +    DION = kDION;
  51.101 +
  51.102 +    CEHI = kCEHI;
  51.103 +    CELO = kCELO;
  51.104 +    CDHI = kCDHI;
  51.105 +    CDLO = kCDLO;
  51.106 +
  51.107 +    for (unsigned int i = 0; i < config->options.size(); i++)
  51.108 +    {
  51.109 +        if (config->options[i].name == "Control")
  51.110 +        {
  51.111 +            if (config->options[i].value == "0")
  51.112 +                control = 0;
  51.113 +            else if (config->options[i].value == "1")
  51.114 +                control = 1;
  51.115 +            else
  51.116 +                syslog(LOG_ERR, "%s error: unknown control setting %s, using default (%d)!\n",
  51.117 +                       config->name.c_str(), config->options[i].value.c_str(), control);
  51.118 +        }
  51.119 +    }
  51.120 +
  51.121 +    // setup linear lcd array
  51.122 +    LCD = new unsigned char *[(width + 7) / 8];
  51.123 +    if (LCD)
  51.124 +    {
  51.125 +        for (x = 0; x < (width + 7) / 8; x++)
  51.126 +        {
  51.127 +            LCD[x] = new unsigned char[height];
  51.128 +            memset(LCD[x], 0, height);
  51.129 +        }
  51.130 +    }
  51.131 +    // setup the lcd array for the paged ks0108
  51.132 +    LCD_page = new unsigned char *[width];
  51.133 +    if (LCD_page)
  51.134 +    {
  51.135 +        for (x = 0; x < width; x++)
  51.136 +        {
  51.137 +            LCD_page[x] = new unsigned char[(height + 7) / 8];
  51.138 +            memset(LCD_page[x], 0, (height + 7) / 8);
  51.139 +        }
  51.140 +    }
  51.141 +
  51.142 +    if (config->device == "")
  51.143 +    {
  51.144 +        // use DirectIO
  51.145 +        if (port->Open(config->port) != 0)
  51.146 +            return -1;
  51.147 +        uSleep(10);
  51.148 +    }
  51.149 +    else
  51.150 +    {
  51.151 +        // use ppdev
  51.152 +        if (port->Open(config->device.c_str()) != 0)
  51.153 +            return -1;
  51.154 +    }
  51.155 +
  51.156 +    if (nSleepInit() != 0)
  51.157 +    {
  51.158 +        syslog(LOG_DEBUG, "%s: INFO: cannot change wait parameters (cDriver::Init)\n", config->name.c_str());
  51.159 +        useSleepInit = false;
  51.160 +    }
  51.161 +    else
  51.162 +    {
  51.163 +        useSleepInit = true;
  51.164 +    }
  51.165 +
  51.166 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  51.167 +    gettimeofday(&tv1, 0);
  51.168 +    for (i = 0; i < 1000; i++)
  51.169 +    {
  51.170 +        port->WriteData(i % 0x100);
  51.171 +    }
  51.172 +    gettimeofday(&tv2, 0);
  51.173 +    if (useSleepInit)
  51.174 +        nSleepDeInit();
  51.175 +    timeForPortCmdInNs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  51.176 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Command: %ldns\n", config->name.c_str(), timeForPortCmdInNs);
  51.177 +
  51.178 +    // initialize graphic mode
  51.179 +    InitGraphic();
  51.180 +
  51.181 +    port->Release();
  51.182 +
  51.183 +    *oldConfig = *config;
  51.184 +
  51.185 +    // clear display
  51.186 +    Clear();
  51.187 +
  51.188 +    syslog(LOG_INFO, "%s: KS0108 initialized.\n", config->name.c_str());
  51.189 +    return 0;
  51.190 +}
  51.191 +
  51.192 +int cDriverKS0108::DeInit()
  51.193 +{
  51.194 +    int x;
  51.195 +
  51.196 +    // free linear lcd array
  51.197 +    if (LCD)
  51.198 +    {
  51.199 +        for (x = 0; x < (width + 7) / 8; x++)
  51.200 +        {
  51.201 +            delete[] LCD[x];
  51.202 +        }
  51.203 +        delete[] LCD;
  51.204 +    }
  51.205 +    // free paged lcd array
  51.206 +    if (LCD_page)
  51.207 +    {
  51.208 +        for (x = 0; x < width; x++)
  51.209 +        {
  51.210 +            delete[] LCD_page[x];
  51.211 +        }
  51.212 +        delete[] LCD_page;
  51.213 +    }
  51.214 +    if (port->Close() != 0)
  51.215 +        return -1;
  51.216 +    return 0;
  51.217 +}
  51.218 +
  51.219 +int cDriverKS0108::CheckSetup()
  51.220 +{
  51.221 +    if (config->device != oldConfig->device ||
  51.222 +        config->port != oldConfig->port ||
  51.223 +        config->width != oldConfig->width ||
  51.224 +        config->height != oldConfig->height)
  51.225 +    {
  51.226 +        DeInit();
  51.227 +        Init();
  51.228 +        return 0;
  51.229 +    }
  51.230 +
  51.231 +    if (config->upsideDown != oldConfig->upsideDown ||
  51.232 +        config->invert != oldConfig->invert)
  51.233 +    {
  51.234 +        oldConfig->upsideDown = config->upsideDown;
  51.235 +        oldConfig->invert = config->invert;
  51.236 +        return 1;
  51.237 +    }
  51.238 +    return 0;
  51.239 +}
  51.240 +
  51.241 +int cDriverKS0108::InitGraphic()
  51.242 +{
  51.243 +    // init controllers
  51.244 +    if (CS1 > -1) {
  51.245 +        KS0108Cmd(SEDS, 1);
  51.246 +        KS0108Cmd(SEPA, 1);
  51.247 +        KS0108Cmd(SEAD, 1);
  51.248 +        KS0108Cmd(DION, 1);
  51.249 +    }
  51.250 +    if (CS2 > -1) {
  51.251 +        KS0108Cmd(SEDS, 2);
  51.252 +        KS0108Cmd(SEPA, 2);
  51.253 +        KS0108Cmd(SEAD, 2);
  51.254 +        KS0108Cmd(DION, 2);
  51.255 +    }
  51.256 +    if (CS3 > -1) {
  51.257 +        KS0108Cmd(SEDS, 3);
  51.258 +        KS0108Cmd(SEPA, 3);
  51.259 +        KS0108Cmd(SEAD, 3);
  51.260 +        KS0108Cmd(DION, 3);
  51.261 +    }
  51.262 +    if (CS4 > -1) {
  51.263 +        KS0108Cmd(SEDS, 4);
  51.264 +        KS0108Cmd(SEPA, 4);
  51.265 +        KS0108Cmd(SEAD, 4);
  51.266 +        KS0108Cmd(DION, 4);
  51.267 +    }
  51.268 +    return 0;
  51.269 +}
  51.270 +
  51.271 +void cDriverKS0108::KS0108Cmd(unsigned char data, int cs)
  51.272 +{
  51.273 +    if (useSleepInit)
  51.274 +        nSleepInit();
  51.275 +    switch (cs) {
  51.276 +        case 1:
  51.277 +            if (control == 1)
  51.278 +                port->WriteControl(CDHI | CS1 | CELO);
  51.279 +            else
  51.280 +                port->WriteControl(CDHI | CS1 | CEHI);
  51.281 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.282 +            port->WriteData(data);
  51.283 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.284 +            if (control == 1)
  51.285 +            {
  51.286 +                port->WriteControl(CDHI | CS1 | CEHI);
  51.287 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.288 +            }
  51.289 +            port->WriteControl(CDHI | CS1 | CELO);
  51.290 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.291 +            break;
  51.292 +        case 2:
  51.293 +            if (control == 1)
  51.294 +                port->WriteControl(CDHI | CS2 | CELO);
  51.295 +            else
  51.296 +                port->WriteControl(CDHI | CS2 | CEHI);
  51.297 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.298 +            port->WriteData(data);
  51.299 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.300 +            if (control == 1)
  51.301 +            {
  51.302 +                port->WriteControl(CDHI | CS2 | CEHI);
  51.303 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.304 +            }
  51.305 +            port->WriteControl(CDHI | CS2 | CELO);
  51.306 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.307 +            break;
  51.308 +        case 3:
  51.309 +            if (control == 1)
  51.310 +                port->WriteControl(CDHI | CS3 | CELO);
  51.311 +            else
  51.312 +                port->WriteControl(CDHI | CS3 | CEHI);
  51.313 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.314 +            port->WriteData(data);
  51.315 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.316 +            if (control == 1)
  51.317 +            {
  51.318 +                port->WriteControl(CDHI | CS3 | CEHI);
  51.319 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.320 +            }
  51.321 +            port->WriteControl(CDHI | CS3 | CELO);
  51.322 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.323 +            break;
  51.324 +        case 4:
  51.325 +            if (control == 1)
  51.326 +                port->WriteControl(CDHI | CS4 | CELO);
  51.327 +            else
  51.328 +                port->WriteControl(CDHI | CS4 | CEHI);
  51.329 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.330 +            port->WriteData(data);
  51.331 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.332 +            if (control == 1)
  51.333 +            {
  51.334 +                port->WriteControl(CDHI | CS4 | CEHI);
  51.335 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.336 +            }
  51.337 +            port->WriteControl(CDHI | CS4 | CELO);
  51.338 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.339 +            break;
  51.340 +    }
  51.341 +    if (useSleepInit)
  51.342 +        nSleepDeInit();
  51.343 +}
  51.344 +
  51.345 +void cDriverKS0108::KS0108Data(unsigned char data, int cs)
  51.346 +{
  51.347 +    if (useSleepInit)
  51.348 +        nSleepInit();
  51.349 +    switch (cs) {
  51.350 +        case 1:
  51.351 +            if (control == 1)
  51.352 +                port->WriteControl(CDLO | CS1 | CELO);
  51.353 +            else
  51.354 +                port->WriteControl(CDLO | CS1 | CEHI);
  51.355 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.356 +            port->WriteData(data);
  51.357 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.358 +            if (control == 1)
  51.359 +            {
  51.360 +                port->WriteControl(CDLO | CS1 | CEHI);
  51.361 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.362 +            }
  51.363 +            port->WriteControl(CDLO | CS1 | CELO);
  51.364 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.365 +            break;
  51.366 +        case 2:
  51.367 +            if (control == 1)
  51.368 +                port->WriteControl(CDLO | CS2 | CELO);
  51.369 +            else
  51.370 +                port->WriteControl(CDLO | CS2 | CEHI);
  51.371 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.372 +            port->WriteData(data);
  51.373 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.374 +            if (control == 1)
  51.375 +            {
  51.376 +                port->WriteControl(CDLO | CS2 | CEHI);
  51.377 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.378 +            }
  51.379 +            port->WriteControl(CDLO | CS2 | CELO);
  51.380 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.381 +            break;
  51.382 +        case 3:
  51.383 +            if (control == 1)
  51.384 +                port->WriteControl(CDLO | CS3 | CELO);
  51.385 +            else
  51.386 +                port->WriteControl(CDLO | CS3 | CEHI);
  51.387 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.388 +            port->WriteData(data);
  51.389 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.390 +            if (control == 1)
  51.391 +            {
  51.392 +                port->WriteControl(CDLO | CS3 | CEHI);
  51.393 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.394 +            }
  51.395 +            port->WriteControl(CDLO | CS3 | CELO);
  51.396 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.397 +            break;
  51.398 +        case 4:
  51.399 +            if (control == 1)
  51.400 +                port->WriteControl(CDLO | CS4 | CELO);
  51.401 +            else
  51.402 +                port->WriteControl(CDLO | CS4 | CEHI);
  51.403 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.404 +            port->WriteData(data);
  51.405 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.406 +            if (control == 1)
  51.407 +            {
  51.408 +                port->WriteControl(CDLO | CS4 | CEHI);
  51.409 +                nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.410 +            }
  51.411 +            port->WriteControl(CDLO | CS4 | CELO);
  51.412 +            nSleep((timeForLCDInNs + timeForPortCmdInNs) + 100 * config->adjustTiming);
  51.413 +            break;
  51.414 +    }
  51.415 +    if (useSleepInit)
  51.416 +        nSleepDeInit();
  51.417 +}
  51.418 +
  51.419 +void cDriverKS0108::Clear()
  51.420 +{
  51.421 +    for (int x = 0; x < (width + 7) / 8; x++)
  51.422 +        memset(LCD[x], 0, height);
  51.423 +}
  51.424 +
  51.425 +void cDriverKS0108::Set8Pixels(int x, int y, unsigned char data)
  51.426 +{
  51.427 +    if (x >= width || y >= height)
  51.428 +        return;
  51.429 +
  51.430 +    if (!config->upsideDown)
  51.431 +    {
  51.432 +        // normal orientation
  51.433 +        LCD[x / 8][y] = LCD[x / 8][y] | data;
  51.434 +    }
  51.435 +    else
  51.436 +    {
  51.437 +        // upside down orientation
  51.438 +        x = width - 1 - x;
  51.439 +        y = height - 1 - y;
  51.440 +        LCD[x / 8][y] = LCD[x / 8][y] | ReverseBits(data);
  51.441 +    }
  51.442 +}
  51.443 +
  51.444 +void cDriverKS0108::Refresh(bool refreshAll)
  51.445 +{
  51.446 +    int   x,y;
  51.447 +    int   xx,yy;
  51.448 +    unsigned char dByte, oneBlock[8];
  51.449 +
  51.450 +    if (CheckSetup() > 0)
  51.451 +        refreshAll = true;
  51.452 +
  51.453 +    if (config->refreshDisplay > 0)
  51.454 +    {
  51.455 +        refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
  51.456 +        if (!refreshAll && !refreshCounter)
  51.457 +            refreshAll=true;
  51.458 +    }
  51.459 +
  51.460 +    refreshAll = true; // differential update is not yet supported
  51.461 +
  51.462 +    if (refreshAll)
  51.463 +    {
  51.464 +        // draw all
  51.465 +
  51.466 +        // convert the linear lcd array to the paged array for the display
  51.467 +        for (y = 0; y < (height + 7) / 8; y++)
  51.468 +        {
  51.469 +            for (x = 0; x < (width + 7) / 8; x++)
  51.470 +            {
  51.471 +                for (yy = 0; yy < 8; yy++)
  51.472 +                {
  51.473 +                    oneBlock[yy] = LCD[x][yy + (y * 8)] ^ (config->invert ? 0xff : 0x00);
  51.474 +                }
  51.475 +                for (xx = 0; xx < 8; xx++)
  51.476 +                {
  51.477 +                    dByte = 0;
  51.478 +                    for (yy = 0; yy < 8; yy++)
  51.479 +                    {
  51.480 +                        if (oneBlock[yy] & bitmask[xx])
  51.481 +                        {
  51.482 +                            dByte += (1 << yy);
  51.483 +                        }
  51.484 +                    }
  51.485 +                    LCD_page[x * 8 + xx][y] = dByte;
  51.486 +                }
  51.487 +            }
  51.488 +        }
  51.489 +
  51.490 +        port->Claim();
  51.491 +
  51.492 +        if (width == 128 && height == 64) {
  51.493 +            for (y = 0; y < 64/8; y++) {
  51.494 +                KS0108Cmd(SEPA + y, 1);
  51.495 +                KS0108Cmd(SEAD, 1);
  51.496 +
  51.497 +                for (x = 0; x < 64; x++) {
  51.498 +                    KS0108Data(LCD_page[x][y], 1);
  51.499 +                }
  51.500 +            }
  51.501 +
  51.502 +            for (y = 0; y < 64/8; y++) {
  51.503 +                KS0108Cmd(SEPA + y, 2);
  51.504 +                KS0108Cmd(SEAD, 2);
  51.505 +
  51.506 +                for (x = 64; x < 128; x++) {
  51.507 +                    KS0108Data(LCD_page[x][y], 2);
  51.508 +                }
  51.509 +            }
  51.510 +        }
  51.511 +
  51.512 +        if (width > 128 && height == 64) {
  51.513 +            for (y = 0; y < 64/8; y++) {
  51.514 +                KS0108Cmd(SEPA + y, 1);
  51.515 +                KS0108Cmd(SEAD, 1);
  51.516 +
  51.517 +                for (x = 0; x < 64; x++) {
  51.518 +                    KS0108Data(LCD_page[x][y], 1);
  51.519 +                }
  51.520 +            }
  51.521 +
  51.522 +            for (y = 0; y < 64/8; y++) {
  51.523 +                KS0108Cmd(SEPA + y, 2);
  51.524 +                KS0108Cmd(SEAD, 2);
  51.525 +                for (x = 64; x < 128; x++) {
  51.526 +                    KS0108Data(LCD_page[x][y], 2);
  51.527 +                }
  51.528 +            }
  51.529 +
  51.530 +            for (y = 0; y < 64/8; y++) {
  51.531 +                KS0108Cmd(SEPA + y, 3);
  51.532 +                KS0108Cmd(SEAD, 3);
  51.533 +
  51.534 +                for (x = 128; x < 192; x++) {
  51.535 +                    KS0108Data(LCD_page[x][y], 3);
  51.536 +                }
  51.537 +            }
  51.538 +
  51.539 +            for (y = 0; y < 64/8; y++) {
  51.540 +                if (width > 192) {
  51.541 +                    KS0108Cmd(SEPA + y, 4);
  51.542 +                    KS0108Cmd(SEAD, 4);
  51.543 +                    for (x = 192; x < 256; x++) {
  51.544 +                        KS0108Data(LCD_page[x][y], 4);
  51.545 +                    }
  51.546 +                }
  51.547 +            }
  51.548 +        }
  51.549 +
  51.550 +        if (width == 128 && height == 128) {
  51.551 +            for (y = 0; y < 64/8; y++) {
  51.552 +                KS0108Cmd(SEPA + y, 1);
  51.553 +                KS0108Cmd(SEAD, 1);
  51.554 +
  51.555 +                for (x = 0; x < 64; x++) {
  51.556 +                    KS0108Data(LCD_page[x][y], 1);
  51.557 +                }
  51.558 +            }
  51.559 +
  51.560 +            for (y = 0; y < 64/8; y++) {
  51.561 +                KS0108Cmd(SEPA + y, 2);
  51.562 +                KS0108Cmd(SEAD, 2);
  51.563 +
  51.564 +                for (x = 64; x < 128; x++) {
  51.565 +                    KS0108Data(LCD_page[x][y], 2);
  51.566 +                }
  51.567 +            }
  51.568 +
  51.569 +            for (y = 0; y < 64/8; y++) {
  51.570 +                KS0108Cmd(SEPA + y, 3);
  51.571 +                KS0108Cmd(SEAD, 3);
  51.572 +
  51.573 +                for (x = 0; x < 64; x++) {
  51.574 +                    KS0108Data(LCD_page[x][y+8], 3);
  51.575 +                }
  51.576 +            }
  51.577 +
  51.578 +            for (y = 0; y < 64/8; y++) {
  51.579 +                KS0108Cmd(SEPA + y, 4);
  51.580 +                KS0108Cmd(SEAD, 4);
  51.581 +
  51.582 +                for (x = 64; x < 128; x++) {
  51.583 +                    KS0108Data(LCD_page[x][y+8], 4);
  51.584 +                }
  51.585 +            }
  51.586 +        }
  51.587 +        port->WriteData(0);
  51.588 +        port->Release();
  51.589 +    }
  51.590 +    else
  51.591 +    {
  51.592 +        // draw only the changed bytes
  51.593 +    }
  51.594 +}
  51.595 +
  51.596 +} // end of namespace
    52.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    52.2 +++ b/graphlcd-base/glcddrivers/ks0108.h	Wed Feb 06 17:32:55 2008 +0000
    52.3 @@ -0,0 +1,78 @@
    52.4 +/*
    52.5 + * GraphLCD driver library
    52.6 + *
    52.7 + * ks0108.h  -  KS0108 driver class
    52.8 + *
    52.9 + * This file is released under the GNU General Public License. Refer
   52.10 + * to the COPYING file distributed with this package.
   52.11 + *
   52.12 + * (c) 2003 Andreas 'randy' Weinberger <vdr AT smue.org>
   52.13 + */
   52.14 +
   52.15 +#ifndef _GLCDDRIVERS_KS0108_H_
   52.16 +#define _GLCDDRIVERS_KS0108_H_
   52.17 +
   52.18 +#include "driver.h"
   52.19 +
   52.20 +
   52.21 +namespace GLCD
   52.22 +{
   52.23 +
   52.24 +class cDriverConfig;
   52.25 +class cParallelPort;
   52.26 +
   52.27 +class cDriverKS0108 : public cDriver
   52.28 +{
   52.29 +private:
   52.30 +    cParallelPort * port;
   52.31 +    unsigned char ** LCD;      // linear lcd display "memory"
   52.32 +    unsigned char ** LCD_page; // paged lcd display "memory"
   52.33 +    int refreshCounter;
   52.34 +    long timeForPortCmdInNs;
   52.35 +    long timeForLCDInNs;
   52.36 +    cDriverConfig * config;
   52.37 +    cDriverConfig * oldConfig;
   52.38 +    bool useSleepInit;
   52.39 +
   52.40 +    int CheckSetup();
   52.41 +    int InitGraphic();
   52.42 +    void KS0108Cmd(unsigned char data, int cs);
   52.43 +    void KS0108Data(unsigned char data, int cs);
   52.44 +
   52.45 +    int SEAD;
   52.46 +    int SEPA;
   52.47 +    int SEDS;
   52.48 +    int DIOF;
   52.49 +    int DION;
   52.50 +
   52.51 +    int CEHI;
   52.52 +    int CELO;
   52.53 +    int CDHI;
   52.54 +    int CDLO;
   52.55 +    int CS1HI;
   52.56 +    int CS1LO;
   52.57 +    int CS2HI;
   52.58 +    int CS2LO;
   52.59 +
   52.60 +    int CS1;
   52.61 +    int CS2;
   52.62 +    int CS3;
   52.63 +    int CS4;
   52.64 +
   52.65 +    unsigned char control;
   52.66 +
   52.67 +public:
   52.68 +    cDriverKS0108(cDriverConfig * config);
   52.69 +    virtual ~cDriverKS0108();
   52.70 +
   52.71 +    virtual int Init();
   52.72 +    virtual int DeInit();
   52.73 +
   52.74 +    virtual void Clear();
   52.75 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   52.76 +    virtual void Refresh(bool refreshAll = false);
   52.77 +};
   52.78 +
   52.79 +} // end of namespace
   52.80 +
   52.81 +#endif
    53.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    53.2 +++ b/graphlcd-base/glcddrivers/network.c	Wed Feb 06 17:32:55 2008 +0000
    53.3 @@ -0,0 +1,267 @@
    53.4 +/*
    53.5 + * GraphLCD driver library
    53.6 + *
    53.7 + * network.c  -  Network output device
    53.8 + *               Output goes to a network client.
    53.9 + *
   53.10 + * This file is released under the GNU General Public License. Refer
   53.11 + * to the COPYING file distributed with this package.
   53.12 + *
   53.13 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   53.14 + */
   53.15 +
   53.16 +#include <stdio.h>
   53.17 +#include <syslog.h>
   53.18 +#include <unistd.h>
   53.19 +#include <sys/types.h>
   53.20 +#include <sys/socket.h>
   53.21 +#include <netinet/in.h>
   53.22 +#include <arpa/inet.h>
   53.23 +#include <errno.h>
   53.24 +
   53.25 +#include "common.h"
   53.26 +#include "config.h"
   53.27 +#include "network.h"
   53.28 +
   53.29 +
   53.30 +namespace GLCD
   53.31 +{
   53.32 +
   53.33 +cDriverNetwork::cDriverNetwork(cDriverConfig * config)
   53.34 +:   config(config)
   53.35 +{
   53.36 +    oldConfig = new cDriverConfig(*config);
   53.37 +    childTid = 0;
   53.38 +    running = false;
   53.39 +    clientConnected = false;
   53.40 +}
   53.41 +
   53.42 +cDriverNetwork::~cDriverNetwork()
   53.43 +{
   53.44 +    delete oldConfig;
   53.45 +}
   53.46 +
   53.47 +int cDriverNetwork::Init()
   53.48 +{
   53.49 +    width = config->width;
   53.50 +    if (width <= 0)
   53.51 +        width = 240;
   53.52 +    height = config->height;
   53.53 +    if (height <= 0)
   53.54 +        height = 128;
   53.55 +    lineSize = (width + 7) / 8;
   53.56 +
   53.57 +    for (unsigned int i = 0; i < config->options.size(); i++)
   53.58 +    {
   53.59 +        if (config->options[i].name == "")
   53.60 +        {
   53.61 +        }
   53.62 +    }
   53.63 +
   53.64 +    newLCD = new unsigned char[lineSize * height];
   53.65 +    if (newLCD)
   53.66 +        memset(newLCD, 0, lineSize * height);
   53.67 +    oldLCD = new unsigned char[lineSize * height];
   53.68 +    if (oldLCD)
   53.69 +        memset(oldLCD, 0, lineSize * height);
   53.70 +
   53.71 +    *oldConfig = *config;
   53.72 +
   53.73 +    // clear display
   53.74 +    Clear();
   53.75 +
   53.76 +    running = true;
   53.77 +    if (pthread_create(&childTid, NULL, (void *(*) (void *)) &ServerThread, (void *)this) != 0)
   53.78 +    {
   53.79 +        syslog(LOG_ERR, "%s: error creating server thread.\n", config->name.c_str());
   53.80 +        running = false;
   53.81 +        return 1;
   53.82 +    }
   53.83 +    syslog(LOG_INFO, "%s: network driver initialized.\n", config->name.c_str());
   53.84 +    return 0;
   53.85 +}
   53.86 +
   53.87 +int cDriverNetwork::DeInit()
   53.88 +{
   53.89 +    // stop server thread
   53.90 +    running = false;
   53.91 +    usleep(3000000); // wait 3 seconds
   53.92 +    pthread_cancel(childTid);
   53.93 +    childTid = 0;
   53.94 +
   53.95 +    if (newLCD)
   53.96 +        delete[] newLCD;
   53.97 +    if (oldLCD)
   53.98 +        delete[] oldLCD;
   53.99 +    return 0;
  53.100 +}
  53.101 +
  53.102 +int cDriverNetwork::CheckSetup()
  53.103 +{
  53.104 +    if (config->width != oldConfig->width ||
  53.105 +        config->height != oldConfig->height)
  53.106 +    {
  53.107 +        DeInit();
  53.108 +        Init();
  53.109 +        return 0;
  53.110 +    }
  53.111 +
  53.112 +    if (config->upsideDown != oldConfig->upsideDown ||
  53.113 +        config->invert != oldConfig->invert)
  53.114 +    {
  53.115 +        oldConfig->upsideDown = config->upsideDown;
  53.116 +        oldConfig->invert = config->invert;
  53.117 +        return 1;
  53.118 +    }
  53.119 +    return 0;
  53.120 +}
  53.121 +
  53.122 +void cDriverNetwork::Clear()
  53.123 +{
  53.124 +    memset(newLCD, 0, lineSize * height);
  53.125 +}
  53.126 +
  53.127 +void cDriverNetwork::Set8Pixels(int x, int y, unsigned char data)
  53.128 +{
  53.129 +    if (x >= width || y >= height)
  53.130 +        return;
  53.131 +
  53.132 +    if (!config->upsideDown)
  53.133 +    {
  53.134 +        // normal orientation
  53.135 +        newLCD[lineSize * y + x / 8] |= data;
  53.136 +    }
  53.137 +    else
  53.138 +    {
  53.139 +        // upside down orientation
  53.140 +        x = width - 1 - x;
  53.141 +        y = height - 1 - y;
  53.142 +        newLCD[lineSize * y + x / 8] |= ReverseBits(data);
  53.143 +    }
  53.144 +}
  53.145 +
  53.146 +void cDriverNetwork::Refresh(bool refreshAll)
  53.147 +{
  53.148 +    int i;
  53.149 +    bool refresh;
  53.150 +
  53.151 +    refresh = false;
  53.152 +    if (CheckSetup() > 0)
  53.153 +        refresh = true;
  53.154 +
  53.155 +    for (i = 0; i < lineSize * height; i++)
  53.156 +    {
  53.157 +        if (newLCD[i] != oldLCD[i])
  53.158 +        {
  53.159 +            refresh = true;
  53.160 +            break;
  53.161 +        }
  53.162 +    }
  53.163 +
  53.164 +    if (refresh && clientConnected)
  53.165 +    {
  53.166 +        char msg[1024];
  53.167 +        int x;
  53.168 +        int y;
  53.169 +        int sent;
  53.170 +
  53.171 +        sprintf(msg, "update begin %d %d\r\n", width, height);
  53.172 +        sent = send(clientSocket, msg, strlen(msg), 0);
  53.173 +        if (sent == -1)
  53.174 +        {
  53.175 +            syslog(LOG_ERR, "%s: error sending message: %s.\n", config->name.c_str(), strerror(errno));
  53.176 +            clientConnected = false;
  53.177 +            return;
  53.178 +        }
  53.179 +        for (y = 0; y < height; y++)
  53.180 +        {
  53.181 +            sprintf(msg, "update line %d ", y);
  53.182 +            for (x = 0; x < lineSize; x++)
  53.183 +            {
  53.184 +                char tmp[3];
  53.185 +                sprintf(tmp, "%02X", newLCD[y * lineSize + x]);
  53.186 +                strcat(msg, tmp);
  53.187 +                oldLCD[i] = newLCD[i];
  53.188 +            }
  53.189 +            strcat(msg, "\r\n");
  53.190 +            sent = send(clientSocket, msg, strlen(msg), 0);
  53.191 +            if (sent == -1)
  53.192 +            {
  53.193 +                syslog(LOG_ERR, "%s: error sending message: %s.\n", config->name.c_str(), strerror(errno));
  53.194 +                clientConnected = false;
  53.195 +                return;
  53.196 +            }
  53.197 +        }
  53.198 +        sprintf(msg, "update end\r\n");
  53.199 +        sent = send(clientSocket, msg, strlen(msg), 0);
  53.200 +        if (sent == -1)
  53.201 +        {
  53.202 +            syslog(LOG_ERR, "%s: error sending message: %s.\n", config->name.c_str(), strerror(errno));
  53.203 +            clientConnected = false;
  53.204 +            return;
  53.205 +        }
  53.206 +    }
  53.207 +}
  53.208 +
  53.209 +void * cDriverNetwork::ServerThread(cDriverNetwork * Driver)
  53.210 +{
  53.211 +    int serverSocket;
  53.212 +    struct sockaddr_in address;
  53.213 +    socklen_t addrlen;
  53.214 +    int clientSocket;
  53.215 +    fd_set set;
  53.216 +    fd_set setsave;
  53.217 +    struct timeval timeout;
  53.218 +
  53.219 +    serverSocket = socket(AF_INET, SOCK_STREAM, 0);
  53.220 +    if (serverSocket == -1)
  53.221 +    {
  53.222 +        syslog(LOG_ERR, "%s: error creating server socket.\n", Driver->config->name.c_str());
  53.223 +        return NULL;
  53.224 +    }
  53.225 +
  53.226 +    int y = 1;
  53.227 +    setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &y, sizeof(int));
  53.228 +
  53.229 +    address.sin_family = AF_INET;
  53.230 +    address.sin_addr.s_addr = INADDR_ANY;
  53.231 +    address.sin_port = htons(2003);
  53.232 +    if (bind(serverSocket, (struct sockaddr *) &address, sizeof(address)) != 0)
  53.233 +    {
  53.234 +        syslog(LOG_ERR, "%s: error port %d is already used.\n", Driver->config->name.c_str(), 2003);
  53.235 +        return NULL;
  53.236 +    }
  53.237 +
  53.238 +    listen(serverSocket, 1);
  53.239 +    addrlen = sizeof(struct sockaddr_in);
  53.240 +
  53.241 +    FD_ZERO(&set);
  53.242 +    FD_SET(serverSocket, &set);
  53.243 +    setsave = set;
  53.244 +
  53.245 +    while (Driver->running)
  53.246 +    {
  53.247 +        set = setsave;
  53.248 +        timeout.tv_sec = 1;
  53.249 +        timeout.tv_usec = 0;
  53.250 +        if (select(FD_SETSIZE, &set, NULL, NULL, &timeout) < 0)
  53.251 +        {
  53.252 +            syslog(LOG_ERR, "%s: error during select.\n", Driver->config->name.c_str());
  53.253 +            break;
  53.254 +        }
  53.255 +
  53.256 +        if (FD_ISSET(serverSocket, &set))
  53.257 +        {
  53.258 +            clientSocket = accept(serverSocket, (struct sockaddr *) &address, &addrlen);
  53.259 +            if (clientSocket > 0)
  53.260 +            {
  53.261 +                Driver->clientSocket = clientSocket;
  53.262 +                Driver->clientConnected = true;
  53.263 +            }
  53.264 +        }
  53.265 +    }
  53.266 +    close(serverSocket);
  53.267 +    return NULL;
  53.268 +}
  53.269 +
  53.270 +} // end of namespace
    54.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    54.2 +++ b/graphlcd-base/glcddrivers/network.h	Wed Feb 06 17:32:55 2008 +0000
    54.3 @@ -0,0 +1,56 @@
    54.4 +/*
    54.5 + * GraphLCD driver library
    54.6 + *
    54.7 + * network.h  -  Network output device
    54.8 + *               Output goes to a network client.
    54.9 + *
   54.10 + * This file is released under the GNU General Public License. Refer
   54.11 + * to the COPYING file distributed with this package.
   54.12 + *
   54.13 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   54.14 + */
   54.15 +
   54.16 +#ifndef _GLCDDRIVERS_NETWORK_H_
   54.17 +#define _GLCDDRIVERS_NETWORK_H_
   54.18 +
   54.19 +#include <pthread.h>
   54.20 +
   54.21 +#include "driver.h"
   54.22 +
   54.23 +
   54.24 +namespace GLCD
   54.25 +{
   54.26 +
   54.27 +class cDriverConfig;
   54.28 +
   54.29 +class cDriverNetwork : public cDriver
   54.30 +{
   54.31 +private:
   54.32 +    unsigned char * newLCD;
   54.33 +    unsigned char * oldLCD;
   54.34 +    cDriverConfig * config;
   54.35 +    cDriverConfig * oldConfig;
   54.36 +    int lineSize;
   54.37 +    bool running;
   54.38 +    pthread_t childTid;
   54.39 +    int clientSocket;
   54.40 +    bool clientConnected;
   54.41 +
   54.42 +    int CheckSetup();
   54.43 +    static void * ServerThread(cDriverNetwork * Driver);
   54.44 +
   54.45 +public:
   54.46 +    cDriverNetwork(cDriverConfig * config);
   54.47 +    virtual ~cDriverNetwork();
   54.48 +
   54.49 +    virtual int Init();
   54.50 +    virtual int DeInit();
   54.51 +
   54.52 +    virtual void Clear();
   54.53 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   54.54 +    virtual void Refresh(bool refreshAll = false);
   54.55 +};
   54.56 +
   54.57 +} // end of namespace
   54.58 +
   54.59 +#endif
    55.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    55.2 +++ b/graphlcd-base/glcddrivers/noritake800.c	Wed Feb 06 17:32:55 2008 +0000
    55.3 @@ -0,0 +1,537 @@
    55.4 +/*
    55.5 + * GraphLCD driver library
    55.6 + *
    55.7 + * noritake800.c  -  Noritake 800(A) series VFD graphlcd driver,
    55.8 + *                   different "Medium 0.6 dot" sizes should work,
    55.9 + *                   see http://www.noritake-itron.com:
   55.10 + *                    - GU128X64-800A,
   55.11 + *                    - GU256X32-800A,
   55.12 + *                    - GU128X32-800A,
   55.13 + *                    - GU160X16-800A,
   55.14 + *                    - GU160X32-800A,
   55.15 + *                    - GU192X16-800A.
   55.16 + *
   55.17 + * based on:
   55.18 + *   ideas and HW-command related stuff from the open source project
   55.19 + *   "lcdplugin for Winamp":
   55.20 + *     (c) 1999 - 2003 Markus Zehnder <lcdplugin AT markuszehnder.ch>
   55.21 + *   GU256x64-372 driver module for graphlcd
   55.22 + *     (c) 20040410 Andreas 'Randy' Weinberger <randy AT smue.org>
   55.23 + *   gu140x32f driver module for graphlcd
   55.24 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab de>
   55.25 + *   HD61830 device
   55.26 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   55.27 + *   lcdproc 0.4 driver hd44780-ext8bit
   55.28 + *     (c) 1999, 1995 Benjamin Tse <blt AT Comports.com>
   55.29 + *
   55.30 + * This file is released under the GNU General Public License. Refer
   55.31 + * to the COPYING file distributed with this package.
   55.32 + *
   55.33 + * (c) 2004 Lucian Muresan <lucianm AT users.sourceforge.net>
   55.34 + */
   55.35 +
   55.36 +#include <errno.h>
   55.37 +#include <syslog.h>
   55.38 +#include <unistd.h>
   55.39 +#include <sys/time.h>
   55.40 +
   55.41 +#include "common.h"
   55.42 +#include "config.h"
   55.43 +#include "noritake800.h"
   55.44 +#include "port.h"
   55.45 +
   55.46 +namespace GLCD
   55.47 +{
   55.48 +
   55.49 +/* LPT Control Port lines */
   55.50 +#define LPT_CTL_HI_DIR      0x20
   55.51 +#define LPT_CTL_HI_IRQEN    0x10
   55.52 +#define LPT_CTL_LO_STROBE   0x01
   55.53 +#define LPT_CTL_LO_LFEED    0x02
   55.54 +#define LPT_CTL_LO_INIT     0x04
   55.55 +#define LPT_CTL_LO_SELECT   0x08
   55.56 +
   55.57 +/* Noritake 800(A) VFD control signals bit masks*/
   55.58 +#define VFDSGN_CD   0x01
   55.59 +#define VFDSGN_WR   0x02
   55.60 +#define VFDSGN_RD   0x04
   55.61 +#define VFDSGN_CSS  0x08
   55.62 +
   55.63 +//wirings
   55.64 +#define WIRING_LIQUIDMP3 0
   55.65 +static const std::string kWiringLiquidmp3 = "LiquidMp3";
   55.66 +#define WIRING_MZ  1
   55.67 +static const std::string kWiringMZ = "MZ";
   55.68 +// ... other wirings may follow
   55.69 +
   55.70 +/* Command set for this display */
   55.71 +#define ANDCNTL         0x03
   55.72 +#define ORCNTL          0x01
   55.73 +#define XORCNTL         0x02
   55.74 +#define Init800A        0x5F /* initialization code sequence 5f */
   55.75 +#define Init800B        0x62
   55.76 +#define Init800C        0x00+n
   55.77 +#define Init800D        0xFF
   55.78 +#define CLEARSCREENS    0x5e /* clear all screens (layers) */
   55.79 +#define LAYER0ON        0x24 /* screen0 both on */
   55.80 +#define LAYER1ON        0x28 /* screen1 both on */
   55.81 +#define LAYERSON        0x2c /* both screens both on */
   55.82 +#define LAYERSOFF       0x20 /* screens both off */
   55.83 +#define ORON            0x40 /* OR screens */
   55.84 +#define ANDON           0x48 /* AND screens */
   55.85 +#define XORON           0x44 /* XOR screens */
   55.86 +#define SETX            0x64 /* set X position */
   55.87 +#define SETY            0x60 /* set Y position */
   55.88 +#define HSHIFT          0x70 /* set horizontal shift */
   55.89 +#define VSHIFT          0xB0
   55.90 +#define AUTOINCOFF      0x80 /* address auto increment off */
   55.91 +#define SETPOSITION     0xff
   55.92 +
   55.93 +
   55.94 +cDriverNoritake800::cDriverNoritake800(cDriverConfig * config)
   55.95 +{
   55.96 +    int x = 0;
   55.97 +    m_bGraphScreen0_On = true;
   55.98 +    m_bGraphScreen1_On = false;
   55.99 +    // default initilaization for the wiring
  55.100 +    m_nWiring = WIRING_LIQUIDMP3;
  55.101 +
  55.102 +    m_Config = config;
  55.103 +    m_oldConfig = new cDriverConfig(* config);
  55.104 +
  55.105 +    m_pport = new cParallelPort();
  55.106 +
  55.107 +    m_nTimingAdjustCmd = 0;
  55.108 +    m_nRefreshCounter = 0;
  55.109 +
  55.110 +    width = m_Config->width;      // 128
  55.111 +    if (width <= 0)
  55.112 +        width = 128;
  55.113 +    height = m_Config->height;    //  64
  55.114 +    if (height <= 0)
  55.115 +        height = 64;
  55.116 +    m_iSizeYb = (height + 7)/8;   //   8
  55.117 +
  55.118 +    //
  55.119 +    // initialize wiring
  55.120 +    //
  55.121 +    for (unsigned int i = 0; i < m_Config->options.size(); i++)
  55.122 +    {
  55.123 +        if (m_Config->options[i].name == "Wiring")
  55.124 +        {
  55.125 +            if (m_Config->options[i].value == kWiringLiquidmp3)
  55.126 +            {
  55.127 +                m_nWiring = WIRING_LIQUIDMP3;
  55.128 +            }
  55.129 +            else if (m_Config->options[i].value == kWiringMZ)
  55.130 +            {
  55.131 +                m_nWiring = WIRING_MZ;
  55.132 +            }
  55.133 +            else
  55.134 +                syslog(LOG_ERR, "%s error: wiring %s not supported, using default wiring(%s)!\n",
  55.135 +                       config->name.c_str(), config->options[i].value.c_str(), kWiringLiquidmp3.c_str());
  55.136 +        }
  55.137 +    }
  55.138 +    // fill the wiring mask cache for all the 16 possibilities
  55.139 +    m_pWiringMaskCache = new unsigned char[16];
  55.140 +    for (unsigned int i = 0; i < 16; i++)
  55.141 +    {
  55.142 +        m_pWiringMaskCache[i] = N800LptWiringMask(i);
  55.143 +    }
  55.144 +
  55.145 +    // setup linear lcd array
  55.146 +    m_pDrawMem = new unsigned char*[width];
  55.147 +    if (m_pDrawMem)
  55.148 +    {
  55.149 +        for (x = 0; x < width; x++)
  55.150 +        {
  55.151 +            m_pDrawMem[x] = new unsigned char[m_iSizeYb];
  55.152 +            memset(m_pDrawMem[x], 0, m_iSizeYb);
  55.153 +        }
  55.154 +    }
  55.155 +    Clear();
  55.156 +
  55.157 +    // setup the lcd array for the "vertikal" mem
  55.158 +    m_pVFDMem = new unsigned char*[width];
  55.159 +    if (m_pVFDMem)
  55.160 +    {
  55.161 +        for (x = 0; x < width; x++)
  55.162 +        {
  55.163 +            m_pVFDMem[x] = new unsigned char[m_iSizeYb];
  55.164 +            memset(m_pVFDMem[x], 0, m_iSizeYb);
  55.165 +        }
  55.166 +    }
  55.167 +    ClearVFDMem();
  55.168 +}
  55.169 +
  55.170 +cDriverNoritake800::~cDriverNoritake800()
  55.171 +{
  55.172 +    int x;
  55.173 +
  55.174 +    if (m_pVFDMem)
  55.175 +        for (x = 0; x < (width + 7) / 8; x++)
  55.176 +        {
  55.177 +            delete[] m_pVFDMem[x];
  55.178 +        }
  55.179 +    delete[] m_pVFDMem;
  55.180 +    if (m_pDrawMem)
  55.181 +        for (x = 0; x < (width + 7) / 8; x++)
  55.182 +        {
  55.183 +            delete[] m_pDrawMem[x];
  55.184 +        }
  55.185 +    delete[] m_pDrawMem;
  55.186 +    delete[] m_pWiringMaskCache;
  55.187 +    delete m_oldConfig;
  55.188 +    delete m_pport;
  55.189 +}
  55.190 +
  55.191 +void cDriverNoritake800::Clear()
  55.192 +{
  55.193 +    for (int x = 0; x < width; x++)
  55.194 +    {
  55.195 +        memset(m_pDrawMem[x], 0, m_iSizeYb);
  55.196 +    }
  55.197 +}
  55.198 +
  55.199 +void cDriverNoritake800::ClearVFDMem()
  55.200 +{
  55.201 +    for (int x = 0; x < width; x++)
  55.202 +    {
  55.203 +        memset(m_pVFDMem[x], 0, m_iSizeYb);
  55.204 +    }
  55.205 +}
  55.206 +
  55.207 +int cDriverNoritake800::DeInit()
  55.208 +{
  55.209 +    if (m_pport->Close() != 0)
  55.210 +        return -1;
  55.211 +    return 0;
  55.212 +}
  55.213 +
  55.214 +int cDriverNoritake800::CheckSetup()
  55.215 +{
  55.216 +    if (m_Config->device != m_oldConfig->device ||
  55.217 +        m_Config->port != m_oldConfig->port ||
  55.218 +        m_Config->width != m_oldConfig->width ||
  55.219 +        m_Config->height != m_oldConfig->height)
  55.220 +    {
  55.221 +        DeInit();
  55.222 +        Init();
  55.223 +        return 0;
  55.224 +    }
  55.225 +
  55.226 +    if (m_Config->brightness != m_oldConfig->brightness)
  55.227 +    {
  55.228 +        m_oldConfig->brightness = m_Config->brightness;
  55.229 +        SetBrightness(m_Config->brightness);
  55.230 +    }
  55.231 +
  55.232 +    if (m_Config->upsideDown != m_oldConfig->upsideDown ||
  55.233 +        m_Config->invert != m_oldConfig->invert)
  55.234 +    {
  55.235 +        m_oldConfig->upsideDown = m_Config->upsideDown;
  55.236 +        m_oldConfig->invert = m_Config->invert;
  55.237 +        return 1;
  55.238 +    }
  55.239 +    return 0;
  55.240 +}
  55.241 +
  55.242 +int cDriverNoritake800::Init()
  55.243 +{
  55.244 +    int x;
  55.245 +    struct timeval tv1, tv2;
  55.246 +
  55.247 +    if (m_Config->device == "")
  55.248 +    {
  55.249 +        // use DirectIO
  55.250 +        if (m_pport->Open(m_Config->port) != 0)
  55.251 +            return -1;
  55.252 +        uSleep(10);
  55.253 +    }
  55.254 +    else
  55.255 +    {
  55.256 +        // use ppdev
  55.257 +        if (m_pport->Open(m_Config->device.c_str()) != 0)
  55.258 +            return -1;
  55.259 +    }
  55.260 +
  55.261 +    if (nSleepInit() != 0)
  55.262 +    {
  55.263 +        syslog(LOG_ERR, "%s: INFO: cannot change wait parameters  Err: %s (cDriver::Init)\n", m_Config->name.c_str(), strerror(errno));
  55.264 +        m_bSleepIsInit = false;
  55.265 +    }
  55.266 +    else
  55.267 +    {
  55.268 +        m_bSleepIsInit = true;
  55.269 +    }
  55.270 +
  55.271 +    // benchmark port access
  55.272 +    m_pport->Claim();
  55.273 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", m_Config->name.c_str());
  55.274 +    gettimeofday(&tv1, 0);
  55.275 +    int nBenchFactor = 100000;
  55.276 +    for (x = 0; x < nBenchFactor; x++)
  55.277 +    {
  55.278 +        m_pport->WriteData(x % 0x100);
  55.279 +    }
  55.280 +    gettimeofday(&tv2, 0);
  55.281 +    nSleepDeInit();
  55.282 +    //m_nTimingAdjustCmd = ((tv2.tv_sec - tv1.tv_sec) * 10000 + (tv2.tv_usec - tv1.tv_usec)) / 1000;
  55.283 +    m_nTimingAdjustCmd = long(double((tv2.tv_sec - tv1.tv_sec) * 1000 + (tv2.tv_usec - tv1.tv_usec)) / double(nBenchFactor));
  55.284 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Port Command: %ldns\n", m_Config->name.c_str(), m_nTimingAdjustCmd);
  55.285 +    m_pport->Release();
  55.286 +
  55.287 +
  55.288 +    // initialize display
  55.289 +    N800Cmd(Init800A);
  55.290 +
  55.291 +    int n;
  55.292 +    for (n=0; n < 15; n++)
  55.293 +    {
  55.294 +        N800Cmd(0x62);
  55.295 +        nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.296 +        N800Cmd(n);
  55.297 +        nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.298 +        N800Data(0xff);
  55.299 +        nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.300 +    }
  55.301 +    nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.302 +
  55.303 +
  55.304 +    N800Cmd(LAYERSOFF | LAYER0ON); // layer 0 of the graphic RAM on
  55.305 +    N800Cmd(ORON);     // OR the layers
  55.306 +    N800Cmd(HSHIFT);    // set horizontal shift
  55.307 +    N800Cmd(0x00);     // no shift
  55.308 +    N800Cmd(VSHIFT);    // Vertical shift =0
  55.309 +    N800Cmd(AUTOINCOFF);   // auto increment off
  55.310 +    N800Cmd(SETX);     // set x coord
  55.311 +    N800Cmd(0x40);     // to 0
  55.312 +    N800Cmd(SETY);     // set y coord
  55.313 +    N800Cmd(0);      // to 0
  55.314 +
  55.315 +    m_pport->Release();
  55.316 +
  55.317 +    *m_oldConfig = *m_Config;
  55.318 +
  55.319 +    // Set Display SetBrightness
  55.320 +    SetBrightness(m_Config->brightness);
  55.321 +    // clear display
  55.322 +    ClearVFDMem();
  55.323 +    Refresh(true);
  55.324 +
  55.325 +    syslog(LOG_INFO, "%s: initialization done.\n", m_Config->name.c_str());
  55.326 +    return 0;
  55.327 +}
  55.328 +
  55.329 +void cDriverNoritake800::Refresh(bool refreshAll)
  55.330 +{
  55.331 +    //
  55.332 +    // for VFD displays, we can safely ignore refreshAll, as they are "sticky"
  55.333 +    //
  55.334 +    int xb, yb;
  55.335 +
  55.336 +    if (CheckSetup() > 0)
  55.337 +        refreshAll = true;  // we don't use it
  55.338 +
  55.339 +    if (!m_pVFDMem || !m_pDrawMem)
  55.340 +        return;
  55.341 +
  55.342 +//  // just refresh if the time needed between refreshes is up
  55.343 +//  m_nRefreshCounter = (m_nRefreshCounter + 1) % m_Config->refreshDisplay;
  55.344 +//  if(!m_nRefreshCounter)
  55.345 +//  {
  55.346 +    m_pport->Claim();
  55.347 +    for (xb = 0; xb < width; ++xb)
  55.348 +    {
  55.349 +        for (yb = 0; yb < m_iSizeYb; ++yb)
  55.350 +        {
  55.351 +            if (m_pVFDMem[xb][yb] != m_pDrawMem[xb][yb])
  55.352 +            {
  55.353 +                m_pVFDMem[xb][yb] = m_pDrawMem[xb][yb];
  55.354 +                // reset RefreshCounter
  55.355 +                m_nRefreshCounter = 0;
  55.356 +                // actually write to display
  55.357 +                N800WriteByte(
  55.358 +                    (m_pVFDMem[xb][yb]) ^ ((m_Config->invert != 0) ? 0xff : 0x00),
  55.359 +                    xb,
  55.360 +                    yb,
  55.361 +                    0);
  55.362 +            }
  55.363 +        }
  55.364 +    }
  55.365 +    m_pport->Release();
  55.366 +//  }
  55.367 +}
  55.368 +
  55.369 +void cDriverNoritake800::N800Cmd(unsigned char data)
  55.370 +{
  55.371 +    if (m_bSleepIsInit)
  55.372 +        nSleepInit();
  55.373 +
  55.374 +    // set direction to "port_output" & C/D to C
  55.375 +    m_pport->WriteControl(m_pWiringMaskCache[0x00]);
  55.376 +    // write to data port
  55.377 +    m_pport->WriteData(data);
  55.378 +    //nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.379 +    // set /WR on the control port
  55.380 +    m_pport->WriteControl(m_pWiringMaskCache[VFDSGN_WR]);
  55.381 +    //nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.382 +    // reset /WR on the control port
  55.383 +    m_pport->WriteControl(m_pWiringMaskCache[0x00]);
  55.384 +    //nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.385 +    // set direction to "port_input"
  55.386 +    m_pport->WriteControl(LPT_CTL_HI_DIR | m_pWiringMaskCache[0x00]);
  55.387 +}
  55.388 +
  55.389 +void cDriverNoritake800::N800Data(unsigned char data)
  55.390 +{
  55.391 +    if (m_bSleepIsInit)
  55.392 +        nSleepInit();
  55.393 +
  55.394 +    // set direction to "port_output" & C/D to C
  55.395 +    m_pport->WriteControl(m_pWiringMaskCache[VFDSGN_CD]);
  55.396 +    // write to data port
  55.397 +    m_pport->WriteData(data);
  55.398 +    //nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.399 +    // set /WR on the control port
  55.400 +    m_pport->WriteControl(m_pWiringMaskCache[VFDSGN_CD | VFDSGN_WR]);
  55.401 +    //nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.402 +    // reset /WR on the control port
  55.403 +    m_pport->WriteControl(m_pWiringMaskCache[VFDSGN_CD]);
  55.404 +    //nSleep(100 + (100 * m_Config->adjustTiming) - m_nTimingAdjustCmd);
  55.405 +    // set direction to "port_input"
  55.406 +    m_pport->WriteControl(LPT_CTL_HI_DIR | m_pWiringMaskCache[0x00]);
  55.407 +}
  55.408 +
  55.409 +void cDriverNoritake800::SetPixel(int x, int y)
  55.410 +{
  55.411 +    unsigned char c;
  55.412 +
  55.413 +    if (!m_pDrawMem)
  55.414 +        return;
  55.415 +
  55.416 +    if (x >= width || x < 0)
  55.417 +        return;
  55.418 +    if (y >= height || y < 0)
  55.419 +        return;
  55.420 +
  55.421 +    if (m_Config->upsideDown)
  55.422 +    {
  55.423 +        x = width - 1 - x;
  55.424 +        y = height - 1 - y;
  55.425 +    }
  55.426 +
  55.427 +    c = 0x80 >> (y % 8);
  55.428 +
  55.429 +    m_pDrawMem[x][y/8] |= c;
  55.430 +}
  55.431 +
  55.432 +void cDriverNoritake800::Set8Pixels(int x, int y, unsigned char data)
  55.433 +{
  55.434 +    int n;
  55.435 +
  55.436 +    // x - pos is'nt mayby align to 8
  55.437 +    x &= 0xFFF8;
  55.438 +
  55.439 +    for (n = 0; n < 8; ++n)
  55.440 +    {
  55.441 +        if (data & (0x80 >> n))      // if bit is set
  55.442 +            SetPixel(x + n, y);
  55.443 +    }
  55.444 +}
  55.445 +
  55.446 +void cDriverNoritake800::SetBrightness(unsigned int percent)
  55.447 +{
  55.448 +    // display can do 16 brightness levels,
  55.449 +    //  0 = light
  55.450 +    // 15 = dark
  55.451 +
  55.452 +    // convert from "light percentage" into darkness values from 0 to 15
  55.453 +    if (percent > 100)
  55.454 +    {
  55.455 +        percent = 100;
  55.456 +    }
  55.457 +    unsigned int darkness = 16 - (unsigned int)((double)percent * 16.0 / 100.0);
  55.458 +
  55.459 +    m_pport->Claim();
  55.460 +    N800Cmd(0x40 + (darkness & 0xf));
  55.461 +    m_pport->Release();
  55.462 +}
  55.463 +
  55.464 +unsigned char cDriverNoritake800::N800LptWiringMask(unsigned char ctrl_bits)
  55.465 +{
  55.466 +    unsigned char newstatus = 0x0;
  55.467 +
  55.468 +    if (m_nWiring == WIRING_LIQUIDMP3)
  55.469 +    {
  55.470 +        if (ctrl_bits & VFDSGN_CSS)
  55.471 +            newstatus |= LPT_CTL_LO_STROBE;
  55.472 +        else
  55.473 +            newstatus &= ~LPT_CTL_LO_STROBE;
  55.474 +
  55.475 +        if (ctrl_bits & VFDSGN_RD)
  55.476 +            newstatus |= LPT_CTL_LO_LFEED;
  55.477 +        else
  55.478 +            newstatus &= ~LPT_CTL_LO_LFEED;
  55.479 +
  55.480 +        if (ctrl_bits & VFDSGN_WR)
  55.481 +            newstatus |= LPT_CTL_LO_INIT;
  55.482 +        else
  55.483 +            newstatus &= ~LPT_CTL_LO_INIT;
  55.484 +
  55.485 +        if (ctrl_bits & VFDSGN_CD)
  55.486 +            newstatus |= LPT_CTL_LO_SELECT;
  55.487 +        else
  55.488 +            newstatus &= ~LPT_CTL_LO_SELECT;
  55.489 +
  55.490 +        // control commands are XOR-ed with 0x5
  55.491 +        // to account for active lows and highs
  55.492 +        newstatus ^= 0x5;
  55.493 +    }
  55.494 +    else if (m_nWiring == WIRING_MZ)
  55.495 +    {
  55.496 +        if (ctrl_bits & VFDSGN_CSS)
  55.497 +            newstatus |= LPT_CTL_LO_INIT;
  55.498 +        else
  55.499 +            newstatus &= ~LPT_CTL_LO_INIT;
  55.500 +
  55.501 +        if (ctrl_bits & VFDSGN_RD)
  55.502 +            newstatus |= LPT_CTL_LO_LFEED;
  55.503 +        else
  55.504 +            newstatus &= ~LPT_CTL_LO_LFEED;
  55.505 +
  55.506 +        if (ctrl_bits & VFDSGN_WR)
  55.507 +            newstatus |= LPT_CTL_LO_STROBE;
  55.508 +        else
  55.509 +            newstatus &= ~LPT_CTL_LO_STROBE;
  55.510 +
  55.511 +        if (ctrl_bits & VFDSGN_CD)
  55.512 +            newstatus |= LPT_CTL_LO_SELECT;
  55.513 +        else
  55.514 +            newstatus &= ~LPT_CTL_LO_SELECT;
  55.515 +    }
  55.516 +    return newstatus;
  55.517 +}
  55.518 +
  55.519 +void cDriverNoritake800::N800WriteByte(unsigned char data, int nCol, int nRow, int layer)
  55.520 +{
  55.521 +    /* set cursor to desired address */
  55.522 +    N800Cmd(SETX);           /* set upper cursor address */
  55.523 +    N800Cmd(nCol);
  55.524 +
  55.525 +    if (layer==0)
  55.526 +    {
  55.527 +        N800Cmd(SETY);     /* set lower cursor address */
  55.528 +        N800Cmd(nRow);     /*layer0 */
  55.529 +    }
  55.530 +    else if (layer==1)
  55.531 +    {
  55.532 +        N800Cmd(SETY);      /* set lower cursor address */
  55.533 +        N800Cmd(nRow+8);    /* layer 1 */
  55.534 +    }
  55.535 +
  55.536 +    N800Data(ReverseBits(data));
  55.537 +}
  55.538 +
  55.539 +} // end of namespace
  55.540 +
    56.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    56.2 +++ b/graphlcd-base/glcddrivers/noritake800.h	Wed Feb 06 17:32:55 2008 +0000
    56.3 @@ -0,0 +1,92 @@
    56.4 +/*
    56.5 + * GraphLCD driver library
    56.6 + *
    56.7 + * noritake800.h  -  Noritake 800(A) series VFD graphlcd driver,
    56.8 + *                   different "Medium 0.6 dot" sizes should work,
    56.9 + *                   see http://www.noritake-itron.com:
   56.10 + *                    - GU128X64-800A,
   56.11 + *                    - GU256X32-800A,
   56.12 + *                    - GU128X32-800A,
   56.13 + *                    - GU160X16-800A,
   56.14 + *                    - GU160X32-800A,
   56.15 + *                    - GU192X16-800A.
   56.16 + *
   56.17 + * based on:
   56.18 + *   ideas and HW-command related stuff from the open source project
   56.19 + *   "lcdplugin for Winamp":
   56.20 + *     (c) 1999 - 2003 Markus Zehnder <lcdplugin AT markuszehnder.ch>
   56.21 + *   GU256x64-372 driver module for graphlcd
   56.22 + *     (c) 20040410 Andreas 'Randy' Weinberger <randy AT smue.org>
   56.23 + *   gu140x32f driver module for graphlcd
   56.24 + *     (c) 2003 Andreas Brachold <vdr04 AT deltab de>
   56.25 + *   HD61830 device
   56.26 + *     (c) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   56.27 + *   lcdproc 0.4 driver hd44780-ext8bit
   56.28 + *     (c) 1999, 1995 Benjamin Tse <blt AT Comports.com>
   56.29 + *
   56.30 + * This file is released under the GNU General Public License. Refer
   56.31 + * to the COPYING file distributed with this package.
   56.32 + *
   56.33 + * (c) 2004 Lucian Muresan <lucianm AT users.sourceforge.net>
   56.34 + */
   56.35 +
   56.36 +#ifndef _GLCDDRIVERS_NORITAKE800_H_
   56.37 +#define _GLCDDRIVERS_NORITAKE800_H_
   56.38 +
   56.39 +#include "driver.h"
   56.40 +
   56.41 +namespace GLCD
   56.42 +{
   56.43 +
   56.44 +class cDriverConfig;
   56.45 +class cParallelPort;
   56.46 +
   56.47 +class cDriverNoritake800 : public cDriver
   56.48 +{
   56.49 +    cParallelPort * m_pport;
   56.50 +
   56.51 +    cDriverConfig * m_Config;
   56.52 +    cDriverConfig * m_oldConfig;
   56.53 +
   56.54 +    int m_iSizeYb;
   56.55 +    int m_nRefreshCounter;
   56.56 +    int m_nWiring;
   56.57 +
   56.58 +    unsigned char ** m_pDrawMem;             /* the draw "memory" */
   56.59 +    unsigned char ** m_pVFDMem;              /* the double buffed display "memory" */
   56.60 +
   56.61 +    long m_nTimingAdjustCmd;
   56.62 +    bool m_bSleepIsInit;
   56.63 +
   56.64 +    // internal graphics layers
   56.65 +    bool m_bGraphScreen0_On;
   56.66 +    bool m_bGraphScreen1_On;
   56.67 +
   56.68 +    unsigned char * m_pWiringMaskCache;
   56.69 +
   56.70 +protected:
   56.71 +    void ClearVFDMem();
   56.72 +    void N800Cmd(unsigned char data);
   56.73 +    void N800Data(unsigned char data);
   56.74 +    int CheckSetup();
   56.75 +    unsigned char N800LptWiringMask(unsigned char ctrl_bits);
   56.76 +    void N800WriteByte(unsigned char data, int nCol, int nRow, int layer);
   56.77 +
   56.78 +public:
   56.79 +    cDriverNoritake800(cDriverConfig * config);
   56.80 +    virtual ~cDriverNoritake800();
   56.81 +
   56.82 +    virtual int Init();
   56.83 +    virtual int DeInit();
   56.84 +
   56.85 +    virtual void Clear();
   56.86 +    virtual void SetPixel(int x, int y);
   56.87 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   56.88 +    virtual void Refresh(bool refreshAll = false);
   56.89 +
   56.90 +    virtual void SetBrightness(unsigned int percent);
   56.91 +};
   56.92 +
   56.93 +} // end of namespace
   56.94 +
   56.95 +#endif
    57.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    57.2 +++ b/graphlcd-base/glcddrivers/port.c	Wed Feb 06 17:32:55 2008 +0000
    57.3 @@ -0,0 +1,350 @@
    57.4 +/*
    57.5 + * GraphLCD driver library
    57.6 + *
    57.7 + * port.c  -  parallel port class with low level routines
    57.8 + *
    57.9 + * This file is released under the GNU General Public License. Refer
   57.10 + * to the COPYING file distributed with this package.
   57.11 + *
   57.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   57.13 + */
   57.14 +
   57.15 +#include <errno.h>
   57.16 +#include <fcntl.h>
   57.17 +#include <stdio.h>
   57.18 +#include <string.h>
   57.19 +#include <syslog.h>
   57.20 +#include <unistd.h>
   57.21 +#include <termios.h>
   57.22 +#include <sys/io.h>
   57.23 +#include <sys/ioctl.h>
   57.24 +#include <linux/ppdev.h>
   57.25 +#include <linux/parport.h>
   57.26 +
   57.27 +
   57.28 +
   57.29 +#include "port.h"
   57.30 +
   57.31 +namespace GLCD
   57.32 +{
   57.33 +
   57.34 +static inline int port_in(int port)
   57.35 +{
   57.36 +    unsigned char value;
   57.37 +    __asm__ volatile ("inb %1,%0"
   57.38 +                      : "=a" (value)
   57.39 +                      : "d" ((unsigned short) port));
   57.40 +    return value;
   57.41 +}
   57.42 +
   57.43 +static inline void port_out(unsigned short int port, unsigned char val)
   57.44 +{
   57.45 +    __asm__ volatile ("outb %0,%1\n"
   57.46 +                      :
   57.47 +                      : "a" (val), "d" (port));
   57.48 +}
   57.49 +
   57.50 +cParallelPort::cParallelPort()
   57.51 +:   fd(-1),
   57.52 +    port(0),
   57.53 +    usePPDev(false)
   57.54 +{
   57.55 +}
   57.56 +
   57.57 +cParallelPort::~cParallelPort()
   57.58 +{
   57.59 +}
   57.60 +
   57.61 +int cParallelPort::Open(int portIO)
   57.62 +{
   57.63 +    usePPDev = false;
   57.64 +    port = portIO;
   57.65 +
   57.66 +    if (port < 0x400)
   57.67 +    {
   57.68 +        if (ioperm(port, 3, 255) == -1)
   57.69 +        {
   57.70 +            syslog(LOG_ERR, "glcd drivers: ERROR ioperm(0x%X) failed! Err:%s (cParallelPort::Open)\n",
   57.71 +                   port, strerror(errno));
   57.72 +            return -1;
   57.73 +        }
   57.74 +    }
   57.75 +    else
   57.76 +    {
   57.77 +        if (iopl(3) == -1)
   57.78 +        {
   57.79 +            syslog(LOG_ERR, "glcd drivers: ERROR iopl failed! Err:%s (cParallelPort::Init)\n",
   57.80 +                   strerror(errno));
   57.81 +            return -1;
   57.82 +        }
   57.83 +    }
   57.84 +    return 0;
   57.85 +}
   57.86 +
   57.87 +int cParallelPort::Open(const char * device)
   57.88 +{
   57.89 +    usePPDev = true;
   57.90 +
   57.91 +    fd = open(device, O_RDWR);
   57.92 +    if (fd == -1)
   57.93 +    {
   57.94 +        syslog(LOG_ERR, "glcd drivers: ERROR cannot open %s. Err:%s (cParallelPort::Init)\n",
   57.95 +               device, strerror(errno));
   57.96 +        return -1;
   57.97 +    }
   57.98 +
   57.99 +    if (ioctl(fd, PPCLAIM, NULL) == -1)
  57.100 +    {
  57.101 +        syslog(LOG_ERR, "glcd drivers: ERROR cannot claim %s. Err:%s (cParallelPort::Init)\n",
  57.102 +               device, strerror(errno));
  57.103 +        close(fd);
  57.104 +        return -1;
  57.105 +    }
  57.106 +
  57.107 +    int mode = PARPORT_MODE_PCSPP;
  57.108 +    if (ioctl(fd, PPSETMODE, &mode) == -1)
  57.109 +    {
  57.110 +        syslog(LOG_ERR, "glcd drivers: ERROR cannot setmode %s. Err:%s (cParallelPort::Init)\n",
  57.111 +               device, strerror(errno));
  57.112 +        close(fd);
  57.113 +        return -1;
  57.114 +    }
  57.115 +
  57.116 +    return 0;
  57.117 +}
  57.118 +
  57.119 +int cParallelPort::Close()
  57.120 +{
  57.121 +    if (usePPDev)
  57.122 +    {
  57.123 +        if (fd != -1)
  57.124 +        {
  57.125 +            ioctl(fd, PPRELEASE);
  57.126 +            close(fd);
  57.127 +            fd = -1;
  57.128 +        }
  57.129 +        else
  57.130 +        {
  57.131 +            return -1;
  57.132 +        }
  57.133 +    }
  57.134 +    else
  57.135 +    {
  57.136 +        if (port < 0x400)
  57.137 +        {
  57.138 +            if (ioperm(port, 3, 0) == -1)
  57.139 +            {
  57.140 +                return -1;
  57.141 +            }
  57.142 +        }
  57.143 +        else
  57.144 +        {
  57.145 +            if (iopl(0) == -1)
  57.146 +            {
  57.147 +                return -1;
  57.148 +            }
  57.149 +        }
  57.150 +    }
  57.151 +    return 0;
  57.152 +}
  57.153 +
  57.154 +void cParallelPort::Claim()
  57.155 +{
  57.156 +    if (usePPDev)
  57.157 +        ioctl(fd, PPCLAIM);
  57.158 +}
  57.159 +
  57.160 +void cParallelPort::Release()
  57.161 +{
  57.162 +    if (usePPDev)
  57.163 +        ioctl(fd, PPRELEASE);
  57.164 +}
  57.165 +
  57.166 +void cParallelPort::SetDirection(int direction)
  57.167 +{
  57.168 +    if (usePPDev)
  57.169 +    {
  57.170 +        if (ioctl(fd, PPDATADIR, &direction) == -1)
  57.171 +        {
  57.172 +            perror("ioctl(PPDATADIR)");
  57.173 +            //exit(1);
  57.174 +        }
  57.175 +    }
  57.176 +    else
  57.177 +    {
  57.178 +        if (direction == kForward)
  57.179 +            port_out(port + 2, port_in(port + 2) & 0xdf);
  57.180 +        else
  57.181 +            port_out(port + 2, port_in(port + 2) | 0x20);
  57.182 +    }
  57.183 +}
  57.184 +
  57.185 +unsigned char cParallelPort::ReadControl()
  57.186 +{
  57.187 +    unsigned char value;
  57.188 +
  57.189 +    if (usePPDev)
  57.190 +    {
  57.191 +        if (ioctl(fd, PPRCONTROL, &value) == -1)
  57.192 +        {
  57.193 +            perror("ioctl(PPRCONTROL)");
  57.194 +            //exit(1);
  57.195 +        }
  57.196 +    }
  57.197 +    else
  57.198 +    {
  57.199 +        value = port_in(port + 2);
  57.200 +    }
  57.201 +
  57.202 +    return value;
  57.203 +}
  57.204 +
  57.205 +void cParallelPort::WriteControl(unsigned char value)
  57.206 +{
  57.207 +    if (usePPDev)
  57.208 +    {
  57.209 +        if (ioctl(fd, PPWCONTROL, &value) == -1)
  57.210 +        {
  57.211 +            perror("ioctl(PPWCONTROL)");
  57.212 +            //exit(1);
  57.213 +        }
  57.214 +    }
  57.215 +    else
  57.216 +    {
  57.217 +        port_out(port + 2, value);
  57.218 +    }
  57.219 +}
  57.220 +
  57.221 +unsigned char cParallelPort::ReadStatus()
  57.222 +{
  57.223 +    unsigned char value;
  57.224 +
  57.225 +    if (usePPDev)
  57.226 +    {
  57.227 +        if (ioctl(fd, PPRSTATUS, &value) == -1)
  57.228 +        {
  57.229 +            perror("ioctl(PPRSTATUS)");
  57.230 +            //exit(1);
  57.231 +        }
  57.232 +    }
  57.233 +    else
  57.234 +    {
  57.235 +        value = port_in(port + 1);
  57.236 +    }
  57.237 +
  57.238 +    return value;
  57.239 +}
  57.240 +
  57.241 +unsigned char cParallelPort::ReadData()
  57.242 +{
  57.243 +    unsigned char data;
  57.244 +
  57.245 +    if (usePPDev)
  57.246 +    {
  57.247 +        if (ioctl(fd, PPRDATA, &data) == -1)
  57.248 +        {
  57.249 +            perror("ioctl(PPRDATA)");
  57.250 +            //exit(1);
  57.251 +        }
  57.252 +    }
  57.253 +    else
  57.254 +    {
  57.255 +        data = port_in(port);
  57.256 +    }
  57.257 +
  57.258 +    return data;
  57.259 +}
  57.260 +
  57.261 +void cParallelPort::WriteData(unsigned char data)
  57.262 +{
  57.263 +    if (usePPDev)
  57.264 +    {
  57.265 +        if (ioctl(fd, PPWDATA, &data) == -1)
  57.266 +        {
  57.267 +            perror("ioctl(PPWDATA)");
  57.268 +            //exit(1);
  57.269 +        }
  57.270 +    }
  57.271 +    else
  57.272 +    {
  57.273 +        port_out(port, data);
  57.274 +    }
  57.275 +}
  57.276 +
  57.277 +
  57.278 +
  57.279 +cSerialPort::cSerialPort()
  57.280 +:   fd(-1)
  57.281 +{
  57.282 +}
  57.283 +
  57.284 +cSerialPort::~cSerialPort()
  57.285 +{
  57.286 +}
  57.287 +
  57.288 +int cSerialPort::Open(const char * device)
  57.289 +{
  57.290 +    struct termios options;
  57.291 +
  57.292 +    fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
  57.293 +    if (fd == -1)
  57.294 +    {
  57.295 +        printf("error opening port\n");
  57.296 +        return -1;
  57.297 +    }
  57.298 +    //fcntl(fd, F_SETFL, FNDELAY);
  57.299 +    fcntl(fd, F_SETFL, 0);
  57.300 +
  57.301 +    tcgetattr(fd, &options);
  57.302 +
  57.303 +    cfsetispeed(&options, B921600);
  57.304 +    cfsetospeed(&options, B921600);
  57.305 +
  57.306 +    options.c_cflag &= ~PARENB;
  57.307 +    options.c_cflag &= ~CSTOPB;
  57.308 +    options.c_cflag &= ~CSIZE;
  57.309 +    options.c_cflag |= CS8;
  57.310 +
  57.311 +    options.c_cflag &= ~CRTSCTS;
  57.312 +
  57.313 +    options.c_cflag |= (CLOCAL | CREAD);
  57.314 +
  57.315 +    options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
  57.316 +
  57.317 +    options.c_iflag &= ~(IXON | IXOFF | IXANY);
  57.318 +
  57.319 +    options.c_oflag &= ~OPOST;
  57.320 +
  57.321 +    tcsetattr(fd, TCSANOW, &options);
  57.322 +
  57.323 +    return 0;
  57.324 +}
  57.325 +
  57.326 +int cSerialPort::Close()
  57.327 +{
  57.328 +    if (fd == -1)
  57.329 +        return -1;
  57.330 +    close(fd);
  57.331 +    return 0;
  57.332 +}
  57.333 +
  57.334 +int cSerialPort::ReadData(unsigned char * data)
  57.335 +{
  57.336 +    if (fd == -1)
  57.337 +        return 0;
  57.338 +    return read(fd, data, 1);
  57.339 +}
  57.340 +
  57.341 +void cSerialPort::WriteData(unsigned char data)
  57.342 +{
  57.343 +    WriteData(&data, 1);
  57.344 +}
  57.345 +
  57.346 +void cSerialPort::WriteData(unsigned char * data, unsigned short length)
  57.347 +{
  57.348 +    if (fd == -1)
  57.349 +        return;
  57.350 +    write(fd, data, length);
  57.351 +}
  57.352 +
  57.353 +} // end of namespace
    58.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    58.2 +++ b/graphlcd-base/glcddrivers/port.h	Wed Feb 06 17:32:55 2008 +0000
    58.3 @@ -0,0 +1,78 @@
    58.4 +/*
    58.5 + * GraphLCD driver library
    58.6 + *
    58.7 + * port.h  -  parallel port class with low level routines
    58.8 + *
    58.9 + * This file is released under the GNU General Public License. Refer
   58.10 + * to the COPYING file distributed with this package.
   58.11 + *
   58.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   58.13 + */
   58.14 +
   58.15 +#ifndef _GLCDDRIVERS_PORT_H_
   58.16 +#define _GLCDDRIVERS_PORT_H_
   58.17 +
   58.18 +namespace GLCD
   58.19 +{
   58.20 +
   58.21 +const int kForward = 0;
   58.22 +const int kReverse = 1;
   58.23 +
   58.24 +const unsigned char kStrobeHigh = 0x00; // Pin 1
   58.25 +const unsigned char kStrobeLow  = 0x01;
   58.26 +const unsigned char kAutoHigh   = 0x00; // Pin 14
   58.27 +const unsigned char kAutoLow    = 0x02;
   58.28 +const unsigned char kInitHigh   = 0x04; // Pin 16
   58.29 +const unsigned char kInitLow    = 0x00;
   58.30 +const unsigned char kSelectHigh = 0x00; // Pin 17
   58.31 +const unsigned char kSelectLow  = 0x08;
   58.32 +
   58.33 +class cParallelPort
   58.34 +{
   58.35 +private:
   58.36 +    int fd;
   58.37 +    int port;
   58.38 +    bool usePPDev;
   58.39 +
   58.40 +public:
   58.41 +    cParallelPort();
   58.42 +    ~cParallelPort();
   58.43 +
   58.44 +    int Open(int port);
   58.45 +    int Open(const char * device);
   58.46 +    int Close();
   58.47 +
   58.48 +    bool IsDirectIO() const { return (!usePPDev); }
   58.49 +    int GetPortHandle() const { return ((usePPDev) ? fd : port); }
   58.50 +
   58.51 +    void Claim();
   58.52 +    void Release();
   58.53 +
   58.54 +    void SetDirection(int direction);
   58.55 +    unsigned char ReadControl();
   58.56 +    void WriteControl(unsigned char values);
   58.57 +    unsigned char ReadStatus();
   58.58 +    unsigned char ReadData();
   58.59 +    void WriteData(unsigned char data);
   58.60 +};
   58.61 +
   58.62 +class cSerialPort
   58.63 +{
   58.64 +private:
   58.65 +    int fd;
   58.66 +
   58.67 +public:
   58.68 +    cSerialPort();
   58.69 +    ~cSerialPort();
   58.70 +
   58.71 +    int Open(const char * device);
   58.72 +    int Close();
   58.73 +
   58.74 +    int ReadData(unsigned char * data);
   58.75 +    void WriteData(unsigned char data);
   58.76 +    void WriteData(unsigned char * data, unsigned short length);
   58.77 +};
   58.78 +
   58.79 +} // end of namespace
   58.80 +
   58.81 +#endif
    59.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    59.2 +++ b/graphlcd-base/glcddrivers/sed1330.c	Wed Feb 06 17:32:55 2008 +0000
    59.3 @@ -0,0 +1,630 @@
    59.4 +/*
    59.5 + * GraphLCD driver library
    59.6 + *
    59.7 + * sed1330.c  -  SED1330 driver class
    59.8 + *
    59.9 + * based on: hd61830.c
   59.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   59.11 + *
   59.12 + * changes for Seiko-Epson displays: Mar 2004
   59.13 + *  (c) 2004 Heinz Gressenberger <heinz.gressenberger AT stmk.gv.at>
   59.14 + *
   59.15 + * init sequence taken from Thomas Baumann's LCD-Test program
   59.16 + *
   59.17 + * This file is released under the GNU General Public License. Refer
   59.18 + * to the COPYING file distributed with this package.
   59.19 + *
   59.20 + * (c) 2003 Roland Praml <praml.roland AT t-online.de>
   59.21 + */
   59.22 +
   59.23 +#include <syslog.h>
   59.24 +#include <sys/time.h>
   59.25 +
   59.26 +#include "common.h"
   59.27 +#include "config.h"
   59.28 +#include "port.h"
   59.29 +#include "sed1330.h"
   59.30 +
   59.31 +
   59.32 +namespace GLCD
   59.33 +{
   59.34 +
   59.35 +// SED1330 Commands
   59.36 +
   59.37 +// Command Codes, Bytes for Param
   59.38 +
   59.39 +#define C_SYSTEMSET  0x40
   59.40 +#define C_SLEEPIN    0x53
   59.41 +#define C_DISPON     0x59
   59.42 +#define C_DISPOFF    0x58
   59.43 +#define C_SCROLL     0x44
   59.44 +#define C_CSRFORM    0x5D
   59.45 +#define C_CGRAMADR   0x5C
   59.46 +#define C_CSRDIR_R   0x4C
   59.47 +#define C_CSRDIR_L   0x4D
   59.48 +#define C_CSRDIR_U   0x4E
   59.49 +#define C_CSRDIR_D   0x4F
   59.50 +#define C_HDOTSCR    0x5A
   59.51 +#define C_OVLAY      0x5B
   59.52 +#define C_CSRW       0x46
   59.53 +#define C_CSRR       0x47
   59.54 +#define C_MWRITE     0x42
   59.55 +#define C_MREAD      0x43
   59.56 +
   59.57 +#define M0 0
   59.58 +// 0-internal CG ROM, 1-external CG-ROM/RAM
   59.59 +
   59.60 +#define M1 0
   59.61 +// 0 - 32 char CG-RAM, 1 - 64 char
   59.62 +
   59.63 +#define M2 0
   59.64 +// 0 - 8x8, 1 - 8x16 matrix in CG-RAM/ROM
   59.65 +
   59.66 +#define FX 8
   59.67 +// character-with
   59.68 +#define FY 8
   59.69 +// character-height
   59.70 +#define BPC 1
   59.71 +// byte per character, 1 - FX<=8, 2 - FX=9..16
   59.72 +
   59.73 +#define SAD1 0x0000
   59.74 +// startadress first screen
   59.75 +
   59.76 +
   59.77 +const int kInterface6800 = 0;
   59.78 +const int kInterface8080 = 1;
   59.79 +
   59.80 +const std::string kWiringOriginal = "Original";
   59.81 +const std::string kWiringPowerLCD = "PowerLCD";
   59.82 +const std::string kWiringLCDProc  = "LCDProc";
   59.83 +const std::string kWiringTweakers = "Tweakers";
   59.84 +const std::string kWiringYASEDW   = "YASEDW";
   59.85 +
   59.86 +const unsigned char kOriginalA0HI = kInitHigh;
   59.87 +const unsigned char kOriginalA0LO = kInitLow;
   59.88 +const unsigned char kOriginalRDHI = kStrobeHigh;
   59.89 +const unsigned char kOriginalRDLO = kStrobeLow;
   59.90 +const unsigned char kOriginalWRHI = kAutoHigh;
   59.91 +const unsigned char kOriginalWRLO = kAutoLow;
   59.92 +const unsigned char kOriginalCSHI = kSelectHigh;
   59.93 +const unsigned char kOriginalCSLO = kSelectLow;
   59.94 +
   59.95 +const unsigned char kPowerLCDA0HI = kInitHigh;
   59.96 +const unsigned char kPowerLCDA0LO = kInitLow;
   59.97 +const unsigned char kPowerLCDRDHI = kSelectHigh;
   59.98 +const unsigned char kPowerLCDRDLO = kSelectLow;
   59.99 +const unsigned char kPowerLCDWRHI = kStrobeHigh;
  59.100 +const unsigned char kPowerLCDWRLO = kStrobeLow;
  59.101 +const unsigned char kPowerLCDCSHI = kAutoHigh;
  59.102 +const unsigned char kPowerLCDCSLO = kAutoLow;
  59.103 +
  59.104 +const unsigned char kLCDProcA0HI = kSelectHigh;
  59.105 +const unsigned char kLCDProcA0LO = kSelectLow;
  59.106 +const unsigned char kLCDProcRDHI = kInitHigh;
  59.107 +const unsigned char kLCDProcRDLO = kInitLow;
  59.108 +const unsigned char kLCDProcWRHI = kAutoHigh;
  59.109 +const unsigned char kLCDProcWRLO = kAutoLow;
  59.110 +const unsigned char kLCDProcCSHI = kStrobeHigh;
  59.111 +const unsigned char kLCDProcCSLO = kStrobeLow;
  59.112 +
  59.113 +const unsigned char kTweakersA0HI = kSelectHigh;
  59.114 +const unsigned char kTweakersA0LO = kSelectLow;
  59.115 +const unsigned char kTweakersRDHI = kAutoHigh;
  59.116 +const unsigned char kTweakersRDLO = kAutoLow;
  59.117 +const unsigned char kTweakersWRHI = kInitHigh;
  59.118 +const unsigned char kTweakersWRLO = kInitLow;
  59.119 +const unsigned char kTweakersCSHI = kStrobeHigh;
  59.120 +const unsigned char kTweakersCSLO = kStrobeLow;
  59.121 +
  59.122 +const unsigned char kYASEDWA0HI = kAutoHigh;
  59.123 +const unsigned char kYASEDWA0LO = kAutoLow;
  59.124 +const unsigned char kYASEDWRDHI = kInitHigh;
  59.125 +const unsigned char kYASEDWRDLO = kInitLow;
  59.126 +const unsigned char kYASEDWWRHI = kStrobeHigh;
  59.127 +const unsigned char kYASEDWWRLO = kStrobeLow;
  59.128 +const unsigned char kYASEDWCSHI = kSelectHigh;
  59.129 +const unsigned char kYASEDWCSLO = kSelectLow;
  59.130 +
  59.131 +
  59.132 +cDriverSED1330::cDriverSED1330(cDriverConfig * config)
  59.133 +:   config(config)
  59.134 +{
  59.135 +    oldConfig = new cDriverConfig(*config);
  59.136 +
  59.137 +    port = new cParallelPort();
  59.138 +
  59.139 +    refreshCounter = 0;
  59.140 +}
  59.141 +
  59.142 +cDriverSED1330::~cDriverSED1330()
  59.143 +{
  59.144 +    delete port;
  59.145 +    delete oldConfig;
  59.146 +}
  59.147 +
  59.148 +int cDriverSED1330::Init()
  59.149 +{
  59.150 +    int x;
  59.151 +    struct timeval tv1, tv2;
  59.152 +
  59.153 +    width = config->width;
  59.154 +    if (width <= 0)
  59.155 +        width = 320;
  59.156 +    height = config->height;
  59.157 +    if (height <= 0)
  59.158 +        height = 240;
  59.159 +
  59.160 +    // default values
  59.161 +    oscillatorFrequency = 9600;
  59.162 +    interface = kInterface6800;
  59.163 +    A0HI = kOriginalA0HI;
  59.164 +    A0LO = kOriginalA0LO;
  59.165 +    RDHI = kOriginalRDHI;
  59.166 +    RDLO = kOriginalRDLO;
  59.167 +    WRHI = kOriginalWRHI;
  59.168 +    WRLO = kOriginalWRLO;
  59.169 +    CSHI = kOriginalCSHI;
  59.170 +    CSLO = kOriginalCSLO;
  59.171 +    ENHI = RDHI;
  59.172 +    ENLO = RDLO;
  59.173 +    RWHI = WRHI;
  59.174 +    RWLO = WRLO;
  59.175 +
  59.176 +    for (unsigned int i = 0; i < config->options.size(); i++)
  59.177 +    {
  59.178 +        if (config->options[i].name == "Wiring")
  59.179 +        {
  59.180 +            if (config->options[i].value == kWiringOriginal)
  59.181 +            {
  59.182 +                A0HI = kOriginalA0HI;
  59.183 +                A0LO = kOriginalA0LO;
  59.184 +                RDHI = kOriginalRDHI;
  59.185 +                RDLO = kOriginalRDLO;
  59.186 +                WRHI = kOriginalWRHI;
  59.187 +                WRLO = kOriginalWRLO;
  59.188 +                CSHI = kOriginalCSHI;
  59.189 +                CSLO = kOriginalCSLO;
  59.190 +            }
  59.191 +            else if (config->options[i].value == kWiringPowerLCD)
  59.192 +            {
  59.193 +                A0HI = kPowerLCDA0HI;
  59.194 +                A0LO = kPowerLCDA0LO;
  59.195 +                RDHI = kPowerLCDRDHI;
  59.196 +                RDLO = kPowerLCDRDLO;
  59.197 +                WRHI = kPowerLCDWRHI;
  59.198 +                WRLO = kPowerLCDWRLO;
  59.199 +                CSHI = kPowerLCDCSHI;
  59.200 +                CSLO = kPowerLCDCSLO;
  59.201 +            }
  59.202 +            else if (config->options[i].value == kWiringLCDProc)
  59.203 +            {
  59.204 +                A0HI = kLCDProcA0HI;
  59.205 +                A0LO = kLCDProcA0LO;
  59.206 +                RDHI = kLCDProcRDHI;
  59.207 +                RDLO = kLCDProcRDLO;
  59.208 +                WRHI = kLCDProcWRHI;
  59.209 +                WRLO = kLCDProcWRLO;
  59.210 +                CSHI = kLCDProcCSHI;
  59.211 +                CSLO = kLCDProcCSLO;
  59.212 +            }
  59.213 +            else if (config->options[i].value == kWiringTweakers)
  59.214 +            {
  59.215 +                A0HI = kTweakersA0HI;
  59.216 +                A0LO = kTweakersA0LO;
  59.217 +                RDHI = kTweakersRDHI;
  59.218 +                RDLO = kTweakersRDLO;
  59.219 +                WRHI = kTweakersWRHI;
  59.220 +                WRLO = kTweakersWRLO;
  59.221 +                CSHI = kTweakersCSHI;
  59.222 +                CSLO = kTweakersCSLO;
  59.223 +            }
  59.224 +            else if (config->options[i].value == kWiringYASEDW)
  59.225 +            {
  59.226 +                A0HI = kYASEDWA0HI;
  59.227 +                A0LO = kYASEDWA0LO;
  59.228 +                RDHI = kYASEDWRDHI;
  59.229 +                RDLO = kYASEDWRDLO;
  59.230 +                WRHI = kYASEDWWRHI;
  59.231 +                WRLO = kYASEDWWRLO;
  59.232 +                CSHI = kYASEDWCSHI;
  59.233 +                CSLO = kYASEDWCSLO;
  59.234 +            }
  59.235 +            else
  59.236 +            {
  59.237 +                syslog(LOG_ERR, "%s error: wiring %s not supported, using default (Original)!\n",
  59.238 +                       config->name.c_str(), config->options[i].value.c_str());
  59.239 +            }
  59.240 +            ENHI = RDHI;
  59.241 +            ENLO = RDLO;
  59.242 +            RWHI = WRHI;
  59.243 +            RWLO = WRLO;
  59.244 +        }
  59.245 +        else if (config->options[i].name == "OscillatorFrequency")
  59.246 +        {
  59.247 +            int freq = atoi(config->options[i].value.c_str());
  59.248 +            if (freq > 1000 && freq < 15000)
  59.249 +                oscillatorFrequency = freq;
  59.250 +            else
  59.251 +                syslog(LOG_ERR, "%s error: oscillator frequency %d out of range, using default (%d)!\n",
  59.252 +                       config->name.c_str(), freq, oscillatorFrequency);
  59.253 +        }
  59.254 +        if (config->options[i].name == "Interface")
  59.255 +        {
  59.256 +            if (config->options[i].value == "6800")
  59.257 +                interface = kInterface6800;
  59.258 +            else if (config->options[i].value == "8080")
  59.259 +                interface = kInterface8080;
  59.260 +            else
  59.261 +                syslog(LOG_ERR, "%s error: interface %s not supported, using default (6800)!\n",
  59.262 +                       config->name.c_str(), config->options[i].value.c_str());
  59.263 +        }
  59.264 +    }
  59.265 +
  59.266 +    // setup lcd array (wanted state)
  59.267 +    newLCD = new unsigned char *[(width + 7) / 8];
  59.268 +    if (newLCD)
  59.269 +    {
  59.270 +        for (x = 0; x < (width + 7) / 8; x++)
  59.271 +        {
  59.272 +            newLCD[x] = new unsigned char[height];
  59.273 +            memset(newLCD[x], 0, height);
  59.274 +        }
  59.275 +    }
  59.276 +    // setup lcd array (current state)
  59.277 +    oldLCD = new unsigned char *[(width + 7) / 8];
  59.278 +    if (oldLCD)
  59.279 +    {
  59.280 +        for (x = 0; x < (width + 7) / 8; x++)
  59.281 +        {
  59.282 +            oldLCD[x] = new unsigned char[height];
  59.283 +            memset(oldLCD[x], 0, height);
  59.284 +        }
  59.285 +    }
  59.286 +
  59.287 +    if (config->device == "")
  59.288 +    {
  59.289 +        // use DirectIO
  59.290 +        if (port->Open(config->port) != 0)
  59.291 +            return -1;
  59.292 +        uSleep(10);
  59.293 +    }
  59.294 +    else
  59.295 +    {
  59.296 +        // use ppdev
  59.297 +        if (port->Open(config->device.c_str()) != 0)
  59.298 +            return -1;
  59.299 +    }
  59.300 +
  59.301 +    if (nSleepInit() != 0)
  59.302 +    {
  59.303 +        syslog(LOG_DEBUG, "%s: INFO: cannot change wait parameters (cDriver::Init)\n", config->name.c_str());
  59.304 +        useSleepInit = false;
  59.305 +    }
  59.306 +    else
  59.307 +    {
  59.308 +        useSleepInit = true;
  59.309 +    }
  59.310 +
  59.311 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  59.312 +    gettimeofday(&tv1, 0);
  59.313 +    for (x = 0; x < 1000; x++)
  59.314 +    {
  59.315 +        port->WriteData(x % 0x100);
  59.316 +    }
  59.317 +    gettimeofday(&tv2, 0);
  59.318 +    if (useSleepInit)
  59.319 +        nSleepDeInit();
  59.320 +    timeForPortCmdInNs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  59.321 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Command: %ldns\n", config->name.c_str(), timeForPortCmdInNs);
  59.322 +
  59.323 +    // initialize graphic mode
  59.324 +    InitGraphic();
  59.325 +
  59.326 +    *oldConfig = *config;
  59.327 +
  59.328 +    // clear display
  59.329 +    Clear();
  59.330 +    // The SED1330 can have up to 64k memory. If there is less memory
  59.331 +    // it will be overwritten twice or more times.
  59.332 +    WriteCmd(C_MWRITE);
  59.333 +    for (x = 0; x < 65536; x++)
  59.334 +        WriteData(0x00);
  59.335 +
  59.336 +    WriteCmd(C_CSRW);
  59.337 +    WriteData(0x00); // initializing cursor adress, low byte
  59.338 +    WriteData(0x00); // high byte
  59.339 +
  59.340 +    port->Release();
  59.341 +
  59.342 +    syslog(LOG_INFO, "%s: SED1330 initialized.\n", config->name.c_str());
  59.343 +    return 0;
  59.344 +}
  59.345 +
  59.346 +int cDriverSED1330::DeInit()
  59.347 +{
  59.348 +    int x;
  59.349 +
  59.350 +    // free lcd array (wanted state)
  59.351 +    if (newLCD)
  59.352 +    {
  59.353 +        for (x = 0; x < (width + 7) / 8; x++)
  59.354 +        {
  59.355 +            delete[] newLCD[x];
  59.356 +        }
  59.357 +        delete[] newLCD;
  59.358 +    }
  59.359 +    // free lcd array (current state)
  59.360 +    if (oldLCD)
  59.361 +    {
  59.362 +        for (x = 0; x < (width + 7) / 8; x++)
  59.363 +        {
  59.364 +            delete[] oldLCD[x];
  59.365 +        }
  59.366 +        delete[] oldLCD;
  59.367 +    }
  59.368 +
  59.369 +    if (port->Close() != 0)
  59.370 +        return -1;
  59.371 +    return 0;
  59.372 +}
  59.373 +
  59.374 +int cDriverSED1330::CheckSetup()
  59.375 +{
  59.376 +    if (config->device != oldConfig->device ||
  59.377 +        config->port != oldConfig->port ||
  59.378 +        config->width != oldConfig->width ||
  59.379 +        config->height != oldConfig->height)
  59.380 +    {
  59.381 +        DeInit();
  59.382 +        Init();
  59.383 +        return 0;
  59.384 +    }
  59.385 +
  59.386 +    if (config->upsideDown != oldConfig->upsideDown ||
  59.387 +        config->invert != oldConfig->invert)
  59.388 +    {
  59.389 +        oldConfig->upsideDown = config->upsideDown;
  59.390 +        oldConfig->invert = config->invert;
  59.391 +        return 1;
  59.392 +    }
  59.393 +    return 0;
  59.394 +}
  59.395 +
  59.396 +int cDriverSED1330::InitGraphic()
  59.397 +{
  59.398 +    // initialize setup with two graphic screens
  59.399 +    // most parts taken from Thomas Baumann's LCD-Test program
  59.400 +    int cr;
  59.401 +    int memGraph;
  59.402 +    int sad1l, sad1h, sad2l, sad2h;
  59.403 +
  59.404 +    cr = (width / FX - 1) * BPC;
  59.405 +    memGraph = ((cr + 1) * height);  // required memory for a graphic layer
  59.406 +    sad1l = SAD1 & 0xFF;
  59.407 +    sad1h = SAD1 >> 8 & 0xFF;
  59.408 +    sad2l = ((SAD1 + memGraph) & 0xFF);
  59.409 +    sad2h = ((SAD1 + memGraph) >> 8 & 0xFF);
  59.410 +
  59.411 +    WriteCmd(C_SYSTEMSET);
  59.412 +    WriteData(0x30 + M0 + (M1 << 1) + (M2 << 2));
  59.413 +    WriteData(0x80 + (FX - 1));
  59.414 +    WriteData(0x00 + (FY - 1));
  59.415 +    WriteData(cr);   // C/R .. display adresses per line
  59.416 +    WriteData((oscillatorFrequency * 1000 / (70 * height) - 1) / 9);  // TC/R .. , fFR=70Hz
  59.417 +    WriteData(height - 1); // L/F .. display lines per screen
  59.418 +    WriteData(cr + 1);   // adresses per virtual display line, low byte
  59.419 +    WriteData(0x00);   // adresses per virtual display line, high byte
  59.420 +    // currently we don't use virtual screens greater then the display,
  59.421 +    // therefore the high byte should always be zero
  59.422 +
  59.423 +    WriteCmd(C_SCROLL);
  59.424 +    WriteData(sad1l);  // low-byte startadress first layer
  59.425 +    WriteData(sad1h);  // high-byte startadress first layer
  59.426 +    WriteData(height); // lines per screen
  59.427 +    WriteData(sad2l);  // low-byte startadress second layer
  59.428 +    WriteData(sad2h);  // high-byte startadress second layer
  59.429 +    WriteData(height); // lines per screen
  59.430 +    WriteData(0x00); // low-byte startadress third layer, not used
  59.431 +    WriteData(0x00); // high-byte startadress third layer, not used
  59.432 +    WriteData(0x00); // low-byte startadress fourth layer, not used
  59.433 +    WriteData(0x00); // high-byte startadress fourth layer, not used
  59.434 +
  59.435 +    WriteCmd(C_CSRFORM);
  59.436 +    WriteData(0x00); // cursor with: 1 pixel
  59.437 +    WriteData(0x86); // cursor height: 7 lines, block mode
  59.438 +
  59.439 +    WriteCmd(C_CSRDIR_R);  // automatic cursor increment to the right
  59.440 +
  59.441 +    WriteCmd(C_OVLAY);
  59.442 +    WriteData(0x0C); // two layer composition with Priority-OR
  59.443 +
  59.444 +    WriteCmd(C_HDOTSCR);
  59.445 +    WriteData(0x00);
  59.446 +
  59.447 +    WriteCmd(C_DISPON);  // display ON with
  59.448 +    WriteData(0x04); // cursor OFF and first layer ON without flashing
  59.449 +
  59.450 +    WriteCmd(C_CSRW);
  59.451 +    WriteData(0x00); // initializing cursor adress, low byte
  59.452 +    WriteData(0x00); // high byte
  59.453 +
  59.454 +    return 0;
  59.455 +}
  59.456 +
  59.457 +void cDriverSED1330::WriteCmd(unsigned char cmd)
  59.458 +{
  59.459 +    //if (useSleepInit)
  59.460 +    //    nSleepInit();
  59.461 +
  59.462 +    if (interface == kInterface6800)
  59.463 +    {
  59.464 +        // set A0 high (instruction), RW low (write) and E low
  59.465 +        port->WriteControl(A0HI | CSLO | RWLO | ENLO);
  59.466 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.467 +        // Output the actual command
  59.468 +        port->WriteData(cmd);
  59.469 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.470 +        // set E high
  59.471 +        port->WriteControl(A0HI | CSLO | RWLO | ENHI);
  59.472 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.473 +        // set E low
  59.474 +        port->WriteControl(A0HI | CSLO | RWLO | ENLO);
  59.475 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.476 +    }
  59.477 +    else
  59.478 +    {
  59.479 +        // set A0 high (instruction), CS low, RD and WR high
  59.480 +        port->WriteControl(A0HI | CSLO | RDHI | WRHI);
  59.481 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.482 +        // Output the actual command
  59.483 +        port->WriteData(cmd);
  59.484 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.485 +        // set WR low
  59.486 +        port->WriteControl(A0HI | CSLO | RDHI | WRLO);
  59.487 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.488 +        // set WR high
  59.489 +        port->WriteControl(A0HI | CSLO | RDHI | WRHI);
  59.490 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.491 +    }
  59.492 +
  59.493 +    //if (useSleepInit)
  59.494 +    //    nSleepDeInit();
  59.495 +}
  59.496 +
  59.497 +void cDriverSED1330::WriteData(unsigned char data)
  59.498 +{
  59.499 +    //if (useSleepInit)
  59.500 +    //    nSleepInit();
  59.501 +
  59.502 +    if (interface == kInterface6800)
  59.503 +    {
  59.504 +        // set A0 low (data), RW low (write) and E low
  59.505 +        port->WriteControl(A0LO | CSLO | RWLO | ENLO);
  59.506 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.507 +        // Output the actual data
  59.508 +        port->WriteData(data);
  59.509 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.510 +        // set E high
  59.511 +        port->WriteControl(A0LO | CSLO | RWLO | ENHI);
  59.512 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.513 +        // set E low
  59.514 +        port->WriteControl(A0LO | CSLO | RWLO | ENLO);
  59.515 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.516 +    }
  59.517 +    else
  59.518 +    {
  59.519 +        // set A0 low (data), CS low, RD and WR high
  59.520 +        port->WriteControl(A0LO | CSLO | RDHI | WRHI);
  59.521 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.522 +        // Output the actual data
  59.523 +        port->WriteData(data);
  59.524 +        //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.525 +        // set WR low
  59.526 +        port->WriteControl(A0LO | CSLO | RDHI | WRLO);
  59.527 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.528 +        // set WR high
  59.529 +        port->WriteControl(A0LO | CSLO | RDHI | WRHI);
  59.530 +        //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  59.531 +    }
  59.532 +
  59.533 +    //if (useSleepInit)
  59.534 +    //    nSleepDeInit();
  59.535 +}
  59.536 +
  59.537 +void cDriverSED1330::Clear()
  59.538 +{
  59.539 +    for (int x = 0; x < (width + 7) / 8; x++)
  59.540 +        memset(newLCD[x], 0, height);
  59.541 +}
  59.542 +
  59.543 +void cDriverSED1330::Set8Pixels(int x, int y, unsigned char data)
  59.544 +{
  59.545 +    if (x >= width || y >= height)
  59.546 +        return;
  59.547 +
  59.548 +    if (!config->upsideDown)
  59.549 +    {
  59.550 +        // normal orientation
  59.551 +        newLCD[x / 8][y] = newLCD[x / 8][y] | data;
  59.552 +    }
  59.553 +    else
  59.554 +    {
  59.555 +        // upside down orientation
  59.556 +        x = width - 1 - x;
  59.557 +        y = height - 1 - y;
  59.558 +        newLCD[x / 8][y] = newLCD[x / 8][y] | ReverseBits(data);
  59.559 +    }
  59.560 +}
  59.561 +
  59.562 +void cDriverSED1330::Refresh(bool refreshAll)
  59.563 +{
  59.564 +    int x;
  59.565 +    int y;
  59.566 +    int pos = SAD1;
  59.567 +
  59.568 +    if (CheckSetup() > 0)
  59.569 +        refreshAll = true;
  59.570 +
  59.571 +    if (config->refreshDisplay > 0)
  59.572 +    {
  59.573 +        refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
  59.574 +        if (!refreshAll && !refreshCounter)
  59.575 +            refreshAll = true;
  59.576 +    }
  59.577 +
  59.578 +    port->Claim();
  59.579 +
  59.580 +    if (refreshAll)
  59.581 +    {
  59.582 +        // draw all
  59.583 +        // set cursor to startadress
  59.584 +        WriteCmd(C_CSRW);
  59.585 +        WriteData(pos & 0xFF);
  59.586 +        WriteData(pos >> 8);
  59.587 +
  59.588 +        for (y = 0; y < height; y++)
  59.589 +        {
  59.590 +            for (x = 0; x < (width + 7) / 8; x++)
  59.591 +            {
  59.592 +                WriteCmd(C_MWRITE); // cursor increments automatically
  59.593 +                WriteData(newLCD[x][y] ^ (config->invert ? 0xff : 0x00));
  59.594 +                oldLCD[x][y] = newLCD[x][y];
  59.595 +                pos++;
  59.596 +            }
  59.597 +        }
  59.598 +        // and reset RefreshCounter
  59.599 +        refreshCounter = 0;
  59.600 +    }
  59.601 +    else
  59.602 +    {
  59.603 +        // draw only the changed bytes
  59.604 +        bool cs = false;
  59.605 +        for (y = 0; y < height; y++)
  59.606 +        {
  59.607 +            for (x = 0; x < (width + 7) / 8; x++)
  59.608 +            {
  59.609 +                if (newLCD[x][y] != oldLCD[x][y])
  59.610 +                {
  59.611 +                    if (!cs)
  59.612 +                    {
  59.613 +                        WriteCmd(C_CSRW);
  59.614 +                        WriteData(pos & 0xFF);
  59.615 +                        WriteData(pos >> 8);
  59.616 +                        WriteCmd(C_MWRITE);
  59.617 +                        cs = true;
  59.618 +                    }
  59.619 +                    WriteData(newLCD[x][y] ^ (config->invert ? 0xff : 0x00));
  59.620 +                    oldLCD[x][y] = newLCD[x][y];
  59.621 +                }
  59.622 +                else
  59.623 +                {
  59.624 +                    cs = false;
  59.625 +                }
  59.626 +                pos++;
  59.627 +            }
  59.628 +        }
  59.629 +    }
  59.630 +    port->Release();
  59.631 +}
  59.632 +
  59.633 +} // end of namespace
    60.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    60.2 +++ b/graphlcd-base/glcddrivers/sed1330.h	Wed Feb 06 17:32:55 2008 +0000
    60.3 @@ -0,0 +1,78 @@
    60.4 +/*
    60.5 + * GraphLCD driver library
    60.6 + *
    60.7 + * sed1330.h  -  SED1330 driver class
    60.8 + *
    60.9 + * based on: hd61830.c
   60.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   60.11 + *
   60.12 + * changes for Seiko-Epson displays: Mar 2004
   60.13 + *  (c) 2004 Heinz Gressenberger <heinz.gressenberger AT stmk.gv.at>
   60.14 + *
   60.15 + * init sequence taken from Thomas Baumann's LCD-Test program
   60.16 + *
   60.17 + * This file is released under the GNU General Public License. Refer
   60.18 + * to the COPYING file distributed with this package.
   60.19 + *
   60.20 + * (c) 2003 Roland Praml <praml.roland AT t-online.de>
   60.21 + */
   60.22 +
   60.23 +#ifndef _GLCDDRIVERS_SED1330_H_
   60.24 +#define _GLCDDRIVERS_SED1330_H_
   60.25 +
   60.26 +#include "driver.h"
   60.27 +
   60.28 +
   60.29 +namespace GLCD
   60.30 +{
   60.31 +
   60.32 +class cDriverConfig;
   60.33 +class cParallelPort;
   60.34 +
   60.35 +class cDriverSED1330 : public cDriver
   60.36 +{
   60.37 +private:
   60.38 +    cParallelPort * port;
   60.39 +    unsigned char ** newLCD; // wanted state
   60.40 +    unsigned char ** oldLCD; // current state
   60.41 +    int refreshCounter;
   60.42 +    long timeForPortCmdInNs;
   60.43 +    cDriverConfig * config;
   60.44 +    cDriverConfig * oldConfig;
   60.45 +    bool useSleepInit;
   60.46 +
   60.47 +    int oscillatorFrequency;
   60.48 +    int interface;
   60.49 +    unsigned char A0HI;
   60.50 +    unsigned char A0LO;
   60.51 +    unsigned char RDHI;
   60.52 +    unsigned char RDLO;
   60.53 +    unsigned char ENHI;
   60.54 +    unsigned char ENLO;
   60.55 +    unsigned char WRHI;
   60.56 +    unsigned char WRLO;
   60.57 +    unsigned char RWHI;
   60.58 +    unsigned char RWLO;
   60.59 +    unsigned char CSHI;
   60.60 +    unsigned char CSLO;
   60.61 +
   60.62 +    int CheckSetup();
   60.63 +    int InitGraphic();
   60.64 +    void WriteCmd(unsigned char cmd);
   60.65 +    void WriteData(unsigned char data);
   60.66 +
   60.67 +public:
   60.68 +    cDriverSED1330(cDriverConfig * config);
   60.69 +    virtual ~cDriverSED1330();
   60.70 +
   60.71 +    virtual int Init();
   60.72 +    virtual int DeInit();
   60.73 +
   60.74 +    virtual void Clear();
   60.75 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   60.76 +    virtual void Refresh(bool refreshAll = false);
   60.77 +};
   60.78 +
   60.79 +} // end of namespace
   60.80 +
   60.81 +#endif
    61.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    61.2 +++ b/graphlcd-base/glcddrivers/sed1520.c	Wed Feb 06 17:32:55 2008 +0000
    61.3 @@ -0,0 +1,402 @@
    61.4 +/*
    61.5 + * GraphLCD driver library
    61.6 + *
    61.7 + * sed1520.c  -  SED1520 driver class
    61.8 + *
    61.9 + * This file is released under the GNU General Public License. Refer
   61.10 + * to the COPYING file distributed with this package.
   61.11 + *
   61.12 + * (c) 2003 Andreas 'randy' Weinberger <vdr AT smue.org>
   61.13 + */
   61.14 +
   61.15 +#include <syslog.h>
   61.16 +#include <sys/time.h>
   61.17 +
   61.18 +#include "common.h"
   61.19 +#include "config.h"
   61.20 +#include "port.h"
   61.21 +#include "sed1520.h"
   61.22 +
   61.23 +
   61.24 +namespace GLCD
   61.25 +{
   61.26 +
   61.27 +// commands
   61.28 +const unsigned char kSEAD = 0x00; // Set (X) Column Address
   61.29 +const unsigned char kSEPA = 0xb8; // Set (Y) Page Address
   61.30 +const unsigned char kSEDS = 0xc0;  // Set Display Start Line
   61.31 +const unsigned char kDION = 0xaf; // Display on
   61.32 +const unsigned char kDIOF = 0xae; // Display off
   61.33 +
   61.34 +// control bits for DirectIO
   61.35 +#define CE1     0x01
   61.36 +#define CE1HI   0x01  // Chip Enable 1 on
   61.37 +#define CE1LO   0x00  // Chip Enable 1 off
   61.38 +
   61.39 +const unsigned char kCS1HI = 0x00; // Chip Select 1
   61.40 +const unsigned char kCS1LO = 0x01;
   61.41 +const unsigned char kCS2HI = 0x04; // Chip Select 2
   61.42 +const unsigned char kCS2LO = 0x00;
   61.43 +const unsigned char kCDHI  = 0x08; // Command/Data Register Select
   61.44 +const unsigned char kCDLO  = 0x00;
   61.45 +const unsigned char kLEDHI = 0x02; // LED Backlight (not supported currently)
   61.46 +const unsigned char kLEDLO = 0x00;
   61.47 +
   61.48 +
   61.49 +cDriverSED1520::cDriverSED1520(cDriverConfig * config)
   61.50 +:   config(config)
   61.51 +{
   61.52 +    oldConfig = new cDriverConfig(*config);
   61.53 +
   61.54 +    port = new cParallelPort();
   61.55 +
   61.56 +    refreshCounter = 0;
   61.57 +}
   61.58 +
   61.59 +cDriverSED1520::~cDriverSED1520()
   61.60 +{
   61.61 +    delete port;
   61.62 +    delete oldConfig;
   61.63 +}
   61.64 +
   61.65 +int cDriverSED1520::Init()
   61.66 +{
   61.67 +    int x;
   61.68 +    int i;
   61.69 +    struct timeval tv1, tv2;
   61.70 +
   61.71 +    if (!(config->width % 8) == 0) {
   61.72 +        width = config->width + (8 - (config->width % 8));
   61.73 +    } else {
   61.74 +        width = config->width;
   61.75 +    }
   61.76 +
   61.77 +    if (!(config->height % 8) == 0) {
   61.78 +        height = config->height + (8 - (config->height % 8));
   61.79 +    } else {
   61.80 +        height = config->height;
   61.81 +    }
   61.82 +
   61.83 +    if (width <= 0)
   61.84 +        width = 120;
   61.85 +    if (height <= 0)
   61.86 +        height = 32;
   61.87 +
   61.88 +    SEAD = kSEAD;
   61.89 +    SEPA = kSEPA;
   61.90 +    SEDS = kSEDS;
   61.91 +    DION = kDION;
   61.92 +    DIOF = kDIOF;
   61.93 +    LED  = kLEDHI;
   61.94 +    CDHI = kCDHI;
   61.95 +    CDLO = kCDLO;
   61.96 +    CS1HI = kCS1HI;
   61.97 +    CS1LO = kCS1LO;
   61.98 +    CS2HI = kCS2HI;
   61.99 +    CS2LO = kCS2LO;
  61.100 +
  61.101 +    for (unsigned int i = 0; i < config->options.size(); i++)
  61.102 +    {
  61.103 +        if (config->options[i].name == "")
  61.104 +        {
  61.105 +        }
  61.106 +    }
  61.107 +
  61.108 +    // setup linear lcd array
  61.109 +    LCD = new unsigned char *[(width + 7) / 8];
  61.110 +    if (LCD)
  61.111 +    {
  61.112 +        for (x = 0; x < (width + 7) / 8; x++)
  61.113 +        {
  61.114 +            LCD[x] = new unsigned char[height];
  61.115 +            memset(LCD[x], 0, height);
  61.116 +        }
  61.117 +    }
  61.118 +    // setup the lcd array for the paged sed1520
  61.119 +    LCD_page = new unsigned char *[width];
  61.120 +    if (LCD_page)
  61.121 +    {
  61.122 +        for (x = 0; x < width; x++)
  61.123 +        {
  61.124 +            LCD_page[x] = new unsigned char[(height + 7) / 8];
  61.125 +            memset(LCD_page[x], 0, (height + 7) / 8);
  61.126 +        }
  61.127 +    }
  61.128 +
  61.129 +    if (config->device == "")
  61.130 +    {
  61.131 +        // use DirectIO
  61.132 +        if (port->Open(config->port) != 0)
  61.133 +            return -1;
  61.134 +        uSleep(10);
  61.135 +    }
  61.136 +    else
  61.137 +    {
  61.138 +        // use ppdev
  61.139 +        if (port->Open(config->device.c_str()) != 0)
  61.140 +            return -1;
  61.141 +    }
  61.142 +
  61.143 +    if (nSleepInit() != 0)
  61.144 +    {
  61.145 +        syslog(LOG_DEBUG, "%s: INFO: cannot change wait parameters (cDriver::Init)\n", config->name.c_str());
  61.146 +        useSleepInit = false;
  61.147 +    }
  61.148 +    else
  61.149 +    {
  61.150 +        useSleepInit = true;
  61.151 +    }
  61.152 +
  61.153 +    syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
  61.154 +    gettimeofday(&tv1, 0);
  61.155 +    for (i = 0; i < 1000; i++)
  61.156 +    {
  61.157 +        port->WriteData(i % 0x100);
  61.158 +    }
  61.159 +    gettimeofday(&tv2, 0);
  61.160 +    if (useSleepInit)
  61.161 +        nSleepDeInit();
  61.162 +    timeForPortCmdInNs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
  61.163 +    syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Command: %ldns\n", config->name.c_str(), timeForPortCmdInNs);
  61.164 +
  61.165 +    // initialize graphic mode
  61.166 +    InitGraphic();
  61.167 +
  61.168 +    port->Release();
  61.169 +
  61.170 +    *oldConfig = *config;
  61.171 +
  61.172 +    // clear display
  61.173 +    Clear();
  61.174 +
  61.175 +    syslog(LOG_INFO, "%s: SED1520 initialized.\n", config->name.c_str());
  61.176 +    return 0;
  61.177 +}
  61.178 +
  61.179 +int cDriverSED1520::DeInit()
  61.180 +{
  61.181 +    int x;
  61.182 +
  61.183 +    // free linear lcd array
  61.184 +    if (LCD)
  61.185 +    {
  61.186 +        for (x = 0; x < (width + 7) / 8; x++)
  61.187 +        {
  61.188 +            delete[] LCD[x];
  61.189 +        }
  61.190 +        delete[] LCD;
  61.191 +    }
  61.192 +    // free the lcd array for the paged sed1520
  61.193 +    if (LCD_page)
  61.194 +    {
  61.195 +        for (x = 0; x < width; x++)
  61.196 +        {
  61.197 +            delete[] LCD_page[x];
  61.198 +        }
  61.199 +        delete[] LCD_page;
  61.200 +    }
  61.201 +
  61.202 +    if (port->Close() != 0)
  61.203 +        return -1;
  61.204 +    return 0;
  61.205 +}
  61.206 +
  61.207 +int cDriverSED1520::CheckSetup()
  61.208 +{
  61.209 +    if (config->device != oldConfig->device ||
  61.210 +        config->port != oldConfig->port ||
  61.211 +        config->width != oldConfig->width ||
  61.212 +        config->height != oldConfig->height)
  61.213 +    {
  61.214 +        DeInit();
  61.215 +        Init();
  61.216 +        return 0;
  61.217 +    }
  61.218 +
  61.219 +    if (config->upsideDown != oldConfig->upsideDown ||
  61.220 +        config->invert != oldConfig->invert)
  61.221 +    {
  61.222 +        oldConfig->upsideDown = config->upsideDown;
  61.223 +        oldConfig->invert = config->invert;
  61.224 +        return 1;
  61.225 +    }
  61.226 +    return 0;
  61.227 +}
  61.228 +
  61.229 +int cDriverSED1520::InitGraphic()
  61.230 +{
  61.231 +    // initialize controller1, set display start 0, set page 0, set y address 0, display on
  61.232 +    SED1520Cmd(SEDS, 1);
  61.233 +    SED1520Cmd(SEPA, 1);
  61.234 +    SED1520Cmd(SEAD, 1);
  61.235 +    SED1520Cmd(DION, 1);
  61.236 +
  61.237 +    // initialize controller2, set display start 0, set page 0, set y address 0, display on
  61.238 +    SED1520Cmd(SEDS, 2);
  61.239 +    SED1520Cmd(SEPA, 2);
  61.240 +    SED1520Cmd(SEAD, 2);
  61.241 +    SED1520Cmd(DION, 2);
  61.242 +
  61.243 +    return 0;
  61.244 +}
  61.245 +
  61.246 +void cDriverSED1520::SED1520Cmd(unsigned char data, int cmdcs)
  61.247 +{
  61.248 +    if (useSleepInit)
  61.249 +        nSleepInit();
  61.250 +
  61.251 +    switch (cmdcs)
  61.252 +    {
  61.253 +        case 1:
  61.254 +            port->WriteControl(CDHI | CS1LO | CS2LO | LEDHI);
  61.255 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.256 +            port->WriteData(data);
  61.257 +            nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.258 +            port->WriteControl(CDHI | CS1HI | CS2LO | LEDHI);
  61.259 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.260 +            break;
  61.261 +        case 2:
  61.262 +            port->WriteControl(CDHI | CS1LO | CS2LO | LED);
  61.263 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.264 +            port->WriteData(data);
  61.265 +            nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.266 +            port->WriteControl(CDHI | CS1LO | CS2HI | LED);
  61.267 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.268 +            break;
  61.269 +    }
  61.270 +    if (useSleepInit)
  61.271 +        nSleepDeInit();
  61.272 +}
  61.273 +
  61.274 +void cDriverSED1520::SED1520Data(unsigned char data, int datacs)
  61.275 +{
  61.276 +    if (useSleepInit)
  61.277 +        nSleepInit();
  61.278 +
  61.279 +    switch (datacs)
  61.280 +    {
  61.281 +        case 1:
  61.282 +            port->WriteControl(CDLO | CS1LO | CS2LO | LEDHI);
  61.283 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.284 +            port->WriteData(data);
  61.285 +            nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.286 +            port->WriteControl(CDLO | CS1HI | CS2LO | LEDHI);
  61.287 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.288 +            break;
  61.289 +        case 2:
  61.290 +            port->WriteControl(CDLO | CS1LO | CS2LO | LED);
  61.291 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.292 +            port->WriteData(data);
  61.293 +            nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.294 +            port->WriteControl(CDLO | CS1LO | CS2HI | LED);
  61.295 +            nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
  61.296 +            break;
  61.297 +    }
  61.298 +    if (useSleepInit)
  61.299 +        nSleepDeInit();
  61.300 +}
  61.301 +
  61.302 +void cDriverSED1520::Clear()
  61.303 +{
  61.304 +    for (int x = 0; x < (width + 7) / 8; x++)
  61.305 +        memset(LCD[x], 0, height);
  61.306 +}
  61.307 +
  61.308 +void cDriverSED1520::Set8Pixels (int x, int y, unsigned char data)
  61.309 +{
  61.310 +    if (x >= width || y >= height)
  61.311 +        return;
  61.312 +
  61.313 +    if (!config->upsideDown)
  61.314 +    {
  61.315 +        // normal orientation
  61.316 +        LCD[x / 8][y] = LCD[x / 8][y] | data;
  61.317 +    }
  61.318 +    else
  61.319 +    {
  61.320 +        // upside down orientation
  61.321 +        x = width - 1 - x;
  61.322 +        y = height - 1 - y;
  61.323 +        LCD[x / 8][y] = LCD[x / 8][y] | ReverseBits(data);
  61.324 +    }
  61.325 +}
  61.326 +
  61.327 +void cDriverSED1520::Refresh(bool refreshAll)
  61.328 +{
  61.329 +    int x,y,xx,yy;
  61.330 +    unsigned char dByte, oneBlock[8];
  61.331 +
  61.332 +    if (CheckSetup() > 0)
  61.333 +        refreshAll = true;
  61.334 +
  61.335 +    if (config->refreshDisplay > 0)
  61.336 +    {
  61.337 +        refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
  61.338 +        if (!refreshAll && !refreshCounter)
  61.339 +            refreshAll = true;
  61.340 +    }
  61.341 +
  61.342 +    refreshAll = true; // differential update is not yet supported
  61.343 +
  61.344 +    if (refreshAll)
  61.345 +    {
  61.346 +        // draw all
  61.347 +
  61.348 +        // convert the linear lcd array to the paged array for the display
  61.349 +        for (y = 0; y < (height + 7) / 8; y++)
  61.350 +        {
  61.351 +            for (x = 0; x < (width + 7) / 8; x++)
  61.352 +            {
  61.353 +                for (yy = 0; yy < 8; yy++)
  61.354 +                {
  61.355 +                    oneBlock[yy] = LCD[x][yy + (y * 8)] ^ (config->invert ? 0xff : 0x00);
  61.356 +                }
  61.357 +                for (xx = 0; xx < 8; xx++)
  61.358 +                {
  61.359 +                    dByte = 0;
  61.360 +                    for (yy = 0; yy < 8; yy++)
  61.361 +                    {
  61.362 +                        if (oneBlock[yy] & bitmask[xx])
  61.363 +                        {
  61.364 +                            dByte += (1 << yy);
  61.365 +                        }
  61.366 +                    }
  61.367 +                    LCD_page[x * 8 + xx][y] = dByte;
  61.368 +                }
  61.369 +            }
  61.370 +        }
  61.371 +
  61.372 +        port->Claim();
  61.373 +
  61.374 +        // send lcd_soll data to display, controller 1
  61.375 +        // set page and start address
  61.376 +        for (y = 0; y < (height + 7) / 8; y++)
  61.377 +        {
  61.378 +            SED1520Cmd(SEAD, 1);
  61.379 +            SED1520Cmd(SEPA + y, 1);
  61.380 +            SED1520Data(0x00 ^ (config->invert ? 0xff : 0x00), 1); // fill first row with zero
  61.381 +
  61.382 +            for (x = 0; x < width / 2 + 1; x++)
  61.383 +            {
  61.384 +                SED1520Data(LCD_page[x][y], 1);
  61.385 +            }
  61.386 +
  61.387 +            SED1520Cmd(SEAD, 2);
  61.388 +            SED1520Cmd(SEPA + y, 2);
  61.389 +
  61.390 +            for (x = width / 2; x < width; x++)
  61.391 +            {
  61.392 +                SED1520Data(LCD_page[x][y], 2);
  61.393 +            }
  61.394 +
  61.395 +            SED1520Data(0x00 ^ (config->invert ? 0xff : 0x00), 2); // fill last row with zero
  61.396 +        }
  61.397 +        port->Release();
  61.398 +    }
  61.399 +    else
  61.400 +    {
  61.401 +        // draw only the changed bytes
  61.402 +    }
  61.403 +}
  61.404 +
  61.405 +} // end of namespace
    62.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    62.2 +++ b/graphlcd-base/glcddrivers/sed1520.h	Wed Feb 06 17:32:55 2008 +0000
    62.3 @@ -0,0 +1,72 @@
    62.4 +/*
    62.5 + * GraphLCD driver library
    62.6 + *
    62.7 + * sed1520.h  -  SED1520 driver class
    62.8 + *
    62.9 + * This file is released under the GNU General Public License. Refer
   62.10 + * to the COPYING file distributed with this package.
   62.11 + *
   62.12 + * (c) 2003 Andreas 'randy' Weinberger <vdr AT smue.org>
   62.13 + */
   62.14 +
   62.15 +#ifndef _GLCDDRIVERS_SED1520_H_
   62.16 +#define _GLCDDRIVERS_SED1520_H_
   62.17 +
   62.18 +#include "driver.h"
   62.19 +
   62.20 +
   62.21 +namespace GLCD
   62.22 +{
   62.23 +
   62.24 +class cDriverConfig;
   62.25 +class cParallelPort;
   62.26 +
   62.27 +class cDriverSED1520 : public cDriver
   62.28 +{
   62.29 +private:
   62.30 +    cParallelPort * port;
   62.31 +    unsigned char ** LCD;      // linear lcd display "memory"
   62.32 +    unsigned char ** LCD_page; // paged lcd display "memory"
   62.33 +    int refreshCounter;
   62.34 +    long timeForPortCmdInNs;
   62.35 +    cDriverConfig * config;
   62.36 +    cDriverConfig * oldConfig;
   62.37 +    bool useSleepInit;
   62.38 +
   62.39 +    int SEAD;
   62.40 +    int SEPA;
   62.41 +    int SEDS;
   62.42 +    int DION;
   62.43 +    int DIOF;
   62.44 +
   62.45 +    int CS1LO;
   62.46 +    int CS2LO;
   62.47 +    int CS1HI;
   62.48 +    int CS2HI;
   62.49 +
   62.50 +    int CDHI;
   62.51 +    int CDLO;
   62.52 +
   62.53 +    int LED;
   62.54 +    int LEDHI;
   62.55 +
   62.56 +    int CheckSetup();
   62.57 +    int InitGraphic();
   62.58 +    void SED1520Cmd(unsigned char data, int cmscd);
   62.59 +    void SED1520Data(unsigned char data, int datacs);
   62.60 +
   62.61 +public:
   62.62 +    cDriverSED1520(cDriverConfig * config);
   62.63 +    virtual ~cDriverSED1520();
   62.64 +
   62.65 +    virtual int Init();
   62.66 +    virtual int DeInit();
   62.67 +
   62.68 +    virtual void Clear();
   62.69 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   62.70 +    virtual void Refresh(bool refreshAll = false);
   62.71 +};
   62.72 +
   62.73 +} // end of namespace
   62.74 +
   62.75 +#endif
    63.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    63.2 +++ b/graphlcd-base/glcddrivers/serdisp.c	Wed Feb 06 17:32:55 2008 +0000
    63.3 @@ -0,0 +1,467 @@
    63.4 +/*
    63.5 + * GraphLCD driver library
    63.6 + *
    63.7 + * serdisp.h  -  include support for displays supported by serdisplib (if library is installed)
    63.8 + *               http://serdisplib.sourceforge.net
    63.9 + *
   63.10 + * This file is released under the GNU General Public License. Refer
   63.11 + * to the COPYING file distributed with this package.
   63.12 + *
   63.13 + * (c) 2003-2005 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
   63.14 + */
   63.15 +
   63.16 +#include <stdio.h>
   63.17 +#include <stdlib.h>
   63.18 +#include <syslog.h>
   63.19 +#include <dlfcn.h>
   63.20 +
   63.21 +#include "common.h"
   63.22 +#include "config.h"
   63.23 +#include "serdisp.h"
   63.24 +
   63.25 +#define SERDISP_VERSION(a,b) ((long)(((a) << 8) + (b)))
   63.26 +#define SERDISP_VERSION_GET_MAJOR(_c)  ((int)( (_c) >> 8 ))
   63.27 +#define SERDISP_VERSION_GET_MINOR(_c)  ((int)( (_c) & 0xFF ))
   63.28 +
   63.29 +// taken from serdisp_control.h
   63.30 +#define FEATURE_CONTRAST  0x01
   63.31 +#define FEATURE_REVERSE   0x02
   63.32 +#define FEATURE_BACKLIGHT 0x03
   63.33 +#define FEATURE_ROTATE    0x04
   63.34 +
   63.35 +#define SD_COL_BLACK      0xFF000000
   63.36 +
   63.37 +namespace GLCD
   63.38 +{
   63.39 +
   63.40 +cDriverSerDisp::cDriverSerDisp(cDriverConfig * config)
   63.41 +:   config(config)
   63.42 +{
   63.43 +    oldConfig = new cDriverConfig(*config);
   63.44 +
   63.45 +    dd = (void *) NULL;
   63.46 +}
   63.47 +
   63.48 +cDriverSerDisp::~cDriverSerDisp(void)
   63.49 +{
   63.50 +    delete oldConfig;
   63.51 +}
   63.52 +
   63.53 +int cDriverSerDisp::Init(void)
   63.54 +{
   63.55 +    char* errmsg; // error message returned by dlerror()
   63.56 +
   63.57 +    std::string controller;
   63.58 +    std::string optionstring = "";
   63.59 +    std::string wiringstring;
   63.60 +
   63.61 +
   63.62 +    // dynamically load serdisplib using dlopen() & co.
   63.63 +
   63.64 +    sdhnd = dlopen("libserdisp.so", RTLD_LAZY);
   63.65 +    if (!sdhnd) { // try /usr/local/lib
   63.66 +        sdhnd = dlopen("/usr/local/lib/libserdisp.so", RTLD_LAZY);
   63.67 +    }
   63.68 +
   63.69 +    if (!sdhnd) { // serdisplib seems not to be installed
   63.70 +        syslog(LOG_ERR, "%s: error: unable to dynamically load library '%s'. Err: %s (cDriver::Init)\n",
   63.71 +        config->name.c_str(), "libserdisp.so", "not found");
   63.72 +        return -1;
   63.73 +    }
   63.74 +
   63.75 +    dlerror(); // clear error code
   63.76 +
   63.77 +    /* pre-init some flags, function pointers, ... */
   63.78 +    supports_options = 0;
   63.79 +    fg_colour = 1;
   63.80 +    bg_colour = -1;
   63.81 +
   63.82 +    // get serdisp version
   63.83 +    fp_serdisp_getversioncode = (long int (*)()) dlsym(sdhnd, "serdisp_getversioncode");
   63.84 +
   63.85 +    if (dlerror()) { // no serdisp_getversioncode() -> version of serdisplib is < 1.95
   63.86 +        syslog(LOG_DEBUG, "%s: INFO: symbol serdisp_getversioncode unknown: autodetecting pre 1.95 serdisplib version (cDriver::Init)\n",
   63.87 +        config->name.c_str());
   63.88 +
   63.89 +        fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
   63.90 +        if (dlerror()) { // no SDCONN_open() -> version of serdisplib is < 1.93
   63.91 +            serdisp_version = SERDISP_VERSION(1,92);
   63.92 +            syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version <= 1.92 (cDriver::Init)\n", config->name.c_str());
   63.93 +
   63.94 +            fp_PP_open = (void*(*)(const char*))dlsym(sdhnd, "PP_open");
   63.95 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
   63.96 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
   63.97 +                    config->name.c_str(), "PP_open", errmsg);
   63.98 +                return -1;
   63.99 +            }
  63.100 +            fp_PP_close = (void*(*)(void*))dlsym(sdhnd, "PP_close");
  63.101 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.102 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.103 +                    config->name.c_str(), "PP_close", errmsg);
  63.104 +                return -1;
  63.105 +            }
  63.106 +        } else {
  63.107 +            serdisp_version = SERDISP_VERSION(1,94);  // no serdisp_getversioncode, but SDCONN_open: 1.93 or 1.94
  63.108 +            syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version 1.93 or 1.94 (cDriver::Init)\n", config->name.c_str());
  63.109 +
  63.110 +            fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
  63.111 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.112 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.113 +                    config->name.c_str(), "serdisp_quit", errmsg);
  63.114 +                return -1;
  63.115 +            }
  63.116 +        }
  63.117 +
  63.118 +        fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setpixel");
  63.119 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.120 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.121 +                config->name.c_str(), "serdisp_setpixel", errmsg);
  63.122 +            return -1;
  63.123 +        }
  63.124 +        fg_colour = 1; /* set foreground to 'pixel on' */
  63.125 +
  63.126 +    } else {  // serdisp version >= 1.95
  63.127 +        serdisp_version = fp_serdisp_getversioncode();
  63.128 +        syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n",
  63.129 +            config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version));
  63.130 +
  63.131 +
  63.132 +        fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
  63.133 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.134 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.135 +                config->name.c_str(), "SDCONN_open", errmsg);
  63.136 +            return -1;
  63.137 +        }
  63.138 +        fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
  63.139 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.140 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.141 +                config->name.c_str(), "serdisp_quit", errmsg);
  63.142 +            return -1;
  63.143 +        }
  63.144 +        fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour");
  63.145 +        if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.146 +            syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.147 +                config->name.c_str(), "serdisp_setcolour", errmsg);
  63.148 +            return -1;
  63.149 +        }
  63.150 +        fg_colour = SD_COL_BLACK; /* set foreground colour to black */
  63.151 +
  63.152 +        if (serdisp_version >= SERDISP_VERSION(1,96) ) {
  63.153 +            supports_options = 1;
  63.154 +
  63.155 +            fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption");
  63.156 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.157 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.158 +                    config->name.c_str(), "serdisp_isoption", errmsg);
  63.159 +                return -1;
  63.160 +            }
  63.161 +            fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption");
  63.162 +            if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.163 +                syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.164 +                    config->name.c_str(), "serdisp_setoption", errmsg);
  63.165 +                return -1;
  63.166 +            }
  63.167 +        } /* >= 1.96 */
  63.168 +    }
  63.169 +
  63.170 +    // load other symbols that will be required
  63.171 +    fp_serdisp_init = (void*(*)(void*, const char*, const char*)) dlsym(sdhnd, "serdisp_init");
  63.172 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.173 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.174 +            config->name.c_str(), "serdisp_init", errmsg);
  63.175 +        return -1;
  63.176 +    }
  63.177 +
  63.178 +    fp_serdisp_rewrite = (void (*)(void*)) dlsym(sdhnd, "serdisp_rewrite");
  63.179 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.180 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.181 +            config->name.c_str(), "serdisp_rewrite", errmsg);
  63.182 +        return -1;
  63.183 +    }
  63.184 +
  63.185 +    fp_serdisp_update = (void (*)(void*)) dlsym(sdhnd, "serdisp_update");
  63.186 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.187 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.188 +            config->name.c_str(), "serdisp_update", errmsg);
  63.189 +        return -1;
  63.190 +    }
  63.191 +
  63.192 +    fp_serdisp_clearbuffer = (void (*)(void*)) dlsym(sdhnd, "serdisp_clearbuffer");
  63.193 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.194 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.195 +            config->name.c_str(), "serdisp_clearbuffer", errmsg);
  63.196 +        return -1;
  63.197 +    }
  63.198 +
  63.199 +    fp_serdisp_feature = (int (*)(void*, int, int)) dlsym(sdhnd, "serdisp_feature");
  63.200 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.201 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.202 +            config->name.c_str(), "serdisp_feature", errmsg);
  63.203 +        return -1;
  63.204 +    }
  63.205 +
  63.206 +    fp_serdisp_close = (void (*)(void*))dlsym(sdhnd, "serdisp_close");
  63.207 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.208 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.209 +            config->name.c_str(), "serdisp_close", errmsg);
  63.210 +        return -1;
  63.211 +    }
  63.212 +
  63.213 +    fp_serdisp_getwidth = (int (*)(void*)) dlsym(sdhnd, "serdisp_getwidth");
  63.214 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.215 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.216 +            config->name.c_str(), "serdisp_getwidth", errmsg);
  63.217 +        return -1;
  63.218 +    }
  63.219 +
  63.220 +    fp_serdisp_getheight = (int (*)(void*)) dlsym(sdhnd, "serdisp_getheight");
  63.221 +    if ( (errmsg = dlerror()) != NULL  ) { // should not happen
  63.222 +        syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
  63.223 +            config->name.c_str(), "serdisp_getheight", errmsg);
  63.224 +        return -1;
  63.225 +    }
  63.226 +
  63.227 +    // done loading all required symbols
  63.228 +
  63.229 +
  63.230 +    // setting up the display
  63.231 +    width = 0;
  63.232 +    height = 0;
  63.233 +
  63.234 +    for (unsigned int i = 0; i < config->options.size(); i++)
  63.235 +    {
  63.236 +        if (config->options[i].name == "Controller") {
  63.237 +            controller = config->options[i].value;
  63.238 +        } else if (config->options[i].name == "Options") {
  63.239 +            optionstring = config->options[i].value;
  63.240 +        } else if (config->options[i].name == "Wiring") {
  63.241 +            wiringstring = config->options[i].value;
  63.242 +        } else if (config->options[i].name == "FGColour") {
  63.243 +            fg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0);
  63.244 +            fg_colour |= 0xFF000000L;  /* force alpha to 0xFF */
  63.245 +        } else if (config->options[i].name == "BGColour") {
  63.246 +            bg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0);
  63.247 +            bg_colour |= 0xFF000000L;  /* force alpha to 0xFF */
  63.248 +        }
  63.249 +    }
  63.250 +
  63.251 +    if (wiringstring.length()) {
  63.252 +        optionstring = "WIRING=" + wiringstring + ((optionstring != "") ? ";" + optionstring : "");
  63.253 +    }
  63.254 +
  63.255 +    if (controller == "")
  63.256 +    {
  63.257 +        syslog(LOG_ERR, "%s error: no controller given!\n", config->name.c_str());
  63.258 +        return -1;
  63.259 +    }
  63.260 +
  63.261 +
  63.262 +    if (config->device == "")
  63.263 +    {
  63.264 +        // use DirectIO
  63.265 +
  63.266 +        // neither device nor port is set
  63.267 +        if (config->port == 0)
  63.268 +            return -1;
  63.269 +
  63.270 +        char temp[10];
  63.271 +        snprintf(temp, 8, "0x%x", config->port);
  63.272 +
  63.273 +        if (serdisp_version < SERDISP_VERSION(1,93) ) {
  63.274 +            sdcd = fp_PP_open(temp);
  63.275 +        } else {
  63.276 +            sdcd = fp_SDCONN_open(temp);
  63.277 +        }
  63.278 +
  63.279 +        if (sdcd == 0) {
  63.280 +            syslog(LOG_ERR, "%s: error: unable to open port 0x%x for display %s. (cDriver::Init)\n",
  63.281 +                config->name.c_str(), config->port, controller.c_str());
  63.282 +            return -1;
  63.283 +        }
  63.284 +
  63.285 +        uSleep(10);
  63.286 +    }
  63.287 +    else
  63.288 +    {
  63.289 +        // use ppdev
  63.290 +        if (serdisp_version < SERDISP_VERSION(1,93) ) {
  63.291 +            sdcd = fp_PP_open(config->device.c_str());
  63.292 +        } else {
  63.293 +            sdcd = fp_SDCONN_open(config->device.c_str());
  63.294 +        }
  63.295 +
  63.296 +        if (sdcd == 0) {
  63.297 +            syslog(LOG_ERR, "%s: error: unable to open device %s for display %s. (cDriver::Init)\n",
  63.298 +                config->name.c_str(), config->device.c_str(), controller.c_str());
  63.299 +            return -1;
  63.300 +        }
  63.301 +    }
  63.302 +
  63.303 +    if (serdisp_version < SERDISP_VERSION(1,95) )
  63.304 +        dd = fp_serdisp_init(sdcd, controller.c_str(), "");
  63.305 +    else
  63.306 +        dd = fp_serdisp_init(sdcd, controller.c_str(), optionstring.c_str());
  63.307 +
  63.308 +    if (!dd)
  63.309 +    {
  63.310 +        syslog(LOG_ERR, "%s: error: cannot open display %s. Err:%s (cDriver::Init)\n",
  63.311 +            config->name.c_str(), controller.c_str(), "no handle");
  63.312 +        return -1;
  63.313 +    }
  63.314 +
  63.315 +    width = config->width;
  63.316 +    if (width <= 0)
  63.317 +        width = fp_serdisp_getwidth(dd);
  63.318 +    height = config->height;
  63.319 +    if (height <= 0)
  63.320 +        height = fp_serdisp_getheight(dd);
  63.321 +
  63.322 +    if (serdisp_version < SERDISP_VERSION(1,96) ) {
  63.323 +        fp_serdisp_feature(dd, FEATURE_ROTATE, config->upsideDown);
  63.324 +        fp_serdisp_feature(dd, FEATURE_CONTRAST, config->contrast);
  63.325 +        fp_serdisp_feature(dd, FEATURE_BACKLIGHT, config->backlight);
  63.326 +        fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
  63.327 +    } else {
  63.328 +        /* standard options */
  63.329 +        fp_serdisp_setoption(dd, "ROTATE", config->upsideDown);
  63.330 +        fp_serdisp_setoption(dd, "CONTRAST", config->contrast);
  63.331 +        fp_serdisp_setoption(dd, "BACKLIGHT", config->backlight);
  63.332 +        fp_serdisp_setoption(dd, "INVERT", config->invert);
  63.333 +
  63.334 +        /* driver dependend options */
  63.335 +        for (unsigned int i = 0; i < config->options.size(); i++) {
  63.336 +            std::string optionname = config->options[i].name;
  63.337 +            if (optionname != "UpsideDown" && optionname != "Contrast" &&
  63.338 +                optionname != "Backlight" && optionname != "Invert") {
  63.339 +
  63.340 +                if ( fp_serdisp_isoption(dd, optionname.c_str()) == 1 )  /* if == 1: option is existing AND r/w */
  63.341 +                    fp_serdisp_setoption(dd, optionname.c_str(), strtol(config->options[i].value.c_str(), NULL, 0));
  63.342 +            }
  63.343 +        }
  63.344 +
  63.345 +    }
  63.346 +
  63.347 +    *oldConfig = *config;
  63.348 +
  63.349 +    // clear display
  63.350 +    Clear();
  63.351 +
  63.352 +    syslog(LOG_INFO, "%s: SerDisp with %s initialized.\n", config->name.c_str(), controller.c_str());
  63.353 +    return 0;
  63.354 +}
  63.355 +
  63.356 +int cDriverSerDisp::DeInit(void)
  63.357 +{
  63.358 +    if (serdisp_version < SERDISP_VERSION(1,93) ) {
  63.359 +        fp_serdisp_close(dd);
  63.360 +        fp_PP_close(sdcd);
  63.361 +        sdcd = NULL;
  63.362 +    } else {
  63.363 +        //fp_serdisp_quit(dd);
  63.364 +        /* use serdisp_close instead of serdisp_quit so that showpic and showtext are usable together with serdisplib */
  63.365 +        fp_serdisp_close(dd);
  63.366 +    }
  63.367 +    (int) dlclose(sdhnd);
  63.368 +    sdhnd = NULL;
  63.369 +
  63.370 +    return 0;
  63.371 +}
  63.372 +
  63.373 +int cDriverSerDisp::CheckSetup()
  63.374 +{
  63.375 +    bool update = false;
  63.376 +
  63.377 +    if (config->device != oldConfig->device ||
  63.378 +        config->port != oldConfig->port ||
  63.379 +        config->width != oldConfig->width ||
  63.380 +        config->height != oldConfig->height)
  63.381 +    {
  63.382 +        DeInit();
  63.383 +        Init();
  63.384 +        return 0;
  63.385 +    }
  63.386 +
  63.387 +    if (config->contrast != oldConfig->contrast)
  63.388 +    {
  63.389 +        fp_serdisp_feature(dd, FEATURE_CONTRAST, config->contrast);
  63.390 +        oldConfig->contrast = config->contrast;
  63.391 +        update = true;
  63.392 +    }
  63.393 +    if (config->backlight != oldConfig->backlight)
  63.394 +    {
  63.395 +        fp_serdisp_feature(dd, FEATURE_BACKLIGHT, config->backlight);
  63.396 +        oldConfig->backlight = config->backlight;
  63.397 +        update = true;
  63.398 +    }
  63.399 +    if (config->upsideDown != oldConfig->upsideDown)
  63.400 +    {
  63.401 +        fp_serdisp_feature(dd, FEATURE_ROTATE, config->upsideDown);
  63.402 +        oldConfig->upsideDown = config->upsideDown;
  63.403 +        update = true;
  63.404 +    }
  63.405 +    if (config->invert != oldConfig->invert)
  63.406 +    {
  63.407 +        fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
  63.408 +        oldConfig->invert = config->invert;
  63.409 +        update = true;
  63.410 +    }
  63.411 +
  63.412 +    /* driver dependend options */
  63.413 +    for (unsigned int i = 0; i < config->options.size(); i++) {
  63.414 +        std::string optionname = config->options[i].name;
  63.415 +        if (optionname != "UpsideDown" && optionname != "Contrast" &&
  63.416 +            optionname != "Backlight" && optionname != "Invert") {
  63.417 +
  63.418 +            if ( fp_serdisp_isoption(dd, optionname.c_str()) == 1 )  /* if == 1: option is existing AND r/w */
  63.419 +                fp_serdisp_setoption(dd, optionname.c_str(), strtol(config->options[i].value.c_str(), NULL, 0));
  63.420 +            oldConfig->options[i] = config->options[i];
  63.421 +            update = true;
  63.422 +        }
  63.423 +    }
  63.424 +
  63.425 +
  63.426 +    if (update)
  63.427 +        return 1;
  63.428 +    return 0;
  63.429 +}
  63.430 +
  63.431 +void cDriverSerDisp::Clear(void)
  63.432 +{
  63.433 +    if (bg_colour == -1)
  63.434 +        fp_serdisp_clearbuffer(dd);
  63.435 +    else {  /* if bg_colour is set, draw background 'by hand' */
  63.436 +        int x,y;
  63.437 +        for (y = 0; y < fp_serdisp_getheight(dd); y++)
  63.438 +            for (x = 0; x < fp_serdisp_getwidth(dd); x++)
  63.439 +                fp_serdisp_setpixcol(dd, x, y, bg_colour);   /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
  63.440 +    }
  63.441 +}
  63.442 +
  63.443 +void cDriverSerDisp::Set8Pixels(int x, int y, unsigned char data) {
  63.444 +    int i, start, pixel;
  63.445 +
  63.446 +    data = ReverseBits(data);
  63.447 +
  63.448 +    start = (x >> 3) << 3;
  63.449 +
  63.450 +    for (i = 0; i < 8; i++) {
  63.451 +        pixel = data & (1 << i);
  63.452 +        if (pixel)
  63.453 +            fp_serdisp_setpixcol(dd, start + i, y, fg_colour);   /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
  63.454 +        else if (!pixel && bg_colour != -1)  /* if bg_colour is set: use it if pixel is not set */
  63.455 +            fp_serdisp_setpixcol(dd, start + i, y, bg_colour);   /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
  63.456 +    }
  63.457 +}
  63.458 +
  63.459 +void cDriverSerDisp::Refresh(bool refreshAll)
  63.460 +{
  63.461 +    if (CheckSetup() == 1)
  63.462 +        refreshAll = true;
  63.463 +
  63.464 +    if (refreshAll)
  63.465 +        fp_serdisp_rewrite(dd);
  63.466 +    else
  63.467 +        fp_serdisp_update(dd);
  63.468 +}
  63.469 +
  63.470 +} // end of namespace
    64.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    64.2 +++ b/graphlcd-base/glcddrivers/serdisp.h	Wed Feb 06 17:32:55 2008 +0000
    64.3 @@ -0,0 +1,78 @@
    64.4 +/*
    64.5 + * GraphLCD driver library
    64.6 + *
    64.7 + * serdisp.h  -  include support for displays supported by serdisplib (if library is installed)
    64.8 + *               http://serdisplib.sourceforge.net
    64.9 + *
   64.10 + * This file is released under the GNU General Public License. Refer
   64.11 + * to the COPYING file distributed with this package.
   64.12 + *
   64.13 + * (c) 2003-2005 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
   64.14 + */
   64.15 +
   64.16 +#ifndef _GLCDDRIVERS_SERDISP_H_
   64.17 +#define _GLCDDRIVERS_SERDISP_H_
   64.18 +
   64.19 +#include "driver.h"
   64.20 +
   64.21 +
   64.22 +namespace GLCD
   64.23 +{
   64.24 +
   64.25 +class cDriverConfig;
   64.26 +
   64.27 +class cDriverSerDisp : public cDriver
   64.28 +{
   64.29 +private:
   64.30 +
   64.31 +    cDriverConfig * config;
   64.32 +    cDriverConfig * oldConfig;
   64.33 +
   64.34 +    long  serdisp_version;
   64.35 +
   64.36 +    int   supports_options;
   64.37 +    long  fg_colour;
   64.38 +    long  bg_colour;
   64.39 +
   64.40 +    void* sdhnd; // serdisplib handle
   64.41 +    void* dd;    // display descriptor
   64.42 +    void* sdcd;  // serdisp connect descriptor
   64.43 +
   64.44 +    long  (*fp_serdisp_getversioncode) ();
   64.45 +
   64.46 +    void* (*fp_SDCONN_open)            (const char sdcdev[]);
   64.47 +
   64.48 +    void* (*fp_PP_open)                (const char sdcdev[]);
   64.49 +    void* (*fp_PP_close)               (void* sdcd);
   64.50 +
   64.51 +    void* (*fp_serdisp_init)           (void* sdcd, const char dispname[], const char extra[]);
   64.52 +    void  (*fp_serdisp_rewrite)        (void* dd);
   64.53 +    void  (*fp_serdisp_update)         (void* dd);
   64.54 +    void  (*fp_serdisp_clearbuffer)    (void* dd);
   64.55 +    void  (*fp_serdisp_setpixcol)      (void* dd, int x, int y, long colour);  // serdisp_setpixel or serdisp_setcolour
   64.56 +    int   (*fp_serdisp_feature)        (void* dd, int feature, int value);
   64.57 +    int   (*fp_serdisp_isoption)       (void* dd, const char* optionname);
   64.58 +    void  (*fp_serdisp_setoption)      (void* dd, const char* optionname, long value);
   64.59 +    int   (*fp_serdisp_getwidth)       (void* dd);
   64.60 +    int   (*fp_serdisp_getheight)      (void* dd);
   64.61 +    void  (*fp_serdisp_quit)           (void* dd);
   64.62 +    void  (*fp_serdisp_close)          (void* dd);
   64.63 +
   64.64 +    int CheckSetup();
   64.65 +
   64.66 +public:
   64.67 +
   64.68 +    cDriverSerDisp(cDriverConfig * config);
   64.69 +    virtual ~cDriverSerDisp();
   64.70 +
   64.71 +    virtual int Init();
   64.72 +    virtual int DeInit();
   64.73 +
   64.74 +    virtual void Clear();
   64.75 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   64.76 +    virtual void Refresh(bool refreshAll = false);
   64.77 +};
   64.78 +
   64.79 +#endif
   64.80 +
   64.81 +} // end of namespace
    65.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    65.2 +++ b/graphlcd-base/glcddrivers/simlcd.c	Wed Feb 06 17:32:55 2008 +0000
    65.3 @@ -0,0 +1,183 @@
    65.4 +/*
    65.5 + * GraphLCD driver library
    65.6 + *
    65.7 + * simlcd.c  -  SimLCD driver class
    65.8 + *              Output goes to a file instead of lcd.
    65.9 + *              Use SimLCD tool to view this file.
   65.10 + *
   65.11 + * This file is released under the GNU General Public License. Refer
   65.12 + * to the COPYING file distributed with this package.
   65.13 + *
   65.14 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   65.15 + */
   65.16 +
   65.17 +#include <stdio.h>
   65.18 +#include <syslog.h>
   65.19 +
   65.20 +#include "common.h"
   65.21 +#include "config.h"
   65.22 +#include "simlcd.h"
   65.23 +
   65.24 +
   65.25 +namespace GLCD
   65.26 +{
   65.27 +
   65.28 +cDriverSimLCD::cDriverSimLCD(cDriverConfig * config)
   65.29 +:   config(config)
   65.30 +{
   65.31 +    oldConfig = new cDriverConfig(*config);
   65.32 +}
   65.33 +
   65.34 +cDriverSimLCD::~cDriverSimLCD()
   65.35 +{
   65.36 +    delete oldConfig;
   65.37 +}
   65.38 +
   65.39 +int cDriverSimLCD::Init()
   65.40 +{
   65.41 +    width = config->width;
   65.42 +    if (width <= 0)
   65.43 +        width = 240;
   65.44 +    height = config->height;
   65.45 +    if (height <= 0)
   65.46 +        height = 128;
   65.47 +
   65.48 +    for (unsigned int i = 0; i < config->options.size(); i++)
   65.49 +    {
   65.50 +        if (config->options[i].name == "")
   65.51 +        {
   65.52 +        }
   65.53 +    }
   65.54 +
   65.55 +    // setup lcd array
   65.56 +    LCD = new unsigned char *[(width + 7) / 8];
   65.57 +    if (LCD)
   65.58 +    {
   65.59 +        for (int x = 0; x < (width + 7) / 8; x++)
   65.60 +        {
   65.61 +            LCD[x] = new unsigned char[height];
   65.62 +            memset(LCD[x], 0, height);
   65.63 +        }
   65.64 +    }
   65.65 +
   65.66 +    *oldConfig = *config;
   65.67 +
   65.68 +    // clear display
   65.69 +    Clear();
   65.70 +
   65.71 +    syslog(LOG_INFO, "%s: SIMLCD initialized.\n", config->name.c_str());
   65.72 +    return 0;
   65.73 +}
   65.74 +
   65.75 +int cDriverSimLCD::DeInit()
   65.76 +{
   65.77 +    // free lcd array
   65.78 +    if (LCD)
   65.79 +    {
   65.80 +        for (int x = 0; x < (width + 7) / 8; x++)
   65.81 +        {
   65.82 +            delete[] LCD[x];
   65.83 +        }
   65.84 +        delete[] LCD;
   65.85 +    }
   65.86 +
   65.87 +    return 0;
   65.88 +}
   65.89 +
   65.90 +int cDriverSimLCD::CheckSetup()
   65.91 +{
   65.92 +    if (config->width != oldConfig->width ||
   65.93 +        config->height != oldConfig->height)
   65.94 +    {
   65.95 +        DeInit();
   65.96 +        Init();
   65.97 +        return 0;
   65.98 +    }
   65.99 +
  65.100 +    if (config->upsideDown != oldConfig->upsideDown ||
  65.101 +        config->invert != oldConfig->invert)
  65.102 +    {
  65.103 +        oldConfig->upsideDown = config->upsideDown;
  65.104 +        oldConfig->invert = config->invert;
  65.105 +        return 1;
  65.106 +    }
  65.107 +    return 0;
  65.108 +}
  65.109 +
  65.110 +void cDriverSimLCD::Clear()
  65.111 +{
  65.112 +    for (int x = 0; x < (width + 7) / 8; x++)
  65.113 +        memset(LCD[x], 0, height);
  65.114 +}
  65.115 +
  65.116 +void cDriverSimLCD::Set8Pixels(int x, int y, unsigned char data)
  65.117 +{
  65.118 +    if (x >= width || y >= height)
  65.119 +        return;
  65.120 +
  65.121 +    if (!config->upsideDown)
  65.122 +    {
  65.123 +        // normal orientation
  65.124 +        LCD[x / 8][y] = LCD[x / 8][y] | data;
  65.125 +    }
  65.126 +    else
  65.127 +    {
  65.128 +        // upside down orientation
  65.129 +        x = width - 1 - x;
  65.130 +        y = height - 1 - y;
  65.131 +        LCD[x / 8][y] = LCD[x / 8][y] | ReverseBits(data);
  65.132 +    }
  65.133 +}
  65.134 +
  65.135 +void cDriverSimLCD::Refresh(bool refreshAll)
  65.136 +{
  65.137 +    FILE * fp = NULL;
  65.138 +    int x;
  65.139 +    int y;
  65.140 +    int i;
  65.141 +    unsigned char c;
  65.142 +
  65.143 +    if (CheckSetup() > 0)
  65.144 +        refreshAll = true;
  65.145 +
  65.146 +    fp = fopen("/tmp/simlcd.sem", "r");
  65.147 +    if (!fp || refreshAll)
  65.148 +    {
  65.149 +        if (fp)
  65.150 +            fclose(fp);
  65.151 +        fp = fopen("/tmp/simlcd.dat", "w");
  65.152 +        if (fp)
  65.153 +        {
  65.154 +            for (y = 0; y < height; y++)
  65.155 +            {
  65.156 +                for (x = 0; x < (width + 7) / 8; x++)
  65.157 +                {
  65.158 +                    c = LCD[x][y] ^ (config->invert ? 0xff : 0x00);
  65.159 +                    for (i = 0; i < 8; i++)
  65.160 +                    {
  65.161 +                        if (c & 0x80)
  65.162 +                        {
  65.163 +                            fprintf(fp,"#");
  65.164 +                        }
  65.165 +                        else
  65.166 +                        {
  65.167 +                            fprintf(fp,".");
  65.168 +                        }
  65.169 +                        c = c << 1;
  65.170 +                    }
  65.171 +                }
  65.172 +                fprintf(fp,"\n");
  65.173 +            }
  65.174 +            fclose(fp);
  65.175 +        }
  65.176 +
  65.177 +        fp = fopen("/tmp/simlcd.sem", "w");
  65.178 +        fclose(fp);
  65.179 +    }
  65.180 +    else
  65.181 +    {
  65.182 +        fclose(fp);
  65.183 +    }
  65.184 +}
  65.185 +
  65.186 +} // end of namespace
    66.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    66.2 +++ b/graphlcd-base/glcddrivers/simlcd.h	Wed Feb 06 17:32:55 2008 +0000
    66.3 @@ -0,0 +1,48 @@
    66.4 +/*
    66.5 + * GraphLCD driver library
    66.6 + *
    66.7 + * simlcd.h  -  SimLCD driver class
    66.8 + *              Output goes to a file instead of lcd.
    66.9 + *              Use SimLCD tool to view this file.
   66.10 + *
   66.11 + * This file is released under the GNU General Public License. Refer
   66.12 + * to the COPYING file distributed with this package.
   66.13 + *
   66.14 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   66.15 + */
   66.16 +
   66.17 +#ifndef _GLCDDRIVERS_SIMLCD_H_
   66.18 +#define _GLCDDRIVERS_SIMLCD_H_
   66.19 +
   66.20 +#include "driver.h"
   66.21 +
   66.22 +
   66.23 +namespace GLCD
   66.24 +{
   66.25 +
   66.26 +class cDriverConfig;
   66.27 +
   66.28 +class cDriverSimLCD : public cDriver
   66.29 +{
   66.30 +private:
   66.31 +    unsigned char ** LCD;
   66.32 +    cDriverConfig * config;
   66.33 +    cDriverConfig * oldConfig;
   66.34 +
   66.35 +    int CheckSetup();
   66.36 +
   66.37 +public:
   66.38 +    cDriverSimLCD(cDriverConfig * config);
   66.39 +    virtual ~cDriverSimLCD();
   66.40 +
   66.41 +    virtual int Init();
   66.42 +    virtual int DeInit();
   66.43 +
   66.44 +    virtual void Clear();
   66.45 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   66.46 +    virtual void Refresh(bool refreshAll = false);
   66.47 +};
   66.48 +
   66.49 +} // end of namespace
   66.50 +
   66.51 +#endif
    67.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    67.2 +++ b/graphlcd-base/glcddrivers/t6963c.c	Wed Feb 06 17:32:55 2008 +0000
    67.3 @@ -0,0 +1,678 @@
    67.4 +/*
    67.5 + * GraphLCD driver library
    67.6 + *
    67.7 + * t6963c.c  -  T6963C driver class
    67.8 + *
    67.9 + * low level routines based on lcdproc 0.5 driver, (c) 2001 Manuel Stahl
   67.10 + *
   67.11 + * This file is released under the GNU General Public License. Refer
   67.12 + * to the COPYING file distributed with this package.
   67.13 + *
   67.14 + * (c) 2003, 2004 Andreas Regel <andreas.regel AT powarman.de>
   67.15 + */
   67.16 +
   67.17 +#include <syslog.h>
   67.18 +
   67.19 +#include "common.h"
   67.20 +#include "config.h"
   67.21 +#include "port.h"
   67.22 +#include "t6963c.h"
   67.23 +
   67.24 +
   67.25 +namespace GLCD
   67.26 +{
   67.27 +
   67.28 +// T6963 commands
   67.29 +const unsigned char kSetCursorPointer  = 0x21;
   67.30 +const unsigned char kSetOffsetRegister = 0x22;
   67.31 +const unsigned char kSetAddressPointer = 0x24;
   67.32 +
   67.33 +const unsigned char kSetTextHomeAddress    = 0x40;
   67.34 +const unsigned char kSetTextArea           = 0x41;
   67.35 +const unsigned char kSetGraphicHomeAddress = 0x42;
   67.36 +const unsigned char kSetGraphicArea        = 0x43;
   67.37 +
   67.38 +const unsigned char kSetMode          = 0x80;
   67.39 +const unsigned char kSetDisplayMode   = 0x90;
   67.40 +const unsigned char kSetCursorPattern = 0xA0;
   67.41 +
   67.42 +const unsigned char kDataWriteInc = 0xC0;
   67.43 +const unsigned char kDataReadInc  = 0xC1;
   67.44 +const unsigned char kDataWriteDec = 0xC2;
   67.45 +const unsigned char kDataReadDec  = 0xC3;
   67.46 +const unsigned char kDataWrite    = 0xC4;
   67.47 +const unsigned char kDataRead     = 0xC5;
   67.48 +
   67.49 +const unsigned char kAutoWrite = 0xB0;
   67.50 +const unsigned char kAutoRead  = 0xB1;
   67.51 +const unsigned char kAutoReset = 0xB2;
   67.52 +
   67.53 +
   67.54 +// T6963 Parameters
   67.55 +const unsigned char kModeOr            = 0x00;
   67.56 +const unsigned char kModeXor           = 0x01;
   67.57 +const unsigned char kModeAnd           = 0x03;
   67.58 +const unsigned char kModeTextAttribute = 0x04;
   67.59 +const unsigned char kModeInternalCG    = 0x00;
   67.60 +const unsigned char kModeExternalCG    = 0x08;
   67.61 +
   67.62 +const unsigned char kTextAttributeNormal    = 0x00;
   67.63 +const unsigned char kTextAttributeInverse   = 0x05;
   67.64 +const unsigned char kTextAttributeNoDisplay = 0x03;
   67.65 +const unsigned char kTextAttributeBlink     = 0x08;
   67.66 +
   67.67 +const unsigned char kDisplayModeBlink   = 0x01;
   67.68 +const unsigned char kDisplayModeCursor  = 0x02;
   67.69 +const unsigned char kDisplayModeText    = 0x04;
   67.70 +const unsigned char kDisplayModeGraphic = 0x08;
   67.71 +
   67.72 +const unsigned short kGraphicBase = 0x0000;
   67.73 +const unsigned short kTextBase    = 0x1500;
   67.74 +const unsigned short kCGRAMBase   = 0x1800;
   67.75 +
   67.76 +
   67.77 +// T6963 Wirings
   67.78 +static const std::string kWiringStandard = "Standard";
   67.79 +static const std::string kWiringWindows  = "Windows";
   67.80 +static const std::string kWiringSerial   = "Serial";
   67.81 +
   67.82 +const unsigned char kStandardWRHI = 0x00; // 01 / nSTRB
   67.83 +const unsigned char kStandardWRLO = 0x01; //
   67.84 +const unsigned char kStandardRDHI = 0x00; // 17 / nSELECT
   67.85 +const unsigned char kStandardRDLO = 0x08; //
   67.86 +const unsigned char kStandardCEHI = 0x00; // 14 / nLINEFEED
   67.87 +const unsigned char kStandardCELO = 0x02; //
   67.88 +const unsigned char kStandardCDHI = 0x04; // 16 / INIT
   67.89 +const unsigned char kStandardCDLO = 0x00; //
   67.90 +
   67.91 +const unsigned char kWindowsWRHI = 0x04; // 16 / INIT
   67.92 +const unsigned char kWindowsWRLO = 0x00; //
   67.93 +const unsigned char kWindowsRDHI = 0x00; // 14 / nLINEFEED
   67.94 +const unsigned char kWindowsRDLO = 0x02; //
   67.95 +const unsigned char kWindowsCEHI = 0x00; // 01 / nSTRB
   67.96 +const unsigned char kWindowsCELO = 0x01; //
   67.97 +const unsigned char kWindowsCDHI = 0x00; // 17 / nSELECT
   67.98 +const unsigned char kWindowsCDLO = 0x08; //
   67.99 +
  67.100 +const unsigned char kSerialWRHI = 0x01; // 01 / nSTRB
  67.101 +const unsigned char kSerialWRLO = 0x00; //
  67.102 +const unsigned char kSerialRDHI = 0x08; // 17 / nSELECT
  67.103 +const unsigned char kSerialRDLO = 0x00; //
  67.104 +const unsigned char kSerialCEHI = 0x02; // 14 / nLINEFEED
  67.105 +const unsigned char kSerialCELO = 0x00; //
  67.106 +const unsigned char kSerialCDHI = 0x00; // 16 / INIT
  67.107 +const unsigned char kSerialCDLO = 0x04; //
  67.108 +
  67.109 +
  67.110 +cDriverT6963C::cDriverT6963C(cDriverConfig * config)
  67.111 +:   config(config)
  67.112 +{
  67.113 +    oldConfig = new cDriverConfig(*config);
  67.114 +
  67.115 +    port = new cParallelPort();
  67.116 +
  67.117 +    //width = config->width;
  67.118 +    //height = config->height;
  67.119 +    refreshCounter = 0;
  67.120 +    displayMode = 0;
  67.121 +    bidirectLPT = 1;
  67.122 +    autoWrite = false;
  67.123 +    serial = 0;
  67.124 +}
  67.125 +
  67.126 +cDriverT6963C::~cDriverT6963C()
  67.127 +{
  67.128 +    delete port;
  67.129 +    delete oldConfig;
  67.130 +}
  67.131 +
  67.132 +int cDriverT6963C::Init()
  67.133 +{
  67.134 +    int x;
  67.135 +
  67.136 +    width = config->width;
  67.137 +    if (width <= 0)
  67.138 +        width = 240;
  67.139 +    height = config->height;
  67.140 +    if (height <= 0)
  67.141 +        height = 128;
  67.142 +
  67.143 +    // default values
  67.144 +    FS = 6;
  67.145 +    WRHI = kStandardWRHI;
  67.146 +    WRLO = kStandardWRLO;
  67.147 +    RDHI = kStandardRDHI;
  67.148 +    RDLO = kStandardRDLO;
  67.149 +    CEHI = kStandardCEHI;
  67.150 +    CELO = kStandardCELO;
  67.151 +    CDHI = kStandardCDHI;
  67.152 +    CDLO = kStandardCDLO;
  67.153 +    useAutoMode = true;
  67.154 +    useStatusCheck = true;
  67.155 +
  67.156 +    for (unsigned int i = 0; i < config->options.size(); i++)
  67.157 +    {
  67.158 +        if (config->options[i].name == "FontSelect")
  67.159 +        {
  67.160 +            int fontSelect = atoi(config->options[i].value.c_str());
  67.161 +            if (fontSelect == 6)
  67.162 +                FS = 6;
  67.163 +            else if (fontSelect == 8)
  67.164 +                FS = 8;
  67.165 +            else
  67.166 +                syslog(LOG_ERR, "%s error: font select %d not supported, using default (%d)!\n",
  67.167 +                       config->name.c_str(), fontSelect, FS);
  67.168 +        }
  67.169 +        else if (config->options[i].name == "Wiring")
  67.170 +        {
  67.171 +            if (config->options[i].value == kWiringStandard)
  67.172 +            {
  67.173 +                WRHI = kStandardWRHI;
  67.174 +                WRLO = kStandardWRLO;
  67.175 +                RDHI = kStandardRDHI;
  67.176 +                RDLO = kStandardRDLO;
  67.177 +                CEHI = kStandardCEHI;
  67.178 +                CELO = kStandardCELO;
  67.179 +                CDHI = kStandardCDHI;
  67.180 +                CDLO = kStandardCDLO;
  67.181 +            }
  67.182 +            else if (config->options[i].value == kWiringWindows)
  67.183 +            {
  67.184 +                WRHI = kWindowsWRHI;
  67.185 +                WRLO = kWindowsWRLO;
  67.186 +                RDHI = kWindowsRDHI;
  67.187 +                RDLO = kWindowsRDLO;
  67.188 +                CEHI = kWindowsCEHI;
  67.189 +                CELO = kWindowsCELO;
  67.190 +                CDHI = kWindowsCDHI;
  67.191 +                CDLO = kWindowsCDLO;
  67.192 +            }
  67.193 +            else if (config->options[i].value == kWiringSerial)
  67.194 +            {
  67.195 +                serial = 1;
  67.196 +                WRHI = kSerialWRHI;
  67.197 +                WRLO = kSerialWRLO;
  67.198 +                RDHI = kSerialRDHI;
  67.199 +                RDLO = kSerialRDLO;
  67.200 +                CEHI = kSerialCEHI;
  67.201 +                CELO = kSerialCELO;
  67.202 +                CDHI = kSerialCDHI;
  67.203 +                CDLO = kSerialCDLO;
  67.204 +            }
  67.205 +            else
  67.206 +                syslog(LOG_ERR, "%s error: wiring %s not supported, using default (Standard)!\n",
  67.207 +                       config->name.c_str(), config->options[i].value.c_str());
  67.208 +        }
  67.209 +        else if (config->options[i].name == "AutoMode")
  67.210 +        {
  67.211 +            if (config->options[i].value == "yes")
  67.212 +                useAutoMode = true;
  67.213 +            else if (config->options[i].value == "no")
  67.214 +                useAutoMode = false;
  67.215 +            else
  67.216 +                syslog(LOG_ERR, "%s error: unknown auto mode setting %s, using default (%s)!\n",
  67.217 +                       config->name.c_str(), config->options[i].value.c_str(), useAutoMode ? "yes" : "no");
  67.218 +        }
  67.219 +        else if (config->options[i].name == "StatusCheck")
  67.220 +        {
  67.221 +            if (config->options[i].value == "yes")
  67.222 +                useStatusCheck = true;
  67.223 +            else if (config->options[i].value == "no")
  67.224 +                useStatusCheck = false;
  67.225 +            else
  67.226 +                syslog(LOG_ERR, "%s error: unknown status check setting %s, using default (%s)!\n",
  67.227 +                       config->name.c_str(), config->options[i].value.c_str(), useStatusCheck ? "yes" : "no");
  67.228 +        }
  67.229 +    }
  67.230 +
  67.231 +    // setup lcd array (wanted state)
  67.232 +    newLCD = new unsigned char*[(width + (FS - 1)) / FS];
  67.233 +    if (newLCD)
  67.234 +    {
  67.235 +        for (x = 0; x < (width + (FS - 1)) / FS; x++)
  67.236 +        {
  67.237 +            newLCD[x] = new unsigned char[height];
  67.238 +            memset(newLCD[x], 0, height);
  67.239 +        }
  67.240 +    }
  67.241 +    // setup lcd array (current state)
  67.242 +    oldLCD = new unsigned char*[(width + (FS - 1)) / FS];
  67.243 +    if (oldLCD)
  67.244 +    {
  67.245 +        for (x = 0; x < (width + (FS - 1)) / FS; x++)
  67.246 +        {
  67.247 +            oldLCD[x] = new unsigned char[height];
  67.248 +            memset(oldLCD[x], 0, height);
  67.249 +        }
  67.250 +    }
  67.251 +
  67.252 +    if (config->device == "")
  67.253 +    {
  67.254 +        // use DirectIO
  67.255 +        if (port->Open(config->port) != 0)
  67.256 +            return -1;
  67.257 +        uSleep(10);
  67.258 +    }
  67.259 +    else
  67.260 +    {
  67.261 +        // use ppdev
  67.262 +        if (port->Open(config->device.c_str()) != 0)
  67.263 +            return -1;
  67.264 +    }
  67.265 +
  67.266 +    // disable chip
  67.267 +    // disable reading from LCD
  67.268 +    // disable writing to LCD
  67.269 +    // command/status mode
  67.270 +    T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
  67.271 +    port->SetDirection(kForward); // make 8-bit parallel port an output port
  67.272 +
  67.273 +    // Test ECP mode
  67.274 +    if (bidirectLPT == 1)
  67.275 +    {
  67.276 +        syslog(LOG_DEBUG, "%s: Testing ECP mode...\n", config->name.c_str());
  67.277 +        int i = 0;
  67.278 +        int ecp_input;
  67.279 +        port->SetDirection(kReverse);
  67.280 +        for (int i = 0; i < 100; i++)
  67.281 +        {
  67.282 +            T6963CSetControl(WRHI | CEHI | CDHI | RDHI);    // wr, ce, cd, rd
  67.283 +            T6963CSetControl(WRHI | CELO | CDHI | RDLO);
  67.284 +            T6963CSetControl(WRHI | CELO | CDHI | RDLO);
  67.285 +            T6963CSetControl(WRHI | CELO | CDHI | RDLO);
  67.286 +            ecp_input = port->ReadData();
  67.287 +            T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
  67.288 +            if ((ecp_input & 0x03) == 0x03)
  67.289 +                break;
  67.290 +        }
  67.291 +        port->SetDirection(kForward);
  67.292 +        if (i >= 100)
  67.293 +        {
  67.294 +            syslog(LOG_DEBUG, "%s: ECP mode not working! -> is now disabled\n", config->name.c_str());
  67.295 +            bidirectLPT = 0;
  67.296 +        }
  67.297 +        else
  67.298 +            syslog(LOG_DEBUG, "%s: working!\n", config->name.c_str());
  67.299 +    }
  67.300 +
  67.301 +    T6963CCommandWord(kSetGraphicHomeAddress, kGraphicBase);
  67.302 +    if (width % FS == 0)
  67.303 +        T6963CCommandWord(kSetGraphicArea, width / FS);
  67.304 +    else
  67.305 +        T6963CCommandWord(kSetGraphicArea, width / FS + 1);
  67.306 +
  67.307 +    T6963CCommand(kSetMode | kModeOr | kModeInternalCG);
  67.308 +
  67.309 +    T6963CDisplayMode(kDisplayModeText, false);
  67.310 +    T6963CDisplayMode(kDisplayModeGraphic, true);
  67.311 +    T6963CDisplayMode(kDisplayModeCursor, false);
  67.312 +    T6963CDisplayMode(kDisplayModeBlink, false);
  67.313 +
  67.314 +    port->Release();
  67.315 +
  67.316 +    *oldConfig = *config;
  67.317 +
  67.318 +    // clear display
  67.319 +    Clear();
  67.320 +
  67.321 +    syslog(LOG_INFO, "%s: T6963 initialized.\n", config->name.c_str());
  67.322 +    return 0;
  67.323 +}
  67.324 +
  67.325 +int cDriverT6963C::DeInit()
  67.326 +{
  67.327 +    int x;
  67.328 +    // free lcd array (wanted state)
  67.329 +    if (newLCD)
  67.330 +    {
  67.331 +        for (x = 0; x < (width + (FS - 1)) / FS; x++)
  67.332 +        {
  67.333 +            delete[] newLCD[x];
  67.334 +        }
  67.335 +        delete[] newLCD;
  67.336 +    }
  67.337 +    // free lcd array (current state)
  67.338 +    if (oldLCD)
  67.339 +    {
  67.340 +        for (x = 0; x < (width + (FS - 1)) / FS; x++)
  67.341 +        {
  67.342 +            delete[] oldLCD[x];
  67.343 +        }
  67.344 +        delete[] oldLCD;
  67.345 +    }
  67.346 +
  67.347 +    if (port->Close() != 0)
  67.348 +        return -1;
  67.349 +    return 0;
  67.350 +}
  67.351 +
  67.352 +int cDriverT6963C::CheckSetup()
  67.353 +{
  67.354 +    if (config->device != oldConfig->device ||
  67.355 +        config->port != oldConfig->port ||
  67.356 +        config->width != oldConfig->width ||
  67.357 +        config->height != oldConfig->height)
  67.358 +    {
  67.359 +        DeInit();
  67.360 +        Init();
  67.361 +        return 0;
  67.362 +    }
  67.363 +
  67.364 +    if (config->upsideDown != oldConfig->upsideDown ||
  67.365 +        config->invert != oldConfig->invert)
  67.366 +    {
  67.367 +        oldConfig->upsideDown = config->upsideDown;
  67.368 +        oldConfig->invert = config->invert;
  67.369 +        return 1;
  67.370 +    }
  67.371 +    return 0;
  67.372 +}
  67.373 +
  67.374 +void cDriverT6963C::Clear()
  67.375 +{
  67.376 +    for (int x = 0; x < (width + (FS - 1)) / FS; x++)
  67.377 +        memset(newLCD[x], 0, height);
  67.378 +}
  67.379 +
  67.380 +void cDriverT6963C::Set8Pixels(int x, int y, unsigned char data)
  67.381 +{
  67.382 +    if (x >= width || y >= height)
  67.383 +        return;
  67.384 +
  67.385 +    if (FS == 6)
  67.386 +    {
  67.387 +        unsigned char data1 = 0;
  67.388 +        unsigned char data2 = 0;
  67.389 +        unsigned char data3 = 0;
  67.390 +
  67.391 +        if (!config->upsideDown)
  67.392 +        {
  67.393 +            // normal orientation
  67.394 +            x = x - (x % 8);
  67.395 +            data1 = data >> (2 + (x % 6));
  67.396 +            if (x % 6 == 5)
  67.397 +            {
  67.398 +                data2 = data >> 1;
  67.399 +                data3 = data << 5;
  67.400 +            }
  67.401 +            else
  67.402 +                data2 = data << (4 - (x % 6));
  67.403 +
  67.404 +            newLCD[x / 6][y] |= data1;
  67.405 +            if (x / 6 + 1 < (width + 5) / 6)
  67.406 +                newLCD[x / 6 + 1][y] |= data2;
  67.407 +            if (x / 6 + 2 < (width + 5) / 6)
  67.408 +                if (x % 6 == 5)
  67.409 +                    newLCD[x / 6 + 2][y] |= data3;
  67.410 +        }
  67.411 +        else
  67.412 +        {
  67.413 +            // upside down orientation
  67.414 +            x = width - 1 - x;
  67.415 +            y = height - 1 - y;
  67.416 +            x = x - (x % 8);
  67.417 +            data = ReverseBits(data);
  67.418 +
  67.419 +            data1 = data >> (2 + (x % 6));
  67.420 +            if (x % 6 == 5)
  67.421 +            {
  67.422 +                data2 = data >> 1;
  67.423 +                data3 = data << 5;
  67.424 +            }
  67.425 +            else
  67.426 +                data2 = data << (4 - (x % 6));
  67.427 +
  67.428 +            newLCD[x / 6][y] |= data1;
  67.429 +            if (x / 6 + 1 < (width + 5) / 6)
  67.430 +                newLCD[x / 6 + 1][y] |= data2;
  67.431 +            if (x / 6 + 2 < (width + 5) / 6)
  67.432 +                if (x % 6 == 5)
  67.433 +                    newLCD[x / 6 + 2][y] |= data3;
  67.434 +        }
  67.435 +    }
  67.436 +    else
  67.437 +    {
  67.438 +        if (!config->upsideDown)
  67.439 +        {
  67.440 +            newLCD[x / 8][y] |= data;
  67.441 +        }
  67.442 +        else
  67.443 +        {
  67.444 +            x = width - 1 - x;
  67.445 +            y = height - 1 - y;
  67.446 +            newLCD[x / 8][y] |= ReverseBits(data);
  67.447 +        }
  67.448 +    }
  67.449 +}
  67.450 +
  67.451 +void cDriverT6963C::Refresh(bool refreshAll)
  67.452 +{
  67.453 +    int x,y;
  67.454 +    int addr = 0;
  67.455 +
  67.456 +    if (CheckSetup() == 1)
  67.457 +        refreshAll = true;
  67.458 +
  67.459 +    if (config->refreshDisplay > 0)
  67.460 +    {
  67.461 +        refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
  67.462 +        if (!refreshAll && !refreshCounter)
  67.463 +            refreshAll = true;
  67.464 +    }
  67.465 +
  67.466 +    port->Claim();
  67.467 +    if (refreshAll)
  67.468 +    {
  67.469 +        // draw all
  67.470 +        T6963CCommandWord(kSetAddressPointer, kGraphicBase);
  67.471 +        if (useAutoMode)
  67.472 +        {
  67.473 +            T6963CCommand(kAutoWrite);
  67.474 +            autoWrite = true;
  67.475 +        }
  67.476 +        for (y = 0; y < height; y++)
  67.477 +        {
  67.478 +            for (x = 0; x < (width + (FS - 1)) / FS; x++)
  67.479 +            {
  67.480 +                if (autoWrite)
  67.481 +                    T6963CData((newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
  67.482 +                else
  67.483 +                    T6963CCommandByte(kDataWriteInc, (newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
  67.484 +                oldLCD[x][y] = newLCD[x][y];
  67.485 +            }
  67.486 +        }
  67.487 +        if (autoWrite)
  67.488 +        {
  67.489 +            T6963CCommand(kAutoReset);
  67.490 +            autoWrite = false;
  67.491 +        }
  67.492 +        // and reset RefreshCounter
  67.493 +        refreshCounter = 0;
  67.494 +    }
  67.495 +    else
  67.496 +    {
  67.497 +        // draw only the changed bytes
  67.498 +
  67.499 +        bool cs = false;
  67.500 +        for (y = 0; y < height; y++)
  67.501 +        {
  67.502 +            for (x = 0; x < (width + (FS - 1)) / FS; x++)
  67.503 +            {
  67.504 +                if (oldLCD[x][y] != newLCD[x][y])
  67.505 +                {
  67.506 +                    if (!cs)
  67.507 +                    {
  67.508 +                        if (width % FS == 0)
  67.509 +                            addr = (y * (width / FS)) + x;
  67.510 +                        else
  67.511 +                            addr = (y * (width / FS + 1)) + x;
  67.512 +                        T6963CCommandWord(kSetAddressPointer, kGraphicBase + addr);
  67.513 +                        if (useAutoMode)
  67.514 +                        {
  67.515 +                            T6963CCommand(kAutoWrite);
  67.516 +                            autoWrite = true;
  67.517 +                        }
  67.518 +                        cs = true;
  67.519 +                    }
  67.520 +                    if (autoWrite)
  67.521 +                        T6963CData((newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
  67.522 +                    else
  67.523 +                        T6963CCommandByte(kDataWriteInc, (newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
  67.524 +                    oldLCD[x][y] = newLCD[x][y];
  67.525 +                }
  67.526 +                else
  67.527 +                {
  67.528 +                    if (autoWrite)
  67.529 +                    {
  67.530 +                        T6963CCommand(kAutoReset);
  67.531 +                        autoWrite = false;
  67.532 +                    }
  67.533 +                    cs = false;
  67.534 +                }
  67.535 +            }
  67.536 +        }
  67.537 +        if (autoWrite)
  67.538 +        {
  67.539 +            T6963CCommand(kAutoReset);
  67.540 +            autoWrite = false;
  67.541 +        }
  67.542 +    }
  67.543 +    port->Release();
  67.544 +}
  67.545 +
  67.546 +void cDriverT6963C::T6963CSetControl(unsigned char flags)
  67.547 +{
  67.548 +    unsigned char status = port->ReadControl();
  67.549 +    status &= 0xF0; // mask 4 bits
  67.550 +    status |= flags; // add new flags
  67.551 +    port->WriteControl(status);
  67.552 +}
  67.553 +
  67.554 +void cDriverT6963C::T6963CDSPReady()
  67.555 +{
  67.556 +    int input = 0;
  67.557 +
  67.558 +    port->SetDirection(kReverse);
  67.559 +    if (bidirectLPT == 1)
  67.560 +    {
  67.561 +        for (int i = 0; i < 10; i++)
  67.562 +        {
  67.563 +            T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
  67.564 +            T6963CSetControl(WRHI | CELO | CDHI | RDLO);
  67.565 +            input = port->ReadData();
  67.566 +            T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
  67.567 +            if (!autoWrite && (input & 3) == 3)
  67.568 +                break;
  67.569 +            if (autoWrite && (input & 8) == 8)
  67.570 +                break;
  67.571 +        }
  67.572 +    }
  67.573 +    else
  67.574 +    {
  67.575 +        T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
  67.576 +        T6963CSetControl(WRHI | CELO | CDHI | RDLO);
  67.577 +        T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
  67.578 +    }
  67.579 +    port->SetDirection(kForward);
  67.580 +}
  67.581 +
  67.582 +void cDriverT6963C::T6963CData(unsigned char data)
  67.583 +{
  67.584 +    if (serial)
  67.585 +    {
  67.586 +        T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
  67.587 +        for (int i = 128; i; i>>=1)
  67.588 +        {
  67.589 +            if (data & i)
  67.590 +            {
  67.591 +                T6963CSetControl(WRLO | CEHI | CDHI | RDLO);
  67.592 +                T6963CSetControl(WRHI | CEHI | CDHI | RDLO);
  67.593 +            }
  67.594 +            else
  67.595 +            {
  67.596 +                T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
  67.597 +                T6963CSetControl(WRHI | CEHI | CDLO | RDLO);
  67.598 +            }
  67.599 +        }
  67.600 +        T6963CSetControl(WRLO | CEHI | CDLO | RDLO); // CD down (data)
  67.601 +        T6963CSetControl(WRLO | CELO | CDLO | RDLO); // CE down
  67.602 +        T6963CSetControl(WRLO | CEHI | CDLO | RDLO); // CE up
  67.603 +    }
  67.604 +    else
  67.605 +    {
  67.606 +        if (useStatusCheck)
  67.607 +            T6963CDSPReady();
  67.608 +        T6963CSetControl(WRHI | CEHI | CDLO | RDHI); // CD down (data)
  67.609 +        T6963CSetControl(WRLO | CELO | CDLO | RDHI); // CE & WR down
  67.610 +        port->WriteData(data);
  67.611 +        T6963CSetControl(WRHI | CEHI | CDLO | RDHI); // CE & WR up again
  67.612 +        T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // CD up again
  67.613 +    }
  67.614 +}
  67.615 +
  67.616 +void cDriverT6963C::T6963CCommand(unsigned char cmd)
  67.617 +{
  67.618 +    if (serial)
  67.619 +    {
  67.620 +        syslog(LOG_DEBUG, "Serial cmd out: ");
  67.621 +        T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
  67.622 +        for (int i = 128; i; i>>=1)
  67.623 +        {
  67.624 +            if (cmd & i)
  67.625 +            {
  67.626 +                T6963CSetControl(WRLO | CEHI | CDHI | RDLO);
  67.627 +                T6963CSetControl(WRHI | CEHI | CDHI | RDLO);
  67.628 +            }
  67.629 +            else
  67.630 +            {
  67.631 +                T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
  67.632 +                T6963CSetControl(WRHI | CEHI | CDLO | RDLO);
  67.633 +            }
  67.634 +        }
  67.635 +        T6963CSetControl(WRLO | CEHI | CDHI | RDLO); // CD up (command)
  67.636 +        T6963CSetControl(WRLO | CELO | CDHI | RDLO); // CE down
  67.637 +        T6963CSetControl(WRLO | CEHI | CDHI | RDLO); // CE up
  67.638 +        T6963CSetControl(WRLO | CEHI | CDLO | RDLO); // CD down
  67.639 +    }
  67.640 +    else
  67.641 +    {
  67.642 +        if (useStatusCheck)
  67.643 +            T6963CDSPReady();
  67.644 +        T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // CD up (command)
  67.645 +        T6963CSetControl(WRLO | CELO | CDHI | RDHI); // CE & WR down
  67.646 +        port->WriteData(cmd);
  67.647 +        T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // CE & WR up again
  67.648 +        T6963CSetControl(WRHI | CEHI | CDLO | RDHI); // CD down again
  67.649 +    }
  67.650 +}
  67.651 +
  67.652 +void cDriverT6963C::T6963CCommandByte(unsigned char cmd, unsigned char data)
  67.653 +{
  67.654 +    T6963CData(data);
  67.655 +    T6963CCommand(cmd);
  67.656 +}
  67.657 +
  67.658 +void cDriverT6963C::T6963CCommand2Bytes(unsigned char cmd, unsigned char data1, unsigned char data2)
  67.659 +{
  67.660 +    T6963CData(data1);
  67.661 +    T6963CData(data2);
  67.662 +    T6963CCommand(cmd);
  67.663 +}
  67.664 +
  67.665 +void cDriverT6963C::T6963CCommandWord(unsigned char cmd, unsigned short data)
  67.666 +{
  67.667 +    T6963CData(data % 256);
  67.668 +    T6963CData(data >> 8);
  67.669 +    T6963CCommand(cmd);
  67.670 +}
  67.671 +
  67.672 +void cDriverT6963C::T6963CDisplayMode(unsigned char mode, bool enable)
  67.673 +{
  67.674 +    if (enable)
  67.675 +        displayMode |= mode;
  67.676 +    else
  67.677 +        displayMode &= ~mode;
  67.678 +    T6963CCommand(kSetDisplayMode | displayMode);
  67.679 +}
  67.680 +
  67.681 +}
    68.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    68.2 +++ b/graphlcd-base/glcddrivers/t6963c.h	Wed Feb 06 17:32:55 2008 +0000
    68.3 @@ -0,0 +1,76 @@
    68.4 +/*
    68.5 + * GraphLCD driver library
    68.6 + *
    68.7 + * t6963c.h  -  T6963C driver class
    68.8 + *
    68.9 + * low level routines based on lcdproc 0.5 driver, (c) 2001 Manuel Stahl
   68.10 + *
   68.11 + * This file is released under the GNU General Public License. Refer
   68.12 + * to the COPYING file distributed with this package.
   68.13 + *
   68.14 + * (c) 2003, 2004 Andreas Regel <andreas.regel AT powarman.de>
   68.15 + */
   68.16 +
   68.17 +#ifndef _GLCDDRIVERS_T6963C_H_
   68.18 +#define _GLCDDRIVERS_T6963C_H_
   68.19 +
   68.20 +#include "driver.h"
   68.21 +
   68.22 +namespace GLCD
   68.23 +{
   68.24 +
   68.25 +class cDriverConfig;
   68.26 +class cParallelPort;
   68.27 +
   68.28 +class cDriverT6963C : public cDriver
   68.29 +{
   68.30 +private:
   68.31 +    cParallelPort * port;
   68.32 +    unsigned char ** newLCD; // wanted state
   68.33 +    unsigned char ** oldLCD; // current state
   68.34 +    cDriverConfig * config;
   68.35 +    cDriverConfig * oldConfig;
   68.36 +    int refreshCounter;
   68.37 +    int bidirectLPT;
   68.38 +    int displayMode;
   68.39 +    bool useAutoMode;
   68.40 +    bool useStatusCheck;
   68.41 +
   68.42 +    int serial;
   68.43 +    int FS;
   68.44 +    int WRHI;
   68.45 +    int WRLO;
   68.46 +    int RDHI;
   68.47 +    int RDLO;
   68.48 +    int CEHI;
   68.49 +    int CELO;
   68.50 +    int CDHI;
   68.51 +    int CDLO;
   68.52 +    bool autoWrite;
   68.53 +
   68.54 +    void T6963CSetControl(unsigned char flags);
   68.55 +    void T6963CDSPReady();
   68.56 +    void T6963CData(unsigned char data);
   68.57 +    void T6963CCommand(unsigned char cmd);
   68.58 +    void T6963CCommandByte(unsigned char cmd, unsigned char data);
   68.59 +    void T6963CCommand2Bytes(unsigned char cmd, unsigned char data1, unsigned char data2);
   68.60 +    void T6963CCommandWord(unsigned char cmd, unsigned short data);
   68.61 +    void T6963CDisplayMode(unsigned char mode, bool enable);
   68.62 +
   68.63 +    int CheckSetup();
   68.64 +
   68.65 +public:
   68.66 +    cDriverT6963C(cDriverConfig * config);
   68.67 +    virtual ~cDriverT6963C();
   68.68 +
   68.69 +    virtual int Init();
   68.70 +    virtual int DeInit();
   68.71 +
   68.72 +    virtual void Clear();
   68.73 +    virtual void Set8Pixels(int x, int y, unsigned char data);
   68.74 +    virtual void Refresh(bool refreshAll = false);
   68.75 +};
   68.76 +
   68.77 +} // end of namespace
   68.78 +
   68.79 +#endif
    69.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    69.2 +++ b/graphlcd-base/glcdgraphics/Makefile	Wed Feb 06 17:32:55 2008 +0000
    69.3 @@ -0,0 +1,68 @@
    69.4 +#
    69.5 +# Makefile for the GraphLCD graphics library
    69.6 +#
    69.7 +
    69.8 +-include ../Make.config
    69.9 +
   69.10 +CXXFLAGS += -fPIC
   69.11 +
   69.12 +VERMAJOR = 2
   69.13 +VERMINOR = 0
   69.14 +VERMICRO = 0
   69.15 +
   69.16 +BASENAME = libglcdgraphics.so
   69.17 +
   69.18 +LIBNAME = $(BASENAME).$(VERMAJOR).$(VERMINOR).$(VERMICRO)
   69.19 +
   69.20 +OBJS = bitmap.o common.o font.o glcd.o image.o imagefile.o pbm.o
   69.21 +
   69.22 +HEADERS = bitmap.h font.h glcd.h image.h imagefile.h pbm.h
   69.23 +
   69.24 +### Implicit rules:
   69.25 +
   69.26 +%.o: %.c
   69.27 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
   69.28 +
   69.29 +# Dependencies:
   69.30 +
   69.31 +MAKEDEP = g++ -MM -MG
   69.32 +DEPFILE = .dependencies
   69.33 +$(DEPFILE): Makefile
   69.34 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
   69.35 +
   69.36 +-include $(DEPFILE)
   69.37 +
   69.38 +ifdef HAVE_FREETYPE2
   69.39 +	ifneq ($(shell which freetype-config),)
   69.40 +		INCLUDES += $(shell freetype-config --cflags)
   69.41 +		LIBS += $(shell freetype-config --libs)
   69.42 +	else
   69.43 +		INCLUDES += -I/usr/include/freetype -I/usr/local/include/freetype
   69.44 +		LIBS += -lfreetype
   69.45 +	endif
   69.46 +	DEFINES += -DHAVE_FREETYPE2
   69.47 +endif### Targets:
   69.48 +
   69.49 +all: $(LIBNAME)
   69.50 +
   69.51 +$(LIBNAME): $(OBJS)
   69.52 +	$(CXX) $(CXXFLAGS) -shared $(OBJS) $(LIBS) -Wl,-soname="$(BASENAME).$(VERMAJOR)" -o $@
   69.53 +	ln -sf $(LIBNAME) $(BASENAME)
   69.54 +
   69.55 +install: all
   69.56 +	install -d $(LIBDIR)
   69.57 +	install -m 755 $(LIBNAME) $(LIBDIR)/
   69.58 +	install -d $(INCDIR)/glcdgraphics
   69.59 +	install -m 644 $(HEADERS) $(INCDIR)/glcdgraphics/
   69.60 +	( cd $(LIBDIR); ln -sf $(LIBNAME) $(BASENAME).$(VERMAJOR); ln -sf $(LIBNAME) $(BASENAME) )
   69.61 +
   69.62 +uninstall:
   69.63 +	rm -f $(LIBDIR)/$(BASENAME)
   69.64 +	rm -f $(LIBDIR)/$(BASENAME).$(VERMAJOR)
   69.65 +	rm -f $(LIBDIR)/$(LIBNAME)
   69.66 +	(for i in $(HEADERS); do rm -f $(INCDIR)/glcdgraphics/$$i; done)
   69.67 +	rmdir $(INCDIR)/glcdgraphics
   69.68 +
   69.69 +clean:
   69.70 +	rm -f $(OBJS) $(DEPFILE) $(LIBNAME) $(BASENAME) *~
   69.71 +
    70.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    70.2 +++ b/graphlcd-base/glcdgraphics/bitmap.c	Wed Feb 06 17:32:55 2008 +0000
    70.3 @@ -0,0 +1,807 @@
    70.4 +/*
    70.5 + * GraphLCD graphics library
    70.6 + *
    70.7 + * bitmap.c  -  cBitmap class
    70.8 + *
    70.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   70.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   70.11 + *
   70.12 + * This file is released under the GNU General Public License. Refer
   70.13 + * to the COPYING file distributed with this package.
   70.14 + *
   70.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   70.16 + */
   70.17 +
   70.18 +#include <stdio.h>
   70.19 +#include <stdlib.h>
   70.20 +#include <string.h>
   70.21 +#include <math.h>
   70.22 +
   70.23 +#include "bitmap.h"
   70.24 +#include "common.h"
   70.25 +#include "font.h"
   70.26 +
   70.27 +
   70.28 +namespace GLCD
   70.29 +{
   70.30 +
   70.31 +const unsigned char bitmask[8]  = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
   70.32 +const unsigned char bitmaskl[8] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
   70.33 +const unsigned char bitmaskr[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
   70.34 +
   70.35 +cBitmap::cBitmap(int width, int height, unsigned char * data)
   70.36 +:   width(width),
   70.37 +    height(height),
   70.38 +    bitmap(NULL)
   70.39 +{
   70.40 +    // lines are byte aligned
   70.41 +    lineSize = (width + 7) / 8;
   70.42 +
   70.43 +    bitmap = new unsigned char[lineSize * height];
   70.44 +    if (data)
   70.45 +        memcpy(bitmap, data, lineSize * height);
   70.46 +}
   70.47 +
   70.48 +cBitmap::cBitmap(const cBitmap & b)
   70.49 +{
   70.50 +    width = b.width;
   70.51 +    height = b.height;
   70.52 +    lineSize = b.lineSize;
   70.53 +    bitmap = new unsigned char[lineSize * height];
   70.54 +    if (b.bitmap)
   70.55 +        memcpy(bitmap, b.bitmap, lineSize * height);
   70.56 +}
   70.57 +
   70.58 +cBitmap::~cBitmap()
   70.59 +{
   70.60 +    delete[] bitmap;
   70.61 +}
   70.62 +
   70.63 +void cBitmap::Clear()
   70.64 +{
   70.65 +    memset(bitmap, 0, lineSize * height);
   70.66 +}
   70.67 +
   70.68 +void cBitmap::Invert()
   70.69 +{
   70.70 +    int i;
   70.71 +
   70.72 +    for (i = 0; i < lineSize * height; i++)
   70.73 +    {
   70.74 +        bitmap[i] ^= 0xFF;
   70.75 +    }
   70.76 +}
   70.77 +
   70.78 +void cBitmap::DrawPixel(int x, int y, eColor color)
   70.79 +{
   70.80 +    if (x < 0 || x > width - 1)
   70.81 +        return;
   70.82 +    if (y < 0 || y > height - 1)
   70.83 +        return;
   70.84 +
   70.85 +    unsigned char c = 0x80 >> (x % 8);
   70.86 +    if (color == clrBlack)
   70.87 +        bitmap[lineSize * y + x / 8] |= c;
   70.88 +    else
   70.89 +        bitmap[lineSize * y + x / 8] &= ~c;
   70.90 +}
   70.91 +
   70.92 +void cBitmap::Draw8Pixels(int x, int y, unsigned char pixels, eColor color)
   70.93 +{
   70.94 +    if (x < 0 || x > width - 1)
   70.95 +        return;
   70.96 +    if (y < 0 || y > height - 1)
   70.97 +        return;
   70.98 +
   70.99 +    if (color == clrBlack)
  70.100 +        bitmap[lineSize * y + x / 8] |= pixels;
  70.101 +    else
  70.102 +        bitmap[lineSize * y + x / 8] &= ~pixels;
  70.103 +}
  70.104 +
  70.105 +void cBitmap::DrawLine(int x1, int y1, int x2, int y2, eColor color)
  70.106 +{
  70.107 +    int d, sx, sy, dx, dy;
  70.108 +    unsigned int ax, ay;
  70.109 +
  70.110 +    dx = x2 - x1;
  70.111 +    ax = abs(dx) << 1;
  70.112 +    if (dx < 0)
  70.113 +        sx = -1;
  70.114 +    else
  70.115 +        sx = 1;
  70.116 +
  70.117 +    dy = y2 - y1;
  70.118 +    ay = abs(dy) << 1;
  70.119 +    if (dy < 0)
  70.120 +        sy = -1;
  70.121 +    else
  70.122 +        sy = 1;
  70.123 +
  70.124 +    DrawPixel(x1, y1, color);
  70.125 +    if (ax > ay)
  70.126 +    {
  70.127 +        d = ay - (ax >> 1);
  70.128 +        while (x1 != x2)
  70.129 +        {
  70.130 +            if (d >= 0)
  70.131 +            {
  70.132 +                y1 += sy;
  70.133 +                d -= ax;
  70.134 +            }
  70.135 +            x1 += sx;
  70.136 +            d += ay;
  70.137 +            DrawPixel(x1, y1, color);
  70.138 +        }
  70.139 +    }
  70.140 +    else
  70.141 +    {
  70.142 +        d = ax - (ay >> 1);
  70.143 +        while (y1 != y2)
  70.144 +        {
  70.145 +            if (d >= 0)
  70.146 +            {
  70.147 +                x1 += sx;
  70.148 +                d -= ay;
  70.149 +            }
  70.150 +            y1 += sy;
  70.151 +            d += ax;
  70.152 +            DrawPixel(x1, y1, color);
  70.153 +        }
  70.154 +    }
  70.155 +}
  70.156 +
  70.157 +void cBitmap::DrawHLine(int x1, int y, int x2, eColor color)
  70.158 +{
  70.159 +    sort(x1,x2);
  70.160 +
  70.161 +    if (x1 / 8 == x2 / 8)
  70.162 +    {
  70.163 +        // start and end in the same byte
  70.164 +        Draw8Pixels(x1, y, bitmaskr[x1 % 8] & bitmaskl[x2 % 8], color);
  70.165 +    }
  70.166 +    else
  70.167 +    {
  70.168 +        // start and end in different bytes
  70.169 +        Draw8Pixels(x1, y, bitmaskr[x1 % 8], color);
  70.170 +        x1 = ((x1 + 8) / 8) * 8;
  70.171 +        while (x1 < (x2 / 8) * 8)
  70.172 +        {
  70.173 +            Draw8Pixels(x1, y, 0xff, color);
  70.174 +            x1 += 8;
  70.175 +        }
  70.176 +        Draw8Pixels(x2, y, bitmaskl[x2 % 8], color);
  70.177 +    }
  70.178 +}
  70.179 +
  70.180 +void cBitmap::DrawVLine(int x, int y1, int y2, eColor color)
  70.181 +{
  70.182 +    int y;
  70.183 +
  70.184 +    sort(y1,y2);
  70.185 +
  70.186 +    for (y = y1; y <= y2; y++)
  70.187 +        DrawPixel(x, y, color);
  70.188 +}
  70.189 +
  70.190 +void cBitmap::DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled)
  70.191 +{
  70.192 +    int y;
  70.193 +
  70.194 +    sort(x1,x2);
  70.195 +    sort(y1,y2);
  70.196 +
  70.197 +    if (!filled)
  70.198 +    {
  70.199 +        DrawHLine(x1, y1, x2, color);
  70.200 +        DrawVLine(x1, y1, y2, color);
  70.201 +        DrawHLine(x1, y2, x2, color);
  70.202 +        DrawVLine(x2, y1, y2, color);
  70.203 +    }
  70.204 +    else
  70.205 +    {
  70.206 +        for (y = y1; y <= y2; y++)
  70.207 +        {
  70.208 +            DrawHLine(x1, y, x2, color);
  70.209 +        }
  70.210 +    }
  70.211 +}
  70.212 +
  70.213 +void cBitmap::DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int type)
  70.214 +{
  70.215 +    sort(x1,x2);
  70.216 +    sort(y1,y2);
  70.217 +
  70.218 +    if (type > (x2 - x1) / 2)
  70.219 +        type = (x2 - x1) / 2;
  70.220 +    if (type > (y2 - y1) / 2)
  70.221 +        type = (y2 - y1) / 2;
  70.222 +
  70.223 +    if (filled)
  70.224 +    {
  70.225 +        DrawHLine(x1 + type, y1, x2 - type, color);
  70.226 +        for (int y = y1 + 1; y < y1 + type; y++)
  70.227 +            DrawHLine(x1 + 1, y, x2 - 1, color);
  70.228 +        for (int y = y1 + type; y <= y2 - type; y++)
  70.229 +            DrawHLine(x1, y, x2, color);
  70.230 +        for (int y = y2 - type + 1; y < y2; y++)
  70.231 +            DrawHLine(x1 + 1, y, x2 - 1, color);
  70.232 +        DrawHLine(x1 + type, y2, x2 - type, color);
  70.233 +        if (type == 4)
  70.234 +        {
  70.235 +            // round the ugly fat box...
  70.236 +            DrawPixel(x1 + 1, y1 + 1, color == clrWhite ? clrBlack : clrWhite);
  70.237 +            DrawPixel(x1 + 1, y2 - 1, color == clrWhite ? clrBlack : clrWhite);
  70.238 +            DrawPixel(x2 - 1, y1 + 1, color == clrWhite ? clrBlack : clrWhite);
  70.239 +            DrawPixel(x2 - 1, y2 - 1, color == clrWhite ? clrBlack : clrWhite);
  70.240 +        }
  70.241 +    }
  70.242 +    else
  70.243 +    {
  70.244 +        DrawHLine(x1 + type, y1, x2 - type, color);
  70.245 +        DrawVLine(x1, y1 + type, y2 - type, color);
  70.246 +        DrawVLine(x2, y1 + type, y2 - type, color);
  70.247 +        DrawHLine(x1 + type, y2, x2 - type, color);
  70.248 +        if (type > 1)
  70.249 +        {
  70.250 +            DrawHLine(x1 + 1, y1 + 1, x1 + type - 1, color);
  70.251 +            DrawHLine(x2 - type + 1, y1 + 1, x2 - 1, color);
  70.252 +            DrawHLine(x1 + 1, y2 - 1, x1 + type - 1, color);
  70.253 +            DrawHLine(x2 - type + 1, y2 - 1, x2 - 1, color);
  70.254 +            DrawVLine(x1 + 1, y1 + 1, y1 + type - 1, color);
  70.255 +            DrawVLine(x1 + 1, y2 - 1, y2 - type + 1, color);
  70.256 +            DrawVLine(x2 - 1, y1 + 1, y1 + type - 1, color);
  70.257 +            DrawVLine(x2 - 1, y2 - 1, y2 - type + 1, color);
  70.258 +        }
  70.259 +    }
  70.260 +}
  70.261 +
  70.262 +void cBitmap::DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants)
  70.263 +{
  70.264 +    // Algorithm based on http://homepage.smc.edu/kennedy_john/BELIPSE.PDF
  70.265 +    int rx = x2 - x1;
  70.266 +    int ry = y2 - y1;
  70.267 +    int cx = (x1 + x2) / 2;
  70.268 +    int cy = (y1 + y2) / 2;
  70.269 +    switch (abs(quadrants))
  70.270 +    {
  70.271 +        case 0: rx /= 2; ry /= 2; break;
  70.272 +        case 1: cx = x1; cy = y2; break;
  70.273 +        case 2: cx = x2; cy = y2; break;
  70.274 +        case 3: cx = x2; cy = y1; break;
  70.275 +        case 4: cx = x1; cy = y1; break;
  70.276 +        case 5: cx = x1;          ry /= 2; break;
  70.277 +        case 6: cy = y2; rx /= 2; break;
  70.278 +        case 7: cx = x2;          ry /= 2; break;
  70.279 +        case 8: cy = y1; rx /= 2; break;
  70.280 +    }
  70.281 +    int TwoASquare = 2 * rx * rx;
  70.282 +    int TwoBSquare = 2 * ry * ry;
  70.283 +    int x = rx;
  70.284 +    int y = 0;
  70.285 +    int XChange = ry * ry * (1 - 2 * rx);
  70.286 +    int YChange = rx * rx;
  70.287 +    int EllipseError = 0;
  70.288 +    int StoppingX = TwoBSquare * rx;
  70.289 +    int StoppingY = 0;
  70.290 +    while (StoppingX >= StoppingY)
  70.291 +    {
  70.292 +        if (filled)
  70.293 +        {
  70.294 +            switch (quadrants)
  70.295 +            {
  70.296 +                case  5: DrawRectangle(cx,     cy + y, cx + x, cy + y, color, filled); // no break
  70.297 +                case  1: DrawRectangle(cx,     cy - y, cx + x, cy - y, color, filled); break;
  70.298 +                case  7: DrawRectangle(cx - x, cy + y, cx,     cy + y, color, filled); // no break
  70.299 +                case  2: DrawRectangle(cx - x, cy - y, cx,     cy - y, color, filled); break;
  70.300 +                case  3: DrawRectangle(cx - x, cy + y, cx,     cy + y, color, filled); break;
  70.301 +                case  4: DrawRectangle(cx,     cy + y, cx + x, cy + y, color, filled); break;
  70.302 +                case  0:
  70.303 +                case  6: DrawRectangle(cx - x, cy - y, cx + x, cy - y, color, filled); if (quadrants == 6) break;
  70.304 +                case  8: DrawRectangle(cx - x, cy + y, cx + x, cy + y, color, filled); break;
  70.305 +                case -1: DrawRectangle(cx + x, cy - y, x2,     cy - y, color, filled); break;
  70.306 +                case -2: DrawRectangle(x1,     cy - y, cx - x, cy - y, color, filled); break;
  70.307 +                case -3: DrawRectangle(x1,     cy + y, cx - x, cy + y, color, filled); break;
  70.308 +                case -4: DrawRectangle(cx + x, cy + y, x2,     cy + y, color, filled); break;
  70.309 +            }
  70.310 +        }
  70.311 +        else
  70.312 +        {
  70.313 +            switch (quadrants)
  70.314 +            {
  70.315 +                case  5: DrawPixel(cx + x, cy + y, color); // no break
  70.316 +                case -1:
  70.317 +                case  1: DrawPixel(cx + x, cy - y, color); break;
  70.318 +                case  7: DrawPixel(cx - x, cy + y, color); // no break
  70.319 +                case -2:
  70.320 +                case  2: DrawPixel(cx - x, cy - y, color); break;
  70.321 +                case -3:
  70.322 +                case  3: DrawPixel(cx - x, cy + y, color); break;
  70.323 +                case -4:
  70.324 +                case  4: DrawPixel(cx + x, cy + y, color); break;
  70.325 +                case  0:
  70.326 +                case  6: DrawPixel(cx - x, cy - y, color); DrawPixel(cx + x, cy - y, color); if (quadrants == 6) break;
  70.327 +                case  8: DrawPixel(cx - x, cy + y, color); DrawPixel(cx + x, cy + y, color); break;
  70.328 +            }
  70.329 +        }
  70.330 +        y++;
  70.331 +        StoppingY += TwoASquare;
  70.332 +        EllipseError += YChange;
  70.333 +        YChange += TwoASquare;
  70.334 +        if (2 * EllipseError + XChange > 0)
  70.335 +        {
  70.336 +            x--;
  70.337 +            StoppingX -= TwoBSquare;
  70.338 +            EllipseError += XChange;
  70.339 +            XChange += TwoBSquare;
  70.340 +        }
  70.341 +    }
  70.342 +    x = 0;
  70.343 +    y = ry;
  70.344 +    XChange = ry * ry;
  70.345 +    YChange = rx * rx * (1 - 2 * ry);
  70.346 +    EllipseError = 0;
  70.347 +    StoppingX = 0;
  70.348 +    StoppingY = TwoASquare * ry;
  70.349 +    while (StoppingX <= StoppingY)
  70.350 +    {
  70.351 +        if (filled)
  70.352 +        {
  70.353 +            switch (quadrants)
  70.354 +            {
  70.355 +                case  5: DrawRectangle(cx,     cy + y, cx + x, cy + y, color, filled); // no break
  70.356 +                case  1: DrawRectangle(cx,     cy - y, cx + x, cy - y, color, filled); break;
  70.357 +                case  7: DrawRectangle(cx - x, cy + y, cx,     cy + y, color, filled); // no break
  70.358 +                case  2: DrawRectangle(cx - x, cy - y, cx,     cy - y, color, filled); break;
  70.359 +                case  3: DrawRectangle(cx - x, cy + y, cx,     cy + y, color, filled); break;
  70.360 +                case  4: DrawRectangle(cx,     cy + y, cx + x, cy + y, color, filled); break;
  70.361 +                case  0:
  70.362 +                case  6: DrawRectangle(cx - x, cy - y, cx + x, cy - y, color, filled); if (quadrants == 6) break;
  70.363 +                case  8: DrawRectangle(cx - x, cy + y, cx + x, cy + y, color, filled); break;
  70.364 +                case -1: DrawRectangle(cx + x, cy - y, x2,     cy - y, color, filled); break;
  70.365 +                case -2: DrawRectangle(x1,     cy - y, cx - x, cy - y, color, filled); break;
  70.366 +                case -3: DrawRectangle(x1,     cy + y, cx - x, cy + y, color, filled); break;
  70.367 +                case -4: DrawRectangle(cx + x, cy + y, x2,     cy + y, color, filled); break;
  70.368 +            }
  70.369 +        }
  70.370 +        else
  70.371 +        {
  70.372 +            switch (quadrants)
  70.373 +            {
  70.374 +                case  5: DrawPixel(cx + x, cy + y, color); // no break
  70.375 +                case -1:
  70.376 +                case  1: DrawPixel(cx + x, cy - y, color); break;
  70.377 +                case  7: DrawPixel(cx - x, cy + y, color); // no break
  70.378 +                case -2:
  70.379 +                case  2: DrawPixel(cx - x, cy - y, color); break;
  70.380 +                case -3:
  70.381 +                case  3: DrawPixel(cx - x, cy + y, color); break;
  70.382 +                case -4:
  70.383 +                case  4: DrawPixel(cx + x, cy + y, color); break;
  70.384 +                case  0:
  70.385 +                case  6: DrawPixel(cx - x, cy - y, color); DrawPixel(cx + x, cy - y, color); if (quadrants == 6) break;
  70.386 +                case  8: DrawPixel(cx - x, cy + y, color); DrawPixel(cx + x, cy + y, color); break;
  70.387 +            }
  70.388 +        }
  70.389 +        x++;
  70.390 +        StoppingX += TwoBSquare;
  70.391 +        EllipseError += XChange;
  70.392 +        XChange += TwoBSquare;
  70.393 +        if (2 * EllipseError + YChange > 0)
  70.394 +        {
  70.395 +            y--;
  70.396 +            StoppingY -= TwoASquare;
  70.397 +            EllipseError += YChange;
  70.398 +            YChange += TwoASquare;
  70.399 +        }
  70.400 +    }
  70.401 +}
  70.402 +
  70.403 +void cBitmap::DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type)
  70.404 +{
  70.405 +    bool upper    = type & 0x01;
  70.406 +    bool falling  = type & 0x02;
  70.407 +    bool vertical = type & 0x04;
  70.408 +    if (vertical)
  70.409 +    {
  70.410 +        for (int y = y1; y <= y2; y++)
  70.411 +        {
  70.412 +            double c = cos((y - y1) * M_PI / (y2 - y1 + 1));
  70.413 +            if (falling)
  70.414 +                c = -c;
  70.415 +            int x = int((x2 - x1 + 1) * c / 2);
  70.416 +            if (upper && !falling || !upper && falling)
  70.417 +                DrawRectangle(x1, y, (x1 + x2) / 2 + x, y, color, true);
  70.418 +            else
  70.419 +                DrawRectangle((x1 + x2) / 2 + x, y, x2, y, color, true);
  70.420 +        }
  70.421 +    }
  70.422 +    else
  70.423 +    {
  70.424 +        for (int x = x1; x <= x2; x++)
  70.425 +        {
  70.426 +            double c = cos((x - x1) * M_PI / (x2 - x1 + 1));
  70.427 +            if (falling)
  70.428 +                c = -c;
  70.429 +            int y = int((y2 - y1 + 1) * c / 2);
  70.430 +            if (upper)
  70.431 +                DrawRectangle(x, y1, x, (y1 + y2) / 2 + y, color, true);
  70.432 +            else
  70.433 +                DrawRectangle(x, (y1 + y2) / 2 + y, x, y2, color, true);
  70.434 +        }
  70.435 +    }
  70.436 +}
  70.437 +
  70.438 +void cBitmap::DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color)
  70.439 +{
  70.440 +    unsigned char cl = 0;
  70.441 +    int xt, yt;
  70.442 +    const unsigned char * data = bitmap.Data();
  70.443 +    unsigned short temp;
  70.444 +    int h, w;
  70.445 +
  70.446 +    w = bitmap.Width();
  70.447 +    h = bitmap.Height();
  70.448 +
  70.449 +    if (data)
  70.450 +    {
  70.451 +        if (!(x % 8))
  70.452 +        {
  70.453 +            // Bitmap is byte alligned (0,8,16,...)
  70.454 +            for (yt = 0; yt < h; yt++)
  70.455 +            {
  70.456 +                for (xt = 0; xt < (w / 8); xt++)
  70.457 +                {
  70.458 +                    cl = *data;
  70.459 +                    Draw8Pixels(x + (xt * 8), y + yt, cl, color);
  70.460 +                    data++;
  70.461 +                }
  70.462 +                if (w % 8)
  70.463 +                {
  70.464 +                    cl = *data;
  70.465 +                    Draw8Pixels(x + ((w / 8) * 8), y + yt, cl & bitmaskl[w % 8 - 1], color);
  70.466 +                    data++;
  70.467 +                }
  70.468 +            }
  70.469 +        }
  70.470 +        else
  70.471 +        {
  70.472 +            // Bitmap is not byte alligned
  70.473 +            for (yt = 0; yt < h; yt++)
  70.474 +            {
  70.475 +                temp = 0;
  70.476 +                for (xt = 0; xt < (w + (x % 8)) / 8; xt++)
  70.477 +                {
  70.478 +                    cl = *(data + yt * ((w + 7) / 8) + xt);
  70.479 +                    temp = temp | ((unsigned short) cl << (8 - (x % 8)));
  70.480 +                    cl = (temp & 0xff00) >> 8;
  70.481 +                    if (!xt)
  70.482 +                    {
  70.483 +                        // first byte
  70.484 +                        Draw8Pixels(x - (x % 8) + (xt * 8), y + yt, cl & bitmaskr[x % 8], color);
  70.485 +                    }
  70.486 +                    else
  70.487 +                    {
  70.488 +                        // not the first byte
  70.489 +                        Draw8Pixels(x - (x % 8) + (xt * 8), y + yt, cl, color);
  70.490 +                    }
  70.491 +                    temp <<= 8;
  70.492 +                }
  70.493 +                if ((w + (x % 8) + 7) / 8 != (w + (x % 8)) / 8)
  70.494 +                {
  70.495 +                    // print the rest
  70.496 +                    cl = *(data + (yt + 1) * ((w + 7) / 8) - 1);
  70.497 +                    temp = temp | ((unsigned short) cl << (8 - (x % 8)));
  70.498 +                    cl = (temp & 0xff00) >> 8;
  70.499 +                    Draw8Pixels(x - (x % 8) + (((w + (x % 8)) / 8) * 8), y + yt, cl & bitmaskl[(w + x) % 8 - 1], color);
  70.500 +                }
  70.501 +            }
  70.502 +        }
  70.503 +    }
  70.504 +}
  70.505 +
  70.506 +int cBitmap::DrawText(int x, int y, int xmax, const std::string & text, const cFont * font,
  70.507 +                      eColor color, bool proportional, int skipPixels)
  70.508 +{
  70.509 +    int xt;
  70.510 +    int yt;
  70.511 +    int i;
  70.512 +    char c;
  70.513 +    int start;
  70.514 +
  70.515 +    clip(x, 0, width - 1);
  70.516 +    clip(y, 0, height - 1);
  70.517 +
  70.518 +    xt = x;
  70.519 +    yt = y;
  70.520 +    start = 0;
  70.521 +
  70.522 +    if (text.length() > 0)
  70.523 +    {
  70.524 +        if (skipPixels > 0)
  70.525 +        {
  70.526 +            if (!proportional)
  70.527 +            {
  70.528 +                if (skipPixels >= (int) text.length() * font->TotalWidth())
  70.529 +                    start = text.length();
  70.530 +                else
  70.531 +                    while (skipPixels > font->TotalWidth())
  70.532 +                    {
  70.533 +                        skipPixels -= font->TotalWidth();
  70.534 +                        start++;
  70.535 +                    }
  70.536 +            }
  70.537 +            else
  70.538 +            {
  70.539 +                if (skipPixels >= font->Width(text))
  70.540 +                    start = text.length();
  70.541 +                else
  70.542 +                    while (skipPixels > font->Width(text[start]))
  70.543 +                    {
  70.544 +                        skipPixels -= font->Width(text[start]);
  70.545 +                        skipPixels -= font->SpaceBetween();
  70.546 +                        start++;
  70.547 +                    }
  70.548 +            }
  70.549 +        }
  70.550 +        for (i = start; i < (int) text.length(); i++)
  70.551 +        {
  70.552 +            c = text[i];
  70.553 +            if (xt > xmax)
  70.554 +            {
  70.555 +                i = text.length();
  70.556 +            }
  70.557 +            else
  70.558 +            {
  70.559 +                if (!proportional)
  70.560 +                {
  70.561 +                    if (skipPixels > 0)
  70.562 +                    {
  70.563 +                        DrawCharacter(xt, yt, xmax, c, font, color, skipPixels);
  70.564 +                        xt += font->TotalWidth() - skipPixels;
  70.565 +                        skipPixels = 0;
  70.566 +                    }
  70.567 +                    else
  70.568 +                    {
  70.569 +                        DrawCharacter(xt, yt, xmax, c, font, color);
  70.570 +                        xt += font->TotalWidth();
  70.571 +                    }
  70.572 +                }
  70.573 +                else
  70.574 +                {
  70.575 +                    if (skipPixels > 0)
  70.576 +                    {
  70.577 +                        xt += DrawCharacter(xt, yt, xmax, c, font, color, skipPixels);
  70.578 +                        skipPixels = 0;
  70.579 +                    }
  70.580 +                    else
  70.581 +                    {
  70.582 +                        xt += DrawCharacter(xt, yt, xmax, c, font, color);
  70.583 +                    }
  70.584 +                    if (xt <= xmax)
  70.585 +                    {
  70.586 +                        xt += font->SpaceBetween();
  70.587 +                    }
  70.588 +                }
  70.589 +            }
  70.590 +        }
  70.591 +    }
  70.592 +    return xt;
  70.593 +}
  70.594 +
  70.595 +int cBitmap::DrawCharacter(int x, int y, int xmax, char c, const cFont * font,
  70.596 +                           eColor color, int skipPixels)
  70.597 +{
  70.598 +    const cBitmap * charBitmap;
  70.599 +
  70.600 +    clip(x, 0, width - 1);
  70.601 +    clip(y, 0, height - 1);
  70.602 +
  70.603 +    charBitmap = font->GetCharacter(c);
  70.604 +    if (charBitmap)
  70.605 +    {
  70.606 +        cBitmap * drawBitmap = charBitmap->SubBitmap(skipPixels, 0, xmax - x + skipPixels, charBitmap->Height() - 1);
  70.607 +        if (drawBitmap)
  70.608 +            DrawBitmap(x, y, *drawBitmap, color);
  70.609 +        delete drawBitmap;
  70.610 +        return charBitmap->Width() - skipPixels;
  70.611 +    }
  70.612 +    return 0;
  70.613 +}
  70.614 +
  70.615 +unsigned char cBitmap::GetPixel(int x, int y) const
  70.616 +{
  70.617 +    unsigned char value;
  70.618 +
  70.619 +    value = bitmap[y * lineSize + x / 8];
  70.620 +    value = (value >> (7 - (x % 8))) & 1;
  70.621 +    return value;
  70.622 +}
  70.623 +
  70.624 +cBitmap * cBitmap::SubBitmap(int x1, int y1, int x2, int y2) const
  70.625 +{
  70.626 +    int w, h;
  70.627 +    int xt, yt;
  70.628 +    cBitmap * bmp;
  70.629 +    unsigned char cl;
  70.630 +    unsigned char * data;
  70.631 +    unsigned short temp;
  70.632 +
  70.633 +    sort(x1,x2);
  70.634 +    sort(y1,y2);
  70.635 +    if (x1 < 0 || x1 > width - 1)
  70.636 +        return NULL;
  70.637 +    if (y1 < 0 || y1 > height - 1)
  70.638 +        return NULL;
  70.639 +    clip(x2, 0, width - 1);
  70.640 +    clip(y2, 0, height - 1);
  70.641 +
  70.642 +    w = x2 - x1 + 1;
  70.643 +    h = y2 - y1 + 1;
  70.644 +    bmp = new cBitmap(w, h);
  70.645 +    if (!bmp || !bmp->Data())
  70.646 +        return NULL;
  70.647 +    bmp->Clear();
  70.648 +    if (x1 % 8 == 0)
  70.649 +    {
  70.650 +        // Bitmap is byte alligned (0,8,16,...)
  70.651 +        for (yt = 0; yt < h; yt++)
  70.652 +        {
  70.653 +            data = &bitmap[(y1 + yt) * lineSize + x1 / 8];
  70.654 +            for (xt = 0; xt < (w / 8) * 8; xt += 8)
  70.655 +            {
  70.656 +                cl = *data;
  70.657 +                bmp->Draw8Pixels(xt, yt, cl, clrBlack);
  70.658 +                data++;
  70.659 +            }
  70.660 +            if (w % 8 != 0)
  70.661 +            {
  70.662 +                cl = *data;
  70.663 +                bmp->Draw8Pixels(xt, yt, cl & bitmaskl[w % 8 - 1], clrBlack);
  70.664 +            }
  70.665 +        }
  70.666 +    }
  70.667 +    else
  70.668 +    {
  70.669 +        // Bitmap is not byte alligned
  70.670 +        for (yt = 0; yt < h; yt++)
  70.671 +        {
  70.672 +            temp = 0;
  70.673 +            data = &bitmap[(y1 + yt) * lineSize + x1 / 8];
  70.674 +            for (xt = 0; xt <= ((w / 8)) * 8; xt += 8)
  70.675 +            {
  70.676 +                cl = *data;
  70.677 +                temp = temp | ((unsigned short) cl << (x1 % 8));
  70.678 +                cl = (temp & 0xff00) >> 8;
  70.679 +                if (xt > 0)
  70.680 +                {
  70.681 +                    bmp->Draw8Pixels(xt - 8, yt, cl, clrBlack);
  70.682 +                }
  70.683 +                temp <<= 8;
  70.684 +                data++;
  70.685 +            }
  70.686 +            if (w % 8 != 0)
  70.687 +            {
  70.688 +                // print the rest
  70.689 +                if (8 - (x1 % 8) < w % 8)
  70.690 +                {
  70.691 +                    cl = *data;
  70.692 +                    temp = temp | ((unsigned short) cl << (x1 % 8));
  70.693 +                }
  70.694 +                cl = (temp & 0xff00) >> 8;
  70.695 +                bmp->Draw8Pixels(xt - 8, yt, cl & bitmaskl[(w % 8) - 1], clrBlack);
  70.696 +            }
  70.697 +        }
  70.698 +    }
  70.699 +    return bmp;
  70.700 +}
  70.701 +
  70.702 +bool cBitmap::LoadPBM(const std::string & fileName)
  70.703 +{
  70.704 +    FILE * pbmFile;
  70.705 +    char str[32];
  70.706 +    int i;
  70.707 +    int ch;
  70.708 +    int w;
  70.709 +    int h;
  70.710 +
  70.711 +    pbmFile = fopen(fileName.c_str(), "rb");
  70.712 +    if (!pbmFile)
  70.713 +        return false;
  70.714 +
  70.715 +    i = 0;
  70.716 +    while ((ch = getc(pbmFile)) != EOF && i < 31)
  70.717 +    {
  70.718 +        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
  70.719 +            break;
  70.720 +        str[i] = ch;
  70.721 +        i++;
  70.722 +    }
  70.723 +    if (ch == EOF)
  70.724 +    {
  70.725 +        fclose(pbmFile);
  70.726 +        return false;
  70.727 +    }
  70.728 +    str[i] = 0;
  70.729 +    if (strcmp(str, "P4") != 0)
  70.730 +        return false;
  70.731 +
  70.732 +    while ((ch = getc(pbmFile)) == '#')
  70.733 +    {
  70.734 +        while ((ch = getc(pbmFile)) != EOF)
  70.735 +        {
  70.736 +            if (ch == '\n' || ch == '\r')
  70.737 +                break;
  70.738 +        }
  70.739 +    }
  70.740 +    if (ch == EOF)
  70.741 +    {
  70.742 +        fclose(pbmFile);
  70.743 +        return false;
  70.744 +    }
  70.745 +    i = 0;
  70.746 +    str[i] = ch;
  70.747 +    i += 1;
  70.748 +    while ((ch = getc(pbmFile)) != EOF && i < 31)
  70.749 +    {
  70.750 +        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
  70.751 +            break;
  70.752 +        str[i] = ch;
  70.753 +        i++;
  70.754 +    }
  70.755 +    if (ch == EOF)
  70.756 +    {
  70.757 +        fclose(pbmFile);
  70.758 +        return false;
  70.759 +    }
  70.760 +    str[i] = 0;
  70.761 +    w = atoi(str);
  70.762 +
  70.763 +    i = 0;
  70.764 +    while ((ch = getc(pbmFile)) != EOF && i < 31)
  70.765 +    {
  70.766 +        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
  70.767 +            break;
  70.768 +        str[i] = ch;
  70.769 +        i++;
  70.770 +    }
  70.771 +    if (ch == EOF)
  70.772 +    {
  70.773 +        fclose(pbmFile);
  70.774 +        return false;
  70.775 +    }
  70.776 +    str[i] = 0;
  70.777 +    h = atoi(str);
  70.778 +
  70.779 +    delete[] bitmap;
  70.780 +    width = w;
  70.781 +    height = h;
  70.782 +    // lines are byte aligned
  70.783 +    lineSize = (width + 7) / 8;
  70.784 +    bitmap = new unsigned char[lineSize * height];
  70.785 +    fread(bitmap, lineSize * height, 1, pbmFile);
  70.786 +    fclose(pbmFile);
  70.787 +
  70.788 +    return true;
  70.789 +}
  70.790 +
  70.791 +void cBitmap::SavePBM(const std::string & fileName)
  70.792 +{
  70.793 +    int i;
  70.794 +    char str[32];
  70.795 +    FILE * fp;
  70.796 +
  70.797 +    fp = fopen(fileName.c_str(), "wb");
  70.798 +    if (fp)
  70.799 +    {
  70.800 +        sprintf(str, "P4\n%d %d\n", width, height);
  70.801 +        fwrite(str, strlen(str), 1, fp);
  70.802 +        for (i = 0; i < lineSize * height; i++)
  70.803 +        {
  70.804 +            fwrite(&bitmap[i], 1, 1, fp);
  70.805 +        }
  70.806 +        fclose(fp);
  70.807 +    }
  70.808 +}
  70.809 +
  70.810 +} // end of namespace
    71.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    71.2 +++ b/graphlcd-base/glcdgraphics/bitmap.h	Wed Feb 06 17:32:55 2008 +0000
    71.3 @@ -0,0 +1,75 @@
    71.4 +/*
    71.5 + * GraphLCD graphics library
    71.6 + *
    71.7 + * bitmap.h  -  cBitmap class
    71.8 + *
    71.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   71.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   71.11 + *
   71.12 + * This file is released under the GNU General Public License. Refer
   71.13 + * to the COPYING file distributed with this package.
   71.14 + *
   71.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   71.16 + */
   71.17 +
   71.18 +#ifndef _GLCDGRAPHICS_BITMAP_H_
   71.19 +#define _GLCDGRAPHICS_BITMAP_H_
   71.20 +
   71.21 +#include <string>
   71.22 +
   71.23 +namespace GLCD
   71.24 +{
   71.25 +
   71.26 +enum eColor
   71.27 +{
   71.28 +    clrBlack,
   71.29 +    clrWhite
   71.30 +};
   71.31 +
   71.32 +class cFont;
   71.33 +
   71.34 +class cBitmap
   71.35 +{
   71.36 +protected:
   71.37 +    int width;
   71.38 +    int height;
   71.39 +    int lineSize;
   71.40 +    unsigned char * bitmap;
   71.41 +
   71.42 +public:
   71.43 +    cBitmap(int width, int height, unsigned char * data = NULL);
   71.44 +    cBitmap(const cBitmap & b);
   71.45 +    ~cBitmap();
   71.46 +
   71.47 +    int Width() const { return width; }
   71.48 +    int Height() const { return height; }
   71.49 +    int LineSize() const { return lineSize; }
   71.50 +    const unsigned char * Data() const { return bitmap; }
   71.51 +
   71.52 +    void Clear();
   71.53 +    void Invert();
   71.54 +    void DrawPixel(int x, int y, eColor color);
   71.55 +    void Draw8Pixels(int x, int y, unsigned char pixels, eColor color);
   71.56 +    void DrawLine(int x1, int y1, int x2, int y2, eColor color);
   71.57 +    void DrawHLine(int x1, int y, int x2, eColor color);
   71.58 +    void DrawVLine(int x, int y1, int y2, eColor color);
   71.59 +    void DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled);
   71.60 +    void DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int size);
   71.61 +    void DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants);
   71.62 +    void DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type);
   71.63 +    void DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color);
   71.64 +    int DrawText(int x, int y, int xmax, const std::string & text, const cFont * font,
   71.65 +                 eColor color = clrBlack, bool proportional = true, int skipPixels = 0);
   71.66 +    int DrawCharacter(int x, int y, int xmax, char c, const cFont * font,
   71.67 +                      eColor color = clrBlack, int skipPixels = 0);
   71.68 +
   71.69 +    cBitmap * SubBitmap(int x1, int y1, int x2, int y2) const;
   71.70 +    unsigned char GetPixel(int x, int y) const;
   71.71 +
   71.72 +    bool LoadPBM(const std::string & fileName);
   71.73 +    void SavePBM(const std::string & fileName);
   71.74 +};
   71.75 +
   71.76 +} // end of namespace
   71.77 +
   71.78 +#endif
    72.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    72.2 +++ b/graphlcd-base/glcdgraphics/common.c	Wed Feb 06 17:32:55 2008 +0000
    72.3 @@ -0,0 +1,60 @@
    72.4 +/*
    72.5 + * GraphLCD graphics library
    72.6 + *
    72.7 + * common.c  -  various functions
    72.8 + *
    72.9 + * This file is released under the GNU General Public License. Refer
   72.10 + * to the COPYING file distributed with this package.
   72.11 + *
   72.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   72.13 + */
   72.14 +
   72.15 +#include <ctype.h>
   72.16 +
   72.17 +#include "common.h"
   72.18 +
   72.19 +
   72.20 +namespace GLCD
   72.21 +{
   72.22 +
   72.23 +void clip(int & value, int min, int max)
   72.24 +{
   72.25 +    if (value < min)
   72.26 +        value = min;
   72.27 +    if (value > max)
   72.28 +        value = max;
   72.29 +}
   72.30 +
   72.31 +void sort(int & value1, int & value2)
   72.32 +{
   72.33 +    if (value2 < value1)
   72.34 +    {
   72.35 +        int tmp;
   72.36 +        tmp = value2;
   72.37 +        value2 = value1;
   72.38 +        value1 = tmp;
   72.39 +    }
   72.40 +}
   72.41 +
   72.42 +std::string trim(const std::string & s)
   72.43 +{
   72.44 +	std::string::size_type start, end;
   72.45 +
   72.46 +	start = 0;
   72.47 +	while (start < s.length())
   72.48 +	{
   72.49 +		if (!isspace(s[start]))
   72.50 +			break;
   72.51 +		start++;
   72.52 +	}
   72.53 +	end = s.length() - 1;
   72.54 +	while (end >= 0)
   72.55 +	{
   72.56 +		if (!isspace(s[end]))
   72.57 +			break;
   72.58 +		end--;
   72.59 +	}
   72.60 +	return s.substr(start, end - start + 1);
   72.61 +}
   72.62 +
   72.63 +} // end of namespace
    73.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    73.2 +++ b/graphlcd-base/glcdgraphics/common.h	Wed Feb 06 17:32:55 2008 +0000
    73.3 @@ -0,0 +1,26 @@
    73.4 +/*
    73.5 + * GraphLCD graphics library
    73.6 + *
    73.7 + * common.h  -  various functions
    73.8 + *
    73.9 + * This file is released under the GNU General Public License. Refer
   73.10 + * to the COPYING file distributed with this package.
   73.11 + *
   73.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   73.13 + */
   73.14 +
   73.15 +#ifndef _GLCDGRAPHICS_COMMON_H_
   73.16 +#define _GLCDGRAPHICS_COMMON_H_
   73.17 +
   73.18 +#include <string>
   73.19 +
   73.20 +namespace GLCD
   73.21 +{
   73.22 +
   73.23 +void clip(int & value, int min, int max);
   73.24 +void sort(int & value1, int & value2);
   73.25 +std::string trim(const std::string & s);
   73.26 +
   73.27 +} // end of namespace
   73.28 +
   73.29 +#endif
    74.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    74.2 +++ b/graphlcd-base/glcdgraphics/font.c	Wed Feb 06 17:32:55 2008 +0000
    74.3 @@ -0,0 +1,581 @@
    74.4 +/*
    74.5 + * GraphLCD graphics library
    74.6 + *
    74.7 + * font.c  -  font handling
    74.8 + *
    74.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   74.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   74.11 + *
   74.12 + * This file is released under the GNU General Public License. Refer
   74.13 + * to the COPYING file distributed with this package.
   74.14 + *
   74.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   74.16 + */
   74.17 +
   74.18 +#include <stdio.h>
   74.19 +#include <stdint.h>
   74.20 +#include <syslog.h>
   74.21 +#include <fcntl.h>
   74.22 +#include <unistd.h>
   74.23 +
   74.24 +#include <algorithm>
   74.25 +
   74.26 +#include "common.h"
   74.27 +#include "font.h"
   74.28 +
   74.29 +#ifdef HAVE_FREETYPE2
   74.30 +#include <ft2build.h>
   74.31 +#include FT_FREETYPE_H
   74.32 +#include <iconv.h>
   74.33 +#endif
   74.34 +
   74.35 +namespace GLCD
   74.36 +{
   74.37 +
   74.38 +static const char * kFontFileSign = "FNT3";
   74.39 +static const uint32_t kFontHeaderSize = 16;
   74.40 +static const uint32_t kCharHeaderSize = 4;
   74.41 +
   74.42 +//#pragma pack(1)
   74.43 +//struct tFontHeader
   74.44 +//{
   74.45 +//    char sign[4];          // = FONTFILE_SIGN
   74.46 +//    unsigned short height; // total height of the font
   74.47 +//    unsigned short ascent; // ascender of the font
   74.48 +//    unsigned short line;   // line height
   74.49 +//    unsigned short reserved;
   74.50 +//    unsigned short space;  // space between characters of a string
   74.51 +//    unsigned short count;  // number of chars in this file
   74.52 +//};
   74.53 +//
   74.54 +//struct tCharHeader
   74.55 +//{
   74.56 +//    unsigned short character;
   74.57 +//    unsigned short width;
   74.58 +//};
   74.59 +//#pragma pack()
   74.60 +
   74.61 +cFont::cFont()
   74.62 +{
   74.63 +    Init();
   74.64 +}
   74.65 +
   74.66 +cFont::~cFont()
   74.67 +{
   74.68 +    Unload();
   74.69 +}
   74.70 +
   74.71 +bool cFont::LoadFNT(const std::string & fileName)
   74.72 +{
   74.73 +    // cleanup if we already had a loaded font
   74.74 +    Unload();
   74.75 +
   74.76 +    FILE * fontFile;
   74.77 +    int i;
   74.78 +    uint8_t buffer[10000];
   74.79 +    uint16_t fontHeight;
   74.80 +    uint16_t numChars;
   74.81 +    int maxWidth = 0;
   74.82 +
   74.83 +    fontFile = fopen(fileName.c_str(), "rb");
   74.84 +    if (!fontFile)
   74.85 +        return false;
   74.86 +
   74.87 +    fread(buffer, kFontHeaderSize, 1, fontFile);
   74.88 +    if (buffer[0] != kFontFileSign[0] ||
   74.89 +        buffer[1] != kFontFileSign[1] ||
   74.90 +        buffer[2] != kFontFileSign[2] ||
   74.91 +        buffer[3] != kFontFileSign[3])
   74.92 +    {
   74.93 +        fclose(fontFile);
   74.94 +        return false;
   74.95 +    }
   74.96 +
   74.97 +    fontHeight = buffer[4] | (buffer[5] << 8);
   74.98 +    totalAscent = buffer[6] | (buffer[7] << 8);
   74.99 +    lineHeight = buffer[8] | (buffer[9] << 8);
  74.100 +    spaceBetween = buffer[12] | (buffer[13] << 8);
  74.101 +    numChars = buffer[14] | (buffer[15] << 8);
  74.102 +    for (i = 0; i < numChars; i++)
  74.103 +    {
  74.104 +        uint8_t chdr[kCharHeaderSize];
  74.105 +        uint16_t charWidth;
  74.106 +        uint16_t character;
  74.107 +        fread(chdr, kCharHeaderSize, 1, fontFile);
  74.108 +        character = chdr[0] | (chdr[1] << 8);
  74.109 +        charWidth = chdr[2] | (chdr[3] << 8);
  74.110 +        fread(buffer, fontHeight * ((charWidth + 7) / 8), 1, fontFile);
  74.111 +        if (characters[character])
  74.112 +            delete characters[character];
  74.113 +        characters[character] = new cBitmap(charWidth, fontHeight, buffer);
  74.114 +        if (characters[character]->Width() > maxWidth)
  74.115 +            maxWidth = characters[character]->Width();
  74.116 +    }
  74.117 +    fclose(fontFile);
  74.118 +
  74.119 +    totalWidth = maxWidth;
  74.120 +    totalHeight = fontHeight;
  74.121 +
  74.122 +    return true;
  74.123 +}
  74.124 +
  74.125 +bool cFont::SaveFNT(const std::string & fileName) const
  74.126 +{
  74.127 +    FILE * fontFile;
  74.128 +    uint8_t fhdr[kFontHeaderSize];
  74.129 +    uint8_t chdr[kCharHeaderSize];
  74.130 +    uint16_t numChars;
  74.131 +    int i;
  74.132 +
  74.133 +    fontFile = fopen(fileName.c_str(),"w+b");
  74.134 +    if (!fontFile)
  74.135 +    {
  74.136 +        syslog(LOG_ERR, "cFont::SaveFNT(): Cannot open file: %s for writing\n",fileName.c_str());
  74.137 +        return false;
  74.138 +    }
  74.139 +
  74.140 +    numChars = 0;
  74.141 +    for (i = 0; i < 256; i++)
  74.142 +    {
  74.143 +        if (characters[i])
  74.144 +        {
  74.145 +            numChars++;
  74.146 +        }
  74.147 +    }
  74.148 +
  74.149 +    memcpy(fhdr, kFontFileSign, 4);
  74.150 +    fhdr[4] = (uint8_t) totalHeight;
  74.151 +    fhdr[5] = (uint8_t) (totalHeight >> 8);
  74.152 +    fhdr[6] = (uint8_t) totalAscent;
  74.153 +    fhdr[7] = (uint8_t) (totalAscent >> 8);
  74.154 +    fhdr[8] = (uint8_t) lineHeight;
  74.155 +    fhdr[9] = (uint8_t) (lineHeight >> 8);
  74.156 +    fhdr[10] = 0;
  74.157 +    fhdr[11] = 0;
  74.158 +    fhdr[12] = (uint8_t) spaceBetween;
  74.159 +    fhdr[13] = (uint8_t) (spaceBetween >> 8);
  74.160 +    fhdr[14] = (uint8_t) numChars;
  74.161 +    fhdr[15] = (uint8_t) (numChars >> 8);
  74.162 +
  74.163 +    // write font file header
  74.164 +    fwrite(fhdr, kFontHeaderSize, 1, fontFile);
  74.165 +
  74.166 +    for (i = 0; i < 256; i++)
  74.167 +    {
  74.168 +        if (characters[i])
  74.169 +        {
  74.170 +            chdr[0] = (uint8_t) i;
  74.171 +            chdr[1] = (uint8_t) (i >> 8);
  74.172 +            chdr[2] = (uint8_t) characters[i]->Width();
  74.173 +            chdr[3] = (uint8_t) (characters[i]->Width() >> 8);
  74.174 +            fwrite(chdr, kCharHeaderSize, 1, fontFile);
  74.175 +            fwrite(characters[i]->Data(), totalHeight * characters[i]->LineSize(), 1, fontFile);
  74.176 +        }
  74.177 +    }
  74.178 +
  74.179 +    fclose(fontFile);
  74.180 +
  74.181 +    syslog(LOG_DEBUG, "cFont::SaveFNT(): Font file '%s' written successfully\n", fileName.c_str());
  74.182 +
  74.183 +    return true;
  74.184 +}
  74.185 +
  74.186 +bool cFont::LoadFT2(const std::string & fileName, const std::string & encoding,
  74.187 +                    int size, bool dingBats)
  74.188 +{
  74.189 +    // cleanup if we already had a loaded font
  74.190 +    Unload();
  74.191 +#ifdef HAVE_FREETYPE2
  74.192 +    if (access(fileName.c_str(), F_OK) != 0)
  74.193 +    {
  74.194 +        syslog(LOG_ERR, "cFont::LoadFT2: Font file (%s) does not exist!!", fileName.c_str());
  74.195 +        return false;
  74.196 +    }
  74.197 +    // file exists
  74.198 +    FT_Library library;
  74.199 +    FT_Face face;
  74.200 +    FT_GlyphSlot slot;
  74.201 +
  74.202 +    int error = FT_Init_FreeType(&library);
  74.203 +    if (error)
  74.204 +    {
  74.205 +        syslog(LOG_ERR, "cFont::LoadFT2: Could not init freetype library");
  74.206 +        return false;
  74.207 +    }
  74.208 +    error = FT_New_Face(library, fileName.c_str(), 0, &face);
  74.209 +    // everything ok?
  74.210 +    if (error == FT_Err_Unknown_File_Format)
  74.211 +    {
  74.212 +        syslog(LOG_ERR, "cFont::LoadFT2: Font file (%s) could be opened and read, but it appears that its font format is unsupported", fileName.c_str());
  74.213 +        error = FT_Done_Face(face);
  74.214 +        syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
  74.215 +        error = FT_Done_FreeType(library);
  74.216 +        syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
  74.217 +        return false;
  74.218 +    }
  74.219 +    else if (error)
  74.220 +    {
  74.221 +        syslog(LOG_ERR, "cFont::LoadFT2: Font file (%s) could not be opened or read, or simply it is broken,\n error code was %x", fileName.c_str(), error);
  74.222 +        error = FT_Done_Face(face);
  74.223 +        syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
  74.224 +        error = FT_Done_FreeType(library);
  74.225 +        syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
  74.226 +        return false;
  74.227 +    }
  74.228 +
  74.229 +    // set slot
  74.230 +    slot = face->glyph;
  74.231 +
  74.232 +    // set Size
  74.233 +    FT_Set_Char_Size(face, 0, size * 64, 0, 0);
  74.234 +
  74.235 +    wchar_t utf_buff[256];
  74.236 +    if (dingBats)
  74.237 +    {
  74.238 +/*
  74.239 +        FT_CharMap charmap = 0;
  74.240 +        for (int n = 0; n < face->num_charmaps; n++)
  74.241 +        {
  74.242 +            if (face->charmaps[n]->platform_id == 3 &&
  74.243 +                face->charmaps[n]->encoding_id == 0)
  74.244 +            {
  74.245 +                charmap = face->charmaps[n];
  74.246 +                //break;
  74.247 +            }
  74.248 +        }
  74.249 +        if (charmap)
  74.250 +            syslog(LOG_ERR, "cFont::LoadFT2: platform_id: %d, encoding_id: %d", charmap->platform_id, charmap->encoding_id);
  74.251 +        error = FT_Set_Charmap(_face, charmap);
  74.252 +        if (error)
  74.253 +        {
  74.254 +            syslog(LOG_ERR, "cFont::LoadFT2: FT_Select_Charmap encoding not supported: %d", charmap->encoding_id);
  74.255 +        }
  74.256 +*/
  74.257 +    }
  74.258 +    else
  74.259 +    {
  74.260 +        iconv_t cd;
  74.261 +        if ((cd = iconv_open("WCHAR_T", encoding.c_str())) == (iconv_t) -1)
  74.262 +        {
  74.263 +            syslog(LOG_ERR, "cFont::LoadFT2: Iconv encoding not supported: %s", encoding.c_str());
  74.264 +            error = FT_Done_Face(face);
  74.265 +            syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
  74.266 +            error = FT_Done_FreeType(library);
  74.267 +            syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
  74.268 +            return false;
  74.269 +        }
  74.270 +        for (int c = 0; c < 256; c++)
  74.271 +        {
  74.272 +            char char_buff = c;
  74.273 +            wchar_t wchar_buff;
  74.274 +            char * in_buff,* out_buff;
  74.275 +            size_t in_len, out_len, count;
  74.276 +
  74.277 +            in_len = 1;
  74.278 +            out_len = 4;
  74.279 +            in_buff = (char *) &char_buff;
  74.280 +            out_buff = (char *) &wchar_buff;
  74.281 +            count = iconv(cd, &in_buff, &in_len, &out_buff, &out_len);
  74.282 +            if ((size_t) -1 == count)
  74.283 +            {
  74.284 +                utf_buff[c] = 0;
  74.285 +            }
  74.286 +            utf_buff[c] = wchar_buff;
  74.287 +        }
  74.288 +        iconv_close(cd);
  74.289 +    }
  74.290 +
  74.291 +    // get some global parameters
  74.292 +    totalHeight = (face->size->metrics.ascender >> 6) - (face->size->metrics.descender >> 6);
  74.293 +    totalWidth = face->size->metrics.max_advance >> 6;
  74.294 +    totalAscent = face->size->metrics.ascender >> 6;
  74.295 +    lineHeight = face->size->metrics.height >> 6;
  74.296 +    spaceBetween = 0;
  74.297 +#if 0
  74.298 +    syslog(LOG_DEBUG, "cFont::LoadFT2: totalHeight = %d", totalHeight);
  74.299 +    syslog(LOG_DEBUG, "cFont::LoadFT2: totalWidth = %d", totalWidth);
  74.300 +    syslog(LOG_DEBUG, "cFont::LoadFT2: totalAscent = %d", totalAscent);
  74.301 +    syslog(LOG_DEBUG, "cFont::LoadFT2: lineHeight = %d", lineHeight);
  74.302 +    syslog(LOG_DEBUG, "cFont::LoadFT2: spaceBetween = %d", spaceBetween);
  74.303 +#endif
  74.304 +    // render glyphs for ASCII codes 0 to 255 in our bitmap class
  74.305 +    FT_UInt glyph_index;
  74.306 +    int num_char;
  74.307 +
  74.308 +    for (num_char = 0; num_char < 256; num_char++)
  74.309 +    {
  74.310 +        if (dingBats)
  74.311 +        {
  74.312 +            //Get FT char index & load the char
  74.313 +            error = FT_Load_Char(face, num_char, FT_LOAD_DEFAULT);
  74.314 +        }
  74.315 +        else
  74.316 +        {
  74.317 +            //Get FT char index
  74.318 +            glyph_index = FT_Get_Char_Index(face, utf_buff[num_char]);
  74.319 +            //Load the char
  74.320 +            error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
  74.321 +        }
  74.322 +        if (error)
  74.323 +        {
  74.324 +            syslog(LOG_ERR, "cFont::LoadFT2: ERROR when calling FT_Load_Glyph: %x", error);
  74.325 +        }
  74.326 +
  74.327 +        // convert to a mono bitmap
  74.328 +        error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO);
  74.329 +        if (error)
  74.330 +        {
  74.331 +            syslog(LOG_ERR, "cFont::LoadFT2: ERROR when calling FT_Render_Glyph: %x", error);
  74.332 +        }
  74.333 +
  74.334 +        // now, fill our pixel data
  74.335 +        cBitmap * charBitmap = new cBitmap(face->glyph->advance.x >> 6, totalHeight);
  74.336 +        charBitmap->Clear();
  74.337 +        unsigned char * bufPtr = face->glyph->bitmap.buffer;
  74.338 +        unsigned char pixel;
  74.339 +        for (int y = 0; y < face->glyph->bitmap.rows; y++)
  74.340 +        {
  74.341 +            for (int x = 0; x < face->glyph->bitmap.width; x++)
  74.342 +            {
  74.343 +                pixel = (bufPtr[x / 8] >> (7 - x % 8)) & 1;
  74.344 +                if (pixel)
  74.345 +                    charBitmap->DrawPixel((face->glyph->metrics.horiBearingX >> 6) + x,
  74.346 +                                          (face->size->metrics.ascender >> 6) - (face->glyph->metrics.horiBearingY >> 6) + y,
  74.347 +                                          GLCD::clrBlack);
  74.348 +            }
  74.349 +            bufPtr += face->glyph->bitmap.pitch;
  74.350 +        }
  74.351 +        SetCharacter((char) num_char, charBitmap);
  74.352 +    }
  74.353 +    error = FT_Done_Face(face);
  74.354 +    if (error)
  74.355 +    {
  74.356 +        syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
  74.357 +    }
  74.358 +    error = FT_Done_FreeType(library);
  74.359 +    if (error)
  74.360 +    {
  74.361 +        syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
  74.362 +    }
  74.363 +    return true;
  74.364 +#else
  74.365 +    syslog(LOG_ERR, "cFont::LoadFT2: glcdgraphics was compiled without FreeType2 support!!!");
  74.366 +    return false;
  74.367 +#endif
  74.368 +}
  74.369 +
  74.370 +int cFont::Width(char ch) const
  74.371 +{
  74.372 +    if (characters[(unsigned char) ch])
  74.373 +        return characters[(unsigned char) ch]->Width();
  74.374 +    else
  74.375 +        return 0;
  74.376 +}
  74.377 +
  74.378 +int cFont::Width(const std::string & str) const
  74.379 +{
  74.380 +    unsigned int i;
  74.381 +    int sum = 0;
  74.382 +
  74.383 +    for (i = 0; i < str.length(); i++)
  74.384 +    {
  74.385 +        sum += Width(str[i]);
  74.386 +    }
  74.387 +    if (str.length() > 1)
  74.388 +    {
  74.389 +        sum += spaceBetween * (str.length() - 1);
  74.390 +    }
  74.391 +    return sum;
  74.392 +}
  74.393 +
  74.394 +int cFont::Width(const std::string & str, unsigned int len) const
  74.395 +{
  74.396 +    unsigned int i;
  74.397 +    int sum = 0;
  74.398 +
  74.399 +    for (i = 0; i < str.length() && i < len; i++)
  74.400 +    {
  74.401 +        sum += Width(str[i]);
  74.402 +    }
  74.403 +    if (std::min(str.length(), (size_t) len) > 1)
  74.404 +    {
  74.405 +        sum += spaceBetween * (std::min(str.length(), (size_t) len) - 1);
  74.406 +    }
  74.407 +    return sum;
  74.408 +}
  74.409 +
  74.410 +int cFont::Height(char ch) const
  74.411 +{
  74.412 +    if (characters[(unsigned char) ch])
  74.413 +        return characters[(unsigned char) ch]->Height();
  74.414 +    else
  74.415 +        return 0;
  74.416 +}
  74.417 +
  74.418 +int cFont::Height(const std::string & str) const
  74.419 +{
  74.420 +    unsigned int i;
  74.421 +    int sum = 0;
  74.422 +
  74.423 +    for (i = 0; i < str.length(); i++)
  74.424 +        sum = std::max(sum, Height(str[i]));
  74.425 +    return sum;
  74.426 +}
  74.427 +
  74.428 +int cFont::Height(const std::string & str, unsigned int len) const
  74.429 +{
  74.430 +    unsigned int i;
  74.431 +    int sum = 0;
  74.432 +
  74.433 +    for (i = 0; i < str.length() && i < len; i++)
  74.434 +        sum = std::max(sum, Height(str[i]));
  74.435 +    return sum;
  74.436 +}
  74.437 +
  74.438 +const cBitmap * cFont::GetCharacter(char ch) const
  74.439 +{
  74.440 +    return characters[(unsigned char) ch];
  74.441 +}
  74.442 +
  74.443 +void cFont::SetCharacter(char ch, cBitmap * bitmapChar)
  74.444 +{
  74.445 +    // adjust maxwidth if necessary
  74.446 +    if (totalWidth < bitmapChar->Width())
  74.447 +        totalWidth = bitmapChar->Width();
  74.448 +
  74.449 +    // delete if already allocated
  74.450 +    if (characters[(unsigned char) ch])
  74.451 +        delete characters[(unsigned char) ch];
  74.452 +
  74.453 +    // store new character
  74.454 +    characters[(unsigned char) ch] = bitmapChar;
  74.455 +}
  74.456 +
  74.457 +void cFont::Init()
  74.458 +{
  74.459 +    totalWidth = 0;
  74.460 +    totalHeight = 0;
  74.461 +    totalAscent = 0;
  74.462 +    spaceBetween = 0;
  74.463 +    lineHeight = 0;
  74.464 +    for (int i = 0; i < 256; i++)
  74.465 +    {
  74.466 +        characters[i] = NULL;
  74.467 +    }
  74.468 +}
  74.469 +
  74.470 +void cFont::Unload()
  74.471 +{
  74.472 +    // cleanup
  74.473 +    for (int i = 0; i < 256; i++)
  74.474 +    {
  74.475 +        if (characters[i])
  74.476 +        {
  74.477 +            delete characters[i];
  74.478 +        }
  74.479 +    }
  74.480 +    // re-init
  74.481 +    Init();
  74.482 +}
  74.483 +
  74.484 +void cFont::WrapText(int Width, int Height, std::string & Text,
  74.485 +                     std::vector <std::string> & Lines, int * ActualWidth) const
  74.486 +{
  74.487 +    int maxLines;
  74.488 +    int lineCount;
  74.489 +    int textWidth;
  74.490 +    std::string::size_type start;
  74.491 +    std::string::size_type pos;
  74.492 +    std::string::size_type posLast;
  74.493 +
  74.494 +    Lines.clear();
  74.495 +    maxLines = 2000;
  74.496 +    if (Height > 0)
  74.497 +    {
  74.498 +        maxLines = Height / LineHeight();
  74.499 +        if (maxLines == 0)
  74.500 +            maxLines = 1;
  74.501 +    }
  74.502 +    lineCount = 0;
  74.503 +
  74.504 +    pos = 0;
  74.505 +    start = 0;
  74.506 +    posLast = 0;
  74.507 +    textWidth = 0;
  74.508 +    while (pos < Text.length() && (Height == 0 || lineCount < maxLines))
  74.509 +    {
  74.510 +        if (Text[pos] == '\n')
  74.511 +        {
  74.512 +            Lines.push_back(trim(Text.substr(start, pos - start)));
  74.513 +            start = pos + 1;
  74.514 +            posLast = pos + 1;
  74.515 +            textWidth = 0;
  74.516 +            lineCount++;
  74.517 +        }
  74.518 +        else if (textWidth > Width && (lineCount + 1) < maxLines)
  74.519 +        {
  74.520 +            if (posLast > start)
  74.521 +            {
  74.522 +                Lines.push_back(trim(Text.substr(start, posLast - start)));
  74.523 +                start = posLast + 1;
  74.524 +                posLast = start;
  74.525 +                textWidth = this->Width(Text.substr(start, pos - start + 1)) + spaceBetween;
  74.526 +            }
  74.527 +            else
  74.528 +            {
  74.529 +                Lines.push_back(trim(Text.substr(start, pos - start)));
  74.530 +                start = pos + 1;
  74.531 +                posLast = start;
  74.532 +                textWidth = this->Width(Text[pos]) + spaceBetween;
  74.533 +            }
  74.534 +            lineCount++;
  74.535 +        }
  74.536 +        else if (Text[pos] == ' ')
  74.537 +        {
  74.538 +            posLast = pos;
  74.539 +            textWidth += this->Width(Text[pos]) + spaceBetween;
  74.540 +        }
  74.541 +        else
  74.542 +        {
  74.543 +            textWidth += this->Width(Text[pos]) + spaceBetween;
  74.544 +        }
  74.545 +        pos++;
  74.546 +    }
  74.547 +
  74.548 +    if (Height == 0 || lineCount < maxLines)
  74.549 +    {
  74.550 +        if (textWidth > Width && (lineCount + 1) < maxLines)
  74.551 +        {
  74.552 +            if (posLast > start)
  74.553 +            {
  74.554 +                Lines.push_back(trim(Text.substr(start, posLast - start)));
  74.555 +                start = posLast + 1;
  74.556 +                posLast = start;
  74.557 +                textWidth = this->Width(Text.substr(start, pos - start + 1)) + spaceBetween;
  74.558 +            }
  74.559 +            else
  74.560 +            {
  74.561 +                Lines.push_back(trim(Text.substr(start, pos - start)));
  74.562 +                start = pos + 1;
  74.563 +                posLast = start;
  74.564 +                textWidth = this->Width(Text[pos]) + spaceBetween;
  74.565 +            }
  74.566 +            lineCount++;
  74.567 +        }
  74.568 +        if (pos > start)
  74.569 +        {
  74.570 +            Lines.push_back(trim(Text.substr(start)));
  74.571 +            lineCount++;
  74.572 +        }
  74.573 +        textWidth = 0;
  74.574 +        for (int i = 0; i < lineCount; i++)
  74.575 +            textWidth = std::max(textWidth, this->Width(Lines[i]));
  74.576 +        textWidth = std::min(textWidth, Width);
  74.577 +    }
  74.578 +    else
  74.579 +        textWidth = Width;
  74.580 +    if (ActualWidth)
  74.581 +        *ActualWidth = textWidth;
  74.582 +}
  74.583 +
  74.584 +} // end of namespace
    75.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    75.2 +++ b/graphlcd-base/glcdgraphics/font.h	Wed Feb 06 17:32:55 2008 +0000
    75.3 @@ -0,0 +1,75 @@
    75.4 +/*
    75.5 + * GraphLCD graphics library
    75.6 + *
    75.7 + * font.h  -  font handling
    75.8 + *
    75.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   75.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   75.11 + *
   75.12 + * This file is released under the GNU General Public License. Refer
   75.13 + * to the COPYING file distributed with this package.
   75.14 + *
   75.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   75.16 + */
   75.17 +
   75.18 +#ifndef _GLCDGRAPHICS_FONT_H_
   75.19 +#define _GLCDGRAPHICS_FONT_H_
   75.20 +
   75.21 +#include <string>
   75.22 +#include <vector>
   75.23 +
   75.24 +#include "bitmap.h"
   75.25 +
   75.26 +namespace GLCD
   75.27 +{
   75.28 +
   75.29 +class cFont
   75.30 +{
   75.31 +private:
   75.32 +    int totalWidth;
   75.33 +    int totalHeight;
   75.34 +    int totalAscent;
   75.35 +    int spaceBetween;
   75.36 +    int lineHeight;
   75.37 +
   75.38 +    cBitmap * characters[256];
   75.39 +protected:
   75.40 +    void Init();
   75.41 +    void Unload();
   75.42 +public:
   75.43 +    cFont();
   75.44 +    ~cFont();
   75.45 +
   75.46 +    bool LoadFNT(const std::string & fileName);
   75.47 +    bool SaveFNT(const std::string & fileName) const;
   75.48 +    bool LoadFT2(const std::string & fileName, const std::string & encoding,
   75.49 +                 int size, bool dingBats = false);
   75.50 +    int TotalWidth() const { return totalWidth; };
   75.51 +    int TotalHeight() const { return totalHeight; };
   75.52 +    int TotalAscent() const { return totalAscent; };
   75.53 +    int SpaceBetween() const { return spaceBetween; };
   75.54 +    int LineHeight() const { return lineHeight; };
   75.55 +
   75.56 +    void SetTotalWidth(int width) { totalWidth = width; };
   75.57 +    void SetTotalHeight(int height) { totalHeight = height; };
   75.58 +    void SetTotalAscent(int ascent) { totalAscent = ascent; };
   75.59 +    void SetSpaceBetween(int width) { spaceBetween = width; };
   75.60 +    void SetLineHeight(int height) { lineHeight = height; };
   75.61 +
   75.62 +    int Width(char ch) const;
   75.63 +    int Width(const std::string & str) const;
   75.64 +    int Width(const std::string & str, unsigned int len) const;
   75.65 +    int Height(char ch) const;
   75.66 +    int Height(const std::string & str) const;
   75.67 +    int Height(const std::string & str, unsigned int len) const;
   75.68 +
   75.69 +    const cBitmap * GetCharacter(char ch) const;
   75.70 +    void SetCharacter(char ch, cBitmap * bitmapChar);
   75.71 +
   75.72 +    void WrapText(int Width, int Height, std::string & Text,
   75.73 +                  std::vector <std::string> & Lines, int * TextWidth = NULL) const;
   75.74 +};
   75.75 +
   75.76 +} // end of namespace
   75.77 +
   75.78 +#endif
    76.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    76.2 +++ b/graphlcd-base/glcdgraphics/glcd.c	Wed Feb 06 17:32:55 2008 +0000
    76.3 @@ -0,0 +1,277 @@
    76.4 +/*
    76.5 + * GraphLCD graphics library
    76.6 + *
    76.7 + * glcd.c  -  GLCD file loading and saving
    76.8 + *
    76.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   76.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   76.11 + *
   76.12 + * This file is released under the GNU General Public License. Refer
   76.13 + * to the COPYING file distributed with this package.
   76.14 + *
   76.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   76.16 + */
   76.17 +
   76.18 +#include <stdio.h>
   76.19 +#include <stdint.h>
   76.20 +#include <syslog.h>
   76.21 +
   76.22 +#include <string>
   76.23 +
   76.24 +#include "bitmap.h"
   76.25 +#include "glcd.h"
   76.26 +#include "image.h"
   76.27 +
   76.28 +
   76.29 +namespace GLCD
   76.30 +{
   76.31 +
   76.32 +using namespace std;
   76.33 +
   76.34 +const char * kGLCDFileSign = "GLC";
   76.35 +
   76.36 +/*
   76.37 +#pragma pack(1)
   76.38 +struct tGLCDHeader
   76.39 +{
   76.40 +    char sign[3];    // = "GLC"
   76.41 +    char format;     // D - single image, A - animation
   76.42 +    uint16_t width;  // width in pixels
   76.43 +    uint16_t height; // height in pixels
   76.44 +    // only for animations
   76.45 +    uint16_t count;  // number of pictures
   76.46 +    uint32_t delay;  // delay in ms
   76.47 +};
   76.48 +#pragma pack()
   76.49 +*/
   76.50 +
   76.51 +cGLCDFile::cGLCDFile()
   76.52 +{
   76.53 +}
   76.54 +
   76.55 +cGLCDFile::~cGLCDFile()
   76.56 +{
   76.57 +}
   76.58 +
   76.59 +bool cGLCDFile::Load(cImage & image, const string & fileName)
   76.60 +{
   76.61 +    FILE * fp;
   76.62 +    long fileSize;
   76.63 +    char sign[4];
   76.64 +    uint8_t buf[6];
   76.65 +    uint16_t width;
   76.66 +    uint16_t height;
   76.67 +    uint16_t count;
   76.68 +    uint32_t delay;
   76.69 +
   76.70 +    fp = fopen(fileName.c_str(), "rb");
   76.71 +    if (!fp)
   76.72 +    {
   76.73 +        syslog(LOG_ERR, "glcdgraphics: open %s failed (cGLCDFile::Load).", fileName.c_str());
   76.74 +        return false;
   76.75 +    }
   76.76 +
   76.77 +    // get len of file
   76.78 +    if (fseek(fp, 0, SEEK_END) != 0)
   76.79 +    {
   76.80 +        fclose(fp);
   76.81 +        return false;
   76.82 +    }
   76.83 +    fileSize = ftell(fp);
   76.84 +
   76.85 +    // rewind and get Header
   76.86 +    if (fseek(fp, 0, SEEK_SET) != 0)
   76.87 +    {
   76.88 +        fclose(fp);
   76.89 +        return false;
   76.90 +    }
   76.91 +
   76.92 +    // read header sign
   76.93 +    if (fread(sign, 4, 1, fp) != 1)
   76.94 +    {
   76.95 +        fclose(fp);
   76.96 +        return false;
   76.97 +    }
   76.98 +
   76.99 +    // check header sign
  76.100 +    if (strncmp(sign, kGLCDFileSign, 3) != 0)
  76.101 +    {
  76.102 +        syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
  76.103 +        fclose(fp);
  76.104 +        return false;
  76.105 +    }
  76.106 +
  76.107 +    // read width and height
  76.108 +    if (fread(buf, 4, 1, fp) != 1)
  76.109 +    {
  76.110 +        fclose(fp);
  76.111 +        return false;
  76.112 +    }
  76.113 +
  76.114 +    width = (buf[1] << 8) | buf[0];
  76.115 +    height = (buf[3] << 8) | buf[2];
  76.116 +    if (width == 0 || height == 0)
  76.117 +    {
  76.118 +        syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
  76.119 +        fclose(fp);
  76.120 +        return false;
  76.121 +    }
  76.122 +
  76.123 +    if (sign[3] == 'D')
  76.124 +    {
  76.125 +        count = 1;
  76.126 +        delay = 10;
  76.127 +        // check file length
  76.128 +        if (fileSize != (long) (height * ((width + 7) / 8) + 8))
  76.129 +        {
  76.130 +            syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong size (cGLCDFile::Load).", fileName.c_str());
  76.131 +            fclose(fp);
  76.132 +            return false;
  76.133 +        }
  76.134 +    }
  76.135 +    else if (sign[3] == 'A')
  76.136 +    {
  76.137 +        // read count and delay
  76.138 +        if (fread(buf, 6, 1, fp) != 1)
  76.139 +        {
  76.140 +            syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
  76.141 +            fclose(fp);
  76.142 +            return false;
  76.143 +        }
  76.144 +        count = (buf[1] << 8) | buf[0];
  76.145 +        delay = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2];
  76.146 +        // check file length
  76.147 +        if (count == 0 ||
  76.148 +            fileSize != (long) (count * (height * ((width + 7) / 8)) + 14))
  76.149 +        {
  76.150 +            syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong size (cGLCDFile::Load).", fileName.c_str());
  76.151 +            fclose(fp);
  76.152 +            return false;
  76.153 +        }
  76.154 +        // Set minimal limit for next image
  76.155 +        if (delay < 10)
  76.156 +            delay = 10;
  76.157 +    }
  76.158 +    else
  76.159 +    {
  76.160 +        syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
  76.161 +        fclose(fp);
  76.162 +        return false;
  76.163 +    }
  76.164 +
  76.165 +    image.Clear();
  76.166 +    image.SetWidth(width);
  76.167 +    image.SetHeight(height);
  76.168 +    image.SetDelay(delay);
  76.169 +    unsigned char * bmpdata = new unsigned char[height * ((width + 7) / 8)];
  76.170 +    if (bmpdata)
  76.171 +    {
  76.172 +        for (unsigned int n = 0; n < count; n++)
  76.173 +        {
  76.174 +            if (fread(bmpdata, height * ((width + 7) / 8), 1, fp) != 1)
  76.175 +            {
  76.176 +                delete[] bmpdata;
  76.177 +                fclose(fp);
  76.178 +                image.Clear();
  76.179 +                return false;
  76.180 +            }
  76.181 +            image.AddBitmap(new cBitmap(width, height, bmpdata));
  76.182 +        }
  76.183 +        delete[] bmpdata;
  76.184 +    }
  76.185 +    else
  76.186 +    {
  76.187 +        syslog(LOG_ERR, "glcdgraphics: malloc failed (cGLCDFile::Load).");
  76.188 +        fclose(fp);
  76.189 +        image.Clear();
  76.190 +        return false;
  76.191 +    }
  76.192 +    fclose(fp);
  76.193 +
  76.194 +    syslog(LOG_DEBUG, "glcdgraphics: image %s loaded.", fileName.c_str());
  76.195 +    return true;
  76.196 +}
  76.197 +
  76.198 +bool cGLCDFile::Save(cImage & image, const string & fileName)
  76.199 +{
  76.200 +    FILE * fp;
  76.201 +    uint8_t buf[14];
  76.202 +    uint16_t width;
  76.203 +    uint16_t height;
  76.204 +    uint16_t count;
  76.205 +    uint32_t delay;
  76.206 +    const cBitmap * bitmap;
  76.207 +    int i;
  76.208 +
  76.209 +    if (image.Count() == 0)
  76.210 +        return false;
  76.211 +
  76.212 +    fp = fopen(fileName.c_str(), "wb");
  76.213 +    if (!fp)
  76.214 +    {
  76.215 +        syslog(LOG_ERR, "glcdgraphics: open %s failed (cGLCDFile::Save).", fileName.c_str());
  76.216 +        return false;
  76.217 +    }
  76.218 +
  76.219 +    memcpy(buf, kGLCDFileSign, 3);
  76.220 +    count = image.Count();
  76.221 +    delay = image.Delay();
  76.222 +    if (count == 1)
  76.223 +    {
  76.224 +        buf[3] = 'D';
  76.225 +    }
  76.226 +    else
  76.227 +    {
  76.228 +        buf[3] = 'A';
  76.229 +    }
  76.230 +    bitmap = image.GetBitmap(0);
  76.231 +    width = bitmap->Width();
  76.232 +    height = bitmap->Height();
  76.233 +    buf[4] = (uint8_t) width;
  76.234 +    buf[5] = (uint8_t) (width >> 8);
  76.235 +    buf[6] = (uint8_t) height;
  76.236 +    buf[7] = (uint8_t) (height >> 8);
  76.237 +    if (count == 1)
  76.238 +    {
  76.239 +        if (fwrite(buf, 8, 1, fp) != 1)
  76.240 +        {
  76.241 +            fclose(fp);
  76.242 +            return false;
  76.243 +        }
  76.244 +    }
  76.245 +    else
  76.246 +    {
  76.247 +        buf[8] = (uint8_t) count;
  76.248 +        buf[9] = (uint8_t) (count >> 8);
  76.249 +        buf[10] = (uint8_t) delay;
  76.250 +        buf[11] = (uint8_t) (delay >> 8);
  76.251 +        buf[12] = (uint8_t) (delay >> 16);
  76.252 +        buf[13] = (uint8_t) (delay >> 24);
  76.253 +        if (fwrite(buf, 14, 1, fp) != 1)
  76.254 +        {
  76.255 +            fclose(fp);
  76.256 +            return false;
  76.257 +        }
  76.258 +    }
  76.259 +    for (i = 0; i < count; i++)
  76.260 +    {
  76.261 +        bitmap = image.GetBitmap(i);
  76.262 +        if (bitmap)
  76.263 +        {
  76.264 +            if (bitmap->Width() == width && bitmap->Height() == height)
  76.265 +            {
  76.266 +                if (fwrite(bitmap->Data(), height * ((width + 7) / 8), 1, fp) != 1)
  76.267 +                {
  76.268 +                    fclose(fp);
  76.269 +                    return false;
  76.270 +                }
  76.271 +            }
  76.272 +        }
  76.273 +    }
  76.274 +    fclose(fp);
  76.275 +
  76.276 +    syslog(LOG_DEBUG, "glcdgraphics: image %s saved.", fileName.c_str());
  76.277 +    return true;
  76.278 +}
  76.279 +
  76.280 +} // end of namespace
    77.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    77.2 +++ b/graphlcd-base/glcdgraphics/glcd.h	Wed Feb 06 17:32:55 2008 +0000
    77.3 @@ -0,0 +1,36 @@
    77.4 +/*
    77.5 + * GraphLCD graphics library
    77.6 + *
    77.7 + * glcd.h  -  GLCD file loading and saving
    77.8 + *
    77.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   77.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   77.11 + *
   77.12 + * This file is released under the GNU General Public License. Refer
   77.13 + * to the COPYING file distributed with this package.
   77.14 + *
   77.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   77.16 + */
   77.17 +
   77.18 +#ifndef _GLCDGRAPHICS_GLCD_H_
   77.19 +#define _GLCDGRAPHICS_GLCD_H_
   77.20 +
   77.21 +#include "imagefile.h"
   77.22 +
   77.23 +namespace GLCD
   77.24 +{
   77.25 +
   77.26 +class cImage;
   77.27 +
   77.28 +class cGLCDFile : public cImageFile
   77.29 +{
   77.30 +public:
   77.31 +    cGLCDFile();
   77.32 +    virtual ~cGLCDFile();
   77.33 +    virtual bool Load(cImage & image, const std::string & fileName);
   77.34 +    virtual bool Save(cImage & image, const std::string & fileName);
   77.35 +};
   77.36 +
   77.37 +} // end of namespace
   77.38 +
   77.39 +#endif
    78.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    78.2 +++ b/graphlcd-base/glcdgraphics/image.c	Wed Feb 06 17:32:55 2008 +0000
    78.3 @@ -0,0 +1,67 @@
    78.4 +/*
    78.5 + * GraphLCD graphics library
    78.6 + *
    78.7 + * image.c  -  image and animation handling
    78.8 + *
    78.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   78.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   78.11 + *
   78.12 + * This file is released under the GNU General Public License. Refer
   78.13 + * to the COPYING file distributed with this package.
   78.14 + *
   78.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   78.16 + */
   78.17 +
   78.18 +#include "bitmap.h"
   78.19 +#include "image.h"
   78.20 +
   78.21 +
   78.22 +namespace GLCD
   78.23 +{
   78.24 +
   78.25 +using namespace std;
   78.26 +
   78.27 +cImage::cImage()
   78.28 +:   width(0),
   78.29 +    height(0),
   78.30 +    delay(0),
   78.31 +    curBitmap(0),
   78.32 +    lastChange(0)
   78.33 +{
   78.34 +}
   78.35 +
   78.36 +cImage::~cImage()
   78.37 +{
   78.38 +    Clear();
   78.39 +}
   78.40 +
   78.41 +cBitmap * cImage::GetBitmap() const
   78.42 +{
   78.43 +    if (curBitmap < bitmaps.size())
   78.44 +        return bitmaps[curBitmap];
   78.45 +    return NULL;
   78.46 +}
   78.47 +
   78.48 +cBitmap * cImage::GetBitmap(unsigned int nr) const
   78.49 +{
   78.50 +    if (nr < bitmaps.size())
   78.51 +        return bitmaps[nr];
   78.52 +    return NULL;
   78.53 +}
   78.54 +
   78.55 +void cImage::Clear()
   78.56 +{
   78.57 +    vector <cBitmap *>::iterator it;
   78.58 +    for (it = bitmaps.begin(); it != bitmaps.end(); it++)
   78.59 +    {
   78.60 +        delete *it;
   78.61 +    }
   78.62 +    bitmaps.clear();
   78.63 +    width = 0;
   78.64 +    height = 0;
   78.65 +    delay = 0;
   78.66 +    curBitmap = 0;
   78.67 +    lastChange = 0;
   78.68 +}
   78.69 +
   78.70 +} // end of namespace
    79.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    79.2 +++ b/graphlcd-base/glcdgraphics/image.h	Wed Feb 06 17:32:55 2008 +0000
    79.3 @@ -0,0 +1,58 @@
    79.4 +/*
    79.5 + * GraphLCD graphics library
    79.6 + *
    79.7 + * image.h  -  image and animation handling
    79.8 + *
    79.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   79.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   79.11 + *
   79.12 + * This file is released under the GNU General Public License. Refer
   79.13 + * to the COPYING file distributed with this package.
   79.14 + *
   79.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   79.16 + */
   79.17 +
   79.18 +#ifndef _GLCDGRAPHICS_IMAGE_H_
   79.19 +#define _GLCDGRAPHICS_IMAGE_H_
   79.20 +
   79.21 +#include <stdint.h>
   79.22 +
   79.23 +#include <vector>
   79.24 +
   79.25 +namespace GLCD
   79.26 +{
   79.27 +
   79.28 +class cBitmap;
   79.29 +
   79.30 +class cImage
   79.31 +{
   79.32 +private:
   79.33 +    unsigned int width;
   79.34 +    unsigned int height;
   79.35 +    unsigned int delay;
   79.36 +    unsigned int curBitmap;
   79.37 +    uint64_t lastChange;
   79.38 +    std::vector <cBitmap *> bitmaps;
   79.39 +public:
   79.40 +    cImage();
   79.41 +    ~cImage();
   79.42 +
   79.43 +    unsigned int Width() const { return width; }
   79.44 +    unsigned int Height() const { return height; }
   79.45 +    unsigned int Count() const { return bitmaps.size(); }
   79.46 +    unsigned int Delay() const { return delay; }
   79.47 +    uint64_t LastChange() const { return lastChange; }
   79.48 +    void First(uint64_t t) { lastChange = t; curBitmap = 0; }
   79.49 +    bool Next(uint64_t t) { lastChange = t; curBitmap++; return curBitmap < bitmaps.size(); }
   79.50 +    void SetWidth(unsigned int Width) { width = Width; }
   79.51 +    void SetHeight(unsigned int Height) { height = Height; }
   79.52 +    void SetDelay(unsigned int d) { delay = d; }
   79.53 +    cBitmap * GetBitmap(unsigned int nr) const;
   79.54 +    cBitmap * GetBitmap() const;
   79.55 +    void AddBitmap(cBitmap * Bitmap) { bitmaps.push_back(Bitmap); }
   79.56 +    void Clear();
   79.57 +};
   79.58 +
   79.59 +} // end of namespace
   79.60 +
   79.61 +#endif
    80.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    80.2 +++ b/graphlcd-base/glcdgraphics/imagefile.c	Wed Feb 06 17:32:55 2008 +0000
    80.3 @@ -0,0 +1,35 @@
    80.4 +/*
    80.5 + * GraphLCD graphics library
    80.6 + *
    80.7 + * imagefile.h  -  base class for file loading and saving
    80.8 + *
    80.9 + * This file is released under the GNU General Public License. Refer
   80.10 + * to the COPYING file distributed with this package.
   80.11 + *
   80.12 + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de>
   80.13 + */
   80.14 +
   80.15 +#include "image.h"
   80.16 +#include "imagefile.h"
   80.17 +
   80.18 +namespace GLCD
   80.19 +{
   80.20 +
   80.21 +cImageFile::cImageFile(void)
   80.22 +{
   80.23 +}
   80.24 +cImageFile::~cImageFile(void)
   80.25 +{
   80.26 +}
   80.27 +
   80.28 +bool cImageFile::Load(cImage & image, const std::string & fileName)
   80.29 +{
   80.30 +    return false;
   80.31 +}
   80.32 +
   80.33 +bool cImageFile::Save(cImage & image, const std::string & fileName)
   80.34 +{
   80.35 +    return false;
   80.36 +}
   80.37 +
   80.38 +} // end of namespace
    81.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    81.2 +++ b/graphlcd-base/glcdgraphics/imagefile.h	Wed Feb 06 17:32:55 2008 +0000
    81.3 @@ -0,0 +1,33 @@
    81.4 +/*
    81.5 + * GraphLCD graphics library
    81.6 + *
    81.7 + * imagefile.h  -  base class for file loading and saving
    81.8 + *
    81.9 + * This file is released under the GNU General Public License. Refer
   81.10 + * to the COPYING file distributed with this package.
   81.11 + *
   81.12 + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de>
   81.13 + */
   81.14 +
   81.15 +#ifndef _GLCDGRAPHICS_IMAGEFILE_H_
   81.16 +#define _GLCDGRAPHICS_IMAGEFILE_H_
   81.17 +
   81.18 +#include <string>
   81.19 +
   81.20 +namespace GLCD
   81.21 +{
   81.22 +
   81.23 +class cImage;
   81.24 +
   81.25 +class cImageFile
   81.26 +{
   81.27 +public:
   81.28 +    cImageFile();
   81.29 +    virtual ~cImageFile();
   81.30 +    virtual bool Load(cImage & image, const std::string & fileName);
   81.31 +    virtual bool Save(cImage & image, const std::string & fileName);
   81.32 +};
   81.33 +
   81.34 +} // end of namespace
   81.35 +
   81.36 +#endif
    82.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    82.2 +++ b/graphlcd-base/glcdgraphics/pbm.c	Wed Feb 06 17:32:55 2008 +0000
    82.3 @@ -0,0 +1,187 @@
    82.4 +/*
    82.5 + * GraphLCD graphics library
    82.6 + *
    82.7 + * pbm.c  -  PBM file loading and saving
    82.8 + *
    82.9 + * This file is released under the GNU General Public License. Refer
   82.10 + * to the COPYING file distributed with this package.
   82.11 + *
   82.12 + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de>
   82.13 + */
   82.14 +
   82.15 +#include <stdio.h>
   82.16 +#include <stdint.h>
   82.17 +#include <syslog.h>
   82.18 +
   82.19 +#include <string>
   82.20 +
   82.21 +#include "bitmap.h"
   82.22 +#include "pbm.h"
   82.23 +#include "image.h"
   82.24 +
   82.25 +
   82.26 +namespace GLCD
   82.27 +{
   82.28 +
   82.29 +cPBMFile::cPBMFile()
   82.30 +{
   82.31 +}
   82.32 +
   82.33 +cPBMFile::~cPBMFile()
   82.34 +{
   82.35 +}
   82.36 +
   82.37 +bool cPBMFile::Load(cImage & image, const std::string & fileName)
   82.38 +{
   82.39 +    FILE * pbmFile;
   82.40 +    char str[32];
   82.41 +    int i;
   82.42 +    int ch;
   82.43 +    int w;
   82.44 +    int h;
   82.45 +
   82.46 +    pbmFile = fopen(fileName.c_str(), "rb");
   82.47 +    if (!pbmFile)
   82.48 +        return false;
   82.49 +
   82.50 +    i = 0;
   82.51 +    while ((ch = getc(pbmFile)) != EOF && i < 31)
   82.52 +    {
   82.53 +        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
   82.54 +            break;
   82.55 +        str[i] = ch;
   82.56 +        i++;
   82.57 +    }
   82.58 +    if (ch == EOF)
   82.59 +    {
   82.60 +        fclose(pbmFile);
   82.61 +        return false;
   82.62 +    }
   82.63 +    str[i] = 0;
   82.64 +    if (strcmp(str, "P4") != 0)
   82.65 +        return false;
   82.66 +
   82.67 +    while ((ch = getc(pbmFile)) == '#')
   82.68 +    {
   82.69 +        while ((ch = getc(pbmFile)) != EOF)
   82.70 +        {
   82.71 +            if (ch == '\n' || ch == '\r')
   82.72 +                break;
   82.73 +        }
   82.74 +    }
   82.75 +    if (ch == EOF)
   82.76 +    {
   82.77 +        fclose(pbmFile);
   82.78 +        return false;
   82.79 +    }
   82.80 +    i = 0;
   82.81 +    str[i] = ch;
   82.82 +    i += 1;
   82.83 +    while ((ch = getc(pbmFile)) != EOF && i < 31)
   82.84 +    {
   82.85 +        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
   82.86 +            break;
   82.87 +        str[i] = ch;
   82.88 +        i++;
   82.89 +    }
   82.90 +    if (ch == EOF)
   82.91 +    {
   82.92 +        fclose(pbmFile);
   82.93 +        return false;
   82.94 +    }
   82.95 +    str[i] = 0;
   82.96 +    w = atoi(str);
   82.97 +
   82.98 +    i = 0;
   82.99 +    while ((ch = getc(pbmFile)) != EOF && i < 31)
  82.100 +    {
  82.101 +        if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
  82.102 +            break;
  82.103 +        str[i] = ch;
  82.104 +        i++;
  82.105 +    }
  82.106 +    if (ch == EOF)
  82.107 +    {
  82.108 +        fclose(pbmFile);
  82.109 +        return false;
  82.110 +    }
  82.111 +    str[i] = 0;
  82.112 +    h = atoi(str);
  82.113 +
  82.114 +    image.Clear();
  82.115 +    image.SetWidth(w);
  82.116 +    image.SetHeight(h);
  82.117 +    image.SetDelay(100);
  82.118 +    unsigned char * bmpdata = new unsigned char[h * ((w + 7) / 8)];
  82.119 +    if (bmpdata)
  82.120 +    {
  82.121 +        if (fread(bmpdata, h * ((w + 7) / 8), 1, pbmFile) != 1)
  82.122 +        {
  82.123 +            delete[] bmpdata;
  82.124 +            fclose(pbmFile);
  82.125 +            image.Clear();
  82.126 +            return false;
  82.127 +        }
  82.128 +        image.AddBitmap(new cBitmap(w, h, bmpdata));
  82.129 +        delete[] bmpdata;
  82.130 +    }
  82.131 +    else
  82.132 +    {
  82.133 +        syslog(LOG_ERR, "glcdgraphics: malloc failed (cPBMFile::Load).");
  82.134 +        fclose(pbmFile);
  82.135 +        return false;
  82.136 +    }
  82.137 +    fclose(pbmFile);
  82.138 +    syslog(LOG_DEBUG, "glcdgraphics: image %s loaded.", fileName.c_str());
  82.139 +
  82.140 +    return true;
  82.141 +}
  82.142 +
  82.143 +bool cPBMFile::Save(cImage & image, const std::string & fileName)
  82.144 +{
  82.145 +    FILE * fp;
  82.146 +    char str[32];
  82.147 +    const cBitmap * bitmap;
  82.148 +
  82.149 +    if (image.Count() == 1)
  82.150 +    {
  82.151 +        fp = fopen(fileName.c_str(), "wb");
  82.152 +        if (fp)
  82.153 +        {
  82.154 +            bitmap = image.GetBitmap(0);
  82.155 +            if (bitmap)
  82.156 +            {
  82.157 +                sprintf(str, "P4\n%d %d\n", bitmap->Width(), bitmap->Height());
  82.158 +                fwrite(str, strlen(str), 1, fp);
  82.159 +                fwrite(bitmap->Data(), bitmap->LineSize() * bitmap->Height(), 1, fp);
  82.160 +            }
  82.161 +            fclose(fp);
  82.162 +        }
  82.163 +    }
  82.164 +    else
  82.165 +    {
  82.166 +        uint16_t i;
  82.167 +        char tmpStr[256];
  82.168 +
  82.169 +        for (i = 0; i < image.Count(); i++)
  82.170 +        {
  82.171 +            sprintf(tmpStr, "%.248s.%05d", fileName.c_str(), i);
  82.172 +            fp = fopen(tmpStr, "wb");
  82.173 +            if (fp)
  82.174 +            {
  82.175 +                bitmap = image.GetBitmap(i);
  82.176 +                if (bitmap)
  82.177 +                {
  82.178 +                    sprintf(str, "P4\n%d %d\n", bitmap->Width(), bitmap->Height());
  82.179 +                    fwrite(str, strlen(str), 1, fp);
  82.180 +                    fwrite(bitmap->Data(), bitmap->LineSize() * bitmap->Height(), 1, fp);
  82.181 +                }
  82.182 +                fclose(fp);
  82.183 +            }
  82.184 +        }
  82.185 +    }
  82.186 +    return true;
  82.187 +}
  82.188 +
  82.189 +} // end of namespace
  82.190 +
    83.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    83.2 +++ b/graphlcd-base/glcdgraphics/pbm.h	Wed Feb 06 17:32:55 2008 +0000
    83.3 @@ -0,0 +1,34 @@
    83.4 +/*
    83.5 + * GraphLCD graphics library
    83.6 + *
    83.7 + * pbm.h  - PBM file loading and saving
    83.8 + *
    83.9 + * This file is released under the GNU General Public License. Refer
   83.10 + * to the COPYING file distributed with this package.
   83.11 + *
   83.12 + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de>
   83.13 + */
   83.14 +
   83.15 +#ifndef _GLCDGRAPHICS_PBM_H_
   83.16 +#define _GLCDGRAPHICS_PBM_H_
   83.17 +
   83.18 +#include "imagefile.h"
   83.19 +
   83.20 +namespace GLCD
   83.21 +{
   83.22 +
   83.23 +class cImage;
   83.24 +
   83.25 +class cPBMFile : public cImageFile
   83.26 +{
   83.27 +public:
   83.28 +    cPBMFile();
   83.29 +    virtual ~cPBMFile();
   83.30 +    virtual bool Load(cImage & image, const std::string & fileName);
   83.31 +    virtual bool Save(cImage & image, const std::string & fileName);
   83.32 +};
   83.33 +
   83.34 +} // end of namespace
   83.35 +
   83.36 +#endif
   83.37 +
    84.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    84.2 +++ b/graphlcd-base/graphlcd.conf	Wed Feb 06 17:32:55 2008 +0000
    84.3 @@ -0,0 +1,528 @@
    84.4 +# graphlcd.conf.sample
    84.5 +#
    84.6 +# This file contains a sample configuration for the graphlcd driver
    84.7 +# library.
    84.8 +# 
    84.9 +# The format is ini-file-like. It is divided into sections that start
   84.10 +# at markers that look like [section]. Comments are all line-based
   84.11 +# comments, and are lines that start with '#'.
   84.12 +#
   84.13 +# The file starts with general settings, that are used by several
   84.14 +# drivers, followed by the sections. Each section represents a single
   84.15 +# display with a driver definition and specific settings which define
   84.16 +# how the driver acts. Some of these parameters like device, port and
   84.17 +# size are already parsed by the library but the drivers can also read
   84.18 +# their own options from the config file. The library passes them to
   84.19 +# the drivers.
   84.20 +
   84.21 +# WaitMethod
   84.22 +#  Select the method that is used for sleeping.
   84.23 +#  Possible values:
   84.24 +#   0 - usleep
   84.25 +#   1 - nanosleep
   84.26 +#   2 - nanosleep (sched_rr) - This is recommended on kernel 2.4 systems
   84.27 +#   3 - gettimeofday - This is recommended on kernel 2.6 systems
   84.28 +#  Defaukt value: 3
   84.29 +WaitMethod=3
   84.30 +
   84.31 +# WaitPriority
   84.32 +#  Select the process priority that is used when sleeping.
   84.33 +#  Possible values: -20 <= x <= 19
   84.34 +#  Default value: 0
   84.35 +WaitPriority=0
   84.36 +
   84.37 +# General driver settings
   84.38 +#  This section lists the display settings that are parsed and
   84.39 +#  recognized by the driver library.
   84.40 +#
   84.41 +# Driver
   84.42 +#  Sets the display's driver.
   84.43 +#  Currently available are: framebuffer, gu140x32f, gu256x64-372,
   84.44 +#                           gu256x64C-3xx0, hd61830, image, ks0108,
   84.45 +#                           sed1520, sed1330, simlcd, t6963c,
   84.46 +#                           gu126x64D-K610A4
   84.47 +#
   84.48 +# Device
   84.49 +#  Instead of using the direct output via port address (see Port), you
   84.50 +#  can use the parport device (/dev/parportX). The advantage over the
   84.51 +#  direct output via port address is that this works for non-root users
   84.52 +#  also. But it's a little bit slower. The modules ppdev.o, parport.o
   84.53 +#  and parport_pc.o must be loaded or compiled into the kernel.
   84.54 +#
   84.55 +# Port
   84.56 +#  Sets the port address of the parallel port. If this parameter is not
   84.57 +#  given, 0x378 is used. To use this direct output, the program that
   84.58 +#  uses the driver library has to be started with user 'root'.
   84.59 +#
   84.60 +# Width
   84.61 +#  Sets the horizontal size of the display. If this parameter is not
   84.62 +#  given, a default one specific to the driver is used.
   84.63 +#
   84.64 +# Height
   84.65 +#  Sets the vertical size of the display. If this parameter is not
   84.66 +#  given, a default one specific to the driver is used.
   84.67 +#
   84.68 +# UpsideDown
   84.69 +#  Rotates the display output by 180 degrees. This might be useful, if
   84.70 +#  the LCD is mounted upside-down.
   84.71 +#  Possible values: 'yes', 'no'
   84.72 +#  Default value: 'no'
   84.73 +#
   84.74 +# Invert
   84.75 +#  Inverts the display.
   84.76 +#  Possible values: 'yes', 'no'
   84.77 +#  Default value: 'no'
   84.78 +#
   84.79 +# Brightness
   84.80 +#  Sets the brightness of your display's backlight if supported by its
   84.81 +#  driver.
   84.82 +#  Supported by: gu140x32f, gu256x64-372, gu256x64-3900, gu126x64D-K610A4
   84.83 +#  Possible values: 0 <= x <= 100)
   84.84 +#  Default value: 100
   84.85 +#
   84.86 +# Contrast
   84.87 +#  Sets the contrast of your display if supported by its driver.
   84.88 +#  Supported by: serdisplib
   84.89 +#  Possible values: 0 <= x <= 10
   84.90 +#  Default value: 5
   84.91 +#
   84.92 +# Backlight
   84.93 +#  Switches the backlight of your display on and off if supported by
   84.94 +#  its driver.
   84.95 +#  Supported by: serdisplib
   84.96 +#  Possible values: 'yes', 'no'
   84.97 +#  Default value: 'yes'
   84.98 +#
   84.99 +# AdjustTiming
  84.100 +#  To get a timing that is as accurate as possible, the drivers measure
  84.101 +#  the time for port commands (see: benchmark in syslog). You might
  84.102 +#  decrease or increase the time to wait after port commands with this
  84.103 +#  parameter. Normally, there is no need to change this parameter.
  84.104 +#  (used by gu140x32f, gu256x64-372, gu256x64-3900, hd61830, ks0108,
  84.105 +#   sed1330, sed1520, gu126x64D-K610A4)
  84.106 +#  Possible values: -50 <= x <= 50
  84.107 +#  Default value: 0
  84.108 +#
  84.109 +# RefreshDisplay
  84.110 +#  Normally, most of the drivers do not update the whole display, but
  84.111 +#  only the areas that have changed since last update. So it might be,
  84.112 +#  that some faulty pixels would stay a longer time. To avoid this, the
  84.113 +#  plugin makes a complete refresh from time to time. This parameter
  84.114 +#  defines how often a complete refresh will be done.
  84.115 +#  e.g.: A value of 5 means, that the plugin will make a complete
  84.116 +#        refresh on every 5th update.
  84.117 +#  A value of 0 completely disables complete refreshs. 
  84.118 +#  Possible values: 0 <= x <= 50
  84.119 +#  Default value: 5
  84.120 +
  84.121 +########################################################################
  84.122 +
  84.123 +[framebuffer]
  84.124 +# framebuffer driver
  84.125 +#  Output goes to a framebuffer device
  84.126 +#  Default size: 320 x 240
  84.127 +Driver=framebuffer
  84.128 +
  84.129 +#Width=320
  84.130 +#Height=240
  84.131 +#UpsideDown=no
  84.132 +#Invert=no
  84.133 +
  84.134 +# Zoom
  84.135 +#  Determines if pixels should be drawn double sized.
  84.136 +#  Possible values: 0, 1
  84.137 +Zoom=1
  84.138 +
  84.139 +########################################################################
  84.140 +
  84.141 +[gu140x32f]
  84.142 +# gu140x32f driver
  84.143 +#  This is an 8-bit driver module for Noritake GU140x32-F7806 VFD
  84.144 +#  displays. The VFD is operating in it's 8 bit-mode connected to a
  84.145 +#  single PC parallel port.
  84.146 +#  Default size: 140 x 32
  84.147 +Driver=gu140x32f
  84.148 +
  84.149 +Port=0x378
  84.150 +#Device=/dev/parport0
  84.151 +#Width=140
  84.152 +#Height=32
  84.153 +#UpsideDown=no
  84.154 +#Invert=no
  84.155 +#Brightness=100
  84.156 +#AdjustTiming=0
  84.157 +#RefreshDisplay=1
  84.158 +
  84.159 +# Wiring
  84.160 +#  Select the type of wiring your display is connected with.
  84.161 +#  Possible values: 'Standard', 'Windows'
  84.162 +#  Default value: 'Standard'
  84.163 +Wiring=Standard
  84.164 +
  84.165 +########################################################################
  84.166 +
  84.167 +[gu256x64-372]
  84.168 +# gu256x64-372 driver
  84.169 +#  This is an 8-bit driver module for Noritake GU256x64-372 VFD
  84.170 +#  displays. The VFD is operating in it's 8 bit-mode connected to a
  84.171 +#  single PC parallel port.
  84.172 +#  Default size: 256 x 64
  84.173 +Driver=gu256x64-372
  84.174 +
  84.175 +Port=0x378
  84.176 +#Device=/dev/parport0
  84.177 +#Width=256
  84.178 +#Height=64
  84.179 +#UpsideDown=no
  84.180 +#Invert=no
  84.181 +#Brightness=100
  84.182 +#AdjustTiming=0
  84.183 +#RefreshDisplay=1
  84.184 +
  84.185 +########################################################################
  84.186 +
  84.187 +[gu256x64-3900]
  84.188 +# gu256x64-3900 driver
  84.189 +#  This is a driver module for Noritake GU256X64x-3900 VFD displays. The
  84.190 +#  VFD is either operating in 8 bit-mode connected to a single PC
  84.191 +#  parallel port or in serial mode connected to a single PC serial port.
  84.192 +#  Default size: 256 x 64
  84.193 +Driver=gu256x64-3900
  84.194 +
  84.195 +Port=0x378
  84.196 +#Device=/dev/parport0
  84.197 +#Width=256
  84.198 +#Height=64
  84.199 +#UpsideDown=no
  84.200 +#Invert=no
  84.201 +#Brightness=100
  84.202 +#AdjustTiming=0
  84.203 +#RefreshDisplay=1
  84.204 +
  84.205 +# Wiring
  84.206 +#  Select the type of wiring your display is connected with.
  84.207 +#  Possible values: 'Standard', 'Satyr'
  84.208 +#  Default value: 'Standard'
  84.209 +Wiring=Standard
  84.210 +
  84.211 +# Interface
  84.212 +#  Select the interface your display is connnected to.
  84.213 +#  Possible values: 'Parallel', 'Serial'
  84.214 +#  Default value: 'Parallel'
  84.215 +Interface=Parallel
  84.216 +
  84.217 +# DMA
  84.218 +#  Enables/disables the usage of the controller's DMA mode which
  84.219 +#  increases writing speed. This only works in parallel interface mode.
  84.220 +#  Possible values: 'yes', 'no'
  84.221 +#  Default value: 'yes'
  84.222 +DMA=yes
  84.223 +
  84.224 +########################################################################
  84.225 +
  84.226 +[gu126x64D-K610A4]
  84.227 +# GU126x64D-K610A4 driver
  84.228 +#  This is a driver module for Noritake GU126x64D-K610A4 VFD displays. 
  84.229 +#  The VFD is operating in 8 bit-mode connected to a single PC
  84.230 +#  parallel port.
  84.231 +#  Default size: 126 x 64
  84.232 +Driver=gu126x64D-K610A4
  84.233 +
  84.234 +Port=0x378
  84.235 +# Device=/dev/parport0
  84.236 +
  84.237 +#Width=126
  84.238 +#Height=64
  84.239 +#UpsideDown=no
  84.240 +#Invert=no
  84.241 +#Brightness=100
  84.242 +#RefreshDisplay=1
  84.243 +#AdjustTiming=30
  84.244 +
  84.245 +#  Debug some methods of the driver
  84.246 +#  (add the values of interest)
  84.247 +#
  84.248 +#   1: show a log at the start of a refresh
  84.249 +#   2: show a log at the end of a refresh with timing information
  84.250 +#   4: show the rows (8 pixel) refreshed
  84.251 +#   8: show every commands/bytes sent to the display
  84.252 +#  16: log every unsuccessful waiting for display acknowledge
  84.253 +#
  84.254 +#Debug=0
  84.255 +
  84.256 +########################################################################
  84.257 +
  84.258 +[hd61830]
  84.259 +# hd61830 driver
  84.260 +#  This is a driver module for the Hitachi HD61830 LCD controller.
  84.261 +#  Default size: 240 x 128
  84.262 +Driver=hd61830
  84.263 +Port=0x378
  84.264 +#Device=/dev/parport0
  84.265 +#Width=240
  84.266 +#Height=128
  84.267 +#UpsideDown=no
  84.268 +#Invert=no
  84.269 +#AdjustTiming=0
  84.270 +#RefreshDisplay=1
  84.271 +
  84.272 +########################################################################
  84.273 +
  84.274 +[image]
  84.275 +# image driver
  84.276 +#  This is a driver module for writing image sequences in PBM (Portable
  84.277 +#  Bit Map) format that show the plugin's output.
  84.278 +#  Default size: 240 x 128
  84.279 +Driver=image
  84.280 +#Width=240
  84.281 +#Height=128
  84.282 +#UpsideDown=no
  84.283 +#Invert=no
  84.284 +
  84.285 +########################################################################
  84.286 +
  84.287 +[ks0108]
  84.288 +# ks0108 driver
  84.289 +#  This is a driver module for the Samsung KS0108 LCD controller.
  84.290 +#  Default size: 128 x 64
  84.291 +Driver=ks0108
  84.292 +Port=0x378
  84.293 +#Device=/dev/parport0
  84.294 +#Width=128
  84.295 +#Height=64
  84.296 +#UpsideDown=no
  84.297 +#Invert=no
  84.298 +#AdjustTiming=0
  84.299 +#RefreshDisplay=1
  84.300 +
  84.301 +# Control
  84.302 +#  Select the variant of triggering the display's control lines.
  84.303 +#  Possible values: '0', '1'
  84.304 +#  Default value: '1'
  84.305 +Control=1
  84.306 +
  84.307 +########################################################################
  84.308 +
  84.309 +[sed1330]
  84.310 +# sed1330 driver
  84.311 +#  This is a driver module for the Epson SED1330/1335 LCD controller.
  84.312 +#  Default size: 320 x 240
  84.313 +Driver=sed1330
  84.314 +Port=0x378
  84.315 +#Device=/dev/parport0
  84.316 +#Width=320
  84.317 +#Height=240
  84.318 +#UpsideDown=no
  84.319 +#Invert=no
  84.320 +#AdjustTiming=0
  84.321 +#refreshDisplay=1
  84.322 +
  84.323 +# Wiring
  84.324 +#  Select the type of wiring your display is connected with.
  84.325 +#  Possible values: 'Original', 'PowerLCD', 'LCDProc', 'Tweakers',
  84.326 +#                   'YASEDW'
  84.327 +#  Default value: 'Original'
  84.328 +Wiring=Original
  84.329 +
  84.330 +# OscillatorFrequency
  84.331 +#  Select the frequency the oscillator on your LCD board uses in kHz.
  84.332 +#  Possible values: 1000 <= x <= 15000)
  84.333 +#  Default value: 9600
  84.334 +OscillatorFrequency=9600
  84.335 +
  84.336 +# Interface
  84.337 +#  Select the interface mode your display is connected with.
  84.338 +#  Possible values: '6800', '8080'
  84.339 +#  Default value: '6800'
  84.340 +Interface=6800
  84.341 +
  84.342 +########################################################################
  84.343 +
  84.344 +[sed1520]
  84.345 +# sed1520 driver
  84.346 +#  This is a driver module for the Epson SED1520 LCD controller.
  84.347 +#  Default size: 120 x 32
  84.348 +Driver=sed1520
  84.349 +Port=0x378
  84.350 +#Device=/dev/parport0
  84.351 +#Width=120
  84.352 +#Height=32
  84.353 +#UpsideDown=no
  84.354 +#Invert=no
  84.355 +#AdjustTiming=0
  84.356 +#RefreshDisplay=1
  84.357 +
  84.358 +########################################################################
  84.359 +
  84.360 +[simlcd]
  84.361 +# simlcd driver
  84.362 +#  This is the SimLCD driver module. Output goes to a file instead of
  84.363 +#  LCD. Use SimLCD tool to view this file.
  84.364 +#  Default size: 240 x 128
  84.365 +Driver=simlcd
  84.366 +#Width=240
  84.367 +#Height=128
  84.368 +#UpsideDown=no
  84.369 +#Invert=no
  84.370 +
  84.371 +########################################################################
  84.372 +
  84.373 +[t6963c]
  84.374 +# t6963c driver
  84.375 +#  This is a driver module for the Toshiba T6963C LCD controller.
  84.376 +#  Default size: 240 x 128
  84.377 +Driver=t6963c
  84.378 +Port=0x378
  84.379 +#Device=/dev/parport0
  84.380 +#Width=240
  84.381 +#Height=128
  84.382 +#UpsideDown=no
  84.383 +#Invert=no
  84.384 +#RefreshDisplay=1
  84.385 +
  84.386 +# Wiring
  84.387 +#  Select the type of wiring your display is connected with.
  84.388 +#  Possible values: 'Standard', 'Windows', 'Serial'
  84.389 +#  Default value: 'Standard'
  84.390 +Wiring=Standard
  84.391 +
  84.392 +# FontSelect
  84.393 +#  Select the font width your display uses for text mode. In most cases
  84.394 +#  this is selectable through one of the pins of your LCD board
  84.395 +#  Possible values: '6', '8'
  84.396 +#  Default value: '6'
  84.397 +FontSelect=6
  84.398 +
  84.399 +# AutoMode
  84.400 +#  Enables or disables the usage of T6963C's auto mode which doubles
  84.401 +#  writing speed when enabled.
  84.402 +#  Possible values: 'yes', 'no'
  84.403 +#  Default value: 'yes'
  84.404 +AutoMode=yes
  84.405 +
  84.406 +# StatusCheck
  84.407 +#  Enables or disables the usage of T6963C's status check. When using a
  84.408 +#  shielded cable for connecting your display, the disabling may be
  84.409 +#  possible. This results in doubling the speed of writing data to the
  84.410 +#  LCD.
  84.411 +#  Possible values: 'yes', 'no'
  84.412 +#  Default value: 'yes'
  84.413 +StatusCheck=yes
  84.414 +
  84.415 +########################################################################
  84.416 +
  84.417 +[serdisp]
  84.418 +Driver=serdisp
  84.419 +# Controller
  84.420 +#  Select the serdisplib name of your display.
  84.421 +#  Possible values: See README in serdisplib package or http://serdisplib.sourceforge.net
  84.422 +#Controller=nokia7110
  84.423 +#Controller=sed1335
  84.424 +Controller=optrex323
  84.425 +
  84.426 +# Options
  84.427 +#  Pass display specific options
  84.428 +#  Possible values: See driver-specific hardware page at http://serdisplib.sourceforge.net
  84.429 +#
  84.430 +#  IMPORTANT: when using generic controllers like sed1330,sed1335,t6963c, width and height
  84.431 +#             need to be set here (if different from default settings)!
  84.432 +#             (serdisplib needs to be extended to be able to use 'Width' and 'Height'
  84.433 +#              settings directly - this will be added later)
  84.434 +#
  84.435 +#Options=MODE=8080
  84.436 +#Options=DELAY=2000;FONTWIDTH=8;CHECK=1
  84.437 +#Options=WIDTH=128;HEIGHT=64
  84.438 +#Options=WIDTH=128;HEIGHT=64;DELAY=2000;FONTWIDTH=8;CHECK=1
  84.439 +
  84.440 +# Wiring
  84.441 +#  Select Wiring
  84.442 +#  Possible values: See driver-specific hardware page at http://serdisplib.sourceforge.net
  84.443 +#Wiring=1
  84.444 +#Wiring=PowerLCD
  84.445 +#Wiring=DATA8,CS:nAUTO,A0:INIT,WR:nSTRB,RD:nSELIN
  84.446 +
  84.447 +# FGColour
  84.448 +#  Drawing colour for non-monochrome displays
  84.449 +#  Possible values: 0xRRGGBB (eg.: 0xFF0000)
  84.450 +#  Defaults to black (0x000000) if not set
  84.451 +#FGColour=0x000000
  84.452 +
  84.453 +# BGColour
  84.454 +#  Background colour for non-monochrome displays
  84.455 +#  Possible values: 0xRRGGBB (eg.: 0x00FFFF)
  84.456 +#  Defaults to white (0xFFFFFF) if not set
  84.457 +#BGColour=0xFFFFFF
  84.458 +
  84.459 +Port=0x378
  84.460 +#Device=/dev/parport0
  84.461 +#UpsideDown=no
  84.462 +#Invert=no
  84.463 +Contrast=5
  84.464 +Backlight=yes
  84.465 +
  84.466 +# Settings 'Width' and 'Height' are ignored at the moment. For generic controllers # (sed1330/1335, t6963) width and height need to be set using setting 'Options' (look above)
  84.467 +##Width=240
  84.468 +##Height=128
  84.469 +
  84.470 +########################################################################
  84.471 +
  84.472 +[noritake800]
  84.473 +# noritake800 driver
  84.474 +#  This is an 8-bit driver module for Noritake Noritake 800(A) series VFD
  84.475 +#  displays. The VFD is operating in it's 8 bit-mode connected to a
  84.476 +#  single PC parallel port.
  84.477 +#  Default size: 128 x 64
  84.478 +Driver=noritake800
  84.479 +Port=0x378
  84.480 +#Device=/dev/parport0
  84.481 +Width=128
  84.482 +Height=64
  84.483 +#UpsideDown=no
  84.484 +#Invert=no
  84.485 +Brightness=50
  84.486 +#AdjustTiming=0		# not used
  84.487 +#RefreshDisplay=0	# not used
  84.488 +
  84.489 +# Wiring
  84.490 +#  Select the type of wiring your display is connected with.
  84.491 +#  Possible values: 'LiquidMp3', 'MZ'
  84.492 +#  Default value: 'LiquidMp3'
  84.493 +Wiring=LiquidMp3
  84.494 +
  84.495 +########################################################################
  84.496 +
  84.497 +[avrctl]
  84.498 +# avrctl driver
  84.499 +#  This is an driver module for my AVR controlled LCD display connected via
  84.500 +#  USB port. It uses some simple commands to update the display content.
  84.501 +#  Default size: 256 x 128
  84.502 +Driver=avrctl
  84.503 +Device=/dev/ttyUSB0
  84.504 +Width=256
  84.505 +Height=128
  84.506 +#UpsideDown=no
  84.507 +#Invert=no
  84.508 +Brightness=50
  84.509 +RefreshDisplay=1
  84.510 +
  84.511 +########################################################################
  84.512 +
  84.513 +[g15daemon]
  84.514 +# pseudo device for the g15daemon meta driver
  84.515 +# Output goes to the g15daemon which then displays it
  84.516 +Driver=g15daemon
  84.517 +Width=160
  84.518 +Height=43
  84.519 +
  84.520 +########################################################################
  84.521 +
  84.522 +[network]
  84.523 +# network driver
  84.524 +#  Default size: 240 x 128
  84.525 +Driver=network
  84.526 +Width=256
  84.527 +Height=128
  84.528 +UpsideDown=no
  84.529 +Invert=no
  84.530 +Brightness=10
  84.531 +RefreshDisplay=1
    85.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    85.2 +++ b/graphlcd-base/tools/Makefile	Wed Feb 06 17:32:55 2008 +0000
    85.3 @@ -0,0 +1,47 @@
    85.4 +#
    85.5 +# Makefile for the graphlcd tools
    85.6 +#
    85.7 +
    85.8 +
    85.9 +-include ../Make.config
   85.10 +
   85.11 +### Targets:
   85.12 +
   85.13 +all:
   85.14 +	@$(MAKE) -C convpic all
   85.15 +	@$(MAKE) -C crtfont all
   85.16 +ifdef HAVE_FREETYPE2
   85.17 +	@$(MAKE) -C genfont all
   85.18 +endif
   85.19 +	@$(MAKE) -C showpic all
   85.20 +	@$(MAKE) -C showtext all
   85.21 +	@$(MAKE) -C lcdtestpattern all
   85.22 +
   85.23 +install:
   85.24 +	@$(MAKE) -C convpic install
   85.25 +	@$(MAKE) -C crtfont install
   85.26 +ifdef HAVE_FREETYPE2
   85.27 +	@$(MAKE) -C genfont install
   85.28 +endif
   85.29 +	@$(MAKE) -C showpic install
   85.30 +	@$(MAKE) -C showtext install
   85.31 +	@$(MAKE) -C lcdtestpattern install
   85.32 +
   85.33 +uninstall:
   85.34 +	@$(MAKE) -C convpic uninstall
   85.35 +	@$(MAKE) -C crtfont uninstall
   85.36 +ifdef HAVE_FREETYPE2
   85.37 +	@$(MAKE) -C genfont uninstall
   85.38 +endif
   85.39 +	@$(MAKE) -C showpic uninstall
   85.40 +	@$(MAKE) -C showtext uninstall
   85.41 +	@$(MAKE) -C lcdtestpattern uninstall
   85.42 + 
   85.43 +clean:
   85.44 +	@$(MAKE) -C convpic clean
   85.45 +	@$(MAKE) -C crtfont clean
   85.46 +	@$(MAKE) -C genfont clean
   85.47 +	@$(MAKE) -C showpic clean
   85.48 +	@$(MAKE) -C showtext clean
   85.49 +	@$(MAKE) -C lcdtestpattern clean
   85.50 +
    86.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    86.2 +++ b/graphlcd-base/tools/convpic/Makefile	Wed Feb 06 17:32:55 2008 +0000
    86.3 @@ -0,0 +1,46 @@
    86.4 +#
    86.5 +# Makefile for the GraphLCD tool convpic
    86.6 +#
    86.7 +
    86.8 +-include ../../Make.config
    86.9 +
   86.10 +PRGNAME = convpic
   86.11 +
   86.12 +OBJS = $(PRGNAME).o bmp.o tiff.o tuxbox.o
   86.13 +
   86.14 +INCLUDES += -I../../
   86.15 +LIBDIRS += -L../../glcdgraphics/
   86.16 +
   86.17 +
   86.18 +all: $(PRGNAME)
   86.19 +.PHONY: all
   86.20 +
   86.21 +# Implicit rules:
   86.22 +
   86.23 +%.o: %.c
   86.24 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
   86.25 +
   86.26 +# Dependencies:
   86.27 +
   86.28 +MAKEDEP = $(CXX) -MM -MG
   86.29 +DEPFILE = .dependencies
   86.30 +$(DEPFILE): Makefile
   86.31 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
   86.32 +
   86.33 +-include $(DEPFILE)
   86.34 +
   86.35 +# The main program:
   86.36 +
   86.37 +$(PRGNAME): $(OBJS)
   86.38 +	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lstdc++ -o $(PRGNAME)
   86.39 +
   86.40 +install: $(PRGNAME)
   86.41 +	install -d $(BINDIR)
   86.42 +	install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
   86.43 +
   86.44 +uninstall:
   86.45 +	rm -f $(BINDIR)/$(PRGNAME)
   86.46 +
   86.47 +clean:
   86.48 +	@-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
   86.49 +
    87.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    87.2 +++ b/graphlcd-base/tools/convpic/bmp.c	Wed Feb 06 17:32:55 2008 +0000
    87.3 @@ -0,0 +1,375 @@
    87.4 +/**
    87.5 + *  GraphLCD plugin for the Video Disk Recorder
    87.6 + *
    87.7 + *  bmp.c  -  bmp logo class
    87.8 + *
    87.9 + *  (C) 2004 Andreas Brachold <vdr04 AT deltab de>
   87.10 + *  (C) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
   87.11 + **/
   87.12 +
   87.13 +/***************************************************************************
   87.14 + *                                                                         *
   87.15 + *   This program is free software; you can redistribute it and/or modify  *
   87.16 + *   it under the terms of the GNU General Public License as published by  *
   87.17 + *   the Free Software Foundation; either version 2 of the License, or     *
   87.18 + *   (at your option) any later version.                                   *
   87.19 + *                                                                         *
   87.20 + *   This program is distributed in the hope that it will be useful,       *
   87.21 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   87.22 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   87.23 + *   GNU General Public License for more details.                          *
   87.24 + *                                                                         *
   87.25 + *   You should have received a copy of the GNU General Public License     *
   87.26 + *   along with this program;                                              *
   87.27 + *   if not, write to the Free Software Foundation, Inc.,                  *
   87.28 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   87.29 + *                                                                         *
   87.30 + ***************************************************************************/
   87.31 +
   87.32 +#include <stdio.h>
   87.33 +#include <stdint.h>
   87.34 +#include <string.h>
   87.35 +
   87.36 +#include <string>
   87.37 +
   87.38 +#include <glcdgraphics/bitmap.h>
   87.39 +#include <glcdgraphics/image.h>
   87.40 +
   87.41 +#include "bmp.h"
   87.42 +
   87.43 +
   87.44 +#pragma pack(1)
   87.45 +typedef struct BMPH {
   87.46 +    uint16_t  bmpIdentifier;
   87.47 +    uint32_t  bmpFileSize;
   87.48 +    uint32_t  bmpReserved;
   87.49 +    uint32_t  bmpBitmapDataOffset;
   87.50 +    uint32_t  bmpBitmapHeaderSize;
   87.51 +    uint32_t  bmpWidth;
   87.52 +    uint32_t  bmpHeight;
   87.53 +    uint16_t  bmpPlanes;
   87.54 +    uint16_t  bmpBitsPerPixel;
   87.55 +    uint32_t  bmpCompression;
   87.56 +    uint32_t  bmpBitmapDataSize;
   87.57 +    uint32_t  bmpHResolution;
   87.58 +    uint32_t  bmpVResolution;
   87.59 +    uint32_t  bmpColors;
   87.60 +    uint32_t  bmpImportantColors;
   87.61 +} BMPHEADER;  // 54 bytes
   87.62 +
   87.63 +typedef struct RGBQ {
   87.64 +    uint8_t  rgbBlue;
   87.65 +    uint8_t  rgbGreen;
   87.66 +    uint8_t  rgbRed;
   87.67 +    uint8_t  rgbReserved;
   87.68 +} RGBQUAD;    // 4 bytes
   87.69 +#pragma pack()
   87.70 +
   87.71 +
   87.72 +uint8_t bitmask[8]  = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
   87.73 +uint8_t bitmaskl[8] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
   87.74 +uint8_t bitmaskr[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
   87.75 +
   87.76 +cBMPFile::cBMPFile()
   87.77 +{
   87.78 +}
   87.79 +
   87.80 +cBMPFile::~cBMPFile()
   87.81 +{
   87.82 +}
   87.83 +
   87.84 +bool cBMPFile::Load(GLCD::cImage & image, const std::string & fileName)
   87.85 +{
   87.86 +    FILE         *fIN;
   87.87 +    BMPHEADER     bmpHeader;
   87.88 +    RGBQUAD      *pPalette;
   87.89 +    char         *pByte;
   87.90 +    char          Dummy;
   87.91 +    long          iNumColors;
   87.92 +    long          iSize;
   87.93 +    uint32_t      x, y;
   87.94 +    uint16_t      iRead;
   87.95 +    uint8_t *  bitmap = NULL;
   87.96 +    bool  bInvert = false;
   87.97 +
   87.98 +    if (fileName.length() > 0)
   87.99 +    {
  87.100 +        fIN = fopen(fileName.c_str(), "rb");
  87.101 +        if (fIN)
  87.102 +        {
  87.103 +            if (fread(&bmpHeader, sizeof(BMPHEADER), 1, fIN)!=1)
  87.104 +            {
  87.105 +                fclose(fIN);
  87.106 +                return false;
  87.107 +            }
  87.108 +
  87.109 +            // check for Windows BMP
  87.110 +            if (bmpHeader.bmpBitmapHeaderSize != 0x00000028 )
  87.111 +            {
  87.112 +                fprintf(stderr, "ERROR: only Windows BMP images are allowed.\n");
  87.113 +                fclose(fIN);
  87.114 +                return false;
  87.115 +            }
  87.116 +
  87.117 +            // check for 2 color
  87.118 +            iNumColors = (1 << bmpHeader.bmpBitsPerPixel);
  87.119 +            if (iNumColors != 2)
  87.120 +            {
  87.121 +                fprintf(stderr, "ERROR: the image has %ld colors, but only images with 2 colors are allowed.\n", iNumColors);
  87.122 +                fclose(fIN);
  87.123 +                return false;
  87.124 +            }
  87.125 +
  87.126 +            iSize = bmpHeader.bmpHeight * bmpHeader.bmpWidth;
  87.127 +
  87.128 +            pPalette = (RGBQUAD *) malloc( iNumColors*sizeof(RGBQUAD));
  87.129 +            if (!pPalette)
  87.130 +            {
  87.131 +                fprintf(stderr, "ERROR: cannot allocate memory\n");
  87.132 +                fclose(fIN);
  87.133 +                return false;
  87.134 +            }
  87.135 +
  87.136 +            if (fread( pPalette, iNumColors*sizeof(RGBQUAD), 1, fIN)!=1)
  87.137 +            {
  87.138 +                free(pPalette);
  87.139 +                fclose(fIN);
  87.140 +                return false;
  87.141 +            }
  87.142 +
  87.143 +            // check colors
  87.144 +            if (pPalette->rgbBlue+pPalette->rgbGreen+pPalette->rgbRed <
  87.145 +                    (pPalette+1)->rgbBlue+(pPalette+1)->rgbGreen+(pPalette+1)->rgbRed)
  87.146 +            {
  87.147 +                // index 0 represents 'black', index 1 'white'
  87.148 +                bInvert = !bInvert;
  87.149 +            }
  87.150 +            else
  87.151 +            {
  87.152 +                // index 0 represents 'white', index 1 'black'
  87.153 +            }
  87.154 +
  87.155 +            if (fseek(fIN, bmpHeader.bmpBitmapDataOffset, SEEK_SET)==EOF)
  87.156 +            {
  87.157 +                free(pPalette);
  87.158 +                fclose(fIN);
  87.159 +                return false;
  87.160 +            }
  87.161 +
  87.162 +            switch (bmpHeader.bmpCompression)
  87.163 +            {
  87.164 +                case 0: // BI_RGB       no compression
  87.165 +                    image.Clear();
  87.166 +                    image.SetWidth(bmpHeader.bmpWidth);
  87.167 +                    image.SetHeight(bmpHeader.bmpHeight);
  87.168 +                    image.SetDelay(100);
  87.169 +                    bitmap = new unsigned char[bmpHeader.bmpHeight * ((bmpHeader.bmpWidth + 7) / 8)];
  87.170 +                    if (!bitmap)
  87.171 +                    {
  87.172 +                        fprintf(stderr, "ERROR: cannot allocate memory\n");
  87.173 +                        free(pPalette);
  87.174 +                        fclose(fIN);
  87.175 +                        image.Clear();
  87.176 +                        return false;
  87.177 +                    }
  87.178 +
  87.179 +                    for (y = bmpHeader.bmpHeight; y > 0; y--)
  87.180 +                    {
  87.181 +                        pByte = (char*)bitmap + (y-1)*((bmpHeader.bmpWidth+7)/8);
  87.182 +                        iRead = 0;
  87.183 +                        for (x = 0; x < bmpHeader.bmpWidth / 8; x++)
  87.184 +                        {
  87.185 +                            if (fread(pByte, sizeof(char), 1, fIN) != 1)
  87.186 +                            {
  87.187 +                                delete[] bitmap;
  87.188 +                                free(pPalette);
  87.189 +                                fclose(fIN);
  87.190 +                                image.Clear();
  87.191 +                                return false;
  87.192 +                            }
  87.193 +                            iRead++;
  87.194 +                            if (bInvert)
  87.195 +                                *pByte = *pByte ^ 0xff;
  87.196 +                            pByte++;
  87.197 +                        }
  87.198 +
  87.199 +                        if (bmpHeader.bmpWidth % 8)
  87.200 +                        {
  87.201 +                            if (fread(pByte, sizeof(char), 1, fIN) != 1)
  87.202 +                            {
  87.203 +                                delete [] bitmap;
  87.204 +                                free(pPalette);
  87.205 +                                fclose(fIN);
  87.206 +                                image.Clear();
  87.207 +                                return false;
  87.208 +                            }
  87.209 +                            iRead++;
  87.210 +                            if (bInvert)
  87.211 +                                *pByte = *pByte^0xff;
  87.212 +                            *pByte = *pByte & bitmaskl[bmpHeader.bmpWidth%8];
  87.213 +                            pByte++;
  87.214 +                        }
  87.215 +
  87.216 +                        // Scan line must be 4-byte-alligned
  87.217 +                        while (iRead % 4)
  87.218 +                        {
  87.219 +                            if (fread(&Dummy, sizeof(char), 1, fIN) != 1)
  87.220 +                            {
  87.221 +                                delete [] bitmap;
  87.222 +                                free(pPalette);
  87.223 +                                fclose(fIN);
  87.224 +                                image.Clear();
  87.225 +                                return false;
  87.226 +                            }
  87.227 +                            iRead++;
  87.228 +                        }
  87.229 +                    }
  87.230 +                    image.AddBitmap(new GLCD::cBitmap(bmpHeader.bmpWidth, bmpHeader.bmpHeight, bitmap));
  87.231 +                    break;
  87.232 +                case 1: // BI_RLE4      RLE 4bit/pixel
  87.233 +                case 2: // BI_RLE8      RLE 8bit/pixel
  87.234 +                case 3: // BI_BITFIELDS
  87.235 +                default:
  87.236 +                    fprintf(stderr, "ERROR: only uncompressed RGB images are allowed.\n");
  87.237 +
  87.238 +                    free(pPalette);
  87.239 +                    fclose(fIN);
  87.240 +                    return false;
  87.241 +            }
  87.242 +            fclose(fIN);
  87.243 +        }
  87.244 +        else
  87.245 +        {
  87.246 +            fprintf(stderr, "ERROR: cannot open picture %s\n", fileName.c_str());
  87.247 +        }
  87.248 +    }
  87.249 +    else
  87.250 +    {
  87.251 +        fprintf(stderr, "ERROR: no FileName given!\n");
  87.252 +    }
  87.253 +    return true;
  87.254 +}
  87.255 +
  87.256 +bool cBMPFile::Save(const GLCD::cBitmap * bitmap, const std::string & fileName)
  87.257 +{
  87.258 +    FILE         *fOut;
  87.259 +    BMPHEADER     bmpHeader;
  87.260 +    RGBQUAD       bmpColor1, bmpColor2;
  87.261 +    uint32_t      dBDO, dBDSx, dBDS;
  87.262 +    char         *pByte;
  87.263 +    char          Dummy = 0x00;
  87.264 +    uint32_t      x, y;
  87.265 +    uint16_t      iWrote;
  87.266 +    const uint8_t * bmpdata = bitmap->Data();
  87.267 +
  87.268 +    if (bitmap
  87.269 +        && bitmap->Width() > 0
  87.270 +        && bitmap->Height() > 0)
  87.271 +    {
  87.272 +        memset(&bmpHeader, 0, sizeof(BMPHEADER));
  87.273 +
  87.274 +        dBDO = sizeof(BMPHEADER)+2*sizeof(RGBQUAD);
  87.275 +        dBDSx = ((bitmap->Width() + 7) / 8 + 3) & 0xfffffffc;
  87.276 +        dBDS = dBDSx * bitmap->Height();
  87.277 +
  87.278 +        bmpHeader.bmpIdentifier       = 0x4d42; // "BM"
  87.279 +        bmpHeader.bmpFileSize         = dBDO + dBDS;
  87.280 +        bmpHeader.bmpBitmapDataOffset = dBDO;
  87.281 +        bmpHeader.bmpBitmapHeaderSize = 0x28;
  87.282 +        bmpHeader.bmpWidth            = bitmap->Width();
  87.283 +        bmpHeader.bmpHeight           = bitmap->Height();
  87.284 +        bmpHeader.bmpPlanes           = 0x01;
  87.285 +        bmpHeader.bmpBitsPerPixel     = 0x01;
  87.286 +        bmpHeader.bmpCompression      = 0x00;
  87.287 +        bmpHeader.bmpBitmapDataSize   = dBDS;
  87.288 +        bmpHeader.bmpHResolution      = 0xb13;  // 72dpi
  87.289 +        bmpHeader.bmpVResolution      = 0xb13;  // 72dpi
  87.290 +        bmpHeader.bmpColors           = 0x02;
  87.291 +        bmpHeader.bmpImportantColors  = 0x02;
  87.292 +
  87.293 +        bmpColor1.rgbBlue     = 0x00;
  87.294 +        bmpColor1.rgbGreen    = 0x00;
  87.295 +        bmpColor1.rgbRed      = 0x00;
  87.296 +        bmpColor1.rgbReserved = 0x00;
  87.297 +        bmpColor2.rgbBlue     = 0xff;
  87.298 +        bmpColor2.rgbGreen    = 0xff;
  87.299 +        bmpColor2.rgbRed      = 0xff;
  87.300 +        bmpColor2.rgbReserved = 0x00;
  87.301 +
  87.302 +
  87.303 +        fOut = fopen(fileName.c_str(), "wb");
  87.304 +        if (!fOut)
  87.305 +        {
  87.306 +            fprintf(stderr,"Cannot create file: %s\n", fileName.c_str());
  87.307 +            return false;
  87.308 +        }
  87.309 +        fwrite(&bmpHeader, sizeof(BMPHEADER), 1, fOut);
  87.310 +        fwrite(&bmpColor1, sizeof(RGBQUAD), 1, fOut);
  87.311 +        fwrite(&bmpColor2, sizeof(RGBQUAD), 1, fOut);
  87.312 +
  87.313 +        for (y=bitmap->Height(); y>0; y--)
  87.314 +        {
  87.315 +            pByte = (char*)bmpdata + (y-1)*((bitmap->Width()+7)/8);
  87.316 +            iWrote = 0;
  87.317 +            for (x=0; x<(uint32_t) bitmap->Width()/8; x++)
  87.318 +            {
  87.319 +                *pByte = *pByte^0xff;
  87.320 +                if (fwrite(pByte, sizeof(char), 1, fOut)!=1)
  87.321 +                {
  87.322 +                    fclose(fOut);
  87.323 +                    return false;
  87.324 +                }
  87.325 +                iWrote++;
  87.326 +                pByte++;
  87.327 +            }
  87.328 +            // Scan line must be 4-byte-alligned
  87.329 +            while (iWrote%4)
  87.330 +            {
  87.331 +                if (fwrite(&Dummy, sizeof(char), 1, fOut)!=1)
  87.332 +                {
  87.333 +                    fclose(fOut);
  87.334 +                    return 3;
  87.335 +                }
  87.336 +                iWrote++;
  87.337 +            }
  87.338 +        }
  87.339 +        fclose(fOut);
  87.340 +    }
  87.341 +    return true;
  87.342 +}
  87.343 +
  87.344 +bool cBMPFile::Save(GLCD::cImage & image, const std::string & fileName)
  87.345 +{
  87.346 +    const GLCD::cBitmap * bitmap;
  87.347 +
  87.348 +    if (image.Count() == 1)
  87.349 +    {
  87.350 +        bitmap = image.GetBitmap(0);
  87.351 +        if (bitmap)
  87.352 +        {
  87.353 +            if (!Save(bitmap, fileName))
  87.354 +            {
  87.355 +                return false;
  87.356 +            }
  87.357 +        }
  87.358 +    }
  87.359 +    else
  87.360 +    {
  87.361 +        uint16_t i;
  87.362 +        char tmpStr[256];
  87.363 +
  87.364 +        for (i = 0; i < image.Count(); i++)
  87.365 +        {
  87.366 +            sprintf(tmpStr, "%.248s.%05d", fileName.c_str(), i);
  87.367 +            bitmap = image.GetBitmap(i);
  87.368 +            if (bitmap)
  87.369 +            {
  87.370 +                if (!Save(bitmap, tmpStr))
  87.371 +                {
  87.372 +                    return false;
  87.373 +                }
  87.374 +            }
  87.375 +        }
  87.376 +    }
  87.377 +    return true;
  87.378 +}
    88.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    88.2 +++ b/graphlcd-base/tools/convpic/bmp.h	Wed Feb 06 17:32:55 2008 +0000
    88.3 @@ -0,0 +1,45 @@
    88.4 +/**
    88.5 + *  GraphLCD plugin for the Video Disk Recorder
    88.6 + *
    88.7 + *  bmp.h  -  bmp logo class
    88.8 + *
    88.9 + *  (C) 2004 Andreas Brachold <vdr04 AT deltab de>
   88.10 + *  (C) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
   88.11 + **/
   88.12 +
   88.13 +/***************************************************************************
   88.14 + *                                                                         *
   88.15 + *   This program is free software; you can redistribute it and/or modify  *
   88.16 + *   it under the terms of the GNU General Public License as published by  *
   88.17 + *   the Free Software Foundation; either version 2 of the License, or     *
   88.18 + *   (at your option) any later version.                                   *
   88.19 + *                                                                         *
   88.20 + *   This program is distributed in the hope that it will be useful,       *
   88.21 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   88.22 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   88.23 + *   GNU General Public License for more details.                          *
   88.24 + *                                                                         *
   88.25 + *   You should have received a copy of the GNU General Public License     *
   88.26 + *   along with this program;                                              *
   88.27 + *   if not, write to the Free Software Foundation, Inc.,                  *
   88.28 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   88.29 + *                                                                         *
   88.30 + ***************************************************************************/
   88.31 +
   88.32 +#ifndef _BMP_H_
   88.33 +#define _BMP_H_
   88.34 +
   88.35 +#include <glcdgraphics/imagefile.h>
   88.36 +
   88.37 +class cBMPFile : public GLCD::cImageFile
   88.38 +{
   88.39 +private:
   88.40 +    bool Save(const GLCD::cBitmap * bitmap, const std::string & fileName);
   88.41 +public:
   88.42 +    cBMPFile();
   88.43 +    virtual ~cBMPFile();
   88.44 +    virtual bool Load(GLCD::cImage & image, const std::string & fileName);
   88.45 +    virtual bool Save(GLCD::cImage & image, const std::string & fileName);
   88.46 +};
   88.47 +
   88.48 +#endif
    89.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    89.2 +++ b/graphlcd-base/tools/convpic/c_bmp2glcd	Wed Feb 06 17:32:55 2008 +0000
    89.3 @@ -0,0 +1,10 @@
    89.4 +#!/bin/sh
    89.5 +# Converts all BMP images to *.glcd
    89.6 +
    89.7 +old=bmp
    89.8 +new=glcd
    89.9 +
   89.10 +for file in ./*."$old"; do
   89.11 +  convpic -i "$file" -o "`basename \"$file\" \"$old\"`$new"
   89.12 +done
   89.13 +
    90.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    90.2 +++ b/graphlcd-base/tools/convpic/c_tif2glcd	Wed Feb 06 17:32:55 2008 +0000
    90.3 @@ -0,0 +1,10 @@
    90.4 +#!/bin/sh
    90.5 +# Converts all TIFF images to *.glcd
    90.6 +
    90.7 +old=tif
    90.8 +new=glcd
    90.9 +
   90.10 +for file in ./*."$old"; do
   90.11 +  convpic -i "$file" -o "`basename \"$file\" \"$old\"`$new"
   90.12 +done
   90.13 +
    91.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    91.2 +++ b/graphlcd-base/tools/convpic/convall	Wed Feb 06 17:32:55 2008 +0000
    91.3 @@ -0,0 +1,10 @@
    91.4 +#!/bin/sh
    91.5 +# Converts all images in current directory
    91.6 +
    91.7 +old=$1
    91.8 +new=$2
    91.9 +
   91.10 +for file in ./*."$old"; do
   91.11 +  convpic -i "$file" -o "`basename \"$file\" \"$old\"`$new"
   91.12 +done
   91.13 +
    92.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    92.2 +++ b/graphlcd-base/tools/convpic/convpic.c	Wed Feb 06 17:32:55 2008 +0000
    92.3 @@ -0,0 +1,279 @@
    92.4 +/**
    92.5 + *  convpic.c  -  a tool to convert images to
    92.6 + *                own proprietary format of the logos and pictures
    92.7 + *                for graphlcd plugin
    92.8 + *
    92.9 + *  (C) 2004 Andreas Brachold <vdr04 AT deltab de>
   92.10 + *  (C) 2001-2003 by Carsten Siebholz <c.siebholz AT t-online.de>
   92.11 + **/
   92.12 +
   92.13 +/***************************************************************************
   92.14 + *                                                                         *
   92.15 + *   This program is free software; you can redistribute it and/or modify  *
   92.16 + *   it under the terms of the GNU General Public License as published by  *
   92.17 + *   the Free Software Foundation; either version 2 of the License, or     *
   92.18 + *   (at your option) any later version.                                   *
   92.19 + *                                                                         *
   92.20 + *   This program is distributed in the hope that it will be useful,       *
   92.21 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   92.22 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   92.23 + *   GNU General Public License for more details.                          *
   92.24 + *                                                                         *
   92.25 + *   You should have received a copy of the GNU General Public License     *
   92.26 + *   along with this program;                                              *
   92.27 + *   if not, write to the Free Software Foundation, Inc.,                  *
   92.28 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   92.29 + *                                                                         *
   92.30 + ***************************************************************************/
   92.31 +
   92.32 +#include <getopt.h>
   92.33 +#include <stdio.h>
   92.34 +#include <stdint.h>
   92.35 +#include <string.h>
   92.36 +#include <stdlib.h>
   92.37 +
   92.38 +#include <string>
   92.39 +
   92.40 +#include <glcdgraphics/bitmap.h>
   92.41 +#include <glcdgraphics/image.h>
   92.42 +#include <glcdgraphics/imagefile.h>
   92.43 +#include <glcdgraphics/glcd.h>
   92.44 +#include <glcdgraphics/pbm.h>
   92.45 +
   92.46 +#include "bmp.h"
   92.47 +#include "tiff.h"
   92.48 +#include "tuxbox.h"
   92.49 +
   92.50 +static const char *prgname = "convpic";
   92.51 +static const char *VERSION = "0.1.1";
   92.52 +
   92.53 +unsigned int delay = 250;
   92.54 +
   92.55 +
   92.56 +enum ePicFormat
   92.57 +{
   92.58 +    pfUndefined,
   92.59 +    pfTIFF,
   92.60 +    pfBMP,
   92.61 +    pfGLCD,
   92.62 +    pfPBM,
   92.63 +    pfTUXBOX
   92.64 +};
   92.65 +
   92.66 +void usage(void);
   92.67 +
   92.68 +ePicFormat getFormat(const char* szFile)
   92.69 +{
   92.70 +    static const struct tagformats {const char* szExt; ePicFormat picformat;} formats[] =
   92.71 +    {
   92.72 +        {".tiff", pfTIFF  },
   92.73 +        {".tif",  pfTIFF  },
   92.74 +        {".bmp",  pfBMP   },
   92.75 +        {".glcd", pfGLCD  },
   92.76 +        {".pbm",  pfPBM   },
   92.77 +        {".ani",  pfTUXBOX}
   92.78 +    };
   92.79 +    ePicFormat pf = pfUndefined;
   92.80 +
   92.81 +    if (szFile)
   92.82 +    {
   92.83 +        for (int i = strlen(szFile) - 1; i >= 0; i--)
   92.84 +        {
   92.85 +            if (*(szFile+i) == '.' && strlen(szFile + i + 1))
   92.86 +            {
   92.87 +                for (unsigned int n = 0; n < sizeof(formats)/sizeof(*formats); n++)
   92.88 +                {
   92.89 +                    if (!strcasecmp((szFile+i), formats[n].szExt))
   92.90 +                    {
   92.91 +                        return formats[n].picformat;
   92.92 +                    }
   92.93 +                }
   92.94 +            }
   92.95 +        }
   92.96 +    }
   92.97 +    return pf;
   92.98 +}
   92.99 +
  92.100 +GLCD::cImageFile * GetFileTranslator(ePicFormat Format)
  92.101 +{
  92.102 +    switch (Format)
  92.103 +    {
  92.104 +        case pfGLCD:
  92.105 +            return new GLCD::cGLCDFile();
  92.106 +
  92.107 +        case pfPBM:
  92.108 +            return new GLCD::cPBMFile();
  92.109 +
  92.110 +        case pfBMP:
  92.111 +            return new cBMPFile();
  92.112 +
  92.113 +        case pfTIFF:
  92.114 +            return new cTIFFFile();
  92.115 +
  92.116 +        case pfTUXBOX:
  92.117 +            return new cTuxBoxFile();
  92.118 +
  92.119 +        default:
  92.120 +            return NULL;
  92.121 +    }
  92.122 +
  92.123 +}
  92.124 +
  92.125 +int main(int argc, char *argv[]) {
  92.126 +    ePicFormat  inFormat = pfUndefined;
  92.127 +    ePicFormat  outFormat = pfUndefined;
  92.128 +    std::string  inFile = "";
  92.129 +    std::string  outFile = "";
  92.130 +    GLCD::cImage  image;
  92.131 +    GLCD::cImage  nextImage;
  92.132 +    GLCD::cImageFile *  pInBitmap = NULL;
  92.133 +    GLCD::cImageFile *  pOutBitmap = NULL;
  92.134 +    bool  bError = false;
  92.135 +    bool  bInvert = false;
  92.136 +    bool  bDelay = false;
  92.137 +
  92.138 +
  92.139 +    static struct option long_options[] =
  92.140 +    {
  92.141 +        {"invert",         no_argument, NULL, 'n'},
  92.142 +        {"infile",   required_argument, NULL, 'i'},
  92.143 +        {"outfile",  required_argument, NULL, 'o'},
  92.144 +        {"delay",    required_argument, NULL, 'd'},
  92.145 +        { NULL}
  92.146 +    };
  92.147 +
  92.148 +    int c, option_index = 0;
  92.149 +    while ((c=getopt_long(argc,argv,"ni:o:d:",long_options, &option_index))!=-1) {
  92.150 +        switch (c) {
  92.151 +            case 'n':
  92.152 +                bInvert = true;
  92.153 +                break;
  92.154 +
  92.155 +            case 'i':
  92.156 +                inFile = optarg;
  92.157 +                break;
  92.158 +
  92.159 +            case 'o':
  92.160 +                outFile = optarg;
  92.161 +                break;
  92.162 +
  92.163 +            case 'd':
  92.164 +                delay = atoi(optarg);
  92.165 +                bDelay = true;
  92.166 +                if (delay < 10)
  92.167 +                {
  92.168 +                    fprintf(stderr, "Warning: You have specify a to short delay, minimum are 10 ms\n");
  92.169 +                    delay = 10;
  92.170 +                }
  92.171 +                break;
  92.172 +
  92.173 +            default:
  92.174 +                return 1;
  92.175 +        }
  92.176 +    }
  92.177 +
  92.178 +    if (inFile.length() == 0)
  92.179 +    {
  92.180 +        fprintf(stderr, "ERROR: You have to specify the infile (-i filename)\n");
  92.181 +        bError = true;
  92.182 +    }
  92.183 +
  92.184 +    if (pfUndefined == (inFormat = getFormat(inFile.c_str())))
  92.185 +    {
  92.186 +        fprintf(stderr, "ERROR: You have to specify a correct extension for the %s\n", inFile.c_str());
  92.187 +        bError = true;
  92.188 +    }
  92.189 +
  92.190 +    if (outFile.length() == 0)
  92.191 +    {
  92.192 +        fprintf(stderr, "ERROR: You have to specify the outfile (-o filename)\n");
  92.193 +        bError = true;
  92.194 +    }
  92.195 +
  92.196 +    if (pfUndefined == (outFormat = getFormat(outFile.c_str())))
  92.197 +    {
  92.198 +        fprintf(stderr, "ERROR: You have to specify a correct extension for the %s \n", outFile.c_str());
  92.199 +        bError = true;
  92.200 +    }
  92.201 +
  92.202 +    if (bError)
  92.203 +    {
  92.204 +        usage();
  92.205 +        return 1;
  92.206 +    }
  92.207 +
  92.208 +
  92.209 +    pInBitmap = GetFileTranslator(inFormat);
  92.210 +    if (!pInBitmap)
  92.211 +        return 2;
  92.212 +
  92.213 +    pOutBitmap = GetFileTranslator(outFormat);
  92.214 +    if (!pOutBitmap)
  92.215 +        return 3;
  92.216 +
  92.217 +    // Load Picture
  92.218 +    fprintf(stdout, "loading %s\n", inFile.c_str());
  92.219 +    bError = !pInBitmap->Load(image, inFile);
  92.220 +    if (!bError)
  92.221 +    {
  92.222 +        // Load more in files
  92.223 +        while (optind < argc && !bError)
  92.224 +        {
  92.225 +            inFile = argv[optind++];
  92.226 +            inFormat = getFormat(inFile.c_str());
  92.227 +            if (inFormat == pfUndefined)
  92.228 +            {
  92.229 +                fprintf(stderr, "ERROR: You have to specify a correct extension for the %s\n", inFile.c_str());
  92.230 +                bError = true;
  92.231 +                break;
  92.232 +            }
  92.233 +            pInBitmap = GetFileTranslator(inFormat);
  92.234 +            if (!pInBitmap)
  92.235 +                break;
  92.236 +
  92.237 +            fprintf(stdout, "loading %s\n", inFile.c_str());
  92.238 +            if (pInBitmap->Load(nextImage, inFile))
  92.239 +            {
  92.240 +                uint16_t i;
  92.241 +                for (i = 0; i < nextImage.Count(); i++)
  92.242 +                {
  92.243 +                    image.AddBitmap(new GLCD::cBitmap(*nextImage.GetBitmap(i)));
  92.244 +                }
  92.245 +            }
  92.246 +        }
  92.247 +        if (bDelay)
  92.248 +            image.SetDelay(delay);
  92.249 +        if (bInvert)
  92.250 +        {
  92.251 +            uint16_t i;
  92.252 +            for (i = 0; i < image.Count(); i++)
  92.253 +            {
  92.254 +                image.GetBitmap(i)->Invert();
  92.255 +            }
  92.256 +        }
  92.257 +        fprintf(stdout, "saving %s\n", outFile.c_str());
  92.258 +        bError = !pOutBitmap->Save(image, outFile);
  92.259 +    }
  92.260 +    if (bError) {
  92.261 +        return 4;
  92.262 +    }
  92.263 +
  92.264 +    fprintf(stdout, "conversion compeleted successfully.\n\n");
  92.265 +
  92.266 +    return 0;
  92.267 +}
  92.268 +
  92.269 +void usage(void)
  92.270 +{
  92.271 +    fprintf(stdout, "\n");
  92.272 +    fprintf(stdout, "%s v%s\n", prgname, VERSION);
  92.273 +    fprintf(stdout, "%s is a tool to convert images to a simple format (*.glcd)\n", prgname);
  92.274 +    fprintf(stdout, "        that is used by the graphlcd plugin for VDR.\n\n");
  92.275 +    fprintf(stdout, "  Usage: %s [-n] -i file[s...] -o outfile \n\n", prgname);
  92.276 +    fprintf(stdout, "  -n  --invert      inverts the output (default: none)\n");
  92.277 +    fprintf(stdout, "  -i  --infile      specifies the name of the input file[s]\n");
  92.278 +    fprintf(stdout, "  -o  --outfile     specifies the name of the output file\n");
  92.279 +    fprintf(stdout, "  -d  --delay       specifies the delay between multiple images [Default: %d ms] \n",delay);
  92.280 +    fprintf(stdout, "\n" );
  92.281 +    fprintf(stdout, "  example: %s -i vdr-logo.bmp -o vdr-logo.glcd \n", prgname );
  92.282 +}
    93.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    93.2 +++ b/graphlcd-base/tools/convpic/formats.txt	Wed Feb 06 17:32:55 2008 +0000
    93.3 @@ -0,0 +1,32 @@
    93.4 +Dateiformat von "Graphlcd-Logo"
    93.5 +
    93.6 +
    93.7 +Einzelbild für LCD
    93.8 +=================================
    93.9 +
   93.10 +HEADER
   93.11 +Position	Typ	Name	Bedeutung
   93.12 +0x0000		char[4]	magic	  - "GLCD"
   93.13 +0x0004		word  	width   - Breite der Bilder (LE)
   93.14 +0x0006		word  	height  - Höhe der Bilder (LE)
   93.15 +0x0008		char[]	data    - Einzel-Bild
   93.16 +
   93.17 +DATEN
   93.18 +char[height][width/8], pro Byte 8 nebeneinander liegende Pixel
   93.19 +
   93.20 +Animation für LCD
   93.21 +=================================
   93.22 +
   93.23 +HEADER
   93.24 +Position	Typ	Name	Bedeutung
   93.25 +0x0000		char[4]	magic	  - "GLCA"
   93.26 +0x0004		word  	width   - Breite der Bilder (LE)
   93.27 +0x0006		word  	height  - Höhe der Bilder (LE)
   93.28 +0x0008		word    count   - Anzahl der Bilder (LE)
   93.29 +0x000a		long	  delay   - Wartezeit zwischen den Bildern (in ms; LE)
   93.30 +0x0010		char[]	data    - Einzel-Bilder
   93.31 +
   93.32 +DATEN
   93.33 +char[height][width/8], pro Byte 8 nebeneinander liegende Pixel (1 = Pixel gesetzt)
   93.34 +
   93.35 +LE = Little Endian byte order = wie bei intel ;)
    94.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    94.2 +++ b/graphlcd-base/tools/convpic/tiff.c	Wed Feb 06 17:32:55 2008 +0000
    94.3 @@ -0,0 +1,201 @@
    94.4 +/**
    94.5 + *  GraphLCD plugin for the Video Disk Recorder
    94.6 + *
    94.7 + *  tiff.c  -  tiff logo class
    94.8 + *
    94.9 + *  (c) 2004 Andreas Brachold <vdr04 AT deltab de>
   94.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
   94.11 + **/
   94.12 +
   94.13 +/***************************************************************************
   94.14 + *                                                                         *
   94.15 + *   This program is free software; you can redistribute it and/or modify  *
   94.16 + *   it under the terms of the GNU General Public License as published by  *
   94.17 + *   the Free Software Foundation; either version 2 of the License, or     *
   94.18 + *   (at your option) any later version.                                   *
   94.19 + *                                                                         *
   94.20 + *   This program is distributed in the hope that it will be useful,       *
   94.21 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   94.22 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   94.23 + *   GNU General Public License for more details.                          *
   94.24 + *                                                                         *
   94.25 + *   You should have received a copy of the GNU General Public License     *
   94.26 + *   along with this program;                                              *
   94.27 + *   if not, write to the Free Software Foundation, Inc.,                  *
   94.28 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   94.29 + *                                                                         *
   94.30 + ***************************************************************************/
   94.31 +
   94.32 +#include <stdio.h>
   94.33 +#include <string.h>
   94.34 +
   94.35 +#include <string>
   94.36 +
   94.37 +#include <glcdgraphics/bitmap.h>
   94.38 +#include <glcdgraphics/image.h>
   94.39 +
   94.40 +#include "tiff.h"
   94.41 +
   94.42 +
   94.43 +#pragma pack(1)
   94.44 +typedef struct TIFFT{
   94.45 +    unsigned short  tag;
   94.46 +    unsigned short  type;
   94.47 +    unsigned long   length;
   94.48 +    /*     1 = BYTE.      8-bit unsigned integer.                                                                  */
   94.49 +    /*     2 = ASCII.     8-bit bytes that store ASCII codes; the last byte must be null.                          */
   94.50 +    /*     3 = SHORT.     A 16-bit (2-byte) unsigned integer.                                                      */
   94.51 +    /*     4 = LONG.      A 32-bit (4-byte) unsigned integer.                                                      */
   94.52 +    /*     5 = RATIONAL.  Two LONGs: the first represents the numerator of a fraction, the second the denominator. */
   94.53 +    unsigned long   off_val;
   94.54 +} TIFFTAG;
   94.55 +#pragma pack()
   94.56 +
   94.57 +#define GETANDCHECK { t=fgetc(fIN);if(t==EOF) {fclose(fIN);return false;};}
   94.58 +
   94.59 +cTIFFFile::cTIFFFile()
   94.60 +{
   94.61 +}
   94.62 +
   94.63 +cTIFFFile::~cTIFFFile()
   94.64 +{
   94.65 +}
   94.66 +
   94.67 +bool cTIFFFile::Load(GLCD::cImage & image, const std::string & fileName)
   94.68 +{
   94.69 +    FILE         *fIN;
   94.70 +    TIFFTAG       tifftag;
   94.71 +    unsigned int  tiff_header, tiff_anztags, tiff_data;
   94.72 +    unsigned char cl,ch,y,i;
   94.73 +    unsigned char height, width, strip, invert;
   94.74 +    unsigned char fLittleEndian=0;
   94.75 +    int j;
   94.76 +    int t;
   94.77 +    unsigned char *bitmap = NULL;
   94.78 +    bool  bInvert = false;
   94.79 +
   94.80 +    if (fileName.length() > 0)
   94.81 +    {
   94.82 +        fIN = fopen(fileName.c_str(), "rb");
   94.83 +        if (fIN)
   94.84 +        {
   94.85 +            //    isyslog("graphlcd plugin: try to load logo %s.", szFileName);
   94.86 +            if (fseek(fIN, 0, SEEK_SET)==EOF)
   94.87 +            {
   94.88 +                fclose(fIN);
   94.89 +                return false;
   94.90 +            }
   94.91 +            GETANDCHECK; cl=(unsigned char)t;
   94.92 +            GETANDCHECK; ch=(unsigned char)t;
   94.93 +            if ((cl==0x49) && (ch==0x49))
   94.94 +            {
   94.95 +                fLittleEndian=1;
   94.96 +            }
   94.97 +
   94.98 +            if (fseek(fIN, 4, SEEK_SET)==EOF)
   94.99 +            {
  94.100 +                fclose(fIN);
  94.101 +                return false;
  94.102 +            }
  94.103 +            GETANDCHECK; cl=(unsigned char)t;
  94.104 +            GETANDCHECK; ch=(unsigned char)t;
  94.105 +            tiff_header = cl+256*ch;
  94.106 +            //printf("tiff_header:%d %x\n", tiff_header, tiff_header);
  94.107 +
  94.108 +            if (fseek(fIN, tiff_header, SEEK_SET)==EOF)
  94.109 +            {
  94.110 +                fclose(fIN);
  94.111 +                return false;
  94.112 +            }
  94.113 +
  94.114 +            GETANDCHECK; cl=(unsigned char)t;
  94.115 +            GETANDCHECK; ch=(unsigned char)t;
  94.116 +            tiff_anztags = cl+256*ch;
  94.117 +            //printf("tiff_anztags:%d %x\n", tiff_anztags, tiff_anztags);
  94.118 +
  94.119 +            height=0;
  94.120 +            width=0;
  94.121 +            strip=0;
  94.122 +            invert=0;
  94.123 +            for (i=0; (i<tiff_anztags)&&(!height||!width||!strip||!invert); i++)
  94.124 +            {
  94.125 +                if (fread(&tifftag, sizeof(tifftag), 1, fIN)!=1)
  94.126 +                {
  94.127 +                    fclose(fIN);
  94.128 +                    return false;
  94.129 +                }
  94.130 +                if (tifftag.tag==0x0100) width=tifftag.off_val;
  94.131 +                if (tifftag.tag==0x0101) height=tifftag.off_val;
  94.132 +                if (tifftag.tag==0x0111) strip=tifftag.off_val;
  94.133 +                if (tifftag.tag==0x0106) invert=tifftag.off_val+1;
  94.134 +                //printf("tag%d: %d %d %ld %ld\n", i,tifftag.tag, tifftag.type, tifftag.length, tifftag.off_val );
  94.135 +            }
  94.136 +
  94.137 +            if (fseek(fIN,strip, SEEK_SET)==EOF)
  94.138 +            {
  94.139 +                fclose(fIN);
  94.140 +                return false;
  94.141 +            }
  94.142 +            GETANDCHECK; cl=(unsigned char)t;
  94.143 +            GETANDCHECK; ch=(unsigned char)t;
  94.144 +            tiff_data = cl+256*ch;
  94.145 +            //printf("tiff_data:%d %x\n", tiff_data, tiff_data);
  94.146 +
  94.147 +            if (fseek(fIN, tiff_data, SEEK_SET)==EOF)
  94.148 +            {
  94.149 +                fclose(fIN);
  94.150 +                return false;
  94.151 +            }
  94.152 +
  94.153 +
  94.154 +            image.Clear();
  94.155 +            image.SetWidth(width);
  94.156 +            image.SetHeight(height);
  94.157 +            image.SetDelay(100);
  94.158 +            bitmap = new unsigned char[height * ((width + 7) / 8)];
  94.159 +            if (bitmap)
  94.160 +            {
  94.161 +                if (fread(bitmap, height*((width+7)/8), 1, fIN)!=1)
  94.162 +                {
  94.163 +                    delete [] bitmap;
  94.164 +                    fclose(fIN);
  94.165 +                    image.Clear();
  94.166 +                    return false;
  94.167 +                }
  94.168 +
  94.169 +                if (invert-1==1) bInvert = !bInvert; // 'Black is zero'
  94.170 +                if (bInvert)
  94.171 +                {
  94.172 +                    for (j=0; j < height * ((width+7)/8); j++)
  94.173 +                    {
  94.174 +                        (*(bitmap+j)) = (*(bitmap+j))^0xff;
  94.175 +                    }
  94.176 +                }
  94.177 +
  94.178 +                // cut the rest of the line
  94.179 +                if (width%8)
  94.180 +                {
  94.181 +                    for (y=1; y<=height; y++) {
  94.182 +                        j=y*((width+7)/8)-1;
  94.183 +                        (*(bitmap+j)) = ((*(bitmap+j))>>(8-width%8))<<(8-width%8);
  94.184 +                    }
  94.185 +                }
  94.186 +                image.AddBitmap(new GLCD::cBitmap(width, height, bitmap));
  94.187 +            }
  94.188 +            else
  94.189 +            {
  94.190 +                fprintf(stderr, "ERROR: cannot allocate memory\n");
  94.191 +            }
  94.192 +            fclose(fIN);
  94.193 +        }
  94.194 +        else
  94.195 +        {
  94.196 +            fprintf(stderr, "ERROR: cannot open picture %s\n", fileName.c_str());
  94.197 +        }
  94.198 +    }
  94.199 +    else
  94.200 +    {
  94.201 +        fprintf(stderr, "ERROR: no szFileName given!\n");
  94.202 +    }
  94.203 +    return true;
  94.204 +}
    95.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    95.2 +++ b/graphlcd-base/tools/convpic/tiff.h	Wed Feb 06 17:32:55 2008 +0000
    95.3 @@ -0,0 +1,42 @@
    95.4 +/**
    95.5 + *  GraphLCD plugin for the Video Disk Recorder
    95.6 + *
    95.7 + *  tiff.h  -  tiff logo class
    95.8 + *
    95.9 + *  (c) 2004 Andreas Brachold <vdr04 AT deltab de>
   95.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
   95.11 + **/
   95.12 +
   95.13 +/***************************************************************************
   95.14 + *                                                                         *
   95.15 + *   This program is free software; you can redistribute it and/or modify  *
   95.16 + *   it under the terms of the GNU General Public License as published by  *
   95.17 + *   the Free Software Foundation; either version 2 of the License, or     *
   95.18 + *   (at your option) any later version.                                   *
   95.19 + *                                                                         *
   95.20 + *   This program is distributed in the hope that it will be useful,       *
   95.21 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   95.22 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   95.23 + *   GNU General Public License for more details.                          *
   95.24 + *                                                                         *
   95.25 + *   You should have received a copy of the GNU General Public License     *
   95.26 + *   along with this program;                                              *
   95.27 + *   if not, write to the Free Software Foundation, Inc.,                  *
   95.28 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   95.29 + *                                                                         *
   95.30 + ***************************************************************************/
   95.31 +
   95.32 +#ifndef _TIFF_H_
   95.33 +#define _TIFF_H_
   95.34 +
   95.35 +#include <glcdgraphics/imagefile.h>
   95.36 +
   95.37 +class cTIFFFile : public GLCD::cImageFile
   95.38 +{
   95.39 +public:
   95.40 +    cTIFFFile();
   95.41 +    virtual ~cTIFFFile();
   95.42 +    virtual bool Load(GLCD::cImage & image, const std::string & fileName);
   95.43 +};
   95.44 +
   95.45 +#endif
    96.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    96.2 +++ b/graphlcd-base/tools/convpic/tuxbox.c	Wed Feb 06 17:32:55 2008 +0000
    96.3 @@ -0,0 +1,280 @@
    96.4 +/**
    96.5 + *  GraphLCD plugin for the Video Disk Recorder
    96.6 + *
    96.7 + *  tuxbox.c  -  tuxbox logo class
    96.8 + *
    96.9 + *  (c) 2004 Andreas Brachold <vdr04 AT deltab de>
   96.10 + **/
   96.11 +
   96.12 +/***************************************************************************
   96.13 + *                                                                         *
   96.14 + *   This program is free software; you can redistribute it and/or modify  *
   96.15 + *   it under the terms of the GNU General Public License as published by  *
   96.16 + *   the Free Software Foundation; either version 2 of the License, or     *
   96.17 + *   (at your option) any later version.                                   *
   96.18 + *                                                                         *
   96.19 + *   This program is distributed in the hope that it will be useful,       *
   96.20 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   96.21 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   96.22 + *   GNU General Public License for more details.                          *
   96.23 + *                                                                         *
   96.24 + *   You should have received a copy of the GNU General Public License     *
   96.25 + *   along with this program;                                              *
   96.26 + *   if not, write to the Free Software Foundation, Inc.,                  *
   96.27 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   96.28 + *                                                                         *
   96.29 + ***************************************************************************/
   96.30 +
   96.31 +#include <stdio.h>
   96.32 +#include <string.h>
   96.33 +#include <netinet/in.h>
   96.34 +
   96.35 +#include <string>
   96.36 +
   96.37 +#include <glcdgraphics/bitmap.h>
   96.38 +#include <glcdgraphics/image.h>
   96.39 +
   96.40 +#include "tuxbox.h"
   96.41 +
   96.42 +#pragma pack(1)
   96.43 +struct ani_header {
   96.44 +    unsigned char magic[4]; // = "LCDA"
   96.45 +    unsigned short format; // Format
   96.46 +    unsigned short width;  // Breite
   96.47 +    unsigned short height; // Höhe
   96.48 +    unsigned short count;  // Anzahl Einzelbilder
   96.49 +    unsigned long delay;  // µs zwischen Einzelbildern
   96.50 +};
   96.51 +#pragma pack()
   96.52 +
   96.53 +cTuxBoxFile::cTuxBoxFile()
   96.54 +{
   96.55 +}
   96.56 +
   96.57 +cTuxBoxFile::~cTuxBoxFile()
   96.58 +{
   96.59 +}
   96.60 +
   96.61 +bool cTuxBoxFile::Load(GLCD::cImage & image, const std::string & fileName)
   96.62 +{
   96.63 +    bool ret = false;
   96.64 +    FILE * fIN;
   96.65 +    long fileLen;
   96.66 +    struct ani_header header;
   96.67 +    bool bInvert = false;
   96.68 +
   96.69 +    fIN = fopen(fileName.c_str(), "rb");
   96.70 +    if (fIN)
   96.71 +    {
   96.72 +        // get len of file
   96.73 +        if (fseek(fIN, 0, SEEK_END))
   96.74 +        {
   96.75 +            fclose(fIN);
   96.76 +            return false;
   96.77 +        }
   96.78 +        fileLen = ftell(fIN);
   96.79 +
   96.80 +        // rewind and get Header
   96.81 +        if (fseek(fIN, 0, SEEK_SET))
   96.82 +        {
   96.83 +            fclose(fIN);
   96.84 +            return false;
   96.85 +        }
   96.86 +
   96.87 +        // Read header
   96.88 +        if (fread(&header, sizeof(header), 1, fIN) != 1)
   96.89 +        {
   96.90 +            fclose(fIN);
   96.91 +            return false;
   96.92 +        }
   96.93 +
   96.94 +        image.Clear();
   96.95 +        image.SetWidth(ntohs(header.width));
   96.96 +        image.SetHeight(ntohs(header.height));
   96.97 +        image.SetDelay(ntohl(header.delay) / 1000);
   96.98 +
   96.99 +        // check Header
  96.100 +        if (strncmp((const char*)header.magic, "LCDA", sizeof(header.magic)) ||
  96.101 +                !image.Width() || !image.Height() || ntohs(header.format) != 0)
  96.102 +        {
  96.103 +            fprintf(stderr, "ERROR: load %s failed, wrong header.\n", fileName.c_str());
  96.104 +            fclose(fIN);
  96.105 +            return false;
  96.106 +        }
  96.107 +
  96.108 +        //fprintf(stderr,"%d %dx%d (%d %d) %d\n",ntohs(header.count),image.Width(),image.Height(),fileLen, ( (ntohs(header.count) * (image.Width() * ((image.Height() + 7) / 8))) + sizeof(header)),lhdr.delay);
  96.109 +
  96.110 +        // check file length
  96.111 +        if (!ntohs(header.count)
  96.112 +                || (fileLen != (long) ( (ntohs(header.count) * (image.Width() * ((image.Height() + 7) / 8))) + sizeof(header))))
  96.113 +        {
  96.114 +            fprintf(stderr, "ERROR: load %s failed, wrong size.\n", fileName.c_str());
  96.115 +            fclose(fIN);
  96.116 +            return false;
  96.117 +        }
  96.118 +        // Set minimal limit for next image
  96.119 +        if (image.Delay() < 10)
  96.120 +            image.SetDelay(10);
  96.121 +        for (unsigned int n=0;n<ntohs(header.count);++n)
  96.122 +        {
  96.123 +            ret = false;
  96.124 +            unsigned int nBmpSize = image.Height() * ((image.Width() + 7) / 8);
  96.125 +            unsigned char *bitmap = new unsigned char[nBmpSize];
  96.126 +            if (!bitmap)
  96.127 +            {
  96.128 +                fprintf(stderr, "ERROR: malloc failed.");
  96.129 +                break;
  96.130 +            }
  96.131 +            unsigned int nAniSize = image.Width() * ((image.Height() + 7) / 8);
  96.132 +            unsigned char *pAni = new unsigned char[nAniSize];
  96.133 +            if (!pAni)
  96.134 +            {
  96.135 +                delete[] bitmap;
  96.136 +                fprintf(stderr, "ERROR: malloc failed.");
  96.137 +                break;
  96.138 +            }
  96.139 +
  96.140 +            if (1 != fread(pAni, nAniSize, 1, fIN))
  96.141 +            {
  96.142 +                fprintf(stderr,"ERROR: Cannot read filedata: %s\n", fileName.c_str());
  96.143 +                delete[] bitmap;
  96.144 +                delete[] pAni;
  96.145 +                break;
  96.146 +            }
  96.147 +
  96.148 +            vert2horz(pAni,bitmap, image.Width(), image.Height());
  96.149 +            delete[] pAni;
  96.150 +
  96.151 +            if (bInvert)
  96.152 +                for (unsigned int i=0;i<nBmpSize;++i)
  96.153 +                    bitmap[i] ^= 0xFF;
  96.154 +
  96.155 +            image.AddBitmap(new GLCD::cBitmap(image.Width(), image.Height(), bitmap));
  96.156 +            ret = true;
  96.157 +        }
  96.158 +        fclose(fIN);
  96.159 +        if (!ret)
  96.160 +            image.Clear();
  96.161 +    }
  96.162 +    return ret;
  96.163 +}
  96.164 +
  96.165 +
  96.166 +bool cTuxBoxFile::Save(GLCD::cImage & image, const std::string & fileName)
  96.167 +{
  96.168 +    FILE *      fOut;
  96.169 +    struct ani_header header;
  96.170 +    bool bRet = false;
  96.171 +
  96.172 +    if (image.Count() > 0
  96.173 +        && image.Width()
  96.174 +        && image.Height())
  96.175 +    {
  96.176 +        memcpy(header.magic, "LCDA", 4);
  96.177 +        header.format = htons(0);
  96.178 +        header.width = htons(image.Width());
  96.179 +        header.height = htons(image.Height());
  96.180 +        header.count = htons(image.Count());
  96.181 +        header.delay = htonl(image.Delay() * 1000);
  96.182 +
  96.183 +
  96.184 +        if (image.Width() != 120 || image.Height() != 64)
  96.185 +        {
  96.186 +            fprintf(stderr,"WARNING: Maybe wrong image dimension (for all I know is 120x64 wanted) %s\n", fileName.c_str());
  96.187 +        }
  96.188 +
  96.189 +        fOut = fopen(fileName.c_str(), "wb");
  96.190 +        if (!fOut) {
  96.191 +            fprintf(stderr,"ERROR: Cannot create file: %s\n", fileName.c_str());
  96.192 +            return false;
  96.193 +        }
  96.194 +
  96.195 +        if (1 != fwrite(&header, sizeof(header), 1, fOut))
  96.196 +        {
  96.197 +            fprintf(stderr,"ERROR: Cannot write fileheader: %s\n", fileName.c_str());
  96.198 +            fclose(fOut);
  96.199 +            return false;
  96.200 +        }
  96.201 +
  96.202 +        for (unsigned int n = 0; n < image.Count(); n++)
  96.203 +        {
  96.204 +            bRet = false;
  96.205 +            unsigned int nAniSize = image.Width() * ((image.Height() + 7) / 8);
  96.206 +            unsigned char *pAni = new unsigned char[nAniSize];
  96.207 +            if (!pAni)
  96.208 +            {
  96.209 +                fprintf(stderr, "ERROR: malloc failed.");
  96.210 +                break;
  96.211 +            }
  96.212 +            horz2vert(image.GetBitmap(n)->Data(), pAni, image.Width(), image.Height());
  96.213 +
  96.214 +            if (1 != fwrite(pAni, nAniSize, 1,  fOut))
  96.215 +            {
  96.216 +                delete [] pAni;
  96.217 +                fprintf(stderr,"ERROR: Cannot write filedata: %s\n", fileName.c_str());
  96.218 +                break;
  96.219 +            }
  96.220 +            delete [] pAni;
  96.221 +            bRet = true;
  96.222 +        }
  96.223 +
  96.224 +        fclose(fOut);
  96.225 +    }
  96.226 +    return bRet;
  96.227 +}
  96.228 +
  96.229 +/** Translate memory alignment from vertical to horizontal
  96.230 +rotate from {Byte} to {Byte}
  96.231 +{o}[o][o][o][o][o][o][o] => { oooooooo }
  96.232 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
  96.233 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
  96.234 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
  96.235 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
  96.236 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
  96.237 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
  96.238 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]*/
  96.239 +void cTuxBoxFile::vert2horz(const unsigned char* source, unsigned char* dest, int width, int height) {
  96.240 +    int x, y, off;
  96.241 +    memset(dest,0,height*((width+7)/8));
  96.242 +
  96.243 +    for (y=0; y<height; ++y)
  96.244 +    {
  96.245 +        for (x=0; x<width; ++x)
  96.246 +        {
  96.247 +            off = x + ((y/8) * width);
  96.248 +            if (source[off] & (0x1 << (y % 8)))
  96.249 +            {
  96.250 +                off = (x / 8) + (y * ((width+7)/8));
  96.251 +                dest[off] |= (unsigned char)(0x80 >> (x % 8));
  96.252 +            }
  96.253 +        }
  96.254 +    }
  96.255 +}
  96.256 +
  96.257 +/** Translate memory alignment from horizontal to vertical (rotate byte)
  96.258 +rotate from {Byte} to {Byte}
  96.259 +{ oooooooo } => {o}[o][o][o][o][o][o][o]
  96.260 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
  96.261 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
  96.262 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
  96.263 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
  96.264 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
  96.265 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
  96.266 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]*/
  96.267 +void cTuxBoxFile::horz2vert(const unsigned char* source, unsigned char* dest, int width, int height) {
  96.268 +    int x, y, off;
  96.269 +    memset(dest,0,width*((height+7)/8));
  96.270 +
  96.271 +    for (y=0; y<height; ++y)
  96.272 +    {
  96.273 +        for (x=0; x<width; ++x)
  96.274 +        {
  96.275 +            off = (x / 8) + ((y) * ((width+7)/8));
  96.276 +            if (source[off] & (0x80 >> (x % 8)))
  96.277 +            {
  96.278 +                off = x + ((y/8) * width);
  96.279 +                dest[off] |= (unsigned char)(0x1 << (y % 8));
  96.280 +            }
  96.281 +        }
  96.282 +    }
  96.283 +}
    97.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    97.2 +++ b/graphlcd-base/tools/convpic/tuxbox.h	Wed Feb 06 17:32:55 2008 +0000
    97.3 @@ -0,0 +1,44 @@
    97.4 +/**
    97.5 + *  GraphLCD plugin for the Video Disk Recorder
    97.6 + *
    97.7 + *  tuxbox.h  -  tuxbox logo class
    97.8 + *
    97.9 + *  (c) 2004 Andreas Brachold <vdr04 AT deltab de>
   97.10 + **/
   97.11 +
   97.12 +/***************************************************************************
   97.13 + *                                                                         *
   97.14 + *   This program is free software; you can redistribute it and/or modify  *
   97.15 + *   it under the terms of the GNU General Public License as published by  *
   97.16 + *   the Free Software Foundation; either version 2 of the License, or     *
   97.17 + *   (at your option) any later version.                                   *
   97.18 + *                                                                         *
   97.19 + *   This program is distributed in the hope that it will be useful,       *
   97.20 + *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
   97.21 + *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
   97.22 + *   GNU General Public License for more details.                          *
   97.23 + *                                                                         *
   97.24 + *   You should have received a copy of the GNU General Public License     *
   97.25 + *   along with this program;                                              *
   97.26 + *   if not, write to the Free Software Foundation, Inc.,                  *
   97.27 + *   59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *
   97.28 + *                                                                         *
   97.29 + ***************************************************************************/
   97.30 +#ifndef _TUXBOX_H_
   97.31 +#define _TUXBOX_H_
   97.32 +
   97.33 +#include <glcdgraphics/imagefile.h>
   97.34 +
   97.35 +class cTuxBoxFile : public GLCD::cImageFile
   97.36 +{
   97.37 +private:
   97.38 +    void vert2horz(const unsigned char* source, unsigned char* dest, int width, int height);
   97.39 +    void horz2vert(const unsigned char* source, unsigned char* dest, int width, int height);
   97.40 +public:
   97.41 +    cTuxBoxFile();
   97.42 +    virtual ~cTuxBoxFile();
   97.43 +    virtual bool Load(GLCD::cImage & image, const std::string & fileName);
   97.44 +    virtual bool Save(GLCD::cImage & image, const std::string & fileName);
   97.45 +};
   97.46 +
   97.47 +#endif
    98.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    98.2 +++ b/graphlcd-base/tools/crtfont/Makefile	Wed Feb 06 17:32:55 2008 +0000
    98.3 @@ -0,0 +1,45 @@
    98.4 +#
    98.5 +# Makefile for the GraphLCD tool crtfont
    98.6 +#
    98.7 +
    98.8 +-include ../../Make.config
    98.9 +
   98.10 +PRGNAME = crtfont
   98.11 +
   98.12 +OBJS = crtfont.o
   98.13 +
   98.14 +INCLUDES += -I../../
   98.15 +LIBDIRS += -L../../glcdgraphics/
   98.16 +
   98.17 +all: $(PRGNAME)
   98.18 +.PHONY: all
   98.19 +
   98.20 +# Implicit rules:
   98.21 +
   98.22 +%.o: %.c
   98.23 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
   98.24 +
   98.25 +# Dependencies:
   98.26 +
   98.27 +MAKEDEP = $(CXX) -MM -MG
   98.28 +DEPFILE = .dependencies
   98.29 +$(DEPFILE): Makefile
   98.30 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
   98.31 +
   98.32 +-include $(DEPFILE)
   98.33 +
   98.34 +# The main program:
   98.35 +
   98.36 +$(PRGNAME): $(OBJS)
   98.37 +	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBDIRS) -lglcdgraphics -lstdc++ -o $(PRGNAME)
   98.38 +
   98.39 +install: $(PRGNAME)
   98.40 +	install -d $(BINDIR)
   98.41 +	install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
   98.42 +
   98.43 +uninstall:
   98.44 +	rm -f $(BINDIR)/$(PRGNAME)
   98.45 +
   98.46 +clean:
   98.47 +	@-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
   98.48 +
    99.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    99.2 +++ b/graphlcd-base/tools/crtfont/crtfont.c	Wed Feb 06 17:32:55 2008 +0000
    99.3 @@ -0,0 +1,305 @@
    99.4 +/*
    99.5 + * GraphLCD tool crtfont
    99.6 + *
    99.7 + * crtfont.c  -  a tool to create *.fnt files for use with the GraphLCD
    99.8 + *               graphics library
    99.9 + *
   99.10 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
   99.11 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
   99.12 + *
   99.13 + * This file is released under the GNU General Public License. Refer
   99.14 + * to the COPYING file distributed with this package.
   99.15 + *
   99.16 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
   99.17 + */
   99.18 +
   99.19 +#include <getopt.h>
   99.20 +#include <stdint.h>
   99.21 +#include <stdio.h>
   99.22 +#include <stdlib.h>
   99.23 +#include <string.h>
   99.24 +#include <glcdgraphics/bitmap.h>
   99.25 +#include <glcdgraphics/font.h>
   99.26 +
   99.27 +static const char *prgname = "crtfont";
   99.28 +static const char *version = "0.1.6";
   99.29 +
   99.30 +const int kMaxLineLength = 1024;
   99.31 +
   99.32 +enum ePicFormat
   99.33 +{
   99.34 +    undefined,
   99.35 +    PBM
   99.36 +};
   99.37 +
   99.38 +
   99.39 +void usage(void);
   99.40 +
   99.41 +char * trimleft(char * str)
   99.42 +{
   99.43 +    char * s = str;
   99.44 +    while (*s == ' ' || *s == '\t')
   99.45 +        s++;
   99.46 +    strcpy(str, s);
   99.47 +    return str;
   99.48 +}
   99.49 +
   99.50 +char * trimright(char * str)
   99.51 +{
   99.52 +    char * s = str + strlen(str) - 1;
   99.53 +    while (s >= str && (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r'))
   99.54 +        *s-- = 0;
   99.55 +    return str;
   99.56 +}
   99.57 +
   99.58 +char * trim(char * str)
   99.59 +{
   99.60 +    return trimleft(trimright(str));
   99.61 +}
   99.62 +
   99.63 +
   99.64 +int main(int argc, char *argv[])
   99.65 +{
   99.66 +    ePicFormat picFormat = undefined;
   99.67 +    GLCD::cFont font;
   99.68 +    char * picName = NULL;
   99.69 +    char * descName = NULL;
   99.70 +    char * fontName = NULL;
   99.71 +    FILE * descFile;
   99.72 +    bool error = false;
   99.73 +    GLCD::cBitmap * bitmap = NULL;
   99.74 +    GLCD::cBitmap * tmpBitmap = NULL;
   99.75 +    GLCD::cBitmap * charBitmap = NULL;
   99.76 +    char line[kMaxLineLength];
   99.77 +    int l = 0;
   99.78 +    char * token;
   99.79 +    int startOffset, endOffset;
   99.80 +    int spaceWidth;
   99.81 +    int version;
   99.82 +    char * ptr;
   99.83 +
   99.84 +    static struct option long_options[] =
   99.85 +    {
   99.86 +        { "format",   required_argument, NULL, 'f'},
   99.87 +        { "bmpfile",  required_argument, NULL, 'b'},
   99.88 +        { "descfile", required_argument, NULL, 'd'},
   99.89 +        { "outfile",  required_argument, NULL, 'o'},
   99.90 +        { NULL}
   99.91 +    };
   99.92 +
   99.93 +    int c, option_index = 0;
   99.94 +    while ((c = getopt_long(argc, argv, "f:b:d:o:", long_options, &option_index)) != -1)
   99.95 +    {
   99.96 +        switch (c)
   99.97 +        {
   99.98 +            case 'f':
   99.99 +                if (strcasecmp(optarg, "PBM") == 0)
  99.100 +                    picFormat = PBM;
  99.101 +                break;
  99.102 +
  99.103 +            case 'b':
  99.104 +                picName = strdup(optarg);
  99.105 +                break;
  99.106 +
  99.107 +            case 'd':
  99.108 +                descName = strdup(optarg);
  99.109 +                break;
  99.110 +
  99.111 +            case 'o':
  99.112 +                fontName = strdup(optarg);
  99.113 +                break;
  99.114 +
  99.115 +            default:
  99.116 +                return 1;
  99.117 +        }
  99.118 +    }
  99.119 +
  99.120 +    if (picFormat == undefined)
  99.121 +    {
  99.122 +        fprintf(stderr, "ERROR: You have to specify the format   (-f <format>)\n");
  99.123 +        error = true;
  99.124 +    }
  99.125 +    if (!picName)
  99.126 +    {
  99.127 +        fprintf(stderr, "ERROR: You have to specify the bmpfile  (-b bmpfile)\n");
  99.128 +        error = true;
  99.129 +    }
  99.130 +    if (!descName)
  99.131 +    {
  99.132 +        fprintf(stderr, "ERROR: You have to specify the descfile (-d descfile)\n");
  99.133 +        error = true;
  99.134 +    }
  99.135 +    if (!fontName)
  99.136 +    {
  99.137 +        fprintf(stderr, "ERROR: You have to specify the outfile  (-o outfile)\n");
  99.138 +        error = true;
  99.139 +    }
  99.140 +
  99.141 +    if (error)
  99.142 +    {
  99.143 +        usage();
  99.144 +        return 1;
  99.145 +    }
  99.146 +
  99.147 +    descFile = fopen(descName,"r");
  99.148 +    if (!descFile)
  99.149 +    {
  99.150 +        fprintf(stderr, "Cannot open file: %s\n",descName);
  99.151 +        return 2;
  99.152 +    }
  99.153 +
  99.154 +    // Load Picture
  99.155 +    switch (picFormat)
  99.156 +    {
  99.157 +        case PBM:
  99.158 +            bitmap = new GLCD::cBitmap(0, 0);
  99.159 +            bitmap->LoadPBM(picName);
  99.160 +            if (!bitmap)
  99.161 +            {
  99.162 +                fprintf(stderr, "Cannot open file: %s\n",picName);
  99.163 +                return 2;
  99.164 +            }
  99.165 +            break;
  99.166 +
  99.167 +        default:
  99.168 +            return 2;
  99.169 +    }
  99.170 +
  99.171 +    if (!bitmap)
  99.172 +        return 3;
  99.173 +
  99.174 +    spaceWidth = 0;
  99.175 +
  99.176 +    version = 0;
  99.177 +    fgets(line, sizeof(line), descFile);
  99.178 +    trim(line);
  99.179 +    if (strstr(line, "version") != NULL)
  99.180 +    {
  99.181 +        ptr = strstr(line, ":");
  99.182 +        version = atoi(ptr + 1);
  99.183 +    }
  99.184 +    if (version != 1)
  99.185 +    {
  99.186 +        fprintf(stderr, "Wrong description file format version (found %d, expected 1)!\n", version);
  99.187 +        return 2;
  99.188 +    }
  99.189 +    while (!feof(descFile))
  99.190 +    {
  99.191 +        fgets(line, sizeof(line), descFile);
  99.192 +        trim(line);
  99.193 +        if (strstr(line, "fontheight") != NULL)
  99.194 +        {
  99.195 +            ptr = strstr(line, ":");
  99.196 +            font.SetTotalHeight(atoi(ptr + 1));
  99.197 +        }
  99.198 +        else if (strstr(line, "fontascent") != NULL)
  99.199 +        {
  99.200 +            ptr = strstr(line, ":");
  99.201 +            font.SetTotalAscent(atoi(ptr + 1));
  99.202 +        }
  99.203 +        else if (strstr(line, "lineheight") != NULL)
  99.204 +        {
  99.205 +            ptr = strstr(line, ":");
  99.206 +            font.SetLineHeight(atoi(ptr + 1));
  99.207 +        }
  99.208 +        else if (strstr(line, "spacebetween") != NULL)
  99.209 +        {
  99.210 +            ptr = strstr(line, ":");
  99.211 +            font.SetSpaceBetween(atoi(ptr + 1));
  99.212 +        }
  99.213 +        else if (strstr(line, "spacewidth") != NULL)
  99.214 +        {
  99.215 +            ptr = strstr(line, ":");
  99.216 +            spaceWidth = atoi(ptr + 1);
  99.217 +        }
  99.218 +        else
  99.219 +        {
  99.220 +            token = strtok(line, " ");
  99.221 +            if (token)
  99.222 +            {
  99.223 +                startOffset = atoi(token);
  99.224 +
  99.225 +                // get character
  99.226 +                token = strtok(NULL, " ");
  99.227 +                while (token)
  99.228 +                {
  99.229 +                    uint16_t character;
  99.230 +                    if (strlen(token) == 1)
  99.231 +                        character = (uint8_t) token[0];
  99.232 +                    else
  99.233 +                        character = atoi(token);
  99.234 +
  99.235 +                    // get EndOffset
  99.236 +                    token = strtok(NULL, " ");
  99.237 +                    endOffset = atoi(token);
  99.238 +                    tmpBitmap = bitmap->SubBitmap(startOffset, l * font.TotalHeight(), endOffset - 1, (l + 1) * font.TotalHeight() - 1);
  99.239 +                    if (spaceWidth > 0)
  99.240 +                    {
  99.241 +                        // calculate width of this character
  99.242 +                        int x;
  99.243 +                        int y;
  99.244 +                        int left = 255;
  99.245 +                        int right = 0;
  99.246 +                        for (y = 0; y < tmpBitmap->Height(); y++)
  99.247 +                        {
  99.248 +                            for (x = 0; x < tmpBitmap->Width(); x++)
  99.249 +                            {
  99.250 +                                if (tmpBitmap->GetPixel(x, y))
  99.251 +                                    break;
  99.252 +                            }
  99.253 +                            if (x < tmpBitmap->Width() && x < left)
  99.254 +                                left = x;
  99.255 +                            for (x = tmpBitmap->Width() - 1; x >= 0; x--)
  99.256 +                            {
  99.257 +                                if (tmpBitmap->GetPixel(x, y))
  99.258 +                                    break;
  99.259 +                            }
  99.260 +                            if (x >= 0 && x > right)
  99.261 +                                right = x;
  99.262 +                        }
  99.263 +                        if (left > right)
  99.264 +                        {
  99.265 +                            left = 0;
  99.266 +                            right = spaceWidth - 1;
  99.267 +                        }
  99.268 +                        charBitmap = tmpBitmap->SubBitmap(left, 0, right, font.TotalHeight() - 1);
  99.269 +                        font.SetCharacter(character, charBitmap);
  99.270 +                        delete tmpBitmap;
  99.271 +                    }
  99.272 +                    else
  99.273 +                    {
  99.274 +                        font.SetCharacter(character, tmpBitmap);
  99.275 +                    }
  99.276 +                    startOffset = endOffset;
  99.277 +
  99.278 +                    // get next character
  99.279 +                    token = strtok(NULL, " ");
  99.280 +                }
  99.281 +            }
  99.282 +            l++;
  99.283 +        }
  99.284 +    }
  99.285 +    fclose(descFile);
  99.286 +    delete bitmap;
  99.287 +
  99.288 +    if (font.SaveFNT(fontName))
  99.289 +        fprintf(stdout,"Font '%s' created successfully\n", fontName);
  99.290 +
  99.291 +    return 0;
  99.292 +}
  99.293 +
  99.294 +void usage(void)
  99.295 +{
  99.296 +    fprintf(stdout, "\n");
  99.297 +    fprintf(stdout, "%s v%s\n", prgname, version);
  99.298 +    fprintf(stdout, "%s is a tool to create *.fnt files that are used by the\n", prgname);
  99.299 +    fprintf(stdout, "        graphlcd plugin for VDR.\n\n");
  99.300 +    fprintf(stdout, "  Usage: %s -f <format> -b bmpfile -d descfile -o outfile\n\n", prgname);
  99.301 +    fprintf(stdout, "  -f  --format      specifies the format of the bitmap. Possible values are:\n");
  99.302 +    fprintf(stdout, "                    PBM : file is an binary PBM file\n" );
  99.303 +    fprintf(stdout, "  -b  --bmpfile     specifies the name of the bitmap file (*.pbm)\n");
  99.304 +    fprintf(stdout, "  -d  --descfile    specifies the name of the description file (*.desc)\n");
  99.305 +    fprintf(stdout, "  -o  --outfile     specifies the name of the output file (*.fnt)\n");
  99.306 +    fprintf(stdout, "\n" );
  99.307 +    fprintf(stdout, "  example: %s -f PBM -b f12.pbm -d f12.desc -o f12.fnt\n", prgname);
  99.308 +}
   100.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   100.2 +++ b/graphlcd-base/tools/genfont/Makefile	Wed Feb 06 17:32:55 2008 +0000
   100.3 @@ -0,0 +1,48 @@
   100.4 +#
   100.5 +# Makefile for the GraphLCD tool crtfont
   100.6 +#
   100.7 +
   100.8 +-include ../../Make.config
   100.9 +
  100.10 +PRGNAME = genfont
  100.11 +
  100.12 +OBJS = genfont.o
  100.13 +
  100.14 +INCLUDES += -I../../
  100.15 +INCLUDES += `freetype-config --cflags`
  100.16 +
  100.17 +LIBDIRS += -L../../glcdgraphics/
  100.18 +LIBS += `freetype-config --libs`
  100.19 +
  100.20 +all: $(PRGNAME)
  100.21 +.PHONY: all
  100.22 +
  100.23 +# Implicit rules:
  100.24 +
  100.25 +%.o: %.c
  100.26 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
  100.27 +
  100.28 +# Dependencies:
  100.29 +
  100.30 +MAKEDEP = $(CXX) -MM -MG
  100.31 +DEPFILE = .dependencies
  100.32 +$(DEPFILE): Makefile
  100.33 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
  100.34 +
  100.35 +-include $(DEPFILE)
  100.36 +
  100.37 +# The main program:
  100.38 +
  100.39 +$(PRGNAME): $(OBJS)
  100.40 +	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBDIRS) $(LIBS) -lglcdgraphics -lstdc++ -o $(PRGNAME)
  100.41 +
  100.42 +install: $(PRGNAME)
  100.43 +	install -d $(BINDIR)
  100.44 +	install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
  100.45 +	
  100.46 +uninstall:
  100.47 +	rm -f $(BINDIR)/$(PRGNAME)
  100.48 +
  100.49 +clean:
  100.50 +	@-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
  100.51 +
   101.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   101.2 +++ b/graphlcd-base/tools/genfont/genfont.c	Wed Feb 06 17:32:55 2008 +0000
   101.3 @@ -0,0 +1,167 @@
   101.4 +/*
   101.5 + * GraphLCD tool genfont
   101.6 + *
   101.7 + * genfont.c  -  a tool to create *.fnt files for use with the GraphLCD
   101.8 + *               graphics library
   101.9 + *
  101.10 + * This file is released under the GNU General Public License. Refer
  101.11 + * to the COPYING file distributed with this package.
  101.12 + *
  101.13 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
  101.14 + */
  101.15 +
  101.16 +#include <getopt.h>
  101.17 +#include <stdio.h>
  101.18 +#include <stdlib.h>
  101.19 +#include <string.h>
  101.20 +
  101.21 +#include <glcdgraphics/bitmap.h>
  101.22 +#include <glcdgraphics/font.h>
  101.23 +
  101.24 +static const char *prgname = "genfont";
  101.25 +static const char *version = "0.0.2";
  101.26 +
  101.27 +void usage(void)
  101.28 +{
  101.29 +    fprintf(stdout, "\n");
  101.30 +    fprintf(stdout, "%s v%s\n", prgname, version);
  101.31 +    fprintf(stdout, "%s is a tool to create *.fnt files that are used by the\n", prgname);
  101.32 +    fprintf(stdout, "        graphlcd plugin for VDR.\n\n");
  101.33 +    fprintf(stdout, "  Usage: %s -f <format> -i infile -o outfile -s size\n\n", prgname);
  101.34 +    fprintf(stdout, "  -f  --format  specifies the format of the output files:\n");
  101.35 +    fprintf(stdout, "                  0 - fnt (default)\n");
  101.36 +    fprintf(stdout, "                  1 - pbm & desc\n");
  101.37 +    fprintf(stdout, "  -i  --input   specifies the name of the input font file (*.ttf)\n");
  101.38 +    fprintf(stdout, "  -o  --output  specifies the base name of the output files\n");
  101.39 +    fprintf(stdout, "  -s  --size    font size of the generated font file\n");
  101.40 +    fprintf(stdout, "\n" );
  101.41 +    fprintf(stdout, "  example: %s -i verdana.ttf -o verdana20 -s 20\n", prgname);
  101.42 +    fprintf(stdout, "           %s -f 1 -i verdana.ttf -o verdana20 -s 20\n", prgname);
  101.43 +}
  101.44 +
  101.45 +
  101.46 +int main(int argc, char *argv[])
  101.47 +{
  101.48 +    static struct option long_options[] =
  101.49 +    {
  101.50 +        { "format", required_argument, NULL, 'f'},
  101.51 +        { "input",  required_argument, NULL, 'i'},
  101.52 +        { "output", required_argument, NULL, 'o'},
  101.53 +        { "size",   required_argument, NULL, 's'},
  101.54 +        { NULL}
  101.55 +    };
  101.56 +
  101.57 +    int c;
  101.58 +    int option_index = 0;
  101.59 +    int format = 0;
  101.60 +    std::string inputFontFile = "";
  101.61 +    std::string outputName = "";
  101.62 +    int size = 30;
  101.63 +
  101.64 +    while ((c = getopt_long(argc, argv, "f:i:o:s:", long_options, &option_index)) != -1)
  101.65 +    {
  101.66 +        switch (c)
  101.67 +        {
  101.68 +            case 'f':
  101.69 +                format = atoi(optarg);
  101.70 +                break;
  101.71 +
  101.72 +            case 'i':
  101.73 +                inputFontFile = optarg;
  101.74 +                break;
  101.75 +
  101.76 +            case 'o':
  101.77 +                outputName = optarg;
  101.78 +                break;
  101.79 +
  101.80 +            case 's':
  101.81 +                size = atoi(optarg);
  101.82 +                break;
  101.83 +
  101.84 +            default:
  101.85 +                usage();
  101.86 +                break;
  101.87 +        }
  101.88 +    }
  101.89 +    if (format > 1)
  101.90 +    {
  101.91 +        usage();
  101.92 +        return 1;
  101.93 +    }
  101.94 +    if (inputFontFile == "")
  101.95 +    {
  101.96 +        usage();
  101.97 +        return 1;
  101.98 +    }
  101.99 +    if (outputName == "")
 101.100 +    {
 101.101 +        outputName = inputFontFile;
 101.102 +    }
 101.103 +
 101.104 +    GLCD::cFont font;
 101.105 +    if (!font.LoadFT2(inputFontFile, "iso-8859-1", size, false))
 101.106 +    {
 101.107 +        return 1;
 101.108 +    }
 101.109 +
 101.110 +    GLCD::cBitmap * bitmap = NULL;
 101.111 +    std::string fileName;
 101.112 +    FILE * descFile = NULL;
 101.113 +    int posX = 0;
 101.114 +    int posY = 0;
 101.115 +
 101.116 +    if (format == 0)
 101.117 +    {
 101.118 +        fileName = outputName + ".fnt";
 101.119 +        if (!font.SaveFNT(fileName))
 101.120 +        {
 101.121 +            return 1;
 101.122 +        }
 101.123 +    }
 101.124 +    else
 101.125 +    {
 101.126 +        fileName = outputName + ".desc";
 101.127 +        descFile = fopen(fileName.c_str(), "wb");
 101.128 +        if (!descFile)
 101.129 +        {
 101.130 +            fprintf(stderr, "Cannot open file: %s\n", fileName.c_str());
 101.131 +            return 1;
 101.132 +        }
 101.133 +        bitmap = new GLCD::cBitmap(32 * font.TotalWidth(), 8 * font.TotalHeight());
 101.134 +        bitmap->Clear();
 101.135 +        fprintf(descFile, "version:1\n");
 101.136 +        fprintf(descFile, "fontheight:%d\n", font.TotalHeight());
 101.137 +        fprintf(descFile, "fontascent:%d\n", font.TotalAscent());
 101.138 +        fprintf(descFile, "lineheight:%d\n", font.LineHeight());
 101.139 +        fprintf(descFile, "spacebetween:%d\n", 0);
 101.140 +        fprintf(descFile, "spacewidth:%d\n", 0);
 101.141 +
 101.142 +        for (unsigned int i = 0; i < 256; i++)
 101.143 +        {
 101.144 +            const GLCD::cBitmap * charBitmap = font.GetCharacter((char) i);
 101.145 +            if (charBitmap == NULL)
 101.146 +                continue;
 101.147 +
 101.148 +            bitmap->DrawBitmap(posX, posY, *charBitmap, GLCD::clrBlack);
 101.149 +            fprintf(descFile, "%d %d ", posX, i);
 101.150 +            posX += charBitmap->Width();
 101.151 +            if ((i % 32) == 31)
 101.152 +            {
 101.153 +                fprintf(descFile, "%d\n", posX);
 101.154 +                posY += font.TotalHeight();
 101.155 +                posX = 0;
 101.156 +            }
 101.157 +        }
 101.158 +
 101.159 +        if (posX > 0) // write last end marker
 101.160 +            fprintf(descFile, "%d\n", posX);
 101.161 +        fileName = outputName + ".pbm";
 101.162 +        bitmap->SavePBM(fileName);
 101.163 +        delete bitmap;
 101.164 +        fclose(descFile);
 101.165 +    }
 101.166 +
 101.167 +    fprintf(stdout, "Font successfully generated.\n");
 101.168 +
 101.169 +    return 0;
 101.170 +}
   102.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   102.2 +++ b/graphlcd-base/tools/lcdtestpattern/Makefile	Wed Feb 06 17:32:55 2008 +0000
   102.3 @@ -0,0 +1,46 @@
   102.4 +#
   102.5 +# Makefile for the GraphLCD tool showpic
   102.6 +#
   102.7 +
   102.8 +-include ../../Make.config
   102.9 +
  102.10 +PRGNAME = lcdtestpattern
  102.11 +
  102.12 +OBJS = lcdtestpattern.o
  102.13 +
  102.14 +INCLUDES += -I../../
  102.15 +LIBDIRS += -L../../glcdgraphics/ -L../../glcddrivers/
  102.16 +
  102.17 +
  102.18 +all: $(PRGNAME)
  102.19 +.PHONY: all
  102.20 +
  102.21 +# Implicit rules:
  102.22 +
  102.23 +%.o: %.c
  102.24 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
  102.25 +
  102.26 +# Dependencies:
  102.27 +
  102.28 +MAKEDEP = $(CXX) -MM -MG
  102.29 +DEPFILE = .dependencies
  102.30 +$(DEPFILE): Makefile
  102.31 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
  102.32 +
  102.33 +-include $(DEPFILE)
  102.34 +
  102.35 +# The main program:
  102.36 +
  102.37 +$(PRGNAME): $(OBJS)
  102.38 +	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lglcddrivers -lstdc++ -o $(PRGNAME)
  102.39 +
  102.40 +install: $(PRGNAME)
  102.41 +	install -d $(BINDIR)
  102.42 +	install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
  102.43 +
  102.44 +uninstall:
  102.45 +	rm -f $(BINDIR)/$(PRGNAME)
  102.46 +
  102.47 +clean:
  102.48 +	@-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
  102.49 +
   103.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   103.2 +++ b/graphlcd-base/tools/lcdtestpattern/lcdtestpattern.c	Wed Feb 06 17:32:55 2008 +0000
   103.3 @@ -0,0 +1,260 @@
   103.4 +/*
   103.5 + * GraphLCD tool lcdtestpattern
   103.6 + *
   103.7 + * lcdtestpattern.c  -  a tool to display some testpattern on an GLCD
   103.8 + *
   103.9 + * based on showpic.c of graphlcd-base
  103.10 + *   (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
  103.11 + *
  103.12 + * This file is released under the GNU General Public License. Refer
  103.13 + * to the COPYING file distributed with this package.
  103.14 + *
  103.15 + * (c) 2007 Alexander Rieger (Alexander.Rieger AT inka.de)
  103.16 + */
  103.17 +
  103.18 +//-----------------------------------------------------------------------------
  103.19 +#include <stdio.h>
  103.20 +#include <string.h>
  103.21 +#include <stdlib.h>
  103.22 +#include <getopt.h>
  103.23 +#include <dlfcn.h>
  103.24 +#include <unistd.h>
  103.25 +#include <syslog.h>
  103.26 +#include <signal.h>
  103.27 +
  103.28 +#include <string>
  103.29 +
  103.30 +#include <glcdgraphics/bitmap.h>
  103.31 +#include <glcdgraphics/glcd.h>
  103.32 +#include <glcdgraphics/image.h>
  103.33 +#include <glcddrivers/config.h>
  103.34 +#include <glcddrivers/common.h>
  103.35 +#include <glcddrivers/driver.h>
  103.36 +#include <glcddrivers/drivers.h>
  103.37 +
  103.38 +//-----------------------------------------------------------------------------
  103.39 +static const char *prgname = "lcdtestpattern";
  103.40 +static const char *version = "0.1.0";
  103.41 +
  103.42 +static const int kDefaultSleepMs = 0;
  103.43 +static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
  103.44 +
  103.45 +static volatile bool stopProgramm = false;
  103.46 +
  103.47 +//-----------------------------------------------------------------------------
  103.48 +static void sighandler(int signal)
  103.49 +{
  103.50 +	switch (signal)
  103.51 +	{
  103.52 +		case SIGINT:
  103.53 +		case SIGQUIT:
  103.54 +		case SIGTERM:
  103.55 +			stopProgramm = true;
  103.56 +	} // switch
  103.57 +} // sighandler()
  103.58 +
  103.59 +//-----------------------------------------------------------------------------
  103.60 +void usage()
  103.61 +{
  103.62 +    fprintf(stdout, "\n");
  103.63 +    fprintf(stdout, "%s v%s\n", prgname, version);
  103.64 +    fprintf(stdout, "%s is a tool to show test patterns on a LCD.\n", prgname);
  103.65 +    fprintf(stdout, "\n");
  103.66 +    fprintf(stdout, "  Usage: %s [-c CONFIGFILE] [-d DISPLAY] [-s SLEEP] [-uie]\n\n", prgname);
  103.67 +    fprintf(stdout, "  -c  --config      specifies the location of the config file\n");
  103.68 +    fprintf(stdout, "                    (default: /etc/graphlcd.conf)\n");
  103.69 +    fprintf(stdout, "  -d  --display     specifies the output display (default is the first one)\n");
  103.70 +    fprintf(stdout, "  -u  --upsidedown  rotates the output by 180 degrees (default: no)\n");
  103.71 +    fprintf(stdout, "  -i  --invert      inverts the output (default: no)\n");
  103.72 +    fprintf(stdout, "  -e  --endless     show all images in endless loop (default: no)\n");
  103.73 +    fprintf(stdout, "  -s  --sleep       set sleeptime between two patterns [ms] (default: %d ms)\n", kDefaultSleepMs);
  103.74 +    fprintf(stdout, "  -b  --brightness  set brightness for display if driver support it [%%]\n");
  103.75 +    fprintf(stdout, "                    (default: config file value)\n");
  103.76 +    fprintf(stdout, "\n" );
  103.77 +    fprintf(stdout, "  examples: %s -c /etc/graphlcd.conf\n", prgname);
  103.78 +    fprintf(stdout, "            %s -c /etc/graphlcd.conf -d LCD_T6963 -u -i\n", prgname);
  103.79 +    fprintf(stdout, "\n" );
  103.80 +} // usage()
  103.81 +
  103.82 +//-----------------------------------------------------------------------------
  103.83 +int main(int argc, char *argv[])
  103.84 +{
  103.85 +    static struct option long_options[] =
  103.86 +    {
  103.87 +        {"config",     required_argument, NULL, 'c'},
  103.88 +        {"display",    required_argument, NULL, 'd'},
  103.89 +        {"sleep",      required_argument, NULL, 's'},
  103.90 +        {"endless",          no_argument, NULL, 'e'},
  103.91 +        {"upsidedown",       no_argument, NULL, 'u'},
  103.92 +        {"invert",           no_argument, NULL, 'i'},
  103.93 +        {"brightness", required_argument, NULL, 'b'},
  103.94 +        {NULL}
  103.95 +    };
  103.96 +
  103.97 +    std::string configName = "";
  103.98 +    std::string displayName = "";
  103.99 +    bool upsideDown = false;
 103.100 +    bool invert = false;
 103.101 +    int brightness = -1;
 103.102 +    bool delay = false;
 103.103 +    int sleepMs = kDefaultSleepMs;
 103.104 +    bool endless = false;
 103.105 +    unsigned int displayNumber = 0;
 103.106 +
 103.107 +    int c, option_index = 0;
 103.108 +    while ((c = getopt_long(argc, argv, "c:d:s:euib:", long_options, &option_index)) != -1)
 103.109 +    {
 103.110 +        switch(c)
 103.111 +        {
 103.112 +          case 'c':
 103.113 +              configName = optarg;
 103.114 +              break;
 103.115 +
 103.116 +          case 'd':
 103.117 +              displayName = optarg;
 103.118 +              break;
 103.119 +
 103.120 +          case 'u':
 103.121 +              upsideDown = true;
 103.122 +              break;
 103.123 +
 103.124 +          case 'i':
 103.125 +              invert = true;
 103.126 +              break;
 103.127 +
 103.128 +          case 's':
 103.129 +              sleepMs = atoi(optarg);
 103.130 +              delay = true;
 103.131 +              break;
 103.132 +
 103.133 +          case 'e':
 103.134 +              endless = true;
 103.135 +              break;
 103.136 +
 103.137 +          case 'b':
 103.138 +              brightness = atoi(optarg);
 103.139 +              if (brightness < 0) brightness = 0;
 103.140 +              if (brightness > 100) brightness = 100;
 103.141 +              break;
 103.142 +
 103.143 +          default:
 103.144 +              usage();
 103.145 +              return 1;
 103.146 +        } // switch
 103.147 +    } // while
 103.148 +
 103.149 +    if (configName.length() == 0)
 103.150 +    {
 103.151 +        configName = kDefaultConfigFile;
 103.152 +        syslog(LOG_INFO, "Error: No config file specified, using default (%s).\n", configName.c_str());
 103.153 +    } // if
 103.154 +
 103.155 +    if (GLCD::Config.Load(configName) == false)
 103.156 +    {
 103.157 +        fprintf(stdout, "Error loading config file!\n");
 103.158 +        return 2;
 103.159 +    } // if
 103.160 +
 103.161 +    if (GLCD::Config.driverConfigs.size() > 0)
 103.162 +    {
 103.163 +        if (displayName.length() > 0)
 103.164 +        {
 103.165 +            for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
 103.166 +            {
 103.167 +              if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
 103.168 +                break;
 103.169 +            } // for
 103.170 +
 103.171 +            if (displayNumber == GLCD::Config.driverConfigs.size())
 103.172 +            {
 103.173 +              fprintf(stdout, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
 103.174 +              return 3;
 103.175 +            } // if
 103.176 +        }
 103.177 +        else
 103.178 +        {
 103.179 +            fprintf(stdout, "WARNING: No display specified, using first one.\n");
 103.180 +            displayNumber = 0;
 103.181 +        } // if
 103.182 +    }
 103.183 +    else
 103.184 +    {
 103.185 +        fprintf(stdout, "ERROR: No displays specified in config file!\n");
 103.186 +        return 4;
 103.187 +    } // if
 103.188 +
 103.189 +    GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
 103.190 +    GLCD::Config.driverConfigs[displayNumber].invert     ^= invert;
 103.191 +
 103.192 +    if (brightness != -1)
 103.193 +    {
 103.194 +        GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
 103.195 +    } // if
 103.196 +
 103.197 +    GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
 103.198 +    if (!lcd)
 103.199 +    {
 103.200 +        fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
 103.201 +        return 6;
 103.202 +    } // if
 103.203 +
 103.204 +    if (lcd->Init() != 0)
 103.205 +    {
 103.206 +        fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
 103.207 +        delete lcd;
 103.208 +        return 7;
 103.209 +    } // if
 103.210 +
 103.211 +    lcd->SetBrightness(GLCD::Config.driverConfigs[displayNumber].brightness);
 103.212 +
 103.213 +    signal(SIGINT, sighandler);
 103.214 +    signal(SIGQUIT, sighandler);
 103.215 +    signal(SIGTERM, sighandler);
 103.216 +    signal(SIGHUP, sighandler);
 103.217 +
 103.218 +    //----- show horizontal lines -----
 103.219 +    for (int aByte = 1; aByte <= 255 && !stopProgramm; ++aByte)
 103.220 +    {
 103.221 +        unsigned char aData = GLCD::ReverseBits(aByte);
 103.222 +        printf("clear and test byte: 0x%02X\n", aByte);
 103.223 +        lcd->Clear();
 103.224 +
 103.225 +        for (int y = 0; y < lcd->Height() && !stopProgramm; ++y)
 103.226 +        {
 103.227 +            for (int x = 0; x < lcd->Width() && !stopProgramm; x += 8)
 103.228 +            {
 103.229 +               lcd->Set8Pixels(x, y, aData);
 103.230 +            } // for
 103.231 +        } // for
 103.232 +
 103.233 +        lcd->Refresh(true);
 103.234 +        usleep(sleepMs * 1000);
 103.235 +    } // for
 103.236 +
 103.237 +    //----- show vertial lines -----
 103.238 +    for (int aByte = 1; aByte <= 255 && !stopProgramm; ++aByte)
 103.239 +    {
 103.240 +        printf("clear and test byte: 0x%02X\n", aByte);
 103.241 +        lcd->Clear();
 103.242 +
 103.243 +        for (int y = 0; y < lcd->Height() && !stopProgramm; ++y)
 103.244 +        {
 103.245 +            unsigned char aData = (((1 << (y % 8)) & aByte) == 0) ? 0x00 : 0xFF;
 103.246 +            for (int x = 0; x < lcd->Width() && !stopProgramm; x += 8)
 103.247 +            {
 103.248 +               lcd->Set8Pixels(x, y, aData);
 103.249 +            } // for
 103.250 +        } // for
 103.251 +
 103.252 +        lcd->Refresh(true);
 103.253 +        usleep(sleepMs * 1000);
 103.254 +    } // for
 103.255 +
 103.256 +    //----- cleanup -----
 103.257 +    lcd->Clear();
 103.258 +    lcd->Refresh(true);
 103.259 +    lcd->DeInit();
 103.260 +    delete lcd;
 103.261 +
 103.262 +    return 0;
 103.263 +} // main()
   104.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   104.2 +++ b/graphlcd-base/tools/showpic/Makefile	Wed Feb 06 17:32:55 2008 +0000
   104.3 @@ -0,0 +1,46 @@
   104.4 +#
   104.5 +# Makefile for the GraphLCD tool showpic
   104.6 +#
   104.7 +
   104.8 +-include ../../Make.config
   104.9 +
  104.10 +PRGNAME = showpic
  104.11 +
  104.12 +OBJS = showpic.o
  104.13 +
  104.14 +INCLUDES += -I../../
  104.15 +LIBDIRS += -L../../glcdgraphics/ -L../../glcddrivers/
  104.16 +
  104.17 +
  104.18 +all: $(PRGNAME)
  104.19 +.PHONY: all
  104.20 +
  104.21 +# Implicit rules:
  104.22 +
  104.23 +%.o: %.c
  104.24 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
  104.25 +
  104.26 +# Dependencies:
  104.27 +
  104.28 +MAKEDEP = $(CXX) -MM -MG
  104.29 +DEPFILE = .dependencies
  104.30 +$(DEPFILE): Makefile
  104.31 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
  104.32 +
  104.33 +-include $(DEPFILE)
  104.34 +
  104.35 +# The main program:
  104.36 +
  104.37 +$(PRGNAME): $(OBJS)
  104.38 +	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lglcddrivers -lstdc++ -o $(PRGNAME)
  104.39 +
  104.40 +install: $(PRGNAME)
  104.41 +	install -d $(BINDIR)
  104.42 +	install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
  104.43 +
  104.44 +uninstall:
  104.45 +	rm -f $(BINDIR)/$(PRGNAME)
  104.46 +
  104.47 +clean:
  104.48 +	@-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
  104.49 +
   105.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   105.2 +++ b/graphlcd-base/tools/showpic/showpic.c	Wed Feb 06 17:32:55 2008 +0000
   105.3 @@ -0,0 +1,256 @@
   105.4 +/*
   105.5 + * GraphLCD tool showpic
   105.6 + *
   105.7 + * showpic.c  -  a tool to show image files in GLCD format on a LCD
   105.8 + *
   105.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
  105.10 + *  (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
  105.11 + *  
  105.12 + * This file is released under the GNU General Public License. Refer
  105.13 + * to the COPYING file distributed with this package.
  105.14 + *
  105.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
  105.16 + */
  105.17 +
  105.18 +#include <stdio.h>
  105.19 +#include <string.h>
  105.20 +#include <stdlib.h>
  105.21 +#include <getopt.h>
  105.22 +#include <dlfcn.h>
  105.23 +#include <unistd.h>
  105.24 +#include <syslog.h>
  105.25 +#include <signal.h>
  105.26 +
  105.27 +#include <string>
  105.28 +
  105.29 +#include <glcdgraphics/bitmap.h>
  105.30 +#include <glcdgraphics/glcd.h>
  105.31 +#include <glcdgraphics/image.h>
  105.32 +#include <glcddrivers/config.h>
  105.33 +#include <glcddrivers/driver.h>
  105.34 +#include <glcddrivers/drivers.h>
  105.35 +
  105.36 +static const char *prgname = "showpic";
  105.37 +static const char *version = "0.1.2";
  105.38 +
  105.39 +static const int kDefaultSleepMs = 100;
  105.40 +static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
  105.41 +
  105.42 +static volatile bool stopProgramm = false;
  105.43 +
  105.44 +static void sighandler(int signal)
  105.45 +{
  105.46 +	switch (signal)
  105.47 +	{
  105.48 +		case SIGINT:
  105.49 +		case SIGQUIT:
  105.50 +		case SIGTERM:
  105.51 +			stopProgramm = true;
  105.52 +	}
  105.53 +}
  105.54 +
  105.55 +void usage()
  105.56 +{
  105.57 +	fprintf(stdout, "\n");
  105.58 +	fprintf(stdout, "%s v%s\n", prgname, version);
  105.59 +	fprintf(stdout, "%s is a tool to show an image on a LCD.\n", prgname);
  105.60 +	fprintf(stdout, "The image must be in a special format (*.glcd).\n");
  105.61 +	fprintf(stdout, "You can create such images with the convpic tool.\n\n");
  105.62 +	fprintf(stdout, "  Usage: %s [-c CONFIGFILE] [-d DISPLAY] [-s SLEEP] [-uie] file [more files]\n\n", prgname);
  105.63 +	fprintf(stdout, "  -c  --config      specifies the location of the config file\n");
  105.64 +	fprintf(stdout, "                    (default: /etc/graphlcd.conf)\n");
  105.65 +	fprintf(stdout, "  -d  --display     specifies the output display (default is the first one)\n");
  105.66 +	fprintf(stdout, "  -u  --upsidedown  rotates the output by 180 degrees (default: no)\n");
  105.67 +	fprintf(stdout, "  -i  --invert      inverts the output (default: no)\n");
  105.68 +	fprintf(stdout, "  -e  --endless     show all images in endless loop (default: no)\n");
  105.69 +	fprintf(stdout, "  -s  --sleep       set sleeptime between two images [ms] (default: %d ms)\n", kDefaultSleepMs);
  105.70 +	fprintf(stdout, "  -b  --brightness  set brightness for display if driver support it [%%]\n");
  105.71 +	fprintf(stdout, "                    (default: config file value)\n");
  105.72 +	fprintf(stdout, "\n" );
  105.73 +	fprintf(stdout, "  examples: %s -c /etc/graphlcd.conf vdr-logo.glcd\n", prgname);
  105.74 +	fprintf(stdout, "            %s -c /etc/graphlcd.conf -d LCD_T6963 -u -i vdr-logo.glcd\n", prgname);
  105.75 +	fprintf(stdout, "\n" );
  105.76 +}
  105.77 +
  105.78 +int main(int argc, char *argv[])
  105.79 +{
  105.80 +	static struct option long_options[] =
  105.81 +	{
  105.82 +		{"config",     required_argument, NULL, 'c'},
  105.83 +		{"display",    required_argument, NULL, 'd'},
  105.84 +		{"sleep",      required_argument, NULL, 's'},
  105.85 +		{"endless",          no_argument, NULL, 'e'},
  105.86 +		{"upsidedown",       no_argument, NULL, 'u'},
  105.87 +		{"invert",           no_argument, NULL, 'i'},
  105.88 +		{"brightness", required_argument, NULL, 'b'},
  105.89 +		{NULL}
  105.90 +	};
  105.91 +
  105.92 +	std::string configName = "";
  105.93 +	std::string displayName = "";
  105.94 +	bool upsideDown = false;
  105.95 +	bool invert = false;
  105.96 +	int brightness = -1;
  105.97 +	bool delay = false;
  105.98 +	int sleepMs = 100;
  105.99 +	bool endless = false;
 105.100 +	unsigned int displayNumber = 0;
 105.101 +
 105.102 +	int c, option_index = 0;
 105.103 +	while ((c = getopt_long(argc, argv, "c:d:s:euib:", long_options, &option_index)) != -1)
 105.104 +	{
 105.105 +		switch(c)
 105.106 +		{
 105.107 +			case 'c':
 105.108 +				configName = optarg;
 105.109 +				break;
 105.110 +
 105.111 +			case 'd':
 105.112 +				displayName = optarg;
 105.113 +				break;
 105.114 +
 105.115 +			case 'u':
 105.116 +				upsideDown = true;
 105.117 +				break;
 105.118 +
 105.119 +			case 'i':
 105.120 +				invert = true;
 105.121 +				break;
 105.122 +
 105.123 +			case 's':
 105.124 +				sleepMs = atoi(optarg);
 105.125 +				delay = true;
 105.126 +				break;
 105.127 +
 105.128 +			case 'e':
 105.129 +				endless = true;
 105.130 +				break;
 105.131 +
 105.132 +			case 'b':
 105.133 +				brightness = atoi(optarg);
 105.134 +				if (brightness < 0) brightness = 0;
 105.135 +				if (brightness > 100) brightness = 100;
 105.136 +				break;
 105.137 +
 105.138 +			default:
 105.139 +				usage();
 105.140 +				return 1;
 105.141 +		}
 105.142 +	}
 105.143 +
 105.144 +	if (configName.length() == 0)
 105.145 +	{
 105.146 +		configName = kDefaultConfigFile;
 105.147 +		syslog(LOG_INFO, "Error: No config file specified, using default (%s).\n", configName.c_str());
 105.148 +	}
 105.149 +
 105.150 +	if (GLCD::Config.Load(configName) == false)
 105.151 +	{
 105.152 +		fprintf(stdout, "Error loading config file!\n");
 105.153 +		return 2;
 105.154 +	}
 105.155 +	if (GLCD::Config.driverConfigs.size() > 0)
 105.156 +	{
 105.157 +		if (displayName.length() > 0)
 105.158 +		{
 105.159 +			for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
 105.160 +			{
 105.161 +				if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
 105.162 +					break;
 105.163 +			}
 105.164 +			if (displayNumber == GLCD::Config.driverConfigs.size())
 105.165 +			{
 105.166 +				fprintf(stdout, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
 105.167 +				return 3;
 105.168 +			}
 105.169 +		}
 105.170 +		else
 105.171 +		{
 105.172 +			fprintf(stdout, "WARNING: No display specified, using first one.\n");
 105.173 +			displayNumber = 0;
 105.174 +		}
 105.175 +	}
 105.176 +	else
 105.177 +	{
 105.178 +		fprintf(stdout, "ERROR: No displays specified in config file!\n");
 105.179 +		return 4;
 105.180 +	}
 105.181 +
 105.182 +	if (optind == argc)
 105.183 +	{
 105.184 +		usage();
 105.185 +		fprintf(stderr, "ERROR: You have to specify the image\n");
 105.186 +		return 5;
 105.187 +	}
 105.188 +
 105.189 +	GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
 105.190 +	GLCD::Config.driverConfigs[displayNumber].invert ^= invert;
 105.191 +	if (brightness != -1)
 105.192 +		GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
 105.193 +	GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
 105.194 +	if (!lcd)
 105.195 +	{
 105.196 +		fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
 105.197 +		return 6;
 105.198 +	}
 105.199 +	if (lcd->Init() != 0)
 105.200 +	{
 105.201 +		fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
 105.202 +		delete lcd;
 105.203 +		return 7;
 105.204 +	}
 105.205 +  lcd->SetBrightness(GLCD::Config.driverConfigs[displayNumber].brightness);
 105.206 +
 105.207 +	signal(SIGINT, sighandler);
 105.208 +	signal(SIGQUIT, sighandler);
 105.209 +	signal(SIGTERM, sighandler);
 105.210 +	signal(SIGHUP, sighandler);
 105.211 +
 105.212 +	const GLCD::cBitmap * bitmap;
 105.213 +	GLCD::cImage image;
 105.214 +	GLCD::cGLCDFile glcd;
 105.215 +	int optFile;
 105.216 +	std::string picFile;
 105.217 +
 105.218 +	optFile = optind;
 105.219 +	while (optFile < argc && !stopProgramm)
 105.220 +	{
 105.221 +		picFile = argv[optFile++];
 105.222 +		if (glcd.Load(image, picFile) == false)
 105.223 +		{
 105.224 +			fprintf(stderr, "ERROR: Failed loading file %s\n", picFile.c_str());
 105.225 +			return 8;
 105.226 +		}
 105.227 +
 105.228 +		if (delay)
 105.229 +			image.SetDelay(sleepMs);
 105.230 +
 105.231 +		while ((bitmap = image.GetBitmap()) != NULL && !stopProgramm)
 105.232 +		{
 105.233 +			lcd->SetScreen(bitmap->Data(), bitmap->Width(), bitmap->Height(), bitmap->LineSize());
 105.234 +			lcd->Refresh(true);
 105.235 +
 105.236 +			if (image.Next(0)) // Select next image
 105.237 +			{
 105.238 +				usleep(image.Delay() * 1000);
 105.239 +			}
 105.240 +			else if (endless && argc == (optind + 1)) // Endless and one and only image
 105.241 +			{
 105.242 +				image.First(0);
 105.243 +				usleep(image.Delay() * 1000);
 105.244 +			}
 105.245 +			else 
 105.246 +				break;
 105.247 +		}
 105.248 +
 105.249 +		if (optFile < argc || endless)
 105.250 +			usleep(sleepMs * 1000);
 105.251 +		if (optFile >= argc && endless)
 105.252 +			optFile = optind;
 105.253 +	}
 105.254 +
 105.255 +	lcd->DeInit();
 105.256 +	delete lcd;
 105.257 +
 105.258 +	return 0;
 105.259 +}
   106.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   106.2 +++ b/graphlcd-base/tools/showtext/Makefile	Wed Feb 06 17:32:55 2008 +0000
   106.3 @@ -0,0 +1,46 @@
   106.4 +#
   106.5 +# Makefile for the GraphLCD tool showtext
   106.6 +#
   106.7 +
   106.8 +-include ../../Make.config
   106.9 +
  106.10 +PRGNAME = showtext
  106.11 +
  106.12 +OBJS = showtext.o
  106.13 +
  106.14 +INCLUDES += -I../../
  106.15 +LIBDIRS += -L../../glcdgraphics/ -L../../glcddrivers/
  106.16 +
  106.17 +
  106.18 +all: $(PRGNAME)
  106.19 +.PHONY: all
  106.20 +
  106.21 +# Implicit rules:
  106.22 +
  106.23 +%.o: %.c
  106.24 +	$(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
  106.25 +
  106.26 +# Dependencies:
  106.27 +
  106.28 +MAKEDEP = $(CXX) -MM -MG
  106.29 +DEPFILE = .dependencies
  106.30 +$(DEPFILE): Makefile
  106.31 +	@$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
  106.32 +
  106.33 +-include $(DEPFILE)
  106.34 +
  106.35 +# The main program:
  106.36 +
  106.37 +$(PRGNAME): $(OBJS)
  106.38 +	$(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lglcddrivers -lstdc++ -o $(PRGNAME)
  106.39 +
  106.40 +install: $(PRGNAME)
  106.41 +	install -d $(BINDIR)
  106.42 +	install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
  106.43 +
  106.44 +uninstall:
  106.45 +	rm -f $(BINDIR)/$(PRGNAME)
  106.46 +
  106.47 +clean:
  106.48 +	@-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
  106.49 +
   107.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   107.2 +++ b/graphlcd-base/tools/showtext/showtext.c	Wed Feb 06 17:32:55 2008 +0000
   107.3 @@ -0,0 +1,279 @@
   107.4 +/*
   107.5 + * GraphLCD tool showtext
   107.6 + *
   107.7 + * showtext.c  -  a tool to show a text on a LCD
   107.8 + *
   107.9 + * This file is released under the GNU General Public License. Refer
  107.10 + * to the COPYING file distributed with this package.
  107.11 + *
  107.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
  107.13 + */
  107.14 +
  107.15 +#include <stdio.h>
  107.16 +#include <string.h>
  107.17 +#include <stdlib.h>
  107.18 +#include <getopt.h>
  107.19 +#include <unistd.h>
  107.20 +
  107.21 +#include <string>
  107.22 +
  107.23 +#include <glcdgraphics/bitmap.h>
  107.24 +#include <glcdgraphics/font.h>
  107.25 +#include <glcddrivers/config.h>
  107.26 +#include <glcddrivers/driver.h>
  107.27 +#include <glcddrivers/drivers.h>
  107.28 +
  107.29 +static const char *prgname = "showtext";
  107.30 +static const char *version = "0.0.3";
  107.31 +
  107.32 +static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
  107.33 +
  107.34 +static const int kFontFNT = 0;
  107.35 +static const int kFontFT2 = 1;
  107.36 +
  107.37 +void usage()
  107.38 +{
  107.39 +	fprintf(stdout, "\n");
  107.40 +	fprintf(stdout, "%s v%s\n", prgname, version);
  107.41 +	fprintf(stdout, "%s is a tool to show a text on a LCD.\n", prgname);
  107.42 +	fprintf(stdout, "\n");
  107.43 +	fprintf(stdout, "  Usage: %s [-c CONFIGFILE] [-d DISPLAY] [-f FONT] [-x XPOS] [-y YPOS] [-uib] text [more text]\n\n", prgname);
  107.44 +	fprintf(stdout, "  -c  --config      specifies the location of the config file\n");
  107.45 +	fprintf(stdout, "                    (default: /etc/graphlcd.conf)\n");
  107.46 +	fprintf(stdout, "  -d  --display     specifies the output display (default is the first one)\n");
  107.47 +	fprintf(stdout, "  -f  --font        specifies the font that is used for the text:\n");
  107.48 +	fprintf(stdout, "                    fnt:/path/to/font.fnt for GraphLCD font format\n");
  107.49 +	fprintf(stdout, "                    ft2:/path/to/font.ttf:size for FreeType2 supported fonts\n");
  107.50 +	fprintf(stdout, "  -e  --encoding    specifies the encoding that is used for the text\n");
  107.51 +	fprintf(stdout, "                    (p.e. iso8859-1)\n");
  107.52 +	fprintf(stdout, "  -x  --xpos        specifies the x-position where the text starts\n");
  107.53 +	fprintf(stdout, "  -y  --ypos        specifies the y-position where the text starts\n");
  107.54 +	fprintf(stdout, "  -u  --upsidedown  rotates the output by 180 degrees (default: no)\n");
  107.55 +	fprintf(stdout, "  -i  --invert      inverts the output (default: no)\n");
  107.56 +	fprintf(stdout, "  -b  --brightness  set brightness for display if driver support it [%%]\n");
  107.57 +	fprintf(stdout, "                    (default: config file value)\n");
  107.58 +	fprintf(stdout, "\n" );
  107.59 +	fprintf(stdout, "  example: %s -c /etc/graphlcd.conf -f fnt:f17.fnt \"Line1\" \"Line2\"\n", prgname);
  107.60 +	fprintf(stdout, "\n" );
  107.61 +}
  107.62 +
  107.63 +int main(int argc, char *argv[])
  107.64 +{
  107.65 +	static struct option long_options[] =
  107.66 +	{
  107.67 +		{"config",     required_argument, NULL, 'c'},
  107.68 +		{"display",    required_argument, NULL, 'd'},
  107.69 +		{"font",       required_argument, NULL, 'f'},
  107.70 +		{"encoding",   required_argument, NULL, 'e'},
  107.71 +		{"upsidedown",       no_argument, NULL, 'u'},
  107.72 +		{"invert",           no_argument, NULL, 'i'},
  107.73 +		{"brightness", required_argument, NULL, 'b'},
  107.74 +		{"xpos",       required_argument, NULL, 'x'},
  107.75 +		{"ypos",       required_argument, NULL, 'y'},
  107.76 +		{NULL}
  107.77 +	};
  107.78 +
  107.79 +	std::string configName = "";
  107.80 +	std::string displayName = "";
  107.81 +	std::string fontName;
  107.82 +	std::string fontFileName = "";
  107.83 +	std::string encoding = "";
  107.84 +	int fontType;
  107.85 +	int fontSize = 16;
  107.86 +	bool upsideDown = false;
  107.87 +	bool invert = false;
  107.88 +	int brightness = -1;
  107.89 +	int x = 0;
  107.90 +	int y = 0;
  107.91 +	unsigned int displayNumber = 0;
  107.92 +
  107.93 +	int c, option_index = 0;
  107.94 +	while ((c = getopt_long(argc, argv, "c:d:f:e:uib:x:y:", long_options, &option_index)) != -1)
  107.95 +	{
  107.96 +		switch (c)
  107.97 +		{
  107.98 +			case 'c':
  107.99 +				configName = optarg;
 107.100 +				break;
 107.101 +
 107.102 +			case 'd':
 107.103 +				displayName = optarg;
 107.104 +				break;
 107.105 +
 107.106 +			case 'f':
 107.107 +				fontName = optarg;
 107.108 +				break;
 107.109 +
 107.110 +			case 'e':
 107.111 +				encoding = optarg;
 107.112 +				break;
 107.113 +
 107.114 +			case 'u':
 107.115 +				upsideDown = true;
 107.116 +				break;
 107.117 +
 107.118 +			case 'i':
 107.119 +				invert = true;
 107.120 +				break;
 107.121 +
 107.122 +			case 'b':
 107.123 +				brightness = atoi(optarg);
 107.124 +				if (brightness < 0) brightness = 0;
 107.125 +				if (brightness > 100) brightness = 100;
 107.126 +				break;
 107.127 +
 107.128 +			case 'x':
 107.129 +				x = atoi(optarg);
 107.130 +				break;
 107.131 +
 107.132 +			case 'y':
 107.133 +				y = atoi(optarg);
 107.134 +				break;
 107.135 +
 107.136 +			default:
 107.137 +				usage();
 107.138 +				return 1;
 107.139 +		}
 107.140 +	}
 107.141 +
 107.142 +	if (configName.length() == 0)
 107.143 +	{
 107.144 +		configName = kDefaultConfigFile;
 107.145 +		fprintf(stdout, "WARNING: No config file specified, using default (%s).\n", configName.c_str());
 107.146 +	}
 107.147 +
 107.148 +	if (GLCD::Config.Load(configName) == false)
 107.149 +	{
 107.150 +		fprintf(stderr, "Error loading config file!\n");
 107.151 +		return 2;
 107.152 +	}
 107.153 +	if (GLCD::Config.driverConfigs.size() > 0)
 107.154 +	{
 107.155 +		if (displayName.length() > 0)
 107.156 +		{
 107.157 +			for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
 107.158 +			{
 107.159 +				if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
 107.160 +					break;
 107.161 +			}
 107.162 +			if (displayNumber == GLCD::Config.driverConfigs.size())
 107.163 +			{
 107.164 +				fprintf(stderr, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
 107.165 +				return 3;
 107.166 +			}
 107.167 +		}
 107.168 +		else
 107.169 +		{
 107.170 +			fprintf(stdout, "WARNING: No display specified, using first one.\n");
 107.171 +			displayNumber = 0;
 107.172 +		}
 107.173 +	}
 107.174 +	else
 107.175 +	{
 107.176 +		fprintf(stderr, "ERROR: No displays specified in config file!\n");
 107.177 +		return 4;
 107.178 +	}
 107.179 +
 107.180 +	if (encoding.length() == 0)
 107.181 +	{
 107.182 +		encoding = "iso8859-1";
 107.183 +		fprintf(stdout, "WARNING: No encoding specified, using default (%s).\n", encoding.c_str());
 107.184 +	}
 107.185 +
 107.186 +	if (fontName.length() == 0)
 107.187 +	{
 107.188 +		fprintf(stderr, "Error: No font specified!\n");
 107.189 +		return 5;
 107.190 +	}
 107.191 +	if (fontName.find("fnt:") == 0)
 107.192 +	{
 107.193 +		fontType = kFontFNT;
 107.194 +		fontFileName = fontName.substr(4);
 107.195 +	}
 107.196 +	else if (fontName.find("ft2:") == 0)
 107.197 +	{
 107.198 +		fontType = kFontFT2;
 107.199 +		std::string::size_type pos = fontName.find(":", 4);
 107.200 +		if (pos == std::string::npos)
 107.201 +		{
 107.202 +			fontSize = 16;
 107.203 +			fprintf(stdout, "WARNING: No font size specified, using default (%d).\n", fontSize);
 107.204 +			fontFileName = fontName.substr(4);
 107.205 +		}
 107.206 +		else
 107.207 +		{
 107.208 +			std::string tmp = fontName.substr(pos + 1);
 107.209 +			fontSize = atoi(tmp.c_str());
 107.210 +			fontFileName = fontName.substr(4, pos - 4);
 107.211 +		}
 107.212 +	}
 107.213 +	else
 107.214 +	{
 107.215 +		fprintf(stderr, "Error: Unknown font type!\n");
 107.216 +		return 6;
 107.217 +	}
 107.218 +	
 107.219 +	if (optind == argc)
 107.220 +	{
 107.221 +		usage();
 107.222 +		fprintf(stderr, "ERROR: You have to specify a text\n");
 107.223 +		return 7;
 107.224 +	}
 107.225 +
 107.226 +	GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
 107.227 +	GLCD::Config.driverConfigs[displayNumber].invert ^= invert;
 107.228 +	if (brightness != -1)
 107.229 +		GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
 107.230 +
 107.231 +	GLCD::cFont font;
 107.232 +	if (fontType == kFontFNT)
 107.233 +	{
 107.234 +		if (font.LoadFNT(fontFileName) == false)
 107.235 +		{
 107.236 +			fprintf(stderr, "ERROR: Failed loading font file %s\n", fontFileName.c_str());
 107.237 +			return 8;
 107.238 +		}
 107.239 +	}
 107.240 +	else
 107.241 +	{
 107.242 +		if (font.LoadFT2(fontFileName, encoding, fontSize) == false)
 107.243 +		{
 107.244 +			fprintf(stderr, "ERROR: Failed loading font file %s\n", fontFileName.c_str());
 107.245 +			return 8;
 107.246 +		}
 107.247 +	}
 107.248 +	GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
 107.249 +	if (!lcd)
 107.250 +	{
 107.251 +		fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
 107.252 +		return 9;
 107.253 +	}
 107.254 +	if (lcd->Init() != 0)
 107.255 +	{
 107.256 +		fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
 107.257 +		delete lcd;
 107.258 +		return 10;
 107.259 +	}
 107.260 +
 107.261 +	GLCD::cBitmap * bitmap = new GLCD::cBitmap(lcd->Width(), lcd->Height());
 107.262 +	int optText;
 107.263 +	std::string text;
 107.264 +
 107.265 +	bitmap->Clear();
 107.266 +	optText = optind;
 107.267 +	while (optText < argc)
 107.268 +	{
 107.269 +		text = argv[optText];
 107.270 +		optText++;
 107.271 +
 107.272 +		bitmap->DrawText(x, y, bitmap->Width() - 1, text, &font);
 107.273 +		y += font.LineHeight();
 107.274 +	}
 107.275 +	lcd->SetScreen(bitmap->Data(), bitmap->Width(), bitmap->Height(), bitmap->LineSize());
 107.276 +	lcd->Refresh(true);
 107.277 +
 107.278 +	lcd->DeInit();
 107.279 +	delete lcd;
 107.280 +
 107.281 +	return 0;
 107.282 +}