1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/graphlcd-base/COPYING Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 g15daemon.o network.o gu126x64D-K610A4.o picctl.o avrctl.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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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, ¶m);
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, ¶m);
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
33.3 @@ -0,0 +1,121 @@
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 "picctl.h"
33.19 +#include "simlcd.h"
33.20 +#include "gu140x32f.h"
33.21 +#include "gu256x64-372.h"
33.22 +#include "gu256x64-3900.h"
33.23 +#include "hd61830.h"
33.24 +#include "ks0108.h"
33.25 +#include "sed1330.h"
33.26 +#include "sed1520.h"
33.27 +#include "t6963c.h"
33.28 +#include "framebuffer.h"
33.29 +#include "image.h"
33.30 +#include "noritake800.h"
33.31 +#include "avrctl.h"
33.32 +#include "network.h"
33.33 +#include "gu126x64D-K610A4.h"
33.34 +#include "serdisp.h"
33.35 +#include "g15daemon.h"
33.36 +
33.37 +namespace GLCD
33.38 +{
33.39 +
33.40 +tDriver drivers[] =
33.41 +{
33.42 + {"simlcd", kDriverSimLCD},
33.43 + {"gu140x32f", kDriverGU140X32F},
33.44 + {"gu256x64-372", kDriverGU256X64_372},
33.45 + {"gu256x64-3900", kDriverGU256X64_3900},
33.46 + {"hd61830", kDriverHD61830},
33.47 + {"ks0108", kDriverKS0108},
33.48 + {"sed1330", kDriverSED1330},
33.49 + {"sed1520", kDriverSED1520},
33.50 + {"t6963c", kDriverT6963C},
33.51 + {"framebuffer", kDriverFramebuffer},
33.52 + {"image", kDriverImage},
33.53 + {"noritake800", kDriverNoritake800},
33.54 + {"avrctl", kDriverAvrCtl},
33.55 + {"picctl", kDriverPICCtl},
33.56 + {"network", kDriverNetwork},
33.57 + {"gu126x64D-K610A4", kDriverGU126X64D_K610A4},
33.58 + {"serdisp", kDriverSerDisp},
33.59 + {"g15daemon", kDriverG15daemon},
33.60 + {"", kDriverUnknown}
33.61 +};
33.62 +
33.63 +tDriver * GetAvailableDrivers(int & count)
33.64 +{
33.65 + for (count = 0; drivers[count].name.length() > 0; count++)
33.66 + ;
33.67 + return drivers;
33.68 +}
33.69 +
33.70 +int GetDriverID(const std::string & driver)
33.71 +{
33.72 + for (int i = 0; drivers[i].name.length() > 0; i++)
33.73 + if (drivers[i].name == driver)
33.74 + return drivers[i].id;
33.75 + return kDriverUnknown;
33.76 +}
33.77 +
33.78 +cDriver * CreateDriver(int driverID, cDriverConfig * config)
33.79 +{
33.80 + switch (driverID)
33.81 + {
33.82 + case kDriverSimLCD:
33.83 + return new cDriverSimLCD(config);
33.84 + case kDriverGU140X32F:
33.85 + return new cDriverGU140X32F(config);
33.86 + case kDriverGU256X64_372:
33.87 + return new cDriverGU256X64_372(config);
33.88 + case kDriverGU256X64_3900:
33.89 + return new cDriverGU256X64_3900(config);
33.90 + case kDriverHD61830:
33.91 + return new cDriverHD61830(config);
33.92 + case kDriverKS0108:
33.93 + return new cDriverKS0108(config);
33.94 + case kDriverSED1330:
33.95 + return new cDriverSED1330(config);
33.96 + case kDriverSED1520:
33.97 + return new cDriverSED1520(config);
33.98 + case kDriverT6963C:
33.99 + return new cDriverT6963C(config);
33.100 + case kDriverFramebuffer:
33.101 + return new cDriverFramebuffer(config);
33.102 + case kDriverImage:
33.103 + return new cDriverImage(config);
33.104 + case kDriverNoritake800:
33.105 + return new cDriverNoritake800(config);
33.106 + case kDriverAvrCtl:
33.107 + return new cDriverAvrCtl(config);
33.108 + case kDriverPICCtl:
33.109 + return cDriverPICCtl::getInstance(config);
33.110 + case kDriverNetwork:
33.111 + return new cDriverNetwork(config);
33.112 + case kDriverGU126X64D_K610A4:
33.113 + return new cDriverGU126X64D_K610A4(config);
33.114 + case kDriverSerDisp:
33.115 + return new cDriverSerDisp(config);
33.116 + case kDriverG15daemon:
33.117 + return new cDriverG15daemon(config);
33.118 + case kDriverUnknown:
33.119 + default:
33.120 + return NULL;
33.121 + }
33.122 +}
33.123 +
33.124 +} // end of namespace
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
34.2 +++ b/graphlcd-base/glcddrivers/drivers.h Thu Feb 07 13:03:18 2008 +0100
34.3 @@ -0,0 +1,59 @@
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 + kDriverPICCtl = 16,
34.46 + kDriverSerDisp = 100,
34.47 + kDriverG15daemon = 200
34.48 +};
34.49 +
34.50 +struct tDriver
34.51 +{
34.52 + std::string name;
34.53 + eDriver id;
34.54 +};
34.55 +
34.56 +tDriver * GetAvailableDrivers(int & count);
34.57 +int GetDriverID(const std::string & driver);
34.58 +cDriver * CreateDriver(int driverID, cDriverConfig * config);
34.59 +
34.60 +} // end of namespace
34.61 +
34.62 +#endif
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
35.2 +++ b/graphlcd-base/glcddrivers/framebuffer.c Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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 Thu Feb 07 13:03:18 2008 +0100
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/picctl.c Thu Feb 07 13:03:18 2008 +0100
57.3 @@ -0,0 +1,442 @@
57.4 +/*
57.5 + * GraphLCD driver library
57.6 + *
57.7 + * picctl.c - PIC controlled LCD driver class
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 + * Codebase by Andreas Regel <andreas.regel AT powarman.de>
57.13 + * (c) 2007 Carsten Presser
57.14 + */
57.15 +
57.16 +#include <stdint.h>
57.17 +#include <syslog.h>
57.18 +#include <math.h>
57.19 +
57.20 +#include "common.h"
57.21 +#include "config.h"
57.22 +#include "port.h"
57.23 +#include "picctl.h"
57.24 +
57.25 +
57.26 +
57.27 +namespace GLCD
57.28 +{
57.29 +
57.30 +/* command header:
57.31 +** 8 bits sync byte (0xAA for sent commands, 0x55 for received commands)
57.32 +** 8 bits command id
57.33 +** 16 bits command length (excluding header)
57.34 +*/
57.35 +const unsigned char CMD_HDR_SYNC = 0;
57.36 +const unsigned char CMD_HDR_COMMAND = 1;
57.37 +const unsigned char CMD_HDR_LENGTH = 2;
57.38 +const unsigned char CMD_DATA_START = 4;
57.39 +
57.40 +const unsigned char CMD_SYNC_SEND = 0xAA;
57.41 +const unsigned char CMD_SYNC_RECV = 0x55;
57.42 +const unsigned char CMD_ESCAPE_BYTE = 0x42;
57.43 +
57.44 +
57.45 +const unsigned char CMD_SYS_SYNC = 0x00;
57.46 +const unsigned char CMD_SYS_ACK = 0x01;
57.47 +const unsigned char CMD_SYS_NACK = 0x02;
57.48 +const unsigned char CMD_SYS_NIMP = 0xFF;
57.49 +const unsigned char CMD_SYS_IR = 0x10;
57.50 +
57.51 +const unsigned char CMD_DISP_CLEAR_SCREEN = 0x10;
57.52 +const unsigned char CMD_DISP_SET_ROW_DATA = 0x14;
57.53 +const unsigned char CMD_DISP_SET_ADDRESS = 0x16;
57.54 +
57.55 +const unsigned char CMD_READ_CLOCK = 0x40;
57.56 +const unsigned char CMD_WRITE_CLOCK = 0x41;
57.57 +const unsigned char CMD_SET_PWM1 = 0x45;
57.58 +const unsigned char CMD_SET_PWM2 = 0x46;
57.59 +
57.60 +const unsigned char CMD_SET_MODE_MANAGED = 0x70;
57.61 +const unsigned char CMD_SET_MODE_UNMANAGED = 0x71;
57.62 +
57.63 +const unsigned char CMD_BOOT = 0x80;
57.64 +
57.65 +
57.66 +// globals...
57.67 +uint8_t cDriverPICCtl::buf[255];
57.68 +uint8_t cDriverPICCtl::buf_pos;
57.69 +uint8_t cDriverPICCtl::buf_cmd_start;
57.70 +bool cDriverPICCtl::buf_flag_escape;
57.71 +
57.72 +// singleton
57.73 +cDriverPICCtl* cDriverPICCtl::instance = 0;
57.74 +
57.75 +cDriverPICCtl* cDriverPICCtl::getInstance(cDriverConfig * config)
57.76 +{
57.77 + if (!instance)
57.78 + instance = new cDriverPICCtl(config);
57.79 + return instance;
57.80 +}
57.81 +// end singleton-pattern
57.82 +
57.83 +
57.84 +
57.85 +cDriverPICCtl::cDriverPICCtl(cDriverConfig * config)
57.86 +: config(config)
57.87 +{
57.88 + oldConfig = new cDriverConfig(*config);
57.89 +
57.90 + port = new cSerialPort();
57.91 +
57.92 + //width = config->width;
57.93 + //height = config->height;
57.94 + refreshCounter = 0;
57.95 + ack_flag = false;
57.96 +
57.97 + buf_pos = 1;
57.98 + buf_cmd_start = 255;
57.99 + buf_flag_escape = false;
57.100 +}
57.101 +
57.102 +cDriverPICCtl::~cDriverPICCtl()
57.103 +{
57.104 + delete port;
57.105 + delete oldConfig;
57.106 +}
57.107 +
57.108 +void cDriverPICCtl::SignalHandler(int signal)
57.109 +{
57.110 + // read all available data
57.111 + while (instance->port->ReadData(&buf[buf_pos]))
57.112 + {
57.113 + // search for SYNC byte
57.114 + if ((buf[buf_pos] == CMD_SYNC_RECV) && (!buf_flag_escape))
57.115 + {
57.116 + if (buf_cmd_start != 255)
57.117 + {
57.118 + // bytes = buf_cmd_start - buf_pos
57.119 + syslog(LOG_INFO, "PICCtl received a malformed packet. Scrapped xxx bytes\n");
57.120 + buf_cmd_start = 0;
57.121 + buf_pos = 0;
57.122 + buf[buf_pos] = CMD_SYNC_RECV;
57.123 + }
57.124 + buf_cmd_start = buf_pos;
57.125 + }
57.126 +
57.127 +
57.128 + if ((buf[buf_pos] == CMD_ESCAPE_BYTE) && (!buf_flag_escape))
57.129 + {
57.130 + buf_flag_escape = true;
57.131 + buf_pos--; // should do!!! better would be something like next();
57.132 + // set flag...
57.133 + // next;
57.134 + }
57.135 + else
57.136 + {
57.137 + buf_flag_escape = false;
57.138 + }
57.139 +
57.140 + // we need to check for a valid packet...
57.141 + if (buf_pos >=CMD_DATA_START)
57.142 + {
57.143 + // if we recieved a valid packet: start decoding
57.144 + if (buf[CMD_HDR_LENGTH+1] == (buf_pos - CMD_DATA_START))
57.145 + {
57.146 + instance->DecodeCmd(&buf[buf_cmd_start],(buf_pos-1));
57.147 + buf_pos = 0;
57.148 + buf_cmd_start = 0;
57.149 + }
57.150 + }
57.151 +
57.152 + buf_pos++;
57.153 +
57.154 + }
57.155 +}
57.156 +
57.157 +
57.158 +void cDriverPICCtl::DecodeCmd(uint8_t * cmd, uint8_t len)
57.159 +{
57.160 + switch (cmd[CMD_HDR_COMMAND])
57.161 + {
57.162 + case CMD_SYS_ACK: instance->ack_flag = true;
57.163 + break;
57.164 +
57.165 + case CMD_SYS_IR: printf(" Incoming Key-Event 0x%02x (Source 0x%02x)\n",cmd[CMD_DATA_START+1],cmd[CMD_DATA_START]);
57.166 + break;
57.167 +
57.168 + default: printf(" recieved Message 0x%x \n",cmd[CMD_HDR_COMMAND]);
57.169 + }
57.170 +
57.171 +}
57.172 +
57.173 +int cDriverPICCtl::Init()
57.174 +{
57.175 + int y;
57.176 +
57.177 + // fixed values so far...
57.178 + width = 240;
57.179 + height = 64;
57.180 +
57.181 + for (unsigned int i = 0; i < config->options.size(); i++)
57.182 + {
57.183 + if (config->options[i].name == "")
57.184 + {
57.185 + }
57.186 + }
57.187 +
57.188 + // setup lcd array (wanted state)
57.189 + newLCD = new unsigned char*[height];
57.190 + if (newLCD)
57.191 + {
57.192 + for (y = 0; y < height; y++)
57.193 + {
57.194 + newLCD[y] = new unsigned char[width/8];
57.195 + memset(newLCD[y], 0, (width/8));
57.196 + }
57.197 + }
57.198 + // setup lcd array (current state)
57.199 + oldLCD = new unsigned char*[height];
57.200 + if (oldLCD)
57.201 + {
57.202 + for (y = 0; y < height; y++)
57.203 + {
57.204 + oldLCD[y] = new unsigned char[width/8];
57.205 + memset(oldLCD[y], 0, (width/8));
57.206 + }
57.207 + }
57.208 +
57.209 + if (config->device == "")
57.210 + {
57.211 + return -1;
57.212 + }
57.213 + if (port->Open(config->device.c_str(), SignalHandler) != 0)
57.214 + return -1;
57.215 +
57.216 + *oldConfig = *config;
57.217 +
57.218 + // clear display
57.219 + Clear();
57.220 + CmdDispClearScreen();
57.221 + CmdDispSetManaged();
57.222 +
57.223 + syslog(LOG_INFO, "%s: PICCtl initialized.\n", config->name.c_str());
57.224 + return 0;
57.225 +}
57.226 +
57.227 +int cDriverPICCtl::DeInit()
57.228 +{
57.229 + int y;
57.230 + // free lcd array (wanted state)
57.231 + if (newLCD)
57.232 + {
57.233 + for (y = 0; y < height; y++)
57.234 + {
57.235 + delete[] newLCD[y];
57.236 + }
57.237 + delete[] newLCD;
57.238 + }
57.239 + // free lcd array (current state)
57.240 + if (oldLCD)
57.241 + {
57.242 + for (y = 0; y < height; y++)
57.243 + {
57.244 + delete[] oldLCD[y];
57.245 + }
57.246 + delete[] oldLCD;
57.247 + }
57.248 +
57.249 + CmdDispSetUnManaged();
57.250 +
57.251 + delete instance;
57.252 + instance = 0;
57.253 +
57.254 + if (port->Close() != 0)
57.255 + return -1;
57.256 + return 0;
57.257 +}
57.258 +
57.259 +int cDriverPICCtl::CheckSetup()
57.260 +{
57.261 + if (config->device != oldConfig->device ||
57.262 + config->width != oldConfig->width ||
57.263 + config->height != oldConfig->height)
57.264 + {
57.265 + DeInit();
57.266 + Init();
57.267 + return 0;
57.268 + }
57.269 +
57.270 + if (config->upsideDown != oldConfig->upsideDown ||
57.271 + config->invert != oldConfig->invert)
57.272 + {
57.273 + oldConfig->upsideDown = config->upsideDown;
57.274 + oldConfig->invert = config->invert;
57.275 + return 1;
57.276 + }
57.277 + return 0;
57.278 +}
57.279 +
57.280 +void cDriverPICCtl::Clear()
57.281 +{
57.282 + for (int y = 0; y < height; y++)
57.283 + memset(newLCD[y], 0, (width/8));
57.284 +}
57.285 +
57.286 +void cDriverPICCtl::Set8Pixels(int x, int y, unsigned char data)
57.287 +{
57.288 + if (x >= width || y >= height)
57.289 + return;
57.290 +
57.291 + if (!config->upsideDown)
57.292 + {
57.293 + newLCD[y][x/8] = data;
57.294 + }
57.295 + else
57.296 + {
57.297 + x = width - 1 - x;
57.298 + y = height - 1 - y;
57.299 + newLCD[y][x / 8] |= ReverseBits(data);
57.300 + }
57.301 +}
57.302 +
57.303 +void cDriverPICCtl::Refresh(bool refreshAll)
57.304 +{
57.305 + int y;
57.306 +
57.307 + if (CheckSetup() == 1)
57.308 + refreshAll = true;
57.309 +
57.310 + if (config->refreshDisplay > 0)
57.311 + {
57.312 + refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
57.313 + if (!refreshAll && !refreshCounter)
57.314 + refreshAll = true;
57.315 + }
57.316 +
57.317 +
57.318 + if (refreshAll)
57.319 + {
57.320 + // draw all
57.321 + // always draw a complete row! (30 bytes!)
57.322 + for (y = 0; y < height; y++)
57.323 + {
57.324 + CmdDispSetColData(y, 0, (width/8), newLCD[y]);
57.325 + memcpy(oldLCD[y], newLCD[y], (width/8));
57.326 + }
57.327 + // and reset RefreshCounter
57.328 + refreshCounter = 0;
57.329 + }
57.330 + else
57.331 + {
57.332 + // for every line
57.333 + for (y = 0; y< height; y++)
57.334 + {
57.335 + // did anysthing change? -> draw new line
57.336 + if (memcmp(newLCD[y],oldLCD[y],(width/8)) != 0)
57.337 + {
57.338 + CmdDispSetColData(y, 0, (width/8), newLCD[y]);
57.339 + memcpy(oldLCD[y], newLCD[y], (width/8));
57.340 + }
57.341 + }
57.342 + }
57.343 +}
57.344 +
57.345 +void cDriverPICCtl::SetBrightness(unsigned int percent)
57.346 +{
57.347 + CmdDispSetBrightness(percent);
57.348 +}
57.349 +
57.350 +void cDriverPICCtl::SetClock(unsigned int percent)
57.351 +{
57.352 + CmdDispSetBrightness(percent);
57.353 +}
57.354 +
57.355 +int cDriverPICCtl::WaitForAck(void)
57.356 +{
57.357 + int timeout;
57.358 +
57.359 + for (timeout=0; timeout<10000; timeout++)
57.360 + {
57.361 + usleep(10);
57.362 + if (ack_flag) return 1;
57.363 + }
57.364 + syslog(LOG_INFO, "PICCtl: missed a ACK packet!.\n");
57.365 + return 0;
57.366 +}
57.367 +
57.368 +void cDriverPICCtl::CmdDispClearScreen(void)
57.369 +{
57.370 + uint8_t cmd[4];
57.371 +
57.372 + cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
57.373 + cmd[CMD_HDR_COMMAND] = CMD_DISP_CLEAR_SCREEN;
57.374 + cmd[CMD_HDR_LENGTH] = 0;
57.375 + cmd[CMD_HDR_LENGTH+1] = 0;
57.376 +
57.377 + port->WriteData(cmd, 4);
57.378 + WaitForAck();
57.379 +}
57.380 +
57.381 +void cDriverPICCtl::CmdDispSetBrightness(uint8_t percent)
57.382 +{
57.383 + uint8_t cmd[5];
57.384 +
57.385 + cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
57.386 + cmd[CMD_HDR_COMMAND] = CMD_SET_PWM1;
57.387 + cmd[CMD_HDR_LENGTH] = 0;
57.388 + cmd[CMD_HDR_LENGTH+1] = 1;
57.389 + cmd[CMD_DATA_START] = (uint8_t) round(percent * 2.55);
57.390 +
57.391 + port->WriteData(cmd, 5);
57.392 + WaitForAck();
57.393 +}
57.394 +
57.395 +void cDriverPICCtl::CmdDispSetColData(uint8_t yoffset, uint8_t xoffset, uint8_t length, uint8_t * data)
57.396 +{
57.397 + uint8_t cmd[64];
57.398 + uint16_t address;
57.399 +
57.400 + address = 0x1E * yoffset + xoffset;
57.401 +
57.402 + cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
57.403 + cmd[CMD_HDR_COMMAND] = CMD_DISP_SET_ROW_DATA;
57.404 + cmd[CMD_HDR_LENGTH] = 0;
57.405 + cmd[CMD_HDR_LENGTH+1] = (length + 2);
57.406 + cmd[CMD_DATA_START] = (uint8_t)(address % 256); // lower address
57.407 + cmd[CMD_DATA_START+1] = (uint8_t)(address / 256); // upper address
57.408 + memcpy(&cmd[CMD_DATA_START+2], data, length);
57.409 +
57.410 + port->WriteData(cmd, length + 6);
57.411 + WaitForAck();
57.412 +
57.413 +// for (address = 0; address < length+6; address ++) printf("0x%02x ",cmd[address]);
57.414 +// printf("address=0x%x upper=0x%x lower=0x%x \n", address, (uint8_t)(address / 256), (uint8_t)(address % 256));
57.415 +// printf("\n");
57.416 +}
57.417 +
57.418 +void cDriverPICCtl::CmdDispSetManaged(void)
57.419 +{
57.420 + uint8_t cmd[4];
57.421 +
57.422 + cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
57.423 + cmd[CMD_HDR_COMMAND] = CMD_SET_MODE_MANAGED;
57.424 + cmd[CMD_HDR_LENGTH] = 0;
57.425 + cmd[CMD_HDR_LENGTH+1] = 0;
57.426 +
57.427 + port->WriteData(cmd,4);
57.428 + WaitForAck();
57.429 +}
57.430 +
57.431 +void cDriverPICCtl::CmdDispSetUnManaged(void)
57.432 +{
57.433 + uint8_t cmd[4];
57.434 +
57.435 + cmd[CMD_HDR_SYNC] = CMD_SYNC_SEND;
57.436 + cmd[CMD_HDR_COMMAND] = CMD_SET_MODE_UNMANAGED;
57.437 + cmd[CMD_HDR_LENGTH] = 0;
57.438 + cmd[CMD_HDR_LENGTH+1] = 0;
57.439 +
57.440 + port->WriteData(cmd,4);
57.441 + WaitForAck();
57.442 +}
57.443 +
57.444 +
57.445 +} // end NameSpace
58.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
58.2 +++ b/graphlcd-base/glcddrivers/picctl.h Thu Feb 07 13:03:18 2008 +0100
58.3 @@ -0,0 +1,73 @@
58.4 +/*
58.5 + * GraphLCD driver library
58.6 + *
58.7 + * picctl.c - PIC controlled LCD driver class
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 + * Codebase by Andreas Regel <andreas.regel AT powarman.de>
58.13 + * (c) 2007 Carsten Presser
58.14 + */
58.15 +
58.16 +#ifndef _GLCDDRIVERS_PICCTL_H_
58.17 +#define _GLCDDRIVERS_PICCTL_H_
58.18 +
58.19 +#include "driver.h"
58.20 +
58.21 +namespace GLCD
58.22 +{
58.23 +
58.24 +class cDriverConfig;
58.25 +class cSerialPort;
58.26 +
58.27 +class cDriverPICCtl : public cDriver
58.28 +{
58.29 +private:
58.30 + cSerialPort * port;
58.31 + unsigned char ** newLCD; // wanted state
58.32 + unsigned char ** oldLCD; // current state
58.33 + cDriverConfig * config;
58.34 + cDriverConfig * oldConfig;
58.35 + int refreshCounter;
58.36 + bool ack_flag;
58.37 +
58.38 + int WaitForAck(void);
58.39 + void CmdDispClearScreen(void);
58.40 + void CmdSetMode(uint8_t mode);
58.41 + void CmdDispSetManaged(void);
58.42 + void CmdDispSetUnManaged(void);
58.43 + void CmdDispSetBrightness(uint8_t percent);
58.44 + void CmdDispSetColData(uint8_t yoffset, uint8_t xoffset, uint8_t length, uint8_t * data);
58.45 + void DecodeCmd(uint8_t * cmd, uint8_t len);
58.46 +
58.47 + int CheckSetup();
58.48 +
58.49 + static void SignalHandler(int signal);
58.50 + static uint8_t buf[255];
58.51 + static uint8_t buf_pos;
58.52 + static uint8_t buf_cmd_start;
58.53 + static bool buf_flag_escape;
58.54 +
58.55 +// singleton
58.56 + static cDriverPICCtl* instance; // die EINE instant
58.57 + cDriverPICCtl(cDriverConfig * config); // Konstruktor
58.58 +
58.59 +public:
58.60 + virtual int Init();
58.61 + virtual int DeInit();
58.62 +
58.63 + virtual void Clear();
58.64 + virtual void Set8Pixels(int x, int y, unsigned char data);
58.65 + virtual void Refresh(bool refreshAll = false);
58.66 + virtual void SetBrightness(unsigned int percent);
58.67 + virtual void SetClock(unsigned int percent);
58.68 +
58.69 +// singleton
58.70 + virtual ~cDriverPICCtl(); // Destruktor
58.71 + static cDriverPICCtl* getInstance(cDriverConfig * config);
58.72 +};
58.73 +
58.74 +} // end of namespace
58.75 +
58.76 +#endif
59.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
59.2 +++ b/graphlcd-base/glcddrivers/port.c Thu Feb 07 13:03:18 2008 +0100
59.3 @@ -0,0 +1,368 @@
59.4 +/*
59.5 + * GraphLCD driver library
59.6 + *
59.7 + * port.c - parallel port class with low level routines
59.8 + *
59.9 + * This file is released under the GNU General Public License. Refer
59.10 + * to the COPYING file distributed with this package.
59.11 + *
59.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
59.13 + */
59.14 +
59.15 +#include <errno.h>
59.16 +#include <fcntl.h>
59.17 +#include <stdio.h>
59.18 +#include <string.h>
59.19 +#include <syslog.h>
59.20 +#include <unistd.h>
59.21 +#include <termios.h>
59.22 +#include <signal.h>
59.23 +#include <sys/io.h>
59.24 +#include <sys/ioctl.h>
59.25 +#include <linux/ppdev.h>
59.26 +#include <linux/parport.h>
59.27 +
59.28 +
59.29 +
59.30 +#include "port.h"
59.31 +
59.32 +
59.33 +
59.34 +
59.35 +namespace GLCD
59.36 +{
59.37 +
59.38 +static inline int port_in(int port)
59.39 +{
59.40 + unsigned char value;
59.41 + __asm__ volatile ("inb %1,%0"
59.42 + : "=a" (value)
59.43 + : "d" ((unsigned short) port));
59.44 + return value;
59.45 +}
59.46 +
59.47 +static inline void port_out(unsigned short int port, unsigned char val)
59.48 +{
59.49 + __asm__ volatile ("outb %0,%1\n"
59.50 + :
59.51 + : "a" (val), "d" (port));
59.52 +}
59.53 +
59.54 +cParallelPort::cParallelPort()
59.55 +: fd(-1),
59.56 + port(0),
59.57 + usePPDev(false)
59.58 +{
59.59 +}
59.60 +
59.61 +cParallelPort::~cParallelPort()
59.62 +{
59.63 +}
59.64 +
59.65 +int cParallelPort::Open(int portIO)
59.66 +{
59.67 + usePPDev = false;
59.68 + port = portIO;
59.69 +
59.70 + if (port < 0x400)
59.71 + {
59.72 + if (ioperm(port, 3, 255) == -1)
59.73 + {
59.74 + syslog(LOG_ERR, "glcd drivers: ERROR ioperm(0x%X) failed! Err:%s (cParallelPort::Open)\n",
59.75 + port, strerror(errno));
59.76 + return -1;
59.77 + }
59.78 + }
59.79 + else
59.80 + {
59.81 + if (iopl(3) == -1)
59.82 + {
59.83 + syslog(LOG_ERR, "glcd drivers: ERROR iopl failed! Err:%s (cParallelPort::Init)\n",
59.84 + strerror(errno));
59.85 + return -1;
59.86 + }
59.87 + }
59.88 + return 0;
59.89 +}
59.90 +
59.91 +int cParallelPort::Open(const char * device)
59.92 +{
59.93 + usePPDev = true;
59.94 +
59.95 + fd = open(device, O_RDWR);
59.96 + if (fd == -1)
59.97 + {
59.98 + syslog(LOG_ERR, "glcd drivers: ERROR cannot open %s. Err:%s (cParallelPort::Init)\n",
59.99 + device, strerror(errno));
59.100 + return -1;
59.101 + }
59.102 +
59.103 + if (ioctl(fd, PPCLAIM, NULL) == -1)
59.104 + {
59.105 + syslog(LOG_ERR, "glcd drivers: ERROR cannot claim %s. Err:%s (cParallelPort::Init)\n",
59.106 + device, strerror(errno));
59.107 + close(fd);
59.108 + return -1;
59.109 + }
59.110 +
59.111 + int mode = PARPORT_MODE_PCSPP;
59.112 + if (ioctl(fd, PPSETMODE, &mode) == -1)
59.113 + {
59.114 + syslog(LOG_ERR, "glcd drivers: ERROR cannot setmode %s. Err:%s (cParallelPort::Init)\n",
59.115 + device, strerror(errno));
59.116 + close(fd);
59.117 + return -1;
59.118 + }
59.119 +
59.120 + return 0;
59.121 +}
59.122 +
59.123 +int cParallelPort::Close()
59.124 +{
59.125 + if (usePPDev)
59.126 + {
59.127 + if (fd != -1)
59.128 + {
59.129 + ioctl(fd, PPRELEASE);
59.130 + close(fd);
59.131 + fd = -1;
59.132 + }
59.133 + else
59.134 + {
59.135 + return -1;
59.136 + }
59.137 + }
59.138 + else
59.139 + {
59.140 + if (port < 0x400)
59.141 + {
59.142 + if (ioperm(port, 3, 0) == -1)
59.143 + {
59.144 + return -1;
59.145 + }
59.146 + }
59.147 + else
59.148 + {
59.149 + if (iopl(0) == -1)
59.150 + {
59.151 + return -1;
59.152 + }
59.153 + }
59.154 + }
59.155 + return 0;
59.156 +}
59.157 +
59.158 +void cParallelPort::Claim()
59.159 +{
59.160 + if (usePPDev)
59.161 + ioctl(fd, PPCLAIM);
59.162 +}
59.163 +
59.164 +void cParallelPort::Release()
59.165 +{
59.166 + if (usePPDev)
59.167 + ioctl(fd, PPRELEASE);
59.168 +}
59.169 +
59.170 +void cParallelPort::SetDirection(int direction)
59.171 +{
59.172 + if (usePPDev)
59.173 + {
59.174 + if (ioctl(fd, PPDATADIR, &direction) == -1)
59.175 + {
59.176 + perror("ioctl(PPDATADIR)");
59.177 + //exit(1);
59.178 + }
59.179 + }
59.180 + else
59.181 + {
59.182 + if (direction == kForward)
59.183 + port_out(port + 2, port_in(port + 2) & 0xdf);
59.184 + else
59.185 + port_out(port + 2, port_in(port + 2) | 0x20);
59.186 + }
59.187 +}
59.188 +
59.189 +unsigned char cParallelPort::ReadControl()
59.190 +{
59.191 + unsigned char value;
59.192 +
59.193 + if (usePPDev)
59.194 + {
59.195 + if (ioctl(fd, PPRCONTROL, &value) == -1)
59.196 + {
59.197 + perror("ioctl(PPRCONTROL)");
59.198 + //exit(1);
59.199 + }
59.200 + }
59.201 + else
59.202 + {
59.203 + value = port_in(port + 2);
59.204 + }
59.205 +
59.206 + return value;
59.207 +}
59.208 +
59.209 +void cParallelPort::WriteControl(unsigned char value)
59.210 +{
59.211 + if (usePPDev)
59.212 + {
59.213 + if (ioctl(fd, PPWCONTROL, &value) == -1)
59.214 + {
59.215 + perror("ioctl(PPWCONTROL)");
59.216 + //exit(1);
59.217 + }
59.218 + }
59.219 + else
59.220 + {
59.221 + port_out(port + 2, value);
59.222 + }
59.223 +}
59.224 +
59.225 +unsigned char cParallelPort::ReadStatus()
59.226 +{
59.227 + unsigned char value;
59.228 +
59.229 + if (usePPDev)
59.230 + {
59.231 + if (ioctl(fd, PPRSTATUS, &value) == -1)
59.232 + {
59.233 + perror("ioctl(PPRSTATUS)");
59.234 + //exit(1);
59.235 + }
59.236 + }
59.237 + else
59.238 + {
59.239 + value = port_in(port + 1);
59.240 + }
59.241 +
59.242 + return value;
59.243 +}
59.244 +
59.245 +unsigned char cParallelPort::ReadData()
59.246 +{
59.247 + unsigned char data;
59.248 +
59.249 + if (usePPDev)
59.250 + {
59.251 + if (ioctl(fd, PPRDATA, &data) == -1)
59.252 + {
59.253 + perror("ioctl(PPRDATA)");
59.254 + //exit(1);
59.255 + }
59.256 + }
59.257 + else
59.258 + {
59.259 + data = port_in(port);
59.260 + }
59.261 +
59.262 + return data;
59.263 +}
59.264 +
59.265 +void cParallelPort::WriteData(unsigned char data)
59.266 +{
59.267 + if (usePPDev)
59.268 + {
59.269 + if (ioctl(fd, PPWDATA, &data) == -1)
59.270 + {
59.271 + perror("ioctl(PPWDATA)");
59.272 + //exit(1);
59.273 + }
59.274 + }
59.275 + else
59.276 + {
59.277 + port_out(port, data);
59.278 + }
59.279 +}
59.280 +
59.281 +
59.282 +
59.283 +cSerialPort::cSerialPort()
59.284 +: fd(-1)
59.285 +{
59.286 +}
59.287 +
59.288 +cSerialPort::~cSerialPort()
59.289 +{
59.290 +}
59.291 +
59.292 +int cSerialPort::Open(const char * device, void (*FP)(int))
59.293 +{
59.294 + struct termios options;
59.295 + struct sigaction saio;
59.296 +
59.297 + fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY);
59.298 + if (fd == -1)
59.299 + {
59.300 + printf("error opening port\n");
59.301 + return -1;
59.302 + }
59.303 +
59.304 +
59.305 + // install the signal handler before making the device asynchronous/
59.306 + saio.sa_handler = FP;
59.307 + sigemptyset (&saio.sa_mask);
59.308 + saio.sa_flags = 0;
59.309 + saio.sa_restorer = NULL;
59.310 + sigaction(SIGIO,&saio,NULL);
59.311 +
59.312 + // allow the process to receive SIGIO
59.313 + fcntl(fd, F_SETOWN, getpid());
59.314 + // Make the file descriptor asynchronous
59.315 + fcntl(fd, F_SETFL, FASYNC);
59.316 +
59.317 + tcgetattr(fd, &options);
59.318 +
59.319 + cfsetispeed(&options, B921600);
59.320 + cfsetospeed(&options, B921600);
59.321 +
59.322 + options.c_cflag &= ~PARENB;
59.323 + options.c_cflag &= ~CSTOPB;
59.324 + options.c_cflag &= ~CSIZE;
59.325 + options.c_cflag |= CS8;
59.326 +
59.327 + options.c_cflag &= ~CRTSCTS;
59.328 +
59.329 + options.c_cflag |= (CLOCAL | CREAD);
59.330 +
59.331 + options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
59.332 +
59.333 + options.c_iflag &= ~(IXON | IXOFF | IXANY);
59.334 +
59.335 + options.c_oflag &= ~OPOST;
59.336 +
59.337 + tcsetattr(fd, TCSANOW, &options);
59.338 +
59.339 + return 0;
59.340 +}
59.341 +
59.342 +int cSerialPort::Close()
59.343 +{
59.344 + if (fd == -1)
59.345 + return -1;
59.346 + close(fd);
59.347 + return 0;
59.348 +}
59.349 +
59.350 +int cSerialPort::ReadData(unsigned char * data)
59.351 +{
59.352 + if (fd == -1)
59.353 + return 0;
59.354 + return read(fd, data, 1);
59.355 +}
59.356 +
59.357 +void cSerialPort::WriteData(unsigned char data)
59.358 +{
59.359 + WriteData(&data, 1);
59.360 +}
59.361 +
59.362 +void cSerialPort::WriteData(unsigned char * data, unsigned short length)
59.363 +{
59.364 + if (fd == -1)
59.365 + return;
59.366 + write(fd, data, length);
59.367 +}
59.368 +
59.369 +
59.370 +} // end of namespace
59.371 +
60.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
60.2 +++ b/graphlcd-base/glcddrivers/port.h Thu Feb 07 13:03:18 2008 +0100
60.3 @@ -0,0 +1,78 @@
60.4 +/*
60.5 + * GraphLCD driver library
60.6 + *
60.7 + * port.h - parallel port class with low level routines
60.8 + *
60.9 + * This file is released under the GNU General Public License. Refer
60.10 + * to the COPYING file distributed with this package.
60.11 + *
60.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
60.13 + */
60.14 +
60.15 +#ifndef _GLCDDRIVERS_PORT_H_
60.16 +#define _GLCDDRIVERS_PORT_H_
60.17 +
60.18 +namespace GLCD
60.19 +{
60.20 +
60.21 +const int kForward = 0;
60.22 +const int kReverse = 1;
60.23 +
60.24 +const unsigned char kStrobeHigh = 0x00; // Pin 1
60.25 +const unsigned char kStrobeLow = 0x01;
60.26 +const unsigned char kAutoHigh = 0x00; // Pin 14
60.27 +const unsigned char kAutoLow = 0x02;
60.28 +const unsigned char kInitHigh = 0x04; // Pin 16
60.29 +const unsigned char kInitLow = 0x00;
60.30 +const unsigned char kSelectHigh = 0x00; // Pin 17
60.31 +const unsigned char kSelectLow = 0x08;
60.32 +
60.33 +class cParallelPort
60.34 +{
60.35 +private:
60.36 + int fd;
60.37 + int port;
60.38 + bool usePPDev;
60.39 +
60.40 +public:
60.41 + cParallelPort();
60.42 + ~cParallelPort();
60.43 +
60.44 + int Open(int port);
60.45 + int Open(const char * device);
60.46 + int Close();
60.47 +
60.48 + bool IsDirectIO() const { return (!usePPDev); }
60.49 + int GetPortHandle() const { return ((usePPDev) ? fd : port); }
60.50 +
60.51 + void Claim();
60.52 + void Release();
60.53 +
60.54 + void SetDirection(int direction);
60.55 + unsigned char ReadControl();
60.56 + void WriteControl(unsigned char values);
60.57 + unsigned char ReadStatus();
60.58 + unsigned char ReadData();
60.59 + void WriteData(unsigned char data);
60.60 +};
60.61 +
60.62 +class cSerialPort
60.63 +{
60.64 +private:
60.65 + int fd;
60.66 +
60.67 +public:
60.68 + cSerialPort();
60.69 + ~cSerialPort();
60.70 +
60.71 + int Open(const char * device, void (*FP)(int));
60.72 + int Close();
60.73 +
60.74 + int ReadData(unsigned char * data);
60.75 + void WriteData(unsigned char data);
60.76 + void WriteData(unsigned char * data, unsigned short length);
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/sed1330.c Thu Feb 07 13:03:18 2008 +0100
61.3 @@ -0,0 +1,630 @@
61.4 +/*
61.5 + * GraphLCD driver library
61.6 + *
61.7 + * sed1330.c - SED1330 driver class
61.8 + *
61.9 + * based on: hd61830.c
61.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
61.11 + *
61.12 + * changes for Seiko-Epson displays: Mar 2004
61.13 + * (c) 2004 Heinz Gressenberger <heinz.gressenberger AT stmk.gv.at>
61.14 + *
61.15 + * init sequence taken from Thomas Baumann's LCD-Test program
61.16 + *
61.17 + * This file is released under the GNU General Public License. Refer
61.18 + * to the COPYING file distributed with this package.
61.19 + *
61.20 + * (c) 2003 Roland Praml <praml.roland AT t-online.de>
61.21 + */
61.22 +
61.23 +#include <syslog.h>
61.24 +#include <sys/time.h>
61.25 +
61.26 +#include "common.h"
61.27 +#include "config.h"
61.28 +#include "port.h"
61.29 +#include "sed1330.h"
61.30 +
61.31 +
61.32 +namespace GLCD
61.33 +{
61.34 +
61.35 +// SED1330 Commands
61.36 +
61.37 +// Command Codes, Bytes for Param
61.38 +
61.39 +#define C_SYSTEMSET 0x40
61.40 +#define C_SLEEPIN 0x53
61.41 +#define C_DISPON 0x59
61.42 +#define C_DISPOFF 0x58
61.43 +#define C_SCROLL 0x44
61.44 +#define C_CSRFORM 0x5D
61.45 +#define C_CGRAMADR 0x5C
61.46 +#define C_CSRDIR_R 0x4C
61.47 +#define C_CSRDIR_L 0x4D
61.48 +#define C_CSRDIR_U 0x4E
61.49 +#define C_CSRDIR_D 0x4F
61.50 +#define C_HDOTSCR 0x5A
61.51 +#define C_OVLAY 0x5B
61.52 +#define C_CSRW 0x46
61.53 +#define C_CSRR 0x47
61.54 +#define C_MWRITE 0x42
61.55 +#define C_MREAD 0x43
61.56 +
61.57 +#define M0 0
61.58 +// 0-internal CG ROM, 1-external CG-ROM/RAM
61.59 +
61.60 +#define M1 0
61.61 +// 0 - 32 char CG-RAM, 1 - 64 char
61.62 +
61.63 +#define M2 0
61.64 +// 0 - 8x8, 1 - 8x16 matrix in CG-RAM/ROM
61.65 +
61.66 +#define FX 8
61.67 +// character-with
61.68 +#define FY 8
61.69 +// character-height
61.70 +#define BPC 1
61.71 +// byte per character, 1 - FX<=8, 2 - FX=9..16
61.72 +
61.73 +#define SAD1 0x0000
61.74 +// startadress first screen
61.75 +
61.76 +
61.77 +const int kInterface6800 = 0;
61.78 +const int kInterface8080 = 1;
61.79 +
61.80 +const std::string kWiringOriginal = "Original";
61.81 +const std::string kWiringPowerLCD = "PowerLCD";
61.82 +const std::string kWiringLCDProc = "LCDProc";
61.83 +const std::string kWiringTweakers = "Tweakers";
61.84 +const std::string kWiringYASEDW = "YASEDW";
61.85 +
61.86 +const unsigned char kOriginalA0HI = kInitHigh;
61.87 +const unsigned char kOriginalA0LO = kInitLow;
61.88 +const unsigned char kOriginalRDHI = kStrobeHigh;
61.89 +const unsigned char kOriginalRDLO = kStrobeLow;
61.90 +const unsigned char kOriginalWRHI = kAutoHigh;
61.91 +const unsigned char kOriginalWRLO = kAutoLow;
61.92 +const unsigned char kOriginalCSHI = kSelectHigh;
61.93 +const unsigned char kOriginalCSLO = kSelectLow;
61.94 +
61.95 +const unsigned char kPowerLCDA0HI = kInitHigh;
61.96 +const unsigned char kPowerLCDA0LO = kInitLow;
61.97 +const unsigned char kPowerLCDRDHI = kSelectHigh;
61.98 +const unsigned char kPowerLCDRDLO = kSelectLow;
61.99 +const unsigned char kPowerLCDWRHI = kStrobeHigh;
61.100 +const unsigned char kPowerLCDWRLO = kStrobeLow;
61.101 +const unsigned char kPowerLCDCSHI = kAutoHigh;
61.102 +const unsigned char kPowerLCDCSLO = kAutoLow;
61.103 +
61.104 +const unsigned char kLCDProcA0HI = kSelectHigh;
61.105 +const unsigned char kLCDProcA0LO = kSelectLow;
61.106 +const unsigned char kLCDProcRDHI = kInitHigh;
61.107 +const unsigned char kLCDProcRDLO = kInitLow;
61.108 +const unsigned char kLCDProcWRHI = kAutoHigh;
61.109 +const unsigned char kLCDProcWRLO = kAutoLow;
61.110 +const unsigned char kLCDProcCSHI = kStrobeHigh;
61.111 +const unsigned char kLCDProcCSLO = kStrobeLow;
61.112 +
61.113 +const unsigned char kTweakersA0HI = kSelectHigh;
61.114 +const unsigned char kTweakersA0LO = kSelectLow;
61.115 +const unsigned char kTweakersRDHI = kAutoHigh;
61.116 +const unsigned char kTweakersRDLO = kAutoLow;
61.117 +const unsigned char kTweakersWRHI = kInitHigh;
61.118 +const unsigned char kTweakersWRLO = kInitLow;
61.119 +const unsigned char kTweakersCSHI = kStrobeHigh;
61.120 +const unsigned char kTweakersCSLO = kStrobeLow;
61.121 +
61.122 +const unsigned char kYASEDWA0HI = kAutoHigh;
61.123 +const unsigned char kYASEDWA0LO = kAutoLow;
61.124 +const unsigned char kYASEDWRDHI = kInitHigh;
61.125 +const unsigned char kYASEDWRDLO = kInitLow;
61.126 +const unsigned char kYASEDWWRHI = kStrobeHigh;
61.127 +const unsigned char kYASEDWWRLO = kStrobeLow;
61.128 +const unsigned char kYASEDWCSHI = kSelectHigh;
61.129 +const unsigned char kYASEDWCSLO = kSelectLow;
61.130 +
61.131 +
61.132 +cDriverSED1330::cDriverSED1330(cDriverConfig * config)
61.133 +: config(config)
61.134 +{
61.135 + oldConfig = new cDriverConfig(*config);
61.136 +
61.137 + port = new cParallelPort();
61.138 +
61.139 + refreshCounter = 0;
61.140 +}
61.141 +
61.142 +cDriverSED1330::~cDriverSED1330()
61.143 +{
61.144 + delete port;
61.145 + delete oldConfig;
61.146 +}
61.147 +
61.148 +int cDriverSED1330::Init()
61.149 +{
61.150 + int x;
61.151 + struct timeval tv1, tv2;
61.152 +
61.153 + width = config->width;
61.154 + if (width <= 0)
61.155 + width = 320;
61.156 + height = config->height;
61.157 + if (height <= 0)
61.158 + height = 240;
61.159 +
61.160 + // default values
61.161 + oscillatorFrequency = 9600;
61.162 + interface = kInterface6800;
61.163 + A0HI = kOriginalA0HI;
61.164 + A0LO = kOriginalA0LO;
61.165 + RDHI = kOriginalRDHI;
61.166 + RDLO = kOriginalRDLO;
61.167 + WRHI = kOriginalWRHI;
61.168 + WRLO = kOriginalWRLO;
61.169 + CSHI = kOriginalCSHI;
61.170 + CSLO = kOriginalCSLO;
61.171 + ENHI = RDHI;
61.172 + ENLO = RDLO;
61.173 + RWHI = WRHI;
61.174 + RWLO = WRLO;
61.175 +
61.176 + for (unsigned int i = 0; i < config->options.size(); i++)
61.177 + {
61.178 + if (config->options[i].name == "Wiring")
61.179 + {
61.180 + if (config->options[i].value == kWiringOriginal)
61.181 + {
61.182 + A0HI = kOriginalA0HI;
61.183 + A0LO = kOriginalA0LO;
61.184 + RDHI = kOriginalRDHI;
61.185 + RDLO = kOriginalRDLO;
61.186 + WRHI = kOriginalWRHI;
61.187 + WRLO = kOriginalWRLO;
61.188 + CSHI = kOriginalCSHI;
61.189 + CSLO = kOriginalCSLO;
61.190 + }
61.191 + else if (config->options[i].value == kWiringPowerLCD)
61.192 + {
61.193 + A0HI = kPowerLCDA0HI;
61.194 + A0LO = kPowerLCDA0LO;
61.195 + RDHI = kPowerLCDRDHI;
61.196 + RDLO = kPowerLCDRDLO;
61.197 + WRHI = kPowerLCDWRHI;
61.198 + WRLO = kPowerLCDWRLO;
61.199 + CSHI = kPowerLCDCSHI;
61.200 + CSLO = kPowerLCDCSLO;
61.201 + }
61.202 + else if (config->options[i].value == kWiringLCDProc)
61.203 + {
61.204 + A0HI = kLCDProcA0HI;
61.205 + A0LO = kLCDProcA0LO;
61.206 + RDHI = kLCDProcRDHI;
61.207 + RDLO = kLCDProcRDLO;
61.208 + WRHI = kLCDProcWRHI;
61.209 + WRLO = kLCDProcWRLO;
61.210 + CSHI = kLCDProcCSHI;
61.211 + CSLO = kLCDProcCSLO;
61.212 + }
61.213 + else if (config->options[i].value == kWiringTweakers)
61.214 + {
61.215 + A0HI = kTweakersA0HI;
61.216 + A0LO = kTweakersA0LO;
61.217 + RDHI = kTweakersRDHI;
61.218 + RDLO = kTweakersRDLO;
61.219 + WRHI = kTweakersWRHI;
61.220 + WRLO = kTweakersWRLO;
61.221 + CSHI = kTweakersCSHI;
61.222 + CSLO = kTweakersCSLO;
61.223 + }
61.224 + else if (config->options[i].value == kWiringYASEDW)
61.225 + {
61.226 + A0HI = kYASEDWA0HI;
61.227 + A0LO = kYASEDWA0LO;
61.228 + RDHI = kYASEDWRDHI;
61.229 + RDLO = kYASEDWRDLO;
61.230 + WRHI = kYASEDWWRHI;
61.231 + WRLO = kYASEDWWRLO;
61.232 + CSHI = kYASEDWCSHI;
61.233 + CSLO = kYASEDWCSLO;
61.234 + }
61.235 + else
61.236 + {
61.237 + syslog(LOG_ERR, "%s error: wiring %s not supported, using default (Original)!\n",
61.238 + config->name.c_str(), config->options[i].value.c_str());
61.239 + }
61.240 + ENHI = RDHI;
61.241 + ENLO = RDLO;
61.242 + RWHI = WRHI;
61.243 + RWLO = WRLO;
61.244 + }
61.245 + else if (config->options[i].name == "OscillatorFrequency")
61.246 + {
61.247 + int freq = atoi(config->options[i].value.c_str());
61.248 + if (freq > 1000 && freq < 15000)
61.249 + oscillatorFrequency = freq;
61.250 + else
61.251 + syslog(LOG_ERR, "%s error: oscillator frequency %d out of range, using default (%d)!\n",
61.252 + config->name.c_str(), freq, oscillatorFrequency);
61.253 + }
61.254 + if (config->options[i].name == "Interface")
61.255 + {
61.256 + if (config->options[i].value == "6800")
61.257 + interface = kInterface6800;
61.258 + else if (config->options[i].value == "8080")
61.259 + interface = kInterface8080;
61.260 + else
61.261 + syslog(LOG_ERR, "%s error: interface %s not supported, using default (6800)!\n",
61.262 + config->name.c_str(), config->options[i].value.c_str());
61.263 + }
61.264 + }
61.265 +
61.266 + // setup lcd array (wanted state)
61.267 + newLCD = new unsigned char *[(width + 7) / 8];
61.268 + if (newLCD)
61.269 + {
61.270 + for (x = 0; x < (width + 7) / 8; x++)
61.271 + {
61.272 + newLCD[x] = new unsigned char[height];
61.273 + memset(newLCD[x], 0, height);
61.274 + }
61.275 + }
61.276 + // setup lcd array (current state)
61.277 + oldLCD = new unsigned char *[(width + 7) / 8];
61.278 + if (oldLCD)
61.279 + {
61.280 + for (x = 0; x < (width + 7) / 8; x++)
61.281 + {
61.282 + oldLCD[x] = new unsigned char[height];
61.283 + memset(oldLCD[x], 0, height);
61.284 + }
61.285 + }
61.286 +
61.287 + if (config->device == "")
61.288 + {
61.289 + // use DirectIO
61.290 + if (port->Open(config->port) != 0)
61.291 + return -1;
61.292 + uSleep(10);
61.293 + }
61.294 + else
61.295 + {
61.296 + // use ppdev
61.297 + if (port->Open(config->device.c_str()) != 0)
61.298 + return -1;
61.299 + }
61.300 +
61.301 + if (nSleepInit() != 0)
61.302 + {
61.303 + syslog(LOG_DEBUG, "%s: INFO: cannot change wait parameters (cDriver::Init)\n", config->name.c_str());
61.304 + useSleepInit = false;
61.305 + }
61.306 + else
61.307 + {
61.308 + useSleepInit = true;
61.309 + }
61.310 +
61.311 + syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
61.312 + gettimeofday(&tv1, 0);
61.313 + for (x = 0; x < 1000; x++)
61.314 + {
61.315 + port->WriteData(x % 0x100);
61.316 + }
61.317 + gettimeofday(&tv2, 0);
61.318 + if (useSleepInit)
61.319 + nSleepDeInit();
61.320 + timeForPortCmdInNs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
61.321 + syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Command: %ldns\n", config->name.c_str(), timeForPortCmdInNs);
61.322 +
61.323 + // initialize graphic mode
61.324 + InitGraphic();
61.325 +
61.326 + *oldConfig = *config;
61.327 +
61.328 + // clear display
61.329 + Clear();
61.330 + // The SED1330 can have up to 64k memory. If there is less memory
61.331 + // it will be overwritten twice or more times.
61.332 + WriteCmd(C_MWRITE);
61.333 + for (x = 0; x < 65536; x++)
61.334 + WriteData(0x00);
61.335 +
61.336 + WriteCmd(C_CSRW);
61.337 + WriteData(0x00); // initializing cursor adress, low byte
61.338 + WriteData(0x00); // high byte
61.339 +
61.340 + port->Release();
61.341 +
61.342 + syslog(LOG_INFO, "%s: SED1330 initialized.\n", config->name.c_str());
61.343 + return 0;
61.344 +}
61.345 +
61.346 +int cDriverSED1330::DeInit()
61.347 +{
61.348 + int x;
61.349 +
61.350 + // free lcd array (wanted state)
61.351 + if (newLCD)
61.352 + {
61.353 + for (x = 0; x < (width + 7) / 8; x++)
61.354 + {
61.355 + delete[] newLCD[x];
61.356 + }
61.357 + delete[] newLCD;
61.358 + }
61.359 + // free lcd array (current state)
61.360 + if (oldLCD)
61.361 + {
61.362 + for (x = 0; x < (width + 7) / 8; x++)
61.363 + {
61.364 + delete[] oldLCD[x];
61.365 + }
61.366 + delete[] oldLCD;
61.367 + }
61.368 +
61.369 + if (port->Close() != 0)
61.370 + return -1;
61.371 + return 0;
61.372 +}
61.373 +
61.374 +int cDriverSED1330::CheckSetup()
61.375 +{
61.376 + if (config->device != oldConfig->device ||
61.377 + config->port != oldConfig->port ||
61.378 + config->width != oldConfig->width ||
61.379 + config->height != oldConfig->height)
61.380 + {
61.381 + DeInit();
61.382 + Init();
61.383 + return 0;
61.384 + }
61.385 +
61.386 + if (config->upsideDown != oldConfig->upsideDown ||
61.387 + config->invert != oldConfig->invert)
61.388 + {
61.389 + oldConfig->upsideDown = config->upsideDown;
61.390 + oldConfig->invert = config->invert;
61.391 + return 1;
61.392 + }
61.393 + return 0;
61.394 +}
61.395 +
61.396 +int cDriverSED1330::InitGraphic()
61.397 +{
61.398 + // initialize setup with two graphic screens
61.399 + // most parts taken from Thomas Baumann's LCD-Test program
61.400 + int cr;
61.401 + int memGraph;
61.402 + int sad1l, sad1h, sad2l, sad2h;
61.403 +
61.404 + cr = (width / FX - 1) * BPC;
61.405 + memGraph = ((cr + 1) * height); // required memory for a graphic layer
61.406 + sad1l = SAD1 & 0xFF;
61.407 + sad1h = SAD1 >> 8 & 0xFF;
61.408 + sad2l = ((SAD1 + memGraph) & 0xFF);
61.409 + sad2h = ((SAD1 + memGraph) >> 8 & 0xFF);
61.410 +
61.411 + WriteCmd(C_SYSTEMSET);
61.412 + WriteData(0x30 + M0 + (M1 << 1) + (M2 << 2));
61.413 + WriteData(0x80 + (FX - 1));
61.414 + WriteData(0x00 + (FY - 1));
61.415 + WriteData(cr); // C/R .. display adresses per line
61.416 + WriteData((oscillatorFrequency * 1000 / (70 * height) - 1) / 9); // TC/R .. , fFR=70Hz
61.417 + WriteData(height - 1); // L/F .. display lines per screen
61.418 + WriteData(cr + 1); // adresses per virtual display line, low byte
61.419 + WriteData(0x00); // adresses per virtual display line, high byte
61.420 + // currently we don't use virtual screens greater then the display,
61.421 + // therefore the high byte should always be zero
61.422 +
61.423 + WriteCmd(C_SCROLL);
61.424 + WriteData(sad1l); // low-byte startadress first layer
61.425 + WriteData(sad1h); // high-byte startadress first layer
61.426 + WriteData(height); // lines per screen
61.427 + WriteData(sad2l); // low-byte startadress second layer
61.428 + WriteData(sad2h); // high-byte startadress second layer
61.429 + WriteData(height); // lines per screen
61.430 + WriteData(0x00); // low-byte startadress third layer, not used
61.431 + WriteData(0x00); // high-byte startadress third layer, not used
61.432 + WriteData(0x00); // low-byte startadress fourth layer, not used
61.433 + WriteData(0x00); // high-byte startadress fourth layer, not used
61.434 +
61.435 + WriteCmd(C_CSRFORM);
61.436 + WriteData(0x00); // cursor with: 1 pixel
61.437 + WriteData(0x86); // cursor height: 7 lines, block mode
61.438 +
61.439 + WriteCmd(C_CSRDIR_R); // automatic cursor increment to the right
61.440 +
61.441 + WriteCmd(C_OVLAY);
61.442 + WriteData(0x0C); // two layer composition with Priority-OR
61.443 +
61.444 + WriteCmd(C_HDOTSCR);
61.445 + WriteData(0x00);
61.446 +
61.447 + WriteCmd(C_DISPON); // display ON with
61.448 + WriteData(0x04); // cursor OFF and first layer ON without flashing
61.449 +
61.450 + WriteCmd(C_CSRW);
61.451 + WriteData(0x00); // initializing cursor adress, low byte
61.452 + WriteData(0x00); // high byte
61.453 +
61.454 + return 0;
61.455 +}
61.456 +
61.457 +void cDriverSED1330::WriteCmd(unsigned char cmd)
61.458 +{
61.459 + //if (useSleepInit)
61.460 + // nSleepInit();
61.461 +
61.462 + if (interface == kInterface6800)
61.463 + {
61.464 + // set A0 high (instruction), RW low (write) and E low
61.465 + port->WriteControl(A0HI | CSLO | RWLO | ENLO);
61.466 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.467 + // Output the actual command
61.468 + port->WriteData(cmd);
61.469 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.470 + // set E high
61.471 + port->WriteControl(A0HI | CSLO | RWLO | ENHI);
61.472 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.473 + // set E low
61.474 + port->WriteControl(A0HI | CSLO | RWLO | ENLO);
61.475 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.476 + }
61.477 + else
61.478 + {
61.479 + // set A0 high (instruction), CS low, RD and WR high
61.480 + port->WriteControl(A0HI | CSLO | RDHI | WRHI);
61.481 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.482 + // Output the actual command
61.483 + port->WriteData(cmd);
61.484 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.485 + // set WR low
61.486 + port->WriteControl(A0HI | CSLO | RDHI | WRLO);
61.487 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.488 + // set WR high
61.489 + port->WriteControl(A0HI | CSLO | RDHI | WRHI);
61.490 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.491 + }
61.492 +
61.493 + //if (useSleepInit)
61.494 + // nSleepDeInit();
61.495 +}
61.496 +
61.497 +void cDriverSED1330::WriteData(unsigned char data)
61.498 +{
61.499 + //if (useSleepInit)
61.500 + // nSleepInit();
61.501 +
61.502 + if (interface == kInterface6800)
61.503 + {
61.504 + // set A0 low (data), RW low (write) and E low
61.505 + port->WriteControl(A0LO | CSLO | RWLO | ENLO);
61.506 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.507 + // Output the actual data
61.508 + port->WriteData(data);
61.509 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.510 + // set E high
61.511 + port->WriteControl(A0LO | CSLO | RWLO | ENHI);
61.512 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.513 + // set E low
61.514 + port->WriteControl(A0LO | CSLO | RWLO | ENLO);
61.515 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.516 + }
61.517 + else
61.518 + {
61.519 + // set A0 low (data), CS low, RD and WR high
61.520 + port->WriteControl(A0LO | CSLO | RDHI | WRHI);
61.521 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.522 + // Output the actual data
61.523 + port->WriteData(data);
61.524 + //nSleep(140 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.525 + // set WR low
61.526 + port->WriteControl(A0LO | CSLO | RDHI | WRLO);
61.527 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.528 + // set WR high
61.529 + port->WriteControl(A0LO | CSLO | RDHI | WRHI);
61.530 + //nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
61.531 + }
61.532 +
61.533 + //if (useSleepInit)
61.534 + // nSleepDeInit();
61.535 +}
61.536 +
61.537 +void cDriverSED1330::Clear()
61.538 +{
61.539 + for (int x = 0; x < (width + 7) / 8; x++)
61.540 + memset(newLCD[x], 0, height);
61.541 +}
61.542 +
61.543 +void cDriverSED1330::Set8Pixels(int x, int y, unsigned char data)
61.544 +{
61.545 + if (x >= width || y >= height)
61.546 + return;
61.547 +
61.548 + if (!config->upsideDown)
61.549 + {
61.550 + // normal orientation
61.551 + newLCD[x / 8][y] = newLCD[x / 8][y] | data;
61.552 + }
61.553 + else
61.554 + {
61.555 + // upside down orientation
61.556 + x = width - 1 - x;
61.557 + y = height - 1 - y;
61.558 + newLCD[x / 8][y] = newLCD[x / 8][y] | ReverseBits(data);
61.559 + }
61.560 +}
61.561 +
61.562 +void cDriverSED1330::Refresh(bool refreshAll)
61.563 +{
61.564 + int x;
61.565 + int y;
61.566 + int pos = SAD1;
61.567 +
61.568 + if (CheckSetup() > 0)
61.569 + refreshAll = true;
61.570 +
61.571 + if (config->refreshDisplay > 0)
61.572 + {
61.573 + refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
61.574 + if (!refreshAll && !refreshCounter)
61.575 + refreshAll = true;
61.576 + }
61.577 +
61.578 + port->Claim();
61.579 +
61.580 + if (refreshAll)
61.581 + {
61.582 + // draw all
61.583 + // set cursor to startadress
61.584 + WriteCmd(C_CSRW);
61.585 + WriteData(pos & 0xFF);
61.586 + WriteData(pos >> 8);
61.587 +
61.588 + for (y = 0; y < height; y++)
61.589 + {
61.590 + for (x = 0; x < (width + 7) / 8; x++)
61.591 + {
61.592 + WriteCmd(C_MWRITE); // cursor increments automatically
61.593 + WriteData(newLCD[x][y] ^ (config->invert ? 0xff : 0x00));
61.594 + oldLCD[x][y] = newLCD[x][y];
61.595 + pos++;
61.596 + }
61.597 + }
61.598 + // and reset RefreshCounter
61.599 + refreshCounter = 0;
61.600 + }
61.601 + else
61.602 + {
61.603 + // draw only the changed bytes
61.604 + bool cs = false;
61.605 + for (y = 0; y < height; y++)
61.606 + {
61.607 + for (x = 0; x < (width + 7) / 8; x++)
61.608 + {
61.609 + if (newLCD[x][y] != oldLCD[x][y])
61.610 + {
61.611 + if (!cs)
61.612 + {
61.613 + WriteCmd(C_CSRW);
61.614 + WriteData(pos & 0xFF);
61.615 + WriteData(pos >> 8);
61.616 + WriteCmd(C_MWRITE);
61.617 + cs = true;
61.618 + }
61.619 + WriteData(newLCD[x][y] ^ (config->invert ? 0xff : 0x00));
61.620 + oldLCD[x][y] = newLCD[x][y];
61.621 + }
61.622 + else
61.623 + {
61.624 + cs = false;
61.625 + }
61.626 + pos++;
61.627 + }
61.628 + }
61.629 + }
61.630 + port->Release();
61.631 +}
61.632 +
61.633 +} // end of namespace
62.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
62.2 +++ b/graphlcd-base/glcddrivers/sed1330.h Thu Feb 07 13:03:18 2008 +0100
62.3 @@ -0,0 +1,78 @@
62.4 +/*
62.5 + * GraphLCD driver library
62.6 + *
62.7 + * sed1330.h - SED1330 driver class
62.8 + *
62.9 + * based on: hd61830.c
62.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
62.11 + *
62.12 + * changes for Seiko-Epson displays: Mar 2004
62.13 + * (c) 2004 Heinz Gressenberger <heinz.gressenberger AT stmk.gv.at>
62.14 + *
62.15 + * init sequence taken from Thomas Baumann's LCD-Test program
62.16 + *
62.17 + * This file is released under the GNU General Public License. Refer
62.18 + * to the COPYING file distributed with this package.
62.19 + *
62.20 + * (c) 2003 Roland Praml <praml.roland AT t-online.de>
62.21 + */
62.22 +
62.23 +#ifndef _GLCDDRIVERS_SED1330_H_
62.24 +#define _GLCDDRIVERS_SED1330_H_
62.25 +
62.26 +#include "driver.h"
62.27 +
62.28 +
62.29 +namespace GLCD
62.30 +{
62.31 +
62.32 +class cDriverConfig;
62.33 +class cParallelPort;
62.34 +
62.35 +class cDriverSED1330 : public cDriver
62.36 +{
62.37 +private:
62.38 + cParallelPort * port;
62.39 + unsigned char ** newLCD; // wanted state
62.40 + unsigned char ** oldLCD; // current state
62.41 + int refreshCounter;
62.42 + long timeForPortCmdInNs;
62.43 + cDriverConfig * config;
62.44 + cDriverConfig * oldConfig;
62.45 + bool useSleepInit;
62.46 +
62.47 + int oscillatorFrequency;
62.48 + int interface;
62.49 + unsigned char A0HI;
62.50 + unsigned char A0LO;
62.51 + unsigned char RDHI;
62.52 + unsigned char RDLO;
62.53 + unsigned char ENHI;
62.54 + unsigned char ENLO;
62.55 + unsigned char WRHI;
62.56 + unsigned char WRLO;
62.57 + unsigned char RWHI;
62.58 + unsigned char RWLO;
62.59 + unsigned char CSHI;
62.60 + unsigned char CSLO;
62.61 +
62.62 + int CheckSetup();
62.63 + int InitGraphic();
62.64 + void WriteCmd(unsigned char cmd);
62.65 + void WriteData(unsigned char data);
62.66 +
62.67 +public:
62.68 + cDriverSED1330(cDriverConfig * config);
62.69 + virtual ~cDriverSED1330();
62.70 +
62.71 + virtual int Init();
62.72 + virtual int DeInit();
62.73 +
62.74 + virtual void Clear();
62.75 + virtual void Set8Pixels(int x, int y, unsigned char data);
62.76 + virtual void Refresh(bool refreshAll = false);
62.77 +};
62.78 +
62.79 +} // end of namespace
62.80 +
62.81 +#endif
63.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
63.2 +++ b/graphlcd-base/glcddrivers/sed1520.c Thu Feb 07 13:03:18 2008 +0100
63.3 @@ -0,0 +1,402 @@
63.4 +/*
63.5 + * GraphLCD driver library
63.6 + *
63.7 + * sed1520.c - SED1520 driver class
63.8 + *
63.9 + * This file is released under the GNU General Public License. Refer
63.10 + * to the COPYING file distributed with this package.
63.11 + *
63.12 + * (c) 2003 Andreas 'randy' Weinberger <vdr AT smue.org>
63.13 + */
63.14 +
63.15 +#include <syslog.h>
63.16 +#include <sys/time.h>
63.17 +
63.18 +#include "common.h"
63.19 +#include "config.h"
63.20 +#include "port.h"
63.21 +#include "sed1520.h"
63.22 +
63.23 +
63.24 +namespace GLCD
63.25 +{
63.26 +
63.27 +// commands
63.28 +const unsigned char kSEAD = 0x00; // Set (X) Column Address
63.29 +const unsigned char kSEPA = 0xb8; // Set (Y) Page Address
63.30 +const unsigned char kSEDS = 0xc0; // Set Display Start Line
63.31 +const unsigned char kDION = 0xaf; // Display on
63.32 +const unsigned char kDIOF = 0xae; // Display off
63.33 +
63.34 +// control bits for DirectIO
63.35 +#define CE1 0x01
63.36 +#define CE1HI 0x01 // Chip Enable 1 on
63.37 +#define CE1LO 0x00 // Chip Enable 1 off
63.38 +
63.39 +const unsigned char kCS1HI = 0x00; // Chip Select 1
63.40 +const unsigned char kCS1LO = 0x01;
63.41 +const unsigned char kCS2HI = 0x04; // Chip Select 2
63.42 +const unsigned char kCS2LO = 0x00;
63.43 +const unsigned char kCDHI = 0x08; // Command/Data Register Select
63.44 +const unsigned char kCDLO = 0x00;
63.45 +const unsigned char kLEDHI = 0x02; // LED Backlight (not supported currently)
63.46 +const unsigned char kLEDLO = 0x00;
63.47 +
63.48 +
63.49 +cDriverSED1520::cDriverSED1520(cDriverConfig * config)
63.50 +: config(config)
63.51 +{
63.52 + oldConfig = new cDriverConfig(*config);
63.53 +
63.54 + port = new cParallelPort();
63.55 +
63.56 + refreshCounter = 0;
63.57 +}
63.58 +
63.59 +cDriverSED1520::~cDriverSED1520()
63.60 +{
63.61 + delete port;
63.62 + delete oldConfig;
63.63 +}
63.64 +
63.65 +int cDriverSED1520::Init()
63.66 +{
63.67 + int x;
63.68 + int i;
63.69 + struct timeval tv1, tv2;
63.70 +
63.71 + if (!(config->width % 8) == 0) {
63.72 + width = config->width + (8 - (config->width % 8));
63.73 + } else {
63.74 + width = config->width;
63.75 + }
63.76 +
63.77 + if (!(config->height % 8) == 0) {
63.78 + height = config->height + (8 - (config->height % 8));
63.79 + } else {
63.80 + height = config->height;
63.81 + }
63.82 +
63.83 + if (width <= 0)
63.84 + width = 120;
63.85 + if (height <= 0)
63.86 + height = 32;
63.87 +
63.88 + SEAD = kSEAD;
63.89 + SEPA = kSEPA;
63.90 + SEDS = kSEDS;
63.91 + DION = kDION;
63.92 + DIOF = kDIOF;
63.93 + LED = kLEDHI;
63.94 + CDHI = kCDHI;
63.95 + CDLO = kCDLO;
63.96 + CS1HI = kCS1HI;
63.97 + CS1LO = kCS1LO;
63.98 + CS2HI = kCS2HI;
63.99 + CS2LO = kCS2LO;
63.100 +
63.101 + for (unsigned int i = 0; i < config->options.size(); i++)
63.102 + {
63.103 + if (config->options[i].name == "")
63.104 + {
63.105 + }
63.106 + }
63.107 +
63.108 + // setup linear lcd array
63.109 + LCD = new unsigned char *[(width + 7) / 8];
63.110 + if (LCD)
63.111 + {
63.112 + for (x = 0; x < (width + 7) / 8; x++)
63.113 + {
63.114 + LCD[x] = new unsigned char[height];
63.115 + memset(LCD[x], 0, height);
63.116 + }
63.117 + }
63.118 + // setup the lcd array for the paged sed1520
63.119 + LCD_page = new unsigned char *[width];
63.120 + if (LCD_page)
63.121 + {
63.122 + for (x = 0; x < width; x++)
63.123 + {
63.124 + LCD_page[x] = new unsigned char[(height + 7) / 8];
63.125 + memset(LCD_page[x], 0, (height + 7) / 8);
63.126 + }
63.127 + }
63.128 +
63.129 + if (config->device == "")
63.130 + {
63.131 + // use DirectIO
63.132 + if (port->Open(config->port) != 0)
63.133 + return -1;
63.134 + uSleep(10);
63.135 + }
63.136 + else
63.137 + {
63.138 + // use ppdev
63.139 + if (port->Open(config->device.c_str()) != 0)
63.140 + return -1;
63.141 + }
63.142 +
63.143 + if (nSleepInit() != 0)
63.144 + {
63.145 + syslog(LOG_DEBUG, "%s: INFO: cannot change wait parameters (cDriver::Init)\n", config->name.c_str());
63.146 + useSleepInit = false;
63.147 + }
63.148 + else
63.149 + {
63.150 + useSleepInit = true;
63.151 + }
63.152 +
63.153 + syslog(LOG_DEBUG, "%s: benchmark started.\n", config->name.c_str());
63.154 + gettimeofday(&tv1, 0);
63.155 + for (i = 0; i < 1000; i++)
63.156 + {
63.157 + port->WriteData(i % 0x100);
63.158 + }
63.159 + gettimeofday(&tv2, 0);
63.160 + if (useSleepInit)
63.161 + nSleepDeInit();
63.162 + timeForPortCmdInNs = (tv2.tv_sec - tv1.tv_sec) * 1000000 + (tv2.tv_usec - tv1.tv_usec);
63.163 + syslog(LOG_DEBUG, "%s: benchmark stopped. Time for Command: %ldns\n", config->name.c_str(), timeForPortCmdInNs);
63.164 +
63.165 + // initialize graphic mode
63.166 + InitGraphic();
63.167 +
63.168 + port->Release();
63.169 +
63.170 + *oldConfig = *config;
63.171 +
63.172 + // clear display
63.173 + Clear();
63.174 +
63.175 + syslog(LOG_INFO, "%s: SED1520 initialized.\n", config->name.c_str());
63.176 + return 0;
63.177 +}
63.178 +
63.179 +int cDriverSED1520::DeInit()
63.180 +{
63.181 + int x;
63.182 +
63.183 + // free linear lcd array
63.184 + if (LCD)
63.185 + {
63.186 + for (x = 0; x < (width + 7) / 8; x++)
63.187 + {
63.188 + delete[] LCD[x];
63.189 + }
63.190 + delete[] LCD;
63.191 + }
63.192 + // free the lcd array for the paged sed1520
63.193 + if (LCD_page)
63.194 + {
63.195 + for (x = 0; x < width; x++)
63.196 + {
63.197 + delete[] LCD_page[x];
63.198 + }
63.199 + delete[] LCD_page;
63.200 + }
63.201 +
63.202 + if (port->Close() != 0)
63.203 + return -1;
63.204 + return 0;
63.205 +}
63.206 +
63.207 +int cDriverSED1520::CheckSetup()
63.208 +{
63.209 + if (config->device != oldConfig->device ||
63.210 + config->port != oldConfig->port ||
63.211 + config->width != oldConfig->width ||
63.212 + config->height != oldConfig->height)
63.213 + {
63.214 + DeInit();
63.215 + Init();
63.216 + return 0;
63.217 + }
63.218 +
63.219 + if (config->upsideDown != oldConfig->upsideDown ||
63.220 + config->invert != oldConfig->invert)
63.221 + {
63.222 + oldConfig->upsideDown = config->upsideDown;
63.223 + oldConfig->invert = config->invert;
63.224 + return 1;
63.225 + }
63.226 + return 0;
63.227 +}
63.228 +
63.229 +int cDriverSED1520::InitGraphic()
63.230 +{
63.231 + // initialize controller1, set display start 0, set page 0, set y address 0, display on
63.232 + SED1520Cmd(SEDS, 1);
63.233 + SED1520Cmd(SEPA, 1);
63.234 + SED1520Cmd(SEAD, 1);
63.235 + SED1520Cmd(DION, 1);
63.236 +
63.237 + // initialize controller2, set display start 0, set page 0, set y address 0, display on
63.238 + SED1520Cmd(SEDS, 2);
63.239 + SED1520Cmd(SEPA, 2);
63.240 + SED1520Cmd(SEAD, 2);
63.241 + SED1520Cmd(DION, 2);
63.242 +
63.243 + return 0;
63.244 +}
63.245 +
63.246 +void cDriverSED1520::SED1520Cmd(unsigned char data, int cmdcs)
63.247 +{
63.248 + if (useSleepInit)
63.249 + nSleepInit();
63.250 +
63.251 + switch (cmdcs)
63.252 + {
63.253 + case 1:
63.254 + port->WriteControl(CDHI | CS1LO | CS2LO | LEDHI);
63.255 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.256 + port->WriteData(data);
63.257 + nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.258 + port->WriteControl(CDHI | CS1HI | CS2LO | LEDHI);
63.259 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.260 + break;
63.261 + case 2:
63.262 + port->WriteControl(CDHI | CS1LO | CS2LO | LED);
63.263 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.264 + port->WriteData(data);
63.265 + nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.266 + port->WriteControl(CDHI | CS1LO | CS2HI | LED);
63.267 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.268 + break;
63.269 + }
63.270 + if (useSleepInit)
63.271 + nSleepDeInit();
63.272 +}
63.273 +
63.274 +void cDriverSED1520::SED1520Data(unsigned char data, int datacs)
63.275 +{
63.276 + if (useSleepInit)
63.277 + nSleepInit();
63.278 +
63.279 + switch (datacs)
63.280 + {
63.281 + case 1:
63.282 + port->WriteControl(CDLO | CS1LO | CS2LO | LEDHI);
63.283 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.284 + port->WriteData(data);
63.285 + nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.286 + port->WriteControl(CDLO | CS1HI | CS2LO | LEDHI);
63.287 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.288 + break;
63.289 + case 2:
63.290 + port->WriteControl(CDLO | CS1LO | CS2LO | LED);
63.291 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.292 + port->WriteData(data);
63.293 + nSleep(650 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.294 + port->WriteControl(CDLO | CS1LO | CS2HI | LED);
63.295 + nSleep(450 - timeForPortCmdInNs + 100 * config->adjustTiming);
63.296 + break;
63.297 + }
63.298 + if (useSleepInit)
63.299 + nSleepDeInit();
63.300 +}
63.301 +
63.302 +void cDriverSED1520::Clear()
63.303 +{
63.304 + for (int x = 0; x < (width + 7) / 8; x++)
63.305 + memset(LCD[x], 0, height);
63.306 +}
63.307 +
63.308 +void cDriverSED1520::Set8Pixels (int x, int y, unsigned char data)
63.309 +{
63.310 + if (x >= width || y >= height)
63.311 + return;
63.312 +
63.313 + if (!config->upsideDown)
63.314 + {
63.315 + // normal orientation
63.316 + LCD[x / 8][y] = LCD[x / 8][y] | data;
63.317 + }
63.318 + else
63.319 + {
63.320 + // upside down orientation
63.321 + x = width - 1 - x;
63.322 + y = height - 1 - y;
63.323 + LCD[x / 8][y] = LCD[x / 8][y] | ReverseBits(data);
63.324 + }
63.325 +}
63.326 +
63.327 +void cDriverSED1520::Refresh(bool refreshAll)
63.328 +{
63.329 + int x,y,xx,yy;
63.330 + unsigned char dByte, oneBlock[8];
63.331 +
63.332 + if (CheckSetup() > 0)
63.333 + refreshAll = true;
63.334 +
63.335 + if (config->refreshDisplay > 0)
63.336 + {
63.337 + refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
63.338 + if (!refreshAll && !refreshCounter)
63.339 + refreshAll = true;
63.340 + }
63.341 +
63.342 + refreshAll = true; // differential update is not yet supported
63.343 +
63.344 + if (refreshAll)
63.345 + {
63.346 + // draw all
63.347 +
63.348 + // convert the linear lcd array to the paged array for the display
63.349 + for (y = 0; y < (height + 7) / 8; y++)
63.350 + {
63.351 + for (x = 0; x < (width + 7) / 8; x++)
63.352 + {
63.353 + for (yy = 0; yy < 8; yy++)
63.354 + {
63.355 + oneBlock[yy] = LCD[x][yy + (y * 8)] ^ (config->invert ? 0xff : 0x00);
63.356 + }
63.357 + for (xx = 0; xx < 8; xx++)
63.358 + {
63.359 + dByte = 0;
63.360 + for (yy = 0; yy < 8; yy++)
63.361 + {
63.362 + if (oneBlock[yy] & bitmask[xx])
63.363 + {
63.364 + dByte += (1 << yy);
63.365 + }
63.366 + }
63.367 + LCD_page[x * 8 + xx][y] = dByte;
63.368 + }
63.369 + }
63.370 + }
63.371 +
63.372 + port->Claim();
63.373 +
63.374 + // send lcd_soll data to display, controller 1
63.375 + // set page and start address
63.376 + for (y = 0; y < (height + 7) / 8; y++)
63.377 + {
63.378 + SED1520Cmd(SEAD, 1);
63.379 + SED1520Cmd(SEPA + y, 1);
63.380 + SED1520Data(0x00 ^ (config->invert ? 0xff : 0x00), 1); // fill first row with zero
63.381 +
63.382 + for (x = 0; x < width / 2 + 1; x++)
63.383 + {
63.384 + SED1520Data(LCD_page[x][y], 1);
63.385 + }
63.386 +
63.387 + SED1520Cmd(SEAD, 2);
63.388 + SED1520Cmd(SEPA + y, 2);
63.389 +
63.390 + for (x = width / 2; x < width; x++)
63.391 + {
63.392 + SED1520Data(LCD_page[x][y], 2);
63.393 + }
63.394 +
63.395 + SED1520Data(0x00 ^ (config->invert ? 0xff : 0x00), 2); // fill last row with zero
63.396 + }
63.397 + port->Release();
63.398 + }
63.399 + else
63.400 + {
63.401 + // draw only the changed bytes
63.402 + }
63.403 +}
63.404 +
63.405 +} // end of namespace
64.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
64.2 +++ b/graphlcd-base/glcddrivers/sed1520.h Thu Feb 07 13:03:18 2008 +0100
64.3 @@ -0,0 +1,72 @@
64.4 +/*
64.5 + * GraphLCD driver library
64.6 + *
64.7 + * sed1520.h - SED1520 driver class
64.8 + *
64.9 + * This file is released under the GNU General Public License. Refer
64.10 + * to the COPYING file distributed with this package.
64.11 + *
64.12 + * (c) 2003 Andreas 'randy' Weinberger <vdr AT smue.org>
64.13 + */
64.14 +
64.15 +#ifndef _GLCDDRIVERS_SED1520_H_
64.16 +#define _GLCDDRIVERS_SED1520_H_
64.17 +
64.18 +#include "driver.h"
64.19 +
64.20 +
64.21 +namespace GLCD
64.22 +{
64.23 +
64.24 +class cDriverConfig;
64.25 +class cParallelPort;
64.26 +
64.27 +class cDriverSED1520 : public cDriver
64.28 +{
64.29 +private:
64.30 + cParallelPort * port;
64.31 + unsigned char ** LCD; // linear lcd display "memory"
64.32 + unsigned char ** LCD_page; // paged lcd display "memory"
64.33 + int refreshCounter;
64.34 + long timeForPortCmdInNs;
64.35 + cDriverConfig * config;
64.36 + cDriverConfig * oldConfig;
64.37 + bool useSleepInit;
64.38 +
64.39 + int SEAD;
64.40 + int SEPA;
64.41 + int SEDS;
64.42 + int DION;
64.43 + int DIOF;
64.44 +
64.45 + int CS1LO;
64.46 + int CS2LO;
64.47 + int CS1HI;
64.48 + int CS2HI;
64.49 +
64.50 + int CDHI;
64.51 + int CDLO;
64.52 +
64.53 + int LED;
64.54 + int LEDHI;
64.55 +
64.56 + int CheckSetup();
64.57 + int InitGraphic();
64.58 + void SED1520Cmd(unsigned char data, int cmscd);
64.59 + void SED1520Data(unsigned char data, int datacs);
64.60 +
64.61 +public:
64.62 + cDriverSED1520(cDriverConfig * config);
64.63 + virtual ~cDriverSED1520();
64.64 +
64.65 + virtual int Init();
64.66 + virtual int DeInit();
64.67 +
64.68 + virtual void Clear();
64.69 + virtual void Set8Pixels(int x, int y, unsigned char data);
64.70 + virtual void Refresh(bool refreshAll = false);
64.71 +};
64.72 +
64.73 +} // end of namespace
64.74 +
64.75 +#endif
65.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
65.2 +++ b/graphlcd-base/glcddrivers/serdisp.c Thu Feb 07 13:03:18 2008 +0100
65.3 @@ -0,0 +1,467 @@
65.4 +/*
65.5 + * GraphLCD driver library
65.6 + *
65.7 + * serdisp.h - include support for displays supported by serdisplib (if library is installed)
65.8 + * http://serdisplib.sourceforge.net
65.9 + *
65.10 + * This file is released under the GNU General Public License. Refer
65.11 + * to the COPYING file distributed with this package.
65.12 + *
65.13 + * (c) 2003-2005 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
65.14 + */
65.15 +
65.16 +#include <stdio.h>
65.17 +#include <stdlib.h>
65.18 +#include <syslog.h>
65.19 +#include <dlfcn.h>
65.20 +
65.21 +#include "common.h"
65.22 +#include "config.h"
65.23 +#include "serdisp.h"
65.24 +
65.25 +#define SERDISP_VERSION(a,b) ((long)(((a) << 8) + (b)))
65.26 +#define SERDISP_VERSION_GET_MAJOR(_c) ((int)( (_c) >> 8 ))
65.27 +#define SERDISP_VERSION_GET_MINOR(_c) ((int)( (_c) & 0xFF ))
65.28 +
65.29 +// taken from serdisp_control.h
65.30 +#define FEATURE_CONTRAST 0x01
65.31 +#define FEATURE_REVERSE 0x02
65.32 +#define FEATURE_BACKLIGHT 0x03
65.33 +#define FEATURE_ROTATE 0x04
65.34 +
65.35 +#define SD_COL_BLACK 0xFF000000
65.36 +
65.37 +namespace GLCD
65.38 +{
65.39 +
65.40 +cDriverSerDisp::cDriverSerDisp(cDriverConfig * config)
65.41 +: config(config)
65.42 +{
65.43 + oldConfig = new cDriverConfig(*config);
65.44 +
65.45 + dd = (void *) NULL;
65.46 +}
65.47 +
65.48 +cDriverSerDisp::~cDriverSerDisp(void)
65.49 +{
65.50 + delete oldConfig;
65.51 +}
65.52 +
65.53 +int cDriverSerDisp::Init(void)
65.54 +{
65.55 + char* errmsg; // error message returned by dlerror()
65.56 +
65.57 + std::string controller;
65.58 + std::string optionstring = "";
65.59 + std::string wiringstring;
65.60 +
65.61 +
65.62 + // dynamically load serdisplib using dlopen() & co.
65.63 +
65.64 + sdhnd = dlopen("libserdisp.so", RTLD_LAZY);
65.65 + if (!sdhnd) { // try /usr/local/lib
65.66 + sdhnd = dlopen("/usr/local/lib/libserdisp.so", RTLD_LAZY);
65.67 + }
65.68 +
65.69 + if (!sdhnd) { // serdisplib seems not to be installed
65.70 + syslog(LOG_ERR, "%s: error: unable to dynamically load library '%s'. Err: %s (cDriver::Init)\n",
65.71 + config->name.c_str(), "libserdisp.so", "not found");
65.72 + return -1;
65.73 + }
65.74 +
65.75 + dlerror(); // clear error code
65.76 +
65.77 + /* pre-init some flags, function pointers, ... */
65.78 + supports_options = 0;
65.79 + fg_colour = 1;
65.80 + bg_colour = -1;
65.81 +
65.82 + // get serdisp version
65.83 + fp_serdisp_getversioncode = (long int (*)()) dlsym(sdhnd, "serdisp_getversioncode");
65.84 +
65.85 + if (dlerror()) { // no serdisp_getversioncode() -> version of serdisplib is < 1.95
65.86 + syslog(LOG_DEBUG, "%s: INFO: symbol serdisp_getversioncode unknown: autodetecting pre 1.95 serdisplib version (cDriver::Init)\n",
65.87 + config->name.c_str());
65.88 +
65.89 + fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
65.90 + if (dlerror()) { // no SDCONN_open() -> version of serdisplib is < 1.93
65.91 + serdisp_version = SERDISP_VERSION(1,92);
65.92 + syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version <= 1.92 (cDriver::Init)\n", config->name.c_str());
65.93 +
65.94 + fp_PP_open = (void*(*)(const char*))dlsym(sdhnd, "PP_open");
65.95 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.96 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.97 + config->name.c_str(), "PP_open", errmsg);
65.98 + return -1;
65.99 + }
65.100 + fp_PP_close = (void*(*)(void*))dlsym(sdhnd, "PP_close");
65.101 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.102 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.103 + config->name.c_str(), "PP_close", errmsg);
65.104 + return -1;
65.105 + }
65.106 + } else {
65.107 + serdisp_version = SERDISP_VERSION(1,94); // no serdisp_getversioncode, but SDCONN_open: 1.93 or 1.94
65.108 + syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version 1.93 or 1.94 (cDriver::Init)\n", config->name.c_str());
65.109 +
65.110 + fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
65.111 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.112 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.113 + config->name.c_str(), "serdisp_quit", errmsg);
65.114 + return -1;
65.115 + }
65.116 + }
65.117 +
65.118 + fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setpixel");
65.119 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.120 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.121 + config->name.c_str(), "serdisp_setpixel", errmsg);
65.122 + return -1;
65.123 + }
65.124 + fg_colour = 1; /* set foreground to 'pixel on' */
65.125 +
65.126 + } else { // serdisp version >= 1.95
65.127 + serdisp_version = fp_serdisp_getversioncode();
65.128 + syslog(LOG_DEBUG, "%s: INFO: detected serdisplib version %d.%d (cDriver::Init)\n",
65.129 + config->name.c_str(), SERDISP_VERSION_GET_MAJOR(serdisp_version), SERDISP_VERSION_GET_MINOR(serdisp_version));
65.130 +
65.131 +
65.132 + fp_SDCONN_open = (void*(*)(const char*)) dlsym(sdhnd, "SDCONN_open");
65.133 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.134 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.135 + config->name.c_str(), "SDCONN_open", errmsg);
65.136 + return -1;
65.137 + }
65.138 + fp_serdisp_quit = (void (*)(void*)) dlsym(sdhnd, "serdisp_quit");
65.139 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.140 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.141 + config->name.c_str(), "serdisp_quit", errmsg);
65.142 + return -1;
65.143 + }
65.144 + fp_serdisp_setpixcol = (void (*)(void*, int, int, long int)) dlsym(sdhnd, "serdisp_setcolour");
65.145 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.146 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.147 + config->name.c_str(), "serdisp_setcolour", errmsg);
65.148 + return -1;
65.149 + }
65.150 + fg_colour = SD_COL_BLACK; /* set foreground colour to black */
65.151 +
65.152 + if (serdisp_version >= SERDISP_VERSION(1,96) ) {
65.153 + supports_options = 1;
65.154 +
65.155 + fp_serdisp_isoption = (int (*)(void*, const char*)) dlsym(sdhnd, "serdisp_isoption");
65.156 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.157 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.158 + config->name.c_str(), "serdisp_isoption", errmsg);
65.159 + return -1;
65.160 + }
65.161 + fp_serdisp_setoption = (void (*)(void*, const char*, long int)) dlsym(sdhnd, "serdisp_setoption");
65.162 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.163 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.164 + config->name.c_str(), "serdisp_setoption", errmsg);
65.165 + return -1;
65.166 + }
65.167 + } /* >= 1.96 */
65.168 + }
65.169 +
65.170 + // load other symbols that will be required
65.171 + fp_serdisp_init = (void*(*)(void*, const char*, const char*)) dlsym(sdhnd, "serdisp_init");
65.172 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.173 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.174 + config->name.c_str(), "serdisp_init", errmsg);
65.175 + return -1;
65.176 + }
65.177 +
65.178 + fp_serdisp_rewrite = (void (*)(void*)) dlsym(sdhnd, "serdisp_rewrite");
65.179 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.180 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.181 + config->name.c_str(), "serdisp_rewrite", errmsg);
65.182 + return -1;
65.183 + }
65.184 +
65.185 + fp_serdisp_update = (void (*)(void*)) dlsym(sdhnd, "serdisp_update");
65.186 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.187 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.188 + config->name.c_str(), "serdisp_update", errmsg);
65.189 + return -1;
65.190 + }
65.191 +
65.192 + fp_serdisp_clearbuffer = (void (*)(void*)) dlsym(sdhnd, "serdisp_clearbuffer");
65.193 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.194 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.195 + config->name.c_str(), "serdisp_clearbuffer", errmsg);
65.196 + return -1;
65.197 + }
65.198 +
65.199 + fp_serdisp_feature = (int (*)(void*, int, int)) dlsym(sdhnd, "serdisp_feature");
65.200 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.201 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.202 + config->name.c_str(), "serdisp_feature", errmsg);
65.203 + return -1;
65.204 + }
65.205 +
65.206 + fp_serdisp_close = (void (*)(void*))dlsym(sdhnd, "serdisp_close");
65.207 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.208 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.209 + config->name.c_str(), "serdisp_close", errmsg);
65.210 + return -1;
65.211 + }
65.212 +
65.213 + fp_serdisp_getwidth = (int (*)(void*)) dlsym(sdhnd, "serdisp_getwidth");
65.214 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.215 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.216 + config->name.c_str(), "serdisp_getwidth", errmsg);
65.217 + return -1;
65.218 + }
65.219 +
65.220 + fp_serdisp_getheight = (int (*)(void*)) dlsym(sdhnd, "serdisp_getheight");
65.221 + if ( (errmsg = dlerror()) != NULL ) { // should not happen
65.222 + syslog(LOG_ERR, "%s: error: cannot load symbol %s. Err:%s (cDriver::Init)\n",
65.223 + config->name.c_str(), "serdisp_getheight", errmsg);
65.224 + return -1;
65.225 + }
65.226 +
65.227 + // done loading all required symbols
65.228 +
65.229 +
65.230 + // setting up the display
65.231 + width = 0;
65.232 + height = 0;
65.233 +
65.234 + for (unsigned int i = 0; i < config->options.size(); i++)
65.235 + {
65.236 + if (config->options[i].name == "Controller") {
65.237 + controller = config->options[i].value;
65.238 + } else if (config->options[i].name == "Options") {
65.239 + optionstring = config->options[i].value;
65.240 + } else if (config->options[i].name == "Wiring") {
65.241 + wiringstring = config->options[i].value;
65.242 + } else if (config->options[i].name == "FGColour") {
65.243 + fg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0);
65.244 + fg_colour |= 0xFF000000L; /* force alpha to 0xFF */
65.245 + } else if (config->options[i].name == "BGColour") {
65.246 + bg_colour = strtoul(config->options[i].value.c_str(), (char **)NULL, 0);
65.247 + bg_colour |= 0xFF000000L; /* force alpha to 0xFF */
65.248 + }
65.249 + }
65.250 +
65.251 + if (wiringstring.length()) {
65.252 + optionstring = "WIRING=" + wiringstring + ((optionstring != "") ? ";" + optionstring : "");
65.253 + }
65.254 +
65.255 + if (controller == "")
65.256 + {
65.257 + syslog(LOG_ERR, "%s error: no controller given!\n", config->name.c_str());
65.258 + return -1;
65.259 + }
65.260 +
65.261 +
65.262 + if (config->device == "")
65.263 + {
65.264 + // use DirectIO
65.265 +
65.266 + // neither device nor port is set
65.267 + if (config->port == 0)
65.268 + return -1;
65.269 +
65.270 + char temp[10];
65.271 + snprintf(temp, 8, "0x%x", config->port);
65.272 +
65.273 + if (serdisp_version < SERDISP_VERSION(1,93) ) {
65.274 + sdcd = fp_PP_open(temp);
65.275 + } else {
65.276 + sdcd = fp_SDCONN_open(temp);
65.277 + }
65.278 +
65.279 + if (sdcd == 0) {
65.280 + syslog(LOG_ERR, "%s: error: unable to open port 0x%x for display %s. (cDriver::Init)\n",
65.281 + config->name.c_str(), config->port, controller.c_str());
65.282 + return -1;
65.283 + }
65.284 +
65.285 + uSleep(10);
65.286 + }
65.287 + else
65.288 + {
65.289 + // use ppdev
65.290 + if (serdisp_version < SERDISP_VERSION(1,93) ) {
65.291 + sdcd = fp_PP_open(config->device.c_str());
65.292 + } else {
65.293 + sdcd = fp_SDCONN_open(config->device.c_str());
65.294 + }
65.295 +
65.296 + if (sdcd == 0) {
65.297 + syslog(LOG_ERR, "%s: error: unable to open device %s for display %s. (cDriver::Init)\n",
65.298 + config->name.c_str(), config->device.c_str(), controller.c_str());
65.299 + return -1;
65.300 + }
65.301 + }
65.302 +
65.303 + if (serdisp_version < SERDISP_VERSION(1,95) )
65.304 + dd = fp_serdisp_init(sdcd, controller.c_str(), "");
65.305 + else
65.306 + dd = fp_serdisp_init(sdcd, controller.c_str(), optionstring.c_str());
65.307 +
65.308 + if (!dd)
65.309 + {
65.310 + syslog(LOG_ERR, "%s: error: cannot open display %s. Err:%s (cDriver::Init)\n",
65.311 + config->name.c_str(), controller.c_str(), "no handle");
65.312 + return -1;
65.313 + }
65.314 +
65.315 + width = config->width;
65.316 + if (width <= 0)
65.317 + width = fp_serdisp_getwidth(dd);
65.318 + height = config->height;
65.319 + if (height <= 0)
65.320 + height = fp_serdisp_getheight(dd);
65.321 +
65.322 + if (serdisp_version < SERDISP_VERSION(1,96) ) {
65.323 + fp_serdisp_feature(dd, FEATURE_ROTATE, config->upsideDown);
65.324 + fp_serdisp_feature(dd, FEATURE_CONTRAST, config->contrast);
65.325 + fp_serdisp_feature(dd, FEATURE_BACKLIGHT, config->backlight);
65.326 + fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
65.327 + } else {
65.328 + /* standard options */
65.329 + fp_serdisp_setoption(dd, "ROTATE", config->upsideDown);
65.330 + fp_serdisp_setoption(dd, "CONTRAST", config->contrast);
65.331 + fp_serdisp_setoption(dd, "BACKLIGHT", config->backlight);
65.332 + fp_serdisp_setoption(dd, "INVERT", config->invert);
65.333 +
65.334 + /* driver dependend options */
65.335 + for (unsigned int i = 0; i < config->options.size(); i++) {
65.336 + std::string optionname = config->options[i].name;
65.337 + if (optionname != "UpsideDown" && optionname != "Contrast" &&
65.338 + optionname != "Backlight" && optionname != "Invert") {
65.339 +
65.340 + if ( fp_serdisp_isoption(dd, optionname.c_str()) == 1 ) /* if == 1: option is existing AND r/w */
65.341 + fp_serdisp_setoption(dd, optionname.c_str(), strtol(config->options[i].value.c_str(), NULL, 0));
65.342 + }
65.343 + }
65.344 +
65.345 + }
65.346 +
65.347 + *oldConfig = *config;
65.348 +
65.349 + // clear display
65.350 + Clear();
65.351 +
65.352 + syslog(LOG_INFO, "%s: SerDisp with %s initialized.\n", config->name.c_str(), controller.c_str());
65.353 + return 0;
65.354 +}
65.355 +
65.356 +int cDriverSerDisp::DeInit(void)
65.357 +{
65.358 + if (serdisp_version < SERDISP_VERSION(1,93) ) {
65.359 + fp_serdisp_close(dd);
65.360 + fp_PP_close(sdcd);
65.361 + sdcd = NULL;
65.362 + } else {
65.363 + //fp_serdisp_quit(dd);
65.364 + /* use serdisp_close instead of serdisp_quit so that showpic and showtext are usable together with serdisplib */
65.365 + fp_serdisp_close(dd);
65.366 + }
65.367 + (int) dlclose(sdhnd);
65.368 + sdhnd = NULL;
65.369 +
65.370 + return 0;
65.371 +}
65.372 +
65.373 +int cDriverSerDisp::CheckSetup()
65.374 +{
65.375 + bool update = false;
65.376 +
65.377 + if (config->device != oldConfig->device ||
65.378 + config->port != oldConfig->port ||
65.379 + config->width != oldConfig->width ||
65.380 + config->height != oldConfig->height)
65.381 + {
65.382 + DeInit();
65.383 + Init();
65.384 + return 0;
65.385 + }
65.386 +
65.387 + if (config->contrast != oldConfig->contrast)
65.388 + {
65.389 + fp_serdisp_feature(dd, FEATURE_CONTRAST, config->contrast);
65.390 + oldConfig->contrast = config->contrast;
65.391 + update = true;
65.392 + }
65.393 + if (config->backlight != oldConfig->backlight)
65.394 + {
65.395 + fp_serdisp_feature(dd, FEATURE_BACKLIGHT, config->backlight);
65.396 + oldConfig->backlight = config->backlight;
65.397 + update = true;
65.398 + }
65.399 + if (config->upsideDown != oldConfig->upsideDown)
65.400 + {
65.401 + fp_serdisp_feature(dd, FEATURE_ROTATE, config->upsideDown);
65.402 + oldConfig->upsideDown = config->upsideDown;
65.403 + update = true;
65.404 + }
65.405 + if (config->invert != oldConfig->invert)
65.406 + {
65.407 + fp_serdisp_feature(dd, FEATURE_REVERSE, config->invert);
65.408 + oldConfig->invert = config->invert;
65.409 + update = true;
65.410 + }
65.411 +
65.412 + /* driver dependend options */
65.413 + for (unsigned int i = 0; i < config->options.size(); i++) {
65.414 + std::string optionname = config->options[i].name;
65.415 + if (optionname != "UpsideDown" && optionname != "Contrast" &&
65.416 + optionname != "Backlight" && optionname != "Invert") {
65.417 +
65.418 + if ( fp_serdisp_isoption(dd, optionname.c_str()) == 1 ) /* if == 1: option is existing AND r/w */
65.419 + fp_serdisp_setoption(dd, optionname.c_str(), strtol(config->options[i].value.c_str(), NULL, 0));
65.420 + oldConfig->options[i] = config->options[i];
65.421 + update = true;
65.422 + }
65.423 + }
65.424 +
65.425 +
65.426 + if (update)
65.427 + return 1;
65.428 + return 0;
65.429 +}
65.430 +
65.431 +void cDriverSerDisp::Clear(void)
65.432 +{
65.433 + if (bg_colour == -1)
65.434 + fp_serdisp_clearbuffer(dd);
65.435 + else { /* if bg_colour is set, draw background 'by hand' */
65.436 + int x,y;
65.437 + for (y = 0; y < fp_serdisp_getheight(dd); y++)
65.438 + for (x = 0; x < fp_serdisp_getwidth(dd); x++)
65.439 + fp_serdisp_setpixcol(dd, x, y, bg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
65.440 + }
65.441 +}
65.442 +
65.443 +void cDriverSerDisp::Set8Pixels(int x, int y, unsigned char data) {
65.444 + int i, start, pixel;
65.445 +
65.446 + data = ReverseBits(data);
65.447 +
65.448 + start = (x >> 3) << 3;
65.449 +
65.450 + for (i = 0; i < 8; i++) {
65.451 + pixel = data & (1 << i);
65.452 + if (pixel)
65.453 + fp_serdisp_setpixcol(dd, start + i, y, fg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
65.454 + else if (!pixel && bg_colour != -1) /* if bg_colour is set: use it if pixel is not set */
65.455 + fp_serdisp_setpixcol(dd, start + i, y, bg_colour); /* >= 1.95: serdisp_setcolour(), < 1.95: serdisp_setpixel() */
65.456 + }
65.457 +}
65.458 +
65.459 +void cDriverSerDisp::Refresh(bool refreshAll)
65.460 +{
65.461 + if (CheckSetup() == 1)
65.462 + refreshAll = true;
65.463 +
65.464 + if (refreshAll)
65.465 + fp_serdisp_rewrite(dd);
65.466 + else
65.467 + fp_serdisp_update(dd);
65.468 +}
65.469 +
65.470 +} // end of namespace
66.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
66.2 +++ b/graphlcd-base/glcddrivers/serdisp.h Thu Feb 07 13:03:18 2008 +0100
66.3 @@ -0,0 +1,78 @@
66.4 +/*
66.5 + * GraphLCD driver library
66.6 + *
66.7 + * serdisp.h - include support for displays supported by serdisplib (if library is installed)
66.8 + * http://serdisplib.sourceforge.net
66.9 + *
66.10 + * This file is released under the GNU General Public License. Refer
66.11 + * to the COPYING file distributed with this package.
66.12 + *
66.13 + * (c) 2003-2005 Wolfgang Astleitner <mrwastl AT users.sourceforge.net>
66.14 + */
66.15 +
66.16 +#ifndef _GLCDDRIVERS_SERDISP_H_
66.17 +#define _GLCDDRIVERS_SERDISP_H_
66.18 +
66.19 +#include "driver.h"
66.20 +
66.21 +
66.22 +namespace GLCD
66.23 +{
66.24 +
66.25 +class cDriverConfig;
66.26 +
66.27 +class cDriverSerDisp : public cDriver
66.28 +{
66.29 +private:
66.30 +
66.31 + cDriverConfig * config;
66.32 + cDriverConfig * oldConfig;
66.33 +
66.34 + long serdisp_version;
66.35 +
66.36 + int supports_options;
66.37 + long fg_colour;
66.38 + long bg_colour;
66.39 +
66.40 + void* sdhnd; // serdisplib handle
66.41 + void* dd; // display descriptor
66.42 + void* sdcd; // serdisp connect descriptor
66.43 +
66.44 + long (*fp_serdisp_getversioncode) ();
66.45 +
66.46 + void* (*fp_SDCONN_open) (const char sdcdev[]);
66.47 +
66.48 + void* (*fp_PP_open) (const char sdcdev[]);
66.49 + void* (*fp_PP_close) (void* sdcd);
66.50 +
66.51 + void* (*fp_serdisp_init) (void* sdcd, const char dispname[], const char extra[]);
66.52 + void (*fp_serdisp_rewrite) (void* dd);
66.53 + void (*fp_serdisp_update) (void* dd);
66.54 + void (*fp_serdisp_clearbuffer) (void* dd);
66.55 + void (*fp_serdisp_setpixcol) (void* dd, int x, int y, long colour); // serdisp_setpixel or serdisp_setcolour
66.56 + int (*fp_serdisp_feature) (void* dd, int feature, int value);
66.57 + int (*fp_serdisp_isoption) (void* dd, const char* optionname);
66.58 + void (*fp_serdisp_setoption) (void* dd, const char* optionname, long value);
66.59 + int (*fp_serdisp_getwidth) (void* dd);
66.60 + int (*fp_serdisp_getheight) (void* dd);
66.61 + void (*fp_serdisp_quit) (void* dd);
66.62 + void (*fp_serdisp_close) (void* dd);
66.63 +
66.64 + int CheckSetup();
66.65 +
66.66 +public:
66.67 +
66.68 + cDriverSerDisp(cDriverConfig * config);
66.69 + virtual ~cDriverSerDisp();
66.70 +
66.71 + virtual int Init();
66.72 + virtual int DeInit();
66.73 +
66.74 + virtual void Clear();
66.75 + virtual void Set8Pixels(int x, int y, unsigned char data);
66.76 + virtual void Refresh(bool refreshAll = false);
66.77 +};
66.78 +
66.79 +#endif
66.80 +
66.81 +} // end of namespace
67.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
67.2 +++ b/graphlcd-base/glcddrivers/simlcd.c Thu Feb 07 13:03:18 2008 +0100
67.3 @@ -0,0 +1,183 @@
67.4 +/*
67.5 + * GraphLCD driver library
67.6 + *
67.7 + * simlcd.c - SimLCD driver class
67.8 + * Output goes to a file instead of lcd.
67.9 + * Use SimLCD tool to view this file.
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) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
67.15 + */
67.16 +
67.17 +#include <stdio.h>
67.18 +#include <syslog.h>
67.19 +
67.20 +#include "common.h"
67.21 +#include "config.h"
67.22 +#include "simlcd.h"
67.23 +
67.24 +
67.25 +namespace GLCD
67.26 +{
67.27 +
67.28 +cDriverSimLCD::cDriverSimLCD(cDriverConfig * config)
67.29 +: config(config)
67.30 +{
67.31 + oldConfig = new cDriverConfig(*config);
67.32 +}
67.33 +
67.34 +cDriverSimLCD::~cDriverSimLCD()
67.35 +{
67.36 + delete oldConfig;
67.37 +}
67.38 +
67.39 +int cDriverSimLCD::Init()
67.40 +{
67.41 + width = config->width;
67.42 + if (width <= 0)
67.43 + width = 240;
67.44 + height = config->height;
67.45 + if (height <= 0)
67.46 + height = 128;
67.47 +
67.48 + for (unsigned int i = 0; i < config->options.size(); i++)
67.49 + {
67.50 + if (config->options[i].name == "")
67.51 + {
67.52 + }
67.53 + }
67.54 +
67.55 + // setup lcd array
67.56 + LCD = new unsigned char *[(width + 7) / 8];
67.57 + if (LCD)
67.58 + {
67.59 + for (int x = 0; x < (width + 7) / 8; x++)
67.60 + {
67.61 + LCD[x] = new unsigned char[height];
67.62 + memset(LCD[x], 0, height);
67.63 + }
67.64 + }
67.65 +
67.66 + *oldConfig = *config;
67.67 +
67.68 + // clear display
67.69 + Clear();
67.70 +
67.71 + syslog(LOG_INFO, "%s: SIMLCD initialized.\n", config->name.c_str());
67.72 + return 0;
67.73 +}
67.74 +
67.75 +int cDriverSimLCD::DeInit()
67.76 +{
67.77 + // free lcd array
67.78 + if (LCD)
67.79 + {
67.80 + for (int x = 0; x < (width + 7) / 8; x++)
67.81 + {
67.82 + delete[] LCD[x];
67.83 + }
67.84 + delete[] LCD;
67.85 + }
67.86 +
67.87 + return 0;
67.88 +}
67.89 +
67.90 +int cDriverSimLCD::CheckSetup()
67.91 +{
67.92 + if (config->width != oldConfig->width ||
67.93 + config->height != oldConfig->height)
67.94 + {
67.95 + DeInit();
67.96 + Init();
67.97 + return 0;
67.98 + }
67.99 +
67.100 + if (config->upsideDown != oldConfig->upsideDown ||
67.101 + config->invert != oldConfig->invert)
67.102 + {
67.103 + oldConfig->upsideDown = config->upsideDown;
67.104 + oldConfig->invert = config->invert;
67.105 + return 1;
67.106 + }
67.107 + return 0;
67.108 +}
67.109 +
67.110 +void cDriverSimLCD::Clear()
67.111 +{
67.112 + for (int x = 0; x < (width + 7) / 8; x++)
67.113 + memset(LCD[x], 0, height);
67.114 +}
67.115 +
67.116 +void cDriverSimLCD::Set8Pixels(int x, int y, unsigned char data)
67.117 +{
67.118 + if (x >= width || y >= height)
67.119 + return;
67.120 +
67.121 + if (!config->upsideDown)
67.122 + {
67.123 + // normal orientation
67.124 + LCD[x / 8][y] = LCD[x / 8][y] | data;
67.125 + }
67.126 + else
67.127 + {
67.128 + // upside down orientation
67.129 + x = width - 1 - x;
67.130 + y = height - 1 - y;
67.131 + LCD[x / 8][y] = LCD[x / 8][y] | ReverseBits(data);
67.132 + }
67.133 +}
67.134 +
67.135 +void cDriverSimLCD::Refresh(bool refreshAll)
67.136 +{
67.137 + FILE * fp = NULL;
67.138 + int x;
67.139 + int y;
67.140 + int i;
67.141 + unsigned char c;
67.142 +
67.143 + if (CheckSetup() > 0)
67.144 + refreshAll = true;
67.145 +
67.146 + fp = fopen("/tmp/simlcd.sem", "r");
67.147 + if (!fp || refreshAll)
67.148 + {
67.149 + if (fp)
67.150 + fclose(fp);
67.151 + fp = fopen("/tmp/simlcd.dat", "w");
67.152 + if (fp)
67.153 + {
67.154 + for (y = 0; y < height; y++)
67.155 + {
67.156 + for (x = 0; x < (width + 7) / 8; x++)
67.157 + {
67.158 + c = LCD[x][y] ^ (config->invert ? 0xff : 0x00);
67.159 + for (i = 0; i < 8; i++)
67.160 + {
67.161 + if (c & 0x80)
67.162 + {
67.163 + fprintf(fp,"#");
67.164 + }
67.165 + else
67.166 + {
67.167 + fprintf(fp,".");
67.168 + }
67.169 + c = c << 1;
67.170 + }
67.171 + }
67.172 + fprintf(fp,"\n");
67.173 + }
67.174 + fclose(fp);
67.175 + }
67.176 +
67.177 + fp = fopen("/tmp/simlcd.sem", "w");
67.178 + fclose(fp);
67.179 + }
67.180 + else
67.181 + {
67.182 + fclose(fp);
67.183 + }
67.184 +}
67.185 +
67.186 +} // end of namespace
68.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
68.2 +++ b/graphlcd-base/glcddrivers/simlcd.h Thu Feb 07 13:03:18 2008 +0100
68.3 @@ -0,0 +1,48 @@
68.4 +/*
68.5 + * GraphLCD driver library
68.6 + *
68.7 + * simlcd.h - SimLCD driver class
68.8 + * Output goes to a file instead of lcd.
68.9 + * Use SimLCD tool to view this file.
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) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
68.15 + */
68.16 +
68.17 +#ifndef _GLCDDRIVERS_SIMLCD_H_
68.18 +#define _GLCDDRIVERS_SIMLCD_H_
68.19 +
68.20 +#include "driver.h"
68.21 +
68.22 +
68.23 +namespace GLCD
68.24 +{
68.25 +
68.26 +class cDriverConfig;
68.27 +
68.28 +class cDriverSimLCD : public cDriver
68.29 +{
68.30 +private:
68.31 + unsigned char ** LCD;
68.32 + cDriverConfig * config;
68.33 + cDriverConfig * oldConfig;
68.34 +
68.35 + int CheckSetup();
68.36 +
68.37 +public:
68.38 + cDriverSimLCD(cDriverConfig * config);
68.39 + virtual ~cDriverSimLCD();
68.40 +
68.41 + virtual int Init();
68.42 + virtual int DeInit();
68.43 +
68.44 + virtual void Clear();
68.45 + virtual void Set8Pixels(int x, int y, unsigned char data);
68.46 + virtual void Refresh(bool refreshAll = false);
68.47 +};
68.48 +
68.49 +} // end of namespace
68.50 +
68.51 +#endif
69.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
69.2 +++ b/graphlcd-base/glcddrivers/t6963c.c Thu Feb 07 13:03:18 2008 +0100
69.3 @@ -0,0 +1,678 @@
69.4 +/*
69.5 + * GraphLCD driver library
69.6 + *
69.7 + * t6963c.c - T6963C driver class
69.8 + *
69.9 + * low level routines based on lcdproc 0.5 driver, (c) 2001 Manuel Stahl
69.10 + *
69.11 + * This file is released under the GNU General Public License. Refer
69.12 + * to the COPYING file distributed with this package.
69.13 + *
69.14 + * (c) 2003, 2004 Andreas Regel <andreas.regel AT powarman.de>
69.15 + */
69.16 +
69.17 +#include <syslog.h>
69.18 +
69.19 +#include "common.h"
69.20 +#include "config.h"
69.21 +#include "port.h"
69.22 +#include "t6963c.h"
69.23 +
69.24 +
69.25 +namespace GLCD
69.26 +{
69.27 +
69.28 +// T6963 commands
69.29 +const unsigned char kSetCursorPointer = 0x21;
69.30 +const unsigned char kSetOffsetRegister = 0x22;
69.31 +const unsigned char kSetAddressPointer = 0x24;
69.32 +
69.33 +const unsigned char kSetTextHomeAddress = 0x40;
69.34 +const unsigned char kSetTextArea = 0x41;
69.35 +const unsigned char kSetGraphicHomeAddress = 0x42;
69.36 +const unsigned char kSetGraphicArea = 0x43;
69.37 +
69.38 +const unsigned char kSetMode = 0x80;
69.39 +const unsigned char kSetDisplayMode = 0x90;
69.40 +const unsigned char kSetCursorPattern = 0xA0;
69.41 +
69.42 +const unsigned char kDataWriteInc = 0xC0;
69.43 +const unsigned char kDataReadInc = 0xC1;
69.44 +const unsigned char kDataWriteDec = 0xC2;
69.45 +const unsigned char kDataReadDec = 0xC3;
69.46 +const unsigned char kDataWrite = 0xC4;
69.47 +const unsigned char kDataRead = 0xC5;
69.48 +
69.49 +const unsigned char kAutoWrite = 0xB0;
69.50 +const unsigned char kAutoRead = 0xB1;
69.51 +const unsigned char kAutoReset = 0xB2;
69.52 +
69.53 +
69.54 +// T6963 Parameters
69.55 +const unsigned char kModeOr = 0x00;
69.56 +const unsigned char kModeXor = 0x01;
69.57 +const unsigned char kModeAnd = 0x03;
69.58 +const unsigned char kModeTextAttribute = 0x04;
69.59 +const unsigned char kModeInternalCG = 0x00;
69.60 +const unsigned char kModeExternalCG = 0x08;
69.61 +
69.62 +const unsigned char kTextAttributeNormal = 0x00;
69.63 +const unsigned char kTextAttributeInverse = 0x05;
69.64 +const unsigned char kTextAttributeNoDisplay = 0x03;
69.65 +const unsigned char kTextAttributeBlink = 0x08;
69.66 +
69.67 +const unsigned char kDisplayModeBlink = 0x01;
69.68 +const unsigned char kDisplayModeCursor = 0x02;
69.69 +const unsigned char kDisplayModeText = 0x04;
69.70 +const unsigned char kDisplayModeGraphic = 0x08;
69.71 +
69.72 +const unsigned short kGraphicBase = 0x0000;
69.73 +const unsigned short kTextBase = 0x1500;
69.74 +const unsigned short kCGRAMBase = 0x1800;
69.75 +
69.76 +
69.77 +// T6963 Wirings
69.78 +static const std::string kWiringStandard = "Standard";
69.79 +static const std::string kWiringWindows = "Windows";
69.80 +static const std::string kWiringSerial = "Serial";
69.81 +
69.82 +const unsigned char kStandardWRHI = 0x00; // 01 / nSTRB
69.83 +const unsigned char kStandardWRLO = 0x01; //
69.84 +const unsigned char kStandardRDHI = 0x00; // 17 / nSELECT
69.85 +const unsigned char kStandardRDLO = 0x08; //
69.86 +const unsigned char kStandardCEHI = 0x00; // 14 / nLINEFEED
69.87 +const unsigned char kStandardCELO = 0x02; //
69.88 +const unsigned char kStandardCDHI = 0x04; // 16 / INIT
69.89 +const unsigned char kStandardCDLO = 0x00; //
69.90 +
69.91 +const unsigned char kWindowsWRHI = 0x04; // 16 / INIT
69.92 +const unsigned char kWindowsWRLO = 0x00; //
69.93 +const unsigned char kWindowsRDHI = 0x00; // 14 / nLINEFEED
69.94 +const unsigned char kWindowsRDLO = 0x02; //
69.95 +const unsigned char kWindowsCEHI = 0x00; // 01 / nSTRB
69.96 +const unsigned char kWindowsCELO = 0x01; //
69.97 +const unsigned char kWindowsCDHI = 0x00; // 17 / nSELECT
69.98 +const unsigned char kWindowsCDLO = 0x08; //
69.99 +
69.100 +const unsigned char kSerialWRHI = 0x01; // 01 / nSTRB
69.101 +const unsigned char kSerialWRLO = 0x00; //
69.102 +const unsigned char kSerialRDHI = 0x08; // 17 / nSELECT
69.103 +const unsigned char kSerialRDLO = 0x00; //
69.104 +const unsigned char kSerialCEHI = 0x02; // 14 / nLINEFEED
69.105 +const unsigned char kSerialCELO = 0x00; //
69.106 +const unsigned char kSerialCDHI = 0x00; // 16 / INIT
69.107 +const unsigned char kSerialCDLO = 0x04; //
69.108 +
69.109 +
69.110 +cDriverT6963C::cDriverT6963C(cDriverConfig * config)
69.111 +: config(config)
69.112 +{
69.113 + oldConfig = new cDriverConfig(*config);
69.114 +
69.115 + port = new cParallelPort();
69.116 +
69.117 + //width = config->width;
69.118 + //height = config->height;
69.119 + refreshCounter = 0;
69.120 + displayMode = 0;
69.121 + bidirectLPT = 1;
69.122 + autoWrite = false;
69.123 + serial = 0;
69.124 +}
69.125 +
69.126 +cDriverT6963C::~cDriverT6963C()
69.127 +{
69.128 + delete port;
69.129 + delete oldConfig;
69.130 +}
69.131 +
69.132 +int cDriverT6963C::Init()
69.133 +{
69.134 + int x;
69.135 +
69.136 + width = config->width;
69.137 + if (width <= 0)
69.138 + width = 240;
69.139 + height = config->height;
69.140 + if (height <= 0)
69.141 + height = 128;
69.142 +
69.143 + // default values
69.144 + FS = 6;
69.145 + WRHI = kStandardWRHI;
69.146 + WRLO = kStandardWRLO;
69.147 + RDHI = kStandardRDHI;
69.148 + RDLO = kStandardRDLO;
69.149 + CEHI = kStandardCEHI;
69.150 + CELO = kStandardCELO;
69.151 + CDHI = kStandardCDHI;
69.152 + CDLO = kStandardCDLO;
69.153 + useAutoMode = true;
69.154 + useStatusCheck = true;
69.155 +
69.156 + for (unsigned int i = 0; i < config->options.size(); i++)
69.157 + {
69.158 + if (config->options[i].name == "FontSelect")
69.159 + {
69.160 + int fontSelect = atoi(config->options[i].value.c_str());
69.161 + if (fontSelect == 6)
69.162 + FS = 6;
69.163 + else if (fontSelect == 8)
69.164 + FS = 8;
69.165 + else
69.166 + syslog(LOG_ERR, "%s error: font select %d not supported, using default (%d)!\n",
69.167 + config->name.c_str(), fontSelect, FS);
69.168 + }
69.169 + else if (config->options[i].name == "Wiring")
69.170 + {
69.171 + if (config->options[i].value == kWiringStandard)
69.172 + {
69.173 + WRHI = kStandardWRHI;
69.174 + WRLO = kStandardWRLO;
69.175 + RDHI = kStandardRDHI;
69.176 + RDLO = kStandardRDLO;
69.177 + CEHI = kStandardCEHI;
69.178 + CELO = kStandardCELO;
69.179 + CDHI = kStandardCDHI;
69.180 + CDLO = kStandardCDLO;
69.181 + }
69.182 + else if (config->options[i].value == kWiringWindows)
69.183 + {
69.184 + WRHI = kWindowsWRHI;
69.185 + WRLO = kWindowsWRLO;
69.186 + RDHI = kWindowsRDHI;
69.187 + RDLO = kWindowsRDLO;
69.188 + CEHI = kWindowsCEHI;
69.189 + CELO = kWindowsCELO;
69.190 + CDHI = kWindowsCDHI;
69.191 + CDLO = kWindowsCDLO;
69.192 + }
69.193 + else if (config->options[i].value == kWiringSerial)
69.194 + {
69.195 + serial = 1;
69.196 + WRHI = kSerialWRHI;
69.197 + WRLO = kSerialWRLO;
69.198 + RDHI = kSerialRDHI;
69.199 + RDLO = kSerialRDLO;
69.200 + CEHI = kSerialCEHI;
69.201 + CELO = kSerialCELO;
69.202 + CDHI = kSerialCDHI;
69.203 + CDLO = kSerialCDLO;
69.204 + }
69.205 + else
69.206 + syslog(LOG_ERR, "%s error: wiring %s not supported, using default (Standard)!\n",
69.207 + config->name.c_str(), config->options[i].value.c_str());
69.208 + }
69.209 + else if (config->options[i].name == "AutoMode")
69.210 + {
69.211 + if (config->options[i].value == "yes")
69.212 + useAutoMode = true;
69.213 + else if (config->options[i].value == "no")
69.214 + useAutoMode = false;
69.215 + else
69.216 + syslog(LOG_ERR, "%s error: unknown auto mode setting %s, using default (%s)!\n",
69.217 + config->name.c_str(), config->options[i].value.c_str(), useAutoMode ? "yes" : "no");
69.218 + }
69.219 + else if (config->options[i].name == "StatusCheck")
69.220 + {
69.221 + if (config->options[i].value == "yes")
69.222 + useStatusCheck = true;
69.223 + else if (config->options[i].value == "no")
69.224 + useStatusCheck = false;
69.225 + else
69.226 + syslog(LOG_ERR, "%s error: unknown status check setting %s, using default (%s)!\n",
69.227 + config->name.c_str(), config->options[i].value.c_str(), useStatusCheck ? "yes" : "no");
69.228 + }
69.229 + }
69.230 +
69.231 + // setup lcd array (wanted state)
69.232 + newLCD = new unsigned char*[(width + (FS - 1)) / FS];
69.233 + if (newLCD)
69.234 + {
69.235 + for (x = 0; x < (width + (FS - 1)) / FS; x++)
69.236 + {
69.237 + newLCD[x] = new unsigned char[height];
69.238 + memset(newLCD[x], 0, height);
69.239 + }
69.240 + }
69.241 + // setup lcd array (current state)
69.242 + oldLCD = new unsigned char*[(width + (FS - 1)) / FS];
69.243 + if (oldLCD)
69.244 + {
69.245 + for (x = 0; x < (width + (FS - 1)) / FS; x++)
69.246 + {
69.247 + oldLCD[x] = new unsigned char[height];
69.248 + memset(oldLCD[x], 0, height);
69.249 + }
69.250 + }
69.251 +
69.252 + if (config->device == "")
69.253 + {
69.254 + // use DirectIO
69.255 + if (port->Open(config->port) != 0)
69.256 + return -1;
69.257 + uSleep(10);
69.258 + }
69.259 + else
69.260 + {
69.261 + // use ppdev
69.262 + if (port->Open(config->device.c_str()) != 0)
69.263 + return -1;
69.264 + }
69.265 +
69.266 + // disable chip
69.267 + // disable reading from LCD
69.268 + // disable writing to LCD
69.269 + // command/status mode
69.270 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
69.271 + port->SetDirection(kForward); // make 8-bit parallel port an output port
69.272 +
69.273 + // Test ECP mode
69.274 + if (bidirectLPT == 1)
69.275 + {
69.276 + syslog(LOG_DEBUG, "%s: Testing ECP mode...\n", config->name.c_str());
69.277 + int i = 0;
69.278 + int ecp_input;
69.279 + port->SetDirection(kReverse);
69.280 + for (int i = 0; i < 100; i++)
69.281 + {
69.282 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // wr, ce, cd, rd
69.283 + T6963CSetControl(WRHI | CELO | CDHI | RDLO);
69.284 + T6963CSetControl(WRHI | CELO | CDHI | RDLO);
69.285 + T6963CSetControl(WRHI | CELO | CDHI | RDLO);
69.286 + ecp_input = port->ReadData();
69.287 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
69.288 + if ((ecp_input & 0x03) == 0x03)
69.289 + break;
69.290 + }
69.291 + port->SetDirection(kForward);
69.292 + if (i >= 100)
69.293 + {
69.294 + syslog(LOG_DEBUG, "%s: ECP mode not working! -> is now disabled\n", config->name.c_str());
69.295 + bidirectLPT = 0;
69.296 + }
69.297 + else
69.298 + syslog(LOG_DEBUG, "%s: working!\n", config->name.c_str());
69.299 + }
69.300 +
69.301 + T6963CCommandWord(kSetGraphicHomeAddress, kGraphicBase);
69.302 + if (width % FS == 0)
69.303 + T6963CCommandWord(kSetGraphicArea, width / FS);
69.304 + else
69.305 + T6963CCommandWord(kSetGraphicArea, width / FS + 1);
69.306 +
69.307 + T6963CCommand(kSetMode | kModeOr | kModeInternalCG);
69.308 +
69.309 + T6963CDisplayMode(kDisplayModeText, false);
69.310 + T6963CDisplayMode(kDisplayModeGraphic, true);
69.311 + T6963CDisplayMode(kDisplayModeCursor, false);
69.312 + T6963CDisplayMode(kDisplayModeBlink, false);
69.313 +
69.314 + port->Release();
69.315 +
69.316 + *oldConfig = *config;
69.317 +
69.318 + // clear display
69.319 + Clear();
69.320 +
69.321 + syslog(LOG_INFO, "%s: T6963 initialized.\n", config->name.c_str());
69.322 + return 0;
69.323 +}
69.324 +
69.325 +int cDriverT6963C::DeInit()
69.326 +{
69.327 + int x;
69.328 + // free lcd array (wanted state)
69.329 + if (newLCD)
69.330 + {
69.331 + for (x = 0; x < (width + (FS - 1)) / FS; x++)
69.332 + {
69.333 + delete[] newLCD[x];
69.334 + }
69.335 + delete[] newLCD;
69.336 + }
69.337 + // free lcd array (current state)
69.338 + if (oldLCD)
69.339 + {
69.340 + for (x = 0; x < (width + (FS - 1)) / FS; x++)
69.341 + {
69.342 + delete[] oldLCD[x];
69.343 + }
69.344 + delete[] oldLCD;
69.345 + }
69.346 +
69.347 + if (port->Close() != 0)
69.348 + return -1;
69.349 + return 0;
69.350 +}
69.351 +
69.352 +int cDriverT6963C::CheckSetup()
69.353 +{
69.354 + if (config->device != oldConfig->device ||
69.355 + config->port != oldConfig->port ||
69.356 + config->width != oldConfig->width ||
69.357 + config->height != oldConfig->height)
69.358 + {
69.359 + DeInit();
69.360 + Init();
69.361 + return 0;
69.362 + }
69.363 +
69.364 + if (config->upsideDown != oldConfig->upsideDown ||
69.365 + config->invert != oldConfig->invert)
69.366 + {
69.367 + oldConfig->upsideDown = config->upsideDown;
69.368 + oldConfig->invert = config->invert;
69.369 + return 1;
69.370 + }
69.371 + return 0;
69.372 +}
69.373 +
69.374 +void cDriverT6963C::Clear()
69.375 +{
69.376 + for (int x = 0; x < (width + (FS - 1)) / FS; x++)
69.377 + memset(newLCD[x], 0, height);
69.378 +}
69.379 +
69.380 +void cDriverT6963C::Set8Pixels(int x, int y, unsigned char data)
69.381 +{
69.382 + if (x >= width || y >= height)
69.383 + return;
69.384 +
69.385 + if (FS == 6)
69.386 + {
69.387 + unsigned char data1 = 0;
69.388 + unsigned char data2 = 0;
69.389 + unsigned char data3 = 0;
69.390 +
69.391 + if (!config->upsideDown)
69.392 + {
69.393 + // normal orientation
69.394 + x = x - (x % 8);
69.395 + data1 = data >> (2 + (x % 6));
69.396 + if (x % 6 == 5)
69.397 + {
69.398 + data2 = data >> 1;
69.399 + data3 = data << 5;
69.400 + }
69.401 + else
69.402 + data2 = data << (4 - (x % 6));
69.403 +
69.404 + newLCD[x / 6][y] |= data1;
69.405 + if (x / 6 + 1 < (width + 5) / 6)
69.406 + newLCD[x / 6 + 1][y] |= data2;
69.407 + if (x / 6 + 2 < (width + 5) / 6)
69.408 + if (x % 6 == 5)
69.409 + newLCD[x / 6 + 2][y] |= data3;
69.410 + }
69.411 + else
69.412 + {
69.413 + // upside down orientation
69.414 + x = width - 1 - x;
69.415 + y = height - 1 - y;
69.416 + x = x - (x % 8);
69.417 + data = ReverseBits(data);
69.418 +
69.419 + data1 = data >> (2 + (x % 6));
69.420 + if (x % 6 == 5)
69.421 + {
69.422 + data2 = data >> 1;
69.423 + data3 = data << 5;
69.424 + }
69.425 + else
69.426 + data2 = data << (4 - (x % 6));
69.427 +
69.428 + newLCD[x / 6][y] |= data1;
69.429 + if (x / 6 + 1 < (width + 5) / 6)
69.430 + newLCD[x / 6 + 1][y] |= data2;
69.431 + if (x / 6 + 2 < (width + 5) / 6)
69.432 + if (x % 6 == 5)
69.433 + newLCD[x / 6 + 2][y] |= data3;
69.434 + }
69.435 + }
69.436 + else
69.437 + {
69.438 + if (!config->upsideDown)
69.439 + {
69.440 + newLCD[x / 8][y] |= data;
69.441 + }
69.442 + else
69.443 + {
69.444 + x = width - 1 - x;
69.445 + y = height - 1 - y;
69.446 + newLCD[x / 8][y] |= ReverseBits(data);
69.447 + }
69.448 + }
69.449 +}
69.450 +
69.451 +void cDriverT6963C::Refresh(bool refreshAll)
69.452 +{
69.453 + int x,y;
69.454 + int addr = 0;
69.455 +
69.456 + if (CheckSetup() == 1)
69.457 + refreshAll = true;
69.458 +
69.459 + if (config->refreshDisplay > 0)
69.460 + {
69.461 + refreshCounter = (refreshCounter + 1) % config->refreshDisplay;
69.462 + if (!refreshAll && !refreshCounter)
69.463 + refreshAll = true;
69.464 + }
69.465 +
69.466 + port->Claim();
69.467 + if (refreshAll)
69.468 + {
69.469 + // draw all
69.470 + T6963CCommandWord(kSetAddressPointer, kGraphicBase);
69.471 + if (useAutoMode)
69.472 + {
69.473 + T6963CCommand(kAutoWrite);
69.474 + autoWrite = true;
69.475 + }
69.476 + for (y = 0; y < height; y++)
69.477 + {
69.478 + for (x = 0; x < (width + (FS - 1)) / FS; x++)
69.479 + {
69.480 + if (autoWrite)
69.481 + T6963CData((newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
69.482 + else
69.483 + T6963CCommandByte(kDataWriteInc, (newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
69.484 + oldLCD[x][y] = newLCD[x][y];
69.485 + }
69.486 + }
69.487 + if (autoWrite)
69.488 + {
69.489 + T6963CCommand(kAutoReset);
69.490 + autoWrite = false;
69.491 + }
69.492 + // and reset RefreshCounter
69.493 + refreshCounter = 0;
69.494 + }
69.495 + else
69.496 + {
69.497 + // draw only the changed bytes
69.498 +
69.499 + bool cs = false;
69.500 + for (y = 0; y < height; y++)
69.501 + {
69.502 + for (x = 0; x < (width + (FS - 1)) / FS; x++)
69.503 + {
69.504 + if (oldLCD[x][y] != newLCD[x][y])
69.505 + {
69.506 + if (!cs)
69.507 + {
69.508 + if (width % FS == 0)
69.509 + addr = (y * (width / FS)) + x;
69.510 + else
69.511 + addr = (y * (width / FS + 1)) + x;
69.512 + T6963CCommandWord(kSetAddressPointer, kGraphicBase + addr);
69.513 + if (useAutoMode)
69.514 + {
69.515 + T6963CCommand(kAutoWrite);
69.516 + autoWrite = true;
69.517 + }
69.518 + cs = true;
69.519 + }
69.520 + if (autoWrite)
69.521 + T6963CData((newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
69.522 + else
69.523 + T6963CCommandByte(kDataWriteInc, (newLCD[x][y]) ^ (config->invert ? 0xff : 0x00));
69.524 + oldLCD[x][y] = newLCD[x][y];
69.525 + }
69.526 + else
69.527 + {
69.528 + if (autoWrite)
69.529 + {
69.530 + T6963CCommand(kAutoReset);
69.531 + autoWrite = false;
69.532 + }
69.533 + cs = false;
69.534 + }
69.535 + }
69.536 + }
69.537 + if (autoWrite)
69.538 + {
69.539 + T6963CCommand(kAutoReset);
69.540 + autoWrite = false;
69.541 + }
69.542 + }
69.543 + port->Release();
69.544 +}
69.545 +
69.546 +void cDriverT6963C::T6963CSetControl(unsigned char flags)
69.547 +{
69.548 + unsigned char status = port->ReadControl();
69.549 + status &= 0xF0; // mask 4 bits
69.550 + status |= flags; // add new flags
69.551 + port->WriteControl(status);
69.552 +}
69.553 +
69.554 +void cDriverT6963C::T6963CDSPReady()
69.555 +{
69.556 + int input = 0;
69.557 +
69.558 + port->SetDirection(kReverse);
69.559 + if (bidirectLPT == 1)
69.560 + {
69.561 + for (int i = 0; i < 10; i++)
69.562 + {
69.563 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
69.564 + T6963CSetControl(WRHI | CELO | CDHI | RDLO);
69.565 + input = port->ReadData();
69.566 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
69.567 + if (!autoWrite && (input & 3) == 3)
69.568 + break;
69.569 + if (autoWrite && (input & 8) == 8)
69.570 + break;
69.571 + }
69.572 + }
69.573 + else
69.574 + {
69.575 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
69.576 + T6963CSetControl(WRHI | CELO | CDHI | RDLO);
69.577 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI);
69.578 + }
69.579 + port->SetDirection(kForward);
69.580 +}
69.581 +
69.582 +void cDriverT6963C::T6963CData(unsigned char data)
69.583 +{
69.584 + if (serial)
69.585 + {
69.586 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
69.587 + for (int i = 128; i; i>>=1)
69.588 + {
69.589 + if (data & i)
69.590 + {
69.591 + T6963CSetControl(WRLO | CEHI | CDHI | RDLO);
69.592 + T6963CSetControl(WRHI | CEHI | CDHI | RDLO);
69.593 + }
69.594 + else
69.595 + {
69.596 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
69.597 + T6963CSetControl(WRHI | CEHI | CDLO | RDLO);
69.598 + }
69.599 + }
69.600 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO); // CD down (data)
69.601 + T6963CSetControl(WRLO | CELO | CDLO | RDLO); // CE down
69.602 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO); // CE up
69.603 + }
69.604 + else
69.605 + {
69.606 + if (useStatusCheck)
69.607 + T6963CDSPReady();
69.608 + T6963CSetControl(WRHI | CEHI | CDLO | RDHI); // CD down (data)
69.609 + T6963CSetControl(WRLO | CELO | CDLO | RDHI); // CE & WR down
69.610 + port->WriteData(data);
69.611 + T6963CSetControl(WRHI | CEHI | CDLO | RDHI); // CE & WR up again
69.612 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // CD up again
69.613 + }
69.614 +}
69.615 +
69.616 +void cDriverT6963C::T6963CCommand(unsigned char cmd)
69.617 +{
69.618 + if (serial)
69.619 + {
69.620 + syslog(LOG_DEBUG, "Serial cmd out: ");
69.621 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
69.622 + for (int i = 128; i; i>>=1)
69.623 + {
69.624 + if (cmd & i)
69.625 + {
69.626 + T6963CSetControl(WRLO | CEHI | CDHI | RDLO);
69.627 + T6963CSetControl(WRHI | CEHI | CDHI | RDLO);
69.628 + }
69.629 + else
69.630 + {
69.631 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO);
69.632 + T6963CSetControl(WRHI | CEHI | CDLO | RDLO);
69.633 + }
69.634 + }
69.635 + T6963CSetControl(WRLO | CEHI | CDHI | RDLO); // CD up (command)
69.636 + T6963CSetControl(WRLO | CELO | CDHI | RDLO); // CE down
69.637 + T6963CSetControl(WRLO | CEHI | CDHI | RDLO); // CE up
69.638 + T6963CSetControl(WRLO | CEHI | CDLO | RDLO); // CD down
69.639 + }
69.640 + else
69.641 + {
69.642 + if (useStatusCheck)
69.643 + T6963CDSPReady();
69.644 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // CD up (command)
69.645 + T6963CSetControl(WRLO | CELO | CDHI | RDHI); // CE & WR down
69.646 + port->WriteData(cmd);
69.647 + T6963CSetControl(WRHI | CEHI | CDHI | RDHI); // CE & WR up again
69.648 + T6963CSetControl(WRHI | CEHI | CDLO | RDHI); // CD down again
69.649 + }
69.650 +}
69.651 +
69.652 +void cDriverT6963C::T6963CCommandByte(unsigned char cmd, unsigned char data)
69.653 +{
69.654 + T6963CData(data);
69.655 + T6963CCommand(cmd);
69.656 +}
69.657 +
69.658 +void cDriverT6963C::T6963CCommand2Bytes(unsigned char cmd, unsigned char data1, unsigned char data2)
69.659 +{
69.660 + T6963CData(data1);
69.661 + T6963CData(data2);
69.662 + T6963CCommand(cmd);
69.663 +}
69.664 +
69.665 +void cDriverT6963C::T6963CCommandWord(unsigned char cmd, unsigned short data)
69.666 +{
69.667 + T6963CData(data % 256);
69.668 + T6963CData(data >> 8);
69.669 + T6963CCommand(cmd);
69.670 +}
69.671 +
69.672 +void cDriverT6963C::T6963CDisplayMode(unsigned char mode, bool enable)
69.673 +{
69.674 + if (enable)
69.675 + displayMode |= mode;
69.676 + else
69.677 + displayMode &= ~mode;
69.678 + T6963CCommand(kSetDisplayMode | displayMode);
69.679 +}
69.680 +
69.681 +}
70.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
70.2 +++ b/graphlcd-base/glcddrivers/t6963c.h Thu Feb 07 13:03:18 2008 +0100
70.3 @@ -0,0 +1,76 @@
70.4 +/*
70.5 + * GraphLCD driver library
70.6 + *
70.7 + * t6963c.h - T6963C driver class
70.8 + *
70.9 + * low level routines based on lcdproc 0.5 driver, (c) 2001 Manuel Stahl
70.10 + *
70.11 + * This file is released under the GNU General Public License. Refer
70.12 + * to the COPYING file distributed with this package.
70.13 + *
70.14 + * (c) 2003, 2004 Andreas Regel <andreas.regel AT powarman.de>
70.15 + */
70.16 +
70.17 +#ifndef _GLCDDRIVERS_T6963C_H_
70.18 +#define _GLCDDRIVERS_T6963C_H_
70.19 +
70.20 +#include "driver.h"
70.21 +
70.22 +namespace GLCD
70.23 +{
70.24 +
70.25 +class cDriverConfig;
70.26 +class cParallelPort;
70.27 +
70.28 +class cDriverT6963C : public cDriver
70.29 +{
70.30 +private:
70.31 + cParallelPort * port;
70.32 + unsigned char ** newLCD; // wanted state
70.33 + unsigned char ** oldLCD; // current state
70.34 + cDriverConfig * config;
70.35 + cDriverConfig * oldConfig;
70.36 + int refreshCounter;
70.37 + int bidirectLPT;
70.38 + int displayMode;
70.39 + bool useAutoMode;
70.40 + bool useStatusCheck;
70.41 +
70.42 + int serial;
70.43 + int FS;
70.44 + int WRHI;
70.45 + int WRLO;
70.46 + int RDHI;
70.47 + int RDLO;
70.48 + int CEHI;
70.49 + int CELO;
70.50 + int CDHI;
70.51 + int CDLO;
70.52 + bool autoWrite;
70.53 +
70.54 + void T6963CSetControl(unsigned char flags);
70.55 + void T6963CDSPReady();
70.56 + void T6963CData(unsigned char data);
70.57 + void T6963CCommand(unsigned char cmd);
70.58 + void T6963CCommandByte(unsigned char cmd, unsigned char data);
70.59 + void T6963CCommand2Bytes(unsigned char cmd, unsigned char data1, unsigned char data2);
70.60 + void T6963CCommandWord(unsigned char cmd, unsigned short data);
70.61 + void T6963CDisplayMode(unsigned char mode, bool enable);
70.62 +
70.63 + int CheckSetup();
70.64 +
70.65 +public:
70.66 + cDriverT6963C(cDriverConfig * config);
70.67 + virtual ~cDriverT6963C();
70.68 +
70.69 + virtual int Init();
70.70 + virtual int DeInit();
70.71 +
70.72 + virtual void Clear();
70.73 + virtual void Set8Pixels(int x, int y, unsigned char data);
70.74 + virtual void Refresh(bool refreshAll = false);
70.75 +};
70.76 +
70.77 +} // end of namespace
70.78 +
70.79 +#endif
71.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
71.2 +++ b/graphlcd-base/glcdgraphics/Makefile Thu Feb 07 13:03:18 2008 +0100
71.3 @@ -0,0 +1,68 @@
71.4 +#
71.5 +# Makefile for the GraphLCD graphics library
71.6 +#
71.7 +
71.8 +-include ../Make.config
71.9 +
71.10 +CXXFLAGS += -fPIC
71.11 +
71.12 +VERMAJOR = 2
71.13 +VERMINOR = 0
71.14 +VERMICRO = 0
71.15 +
71.16 +BASENAME = libglcdgraphics.so
71.17 +
71.18 +LIBNAME = $(BASENAME).$(VERMAJOR).$(VERMINOR).$(VERMICRO)
71.19 +
71.20 +OBJS = bitmap.o common.o font.o glcd.o image.o imagefile.o pbm.o
71.21 +
71.22 +HEADERS = bitmap.h font.h glcd.h image.h imagefile.h pbm.h
71.23 +
71.24 +### Implicit rules:
71.25 +
71.26 +%.o: %.c
71.27 + $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
71.28 +
71.29 +# Dependencies:
71.30 +
71.31 +MAKEDEP = g++ -MM -MG
71.32 +DEPFILE = .dependencies
71.33 +$(DEPFILE): Makefile
71.34 + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
71.35 +
71.36 +-include $(DEPFILE)
71.37 +
71.38 +ifdef HAVE_FREETYPE2
71.39 + ifneq ($(shell which freetype-config),)
71.40 + INCLUDES += $(shell freetype-config --cflags)
71.41 + LIBS += $(shell freetype-config --libs)
71.42 + else
71.43 + INCLUDES += -I/usr/include/freetype -I/usr/local/include/freetype
71.44 + LIBS += -lfreetype
71.45 + endif
71.46 + DEFINES += -DHAVE_FREETYPE2
71.47 +endif### Targets:
71.48 +
71.49 +all: $(LIBNAME)
71.50 +
71.51 +$(LIBNAME): $(OBJS)
71.52 + $(CXX) $(CXXFLAGS) -shared $(OBJS) $(LIBS) -Wl,-soname="$(BASENAME).$(VERMAJOR)" -o $@
71.53 + ln -sf $(LIBNAME) $(BASENAME)
71.54 +
71.55 +install: all
71.56 + install -d $(LIBDIR)
71.57 + install -m 755 $(LIBNAME) $(LIBDIR)/
71.58 + install -d $(INCDIR)/glcdgraphics
71.59 + install -m 644 $(HEADERS) $(INCDIR)/glcdgraphics/
71.60 + ( cd $(LIBDIR); ln -sf $(LIBNAME) $(BASENAME).$(VERMAJOR); ln -sf $(LIBNAME) $(BASENAME) )
71.61 +
71.62 +uninstall:
71.63 + rm -f $(LIBDIR)/$(BASENAME)
71.64 + rm -f $(LIBDIR)/$(BASENAME).$(VERMAJOR)
71.65 + rm -f $(LIBDIR)/$(LIBNAME)
71.66 + (for i in $(HEADERS); do rm -f $(INCDIR)/glcdgraphics/$$i; done)
71.67 + rmdir $(INCDIR)/glcdgraphics
71.68 +
71.69 +clean:
71.70 + rm -f $(OBJS) $(DEPFILE) $(LIBNAME) $(BASENAME) *~
71.71 +
72.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
72.2 +++ b/graphlcd-base/glcdgraphics/bitmap.c Thu Feb 07 13:03:18 2008 +0100
72.3 @@ -0,0 +1,807 @@
72.4 +/*
72.5 + * GraphLCD graphics library
72.6 + *
72.7 + * bitmap.c - cBitmap class
72.8 + *
72.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
72.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
72.11 + *
72.12 + * This file is released under the GNU General Public License. Refer
72.13 + * to the COPYING file distributed with this package.
72.14 + *
72.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
72.16 + */
72.17 +
72.18 +#include <stdio.h>
72.19 +#include <stdlib.h>
72.20 +#include <string.h>
72.21 +#include <math.h>
72.22 +
72.23 +#include "bitmap.h"
72.24 +#include "common.h"
72.25 +#include "font.h"
72.26 +
72.27 +
72.28 +namespace GLCD
72.29 +{
72.30 +
72.31 +const unsigned char bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
72.32 +const unsigned char bitmaskl[8] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
72.33 +const unsigned char bitmaskr[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
72.34 +
72.35 +cBitmap::cBitmap(int width, int height, unsigned char * data)
72.36 +: width(width),
72.37 + height(height),
72.38 + bitmap(NULL)
72.39 +{
72.40 + // lines are byte aligned
72.41 + lineSize = (width + 7) / 8;
72.42 +
72.43 + bitmap = new unsigned char[lineSize * height];
72.44 + if (data)
72.45 + memcpy(bitmap, data, lineSize * height);
72.46 +}
72.47 +
72.48 +cBitmap::cBitmap(const cBitmap & b)
72.49 +{
72.50 + width = b.width;
72.51 + height = b.height;
72.52 + lineSize = b.lineSize;
72.53 + bitmap = new unsigned char[lineSize * height];
72.54 + if (b.bitmap)
72.55 + memcpy(bitmap, b.bitmap, lineSize * height);
72.56 +}
72.57 +
72.58 +cBitmap::~cBitmap()
72.59 +{
72.60 + delete[] bitmap;
72.61 +}
72.62 +
72.63 +void cBitmap::Clear()
72.64 +{
72.65 + memset(bitmap, 0, lineSize * height);
72.66 +}
72.67 +
72.68 +void cBitmap::Invert()
72.69 +{
72.70 + int i;
72.71 +
72.72 + for (i = 0; i < lineSize * height; i++)
72.73 + {
72.74 + bitmap[i] ^= 0xFF;
72.75 + }
72.76 +}
72.77 +
72.78 +void cBitmap::DrawPixel(int x, int y, eColor color)
72.79 +{
72.80 + if (x < 0 || x > width - 1)
72.81 + return;
72.82 + if (y < 0 || y > height - 1)
72.83 + return;
72.84 +
72.85 + unsigned char c = 0x80 >> (x % 8);
72.86 + if (color == clrBlack)
72.87 + bitmap[lineSize * y + x / 8] |= c;
72.88 + else
72.89 + bitmap[lineSize * y + x / 8] &= ~c;
72.90 +}
72.91 +
72.92 +void cBitmap::Draw8Pixels(int x, int y, unsigned char pixels, eColor color)
72.93 +{
72.94 + if (x < 0 || x > width - 1)
72.95 + return;
72.96 + if (y < 0 || y > height - 1)
72.97 + return;
72.98 +
72.99 + if (color == clrBlack)
72.100 + bitmap[lineSize * y + x / 8] |= pixels;
72.101 + else
72.102 + bitmap[lineSize * y + x / 8] &= ~pixels;
72.103 +}
72.104 +
72.105 +void cBitmap::DrawLine(int x1, int y1, int x2, int y2, eColor color)
72.106 +{
72.107 + int d, sx, sy, dx, dy;
72.108 + unsigned int ax, ay;
72.109 +
72.110 + dx = x2 - x1;
72.111 + ax = abs(dx) << 1;
72.112 + if (dx < 0)
72.113 + sx = -1;
72.114 + else
72.115 + sx = 1;
72.116 +
72.117 + dy = y2 - y1;
72.118 + ay = abs(dy) << 1;
72.119 + if (dy < 0)
72.120 + sy = -1;
72.121 + else
72.122 + sy = 1;
72.123 +
72.124 + DrawPixel(x1, y1, color);
72.125 + if (ax > ay)
72.126 + {
72.127 + d = ay - (ax >> 1);
72.128 + while (x1 != x2)
72.129 + {
72.130 + if (d >= 0)
72.131 + {
72.132 + y1 += sy;
72.133 + d -= ax;
72.134 + }
72.135 + x1 += sx;
72.136 + d += ay;
72.137 + DrawPixel(x1, y1, color);
72.138 + }
72.139 + }
72.140 + else
72.141 + {
72.142 + d = ax - (ay >> 1);
72.143 + while (y1 != y2)
72.144 + {
72.145 + if (d >= 0)
72.146 + {
72.147 + x1 += sx;
72.148 + d -= ay;
72.149 + }
72.150 + y1 += sy;
72.151 + d += ax;
72.152 + DrawPixel(x1, y1, color);
72.153 + }
72.154 + }
72.155 +}
72.156 +
72.157 +void cBitmap::DrawHLine(int x1, int y, int x2, eColor color)
72.158 +{
72.159 + sort(x1,x2);
72.160 +
72.161 + if (x1 / 8 == x2 / 8)
72.162 + {
72.163 + // start and end in the same byte
72.164 + Draw8Pixels(x1, y, bitmaskr[x1 % 8] & bitmaskl[x2 % 8], color);
72.165 + }
72.166 + else
72.167 + {
72.168 + // start and end in different bytes
72.169 + Draw8Pixels(x1, y, bitmaskr[x1 % 8], color);
72.170 + x1 = ((x1 + 8) / 8) * 8;
72.171 + while (x1 < (x2 / 8) * 8)
72.172 + {
72.173 + Draw8Pixels(x1, y, 0xff, color);
72.174 + x1 += 8;
72.175 + }
72.176 + Draw8Pixels(x2, y, bitmaskl[x2 % 8], color);
72.177 + }
72.178 +}
72.179 +
72.180 +void cBitmap::DrawVLine(int x, int y1, int y2, eColor color)
72.181 +{
72.182 + int y;
72.183 +
72.184 + sort(y1,y2);
72.185 +
72.186 + for (y = y1; y <= y2; y++)
72.187 + DrawPixel(x, y, color);
72.188 +}
72.189 +
72.190 +void cBitmap::DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled)
72.191 +{
72.192 + int y;
72.193 +
72.194 + sort(x1,x2);
72.195 + sort(y1,y2);
72.196 +
72.197 + if (!filled)
72.198 + {
72.199 + DrawHLine(x1, y1, x2, color);
72.200 + DrawVLine(x1, y1, y2, color);
72.201 + DrawHLine(x1, y2, x2, color);
72.202 + DrawVLine(x2, y1, y2, color);
72.203 + }
72.204 + else
72.205 + {
72.206 + for (y = y1; y <= y2; y++)
72.207 + {
72.208 + DrawHLine(x1, y, x2, color);
72.209 + }
72.210 + }
72.211 +}
72.212 +
72.213 +void cBitmap::DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int type)
72.214 +{
72.215 + sort(x1,x2);
72.216 + sort(y1,y2);
72.217 +
72.218 + if (type > (x2 - x1) / 2)
72.219 + type = (x2 - x1) / 2;
72.220 + if (type > (y2 - y1) / 2)
72.221 + type = (y2 - y1) / 2;
72.222 +
72.223 + if (filled)
72.224 + {
72.225 + DrawHLine(x1 + type, y1, x2 - type, color);
72.226 + for (int y = y1 + 1; y < y1 + type; y++)
72.227 + DrawHLine(x1 + 1, y, x2 - 1, color);
72.228 + for (int y = y1 + type; y <= y2 - type; y++)
72.229 + DrawHLine(x1, y, x2, color);
72.230 + for (int y = y2 - type + 1; y < y2; y++)
72.231 + DrawHLine(x1 + 1, y, x2 - 1, color);
72.232 + DrawHLine(x1 + type, y2, x2 - type, color);
72.233 + if (type == 4)
72.234 + {
72.235 + // round the ugly fat box...
72.236 + DrawPixel(x1 + 1, y1 + 1, color == clrWhite ? clrBlack : clrWhite);
72.237 + DrawPixel(x1 + 1, y2 - 1, color == clrWhite ? clrBlack : clrWhite);
72.238 + DrawPixel(x2 - 1, y1 + 1, color == clrWhite ? clrBlack : clrWhite);
72.239 + DrawPixel(x2 - 1, y2 - 1, color == clrWhite ? clrBlack : clrWhite);
72.240 + }
72.241 + }
72.242 + else
72.243 + {
72.244 + DrawHLine(x1 + type, y1, x2 - type, color);
72.245 + DrawVLine(x1, y1 + type, y2 - type, color);
72.246 + DrawVLine(x2, y1 + type, y2 - type, color);
72.247 + DrawHLine(x1 + type, y2, x2 - type, color);
72.248 + if (type > 1)
72.249 + {
72.250 + DrawHLine(x1 + 1, y1 + 1, x1 + type - 1, color);
72.251 + DrawHLine(x2 - type + 1, y1 + 1, x2 - 1, color);
72.252 + DrawHLine(x1 + 1, y2 - 1, x1 + type - 1, color);
72.253 + DrawHLine(x2 - type + 1, y2 - 1, x2 - 1, color);
72.254 + DrawVLine(x1 + 1, y1 + 1, y1 + type - 1, color);
72.255 + DrawVLine(x1 + 1, y2 - 1, y2 - type + 1, color);
72.256 + DrawVLine(x2 - 1, y1 + 1, y1 + type - 1, color);
72.257 + DrawVLine(x2 - 1, y2 - 1, y2 - type + 1, color);
72.258 + }
72.259 + }
72.260 +}
72.261 +
72.262 +void cBitmap::DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants)
72.263 +{
72.264 + // Algorithm based on http://homepage.smc.edu/kennedy_john/BELIPSE.PDF
72.265 + int rx = x2 - x1;
72.266 + int ry = y2 - y1;
72.267 + int cx = (x1 + x2) / 2;
72.268 + int cy = (y1 + y2) / 2;
72.269 + switch (abs(quadrants))
72.270 + {
72.271 + case 0: rx /= 2; ry /= 2; break;
72.272 + case 1: cx = x1; cy = y2; break;
72.273 + case 2: cx = x2; cy = y2; break;
72.274 + case 3: cx = x2; cy = y1; break;
72.275 + case 4: cx = x1; cy = y1; break;
72.276 + case 5: cx = x1; ry /= 2; break;
72.277 + case 6: cy = y2; rx /= 2; break;
72.278 + case 7: cx = x2; ry /= 2; break;
72.279 + case 8: cy = y1; rx /= 2; break;
72.280 + }
72.281 + int TwoASquare = 2 * rx * rx;
72.282 + int TwoBSquare = 2 * ry * ry;
72.283 + int x = rx;
72.284 + int y = 0;
72.285 + int XChange = ry * ry * (1 - 2 * rx);
72.286 + int YChange = rx * rx;
72.287 + int EllipseError = 0;
72.288 + int StoppingX = TwoBSquare * rx;
72.289 + int StoppingY = 0;
72.290 + while (StoppingX >= StoppingY)
72.291 + {
72.292 + if (filled)
72.293 + {
72.294 + switch (quadrants)
72.295 + {
72.296 + case 5: DrawRectangle(cx, cy + y, cx + x, cy + y, color, filled); // no break
72.297 + case 1: DrawRectangle(cx, cy - y, cx + x, cy - y, color, filled); break;
72.298 + case 7: DrawRectangle(cx - x, cy + y, cx, cy + y, color, filled); // no break
72.299 + case 2: DrawRectangle(cx - x, cy - y, cx, cy - y, color, filled); break;
72.300 + case 3: DrawRectangle(cx - x, cy + y, cx, cy + y, color, filled); break;
72.301 + case 4: DrawRectangle(cx, cy + y, cx + x, cy + y, color, filled); break;
72.302 + case 0:
72.303 + case 6: DrawRectangle(cx - x, cy - y, cx + x, cy - y, color, filled); if (quadrants == 6) break;
72.304 + case 8: DrawRectangle(cx - x, cy + y, cx + x, cy + y, color, filled); break;
72.305 + case -1: DrawRectangle(cx + x, cy - y, x2, cy - y, color, filled); break;
72.306 + case -2: DrawRectangle(x1, cy - y, cx - x, cy - y, color, filled); break;
72.307 + case -3: DrawRectangle(x1, cy + y, cx - x, cy + y, color, filled); break;
72.308 + case -4: DrawRectangle(cx + x, cy + y, x2, cy + y, color, filled); break;
72.309 + }
72.310 + }
72.311 + else
72.312 + {
72.313 + switch (quadrants)
72.314 + {
72.315 + case 5: DrawPixel(cx + x, cy + y, color); // no break
72.316 + case -1:
72.317 + case 1: DrawPixel(cx + x, cy - y, color); break;
72.318 + case 7: DrawPixel(cx - x, cy + y, color); // no break
72.319 + case -2:
72.320 + case 2: DrawPixel(cx - x, cy - y, color); break;
72.321 + case -3:
72.322 + case 3: DrawPixel(cx - x, cy + y, color); break;
72.323 + case -4:
72.324 + case 4: DrawPixel(cx + x, cy + y, color); break;
72.325 + case 0:
72.326 + case 6: DrawPixel(cx - x, cy - y, color); DrawPixel(cx + x, cy - y, color); if (quadrants == 6) break;
72.327 + case 8: DrawPixel(cx - x, cy + y, color); DrawPixel(cx + x, cy + y, color); break;
72.328 + }
72.329 + }
72.330 + y++;
72.331 + StoppingY += TwoASquare;
72.332 + EllipseError += YChange;
72.333 + YChange += TwoASquare;
72.334 + if (2 * EllipseError + XChange > 0)
72.335 + {
72.336 + x--;
72.337 + StoppingX -= TwoBSquare;
72.338 + EllipseError += XChange;
72.339 + XChange += TwoBSquare;
72.340 + }
72.341 + }
72.342 + x = 0;
72.343 + y = ry;
72.344 + XChange = ry * ry;
72.345 + YChange = rx * rx * (1 - 2 * ry);
72.346 + EllipseError = 0;
72.347 + StoppingX = 0;
72.348 + StoppingY = TwoASquare * ry;
72.349 + while (StoppingX <= StoppingY)
72.350 + {
72.351 + if (filled)
72.352 + {
72.353 + switch (quadrants)
72.354 + {
72.355 + case 5: DrawRectangle(cx, cy + y, cx + x, cy + y, color, filled); // no break
72.356 + case 1: DrawRectangle(cx, cy - y, cx + x, cy - y, color, filled); break;
72.357 + case 7: DrawRectangle(cx - x, cy + y, cx, cy + y, color, filled); // no break
72.358 + case 2: DrawRectangle(cx - x, cy - y, cx, cy - y, color, filled); break;
72.359 + case 3: DrawRectangle(cx - x, cy + y, cx, cy + y, color, filled); break;
72.360 + case 4: DrawRectangle(cx, cy + y, cx + x, cy + y, color, filled); break;
72.361 + case 0:
72.362 + case 6: DrawRectangle(cx - x, cy - y, cx + x, cy - y, color, filled); if (quadrants == 6) break;
72.363 + case 8: DrawRectangle(cx - x, cy + y, cx + x, cy + y, color, filled); break;
72.364 + case -1: DrawRectangle(cx + x, cy - y, x2, cy - y, color, filled); break;
72.365 + case -2: DrawRectangle(x1, cy - y, cx - x, cy - y, color, filled); break;
72.366 + case -3: DrawRectangle(x1, cy + y, cx - x, cy + y, color, filled); break;
72.367 + case -4: DrawRectangle(cx + x, cy + y, x2, cy + y, color, filled); break;
72.368 + }
72.369 + }
72.370 + else
72.371 + {
72.372 + switch (quadrants)
72.373 + {
72.374 + case 5: DrawPixel(cx + x, cy + y, color); // no break
72.375 + case -1:
72.376 + case 1: DrawPixel(cx + x, cy - y, color); break;
72.377 + case 7: DrawPixel(cx - x, cy + y, color); // no break
72.378 + case -2:
72.379 + case 2: DrawPixel(cx - x, cy - y, color); break;
72.380 + case -3:
72.381 + case 3: DrawPixel(cx - x, cy + y, color); break;
72.382 + case -4:
72.383 + case 4: DrawPixel(cx + x, cy + y, color); break;
72.384 + case 0:
72.385 + case 6: DrawPixel(cx - x, cy - y, color); DrawPixel(cx + x, cy - y, color); if (quadrants == 6) break;
72.386 + case 8: DrawPixel(cx - x, cy + y, color); DrawPixel(cx + x, cy + y, color); break;
72.387 + }
72.388 + }
72.389 + x++;
72.390 + StoppingX += TwoBSquare;
72.391 + EllipseError += XChange;
72.392 + XChange += TwoBSquare;
72.393 + if (2 * EllipseError + YChange > 0)
72.394 + {
72.395 + y--;
72.396 + StoppingY -= TwoASquare;
72.397 + EllipseError += YChange;
72.398 + YChange += TwoASquare;
72.399 + }
72.400 + }
72.401 +}
72.402 +
72.403 +void cBitmap::DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type)
72.404 +{
72.405 + bool upper = type & 0x01;
72.406 + bool falling = type & 0x02;
72.407 + bool vertical = type & 0x04;
72.408 + if (vertical)
72.409 + {
72.410 + for (int y = y1; y <= y2; y++)
72.411 + {
72.412 + double c = cos((y - y1) * M_PI / (y2 - y1 + 1));
72.413 + if (falling)
72.414 + c = -c;
72.415 + int x = int((x2 - x1 + 1) * c / 2);
72.416 + if (upper && !falling || !upper && falling)
72.417 + DrawRectangle(x1, y, (x1 + x2) / 2 + x, y, color, true);
72.418 + else
72.419 + DrawRectangle((x1 + x2) / 2 + x, y, x2, y, color, true);
72.420 + }
72.421 + }
72.422 + else
72.423 + {
72.424 + for (int x = x1; x <= x2; x++)
72.425 + {
72.426 + double c = cos((x - x1) * M_PI / (x2 - x1 + 1));
72.427 + if (falling)
72.428 + c = -c;
72.429 + int y = int((y2 - y1 + 1) * c / 2);
72.430 + if (upper)
72.431 + DrawRectangle(x, y1, x, (y1 + y2) / 2 + y, color, true);
72.432 + else
72.433 + DrawRectangle(x, (y1 + y2) / 2 + y, x, y2, color, true);
72.434 + }
72.435 + }
72.436 +}
72.437 +
72.438 +void cBitmap::DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color)
72.439 +{
72.440 + unsigned char cl = 0;
72.441 + int xt, yt;
72.442 + const unsigned char * data = bitmap.Data();
72.443 + unsigned short temp;
72.444 + int h, w;
72.445 +
72.446 + w = bitmap.Width();
72.447 + h = bitmap.Height();
72.448 +
72.449 + if (data)
72.450 + {
72.451 + if (!(x % 8))
72.452 + {
72.453 + // Bitmap is byte alligned (0,8,16,...)
72.454 + for (yt = 0; yt < h; yt++)
72.455 + {
72.456 + for (xt = 0; xt < (w / 8); xt++)
72.457 + {
72.458 + cl = *data;
72.459 + Draw8Pixels(x + (xt * 8), y + yt, cl, color);
72.460 + data++;
72.461 + }
72.462 + if (w % 8)
72.463 + {
72.464 + cl = *data;
72.465 + Draw8Pixels(x + ((w / 8) * 8), y + yt, cl & bitmaskl[w % 8 - 1], color);
72.466 + data++;
72.467 + }
72.468 + }
72.469 + }
72.470 + else
72.471 + {
72.472 + // Bitmap is not byte alligned
72.473 + for (yt = 0; yt < h; yt++)
72.474 + {
72.475 + temp = 0;
72.476 + for (xt = 0; xt < (w + (x % 8)) / 8; xt++)
72.477 + {
72.478 + cl = *(data + yt * ((w + 7) / 8) + xt);
72.479 + temp = temp | ((unsigned short) cl << (8 - (x % 8)));
72.480 + cl = (temp & 0xff00) >> 8;
72.481 + if (!xt)
72.482 + {
72.483 + // first byte
72.484 + Draw8Pixels(x - (x % 8) + (xt * 8), y + yt, cl & bitmaskr[x % 8], color);
72.485 + }
72.486 + else
72.487 + {
72.488 + // not the first byte
72.489 + Draw8Pixels(x - (x % 8) + (xt * 8), y + yt, cl, color);
72.490 + }
72.491 + temp <<= 8;
72.492 + }
72.493 + if ((w + (x % 8) + 7) / 8 != (w + (x % 8)) / 8)
72.494 + {
72.495 + // print the rest
72.496 + cl = *(data + (yt + 1) * ((w + 7) / 8) - 1);
72.497 + temp = temp | ((unsigned short) cl << (8 - (x % 8)));
72.498 + cl = (temp & 0xff00) >> 8;
72.499 + Draw8Pixels(x - (x % 8) + (((w + (x % 8)) / 8) * 8), y + yt, cl & bitmaskl[(w + x) % 8 - 1], color);
72.500 + }
72.501 + }
72.502 + }
72.503 + }
72.504 +}
72.505 +
72.506 +int cBitmap::DrawText(int x, int y, int xmax, const std::string & text, const cFont * font,
72.507 + eColor color, bool proportional, int skipPixels)
72.508 +{
72.509 + int xt;
72.510 + int yt;
72.511 + int i;
72.512 + char c;
72.513 + int start;
72.514 +
72.515 + clip(x, 0, width - 1);
72.516 + clip(y, 0, height - 1);
72.517 +
72.518 + xt = x;
72.519 + yt = y;
72.520 + start = 0;
72.521 +
72.522 + if (text.length() > 0)
72.523 + {
72.524 + if (skipPixels > 0)
72.525 + {
72.526 + if (!proportional)
72.527 + {
72.528 + if (skipPixels >= (int) text.length() * font->TotalWidth())
72.529 + start = text.length();
72.530 + else
72.531 + while (skipPixels > font->TotalWidth())
72.532 + {
72.533 + skipPixels -= font->TotalWidth();
72.534 + start++;
72.535 + }
72.536 + }
72.537 + else
72.538 + {
72.539 + if (skipPixels >= font->Width(text))
72.540 + start = text.length();
72.541 + else
72.542 + while (skipPixels > font->Width(text[start]))
72.543 + {
72.544 + skipPixels -= font->Width(text[start]);
72.545 + skipPixels -= font->SpaceBetween();
72.546 + start++;
72.547 + }
72.548 + }
72.549 + }
72.550 + for (i = start; i < (int) text.length(); i++)
72.551 + {
72.552 + c = text[i];
72.553 + if (xt > xmax)
72.554 + {
72.555 + i = text.length();
72.556 + }
72.557 + else
72.558 + {
72.559 + if (!proportional)
72.560 + {
72.561 + if (skipPixels > 0)
72.562 + {
72.563 + DrawCharacter(xt, yt, xmax, c, font, color, skipPixels);
72.564 + xt += font->TotalWidth() - skipPixels;
72.565 + skipPixels = 0;
72.566 + }
72.567 + else
72.568 + {
72.569 + DrawCharacter(xt, yt, xmax, c, font, color);
72.570 + xt += font->TotalWidth();
72.571 + }
72.572 + }
72.573 + else
72.574 + {
72.575 + if (skipPixels > 0)
72.576 + {
72.577 + xt += DrawCharacter(xt, yt, xmax, c, font, color, skipPixels);
72.578 + skipPixels = 0;
72.579 + }
72.580 + else
72.581 + {
72.582 + xt += DrawCharacter(xt, yt, xmax, c, font, color);
72.583 + }
72.584 + if (xt <= xmax)
72.585 + {
72.586 + xt += font->SpaceBetween();
72.587 + }
72.588 + }
72.589 + }
72.590 + }
72.591 + }
72.592 + return xt;
72.593 +}
72.594 +
72.595 +int cBitmap::DrawCharacter(int x, int y, int xmax, char c, const cFont * font,
72.596 + eColor color, int skipPixels)
72.597 +{
72.598 + const cBitmap * charBitmap;
72.599 +
72.600 + clip(x, 0, width - 1);
72.601 + clip(y, 0, height - 1);
72.602 +
72.603 + charBitmap = font->GetCharacter(c);
72.604 + if (charBitmap)
72.605 + {
72.606 + cBitmap * drawBitmap = charBitmap->SubBitmap(skipPixels, 0, xmax - x + skipPixels, charBitmap->Height() - 1);
72.607 + if (drawBitmap)
72.608 + DrawBitmap(x, y, *drawBitmap, color);
72.609 + delete drawBitmap;
72.610 + return charBitmap->Width() - skipPixels;
72.611 + }
72.612 + return 0;
72.613 +}
72.614 +
72.615 +unsigned char cBitmap::GetPixel(int x, int y) const
72.616 +{
72.617 + unsigned char value;
72.618 +
72.619 + value = bitmap[y * lineSize + x / 8];
72.620 + value = (value >> (7 - (x % 8))) & 1;
72.621 + return value;
72.622 +}
72.623 +
72.624 +cBitmap * cBitmap::SubBitmap(int x1, int y1, int x2, int y2) const
72.625 +{
72.626 + int w, h;
72.627 + int xt, yt;
72.628 + cBitmap * bmp;
72.629 + unsigned char cl;
72.630 + unsigned char * data;
72.631 + unsigned short temp;
72.632 +
72.633 + sort(x1,x2);
72.634 + sort(y1,y2);
72.635 + if (x1 < 0 || x1 > width - 1)
72.636 + return NULL;
72.637 + if (y1 < 0 || y1 > height - 1)
72.638 + return NULL;
72.639 + clip(x2, 0, width - 1);
72.640 + clip(y2, 0, height - 1);
72.641 +
72.642 + w = x2 - x1 + 1;
72.643 + h = y2 - y1 + 1;
72.644 + bmp = new cBitmap(w, h);
72.645 + if (!bmp || !bmp->Data())
72.646 + return NULL;
72.647 + bmp->Clear();
72.648 + if (x1 % 8 == 0)
72.649 + {
72.650 + // Bitmap is byte alligned (0,8,16,...)
72.651 + for (yt = 0; yt < h; yt++)
72.652 + {
72.653 + data = &bitmap[(y1 + yt) * lineSize + x1 / 8];
72.654 + for (xt = 0; xt < (w / 8) * 8; xt += 8)
72.655 + {
72.656 + cl = *data;
72.657 + bmp->Draw8Pixels(xt, yt, cl, clrBlack);
72.658 + data++;
72.659 + }
72.660 + if (w % 8 != 0)
72.661 + {
72.662 + cl = *data;
72.663 + bmp->Draw8Pixels(xt, yt, cl & bitmaskl[w % 8 - 1], clrBlack);
72.664 + }
72.665 + }
72.666 + }
72.667 + else
72.668 + {
72.669 + // Bitmap is not byte alligned
72.670 + for (yt = 0; yt < h; yt++)
72.671 + {
72.672 + temp = 0;
72.673 + data = &bitmap[(y1 + yt) * lineSize + x1 / 8];
72.674 + for (xt = 0; xt <= ((w / 8)) * 8; xt += 8)
72.675 + {
72.676 + cl = *data;
72.677 + temp = temp | ((unsigned short) cl << (x1 % 8));
72.678 + cl = (temp & 0xff00) >> 8;
72.679 + if (xt > 0)
72.680 + {
72.681 + bmp->Draw8Pixels(xt - 8, yt, cl, clrBlack);
72.682 + }
72.683 + temp <<= 8;
72.684 + data++;
72.685 + }
72.686 + if (w % 8 != 0)
72.687 + {
72.688 + // print the rest
72.689 + if (8 - (x1 % 8) < w % 8)
72.690 + {
72.691 + cl = *data;
72.692 + temp = temp | ((unsigned short) cl << (x1 % 8));
72.693 + }
72.694 + cl = (temp & 0xff00) >> 8;
72.695 + bmp->Draw8Pixels(xt - 8, yt, cl & bitmaskl[(w % 8) - 1], clrBlack);
72.696 + }
72.697 + }
72.698 + }
72.699 + return bmp;
72.700 +}
72.701 +
72.702 +bool cBitmap::LoadPBM(const std::string & fileName)
72.703 +{
72.704 + FILE * pbmFile;
72.705 + char str[32];
72.706 + int i;
72.707 + int ch;
72.708 + int w;
72.709 + int h;
72.710 +
72.711 + pbmFile = fopen(fileName.c_str(), "rb");
72.712 + if (!pbmFile)
72.713 + return false;
72.714 +
72.715 + i = 0;
72.716 + while ((ch = getc(pbmFile)) != EOF && i < 31)
72.717 + {
72.718 + if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
72.719 + break;
72.720 + str[i] = ch;
72.721 + i++;
72.722 + }
72.723 + if (ch == EOF)
72.724 + {
72.725 + fclose(pbmFile);
72.726 + return false;
72.727 + }
72.728 + str[i] = 0;
72.729 + if (strcmp(str, "P4") != 0)
72.730 + return false;
72.731 +
72.732 + while ((ch = getc(pbmFile)) == '#')
72.733 + {
72.734 + while ((ch = getc(pbmFile)) != EOF)
72.735 + {
72.736 + if (ch == '\n' || ch == '\r')
72.737 + break;
72.738 + }
72.739 + }
72.740 + if (ch == EOF)
72.741 + {
72.742 + fclose(pbmFile);
72.743 + return false;
72.744 + }
72.745 + i = 0;
72.746 + str[i] = ch;
72.747 + i += 1;
72.748 + while ((ch = getc(pbmFile)) != EOF && i < 31)
72.749 + {
72.750 + if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
72.751 + break;
72.752 + str[i] = ch;
72.753 + i++;
72.754 + }
72.755 + if (ch == EOF)
72.756 + {
72.757 + fclose(pbmFile);
72.758 + return false;
72.759 + }
72.760 + str[i] = 0;
72.761 + w = atoi(str);
72.762 +
72.763 + i = 0;
72.764 + while ((ch = getc(pbmFile)) != EOF && i < 31)
72.765 + {
72.766 + if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
72.767 + break;
72.768 + str[i] = ch;
72.769 + i++;
72.770 + }
72.771 + if (ch == EOF)
72.772 + {
72.773 + fclose(pbmFile);
72.774 + return false;
72.775 + }
72.776 + str[i] = 0;
72.777 + h = atoi(str);
72.778 +
72.779 + delete[] bitmap;
72.780 + width = w;
72.781 + height = h;
72.782 + // lines are byte aligned
72.783 + lineSize = (width + 7) / 8;
72.784 + bitmap = new unsigned char[lineSize * height];
72.785 + fread(bitmap, lineSize * height, 1, pbmFile);
72.786 + fclose(pbmFile);
72.787 +
72.788 + return true;
72.789 +}
72.790 +
72.791 +void cBitmap::SavePBM(const std::string & fileName)
72.792 +{
72.793 + int i;
72.794 + char str[32];
72.795 + FILE * fp;
72.796 +
72.797 + fp = fopen(fileName.c_str(), "wb");
72.798 + if (fp)
72.799 + {
72.800 + sprintf(str, "P4\n%d %d\n", width, height);
72.801 + fwrite(str, strlen(str), 1, fp);
72.802 + for (i = 0; i < lineSize * height; i++)
72.803 + {
72.804 + fwrite(&bitmap[i], 1, 1, fp);
72.805 + }
72.806 + fclose(fp);
72.807 + }
72.808 +}
72.809 +
72.810 +} // end of namespace
73.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
73.2 +++ b/graphlcd-base/glcdgraphics/bitmap.h Thu Feb 07 13:03:18 2008 +0100
73.3 @@ -0,0 +1,75 @@
73.4 +/*
73.5 + * GraphLCD graphics library
73.6 + *
73.7 + * bitmap.h - cBitmap class
73.8 + *
73.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
73.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
73.11 + *
73.12 + * This file is released under the GNU General Public License. Refer
73.13 + * to the COPYING file distributed with this package.
73.14 + *
73.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
73.16 + */
73.17 +
73.18 +#ifndef _GLCDGRAPHICS_BITMAP_H_
73.19 +#define _GLCDGRAPHICS_BITMAP_H_
73.20 +
73.21 +#include <string>
73.22 +
73.23 +namespace GLCD
73.24 +{
73.25 +
73.26 +enum eColor
73.27 +{
73.28 + clrBlack,
73.29 + clrWhite
73.30 +};
73.31 +
73.32 +class cFont;
73.33 +
73.34 +class cBitmap
73.35 +{
73.36 +protected:
73.37 + int width;
73.38 + int height;
73.39 + int lineSize;
73.40 + unsigned char * bitmap;
73.41 +
73.42 +public:
73.43 + cBitmap(int width, int height, unsigned char * data = NULL);
73.44 + cBitmap(const cBitmap & b);
73.45 + ~cBitmap();
73.46 +
73.47 + int Width() const { return width; }
73.48 + int Height() const { return height; }
73.49 + int LineSize() const { return lineSize; }
73.50 + const unsigned char * Data() const { return bitmap; }
73.51 +
73.52 + void Clear();
73.53 + void Invert();
73.54 + void DrawPixel(int x, int y, eColor color);
73.55 + void Draw8Pixels(int x, int y, unsigned char pixels, eColor color);
73.56 + void DrawLine(int x1, int y1, int x2, int y2, eColor color);
73.57 + void DrawHLine(int x1, int y, int x2, eColor color);
73.58 + void DrawVLine(int x, int y1, int y2, eColor color);
73.59 + void DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled);
73.60 + void DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int size);
73.61 + void DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants);
73.62 + void DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type);
73.63 + void DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color);
73.64 + int DrawText(int x, int y, int xmax, const std::string & text, const cFont * font,
73.65 + eColor color = clrBlack, bool proportional = true, int skipPixels = 0);
73.66 + int DrawCharacter(int x, int y, int xmax, char c, const cFont * font,
73.67 + eColor color = clrBlack, int skipPixels = 0);
73.68 +
73.69 + cBitmap * SubBitmap(int x1, int y1, int x2, int y2) const;
73.70 + unsigned char GetPixel(int x, int y) const;
73.71 +
73.72 + bool LoadPBM(const std::string & fileName);
73.73 + void SavePBM(const std::string & fileName);
73.74 +};
73.75 +
73.76 +} // end of namespace
73.77 +
73.78 +#endif
74.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
74.2 +++ b/graphlcd-base/glcdgraphics/common.c Thu Feb 07 13:03:18 2008 +0100
74.3 @@ -0,0 +1,60 @@
74.4 +/*
74.5 + * GraphLCD graphics library
74.6 + *
74.7 + * common.c - various functions
74.8 + *
74.9 + * This file is released under the GNU General Public License. Refer
74.10 + * to the COPYING file distributed with this package.
74.11 + *
74.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
74.13 + */
74.14 +
74.15 +#include <ctype.h>
74.16 +
74.17 +#include "common.h"
74.18 +
74.19 +
74.20 +namespace GLCD
74.21 +{
74.22 +
74.23 +void clip(int & value, int min, int max)
74.24 +{
74.25 + if (value < min)
74.26 + value = min;
74.27 + if (value > max)
74.28 + value = max;
74.29 +}
74.30 +
74.31 +void sort(int & value1, int & value2)
74.32 +{
74.33 + if (value2 < value1)
74.34 + {
74.35 + int tmp;
74.36 + tmp = value2;
74.37 + value2 = value1;
74.38 + value1 = tmp;
74.39 + }
74.40 +}
74.41 +
74.42 +std::string trim(const std::string & s)
74.43 +{
74.44 + std::string::size_type start, end;
74.45 +
74.46 + start = 0;
74.47 + while (start < s.length())
74.48 + {
74.49 + if (!isspace(s[start]))
74.50 + break;
74.51 + start++;
74.52 + }
74.53 + end = s.length() - 1;
74.54 + while (end >= 0)
74.55 + {
74.56 + if (!isspace(s[end]))
74.57 + break;
74.58 + end--;
74.59 + }
74.60 + return s.substr(start, end - start + 1);
74.61 +}
74.62 +
74.63 +} // end of namespace
75.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
75.2 +++ b/graphlcd-base/glcdgraphics/common.h Thu Feb 07 13:03:18 2008 +0100
75.3 @@ -0,0 +1,26 @@
75.4 +/*
75.5 + * GraphLCD graphics library
75.6 + *
75.7 + * common.h - various functions
75.8 + *
75.9 + * This file is released under the GNU General Public License. Refer
75.10 + * to the COPYING file distributed with this package.
75.11 + *
75.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
75.13 + */
75.14 +
75.15 +#ifndef _GLCDGRAPHICS_COMMON_H_
75.16 +#define _GLCDGRAPHICS_COMMON_H_
75.17 +
75.18 +#include <string>
75.19 +
75.20 +namespace GLCD
75.21 +{
75.22 +
75.23 +void clip(int & value, int min, int max);
75.24 +void sort(int & value1, int & value2);
75.25 +std::string trim(const std::string & s);
75.26 +
75.27 +} // end of namespace
75.28 +
75.29 +#endif
76.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
76.2 +++ b/graphlcd-base/glcdgraphics/font.c Thu Feb 07 13:03:18 2008 +0100
76.3 @@ -0,0 +1,581 @@
76.4 +/*
76.5 + * GraphLCD graphics library
76.6 + *
76.7 + * font.c - font handling
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 +#include <fcntl.h>
76.22 +#include <unistd.h>
76.23 +
76.24 +#include <algorithm>
76.25 +
76.26 +#include "common.h"
76.27 +#include "font.h"
76.28 +
76.29 +#ifdef HAVE_FREETYPE2
76.30 +#include <ft2build.h>
76.31 +#include FT_FREETYPE_H
76.32 +#include <iconv.h>
76.33 +#endif
76.34 +
76.35 +namespace GLCD
76.36 +{
76.37 +
76.38 +static const char * kFontFileSign = "FNT3";
76.39 +static const uint32_t kFontHeaderSize = 16;
76.40 +static const uint32_t kCharHeaderSize = 4;
76.41 +
76.42 +//#pragma pack(1)
76.43 +//struct tFontHeader
76.44 +//{
76.45 +// char sign[4]; // = FONTFILE_SIGN
76.46 +// unsigned short height; // total height of the font
76.47 +// unsigned short ascent; // ascender of the font
76.48 +// unsigned short line; // line height
76.49 +// unsigned short reserved;
76.50 +// unsigned short space; // space between characters of a string
76.51 +// unsigned short count; // number of chars in this file
76.52 +//};
76.53 +//
76.54 +//struct tCharHeader
76.55 +//{
76.56 +// unsigned short character;
76.57 +// unsigned short width;
76.58 +//};
76.59 +//#pragma pack()
76.60 +
76.61 +cFont::cFont()
76.62 +{
76.63 + Init();
76.64 +}
76.65 +
76.66 +cFont::~cFont()
76.67 +{
76.68 + Unload();
76.69 +}
76.70 +
76.71 +bool cFont::LoadFNT(const std::string & fileName)
76.72 +{
76.73 + // cleanup if we already had a loaded font
76.74 + Unload();
76.75 +
76.76 + FILE * fontFile;
76.77 + int i;
76.78 + uint8_t buffer[10000];
76.79 + uint16_t fontHeight;
76.80 + uint16_t numChars;
76.81 + int maxWidth = 0;
76.82 +
76.83 + fontFile = fopen(fileName.c_str(), "rb");
76.84 + if (!fontFile)
76.85 + return false;
76.86 +
76.87 + fread(buffer, kFontHeaderSize, 1, fontFile);
76.88 + if (buffer[0] != kFontFileSign[0] ||
76.89 + buffer[1] != kFontFileSign[1] ||
76.90 + buffer[2] != kFontFileSign[2] ||
76.91 + buffer[3] != kFontFileSign[3])
76.92 + {
76.93 + fclose(fontFile);
76.94 + return false;
76.95 + }
76.96 +
76.97 + fontHeight = buffer[4] | (buffer[5] << 8);
76.98 + totalAscent = buffer[6] | (buffer[7] << 8);
76.99 + lineHeight = buffer[8] | (buffer[9] << 8);
76.100 + spaceBetween = buffer[12] | (buffer[13] << 8);
76.101 + numChars = buffer[14] | (buffer[15] << 8);
76.102 + for (i = 0; i < numChars; i++)
76.103 + {
76.104 + uint8_t chdr[kCharHeaderSize];
76.105 + uint16_t charWidth;
76.106 + uint16_t character;
76.107 + fread(chdr, kCharHeaderSize, 1, fontFile);
76.108 + character = chdr[0] | (chdr[1] << 8);
76.109 + charWidth = chdr[2] | (chdr[3] << 8);
76.110 + fread(buffer, fontHeight * ((charWidth + 7) / 8), 1, fontFile);
76.111 + if (characters[character])
76.112 + delete characters[character];
76.113 + characters[character] = new cBitmap(charWidth, fontHeight, buffer);
76.114 + if (characters[character]->Width() > maxWidth)
76.115 + maxWidth = characters[character]->Width();
76.116 + }
76.117 + fclose(fontFile);
76.118 +
76.119 + totalWidth = maxWidth;
76.120 + totalHeight = fontHeight;
76.121 +
76.122 + return true;
76.123 +}
76.124 +
76.125 +bool cFont::SaveFNT(const std::string & fileName) const
76.126 +{
76.127 + FILE * fontFile;
76.128 + uint8_t fhdr[kFontHeaderSize];
76.129 + uint8_t chdr[kCharHeaderSize];
76.130 + uint16_t numChars;
76.131 + int i;
76.132 +
76.133 + fontFile = fopen(fileName.c_str(),"w+b");
76.134 + if (!fontFile)
76.135 + {
76.136 + syslog(LOG_ERR, "cFont::SaveFNT(): Cannot open file: %s for writing\n",fileName.c_str());
76.137 + return false;
76.138 + }
76.139 +
76.140 + numChars = 0;
76.141 + for (i = 0; i < 256; i++)
76.142 + {
76.143 + if (characters[i])
76.144 + {
76.145 + numChars++;
76.146 + }
76.147 + }
76.148 +
76.149 + memcpy(fhdr, kFontFileSign, 4);
76.150 + fhdr[4] = (uint8_t) totalHeight;
76.151 + fhdr[5] = (uint8_t) (totalHeight >> 8);
76.152 + fhdr[6] = (uint8_t) totalAscent;
76.153 + fhdr[7] = (uint8_t) (totalAscent >> 8);
76.154 + fhdr[8] = (uint8_t) lineHeight;
76.155 + fhdr[9] = (uint8_t) (lineHeight >> 8);
76.156 + fhdr[10] = 0;
76.157 + fhdr[11] = 0;
76.158 + fhdr[12] = (uint8_t) spaceBetween;
76.159 + fhdr[13] = (uint8_t) (spaceBetween >> 8);
76.160 + fhdr[14] = (uint8_t) numChars;
76.161 + fhdr[15] = (uint8_t) (numChars >> 8);
76.162 +
76.163 + // write font file header
76.164 + fwrite(fhdr, kFontHeaderSize, 1, fontFile);
76.165 +
76.166 + for (i = 0; i < 256; i++)
76.167 + {
76.168 + if (characters[i])
76.169 + {
76.170 + chdr[0] = (uint8_t) i;
76.171 + chdr[1] = (uint8_t) (i >> 8);
76.172 + chdr[2] = (uint8_t) characters[i]->Width();
76.173 + chdr[3] = (uint8_t) (characters[i]->Width() >> 8);
76.174 + fwrite(chdr, kCharHeaderSize, 1, fontFile);
76.175 + fwrite(characters[i]->Data(), totalHeight * characters[i]->LineSize(), 1, fontFile);
76.176 + }
76.177 + }
76.178 +
76.179 + fclose(fontFile);
76.180 +
76.181 + syslog(LOG_DEBUG, "cFont::SaveFNT(): Font file '%s' written successfully\n", fileName.c_str());
76.182 +
76.183 + return true;
76.184 +}
76.185 +
76.186 +bool cFont::LoadFT2(const std::string & fileName, const std::string & encoding,
76.187 + int size, bool dingBats)
76.188 +{
76.189 + // cleanup if we already had a loaded font
76.190 + Unload();
76.191 +#ifdef HAVE_FREETYPE2
76.192 + if (access(fileName.c_str(), F_OK) != 0)
76.193 + {
76.194 + syslog(LOG_ERR, "cFont::LoadFT2: Font file (%s) does not exist!!", fileName.c_str());
76.195 + return false;
76.196 + }
76.197 + // file exists
76.198 + FT_Library library;
76.199 + FT_Face face;
76.200 + FT_GlyphSlot slot;
76.201 +
76.202 + int error = FT_Init_FreeType(&library);
76.203 + if (error)
76.204 + {
76.205 + syslog(LOG_ERR, "cFont::LoadFT2: Could not init freetype library");
76.206 + return false;
76.207 + }
76.208 + error = FT_New_Face(library, fileName.c_str(), 0, &face);
76.209 + // everything ok?
76.210 + if (error == FT_Err_Unknown_File_Format)
76.211 + {
76.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());
76.213 + error = FT_Done_Face(face);
76.214 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
76.215 + error = FT_Done_FreeType(library);
76.216 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
76.217 + return false;
76.218 + }
76.219 + else if (error)
76.220 + {
76.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);
76.222 + error = FT_Done_Face(face);
76.223 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
76.224 + error = FT_Done_FreeType(library);
76.225 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
76.226 + return false;
76.227 + }
76.228 +
76.229 + // set slot
76.230 + slot = face->glyph;
76.231 +
76.232 + // set Size
76.233 + FT_Set_Char_Size(face, 0, size * 64, 0, 0);
76.234 +
76.235 + wchar_t utf_buff[256];
76.236 + if (dingBats)
76.237 + {
76.238 +/*
76.239 + FT_CharMap charmap = 0;
76.240 + for (int n = 0; n < face->num_charmaps; n++)
76.241 + {
76.242 + if (face->charmaps[n]->platform_id == 3 &&
76.243 + face->charmaps[n]->encoding_id == 0)
76.244 + {
76.245 + charmap = face->charmaps[n];
76.246 + //break;
76.247 + }
76.248 + }
76.249 + if (charmap)
76.250 + syslog(LOG_ERR, "cFont::LoadFT2: platform_id: %d, encoding_id: %d", charmap->platform_id, charmap->encoding_id);
76.251 + error = FT_Set_Charmap(_face, charmap);
76.252 + if (error)
76.253 + {
76.254 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Select_Charmap encoding not supported: %d", charmap->encoding_id);
76.255 + }
76.256 +*/
76.257 + }
76.258 + else
76.259 + {
76.260 + iconv_t cd;
76.261 + if ((cd = iconv_open("WCHAR_T", encoding.c_str())) == (iconv_t) -1)
76.262 + {
76.263 + syslog(LOG_ERR, "cFont::LoadFT2: Iconv encoding not supported: %s", encoding.c_str());
76.264 + error = FT_Done_Face(face);
76.265 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
76.266 + error = FT_Done_FreeType(library);
76.267 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
76.268 + return false;
76.269 + }
76.270 + for (int c = 0; c < 256; c++)
76.271 + {
76.272 + char char_buff = c;
76.273 + wchar_t wchar_buff;
76.274 + char * in_buff,* out_buff;
76.275 + size_t in_len, out_len, count;
76.276 +
76.277 + in_len = 1;
76.278 + out_len = 4;
76.279 + in_buff = (char *) &char_buff;
76.280 + out_buff = (char *) &wchar_buff;
76.281 + count = iconv(cd, &in_buff, &in_len, &out_buff, &out_len);
76.282 + if ((size_t) -1 == count)
76.283 + {
76.284 + utf_buff[c] = 0;
76.285 + }
76.286 + utf_buff[c] = wchar_buff;
76.287 + }
76.288 + iconv_close(cd);
76.289 + }
76.290 +
76.291 + // get some global parameters
76.292 + totalHeight = (face->size->metrics.ascender >> 6) - (face->size->metrics.descender >> 6);
76.293 + totalWidth = face->size->metrics.max_advance >> 6;
76.294 + totalAscent = face->size->metrics.ascender >> 6;
76.295 + lineHeight = face->size->metrics.height >> 6;
76.296 + spaceBetween = 0;
76.297 +#if 0
76.298 + syslog(LOG_DEBUG, "cFont::LoadFT2: totalHeight = %d", totalHeight);
76.299 + syslog(LOG_DEBUG, "cFont::LoadFT2: totalWidth = %d", totalWidth);
76.300 + syslog(LOG_DEBUG, "cFont::LoadFT2: totalAscent = %d", totalAscent);
76.301 + syslog(LOG_DEBUG, "cFont::LoadFT2: lineHeight = %d", lineHeight);
76.302 + syslog(LOG_DEBUG, "cFont::LoadFT2: spaceBetween = %d", spaceBetween);
76.303 +#endif
76.304 + // render glyphs for ASCII codes 0 to 255 in our bitmap class
76.305 + FT_UInt glyph_index;
76.306 + int num_char;
76.307 +
76.308 + for (num_char = 0; num_char < 256; num_char++)
76.309 + {
76.310 + if (dingBats)
76.311 + {
76.312 + //Get FT char index & load the char
76.313 + error = FT_Load_Char(face, num_char, FT_LOAD_DEFAULT);
76.314 + }
76.315 + else
76.316 + {
76.317 + //Get FT char index
76.318 + glyph_index = FT_Get_Char_Index(face, utf_buff[num_char]);
76.319 + //Load the char
76.320 + error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
76.321 + }
76.322 + if (error)
76.323 + {
76.324 + syslog(LOG_ERR, "cFont::LoadFT2: ERROR when calling FT_Load_Glyph: %x", error);
76.325 + }
76.326 +
76.327 + // convert to a mono bitmap
76.328 + error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO);
76.329 + if (error)
76.330 + {
76.331 + syslog(LOG_ERR, "cFont::LoadFT2: ERROR when calling FT_Render_Glyph: %x", error);
76.332 + }
76.333 +
76.334 + // now, fill our pixel data
76.335 + cBitmap * charBitmap = new cBitmap(face->glyph->advance.x >> 6, totalHeight);
76.336 + charBitmap->Clear();
76.337 + unsigned char * bufPtr = face->glyph->bitmap.buffer;
76.338 + unsigned char pixel;
76.339 + for (int y = 0; y < face->glyph->bitmap.rows; y++)
76.340 + {
76.341 + for (int x = 0; x < face->glyph->bitmap.width; x++)
76.342 + {
76.343 + pixel = (bufPtr[x / 8] >> (7 - x % 8)) & 1;
76.344 + if (pixel)
76.345 + charBitmap->DrawPixel((face->glyph->metrics.horiBearingX >> 6) + x,
76.346 + (face->size->metrics.ascender >> 6) - (face->glyph->metrics.horiBearingY >> 6) + y,
76.347 + GLCD::clrBlack);
76.348 + }
76.349 + bufPtr += face->glyph->bitmap.pitch;
76.350 + }
76.351 + SetCharacter((char) num_char, charBitmap);
76.352 + }
76.353 + error = FT_Done_Face(face);
76.354 + if (error)
76.355 + {
76.356 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_Face(..) returned (%d)", error);
76.357 + }
76.358 + error = FT_Done_FreeType(library);
76.359 + if (error)
76.360 + {
76.361 + syslog(LOG_ERR, "cFont::LoadFT2: FT_Done_FreeType(..) returned (%d)", error);
76.362 + }
76.363 + return true;
76.364 +#else
76.365 + syslog(LOG_ERR, "cFont::LoadFT2: glcdgraphics was compiled without FreeType2 support!!!");
76.366 + return false;
76.367 +#endif
76.368 +}
76.369 +
76.370 +int cFont::Width(char ch) const
76.371 +{
76.372 + if (characters[(unsigned char) ch])
76.373 + return characters[(unsigned char) ch]->Width();
76.374 + else
76.375 + return 0;
76.376 +}
76.377 +
76.378 +int cFont::Width(const std::string & str) const
76.379 +{
76.380 + unsigned int i;
76.381 + int sum = 0;
76.382 +
76.383 + for (i = 0; i < str.length(); i++)
76.384 + {
76.385 + sum += Width(str[i]);
76.386 + }
76.387 + if (str.length() > 1)
76.388 + {
76.389 + sum += spaceBetween * (str.length() - 1);
76.390 + }
76.391 + return sum;
76.392 +}
76.393 +
76.394 +int cFont::Width(const std::string & str, unsigned int len) const
76.395 +{
76.396 + unsigned int i;
76.397 + int sum = 0;
76.398 +
76.399 + for (i = 0; i < str.length() && i < len; i++)
76.400 + {
76.401 + sum += Width(str[i]);
76.402 + }
76.403 + if (std::min(str.length(), (size_t) len) > 1)
76.404 + {
76.405 + sum += spaceBetween * (std::min(str.length(), (size_t) len) - 1);
76.406 + }
76.407 + return sum;
76.408 +}
76.409 +
76.410 +int cFont::Height(char ch) const
76.411 +{
76.412 + if (characters[(unsigned char) ch])
76.413 + return characters[(unsigned char) ch]->Height();
76.414 + else
76.415 + return 0;
76.416 +}
76.417 +
76.418 +int cFont::Height(const std::string & str) const
76.419 +{
76.420 + unsigned int i;
76.421 + int sum = 0;
76.422 +
76.423 + for (i = 0; i < str.length(); i++)
76.424 + sum = std::max(sum, Height(str[i]));
76.425 + return sum;
76.426 +}
76.427 +
76.428 +int cFont::Height(const std::string & str, unsigned int len) const
76.429 +{
76.430 + unsigned int i;
76.431 + int sum = 0;
76.432 +
76.433 + for (i = 0; i < str.length() && i < len; i++)
76.434 + sum = std::max(sum, Height(str[i]));
76.435 + return sum;
76.436 +}
76.437 +
76.438 +const cBitmap * cFont::GetCharacter(char ch) const
76.439 +{
76.440 + return characters[(unsigned char) ch];
76.441 +}
76.442 +
76.443 +void cFont::SetCharacter(char ch, cBitmap * bitmapChar)
76.444 +{
76.445 + // adjust maxwidth if necessary
76.446 + if (totalWidth < bitmapChar->Width())
76.447 + totalWidth = bitmapChar->Width();
76.448 +
76.449 + // delete if already allocated
76.450 + if (characters[(unsigned char) ch])
76.451 + delete characters[(unsigned char) ch];
76.452 +
76.453 + // store new character
76.454 + characters[(unsigned char) ch] = bitmapChar;
76.455 +}
76.456 +
76.457 +void cFont::Init()
76.458 +{
76.459 + totalWidth = 0;
76.460 + totalHeight = 0;
76.461 + totalAscent = 0;
76.462 + spaceBetween = 0;
76.463 + lineHeight = 0;
76.464 + for (int i = 0; i < 256; i++)
76.465 + {
76.466 + characters[i] = NULL;
76.467 + }
76.468 +}
76.469 +
76.470 +void cFont::Unload()
76.471 +{
76.472 + // cleanup
76.473 + for (int i = 0; i < 256; i++)
76.474 + {
76.475 + if (characters[i])
76.476 + {
76.477 + delete characters[i];
76.478 + }
76.479 + }
76.480 + // re-init
76.481 + Init();
76.482 +}
76.483 +
76.484 +void cFont::WrapText(int Width, int Height, std::string & Text,
76.485 + std::vector <std::string> & Lines, int * ActualWidth) const
76.486 +{
76.487 + int maxLines;
76.488 + int lineCount;
76.489 + int textWidth;
76.490 + std::string::size_type start;
76.491 + std::string::size_type pos;
76.492 + std::string::size_type posLast;
76.493 +
76.494 + Lines.clear();
76.495 + maxLines = 2000;
76.496 + if (Height > 0)
76.497 + {
76.498 + maxLines = Height / LineHeight();
76.499 + if (maxLines == 0)
76.500 + maxLines = 1;
76.501 + }
76.502 + lineCount = 0;
76.503 +
76.504 + pos = 0;
76.505 + start = 0;
76.506 + posLast = 0;
76.507 + textWidth = 0;
76.508 + while (pos < Text.length() && (Height == 0 || lineCount < maxLines))
76.509 + {
76.510 + if (Text[pos] == '\n')
76.511 + {
76.512 + Lines.push_back(trim(Text.substr(start, pos - start)));
76.513 + start = pos + 1;
76.514 + posLast = pos + 1;
76.515 + textWidth = 0;
76.516 + lineCount++;
76.517 + }
76.518 + else if (textWidth > Width && (lineCount + 1) < maxLines)
76.519 + {
76.520 + if (posLast > start)
76.521 + {
76.522 + Lines.push_back(trim(Text.substr(start, posLast - start)));
76.523 + start = posLast + 1;
76.524 + posLast = start;
76.525 + textWidth = this->Width(Text.substr(start, pos - start + 1)) + spaceBetween;
76.526 + }
76.527 + else
76.528 + {
76.529 + Lines.push_back(trim(Text.substr(start, pos - start)));
76.530 + start = pos + 1;
76.531 + posLast = start;
76.532 + textWidth = this->Width(Text[pos]) + spaceBetween;
76.533 + }
76.534 + lineCount++;
76.535 + }
76.536 + else if (Text[pos] == ' ')
76.537 + {
76.538 + posLast = pos;
76.539 + textWidth += this->Width(Text[pos]) + spaceBetween;
76.540 + }
76.541 + else
76.542 + {
76.543 + textWidth += this->Width(Text[pos]) + spaceBetween;
76.544 + }
76.545 + pos++;
76.546 + }
76.547 +
76.548 + if (Height == 0 || lineCount < maxLines)
76.549 + {
76.550 + if (textWidth > Width && (lineCount + 1) < maxLines)
76.551 + {
76.552 + if (posLast > start)
76.553 + {
76.554 + Lines.push_back(trim(Text.substr(start, posLast - start)));
76.555 + start = posLast + 1;
76.556 + posLast = start;
76.557 + textWidth = this->Width(Text.substr(start, pos - start + 1)) + spaceBetween;
76.558 + }
76.559 + else
76.560 + {
76.561 + Lines.push_back(trim(Text.substr(start, pos - start)));
76.562 + start = pos + 1;
76.563 + posLast = start;
76.564 + textWidth = this->Width(Text[pos]) + spaceBetween;
76.565 + }
76.566 + lineCount++;
76.567 + }
76.568 + if (pos > start)
76.569 + {
76.570 + Lines.push_back(trim(Text.substr(start)));
76.571 + lineCount++;
76.572 + }
76.573 + textWidth = 0;
76.574 + for (int i = 0; i < lineCount; i++)
76.575 + textWidth = std::max(textWidth, this->Width(Lines[i]));
76.576 + textWidth = std::min(textWidth, Width);
76.577 + }
76.578 + else
76.579 + textWidth = Width;
76.580 + if (ActualWidth)
76.581 + *ActualWidth = textWidth;
76.582 +}
76.583 +
76.584 +} // end of namespace
77.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
77.2 +++ b/graphlcd-base/glcdgraphics/font.h Thu Feb 07 13:03:18 2008 +0100
77.3 @@ -0,0 +1,75 @@
77.4 +/*
77.5 + * GraphLCD graphics library
77.6 + *
77.7 + * font.h - font handling
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_FONT_H_
77.19 +#define _GLCDGRAPHICS_FONT_H_
77.20 +
77.21 +#include <string>
77.22 +#include <vector>
77.23 +
77.24 +#include "bitmap.h"
77.25 +
77.26 +namespace GLCD
77.27 +{
77.28 +
77.29 +class cFont
77.30 +{
77.31 +private:
77.32 + int totalWidth;
77.33 + int totalHeight;
77.34 + int totalAscent;
77.35 + int spaceBetween;
77.36 + int lineHeight;
77.37 +
77.38 + cBitmap * characters[256];
77.39 +protected:
77.40 + void Init();
77.41 + void Unload();
77.42 +public:
77.43 + cFont();
77.44 + ~cFont();
77.45 +
77.46 + bool LoadFNT(const std::string & fileName);
77.47 + bool SaveFNT(const std::string & fileName) const;
77.48 + bool LoadFT2(const std::string & fileName, const std::string & encoding,
77.49 + int size, bool dingBats = false);
77.50 + int TotalWidth() const { return totalWidth; };
77.51 + int TotalHeight() const { return totalHeight; };
77.52 + int TotalAscent() const { return totalAscent; };
77.53 + int SpaceBetween() const { return spaceBetween; };
77.54 + int LineHeight() const { return lineHeight; };
77.55 +
77.56 + void SetTotalWidth(int width) { totalWidth = width; };
77.57 + void SetTotalHeight(int height) { totalHeight = height; };
77.58 + void SetTotalAscent(int ascent) { totalAscent = ascent; };
77.59 + void SetSpaceBetween(int width) { spaceBetween = width; };
77.60 + void SetLineHeight(int height) { lineHeight = height; };
77.61 +
77.62 + int Width(char ch) const;
77.63 + int Width(const std::string & str) const;
77.64 + int Width(const std::string & str, unsigned int len) const;
77.65 + int Height(char ch) const;
77.66 + int Height(const std::string & str) const;
77.67 + int Height(const std::string & str, unsigned int len) const;
77.68 +
77.69 + const cBitmap * GetCharacter(char ch) const;
77.70 + void SetCharacter(char ch, cBitmap * bitmapChar);
77.71 +
77.72 + void WrapText(int Width, int Height, std::string & Text,
77.73 + std::vector <std::string> & Lines, int * TextWidth = NULL) const;
77.74 +};
77.75 +
77.76 +} // end of namespace
77.77 +
77.78 +#endif
78.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
78.2 +++ b/graphlcd-base/glcdgraphics/glcd.c Thu Feb 07 13:03:18 2008 +0100
78.3 @@ -0,0 +1,277 @@
78.4 +/*
78.5 + * GraphLCD graphics library
78.6 + *
78.7 + * glcd.c - GLCD file loading and saving
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 <stdio.h>
78.19 +#include <stdint.h>
78.20 +#include <syslog.h>
78.21 +
78.22 +#include <string>
78.23 +
78.24 +#include "bitmap.h"
78.25 +#include "glcd.h"
78.26 +#include "image.h"
78.27 +
78.28 +
78.29 +namespace GLCD
78.30 +{
78.31 +
78.32 +using namespace std;
78.33 +
78.34 +const char * kGLCDFileSign = "GLC";
78.35 +
78.36 +/*
78.37 +#pragma pack(1)
78.38 +struct tGLCDHeader
78.39 +{
78.40 + char sign[3]; // = "GLC"
78.41 + char format; // D - single image, A - animation
78.42 + uint16_t width; // width in pixels
78.43 + uint16_t height; // height in pixels
78.44 + // only for animations
78.45 + uint16_t count; // number of pictures
78.46 + uint32_t delay; // delay in ms
78.47 +};
78.48 +#pragma pack()
78.49 +*/
78.50 +
78.51 +cGLCDFile::cGLCDFile()
78.52 +{
78.53 +}
78.54 +
78.55 +cGLCDFile::~cGLCDFile()
78.56 +{
78.57 +}
78.58 +
78.59 +bool cGLCDFile::Load(cImage & image, const string & fileName)
78.60 +{
78.61 + FILE * fp;
78.62 + long fileSize;
78.63 + char sign[4];
78.64 + uint8_t buf[6];
78.65 + uint16_t width;
78.66 + uint16_t height;
78.67 + uint16_t count;
78.68 + uint32_t delay;
78.69 +
78.70 + fp = fopen(fileName.c_str(), "rb");
78.71 + if (!fp)
78.72 + {
78.73 + syslog(LOG_ERR, "glcdgraphics: open %s failed (cGLCDFile::Load).", fileName.c_str());
78.74 + return false;
78.75 + }
78.76 +
78.77 + // get len of file
78.78 + if (fseek(fp, 0, SEEK_END) != 0)
78.79 + {
78.80 + fclose(fp);
78.81 + return false;
78.82 + }
78.83 + fileSize = ftell(fp);
78.84 +
78.85 + // rewind and get Header
78.86 + if (fseek(fp, 0, SEEK_SET) != 0)
78.87 + {
78.88 + fclose(fp);
78.89 + return false;
78.90 + }
78.91 +
78.92 + // read header sign
78.93 + if (fread(sign, 4, 1, fp) != 1)
78.94 + {
78.95 + fclose(fp);
78.96 + return false;
78.97 + }
78.98 +
78.99 + // check header sign
78.100 + if (strncmp(sign, kGLCDFileSign, 3) != 0)
78.101 + {
78.102 + syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
78.103 + fclose(fp);
78.104 + return false;
78.105 + }
78.106 +
78.107 + // read width and height
78.108 + if (fread(buf, 4, 1, fp) != 1)
78.109 + {
78.110 + fclose(fp);
78.111 + return false;
78.112 + }
78.113 +
78.114 + width = (buf[1] << 8) | buf[0];
78.115 + height = (buf[3] << 8) | buf[2];
78.116 + if (width == 0 || height == 0)
78.117 + {
78.118 + syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
78.119 + fclose(fp);
78.120 + return false;
78.121 + }
78.122 +
78.123 + if (sign[3] == 'D')
78.124 + {
78.125 + count = 1;
78.126 + delay = 10;
78.127 + // check file length
78.128 + if (fileSize != (long) (height * ((width + 7) / 8) + 8))
78.129 + {
78.130 + syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong size (cGLCDFile::Load).", fileName.c_str());
78.131 + fclose(fp);
78.132 + return false;
78.133 + }
78.134 + }
78.135 + else if (sign[3] == 'A')
78.136 + {
78.137 + // read count and delay
78.138 + if (fread(buf, 6, 1, fp) != 1)
78.139 + {
78.140 + syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
78.141 + fclose(fp);
78.142 + return false;
78.143 + }
78.144 + count = (buf[1] << 8) | buf[0];
78.145 + delay = (buf[5] << 24) | (buf[4] << 16) | (buf[3] << 8) | buf[2];
78.146 + // check file length
78.147 + if (count == 0 ||
78.148 + fileSize != (long) (count * (height * ((width + 7) / 8)) + 14))
78.149 + {
78.150 + syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong size (cGLCDFile::Load).", fileName.c_str());
78.151 + fclose(fp);
78.152 + return false;
78.153 + }
78.154 + // Set minimal limit for next image
78.155 + if (delay < 10)
78.156 + delay = 10;
78.157 + }
78.158 + else
78.159 + {
78.160 + syslog(LOG_ERR, "glcdgraphics: load %s failed, wrong header (cGLCDFile::Load).", fileName.c_str());
78.161 + fclose(fp);
78.162 + return false;
78.163 + }
78.164 +
78.165 + image.Clear();
78.166 + image.SetWidth(width);
78.167 + image.SetHeight(height);
78.168 + image.SetDelay(delay);
78.169 + unsigned char * bmpdata = new unsigned char[height * ((width + 7) / 8)];
78.170 + if (bmpdata)
78.171 + {
78.172 + for (unsigned int n = 0; n < count; n++)
78.173 + {
78.174 + if (fread(bmpdata, height * ((width + 7) / 8), 1, fp) != 1)
78.175 + {
78.176 + delete[] bmpdata;
78.177 + fclose(fp);
78.178 + image.Clear();
78.179 + return false;
78.180 + }
78.181 + image.AddBitmap(new cBitmap(width, height, bmpdata));
78.182 + }
78.183 + delete[] bmpdata;
78.184 + }
78.185 + else
78.186 + {
78.187 + syslog(LOG_ERR, "glcdgraphics: malloc failed (cGLCDFile::Load).");
78.188 + fclose(fp);
78.189 + image.Clear();
78.190 + return false;
78.191 + }
78.192 + fclose(fp);
78.193 +
78.194 + syslog(LOG_DEBUG, "glcdgraphics: image %s loaded.", fileName.c_str());
78.195 + return true;
78.196 +}
78.197 +
78.198 +bool cGLCDFile::Save(cImage & image, const string & fileName)
78.199 +{
78.200 + FILE * fp;
78.201 + uint8_t buf[14];
78.202 + uint16_t width;
78.203 + uint16_t height;
78.204 + uint16_t count;
78.205 + uint32_t delay;
78.206 + const cBitmap * bitmap;
78.207 + int i;
78.208 +
78.209 + if (image.Count() == 0)
78.210 + return false;
78.211 +
78.212 + fp = fopen(fileName.c_str(), "wb");
78.213 + if (!fp)
78.214 + {
78.215 + syslog(LOG_ERR, "glcdgraphics: open %s failed (cGLCDFile::Save).", fileName.c_str());
78.216 + return false;
78.217 + }
78.218 +
78.219 + memcpy(buf, kGLCDFileSign, 3);
78.220 + count = image.Count();
78.221 + delay = image.Delay();
78.222 + if (count == 1)
78.223 + {
78.224 + buf[3] = 'D';
78.225 + }
78.226 + else
78.227 + {
78.228 + buf[3] = 'A';
78.229 + }
78.230 + bitmap = image.GetBitmap(0);
78.231 + width = bitmap->Width();
78.232 + height = bitmap->Height();
78.233 + buf[4] = (uint8_t) width;
78.234 + buf[5] = (uint8_t) (width >> 8);
78.235 + buf[6] = (uint8_t) height;
78.236 + buf[7] = (uint8_t) (height >> 8);
78.237 + if (count == 1)
78.238 + {
78.239 + if (fwrite(buf, 8, 1, fp) != 1)
78.240 + {
78.241 + fclose(fp);
78.242 + return false;
78.243 + }
78.244 + }
78.245 + else
78.246 + {
78.247 + buf[8] = (uint8_t) count;
78.248 + buf[9] = (uint8_t) (count >> 8);
78.249 + buf[10] = (uint8_t) delay;
78.250 + buf[11] = (uint8_t) (delay >> 8);
78.251 + buf[12] = (uint8_t) (delay >> 16);
78.252 + buf[13] = (uint8_t) (delay >> 24);
78.253 + if (fwrite(buf, 14, 1, fp) != 1)
78.254 + {
78.255 + fclose(fp);
78.256 + return false;
78.257 + }
78.258 + }
78.259 + for (i = 0; i < count; i++)
78.260 + {
78.261 + bitmap = image.GetBitmap(i);
78.262 + if (bitmap)
78.263 + {
78.264 + if (bitmap->Width() == width && bitmap->Height() == height)
78.265 + {
78.266 + if (fwrite(bitmap->Data(), height * ((width + 7) / 8), 1, fp) != 1)
78.267 + {
78.268 + fclose(fp);
78.269 + return false;
78.270 + }
78.271 + }
78.272 + }
78.273 + }
78.274 + fclose(fp);
78.275 +
78.276 + syslog(LOG_DEBUG, "glcdgraphics: image %s saved.", fileName.c_str());
78.277 + return true;
78.278 +}
78.279 +
78.280 +} // end of namespace
79.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
79.2 +++ b/graphlcd-base/glcdgraphics/glcd.h Thu Feb 07 13:03:18 2008 +0100
79.3 @@ -0,0 +1,36 @@
79.4 +/*
79.5 + * GraphLCD graphics library
79.6 + *
79.7 + * glcd.h - GLCD file loading and saving
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_GLCD_H_
79.19 +#define _GLCDGRAPHICS_GLCD_H_
79.20 +
79.21 +#include "imagefile.h"
79.22 +
79.23 +namespace GLCD
79.24 +{
79.25 +
79.26 +class cImage;
79.27 +
79.28 +class cGLCDFile : public cImageFile
79.29 +{
79.30 +public:
79.31 + cGLCDFile();
79.32 + virtual ~cGLCDFile();
79.33 + virtual bool Load(cImage & image, const std::string & fileName);
79.34 + virtual bool Save(cImage & image, const std::string & fileName);
79.35 +};
79.36 +
79.37 +} // end of namespace
79.38 +
79.39 +#endif
80.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
80.2 +++ b/graphlcd-base/glcdgraphics/image.c Thu Feb 07 13:03:18 2008 +0100
80.3 @@ -0,0 +1,67 @@
80.4 +/*
80.5 + * GraphLCD graphics library
80.6 + *
80.7 + * image.c - image and animation handling
80.8 + *
80.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
80.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
80.11 + *
80.12 + * This file is released under the GNU General Public License. Refer
80.13 + * to the COPYING file distributed with this package.
80.14 + *
80.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
80.16 + */
80.17 +
80.18 +#include "bitmap.h"
80.19 +#include "image.h"
80.20 +
80.21 +
80.22 +namespace GLCD
80.23 +{
80.24 +
80.25 +using namespace std;
80.26 +
80.27 +cImage::cImage()
80.28 +: width(0),
80.29 + height(0),
80.30 + delay(0),
80.31 + curBitmap(0),
80.32 + lastChange(0)
80.33 +{
80.34 +}
80.35 +
80.36 +cImage::~cImage()
80.37 +{
80.38 + Clear();
80.39 +}
80.40 +
80.41 +cBitmap * cImage::GetBitmap() const
80.42 +{
80.43 + if (curBitmap < bitmaps.size())
80.44 + return bitmaps[curBitmap];
80.45 + return NULL;
80.46 +}
80.47 +
80.48 +cBitmap * cImage::GetBitmap(unsigned int nr) const
80.49 +{
80.50 + if (nr < bitmaps.size())
80.51 + return bitmaps[nr];
80.52 + return NULL;
80.53 +}
80.54 +
80.55 +void cImage::Clear()
80.56 +{
80.57 + vector <cBitmap *>::iterator it;
80.58 + for (it = bitmaps.begin(); it != bitmaps.end(); it++)
80.59 + {
80.60 + delete *it;
80.61 + }
80.62 + bitmaps.clear();
80.63 + width = 0;
80.64 + height = 0;
80.65 + delay = 0;
80.66 + curBitmap = 0;
80.67 + lastChange = 0;
80.68 +}
80.69 +
80.70 +} // end of namespace
81.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
81.2 +++ b/graphlcd-base/glcdgraphics/image.h Thu Feb 07 13:03:18 2008 +0100
81.3 @@ -0,0 +1,58 @@
81.4 +/*
81.5 + * GraphLCD graphics library
81.6 + *
81.7 + * image.h - image and animation handling
81.8 + *
81.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
81.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
81.11 + *
81.12 + * This file is released under the GNU General Public License. Refer
81.13 + * to the COPYING file distributed with this package.
81.14 + *
81.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
81.16 + */
81.17 +
81.18 +#ifndef _GLCDGRAPHICS_IMAGE_H_
81.19 +#define _GLCDGRAPHICS_IMAGE_H_
81.20 +
81.21 +#include <stdint.h>
81.22 +
81.23 +#include <vector>
81.24 +
81.25 +namespace GLCD
81.26 +{
81.27 +
81.28 +class cBitmap;
81.29 +
81.30 +class cImage
81.31 +{
81.32 +private:
81.33 + unsigned int width;
81.34 + unsigned int height;
81.35 + unsigned int delay;
81.36 + unsigned int curBitmap;
81.37 + uint64_t lastChange;
81.38 + std::vector <cBitmap *> bitmaps;
81.39 +public:
81.40 + cImage();
81.41 + ~cImage();
81.42 +
81.43 + unsigned int Width() const { return width; }
81.44 + unsigned int Height() const { return height; }
81.45 + unsigned int Count() const { return bitmaps.size(); }
81.46 + unsigned int Delay() const { return delay; }
81.47 + uint64_t LastChange() const { return lastChange; }
81.48 + void First(uint64_t t) { lastChange = t; curBitmap = 0; }
81.49 + bool Next(uint64_t t) { lastChange = t; curBitmap++; return curBitmap < bitmaps.size(); }
81.50 + void SetWidth(unsigned int Width) { width = Width; }
81.51 + void SetHeight(unsigned int Height) { height = Height; }
81.52 + void SetDelay(unsigned int d) { delay = d; }
81.53 + cBitmap * GetBitmap(unsigned int nr) const;
81.54 + cBitmap * GetBitmap() const;
81.55 + void AddBitmap(cBitmap * Bitmap) { bitmaps.push_back(Bitmap); }
81.56 + void Clear();
81.57 +};
81.58 +
81.59 +} // end of namespace
81.60 +
81.61 +#endif
82.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
82.2 +++ b/graphlcd-base/glcdgraphics/imagefile.c Thu Feb 07 13:03:18 2008 +0100
82.3 @@ -0,0 +1,35 @@
82.4 +/*
82.5 + * GraphLCD graphics library
82.6 + *
82.7 + * imagefile.h - base class for 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 "image.h"
82.16 +#include "imagefile.h"
82.17 +
82.18 +namespace GLCD
82.19 +{
82.20 +
82.21 +cImageFile::cImageFile(void)
82.22 +{
82.23 +}
82.24 +cImageFile::~cImageFile(void)
82.25 +{
82.26 +}
82.27 +
82.28 +bool cImageFile::Load(cImage & image, const std::string & fileName)
82.29 +{
82.30 + return false;
82.31 +}
82.32 +
82.33 +bool cImageFile::Save(cImage & image, const std::string & fileName)
82.34 +{
82.35 + return false;
82.36 +}
82.37 +
82.38 +} // end of namespace
83.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
83.2 +++ b/graphlcd-base/glcdgraphics/imagefile.h Thu Feb 07 13:03:18 2008 +0100
83.3 @@ -0,0 +1,33 @@
83.4 +/*
83.5 + * GraphLCD graphics library
83.6 + *
83.7 + * imagefile.h - base class for 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_IMAGEFILE_H_
83.16 +#define _GLCDGRAPHICS_IMAGEFILE_H_
83.17 +
83.18 +#include <string>
83.19 +
83.20 +namespace GLCD
83.21 +{
83.22 +
83.23 +class cImage;
83.24 +
83.25 +class cImageFile
83.26 +{
83.27 +public:
83.28 + cImageFile();
83.29 + virtual ~cImageFile();
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
84.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
84.2 +++ b/graphlcd-base/glcdgraphics/pbm.c Thu Feb 07 13:03:18 2008 +0100
84.3 @@ -0,0 +1,187 @@
84.4 +/*
84.5 + * GraphLCD graphics library
84.6 + *
84.7 + * pbm.c - PBM file loading and saving
84.8 + *
84.9 + * This file is released under the GNU General Public License. Refer
84.10 + * to the COPYING file distributed with this package.
84.11 + *
84.12 + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de>
84.13 + */
84.14 +
84.15 +#include <stdio.h>
84.16 +#include <stdint.h>
84.17 +#include <syslog.h>
84.18 +
84.19 +#include <string>
84.20 +
84.21 +#include "bitmap.h"
84.22 +#include "pbm.h"
84.23 +#include "image.h"
84.24 +
84.25 +
84.26 +namespace GLCD
84.27 +{
84.28 +
84.29 +cPBMFile::cPBMFile()
84.30 +{
84.31 +}
84.32 +
84.33 +cPBMFile::~cPBMFile()
84.34 +{
84.35 +}
84.36 +
84.37 +bool cPBMFile::Load(cImage & image, const std::string & fileName)
84.38 +{
84.39 + FILE * pbmFile;
84.40 + char str[32];
84.41 + int i;
84.42 + int ch;
84.43 + int w;
84.44 + int h;
84.45 +
84.46 + pbmFile = fopen(fileName.c_str(), "rb");
84.47 + if (!pbmFile)
84.48 + return false;
84.49 +
84.50 + i = 0;
84.51 + while ((ch = getc(pbmFile)) != EOF && i < 31)
84.52 + {
84.53 + if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
84.54 + break;
84.55 + str[i] = ch;
84.56 + i++;
84.57 + }
84.58 + if (ch == EOF)
84.59 + {
84.60 + fclose(pbmFile);
84.61 + return false;
84.62 + }
84.63 + str[i] = 0;
84.64 + if (strcmp(str, "P4") != 0)
84.65 + return false;
84.66 +
84.67 + while ((ch = getc(pbmFile)) == '#')
84.68 + {
84.69 + while ((ch = getc(pbmFile)) != EOF)
84.70 + {
84.71 + if (ch == '\n' || ch == '\r')
84.72 + break;
84.73 + }
84.74 + }
84.75 + if (ch == EOF)
84.76 + {
84.77 + fclose(pbmFile);
84.78 + return false;
84.79 + }
84.80 + i = 0;
84.81 + str[i] = ch;
84.82 + i += 1;
84.83 + while ((ch = getc(pbmFile)) != EOF && i < 31)
84.84 + {
84.85 + if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
84.86 + break;
84.87 + str[i] = ch;
84.88 + i++;
84.89 + }
84.90 + if (ch == EOF)
84.91 + {
84.92 + fclose(pbmFile);
84.93 + return false;
84.94 + }
84.95 + str[i] = 0;
84.96 + w = atoi(str);
84.97 +
84.98 + i = 0;
84.99 + while ((ch = getc(pbmFile)) != EOF && i < 31)
84.100 + {
84.101 + if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r')
84.102 + break;
84.103 + str[i] = ch;
84.104 + i++;
84.105 + }
84.106 + if (ch == EOF)
84.107 + {
84.108 + fclose(pbmFile);
84.109 + return false;
84.110 + }
84.111 + str[i] = 0;
84.112 + h = atoi(str);
84.113 +
84.114 + image.Clear();
84.115 + image.SetWidth(w);
84.116 + image.SetHeight(h);
84.117 + image.SetDelay(100);
84.118 + unsigned char * bmpdata = new unsigned char[h * ((w + 7) / 8)];
84.119 + if (bmpdata)
84.120 + {
84.121 + if (fread(bmpdata, h * ((w + 7) / 8), 1, pbmFile) != 1)
84.122 + {
84.123 + delete[] bmpdata;
84.124 + fclose(pbmFile);
84.125 + image.Clear();
84.126 + return false;
84.127 + }
84.128 + image.AddBitmap(new cBitmap(w, h, bmpdata));
84.129 + delete[] bmpdata;
84.130 + }
84.131 + else
84.132 + {
84.133 + syslog(LOG_ERR, "glcdgraphics: malloc failed (cPBMFile::Load).");
84.134 + fclose(pbmFile);
84.135 + return false;
84.136 + }
84.137 + fclose(pbmFile);
84.138 + syslog(LOG_DEBUG, "glcdgraphics: image %s loaded.", fileName.c_str());
84.139 +
84.140 + return true;
84.141 +}
84.142 +
84.143 +bool cPBMFile::Save(cImage & image, const std::string & fileName)
84.144 +{
84.145 + FILE * fp;
84.146 + char str[32];
84.147 + const cBitmap * bitmap;
84.148 +
84.149 + if (image.Count() == 1)
84.150 + {
84.151 + fp = fopen(fileName.c_str(), "wb");
84.152 + if (fp)
84.153 + {
84.154 + bitmap = image.GetBitmap(0);
84.155 + if (bitmap)
84.156 + {
84.157 + sprintf(str, "P4\n%d %d\n", bitmap->Width(), bitmap->Height());
84.158 + fwrite(str, strlen(str), 1, fp);
84.159 + fwrite(bitmap->Data(), bitmap->LineSize() * bitmap->Height(), 1, fp);
84.160 + }
84.161 + fclose(fp);
84.162 + }
84.163 + }
84.164 + else
84.165 + {
84.166 + uint16_t i;
84.167 + char tmpStr[256];
84.168 +
84.169 + for (i = 0; i < image.Count(); i++)
84.170 + {
84.171 + sprintf(tmpStr, "%.248s.%05d", fileName.c_str(), i);
84.172 + fp = fopen(tmpStr, "wb");
84.173 + if (fp)
84.174 + {
84.175 + bitmap = image.GetBitmap(i);
84.176 + if (bitmap)
84.177 + {
84.178 + sprintf(str, "P4\n%d %d\n", bitmap->Width(), bitmap->Height());
84.179 + fwrite(str, strlen(str), 1, fp);
84.180 + fwrite(bitmap->Data(), bitmap->LineSize() * bitmap->Height(), 1, fp);
84.181 + }
84.182 + fclose(fp);
84.183 + }
84.184 + }
84.185 + }
84.186 + return true;
84.187 +}
84.188 +
84.189 +} // end of namespace
84.190 +
85.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
85.2 +++ b/graphlcd-base/glcdgraphics/pbm.h Thu Feb 07 13:03:18 2008 +0100
85.3 @@ -0,0 +1,34 @@
85.4 +/*
85.5 + * GraphLCD graphics library
85.6 + *
85.7 + * pbm.h - PBM file loading and saving
85.8 + *
85.9 + * This file is released under the GNU General Public License. Refer
85.10 + * to the COPYING file distributed with this package.
85.11 + *
85.12 + * (c) 2006 Andreas Regel <andreas.regel AT powarman.de>
85.13 + */
85.14 +
85.15 +#ifndef _GLCDGRAPHICS_PBM_H_
85.16 +#define _GLCDGRAPHICS_PBM_H_
85.17 +
85.18 +#include "imagefile.h"
85.19 +
85.20 +namespace GLCD
85.21 +{
85.22 +
85.23 +class cImage;
85.24 +
85.25 +class cPBMFile : public cImageFile
85.26 +{
85.27 +public:
85.28 + cPBMFile();
85.29 + virtual ~cPBMFile();
85.30 + virtual bool Load(cImage & image, const std::string & fileName);
85.31 + virtual bool Save(cImage & image, const std::string & fileName);
85.32 +};
85.33 +
85.34 +} // end of namespace
85.35 +
85.36 +#endif
85.37 +
86.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
86.2 +++ b/graphlcd-base/graphlcd.conf Thu Feb 07 13:03:18 2008 +0100
86.3 @@ -0,0 +1,528 @@
86.4 +# graphlcd.conf.sample
86.5 +#
86.6 +# This file contains a sample configuration for the graphlcd driver
86.7 +# library.
86.8 +#
86.9 +# The format is ini-file-like. It is divided into sections that start
86.10 +# at markers that look like [section]. Comments are all line-based
86.11 +# comments, and are lines that start with '#'.
86.12 +#
86.13 +# The file starts with general settings, that are used by several
86.14 +# drivers, followed by the sections. Each section represents a single
86.15 +# display with a driver definition and specific settings which define
86.16 +# how the driver acts. Some of these parameters like device, port and
86.17 +# size are already parsed by the library but the drivers can also read
86.18 +# their own options from the config file. The library passes them to
86.19 +# the drivers.
86.20 +
86.21 +# WaitMethod
86.22 +# Select the method that is used for sleeping.
86.23 +# Possible values:
86.24 +# 0 - usleep
86.25 +# 1 - nanosleep
86.26 +# 2 - nanosleep (sched_rr) - This is recommended on kernel 2.4 systems
86.27 +# 3 - gettimeofday - This is recommended on kernel 2.6 systems
86.28 +# Defaukt value: 3
86.29 +WaitMethod=3
86.30 +
86.31 +# WaitPriority
86.32 +# Select the process priority that is used when sleeping.
86.33 +# Possible values: -20 <= x <= 19
86.34 +# Default value: 0
86.35 +WaitPriority=0
86.36 +
86.37 +# General driver settings
86.38 +# This section lists the display settings that are parsed and
86.39 +# recognized by the driver library.
86.40 +#
86.41 +# Driver
86.42 +# Sets the display's driver.
86.43 +# Currently available are: framebuffer, gu140x32f, gu256x64-372,
86.44 +# gu256x64C-3xx0, hd61830, image, ks0108,
86.45 +# sed1520, sed1330, simlcd, t6963c,
86.46 +# gu126x64D-K610A4
86.47 +#
86.48 +# Device
86.49 +# Instead of using the direct output via port address (see Port), you
86.50 +# can use the parport device (/dev/parportX). The advantage over the
86.51 +# direct output via port address is that this works for non-root users
86.52 +# also. But it's a little bit slower. The modules ppdev.o, parport.o
86.53 +# and parport_pc.o must be loaded or compiled into the kernel.
86.54 +#
86.55 +# Port
86.56 +# Sets the port address of the parallel port. If this parameter is not
86.57 +# given, 0x378 is used. To use this direct output, the program that
86.58 +# uses the driver library has to be started with user 'root'.
86.59 +#
86.60 +# Width
86.61 +# Sets the horizontal size of the display. If this parameter is not
86.62 +# given, a default one specific to the driver is used.
86.63 +#
86.64 +# Height
86.65 +# Sets the vertical size of the display. If this parameter is not
86.66 +# given, a default one specific to the driver is used.
86.67 +#
86.68 +# UpsideDown
86.69 +# Rotates the display output by 180 degrees. This might be useful, if
86.70 +# the LCD is mounted upside-down.
86.71 +# Possible values: 'yes', 'no'
86.72 +# Default value: 'no'
86.73 +#
86.74 +# Invert
86.75 +# Inverts the display.
86.76 +# Possible values: 'yes', 'no'
86.77 +# Default value: 'no'
86.78 +#
86.79 +# Brightness
86.80 +# Sets the brightness of your display's backlight if supported by its
86.81 +# driver.
86.82 +# Supported by: gu140x32f, gu256x64-372, gu256x64-3900, gu126x64D-K610A4
86.83 +# Possible values: 0 <= x <= 100)
86.84 +# Default value: 100
86.85 +#
86.86 +# Contrast
86.87 +# Sets the contrast of your display if supported by its driver.
86.88 +# Supported by: serdisplib
86.89 +# Possible values: 0 <= x <= 10
86.90 +# Default value: 5
86.91 +#
86.92 +# Backlight
86.93 +# Switches the backlight of your display on and off if supported by
86.94 +# its driver.
86.95 +# Supported by: serdisplib
86.96 +# Possible values: 'yes', 'no'
86.97 +# Default value: 'yes'
86.98 +#
86.99 +# AdjustTiming
86.100 +# To get a timing that is as accurate as possible, the drivers measure
86.101 +# the time for port commands (see: benchmark in syslog). You might
86.102 +# decrease or increase the time to wait after port commands with this
86.103 +# parameter. Normally, there is no need to change this parameter.
86.104 +# (used by gu140x32f, gu256x64-372, gu256x64-3900, hd61830, ks0108,
86.105 +# sed1330, sed1520, gu126x64D-K610A4)
86.106 +# Possible values: -50 <= x <= 50
86.107 +# Default value: 0
86.108 +#
86.109 +# RefreshDisplay
86.110 +# Normally, most of the drivers do not update the whole display, but
86.111 +# only the areas that have changed since last update. So it might be,
86.112 +# that some faulty pixels would stay a longer time. To avoid this, the
86.113 +# plugin makes a complete refresh from time to time. This parameter
86.114 +# defines how often a complete refresh will be done.
86.115 +# e.g.: A value of 5 means, that the plugin will make a complete
86.116 +# refresh on every 5th update.
86.117 +# A value of 0 completely disables complete refreshs.
86.118 +# Possible values: 0 <= x <= 50
86.119 +# Default value: 5
86.120 +
86.121 +########################################################################
86.122 +
86.123 +[framebuffer]
86.124 +# framebuffer driver
86.125 +# Output goes to a framebuffer device
86.126 +# Default size: 320 x 240
86.127 +Driver=framebuffer
86.128 +
86.129 +#Width=320
86.130 +#Height=240
86.131 +#UpsideDown=no
86.132 +#Invert=no
86.133 +
86.134 +# Zoom
86.135 +# Determines if pixels should be drawn double sized.
86.136 +# Possible values: 0, 1
86.137 +Zoom=1
86.138 +
86.139 +########################################################################
86.140 +
86.141 +[gu140x32f]
86.142 +# gu140x32f driver
86.143 +# This is an 8-bit driver module for Noritake GU140x32-F7806 VFD
86.144 +# displays. The VFD is operating in it's 8 bit-mode connected to a
86.145 +# single PC parallel port.
86.146 +# Default size: 140 x 32
86.147 +Driver=gu140x32f
86.148 +
86.149 +Port=0x378
86.150 +#Device=/dev/parport0
86.151 +#Width=140
86.152 +#Height=32
86.153 +#UpsideDown=no
86.154 +#Invert=no
86.155 +#Brightness=100
86.156 +#AdjustTiming=0
86.157 +#RefreshDisplay=1
86.158 +
86.159 +# Wiring
86.160 +# Select the type of wiring your display is connected with.
86.161 +# Possible values: 'Standard', 'Windows'
86.162 +# Default value: 'Standard'
86.163 +Wiring=Standard
86.164 +
86.165 +########################################################################
86.166 +
86.167 +[gu256x64-372]
86.168 +# gu256x64-372 driver
86.169 +# This is an 8-bit driver module for Noritake GU256x64-372 VFD
86.170 +# displays. The VFD is operating in it's 8 bit-mode connected to a
86.171 +# single PC parallel port.
86.172 +# Default size: 256 x 64
86.173 +Driver=gu256x64-372
86.174 +
86.175 +Port=0x378
86.176 +#Device=/dev/parport0
86.177 +#Width=256
86.178 +#Height=64
86.179 +#UpsideDown=no
86.180 +#Invert=no
86.181 +#Brightness=100
86.182 +#AdjustTiming=0
86.183 +#RefreshDisplay=1
86.184 +
86.185 +########################################################################
86.186 +
86.187 +[gu256x64-3900]
86.188 +# gu256x64-3900 driver
86.189 +# This is a driver module for Noritake GU256X64x-3900 VFD displays. The
86.190 +# VFD is either operating in 8 bit-mode connected to a single PC
86.191 +# parallel port or in serial mode connected to a single PC serial port.
86.192 +# Default size: 256 x 64
86.193 +Driver=gu256x64-3900
86.194 +
86.195 +Port=0x378
86.196 +#Device=/dev/parport0
86.197 +#Width=256
86.198 +#Height=64
86.199 +#UpsideDown=no
86.200 +#Invert=no
86.201 +#Brightness=100
86.202 +#AdjustTiming=0
86.203 +#RefreshDisplay=1
86.204 +
86.205 +# Wiring
86.206 +# Select the type of wiring your display is connected with.
86.207 +# Possible values: 'Standard', 'Satyr'
86.208 +# Default value: 'Standard'
86.209 +Wiring=Standard
86.210 +
86.211 +# Interface
86.212 +# Select the interface your display is connnected to.
86.213 +# Possible values: 'Parallel', 'Serial'
86.214 +# Default value: 'Parallel'
86.215 +Interface=Parallel
86.216 +
86.217 +# DMA
86.218 +# Enables/disables the usage of the controller's DMA mode which
86.219 +# increases writing speed. This only works in parallel interface mode.
86.220 +# Possible values: 'yes', 'no'
86.221 +# Default value: 'yes'
86.222 +DMA=yes
86.223 +
86.224 +########################################################################
86.225 +
86.226 +[gu126x64D-K610A4]
86.227 +# GU126x64D-K610A4 driver
86.228 +# This is a driver module for Noritake GU126x64D-K610A4 VFD displays.
86.229 +# The VFD is operating in 8 bit-mode connected to a single PC
86.230 +# parallel port.
86.231 +# Default size: 126 x 64
86.232 +Driver=gu126x64D-K610A4
86.233 +
86.234 +Port=0x378
86.235 +# Device=/dev/parport0
86.236 +
86.237 +#Width=126
86.238 +#Height=64
86.239 +#UpsideDown=no
86.240 +#Invert=no
86.241 +#Brightness=100
86.242 +#RefreshDisplay=1
86.243 +#AdjustTiming=30
86.244 +
86.245 +# Debug some methods of the driver
86.246 +# (add the values of interest)
86.247 +#
86.248 +# 1: show a log at the start of a refresh
86.249 +# 2: show a log at the end of a refresh with timing information
86.250 +# 4: show the rows (8 pixel) refreshed
86.251 +# 8: show every commands/bytes sent to the display
86.252 +# 16: log every unsuccessful waiting for display acknowledge
86.253 +#
86.254 +#Debug=0
86.255 +
86.256 +########################################################################
86.257 +
86.258 +[hd61830]
86.259 +# hd61830 driver
86.260 +# This is a driver module for the Hitachi HD61830 LCD controller.
86.261 +# Default size: 240 x 128
86.262 +Driver=hd61830
86.263 +Port=0x378
86.264 +#Device=/dev/parport0
86.265 +#Width=240
86.266 +#Height=128
86.267 +#UpsideDown=no
86.268 +#Invert=no
86.269 +#AdjustTiming=0
86.270 +#RefreshDisplay=1
86.271 +
86.272 +########################################################################
86.273 +
86.274 +[image]
86.275 +# image driver
86.276 +# This is a driver module for writing image sequences in PBM (Portable
86.277 +# Bit Map) format that show the plugin's output.
86.278 +# Default size: 240 x 128
86.279 +Driver=image
86.280 +#Width=240
86.281 +#Height=128
86.282 +#UpsideDown=no
86.283 +#Invert=no
86.284 +
86.285 +########################################################################
86.286 +
86.287 +[ks0108]
86.288 +# ks0108 driver
86.289 +# This is a driver module for the Samsung KS0108 LCD controller.
86.290 +# Default size: 128 x 64
86.291 +Driver=ks0108
86.292 +Port=0x378
86.293 +#Device=/dev/parport0
86.294 +#Width=128
86.295 +#Height=64
86.296 +#UpsideDown=no
86.297 +#Invert=no
86.298 +#AdjustTiming=0
86.299 +#RefreshDisplay=1
86.300 +
86.301 +# Control
86.302 +# Select the variant of triggering the display's control lines.
86.303 +# Possible values: '0', '1'
86.304 +# Default value: '1'
86.305 +Control=1
86.306 +
86.307 +########################################################################
86.308 +
86.309 +[sed1330]
86.310 +# sed1330 driver
86.311 +# This is a driver module for the Epson SED1330/1335 LCD controller.
86.312 +# Default size: 320 x 240
86.313 +Driver=sed1330
86.314 +Port=0x378
86.315 +#Device=/dev/parport0
86.316 +#Width=320
86.317 +#Height=240
86.318 +#UpsideDown=no
86.319 +#Invert=no
86.320 +#AdjustTiming=0
86.321 +#refreshDisplay=1
86.322 +
86.323 +# Wiring
86.324 +# Select the type of wiring your display is connected with.
86.325 +# Possible values: 'Original', 'PowerLCD', 'LCDProc', 'Tweakers',
86.326 +# 'YASEDW'
86.327 +# Default value: 'Original'
86.328 +Wiring=Original
86.329 +
86.330 +# OscillatorFrequency
86.331 +# Select the frequency the oscillator on your LCD board uses in kHz.
86.332 +# Possible values: 1000 <= x <= 15000)
86.333 +# Default value: 9600
86.334 +OscillatorFrequency=9600
86.335 +
86.336 +# Interface
86.337 +# Select the interface mode your display is connected with.
86.338 +# Possible values: '6800', '8080'
86.339 +# Default value: '6800'
86.340 +Interface=6800
86.341 +
86.342 +########################################################################
86.343 +
86.344 +[sed1520]
86.345 +# sed1520 driver
86.346 +# This is a driver module for the Epson SED1520 LCD controller.
86.347 +# Default size: 120 x 32
86.348 +Driver=sed1520
86.349 +Port=0x378
86.350 +#Device=/dev/parport0
86.351 +#Width=120
86.352 +#Height=32
86.353 +#UpsideDown=no
86.354 +#Invert=no
86.355 +#AdjustTiming=0
86.356 +#RefreshDisplay=1
86.357 +
86.358 +########################################################################
86.359 +
86.360 +[simlcd]
86.361 +# simlcd driver
86.362 +# This is the SimLCD driver module. Output goes to a file instead of
86.363 +# LCD. Use SimLCD tool to view this file.
86.364 +# Default size: 240 x 128
86.365 +Driver=simlcd
86.366 +#Width=240
86.367 +#Height=128
86.368 +#UpsideDown=no
86.369 +#Invert=no
86.370 +
86.371 +########################################################################
86.372 +
86.373 +[t6963c]
86.374 +# t6963c driver
86.375 +# This is a driver module for the Toshiba T6963C LCD controller.
86.376 +# Default size: 240 x 128
86.377 +Driver=t6963c
86.378 +Port=0x378
86.379 +#Device=/dev/parport0
86.380 +#Width=240
86.381 +#Height=128
86.382 +#UpsideDown=no
86.383 +#Invert=no
86.384 +#RefreshDisplay=1
86.385 +
86.386 +# Wiring
86.387 +# Select the type of wiring your display is connected with.
86.388 +# Possible values: 'Standard', 'Windows', 'Serial'
86.389 +# Default value: 'Standard'
86.390 +Wiring=Standard
86.391 +
86.392 +# FontSelect
86.393 +# Select the font width your display uses for text mode. In most cases
86.394 +# this is selectable through one of the pins of your LCD board
86.395 +# Possible values: '6', '8'
86.396 +# Default value: '6'
86.397 +FontSelect=6
86.398 +
86.399 +# AutoMode
86.400 +# Enables or disables the usage of T6963C's auto mode which doubles
86.401 +# writing speed when enabled.
86.402 +# Possible values: 'yes', 'no'
86.403 +# Default value: 'yes'
86.404 +AutoMode=yes
86.405 +
86.406 +# StatusCheck
86.407 +# Enables or disables the usage of T6963C's status check. When using a
86.408 +# shielded cable for connecting your display, the disabling may be
86.409 +# possible. This results in doubling the speed of writing data to the
86.410 +# LCD.
86.411 +# Possible values: 'yes', 'no'
86.412 +# Default value: 'yes'
86.413 +StatusCheck=yes
86.414 +
86.415 +########################################################################
86.416 +
86.417 +[serdisp]
86.418 +Driver=serdisp
86.419 +# Controller
86.420 +# Select the serdisplib name of your display.
86.421 +# Possible values: See README in serdisplib package or http://serdisplib.sourceforge.net
86.422 +#Controller=nokia7110
86.423 +#Controller=sed1335
86.424 +Controller=optrex323
86.425 +
86.426 +# Options
86.427 +# Pass display specific options
86.428 +# Possible values: See driver-specific hardware page at http://serdisplib.sourceforge.net
86.429 +#
86.430 +# IMPORTANT: when using generic controllers like sed1330,sed1335,t6963c, width and height
86.431 +# need to be set here (if different from default settings)!
86.432 +# (serdisplib needs to be extended to be able to use 'Width' and 'Height'
86.433 +# settings directly - this will be added later)
86.434 +#
86.435 +#Options=MODE=8080
86.436 +#Options=DELAY=2000;FONTWIDTH=8;CHECK=1
86.437 +#Options=WIDTH=128;HEIGHT=64
86.438 +#Options=WIDTH=128;HEIGHT=64;DELAY=2000;FONTWIDTH=8;CHECK=1
86.439 +
86.440 +# Wiring
86.441 +# Select Wiring
86.442 +# Possible values: See driver-specific hardware page at http://serdisplib.sourceforge.net
86.443 +#Wiring=1
86.444 +#Wiring=PowerLCD
86.445 +#Wiring=DATA8,CS:nAUTO,A0:INIT,WR:nSTRB,RD:nSELIN
86.446 +
86.447 +# FGColour
86.448 +# Drawing colour for non-monochrome displays
86.449 +# Possible values: 0xRRGGBB (eg.: 0xFF0000)
86.450 +# Defaults to black (0x000000) if not set
86.451 +#FGColour=0x000000
86.452 +
86.453 +# BGColour
86.454 +# Background colour for non-monochrome displays
86.455 +# Possible values: 0xRRGGBB (eg.: 0x00FFFF)
86.456 +# Defaults to white (0xFFFFFF) if not set
86.457 +#BGColour=0xFFFFFF
86.458 +
86.459 +Port=0x378
86.460 +#Device=/dev/parport0
86.461 +#UpsideDown=no
86.462 +#Invert=no
86.463 +Contrast=5
86.464 +Backlight=yes
86.465 +
86.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)
86.467 +##Width=240
86.468 +##Height=128
86.469 +
86.470 +########################################################################
86.471 +
86.472 +[noritake800]
86.473 +# noritake800 driver
86.474 +# This is an 8-bit driver module for Noritake Noritake 800(A) series VFD
86.475 +# displays. The VFD is operating in it's 8 bit-mode connected to a
86.476 +# single PC parallel port.
86.477 +# Default size: 128 x 64
86.478 +Driver=noritake800
86.479 +Port=0x378
86.480 +#Device=/dev/parport0
86.481 +Width=128
86.482 +Height=64
86.483 +#UpsideDown=no
86.484 +#Invert=no
86.485 +Brightness=50
86.486 +#AdjustTiming=0 # not used
86.487 +#RefreshDisplay=0 # not used
86.488 +
86.489 +# Wiring
86.490 +# Select the type of wiring your display is connected with.
86.491 +# Possible values: 'LiquidMp3', 'MZ'
86.492 +# Default value: 'LiquidMp3'
86.493 +Wiring=LiquidMp3
86.494 +
86.495 +########################################################################
86.496 +
86.497 +[avrctl]
86.498 +# avrctl driver
86.499 +# This is an driver module for my AVR controlled LCD display connected via
86.500 +# USB port. It uses some simple commands to update the display content.
86.501 +# Default size: 256 x 128
86.502 +Driver=avrctl
86.503 +Device=/dev/ttyUSB0
86.504 +Width=256
86.505 +Height=128
86.506 +#UpsideDown=no
86.507 +#Invert=no
86.508 +Brightness=50
86.509 +RefreshDisplay=1
86.510 +
86.511 +########################################################################
86.512 +
86.513 +[g15daemon]
86.514 +# pseudo device for the g15daemon meta driver
86.515 +# Output goes to the g15daemon which then displays it
86.516 +Driver=g15daemon
86.517 +Width=160
86.518 +Height=43
86.519 +
86.520 +########################################################################
86.521 +
86.522 +[network]
86.523 +# network driver
86.524 +# Default size: 240 x 128
86.525 +Driver=network
86.526 +Width=256
86.527 +Height=128
86.528 +UpsideDown=no
86.529 +Invert=no
86.530 +Brightness=10
86.531 +RefreshDisplay=1
87.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
87.2 +++ b/graphlcd-base/tools/Makefile Thu Feb 07 13:03:18 2008 +0100
87.3 @@ -0,0 +1,47 @@
87.4 +#
87.5 +# Makefile for the graphlcd tools
87.6 +#
87.7 +
87.8 +
87.9 +-include ../Make.config
87.10 +
87.11 +### Targets:
87.12 +
87.13 +all:
87.14 + @$(MAKE) -C convpic all
87.15 + @$(MAKE) -C crtfont all
87.16 +ifdef HAVE_FREETYPE2
87.17 + @$(MAKE) -C genfont all
87.18 +endif
87.19 + @$(MAKE) -C showpic all
87.20 + @$(MAKE) -C showtext all
87.21 + @$(MAKE) -C lcdtestpattern all
87.22 +
87.23 +install:
87.24 + @$(MAKE) -C convpic install
87.25 + @$(MAKE) -C crtfont install
87.26 +ifdef HAVE_FREETYPE2
87.27 + @$(MAKE) -C genfont install
87.28 +endif
87.29 + @$(MAKE) -C showpic install
87.30 + @$(MAKE) -C showtext install
87.31 + @$(MAKE) -C lcdtestpattern install
87.32 +
87.33 +uninstall:
87.34 + @$(MAKE) -C convpic uninstall
87.35 + @$(MAKE) -C crtfont uninstall
87.36 +ifdef HAVE_FREETYPE2
87.37 + @$(MAKE) -C genfont uninstall
87.38 +endif
87.39 + @$(MAKE) -C showpic uninstall
87.40 + @$(MAKE) -C showtext uninstall
87.41 + @$(MAKE) -C lcdtestpattern uninstall
87.42 +
87.43 +clean:
87.44 + @$(MAKE) -C convpic clean
87.45 + @$(MAKE) -C crtfont clean
87.46 + @$(MAKE) -C genfont clean
87.47 + @$(MAKE) -C showpic clean
87.48 + @$(MAKE) -C showtext clean
87.49 + @$(MAKE) -C lcdtestpattern clean
87.50 +
88.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
88.2 +++ b/graphlcd-base/tools/convpic/Makefile Thu Feb 07 13:03:18 2008 +0100
88.3 @@ -0,0 +1,46 @@
88.4 +#
88.5 +# Makefile for the GraphLCD tool convpic
88.6 +#
88.7 +
88.8 +-include ../../Make.config
88.9 +
88.10 +PRGNAME = convpic
88.11 +
88.12 +OBJS = $(PRGNAME).o bmp.o tiff.o tuxbox.o
88.13 +
88.14 +INCLUDES += -I../../
88.15 +LIBDIRS += -L../../glcdgraphics/
88.16 +
88.17 +
88.18 +all: $(PRGNAME)
88.19 +.PHONY: all
88.20 +
88.21 +# Implicit rules:
88.22 +
88.23 +%.o: %.c
88.24 + $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
88.25 +
88.26 +# Dependencies:
88.27 +
88.28 +MAKEDEP = $(CXX) -MM -MG
88.29 +DEPFILE = .dependencies
88.30 +$(DEPFILE): Makefile
88.31 + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
88.32 +
88.33 +-include $(DEPFILE)
88.34 +
88.35 +# The main program:
88.36 +
88.37 +$(PRGNAME): $(OBJS)
88.38 + $(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lstdc++ -o $(PRGNAME)
88.39 +
88.40 +install: $(PRGNAME)
88.41 + install -d $(BINDIR)
88.42 + install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
88.43 +
88.44 +uninstall:
88.45 + rm -f $(BINDIR)/$(PRGNAME)
88.46 +
88.47 +clean:
88.48 + @-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
88.49 +
89.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
89.2 +++ b/graphlcd-base/tools/convpic/bmp.c Thu Feb 07 13:03:18 2008 +0100
89.3 @@ -0,0 +1,375 @@
89.4 +/**
89.5 + * GraphLCD plugin for the Video Disk Recorder
89.6 + *
89.7 + * bmp.c - bmp logo class
89.8 + *
89.9 + * (C) 2004 Andreas Brachold <vdr04 AT deltab de>
89.10 + * (C) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
89.11 + **/
89.12 +
89.13 +/***************************************************************************
89.14 + * *
89.15 + * This program is free software; you can redistribute it and/or modify *
89.16 + * it under the terms of the GNU General Public License as published by *
89.17 + * the Free Software Foundation; either version 2 of the License, or *
89.18 + * (at your option) any later version. *
89.19 + * *
89.20 + * This program is distributed in the hope that it will be useful, *
89.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
89.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
89.23 + * GNU General Public License for more details. *
89.24 + * *
89.25 + * You should have received a copy of the GNU General Public License *
89.26 + * along with this program; *
89.27 + * if not, write to the Free Software Foundation, Inc., *
89.28 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
89.29 + * *
89.30 + ***************************************************************************/
89.31 +
89.32 +#include <stdio.h>
89.33 +#include <stdint.h>
89.34 +#include <string.h>
89.35 +
89.36 +#include <string>
89.37 +
89.38 +#include <glcdgraphics/bitmap.h>
89.39 +#include <glcdgraphics/image.h>
89.40 +
89.41 +#include "bmp.h"
89.42 +
89.43 +
89.44 +#pragma pack(1)
89.45 +typedef struct BMPH {
89.46 + uint16_t bmpIdentifier;
89.47 + uint32_t bmpFileSize;
89.48 + uint32_t bmpReserved;
89.49 + uint32_t bmpBitmapDataOffset;
89.50 + uint32_t bmpBitmapHeaderSize;
89.51 + uint32_t bmpWidth;
89.52 + uint32_t bmpHeight;
89.53 + uint16_t bmpPlanes;
89.54 + uint16_t bmpBitsPerPixel;
89.55 + uint32_t bmpCompression;
89.56 + uint32_t bmpBitmapDataSize;
89.57 + uint32_t bmpHResolution;
89.58 + uint32_t bmpVResolution;
89.59 + uint32_t bmpColors;
89.60 + uint32_t bmpImportantColors;
89.61 +} BMPHEADER; // 54 bytes
89.62 +
89.63 +typedef struct RGBQ {
89.64 + uint8_t rgbBlue;
89.65 + uint8_t rgbGreen;
89.66 + uint8_t rgbRed;
89.67 + uint8_t rgbReserved;
89.68 +} RGBQUAD; // 4 bytes
89.69 +#pragma pack()
89.70 +
89.71 +
89.72 +uint8_t bitmask[8] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01};
89.73 +uint8_t bitmaskl[8] = {0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff};
89.74 +uint8_t bitmaskr[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01};
89.75 +
89.76 +cBMPFile::cBMPFile()
89.77 +{
89.78 +}
89.79 +
89.80 +cBMPFile::~cBMPFile()
89.81 +{
89.82 +}
89.83 +
89.84 +bool cBMPFile::Load(GLCD::cImage & image, const std::string & fileName)
89.85 +{
89.86 + FILE *fIN;
89.87 + BMPHEADER bmpHeader;
89.88 + RGBQUAD *pPalette;
89.89 + char *pByte;
89.90 + char Dummy;
89.91 + long iNumColors;
89.92 + long iSize;
89.93 + uint32_t x, y;
89.94 + uint16_t iRead;
89.95 + uint8_t * bitmap = NULL;
89.96 + bool bInvert = false;
89.97 +
89.98 + if (fileName.length() > 0)
89.99 + {
89.100 + fIN = fopen(fileName.c_str(), "rb");
89.101 + if (fIN)
89.102 + {
89.103 + if (fread(&bmpHeader, sizeof(BMPHEADER), 1, fIN)!=1)
89.104 + {
89.105 + fclose(fIN);
89.106 + return false;
89.107 + }
89.108 +
89.109 + // check for Windows BMP
89.110 + if (bmpHeader.bmpBitmapHeaderSize != 0x00000028 )
89.111 + {
89.112 + fprintf(stderr, "ERROR: only Windows BMP images are allowed.\n");
89.113 + fclose(fIN);
89.114 + return false;
89.115 + }
89.116 +
89.117 + // check for 2 color
89.118 + iNumColors = (1 << bmpHeader.bmpBitsPerPixel);
89.119 + if (iNumColors != 2)
89.120 + {
89.121 + fprintf(stderr, "ERROR: the image has %ld colors, but only images with 2 colors are allowed.\n", iNumColors);
89.122 + fclose(fIN);
89.123 + return false;
89.124 + }
89.125 +
89.126 + iSize = bmpHeader.bmpHeight * bmpHeader.bmpWidth;
89.127 +
89.128 + pPalette = (RGBQUAD *) malloc( iNumColors*sizeof(RGBQUAD));
89.129 + if (!pPalette)
89.130 + {
89.131 + fprintf(stderr, "ERROR: cannot allocate memory\n");
89.132 + fclose(fIN);
89.133 + return false;
89.134 + }
89.135 +
89.136 + if (fread( pPalette, iNumColors*sizeof(RGBQUAD), 1, fIN)!=1)
89.137 + {
89.138 + free(pPalette);
89.139 + fclose(fIN);
89.140 + return false;
89.141 + }
89.142 +
89.143 + // check colors
89.144 + if (pPalette->rgbBlue+pPalette->rgbGreen+pPalette->rgbRed <
89.145 + (pPalette+1)->rgbBlue+(pPalette+1)->rgbGreen+(pPalette+1)->rgbRed)
89.146 + {
89.147 + // index 0 represents 'black', index 1 'white'
89.148 + bInvert = !bInvert;
89.149 + }
89.150 + else
89.151 + {
89.152 + // index 0 represents 'white', index 1 'black'
89.153 + }
89.154 +
89.155 + if (fseek(fIN, bmpHeader.bmpBitmapDataOffset, SEEK_SET)==EOF)
89.156 + {
89.157 + free(pPalette);
89.158 + fclose(fIN);
89.159 + return false;
89.160 + }
89.161 +
89.162 + switch (bmpHeader.bmpCompression)
89.163 + {
89.164 + case 0: // BI_RGB no compression
89.165 + image.Clear();
89.166 + image.SetWidth(bmpHeader.bmpWidth);
89.167 + image.SetHeight(bmpHeader.bmpHeight);
89.168 + image.SetDelay(100);
89.169 + bitmap = new unsigned char[bmpHeader.bmpHeight * ((bmpHeader.bmpWidth + 7) / 8)];
89.170 + if (!bitmap)
89.171 + {
89.172 + fprintf(stderr, "ERROR: cannot allocate memory\n");
89.173 + free(pPalette);
89.174 + fclose(fIN);
89.175 + image.Clear();
89.176 + return false;
89.177 + }
89.178 +
89.179 + for (y = bmpHeader.bmpHeight; y > 0; y--)
89.180 + {
89.181 + pByte = (char*)bitmap + (y-1)*((bmpHeader.bmpWidth+7)/8);
89.182 + iRead = 0;
89.183 + for (x = 0; x < bmpHeader.bmpWidth / 8; x++)
89.184 + {
89.185 + if (fread(pByte, sizeof(char), 1, fIN) != 1)
89.186 + {
89.187 + delete[] bitmap;
89.188 + free(pPalette);
89.189 + fclose(fIN);
89.190 + image.Clear();
89.191 + return false;
89.192 + }
89.193 + iRead++;
89.194 + if (bInvert)
89.195 + *pByte = *pByte ^ 0xff;
89.196 + pByte++;
89.197 + }
89.198 +
89.199 + if (bmpHeader.bmpWidth % 8)
89.200 + {
89.201 + if (fread(pByte, sizeof(char), 1, fIN) != 1)
89.202 + {
89.203 + delete [] bitmap;
89.204 + free(pPalette);
89.205 + fclose(fIN);
89.206 + image.Clear();
89.207 + return false;
89.208 + }
89.209 + iRead++;
89.210 + if (bInvert)
89.211 + *pByte = *pByte^0xff;
89.212 + *pByte = *pByte & bitmaskl[bmpHeader.bmpWidth%8];
89.213 + pByte++;
89.214 + }
89.215 +
89.216 + // Scan line must be 4-byte-alligned
89.217 + while (iRead % 4)
89.218 + {
89.219 + if (fread(&Dummy, sizeof(char), 1, fIN) != 1)
89.220 + {
89.221 + delete [] bitmap;
89.222 + free(pPalette);
89.223 + fclose(fIN);
89.224 + image.Clear();
89.225 + return false;
89.226 + }
89.227 + iRead++;
89.228 + }
89.229 + }
89.230 + image.AddBitmap(new GLCD::cBitmap(bmpHeader.bmpWidth, bmpHeader.bmpHeight, bitmap));
89.231 + break;
89.232 + case 1: // BI_RLE4 RLE 4bit/pixel
89.233 + case 2: // BI_RLE8 RLE 8bit/pixel
89.234 + case 3: // BI_BITFIELDS
89.235 + default:
89.236 + fprintf(stderr, "ERROR: only uncompressed RGB images are allowed.\n");
89.237 +
89.238 + free(pPalette);
89.239 + fclose(fIN);
89.240 + return false;
89.241 + }
89.242 + fclose(fIN);
89.243 + }
89.244 + else
89.245 + {
89.246 + fprintf(stderr, "ERROR: cannot open picture %s\n", fileName.c_str());
89.247 + }
89.248 + }
89.249 + else
89.250 + {
89.251 + fprintf(stderr, "ERROR: no FileName given!\n");
89.252 + }
89.253 + return true;
89.254 +}
89.255 +
89.256 +bool cBMPFile::Save(const GLCD::cBitmap * bitmap, const std::string & fileName)
89.257 +{
89.258 + FILE *fOut;
89.259 + BMPHEADER bmpHeader;
89.260 + RGBQUAD bmpColor1, bmpColor2;
89.261 + uint32_t dBDO, dBDSx, dBDS;
89.262 + char *pByte;
89.263 + char Dummy = 0x00;
89.264 + uint32_t x, y;
89.265 + uint16_t iWrote;
89.266 + const uint8_t * bmpdata = bitmap->Data();
89.267 +
89.268 + if (bitmap
89.269 + && bitmap->Width() > 0
89.270 + && bitmap->Height() > 0)
89.271 + {
89.272 + memset(&bmpHeader, 0, sizeof(BMPHEADER));
89.273 +
89.274 + dBDO = sizeof(BMPHEADER)+2*sizeof(RGBQUAD);
89.275 + dBDSx = ((bitmap->Width() + 7) / 8 + 3) & 0xfffffffc;
89.276 + dBDS = dBDSx * bitmap->Height();
89.277 +
89.278 + bmpHeader.bmpIdentifier = 0x4d42; // "BM"
89.279 + bmpHeader.bmpFileSize = dBDO + dBDS;
89.280 + bmpHeader.bmpBitmapDataOffset = dBDO;
89.281 + bmpHeader.bmpBitmapHeaderSize = 0x28;
89.282 + bmpHeader.bmpWidth = bitmap->Width();
89.283 + bmpHeader.bmpHeight = bitmap->Height();
89.284 + bmpHeader.bmpPlanes = 0x01;
89.285 + bmpHeader.bmpBitsPerPixel = 0x01;
89.286 + bmpHeader.bmpCompression = 0x00;
89.287 + bmpHeader.bmpBitmapDataSize = dBDS;
89.288 + bmpHeader.bmpHResolution = 0xb13; // 72dpi
89.289 + bmpHeader.bmpVResolution = 0xb13; // 72dpi
89.290 + bmpHeader.bmpColors = 0x02;
89.291 + bmpHeader.bmpImportantColors = 0x02;
89.292 +
89.293 + bmpColor1.rgbBlue = 0x00;
89.294 + bmpColor1.rgbGreen = 0x00;
89.295 + bmpColor1.rgbRed = 0x00;
89.296 + bmpColor1.rgbReserved = 0x00;
89.297 + bmpColor2.rgbBlue = 0xff;
89.298 + bmpColor2.rgbGreen = 0xff;
89.299 + bmpColor2.rgbRed = 0xff;
89.300 + bmpColor2.rgbReserved = 0x00;
89.301 +
89.302 +
89.303 + fOut = fopen(fileName.c_str(), "wb");
89.304 + if (!fOut)
89.305 + {
89.306 + fprintf(stderr,"Cannot create file: %s\n", fileName.c_str());
89.307 + return false;
89.308 + }
89.309 + fwrite(&bmpHeader, sizeof(BMPHEADER), 1, fOut);
89.310 + fwrite(&bmpColor1, sizeof(RGBQUAD), 1, fOut);
89.311 + fwrite(&bmpColor2, sizeof(RGBQUAD), 1, fOut);
89.312 +
89.313 + for (y=bitmap->Height(); y>0; y--)
89.314 + {
89.315 + pByte = (char*)bmpdata + (y-1)*((bitmap->Width()+7)/8);
89.316 + iWrote = 0;
89.317 + for (x=0; x<(uint32_t) bitmap->Width()/8; x++)
89.318 + {
89.319 + *pByte = *pByte^0xff;
89.320 + if (fwrite(pByte, sizeof(char), 1, fOut)!=1)
89.321 + {
89.322 + fclose(fOut);
89.323 + return false;
89.324 + }
89.325 + iWrote++;
89.326 + pByte++;
89.327 + }
89.328 + // Scan line must be 4-byte-alligned
89.329 + while (iWrote%4)
89.330 + {
89.331 + if (fwrite(&Dummy, sizeof(char), 1, fOut)!=1)
89.332 + {
89.333 + fclose(fOut);
89.334 + return 3;
89.335 + }
89.336 + iWrote++;
89.337 + }
89.338 + }
89.339 + fclose(fOut);
89.340 + }
89.341 + return true;
89.342 +}
89.343 +
89.344 +bool cBMPFile::Save(GLCD::cImage & image, const std::string & fileName)
89.345 +{
89.346 + const GLCD::cBitmap * bitmap;
89.347 +
89.348 + if (image.Count() == 1)
89.349 + {
89.350 + bitmap = image.GetBitmap(0);
89.351 + if (bitmap)
89.352 + {
89.353 + if (!Save(bitmap, fileName))
89.354 + {
89.355 + return false;
89.356 + }
89.357 + }
89.358 + }
89.359 + else
89.360 + {
89.361 + uint16_t i;
89.362 + char tmpStr[256];
89.363 +
89.364 + for (i = 0; i < image.Count(); i++)
89.365 + {
89.366 + sprintf(tmpStr, "%.248s.%05d", fileName.c_str(), i);
89.367 + bitmap = image.GetBitmap(i);
89.368 + if (bitmap)
89.369 + {
89.370 + if (!Save(bitmap, tmpStr))
89.371 + {
89.372 + return false;
89.373 + }
89.374 + }
89.375 + }
89.376 + }
89.377 + return true;
89.378 +}
90.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
90.2 +++ b/graphlcd-base/tools/convpic/bmp.h Thu Feb 07 13:03:18 2008 +0100
90.3 @@ -0,0 +1,45 @@
90.4 +/**
90.5 + * GraphLCD plugin for the Video Disk Recorder
90.6 + *
90.7 + * bmp.h - bmp logo class
90.8 + *
90.9 + * (C) 2004 Andreas Brachold <vdr04 AT deltab de>
90.10 + * (C) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
90.11 + **/
90.12 +
90.13 +/***************************************************************************
90.14 + * *
90.15 + * This program is free software; you can redistribute it and/or modify *
90.16 + * it under the terms of the GNU General Public License as published by *
90.17 + * the Free Software Foundation; either version 2 of the License, or *
90.18 + * (at your option) any later version. *
90.19 + * *
90.20 + * This program is distributed in the hope that it will be useful, *
90.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
90.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
90.23 + * GNU General Public License for more details. *
90.24 + * *
90.25 + * You should have received a copy of the GNU General Public License *
90.26 + * along with this program; *
90.27 + * if not, write to the Free Software Foundation, Inc., *
90.28 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
90.29 + * *
90.30 + ***************************************************************************/
90.31 +
90.32 +#ifndef _BMP_H_
90.33 +#define _BMP_H_
90.34 +
90.35 +#include <glcdgraphics/imagefile.h>
90.36 +
90.37 +class cBMPFile : public GLCD::cImageFile
90.38 +{
90.39 +private:
90.40 + bool Save(const GLCD::cBitmap * bitmap, const std::string & fileName);
90.41 +public:
90.42 + cBMPFile();
90.43 + virtual ~cBMPFile();
90.44 + virtual bool Load(GLCD::cImage & image, const std::string & fileName);
90.45 + virtual bool Save(GLCD::cImage & image, const std::string & fileName);
90.46 +};
90.47 +
90.48 +#endif
91.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
91.2 +++ b/graphlcd-base/tools/convpic/c_bmp2glcd Thu Feb 07 13:03:18 2008 +0100
91.3 @@ -0,0 +1,10 @@
91.4 +#!/bin/sh
91.5 +# Converts all BMP images to *.glcd
91.6 +
91.7 +old=bmp
91.8 +new=glcd
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/c_tif2glcd Thu Feb 07 13:03:18 2008 +0100
92.3 @@ -0,0 +1,10 @@
92.4 +#!/bin/sh
92.5 +# Converts all TIFF images to *.glcd
92.6 +
92.7 +old=tif
92.8 +new=glcd
92.9 +
92.10 +for file in ./*."$old"; do
92.11 + convpic -i "$file" -o "`basename \"$file\" \"$old\"`$new"
92.12 +done
92.13 +
93.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
93.2 +++ b/graphlcd-base/tools/convpic/convall Thu Feb 07 13:03:18 2008 +0100
93.3 @@ -0,0 +1,10 @@
93.4 +#!/bin/sh
93.5 +# Converts all images in current directory
93.6 +
93.7 +old=$1
93.8 +new=$2
93.9 +
93.10 +for file in ./*."$old"; do
93.11 + convpic -i "$file" -o "`basename \"$file\" \"$old\"`$new"
93.12 +done
93.13 +
94.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
94.2 +++ b/graphlcd-base/tools/convpic/convpic.c Thu Feb 07 13:03:18 2008 +0100
94.3 @@ -0,0 +1,279 @@
94.4 +/**
94.5 + * convpic.c - a tool to convert images to
94.6 + * own proprietary format of the logos and pictures
94.7 + * for graphlcd plugin
94.8 + *
94.9 + * (C) 2004 Andreas Brachold <vdr04 AT deltab de>
94.10 + * (C) 2001-2003 by 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 <getopt.h>
94.33 +#include <stdio.h>
94.34 +#include <stdint.h>
94.35 +#include <string.h>
94.36 +#include <stdlib.h>
94.37 +
94.38 +#include <string>
94.39 +
94.40 +#include <glcdgraphics/bitmap.h>
94.41 +#include <glcdgraphics/image.h>
94.42 +#include <glcdgraphics/imagefile.h>
94.43 +#include <glcdgraphics/glcd.h>
94.44 +#include <glcdgraphics/pbm.h>
94.45 +
94.46 +#include "bmp.h"
94.47 +#include "tiff.h"
94.48 +#include "tuxbox.h"
94.49 +
94.50 +static const char *prgname = "convpic";
94.51 +static const char *VERSION = "0.1.1";
94.52 +
94.53 +unsigned int delay = 250;
94.54 +
94.55 +
94.56 +enum ePicFormat
94.57 +{
94.58 + pfUndefined,
94.59 + pfTIFF,
94.60 + pfBMP,
94.61 + pfGLCD,
94.62 + pfPBM,
94.63 + pfTUXBOX
94.64 +};
94.65 +
94.66 +void usage(void);
94.67 +
94.68 +ePicFormat getFormat(const char* szFile)
94.69 +{
94.70 + static const struct tagformats {const char* szExt; ePicFormat picformat;} formats[] =
94.71 + {
94.72 + {".tiff", pfTIFF },
94.73 + {".tif", pfTIFF },
94.74 + {".bmp", pfBMP },
94.75 + {".glcd", pfGLCD },
94.76 + {".pbm", pfPBM },
94.77 + {".ani", pfTUXBOX}
94.78 + };
94.79 + ePicFormat pf = pfUndefined;
94.80 +
94.81 + if (szFile)
94.82 + {
94.83 + for (int i = strlen(szFile) - 1; i >= 0; i--)
94.84 + {
94.85 + if (*(szFile+i) == '.' && strlen(szFile + i + 1))
94.86 + {
94.87 + for (unsigned int n = 0; n < sizeof(formats)/sizeof(*formats); n++)
94.88 + {
94.89 + if (!strcasecmp((szFile+i), formats[n].szExt))
94.90 + {
94.91 + return formats[n].picformat;
94.92 + }
94.93 + }
94.94 + }
94.95 + }
94.96 + }
94.97 + return pf;
94.98 +}
94.99 +
94.100 +GLCD::cImageFile * GetFileTranslator(ePicFormat Format)
94.101 +{
94.102 + switch (Format)
94.103 + {
94.104 + case pfGLCD:
94.105 + return new GLCD::cGLCDFile();
94.106 +
94.107 + case pfPBM:
94.108 + return new GLCD::cPBMFile();
94.109 +
94.110 + case pfBMP:
94.111 + return new cBMPFile();
94.112 +
94.113 + case pfTIFF:
94.114 + return new cTIFFFile();
94.115 +
94.116 + case pfTUXBOX:
94.117 + return new cTuxBoxFile();
94.118 +
94.119 + default:
94.120 + return NULL;
94.121 + }
94.122 +
94.123 +}
94.124 +
94.125 +int main(int argc, char *argv[]) {
94.126 + ePicFormat inFormat = pfUndefined;
94.127 + ePicFormat outFormat = pfUndefined;
94.128 + std::string inFile = "";
94.129 + std::string outFile = "";
94.130 + GLCD::cImage image;
94.131 + GLCD::cImage nextImage;
94.132 + GLCD::cImageFile * pInBitmap = NULL;
94.133 + GLCD::cImageFile * pOutBitmap = NULL;
94.134 + bool bError = false;
94.135 + bool bInvert = false;
94.136 + bool bDelay = false;
94.137 +
94.138 +
94.139 + static struct option long_options[] =
94.140 + {
94.141 + {"invert", no_argument, NULL, 'n'},
94.142 + {"infile", required_argument, NULL, 'i'},
94.143 + {"outfile", required_argument, NULL, 'o'},
94.144 + {"delay", required_argument, NULL, 'd'},
94.145 + { NULL}
94.146 + };
94.147 +
94.148 + int c, option_index = 0;
94.149 + while ((c=getopt_long(argc,argv,"ni:o:d:",long_options, &option_index))!=-1) {
94.150 + switch (c) {
94.151 + case 'n':
94.152 + bInvert = true;
94.153 + break;
94.154 +
94.155 + case 'i':
94.156 + inFile = optarg;
94.157 + break;
94.158 +
94.159 + case 'o':
94.160 + outFile = optarg;
94.161 + break;
94.162 +
94.163 + case 'd':
94.164 + delay = atoi(optarg);
94.165 + bDelay = true;
94.166 + if (delay < 10)
94.167 + {
94.168 + fprintf(stderr, "Warning: You have specify a to short delay, minimum are 10 ms\n");
94.169 + delay = 10;
94.170 + }
94.171 + break;
94.172 +
94.173 + default:
94.174 + return 1;
94.175 + }
94.176 + }
94.177 +
94.178 + if (inFile.length() == 0)
94.179 + {
94.180 + fprintf(stderr, "ERROR: You have to specify the infile (-i filename)\n");
94.181 + bError = true;
94.182 + }
94.183 +
94.184 + if (pfUndefined == (inFormat = getFormat(inFile.c_str())))
94.185 + {
94.186 + fprintf(stderr, "ERROR: You have to specify a correct extension for the %s\n", inFile.c_str());
94.187 + bError = true;
94.188 + }
94.189 +
94.190 + if (outFile.length() == 0)
94.191 + {
94.192 + fprintf(stderr, "ERROR: You have to specify the outfile (-o filename)\n");
94.193 + bError = true;
94.194 + }
94.195 +
94.196 + if (pfUndefined == (outFormat = getFormat(outFile.c_str())))
94.197 + {
94.198 + fprintf(stderr, "ERROR: You have to specify a correct extension for the %s \n", outFile.c_str());
94.199 + bError = true;
94.200 + }
94.201 +
94.202 + if (bError)
94.203 + {
94.204 + usage();
94.205 + return 1;
94.206 + }
94.207 +
94.208 +
94.209 + pInBitmap = GetFileTranslator(inFormat);
94.210 + if (!pInBitmap)
94.211 + return 2;
94.212 +
94.213 + pOutBitmap = GetFileTranslator(outFormat);
94.214 + if (!pOutBitmap)
94.215 + return 3;
94.216 +
94.217 + // Load Picture
94.218 + fprintf(stdout, "loading %s\n", inFile.c_str());
94.219 + bError = !pInBitmap->Load(image, inFile);
94.220 + if (!bError)
94.221 + {
94.222 + // Load more in files
94.223 + while (optind < argc && !bError)
94.224 + {
94.225 + inFile = argv[optind++];
94.226 + inFormat = getFormat(inFile.c_str());
94.227 + if (inFormat == pfUndefined)
94.228 + {
94.229 + fprintf(stderr, "ERROR: You have to specify a correct extension for the %s\n", inFile.c_str());
94.230 + bError = true;
94.231 + break;
94.232 + }
94.233 + pInBitmap = GetFileTranslator(inFormat);
94.234 + if (!pInBitmap)
94.235 + break;
94.236 +
94.237 + fprintf(stdout, "loading %s\n", inFile.c_str());
94.238 + if (pInBitmap->Load(nextImage, inFile))
94.239 + {
94.240 + uint16_t i;
94.241 + for (i = 0; i < nextImage.Count(); i++)
94.242 + {
94.243 + image.AddBitmap(new GLCD::cBitmap(*nextImage.GetBitmap(i)));
94.244 + }
94.245 + }
94.246 + }
94.247 + if (bDelay)
94.248 + image.SetDelay(delay);
94.249 + if (bInvert)
94.250 + {
94.251 + uint16_t i;
94.252 + for (i = 0; i < image.Count(); i++)
94.253 + {
94.254 + image.GetBitmap(i)->Invert();
94.255 + }
94.256 + }
94.257 + fprintf(stdout, "saving %s\n", outFile.c_str());
94.258 + bError = !pOutBitmap->Save(image, outFile);
94.259 + }
94.260 + if (bError) {
94.261 + return 4;
94.262 + }
94.263 +
94.264 + fprintf(stdout, "conversion compeleted successfully.\n\n");
94.265 +
94.266 + return 0;
94.267 +}
94.268 +
94.269 +void usage(void)
94.270 +{
94.271 + fprintf(stdout, "\n");
94.272 + fprintf(stdout, "%s v%s\n", prgname, VERSION);
94.273 + fprintf(stdout, "%s is a tool to convert images to a simple format (*.glcd)\n", prgname);
94.274 + fprintf(stdout, " that is used by the graphlcd plugin for VDR.\n\n");
94.275 + fprintf(stdout, " Usage: %s [-n] -i file[s...] -o outfile \n\n", prgname);
94.276 + fprintf(stdout, " -n --invert inverts the output (default: none)\n");
94.277 + fprintf(stdout, " -i --infile specifies the name of the input file[s]\n");
94.278 + fprintf(stdout, " -o --outfile specifies the name of the output file\n");
94.279 + fprintf(stdout, " -d --delay specifies the delay between multiple images [Default: %d ms] \n",delay);
94.280 + fprintf(stdout, "\n" );
94.281 + fprintf(stdout, " example: %s -i vdr-logo.bmp -o vdr-logo.glcd \n", prgname );
94.282 +}
95.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
95.2 +++ b/graphlcd-base/tools/convpic/formats.txt Thu Feb 07 13:03:18 2008 +0100
95.3 @@ -0,0 +1,32 @@
95.4 +Dateiformat von "Graphlcd-Logo"
95.5 +
95.6 +
95.7 +Einzelbild für LCD
95.8 +=================================
95.9 +
95.10 +HEADER
95.11 +Position Typ Name Bedeutung
95.12 +0x0000 char[4] magic - "GLCD"
95.13 +0x0004 word width - Breite der Bilder (LE)
95.14 +0x0006 word height - Höhe der Bilder (LE)
95.15 +0x0008 char[] data - Einzel-Bild
95.16 +
95.17 +DATEN
95.18 +char[height][width/8], pro Byte 8 nebeneinander liegende Pixel
95.19 +
95.20 +Animation für LCD
95.21 +=================================
95.22 +
95.23 +HEADER
95.24 +Position Typ Name Bedeutung
95.25 +0x0000 char[4] magic - "GLCA"
95.26 +0x0004 word width - Breite der Bilder (LE)
95.27 +0x0006 word height - Höhe der Bilder (LE)
95.28 +0x0008 word count - Anzahl der Bilder (LE)
95.29 +0x000a long delay - Wartezeit zwischen den Bildern (in ms; LE)
95.30 +0x0010 char[] data - Einzel-Bilder
95.31 +
95.32 +DATEN
95.33 +char[height][width/8], pro Byte 8 nebeneinander liegende Pixel (1 = Pixel gesetzt)
95.34 +
95.35 +LE = Little Endian byte order = wie bei intel ;)
96.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
96.2 +++ b/graphlcd-base/tools/convpic/tiff.c Thu Feb 07 13:03:18 2008 +0100
96.3 @@ -0,0 +1,201 @@
96.4 +/**
96.5 + * GraphLCD plugin for the Video Disk Recorder
96.6 + *
96.7 + * tiff.c - tiff logo class
96.8 + *
96.9 + * (c) 2004 Andreas Brachold <vdr04 AT deltab de>
96.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
96.11 + **/
96.12 +
96.13 +/***************************************************************************
96.14 + * *
96.15 + * This program is free software; you can redistribute it and/or modify *
96.16 + * it under the terms of the GNU General Public License as published by *
96.17 + * the Free Software Foundation; either version 2 of the License, or *
96.18 + * (at your option) any later version. *
96.19 + * *
96.20 + * This program is distributed in the hope that it will be useful, *
96.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
96.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
96.23 + * GNU General Public License for more details. *
96.24 + * *
96.25 + * You should have received a copy of the GNU General Public License *
96.26 + * along with this program; *
96.27 + * if not, write to the Free Software Foundation, Inc., *
96.28 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
96.29 + * *
96.30 + ***************************************************************************/
96.31 +
96.32 +#include <stdio.h>
96.33 +#include <string.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 "tiff.h"
96.41 +
96.42 +
96.43 +#pragma pack(1)
96.44 +typedef struct TIFFT{
96.45 + unsigned short tag;
96.46 + unsigned short type;
96.47 + unsigned long length;
96.48 + /* 1 = BYTE. 8-bit unsigned integer. */
96.49 + /* 2 = ASCII. 8-bit bytes that store ASCII codes; the last byte must be null. */
96.50 + /* 3 = SHORT. A 16-bit (2-byte) unsigned integer. */
96.51 + /* 4 = LONG. A 32-bit (4-byte) unsigned integer. */
96.52 + /* 5 = RATIONAL. Two LONGs: the first represents the numerator of a fraction, the second the denominator. */
96.53 + unsigned long off_val;
96.54 +} TIFFTAG;
96.55 +#pragma pack()
96.56 +
96.57 +#define GETANDCHECK { t=fgetc(fIN);if(t==EOF) {fclose(fIN);return false;};}
96.58 +
96.59 +cTIFFFile::cTIFFFile()
96.60 +{
96.61 +}
96.62 +
96.63 +cTIFFFile::~cTIFFFile()
96.64 +{
96.65 +}
96.66 +
96.67 +bool cTIFFFile::Load(GLCD::cImage & image, const std::string & fileName)
96.68 +{
96.69 + FILE *fIN;
96.70 + TIFFTAG tifftag;
96.71 + unsigned int tiff_header, tiff_anztags, tiff_data;
96.72 + unsigned char cl,ch,y,i;
96.73 + unsigned char height, width, strip, invert;
96.74 + unsigned char fLittleEndian=0;
96.75 + int j;
96.76 + int t;
96.77 + unsigned char *bitmap = NULL;
96.78 + bool bInvert = false;
96.79 +
96.80 + if (fileName.length() > 0)
96.81 + {
96.82 + fIN = fopen(fileName.c_str(), "rb");
96.83 + if (fIN)
96.84 + {
96.85 + // isyslog("graphlcd plugin: try to load logo %s.", szFileName);
96.86 + if (fseek(fIN, 0, SEEK_SET)==EOF)
96.87 + {
96.88 + fclose(fIN);
96.89 + return false;
96.90 + }
96.91 + GETANDCHECK; cl=(unsigned char)t;
96.92 + GETANDCHECK; ch=(unsigned char)t;
96.93 + if ((cl==0x49) && (ch==0x49))
96.94 + {
96.95 + fLittleEndian=1;
96.96 + }
96.97 +
96.98 + if (fseek(fIN, 4, SEEK_SET)==EOF)
96.99 + {
96.100 + fclose(fIN);
96.101 + return false;
96.102 + }
96.103 + GETANDCHECK; cl=(unsigned char)t;
96.104 + GETANDCHECK; ch=(unsigned char)t;
96.105 + tiff_header = cl+256*ch;
96.106 + //printf("tiff_header:%d %x\n", tiff_header, tiff_header);
96.107 +
96.108 + if (fseek(fIN, tiff_header, SEEK_SET)==EOF)
96.109 + {
96.110 + fclose(fIN);
96.111 + return false;
96.112 + }
96.113 +
96.114 + GETANDCHECK; cl=(unsigned char)t;
96.115 + GETANDCHECK; ch=(unsigned char)t;
96.116 + tiff_anztags = cl+256*ch;
96.117 + //printf("tiff_anztags:%d %x\n", tiff_anztags, tiff_anztags);
96.118 +
96.119 + height=0;
96.120 + width=0;
96.121 + strip=0;
96.122 + invert=0;
96.123 + for (i=0; (i<tiff_anztags)&&(!height||!width||!strip||!invert); i++)
96.124 + {
96.125 + if (fread(&tifftag, sizeof(tifftag), 1, fIN)!=1)
96.126 + {
96.127 + fclose(fIN);
96.128 + return false;
96.129 + }
96.130 + if (tifftag.tag==0x0100) width=tifftag.off_val;
96.131 + if (tifftag.tag==0x0101) height=tifftag.off_val;
96.132 + if (tifftag.tag==0x0111) strip=tifftag.off_val;
96.133 + if (tifftag.tag==0x0106) invert=tifftag.off_val+1;
96.134 + //printf("tag%d: %d %d %ld %ld\n", i,tifftag.tag, tifftag.type, tifftag.length, tifftag.off_val );
96.135 + }
96.136 +
96.137 + if (fseek(fIN,strip, SEEK_SET)==EOF)
96.138 + {
96.139 + fclose(fIN);
96.140 + return false;
96.141 + }
96.142 + GETANDCHECK; cl=(unsigned char)t;
96.143 + GETANDCHECK; ch=(unsigned char)t;
96.144 + tiff_data = cl+256*ch;
96.145 + //printf("tiff_data:%d %x\n", tiff_data, tiff_data);
96.146 +
96.147 + if (fseek(fIN, tiff_data, SEEK_SET)==EOF)
96.148 + {
96.149 + fclose(fIN);
96.150 + return false;
96.151 + }
96.152 +
96.153 +
96.154 + image.Clear();
96.155 + image.SetWidth(width);
96.156 + image.SetHeight(height);
96.157 + image.SetDelay(100);
96.158 + bitmap = new unsigned char[height * ((width + 7) / 8)];
96.159 + if (bitmap)
96.160 + {
96.161 + if (fread(bitmap, height*((width+7)/8), 1, fIN)!=1)
96.162 + {
96.163 + delete [] bitmap;
96.164 + fclose(fIN);
96.165 + image.Clear();
96.166 + return false;
96.167 + }
96.168 +
96.169 + if (invert-1==1) bInvert = !bInvert; // 'Black is zero'
96.170 + if (bInvert)
96.171 + {
96.172 + for (j=0; j < height * ((width+7)/8); j++)
96.173 + {
96.174 + (*(bitmap+j)) = (*(bitmap+j))^0xff;
96.175 + }
96.176 + }
96.177 +
96.178 + // cut the rest of the line
96.179 + if (width%8)
96.180 + {
96.181 + for (y=1; y<=height; y++) {
96.182 + j=y*((width+7)/8)-1;
96.183 + (*(bitmap+j)) = ((*(bitmap+j))>>(8-width%8))<<(8-width%8);
96.184 + }
96.185 + }
96.186 + image.AddBitmap(new GLCD::cBitmap(width, height, bitmap));
96.187 + }
96.188 + else
96.189 + {
96.190 + fprintf(stderr, "ERROR: cannot allocate memory\n");
96.191 + }
96.192 + fclose(fIN);
96.193 + }
96.194 + else
96.195 + {
96.196 + fprintf(stderr, "ERROR: cannot open picture %s\n", fileName.c_str());
96.197 + }
96.198 + }
96.199 + else
96.200 + {
96.201 + fprintf(stderr, "ERROR: no szFileName given!\n");
96.202 + }
96.203 + return true;
96.204 +}
97.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
97.2 +++ b/graphlcd-base/tools/convpic/tiff.h Thu Feb 07 13:03:18 2008 +0100
97.3 @@ -0,0 +1,42 @@
97.4 +/**
97.5 + * GraphLCD plugin for the Video Disk Recorder
97.6 + *
97.7 + * tiff.h - tiff logo class
97.8 + *
97.9 + * (c) 2004 Andreas Brachold <vdr04 AT deltab de>
97.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online de>
97.11 + **/
97.12 +
97.13 +/***************************************************************************
97.14 + * *
97.15 + * This program is free software; you can redistribute it and/or modify *
97.16 + * it under the terms of the GNU General Public License as published by *
97.17 + * the Free Software Foundation; either version 2 of the License, or *
97.18 + * (at your option) any later version. *
97.19 + * *
97.20 + * This program is distributed in the hope that it will be useful, *
97.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
97.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
97.23 + * GNU General Public License for more details. *
97.24 + * *
97.25 + * You should have received a copy of the GNU General Public License *
97.26 + * along with this program; *
97.27 + * if not, write to the Free Software Foundation, Inc., *
97.28 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
97.29 + * *
97.30 + ***************************************************************************/
97.31 +
97.32 +#ifndef _TIFF_H_
97.33 +#define _TIFF_H_
97.34 +
97.35 +#include <glcdgraphics/imagefile.h>
97.36 +
97.37 +class cTIFFFile : public GLCD::cImageFile
97.38 +{
97.39 +public:
97.40 + cTIFFFile();
97.41 + virtual ~cTIFFFile();
97.42 + virtual bool Load(GLCD::cImage & image, const std::string & fileName);
97.43 +};
97.44 +
97.45 +#endif
98.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
98.2 +++ b/graphlcd-base/tools/convpic/tuxbox.c Thu Feb 07 13:03:18 2008 +0100
98.3 @@ -0,0 +1,280 @@
98.4 +/**
98.5 + * GraphLCD plugin for the Video Disk Recorder
98.6 + *
98.7 + * tuxbox.c - tuxbox logo class
98.8 + *
98.9 + * (c) 2004 Andreas Brachold <vdr04 AT deltab de>
98.10 + **/
98.11 +
98.12 +/***************************************************************************
98.13 + * *
98.14 + * This program is free software; you can redistribute it and/or modify *
98.15 + * it under the terms of the GNU General Public License as published by *
98.16 + * the Free Software Foundation; either version 2 of the License, or *
98.17 + * (at your option) any later version. *
98.18 + * *
98.19 + * This program is distributed in the hope that it will be useful, *
98.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
98.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
98.22 + * GNU General Public License for more details. *
98.23 + * *
98.24 + * You should have received a copy of the GNU General Public License *
98.25 + * along with this program; *
98.26 + * if not, write to the Free Software Foundation, Inc., *
98.27 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
98.28 + * *
98.29 + ***************************************************************************/
98.30 +
98.31 +#include <stdio.h>
98.32 +#include <string.h>
98.33 +#include <netinet/in.h>
98.34 +
98.35 +#include <string>
98.36 +
98.37 +#include <glcdgraphics/bitmap.h>
98.38 +#include <glcdgraphics/image.h>
98.39 +
98.40 +#include "tuxbox.h"
98.41 +
98.42 +#pragma pack(1)
98.43 +struct ani_header {
98.44 + unsigned char magic[4]; // = "LCDA"
98.45 + unsigned short format; // Format
98.46 + unsigned short width; // Breite
98.47 + unsigned short height; // Höhe
98.48 + unsigned short count; // Anzahl Einzelbilder
98.49 + unsigned long delay; // µs zwischen Einzelbildern
98.50 +};
98.51 +#pragma pack()
98.52 +
98.53 +cTuxBoxFile::cTuxBoxFile()
98.54 +{
98.55 +}
98.56 +
98.57 +cTuxBoxFile::~cTuxBoxFile()
98.58 +{
98.59 +}
98.60 +
98.61 +bool cTuxBoxFile::Load(GLCD::cImage & image, const std::string & fileName)
98.62 +{
98.63 + bool ret = false;
98.64 + FILE * fIN;
98.65 + long fileLen;
98.66 + struct ani_header header;
98.67 + bool bInvert = false;
98.68 +
98.69 + fIN = fopen(fileName.c_str(), "rb");
98.70 + if (fIN)
98.71 + {
98.72 + // get len of file
98.73 + if (fseek(fIN, 0, SEEK_END))
98.74 + {
98.75 + fclose(fIN);
98.76 + return false;
98.77 + }
98.78 + fileLen = ftell(fIN);
98.79 +
98.80 + // rewind and get Header
98.81 + if (fseek(fIN, 0, SEEK_SET))
98.82 + {
98.83 + fclose(fIN);
98.84 + return false;
98.85 + }
98.86 +
98.87 + // Read header
98.88 + if (fread(&header, sizeof(header), 1, fIN) != 1)
98.89 + {
98.90 + fclose(fIN);
98.91 + return false;
98.92 + }
98.93 +
98.94 + image.Clear();
98.95 + image.SetWidth(ntohs(header.width));
98.96 + image.SetHeight(ntohs(header.height));
98.97 + image.SetDelay(ntohl(header.delay) / 1000);
98.98 +
98.99 + // check Header
98.100 + if (strncmp((const char*)header.magic, "LCDA", sizeof(header.magic)) ||
98.101 + !image.Width() || !image.Height() || ntohs(header.format) != 0)
98.102 + {
98.103 + fprintf(stderr, "ERROR: load %s failed, wrong header.\n", fileName.c_str());
98.104 + fclose(fIN);
98.105 + return false;
98.106 + }
98.107 +
98.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);
98.109 +
98.110 + // check file length
98.111 + if (!ntohs(header.count)
98.112 + || (fileLen != (long) ( (ntohs(header.count) * (image.Width() * ((image.Height() + 7) / 8))) + sizeof(header))))
98.113 + {
98.114 + fprintf(stderr, "ERROR: load %s failed, wrong size.\n", fileName.c_str());
98.115 + fclose(fIN);
98.116 + return false;
98.117 + }
98.118 + // Set minimal limit for next image
98.119 + if (image.Delay() < 10)
98.120 + image.SetDelay(10);
98.121 + for (unsigned int n=0;n<ntohs(header.count);++n)
98.122 + {
98.123 + ret = false;
98.124 + unsigned int nBmpSize = image.Height() * ((image.Width() + 7) / 8);
98.125 + unsigned char *bitmap = new unsigned char[nBmpSize];
98.126 + if (!bitmap)
98.127 + {
98.128 + fprintf(stderr, "ERROR: malloc failed.");
98.129 + break;
98.130 + }
98.131 + unsigned int nAniSize = image.Width() * ((image.Height() + 7) / 8);
98.132 + unsigned char *pAni = new unsigned char[nAniSize];
98.133 + if (!pAni)
98.134 + {
98.135 + delete[] bitmap;
98.136 + fprintf(stderr, "ERROR: malloc failed.");
98.137 + break;
98.138 + }
98.139 +
98.140 + if (1 != fread(pAni, nAniSize, 1, fIN))
98.141 + {
98.142 + fprintf(stderr,"ERROR: Cannot read filedata: %s\n", fileName.c_str());
98.143 + delete[] bitmap;
98.144 + delete[] pAni;
98.145 + break;
98.146 + }
98.147 +
98.148 + vert2horz(pAni,bitmap, image.Width(), image.Height());
98.149 + delete[] pAni;
98.150 +
98.151 + if (bInvert)
98.152 + for (unsigned int i=0;i<nBmpSize;++i)
98.153 + bitmap[i] ^= 0xFF;
98.154 +
98.155 + image.AddBitmap(new GLCD::cBitmap(image.Width(), image.Height(), bitmap));
98.156 + ret = true;
98.157 + }
98.158 + fclose(fIN);
98.159 + if (!ret)
98.160 + image.Clear();
98.161 + }
98.162 + return ret;
98.163 +}
98.164 +
98.165 +
98.166 +bool cTuxBoxFile::Save(GLCD::cImage & image, const std::string & fileName)
98.167 +{
98.168 + FILE * fOut;
98.169 + struct ani_header header;
98.170 + bool bRet = false;
98.171 +
98.172 + if (image.Count() > 0
98.173 + && image.Width()
98.174 + && image.Height())
98.175 + {
98.176 + memcpy(header.magic, "LCDA", 4);
98.177 + header.format = htons(0);
98.178 + header.width = htons(image.Width());
98.179 + header.height = htons(image.Height());
98.180 + header.count = htons(image.Count());
98.181 + header.delay = htonl(image.Delay() * 1000);
98.182 +
98.183 +
98.184 + if (image.Width() != 120 || image.Height() != 64)
98.185 + {
98.186 + fprintf(stderr,"WARNING: Maybe wrong image dimension (for all I know is 120x64 wanted) %s\n", fileName.c_str());
98.187 + }
98.188 +
98.189 + fOut = fopen(fileName.c_str(), "wb");
98.190 + if (!fOut) {
98.191 + fprintf(stderr,"ERROR: Cannot create file: %s\n", fileName.c_str());
98.192 + return false;
98.193 + }
98.194 +
98.195 + if (1 != fwrite(&header, sizeof(header), 1, fOut))
98.196 + {
98.197 + fprintf(stderr,"ERROR: Cannot write fileheader: %s\n", fileName.c_str());
98.198 + fclose(fOut);
98.199 + return false;
98.200 + }
98.201 +
98.202 + for (unsigned int n = 0; n < image.Count(); n++)
98.203 + {
98.204 + bRet = false;
98.205 + unsigned int nAniSize = image.Width() * ((image.Height() + 7) / 8);
98.206 + unsigned char *pAni = new unsigned char[nAniSize];
98.207 + if (!pAni)
98.208 + {
98.209 + fprintf(stderr, "ERROR: malloc failed.");
98.210 + break;
98.211 + }
98.212 + horz2vert(image.GetBitmap(n)->Data(), pAni, image.Width(), image.Height());
98.213 +
98.214 + if (1 != fwrite(pAni, nAniSize, 1, fOut))
98.215 + {
98.216 + delete [] pAni;
98.217 + fprintf(stderr,"ERROR: Cannot write filedata: %s\n", fileName.c_str());
98.218 + break;
98.219 + }
98.220 + delete [] pAni;
98.221 + bRet = true;
98.222 + }
98.223 +
98.224 + fclose(fOut);
98.225 + }
98.226 + return bRet;
98.227 +}
98.228 +
98.229 +/** Translate memory alignment from vertical to horizontal
98.230 +rotate from {Byte} to {Byte}
98.231 +{o}[o][o][o][o][o][o][o] => { oooooooo }
98.232 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
98.233 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
98.234 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
98.235 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
98.236 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
98.237 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]
98.238 +{o}[o][o][o][o][o][o][o] => [ oooooooo ]*/
98.239 +void cTuxBoxFile::vert2horz(const unsigned char* source, unsigned char* dest, int width, int height) {
98.240 + int x, y, off;
98.241 + memset(dest,0,height*((width+7)/8));
98.242 +
98.243 + for (y=0; y<height; ++y)
98.244 + {
98.245 + for (x=0; x<width; ++x)
98.246 + {
98.247 + off = x + ((y/8) * width);
98.248 + if (source[off] & (0x1 << (y % 8)))
98.249 + {
98.250 + off = (x / 8) + (y * ((width+7)/8));
98.251 + dest[off] |= (unsigned char)(0x80 >> (x % 8));
98.252 + }
98.253 + }
98.254 + }
98.255 +}
98.256 +
98.257 +/** Translate memory alignment from horizontal to vertical (rotate byte)
98.258 +rotate from {Byte} to {Byte}
98.259 +{ oooooooo } => {o}[o][o][o][o][o][o][o]
98.260 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
98.261 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
98.262 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
98.263 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
98.264 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
98.265 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]
98.266 +[ oooooooo ] => {o}[o][o][o][o][o][o][o]*/
98.267 +void cTuxBoxFile::horz2vert(const unsigned char* source, unsigned char* dest, int width, int height) {
98.268 + int x, y, off;
98.269 + memset(dest,0,width*((height+7)/8));
98.270 +
98.271 + for (y=0; y<height; ++y)
98.272 + {
98.273 + for (x=0; x<width; ++x)
98.274 + {
98.275 + off = (x / 8) + ((y) * ((width+7)/8));
98.276 + if (source[off] & (0x80 >> (x % 8)))
98.277 + {
98.278 + off = x + ((y/8) * width);
98.279 + dest[off] |= (unsigned char)(0x1 << (y % 8));
98.280 + }
98.281 + }
98.282 + }
98.283 +}
99.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
99.2 +++ b/graphlcd-base/tools/convpic/tuxbox.h Thu Feb 07 13:03:18 2008 +0100
99.3 @@ -0,0 +1,44 @@
99.4 +/**
99.5 + * GraphLCD plugin for the Video Disk Recorder
99.6 + *
99.7 + * tuxbox.h - tuxbox logo class
99.8 + *
99.9 + * (c) 2004 Andreas Brachold <vdr04 AT deltab de>
99.10 + **/
99.11 +
99.12 +/***************************************************************************
99.13 + * *
99.14 + * This program is free software; you can redistribute it and/or modify *
99.15 + * it under the terms of the GNU General Public License as published by *
99.16 + * the Free Software Foundation; either version 2 of the License, or *
99.17 + * (at your option) any later version. *
99.18 + * *
99.19 + * This program is distributed in the hope that it will be useful, *
99.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of *
99.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
99.22 + * GNU General Public License for more details. *
99.23 + * *
99.24 + * You should have received a copy of the GNU General Public License *
99.25 + * along with this program; *
99.26 + * if not, write to the Free Software Foundation, Inc., *
99.27 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
99.28 + * *
99.29 + ***************************************************************************/
99.30 +#ifndef _TUXBOX_H_
99.31 +#define _TUXBOX_H_
99.32 +
99.33 +#include <glcdgraphics/imagefile.h>
99.34 +
99.35 +class cTuxBoxFile : public GLCD::cImageFile
99.36 +{
99.37 +private:
99.38 + void vert2horz(const unsigned char* source, unsigned char* dest, int width, int height);
99.39 + void horz2vert(const unsigned char* source, unsigned char* dest, int width, int height);
99.40 +public:
99.41 + cTuxBoxFile();
99.42 + virtual ~cTuxBoxFile();
99.43 + virtual bool Load(GLCD::cImage & image, const std::string & fileName);
99.44 + virtual bool Save(GLCD::cImage & image, const std::string & fileName);
99.45 +};
99.46 +
99.47 +#endif
100.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
100.2 +++ b/graphlcd-base/tools/crtfont/Makefile Thu Feb 07 13:03:18 2008 +0100
100.3 @@ -0,0 +1,45 @@
100.4 +#
100.5 +# Makefile for the GraphLCD tool crtfont
100.6 +#
100.7 +
100.8 +-include ../../Make.config
100.9 +
100.10 +PRGNAME = crtfont
100.11 +
100.12 +OBJS = crtfont.o
100.13 +
100.14 +INCLUDES += -I../../
100.15 +LIBDIRS += -L../../glcdgraphics/
100.16 +
100.17 +all: $(PRGNAME)
100.18 +.PHONY: all
100.19 +
100.20 +# Implicit rules:
100.21 +
100.22 +%.o: %.c
100.23 + $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
100.24 +
100.25 +# Dependencies:
100.26 +
100.27 +MAKEDEP = $(CXX) -MM -MG
100.28 +DEPFILE = .dependencies
100.29 +$(DEPFILE): Makefile
100.30 + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
100.31 +
100.32 +-include $(DEPFILE)
100.33 +
100.34 +# The main program:
100.35 +
100.36 +$(PRGNAME): $(OBJS)
100.37 + $(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBDIRS) -lglcdgraphics -lstdc++ -o $(PRGNAME)
100.38 +
100.39 +install: $(PRGNAME)
100.40 + install -d $(BINDIR)
100.41 + install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
100.42 +
100.43 +uninstall:
100.44 + rm -f $(BINDIR)/$(PRGNAME)
100.45 +
100.46 +clean:
100.47 + @-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
100.48 +
101.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
101.2 +++ b/graphlcd-base/tools/crtfont/crtfont.c Thu Feb 07 13:03:18 2008 +0100
101.3 @@ -0,0 +1,305 @@
101.4 +/*
101.5 + * GraphLCD tool crtfont
101.6 + *
101.7 + * crtfont.c - a tool to create *.fnt files for use with the GraphLCD
101.8 + * graphics library
101.9 + *
101.10 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
101.11 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
101.12 + *
101.13 + * This file is released under the GNU General Public License. Refer
101.14 + * to the COPYING file distributed with this package.
101.15 + *
101.16 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
101.17 + */
101.18 +
101.19 +#include <getopt.h>
101.20 +#include <stdint.h>
101.21 +#include <stdio.h>
101.22 +#include <stdlib.h>
101.23 +#include <string.h>
101.24 +#include <glcdgraphics/bitmap.h>
101.25 +#include <glcdgraphics/font.h>
101.26 +
101.27 +static const char *prgname = "crtfont";
101.28 +static const char *version = "0.1.6";
101.29 +
101.30 +const int kMaxLineLength = 1024;
101.31 +
101.32 +enum ePicFormat
101.33 +{
101.34 + undefined,
101.35 + PBM
101.36 +};
101.37 +
101.38 +
101.39 +void usage(void);
101.40 +
101.41 +char * trimleft(char * str)
101.42 +{
101.43 + char * s = str;
101.44 + while (*s == ' ' || *s == '\t')
101.45 + s++;
101.46 + strcpy(str, s);
101.47 + return str;
101.48 +}
101.49 +
101.50 +char * trimright(char * str)
101.51 +{
101.52 + char * s = str + strlen(str) - 1;
101.53 + while (s >= str && (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r'))
101.54 + *s-- = 0;
101.55 + return str;
101.56 +}
101.57 +
101.58 +char * trim(char * str)
101.59 +{
101.60 + return trimleft(trimright(str));
101.61 +}
101.62 +
101.63 +
101.64 +int main(int argc, char *argv[])
101.65 +{
101.66 + ePicFormat picFormat = undefined;
101.67 + GLCD::cFont font;
101.68 + char * picName = NULL;
101.69 + char * descName = NULL;
101.70 + char * fontName = NULL;
101.71 + FILE * descFile;
101.72 + bool error = false;
101.73 + GLCD::cBitmap * bitmap = NULL;
101.74 + GLCD::cBitmap * tmpBitmap = NULL;
101.75 + GLCD::cBitmap * charBitmap = NULL;
101.76 + char line[kMaxLineLength];
101.77 + int l = 0;
101.78 + char * token;
101.79 + int startOffset, endOffset;
101.80 + int spaceWidth;
101.81 + int version;
101.82 + char * ptr;
101.83 +
101.84 + static struct option long_options[] =
101.85 + {
101.86 + { "format", required_argument, NULL, 'f'},
101.87 + { "bmpfile", required_argument, NULL, 'b'},
101.88 + { "descfile", required_argument, NULL, 'd'},
101.89 + { "outfile", required_argument, NULL, 'o'},
101.90 + { NULL}
101.91 + };
101.92 +
101.93 + int c, option_index = 0;
101.94 + while ((c = getopt_long(argc, argv, "f:b:d:o:", long_options, &option_index)) != -1)
101.95 + {
101.96 + switch (c)
101.97 + {
101.98 + case 'f':
101.99 + if (strcasecmp(optarg, "PBM") == 0)
101.100 + picFormat = PBM;
101.101 + break;
101.102 +
101.103 + case 'b':
101.104 + picName = strdup(optarg);
101.105 + break;
101.106 +
101.107 + case 'd':
101.108 + descName = strdup(optarg);
101.109 + break;
101.110 +
101.111 + case 'o':
101.112 + fontName = strdup(optarg);
101.113 + break;
101.114 +
101.115 + default:
101.116 + return 1;
101.117 + }
101.118 + }
101.119 +
101.120 + if (picFormat == undefined)
101.121 + {
101.122 + fprintf(stderr, "ERROR: You have to specify the format (-f <format>)\n");
101.123 + error = true;
101.124 + }
101.125 + if (!picName)
101.126 + {
101.127 + fprintf(stderr, "ERROR: You have to specify the bmpfile (-b bmpfile)\n");
101.128 + error = true;
101.129 + }
101.130 + if (!descName)
101.131 + {
101.132 + fprintf(stderr, "ERROR: You have to specify the descfile (-d descfile)\n");
101.133 + error = true;
101.134 + }
101.135 + if (!fontName)
101.136 + {
101.137 + fprintf(stderr, "ERROR: You have to specify the outfile (-o outfile)\n");
101.138 + error = true;
101.139 + }
101.140 +
101.141 + if (error)
101.142 + {
101.143 + usage();
101.144 + return 1;
101.145 + }
101.146 +
101.147 + descFile = fopen(descName,"r");
101.148 + if (!descFile)
101.149 + {
101.150 + fprintf(stderr, "Cannot open file: %s\n",descName);
101.151 + return 2;
101.152 + }
101.153 +
101.154 + // Load Picture
101.155 + switch (picFormat)
101.156 + {
101.157 + case PBM:
101.158 + bitmap = new GLCD::cBitmap(0, 0);
101.159 + bitmap->LoadPBM(picName);
101.160 + if (!bitmap)
101.161 + {
101.162 + fprintf(stderr, "Cannot open file: %s\n",picName);
101.163 + return 2;
101.164 + }
101.165 + break;
101.166 +
101.167 + default:
101.168 + return 2;
101.169 + }
101.170 +
101.171 + if (!bitmap)
101.172 + return 3;
101.173 +
101.174 + spaceWidth = 0;
101.175 +
101.176 + version = 0;
101.177 + fgets(line, sizeof(line), descFile);
101.178 + trim(line);
101.179 + if (strstr(line, "version") != NULL)
101.180 + {
101.181 + ptr = strstr(line, ":");
101.182 + version = atoi(ptr + 1);
101.183 + }
101.184 + if (version != 1)
101.185 + {
101.186 + fprintf(stderr, "Wrong description file format version (found %d, expected 1)!\n", version);
101.187 + return 2;
101.188 + }
101.189 + while (!feof(descFile))
101.190 + {
101.191 + fgets(line, sizeof(line), descFile);
101.192 + trim(line);
101.193 + if (strstr(line, "fontheight") != NULL)
101.194 + {
101.195 + ptr = strstr(line, ":");
101.196 + font.SetTotalHeight(atoi(ptr + 1));
101.197 + }
101.198 + else if (strstr(line, "fontascent") != NULL)
101.199 + {
101.200 + ptr = strstr(line, ":");
101.201 + font.SetTotalAscent(atoi(ptr + 1));
101.202 + }
101.203 + else if (strstr(line, "lineheight") != NULL)
101.204 + {
101.205 + ptr = strstr(line, ":");
101.206 + font.SetLineHeight(atoi(ptr + 1));
101.207 + }
101.208 + else if (strstr(line, "spacebetween") != NULL)
101.209 + {
101.210 + ptr = strstr(line, ":");
101.211 + font.SetSpaceBetween(atoi(ptr + 1));
101.212 + }
101.213 + else if (strstr(line, "spacewidth") != NULL)
101.214 + {
101.215 + ptr = strstr(line, ":");
101.216 + spaceWidth = atoi(ptr + 1);
101.217 + }
101.218 + else
101.219 + {
101.220 + token = strtok(line, " ");
101.221 + if (token)
101.222 + {
101.223 + startOffset = atoi(token);
101.224 +
101.225 + // get character
101.226 + token = strtok(NULL, " ");
101.227 + while (token)
101.228 + {
101.229 + uint16_t character;
101.230 + if (strlen(token) == 1)
101.231 + character = (uint8_t) token[0];
101.232 + else
101.233 + character = atoi(token);
101.234 +
101.235 + // get EndOffset
101.236 + token = strtok(NULL, " ");
101.237 + endOffset = atoi(token);
101.238 + tmpBitmap = bitmap->SubBitmap(startOffset, l * font.TotalHeight(), endOffset - 1, (l + 1) * font.TotalHeight() - 1);
101.239 + if (spaceWidth > 0)
101.240 + {
101.241 + // calculate width of this character
101.242 + int x;
101.243 + int y;
101.244 + int left = 255;
101.245 + int right = 0;
101.246 + for (y = 0; y < tmpBitmap->Height(); y++)
101.247 + {
101.248 + for (x = 0; x < tmpBitmap->Width(); x++)
101.249 + {
101.250 + if (tmpBitmap->GetPixel(x, y))
101.251 + break;
101.252 + }
101.253 + if (x < tmpBitmap->Width() && x < left)
101.254 + left = x;
101.255 + for (x = tmpBitmap->Width() - 1; x >= 0; x--)
101.256 + {
101.257 + if (tmpBitmap->GetPixel(x, y))
101.258 + break;
101.259 + }
101.260 + if (x >= 0 && x > right)
101.261 + right = x;
101.262 + }
101.263 + if (left > right)
101.264 + {
101.265 + left = 0;
101.266 + right = spaceWidth - 1;
101.267 + }
101.268 + charBitmap = tmpBitmap->SubBitmap(left, 0, right, font.TotalHeight() - 1);
101.269 + font.SetCharacter(character, charBitmap);
101.270 + delete tmpBitmap;
101.271 + }
101.272 + else
101.273 + {
101.274 + font.SetCharacter(character, tmpBitmap);
101.275 + }
101.276 + startOffset = endOffset;
101.277 +
101.278 + // get next character
101.279 + token = strtok(NULL, " ");
101.280 + }
101.281 + }
101.282 + l++;
101.283 + }
101.284 + }
101.285 + fclose(descFile);
101.286 + delete bitmap;
101.287 +
101.288 + if (font.SaveFNT(fontName))
101.289 + fprintf(stdout,"Font '%s' created successfully\n", fontName);
101.290 +
101.291 + return 0;
101.292 +}
101.293 +
101.294 +void usage(void)
101.295 +{
101.296 + fprintf(stdout, "\n");
101.297 + fprintf(stdout, "%s v%s\n", prgname, version);
101.298 + fprintf(stdout, "%s is a tool to create *.fnt files that are used by the\n", prgname);
101.299 + fprintf(stdout, " graphlcd plugin for VDR.\n\n");
101.300 + fprintf(stdout, " Usage: %s -f <format> -b bmpfile -d descfile -o outfile\n\n", prgname);
101.301 + fprintf(stdout, " -f --format specifies the format of the bitmap. Possible values are:\n");
101.302 + fprintf(stdout, " PBM : file is an binary PBM file\n" );
101.303 + fprintf(stdout, " -b --bmpfile specifies the name of the bitmap file (*.pbm)\n");
101.304 + fprintf(stdout, " -d --descfile specifies the name of the description file (*.desc)\n");
101.305 + fprintf(stdout, " -o --outfile specifies the name of the output file (*.fnt)\n");
101.306 + fprintf(stdout, "\n" );
101.307 + fprintf(stdout, " example: %s -f PBM -b f12.pbm -d f12.desc -o f12.fnt\n", prgname);
101.308 +}
102.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
102.2 +++ b/graphlcd-base/tools/genfont/Makefile Thu Feb 07 13:03:18 2008 +0100
102.3 @@ -0,0 +1,48 @@
102.4 +#
102.5 +# Makefile for the GraphLCD tool crtfont
102.6 +#
102.7 +
102.8 +-include ../../Make.config
102.9 +
102.10 +PRGNAME = genfont
102.11 +
102.12 +OBJS = genfont.o
102.13 +
102.14 +INCLUDES += -I../../
102.15 +INCLUDES += `freetype-config --cflags`
102.16 +
102.17 +LIBDIRS += -L../../glcdgraphics/
102.18 +LIBS += `freetype-config --libs`
102.19 +
102.20 +all: $(PRGNAME)
102.21 +.PHONY: all
102.22 +
102.23 +# Implicit rules:
102.24 +
102.25 +%.o: %.c
102.26 + $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
102.27 +
102.28 +# Dependencies:
102.29 +
102.30 +MAKEDEP = $(CXX) -MM -MG
102.31 +DEPFILE = .dependencies
102.32 +$(DEPFILE): Makefile
102.33 + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
102.34 +
102.35 +-include $(DEPFILE)
102.36 +
102.37 +# The main program:
102.38 +
102.39 +$(PRGNAME): $(OBJS)
102.40 + $(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBDIRS) $(LIBS) -lglcdgraphics -lstdc++ -o $(PRGNAME)
102.41 +
102.42 +install: $(PRGNAME)
102.43 + install -d $(BINDIR)
102.44 + install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
102.45 +
102.46 +uninstall:
102.47 + rm -f $(BINDIR)/$(PRGNAME)
102.48 +
102.49 +clean:
102.50 + @-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
102.51 +
103.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
103.2 +++ b/graphlcd-base/tools/genfont/genfont.c Thu Feb 07 13:03:18 2008 +0100
103.3 @@ -0,0 +1,167 @@
103.4 +/*
103.5 + * GraphLCD tool genfont
103.6 + *
103.7 + * genfont.c - a tool to create *.fnt files for use with the GraphLCD
103.8 + * graphics library
103.9 + *
103.10 + * This file is released under the GNU General Public License. Refer
103.11 + * to the COPYING file distributed with this package.
103.12 + *
103.13 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
103.14 + */
103.15 +
103.16 +#include <getopt.h>
103.17 +#include <stdio.h>
103.18 +#include <stdlib.h>
103.19 +#include <string.h>
103.20 +
103.21 +#include <glcdgraphics/bitmap.h>
103.22 +#include <glcdgraphics/font.h>
103.23 +
103.24 +static const char *prgname = "genfont";
103.25 +static const char *version = "0.0.2";
103.26 +
103.27 +void usage(void)
103.28 +{
103.29 + fprintf(stdout, "\n");
103.30 + fprintf(stdout, "%s v%s\n", prgname, version);
103.31 + fprintf(stdout, "%s is a tool to create *.fnt files that are used by the\n", prgname);
103.32 + fprintf(stdout, " graphlcd plugin for VDR.\n\n");
103.33 + fprintf(stdout, " Usage: %s -f <format> -i infile -o outfile -s size\n\n", prgname);
103.34 + fprintf(stdout, " -f --format specifies the format of the output files:\n");
103.35 + fprintf(stdout, " 0 - fnt (default)\n");
103.36 + fprintf(stdout, " 1 - pbm & desc\n");
103.37 + fprintf(stdout, " -i --input specifies the name of the input font file (*.ttf)\n");
103.38 + fprintf(stdout, " -o --output specifies the base name of the output files\n");
103.39 + fprintf(stdout, " -s --size font size of the generated font file\n");
103.40 + fprintf(stdout, "\n" );
103.41 + fprintf(stdout, " example: %s -i verdana.ttf -o verdana20 -s 20\n", prgname);
103.42 + fprintf(stdout, " %s -f 1 -i verdana.ttf -o verdana20 -s 20\n", prgname);
103.43 +}
103.44 +
103.45 +
103.46 +int main(int argc, char *argv[])
103.47 +{
103.48 + static struct option long_options[] =
103.49 + {
103.50 + { "format", required_argument, NULL, 'f'},
103.51 + { "input", required_argument, NULL, 'i'},
103.52 + { "output", required_argument, NULL, 'o'},
103.53 + { "size", required_argument, NULL, 's'},
103.54 + { NULL}
103.55 + };
103.56 +
103.57 + int c;
103.58 + int option_index = 0;
103.59 + int format = 0;
103.60 + std::string inputFontFile = "";
103.61 + std::string outputName = "";
103.62 + int size = 30;
103.63 +
103.64 + while ((c = getopt_long(argc, argv, "f:i:o:s:", long_options, &option_index)) != -1)
103.65 + {
103.66 + switch (c)
103.67 + {
103.68 + case 'f':
103.69 + format = atoi(optarg);
103.70 + break;
103.71 +
103.72 + case 'i':
103.73 + inputFontFile = optarg;
103.74 + break;
103.75 +
103.76 + case 'o':
103.77 + outputName = optarg;
103.78 + break;
103.79 +
103.80 + case 's':
103.81 + size = atoi(optarg);
103.82 + break;
103.83 +
103.84 + default:
103.85 + usage();
103.86 + break;
103.87 + }
103.88 + }
103.89 + if (format > 1)
103.90 + {
103.91 + usage();
103.92 + return 1;
103.93 + }
103.94 + if (inputFontFile == "")
103.95 + {
103.96 + usage();
103.97 + return 1;
103.98 + }
103.99 + if (outputName == "")
103.100 + {
103.101 + outputName = inputFontFile;
103.102 + }
103.103 +
103.104 + GLCD::cFont font;
103.105 + if (!font.LoadFT2(inputFontFile, "iso-8859-1", size, false))
103.106 + {
103.107 + return 1;
103.108 + }
103.109 +
103.110 + GLCD::cBitmap * bitmap = NULL;
103.111 + std::string fileName;
103.112 + FILE * descFile = NULL;
103.113 + int posX = 0;
103.114 + int posY = 0;
103.115 +
103.116 + if (format == 0)
103.117 + {
103.118 + fileName = outputName + ".fnt";
103.119 + if (!font.SaveFNT(fileName))
103.120 + {
103.121 + return 1;
103.122 + }
103.123 + }
103.124 + else
103.125 + {
103.126 + fileName = outputName + ".desc";
103.127 + descFile = fopen(fileName.c_str(), "wb");
103.128 + if (!descFile)
103.129 + {
103.130 + fprintf(stderr, "Cannot open file: %s\n", fileName.c_str());
103.131 + return 1;
103.132 + }
103.133 + bitmap = new GLCD::cBitmap(32 * font.TotalWidth(), 8 * font.TotalHeight());
103.134 + bitmap->Clear();
103.135 + fprintf(descFile, "version:1\n");
103.136 + fprintf(descFile, "fontheight:%d\n", font.TotalHeight());
103.137 + fprintf(descFile, "fontascent:%d\n", font.TotalAscent());
103.138 + fprintf(descFile, "lineheight:%d\n", font.LineHeight());
103.139 + fprintf(descFile, "spacebetween:%d\n", 0);
103.140 + fprintf(descFile, "spacewidth:%d\n", 0);
103.141 +
103.142 + for (unsigned int i = 0; i < 256; i++)
103.143 + {
103.144 + const GLCD::cBitmap * charBitmap = font.GetCharacter((char) i);
103.145 + if (charBitmap == NULL)
103.146 + continue;
103.147 +
103.148 + bitmap->DrawBitmap(posX, posY, *charBitmap, GLCD::clrBlack);
103.149 + fprintf(descFile, "%d %d ", posX, i);
103.150 + posX += charBitmap->Width();
103.151 + if ((i % 32) == 31)
103.152 + {
103.153 + fprintf(descFile, "%d\n", posX);
103.154 + posY += font.TotalHeight();
103.155 + posX = 0;
103.156 + }
103.157 + }
103.158 +
103.159 + if (posX > 0) // write last end marker
103.160 + fprintf(descFile, "%d\n", posX);
103.161 + fileName = outputName + ".pbm";
103.162 + bitmap->SavePBM(fileName);
103.163 + delete bitmap;
103.164 + fclose(descFile);
103.165 + }
103.166 +
103.167 + fprintf(stdout, "Font successfully generated.\n");
103.168 +
103.169 + return 0;
103.170 +}
104.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
104.2 +++ b/graphlcd-base/tools/lcdtestpattern/Makefile Thu Feb 07 13:03:18 2008 +0100
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 = lcdtestpattern
104.11 +
104.12 +OBJS = lcdtestpattern.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/lcdtestpattern/lcdtestpattern.c Thu Feb 07 13:03:18 2008 +0100
105.3 @@ -0,0 +1,260 @@
105.4 +/*
105.5 + * GraphLCD tool lcdtestpattern
105.6 + *
105.7 + * lcdtestpattern.c - a tool to display some testpattern on an GLCD
105.8 + *
105.9 + * based on showpic.c of graphlcd-base
105.10 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.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) 2007 Alexander Rieger (Alexander.Rieger AT inka.de)
105.16 + */
105.17 +
105.18 +//-----------------------------------------------------------------------------
105.19 +#include <stdio.h>
105.20 +#include <string.h>
105.21 +#include <stdlib.h>
105.22 +#include <getopt.h>
105.23 +#include <dlfcn.h>
105.24 +#include <unistd.h>
105.25 +#include <syslog.h>
105.26 +#include <signal.h>
105.27 +
105.28 +#include <string>
105.29 +
105.30 +#include <glcdgraphics/bitmap.h>
105.31 +#include <glcdgraphics/glcd.h>
105.32 +#include <glcdgraphics/image.h>
105.33 +#include <glcddrivers/config.h>
105.34 +#include <glcddrivers/common.h>
105.35 +#include <glcddrivers/driver.h>
105.36 +#include <glcddrivers/drivers.h>
105.37 +
105.38 +//-----------------------------------------------------------------------------
105.39 +static const char *prgname = "lcdtestpattern";
105.40 +static const char *version = "0.1.0";
105.41 +
105.42 +static const int kDefaultSleepMs = 0;
105.43 +static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
105.44 +
105.45 +static volatile bool stopProgramm = false;
105.46 +
105.47 +//-----------------------------------------------------------------------------
105.48 +static void sighandler(int signal)
105.49 +{
105.50 + switch (signal)
105.51 + {
105.52 + case SIGINT:
105.53 + case SIGQUIT:
105.54 + case SIGTERM:
105.55 + stopProgramm = true;
105.56 + } // switch
105.57 +} // sighandler()
105.58 +
105.59 +//-----------------------------------------------------------------------------
105.60 +void usage()
105.61 +{
105.62 + fprintf(stdout, "\n");
105.63 + fprintf(stdout, "%s v%s\n", prgname, version);
105.64 + fprintf(stdout, "%s is a tool to show test patterns on a LCD.\n", prgname);
105.65 + fprintf(stdout, "\n");
105.66 + fprintf(stdout, " Usage: %s [-c CONFIGFILE] [-d DISPLAY] [-s SLEEP] [-uie]\n\n", prgname);
105.67 + fprintf(stdout, " -c --config specifies the location of the config file\n");
105.68 + fprintf(stdout, " (default: /etc/graphlcd.conf)\n");
105.69 + fprintf(stdout, " -d --display specifies the output display (default is the first one)\n");
105.70 + fprintf(stdout, " -u --upsidedown rotates the output by 180 degrees (default: no)\n");
105.71 + fprintf(stdout, " -i --invert inverts the output (default: no)\n");
105.72 + fprintf(stdout, " -e --endless show all images in endless loop (default: no)\n");
105.73 + fprintf(stdout, " -s --sleep set sleeptime between two patterns [ms] (default: %d ms)\n", kDefaultSleepMs);
105.74 + fprintf(stdout, " -b --brightness set brightness for display if driver support it [%%]\n");
105.75 + fprintf(stdout, " (default: config file value)\n");
105.76 + fprintf(stdout, "\n" );
105.77 + fprintf(stdout, " examples: %s -c /etc/graphlcd.conf\n", prgname);
105.78 + fprintf(stdout, " %s -c /etc/graphlcd.conf -d LCD_T6963 -u -i\n", prgname);
105.79 + fprintf(stdout, "\n" );
105.80 +} // usage()
105.81 +
105.82 +//-----------------------------------------------------------------------------
105.83 +int main(int argc, char *argv[])
105.84 +{
105.85 + static struct option long_options[] =
105.86 + {
105.87 + {"config", required_argument, NULL, 'c'},
105.88 + {"display", required_argument, NULL, 'd'},
105.89 + {"sleep", required_argument, NULL, 's'},
105.90 + {"endless", no_argument, NULL, 'e'},
105.91 + {"upsidedown", no_argument, NULL, 'u'},
105.92 + {"invert", no_argument, NULL, 'i'},
105.93 + {"brightness", required_argument, NULL, 'b'},
105.94 + {NULL}
105.95 + };
105.96 +
105.97 + std::string configName = "";
105.98 + std::string displayName = "";
105.99 + bool upsideDown = false;
105.100 + bool invert = false;
105.101 + int brightness = -1;
105.102 + bool delay = false;
105.103 + int sleepMs = kDefaultSleepMs;
105.104 + bool endless = false;
105.105 + unsigned int displayNumber = 0;
105.106 +
105.107 + int c, option_index = 0;
105.108 + while ((c = getopt_long(argc, argv, "c:d:s:euib:", long_options, &option_index)) != -1)
105.109 + {
105.110 + switch(c)
105.111 + {
105.112 + case 'c':
105.113 + configName = optarg;
105.114 + break;
105.115 +
105.116 + case 'd':
105.117 + displayName = optarg;
105.118 + break;
105.119 +
105.120 + case 'u':
105.121 + upsideDown = true;
105.122 + break;
105.123 +
105.124 + case 'i':
105.125 + invert = true;
105.126 + break;
105.127 +
105.128 + case 's':
105.129 + sleepMs = atoi(optarg);
105.130 + delay = true;
105.131 + break;
105.132 +
105.133 + case 'e':
105.134 + endless = true;
105.135 + break;
105.136 +
105.137 + case 'b':
105.138 + brightness = atoi(optarg);
105.139 + if (brightness < 0) brightness = 0;
105.140 + if (brightness > 100) brightness = 100;
105.141 + break;
105.142 +
105.143 + default:
105.144 + usage();
105.145 + return 1;
105.146 + } // switch
105.147 + } // while
105.148 +
105.149 + if (configName.length() == 0)
105.150 + {
105.151 + configName = kDefaultConfigFile;
105.152 + syslog(LOG_INFO, "Error: No config file specified, using default (%s).\n", configName.c_str());
105.153 + } // if
105.154 +
105.155 + if (GLCD::Config.Load(configName) == false)
105.156 + {
105.157 + fprintf(stdout, "Error loading config file!\n");
105.158 + return 2;
105.159 + } // if
105.160 +
105.161 + if (GLCD::Config.driverConfigs.size() > 0)
105.162 + {
105.163 + if (displayName.length() > 0)
105.164 + {
105.165 + for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
105.166 + {
105.167 + if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
105.168 + break;
105.169 + } // for
105.170 +
105.171 + if (displayNumber == GLCD::Config.driverConfigs.size())
105.172 + {
105.173 + fprintf(stdout, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
105.174 + return 3;
105.175 + } // if
105.176 + }
105.177 + else
105.178 + {
105.179 + fprintf(stdout, "WARNING: No display specified, using first one.\n");
105.180 + displayNumber = 0;
105.181 + } // if
105.182 + }
105.183 + else
105.184 + {
105.185 + fprintf(stdout, "ERROR: No displays specified in config file!\n");
105.186 + return 4;
105.187 + } // if
105.188 +
105.189 + GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
105.190 + GLCD::Config.driverConfigs[displayNumber].invert ^= invert;
105.191 +
105.192 + if (brightness != -1)
105.193 + {
105.194 + GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
105.195 + } // if
105.196 +
105.197 + GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
105.198 + if (!lcd)
105.199 + {
105.200 + fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
105.201 + return 6;
105.202 + } // if
105.203 +
105.204 + if (lcd->Init() != 0)
105.205 + {
105.206 + fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
105.207 + delete lcd;
105.208 + return 7;
105.209 + } // if
105.210 +
105.211 + lcd->SetBrightness(GLCD::Config.driverConfigs[displayNumber].brightness);
105.212 +
105.213 + signal(SIGINT, sighandler);
105.214 + signal(SIGQUIT, sighandler);
105.215 + signal(SIGTERM, sighandler);
105.216 + signal(SIGHUP, sighandler);
105.217 +
105.218 + //----- show horizontal lines -----
105.219 + for (int aByte = 1; aByte <= 255 && !stopProgramm; ++aByte)
105.220 + {
105.221 + unsigned char aData = GLCD::ReverseBits(aByte);
105.222 + printf("clear and test byte: 0x%02X\n", aByte);
105.223 + lcd->Clear();
105.224 +
105.225 + for (int y = 0; y < lcd->Height() && !stopProgramm; ++y)
105.226 + {
105.227 + for (int x = 0; x < lcd->Width() && !stopProgramm; x += 8)
105.228 + {
105.229 + lcd->Set8Pixels(x, y, aData);
105.230 + } // for
105.231 + } // for
105.232 +
105.233 + lcd->Refresh(true);
105.234 + usleep(sleepMs * 1000);
105.235 + } // for
105.236 +
105.237 + //----- show vertial lines -----
105.238 + for (int aByte = 1; aByte <= 255 && !stopProgramm; ++aByte)
105.239 + {
105.240 + printf("clear and test byte: 0x%02X\n", aByte);
105.241 + lcd->Clear();
105.242 +
105.243 + for (int y = 0; y < lcd->Height() && !stopProgramm; ++y)
105.244 + {
105.245 + unsigned char aData = (((1 << (y % 8)) & aByte) == 0) ? 0x00 : 0xFF;
105.246 + for (int x = 0; x < lcd->Width() && !stopProgramm; x += 8)
105.247 + {
105.248 + lcd->Set8Pixels(x, y, aData);
105.249 + } // for
105.250 + } // for
105.251 +
105.252 + lcd->Refresh(true);
105.253 + usleep(sleepMs * 1000);
105.254 + } // for
105.255 +
105.256 + //----- cleanup -----
105.257 + lcd->Clear();
105.258 + lcd->Refresh(true);
105.259 + lcd->DeInit();
105.260 + delete lcd;
105.261 +
105.262 + return 0;
105.263 +} // main()
106.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
106.2 +++ b/graphlcd-base/tools/showpic/Makefile Thu Feb 07 13:03:18 2008 +0100
106.3 @@ -0,0 +1,46 @@
106.4 +#
106.5 +# Makefile for the GraphLCD tool showpic
106.6 +#
106.7 +
106.8 +-include ../../Make.config
106.9 +
106.10 +PRGNAME = showpic
106.11 +
106.12 +OBJS = showpic.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/showpic/showpic.c Thu Feb 07 13:03:18 2008 +0100
107.3 @@ -0,0 +1,256 @@
107.4 +/*
107.5 + * GraphLCD tool showpic
107.6 + *
107.7 + * showpic.c - a tool to show image files in GLCD format on a LCD
107.8 + *
107.9 + * based on graphlcd plugin 0.1.1 for the Video Disc Recorder
107.10 + * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de>
107.11 + *
107.12 + * This file is released under the GNU General Public License. Refer
107.13 + * to the COPYING file distributed with this package.
107.14 + *
107.15 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
107.16 + */
107.17 +
107.18 +#include <stdio.h>
107.19 +#include <string.h>
107.20 +#include <stdlib.h>
107.21 +#include <getopt.h>
107.22 +#include <dlfcn.h>
107.23 +#include <unistd.h>
107.24 +#include <syslog.h>
107.25 +#include <signal.h>
107.26 +
107.27 +#include <string>
107.28 +
107.29 +#include <glcdgraphics/bitmap.h>
107.30 +#include <glcdgraphics/glcd.h>
107.31 +#include <glcdgraphics/image.h>
107.32 +#include <glcddrivers/config.h>
107.33 +#include <glcddrivers/driver.h>
107.34 +#include <glcddrivers/drivers.h>
107.35 +
107.36 +static const char *prgname = "showpic";
107.37 +static const char *version = "0.1.2";
107.38 +
107.39 +static const int kDefaultSleepMs = 100;
107.40 +static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
107.41 +
107.42 +static volatile bool stopProgramm = false;
107.43 +
107.44 +static void sighandler(int signal)
107.45 +{
107.46 + switch (signal)
107.47 + {
107.48 + case SIGINT:
107.49 + case SIGQUIT:
107.50 + case SIGTERM:
107.51 + stopProgramm = true;
107.52 + }
107.53 +}
107.54 +
107.55 +void usage()
107.56 +{
107.57 + fprintf(stdout, "\n");
107.58 + fprintf(stdout, "%s v%s\n", prgname, version);
107.59 + fprintf(stdout, "%s is a tool to show an image on a LCD.\n", prgname);
107.60 + fprintf(stdout, "The image must be in a special format (*.glcd).\n");
107.61 + fprintf(stdout, "You can create such images with the convpic tool.\n\n");
107.62 + fprintf(stdout, " Usage: %s [-c CONFIGFILE] [-d DISPLAY] [-s SLEEP] [-uie] file [more files]\n\n", prgname);
107.63 + fprintf(stdout, " -c --config specifies the location of the config file\n");
107.64 + fprintf(stdout, " (default: /etc/graphlcd.conf)\n");
107.65 + fprintf(stdout, " -d --display specifies the output display (default is the first one)\n");
107.66 + fprintf(stdout, " -u --upsidedown rotates the output by 180 degrees (default: no)\n");
107.67 + fprintf(stdout, " -i --invert inverts the output (default: no)\n");
107.68 + fprintf(stdout, " -e --endless show all images in endless loop (default: no)\n");
107.69 + fprintf(stdout, " -s --sleep set sleeptime between two images [ms] (default: %d ms)\n", kDefaultSleepMs);
107.70 + fprintf(stdout, " -b --brightness set brightness for display if driver support it [%%]\n");
107.71 + fprintf(stdout, " (default: config file value)\n");
107.72 + fprintf(stdout, "\n" );
107.73 + fprintf(stdout, " examples: %s -c /etc/graphlcd.conf vdr-logo.glcd\n", prgname);
107.74 + fprintf(stdout, " %s -c /etc/graphlcd.conf -d LCD_T6963 -u -i vdr-logo.glcd\n", prgname);
107.75 + fprintf(stdout, "\n" );
107.76 +}
107.77 +
107.78 +int main(int argc, char *argv[])
107.79 +{
107.80 + static struct option long_options[] =
107.81 + {
107.82 + {"config", required_argument, NULL, 'c'},
107.83 + {"display", required_argument, NULL, 'd'},
107.84 + {"sleep", required_argument, NULL, 's'},
107.85 + {"endless", no_argument, NULL, 'e'},
107.86 + {"upsidedown", no_argument, NULL, 'u'},
107.87 + {"invert", no_argument, NULL, 'i'},
107.88 + {"brightness", required_argument, NULL, 'b'},
107.89 + {NULL}
107.90 + };
107.91 +
107.92 + std::string configName = "";
107.93 + std::string displayName = "";
107.94 + bool upsideDown = false;
107.95 + bool invert = false;
107.96 + int brightness = -1;
107.97 + bool delay = false;
107.98 + int sleepMs = 100;
107.99 + bool endless = false;
107.100 + unsigned int displayNumber = 0;
107.101 +
107.102 + int c, option_index = 0;
107.103 + while ((c = getopt_long(argc, argv, "c:d:s:euib:", long_options, &option_index)) != -1)
107.104 + {
107.105 + switch(c)
107.106 + {
107.107 + case 'c':
107.108 + configName = optarg;
107.109 + break;
107.110 +
107.111 + case 'd':
107.112 + displayName = optarg;
107.113 + break;
107.114 +
107.115 + case 'u':
107.116 + upsideDown = true;
107.117 + break;
107.118 +
107.119 + case 'i':
107.120 + invert = true;
107.121 + break;
107.122 +
107.123 + case 's':
107.124 + sleepMs = atoi(optarg);
107.125 + delay = true;
107.126 + break;
107.127 +
107.128 + case 'e':
107.129 + endless = true;
107.130 + break;
107.131 +
107.132 + case 'b':
107.133 + brightness = atoi(optarg);
107.134 + if (brightness < 0) brightness = 0;
107.135 + if (brightness > 100) brightness = 100;
107.136 + break;
107.137 +
107.138 + default:
107.139 + usage();
107.140 + return 1;
107.141 + }
107.142 + }
107.143 +
107.144 + if (configName.length() == 0)
107.145 + {
107.146 + configName = kDefaultConfigFile;
107.147 + syslog(LOG_INFO, "Error: No config file specified, using default (%s).\n", configName.c_str());
107.148 + }
107.149 +
107.150 + if (GLCD::Config.Load(configName) == false)
107.151 + {
107.152 + fprintf(stdout, "Error loading config file!\n");
107.153 + return 2;
107.154 + }
107.155 + if (GLCD::Config.driverConfigs.size() > 0)
107.156 + {
107.157 + if (displayName.length() > 0)
107.158 + {
107.159 + for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
107.160 + {
107.161 + if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
107.162 + break;
107.163 + }
107.164 + if (displayNumber == GLCD::Config.driverConfigs.size())
107.165 + {
107.166 + fprintf(stdout, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
107.167 + return 3;
107.168 + }
107.169 + }
107.170 + else
107.171 + {
107.172 + fprintf(stdout, "WARNING: No display specified, using first one.\n");
107.173 + displayNumber = 0;
107.174 + }
107.175 + }
107.176 + else
107.177 + {
107.178 + fprintf(stdout, "ERROR: No displays specified in config file!\n");
107.179 + return 4;
107.180 + }
107.181 +
107.182 + if (optind == argc)
107.183 + {
107.184 + usage();
107.185 + fprintf(stderr, "ERROR: You have to specify the image\n");
107.186 + return 5;
107.187 + }
107.188 +
107.189 + GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
107.190 + GLCD::Config.driverConfigs[displayNumber].invert ^= invert;
107.191 + if (brightness != -1)
107.192 + GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
107.193 + GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
107.194 + if (!lcd)
107.195 + {
107.196 + fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
107.197 + return 6;
107.198 + }
107.199 + if (lcd->Init() != 0)
107.200 + {
107.201 + fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
107.202 + delete lcd;
107.203 + return 7;
107.204 + }
107.205 + lcd->SetBrightness(GLCD::Config.driverConfigs[displayNumber].brightness);
107.206 +
107.207 + signal(SIGINT, sighandler);
107.208 + signal(SIGQUIT, sighandler);
107.209 + signal(SIGTERM, sighandler);
107.210 + signal(SIGHUP, sighandler);
107.211 +
107.212 + const GLCD::cBitmap * bitmap;
107.213 + GLCD::cImage image;
107.214 + GLCD::cGLCDFile glcd;
107.215 + int optFile;
107.216 + std::string picFile;
107.217 +
107.218 + optFile = optind;
107.219 + while (optFile < argc && !stopProgramm)
107.220 + {
107.221 + picFile = argv[optFile++];
107.222 + if (glcd.Load(image, picFile) == false)
107.223 + {
107.224 + fprintf(stderr, "ERROR: Failed loading file %s\n", picFile.c_str());
107.225 + return 8;
107.226 + }
107.227 +
107.228 + if (delay)
107.229 + image.SetDelay(sleepMs);
107.230 +
107.231 + while ((bitmap = image.GetBitmap()) != NULL && !stopProgramm)
107.232 + {
107.233 + lcd->SetScreen(bitmap->Data(), bitmap->Width(), bitmap->Height(), bitmap->LineSize());
107.234 + lcd->Refresh(true);
107.235 +
107.236 + if (image.Next(0)) // Select next image
107.237 + {
107.238 + usleep(image.Delay() * 1000);
107.239 + }
107.240 + else if (endless && argc == (optind + 1)) // Endless and one and only image
107.241 + {
107.242 + image.First(0);
107.243 + usleep(image.Delay() * 1000);
107.244 + }
107.245 + else
107.246 + break;
107.247 + }
107.248 +
107.249 + if (optFile < argc || endless)
107.250 + usleep(sleepMs * 1000);
107.251 + if (optFile >= argc && endless)
107.252 + optFile = optind;
107.253 + }
107.254 +
107.255 + lcd->DeInit();
107.256 + delete lcd;
107.257 +
107.258 + return 0;
107.259 +}
108.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
108.2 +++ b/graphlcd-base/tools/showtext/Makefile Thu Feb 07 13:03:18 2008 +0100
108.3 @@ -0,0 +1,46 @@
108.4 +#
108.5 +# Makefile for the GraphLCD tool showtext
108.6 +#
108.7 +
108.8 +-include ../../Make.config
108.9 +
108.10 +PRGNAME = showtext
108.11 +
108.12 +OBJS = showtext.o
108.13 +
108.14 +INCLUDES += -I../../
108.15 +LIBDIRS += -L../../glcdgraphics/ -L../../glcddrivers/
108.16 +
108.17 +
108.18 +all: $(PRGNAME)
108.19 +.PHONY: all
108.20 +
108.21 +# Implicit rules:
108.22 +
108.23 +%.o: %.c
108.24 + $(CXX) $(CXXFLAGS) -c $(DEFINES) $(INCLUDES) $<
108.25 +
108.26 +# Dependencies:
108.27 +
108.28 +MAKEDEP = $(CXX) -MM -MG
108.29 +DEPFILE = .dependencies
108.30 +$(DEPFILE): Makefile
108.31 + @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@
108.32 +
108.33 +-include $(DEPFILE)
108.34 +
108.35 +# The main program:
108.36 +
108.37 +$(PRGNAME): $(OBJS)
108.38 + $(CXX) $(CXXFLAGS) -rdynamic $(OBJS) $(LIBS) $(LIBDIRS) -lglcdgraphics -lglcddrivers -lstdc++ -o $(PRGNAME)
108.39 +
108.40 +install: $(PRGNAME)
108.41 + install -d $(BINDIR)
108.42 + install -m 755 -o root -g root -s $(PRGNAME) $(BINDIR)
108.43 +
108.44 +uninstall:
108.45 + rm -f $(BINDIR)/$(PRGNAME)
108.46 +
108.47 +clean:
108.48 + @-rm -f $(OBJS) $(DEPFILE) $(PRGNAME) *~
108.49 +
109.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
109.2 +++ b/graphlcd-base/tools/showtext/showtext.c Thu Feb 07 13:03:18 2008 +0100
109.3 @@ -0,0 +1,279 @@
109.4 +/*
109.5 + * GraphLCD tool showtext
109.6 + *
109.7 + * showtext.c - a tool to show a text on a LCD
109.8 + *
109.9 + * This file is released under the GNU General Public License. Refer
109.10 + * to the COPYING file distributed with this package.
109.11 + *
109.12 + * (c) 2004 Andreas Regel <andreas.regel AT powarman.de>
109.13 + */
109.14 +
109.15 +#include <stdio.h>
109.16 +#include <string.h>
109.17 +#include <stdlib.h>
109.18 +#include <getopt.h>
109.19 +#include <unistd.h>
109.20 +
109.21 +#include <string>
109.22 +
109.23 +#include <glcdgraphics/bitmap.h>
109.24 +#include <glcdgraphics/font.h>
109.25 +#include <glcddrivers/config.h>
109.26 +#include <glcddrivers/driver.h>
109.27 +#include <glcddrivers/drivers.h>
109.28 +
109.29 +static const char *prgname = "showtext";
109.30 +static const char *version = "0.0.3";
109.31 +
109.32 +static const char * kDefaultConfigFile = "/etc/graphlcd.conf";
109.33 +
109.34 +static const int kFontFNT = 0;
109.35 +static const int kFontFT2 = 1;
109.36 +
109.37 +void usage()
109.38 +{
109.39 + fprintf(stdout, "\n");
109.40 + fprintf(stdout, "%s v%s\n", prgname, version);
109.41 + fprintf(stdout, "%s is a tool to show a text on a LCD.\n", prgname);
109.42 + fprintf(stdout, "\n");
109.43 + fprintf(stdout, " Usage: %s [-c CONFIGFILE] [-d DISPLAY] [-f FONT] [-x XPOS] [-y YPOS] [-uib] text [more text]\n\n", prgname);
109.44 + fprintf(stdout, " -c --config specifies the location of the config file\n");
109.45 + fprintf(stdout, " (default: /etc/graphlcd.conf)\n");
109.46 + fprintf(stdout, " -d --display specifies the output display (default is the first one)\n");
109.47 + fprintf(stdout, " -f --font specifies the font that is used for the text:\n");
109.48 + fprintf(stdout, " fnt:/path/to/font.fnt for GraphLCD font format\n");
109.49 + fprintf(stdout, " ft2:/path/to/font.ttf:size for FreeType2 supported fonts\n");
109.50 + fprintf(stdout, " -e --encoding specifies the encoding that is used for the text\n");
109.51 + fprintf(stdout, " (p.e. iso8859-1)\n");
109.52 + fprintf(stdout, " -x --xpos specifies the x-position where the text starts\n");
109.53 + fprintf(stdout, " -y --ypos specifies the y-position where the text starts\n");
109.54 + fprintf(stdout, " -u --upsidedown rotates the output by 180 degrees (default: no)\n");
109.55 + fprintf(stdout, " -i --invert inverts the output (default: no)\n");
109.56 + fprintf(stdout, " -b --brightness set brightness for display if driver support it [%%]\n");
109.57 + fprintf(stdout, " (default: config file value)\n");
109.58 + fprintf(stdout, "\n" );
109.59 + fprintf(stdout, " example: %s -c /etc/graphlcd.conf -f fnt:f17.fnt \"Line1\" \"Line2\"\n", prgname);
109.60 + fprintf(stdout, "\n" );
109.61 +}
109.62 +
109.63 +int main(int argc, char *argv[])
109.64 +{
109.65 + static struct option long_options[] =
109.66 + {
109.67 + {"config", required_argument, NULL, 'c'},
109.68 + {"display", required_argument, NULL, 'd'},
109.69 + {"font", required_argument, NULL, 'f'},
109.70 + {"encoding", required_argument, NULL, 'e'},
109.71 + {"upsidedown", no_argument, NULL, 'u'},
109.72 + {"invert", no_argument, NULL, 'i'},
109.73 + {"brightness", required_argument, NULL, 'b'},
109.74 + {"xpos", required_argument, NULL, 'x'},
109.75 + {"ypos", required_argument, NULL, 'y'},
109.76 + {NULL}
109.77 + };
109.78 +
109.79 + std::string configName = "";
109.80 + std::string displayName = "";
109.81 + std::string fontName;
109.82 + std::string fontFileName = "";
109.83 + std::string encoding = "";
109.84 + int fontType;
109.85 + int fontSize = 16;
109.86 + bool upsideDown = false;
109.87 + bool invert = false;
109.88 + int brightness = -1;
109.89 + int x = 0;
109.90 + int y = 0;
109.91 + unsigned int displayNumber = 0;
109.92 +
109.93 + int c, option_index = 0;
109.94 + while ((c = getopt_long(argc, argv, "c:d:f:e:uib:x:y:", long_options, &option_index)) != -1)
109.95 + {
109.96 + switch (c)
109.97 + {
109.98 + case 'c':
109.99 + configName = optarg;
109.100 + break;
109.101 +
109.102 + case 'd':
109.103 + displayName = optarg;
109.104 + break;
109.105 +
109.106 + case 'f':
109.107 + fontName = optarg;
109.108 + break;
109.109 +
109.110 + case 'e':
109.111 + encoding = optarg;
109.112 + break;
109.113 +
109.114 + case 'u':
109.115 + upsideDown = true;
109.116 + break;
109.117 +
109.118 + case 'i':
109.119 + invert = true;
109.120 + break;
109.121 +
109.122 + case 'b':
109.123 + brightness = atoi(optarg);
109.124 + if (brightness < 0) brightness = 0;
109.125 + if (brightness > 100) brightness = 100;
109.126 + break;
109.127 +
109.128 + case 'x':
109.129 + x = atoi(optarg);
109.130 + break;
109.131 +
109.132 + case 'y':
109.133 + y = atoi(optarg);
109.134 + break;
109.135 +
109.136 + default:
109.137 + usage();
109.138 + return 1;
109.139 + }
109.140 + }
109.141 +
109.142 + if (configName.length() == 0)
109.143 + {
109.144 + configName = kDefaultConfigFile;
109.145 + fprintf(stdout, "WARNING: No config file specified, using default (%s).\n", configName.c_str());
109.146 + }
109.147 +
109.148 + if (GLCD::Config.Load(configName) == false)
109.149 + {
109.150 + fprintf(stderr, "Error loading config file!\n");
109.151 + return 2;
109.152 + }
109.153 + if (GLCD::Config.driverConfigs.size() > 0)
109.154 + {
109.155 + if (displayName.length() > 0)
109.156 + {
109.157 + for (displayNumber = 0; displayNumber < GLCD::Config.driverConfigs.size(); displayNumber++)
109.158 + {
109.159 + if (GLCD::Config.driverConfigs[displayNumber].name == displayName)
109.160 + break;
109.161 + }
109.162 + if (displayNumber == GLCD::Config.driverConfigs.size())
109.163 + {
109.164 + fprintf(stderr, "ERROR: Specified display %s not found in config file!\n", displayName.c_str());
109.165 + return 3;
109.166 + }
109.167 + }
109.168 + else
109.169 + {
109.170 + fprintf(stdout, "WARNING: No display specified, using first one.\n");
109.171 + displayNumber = 0;
109.172 + }
109.173 + }
109.174 + else
109.175 + {
109.176 + fprintf(stderr, "ERROR: No displays specified in config file!\n");
109.177 + return 4;
109.178 + }
109.179 +
109.180 + if (encoding.length() == 0)
109.181 + {
109.182 + encoding = "iso8859-1";
109.183 + fprintf(stdout, "WARNING: No encoding specified, using default (%s).\n", encoding.c_str());
109.184 + }
109.185 +
109.186 + if (fontName.length() == 0)
109.187 + {
109.188 + fprintf(stderr, "Error: No font specified!\n");
109.189 + return 5;
109.190 + }
109.191 + if (fontName.find("fnt:") == 0)
109.192 + {
109.193 + fontType = kFontFNT;
109.194 + fontFileName = fontName.substr(4);
109.195 + }
109.196 + else if (fontName.find("ft2:") == 0)
109.197 + {
109.198 + fontType = kFontFT2;
109.199 + std::string::size_type pos = fontName.find(":", 4);
109.200 + if (pos == std::string::npos)
109.201 + {
109.202 + fontSize = 16;
109.203 + fprintf(stdout, "WARNING: No font size specified, using default (%d).\n", fontSize);
109.204 + fontFileName = fontName.substr(4);
109.205 + }
109.206 + else
109.207 + {
109.208 + std::string tmp = fontName.substr(pos + 1);
109.209 + fontSize = atoi(tmp.c_str());
109.210 + fontFileName = fontName.substr(4, pos - 4);
109.211 + }
109.212 + }
109.213 + else
109.214 + {
109.215 + fprintf(stderr, "Error: Unknown font type!\n");
109.216 + return 6;
109.217 + }
109.218 +
109.219 + if (optind == argc)
109.220 + {
109.221 + usage();
109.222 + fprintf(stderr, "ERROR: You have to specify a text\n");
109.223 + return 7;
109.224 + }
109.225 +
109.226 + GLCD::Config.driverConfigs[displayNumber].upsideDown ^= upsideDown;
109.227 + GLCD::Config.driverConfigs[displayNumber].invert ^= invert;
109.228 + if (brightness != -1)
109.229 + GLCD::Config.driverConfigs[displayNumber].brightness = brightness;
109.230 +
109.231 + GLCD::cFont font;
109.232 + if (fontType == kFontFNT)
109.233 + {
109.234 + if (font.LoadFNT(fontFileName) == false)
109.235 + {
109.236 + fprintf(stderr, "ERROR: Failed loading font file %s\n", fontFileName.c_str());
109.237 + return 8;
109.238 + }
109.239 + }
109.240 + else
109.241 + {
109.242 + if (font.LoadFT2(fontFileName, encoding, fontSize) == false)
109.243 + {
109.244 + fprintf(stderr, "ERROR: Failed loading font file %s\n", fontFileName.c_str());
109.245 + return 8;
109.246 + }
109.247 + }
109.248 + GLCD::cDriver * lcd = GLCD::CreateDriver(GLCD::Config.driverConfigs[displayNumber].id, &GLCD::Config.driverConfigs[displayNumber]);
109.249 + if (!lcd)
109.250 + {
109.251 + fprintf(stderr, "ERROR: Failed creating display object %s\n", displayName.c_str());
109.252 + return 9;
109.253 + }
109.254 + if (lcd->Init() != 0)
109.255 + {
109.256 + fprintf(stderr, "ERROR: Failed initializing display %s\n", displayName.c_str());
109.257 + delete lcd;
109.258 + return 10;
109.259 + }
109.260 +
109.261 + GLCD::cBitmap * bitmap = new GLCD::cBitmap(lcd->Width(), lcd->Height());
109.262 + int optText;
109.263 + std::string text;
109.264 +
109.265 + bitmap->Clear();
109.266 + optText = optind;
109.267 + while (optText < argc)
109.268 + {
109.269 + text = argv[optText];
109.270 + optText++;
109.271 +
109.272 + bitmap->DrawText(x, y, bitmap->Width() - 1, text, &font);
109.273 + y += font.LineHeight();
109.274 + }
109.275 + lcd->SetScreen(bitmap->Data(), bitmap->Width(), bitmap->Height(), bitmap->LineSize());
109.276 + lcd->Refresh(true);
109.277 +
109.278 + lcd->DeInit();
109.279 + delete lcd;
109.280 +
109.281 + return 0;
109.282 +}