From 3cc5e2eee7251bf4e86e3a33a4210ee6b8aaf084 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 11:56:25 +0200 Subject: [PATCH 01/47] contributors update --- contributors.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/contributors.txt b/contributors.txt index 5f122b6d..289aa98f 100644 --- a/contributors.txt +++ b/contributors.txt @@ -6,6 +6,7 @@ At this point we want to thank all of these people for their work. Date NickName RealName Contribution ==== ======== ======== ============ +09.08.2012 inmarket Andrew Hannam GDISP VMT, ASYNC and MULTITHREAD implementation 30.07.2012 inmarket Andrew Hannam halext implementation - dxli Dongxu Li lcdDrawEllipse() filled option - benwilliam - fastMath & lcdDrawEllipse() From b9449b89e88e9ef5d29742e37fc8131462c95e2e Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 12:35:04 +0200 Subject: [PATCH 02/47] Doxygenfile update --- Doxyfile | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 Doxyfile diff --git a/Doxyfile b/Doxyfile deleted file mode 100644 index 4c38027b..00000000 --- a/Doxyfile +++ /dev/null @@ -1,23 +0,0 @@ -DOXYFILE_ENCODING = UTF-8 -PROJECT_NAME = "ChibiOS-LCD-Driver" -PROJECT_NUMBER = 0.0.1 -PROJECT_BRIEF = "Library for interfacing GLCDs with Touchpad to ChibiOS" -OUTPUT_LANGUAGE = English -TAB_SIZE = 2 -OPTIMIZE_OUTPUT_FOR_C = YES -INPUT = -RECURSIVE = YES -GENERATE_LATEX = NO -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_DYNAMIC_SECTIONS = YES -GENERATE_TREEVIEW = YES -DISABLE_INDEX = YES -TREEVIEW_WIDTH = 300 -SEARCHENGINE = YES -CLASS_DIAGRAMS = YES -HIDE_UNDOC_RELATIONS = YES -HAVE_DOT = YES -GRAPHICAL_HIERARCHY = YES - From aae3722857ce4e11f2843c5c58655d48a243a48a Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 12:35:14 +0200 Subject: [PATCH 03/47] Doxygenfile update --- Doxygenfile | 1747 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1747 insertions(+) create mode 100644 Doxygenfile diff --git a/Doxygenfile b/Doxygenfile new file mode 100644 index 00000000..fa2a47e7 --- /dev/null +++ b/Doxygenfile @@ -0,0 +1,1747 @@ +# Doxyfile 1.7.4 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (" "). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded +# by quotes) that should identify the project. + +PROJECT_NAME = ChibiOS-LCD-Driver + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. +# This could be handy for archiving the generated documentation or +# if some version control system is used. + +PROJECT_NUMBER = 0.0.1 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer +# a quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = + +# With the PROJECT_LOGO tag one can specify an logo or icon that is +# included in the documentation. The maximum height of the logo should not +# exceed 55 pixels and the maximum width should not exceed 200 pixels. +# Doxygen will copy the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) +# base path where the generated documentation will be put. +# If a relative path is entered, it will be relative to the location +# where doxygen was started. If left blank the current directory will be used. + +OUTPUT_DIRECTORY = + +# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create +# 4096 sub-directories (in 2 levels) under the output directory of each output +# format and will distribute the generated files over these directories. +# Enabling this option can be useful when feeding doxygen a huge amount of +# source files, where putting all generated files in the same directory would +# otherwise cause performance problems for the file system. + +CREATE_SUBDIRS = NO + +# The OUTPUT_LANGUAGE tag is used to specify the language in which all +# documentation generated by doxygen is written. Doxygen will use this +# information to generate all constant output in the proper language. +# The default language is English, other supported languages are: +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. + +OUTPUT_LANGUAGE = English + +# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will +# include brief member descriptions after the members that are listed in +# the file and class documentation (similar to JavaDoc). +# Set to NO to disable this. + +BRIEF_MEMBER_DESC = YES + +# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend +# the brief description of a member or function before the detailed description. +# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the +# brief descriptions will be completely suppressed. + +REPEAT_BRIEF = YES + +# This tag implements a quasi-intelligent brief description abbreviator +# that is used to form the text in various listings. Each string +# in this list, if found as the leading text of the brief description, will be +# stripped from the text and the result after processing the whole list, is +# used as the annotated text. Otherwise, the brief description is used as-is. +# If left blank, the following values are used ("$name" is automatically +# replaced with the name of the entity): "The $name class" "The $name widget" +# "The $name file" "is" "provides" "specifies" "contains" +# "represents" "a" "an" "the" + +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the + +# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then +# Doxygen will generate a detailed section even if there is only a brief +# description. + +ALWAYS_DETAILED_SEC = YES + +# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all +# inherited members of a class in the documentation of that class as if those +# members were ordinary class members. Constructors, destructors and assignment +# operators of the base classes will not be shown. + +INLINE_INHERITED_MEMB = NO + +# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full +# path before files name in the file list and in the header files. If set +# to NO the shortest path that makes the file name unique will be used. + +FULL_PATH_NAMES = NO + +# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag +# can be used to strip a user-defined part of the path. Stripping is +# only done if one of the specified strings matches the left-hand part of +# the path. The tag can be used to show relative paths in the file list. +# If left blank the directory from which doxygen is run is used as the +# path to strip. + +STRIP_FROM_PATH = "C:/Documents and Settings/Administrator/" + +# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of +# the path mentioned in the documentation of a class, which tells +# the reader which header file to include in order to use a class. +# If left blank only the name of the header file containing the class +# definition is used. Otherwise one should specify the include paths that +# are normally passed to the compiler using the -I flag. + +STRIP_FROM_INC_PATH = + +# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter +# (but less readable) file names. This can be useful if your file system +# doesn't support long names like on DOS, Mac, or CD-ROM. + +SHORT_NAMES = NO + +# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen +# will interpret the first line (until the first dot) of a JavaDoc-style +# comment as the brief description. If set to NO, the JavaDoc +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) + +JAVADOC_AUTOBRIEF = NO + +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + +# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen +# treat a multi-line C++ special comment block (i.e. a block of //! or /// +# comments) as a brief description. This used to be the default behaviour. +# The new default is to treat a multi-line C++ comment block as a detailed +# description. Set this tag to YES if you prefer the old behaviour instead. + +MULTILINE_CPP_IS_BRIEF = NO + +# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented +# member inherits the documentation from any documented member that it +# re-implements. + +INHERIT_DOCS = NO + +# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce +# a new page for each member. If set to NO, the documentation of a member will +# be part of the file/class/namespace that contains it. + +SEPARATE_MEMBER_PAGES = NO + +# The TAB_SIZE tag can be used to set the number of spaces in a tab. +# Doxygen uses this value to replace tabs by spaces in code fragments. + +TAB_SIZE = 2 + +# This tag can be used to specify a number of aliases that acts +# as commands in the documentation. An alias has the form "name=value". +# For example adding "sideeffect=\par Side Effects:\n" will allow you to +# put the command \sideeffect (or @sideeffect) in the documentation, which +# will result in a user-defined paragraph with heading "Side Effects:". +# You can put \n's in the value part of an alias to insert newlines. + +ALIASES = "iclass=@par Function Class:\n This is an \ + I-Class API, this function can be \ + invoked from within a system lock zone by both \ + threads and interrupt handlers." \ + "sclass=@par Function Class:\n This is an \ + S-Class API, this function can be \ + invoked from within a system lock zone by threads \ + only." \ + "api=@par Function Class:\n Normal API, this \ + function can be invoked by regular system threads \ + but not from within a lock zone." \ + "notapi=@par Function Class:\n Not an API, this \ + function is for internal use only." \ + "isr=@par Function Class:\n Interrupt handler, \ + this function should not be directly invoked." \ + "init=@par Function Class:\n Initializer, this \ + function just initializes an object and can be \ + invoked before the kernel is initialized." \ + "special=@par Function Class:\n Special function, \ + this function has special requirements see the \ + notes." + +# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C +# sources only. Doxygen will then generate output that is more tailored for C. +# For instance, some of the names that are used will be different. The list +# of all members will be omitted, etc. + +OPTIMIZE_OUTPUT_FOR_C = YES + +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. + +OPTIMIZE_OUTPUT_JAVA = NO + +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it +# parses. With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this +# tag. The format is ext=language, where ext is a file extension, and language +# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, +# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make +# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C +# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions +# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also makes the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + +# Set the SUBGROUPING tag to YES (the default) to allow class member groups of +# the same type (for instance a group of public functions) to be put as a +# subgroup of that type (e.g. under the Public Functions section). Set it to +# NO to prevent subgrouping. Alternatively, this can be done per class using +# the \nosubgrouping command. + +SUBGROUPING = YES + +# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and +# unions are shown inside the group in which they are included (e.g. using +# @ingroup) instead of on a separate page (for HTML and Man pages) or +# section (for LaTeX and RTF). + +INLINE_GROUPED_CLASSES = NO + +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = NO + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penalty. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will roughly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- + +# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in +# documentation are documented, even if no documentation was available. +# Private class members and static file members will be hidden unless +# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES + +EXTRACT_ALL = NO + +# If the EXTRACT_PRIVATE tag is set to YES all private members of a class +# will be included in the documentation. + +EXTRACT_PRIVATE = NO + +# If the EXTRACT_STATIC tag is set to YES all static members of a file +# will be included in the documentation. + +EXTRACT_STATIC = NO + +# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) +# defined locally in source files will be included in the documentation. +# If set to NO only classes defined in header files are included. + +EXTRACT_LOCAL_CLASSES = NO + +# This flag is only useful for Objective-C code. When set to YES local +# methods, which are defined in the implementation section but not in +# the interface are included in the documentation. +# If set to NO (the default) only methods in the interface are included. + +EXTRACT_LOCAL_METHODS = NO + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespaces are hidden. + +EXTRACT_ANON_NSPACES = NO + +# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all +# undocumented members of documented classes, files or namespaces. +# If set to NO (the default) these members will be included in the +# various overviews, but no documentation section is generated. +# This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_MEMBERS = YES + +# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all +# undocumented classes that are normally visible in the class hierarchy. +# If set to NO (the default) these classes will be included in the various +# overviews. This option has no effect if EXTRACT_ALL is enabled. + +HIDE_UNDOC_CLASSES = YES + +# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all +# friend (class|struct|union) declarations. +# If set to NO (the default) these declarations will be included in the +# documentation. + +HIDE_FRIEND_COMPOUNDS = NO + +# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any +# documentation blocks found inside the body of a function. +# If set to NO (the default) these blocks will be appended to the +# function's detailed documentation block. + +HIDE_IN_BODY_DOCS = NO + +# The INTERNAL_DOCS tag determines if documentation +# that is typed after a \internal command is included. If the tag is set +# to NO (the default) then the documentation will be excluded. +# Set it to YES to include the internal documentation. + +INTERNAL_DOCS = NO + +# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate +# file names in lower-case letters. If set to YES upper-case letters are also +# allowed. This is useful if you have classes or files whose names only differ +# in case and if your file system supports case sensitive file names. Windows +# and Mac users are advised to set this option to NO. + +CASE_SENSE_NAMES = NO + +# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen +# will show members with their full class and namespace scopes in the +# documentation. If set to YES the scope will be hidden. + +HIDE_SCOPE_NAMES = NO + +# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen +# will put a list of the files that are included by a file in the documentation +# of that file. + +SHOW_INCLUDE_FILES = YES + +# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen +# will list include files with double quotes in the documentation +# rather than with sharp brackets. + +FORCE_LOCAL_INCLUDES = NO + +# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] +# is inserted in the documentation for inline members. + +INLINE_INFO = YES + +# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen +# will sort the (detailed) documentation of file and class members +# alphabetically by member name. If set to NO the members will appear in +# declaration order. + +SORT_MEMBER_DOCS = NO + +# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the +# brief documentation of file, namespace and class members alphabetically +# by member name. If set to NO (the default) the members will appear in +# declaration order. + +SORT_BRIEF_DOCS = NO + +# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen +# will sort the (brief and detailed) documentation of class members so that +# constructors and destructors are listed first. If set to NO (the default) +# the constructors will appear in the respective orders defined by +# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. +# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO +# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. + +SORT_MEMBERS_CTORS_1ST = NO + +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + +# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be +# sorted by fully-qualified names, including namespaces. If set to +# NO (the default), the class list will be sorted only by class name, +# not including the namespace part. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option applies only to the class list, not to the +# alphabetical list. + +SORT_BY_SCOPE_NAME = NO + +# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to +# do proper type resolution of all parameters of a function it will reject a +# match between the prototype and the implementation of a member function even +# if there is only one candidate or it is obvious which candidate to choose +# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen +# will still accept a match between prototype and implementation in such cases. + +STRICT_PROTO_MATCHING = NO + +# The GENERATE_TODOLIST tag can be used to enable (YES) or +# disable (NO) the todo list. This list is created by putting \todo +# commands in the documentation. + +GENERATE_TODOLIST = YES + +# The GENERATE_TESTLIST tag can be used to enable (YES) or +# disable (NO) the test list. This list is created by putting \test +# commands in the documentation. + +GENERATE_TESTLIST = YES + +# The GENERATE_BUGLIST tag can be used to enable (YES) or +# disable (NO) the bug list. This list is created by putting \bug +# commands in the documentation. + +GENERATE_BUGLIST = YES + +# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or +# disable (NO) the deprecated list. This list is created by putting +# \deprecated commands in the documentation. + +GENERATE_DEPRECATEDLIST= YES + +# The ENABLED_SECTIONS tag can be used to enable conditional +# documentation sections, marked by \if sectionname ... \endif. + +ENABLED_SECTIONS = + +# The MAX_INITIALIZER_LINES tag determines the maximum number of lines +# the initial value of a variable or macro consists of for it to appear in +# the documentation. If the initializer consists of more lines than specified +# here it will be hidden. Use a value of 0 to hide initializers completely. +# The appearance of the initializer of individual variables and macros in the +# documentation can be controlled using \showinitializer or \hideinitializer +# command in the documentation regardless of this setting. + +MAX_INITIALIZER_LINES = 30 + +# Set the SHOW_USED_FILES tag to NO to disable the list of files generated +# at the bottom of the documentation of classes and structs. If set to YES the +# list will mention the files that were used to generate the documentation. + +SHOW_USED_FILES = NO + +# If the sources in your project are distributed over multiple directories +# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy +# in the documentation. The default is NO. + +SHOW_DIRECTORIES = NO + +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. +# This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + +# The FILE_VERSION_FILTER tag can be used to specify a program or script that +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via +# popen()) the command , where is the value of +# the FILE_VERSION_FILTER tag, and is the name of an input file +# provided by doxygen. Whatever the program writes to standard output +# is used as the file version. See the manual for examples. + +FILE_VERSION_FILTER = + +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed +# by doxygen. The layout file controls the global structure of the generated +# output files in an output format independent way. The create the layout file +# that represents doxygen's defaults, run doxygen with the -l option. +# You can optionally specify a file name after the option, if omitted +# DoxygenLayout.xml will be used as the name of the layout file. + +LAYOUT_FILE = ./rsc/layout.xml + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +# The QUIET tag can be used to turn on/off the messages that are generated +# by doxygen. Possible values are YES and NO. If left blank NO is used. + +QUIET = YES + +# The WARNINGS tag can be used to turn on/off the warning messages that are +# generated by doxygen. Possible values are YES and NO. If left blank +# NO is used. + +WARNINGS = YES + +# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings +# for undocumented members. If EXTRACT_ALL is set to YES then this flag will +# automatically be disabled. + +WARN_IF_UNDOCUMENTED = YES + +# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for +# potential errors in the documentation, such as not documenting some +# parameters in a documented function, or documenting parameters that +# don't exist or using markup commands wrongly. + +WARN_IF_DOC_ERROR = YES + +# The WARN_NO_PARAMDOC option can be enabled to get warnings for +# functions that are documented, but have no documentation for their parameters +# or return value. If set to NO (the default) doxygen will only warn about +# wrong or incomplete parameter documentation, but not about the absence of +# documentation. + +WARN_NO_PARAMDOC = YES + +# The WARN_FORMAT tag determines the format of the warning messages that +# doxygen can produce. The string should contain the $file, $line, and $text +# tags, which will be replaced by the file and line number from which the +# warning originated and the warning text. Optionally the format may contain +# $version, which will be replaced by the version of the file (if it could +# be obtained via FILE_VERSION_FILTER) + +WARN_FORMAT = "$file:$line: $text" + +# The WARN_LOGFILE tag can be used to specify a file to which warning +# and error messages should be written. If left blank the output is written +# to stderr. + +WARN_LOGFILE = + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +# The INPUT tag can be used to specify the files and/or directories that contain +# documented source files. You may enter file names like "myfile.cpp" or +# directories like "/usr/src/myproject". Separate the files or directories +# with spaces. + +INPUT = + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 + +# If the value of the INPUT tag contains directories, you can use the +# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank the following patterns are tested: +# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh +# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py +# *.f90 *.f *.for *.vhd *.vhdl + +FILE_PATTERNS = + +# The RECURSIVE tag can be used to turn specify whether or not subdirectories +# should be searched for input files as well. Possible values are YES and NO. +# If left blank NO is used. + +RECURSIVE = YES + +# The EXCLUDE tag can be used to specify files and/or directories that should +# excluded from the INPUT source files. This way you can easily exclude a +# subdirectory from a directory tree whose root is specified with the INPUT tag. + +EXCLUDE = + +# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# directories that are symbolic links (a Unix file system feature) are excluded +# from the input. + +EXCLUDE_SYMLINKS = NO + +# If the value of the INPUT tag contains directories, you can use the +# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* + +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = + +# The EXAMPLE_PATH tag can be used to specify one or more files or +# directories that contain example code fragments that are included (see +# the \include command). + +EXAMPLE_PATH = + +# If the value of the EXAMPLE_PATH tag contains directories, you can use the +# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp +# and *.h) to filter out the source-files in the directories. If left +# blank all files are included. + +EXAMPLE_PATTERNS = * + +# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be +# searched for input files to be used with the \include or \dontinclude +# commands irrespective of the value of the RECURSIVE tag. +# Possible values are YES and NO. If left blank NO is used. + +EXAMPLE_RECURSIVE = NO + +# The IMAGE_PATH tag can be used to specify one or more files or +# directories that contain image that are included in the documentation (see +# the \image command). + +IMAGE_PATH = ./rsc + +# The INPUT_FILTER tag can be used to specify a program that doxygen should +# invoke to filter for each input file. Doxygen will invoke the filter program +# by executing (via popen()) the command , where +# is the value of the INPUT_FILTER tag, and is the name of an +# input file. Doxygen will then use the output that the filter program writes +# to standard output. +# If FILTER_PATTERNS is specified, this tag will be +# ignored. + +INPUT_FILTER = + +# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern +# basis. +# Doxygen will compare the file name with each pattern and apply the +# filter if there is a match. +# The filters are a list of the form: +# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further +# info on how filters are used. If FILTER_PATTERNS is empty or if +# non of the patterns match the file name, INPUT_FILTER is applied. + +FILTER_PATTERNS = + +# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using +# INPUT_FILTER) will be used to filter the input files when producing source +# files to browse (i.e. when SOURCE_BROWSER is set to YES). + +FILTER_SOURCE_FILES = NO + +# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file +# pattern. A pattern will override the setting for FILTER_PATTERN (if any) +# and it is also possible to disable source filtering for a specific pattern +# using *.ext= (so without naming a filter). This option only has effect when +# FILTER_SOURCE_FILES is enabled. + +FILTER_SOURCE_PATTERNS = + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +# If the SOURCE_BROWSER tag is set to YES then a list of source files will +# be generated. Documented entities will be cross-referenced with these sources. +# Note: To get rid of all source code in the generated output, make sure also +# VERBATIM_HEADERS is set to NO. + +SOURCE_BROWSER = YES + +# Setting the INLINE_SOURCES tag to YES will include the body +# of functions and classes directly in the documentation. + +INLINE_SOURCES = NO + +# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct +# doxygen to hide any special comment blocks from generated source code +# fragments. Normal C and C++ comments will always remain visible. + +STRIP_CODE_COMMENTS = NO + +# If the REFERENCED_BY_RELATION tag is set to YES +# then for each documented function all documented +# functions referencing it will be listed. + +REFERENCED_BY_RELATION = YES + +# If the REFERENCES_RELATION tag is set to YES +# then for each documented function all documented entities +# called/used by that function will be listed. + +REFERENCES_RELATION = YES + +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. +# Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = NO + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + +# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen +# will generate a verbatim copy of the header file for each class for +# which an include is specified. Set to NO to disable this. + +VERBATIM_HEADERS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- + +# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index +# of all compounds will be generated. Enable this if the project +# contains a lot of classes, structs, unions or interfaces. + +ALPHABETICAL_INDEX = NO + +# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then +# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns +# in which this list will be split (can be a number in the range [1..20]) + +COLS_IN_ALPHA_INDEX = 5 + +# In case all classes in a project start with a common prefix, all +# classes will be put under the same header in the alphabetical index. +# The IGNORE_PREFIX tag can be used to specify one or more prefixes that +# should be ignored while generating the index headers. + +IGNORE_PREFIX = + +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- + +# If the GENERATE_HTML tag is set to YES (the default) Doxygen will +# generate HTML output. + +GENERATE_HTML = YES + +# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `html' will be used as the default path. + +HTML_OUTPUT = html + +# The HTML_FILE_EXTENSION tag can be used to specify the file extension for +# each generated HTML page (for example: .htm,.php,.asp). If it is left blank +# doxygen will generate files with .html extension. + +HTML_FILE_EXTENSION = .html + +# The HTML_HEADER tag can be used to specify a personal HTML header for +# each generated HTML page. If it is left blank doxygen will generate a +# standard header. Note that when using a custom header you are responsible +# for the proper inclusion of any scripts and style sheets that doxygen +# needs, which is dependent on the configuration options used. +# It is adviced to generate a default header using "doxygen -w html +# header.html footer.html stylesheet.css YourConfigFile" and then modify +# that header. Note that the header is subject to change so you typically +# have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! + +HTML_HEADER = + +# The HTML_FOOTER tag can be used to specify a personal HTML footer for +# each generated HTML page. If it is left blank doxygen will generate a +# standard footer. + +HTML_FOOTER = + +# The HTML_STYLESHEET tag can be used to specify a user-defined cascading +# style sheet that is used by each HTML page. It can be used to +# fine-tune the look of the HTML output. If the tag is left blank doxygen +# will generate a default style sheet. Note that doxygen will try to copy +# the style sheet file to the HTML output directory, so don't put your own +# stylesheet in the HTML output directory as well, or it will be erased! + +HTML_STYLESHEET = + +# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or +# other source files which should be copied to the HTML output directory. Note +# that these files will be copied to the base HTML output directory. Use the +# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these +# files. In the HTML_STYLESHEET file, use the file name only. Also note that +# the files will be copied as-is; there are no commands or markers available. + +HTML_EXTRA_FILES = + +# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. +# Doxygen will adjust the colors in the stylesheet and background images +# according to this color. Hue is specified as an angle on a colorwheel, +# see http://en.wikipedia.org/wiki/Hue for more information. +# For instance the value 0 represents red, 60 is yellow, 120 is green, +# 180 is cyan, 240 is blue, 300 purple, and 360 is red again. +# The allowed range is 0 to 359. + +HTML_COLORSTYLE_HUE = 220 + +# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of +# the colors in the HTML output. For a value of 0 the output will use +# grayscales only. A value of 255 will produce the most vivid colors. + +HTML_COLORSTYLE_SAT = 100 + +# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to +# the luminance component of the colors in the HTML output. Values below +# 100 gradually make the output lighter, whereas values above 100 make +# the output darker. The value divided by 100 is the actual gamma applied, +# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, +# and 100 does not change the gamma. + +HTML_COLORSTYLE_GAMMA = 80 + +# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML +# page will contain the date and time when the page was generated. Setting +# this to NO can help when comparing the output of multiple runs. + +HTML_TIMESTAMP = YES + +# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, +# files or namespaces will be aligned in HTML using tables. If set to +# NO a bullet list will be used. + +HTML_ALIGN_MEMBERS = YES + +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = NO + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html +# for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "Doxygen generated docs" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.doxygen.Project + +# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify +# the documentation publisher. This should be a reverse domain-name style +# string, e.g. com.mycompany.MyDocSet.documentation. + +DOCSET_PUBLISHER_ID = org.doxygen.Publisher + +# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. + +DOCSET_PUBLISHER_NAME = Publisher + +# If the GENERATE_HTMLHELP tag is set to YES, additional index files +# will be generated that can be used as input for tools like the +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) +# of the generated HTML documentation. + +GENERATE_HTMLHELP = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can +# be used to specify the file name of the resulting .chm file. You +# can add a path in front of the file if the result should not be +# written to the html output directory. + +CHM_FILE = ../ChibiOS-LCD-Driver.chm + +# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can +# be used to specify the location (absolute path including file name) of +# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run +# the HTML help compiler on the generated index.hhp. + +HHC_LOCATION = "\"C:/Program Files/HTML Help Workshop/hhc.exe\"" + +# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag +# controls if a separate .chi index file is generated (YES) or that +# it should be included in the master .chm file (NO). + +GENERATE_CHI = NO + +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + +# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag +# controls whether a binary table of contents is generated (YES) or a +# normal table of contents (NO) in the .chm file. + +BINARY_TOC = NO + +# The TOC_EXPAND flag can be set to YES to add extra items for group members +# to the contents of the HTML help documentation and to the tree view. + +TOC_EXPAND = NO + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and +# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated +# that can be used as input for Qt's qhelpgenerator to generate a +# Qt Compressed Help (.qch) of the generated HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = org.doxygen.Project + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to +# add. For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the +# custom filter to add. For more information please see +# +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this +# project's +# filter section matches. +# +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = + +# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files +# will be generated, which together with the HTML files, form an Eclipse help +# plugin. To install this plugin and make it available under the help contents +# menu in Eclipse, the contents of the directory containing the HTML and XML +# files needs to be copied into the plugins directory of eclipse. The name of +# the directory within the plugins directory should be the same as +# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before +# the help appears. + +GENERATE_ECLIPSEHELP = NO + +# A unique identifier for the eclipse help plugin. When installing the plugin +# the directory name containing the HTML and XML files should also have +# this name. + +ECLIPSE_DOC_ID = org.doxygen.Project + +# The DISABLE_INDEX tag can be used to turn on/off the condensed index at +# top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. + +DISABLE_INDEX = NO + +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. + +ENUM_VALUES_PER_LINE = 4 + +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to YES, a side panel will be generated +# containing a tree-like index structure (just like the one that +# is generated for HTML Help). For this to work a browser that supports +# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). +# Windows users are probably better off using the HTML help feature. + +GENERATE_TREEVIEW = YES + +# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list. + +USE_INLINE_TREES = NO + +# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be +# used to set the initial width (in pixels) of the frame in which the tree +# is shown. + +TREEVIEW_WIDTH = 250 + +# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open +# links to external symbols imported via tag files in a separate window. + +EXT_LINKS_IN_WINDOW = NO + +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + +# Use the FORMULA_TRANPARENT tag to determine whether or not the images +# generated for formulas are transparent PNGs. Transparent PNGs are +# not supported properly for IE 6.0, but are supported on all modern browsers. +# Note that when changing this option you need to delete any form_*.png files +# in the HTML output before the changes have effect. + +FORMULA_TRANSPARENT = YES + +# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax +# (see http://www.mathjax.org) which uses client side Javascript for the +# rendering instead of using prerendered bitmaps. Use this if you do not +# have LaTeX installed or if you want to formulas look prettier in the HTML +# output. When enabled you also need to install MathJax separately and +# configure the path to it using the MATHJAX_RELPATH option. + +USE_MATHJAX = NO + +# When MathJax is enabled you need to specify the location relative to the +# HTML output directory using the MATHJAX_RELPATH option. The destination +# directory should contain the MathJax.js script. For instance, if the mathjax +# directory is located at the same level as the HTML output directory, then +# MATHJAX_RELPATH should be ../mathjax. The default value points to the +# mathjax.org site, so you can quickly see the result without installing +# MathJax, but it is strongly recommended to install a local copy of MathJax +# before deployment. + +MATHJAX_RELPATH = http://www.mathjax.org/mathjax + +# When the SEARCHENGINE tag is enabled doxygen will generate a search box +# for the HTML output. The underlying search engine uses javascript +# and DHTML and should work on any modern browser. Note that when using +# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets +# (GENERATE_DOCSET) there is already a search function so this one should +# typically be disabled. For large projects the javascript based search engine +# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. + +SEARCHENGINE = NO + +# When the SERVER_BASED_SEARCH tag is enabled the search engine will be +# implemented using a PHP enabled web server instead of at the web client +# using Javascript. Doxygen will generate the search PHP script and index +# file to put on the web server. The advantage of the server +# based approach is that it scales better to large projects and allows +# full text search. The disadvantages are that it is more difficult to setup +# and does not have live searching capabilities. + +SERVER_BASED_SEARCH = NO + +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- + +# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will +# generate Latex output. + +GENERATE_LATEX = NO + +# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `latex' will be used as the default path. + +LATEX_OUTPUT = latex + +# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be +# invoked. If left blank `latex' will be used as the default command name. +# Note that when enabling USE_PDFLATEX this option is only used for +# generating bitmaps for formulas in the HTML output, but not in the +# Makefile that is written to the output directory. + +LATEX_CMD_NAME = latex + +# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to +# generate index for LaTeX. If left blank `makeindex' will be used as the +# default command name. + +MAKEINDEX_CMD_NAME = makeindex + +# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact +# LaTeX documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_LATEX = NO + +# The PAPER_TYPE tag can be used to set the paper type that is used +# by the printer. Possible values are: a4, letter, legal and +# executive. If left blank a4wide will be used. + +PAPER_TYPE = a4wide + +# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX +# packages that should be included in the LaTeX output. + +EXTRA_PACKAGES = + +# The LATEX_HEADER tag can be used to specify a personal LaTeX header for +# the generated latex document. The header should contain everything until +# the first chapter. If it is left blank doxygen will generate a +# standard header. Notice: only use this tag if you know what you are doing! + +LATEX_HEADER = + +# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for +# the generated latex document. The footer should contain everything after +# the last chapter. If it is left blank doxygen will generate a +# standard footer. Notice: only use this tag if you know what you are doing! + +LATEX_FOOTER = + +# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated +# is prepared for conversion to pdf (using ps2pdf). The pdf file will +# contain links (just like the HTML output) instead of page references +# This makes the output suitable for online browsing using a pdf viewer. + +PDF_HYPERLINKS = YES + +# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of +# plain latex in the generated Makefile. Set this option to YES to get a +# higher quality PDF documentation. + +USE_PDFLATEX = YES + +# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. +# command to the generated LaTeX files. This will instruct LaTeX to keep +# running if errors occur, instead of asking the user for help. +# This option is also used when generating formulas in HTML. + +LATEX_BATCHMODE = NO + +# If LATEX_HIDE_INDICES is set to YES then doxygen will not +# include the index chapters (such as File Index, Compound Index, etc.) +# in the output. + +LATEX_HIDE_INDICES = NO + +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- + +# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output +# The RTF output is optimized for Word 97 and may not look very pretty with +# other RTF readers or editors. + +GENERATE_RTF = NO + +# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `rtf' will be used as the default path. + +RTF_OUTPUT = rtf + +# If the COMPACT_RTF tag is set to YES Doxygen generates more compact +# RTF documents. This may be useful for small projects and may help to +# save some trees in general. + +COMPACT_RTF = NO + +# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated +# will contain hyperlink fields. The RTF file will +# contain links (just like the HTML output) instead of page references. +# This makes the output suitable for online browsing using WORD or other +# programs which support those fields. +# Note: wordpad (write) and others do not support links. + +RTF_HYPERLINKS = NO + +# Load stylesheet definitions from file. Syntax is similar to doxygen's +# config file, i.e. a series of assignments. You only have to provide +# replacements, missing definitions are set to their default value. + +RTF_STYLESHEET_FILE = + +# Set optional variables used in the generation of an rtf document. +# Syntax is similar to doxygen's config file. + +RTF_EXTENSIONS_FILE = + +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- + +# If the GENERATE_MAN tag is set to YES (the default) Doxygen will +# generate man pages + +GENERATE_MAN = NO + +# The MAN_OUTPUT tag is used to specify where the man pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `man' will be used as the default path. + +MAN_OUTPUT = man + +# The MAN_EXTENSION tag determines the extension that is added to +# the generated man pages (default is the subroutine's section .3) + +MAN_EXTENSION = .3 + +# If the MAN_LINKS tag is set to YES and Doxygen generates man output, +# then it will generate one additional man file for each entity +# documented in the real man page(s). These additional files +# only source the real man page, but without them the man command +# would be unable to find the correct page. The default is NO. + +MAN_LINKS = NO + +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- + +# If the GENERATE_XML tag is set to YES Doxygen will +# generate an XML file that captures the structure of +# the code including all documentation. + +GENERATE_XML = NO + +# The XML_OUTPUT tag is used to specify where the XML pages will be put. +# If a relative path is entered the value of OUTPUT_DIRECTORY will be +# put in front of it. If left blank `xml' will be used as the default path. + +XML_OUTPUT = xml + +# The XML_SCHEMA tag can be used to specify an XML schema, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_SCHEMA = + +# The XML_DTD tag can be used to specify an XML DTD, +# which can be used by a validating XML parser to check the +# syntax of the XML files. + +XML_DTD = + +# If the XML_PROGRAMLISTING tag is set to YES Doxygen will +# dump the program listings (including syntax highlighting +# and cross-referencing information) to the XML output. Note that +# enabling this will significantly increase the size of the XML output. + +XML_PROGRAMLISTING = YES + +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- + +# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will +# generate an AutoGen Definitions (see autogen.sf.net) file +# that captures the structure of the code including all +# documentation. Note that this feature is still experimental +# and incomplete at the moment. + +GENERATE_AUTOGEN_DEF = NO + +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- + +# If the GENERATE_PERLMOD tag is set to YES Doxygen will +# generate a Perl module file that captures the structure of +# the code including all documentation. Note that this +# feature is still experimental and incomplete at the +# moment. + +GENERATE_PERLMOD = NO + +# If the PERLMOD_LATEX tag is set to YES Doxygen will generate +# the necessary Makefile rules, Perl scripts and LaTeX code to be able +# to generate PDF and DVI output from the Perl module output. + +PERLMOD_LATEX = NO + +# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be +# nicely formatted so it can be parsed by a human reader. +# This is useful +# if you want to understand what is going on. +# On the other hand, if this +# tag is set to NO the size of the Perl module output will be much smaller +# and Perl will parse it just the same. + +PERLMOD_PRETTY = YES + +# The names of the make variables in the generated doxyrules.make file +# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. +# This is useful so different doxyrules.make files included by the same +# Makefile don't overwrite each other's variables. + +PERLMOD_MAKEVAR_PREFIX = + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will +# evaluate all C-preprocessor directives found in the sources and include +# files. + +ENABLE_PREPROCESSING = YES + +# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro +# names in the source code. If set to NO (the default) only conditional +# compilation will be performed. Macro expansion can be done in a controlled +# way by setting EXPAND_ONLY_PREDEF to YES. + +MACRO_EXPANSION = YES + +# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES +# then the macro expansion is limited to the macros specified with the +# PREDEFINED and EXPAND_AS_DEFINED tags. + +EXPAND_ONLY_PREDEF = YES + +# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files +# pointed to by INCLUDE_PATH will be searched when a #include is found. + +SEARCH_INCLUDES = YES + +# The INCLUDE_PATH tag can be used to specify one or more directories that +# contain include files that are not input files but should be processed by +# the preprocessor. + +INCLUDE_PATH = + +# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard +# patterns (like *.h and *.hpp) to filter out the header-files in the +# directories. If left blank, the patterns specified with FILE_PATTERNS will +# be used. + +INCLUDE_FILE_PATTERNS = + +# The PREDEFINED tag can be used to specify one or more macro names that +# are defined before the preprocessor is started (similar to the -D option of +# gcc). The argument of the tag is a list of macros of the form: name +# or name=definition (no spaces). If the definition and the = are +# omitted =1 is assumed. To prevent a macro definition from being +# undefined via #undef or recursively expanded use the := operator +# instead of the = operator. + +PREDEFINED = __DOXYGEN__ + +# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then +# this tag can be used to specify a list of macro names that should be expanded. +# The macro definition that is found in the sources will be used. +# Use the PREDEFINED tag if you want to use a different macro definition that +# overrules the definition found in the source code. + +EXPAND_AS_DEFINED = + +# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then +# doxygen's preprocessor will remove all references to function-like macros +# that are alone on a line, have an all uppercase name, and do not end with a +# semicolon, because these will confuse the parser if not removed. + +SKIP_FUNCTION_MACROS = NO + +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- + +# The TAGFILES option can be used to specify one or more tagfiles. +# Optionally an initial location of the external documentation +# can be added for each tagfile. The format of a tag file without +# this location is as follows: +# +# TAGFILES = file1 file2 ... +# Adding location for the tag files is done as follows: +# +# TAGFILES = file1=loc1 "file2 = loc2" ... +# where "loc1" and "loc2" can be relative or absolute paths or +# URLs. If a location is present for each tag, the installdox tool +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) +# If a tag file is not located in the directory in which doxygen +# is run, you must also specify the path to the tagfile here. + +TAGFILES = + +# When a file name is specified after GENERATE_TAGFILE, doxygen will create +# a tag file that is based on the input files it reads. + +GENERATE_TAGFILE = + +# If the ALLEXTERNALS tag is set to YES all external classes will be listed +# in the class index. If set to NO only the inherited external classes +# will be listed. + +ALLEXTERNALS = NO + +# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed +# in the modules index. If set to NO, only the current project's groups will +# be listed. + +EXTERNAL_GROUPS = YES + +# The PERL_PATH should be the absolute path and name of the perl script +# interpreter (i.e. the result of `which perl'). + +PERL_PATH = /usr/bin/perl + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will +# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base +# or super classes. Setting the tag to NO turns the diagrams off. Note that +# this option also works with HAVE_DOT disabled, but it is recommended to +# install and use dot, since it yields more powerful graphs. + +CLASS_DIAGRAMS = NO + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = + +# If set to YES, the inheritance and collaboration graphs will hide +# inheritance and usage relations if the target is undocumented +# or is not a class. + +HIDE_UNDOC_RELATIONS = YES + +# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is +# available from the path. This tool is part of Graphviz, a graph visualization +# toolkit from AT&T and Lucent Bell Labs. The other options in this section +# have no effect if this option is set to NO (the default) + +HAVE_DOT = YES + +# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is +# allowed to run in parallel. When set to 0 (the default) doxygen will +# base this on the number of processors available in the system. You can set it +# explicitly to a value larger than 0 to get control over the balance +# between CPU load and processing speed. + +DOT_NUM_THREADS = 0 + +# By default doxygen will write a font called Helvetica to the output +# directory and reference it in all dot files that doxygen generates. +# When you want a differently looking font you can specify the font name +# using DOT_FONTNAME. You need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 8 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = + +# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect inheritance relations. Setting this tag to YES will force the +# the CLASS_DIAGRAMS tag to NO. + +CLASS_GRAPH = YES + +# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for each documented class showing the direct and +# indirect implementation dependencies (inheritance, containment, and +# class references variables) of the class with other documented classes. + +COLLABORATION_GRAPH = YES + +# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen +# will generate a graph for groups, showing the direct groups dependencies + +GROUP_GRAPHS = YES + +# If the UML_LOOK tag is set to YES doxygen will generate inheritance and +# collaboration diagrams in a style similar to the OMG's Unified Modeling +# Language. + +UML_LOOK = YES + +# If set to YES, the inheritance and collaboration graphs will show the +# relations between templates and their instances. + +TEMPLATE_RELATIONS = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT +# tags are set to YES then doxygen will generate a graph for each documented +# file showing the direct and indirect include dependencies of the file with +# other documented files. + +INCLUDE_GRAPH = NO + +# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and +# HAVE_DOT tags are set to YES then doxygen will generate a graph for each +# documented header file showing the documented files that directly or +# indirectly include this file. + +INCLUDED_BY_GRAPH = NO + +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. + +CALL_GRAPH = YES + +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + +# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen +# will generate a graphical hierarchy of all classes instead of a textual one. + +GRAPHICAL_HIERARCHY = YES + +# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# then doxygen will show the dependencies a directory has on other directories +# in a graphical way. The dependency relations are determined by the #include +# relations between the files in the directories. + +DIRECTORY_GRAPH = NO + +# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images +# generated by dot. Possible values are svg, png, jpg, or gif. +# If left blank png will be used. + +DOT_IMAGE_FORMAT = png + +# The tag DOT_PATH can be used to specify the path where the dot tool can be +# found. If left blank, it is assumed the dot tool can be found in the path. + +DOT_PATH = + +# The DOTFILE_DIRS tag can be used to specify one or more directories that +# contain dot files that are included in the documentation (see the +# \dotfile command). + +DOTFILE_DIRS = + +# The MSCFILE_DIRS tag can be used to specify one or more directories that +# contain msc files that are included in the documentation (see the +# \mscfile command). + +MSCFILE_DIRS = + +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. + +DOT_GRAPH_MAX_NODES = 20 + +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. + +MAX_DOT_GRAPH_DEPTH = 3 + +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). + +DOT_TRANSPARENT = YES + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES + +# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will +# generate a legend page explaining the meaning of the various boxes and +# arrows in the dot generated graphs. + +GENERATE_LEGEND = YES + +# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will +# remove the intermediate dot files that are used to generate +# the various graphs. + +DOT_CLEANUP = YES + From c5e9fa504f425f0fa11054bee85b2dd50a75b48c Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 12:54:22 +0200 Subject: [PATCH 04/47] added SPI config struct to TOUCHPADDriver --- halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c | 8 +------- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c | 8 +------- halext/include/touchpad_lld.h | 6 +++++- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c index 85db56e7..a5265995 100644 --- a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c @@ -59,12 +59,6 @@ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ -static const SPIConfig spicfg = { - NULL, - TP_CS_PORT, - TP_CS, - SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; /*===========================================================================*/ /* Driver local functions. */ @@ -86,7 +80,7 @@ static const SPIConfig spicfg = { * @notapi */ void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, &spicfg); + spiStart(tp->spid, tp->spicfg); } /** diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 00f6336c..a222a6aa 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -59,12 +59,6 @@ /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ -static const SPIConfig spicfg = { - NULL, - TP_CS_PORT, - TP_CS, - SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; /*===========================================================================*/ /* Driver local functions. */ @@ -86,7 +80,7 @@ static const SPIConfig spicfg = { * @notapi */ void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, &spicfg); + spiStart(tp->spid, tp->spicfg); } /** diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index c0339e05..45a561d3 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -61,9 +61,13 @@ typedef struct TOUCHPADDriver TOUCHPADDriver; struct TOUCHPADDriver { /* * @brief Pointer to SPI driver. - * @note SPI driver must be enabled in mcu- and halconf.h */ SPIDriver *spid; + + /* + * @brief SPI configuration. + */ + SPIConfig *spicfg; }; /*===========================================================================*/ From 58ddfd92104854ba58a68e85021a4bd0a6a8a99d Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 9 Aug 2012 16:25:23 +0530 Subject: [PATCH 05/47] Changes to the Touchpad Configuration structure Added field to the driver structure to set PENIRQ pin and port, defines removed --- halext/include/touchpad_lld.h | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h index c0339e05..a654299b 100644 --- a/halext/include/touchpad_lld.h +++ b/halext/include/touchpad_lld.h @@ -53,17 +53,36 @@ /* Driver types. */ /*===========================================================================*/ -typedef struct TOUCHPADDriver TOUCHPADDriver; +typedef struct _TOUCHPADDriver TOUCHPADDriver; /** * @brief Structure representing a Touchpad driver. */ -struct TOUCHPADDriver { +struct _TOUCHPADDriver { /* * @brief Pointer to SPI driver. - * @note SPI driver must be enabled in mcu- and halconf.h + * @note SPI driver must be enabled in mcuconf.h and halconf.h */ - SPIDriver *spid; + SPIDriver *spip; + + /* + * @brief Pointer to the SPI configuration structure. + * @note The lowest possible speed ~ 1-2MHz is to be used, otherwise + * will result in a lot of noise + */ + SPIConfig *spicfg; + + /* + * @brief Touchscreen controller TPIRQ pin GPIO port + */ + ioportid_t tpIRQPort; + + /* + * @brief Touchscreen controller TPIRQ GPIO pin + * @note The lowest possible speed ~ 1-2MHz is to be used, otherwise + * will result in a lot of noise + */ + ioportmask_t tpIRQPin; }; /*===========================================================================*/ From 823db82c7ff6584fdee8caf02de79dd82bfac25c Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 9 Aug 2012 16:26:08 +0530 Subject: [PATCH 06/47] Update to touchpad LLDs to use new structure. --- .../touchpad/touchpadADS7843/touchpad_lld.c | 26 ++++------- .../touchpad/touchpadXPT2046/touchpad_lld.c | 45 ++++++++----------- 2 files changed, 28 insertions(+), 43 deletions(-) diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c index 85db56e7..313fdb86 100644 --- a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c @@ -52,19 +52,11 @@ /* Driver exported variables. */ /*===========================================================================*/ -#if !defined(__DOXYGEN__) - TOUCHPADDriver Touchpad; -#endif /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ -static const SPIConfig spicfg = { - NULL, - TP_CS_PORT, - TP_CS, - SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; +static TOUCHPADDriver* tpDriver; /*===========================================================================*/ /* Driver local functions. */ @@ -86,7 +78,7 @@ static const SPIConfig spicfg = { * @notapi */ void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, &spicfg); + spiStart(tp->spip, tp->spicfg); } /** @@ -100,10 +92,10 @@ uint16_t tp_lld_read_x(void) { uint16_t y; txbuf[0] = 0xd0; - TP_CS_LOW; + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); spiSend(&SPID1, 1, txbuf); spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); y = rxbuf[0] << 4; y |= rxbuf[1] >> 4; @@ -122,10 +114,10 @@ uint16_t tp_lld_read_y(void) { uint16_t y; txbuf[0] = 0x90; - TP_CS_LOW; + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); spiSend(&SPID1, 1, txbuf); spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); y = rxbuf[0] << 4; y |= rxbuf[1] >> 4; @@ -142,9 +134,9 @@ uint16_t tp_lld_read_y(void) { * * @noapi */ - uint8_t tp_lld_irq(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); - } + uint8_t tp_lld_irq(void) { + return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); + } #endif #endif /* HAL_USE_TOUCHPAD */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 00f6336c..876cb4ba 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -36,9 +36,6 @@ /* Driver local definitions. */ /*===========================================================================*/ -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) @@ -52,32 +49,27 @@ /* Driver exported variables. */ /*===========================================================================*/ -#if !defined(__DOXYGEN__) - TOUCHPADDriver Touchpad; -#endif /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ -static const SPIConfig spicfg = { - NULL, - TP_CS_PORT, - TP_CS, - SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; +static TOUCHPADDriver* tpDriver; /*===========================================================================*/ /* Driver local functions. */ /*===========================================================================*/ + /*===========================================================================*/ /* Driver interrupt handlers. */ /*===========================================================================*/ + /*===========================================================================*/ /* Driver exported functions. */ /*===========================================================================*/ + /* ---- Required Routines ---- */ /** @@ -86,7 +78,9 @@ static const SPIConfig spicfg = { * @notapi */ void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, &spicfg); + tpDriver=tp; + + spiStart(tp->spip, tp->spicfg); } /** @@ -100,11 +94,10 @@ uint16_t tp_lld_read_x(void) { uint16_t y; txbuf[0] = 0xd0; - TP_CS_LOW; + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); spiSend(&SPID1, 1, txbuf); spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); y = rxbuf[0] << 4; y |= rxbuf[1] >> 4; @@ -122,10 +115,10 @@ uint16_t tp_lld_read_y(void) { uint16_t y; txbuf[0] = 0x90; - TP_CS_LOW; + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); spiSend(&SPID1, 1, txbuf); spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); y = rxbuf[0] << 4; y |= rxbuf[1] >> 4; @@ -135,15 +128,15 @@ uint16_t tp_lld_read_y(void) { /* ---- Optional Routines ---- */ #if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) - /* - * @brief for checking if touchpad is pressed or not. - * - * @return 1 if pressed / 0 if not pressed - * - * @noapi - */ + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @noapi + */ uint8_t tp_lld_irq(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); } #endif From 65b3e2d7196a16c134cef96c55c26b40c03382a4 Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 9 Aug 2012 14:28:24 +0200 Subject: [PATCH 07/47] small doc fixes --- halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index a222a6aa..195c8aa6 100644 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -106,7 +106,7 @@ uint16_t tp_lld_read_x(void) { } /* - * @brief Reads out the X direction. + * @brief Reads out the Y direction. * * @notapi */ @@ -134,7 +134,7 @@ uint16_t tp_lld_read_y(void) { * * @return 1 if pressed / 0 if not pressed * - * @noapi + * @notapi */ uint8_t tp_lld_irq(void) { return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); From f0cb18c2cf747c2a9fed1717298a44dae96c119c Mon Sep 17 00:00:00 2001 From: Tectu Date: Fri, 10 Aug 2012 00:36:05 +0200 Subject: [PATCH 08/47] removed demos since out of date --- demos/README | 24 ------------- demos/console/main.c | 51 -------------------------- demos/drawing/main.c | 48 ------------------------- demos/gui/main.c | 79 ----------------------------------------- demos/powermodes/main.c | 55 ---------------------------- 5 files changed, 257 deletions(-) delete mode 100644 demos/README delete mode 100755 demos/console/main.c delete mode 100755 demos/drawing/main.c delete mode 100755 demos/gui/main.c delete mode 100755 demos/powermodes/main.c diff --git a/demos/README b/demos/README deleted file mode 100644 index 3d3d6013..00000000 --- a/demos/README +++ /dev/null @@ -1,24 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -This are a few demos, showing how to use the library. - -Please note that this are not compilable projects. - diff --git a/demos/console/main.c b/demos/console/main.c deleted file mode 100755 index b8ccd633..00000000 --- a/demos/console/main.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" -#include "glcd.h" -#include "test.h" -#include "console.h" - -static GLCDDriver GLCDD1; -static GLCDConsole CON1; - -int main(void) { - halInit(); - chSysInit(); - - // init LCD and clear it - lcdInit(&GLCDD1); - lcdClear(Black); - - // init console - lcdConsoleInit(&CON1, 0, 0, lcdGetWidth(), lcdGetHeight(), font_Small, Black, White); - - // use test thread for console output - TestThread((BaseSequentialStream*)&CON1); - - while (TRUE) { - - chThdSleepMilliseconds(200); - } - - return 0; -} - diff --git a/demos/drawing/main.c b/demos/drawing/main.c deleted file mode 100755 index 391b0786..00000000 --- a/demos/drawing/main.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" -#include "glcd.h" - -static GLCDDriver GLCDD1; - -int main(void) { - halInit(); - chSysInit(); - - lcdInit(&GLCDD1); - lcdClear(Black); - lcdDrawString(100, 100, "Hello World", White, Black); - - lcdMoveCursor(10,10,White, Black); - chprintf((BaseSequentialStream *)&GLCDD1, "chTimeNow: %d", chTimeNow()); - - lcdDrawCircle(150, 150, 10, filled, Green); - lcdDrawLine(0, 0, lcdGetWidth(), lcdGetHeight(), Yellow); - - while (TRUE) { - - chThdSleepMilliseconds(200); - } - - return 0; -} - diff --git a/demos/gui/main.c b/demos/gui/main.c deleted file mode 100755 index ca1a499b..00000000 --- a/demos/gui/main.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" -#include "gui.h" -#include "glcd.h" -#include "touchpad.h" - -// GLCD driver object -static GLCDDriver GLCDD1; - -int main(void) { - uint8_t setActive, setState, clearActive, clearState; - - halInit(); - chSysInit(); - - // Initializes the LCD - lcdInit(&GLCDD1); - - // Initializes the touchpad - tpInit(&SPID1); - - // clear the entire LCD screen - lcdClear(Black); - - // Initializes the GUI thread - // 10ms interval - // HIGHPRIO thread priority level - guiInit(10, HIGHPRIO); - - // set the following buttons to active - // buttons wouldn't have any effect if you set these variables to 'inactive' - setActive = active; - clearActive = active; - - // draw a button to set, and one to clear the LED - guiDrawButton(10, 10, 60, 60, "Set", font_Larger, Black, Yellow, 6, "SetButton", &setActive, &setState); - guiDrawButton(70, 10, 120, 60, "Clear", font_Larger, Black, Red, 6, "ClearButton", &clearActive, &clearState); - - // you can delete a GUI element at any time from the GUI. You have to pass the GUI element name here. - // please note that you have to redraw the screen to delete the element yourself. - // guiDeleteElement("SetButton"); - // guiDeleteElement("ClearButton"); - - while (TRUE) { - - // check if button 'set' is pressed - if(setState) - palSetPad(GPIOD, GPIOD_LED3); - - // check if button 'clear' is pressed - if(clearState) - palClearPad(GPIOD, GPIOD_LED3); - - chThdSleepMilliseconds(200); - } - - return 0; -} - diff --git a/demos/powermodes/main.c b/demos/powermodes/main.c deleted file mode 100755 index 8a138d06..00000000 --- a/demos/powermodes/main.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" -#include "glcd.h" - -static GLCDDriver GLCDD1; - -int main(void) { - halInit(); - chSysInit(); - - lcdInit(&GLCDD1); - lcdClear(Black); - lcdDrawString(100, 100, "Hello World", White, Black); - - // wait two seconds to see current LCD content - chThdSleepSeconds(2); - - // brings LCD to sleep mode - lcdSetPowerMode(sleepOn); - - // wait two seconds to see current LCD content - chThdSleepSeconds(2); - - // brings LCD back from sleep mode - // content displayed before gets displayed again - lcdSetPowerMode(sleepOff); - - while (TRUE) { - - chThdSleepMilliseconds(200); - } - - return 0; -} - From 055cc454eca7d134eed4bd38c015e4959b3cc340 Mon Sep 17 00:00:00 2001 From: Tectu Date: Fri, 10 Aug 2012 00:50:04 +0200 Subject: [PATCH 09/47] Calibration string fix --- halext/src/touchpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c index 3539ad32..977bb31c 100644 --- a/halext/src/touchpad.c +++ b/halext/src/touchpad.c @@ -210,7 +210,7 @@ void tpCalibrate(void) { //gdispSetOrientation(portrait); gdispClear(Red); - gdispDrawString(40, 10, "Calibration", &fontUI1Double, White); + gdispFillStringBox(0, 10, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Red, justifyCenter); for(i = 0; i < 2; i++) { _tpDrawCross(cross[i][0], cross[i][1]); From 91ff4f0e8c42268f8d28605ce1fa6f3b7e4047ff Mon Sep 17 00:00:00 2001 From: Thomas Saunders Date: Sat, 11 Aug 2012 14:03:07 +0100 Subject: [PATCH 10/47] re-fix S6D1121 vertical scroll --- halext/drivers/gdispS6d1121/gdisp_lld.c | 2 +- halext/drivers/gdispS6d1121/gdisp_lld_config.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/halext/drivers/gdispS6d1121/gdisp_lld.c b/halext/drivers/gdispS6d1121/gdisp_lld.c index 32e0fa32..5811a6ed 100644 --- a/halext/drivers/gdispS6d1121/gdisp_lld.c +++ b/halext/drivers/gdispS6d1121/gdisp_lld.c @@ -561,7 +561,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); lld_lcdWriteStreamStart(); gap = cx*abslines; - for(i = 0; i < gap; i++) lld_lcdWriteData(color); + for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); lld_lcdWriteStreamStop(); lld_lcdResetViewPort(); } diff --git a/halext/drivers/gdispS6d1121/gdisp_lld_config.h b/halext/drivers/gdispS6d1121/gdisp_lld_config.h index 57aaf692..ee3fdeee 100644 --- a/halext/drivers/gdispS6d1121/gdisp_lld_config.h +++ b/halext/drivers/gdispS6d1121/gdisp_lld_config.h @@ -48,7 +48,7 @@ #define GDISP_HARDWARE_ELLIPSEFILLS FALSE #define GDISP_HARDWARE_TEXT FALSE #define GDISP_HARDWARE_TEXTFILLS FALSE -#define GDISP_HARDWARE_SCROLL FALSE +#define GDISP_HARDWARE_SCROLL TRUE #define GDISP_HARDWARE_PIXELREAD FALSE #define GDISP_HARDWARE_CONTROL TRUE #define GDISP_HARDWARE_QUERY FALSE From 1c105a40cfc676f2166ad93251147ab52ca06874 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 02:45:49 +0200 Subject: [PATCH 11/47] added demos readme --- demos/readme.txt | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 demos/readme.txt diff --git a/demos/readme.txt b/demos/readme.txt new file mode 100644 index 00000000..fbea2090 --- /dev/null +++ b/demos/readme.txt @@ -0,0 +1,4 @@ +This folder contains a few demos which explain how to use the library. + +Only the main files are contained. No compile-able projects + From 2285ddfc63b852e60fa0a95d32ffb6cc1d59c8a2 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 02:48:05 +0200 Subject: [PATCH 12/47] added touchpad demo --- demos/touchpad/main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 demos/touchpad/main.c diff --git a/demos/touchpad/main.c b/demos/touchpad/main.c new file mode 100644 index 00000000..1651a3bf --- /dev/null +++ b/demos/touchpad/main.c @@ -0,0 +1,26 @@ +#include "ch.h" +#include "hal.h" +#include "gdisp.h" +#include "touchpad.h" + +TOUCHPADDriver TOUCHPADD1 = { + &SPID1, +}; + +int main(void) { + halInit(); + chSysInit(); + + gdispInit(); + gdispClear(Lime); + + tpInit(&TOUCHPADD1); + tpCalibrate(); + + while (TRUE) { + gdispFillCircle(tpReadX(), tpReadY(), 3, Black); + + chThdSleepMilliseconds(100); + } +} + From e7f0c8e2c2791fd2e571c762f03e277161f98a4b Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 02:51:30 +0200 Subject: [PATCH 13/47] added lcd demo dummy --- demos/lcd/main.c | 19 +++++++++++++++++++ demos/touchpad/main.c | 26 -------------------------- 2 files changed, 19 insertions(+), 26 deletions(-) create mode 100644 demos/lcd/main.c delete mode 100644 demos/touchpad/main.c diff --git a/demos/lcd/main.c b/demos/lcd/main.c new file mode 100644 index 00000000..99b87948 --- /dev/null +++ b/demos/lcd/main.c @@ -0,0 +1,19 @@ +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +int main(void) { + halInit(); + chSysInit(); + + gdispInit(); + gdispClear(Black); + + // gdispDrawXXX(...); + + while (TRUE) { + + chThdSleepMilliseconds(100); + } +} + diff --git a/demos/touchpad/main.c b/demos/touchpad/main.c deleted file mode 100644 index 1651a3bf..00000000 --- a/demos/touchpad/main.c +++ /dev/null @@ -1,26 +0,0 @@ -#include "ch.h" -#include "hal.h" -#include "gdisp.h" -#include "touchpad.h" - -TOUCHPADDriver TOUCHPADD1 = { - &SPID1, -}; - -int main(void) { - halInit(); - chSysInit(); - - gdispInit(); - gdispClear(Lime); - - tpInit(&TOUCHPADD1); - tpCalibrate(); - - while (TRUE) { - gdispFillCircle(tpReadX(), tpReadY(), 3, Black); - - chThdSleepMilliseconds(100); - } -} - From 54229cbdaaf585b5adf9b085229a22c9824c112c Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 04:11:03 +0200 Subject: [PATCH 14/47] restructure --- drivers/drivers.mk | 8 - drivers/lcd/s6d1121_lld.c | 543 ---------- drivers/lcd/s6d1121_lld.h | 73 -- drivers/lcd/ssd1289_lld.c | 469 -------- drivers/lcd/ssd1289_lld.h | 182 ---- drivers/touchpad/ads7843_lld.c | 63 -- drivers/touchpad/ads7843_lld.h | 35 - drivers/touchpad/xpt2046_lld.c | 63 -- drivers/touchpad/xpt2046_lld.h | 35 - glcd/console.c | 171 --- glcd/console.h | 84 -- glcd/glcd.c | 431 -------- glcd/glcd.h | 148 --- glcd/glcd.mk | 5 - glcd/glcdWorker.h | 170 --- glcd/readme.txt | 25 - glcdconf.h | 47 - graph/graph.c | 75 -- graph/graph.h | 72 -- graph/graph.mk | 3 - gui/gui.c | 334 ------ gui/gui.h | 115 -- gui/gui.mk | 3 - halext/drivers/gdispNokia6610/GE12.h | 81 -- halext/drivers/gdispNokia6610/GE8.h | 67 -- halext/drivers/gdispNokia6610/gdisp_lld.c | 688 ------------ halext/drivers/gdispNokia6610/gdisp_lld.mk | 5 - .../gdispNokia6610/gdisp_lld_board_example.h | 97 -- .../gdisp_lld_board_olimexsam7ex256.h | 199 ---- .../drivers/gdispNokia6610/gdisp_lld_config.h | 66 -- halext/drivers/gdispNokia6610/readme.txt | 17 - halext/drivers/gdispS6d1121/gdisp_lld.c | 688 ------------ halext/drivers/gdispS6d1121/gdisp_lld.mk | 5 - .../drivers/gdispS6d1121/gdisp_lld_config.h | 66 -- halext/drivers/gdispS6d1121/readme.txt | 16 - halext/drivers/gdispS6d1121/s6d1121_lld.c.h | 244 ----- halext/drivers/gdispSsd1289/gdisp_lld.c | 610 ----------- halext/drivers/gdispSsd1289/gdisp_lld.mk | 5 - .../drivers/gdispSsd1289/gdisp_lld_config.h | 66 -- halext/drivers/gdispSsd1289/readme.txt | 16 - halext/drivers/gdispSsd1289/ssd1289_lld.c.h | 322 ------ halext/drivers/gdispTestStub/gdisp_lld.c | 361 ------- halext/drivers/gdispTestStub/gdisp_lld.mk | 5 - .../drivers/gdispTestStub/gdisp_lld_config.h | 66 -- halext/drivers/gdispTestStub/readme.txt | 17 - halext/drivers/gdispVMT/gdisp_lld.c | 249 ----- halext/drivers/gdispVMT/gdisp_lld.mk | 7 - halext/drivers/gdispVMT/gdisp_lld_config.h | 67 -- halext/drivers/gdispVMT/gdisp_lld_driver1.c | 51 - halext/drivers/gdispVMT/gdisp_lld_driver2.c | 51 - halext/drivers/gdispVMT/readme.txt | 23 - .../touchpad/touchpadADS7843/readme.txt | 9 - .../touchpad/touchpadADS7843/touchpad_lld.c | 146 --- .../touchpad/touchpadADS7843/touchpad_lld.mk | 6 - .../touchpadADS7843/touchpad_lld_config.h | 44 - .../touchpad/touchpadXPT2046/readme.txt | 9 - .../touchpad/touchpadXPT2046/touchpad_lld.c | 158 --- .../touchpad/touchpadXPT2046/touchpad_lld.mk | 6 - .../touchpadXPT2046/touchpad_lld_config.h | 44 - halext/halext.mk | 9 - halext/include/gdisp.h | 266 ----- halext/include/gdisp_emulation.c | 549 ---------- halext/include/gdisp_fonts.h | 90 -- halext/include/gdisp_lld.h | 599 ----------- halext/include/gdisp_lld_msgs.h | 165 --- halext/include/glcd.h | 136 --- halext/include/touchpad.h | 93 -- halext/include/touchpad_lld.h | 106 -- halext/readme.txt | 28 - halext/src/gdisp-readme.txt | 14 - halext/src/gdisp.c | 997 ------------------ halext/src/gdisp_fonts.c | 655 ------------ halext/src/touchpad.c | 261 ----- halext/templates/gdispXXXXX/gdisp_lld.c | 490 --------- halext/templates/gdispXXXXX/gdisp_lld.mk | 5 - .../templates/gdispXXXXX/gdisp_lld_config.h | 66 -- halext/templates/gdispXXXXX/readme.txt | 35 - halext/templates/readme.txt | 4 - lcd.mk | 29 +- readme | 19 - touchpad/touchpad.c | 161 --- touchpad/touchpad.h | 109 -- touchpad/touchpad.mk | 3 - 83 files changed, 4 insertions(+), 12616 deletions(-) delete mode 100644 drivers/drivers.mk delete mode 100644 drivers/lcd/s6d1121_lld.c delete mode 100644 drivers/lcd/s6d1121_lld.h delete mode 100644 drivers/lcd/ssd1289_lld.c delete mode 100644 drivers/lcd/ssd1289_lld.h delete mode 100644 drivers/touchpad/ads7843_lld.c delete mode 100644 drivers/touchpad/ads7843_lld.h delete mode 100644 drivers/touchpad/xpt2046_lld.c delete mode 100644 drivers/touchpad/xpt2046_lld.h delete mode 100644 glcd/console.c delete mode 100644 glcd/console.h delete mode 100644 glcd/glcd.c delete mode 100644 glcd/glcd.h delete mode 100644 glcd/glcd.mk delete mode 100644 glcd/glcdWorker.h delete mode 100644 glcd/readme.txt delete mode 100644 glcdconf.h delete mode 100644 graph/graph.c delete mode 100644 graph/graph.h delete mode 100644 graph/graph.mk delete mode 100644 gui/gui.c delete mode 100644 gui/gui.h delete mode 100644 gui/gui.mk delete mode 100644 halext/drivers/gdispNokia6610/GE12.h delete mode 100644 halext/drivers/gdispNokia6610/GE8.h delete mode 100644 halext/drivers/gdispNokia6610/gdisp_lld.c delete mode 100644 halext/drivers/gdispNokia6610/gdisp_lld.mk delete mode 100644 halext/drivers/gdispNokia6610/gdisp_lld_board_example.h delete mode 100644 halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h delete mode 100644 halext/drivers/gdispNokia6610/gdisp_lld_config.h delete mode 100644 halext/drivers/gdispNokia6610/readme.txt delete mode 100644 halext/drivers/gdispS6d1121/gdisp_lld.c delete mode 100644 halext/drivers/gdispS6d1121/gdisp_lld.mk delete mode 100644 halext/drivers/gdispS6d1121/gdisp_lld_config.h delete mode 100644 halext/drivers/gdispS6d1121/readme.txt delete mode 100644 halext/drivers/gdispS6d1121/s6d1121_lld.c.h delete mode 100644 halext/drivers/gdispSsd1289/gdisp_lld.c delete mode 100644 halext/drivers/gdispSsd1289/gdisp_lld.mk delete mode 100644 halext/drivers/gdispSsd1289/gdisp_lld_config.h delete mode 100644 halext/drivers/gdispSsd1289/readme.txt delete mode 100644 halext/drivers/gdispSsd1289/ssd1289_lld.c.h delete mode 100644 halext/drivers/gdispTestStub/gdisp_lld.c delete mode 100644 halext/drivers/gdispTestStub/gdisp_lld.mk delete mode 100644 halext/drivers/gdispTestStub/gdisp_lld_config.h delete mode 100644 halext/drivers/gdispTestStub/readme.txt delete mode 100644 halext/drivers/gdispVMT/gdisp_lld.c delete mode 100644 halext/drivers/gdispVMT/gdisp_lld.mk delete mode 100644 halext/drivers/gdispVMT/gdisp_lld_config.h delete mode 100644 halext/drivers/gdispVMT/gdisp_lld_driver1.c delete mode 100644 halext/drivers/gdispVMT/gdisp_lld_driver2.c delete mode 100644 halext/drivers/gdispVMT/readme.txt delete mode 100644 halext/drivers/touchpad/touchpadADS7843/readme.txt delete mode 100644 halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c delete mode 100644 halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk delete mode 100644 halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/readme.txt delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk delete mode 100644 halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h delete mode 100644 halext/halext.mk delete mode 100644 halext/include/gdisp.h delete mode 100644 halext/include/gdisp_emulation.c delete mode 100644 halext/include/gdisp_fonts.h delete mode 100644 halext/include/gdisp_lld.h delete mode 100644 halext/include/gdisp_lld_msgs.h delete mode 100644 halext/include/glcd.h delete mode 100644 halext/include/touchpad.h delete mode 100644 halext/include/touchpad_lld.h delete mode 100644 halext/readme.txt delete mode 100644 halext/src/gdisp-readme.txt delete mode 100644 halext/src/gdisp.c delete mode 100644 halext/src/gdisp_fonts.c delete mode 100644 halext/src/touchpad.c delete mode 100644 halext/templates/gdispXXXXX/gdisp_lld.c delete mode 100644 halext/templates/gdispXXXXX/gdisp_lld.mk delete mode 100644 halext/templates/gdispXXXXX/gdisp_lld_config.h delete mode 100644 halext/templates/gdispXXXXX/readme.txt delete mode 100644 halext/templates/readme.txt delete mode 100644 readme delete mode 100644 touchpad/touchpad.c delete mode 100644 touchpad/touchpad.h delete mode 100644 touchpad/touchpad.mk diff --git a/drivers/drivers.mk b/drivers/drivers.mk deleted file mode 100644 index 061d7cf0..00000000 --- a/drivers/drivers.mk +++ /dev/null @@ -1,8 +0,0 @@ -LCD_DRIVERS_SRC = $(LCDLIB)/drivers/lcd/ssd1289_lld.c \ - $(LCDLIB)/drivers/lcd/s6d1121_lld.c \ - $(LCDLIB)/drivers/touchpad/ads7843_lld.c \ - $(LCDLIB)/drivers/touchpad/xpt2046_lld.c \ - -LCD_DRIVERS_INC = $(LCDLIB)/drivers/lcd \ - $(LCDLIB)/drivers/touchpad \ - diff --git a/drivers/lcd/s6d1121_lld.c b/drivers/lcd/s6d1121_lld.c deleted file mode 100644 index 2fdd055e..00000000 --- a/drivers/lcd/s6d1121_lld.c +++ /dev/null @@ -1,543 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" - -#include "s6d1121_lld.h" -#include "chprintf.h" - -#ifdef LCD_USE_S6D1121 - -static uint8_t orientation; -extern uint16_t lcd_width, lcd_height; - -/* all interfaces use RST via GPIO */ -/* TODO: option to disable RST; assumes RST is tied high */ -#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN) -#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN) - -#define s6d1121_delay(n) halPolledDelay(MS2RTT(n)); - -static uint16_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)]; - -#if defined(LCD_USE_GPIO) - -#define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN) -#define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN) - -#define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN) -#define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN) - -#define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN) -#define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN) - -#define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN) -#define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN) - -#define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN) -#define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN) - - -static inline void lld_lcddelay(void) -{ - asm volatile ("nop"); - asm volatile ("nop"); -} - -static inline void lld_lcdwrite(uint16_t db) -{ - LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0); - LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F); - - LCD_WR_LOW; - lld_lcddelay(); - LCD_WR_HIGH; -} - -static __inline uint16_t lld_lcdReadData(void) { - uint16_t value=0; - - LCD_RS_HIGH; - LCD_WR_HIGH; - LCD_RD_LOW; - -#ifndef STM32F4XX - // change pin mode to digital input - LCD_DATA_PORT->CRH = 0x47444444; - LCD_DATA_PORT->CRL = 0x47444444; -#else - -#endif - -#ifndef STM32F4XX - // change pin mode back to digital output - LCD_DATA_PORT->CRH = 0x33333333; - LCD_DATA_PORT->CRL = 0x33333333; -#else -#endif - LCD_RD_HIGH; - - return value; -} - -static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - uint16_t lcdRAM; - - LCD_CS_LOW; - LCD_RS_LOW; - lld_lcdwrite(lcdReg); - LCD_RS_HIGH; - lcdRAM = lld_lcdReadData(); - - LCD_CS_HIGH; - - return lcdRAM; -} - -void lld_lcdWriteIndex(uint16_t lcdReg) { - LCD_RS_LOW; - - lld_lcdwrite(lcdReg); - - LCD_RS_HIGH; -} - -void lld_lcdWriteData(uint16_t lcdData) { - lld_lcdwrite(lcdData); -} - -void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { - LCD_CS_LOW; - - lld_lcdWriteIndex(lcdReg); - lld_lcdWriteData(lcdRegValue); - - LCD_CS_HIGH; -} - -static __inline void lld_lcdWriteStreamStart(void) { - LCD_CS_LOW; - lld_lcdWriteIndex(0x0022); -} - -static __inline void lld_lcdWriteStreamStop(void) { - LCD_CS_HIGH; -} - -__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - for(i = 0; i < size; i++) { - lld_lcdwrite(buffer[i]); - } -} - -__inline void lld_lcdReadStreamStart(void) { - /* TODO */ -} - -__inline void lld_lcdReadStreamStop(void) { - /* TODO */ -} - -__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - /* TODO */ -} - -#elif defined(LCD_USE_FSMC) - -#define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ -#define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - -static __inline void lld_lcdWriteIndex(uint16_t index) { - LCD_REG = index; -} - -static __inline void lld_lcdWriteData(uint16_t data) { - LCD_RAM = data; -} - -static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - LCD_REG = lcdReg; - LCD_RAM = lcdRegValue; -} - -static __inline uint16_t lld_lcdReadData(void) { - return (LCD_RAM); -} - -static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - LCD_REG = lcdReg; - return LCD_RAM; -} - -__inline void lld_lcdWriteStreamStart(void) { - LCD_REG = 0x0022; -} - -__inline void lld_lcdWriteStreamStop(void) { - -} - -__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - for(i = 0; i < size; i++) - LCD_RAM = buffer[i]; -} - -__inline void lld_lcdReadStreamStart(void) { - LCD_REG = 0x0022; -} - -__inline void lld_lcdReadStreamStop(void) { - -} - -__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - /* throw away first value read */ - volatile uint16_t dummy = LCD_RAM; - - for(i = 0; i < size; i++) { - buffer[i] = LCD_RAM; - } -} - -#endif - -void lld_lcdSetPowerMode(uint8_t powerMode) { - /* TODO: implement */ -} - -void lld_lcdInit(void) { - palSetPadMode(LCD_RST_GPIO, LCD_RST_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - // A Good idea to reset the module before using - LCD_RST_LOW; - s6d1121_delay(2); - LCD_RST_HIGH; // Hardware Reset - s6d1121_delay(2); - -#ifdef LCD_USE_GPIO - // IO Default Configurations - palSetPadMode(LCD_CS_GPIO, LCD_CS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_WR_GPIO, LCD_WR_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_RD_GPIO, LCD_RD_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_RS_GPIO, LCD_RS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_BL_GPIO, LCD_BL_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - - palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - - LCD_CS_HIGH; - LCD_RD_HIGH; - LCD_WR_HIGH; - LCD_BL_LOW; - - -#elif defined(LCD_USE_FSMC) -#if defined(STM32F1XX) - /* FSMC setup. TODO: this only works for STM32F1 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - - /* TODO: pin setup */ -#elif defined(STM32F4XX) - /* STM32F4 FSMC init */ - rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); - - /* set pins to FSMC mode */ - IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | - (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; - - IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | - (1 << 13) | (1 << 14) | (1 << 15), 0}; - - palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); - palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); -#else -#error "FSMC not implemented for this device" -#endif - int FSMC_Bank = 0; - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (10) | (10 << 8) | (10 << 16); - - /* Bank1 NOR/SRAM control register configuration */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; -#endif - - lld_lcdWriteReg(0x11,0x2004); - lld_lcdWriteReg(0x13,0xCC00); - lld_lcdWriteReg(0x15,0x2600); - lld_lcdWriteReg(0x14,0x252A); - lld_lcdWriteReg(0x12,0x0033); - lld_lcdWriteReg(0x13,0xCC04); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x13,0xCC06); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x13,0xCC4F); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x13,0x674F); - lld_lcdWriteReg(0x11,0x2003); - - s6d1121_delay(1); - - // Gamma Setting - lld_lcdWriteReg(0x30,0x2609); - lld_lcdWriteReg(0x31,0x242C); - lld_lcdWriteReg(0x32,0x1F23); - lld_lcdWriteReg(0x33,0x2425); - lld_lcdWriteReg(0x34,0x2226); - lld_lcdWriteReg(0x35,0x2523); - lld_lcdWriteReg(0x36,0x1C1A); - lld_lcdWriteReg(0x37,0x131D); - lld_lcdWriteReg(0x38,0x0B11); - lld_lcdWriteReg(0x39,0x1210); - lld_lcdWriteReg(0x3A,0x1315); - lld_lcdWriteReg(0x3B,0x3619); - lld_lcdWriteReg(0x3C,0x0D00); - lld_lcdWriteReg(0x3D,0x000D); - - lld_lcdWriteReg(0x16,0x0007); - lld_lcdWriteReg(0x02,0x0013); - lld_lcdWriteReg(0x03,0x0003); - lld_lcdWriteReg(0x01,0x0127); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x08,0x0303); - lld_lcdWriteReg(0x0A,0x000B); - lld_lcdWriteReg(0x0B,0x0003); - lld_lcdWriteReg(0x0C,0x0000); - lld_lcdWriteReg(0x41,0x0000); - lld_lcdWriteReg(0x50,0x0000); - lld_lcdWriteReg(0x60,0x0005); - lld_lcdWriteReg(0x70,0x000B); - lld_lcdWriteReg(0x71,0x0000); - lld_lcdWriteReg(0x78,0x0000); - lld_lcdWriteReg(0x7A,0x0000); - lld_lcdWriteReg(0x79,0x0007); - lld_lcdWriteReg(0x07,0x0051); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x07,0x0053); - lld_lcdWriteReg(0x79,0x0000); - - lld_lcdResetWindow(); -} - -void lld_lcdSetCursor(uint16_t x, uint16_t y) { - /* R20h - 8 bit - * R21h - 9 bit - */ - switch(lcdGetOrientation()) { - case portraitInv: - lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF); - lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF); - break; - case portrait: - lld_lcdWriteReg(0x0020, x & 0x00FF); - lld_lcdWriteReg(0x0021, y & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x0020, y & 0x00FF); - lld_lcdWriteReg(0x0021, x & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF); - lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } -} - -void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) { - uint32_t index = 0, area; - - area = ((x1-x0)*(y1-y0)); - - lld_lcdSetWindow(x0, y0, x1, y1); - - lld_lcdWriteStreamStart(); - - for(index = 0; index < area; index++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); - - lld_lcdResetWindow(); -} - -// Do not use now, will be fixed in future -void lld_lcdSetOrientation(uint8_t newOrientation) { - orientation = newOrientation; - - switch(orientation) { - case portrait: - lld_lcdWriteReg(0x0001,0x0127); - lld_lcdWriteReg(0x03, 0b0011); - lcd_height = SCREEN_HEIGHT; - lcd_width = SCREEN_WIDTH; - break; - case landscape: - lld_lcdWriteReg(0x0001,0x0027); - lld_lcdWriteReg(0x0003, 0b1011); - lcd_height = SCREEN_WIDTH; - lcd_width = SCREEN_HEIGHT; - break; - case portraitInv: - lld_lcdWriteReg(0x0001,0x0127); - lld_lcdWriteReg(0x0003, 0b0000); - lcd_height = SCREEN_HEIGHT; - lcd_width = SCREEN_WIDTH; - break; - case landscapeInv: - lld_lcdWriteReg(0x0001,0x0027); - lld_lcdWriteReg(0x0003, 0b1000); - lcd_height = SCREEN_WIDTH; - lcd_width = SCREEN_HEIGHT; - break; - } -} - -void lld_lcdResetWindow(void) { - switch(lcdGetOrientation()) { - case portrait: - case portraitInv: - lld_lcdSetWindow(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - break; - case landscape: - case landscapeInv: - lld_lcdSetWindow(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH); - break; - } -} - -void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - /* HSA / HEA are 8 bit - * VSA / VEA are 9 bit - * use masks 0x00FF and 0x01FF to enforce this - */ - switch(lcdGetOrientation()) { - case portrait: - lld_lcdWriteReg(0x46, (((x1-1) & 0x00FF) << 8) | (x0 & 0x00FF)); - lld_lcdWriteReg(0x48, y0 & 0x01FF); - lld_lcdWriteReg(0x47, (y1-1) & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x46, (((y1-1) & 0x00FF) << 8) | (y1 & 0x00FF)); - lld_lcdWriteReg(0x48, x0 & 0x01FF); - lld_lcdWriteReg(0x47, (x1-1) & 0x01FF); - break; - case portraitInv: - lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x0-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - x1) & 0x00FF)); - lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-y1) & 0x01FF); - lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y0-1) & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y0 - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - y1) & 0x00FF)); - lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - x1) & 0x01FF); - lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x0 - 1) & 0x01FF); - break; - } - - lld_lcdSetCursor(x0, y0); -} - -void lld_lcdClear(uint16_t color) { - uint32_t index = 0; - lld_lcdSetCursor(0, 0); - lld_lcdWriteStreamStart(); - - for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); -} - -// Do not use! -uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y) { - uint16_t dummy; - - lld_lcdSetCursor(x,y); - lld_lcdWriteStreamStart(); - - dummy = lld_lcdReadData(); - dummy = lld_lcdReadData(); - - lld_lcdWriteStreamStop(); - - return dummy; -} - -void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) { - lld_lcdSetCursor(x, y); - lld_lcdWriteReg(0x0022, color); -} - -uint16_t lld_lcdGetOrientation(void) { - return orientation; -} - -uint16_t lld_lcdGetHeight(void) { - return lcd_height; -} - -uint16_t lld_lcdGetWidth(void) { - return lcd_width; -} - -/* a positive lines value shifts the screen up, negative down */ -/* TODO: test this */ -void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) { - uint16_t row0, row1; - uint16_t i; - - for(i = 0; i < ((y1-y0) - abs(lines)); i++) { - if(lines > 0) { - row0 = y0 + i + lines; - row1 = y0 + i; - } else { - row0 = (y1 - i - 1) + lines; - row1 = (y1 - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - lld_lcdSetWindow(x0, row0, x1, row0); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, x1-x0); - lld_lcdReadStreamStop(); - - lld_lcdSetWindow(x0, row1, x1, row1); - lld_lcdWriteStreamStart(); - lld_lcdWriteStream(buf, x1-x0); - lld_lcdWriteStreamStop(); - } - - lld_lcdResetWindow(); -} - - -#endif diff --git a/drivers/lcd/s6d1121_lld.h b/drivers/lcd/s6d1121_lld.h deleted file mode 100644 index dc23d779..00000000 --- a/drivers/lcd/s6d1121_lld.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef S6D1121_H -#define S6D1121_H - -#include "glcd.h" - -#ifdef LCD_USE_S6D1121 - -// I/O assignments -#define LCD_BL_GPIO GPIOB -#define LCD_BL_PIN 8 - -#define LCD_CS_GPIO GPIOD -#define LCD_CS_PIN 7 - -#define LCD_RS_GPIO GPIOD -#define LCD_RS_PIN 11 - -#define LCD_RST_GPIO GPIOD -#define LCD_RST_PIN 10 - -#define LCD_RD_GPIO GPIOD -#define LCD_RD_PIN 9 - -#define LCD_WR_GPIO GPIOD -#define LCD_WR_PIN 8 - -#define LCD_D0_GPIO GPIOD -#define LCD_D4_GPIO GPIOE - -#ifdef __cplusplus -extern "C" { -#endif - - -void lld_lcdInit(void); -void lld_lcdSetCursor(uint16_t x, uint16_t y); -void lld_lcdSetOrientation(uint8_t newOrientation); -void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); -void lld_lcdClear(uint16_t color); -void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color); -uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y); -uint16_t lld_lcdGetOrientation(void); -uint16_t lld_lcdGetHeight(void); -uint16_t lld_lcdGetWidth(void); -void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines); - -#ifdef __cplusplus -} -#endif - -#endif -#endif - diff --git a/drivers/lcd/ssd1289_lld.c b/drivers/lcd/ssd1289_lld.c deleted file mode 100644 index 6c6c15b5..00000000 --- a/drivers/lcd/ssd1289_lld.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ssd1289_lld.h" - -#ifdef LCD_USE_SSD1289 - -uint8_t orientation; -uint16_t DeviceCode; -extern uint16_t lcd_width, lcd_height; - -static uint16_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)]; - -#ifdef LCD_USE_GPIO - -static __inline void lld_lcdWriteIndex(uint16_t index) { - Clr_RS; - Set_RD; - - lld_lcdWriteGPIO(index); - - Clr_WR; - Set_WR; -} - -static __inline void lld_lcdWriteData(uint16_t data) { - Set_RS; - - lld_lcdWriteGPIO(data); - - Clr_WR; - Set_WR; -} - -static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - Clr_CS; - - lld_lcdWriteIndex(lcdReg); - lld_lcdWriteData(lcdRegValue); - - Set_CS; -} - -static __inline uint16_t lld_lcdReadData(void) { - uint16_t value; - - Set_RS; - Set_WR; - Clr_RD; - - value = lld_lcdReadGPIO(); - - Set_RD; - - return value; -} - -static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - uint16_t lcdRAM; - - Clr_CS; - lld_lcdWriteIndex(lcdReg); - lcdRAM = lld_lcdReadData(); - - Set_CS; - - return lcdRAM; -} - -__inline void lld_lcdWriteStreamStart(void) { - Clr_CS; - - lld_lcdWriteIndex(0x0022); -} - -__inline void lld_lcdWriteStreamStop(void) { - Set_CS; -} - -__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - Set_RS; - - for(i = 0; i < size; i++) { - lld_lcdWriteGPIO(buffer[i]); - Clr_WR; - Set_WR; - } -} - -__inline void lld_lcdReadStreamStart(void) { - Clr_CS - - lld_lcdWriteIndex(0x0022); -} - -__inline void lld_lcdReadStreamStop(void) { - Set_CS; -} - -__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - volatile uint16_t dummy; - - dummy = lld_lcdReadData(); - for(i = 0; i < size; i++) - buffer[i] = lld_lcdReadData(); -} - -#endif // LCD_USE_GPIO - -#ifdef LCD_USE_SPI - /* TODO */ -#endif // LCD_USE_SPI - -#ifdef LCD_USE_FSMC - -#define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ -#define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - -static __inline void lld_lcdWriteIndex(uint16_t index) { - LCD_REG = index; -} - -static __inline void lld_lcdWriteData(uint16_t data) { - LCD_RAM = data; -} - -static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - LCD_REG = lcdReg; - LCD_RAM = lcdRegValue; -} - -static __inline uint16_t lld_lcdReadData(void) { - return (LCD_RAM); -} - -static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - LCD_REG = lcdReg; - volatile uint16_t dummy = LCD_RAM; - return (LCD_RAM); -} - -__inline void lld_lcdWriteStreamStart(void) { - LCD_REG = 0x0022; -} - -__inline void lld_lcdWriteStreamStop(void) { - -} - -__inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - for(i = 0; i < size; i++) - LCD_RAM = buffer[i]; -} - -__inline void lld_lcdReadStreamStart(void) { - LCD_REG = 0x0022; -} - -__inline void lld_lcdReadStreamStop(void) { - -} - -__inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - /* throw away first value read */ - volatile uint16_t dummy = LCD_RAM; - - for(i = 0; i < size; i++) { - buffer[i] = LCD_RAM; - } -} -#endif // LCD_USE_FSMC - -static __inline void lld_lcdDelay(uint16_t us) { - chThdSleepMicroseconds(us); -} - -void lld_lcdSetPowerMode(uint8_t powerMode) { - switch(powerMode) { - case powerOff: - lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode - lld_lcdWriteReg(0x0007, 0x0000); // halt operation - lld_lcdWriteReg(0x0000, 0x0000); // turn off oszillator - lld_lcdWriteReg(0x0010, 0x0001); // enter sleepmode - break; - case powerOn: - lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode - lld_lcdInit(); - break; - case sleepOn: - lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode - break; - case sleepOff: - lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode - break; - } -} - -void lld_lcdSetCursor(uint16_t x, uint16_t y) { - /* Reg 0x004E is an 8 bit value - * Reg 0x004F is 9 bit - * Use a bit mask to make sure they are not set too high - */ - switch(lcdGetOrientation()) { - case portraitInv: - lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF); - lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF); - break; - case portrait: - lld_lcdWriteReg(0x004e, x & 0x00FF); - lld_lcdWriteReg(0x004f, y & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x004e, y & 0x00FF); - lld_lcdWriteReg(0x004f, x & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x004e, (SCREEN_WIDTH - y - 1) & 0x00FF); - lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } -} - -void lld_lcdSetOrientation(uint8_t newOrientation) { - orientation = newOrientation; - - switch(orientation) { - case portrait: - lld_lcdWriteReg(0x0001, 0x2B3F); - /* ID = 11 AM = 0 */ - lld_lcdWriteReg(0x0011, 0x6070); - lcd_height = SCREEN_HEIGHT; - lcd_width = SCREEN_WIDTH; - break; - case landscape: - lld_lcdWriteReg(0x0001, 0x293F); - /* ID = 11 AM = 1 */ - lld_lcdWriteReg(0x0011, 0x6078); - lcd_height = SCREEN_WIDTH; - lcd_width = SCREEN_HEIGHT; - break; - case portraitInv: - lld_lcdWriteReg(0x0001, 0x2B3F); - /* ID = 01 AM = 0 */ - lld_lcdWriteReg(0x0011, 0x6040); - lcd_height = SCREEN_HEIGHT; - lcd_width = SCREEN_WIDTH; - break; - case landscapeInv: - lld_lcdWriteReg(0x0001, 0x293F); - /* ID = 01 AM = 1 */ - lld_lcdWriteReg(0x0011, 0x6048); - lcd_height = SCREEN_WIDTH; - lcd_width = SCREEN_HEIGHT; - break; - } -} - -void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { - lld_lcdSetCursor(x0, y0); - - /* Reg 0x44 - Horizontal RAM address position - * Upper Byte - HEA - * Lower Byte - HSA - * 0 <= HSA <= HEA <= 0xEF - * Reg 0x45,0x46 - Vertical RAM address position - * Lower 9 bits gives 0-511 range in each value - * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F - */ - - switch(lcdGetOrientation()) { - case portrait: - lld_lcdWriteReg(0x44, (((x1-1) << 8) & 0xFF00 ) | (x0 & 0x00FF)); - lld_lcdWriteReg(0x45, y0 & 0x01FF); - lld_lcdWriteReg(0x46, (y1-1) & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x44, (((y1-1) << 8) & 0xFF00) | (y1 & 0x00FF)); - lld_lcdWriteReg(0x45, x0 & 0x01FF); - lld_lcdWriteReg(0x46, (x1-1) & 0x01FF); - break; - case portraitInv: - lld_lcdWriteReg(0x44, (((SCREEN_WIDTH-x0-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - x1) & 0x00FF)); - lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-y1) & 0x01FF); - lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y0-1) & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y0 - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - y1) & 0x00FF)); - lld_lcdWriteReg(0x45, (SCREEN_HEIGHT - x1) & 0x01FF); - lld_lcdWriteReg(0x46, (SCREEN_HEIGHT - x0 - 1) & 0x01FF); - break; - } - - lld_lcdSetCursor(x0, y0); -} - -void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) { - uint32_t index = 0, area; - - area = ((x1-x0)*(y1-y0)); - - lld_lcdSetWindow(x0, y0, x1, y1); - lld_lcdWriteStreamStart(); - - for(index = 0; index < area; index++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); -} - -void lld_lcdClear(uint16_t color) { - uint32_t index = 0; - - lld_lcdSetCursor(0, 0); - lld_lcdWriteStreamStart(); - - for(index = 0; index < SCREEN_WIDTH * SCREEN_HEIGHT; index++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); -} - -uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y) { - uint16_t dummy; - - lld_lcdSetCursor(x,y); - lld_lcdWriteStreamStart(); - - dummy = lld_lcdReadData(); - dummy = lld_lcdReadData(); - - lld_lcdWriteStreamStop(); - - return dummy; -} - -void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) { - lld_lcdSetCursor(x, y); - lld_lcdWriteReg(0x0022, color); -} - -void lld_lcdInit(void) { -#ifdef LCD_USE_FSMC - /* FSMC setup. TODO: this only works for STM32F1 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - int FSMC_Bank = 0; - /* timing structure */ - /* from datasheet: - address setup: 0ns - address hold: 0ns - Data setup: 5ns - Data hold: 5ns - Data access: 250ns - output hold: 100ns - */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_1 | FSMC_BTR1_DATAST_1; - - /* Bank1 NOR/SRAM control register configuration */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; -#endif - DeviceCode = lld_lcdReadReg(0x0000); - - lld_lcdWriteReg(0x0000,0x0001); lld_lcdDelay(5); - lld_lcdWriteReg(0x0003,0xA8A4); lld_lcdDelay(5); - lld_lcdWriteReg(0x000C,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x000D,0x080C); lld_lcdDelay(5); - lld_lcdWriteReg(0x000E,0x2B00); lld_lcdDelay(5); - lld_lcdWriteReg(0x001E,0x00B0); lld_lcdDelay(5); - lld_lcdWriteReg(0x0001,0x2B3F); lld_lcdDelay(5); - lld_lcdWriteReg(0x0002,0x0600); lld_lcdDelay(5); - lld_lcdWriteReg(0x0010,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0011,0x6070); lld_lcdDelay(5); - lld_lcdWriteReg(0x0005,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0006,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0016,0xEF1C); lld_lcdDelay(5); - lld_lcdWriteReg(0x0017,0x0003); lld_lcdDelay(5); - lld_lcdWriteReg(0x0007,0x0133); lld_lcdDelay(5); - lld_lcdWriteReg(0x000B,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x000F,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0041,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0042,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0048,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0049,0x013F); lld_lcdDelay(5); - lld_lcdWriteReg(0x004A,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x004B,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0044,0xEF00); lld_lcdDelay(5); - lld_lcdWriteReg(0x0045,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0046,0x013F); lld_lcdDelay(5); - lld_lcdWriteReg(0x0030,0x0707); lld_lcdDelay(5); - lld_lcdWriteReg(0x0031,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0032,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0033,0x0502); lld_lcdDelay(5); - lld_lcdWriteReg(0x0034,0x0507); lld_lcdDelay(5); - lld_lcdWriteReg(0x0035,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0036,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0037,0x0502); lld_lcdDelay(5); - lld_lcdWriteReg(0x003A,0x0302); lld_lcdDelay(5); - lld_lcdWriteReg(0x003B,0x0302); lld_lcdDelay(5); - lld_lcdWriteReg(0x0023,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0024,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0025,0x8000); lld_lcdDelay(5); - lld_lcdWriteReg(0x004f,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x004e,0x0000); lld_lcdDelay(5); -} - -uint16_t lld_lcdGetOrientation(void) { - return orientation; -} - -uint16_t lld_lcdGetHeight(void) { - return lcd_height; -} - -uint16_t lld_lcdGetWidth(void) { - return lcd_width; -} - -/* a positive lines value shifts the screen up, negative down */ -void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) { - uint16_t row0, row1; - uint16_t i; - - lld_lcdSetWindow(x0, y0, x1, y1); - - for(i = 0; i < ((y1-y0) - abs(lines)); i++) { - if(lines > 0) { - row0 = y0 + i + lines; - row1 = y0 + i; - } else { - row0 = (y1 - i - 1) + lines; - row1 = (y1 - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - lld_lcdSetWindow(x0, row0, x1, row0); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, x1-x0); - lld_lcdReadStreamStop(); - - lld_lcdSetWindow(x0, row1, x1, row1); - lld_lcdWriteStreamStart(); - lld_lcdWriteStream(buf, x1-x0); - lld_lcdWriteStreamStop(); - } -} - -#endif - diff --git a/drivers/lcd/ssd1289_lld.h b/drivers/lcd/ssd1289_lld.h deleted file mode 100644 index 60f9e569..00000000 --- a/drivers/lcd/ssd1289_lld.h +++ /dev/null @@ -1,182 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef SSD1289_H -#define SSD1289_H - -#include "glcd.h" - -#ifdef LCD_USE_SSD1289 - -#ifdef __cplusplus -extern "C" { -#endif - -void lld_lcdInit(void); -void lld_lcdWriteStreamStart(void); -void lld_lcdWriteStreamStop(void); -void lld_lcdWriteStream(uint16_t *buffer, uint16_t size); -void lld_lcdSetCursor(uint16_t x, uint16_t y); -void lld_lcdSetOrientation(uint8_t newOrientation); -void lld_lcdSetWindow(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); -void lld_lcdClear(uint16_t color); -void lld_lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color); -void lld_lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); -void lld_lcdSetPowerMode(uint8_t powerMode); -uint16_t lld_lcdGetPixelColor(uint16_t x, uint16_t y); -uint16_t lld_lcdGetOrientation(void); -uint16_t lld_lcdGetHeight(void); -uint16_t lld_lcdGetWidth(void); -void lld_lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines); - -#ifdef __cplusplus -} -#endif - -#ifdef LCD_USE_GPIO - #define Set_CS palSetPad(LCD_CMD_PORT, LCD_CS); - #define Clr_CS palClearPad(LCD_CMD_PORT, LCD_CS); - #define Set_RS palSetPad(LCD_CMD_PORT, LCD_RS); - #define Clr_RS palClearPad(LCD_CMD_PORT, LCD_RS); - #define Set_WR palSetPad(LCD_CMD_PORT, LCD_WR); - #define Clr_WR palClearPad(LCD_CMD_PORT, LCD_WR); - #define Set_RD palSetPad(LCD_CMD_PORT, LCD_RD); - #define Clr_RD palClearPad(LCD_CMD_PORT, LCD_RD); -#endif - -#ifdef LCD_USE_SPI - /* TODO */ -#endif - -#ifdef LCD_USE_FSMC -/* LCD Registers */ - #define R0 0x00 - #define R1 0x01 - #define R2 0x02 - #define R3 0x03 - #define R4 0x04 - #define R5 0x05 - #define R6 0x06 - #define R7 0x07 - #define R8 0x08 - #define R9 0x09 - #define R10 0x0A - #define R12 0x0C - #define R13 0x0D - #define R14 0x0E - #define R15 0x0F - #define R16 0x10 - #define R17 0x11 - #define R18 0x12 - #define R19 0x13 - #define R20 0x14 - #define R21 0x15 - #define R22 0x16 - #define R23 0x17 - #define R24 0x18 - #define R25 0x19 - #define R26 0x1A - #define R27 0x1B - #define R28 0x1C - #define R29 0x1D - #define R30 0x1E - #define R31 0x1F - #define R32 0x20 - #define R33 0x21 - #define R34 0x22 - #define R36 0x24 - #define R37 0x25 - #define R40 0x28 - #define R41 0x29 - #define R43 0x2B - #define R45 0x2D - #define R48 0x30 - #define R49 0x31 - #define R50 0x32 - #define R51 0x33 - #define R52 0x34 - #define R53 0x35 - #define R54 0x36 - #define R55 0x37 - #define R56 0x38 - #define R57 0x39 - #define R59 0x3B - #define R60 0x3C - #define R61 0x3D - #define R62 0x3E - #define R63 0x3F - #define R64 0x40 - #define R65 0x41 - #define R66 0x42 - #define R67 0x43 - #define R68 0x44 - #define R69 0x45 - #define R70 0x46 - #define R71 0x47 - #define R72 0x48 - #define R73 0x49 - #define R74 0x4A - #define R75 0x4B - #define R76 0x4C - #define R77 0x4D - #define R78 0x4E - #define R79 0x4F - #define R80 0x50 - #define R81 0x51 - #define R82 0x52 - #define R83 0x53 - #define R96 0x60 - #define R97 0x61 - #define R106 0x6A - #define R118 0x76 - #define R128 0x80 - #define R129 0x81 - #define R130 0x82 - #define R131 0x83 - #define R132 0x84 - #define R133 0x85 - #define R134 0x86 - #define R135 0x87 - #define R136 0x88 - #define R137 0x89 - #define R139 0x8B - #define R140 0x8C - #define R141 0x8D - #define R143 0x8F - #define R144 0x90 - #define R145 0x91 - #define R146 0x92 - #define R147 0x93 - #define R148 0x94 - #define R149 0x95 - #define R150 0x96 - #define R151 0x97 - #define R152 0x98 - #define R153 0x99 - #define R154 0x9A - #define R157 0x9D - #define R192 0xC0 - #define R193 0xC1 - #define R229 0xE5 -#endif - -#endif -#endif - diff --git a/drivers/touchpad/ads7843_lld.c b/drivers/touchpad/ads7843_lld.c deleted file mode 100644 index 1f1e7c58..00000000 --- a/drivers/touchpad/ads7843_lld.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ads7843_lld.h" - -#ifdef TOUCHPAD_USE_ADS7843 - -__inline uint16_t lld_tpReadX(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t x; - - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - x = rxbuf[0] << 4; - x |= rxbuf[1] >> 4; - - return x; -} - -__inline uint16_t lld_tpReadY(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -__inline uint16_t lld_tpReadZ(void) { - return 0; -} - -#endif diff --git a/drivers/touchpad/ads7843_lld.h b/drivers/touchpad/ads7843_lld.h deleted file mode 100644 index f20b31f7..00000000 --- a/drivers/touchpad/ads7843_lld.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef ADS7843_LLD_H -#define ADS7843_LLD_H - -#include "glcd.h" -#include "touchpad.h" - -#ifdef TOUCHPAD_USE_ADS7843 - -uint16_t lld_tpReadX(void); -uint16_t lld_tpReadY(void); -uint16_t lld_tpReadZ(void); - -#endif -#endif - diff --git a/drivers/touchpad/xpt2046_lld.c b/drivers/touchpad/xpt2046_lld.c deleted file mode 100644 index 57b9c50d..00000000 --- a/drivers/touchpad/xpt2046_lld.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "xpt2046_lld.h" - -#ifdef TOUCHPAD_USE_XPT2046 - -__inline uint16_t lld_tpReadX(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t x; - - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - x = rxbuf[0] << 4; - x |= rxbuf[1] >> 4; - - return x; -} - -__inline uint16_t lld_tpReadY(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -__inline uint16_t lld_tpReadZ(void) { - return 0; -} - -#endif diff --git a/drivers/touchpad/xpt2046_lld.h b/drivers/touchpad/xpt2046_lld.h deleted file mode 100644 index 1511f6b3..00000000 --- a/drivers/touchpad/xpt2046_lld.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef XPT2046_LLD_H -#define XPT2046_LLD_H - -#include "glcd.h" -#include "touchpad.h" - -#ifdef TOUCHPAD_USE_XPT2046 - -uint16_t lld_tpReadX(void); -uint16_t lld_tpReadY(void); -uint16_t lld_tpReadZ(void); - -#endif -#endif - diff --git a/glcd/console.c b/glcd/console.c deleted file mode 100644 index caddfce2..00000000 --- a/glcd/console.c +++ /dev/null @@ -1,171 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" - -#include "glcd.h" -#include "console.h" - -/* - * Interface implementation. The interface is write only - */ - -static size_t writes(void *ip, const uint8_t *bp, size_t n) { - return lcdConsoleWrite((GLCDConsole *)ip, bp, n); -} - -static size_t reads(void *ip, uint8_t *bp, size_t n) { - (void)ip; - (void)bp; - (void)n; - - return 0; -} - -static msg_t put(void *ip, uint8_t b) { - return lcdConsolePut((GLCDConsole *)ip, (char)b); -} - -static msg_t get(void *ip) { - (void)ip; - - return RDY_OK; -} - -static msg_t putt(void *ip, uint8_t b, systime_t timeout) { - (void)timeout; - - /* TODO: handle timeout */ - - return lcdConsolePut((GLCDConsole *)ip, (char)b); -} - -static msg_t gett(void *ip, systime_t timeout) { - (void)ip; - (void)timeout; - - return RDY_OK; -} - -static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) { - (void)time; - - return lcdConsoleWrite((GLCDConsole *)ip, bp, n); -} - -static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) { - (void)ip; - (void)bp; - (void)n; - (void)time; - - return 0; -} - -static uint16_t getflags(void *ip) { - _chn_get_and_clear_flags_impl(ip); -} - -static const struct GLCDConsoleVMT vmt = { - writes, reads, put, get, - putt, gett, writet, readt, - getflags -}; - - -msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color) { - const uint8_t* ptr; - uint16_t chi; - uint16_t x,y; - - console->vmt = &vmt; - /* read font, get height */ - console->fy = lcdGetFontHeight(font); - - /* calculate the size of the console as an integer multiple of characters height*/ - console->sx = width; - console->sy = (((int16_t)(height/console->fy))-1)*console->fy; - - console->cx = 0; - console->cy = 0; - console->x0 = x0; - console->y0 = y0; - - console->bkcolor = bkcolor; - console->color = color; - - console->font = font; - - lcdFillArea(x0, y0, x0+width, y0+height, console->bkcolor); - return RDY_OK; -} - -msg_t lcdConsolePut(GLCDConsole *console, char c) { - uint8_t width; - - if(c == '\n') { - /* clear the text at the end of the line */ - if(console->cx < console->sx) - lcdFillArea(console->x0 + console->cx, console->y0 + console->cy, - console->x0 + console->sx, console->y0 + console->cy + console->fy, - console->bkcolor); - console->cx = 0; - console->cy += console->fy; - } else if(c == '\r') { - /* TODO: work backwards through the buffer to the start of the current line */ - //console->cx = 0; - } else { - width = lcdMeasureChar(c, console->font); - if((console->cx + width) >= console->sx) { - /* clear the text at the end of the line */ - lcdFillArea(console->x0 + console->cx, console->y0 + console->cy, - console->x0 + console->cx + width, console->y0 + console->cy + console->fy, - console->bkcolor); - console->cx = 0; - console->cy += console->fy; - } - - if((console->cy > console->sy)) { - - lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx, - console->y0 + console->sy + console->fy, console->fy); - /* reset the cursor */ - console->cx = 0; - console->cy = console->sy; - } - - lcdDrawChar(console->x0 + console->cx, console->y0 + console->cy, c, - console->font, console->color, console->bkcolor, solid); - - /* update cursor */ - console->cx += width; - } - return RDY_OK; -} - -msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n) { - size_t i; - for(i = 0; i < n; i++) - lcdConsolePut(console, bp[i]); - - return RDY_OK; -} - - diff --git a/glcd/console.h b/glcd/console.h deleted file mode 100644 index f76c5adf..00000000 --- a/glcd/console.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef CONSOLE_H -#define CONSOLE_H - -#include "glcd.h" - -/** - * @brief Structure representing a GLCD driver. - */ -typedef struct GLCDConsole GLCDConsole; - -/** - * @brief @p GLCDConsole specific methods. - */ -#define _glcd_driver_methods \ - _base_asynchronous_channel_methods - -/** - * @extends BaseAsynchronousChannelVMT - * - * @brief @p GLCDConsole virtual methods table. - */ -struct GLCDConsoleVMT { - _glcd_driver_methods -}; - -/** - * @extends BaseAsynchronousChannel - * - * @brief GLCD Console class. - * @details This class extends @p BaseAsynchronousChannel by adding physical - * I/O queues. - */ -struct GLCDConsole { - /** @brief Virtual Methods Table.*/ - const struct GLCDConsoleVMT *vmt; - _base_asynchronous_channel_data - /* WARNING: Do not add any data to this struct above this comment, only below */ - /* font */ - font_t font; - /* lcd area to use */ - uint16_t x0,y0; - /* current cursor position, in pixels */ - uint16_t cx,cy; - /* console size in pixels */ - uint16_t sx,sy; - /* foreground and background colour */ - uint16_t bkcolor, color; - /* font size in pixels */ - uint8_t fy; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color); -msg_t lcdConsolePut(GLCDConsole *console, char c); -msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n); - -#ifdef __cplusplus -} -#endif - -#endif /* CONSOLE_H */ diff --git a/glcd/glcd.c b/glcd/glcd.c deleted file mode 100644 index 9d4db9cf..00000000 --- a/glcd/glcd.c +++ /dev/null @@ -1,431 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "ch.h" -#include "hal.h" - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/* Hack 1: Manually load the low level driver capabilities first so we can - * control what we implement with hardware scrolling and pixel read. - */ -#include "gdisp_lld_config.h" - -/* Hack 2: Force on the bits of functionality that glcd needs. */ -#define HAL_USE_GDISP TRUE -#define GDISP_NEED_VALIDATION FALSE /* The original glcd didn't so we don't here either */ -#define GDISP_NEED_CIRCLE TRUE -#define GDISP_NEED_ELLIPSE TRUE -#define GDISP_NEED_TEXT TRUE -#define GDISP_NEED_SCROLL GDISP_HARDWARE_SCROLL -#define GDISP_NEED_PIXELREAD GDISP_HARDWARE_PIXELREAD -#define GDISP_NEED_CONTROL TRUE -#define GDISP_NEED_MULTITHREAD FALSE /* We implement multi-thread here */ - -/* Now load the low level driver and font structure definitions */ -#include "gdisp_lld.h" -#include "gdisp_fonts.h" - -/* Hack 3: GLCD only supports RGB565. Anything else would require significant API changes. */ -#ifndef GDISP_PIXELFORMAT_RGB565 -#error "GLCD only support drivers with RGB565 pixel format" -#endif - -/* Now load the glcd headers */ -#include "glcd.h" -#include "glcdWorker.h" - -/* Hack 4: Include the emulation code and font tables. - * We have to include it here rather than compiling - * the files as we need to pass our control defines - * as they are not being defined by the application. - * We need to turn off the inclusion of gdisp.h due - * to conflicting type defines etc. - */ -#define _GDISP_H // Prevent gdisp.h from being included -#include "gdisp_emulation.c" -#include "gdisp_fonts.c" - -#define EMSG(a) struct a *emsg = (struct a*)msg - -static Thread *workerThread = NULL; - -static WORKING_AREA(waGLCDWorkerThread, GLCD_WORKER_SIZE); -static msg_t ThreadGLCDWorker(void *arg) { - (void)arg; - Thread *p; - - chRegSetThreadName("GLCDWorker"); - - while(TRUE) { - /* Wait for msg with work to do. */ - p = chMsgWait(); - struct glcd_msg_base *msg = (struct glcd_msg_base*)chMsgGet(p); - glcd_result_t result = GLCD_PROGRESS; - - /* do work here */ - switch(msg->action) { - case GLCD_SET_POWERMODE: { - EMSG(glcd_msg_powermode); - gdisp_lld_control(GDISP_CONTROL_POWER, (void *)(int)emsg->powermode); - result = GLCD_DONE; - break; - } - - case GLCD_SET_ORIENTATION: { - EMSG(glcd_msg_orientation); - gdisp_lld_control(GDISP_CONTROL_ORIENTATION, (void *)(int)emsg->newOrientation); - result = GLCD_DONE; - break; - } - case GLCD_FILL_AREA: { - EMSG(glcd_msg_fill_area); - gdisp_lld_fillarea(emsg->x0, emsg->y0, emsg->x1-emsg->x0+1,emsg->y1-emsg->y0+1,emsg->color); - result = GLCD_DONE; - break; - } - - case GLCD_WRITE_AREA: { - EMSG(glcd_msg_write_area); - gdisp_lld_blitarea(emsg->x0, emsg->y0, emsg->x1-emsg->x0+1, emsg->y1-emsg->y0+1, emsg->buffer); - result = GLCD_DONE; - break; - } - - case GLCD_CLEAR: { - EMSG(glcd_msg_clear); - gdisp_lld_clear(emsg->color); - result = GLCD_DONE; - break; - } - - case GLCD_GET_PIXEL_COLOR: { - /* Hack 5: This may now fail if the low level driver doesn't - * support it. Previously this support was required - * in the driver by GLCD - */ -#if GDISP_HARDWARE_READPIXEL - ((struct glcd_msg_get_pixel_color *)emsg)->color = - gdisp_lld_getpixelcolor(emsg->x, emsg->y); - result = GLCD_DONE; -#else - EMSG(glcd_msg_get_pixel_color); - ((struct glcd_msg_get_pixel_color *)emsg)->color = 0; - result = GLCD_FAILED; -#endif - break; - } - - case GLCD_DRAW_PIXEL: { - EMSG(glcd_msg_draw_pixel); - gdisp_lld_drawpixel(emsg->x, emsg->y, emsg->color); - result = GLCD_DONE; - break; - } - - case GLCD_VERTICAL_SCROLL: { - /* Hack 6: This may now fail if the low level driver doesn't - * support it. Previously this support was required - * in the driver by GLCD - */ -#if GDISP_HARDWARE_SCROLL - EMSG(glcd_msg_vertical_scroll); - gdisp_lld_verticalscroll(emsg->x0, emsg->y0, emsg->x1-emsg->x0+1, emsg->y1-emsg->y0+1, emsg->lines, 0); - result = GLCD_DONE; -#else - result = GLCD_FAILED; -#endif - break; - } - - case GLCD_DRAW_CHAR: { - EMSG(glcd_msg_draw_char); - if (emsg->tpText) - gdisp_lld_drawchar(emsg->cx, emsg->cy, emsg->c, emsg->font, emsg->color); - else - gdisp_lld_fillchar(emsg->cx, emsg->cy, emsg->c, emsg->font, emsg->color, emsg->bkcolor); - /* We can't normally access a high level function here but in this case it is safe - * because the routine only accesses const data members (multi-thread safe). - */ - emsg->ret_width = lcdMeasureChar(emsg->c, emsg->font); - result = GLCD_DONE; - break; - } - - default: { - result = GLCD_FAILED; - break; - } - } - - /* Done, release msg again. */ - chMsgRelease(p, (msg_t)result); - - } - - return 0; -} - -void lcdInit(GLCDDriver *UNUSED(glcdp)) { - workerThread = chThdCreateStatic(waGLCDWorkerThread, sizeof(waGLCDWorkerThread), NORMALPRIO, ThreadGLCDWorker, NULL); - - gdisp_lld_init(); -} - -uint16_t lcdGetHeight(void) { - return GDISP.Height; -} - -uint16_t lcdGetWidth(void) { - return GDISP.Width; -} - -uint16_t lcdGetOrientation(void) { - return GDISP.Orientation; -} - -glcd_result_t lcdSetPowerMode(uint8_t powerMode) { - struct glcd_msg_powermode msg; - - msg.action = GLCD_SET_POWERMODE; - msg.powermode = powerMode; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -glcd_result_t lcdSetOrientation(uint8_t newOrientation) { - struct glcd_msg_orientation msg; - - msg.action = GLCD_SET_ORIENTATION; - msg.newOrientation = newOrientation; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -glcd_result_t lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) { - struct glcd_msg_fill_area msg; - - msg.action = GLCD_FILL_AREA; - msg.x0 = x0; - msg.y0 = y0; - msg.x1 = x1; - msg.y1 = y1; - msg.color = color; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -glcd_result_t lcdWriteArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t *buffer, size_t n) { - struct glcd_msg_write_area msg; - - msg.action = GLCD_WRITE_AREA; - msg.x0 = x0; - msg.y0 = y0; - msg.x1 = x1; - msg.y1 = y1; - msg.buffer = buffer; - msg.size = n; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -glcd_result_t lcdClear(uint16_t color) { - struct glcd_msg_clear msg; - - msg.action = GLCD_CLEAR; - msg.color = color; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -uint16_t lcdGetPixelColor(uint16_t x, uint16_t y) { - struct glcd_msg_get_pixel_color msg; - - msg.action = GLCD_GET_PIXEL_COLOR; - msg.x = x; - msg.y = y; - - chMsgSend(workerThread, (msg_t)&msg); - - return msg.color; -} - -glcd_result_t lcdDrawPixel(uint16_t x, uint16_t y, uint16_t color) { - struct glcd_msg_draw_pixel msg; - - msg.action = GLCD_DRAW_PIXEL; - msg.x = x; - msg.y = y; - msg.color = color; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -glcd_result_t lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines) { - struct glcd_msg_vertical_scroll msg; - - msg.action = GLCD_VERTICAL_SCROLL; - msg.x0 = x0; - msg.y0 = y0; - msg.x1 = x1; - msg.y1 = y1; - msg.lines = lines; - - return (glcd_result_t)chMsgSend(workerThread, (msg_t)&msg); -} - -void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color) { - struct glcd_msg_draw_line msg; - - msg.action = GLCD_DRAW_LINE; - msg.x0 = x0; - msg.y0 = y0; - msg.x1 = x1; - msg.y1 = y1; - msg.color = color; - - chMsgSend(workerThread, (msg_t)&msg); -} - -uint16_t lcdDrawChar(uint16_t cx, uint16_t cy, char c, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText) { - struct glcd_msg_draw_char msg; - - msg.action = GLCD_DRAW_CHAR; - msg.cx = cx; - msg.cy = cy; - msg.c = c; - msg.font = font; - msg.color = color; - msg.bkcolor = bkcolor; - msg.tpText = tpText; - msg.ret_width = 0; - - chMsgSend(workerThread, (msg_t)&msg); - - return msg.ret_width; -} - -void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color) { - struct glcd_msg_draw_circle msg; - - msg.action = GLCD_DRAW_CIRCLE; - msg.x = x; - msg.y = y; - msg.radius = radius; - msg.filled = filled; - msg.color = color; - - chMsgSend(workerThread, (msg_t)&msg); -} - -void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint8_t filled, uint16_t color) { - struct glcd_msg_draw_ellipse msg; - - msg.action = GLCD_DRAW_ELLIPSE; - msg.x = x; - msg.y = y; - msg.a = a; - msg.b = b; - msg.filled = filled; - msg.color = color; - - chMsgSend(workerThread, (msg_t)&msg); -} - -/* WARNING: No boundary checks! Unpredictable behaviour if text exceeds boundary */ -void lcdDrawString(uint16_t x, uint16_t y, const char *str, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText) { - uint16_t cx = x, cy = y; - - while (*str) { - cx += lcdDrawChar(cx, cy, *str++, font, color, bkcolor, tpText); - } -} - -uint16_t lcdMeasureChar(char c, font_t font) { - return (_getCharWidth(font, c)+font->charPadding) * font->xscale; -} - -uint16_t lcdMeasureString(const char *str, font_t font) { - uint16_t result = 0; - - /* Measure each char width, add it, return the result */ - while (*str) - result += lcdMeasureChar(*str++, font); - - return result; -} - -uint16_t lcdGetFontHeight(font_t font) { - return font->height; -} - -uint16_t lcdBGR2RGB(uint16_t color) { - uint16_t r, g, b, rgb; - - b = ( color>>0 ) & 0x1f; - g = ( color>>5 ) & 0x3f; - r = ( color>>11 ) & 0x1f; - - rgb = (b<<11) + (g<<5) + (r<<0); - - return( rgb ); -} - -void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color) { - uint16_t TempX; - uint16_t TempY; - - if (x0 > x1) { - TempX = x1; - x1 = x0; - x0 = TempX; - } - if (y0 > y1) { - TempY = y1; - y1 = y0; - y0 = TempY; - } - if(filled) { - lcdFillArea(x0, y0, x1+1, y1+1, color); - } else { - lcdDrawLine(x0, y0, x1, y0, color); - lcdDrawLine(x0, y1, x1, y1, color); - lcdDrawLine(x0, y0, x0, y1, color); - lcdDrawLine(x1, y0, x1, y1+1, color); - } -} - -void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, font_t font, uint16_t fontColor, uint16_t bkColor) { - uint16_t off_left, off_up; - - off_left = ((x1-x0)-lcdMeasureString(str, font))/2; - off_up = ((y1-y0) - lcdGetFontHeight(font)) / 2; - - lcdDrawRect(x0, y0, x1, y1, filled, bkColor); - /* Abhishek: default to solid text for this? */ - lcdDrawString(x0+off_left, y0+off_up, str, font, fontColor, bkColor, solid); -} diff --git a/glcd/glcd.h b/glcd/glcd.h deleted file mode 100644 index 9fee528d..00000000 --- a/glcd/glcd.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GLCD_H -#define GLCD_H - -#include "ch.h" -#include "hal.h" - -#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv) -#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv) - -/* New fonts */ -extern const struct font fontSmall; -extern const struct font fontSmallDouble; -extern const struct font fontSmallNarrow; -extern const struct font fontLarger; -extern const struct font fontLargerDouble; -extern const struct font fontLargerNarrow; -extern const struct font fontUI1; -extern const struct font fontUI1Double; -extern const struct font fontUI1Narrow; -extern const struct font fontUI2; -extern const struct font fontUI2Double; -extern const struct font fontUI2Narrow; -extern const struct font fontLargeNumbers; -extern const struct font fontLargeNumbersDouble; -extern const struct font fontLargeNumbersNarrow; - -/* Old font names */ -#define font_Small (&fontSmall) -#define font_SmallDouble (&fontSmallDouble) -#define font_SmallNarrow (&fontSmall) -#define font_Larger (&fontLarger) -#define font_LargerDouble (&fontLargerDouble) -#define font_LargerNarrow (&fontLargerNarrow) -#define font_MediumBold (&fontUI1) -#define font_MediumBoldDouble (&fontUI1Double) -#define font_MediumBoldNarrow (&fontUI1Narrow) -#define font_LargeNumbers (&fontLargeNumbers) -#define font_LargeNumbersDouble (&fontLargeNumbersDouble) -#define font_LargeNumbersNarrow (&fontLargeNumbersNarrow) - -/* LCD color - Note that GLCD only supports 16 bit color in the API */ -#define White 0xFFFF -#define Black 0x0000 -#define Grey 0xF7DE -#define Blue 0x001F -#define Blue2 0x051F -#define Red 0xF800 -#define Magenta 0xF81F -#define Green 0x07E0 -#define Cyan 0x7FFF -#define Yellow 0xFFE0 - -#define RGB565CONVERT(red, green, blue) \ -(uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 )) - -#ifndef _GDISP_LLD_H - /* Don't double define these at the low level driver */ - typedef const struct font *font_t; - enum orientation {portrait, landscape, portraitInv, landscapeInv}; - enum powermode {powerOff, powerSleep, powerOn}; - #define sleepOn powerSleep - #define sleepOff powerOn -#endif - -enum filled {frame, filled}; -enum transparency {solid, transparent}; - -/** - * @brief Structure representing a GLCD driver. - */ -typedef struct GLCDDriver GLCDDriver; - -struct GLCDDriver { -}; - -enum glcd_result { GLCD_DONE, - GLCD_FAILED, - GLCD_PROGRESS, - }; - -typedef enum glcd_result glcd_result_t; - -#ifdef __cplusplus -extern "C" { -#endif - -/* Core functions */ -void lcdInit(GLCDDriver *GLCDD1); -glcd_result_t lcdClear(uint16_t color); -glcd_result_t lcdSetOrientation(uint8_t newOrientation); -glcd_result_t lcdFillArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); -glcd_result_t lcdWriteArea(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t *buffer, size_t n); -glcd_result_t lcdSetPowerMode(uint8_t powerMode); - -/* Drawing functions */ -glcd_result_t lcdDrawPixel(uint16_t x, uint16_t y, uint16_t point); -void lcdDrawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color); -void lcdDrawRect(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t filled, uint16_t color); -void lcdDrawRectString(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, const char* str, font_t font, uint16_t fontColor, uint16_t bkColor); -void lcdDrawCircle(uint16_t x, uint16_t y, uint16_t radius, uint8_t filled, uint16_t color); -void lcdDrawEllipse(uint16_t x, uint16_t y, uint16_t a, uint16_t b, uint8_t filled, uint16_t color); - -/* Text Rendering Functions */ -uint16_t lcdDrawChar(uint16_t cx, uint16_t cy, char c, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText); -void lcdDrawString(uint16_t x, uint16_t y, const char *str, font_t font, uint16_t color, uint16_t bkcolor, bool_t tpText); - -/* Character measuring functions */ -uint16_t lcdMeasureChar(char c, font_t font); -uint16_t lcdMeasureString(const char* str, font_t font); -uint16_t lcdGetFontHeight(font_t font); - -/* Size and orientation related */ -uint16_t lcdGetHeight(void); -uint16_t lcdGetWidth(void); -uint16_t lcdGetOrientation(void); - -/* BGR->RGB and pixel readback */ -uint16_t lcdBGR2RGB(uint16_t color); -uint16_t lcdGetPixelColor(uint16_t x, uint16_t y); - -/* Scrolling function */ -glcd_result_t lcdVerticalScroll(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, int16_t lines); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/glcd/glcd.mk b/glcd/glcd.mk deleted file mode 100644 index 22ed8922..00000000 --- a/glcd/glcd.mk +++ /dev/null @@ -1,5 +0,0 @@ -LCD_GLCD_SRC = $(LCDLIB)/glcd/glcd.c \ - $(LCDLIB)/glcd/console.c - -LCD_GLCD_INC = $(LCDLIB)/glcd \ - ${CHIBIOS}/os/halext/include ${CHIBIOS}/os/halext/src diff --git a/glcd/glcdWorker.h b/glcd/glcdWorker.h deleted file mode 100644 index 0d29d2da..00000000 --- a/glcd/glcdWorker.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GLCD_WORKER_H -#define GLCD_WORKER_H - -#include "glcd.h" - -#define GLCD_WORKER_SIZE 512 - -enum glcd_action { GLCD_SET_POWERMODE, - GLCD_SET_ORIENTATION, - GLCD_FILL_AREA, - GLCD_WRITE_AREA, - GLCD_CLEAR, - GLCD_GET_PIXEL_COLOR, - GLCD_DRAW_PIXEL, - GLCD_VERTICAL_SCROLL, - GLCD_DRAW_CHAR, - GLCD_DRAW_LINE, - GLCD_DRAW_CIRCLE, - GLCD_DRAW_ELLIPSE, - }; - -#define _glcd_msg_base \ - enum glcd_action action; - -struct glcd_msg_base { - _glcd_msg_base -}; - -struct glcd_msg_powermode { - _glcd_msg_base - - uint8_t powermode; -}; - -struct glcd_msg_orientation { - _glcd_msg_base - - uint8_t newOrientation; -}; - -struct glcd_msg_set_window { - _glcd_msg_base - - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; -}; - -struct glcd_msg_fill_area { - _glcd_msg_base - - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - uint16_t color; -}; - -struct glcd_msg_write_area { - _glcd_msg_base - - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - uint16_t *buffer; - size_t size; -}; - -struct glcd_msg_clear { - _glcd_msg_base - - uint16_t color; -}; - -struct glcd_msg_get_pixel_color { - _glcd_msg_base - - uint16_t x; - uint16_t y; - uint16_t color; -}; - -struct glcd_msg_draw_pixel { - _glcd_msg_base - - uint16_t x; - uint16_t y; - uint16_t color; -}; - -struct glcd_msg_vertical_scroll { - _glcd_msg_base - - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - int16_t lines; -}; - -struct glcd_msg_draw_line { - _glcd_msg_base - - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - int16_t color; -}; - -struct glcd_msg_draw_circle { - _glcd_msg_base - - uint16_t x; - uint16_t y; - uint16_t radius; - uint16_t y1; - uint8_t filled; - int16_t color; -}; - -struct glcd_msg_draw_ellipse { - _glcd_msg_base - - uint16_t x; - uint16_t y; - uint16_t a; - uint16_t b; - uint16_t y1; - uint8_t filled; - int16_t color; -}; - -struct glcd_msg_draw_char { - _glcd_msg_base; - - uint16_t cx; - uint16_t cy; - uint16_t color; - uint16_t bkcolor; - uint16_t ret_width; - char c; - font_t font; - bool_t tpText; -}; - -#endif - diff --git a/glcd/readme.txt b/glcd/readme.txt deleted file mode 100644 index 985e87c3..00000000 --- a/glcd/readme.txt +++ /dev/null @@ -1,25 +0,0 @@ -GLCD now uses the GDISP low level drivers and fonts. - -To update your make to use this new version: - Add the low level driver yo want to use to your make file. eg. - include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk - -There some restrictions that GLCD places on your use of new features and on the capabilities -of the low level driver. - -They are: - 1/ GLCD requires a driver that supports RGB565 pixel format. This is a - limitation of the GLCD API. To update the API would create compatability - issues with existing applications. - 2/ If you want to use the GLCD scroll or the GLCD read-pixel calls then your - low level driver must support them. If it doesn't these calls will - fail. - 3/ You cannot reduce the code size like in GDISP by defining macros to - compile out code that you are not using. - 4/ Some of the new features of GDISP like right or center justified text are not - supported as there is no equivelant API in GDISP. - 5/ There is no mechanism to send hardware specific commands to the low level driver - such as commands to control the back-light. - -What it does do that GDISP currently doesn't: - 1/ Asynchronous multi-thread support. \ No newline at end of file diff --git a/glcdconf.h b/glcdconf.h deleted file mode 100644 index c2dd00de..00000000 --- a/glcdconf.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GLCDCONF_H -#define GLCDCONF_H - -#define SCREEN_WIDTH 240 -#define SCREEN_HEIGHT 320 - -/***** LCD CONTROLLER *****/ -#define LCD_USE_SSD1289 -// #define LCD_USE_S6D1121 - - -/***** LCD INTERFACE *****/ -#define LCD_USE_GPIO -// #define LCD_USE_SPI -// #define LCD_USE_FSMC - - -/***** TOUCHPAD CONTROLLER *****/ -// #define TOUCHPAD_USE_ADS7843 -#define TOUCHPAD_USE_XPT2046 - - -/***** GUI OPTIONS *****/ -#define GUI_USE_ANIMATIONS - -#endif - diff --git a/graph/graph.c b/graph/graph.c deleted file mode 100644 index 853ab738..00000000 --- a/graph/graph.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "glcd.h" - -#define MARKSIZE 5 // half - -static uint16_t x, y; // origins in graph -static uint16_t grid_X, grid_Y; //grids - -void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color) { - uint16_t i, length; - volatile uint16_t off; - - x = x0; - y = y0; - grid_X = gridX; - grid_Y = gridY; - - // X-Axis - length = x1 - x0; - lcdDrawLine(x0, y0, x1, y0, color); - lcdDrawLine(x1, y0, x1-5, y0+5, color); - lcdDrawLine(x1, y0, x1-5, y0-5, color); - for(i=1; i<(length / grid_X); i++) { - off = x0 + i * grid_X; - lcdDrawLine(off, y0-MARKSIZE, off, y0+MARKSIZE, color); - } - - // Y-Axis - length = y0 - y1; - lcdDrawLine(x0, y0, x0, y1, color); - lcdDrawLine(x0, y1, x0-5, y1+5, color); - lcdDrawLine(x0, y1, x0+5, y1+5, color); - for(i=1; i<(length / grid_Y); i++) { - off = y0 + i * grid_Y; - lcdDrawLine(x0-MARKSIZE, off, x0+MARKSIZE, off, color); - } -} - -void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color) { - uint16_t i; - - for(i = 0; i < entries; i++) - lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, color); -} - -void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor) { - uint16_t i; - - for(i = 0; i < entries; ++i) - lcdDrawLine(coord[i-1][0]+x, y-coord[i-1][1], coord[i][0]+x, y-coord[i][1], lineColor); - for(i = 0; i < entries; ++i) - if(radius != 0) - lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, dotColor); -} - - diff --git a/graph/graph.h b/graph/graph.h deleted file mode 100644 index f4286fc2..00000000 --- a/graph/graph.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GRAPH_H -#define GRAPH_H - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * Description: does draw axis arrows and grid - * - * param: - * - x0, y0, x1, y1: location of arrows - * - gridX, gridY: grid size in X and Y direction - * - color: color of arrows - * - * return: none - */ -void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color); - -/* - * Description: does draw coordinates into graph as dots - * - * param: - * - coord: two dimensionl array containing X and Y coordinates - * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0]) - * - radius: size of the dots - * - color: color of the dots - * - * return: none - */ -void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color); - -/* - * Description: does draw coordinates into graph connected by lines - * - * param: - * - coord: two dimensional array containing X and Y coordinates - * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0]) - * - radius: if not 0, graphDrawDots() gets invoked - * - lineColor: color of the lines - * - dotColor: color of dots, if radius != 0 - * - * return: none - */ -void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/graph/graph.mk b/graph/graph.mk deleted file mode 100644 index 706a9412..00000000 --- a/graph/graph.mk +++ /dev/null @@ -1,3 +0,0 @@ -LCD_GRAPH_SRC = $(LCDLIB)/graph/graph.c - -LCD_GRAPH_INC = $(LCDLIB)/graph diff --git a/gui/gui.c b/gui/gui.c deleted file mode 100644 index 40553d86..00000000 --- a/gui/gui.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "gui.h" - -static struct guiNode_t *firstGUI = NULL; -uint16_t x, y; // global touchpad coordinates - -static uint8_t addElement(struct guiNode_t *newNode) { - struct guiNode_t *new; - - if(firstGUI == NULL) { - firstGUI = chHeapAlloc(NULL, sizeof(struct guiNode_t)); - if(firstGUI == NULL) - return 0; - - *firstGUI = *newNode; - firstGUI->next = NULL; - } else { - new = firstGUI; - while(new->next != NULL) - new = new->next; - - new->next = chHeapAlloc(NULL, sizeof(struct guiNode_t)); - if(new->next == NULL) - return 0; - - new = new->next; - *new = *newNode; - new->next = NULL; - } - - return 1; -} - -static uint8_t deleteElement(char *label) { - struct guiNode_t *pointer, *pointer1; - - if(firstGUI != NULL) { - if(strcmp(firstGUI->label, label) == 0) { - pointer = firstGUI->next; - chHeapFree(firstGUI); - firstGUI = pointer; - } else { - pointer = firstGUI; - - while(pointer->next != NULL) { - pointer1 = pointer->next; - - if(strcmp(firstGUI->label, label) == 0) { - pointer->next = pointer1->next; - chHeapFree(pointer1); - break; - } - - pointer = pointer1; - - } - } - - return 1; // successful - } - - return 0; // not successful -} - -void guiPrintElements(BaseSequentialStream *chp) { - struct guiNode_t *pointer = firstGUI; - - chprintf(chp, "\r\n\nguiNodes:\r\n\n"); - - while(pointer != NULL) { - chprintf(chp, "x0: %d\r\n", pointer->x0); - chprintf(chp, "y0: %d\r\n", pointer->y0); - chprintf(chp, "x1: %d\r\n", pointer->x1); - chprintf(chp, "y1: %d\r\n", pointer->y1); - chprintf(chp, "label: %s\r\n", pointer->label); - chprintf(chp, "active: %d\r\n", *(pointer->active)); - chprintf(chp, "state: %d\r\n", *(pointer->state)); - chprintf(chp, "*next: 0x%x\r\n", pointer->next); - chprintf(chp, "\r\n\n"); - pointer = pointer->next; - } -} - -static inline void buttonUpdate(struct guiNode_t *node) { - if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) { - *(node->state) = 1; - } else { - *(node->state) = 0; - } -} - -static inline void sliderUpdate(struct guiNode_t *node) { - uint16_t length = 1; - - if(node->orientation == horizontal) - length = node->x1 - node->x0; - else if(node->orientation == vertical) - length = node->y1 - node->y0; - - if(node->mode == modePassive) { - node->percentage = *(node->state); - } else if(node->mode == modeActive) { - if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) { - if(node->orientation == horizontal) { - node->percentage = (((x - node->x0) * 100) / length); - } else if(node->orientation == vertical) { - node->percentage = (((y - node->y0) * 100) / length); - } - } - - *(node->state) = node->percentage; - } - - // a bit of safety here - if(node->percentage > 100) - node->percentage = 100; - - if(node->orientation == horizontal) { - node->value = ((((node->x1)-(node->x0)) * node->percentage) / 100); - if(node->oldValue > node->value || node->value == 0) - lcdFillArea(node->x0+1, node->y0+1, node->x1, node->y1, node->bkColor); - else - lcdDrawRect(node->x0+1, node->y0+1, node->x0+node->value, node->y1, filled, node->valueColor); - } else if(node->orientation == vertical) { - node->value = ((((node->y1)-(node->y0)) * node->percentage) / 100); - if(node->oldValue > node->value || node->value == 0) - lcdFillArea(node->x0+1, node->y0+1, node->x1, node->y1, node->bkColor); - else - lcdDrawRect(node->x0+1, node->y0+1, node->x1, node->y0+node->value, filled, node->valueColor); - } - - node->oldValue = node->value; -} - -static inline void wheelUpdate(struct guiNode_t *node) { - (void)node; -} - -static inline void keymatrixUpdate(struct guiNode_t *node) { - (void)node; -} - -static void guiThread(const uint16_t interval) { - struct guiNode_t *node; - - chRegSetThreadName("GUI"); - - while(TRUE) { - for(node = firstGUI; node; node = node->next) { - // check if GUI element is set active - if(*(node->active) == active) { - x = tpReadX(); - y = tpReadY(); - - switch(node->type) { - case button: - buttonUpdate(node); - break; - case slider: - sliderUpdate(node); - break; - case wheel: - wheelUpdate(node); - break; - case keymatrix: - keymatrixUpdate(node); - break; - } - } - } - - chThdSleepMilliseconds(interval); - } -} - -Thread *guiInit(uint16_t interval, tprio_t priority) { - Thread *tp = NULL; - - tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(512), priority, guiThread, interval); - - return tp; -} - -uint8_t guiDeleteElement(char *label) { - return deleteElement(label); -} - -uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state) { - struct guiNode_t *newNode; - uint16_t i; - - newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); - if(newNode == NULL) - return 0; - - newNode->type = button; - newNode->label = label; - newNode->x0 = x0; - newNode->y0 = y0; - newNode->x1 = x1; - newNode->y1 = y1; - newNode->shadow = shadow; - newNode->active = active; - newNode->state = state; - - if(addElement(newNode) != 1) - return 0; - - lcdDrawRectString(x0, y0, x1, y1, str, font, fontColor, buttonColor); - - if(shadow != 0) { - for(i = 0; i < shadow; i++) { - lcdDrawLine(x0+shadow, y1+i, x1+shadow-1, y1+i, Black); - lcdDrawLine(x1+i, y0+shadow, x1+i, y1+shadow-1, Black); - } - } - - chHeapFree(newNode); - - return 1; -} - -uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value) { - struct guiNode_t *newNode; - - newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); - if(newNode == NULL) - return 0; - - newNode->type = slider; - newNode->label = label; - newNode->x0 = x0; - newNode->y0 = y0; - newNode->x1 = x1; - newNode->y1 = y1; - newNode->mode = mode; - newNode->bkColor = bkColor; - newNode->valueColor = valueColor; - newNode->state = value; - newNode->active = active; - newNode->orientation = orientation; - newNode->percentage = 0; - - if(addElement(newNode) != 1) - return 0; - - (void)bkColor; - (void)valueColor; - - // lcdDraw functions - lcdDrawRect(x0, y0, x1, y1, frame, frameColor); - - chHeapFree(newNode); - - return 1; -} - -uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value) { - struct guiNode_t *newNode; - - newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); - if(newNode == NULL) - return 0; - - newNode->type = wheel; - newNode->label = label; - newNode->x0 = x0; - newNode->y0 = y0; - newNode->r1 = radius1; - newNode->r2 = radius2; - newNode->active = active; - newNode->state = value; - - if(addElement(newNode) != 1) - return 0; - - (void)bkColor; - (void)valueColor; - // lcdDraw functions - - chHeapFree(newNode); - - return 1; -} - -uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t size, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value) { - struct guiNode_t *newNode; - - newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); - if(newNode == NULL) - return 0; - - newNode->type = keymatrix; - newNode->label = label; - newNode->x0 = x0; - newNode->y0 = y0; - newNode->shadow = shadow; - newNode->active = active; - newNode->state = value; - - if(addElement(newNode) != 1) - return 0; - - // lcdDraw functions - (void)size; - (void)space; - (void)buttonColor; - (void)fontColor; - (void)font; - - chHeapFree(newNode); - - return 1; -} - diff --git a/gui/gui.h b/gui/gui.h deleted file mode 100644 index 04d9a8b1..00000000 --- a/gui/gui.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GUI_H -#define GUI_H - -#include "ch.h" -#include "hal.h" -#include "glcd.h" -#include "chprintf.h" -#include "touchpad.h" -#include - -struct guiNode_t { - uint8_t type; - uint16_t x0; - uint16_t y0; - uint16_t x1; - uint16_t y1; - uint16_t r1; - uint16_t r2; - uint16_t shadow; - uint16_t bkColor; - uint16_t valueColor; - uint16_t value; - uint16_t oldValue; - uint16_t percentage; - uint8_t orientation; - uint8_t mode; - uint8_t *active; - uint8_t *state; - char *label; - struct guiNode_t *next; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -enum {button, slider, wheel, keymatrix}; -enum {horizontal, vertical}; -enum {inactive, active}; -enum {modePassive, modeActive}; - -/* - * Description: creates the GUI thread - * - * param: - interval: thread sleep in milliseconds after each GUI element update - * - priority: priority of the thread - * - * return: pointer to created thread - */ -Thread *guiInit(uint16_t interval, tprio_t priority); - -/* - * Description: prints all GUI elements structs (linked list) - * - * param: - chp: pointer to output stream - * - * return: none - */ -void guiPrintElements(BaseSequentialStream *chp); - -/* - * Description: deletes a GUI element from the linked list - * - * param: - label: label of the element (parameter of each guiDrawXXX function) - * - * return: 1 if successful, 0 otherwise - */ -uint8_t guiDeleteElement(char *label); - -/* - * Description: draws a button on the screen and keeps it's state up to date - * - * param: - x0, y0, x1, y1: start and end coordinates of the button's rectangle - * - str: string that gets drawn into the rectangle - button's lable - * - fontColor: color of the lable - * - buttonColor: color of the rectangle - * - shadow: draws a black shadow with N pixels size if != 0 - * - active: pass pointer to variable which holds the state 'active' or 'inactive' - * - state: pass pointer to variable whcih will keep the state of the button (pressed / unpressed)' - * - * return: 1 if button successfully created - */ -uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state); - -uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value); - -uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value); - -uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t buttonSize, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/gui/gui.mk b/gui/gui.mk deleted file mode 100644 index e25cbd73..00000000 --- a/gui/gui.mk +++ /dev/null @@ -1,3 +0,0 @@ -LCD_GUI_SRC = $(LCDLIB)/gui/gui.c - -LCD_GUI_INC = $(LCDLIB)/gui diff --git a/halext/drivers/gdispNokia6610/GE12.h b/halext/drivers/gdispNokia6610/GE12.h deleted file mode 100644 index 7f438d9a..00000000 --- a/halext/drivers/gdispNokia6610/GE12.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GE12_H -#define GE12_H - -// ************************************************************************************* -// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver (GE12) -// -// Taken from Philips data sheet Feb 14, 2003 -// ************************************************************************************* - -// Philips PCF8833 LCD controller command codes -#define NOP 0x00 // nop -#define SWRESET 0x01 // software reset -#define BSTROFF 0x02 // booster voltage OFF -#define BSTRON 0x03 // booster voltage ON -#define RDDIDIF 0x04 // read display identification -#define RDDST 0x09 // read display status -#define SLEEPIN 0x10 // sleep in -#define SLEEPOUT 0x11 // sleep out -#define PTLON 0x12 // partial display mode -#define NORON 0x13 // display normal mode -#define INVOFF 0x20 // inversion OFF -#define INVON 0x21 // inversion ON -#define DALO 0x22 // all pixel OFF -#define DAL 0x23 // all pixel ON -#define SETCON 0x25 // write contrast -#define DISPOFF 0x28 // display OFF -#define DISPON 0x29 // display ON -#define CASET 0x2A // column address set -#define PASET 0x2B // page address set -#define RAMWR 0x2C // memory write -#define RGBSET 0x2D // colour set -#define PTLAR 0x30 // partial area -#define VSCRDEF 0x33 // vertical scrolling definition -#define TEOFF 0x34 // test mode -#define TEON 0x35 // test mode -#define MADCTL 0x36 // memory access control -#define SEP 0x37 // vertical scrolling start address -#define IDMOFF 0x38 // idle mode OFF -#define IDMON 0x39 // idle mode ON -#define COLMOD 0x3A // interface pixel format -#define SETVOP 0xB0 // set Vop -#define BRS 0xB4 // bottom row swap -#define TRS 0xB6 // top row swap -#define DISCTR 0xB9 // display control -#define DOR 0xBA // data order -#define TCDFE 0xBD // enable/disable DF temperature compensation -#define TCVOPE 0xBF // enable/disable Vop temp comp -#define EC 0xC0 // internal or external oscillator -#define SETMUL 0xC2 // set multiplication factor -#define TCVOPAB 0xC3 // set TCVOP slopes A and B -#define TCVOPCD 0xC4 // set TCVOP slopes c and d -#define TCDF 0xC5 // set divider frequency -#define DF8COLOR 0xC6 // set divider frequency 8-color mode -#define SETBS 0xC7 // set bias system -#define RDTEMP 0xC8 // temperature read back -#define NLI 0xC9 // n-line inversion -#define RDID1 0xDA // read ID1 -#define RDID2 0xDB // read ID2 -#define RDID3 0xDC // read ID3 - -#endif /* GE12_H */ diff --git a/halext/drivers/gdispNokia6610/GE8.h b/halext/drivers/gdispNokia6610/GE8.h deleted file mode 100644 index 3ae0be77..00000000 --- a/halext/drivers/gdispNokia6610/GE8.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef GE8_H -#define GE8_H - -// ***************************************************************************** -// Include file for Epson S1D15G00 LCD Controller (GE8) -// -// Author: James P Lynch August 30, 2007 -// Modified for GDISP: Andrew Hannam August 2, 2012 -// -// ***************************************************************************** - -#define DISON 0xAF // Display on -#define DISOFF 0xAE // Display off -#define DISNOR 0xA6 // Normal display -#define DISINV 0xA7 // Inverse display -#define COMSCN 0xBB // Common scan direction -#define DISCTL 0xCA // Display control -#define SLPIN 0x95 // Sleep in -#define SLPOUT 0x94 // Sleep out -#define PASET 0x75 // Page address set -#define CASET 0x15 // Column address set -#define DATCTL 0xBC // Data scan direction, etc. -#define RGBSET8 0xCE // 256-color position set -#define RAMWR 0x5C // Writing to memory -#define RAMRD 0x5D // Reading from memory -#define PTLIN 0xA8 // Partial display in -#define PTLOUT 0xA9 // Partial display out -#define RMWIN 0xE0 // Read and modify write -#define RMWOUT 0xEE // End -#define ASCSET 0xAA // Area scroll set -#define SCSTART 0xAB // Scroll start set -#define OSCON 0xD1 // Internal oscillation on -#define OSCOFF 0xD2 // Internal oscillation off -#define PWRCTR 0x20 // Power control -#define VOLCTR 0x81 // Electronic volume control -#define VOLUP 0xD6 // Increment electronic control by 1 -#define VOLDOWN 0xD7 // Decrement electronic control by 1 -#define TMPGRD 0x82 // Temperature gradient set -#define EPCTIN 0xCD // Control EEPROM -#define EPCOUT 0xCC // Cancel EEPROM control -#define EPMWR 0xFC // Write into EEPROM -#define EPMRD 0xFD // Read from EEPROM -#define EPSRRD1 0x7C // Read register 1 -#define EPSRRD2 0x7D // Read register 2 -#define NOP 0x25 // NOP instruction - -#endif /* GE8_H */ diff --git a/halext/drivers/gdispNokia6610/gdisp_lld.c b/halext/drivers/gdispNokia6610/gdisp_lld.c deleted file mode 100644 index 5ebe2177..00000000 --- a/halext/drivers/gdispNokia6610/gdisp_lld.c +++ /dev/null @@ -1,688 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispNokia6610/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/* Include the emulation code for things we don't support */ -#include "gdisp_emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/* Controller definitions */ -#if defined(LCD_USE_GE8) - #include "GE8.h" -#elif defined(LCD_USE_GE12) - #include "GE12.h" -#else - #error "gdispNokia6610: Either LCD_USE_GE8 or LCD_USE_GE12 must be defined depending on your controller" -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#include "gdisp_fonts.h" - -#if defined(BOARD_OLIMEX_SAM7_EX256) - #include "gdisp_lld_board_olimexsam7ex256.h" -#else - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#endif - -#define gdisp_lld_write_command(cmd) GDISP_LLD(write_spi)((cmd) & ~0x0100) -#define gdisp_lld_write_data(data) GDISP_LLD(write_spi)((data) | 0x0100) - -static __inline void gdisp_lld_setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { - gdisp_lld_write_command(CASET); // Column address set - gdisp_lld_write_data(x); - gdisp_lld_write_data(x+cx-1); - gdisp_lld_write_command(PASET); // Page address set - gdisp_lld_write_data(y); - gdisp_lld_write_data(y+cy-1); -} - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - GDISP_LLD(init_board)(); - - // Hardware reset - GDISP_LLD(setpin_reset)(TRUE); - chThdSleepMilliseconds(20); - GDISP_LLD(setpin_reset)(FALSE); - chThdSleepMilliseconds(20); - - #if defined(LCD_USE_GE8) - #if 1 - gdisp_lld_write_command(DISCTL); // Display control - gdisp_lld_write_data(0x00); // P1: 0x00 = 2 divisions, switching period=8 (default) - gdisp_lld_write_data(0x20); // P2: 0x20 = nlines/4 - 1 = 132/4 - 1 = 32) - gdisp_lld_write_data(0x00); // P3: 0x00 = no inversely highlighted lines - gdisp_lld_write_command(COMSCN); // COM scan - gdisp_lld_write_data(1); // P1: 0x01 = Scan 1->80, 160<-81 - gdisp_lld_write_command(OSCON); // Internal oscilator ON - gdisp_lld_write_command(SLPOUT); // Sleep out - gdisp_lld_write_command(PWRCTR); // Power control - gdisp_lld_write_data(0x0f); // reference voltage regulator on, circuit voltage follower on, BOOST ON - // Interesting - all the code seems to say this should be done. But my display doesn't want it! - //gdisp_lld_write_command(DISINV); // Inverse display - gdisp_lld_write_command(DATCTL); // Data control - gdisp_lld_write_data(0x01); // P1: 0x01 = page address inverted, column address normal, address scan in column direction - gdisp_lld_write_data(0x00); // P2: 0x00 = RGB sequence (default value) - gdisp_lld_write_data(0x02); // P3: 0x02 = Grayscale -> 16 (selects 12-bit color, type A) - gdisp_lld_write_command(VOLCTR); // Voltage control (contrast setting) - gdisp_lld_write_data(32); // P1 = 32 volume value (experiment with this value to get the best contrast) - gdisp_lld_write_data(3); // P2 = 3 resistance ratio (only value that works) - chThdSleepMilliseconds(100); // allow power supply to stabilize - gdisp_lld_write_command(DISON); // Turn on the display - #else - // Alternative - gdisp_lld_write_command(DISCTL); // Display control - gdisp_lld_write_data(0x00); // default - gdisp_lld_write_data(0x20); // (32 + 1) * 4 = 132 lines (of which 130 are visible) - gdisp_lld_write_data(0x0a); // default - gdisp_lld_write_command(COMSCN); // COM scan - gdisp_lld_write_data(0x00); // Scan 1-80 - gdisp_lld_write_command(OSCON); // Internal oscilator ON - chThdSleepMilliseconds(100); // wait aproximetly 100ms - gdisp_lld_write_command(SLPOUT); // Sleep out - gdisp_lld_write_command(VOLCTR); // Voltage control - gdisp_lld_write_data(0x1F); // middle value of V1 - gdisp_lld_write_data(0x03); // middle value of resistance value - gdisp_lld_write_command(TMPGRD); // Temperature gradient - gdisp_lld_write_data(0x00); // default - gdisp_lld_write_command(PWRCTR); // Power control - gdisp_lld_write_data(0x0f); // referance voltage regulator on, circuit voltage follower on, BOOST ON - gdisp_lld_write_command(DISNOR); // Normal display - gdisp_lld_write_command(DISINV); // Inverse display - gdisp_lld_write_command(PTLOUT); // Partial area off - // gdisp_lld_write_command(ASCSET); // Scroll area set - // gdisp_lld_write_data(0); - // gdisp_lld_write_data(0); - // gdisp_lld_write_data(40); - // gdisp_lld_write_data(3); - // gdisp_lld_write_command(SCSTART); // Vertical scrool address start - // gdisp_lld_write_data(0); - gdisp_lld_write_command(DATCTL); // Data control - gdisp_lld_write_data(0x00); // all inversions off, column direction - gdisp_lld_write_data(0x03); // RGB sequence - gdisp_lld_write_data(0x02); // Grayscale -> 16 - gdisp_lld_write_command(PASET); // Page Address set - gdisp_lld_write_data(0); - gdisp_lld_write_data(131); - gdisp_lld_write_command(CASET); // Page Column set - gdisp_lld_write_data(0); - gdisp_lld_write_data(131); - gdisp_lld_write_command(DISON); // Turn on the display - #endif - - #elif defined(LCD_USE_GE12) - #if 1 - gdisp_lld_write_command(SLEEPOUT); // Sleep out - gdisp_lld_write_command(INVON); // Inversion on: seems to be required for this controller - gdisp_lld_write_command(COLMOD); // Color Interface Pixel Format - gdisp_lld_write_data(0x03); // 0x03 = 12 bits-per-pixel - gdisp_lld_write_command(MADCTL); // Memory access controler - gdisp_lld_write_data(0xC8); // 0xC0 = mirror x and y, reverse rgb - gdisp_lld_write_command(SETCON); // Write contrast - gdisp_lld_write_data(0x30); // contrast - experiental value - chThdSleepMilliseconds(20); - gdisp_lld_write_command(DISPON); // Display On - #else - // Alternative - // Hardware reset commented out - gdisp_lld_write_command(SOFTRST); // Software Reset - chThdSleepMilliseconds(20); - gdisp_lld_write_command(INITESC); // Initial escape - chThdSleepMilliseconds(20); - gdisp_lld_write_command(REFSET); // Refresh set - gdisp_lld_write_data(0); - gdisp_lld_write_command(DISPCTRL); // Set Display control - gdisp_lld_write_data(128); // Set the lenght of one selection term - gdisp_lld_write_data(128); // Set N inversion -> no N inversion - gdisp_lld_write_data(134); // Set frame frequence and bias rate -> 2 devision of frequency and 1/8 bias, 1/67 duty, 96x67 size - gdisp_lld_write_data(84); // Set duty parameter - gdisp_lld_write_data(69); // Set duty parameter - gdisp_lld_write_data(82); // Set duty parameter - gdisp_lld_write_data(67); // Set duty parameter - gdisp_lld_write_command(GRAYSCALE0); // Grey scale 0 position set - 15 parameters - gdisp_lld_write_data(1); // GCP1 - gray lavel to be output when the RAM data is "0001" - gdisp_lld_write_data(2); // GCP2 - gray lavel to be output when the RAM data is "0010" - gdisp_lld_write_data(4); // GCP3 - gray lavel to be output when the RAM data is "0011" - gdisp_lld_write_data(8); // GCP4 - gray lavel to be output when the RAM data is "0100" - gdisp_lld_write_data(16); // GCP5 - gray lavel to be output when the RAM data is "0101" - gdisp_lld_write_data(30); // GCP6 - gray lavel to be output when the RAM data is "0110" - gdisp_lld_write_data(40); // GCP7 - gray lavel to be output when the RAM data is "0111" - gdisp_lld_write_data(50); // GCP8 - gray lavel to be output when the RAM data is "1000" - gdisp_lld_write_data(60); // GCP9 - gray lavel to be output when the RAM data is "1001" - gdisp_lld_write_data(70); // GCP10 - gray lavel to be output when the RAM data is "1010" - gdisp_lld_write_data(80); // GCP11 - gray lavel to be output when the RAM data is "1011" - gdisp_lld_write_data(90); // GCP12 - gray lavel to be output when the RAM data is "1100" - gdisp_lld_write_data(100); // GCP13 - gray lavel to be output when the RAM data is "1101" - gdisp_lld_write_data(110); // GCP14 - gray lavel to be output when the RAM data is "1110" - gdisp_lld_write_data(127); // GCP15 - gray lavel to be output when the RAM data is "1111" - gdisp_lld_write_command(GAMMA); // Gamma curve set - select gray scale - GRAYSCALE 0 or GREYSCALE 1 - gdisp_lld_write_data(1); // Select grey scale 0 - gdisp_lld_write_command(COMMONDRV); // Command driver output - gdisp_lld_write_data(0); // Set COM1-COM41 side come first, normal mod - gdisp_lld_write_command(NORMALMODE); // Set Normal mode (my) - // gdisp_lld_write_command(INVERSIONOFF); // Inversion off - gdisp_lld_write_command(COLADDRSET); // Column address set - gdisp_lld_write_data(0); - gdisp_lld_write_data(131); - gdisp_lld_write_command(PAGEADDRSET); // Page address set - gdisp_lld_write_data(0); - gdisp_lld_write_data(131); - gdisp_lld_write_command(ACCESSCTRL); // Memory access controler - gdisp_lld_write_data(0x40); // horizontal - //gdisp_lld_write_data(0x20); // vertical - gdisp_lld_write_command(PWRCTRL); // Power control - gdisp_lld_write_data(4); // Internal resistance, V1OUT -> high power mode, oscilator devision rate - gdisp_lld_write_command(SLEEPOUT); // Sleep out - gdisp_lld_write_command(VOLTCTRL); // Voltage control - voltage control and write contrast define LCD electronic volume - //gdisp_lld_write_data(0x7f); // full voltage control - //gdisp_lld_write_data(0x03); // must be "1" - gdisp_lld_write_command(CONTRAST); // Write contrast - gdisp_lld_write_data(0x3b); // contrast - chThdSleepMilliseconds(20); - gdisp_lld_write_command(TEMPGRADIENT); // Temperature gradient - for(i=0; i<14; i++) gdisp_lld_write_data(0); - gdisp_lld_write_command(BOOSTVON); // Booster voltage ON - gdisp_lld_write_command(DISPLAYON); // Finally - Display On - #endif - #endif - - /* Turn on the back-light */ - GDISP_LLD(setpin_backlight)(TRUE); - - /* Initialise the GDISP structure to match */ - GDISP.Width = 132; - GDISP.Height = 132; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return; - #endif - gdisp_lld_setviewport(x, y, 1, 1); - gdisp_lld_write_command(RAMWR); - gdisp_lld_write_data((color >> 4) & 0xFF); - gdisp_lld_write_data((color << 4) & 0xF0); - gdisp_lld_write_command(NOP); -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If fillarea() is defined there is little - point in defining clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - fillarea() and blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear(color_t color) { - /* NOT IMPLEMENTED */ - /* Nothing to be gained by implementing this - * as fillarea is just as fast. - */ - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - unsigned i, tuples; - - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel. - // This extra pixel is ignored by the controller. - - gdisp_lld_setviewport(x, y, cx, cy); - gdisp_lld_write_command(RAMWR); - for(i=0; i < tuples; i++) { - gdisp_lld_write_data((color >> 4) & 0xFF); - gdisp_lld_write_data(((color << 4) & 0xF0)|((color >> 8) & 0x0F)); - gdisp_lld_write_data(color & 0xFF); - } - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - unsigned i, area, tuples; - #ifndef GDISP_PACKED_PIXELS - color_t c1, c2; - #endif - - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) return; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - area = cx*cy; - - gdisp_lld_setviewport(x, y, cx, cy); - gdisp_lld_write_command(RAMWR); - - #ifdef GDISP_PACKED_PIXELS - // 3 bytes per 2 pixels + an extra 2 bytes if the total size is odd. - // Note we can't just over-estimate this and let the controller handle the extra pixel - // as that might over-run our source buffer (very bad in some circumstances). - tuples = (area/2)*3+(area & 0x01)*2; - for(i=0; i < tuples; i++) - gdisp_lld_write_data(*buffer++); - if (area & 0x01) - gdisp_lld_write_command(NOP); - #else - // Although this controller uses packed pixels we support unpacked pixel - // formats in this blit by packing the data as we feed it to the controller. - tuples = area/2; - for(i=0; i < tuples; i++) { - c1 = *buffer++; - c2 = *buffer++; - gdisp_lld_write_data((c1 >> 4) & 0xFF); - gdisp_lld_write_data(((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)); - gdisp_lld_write_data(c2 & 0xFF); - } - if (area & 0x01) { - c1 = *buffer++; - gdisp_lld_write_data((c1 >> 4) & 0xFF); - gdisp_lld_write_data((c1 << 4) & 0xF0); - gdisp_lld_write_command(NOP); - } - #endif - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - #include "gdisp_fonts.h" -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - /* NOT IMPLEMENTED */ - } -#endif - -#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(int what, void *value) { - /* NOT IMPLEMENTED YET */ - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - /* Code here */ - break; - case powerOn: - /* Code here */ - /* You may need this --- - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init(); - */ - break; - case powerSleep: - /* Code here */ - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility) - // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb) - switch((gdisp_orientation_t)value) { - case portrait: - /* Code here */ - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscape: - /* Code here */ - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - case portraitInv: - /* Code here */ - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscapeInv: - /* Code here */ - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - default: - return; - } - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) -/** - * @brief Query a driver value. - * @detail Typecase the result to the type you want. - * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen - * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen - * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode - * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation - * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) - * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). - * GDISP_QUERY_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to Query - * - * @notapi - */ -void *GDISP_LLD(query)(unsigned what) { - switch(what) { - case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; - case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; - case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; - case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; - case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; - case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; - case GDISP_QUERY_LLD+0: - /* Code here */ - default: return (void *)-1; - } -} -#endif - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispNokia6610/gdisp_lld.mk b/halext/drivers/gdispNokia6610/gdisp_lld.mk deleted file mode 100644 index 43ed7581..00000000 --- a/halext/drivers/gdispNokia6610/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -HALSRC += $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/gdispNokia6610 diff --git a/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h b/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h deleted file mode 100644 index 0e2b806e..00000000 --- a/halext/drivers/gdispNokia6610/gdisp_lld_board_example.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispNokia6610/gdisp_lld_board_example.h - * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the spi port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void GDISP_LLD(init_board)(void) { - /* Code here */ -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { - /* Code here */ -} - -/** - * @brief Set or clear the lcd back-light pin. - * - * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off - * - * @notapi - */ -static __inline void GDISP_LLD(setpin_backlight)(bool_t state) { - /* Code here */ -} - -/** - * @brief Send a 9 bit command/data to the lcd. - * @note The chip select may need to be asserted/de-asserted - * around the actual spi write - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void GDISP_LLD(write_spi)(uint16_t data) { - /* Code here */ -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * @note The chip select may need to be asserted/de-asserted - * around the actual spi read - * - * @notapi - */ -static __inline uint16_t GDISP_LLD(read_spi)(void) { - /* Code here */ -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h b/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h deleted file mode 100644 index b5b4b1d5..00000000 --- a/halext/drivers/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h +++ /dev/null @@ -1,199 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h - * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_BOARD_H -#define _GDISP_LLD_BOARD_H - -// mask definitions -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 - -// ****************************************************** -// Pointers to AT91SAM7X256 peripheral data structures -// ****************************************************** -volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; -volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB; -volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0; -volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; -volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0; - -/** - * @brief Initialise the board for the display. - * @notes Performs the following functions: - * 1. initialise the spi port used by your display - * 2. initialise the reset pin (initial state not-in-reset) - * 3. initialise the chip select pin (initial state not-active) - * 4. initialise the backlight pin (initial state back-light off) - * - * @notapi - */ -static __inline void GDISP_LLD(init_board)(void) { - // ********************************************************************************************* - // InitSpi( ) - // - // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display - // - // I/O ports used: PA2 = LCD Reset (set to low to reset) - // PA12 = LCD chip select (set to low to select the LCD chip) - // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface) - // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) - // PA18 = SPI0_SPCK Serial Clock (to LCD slave) - // PB20 = backlight control (normally PWM control, 1 = full on) - // - // *********************************************************************************************} - - /* This code should really use the ChibiOS driver for these functions */ - - // Pin for backlight - pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW - pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output - - // Reset pin - pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH - pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output - - // CS pin - this seems to be ignored - // pPIOA->PIO_SODR = BIT12; // Set PA2 to HIGH - // pPIOA->PIO_OER = BIT12; // Configure PA2 as output - - // Init SPI0 - // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral) - // BIT12 = PA12 -> SPI0_NPCS0 chip select - // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface) - // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) - // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave) - pPIOA->PIO_PDR = BIT12 | BIT16 | BIT17 | BIT18; - pPIOA->PIO_ASR = BIT12 | BIT16 | BIT17 | BIT18; - pPIOA->PIO_BSR = 0; - - //enable the clock of SPI - pPMC->PMC_PCER = 1 << AT91C_ID_SPI0; - - // Fixed mode - pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset - pSPI->SPI_CR = 0x01; //SPI Enable - - //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110 - pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110 - - //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz - pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above -} - -/** - * @brief Set or clear the lcd reset pin. - * - * @param[in] state TRUE = lcd in reset, FALSE = normal operation - * - * @notapi - */ -static __inline void GDISP_LLD(setpin_reset)(bool_t state) { - if (state) - palClearPad(IOPORT1, PIOA_LCD_RESET); -// pPIOA->PIO_CODR = PIOA_LCD_RESET_MASK; - else - palSetPad(IOPORT1, PIOA_LCD_RESET); -// pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; -} - -/** - * @brief Set or clear the lcd back-light pin. - * - * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off - * - * @notapi - */ -static __inline void GDISP_LLD(setpin_backlight)(bool_t state) { - if (state) - palSetPad(IOPORT2, PIOB_LCD_BL); -// pPIOB->PIO_SODR = PIOB_LCD_BL_MASK; - else - palClearPad(IOPORT2, PIOB_LCD_BL); -// pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; -} - -/** - * @brief Send a 9 bit command/data to the lcd. - * - * @param[in] data The data to send - * - * @notapi - */ -static __inline void GDISP_LLD(write_spi)(uint16_t data) { - // wait for the previous transfer to complete - while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); - // send the data - pSPI->SPI_TDR = data; -} - -#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) -/** - * @brief Read data from the lcd. - * - * @return The data from the lcd - * - * @notapi - */ -static __inline uint16_t GDISP_LLD(read_spi)(void) { - #error "gdispNokia6610: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board" - return 0; -} -#endif - -#endif /* _GDISP_LLD_BOARD_H */ -/** @} */ diff --git a/halext/drivers/gdispNokia6610/gdisp_lld_config.h b/halext/drivers/gdispNokia6610/gdisp_lld_config.h deleted file mode 100644 index 9e2d1258..00000000 --- a/halext/drivers/gdispNokia6610/gdisp_lld_config.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispNokia6610/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if HAL_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "Nokia6610" -#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610 - -#define GDISP_HARDWARE_LINES FALSE -#define GDISP_HARDWARE_CLEARS FALSE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CIRCLES FALSE -#define GDISP_HARDWARE_CIRCLEFILLS FALSE -#define GDISP_HARDWARE_ELLIPSES FALSE -#define GDISP_HARDWARE_ELLIPSEFILLS FALSE -#define GDISP_HARDWARE_TEXT FALSE -#define GDISP_HARDWARE_TEXTFILLS FALSE -#define GDISP_HARDWARE_SCROLL FALSE -#define GDISP_HARDWARE_PIXELREAD FALSE -#define GDISP_HARDWARE_CONTROL FALSE -#define GDISP_HARDWARE_QUERY FALSE - -#define GDISP_SOFTWARE_TEXTFILLDRAW TRUE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/drivers/gdispNokia6610/readme.txt b/halext/drivers/gdispNokia6610/readme.txt deleted file mode 100644 index facb400f..00000000 --- a/halext/drivers/gdispNokia6610/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) One (only) of: - #define LCD_USE_GE8 /* The Epson controller */ - #define LCD_USE_GE12 /* The Philips controller */ - d) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h file as a basis. - Currently known boards are: - Olimex SAM7-EX256 - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk diff --git a/halext/drivers/gdispS6d1121/gdisp_lld.c b/halext/drivers/gdispS6d1121/gdisp_lld.c deleted file mode 100644 index 5811a6ed..00000000 --- a/halext/drivers/gdispS6d1121/gdisp_lld.c +++ /dev/null @@ -1,688 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispS6d1121/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the S6d1121 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/* Include the emulation code for things we don't support */ -#include "gdisp_emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#include "s6d1121_lld.c.h" - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - palSetPadMode(LCD_RST_GPIO, LCD_RST_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - // A Good idea to reset the module before using - LCD_RST_LOW; - s6d1121_delay(2); - LCD_RST_HIGH; // Hardware Reset - s6d1121_delay(2); - - #ifdef LCD_USE_GPIO - // IO Default Configurations - palSetPadMode(LCD_CS_GPIO, LCD_CS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_WR_GPIO, LCD_WR_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_RD_GPIO, LCD_RD_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_RS_GPIO, LCD_RS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetPadMode(LCD_BL_GPIO, LCD_BL_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - - palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); - - LCD_CS_HIGH; - LCD_RD_HIGH; - LCD_WR_HIGH; - LCD_BL_LOW; - - #elif defined(LCD_USE_FSMC) - #if defined(STM32F1XX) - /* FSMC setup. TODO: this only works for STM32F1 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - - /* TODO: pin setup */ - #elif defined(STM32F4XX) - /* STM32F4 FSMC init */ - rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); - - /* set pins to FSMC mode */ - IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | - (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; - - IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | - (1 << 13) | (1 << 14) | (1 << 15), 0}; - - palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); - palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); - #else - #error "FSMC not implemented for this device" - #endif - - int FSMC_Bank = 0; - /* FSMC timing */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = (10) | (10 << 8) | (10 << 16); - - /* Bank1 NOR/SRAM control register configuration */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; - #endif - - lld_lcdWriteReg(0x11,0x2004); - lld_lcdWriteReg(0x13,0xCC00); - lld_lcdWriteReg(0x15,0x2600); - lld_lcdWriteReg(0x14,0x252A); - lld_lcdWriteReg(0x12,0x0033); - lld_lcdWriteReg(0x13,0xCC04); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x13,0xCC06); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x13,0xCC4F); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x13,0x674F); - lld_lcdWriteReg(0x11,0x2003); - - s6d1121_delay(1); - - // Gamma Setting - lld_lcdWriteReg(0x30,0x2609); - lld_lcdWriteReg(0x31,0x242C); - lld_lcdWriteReg(0x32,0x1F23); - lld_lcdWriteReg(0x33,0x2425); - lld_lcdWriteReg(0x34,0x2226); - lld_lcdWriteReg(0x35,0x2523); - lld_lcdWriteReg(0x36,0x1C1A); - lld_lcdWriteReg(0x37,0x131D); - lld_lcdWriteReg(0x38,0x0B11); - lld_lcdWriteReg(0x39,0x1210); - lld_lcdWriteReg(0x3A,0x1315); - lld_lcdWriteReg(0x3B,0x3619); - lld_lcdWriteReg(0x3C,0x0D00); - lld_lcdWriteReg(0x3D,0x000D); - - lld_lcdWriteReg(0x16,0x0007); - lld_lcdWriteReg(0x02,0x0013); - lld_lcdWriteReg(0x03,0x0003); - lld_lcdWriteReg(0x01,0x0127); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x08,0x0303); - lld_lcdWriteReg(0x0A,0x000B); - lld_lcdWriteReg(0x0B,0x0003); - lld_lcdWriteReg(0x0C,0x0000); - lld_lcdWriteReg(0x41,0x0000); - lld_lcdWriteReg(0x50,0x0000); - lld_lcdWriteReg(0x60,0x0005); - lld_lcdWriteReg(0x70,0x000B); - lld_lcdWriteReg(0x71,0x0000); - lld_lcdWriteReg(0x78,0x0000); - lld_lcdWriteReg(0x7A,0x0000); - lld_lcdWriteReg(0x79,0x0007); - lld_lcdWriteReg(0x07,0x0051); - - s6d1121_delay(1); - - lld_lcdWriteReg(0x07,0x0053); - lld_lcdWriteReg(0x79,0x0000); - - lld_lcdResetViewPort(); - - /* Now initialise the GDISP structure */ - GDISP.Width = SCREEN_WIDTH; - GDISP.Height = SCREEN_HEIGHT; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return; - #endif - lld_lcdSetCursor(x, y); - lld_lcdWriteReg(0x0022, color); -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If fillarea() is defined there is little - point in defining clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - fillarea() and blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear)(color_t color) { - unsigned i; - - lld_lcdSetCursor(0, 0); - lld_lcdWriteStreamStart(); - - for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - #if GDISP_NEED_VALIDATION - /* Need to clip to screen */ - #endif - /* Code here */ - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - unsigned i, area; - - area = cx*cy; - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - for(i = 0; i < area; i++) - lld_lcdWriteData(color); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - unsigned i, area; - - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) return; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - area = cx*cy; - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - for(i = 0; i < area; i++) - lld_lcdWriteData(*buffer++); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - #include "gdisp_fonts.h" -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - /* This routine is marked "DO NOT USE" in the original - * GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL - * turned off for now. - */ - color_t color; - - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return 0; - #endif - - lld_lcdSetCursor(x, y); - lld_lcdWriteStreamStart(); - - color = lld_lcdReadData(); - color = lld_lcdReadData(); - - lld_lcdWriteStreamStop(); - - return color; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - /* This is marked as "TODO: Test this" in the original GLCD driver. - * For now we just leave the GDISP_HARDWARE_SCROLL off. - */ - static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)]; - coord_t row0, row1; - unsigned i, gap, abslines; - - abslines = lines < 0 ? -lines : lines; - - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - if (!abslines) return; - if (abslines >= cy) { - abslines = cy; - gap = 0; - } else { - gap = cy - abslines; - for(i = 0; i < gap; i++) { - if(lines > 0) { - row0 = y + i + lines; - row1 = y + i; - } else { - row0 = (y - i - 1) + lines; - row1 = (y - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - lld_lcdSetViewPort(x, row0, cx, 1); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, cx); - lld_lcdReadStreamStop(); - - lld_lcdSetViewPort(x, row1, cx, 1); - lld_lcdWriteStreamStart(); - lld_lcdWriteStream(buf, cx); - lld_lcdWriteStreamStop(); - } - } - - /* fill the remaining gap */ - lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); - lld_lcdWriteStreamStart(); - gap = cx*abslines; - for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - /* Code here */ - /* break; */ - case powerOn: - /* Code here */ - /* You may need this --- - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init(); - */ - /* break; */ - case powerSleep: - /* Code here */ - /* break; */ - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case portrait: - lld_lcdWriteReg(0x0001,0x0127); - lld_lcdWriteReg(0x03, 0b0011); - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscape: - lld_lcdWriteReg(0x0001,0x0027); - lld_lcdWriteReg(0x0003, 0b1011); - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - case portraitInv: - lld_lcdWriteReg(0x0001,0x0127); - lld_lcdWriteReg(0x0003, 0b0000); - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscapeInv: - lld_lcdWriteReg(0x0001,0x0027); - lld_lcdWriteReg(0x0003, 0b1000); - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - default: - return; - } - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) -/** - * @brief Query a driver value. - * @detail Typecase the result to the type you want. - * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen - * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen - * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode - * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation - * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) - * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). - * GDISP_QUERY_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to Query - * - * @notapi - */ -void *GDISP_LLD(query)(unsigned what) { - switch(what) { - case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; - case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; - case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; - case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; - case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; - case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; - case GDISP_QUERY_LLD+0: - /* Code here */ - default: return (void *)-1; - } -} -#endif - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispS6d1121/gdisp_lld.mk b/halext/drivers/gdispS6d1121/gdisp_lld.mk deleted file mode 100644 index 1ad9ab88..00000000 --- a/halext/drivers/gdispS6d1121/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -HALSRC += $(LCDLIB)/halext/drivers/gdispS6d1121/gdisp_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/gdispS6d1121 diff --git a/halext/drivers/gdispS6d1121/gdisp_lld_config.h b/halext/drivers/gdispS6d1121/gdisp_lld_config.h deleted file mode 100644 index ee3fdeee..00000000 --- a/halext/drivers/gdispS6d1121/gdisp_lld_config.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispS6d1121/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the S6d1121 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if HAL_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "S6d1121" -#define GDISP_LLD(x) gdisp_lld_##x##_S6d1121 - -#define GDISP_HARDWARE_LINES FALSE -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CIRCLES FALSE -#define GDISP_HARDWARE_CIRCLEFILLS FALSE -#define GDISP_HARDWARE_ELLIPSES FALSE -#define GDISP_HARDWARE_ELLIPSEFILLS FALSE -#define GDISP_HARDWARE_TEXT FALSE -#define GDISP_HARDWARE_TEXTFILLS FALSE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD FALSE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_HARDWARE_QUERY FALSE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/drivers/gdispS6d1121/readme.txt b/halext/drivers/gdispS6d1121/readme.txt deleted file mode 100644 index fc24d4a2..00000000 --- a/halext/drivers/gdispS6d1121/readme.txt +++ /dev/null @@ -1,16 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) One (only) of: - #define LCD_USE_GPIO - #define LCD_USE_SPI - #define LCD_USE_FSMC - d) All of the following (with appropriate values): - #define SCREEN_WIDTH 320 - #define SCREEN_HEIGHT 240 - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispS6d1121/gdisp_lld.mk diff --git a/halext/drivers/gdispS6d1121/s6d1121_lld.c.h b/halext/drivers/gdispS6d1121/s6d1121_lld.c.h deleted file mode 100644 index c1539fe7..00000000 --- a/halext/drivers/gdispS6d1121/s6d1121_lld.c.h +++ /dev/null @@ -1,244 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef S6D1121_H -#define S6D1121_H - -// I/O assignments -#define LCD_BL_GPIO GPIOB -#define LCD_BL_PIN 8 - -#define LCD_CS_GPIO GPIOD -#define LCD_CS_PIN 7 - -#define LCD_RS_GPIO GPIOD -#define LCD_RS_PIN 11 - -#define LCD_RST_GPIO GPIOD -#define LCD_RST_PIN 10 - -#define LCD_RD_GPIO GPIOD -#define LCD_RD_PIN 9 - -#define LCD_WR_GPIO GPIOD -#define LCD_WR_PIN 8 - -#define LCD_D0_GPIO GPIOD -#define LCD_D4_GPIO GPIOE - -/* all interfaces use RST via GPIO */ -/* TODO: option to disable RST; assumes RST is tied high */ -#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN) -#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN) - -#define s6d1121_delay(n) halPolledDelay(MS2RTT(n)); - -#if defined(LCD_USE_GPIO) - - #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN) - #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN) - - #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN) - #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN) - - #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN) - #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN) - - #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN) - #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN) - - #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN) - #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN) - - - static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); } - static inline void lld_lcdwrite(uint16_t db) { - LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0); - LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F); - LCD_WR_LOW; - lld_lcddelay(); - LCD_WR_HIGH; - } - static __inline uint16_t lld_lcdReadData(void) { - uint16_t value=0; - - LCD_RS_HIGH; LCD_WR_HIGH; LCD_RD_LOW; - #ifndef STM32F4XX - // change pin mode to digital input - LCD_DATA_PORT->CRH = 0x47444444; - LCD_DATA_PORT->CRL = 0x47444444; - #endif - #ifndef STM32F4XX - // change pin mode back to digital output - LCD_DATA_PORT->CRH = 0x33333333; - LCD_DATA_PORT->CRL = 0x33333333; - #endif - LCD_RD_HIGH; - return value; - } - static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - uint16_t lcdRAM; - - LCD_CS_LOW; LCD_RS_LOW; - lld_lcdwrite(lcdReg); - LCD_RS_HIGH; - lcdRAM = lld_lcdReadData(); - LCD_CS_HIGH; - return lcdRAM; - } - static void lld_lcdWriteIndex(uint16_t lcdReg) { - LCD_RS_LOW; - lld_lcdwrite(lcdReg); - LCD_RS_HIGH; - } - static void lld_lcdWriteData(uint16_t lcdData) { - lld_lcdwrite(lcdData); - } - static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { - LCD_CS_LOW; - lld_lcdWriteIndex(lcdReg); - lld_lcdWriteData(lcdRegValue); - LCD_CS_HIGH; - } - static __inline void lld_lcdWriteStreamStart(void) { - LCD_CS_LOW; - lld_lcdWriteIndex(0x0022); - } - static __inline void lld_lcdWriteStreamStop(void) { - LCD_CS_HIGH; - } - static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); } - } - static __inline void lld_lcdReadStreamStart(void) { /* TODO */ } - static __inline void lld_lcdReadStreamStop(void) { /* TODO */ } - static __inline void lld_lcdReadStream(uint16_t *UNUSED(buffer), size_t UNUSED(size)) { /* TODO */ } - -#elif defined(LCD_USE_FSMC) - #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ - #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - - static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; } - static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; } - static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - LCD_REG = lcdReg; - LCD_RAM = lcdRegValue; - } - static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); } - static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - LCD_REG = lcdReg; - return LCD_RAM; - } - static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; } - static __inline void lld_lcdWriteStreamStop(void) {} - static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - for(i = 0; i < size; i++) LCD_RAM = buffer[i]; - } - static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; } - static __inline void lld_lcdReadStreamStop(void) {} - static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - volatile uint16_t dummy; - - /* throw away first value read */ - dummy = LCD_RAM; - for(i = 0; i < size; i++) buffer[i] = LCD_RAM; - } - -#elif defined(LCD_USE_SPI) - #error "gdispS6d1121: LCD_USE_SPI not implemented yet" - -#else - #error "gdispS6d1121: No known LCD_USE_XXX has been defined" -#endif - -static void lld_lcdSetCursor(coord_t x, coord_t y) { - /* R20h - 8 bit - * R21h - 9 bit - */ - switch(GDISP.Orientation) { - case portraitInv: - lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF); - lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF); - break; - case portrait: - lld_lcdWriteReg(0x0020, x & 0x00FF); - lld_lcdWriteReg(0x0021, y & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x0020, y & 0x00FF); - lld_lcdWriteReg(0x0021, x & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF); - lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } -} - -static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { - /* HSA / HEA are 8 bit - * VSA / VEA are 9 bit - * use masks 0x00FF and 0x01FF to enforce this - */ - - switch(GDISP.Orientation) { - case portrait: - lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); - lld_lcdWriteReg(0x48, y & 0x01FF); - lld_lcdWriteReg(0x47, (y+cy-1) & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF)); - lld_lcdWriteReg(0x48, x & 0x01FF); - lld_lcdWriteReg(0x47, (x+cx-1) & 0x01FF); - break; - case portraitInv: - lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF)); - lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-(y+cy)) & 0x01FF); - lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y-1) & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF)); - lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - (x+cx)) & 0x01FF); - lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } - - lld_lcdSetCursor(x, y); -} - -static void lld_lcdResetViewPort(void) { - switch(GDISP.Orientation) { - case portrait: - case portraitInv: - lld_lcdSetViewPort(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); - break; - case landscape: - case landscapeInv: - lld_lcdSetViewPort(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH); - break; - } -} - -#endif /* S6D1121_H */ diff --git a/halext/drivers/gdispSsd1289/gdisp_lld.c b/halext/drivers/gdispSsd1289/gdisp_lld.c deleted file mode 100644 index 7dfb83a7..00000000 --- a/halext/drivers/gdispSsd1289/gdisp_lld.c +++ /dev/null @@ -1,610 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispSsd1289/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for the Ssd1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/* Include the emulation code for things we don't support */ -#include "gdisp_emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#include "ssd1289_lld.c.h" - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - uint16_t deviceCode; - - #ifdef LCD_USE_FSMC - /* FSMC setup. TODO: this only works for STM32F1 */ - rccEnableAHB(RCC_AHBENR_FSMCEN, 0); - int FSMC_Bank = 0; - /* timing structure */ - /* from datasheet: - address setup: 0ns - address hold: 0ns - Data setup: 5ns - Data hold: 5ns - Data access: 250ns - output hold: 100ns - */ - FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_1 | FSMC_BTR1_DATAST_1; - - /* Bank1 NOR/SRAM control register configuration */ - FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; - #endif - - deviceCode = lld_lcdReadReg(0x0000); - - lld_lcdWriteReg(0x0000,0x0001); lld_lcdDelay(5); - lld_lcdWriteReg(0x0003,0xA8A4); lld_lcdDelay(5); - lld_lcdWriteReg(0x000C,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x000D,0x080C); lld_lcdDelay(5); - lld_lcdWriteReg(0x000E,0x2B00); lld_lcdDelay(5); - lld_lcdWriteReg(0x001E,0x00B0); lld_lcdDelay(5); - lld_lcdWriteReg(0x0001,0x2B3F); lld_lcdDelay(5); - lld_lcdWriteReg(0x0002,0x0600); lld_lcdDelay(5); - lld_lcdWriteReg(0x0010,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0011,0x6070); lld_lcdDelay(5); - lld_lcdWriteReg(0x0005,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0006,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0016,0xEF1C); lld_lcdDelay(5); - lld_lcdWriteReg(0x0017,0x0003); lld_lcdDelay(5); - lld_lcdWriteReg(0x0007,0x0133); lld_lcdDelay(5); - lld_lcdWriteReg(0x000B,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x000F,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0041,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0042,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0048,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0049,0x013F); lld_lcdDelay(5); - lld_lcdWriteReg(0x004A,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x004B,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0044,0xEF00); lld_lcdDelay(5); - lld_lcdWriteReg(0x0045,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0046,0x013F); lld_lcdDelay(5); - lld_lcdWriteReg(0x0030,0x0707); lld_lcdDelay(5); - lld_lcdWriteReg(0x0031,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0032,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0033,0x0502); lld_lcdDelay(5); - lld_lcdWriteReg(0x0034,0x0507); lld_lcdDelay(5); - lld_lcdWriteReg(0x0035,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0036,0x0204); lld_lcdDelay(5); - lld_lcdWriteReg(0x0037,0x0502); lld_lcdDelay(5); - lld_lcdWriteReg(0x003A,0x0302); lld_lcdDelay(5); - lld_lcdWriteReg(0x003B,0x0302); lld_lcdDelay(5); - lld_lcdWriteReg(0x0023,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0024,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x0025,0x8000); lld_lcdDelay(5); - lld_lcdWriteReg(0x004f,0x0000); lld_lcdDelay(5); - lld_lcdWriteReg(0x004e,0x0000); lld_lcdDelay(5); - - /* Initialise the GDISP structure */ - GDISP.Width = SCREEN_WIDTH; - GDISP.Height = SCREEN_HEIGHT; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return; - #endif - lld_lcdSetCursor(x, y); - lld_lcdWriteReg(0x0022, color); -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If gfillarea() is defined there is little - point in defining clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - fillarea() and blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear)(color_t color) { - unsigned i; - - lld_lcdSetCursor(0, 0); - lld_lcdWriteStreamStart(); - - for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++) - lld_lcdWriteData(color); - - lld_lcdWriteStreamStop(); - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - unsigned i, area; - - area = cx*cy; - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - for(i = 0; i < area; i++) - lld_lcdWriteData(color); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - unsigned i, area; - - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) return; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - area = cx*cy; - lld_lcdSetViewPort(x, y, cx, cy); - lld_lcdWriteStreamStart(); - for(i = 0; i < area; i++) - lld_lcdWriteData(*buffer++); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - #include "gdisp_fonts.h" -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - /* NOT IMPLEMENTED */ - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - color_t color; - - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return 0; - #endif - - lld_lcdSetCursor(x, y); - lld_lcdWriteStreamStart(); - - color = lld_lcdReadData(); - color = lld_lcdReadData(); - - lld_lcdWriteStreamStop(); - - return color; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)]; - coord_t row0, row1; - unsigned i, gap, abslines; - - abslines = lines < 0 ? -lines : lines; - - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - - if (!abslines) return; - if (abslines >= cy) { - abslines = cy; - gap = 0; - } else { - gap = cy - abslines; - for(i = 0; i < gap; i++) { - if(lines > 0) { - row0 = y + i + lines; - row1 = y + i; - } else { - row0 = (y - i - 1) + lines; - row1 = (y - i - 1); - } - - /* read row0 into the buffer and then write at row1*/ - lld_lcdSetViewPort(x, row0, cx, 1); - lld_lcdReadStreamStart(); - lld_lcdReadStream(buf, cx); - lld_lcdReadStreamStop(); - - lld_lcdSetViewPort(x, row1, cx, 1); - lld_lcdWriteStreamStart(); - lld_lcdWriteStream(buf, cx); - lld_lcdWriteStreamStop(); - } - } - - /* fill the remaining gap */ - lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); - lld_lcdWriteStreamStart(); - gap = cx*abslines; - for(i = 0; i < gap; i++) lld_lcdWriteData(color); - lld_lcdWriteStreamStop(); - lld_lcdResetViewPort(); - } -#endif - -#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode - lld_lcdWriteReg(0x0007, 0x0000); // halt operation - lld_lcdWriteReg(0x0000, 0x0000); // turn off oszillator - lld_lcdWriteReg(0x0010, 0x0001); // enter sleepmode - break; - case powerOn: - lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init)(); - break; - case powerSleep: - lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case portrait: - lld_lcdWriteReg(0x0001, 0x2B3F); - /* ID = 11 AM = 0 */ - lld_lcdWriteReg(0x0011, 0x6070); - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscape: - lld_lcdWriteReg(0x0001, 0x293F); - /* ID = 11 AM = 1 */ - lld_lcdWriteReg(0x0011, 0x6078); - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - case portraitInv: - lld_lcdWriteReg(0x0001, 0x2B3F); - /* ID = 01 AM = 0 */ - lld_lcdWriteReg(0x0011, 0x6040); - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscapeInv: - lld_lcdWriteReg(0x0001, 0x293F); - /* ID = 01 AM = 1 */ - lld_lcdWriteReg(0x0011, 0x6048); - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - default: - return; - } - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) -/** - * @brief Query a driver value. - * @detail Typecase the result to the type you want. - * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen - * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen - * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode - * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation - * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) - * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). - * GDISP_QUERY_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to Query - * - * @notapi - */ -void *GDISP_LLD(query)(unsigned what) { - switch(what) { - case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; - case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; - case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; - case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; - case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; - case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; - case GDISP_QUERY_LLD+0: - /* Code here */ - default: return (void *)-1; - } -} -#endif - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispSsd1289/gdisp_lld.mk b/halext/drivers/gdispSsd1289/gdisp_lld.mk deleted file mode 100644 index 97d84f4d..00000000 --- a/halext/drivers/gdispSsd1289/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -HALSRC += $(LCDLIB)/halext/drivers/gdispSsd1289/gdisp_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/gdispSsd1289 diff --git a/halext/drivers/gdispSsd1289/gdisp_lld_config.h b/halext/drivers/gdispSsd1289/gdisp_lld_config.h deleted file mode 100644 index 123ce875..00000000 --- a/halext/drivers/gdispSsd1289/gdisp_lld_config.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispSsd1289/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header for the Ssd1289 display. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if HAL_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "SSD1289" -#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289 - -#define GDISP_HARDWARE_LINES FALSE -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CIRCLES FALSE -#define GDISP_HARDWARE_CIRCLEFILLS FALSE -#define GDISP_HARDWARE_ELLIPSES FALSE -#define GDISP_HARDWARE_ELLIPSEFILLS FALSE -#define GDISP_HARDWARE_TEXT FALSE -#define GDISP_HARDWARE_TEXTFILLS FALSE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_HARDWARE_QUERY FALSE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/drivers/gdispSsd1289/readme.txt b/halext/drivers/gdispSsd1289/readme.txt deleted file mode 100644 index 17d22223..00000000 --- a/halext/drivers/gdispSsd1289/readme.txt +++ /dev/null @@ -1,16 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) One (only) of: - #define LCD_USE_GPIO - #define LCD_USE_SPI - #define LCD_USE_FSMC - d) All of the following (with appropriate values): - #define SCREEN_WIDTH 320 - #define SCREEN_HEIGHT 240 - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispSsd1289/gdisp_lld.mk diff --git a/halext/drivers/gdispSsd1289/ssd1289_lld.c.h b/halext/drivers/gdispSsd1289/ssd1289_lld.c.h deleted file mode 100644 index 7c0fade2..00000000 --- a/halext/drivers/gdispSsd1289/ssd1289_lld.c.h +++ /dev/null @@ -1,322 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef SSD1289_H -#define SSD1289_H - -#if defined(LCD_USE_GPIO) - #define Set_CS palSetPad(LCD_CMD_PORT, LCD_CS); - #define Clr_CS palClearPad(LCD_CMD_PORT, LCD_CS); - #define Set_RS palSetPad(LCD_CMD_PORT, LCD_RS); - #define Clr_RS palClearPad(LCD_CMD_PORT, LCD_RS); - #define Set_WR palSetPad(LCD_CMD_PORT, LCD_WR); - #define Clr_WR palClearPad(LCD_CMD_PORT, LCD_WR); - #define Set_RD palSetPad(LCD_CMD_PORT, LCD_RD); - #define Clr_RD palClearPad(LCD_CMD_PORT, LCD_RD); - - static __inline void lld_lcdWriteIndex(uint16_t index) { - Clr_RS; Set_RD; - lld_lcdWriteGPIO(index); - Clr_WR; Set_WR; - } - static __inline void lld_lcdWriteData(uint16_t data) { - Set_RS; - lld_lcdWriteGPIO(data); - Clr_WR; Set_WR; - } - static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - Clr_CS; - lld_lcdWriteIndex(lcdReg); - lld_lcdWriteData(lcdRegValue); - Set_CS; - } - static __inline uint16_t lld_lcdReadData(void) { - uint16_t value; - - Set_RS; Set_WR; Clr_RD; - value = lld_lcdReadGPIO(); - Set_RD; - return value; - } - static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - uint16_t value; - - Clr_CS; - lld_lcdWriteIndex(lcdReg); - value = lld_lcdReadData(); - Set_CS; - return value; - } - - static __inline void lld_lcdWriteStreamStart(void) { - Clr_CS; - lld_lcdWriteIndex(0x0022); - } - - static __inline void lld_lcdWriteStreamStop(void) { - Set_CS; - } - - static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - Set_RS; - for(i = 0; i < size; i++) { lld_lcdWriteGPIO(buffer[i]); Clr_WR; Set_WR; } - } - - static __inline void lld_lcdReadStreamStart(void) { - Clr_CS - lld_lcdWriteIndex(0x0022); - } - - static __inline void lld_lcdReadStreamStop(void) { - Set_CS; - } - - static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - volatile uint16_t dummy; - - dummy = lld_lcdReadData(); - for(i = 0; i < size; i++) buffer[i] = lld_lcdReadData(); - } - -#elif defined(LCD_USE_FSMC) - /* LCD Registers */ - #define R0 0x00 - #define R1 0x01 - #define R2 0x02 - #define R3 0x03 - #define R4 0x04 - #define R5 0x05 - #define R6 0x06 - #define R7 0x07 - #define R8 0x08 - #define R9 0x09 - #define R10 0x0A - #define R12 0x0C - #define R13 0x0D - #define R14 0x0E - #define R15 0x0F - #define R16 0x10 - #define R17 0x11 - #define R18 0x12 - #define R19 0x13 - #define R20 0x14 - #define R21 0x15 - #define R22 0x16 - #define R23 0x17 - #define R24 0x18 - #define R25 0x19 - #define R26 0x1A - #define R27 0x1B - #define R28 0x1C - #define R29 0x1D - #define R30 0x1E - #define R31 0x1F - #define R32 0x20 - #define R33 0x21 - #define R34 0x22 - #define R36 0x24 - #define R37 0x25 - #define R40 0x28 - #define R41 0x29 - #define R43 0x2B - #define R45 0x2D - #define R48 0x30 - #define R49 0x31 - #define R50 0x32 - #define R51 0x33 - #define R52 0x34 - #define R53 0x35 - #define R54 0x36 - #define R55 0x37 - #define R56 0x38 - #define R57 0x39 - #define R59 0x3B - #define R60 0x3C - #define R61 0x3D - #define R62 0x3E - #define R63 0x3F - #define R64 0x40 - #define R65 0x41 - #define R66 0x42 - #define R67 0x43 - #define R68 0x44 - #define R69 0x45 - #define R70 0x46 - #define R71 0x47 - #define R72 0x48 - #define R73 0x49 - #define R74 0x4A - #define R75 0x4B - #define R76 0x4C - #define R77 0x4D - #define R78 0x4E - #define R79 0x4F - #define R80 0x50 - #define R81 0x51 - #define R82 0x52 - #define R83 0x53 - #define R96 0x60 - #define R97 0x61 - #define R106 0x6A - #define R118 0x76 - #define R128 0x80 - #define R129 0x81 - #define R130 0x82 - #define R131 0x83 - #define R132 0x84 - #define R133 0x85 - #define R134 0x86 - #define R135 0x87 - #define R136 0x88 - #define R137 0x89 - #define R139 0x8B - #define R140 0x8C - #define R141 0x8D - #define R143 0x8F - #define R144 0x90 - #define R145 0x91 - #define R146 0x92 - #define R147 0x93 - #define R148 0x94 - #define R149 0x95 - #define R150 0x96 - #define R151 0x97 - #define R152 0x98 - #define R153 0x99 - #define R154 0x9A - #define R157 0x9D - #define R192 0xC0 - #define R193 0xC1 - #define R229 0xE5 - - #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ - #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ - - static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; } - static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; } - static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { - LCD_REG = lcdReg; - LCD_RAM = lcdRegValue; - } - static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); } - static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { - volatile uint16_t dummy; - - LCD_REG = lcdReg; - dummy = LCD_RAM; - return (LCD_RAM); - } - static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; } - static __inline void lld_lcdWriteStreamStop(void) {} - static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { - uint16_t i; - - for(i = 0; i < size; i++) LCD_RAM = buffer[i]; - } - static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; } - static __inline void lld_lcdReadStreamStop(void) {} - static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { - uint16_t i; - volatile uint16_t dummy; - - dummy = LCD_RAM; /* throw away first value read */ - for(i = 0; i < size; i++) buffer[i] = LCD_RAM; - } - -#elif defined(LCD_USE_SPI) - #error "gdispSsd1289: LCD_USE_SPI not implemented yet" - -#else - #error "gdispSsd1289: No known LCD_USE_XXX has been defined" -#endif - -static __inline void lld_lcdDelay(uint16_t us) { - chThdSleepMicroseconds(us); -} - -static void lld_lcdSetCursor(uint16_t x, uint16_t y) { - /* Reg 0x004E is an 8 bit value - * Reg 0x004F is 9 bit - * Use a bit mask to make sure they are not set too high - */ - switch(GDISP.Orientation) { - case portraitInv: - lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF); - lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF); - break; - case portrait: - lld_lcdWriteReg(0x004e, x & 0x00FF); - lld_lcdWriteReg(0x004f, y & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x004e, y & 0x00FF); - lld_lcdWriteReg(0x004f, x & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x004e, (SCREEN_WIDTH - y - 1) & 0x00FF); - lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } -} - -static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { - lld_lcdSetCursor(x, y); - - /* Reg 0x44 - Horizontal RAM address position - * Upper Byte - HEA - * Lower Byte - HSA - * 0 <= HSA <= HEA <= 0xEF - * Reg 0x45,0x46 - Vertical RAM address position - * Lower 9 bits gives 0-511 range in each value - * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F - */ - - switch(GDISP.Orientation) { - case portrait: - lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); - lld_lcdWriteReg(0x45, y & 0x01FF); - lld_lcdWriteReg(0x46, (y+cy-1) & 0x01FF); - break; - case landscape: - lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF)); - lld_lcdWriteReg(0x45, x & 0x01FF); - lld_lcdWriteReg(0x46, (x+cx-1) & 0x01FF); - break; - case portraitInv: - lld_lcdWriteReg(0x44, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF)); - lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-(y+cy)) & 0x01FF); - lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y-1) & 0x01FF); - break; - case landscapeInv: - lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF)); - lld_lcdWriteReg(0x45, (SCREEN_HEIGHT - (x+cx)) & 0x01FF); - lld_lcdWriteReg(0x46, (SCREEN_HEIGHT - x - 1) & 0x01FF); - break; - } - - lld_lcdSetCursor(x, y); -} - -static __inline void lld_lcdResetViewPort(void) {} - -#endif /* SSD1289_H */ diff --git a/halext/drivers/gdispTestStub/gdisp_lld.c b/halext/drivers/gdispTestStub/gdisp_lld.c deleted file mode 100644 index fd8410fb..00000000 --- a/halext/drivers/gdispTestStub/gdisp_lld.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispTestStub/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source (stub). - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/* Include the emulation code for things we don't support */ -#include "gdisp_emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialization. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise the GDISP structure */ - GDISP.Width = 128; - GDISP.Height = 128; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOff; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) { -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If fillarea() is defined there is little - point in defining clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - fillarea() and blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear)(color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void GDISP_LLD(drawline)(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) { - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), const pixel_t *UNUSED(buffer)) { - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(drawcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(fillcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(drawellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(fillellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void GDISP_LLD(drawchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) { - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void GDISP_LLD(fillchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t UNUSED(x), coord_t UNUSED(y)) { - return 0; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) { - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) { - } -#endif - -#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) -/** - * @brief Query a driver value. - * @detail Typecase the result to the type you want. - * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen - * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen - * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode - * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation - * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) - * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). - * GDISP_QUERY_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to Query - * - * @notapi - */ -void *GDISP_LLD(query)(unsigned what) { - switch(what) { - case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; - case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; - case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; - case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; - case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; - case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; - case GDISP_QUERY_LLD+0: - /* Code here */ - default: return (void *)-1; - } -} -#endif - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispTestStub/gdisp_lld.mk b/halext/drivers/gdispTestStub/gdisp_lld.mk deleted file mode 100644 index c58725e5..00000000 --- a/halext/drivers/gdispTestStub/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -HALSRC += $(LCDLIB)/halext/drivers/gdispTestStub/gdisp_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/gdispTestStub diff --git a/halext/drivers/gdispTestStub/gdisp_lld_config.h b/halext/drivers/gdispTestStub/gdisp_lld_config.h deleted file mode 100644 index d66e050f..00000000 --- a/halext/drivers/gdispTestStub/gdisp_lld_config.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispTestStub/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header (stub). - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if HAL_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "TestStub" -#define GDISP_LLD(x) gdisp_lld_##x##_TestStub - -#define GDISP_HARDWARE_LINES FALSE -#define GDISP_HARDWARE_CLEARS FALSE -#define GDISP_HARDWARE_FILLS FALSE -#define GDISP_HARDWARE_BITFILLS FALSE -#define GDISP_HARDWARE_CIRCLES FALSE -#define GDISP_HARDWARE_CIRCLEFILLS FALSE -#define GDISP_HARDWARE_ELLIPSES FALSE -#define GDISP_HARDWARE_ELLIPSEFILLS FALSE -#define GDISP_HARDWARE_TEXT FALSE -#define GDISP_HARDWARE_TEXTFILLS FALSE -#define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL -#define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD -#define GDISP_HARDWARE_CONTROL FALSE -#define GDISP_HARDWARE_QUERY FALSE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/drivers/gdispTestStub/readme.txt b/halext/drivers/gdispTestStub/readme.txt deleted file mode 100644 index 83611acf..00000000 --- a/halext/drivers/gdispTestStub/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -This low level driver is a test stub that doesn't talk to any -real hardware. It is included to allow testing of the compilation -process. - -Do not use this driver as a template for new drivers. Use the - templates/gdispXXXXX directory for that. - -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) - you want to compile test eg: GDISP_NEED_MULTITHREAD - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk diff --git a/halext/drivers/gdispVMT/gdisp_lld.c b/halext/drivers/gdispVMT/gdisp_lld.c deleted file mode 100644 index 1528f470..00000000 --- a/halext/drivers/gdispVMT/gdisp_lld.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispVMT/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -#define GDISP_LLD_NO_STRUCT - -/* Include the emulation code for things we don't support */ -#include "gdisp_emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_) -#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_) - -/* Prototypes for lld driver functions */ -bool_t GDISP_LLD1(init)(void); -void GDISP_LLD1(clear)(color_t color); -void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD1(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); -void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); -#if GDISP_NEED_CIRCLE - void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif -#if GDISP_NEED_ELLIPSE - void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif -#if GDISP_NEED_TEXT - void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif -#if GDISP_NEED_PIXELREAD - color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y); -#endif -#if GDISP_NEED_SCROLL - void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif -#if GDISP_NEED_CONTROL - void GDISP_LLD1(control)(unsigned what, void *value); -#endif -#if GDISP_NEED_QUERY - void *GDISP_LLD1(query)(unsigned what); -#endif - -bool_t GDISP_LLD2(init)(void); -void GDISP_LLD2(clear)(color_t color); -void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD2(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); -void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); -#if GDISP_NEED_CIRCLE - void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif -#if GDISP_NEED_ELLIPSE - void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif -#if GDISP_NEED_TEXT - void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif -#if GDISP_NEED_PIXELREAD - color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y); -#endif -#if GDISP_NEED_SCROLL - void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif -#if GDISP_NEED_CONTROL - void GDISP_LLD2(control)(unsigned what, void *value); -#endif -#if GDISP_NEED_QUERY - void *GDISP_LLD2(query)(unsigned what); -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/* Our VMT table variables */ -void GDISP_LLD_VMT(clear)(color_t color); -void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); -void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); -void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); -void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); - -#if GDISP_NEED_CIRCLE -void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); -#endif - -#if GDISP_NEED_ELLIPSE -void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); -#endif - -/* Text Rendering Functions */ -#if GDISP_NEED_TEXT -void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); -void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); -#endif - -/* Pixel readback */ -#if GDISP_NEED_PIXELREAD -color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); -#endif - -/* Scrolling Function - clears the area scrolled out */ -#if GDISP_NEED_SCROLL -void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); -#endif - -/* Set driver specific control */ -#if GDISP_NEED_CONTROL -void GDISP_LLD_VMT(control)(unsigned what, void *value); -#endif -/* Set driver specific control */ -#if GDISP_NEED_QUERY -void *GDISP_LLD_VMT(query)(unsigned what); -#endif - - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -bool_t gdisp_lld_init_VMT(void) { - if (GDISP_VMT_NAME1(gdisp_lld_init_)()) { - gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_); - gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_); - gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_); - gdisp_lld_blitarea_VMT = GDISP_VMT_NAME1(gdisp_lld_blitarea_); - gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_); - #if GDISP_NEED_CIRCLE - gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_); - gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_); - #endif - #if GDISP_NEED_ELLIPSE - gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_); - gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_); - #endif - #if GDISP_NEED_TEXT - gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_); - gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_); - #endif - #if GDISP_NEED_PIXELREAD - gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_); - #endif - #if GDISP_NEED_SCROLL - gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_); - #endif - #if GDISP_NEED_CONTROL - gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_); - #endif - #if GDISP_NEED_QUERY - gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_); - #endif - - return TRUE; - } - - if (GDISP_VMT_NAME2(gdisp_lld_init_)()) { - gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_); - gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_); - gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_); - gdisp_lld_blitarea_VMT = GDISP_VMT_NAME2(gdisp_lld_blitarea_); - gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_); - #if GDISP_NEED_CIRCLE - gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_); - gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_); - #endif - #if GDISP_NEED_ELLIPSE - gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_); - gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_); - #endif - #if GDISP_NEED_TEXT - gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_); - gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_); - #endif - #if GDISP_NEED_PIXELREAD - gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_); - #endif - #if GDISP_NEED_SCROLL - gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_); - #endif - #if GDISP_NEED_CONTROL - gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_); - #endif - #if GDISP_NEED_QUERY - gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_); - #endif - - return TRUE; - } - return FALSE; -} - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispVMT/gdisp_lld.mk b/halext/drivers/gdispVMT/gdisp_lld.mk deleted file mode 100644 index ab935370..00000000 --- a/halext/drivers/gdispVMT/gdisp_lld.mk +++ /dev/null @@ -1,7 +0,0 @@ -# List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld.c \ - ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver1.c \ - ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver2.c - -# Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispVMT diff --git a/halext/drivers/gdispVMT/gdisp_lld_config.h b/halext/drivers/gdispVMT/gdisp_lld_config.h deleted file mode 100644 index 6c6f7c80..00000000 --- a/halext/drivers/gdispVMT/gdisp_lld_config.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispVMT/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header template. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if HAL_USE_GDISP - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "VMT" -#define GDISP_LLD(x) gdisp_lld_##x##_VMT -#define GDISP_LLD_VMT(x) (*GDISP_LLD(x)) - -#define GDISP_HARDWARE_LINES TRUE -#define GDISP_HARDWARE_CLEARS TRUE -#define GDISP_HARDWARE_FILLS TRUE -#define GDISP_HARDWARE_BITFILLS TRUE -#define GDISP_HARDWARE_CIRCLES TRUE -#define GDISP_HARDWARE_CIRCLEFILLS TRUE -#define GDISP_HARDWARE_ELLIPSES TRUE -#define GDISP_HARDWARE_ELLIPSEFILLS TRUE -#define GDISP_HARDWARE_TEXT TRUE -#define GDISP_HARDWARE_TEXTFILLS TRUE -#define GDISP_HARDWARE_SCROLL TRUE -#define GDISP_HARDWARE_PIXELREAD TRUE -#define GDISP_HARDWARE_CONTROL TRUE -#define GDISP_HARDWARE_QUERY TRUE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/drivers/gdispVMT/gdisp_lld_driver1.c b/halext/drivers/gdispVMT/gdisp_lld_driver1.c deleted file mode 100644 index f088623e..00000000 --- a/halext/drivers/gdispVMT/gdisp_lld_driver1.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispVMT/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -#define CONFIGFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld_config.h> -#define DRIVERFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld.c> - -/* We don't need these in our VMT referenced driver */ -#undef GDISP_NEED_MSGAPI -#define GDISP_NEED_MSGAPI FALSE - -/* Include the specific config file we want */ -#include CONFIGFILE() - -/* Bring in our API */ -#include "gdisp.h" - -/* Add the low level driver */ -#include DRIVERFILE() - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispVMT/gdisp_lld_driver2.c b/halext/drivers/gdispVMT/gdisp_lld_driver2.c deleted file mode 100644 index 325a53e6..00000000 --- a/halext/drivers/gdispVMT/gdisp_lld_driver2.c +++ /dev/null @@ -1,51 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdispVMT/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source for VMT. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -#define CONFIGFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld_config.h> -#define DRIVERFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld.c> - -/* We don't need these in our VMT referenced driver */ -#undef GDISP_NEED_MSGAPI -#define GDISP_NEED_MSGAPI FALSE - -/* Include the specific config file we want */ -#include CONFIGFILE() - -/* Bring in our API */ -#include "gdisp.h" - -/* Add the low level driver */ -#include DRIVERFILE() - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/drivers/gdispVMT/readme.txt b/halext/drivers/gdispVMT/readme.txt deleted file mode 100644 index 91d3f58c..00000000 --- a/halext/drivers/gdispVMT/readme.txt +++ /dev/null @@ -1,23 +0,0 @@ -This driver enables you to have two underlying drivers handling different hardware. -A choice is made at run-time of which driver to call based on which driver succeeds -to initialise first (init returns TRUE). - -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) Define these: - #define GDISP_VMT_NAME1(x) x##YourDriver1 - #define GDISP_VMT_NAME2(x) x##YourDriver2 - Note YourDriver1 & 2 are the basenames of the directories containing the driver. - Note that both drivers must be the same pixel format which is - GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your - pixel format is different on both drivers. - d) Any driver specific defines. If both drivers use the same defines then they must - accept the same values for the define. - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk - \ No newline at end of file diff --git a/halext/drivers/touchpad/touchpadADS7843/readme.txt b/halext/drivers/touchpad/touchpadADS7843/readme.txt deleted file mode 100644 index 34a57bc0..00000000 --- a/halext/drivers/touchpad/touchpadADS7843/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_TOUCHPAD TRUE - -2. To your makefile add the following lines: - include $(LCDLIB)/lcd.mk - include $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk - diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c deleted file mode 100644 index a5265995..00000000 --- a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpadADS7843/touchpad_lld.c - * @brief Touchpad Driver subsystem low level driver source. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "touchpad.h" - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -#if !defined(__DOXYGEN__) - TOUCHPADDriver Touchpad; -#endif - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ - -/** - * @brief Low level Touchpad driver initialization. - * - * @notapi - */ -void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, tp->spicfg); -} - -/** - * @brief Reads out the X direction. - * - * @notapi - */ -uint16_t tp_lld_read_x(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -/* - * @brief Reads out the X direction. - * - * @notapi - */ -uint16_t tp_lld_read_y(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -/* ---- Optional Routines ---- */ -#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) - /* - * @brief for checking if touchpad is pressed or not. - * - * @return 1 if pressed / 0 if not pressed - * - * @noapi - */ - uint8_t tp_lld_irq(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); - } -#endif - -#endif /* HAL_USE_TOUCHPAD */ -/** @} */ - diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk deleted file mode 100644 index 42f66b8c..00000000 --- a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List the required driver. -HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843 - diff --git a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h deleted file mode 100644 index 1e878795..00000000 --- a/halext/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpadADS7843/touchpad_lld_config.h - * @brief Touchpad Driver subsystem low level driver. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#ifndef _TOUCHPAD_LLD_CONFIG_H -#define _TOUCHPAD_LLD_CONFIG_H - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define TOUCHPAD_HAS_IRQ TRUE -#define TOUCHPAD_HAS_PRESSURE FALSE - -#endif /* HAL_USE_TOUCHPAD */ - -#endif /* _TOUCHPAD_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/drivers/touchpad/touchpadXPT2046/readme.txt b/halext/drivers/touchpad/touchpadXPT2046/readme.txt deleted file mode 100644 index 992d346d..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_TOUCHPAD TRUE - -2. To your makefile add the following lines: - include $(LCDLIB)/lcd.mk - include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk - diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c deleted file mode 100644 index 195c8aa6..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpadXPT2046/touchpad_lld.c - * @brief Touchpad Driver subsystem low level driver source. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "touchpad.h" - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -#if !defined(__DOXYGEN__) - TOUCHPADDriver Touchpad; -#endif - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ - -/** - * @brief Low level Touchpad driver initialization. - * - * @notapi - */ -void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, tp->spicfg); -} - -/** - * @brief Reads out the X direction. - * - * @notapi - */ -uint16_t tp_lld_read_x(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -/* - * @brief Reads out the Y direction. - * - * @notapi - */ -uint16_t tp_lld_read_y(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -/* ---- Optional Routines ---- */ -#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) - /* - * @brief for checking if touchpad is pressed or not. - * - * @return 1 if pressed / 0 if not pressed - * - * @notapi - */ - uint8_t tp_lld_irq(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); - } -#endif - -#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) - /* - * @brief Reads out the Z direction / pressure. - * - * @notapi - */ - uint16_t tp_lld_read_z(void) { - /* ToDo */ - return 42; - } -#endif - -#endif /* HAL_USE_TOUCHPAD */ -/** @} */ - diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk deleted file mode 100644 index 9409795b..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List the required driver. -HALSRC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.c - -# Required include directories -HALINC += $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046 - diff --git a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h deleted file mode 100644 index 4ddd8da0..00000000 --- a/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpadXPT2046/touchpad_lld_config.h - * @brief Touchppad Driver subsystem low level driver. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#ifndef _TOUCHPAD_LLD_CONFIG_H -#define _TOUCHPAD_LLD_CONFIG_H - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define TOUCHPAD_HAS_IRQ TRUE -#define TOUCHPAD_HAS_PRESSURE TRUE - -#endif /* HAL_USE_TOUCHPAD */ - -#endif /* _TOUCHPAD_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/halext.mk b/halext/halext.mk deleted file mode 100644 index 045d864f..00000000 --- a/halext/halext.mk +++ /dev/null @@ -1,9 +0,0 @@ -# List of all the ChibiOS/RT META files, there is no need to remove the files -# from this list, you can disable parts of the kernel by editing halconf.h. - -HALSRC += $(LCDLIB)/halext/src/gdisp.c \ - $(LCDLIB)/halext/src/gdisp_fonts.c \ - $(LCDLIB)/halext/src/touchpad.c - -# Required include directories -HALINC += $(LCDLIB)/halext/include diff --git a/halext/include/gdisp.h b/halext/include/gdisp.h deleted file mode 100644 index b5a59cf9..00000000 --- a/halext/include/gdisp.h +++ /dev/null @@ -1,266 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file gdisp.h - * @brief GDISP Graphic Driver subsystem header file. - * - * @addtogroup GDISP - * @{ - */ -#ifndef _GDISP_H -#define _GDISP_H - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/** - * @brief Some basic colors - */ -#define White HTML2COLOR(0xFFFFFF) -#define Black HTML2COLOR(0x000000) -#define Gray HTML2COLOR(0x808080) -#define Grey Gray -#define Blue HTML2COLOR(0x0000FF) -#define Red HTML2COLOR(0xFF0000) -#define Fuchsia HTML2COLOR(0xFF00FF) -#define Magenta Fuchsia -#define Green HTML2COLOR(0x008000) -#define Yellow HTML2COLOR(0xFFFF00) -#define Aqua HTML2COLOR(0x00FFFF) -#define Cyan Aqua -#define Lime HTML2COLOR(0x00FF00) -#define Maroon HTML2COLOR(0x800000) -#define Navy HTML2COLOR(0x000080) -#define Olive HTML2COLOR(0x808000) -#define Purple HTML2COLOR(0x800080) -#define Silver HTML2COLOR(0xC0C0C0) -#define Teal HTML2COLOR(0x008080) -#define Orange HTML2COLOR(0xFFA500) -#define Pink HTML2COLOR(0xFFC0CB) -#define SkyBlue HTML2COLOR(0x87CEEB) - -/*===========================================================================*/ -/* Driver pre-compile time settings. */ -/*===========================================================================*/ - -/** - * @name GDISP more complex functionality to be compiled - * @{ - */ - /** - * @brief Do the drawing functions need to be thread-safe. - * @details Defaults to FALSE - * @note Both GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC make - * the gdisp API thread-safe. - * @note This is more efficient than GDISP_NEED_ASYNC as it only - * requires a context switch if something else is already - * drawing. - */ - #ifndef GDISP_NEED_MULTITHREAD - #define GDISP_NEED_MULTITHREAD FALSE - #endif - - /** - * @brief Use asynchronous calls (multi-thread safe). - * @details Defaults to FALSE - * @note Both GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC make - * the gdisp API thread-safe. - * @note Turning this on adds two context switches per transaction - * so it can significantly slow graphics drawing. - */ - #ifndef GDISP_NEED_ASYNC - #define GDISP_NEED_ASYNC FALSE - #endif -/** @} */ - -#if GDISP_NEED_MULTITHREAD && GDISP_NEED_ASYNC - #error "GDISP: Only one of GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC should be defined." -#endif - -#if GDISP_NEED_ASYNC - /* Messaging API is required for Async Multi-Thread */ - #undef GDISP_NEED_MSGAPI - #define GDISP_NEED_MSGAPI TRUE -#endif - -/*===========================================================================*/ -/* Low Level Driver details and error checks. */ -/*===========================================================================*/ - -/* Include the low level driver information */ -#include "gdisp_lld.h" - -/*===========================================================================*/ -/* Type definitions */ -/*===========================================================================*/ - -/** - * @brief Type for the text justification. - */ -typedef enum justify {justifyLeft, justifyCenter, justifyRight} justify_t; -/** - * @brief Type for the font metric. - */ -typedef enum fontmetric {fontHeight, fontDescendersHeight, fontLineSpacing, fontCharPadding, fontMinWidth, fontMaxWidth} fontmetric_t; - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) -/** - * @brief Predefined fonts. - */ -extern const struct font fontSmall; -extern const struct font fontSmallDouble; -extern const struct font fontSmallNarrow; -extern const struct font fontLarger; -extern const struct font fontLargerDouble; -extern const struct font fontLargerNarrow; -extern const struct font fontUI1; -extern const struct font fontUI1Double; -extern const struct font fontUI1Narrow; -extern const struct font fontUI2; -extern const struct font fontUI2Double; -extern const struct font fontUI2Narrow; -extern const struct font fontLargeNumbers; -extern const struct font fontLargeNumbersDouble; -extern const struct font fontLargeNumbersNarrow; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC - - /* Base Functions */ - bool_t gdispInit(void); - bool_t gdispIsBusy(void); - - /* Drawing Functions */ - void gdispClear(color_t color); - void gdispDrawPixel(coord_t x, coord_t y, color_t color); - void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); - void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); - void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); - - /* Circle Functions */ - #if GDISP_NEED_CIRCLE - void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color); - void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color); - #endif - - /* Ellipse Functions */ - #if GDISP_NEED_ELLIPSE - void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - #endif - - /* Basic Text Rendering Functions */ - #if GDISP_NEED_TEXT - void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color); - void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); - #endif - - /* Read a pixel Function */ - #if GDISP_NEED_PIXELREAD - color_t gdispGetPixelColor(coord_t x, coord_t y); - #endif - - /* Scrolling Function - clears the area scrolled out */ - #if GDISP_NEED_SCROLL - void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); - #endif - - /* Set driver specific control */ - #if GDISP_NEED_CONTROL - void gdispControl(unsigned what, void *value); - #endif - - /* Query driver specific data */ - #if GDISP_NEED_CONTROL - void *gdispQuery(unsigned what); - #endif - -#else - - /* The same as above but use the low level driver directly if no multi-thread support is needed */ - #define gdispInit(gdisp) GDISP_LLD(init)() - #define gdispIsBusy() FALSE - #define gdispClear(color) GDISP_LLD(clear)(color) - #define gdispDrawPixel(x, y, color) GDISP_LLD(drawpixel)(x, y, color) - #define gdispDrawLine(x0, y0, x1, y1, color) GDISP_LLD(drawline)(x0, y0, x1, y1, color) - #define gdispFillArea(x, y, cx, cy, color) GDISP_LLD(fillarea)(x, y, cx, cy, color) - #define gdispBlitArea(x, y, cx, cy, buffer) GDISP_LLD(blitarea)(x, y, cx, cy, buffer) - #define gdispDrawCircle(x, y, radius, color) GDISP_LLD(drawcircle)(x, y, radius, color) - #define gdispFillCircle(x, y, radius, color) GDISP_LLD(fillcircle)(x, y, radius, color) - #define gdispDrawEllipse(x, y, a, b, color) GDISP_LLD(drawellipse)(x, y, a, b, color) - #define gdispFillEllipse(x, y, a, b, color) GDISP_LLD(fillellipse)(x, y, a, b, color) - #define gdispDrawChar(x, y, c, font, color) GDISP_LLD(drawchar)(x, y, c, font, color) - #define gdispFillChar(x, y, c, font, color, bgcolor) GDISP_LLD(fillchar)(x, y, c, font, color, bgcolor) - #define gdispGetPixelColor(x, y) GDISP_LLD(getpixelcolor)(x, y) - #define gdispVerticalScroll(x, y, cx, cy, lines, bgcolor) GDISP_LLD(verticalscroll)(x, y, cx, cy, lines, bgcolor) - #define gdispControl(what, value) GDISP_LLD(control)(what, value) - #define gdispQuery(what) GDISP_LLD(query)(what) - -#endif - -void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); - -/* Extra Text Functions */ -#if GDISP_NEED_TEXT - void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color); - void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor); - void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgColor, justify_t justify); - coord_t gdispGetFontMetric(font_t font, fontmetric_t metric); - coord_t gdispGetCharWidth(char c, font_t font); - coord_t gdispGetStringWidth(const char* str, font_t font); -#endif - -/* Support routine for packed pixel formats */ -#ifndef gdispPackPixels - void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color); -#endif - -/* Macro definitions for common gets and sets */ -#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode)) -#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORITENTATION, (void *)(unsigned)(newOrientation)) -#define gdispSetBacklight(percent) gdispControl(GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent)) -#define gdispSetContrast(percent) gdispControl(GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent)) - -#define gdispGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH)) -#define gdispGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT)) -#define gdispGetPowerMode() ((gdisp_powermode_t)(unsigned)gdispQuery(GDISP_QUERY_POWER)) -#define gdispGetOrientation() ((gdisp_orientation_t)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) -#define gdispGetBacklight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_BACKLIGHT)) -#define gdispGetContrast() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_CONTRAST)) - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_H */ -/** @} */ diff --git a/halext/include/gdisp_emulation.c b/halext/include/gdisp_emulation.c deleted file mode 100644 index cb3773a7..00000000 --- a/halext/include/gdisp_emulation.c +++ /dev/null @@ -1,549 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - Emulation routines included into gdisp_lld.c -*/ - -/* - Even though this is a software emulation of a low level driver - most validation doesn't need to happen here as eventually - we call a real low level driver routine and if validation is - required - it will do it. -*/ -#ifndef GDISP_EMULATION_C -#define GDISP_EMULATION_C - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -#ifndef GDISP_LLD_NO_STRUCT - static struct GDISPDriver { - coord_t Width; - coord_t Height; - gdisp_orientation_t Orientation; - gdisp_powermode_t Powermode; - coord_t Backlight; - coord_t Contrast; - } GDISP; -#endif - -#if !GDISP_HARDWARE_CLEARS - void GDISP_LLD(clear)(color_t color) { - GDISP_LLD(fillarea)(0, 0, GDISP.Width, GDISP.Height, color); - } -#endif - -#if !GDISP_HARDWARE_LINES - void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - int16_t dy, dx; - int16_t addx, addy; - int16_t P, diff, i; - - #if GDISP_HARDWARE_FILLS || GDISP_HARDWARE_SCROLL - // speed improvement if vertical or horizontal - if (x0 == x1) { - if (y1 > y0) - GDISP_LLD(fillarea)(x0, y0, 1, y1-y0+1, color); - else - GDISP_LLD(fillarea)(x0, y1, 1, y0-y1+1, color); - return; - } - if (y0 == y1) { - if (x1 > x0) - GDISP_LLD(fillarea)(x0, y0, x1-x0+1, 1, color); - else - GDISP_LLD(fillarea)(x0, y1, x0-x1+1, 1, color); - return; - } - #endif - - if (x1 >= x0) { - dx = x1 - x0; - addx = 1; - } else { - dx = x0 - x1; - addx = -1; - } - if (y1 >= y0) { - dy = y1 - y0; - addy = 1; - } else { - dy = y0 - y1; - addy = -1; - } - - if (dx >= dy) { - dy *= 2; - P = dy - dx; - diff = P - dx; - - for(i=0; i<=dx; ++i) { - GDISP_LLD(drawpixel)(x0, y0, color); - if (P < 0) { - P += dy; - x0 += addx; - } else { - P += diff; - x0 += addx; - y0 += addy; - } - } - } else { - dx *= 2; - P = dx - dy; - diff = P - dy; - - for(i=0; i<=dy; ++i) { - GDISP_LLD(drawpixel)(x0, y0, color); - if (P < 0) { - P += dx; - y0 += addy; - } else { - P += diff; - x0 += addx; - y0 += addy; - } - } - } - } -#endif - -#if !GDISP_HARDWARE_FILLS - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_HARDWARE_SCROLL - GDISP_LLD(verticalscroll)(x, y, cx, cy, cy, color); - #elif GDISP_HARDWARE_LINES - coord_t x1, y1; - - x1 = x + cx - 1; - y1 = y + cy; - for(; y < y1; y++) - GDISP_LLD(drawline)(x, y, x1, y, color); - #else - coord_t x0, x1, y1; - - x0 = x; - x1 = x + cx; - y1 = y + cy; - for(; y < y1; y++) - for(x = x0; x < x1; x++) - GDISP_LLD(drawpixel)(x, y, color); - #endif - } -#endif - -#if !GDISP_HARDWARE_BITFILLS - void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - coord_t x0, x1, y1; - - x0 = x; - x1 = x + cx; - y1 = y + cy; - for(; y < y1; y++) - for(x = x0; x < x1; x++) - GDISP_LLD(drawpixel)(x, y, *buffer++); - } -#endif - -#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLES - void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - int16_t a, b, P; - - a = 0; - b = radius; - P = 1 - radius; - - do { - GDISP_LLD(drawpixel)(a+x, b+y, color); - GDISP_LLD(drawpixel)(b+x, a+y, color); - GDISP_LLD(drawpixel)(x-a, b+y, color); - GDISP_LLD(drawpixel)(x-b, a+y, color); - GDISP_LLD(drawpixel)(b+x, y-a, color); - GDISP_LLD(drawpixel)(a+x, y-b, color); - GDISP_LLD(drawpixel)(x-a, y-b, color); - GDISP_LLD(drawpixel)(x-b, y-a, color); - if (P < 0) - P += 3 + 2*a++; - else - P += 5 + 2*(a++ - b--); - } while(a <= b); - } -#endif - -#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLEFILLS - void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - int16_t a, b, P; - - a = 0; - b = radius; - P = 1 - radius; - - do { - GDISP_LLD(drawline)(x-a, y+b, x+a, y+b, color); - GDISP_LLD(drawline)(x-a, y-b, x+a, y-b, color); - GDISP_LLD(drawline)(x-b, y+a, x+b, y+a, color); - GDISP_LLD(drawline)(x-b, y-a, x+b, y-a, color); - if (P < 0) - P += 3 + 2*a++; - else - P += 5 + 2*(a++ - b--); - } while(a <= b); - } -#endif - -#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSES - void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */ - long a2 = a*a, b2 = b*b; - long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */ - - do { - GDISP_LLD(drawpixel)(x+dx, y+dy, color); /* I. Quadrant */ - GDISP_LLD(drawpixel)(x-dx, y+dy, color); /* II. Quadrant */ - GDISP_LLD(drawpixel)(x-dx, y-dy, color); /* III. Quadrant */ - GDISP_LLD(drawpixel)(x+dx, y-dy, color); /* IV. Quadrant */ - - e2 = 2*err; - if(e2 < (2*dx+1)*b2) { - dx++; - err += (2*dx+1)*b2; - } - if(e2 > -(2*dy-1)*a2) { - dy--; - err -= (2*dy-1)*a2; - } - } while(dy >= 0); - - while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */ - GDISP_LLD(drawpixel)(x+dx, y, color); /* -> Spitze der Ellipse vollenden */ - GDISP_LLD(drawpixel)(x-dx, y, color); - } - } -#endif - -#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSEFILLS - void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */ - long a2 = a*a, b2 = b*b; - long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */ - - do { - GDISP_LLD(drawline)(x-dx,y+dy,x+dx,y+dy, color); - GDISP_LLD(drawline)(x-dx,y-dy,x+dx,y-dy, color); - - e2 = 2*err; - if(e2 < (2*dx+1)*b2) { - dx++; - err += (2*dx+1)*b2; - } - if(e2 > -(2*dy-1)*a2) { - dy--; - err -= (2*dy-1)*a2; - } - } while(dy >= 0); - - while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */ - GDISP_LLD(drawpixel)(x+dx, y, color); /* -> Spitze der Ellipse vollenden */ - GDISP_LLD(drawpixel)(x-dx, y, color); - } - } -#endif - -#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT - #include "gdisp_fonts.h" -#endif - -#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT - void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { - const fontcolumn_t *ptr; - fontcolumn_t column; - coord_t width, height, xscale, yscale; - coord_t i, j, xs, ys; - - /* Check we actually have something to print */ - width = _getCharWidth(font, c); - if (!width) return; - - xscale = font->xscale; - yscale = font->yscale; - height = font->height * yscale; - width *= xscale; - - ptr = _getCharData(font, c); - - /* Loop through the data and display. The font data is LSBit first, down the column */ - for(i=0; i < width; i+=xscale) { - /* Get the font bitmap data for the column */ - column = *ptr++; - - /* Draw each pixel */ - for(j=0; j < height; j+=yscale, column >>= 1) { - if (column & 0x01) { - for(xs=0; xs < xscale; xs++) - for(ys=0; ys < yscale; ys++) - GDISP_LLD(drawpixel)(x+i+xs, y+j+ys, color); - } - } - } - } -#endif - -#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXTFILLS - void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - coord_t width, height; - coord_t xscale, yscale; - - /* Check we actually have something to print */ - width = _getCharWidth(font, c); - if (!width) return; - - xscale = font->xscale; - yscale = font->yscale; - height = font->height * yscale; - width *= xscale; - - /* Method 1: Use background fill and then draw the text */ - #if GDISP_HARDWARE_TEXT || GDISP_SOFTWARE_TEXTFILLDRAW - - /* Fill the area */ - GDISP_LLD(fillarea)(x, y, width, height, bgcolor); - - /* Draw the text */ - GDISP_LLD(drawchar)(x, y, c, font, color); - - /* Method 2: Create a single column bitmap and then blit it */ - #elif GDISP_HARDWARE_BITFILLS && GDISP_SOFTWARE_TEXTBLITCOLUMN - { - const fontcolumn_t *ptr; - fontcolumn_t column; - coord_t i, j, xs, ys; - - /* Working buffer for fast non-transparent text rendering [patch by Badger] - This needs to be larger than the largest character we can print. - Assume the max is double sized by one column. - */ - static pixel_t buf[sizeof(fontcolumn_t)*8*2]; - - #if GDISP_NEED_VALIDATION - /* Check our buffer is big enough */ - if (height > sizeof(buf)/sizeof(buf[0])) return; - #endif - - ptr = _getCharData(font, c); - - /* Loop through the data and display. The font data is LSBit first, down the column */ - for(i = 0; i < width; i+=xscale) { - /* Get the font bitmap data for the column */ - column = *ptr++; - - /* Draw each pixel */ - for(j = 0; j < height; j+=yscale, column >>= 1) { - if (column & 0x01) { - for(ys=0; ys < yscale; ys++) - gdispPackPixels(buf, 1, j+ys, 0, color); - } else { - for(ys=0; ys < yscale; ys++) - gdispPackPixels(buf, 1, j+ys, 0, bgcolor); - } - } - - for(xs=0; xs < xscale; xs++) - GDISP_LLD(blitarea)(x+i+xs, y, 1, height, buf); - } - } - - /* Method 3: Create a character bitmap and then blit it */ - #elif GDISP_HARDWARE_BITFILLS - { - const fontcolumn_t *ptr; - fontcolumn_t column; - coord_t i, j, xs, ys; - - /* Working buffer for fast non-transparent text rendering [patch by Badger] - This needs to be larger than the largest character we can print. - Assume the max is double sized. - */ - static pixel_t buf[20*(sizeof(fontcolumn_t)*8)*2]; - - #if GDISP_NEED_VALIDATION - /* Check our buffer is big enough */ - if ((unsigned)(width * height) > sizeof(buf)/sizeof(buf[0])) return; - #endif - - ptr = _getCharData(font, c); - - /* Loop through the data and display. The font data is LSBit first, down the column */ - for(i = 0; i < width; i+=xscale) { - /* Get the font bitmap data for the column */ - column = *ptr++; - - /* Draw each pixel */ - for(j = 0; j < height; j+=yscale, column >>= 1) { - if (column & 0x01) { - for(xs=0; xs < xscale; xs++) - for(ys=0; ys < yscale; ys++) - gdispPackPixels(buf, width, i+xs, j+ys, color); - } else { - for(xs=0; xs < xscale; xs++) - for(ys=0; ys < yscale; ys++) - gdispPackPixels(buf, width, i+xs, j+ys, bgcolor); - } - } - } - - /* [Patch by Badger] Write all in one stroke */ - GDISP_LLD(blitarea)(x, y, width, height, buf); - } - - /* Method 4: Draw pixel by pixel */ - #else - { - const fontcolumn_t *ptr; - fontcolumn_t column; - coord_t i, j, xs, ys; - - ptr = _getCharData(font, c); - - /* Loop through the data and display. The font data is LSBit first, down the column */ - for(i = 0; i < width; i+=xscale) { - /* Get the font bitmap data for the column */ - column = *ptr++; - - /* Draw each pixel */ - for(j = 0; j < height; j+=yscale, column >>= 1) { - if (column & 0x01) { - for(xs=0; xs < xscale; xs++) - for(ys=0; ys < yscale; ys++) - GDISP_LLD(drawpixel)(x+i, y+j, color); - } else { - for(xs=0; xs < xscale; xs++) - for(ys=0; ys < yscale; ys++) - GDISP_LLD(drawpixel)(x+i, y+j, bgcolor); - } - } - } - } - #endif - } -#endif - - -#if GDISP_NEED_CONTROL && !GDISP_HARDWARE_CONTROL - void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) { - /* Ignore everything */ - } -#endif - -#if GDISP_NEED_QUERY && !GDISP_HARDWARE_QUERY -void *GDISP_LLD(query)(unsigned what) { - switch(what) { - case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; - case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; - case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; - case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; - case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; - case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; - default: return (void *)-1; - } -} -#endif - -#if GDISP_NEED_MSGAPI - void GDISP_LLD(msgdispatch)(gdisp_lld_msg_t *msg) { - switch(msg->action) { - case GDISP_LLD_MSG_NOP: - break; - case GDISP_LLD_MSG_INIT: - GDISP_LLD(init)(); - break; - case GDISP_LLD_MSG_CLEAR: - GDISP_LLD(clear)(msg->clear.color); - break; - case GDISP_LLD_MSG_DRAWPIXEL: - GDISP_LLD(drawpixel)(msg->drawpixel.x, msg->drawpixel.y, msg->drawpixel.color); - break; - case GDISP_LLD_MSG_FILLAREA: - GDISP_LLD(fillarea)(msg->fillarea.x, msg->fillarea.y, msg->fillarea.cx, msg->fillarea.cy, msg->fillarea.color); - break; - case GDISP_LLD_MSG_BLITAREA: - GDISP_LLD(blitarea)(msg->blitarea.x, msg->blitarea.y, msg->blitarea.cx, msg->blitarea.cy, msg->blitarea.buffer); - break; - case GDISP_LLD_MSG_DRAWLINE: - GDISP_LLD(drawline)(msg->drawline.x0, msg->drawline.y0, msg->drawline.x1, msg->drawline.y1, msg->drawline.color); - break; - #if GDISP_NEED_CIRCLE - case GDISP_LLD_MSG_DRAWCIRCLE: - GDISP_LLD(drawcircle)(msg->drawcircle.x, msg->drawcircle.y, msg->drawcircle.radius, msg->drawcircle.color); - break; - case GDISP_LLD_MSG_FILLCIRCLE: - GDISP_LLD(fillcircle)(msg->fillcircle.x, msg->fillcircle.y, msg->fillcircle.radius, msg->fillcircle.color); - break; - #endif - #if GDISP_NEED_ELLIPSE - case GDISP_LLD_MSG_DRAWELLIPSE: - GDISP_LLD(drawellipse)(msg->drawellipse.x, msg->drawellipse.y, msg->drawellipse.a, msg->drawellipse.b, msg->drawellipse.color); - break; - case GDISP_LLD_MSG_FILLELLIPSE: - GDISP_LLD(fillellipse)(msg->fillellipse.x, msg->fillellipse.y, msg->fillellipse.a, msg->fillellipse.b, msg->fillellipse.color); - break; - #endif - #if GDISP_NEED_TEXT - case GDISP_LLD_MSG_DRAWCHAR: - GDISP_LLD(drawchar)(msg->drawchar.x, msg->drawchar.y, msg->drawchar.c, msg->drawchar.font, msg->drawchar.color); - break; - case GDISP_LLD_MSG_FILLCHAR: - GDISP_LLD(fillchar)(msg->fillchar.x, msg->fillchar.y, msg->fillchar.c, msg->fillchar.font, msg->fillchar.color, msg->fillchar.bgcolor); - break; - #endif - #if GDISP_NEED_PIXELREAD - case GDISP_LLD_MSG_GETPIXELCOLOR: - msg->getpixelcolor.result = GDISP_LLD(getpixelcolor)(msg->getpixelcolor.x, msg->getpixelcolor.y); - break; - #endif - #if GDISP_NEED_SCROLL - case GDISP_LLD_MSG_VERTICALSCROLL: - GDISP_LLD(verticalscroll)(msg->verticalscroll.x, msg->verticalscroll.y, msg->verticalscroll.cx, msg->verticalscroll.cy, msg->verticalscroll.lines, msg->verticalscroll.bgcolor); - break; - #endif - #if GDISP_NEED_CONTROL - case GDISP_LLD_MSG_CONTROL: - GDISP_LLD(control)(msg->control.what, msg->control.value); - break; - #endif - #if GDISP_NEED_QUERY - case GDISP_LLD_MSG_QUERY: - msg->query.result = GDISP_LLD(query)(msg->query.what); - break; - #endif - } - } -#endif - -#endif /* HAL_USE_GDISP */ -#endif /* GDISP_EMULATION_C */ diff --git a/halext/include/gdisp_fonts.h b/halext/include/gdisp_fonts.h deleted file mode 100644 index a1a4c3cb..00000000 --- a/halext/include/gdisp_fonts.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file gdisp_fonts.h - * @brief GDISP internal font definitions. - * @details This is not generally needed by an application. It is used - * by the low level drivers that need to understand a font. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_FONTS_H -#define _GDISP_FONTS_H - -/* Don't test against HAL_USE_GDISP as we may want to use this in other non-GDISP utilities. */ - -/** - * @brief The maximum height of a font. - * @details Either 16 or 32. Defaults to 16 - * @note Setting this to 32 causes the font tables to take - * twice the internal program memory. - */ -#ifndef GDISP_MAX_FONT_HEIGHT - #define GDISP_MAX_FONT_HEIGHT 16 -#endif - -/** - * @brief The type of a font column. - * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately. - */ -#if GDISP_MAX_FONT_HEIGHT == 16 - typedef uint16_t fontcolumn_t; -#elif GDISP_MAX_FONT_HEIGHT == 32 - typedef uint32_t fontcolumn_t; -#else - #error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32" -#endif - -/** - * @brief Internal font structure. - * @note This structure is followed by: - * 1. An array of character widths (uint8_t) - * 2. An array of column data offsets (relative to the font structure) - * 3. Each characters array of column data (fontcolumn_t) - * Each sub-structure must be padded to a multiple of 8 bytes - * to allow the tables to work across many different compilers. - */ -struct font { - uint8_t height; - uint8_t charPadding; - uint8_t lineSpacing; - uint8_t descenderHeight; - uint8_t minWidth; - uint8_t maxWidth; - char minChar; - char maxChar; - uint8_t xscale; - uint8_t yscale; - const uint8_t *widthTable; - const uint16_t *offsetTable; - const fontcolumn_t *dataTable; - }; - -/** - * @brief Macros to get to the complex parts of the font structure. - */ -#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar]) -#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar]) -#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)]) - -#endif /* _GDISP_FONTS_H */ -/** @} */ diff --git a/halext/include/gdisp_lld.h b/halext/include/gdisp_lld.h deleted file mode 100644 index 99865a9f..00000000 --- a/halext/include/gdisp_lld.h +++ /dev/null @@ -1,599 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file gdisp_lld.h - * @brief GDISP Graphic Driver subsystem low level driver header. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_H -#define _GDISP_LLD_H - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Low level driver configuration needs */ -/*===========================================================================*/ - -/** - * @name GDISP low level driver more complex functionality to be compiled - * @{ - */ - /** - * @brief Should all operations be clipped to the screen and colors validated. - * @details Defaults to TRUE. - * @note If this is FALSE, any operations that extend beyond the - * edge of the screen will have undefined results. Any - * out-of-range colors will produce undefined results. - * @note If defined then all low level and high level driver routines - * must check the validity of inputs and do something sensible - * if they are out of range. It doesn't have to be efficient, - * just valid. - */ - #ifndef GDISP_NEED_VALIDATION - #define GDISP_NEED_VALIDATION TRUE - #endif - - /** - * @brief Are circle functions needed. - * @details Defaults to TRUE - */ - #ifndef GDISP_NEED_CIRCLE - #define GDISP_NEED_CIRCLE TRUE - #endif - - /** - * @brief Are ellipse functions needed. - * @details Defaults to TRUE - */ - #ifndef GDISP_NEED_ELLIPSE - #define GDISP_NEED_ELLIPSE TRUE - #endif - - /** - * @brief Are text functions needed. - * @details Defaults to TRUE - */ - #ifndef GDISP_NEED_TEXT - #define GDISP_NEED_TEXT TRUE - #endif - - /** - * @brief Is scrolling needed. - * @details Defaults to FALSE - */ - #ifndef GDISP_NEED_SCROLL - #define GDISP_NEED_SCROLL FALSE - #endif - - /** - * @brief Is the capability to read pixels back needed. - * @details Defaults to FALSE - */ - #ifndef GDISP_NEED_PIXELREAD - #define GDISP_NEED_PIXELREAD FALSE - #endif - - /** - * @brief Control some aspect of the drivers operation. - * @details Defaults to FALSE - */ - #ifndef GDISP_NEED_CONTROL - #define GDISP_NEED_CONTROL FALSE - #endif - - /** - * @brief Query some aspect of the drivers operation. - * @details Defaults to TRUE - */ - #ifndef GDISP_NEED_QUERY - #define GDISP_NEED_QUERY TRUE - #endif - - /** - * @brief Is the messaging api interface required. - * @details Defaults to FALSE - */ - #ifndef GDISP_NEED_MSGAPI - #define GDISP_NEED_MSGAPI FALSE - #endif -/** @} */ - -/*===========================================================================*/ -/* Include the low level driver configuration information */ -/*===========================================================================*/ - -#include "gdisp_lld_config.h" - -/*===========================================================================*/ -/* Constants. */ -/*===========================================================================*/ - -/** - * @brief Driver Control Constants - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - */ -#define GDISP_CONTROL_POWER 0 -#define GDISP_CONTROL_ORIENTATION 1 -#define GDISP_CONTROL_BACKLIGHT 2 -#define GDISP_CONTROL_CONTRAST 3 -#define GDISP_CONTROL_LLD 1000 - -/** - * @brief Driver Query Constants - * @detail Unsupported query codes return (void *)-1. - * @note There are some predefined and some specific to the low level driver. - * @note The result should be typecast the required type. - * @note GDISP_QUERY_WIDTH - Gets the width of the screen - * GDISP_QUERY_HEIGHT - Gets the height of the screen - * GDISP_QUERY_POWER - Get the current powermode - * GDISP_QUERY_ORIENTATION - Get the current orientation - * GDISP_QUERY_BACKLIGHT - Get the backlight state (0 to 100) - * GDISP_QUERY_CONTRAST - Get the contrast. - * GDISP_QUERY_LLD - Low level driver control constants start at - * this value. - */ -#define GDISP_QUERY_WIDTH 0 -#define GDISP_QUERY_HEIGHT 1 -#define GDISP_QUERY_POWER 2 -#define GDISP_QUERY_ORIENTATION 3 -#define GDISP_QUERY_BACKLIGHT 4 -#define GDISP_QUERY_CONTRAST 5 -#define GDISP_QUERY_LLD 1000 - -/** - * @brief Driver Pixel Format Constants - */ -#define GDISP_PIXELFORMAT_RGB565 565 -#define GDISP_PIXELFORMAT_RGB888 888 -#define GDISP_PIXELFORMAT_RGB444 444 -#define GDISP_PIXELFORMAT_RGB332 332 -#define GDISP_PIXELFORMAT_RGB666 666 -#define GDISP_PIXELFORMAT_CUSTOM 99999 -#define GDISP_PIXELFORMAT_ERROR 88888 - -/*===========================================================================*/ -/* Error checks. */ -/*===========================================================================*/ - -/** - * @name GDISP hardware accelerated support - * @{ - */ - /** - * @brief Hardware accelerated line drawing. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_LINES - #define GDISP_HARDWARE_LINES FALSE - #endif - - /** - * @brief Hardware accelerated screen clears. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_CLEARS - #define GDISP_HARDWARE_CLEARS FALSE - #endif - - /** - * @brief Hardware accelerated rectangular fills. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_FILLS - #define GDISP_HARDWARE_FILLS FALSE - #endif - - /** - * @brief Hardware accelerated fills from an image. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_BITFILLS - #define GDISP_HARDWARE_BITFILLS FALSE - #endif - - /** - * @brief Hardware accelerated circles. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_CIRCLES - #define GDISP_HARDWARE_CIRCLES FALSE - #endif - - /** - * @brief Hardware accelerated filled circles. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_CIRCLEFILLS - #define GDISP_HARDWARE_CIRCLEFILLS FALSE - #endif - - /** - * @brief Hardware accelerated ellipses. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_ELLIPSES - #define GDISP_HARDWARE_ELLIPSES FALSE - #endif - - /** - * @brief Hardware accelerated filled ellipses. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_ELLIPSEFILLS - #define GDISP_HARDWARE_ELLIPSEFILLS FALSE - #endif - - /** - * @brief Hardware accelerated text drawing. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_TEXT - #define GDISP_HARDWARE_TEXT FALSE - #endif - - /** - * @brief Hardware accelerated text drawing with a filled background. - * @details If set to @p FALSE software emulation is used. - */ - #ifndef GDISP_HARDWARE_TEXTFILLS - #define GDISP_HARDWARE_TEXTFILLS FALSE - #endif - - /** - * @brief Hardware accelerated scrolling. - * @details If set to @p FALSE there is no support for scrolling. - */ - #ifndef GDISP_HARDWARE_SCROLL - #define GDISP_HARDWARE_SCROLL FALSE - #endif - - /** - * @brief Reading back of pixel values. - * @details If set to @p FALSE there is no support for pixel read-back. - */ - #ifndef GDISP_HARDWARE_PIXELREAD - #define GDISP_HARDWARE_PIXELREAD FALSE - #endif - - /** - * @brief The driver supports one or more control commands. - * @details If set to @p FALSE there is no support for control commands. - */ - #ifndef GDISP_HARDWARE_CONTROL - #define GDISP_HARDWARE_CONTROL FALSE - #endif - - /** - * @brief The driver supports a non-standard query. - * @details If set to @p FALSE there is no support for non-standard queries. - */ - #ifndef GDISP_HARDWARE_QUERY - #define GDISP_HARDWARE_QUERY FALSE - #endif -/** @} */ - -/** - * @name GDISP software algorithm choices - * @{ - */ - /** - * @brief For filled text drawing, use a background fill and then draw - * the text instead of using a blit or direct pixel drawing. - * @details If set to @p TRUE background fill and then text draw is used. - * @note This is ignored if hardware accelerated text is supported. - */ - #ifndef GDISP_SOFTWARE_TEXTFILLDRAW - #define GDISP_SOFTWARE_TEXTFILLDRAW FALSE - #endif - - /** - * @brief For filled text drawing, when using a bitmap blit - * use a column by column buffer rather than a full character - * buffer to save memory at a small performance cost. - * @details If set to @p TRUE background fill one character column at a time. - * @note This is ignored if software text using blit is not being used. - */ - #ifndef GDISP_SOFTWARE_TEXTBLITCOLUMN - #define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - #endif -/** @} */ - -/** - * @name GDISP pixel format choices - * @{ - */ - /** - * @brief The native pixel format for this device - * @note Should be set to one of the following: - * GDISP_PIXELFORMAT_RGB565 - * GDISP_PIXELFORMAT_RGB888 - * GDISP_PIXELFORMAT_RGB444 - * GDISP_PIXELFORMAT_RGB332 - * GDISP_PIXELFORMAT_RGB666 - * GDISP_PIXELFORMAT_CUSTOM - * @note If you set GDISP_PIXELFORMAT_CUSTOM you need to also define - * color_t, RGB2COLOR(r,g,b), HTML2COLOR(h), - * RED_OF(c), GREEN_OF(c), BLUE_OF(c), - * COLOR(c) and MASKCOLOR. - */ - #ifndef GDISP_PIXELFORMAT - #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_ERROR - #endif - - /** - * @brief Do pixels require packing for a blit - * @note Is only valid for a pixel format that doesn't fill it's datatype. ie formats: - * GDISP_PIXELFORMAT_RGB888 - * GDISP_PIXELFORMAT_RGB444 - * GDISP_PIXELFORMAT_RGB666 - * GDISP_PIXELFORMAT_CUSTOM - * @note If you use GDISP_PIXELFORMAT_CUSTOM and packed bit fills - * you need to also define @P gdispPackPixels(buf,cx,x,y,c) - * @note If you are using GDISP_HARDWARE_BITFILLS = FALSE then the pixel - * format must not be a packed format as the software blit does - * not support packed pixels - * @note Very few cases should actually require packed pixels as the low - * level driver can also pack on the fly as it is sending it - * to the graphics device. - */ - #ifndef GDISP_PACKED_PIXELS - #define GDISP_PACKED_PIXELS FALSE - #endif - - /** - * @brief Do lines of pixels require packing for a blit - * @note Ignored if GDISP_PACKED_PIXELS is FALSE - */ - #ifndef GDISP_PACKED_LINES - #define GDISP_PACKED_LINES FALSE - #endif -/** @} */ - -/*===========================================================================*/ -/* Define the macro's for the various pixel formats */ -/*===========================================================================*/ - -#if defined(__DOXYGEN__) - /** - * @brief The color of a pixel. - */ - typedef uint16_t color_t; - /** - * @brief Convert a number (of any type) to a color_t. - * @details Masks any invalid bits in the color - */ - #define COLOR(c) ((color_t)(c)) - /** - * @brief Does the color_t type contain invalid bits that need masking. - */ - #define MASKCOLOR FALSE - /** - * @brief Convert red, green, blue (each 0 to 255) into a color value. - */ - #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3))) - /** - * @brief Convert a 6 digit HTML code (hex) into a color value. - */ - #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3))) - /** - * @brief Extract the red component (0 to 255) of a color value. - */ - #define RED_OF(c) (((c) & 0xF800)>>8) - /** - * @brief Extract the green component (0 to 255) of a color value. - */ - #define GREEN_OF(c) (((c)&0x007E)>>3) - /** - * @brief Extract the blue component (0 to 255) of a color value. - */ - #define BLUE_OF(c) (((c)&0x001F)<<3) - -#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB565 - typedef uint16_t color_t; - #define COLOR(c) ((color_t)(c)) - #define MASKCOLOR FALSE - #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3))) - #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3))) - #define RED_OF(c) (((c) & 0xF800)>>8) - #define GREEN_OF(c) (((c)&0x007E)>>3) - #define BLUE_OF(c) (((c)&0x001F)<<3) - #define RGB565CONVERT(red, green, blue) (uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 )) - - -#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB888 - typedef uint32_t color_t; - #define COLOR(c) ((color_t)(((c) & 0xFFFFFF))) - #define MASKCOLOR TRUE - #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xFF)<<16) | (((g) & 0xFF) << 8) | ((b) & 0xFF))) - #define HTML2COLOR(h) ((color_t)(h)) - #define RED_OF(c) (((c) & 0xFF0000)>>16) - #define GREEN_OF(c) (((c)&0x00FF00)>>8) - #define BLUE_OF(c) ((c)&0x0000FF) - -#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB444 - typedef uint16_t color_t; - #define COLOR(c) ((color_t)(((c) & 0x0FFF))) - #define MASKCOLOR TRUE - #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF0)<<4) | ((g) & 0xF0) | (((b) & 0xF0)>>4))) - #define HTML2COLOR(h) ((color_t)((((h) & 0xF00000)>>12) | (((h) & 0x00F000)>>8) | (((h) & 0x0000F0)>>4))) - #define RED_OF(c) (((c) & 0x0F00)>>4) - #define GREEN_OF(c) ((c)&0x00F0) - #define BLUE_OF(c) (((c)&0x000F)<<4) - -#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB332 - typedef uint8_t color_t; - #define COLOR(c) ((color_t)(c)) - #define MASKCOLOR FALSE - #define RGB2COLOR(r,g,b) ((color_t)(((r) & 0xE0) | (((g) & 0xE0)>>3) | (((b) & 0xC0)>>6))) - #define HTML2COLOR(h) ((color_t)((((h) & 0xE00000)>>16) | (((h) & 0x00E000)>>11) | (((h) & 0x0000C0)>>6))) - #define RED_OF(c) ((c) & 0xE0) - #define GREEN_OF(c) (((c)&0x1C)<<3) - #define BLUE_OF(c) (((c)&0x03)<<6) - -#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB666 - typedef uint32_t color_t; - #define COLOR(c) ((color_t)(((c) & 0x03FFFF))) - #define MASKCOLOR TRUE - #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xFC)<<10) | (((g) & 0xFC)<<4) | (((b) & 0xFC)>>2))) - #define HTML2COLOR(h) ((color_t)((((h) & 0xFC0000)>>6) | (((h) & 0x00FC00)>>4) | (((h) & 0x0000FC)>>2))) - #define RED_OF(c) (((c) & 0x03F000)>>12) - #define GREEN_OF(c) (((c)&0x00FC00)>>8) - #define BLUE_OF(c) (((c)&0x00003F)<<2) - -#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM - #error "GDISP: No supported pixel format has been specified." -#endif - -/* Verify information for packed pixels and define a non-packed pixel macro */ -#if !GDISP_PACKED_PIXELS - #define gdispPackPixels(buf,cx,x,y,c) { ((color_t *)(buf))[(y)*(cx)+(x)] = (c); } -#elif !GDISP_HARDWARE_BITFILLS - #error "GDISP: packed pixel formats are only supported for hardware accelerated drivers." -#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB888 \ - && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB444 \ - && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB666 \ - && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM - #error "GDISP: A packed pixel format has been specified for an unsupported pixel format." -#endif - -#if GDISP_NEED_SCROLL && !GDISP_HARDWARE_SCROLL - #error "GDISP: Hardware scrolling is wanted but not supported." -#endif - -#if GDISP_NEED_PIXELREAD && !GDISP_HARDWARE_PIXELREAD - #error "GDISP: Pixel read-back is wanted but not supported." -#endif - -/*===========================================================================*/ -/* Driver types. */ -/*===========================================================================*/ - -/** - * @brief The type for a coordinate or length on the screen. - */ -typedef uint16_t coord_t; -/** - * @brief The type of a pixel. - */ -typedef color_t pixel_t; -/** - * @brief The type of a font. - */ -typedef const struct font *font_t; -/** - * @brief Type for the screen orientation. - */ -typedef enum orientation {portrait, landscape, portraitInv, landscapeInv} gdisp_orientation_t; -/** - * @brief Type for the available power modes for the screen. - */ -typedef enum powermode {powerOff, powerSleep, powerOn} gdisp_powermode_t; - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifndef GDISP_LLD_VMT - /* Special magic stuff for the VMT driver */ - #define GDISP_LLD_VMT(x) GDISP_LLD(x) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - /* Core functions */ - extern bool_t GDISP_LLD(init)(void); - - /* Some of these functions will be implemented in software by the high level driver - depending on the GDISP_HARDWARE_XXX macros defined in gdisp_lld_config.h. - */ - - /* Drawing functions */ - extern void GDISP_LLD_VMT(clear)(color_t color); - extern void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); - extern void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); - extern void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); - extern void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); - - /* Circular Drawing Functions */ - #if GDISP_NEED_CIRCLE - extern void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - extern void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); - #endif - - #if GDISP_NEED_ELLIPSE - extern void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - extern void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); - #endif - - /* Text Rendering Functions */ - #if GDISP_NEED_TEXT - extern void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); - extern void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); - #endif - - /* Pixel readback */ - #if GDISP_NEED_PIXELREAD - extern color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); - #endif - - /* Scrolling Function - clears the area scrolled out */ - #if GDISP_NEED_SCROLL - extern void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); - #endif - - /* Set driver specific control */ - #if GDISP_NEED_CONTROL - extern void GDISP_LLD_VMT(control)(unsigned what, void *value); - #endif - - /* Query driver specific data */ - #if GDISP_NEED_QUERY - extern void *GDISP_LLD_VMT(query)(unsigned what); - #endif - - /* Messaging API */ - #if GDISP_NEED_MSGAPI - #include "gdisp_lld_msgs.h" - extern void GDISP_LLD(msgdispatch)(gdisp_lld_msg_t *msg); - #endif - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_H */ -/** @} */ diff --git a/halext/include/gdisp_lld_msgs.h b/halext/include/gdisp_lld_msgs.h deleted file mode 100644 index 28a6707e..00000000 --- a/halext/include/gdisp_lld_msgs.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/** - * @file gdisp_lld_msgs.h - * @brief GDISP Graphic Driver subsystem low level driver message structures. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_MSGS_H -#define _GDISP_LLD_MSGS_H - -/* This file describes the message API for gdisp_lld */ -#if HAL_USE_GDISP && GDISP_NEED_MSGAPI - -typedef enum gdisp_msgaction { - GDISP_LLD_MSG_NOP, - GDISP_LLD_MSG_INIT, - GDISP_LLD_MSG_CLEAR, - GDISP_LLD_MSG_DRAWPIXEL, - GDISP_LLD_MSG_FILLAREA, - GDISP_LLD_MSG_BLITAREA, - GDISP_LLD_MSG_DRAWLINE, - #if GDISP_NEED_CIRCLE - GDISP_LLD_MSG_DRAWCIRCLE, - GDISP_LLD_MSG_FILLCIRCLE, - #endif - #if GDISP_NEED_ELLIPSE - GDISP_LLD_MSG_DRAWELLIPSE, - GDISP_LLD_MSG_FILLELLIPSE, - #endif - #if GDISP_NEED_TEXT - GDISP_LLD_MSG_DRAWCHAR, - GDISP_LLD_MSG_FILLCHAR, - #endif - #if GDISP_NEED_PIXELREAD - GDISP_LLD_MSG_GETPIXELCOLOR, - #endif - #if GDISP_NEED_SCROLL - GDISP_LLD_MSG_VERTICALSCROLL, - #endif - #if GDISP_NEED_CONTROL - GDISP_LLD_MSG_CONTROL, - #endif - #if GDISP_NEED_QUERY - GDISP_LLD_MSG_QUERY, - #endif -} gdisp_msgaction_t; - -typedef union gdisp_lld_msg { - gdisp_msgaction_t action; - struct gdisp_lld_msg_init { - gdisp_msgaction_t action; // GDISP_LLD_MSG_INIT - } init; - struct gdisp_lld_msg_clear { - gdisp_msgaction_t action; // GDISP_LLD_MSG_CLEAR - color_t color; - } clear; - struct gdisp_lld_msg_drawpixel { - gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWPIXEL - coord_t x, y; - color_t color; - } drawpixel; - struct gdisp_lld_msg_fillarea { - gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLAREA - coord_t x, y; - coord_t cx, cy; - color_t color; - } fillarea; - struct gdisp_lld_msg_blitarea { - gdisp_msgaction_t action; // GDISP_LLD_MSG_BLITAREA - coord_t x, y; - coord_t cx, cy; - const pixel_t *buffer; - } blitarea; - struct gdisp_lld_msg_drawline { - gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWLINE - coord_t x0, y0; - coord_t x1, y1; - color_t color; - } drawline; - struct gdisp_lld_msg_drawcircle { - gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCIRCLE - coord_t x, y; - coord_t radius; - color_t color; - } drawcircle; - struct gdisp_lld_msg_fillcircle { - gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCIRCLE - coord_t x, y; - coord_t radius; - color_t color; - } fillcircle; - struct gdisp_lld_msg_drawellipse { - gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWELLIPSE - coord_t x, y; - coord_t a, b; - color_t color; - } drawellipse; - struct gdisp_lld_msg_fillellipse { - gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLELLIPSE - coord_t x, y; - coord_t a, b; - color_t color; - } fillellipse; - struct gdisp_lld_msg_drawchar { - gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCHAR - coord_t x, y; - char c; - font_t font; - color_t color; - } drawchar; - struct gdisp_lld_msg_fillchar { - gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCHAR - coord_t x, y; - char c; - font_t font; - color_t color; - color_t bgcolor; - } fillchar; - struct gdisp_lld_msg_getpixelcolor { - gdisp_msgaction_t action; // GDISP_LLD_MSG_GETPIXELCOLOR - coord_t x, y; - color_t result; - } getpixelcolor; - struct gdisp_lld_msg_verticalscroll { - gdisp_msgaction_t action; // GDISP_LLD_MSG_VERTICALSCROLL - coord_t x, y; - coord_t cx, cy; - int lines; - color_t bgcolor; - } verticalscroll; - struct gdisp_lld_msg_control { - gdisp_msgaction_t action; // GDISP_LLD_MSG_CONTROL - int what; - void * value; - } control; - struct gdisp_lld_msg_query { - gdisp_msgaction_t action; // GDISP_LLD_MSG_QUERY - int what; - void * result; - } query; -} gdisp_lld_msg_t; - -#endif /* HAL_USE_GDISP */ -#endif /* _GDISP_LLD_MSGS_H */ -/** @} */ diff --git a/halext/include/glcd.h b/halext/include/glcd.h deleted file mode 100644 index ab2f6be2..00000000 --- a/halext/include/glcd.h +++ /dev/null @@ -1,136 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/* - This file is an emulation of the GLCD interface using the - new GDISP interface. It is probably not a perfect replica, - some code changes may be necessary. - Note it does not replicate the GLCD low level driver, just - the high level interface. - You may also need to define the various GDISP_NEED_XXX in your - halconf.h in order to turn on the functionality you need. -*/ - -#ifndef GLCD_H -#define GLCD_H - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv) -#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv) - -#define RGB565CONVERT(r, g, b) RGB2COLOR(r,g,b) - -enum filled {frame, filled}; -enum transparency {solid, transparent}; -#define sleepOn powerSleep -#define sleepOff powerOn - -#define font_Small (&fontSmall) -#define font_SmallDouble (&fontSmallDouble) -#define font_SmallNarrow (&fontSmall) -#define font_Larger (&fontLarger) -#define font_LargerDouble (&fontLargerDouble) -#define font_LargerNarrow (&fontLargerNarrow) -#define font_MediumBold (&fontUI1) -#define font_MediumBoldDouble (&fontUI1Double) -#define font_MediumBoldNarrow (&fontUI1Narrow) -#define font_LargeNumbers (&fontLargeNumbers) -#define font_LargeNumbersDouble (&fontLargeNumbersDouble) -#define font_LargeNumbersNarrow (&fontLargeNumbersNarrow) - -enum glcd_result { GLCD_DONE, - GLCD_FAILED, - GLCD_PROGRESS, - }; - -typedef enum glcd_result glcd_result_t; - -/* Core functions */ -#define lcdInit(dvr) gdispInit(dvr) -static __inline glcd_result_t lcdClear(color_t color) { - gdispClear(color); - return GLCD_DONE; -} -static __inline glcd_result_t lcdSetOrientation(enum orientation newO) { - gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO); - return ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) == (newO) ? GLCD_DONE : GLCD_FAILED; -} -static __inline glcd_result_t lcdFillArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1,color_t c) { - gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); - return GLCD_DONE; -} -static __inline glcd_result_t lcdWriteArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1, const pixel_t *b, coord_t n) { - (void)n; - gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b)); - return GLCD_DONE; -} -static __inline glcd_result_t lcdSetPowerMode(enum powermode pm) { - gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm); - return ((enum powermode)(unsigned)gdispQuery(GDISP_QUERY_POWER)) == (pm) ? GLCD_DONE : GLCD_FAILED; -} - -/* Drawing functions */ -static __inline glcd_result_t lcdDrawPixel(coord_t x, coord_t y, color_t c) { - gdispDrawPixel((x),(y),(c)); - return GLCD_DONE; -} -#define lcdDrawLine(x0,y0,x1,y1,c) gdispDrawLine((x0),(y0),(x1),(y1),(c)) -#define lcdDrawRect(x0,y0,x1,y1,f,c) {if(f) gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); else gdispDrawBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));} -#define lcdDrawRectString(x0,y0,x1,y1,s,f,c,b) gdispFillStringBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(s),(f),(c),(b),justifyLeft) -#define lcdDrawCircle(x,y,r,f,c) {if(f) gdispFillCircle((x),(y),(r),(c)); else gdispDrawCircle((x),(y),(r),(c));} -#define lcdDrawEllipse(x,y,a,b,f,c) {if(f) gdispFillEllipse((x),(y),(a),(b),(c)); else gdispDrawEllipse((x),(y),(a),(b),(c));} - -/* Text Rendering Functions */ -static __inline coord_t lcdDrawChar(coord_t x, coord_t y, char h, font_t f, color_t c, color_t b, bool_t t) { - if (t) - gdispDrawChar((x),(y),(h),(f),(c)); - else - gdispFillChar((x),(y),(h),(f),(c),(b)); - return gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding); -} -static __inline coord_t lcdDrawString(coord_t x, coord_t y, const char *s, font_t f, color_t c, color_t b, bool_t t) { - if (t) - gdispDrawString((x),(y),(s),(f),(c)); - else - gdispFillString((x),(y),(s),(f),(c),(b)); - return gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding); -} - -/* Character measuring functions */ -#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding)) -#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding)) -#define lcdGetFontHeight(f) gdispGetFontMetric((f), fontHeight) - -/* Size and orientation related */ -#define lcdGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT)) -#define lcdGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH)) -#define lcdGetOrientation() ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) - -/* BGR->RGB and pixel readback */ -#define lcdBGR2RGB(c) RGB2COLOR(BLUE_OF(c),GREEN_OF(c),RED_OF(c)) -#define lcdGetPixelColor(x,y) gdispGetPixelColor((x),(y)) - -/* Scrolling function */ -#define lcdVerticalScroll(x0,y0,x1,y1,l) gdispVerticalScroll((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,l,Black) - -#endif diff --git a/halext/include/touchpad.h b/halext/include/touchpad.h deleted file mode 100644 index 445d3202..00000000 --- a/halext/include/touchpad.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - ChibiOS-LCD-Driver/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpad.h - * @brief TOUCHPAD Touchpad Driver subsystem header file. - * - * @addgroup TOUCHPAD - * @{ - */ -#ifndef _TOUCHPAD_H -#define _TOUCHPAD_H - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/** - * @brief specifies how many conversions are made for a readout. - * - * @note higher is more accurate, but takes more time - */ -#define CONVERSIONS 3 - -/*===========================================================================*/ -/* Driver constants. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Low Level Driver details and error checks. */ -/*===========================================================================*/ - -/* Include the low level driver information */ -#include "touchpad_lld.h" - -/*===========================================================================*/ -/* Type definitions */ -/*===========================================================================*/ - -/** - * @brief Struct used for calibration - */ -struct cal { - float xm; - float ym; - float xn; - float yn; -}; - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#ifdef __cplusplus -extern "C" { -#endif - -void tpInit(TOUCHPADDriver *tp); -uint16_t tpReadX(void); -uint16_t tpReadY(void); - -#if TOUCHPAD_HAS_IRQ - uint8_t tpIRQ(void); -#endif - -#if TOUCHPAD_HAS_PRESSURE - uint16_t tpReadZ(void); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_TOUCHPAD */ - -#endif /* _TOUCHPAD_H */ -/** @} */ - diff --git a/halext/include/touchpad_lld.h b/halext/include/touchpad_lld.h deleted file mode 100644 index 45a561d3..00000000 --- a/halext/include/touchpad_lld.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - ChibiOS-LCD-Driver/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpad_lld.h - * @brief TOUCHPAD Driver subsystem low level driver header. - * - * @addgroup TOUCHPAD - * @{ - */ - -#ifndef _TOUCHPAD_LLD_H -#define _TOUCHPAD_LLD_H - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Include the low level driver configuration information */ -/*===========================================================================*/ - -#include "touchpad_lld_config.h" - -/*===========================================================================*/ -/* Error checks. */ -/*===========================================================================*/ - -#ifndef TOUCHPAD_HAS_IRQ - #define TOUCHPAD_HAS_IRQ FALSE -#endif - -#ifndef TOUCHPAD_HAS_PRESSURE - #define TOUCHPAD_HAS_PRESSURE FALSE -#endif - -/*===========================================================================*/ -/* Driver types. */ -/*===========================================================================*/ - -typedef struct TOUCHPADDriver TOUCHPADDriver; - -/** - * @brief Structure representing a Touchpad driver. - */ -struct TOUCHPADDriver { - /* - * @brief Pointer to SPI driver. - */ - SPIDriver *spid; - - /* - * @brief SPI configuration. - */ - SPIConfig *spicfg; -}; - -/*===========================================================================*/ -/* External declarations. */ -/*===========================================================================*/ - -#if !defined(__DOXYGEN__) - extern TOUCHPADDriver Touchpad; -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - /* Core functions */ - void tp_lld_init(TOUCHPADDriver *tp); - uint16_t tp_lld_read_x(void); - uint16_t tp_lld_read_y(void); - - #if TOUCHPAD_HAS_IRQ - uint8_t tp_lld_irq(void); - #endif - - #if TOUCHPAD_HAS_PRESSURE - uint16_t tp_lld_read_z(void); - #endif - -#ifdef __cplusplus -} -#endif - -#endif /* HAL_USE_TOUCHPAD */ - -#endif /* _TOUCHPAD_LLD_H */ -/** @} */ - diff --git a/halext/readme.txt b/halext/readme.txt deleted file mode 100644 index 907c7eb4..00000000 --- a/halext/readme.txt +++ /dev/null @@ -1,28 +0,0 @@ -To include any of these functions/drivers in your project... - - 1/ Specify the path to the LCDLIB. If none defined, default is $(CHIBIOS)/ext/lcd - - 2/ In your project Makefile (amongst similiar lines but after the hal line) add the line... - include $(LCDLIB)/lcd.mk - - 3/ In your project Makefile add the makefiles for any specific drivers you want e.g - include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk - include $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.mk - - 4/ In your project halconf.h turn on the support you want eg. - /** - * @brief Enables the Touchpad subsystem. - */ - #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) - #define HAL_USE_TOUCHPAD TRUE - #endif - /** - * @brief Enables the GDISP subsystem. - */ - #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__) - #define HAL_USE_GDISP TRUE - /* Any driver specific defines required go here. The below line is an example. */ - #define GDISP_NEED_MULTITHREAD TRUE - #endif - 5/ Do a make clean. - diff --git a/halext/src/gdisp-readme.txt b/halext/src/gdisp-readme.txt deleted file mode 100644 index 12b00e2c..00000000 --- a/halext/src/gdisp-readme.txt +++ /dev/null @@ -1,14 +0,0 @@ -The new GDISP driver is an architecture independant rewrite of the GLCD interface. -This new architecture independance should allow many new low level drivers to be easily added. - -GDISP allows low-level driver hardware accelerated drawing routines while providing a software emulation -if the low level driver can not provide it. A basic low level driver now only requires 2 routines to be written. - -A glcd.h compatability file has been included that allow applications written to use the existing GLCD driver to -use the GDISP driver with little or no change. - -It is written in the ChibiOS style with ChibiOS style includes and documentation. - -It is encapsulated into a "halext" structure with appropriate readme's that allow for easy inclusion in any -ChibiOS project. This structure can be seamlessly added to as new driver types are added and it supports -low level drivers that are neither platform or board specific (although they can be). diff --git a/halext/src/gdisp.c b/halext/src/gdisp.c deleted file mode 100644 index ee2b98e4..00000000 --- a/halext/src/gdisp.c +++ /dev/null @@ -1,997 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file gdisp.c - * @brief GDISP Driver code. - * - * @addtogroup GDISP - * @{ - */ -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#ifndef _GDISP_C -#define _GDISP_C - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -#ifdef GDISP_NEED_TEXT - #include "gdisp_fonts.h" -#endif - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -#if GDISP_NEED_MULTITHREAD - #if !CH_USE_MUTEXES - #error "GDISP: CH_USE_MUTEXES must be defined in chconf.h because GDISP_NEED_MULTITHREAD is defined" - #endif -#endif - -#if GDISP_NEED_ASYNC - #if !CH_USE_MAILBOXES || !CH_USE_MUTEXES || !CH_USE_SEMAPHORES - #error "GDISP: CH_USE_MAILBOXES, CH_USE_SEMAPHORES and CH_USE_MUTEXES must be defined in chconf.h because GDISP_NEED_ASYNC is defined" - #endif -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC - static Mutex gdispMutex; -#endif - -#if GDISP_NEED_ASYNC - #define GDISP_THREAD_STACK_SIZE 512 /* Just a number - not yet a reflection of actual use */ - #define GDISP_QUEUE_SIZE 8 /* We only allow a short queue */ - - static Thread * lldThread; - static Mailbox gdispMailbox; - static msg_t gdispMailboxQueue[GDISP_QUEUE_SIZE]; - static Semaphore gdispMsgsSem; - static Mutex gdispMsgsMutex; - static gdisp_lld_msg_t gdispMsgs[GDISP_QUEUE_SIZE]; - static WORKING_AREA(waGDISPThread, GDISP_THREAD_STACK_SIZE); -#endif - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#if GDISP_NEED_ASYNC - static msg_t GDISPThreadHandler(void *UNUSED(arg)) { - gdisp_lld_msg_t *pmsg; - - #if CH_USE_REGISTRY - chRegSetThreadName("GDISPAsyncAPI"); - #endif - - while(1) { - /* Wait for msg with work to do. */ - chMBFetch(&gdispMailbox, (msg_t *)&pmsg, TIME_INFINITE); - - /* OK - we need to obtain the mutex in case a synchronous operation is occurring */ - chMtxLock(&gdispMutex); - GDISP_LLD(msgdispatch)(pmsg); - chMtxUnlock(); - - /* Mark the message as free */ - pmsg->action = GDISP_LLD_MSG_NOP; - chSemSignal(&gdispMsgsSem); - } - return 0; - } - - static gdisp_lld_msg_t *gdispAllocMsg(gdisp_msgaction_t action) { - gdisp_lld_msg_t *p; - - while(1) { /* To be sure, to be sure */ - - /* Wait for a slot */ - chSemWait(&gdispMsgsSem); - - /* Find the slot */ - chMtxLock(&gdispMsgsMutex); - for(p=gdispMsgs; p < &gdispMsgs[GDISP_QUEUE_SIZE]; p++) { - if (p->action == GDISP_LLD_MSG_NOP) { - /* Allocate it */ - p->action = action; - chMtxUnlock(); - return p; - } - } - chMtxUnlock(); - - /* Oops - none found, try again */ - chSemSignal(&gdispMsgsSem); - } - } -#endif - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief GDISP Driver initialization. - * @note This function is NOT currently implicitly invoked by @p halInit(). - * It must be called manually. - * - * @init - */ - bool_t gdispInit(void) { - bool_t res; - - /* Initialise Mutex */ - chMtxInit(&gdispMutex); - - /* Initialise driver */ - chMtxLock(&gdispMutex); - res = GDISP_LLD(init)(); - chMtxUnlock(); - - return res; - } -#elif GDISP_NEED_ASYNC - bool_t gdispInit(void) { - bool_t res; - unsigned i; - - /* Mark all the Messages as free */ - for(i=0; i < GDISP_QUEUE_SIZE; i++) - gdispMsgs[i].action = GDISP_LLD_MSG_NOP; - - /* Initialise our Mailbox, Mutex's and Counting Semaphore. - * A Mutex is required as well as the Mailbox and Thread because some calls have to be synchronous. - * Synchronous calls get handled by the calling thread, asynchronous by our worker thread. - */ - chMBInit(&gdispMailbox, gdispMailboxQueue, sizeof(gdispMailboxQueue)/sizeof(gdispMailboxQueue[0])); - chMtxInit(&gdispMutex); - chMtxInit(&gdispMsgsMutex); - chSemInit(&gdispMsgsSem, GDISP_QUEUE_SIZE); - - lldThread = chThdCreateStatic(waGDISPThread, sizeof(waGDISPThread), NORMALPRIO, GDISPThreadHandler, NULL); - - /* Initialise driver - synchronous */ - chMtxLock(&gdispMutex); - res = GDISP_LLD(init)(); - chMtxUnlock(); - - return res; - } -#endif - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Test if the GDISP engine is currently drawing. - * @note This function will always return FALSE if - * GDISP_NEED_ASYNC is not defined. - * - * @init - */ - bool_t gdispIsBusy(void) { - return FALSE; - } -#elif GDISP_NEED_ASYNC - bool_t gdispIsBusy(void) { - return chMBGetUsedCountI(&gdispMailbox) != FALSE; - } -#endif - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Clear the display to the specified color. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] color The color to use when clearing the screen - * - * @api - */ - void gdispClear(color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(clear)(color); - chMtxUnlock(); - } -#elif GDISP_NEED_ASYNC - void gdispClear(color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_CLEAR); - p->clear.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Set a pixel in the specified color. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x,y The position to set the pixel. - * @param[in] color The color to use - * - * @api - */ - void gdispDrawPixel(coord_t x, coord_t y, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(drawpixel)(x, y, color); - chMtxUnlock(); - } -#elif GDISP_NEED_ASYNC - void gdispDrawPixel(coord_t x, coord_t y, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWPIXEL); - p->drawpixel.x = x; - p->drawpixel.y = y; - p->drawpixel.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The start position - * @param[in] x1,y1 The end position - * @param[in] color The color to use - * - * @api - */ - void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(drawline)(x0, y0, x1, y1, color); - chMtxUnlock(); - } -#elif GDISP_NEED_ASYNC - void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWLINE); - p->drawline.x0 = x0; - p->drawline.y0 = y0; - p->drawline.x1 = x1; - p->drawline.y1 = y1; - p->drawline.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The start position - * @param[in] cx,cy The size of the box (outside dimensions) - * @param[in] color The color to use - * - * @api - */ - void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(fillarea)(x, y, cx, cy, color); - chMtxUnlock(); - } -#elif GDISP_NEED_ASYNC - void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLAREA); - p->fillarea.x = x; - p->fillarea.y = y; - p->fillarea.cx = cx; - p->fillarea.cy = cy; - p->fillarea.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) - /** - * @brief Fill an area using the supplied bitmap. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * @details The bitmap is in the pixel format specified by the low level driver - * @note If a packed pixel format is used and the width doesn't - * match a whole number of bytes, the next line will start on a - * non-byte boundary (no end-of-line padding). - * @note If GDISP_NEED_ASYNC is defined then the buffer must be static - * or at least retained until this call has finished the blit. You can - * tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE. - * - * @param[in] x0,y0 The start position - * @param[in] cx,cy The size of the filled area - * @param[in] buffer The bitmap in the driver's pixel format. - * - * @api - */ - void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - chMtxLock(&gdispMutex); - GDISP_LLD(blitarea)(x, y, cx, cy, buffer); - chMtxUnlock(); - } -#elif GDISP_NEED_ASYNC - void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_BLITAREA); - p->blitarea.x = x; - p->blitarea.y = y; - p->blitarea.cx = cx; - p->blitarea.cy = cy; - p->blitarea.buffer = buffer; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The center of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color to use - * - * @api - */ - void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(drawcircle)(x, y, radius, color); - chMtxUnlock(); - } -#elif GDISP_NEED_CIRCLE && GDISP_NEED_ASYNC - void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWCIRCLE); - p->drawcircle.x = x; - p->drawcircle.y = y; - p->drawcircle.radius = radius; - p->drawcircle.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Draw a filled circle. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The center of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color to use - * - * @api - */ - void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(fillcircle)(x, y, radius, color); - chMtxUnlock(); - } -#elif GDISP_NEED_CIRCLE && GDISP_NEED_ASYNC - void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLCIRCLE); - p->fillcircle.x = x; - p->fillcircle.y = y; - p->fillcircle.radius = radius; - p->fillcircle.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The center of the ellipse - * @param[in] a,b The dimensions of the ellipse - * @param[in] color The color to use - * - * @api - */ - void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(drawellipse)(x, y, a, b, color); - chMtxUnlock(); - } -#elif GDISP_NEED_ELLIPSE && GDISP_NEED_ASYNC - void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWELLIPSE); - p->drawellipse.x = x; - p->drawellipse.y = y; - p->drawellipse.a = a; - p->drawellipse.b = b; - p->drawellipse.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Draw a filled ellipse. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The center of the ellipse - * @param[in] a,b The dimensions of the ellipse - * @param[in] color The color to use - * - * @api - */ - void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(fillellipse)(x, y, a, b, color); - chMtxUnlock(); - } -#elif GDISP_NEED_ELLIPSE && GDISP_NEED_ASYNC - void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLELLIPSE); - p->fillellipse.x = x; - p->fillellipse.y = y; - p->fillellipse.a = a; - p->fillellipse.b = b; - p->fillellipse.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Draw a text character. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x,y The position for the text - * @param[in] c The character to draw - * @param[in] color The color to use - * - * @api - */ - void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color) { - chMtxLock(&gdispMutex); - GDISP_LLD(drawchar)(x, y, c, font, color); - chMtxUnlock(); - } -#elif GDISP_NEED_TEXT && GDISP_NEED_ASYNC - void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWCHAR); - p->drawchar.x = x; - p->drawchar.y = y; - p->drawchar.c = c; - p->drawchar.font = font; - p->drawchar.color = color; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Draw a text character with a filled background. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x,y The position for the text - * @param[in] c The character to draw - * @param[in] color The color to use - * @param[in] bgcolor The background color to use - * - * @api - */ - void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - chMtxLock(&gdispMutex); - GDISP_LLD(fillchar)(x, y, c, font, color, bgcolor); - chMtxUnlock(); - } -#elif GDISP_NEED_TEXT && GDISP_NEED_ASYNC - void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLCHAR); - p->fillchar.x = x; - p->fillchar.y = y; - p->fillchar.c = c; - p->fillchar.font = font; - p->fillchar.color = color; - p->fillchar.bgcolor = bgcolor; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_PIXELREAD && (GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC)) || defined(__DOXYGEN__) - /** - * @brief Get the color of a pixel. - * @return The color of the pixel. - * - * @param[in] x,y The position of the pixel - * - * @api - */ - color_t gdispGetPixelColor(coord_t x, coord_t y) { - color_t c; - - /* Always synchronous as it must return a value */ - chMtxLock(&gdispMutex); - c = GDISP_LLD(getpixelcolor)(x, y); - chMtxUnlock(); - - return c; - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @api - */ - void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - chMtxLock(&gdispMutex); - GDISP_LLD(verticalscroll)(x, y, cx, cy, lines, bgcolor); - chMtxUnlock(); - } -#elif GDISP_NEED_SCROLL && GDISP_NEED_ASYNC - void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_VERTICALSCROLL); - p->verticalscroll.x = x; - p->verticalscroll.y = y; - p->verticalscroll.cx = cx; - p->verticalscroll.cy = cy; - p->verticalscroll.lines = lines; - p->verticalscroll.bgcolor = bgcolor; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) - /** - * @brief Set the power mode for the display. - * @pre The GDISP unit must have been initialised using @p gdispInit(). - * @note Depending on the hardware implementation this function may not - * support some codes. They will be ignored. - * - * @param[in] powerMode The power mode to use - * - * @api - */ - void gdispControl(unsigned what, void *value) { - chMtxLock(&gdispMutex); - GDISP_LLD(control)(what, value); - chMtxUnlock(); - } -#elif GDISP_NEED_CONTROL && GDISP_NEED_ASYNC - void gdispControl(unsigned what, void *value) { - gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_CONTROL); - p->control.what = what; - p->control.value = value; - chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); - } -#endif - -#if (GDISP_NEED_QUERY && (GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC)) || defined(__DOXYGEN__) - /** - * @brief Query a property of the display. - * @pre The GDISP unit must have been initialised using @p gdispInit(). - * @note The result must be typecast to the correct type. - * @note An uunsupported query will return (void *)-1. - * - * @param[in] what What to query - * - * @api - */ - void *gdispQuery(unsigned what) { - void *res; - - chMtxLock(&gdispMutex); - res = GDISP_LLD(query)(what); - chMtxUnlock(); - return res; - } -#endif - -/*===========================================================================*/ -/* High Level Driver Routines. */ -/*===========================================================================*/ - -/** - * @brief Draw a rectangular box. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x0,y0 The start position - * @param[in] cx,cy The size of the box (outside dimensions) - * @param[in] color The color to use - * @param[in] filled Should the box should be filled - * - * @api - */ -void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - /* No mutex required as we only call high level functions which have their own mutex */ - coord_t x1, y1; - - x1 = x+cx-1; - y1 = y+cy-1; - - if (cx > 2) { - if (cy >= 1) { - gdispDrawLine(x, y, x1, y, color); - if (cy >= 2) { - gdispDrawLine(x, y1, x1, y1, color); - if (cy > 2) { - gdispDrawLine(x, y+1, x, y1-1, color); - gdispDrawLine(x1, y+1, x1, y1-1, color); - } - } - } - } else if (cx == 2) { - gdispDrawLine(x, y, x, y1, color); - gdispDrawLine(x1, y, x1, y1, color); - } else if (cx == 1) { - gdispDrawLine(x, y, x, y1, color); - } -} - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) - /** - * @brief Draw a text string. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x,y The position for the text - * @param[in] str The string to draw - * @param[in] color The color to use - * - * @api - */ - void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color) { - /* No mutex required as we only call high level functions which have their own mutex */ - coord_t w, p; - char c; - int first; - - first = 1; - p = font->charPadding * font->xscale; - while(*str) { - /* Get the next printable character */ - c = *str++; - w = _getCharWidth(font, c) * font->xscale; - if (!w) continue; - - /* Handle inter-character padding */ - if (p) { - if (!first) - x += p; - else - first = 0; - } - - /* Print the character */ - gdispDrawChar(x, y, c, font, color); - x += w; - } - } -#endif - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) - /** - * @brief Draw a text string. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * - * @param[in] x,y The position for the text - * @param[in] str The string to draw - * @param[in] color The color to use - * @param[in] bgcolor The background color to use - * - * @api - */ - void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor) { - /* No mutex required as we only call high level functions which have their own mutex */ - coord_t w, h, p; - char c; - int first; - - first = 1; - h = font->height * font->yscale; - p = font->charPadding * font->xscale; - while(*str) { - /* Get the next printable character */ - c = *str++; - w = _getCharWidth(font, c) * font->xscale; - if (!w) continue; - - /* Handle inter-character padding */ - if (p) { - if (!first) { - gdispFillArea(x, y, p, h, bgcolor); - x += p; - } else - first = 0; - } - - /* Print the character */ - gdispFillChar(x, y, c, font, color, bgcolor); - x += w; - } - } -#endif - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) - /** - * @brief Draw a text string verticly centered within the specified box. - * @pre The GDISP unit must be in powerOn or powerSleep mode. - * @note The entire box is filled - * - * @param[in] x,y The position for the text (need to define top-right or base-line - check code) - * @param[in] str The string to draw - * @param[in] color The color to use - * @param[in] bgcolor The background color to use - * @param[in] justify Justify the text left, center or right within the box - * - * @api - */ - void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgcolor, justify_t justify) { - /* No mutex required as we only call high level functions which have their own mutex */ - coord_t w, h, p, ypos, xpos; - char c; - int first; - const char *rstr; - - h = font->height * font->yscale; - p = font->charPadding * font->xscale; - - /* Oops - font too large for the area */ - if (h > cy) return; - - /* See if we need to fill above the font */ - ypos = (cy - h + 1)/2; - if (ypos > 0) { - gdispFillArea(x, y, cx, ypos, bgcolor); - y += ypos; - cy -= ypos; - } - - /* See if we need to fill below the font */ - ypos = cy - h; - if (ypos > 0) { - gdispFillArea(x, y+cy-ypos, cx, ypos, bgcolor); - cy -= ypos; - } - - /* get the start of the printable string and the xpos */ - switch(justify) { - case justifyCenter: - /* Get the length of the entire string */ - w = gdispGetStringWidth(str, font); - if (w <= cx) - xpos = x + (cx - w)/2; - else { - /* Calculate how much of the string we need to get rid of */ - ypos = (w - cx)/2; - xpos = 0; - first = 1; - while(*str) { - /* Get the next printable character */ - c = *str++; - w = _getCharWidth(font, c) * font->xscale; - if (!w) continue; - - /* Handle inter-character padding */ - if (p) { - if (!first) { - xpos += p; - if (xpos > ypos) break; - } else - first = 0; - } - - /* Print the character */ - xpos += w; - if (xpos > ypos) break; - } - xpos = ypos - xpos + x; - } - break; - case justifyRight: - /* Find the end of the string */ - for(rstr = str; *str; str++); - xpos = x+cx - 2; - first = 1; - for(str--; str >= rstr; str--) { - /* Get the next printable character */ - c = *str; - w = _getCharWidth(font, c) * font->xscale; - if (!w) continue; - - /* Handle inter-character padding */ - if (p) { - if (!first) { - if (xpos - p < x) break; - xpos -= p; - } else - first = 0; - } - - /* Print the character */ - if (xpos - w < x) break; - xpos -= w; - } - str++; - break; - case justifyLeft: - /* Fall through */ - default: - xpos = x+1; - break; - } - - /* Fill any space to the left */ - if (x < xpos) - gdispFillArea(x, y, xpos-x, cy, bgcolor); - - /* Print characters until we run out of room */ - first = 1; - while(*str) { - /* Get the next printable character */ - c = *str++; - w = _getCharWidth(font, c) * font->xscale; - if (!w) continue; - - /* Handle inter-character padding */ - if (p) { - if (!first) { - if (xpos + p > x+cx) break; - gdispFillArea(xpos, y, p, cy, bgcolor); - xpos += p; - } else - first = 0; - } - - /* Print the character */ - if (xpos + w > x+cx) break; - gdispFillChar(xpos, y, c, font, color, bgcolor); - xpos += w; - } - - /* Fill any space to the right */ - if (xpos < x+cx) - gdispFillArea(xpos, y, x+cx-xpos, cy, bgcolor); - } -#endif - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) - /** - * @brief Get a metric of a font. - * @return The metric requested in pixels. - * - * @param[in] font The font to test - * @param[in] metric The metric to measure - * - * @api - */ - coord_t gdispGetFontMetric(font_t font, fontmetric_t metric) { - /* No mutex required as we only read static data */ - switch(metric) { - case fontHeight: return font->height * font->yscale; - case fontDescendersHeight: return font->descenderHeight * font->yscale; - case fontLineSpacing: return font->lineSpacing * font->yscale; - case fontCharPadding: return font->charPadding * font->xscale; - case fontMinWidth: return font->minWidth * font->xscale; - case fontMaxWidth: return font->maxWidth * font->xscale; - } - return 0; - } -#endif - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) - /** - * @brief Get the pixel width of a character. - * @return The width of the character in pixels. Does not include any between character padding. - * - * @param[in] c The character to draw - * @param[in] font The font to use - * - * @api - */ - coord_t gdispGetCharWidth(char c, font_t font) { - /* No mutex required as we only read static data */ - return _getCharWidth(font, c) * font->xscale; - } -#endif - -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) - /** - * @brief Get the pixel width of a string. - * @return The width of the string in pixels. - * - * @param[in] str The string to measure - * @param[in] font The font to use - * - * @api - */ - coord_t gdispGetStringWidth(const char* str, font_t font) { - /* No mutex required as we only read static data */ - coord_t w, p, x; - char c; - int first; - - first = 1; - x = 0; - p = font->charPadding * font->xscale; - while(*str) { - /* Get the next printable character */ - c = *str++; - w = _getCharWidth(font, c) * font->xscale; - if (!w) continue; - - /* Handle inter-character padding */ - if (p) { - if (!first) - x += p; - else - first = 0; - } - - /* Add the character width */ - x += w; - } - return x; - } -#endif - -#if (!defined(gdispPackPixels) && !defined(GDISP_PIXELFORMAT_CUSTOM)) || defined(__DOXYGEN__) - /** - * @brief Pack a pixel into a pixel buffer. - * @note This function performs no buffer boundary checking - * regardless of whether GDISP_NEED_CLIPPING has been specified. - * - * @param[in] buf The buffer to put the pixel in - * @param[in] cx The width of a pixel line - * @param[in] x, y The location of the pixel to place - * @param[in] color The color to put into the buffer - * - * @api - */ - void gdispPackPixels(pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color) { - /* No mutex required as we only read static data */ - #if defined(GDISP_PIXELFORMAT_RGB888) - #error "GDISP: Packed pixels not supported yet" - #elif defined(GDISP_PIXELFORMAT_RGB444) - #error "GDISP: Packed pixels not supported yet" - #elif defined(GDISP_PIXELFORMAT_RGB666) - #error "GDISP: Packed pixels not supported yet" - #elif - #error "GDISP: Unsupported packed pixel format" - #endif - } -#endif - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_C */ -/** @} */ diff --git a/halext/src/gdisp_fonts.c b/halext/src/gdisp_fonts.c deleted file mode 100644 index 25a56526..00000000 --- a/halext/src/gdisp_fonts.c +++ /dev/null @@ -1,655 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ -/* - Font tables included into gdisp.c -*/ -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -#if GDISP_NEED_TEXT - -#include "gdisp_fonts.h" - - -/* fontSmall - for side buttons */ -#if 1 - /* Forward Declarations of internal arrays */ - static const uint8_t fontSmall_Widths[]; - static const uint16_t fontSmall_Offsets[]; - static const fontcolumn_t fontSmall_Data[]; - - const struct font fontSmall = { 11, 0, 14, 2, 2, 12, ' ', '~', 1, 1, - fontSmall_Widths, - fontSmall_Offsets, - fontSmall_Data}; - const struct font fontSmallDouble = { 11, 0, 14, 2, 2, 12, ' ', '~', 2, 2, - fontSmall_Widths, - fontSmall_Offsets, - fontSmall_Data}; - const struct font fontSmallNarrow = { 11, 0, 14, 2, 2, 12, ' ', '~', 1, 2, - fontSmall_Widths, - fontSmall_Offsets, - fontSmall_Data}; - - static const uint8_t fontSmall_Widths[] = { - 2, 3, 6, 8, 7, 9, 7, 3, 4, 4, 5, 7, 4, 4, 3, 6, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 4, 6, 7, 6, 7, - 12, 8, 7, 8, 8, 7, 7, 8, 8, 3, 5, 8, 7, 9, 8, 8, - 8, 8, 8, 7, 7, 8, 8, 12, 8, 8, 8, 4, 6, 4, 7, 7, - 4, 7, 7, 7, 7, 7, 4, 7, 7, 3, 3, 7, 3, 9, 7, 7, - 7, 7, 4, 6, 4, 7, 7, 9, 6, 6, 6, 5, 3, 5, 8, 0 - }; - static const uint16_t fontSmall_Offsets[] = { - 0, 2, 5, 11, 19, 26, 35, 42, - 45, 49, 53, 58, 65, 69, 73, 76, - 82, 89, 96, 103, 110, 117, 124, 131, - 138, 145, 152, 155, 159, 165, 172, 178, - 185, 197, 205, 212, 220, 228, 235, 242, - 250, 258, 261, 266, 274, 281, 290, 298, - 306, 314, 322, 330, 337, 344, 352, 360, - 372, 380, 388, 396, 400, 406, 410, 417, - 424, 428, 435, 442, 449, 456, 463, 467, - 474, 481, 484, 487, 494, 497, 506, 513, - 520, 527, 534, 538, 544, 548, 555, 562, - 571, 577, 583, 589, 594, 597, 602, 0 - }; - static const fontcolumn_t fontSmall_Data[] = { - /* */ 0x0000, 0x0000, - /* ! */ 0x0000, 0x017F, 0x017F, - /* " */ 0x0000, 0x0007, 0x0007, 0x0000, 0x0007, 0x0007, - /* # */ 0x0000, 0x0044, 0x01FF, 0x01FF, 0x0044, 0x01FF, 0x01FF, 0x0044, - /* $ */ 0x0000, 0x008C, 0x019E, 0x03FF, 0x03FF, 0x01E6, 0x00C4, - /* % */ 0x0000, 0x0082, 0x00C7, 0x0065, 0x00B7, 0x01DA, 0x014C, 0x01C6, 0x0082, - /* & */ 0x0000, 0x00E6, 0x01FF, 0x013F, 0x01E6, 0x01E0, 0x0120, - /* ' */ 0x0000, 0x0007, 0x0007, - /* ( */ 0x0000, 0x03FE, 0x07FF, 0x0401, - /* ) */ 0x0000, 0x0401, 0x07FF, 0x03FE, - /* * */ 0x0000, 0x000A, 0x000E, 0x000E, 0x000A, - /* + */ 0x0000, 0x0020, 0x0020, 0x00F8, 0x00F8, 0x0020, 0x0020, - /* , */ 0x0000, 0x0200, 0x0300, 0x0100, - /* - */ 0x0000, 0x0020, 0x0020, 0x0020, - /* . */ 0x0000, 0x0100, 0x0100, - /* / */ 0x0000, 0x0180, 0x01E0, 0x0078, 0x001F, 0x0007, - /* 0 */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x01FF, 0x00FE, - /* 1 */ 0x0000, 0x0002, 0x0002, 0x01FF, 0x01FF, 0x0000, 0x0000, - /* 2 */ 0x0000, 0x0182, 0x01C3, 0x0161, 0x0131, 0x011F, 0x010E, - /* 3 */ 0x0000, 0x0082, 0x0183, 0x0111, 0x0111, 0x01FF, 0x00EE, - /* 4 */ 0x0000, 0x0060, 0x0078, 0x005E, 0x01FF, 0x01FF, 0x0040, - /* 5 */ 0x0000, 0x009F, 0x019F, 0x0109, 0x0109, 0x01F9, 0x00F1, - /* 6 */ 0x0000, 0x00FE, 0x01FF, 0x0111, 0x0111, 0x01F3, 0x00E2, - /* 7 */ 0x0000, 0x0001, 0x01C1, 0x01F1, 0x003D, 0x000F, 0x0003, - /* 8 */ 0x0000, 0x00EE, 0x01FF, 0x0111, 0x0111, 0x01FF, 0x00EE, - /* 9 */ 0x0000, 0x008E, 0x019F, 0x0111, 0x0111, 0x01FF, 0x00FE, - /* : */ 0x0000, 0x0108, 0x0108, - /* ; */ 0x0000, 0x0200, 0x0308, 0x0108, - /* < */ 0x0000, 0x0020, 0x0070, 0x00D8, 0x018C, 0x0104, - /* = */ 0x0000, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, - /* > */ 0x0000, 0x0104, 0x018C, 0x00D8, 0x0070, 0x0020, - /* ? */ 0x0000, 0x0002, 0x0003, 0x0161, 0x0171, 0x001F, 0x000E, - /* @ */ 0x0000, 0x0078, 0x01FE, 0x0186, 0x0333, 0x0279, 0x0249, 0x0279, 0x027B, 0x0246, 0x007E, 0x0078, - /* A */ 0x0180, 0x01F0, 0x007C, 0x004F, 0x004F, 0x007C, 0x01F0, 0x0180, - /* B */ 0x0000, 0x01FF, 0x01FF, 0x0111, 0x0111, 0x01FF, 0x00EE, - /* C */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x0101, 0x0183, 0x0082, - /* D */ 0x0000, 0x01FF, 0x01FF, 0x0101, 0x0101, 0x0183, 0x00FE, 0x007C, - /* E */ 0x0000, 0x01FF, 0x01FF, 0x0111, 0x0111, 0x0111, 0x0101, - /* F */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x0001, - /* G */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0111, 0x0191, 0x01F3, 0x01F2, - /* H */ 0x0000, 0x01FF, 0x01FF, 0x0010, 0x0010, 0x0010, 0x01FF, 0x01FF, - /* I */ 0x0000, 0x01FF, 0x01FF, - /* J */ 0x00C0, 0x01C0, 0x0100, 0x01FF, 0x00FF, - /* K */ 0x0000, 0x01FF, 0x01FF, 0x003C, 0x0066, 0x00C3, 0x0181, 0x0100, - /* L */ 0x0000, 0x01FF, 0x01FF, 0x0100, 0x0100, 0x0100, 0x0100, - /* M */ 0x0000, 0x01FF, 0x01FF, 0x003C, 0x00F0, 0x00F0, 0x003C, 0x01FF, 0x01FF, - /* N */ 0x0000, 0x01FF, 0x01FF, 0x001E, 0x0038, 0x00E0, 0x01FF, 0x01FF, - /* O */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x0101, 0x01FF, 0x00FE, - /* P */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x001F, 0x000E, - /* Q */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0141, 0x01C1, 0x03FF, 0x02FE, - /* R */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x01FF, 0x01EE, - /* S */ 0x0000, 0x008E, 0x019F, 0x0111, 0x0111, 0x01F3, 0x00E2, - /* T */ 0x0000, 0x0001, 0x0001, 0x01FF, 0x01FF, 0x0001, 0x0001, - /* U */ 0x0000, 0x00FF, 0x01FF, 0x0100, 0x0100, 0x0100, 0x01FF, 0x00FF, - /* V */ 0x0003, 0x001F, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x001F, 0x0003, - /* W */ 0x0003, 0x001F, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x001F, 0x0003, - /* X */ 0x0183, 0x01C7, 0x006C, 0x0038, 0x0038, 0x006C, 0x01C7, 0x0183, - /* Y */ 0x0003, 0x0007, 0x000C, 0x01F8, 0x01F8, 0x000C, 0x0007, 0x0003, - /* Z */ 0x0181, 0x01C1, 0x0161, 0x0131, 0x0119, 0x010D, 0x0107, 0x0103, - /* [ */ 0x0000, 0x07FF, 0x07FF, 0x0401, - /* \ */ 0x0000, 0x0007, 0x001F, 0x0078, 0x01E0, 0x0180, - /* ] */ 0x0000, 0x0401, 0x07FF, 0x07FF, - /* ^ */ 0x0000, 0x0002, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002, - /* _ */ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, - /* ` */ 0x0000, 0x0001, 0x0003, 0x0002, - /* a */ 0x0000, 0x00C0, 0x01E8, 0x0128, 0x0128, 0x01F8, 0x01F0, - /* b */ 0x0000, 0x01FF, 0x01FF, 0x0108, 0x0108, 0x01F8, 0x00F0, - /* c */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x0198, 0x0090, - /* d */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01FF, 0x01FF, - /* e */ 0x0000, 0x00F0, 0x01F8, 0x0128, 0x0128, 0x01B8, 0x00B0, - /* f */ 0x0000, 0x01FE, 0x01FF, 0x0009, - /* g */ 0x0000, 0x04F0, 0x05F8, 0x0508, 0x0508, 0x07F8, 0x03F8, - /* h */ 0x0000, 0x01FF, 0x01FF, 0x0018, 0x0008, 0x01F8, 0x01F0, - /* i */ 0x0000, 0x01F9, 0x01F9, - /* j */ 0x0000, 0x07F9, 0x07F9, - /* k */ 0x0000, 0x01FF, 0x01FF, 0x0070, 0x00D8, 0x0188, 0x0100, - /* l */ 0x0000, 0x01FF, 0x01FF, - /* m */ 0x0000, 0x01F8, 0x01F8, 0x0008, 0x01F8, 0x01F8, 0x0008, 0x01F8, 0x01F0, - /* n */ 0x0000, 0x01F8, 0x01F8, 0x0018, 0x0008, 0x01F8, 0x01F0, - /* o */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01F8, 0x00F0, - /* p */ 0x0000, 0x07F8, 0x07F8, 0x0108, 0x0108, 0x01F8, 0x00F0, - /* q */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x07F8, 0x07F8, - /* r */ 0x0000, 0x01F8, 0x01F8, 0x0008, - /* s */ 0x0000, 0x0090, 0x01B8, 0x0168, 0x01D8, 0x0090, - /* t */ 0x0000, 0x00FE, 0x01FE, 0x0108, - /* u */ 0x0000, 0x00F8, 0x01F8, 0x0100, 0x0180, 0x01F8, 0x01F8, - /* v */ 0x0000, 0x0018, 0x0078, 0x01E0, 0x01E0, 0x0078, 0x0018, - /* w */ 0x0000, 0x0078, 0x01F8, 0x01E0, 0x0078, 0x0078, 0x01E0, 0x01F8, 0x0078, - /* x */ 0x0000, 0x0198, 0x01F8, 0x0060, 0x01F8, 0x0198, - /* y */ 0x0400, 0x0478, 0x07F8, 0x0380, 0x00F8, 0x0078, - /* z */ 0x0000, 0x0188, 0x01C8, 0x0168, 0x0138, 0x0118, - /* { */ 0x0000, 0x0010, 0x01FF, 0x03EF, 0x0200, - /* | */ 0x0000, 0x03FF, 0x03FF, - /* } */ 0x0000, 0x0200, 0x03EF, 0x01FF, 0x0010, - /* ~ */ 0x0000, 0x0004, 0x0006, 0x0002, 0x0006, 0x0004, 0x0006, 0x0002 - }; -#endif - -/* fontLarger - Tahoma, 11, Bold */ -#if 1 - /* Forward Declarations of internal arrays */ - static const uint8_t fontLarger_Widths[]; - static const uint16_t fontLarger_Offsets[]; - static const fontcolumn_t fontLarger_Data[]; - - const struct font fontLarger = { 12, 1, 13, 2, 2, 13, ' ', '~', 1, 1, - fontLarger_Widths, - fontLarger_Offsets, - fontLarger_Data}; - const struct font fontLargerDouble = { 12, 1, 13, 2, 2, 13, ' ', '~', 2, 2, - fontLarger_Widths, - fontLarger_Offsets, - fontLarger_Data}; - const struct font fontLargerNarrow = { 12, 1, 13, 2, 2, 13, ' ', '~', 1, 2, - fontLarger_Widths, - fontLarger_Offsets, - fontLarger_Data}; - static const uint8_t fontLarger_Widths[] = { - 2, 3, 5, 8, 7, 13, 8, 2, 4, 4, 7, 8, 3, 4, 3, 5, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 9, 8, 9, 6, - 9, 8, 7, 7, 8, 6, 5, 7, 8, 4, 5, 7, 6, 10, 7, 8, - 7, 8, 8, 7, 6, 7, 7, 11, 7, 6, 6, 4, 5, 4, 9, 8, - 5, 6, 7, 5, 7, 6, 5, 7, 7, 2, 3, 6, 2, 10, 7, 7, - 7, 7, 4, 5, 5, 7, 6, 10, 6, 6, 5, 6, 4, 6, 9, 0 - }; - static const uint16_t fontLarger_Offsets[] = { - 0, 2, 5, 10, 18, 25, 38, 46, - 48, 52, 56, 63, 71, 74, 78, 81, - 86, 93, 100, 107, 114, 121, 128, 135, - 142, 149, 156, 159, 162, 171, 179, 188, - 194, 203, 211, 218, 225, 233, 239, 244, - 251, 259, 263, 268, 275, 281, 291, 298, - 306, 313, 321, 329, 336, 342, 349, 356, - 367, 374, 380, 386, 390, 395, 399, 408, - 416, 421, 427, 434, 439, 446, 452, 457, - 464, 471, 473, 476, 482, 484, 494, 501, - 508, 515, 522, 526, 531, 536, 543, 549, - 559, 565, 571, 576, 582, 586, 592, 0 - }; - static const fontcolumn_t fontLarger_Data[] = { - /* */ 0x0000, 0x0000, - /* ! */ 0x0000, 0x037E, 0x037E, - /* " */ 0x0007, 0x0007, 0x0000, 0x0007, 0x0007, - /* # */ 0x00C0, 0x03D8, 0x00F8, 0x00DE, 0x03D8, 0x00F8, 0x00DE, 0x0018, - /* $ */ 0x0118, 0x023C, 0x0264, 0x0FFF, 0x0264, 0x03C4, 0x0188, - /* % */ 0x001C, 0x003E, 0x0022, 0x023E, 0x011C, 0x00C0, 0x0020, 0x0018, 0x01C4, 0x03E2, 0x0220, 0x03E0, - 0x01C0, - /* & */ 0x01CC, 0x03FE, 0x0232, 0x0272, 0x03DE, 0x018C, 0x03E0, 0x0260, - /* ' */ 0x0007, 0x0007, - /* ( */ 0x01F8, 0x07FE, 0x0E07, 0x0801, - /* ) */ 0x0801, 0x0E07, 0x07FE, 0x01F8, - /* * */ 0x0000, 0x000A, 0x0004, 0x001F, 0x001F, 0x0004, 0x000A, - /* + */ 0x0000, 0x0020, 0x0020, 0x0020, 0x01FC, 0x0020, 0x0020, 0x0020, - /* , */ 0x0000, 0x0F00, 0x0700, - /* - */ 0x0020, 0x0020, 0x0020, 0x0020, - /* . */ 0x0000, 0x0300, 0x0300, - /* / */ 0x0C00, 0x0380, 0x0060, 0x001C, 0x0003, - /* 0 */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x03FE, 0x01FC, - /* 1 */ 0x0000, 0x0204, 0x0204, 0x03FE, 0x03FE, 0x0200, 0x0200, - /* 2 */ 0x0204, 0x0302, 0x0382, 0x02C2, 0x0262, 0x023E, 0x021C, - /* 3 */ 0x0104, 0x0202, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC, - /* 4 */ 0x0060, 0x0050, 0x0048, 0x0044, 0x03FE, 0x03FE, 0x0040, - /* 5 */ 0x0100, 0x021E, 0x021E, 0x0212, 0x0212, 0x03F2, 0x01E2, - /* 6 */ 0x01F8, 0x03FC, 0x0216, 0x0212, 0x0212, 0x03F2, 0x01E0, - /* 7 */ 0x0002, 0x0002, 0x0382, 0x03E2, 0x007A, 0x001E, 0x0006, - /* 8 */ 0x01DC, 0x03FE, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC, - /* 9 */ 0x003C, 0x027E, 0x0242, 0x0242, 0x0342, 0x01FE, 0x00FC, - /* : */ 0x0000, 0x0318, 0x0318, - /* ; */ 0x0000, 0x0F18, 0x0718, - /* < */ 0x0000, 0x0060, 0x0060, 0x0090, 0x0090, 0x0108, 0x0108, 0x0204, 0x0204, - /* = */ 0x0000, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, - /* > */ 0x0000, 0x0204, 0x0204, 0x0108, 0x0108, 0x0090, 0x0090, 0x0060, 0x0060, - /* ? */ 0x0004, 0x0002, 0x0362, 0x0372, 0x001E, 0x000C, - /* @ */ 0x01F8, 0x0204, 0x04F2, 0x05FA, 0x050A, 0x04FA, 0x05FA, 0x0104, 0x00F8, - /* A */ 0x0380, 0x03F0, 0x00FC, 0x008E, 0x008E, 0x00FC, 0x03F0, 0x0380, - /* B */ 0x03FE, 0x03FE, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC, - /* C */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0202, 0x018C, - /* D */ 0x03FE, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0306, 0x01FC, 0x00F8, - /* E */ 0x03FE, 0x03FE, 0x0222, 0x0222, 0x0222, 0x0222, - /* F */ 0x03FE, 0x03FE, 0x0022, 0x0022, 0x0022, - /* G */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0222, 0x03E2, 0x03EC, - /* H */ 0x03FE, 0x03FE, 0x0020, 0x0020, 0x0020, 0x0020, 0x03FE, 0x03FE, - /* I */ 0x0202, 0x03FE, 0x03FE, 0x0202, - /* J */ 0x0200, 0x0202, 0x0202, 0x03FE, 0x01FE, - /* K */ 0x03FE, 0x03FE, 0x0070, 0x00D8, 0x018C, 0x0306, 0x0202, - /* L */ 0x03FE, 0x03FE, 0x0200, 0x0200, 0x0200, 0x0200, - /* M */ 0x03FE, 0x000E, 0x001C, 0x0038, 0x0070, 0x0030, 0x0018, 0x000C, 0x03FE, 0x03FE, - /* N */ 0x03FE, 0x000E, 0x001C, 0x0070, 0x01E0, 0x0380, 0x03FE, - /* O */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0202, 0x03FE, 0x01FC, - /* P */ 0x03FE, 0x03FE, 0x0042, 0x0042, 0x0042, 0x007E, 0x003C, - /* Q */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0602, 0x0E02, 0x0BFE, 0x09FC, - /* R */ 0x03FE, 0x03FE, 0x0022, 0x0062, 0x00E2, 0x01BE, 0x031C, 0x0200, - /* S */ 0x019C, 0x023E, 0x0222, 0x0222, 0x0222, 0x03E2, 0x01CC, - /* T */ 0x0002, 0x0002, 0x03FE, 0x03FE, 0x0002, 0x0002, - /* U */ 0x01FE, 0x03FE, 0x0200, 0x0200, 0x0200, 0x03FE, 0x01FE, - /* V */ 0x000E, 0x007E, 0x03F0, 0x0380, 0x03F0, 0x007E, 0x000E, - /* W */ 0x001E, 0x00FE, 0x03E0, 0x03E0, 0x00FC, 0x000E, 0x00FC, 0x03E0, 0x03E0, 0x00FE, 0x001E, - /* X */ 0x0306, 0x038E, 0x00F8, 0x0070, 0x00F8, 0x038E, 0x0306, - /* Y */ 0x000E, 0x003E, 0x03F0, 0x03F0, 0x003E, 0x000E, - /* Z */ 0x0382, 0x03C2, 0x0262, 0x0232, 0x021E, 0x020E, - /* [ */ 0x0FFF, 0x0FFF, 0x0801, 0x0801, - /* \ */ 0x0003, 0x001C, 0x0060, 0x0380, 0x0C00, - /* ] */ 0x0801, 0x0801, 0x0FFF, 0x0FFF, - /* ^ */ 0x0000, 0x0010, 0x0008, 0x0004, 0x0002, 0x0002, 0x0004, 0x0008, 0x0010, - /* _ */ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, - /* ` */ 0x0000, 0x0000, 0x0001, 0x0003, 0x0002, - /* a */ 0x0180, 0x03D0, 0x0248, 0x0248, 0x03F8, 0x03F0, - /* b */ 0x03FF, 0x03FF, 0x0210, 0x0208, 0x0208, 0x03F8, 0x01F0, - /* c */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0208, - /* d */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0108, 0x03FF, 0x03FF, - /* e */ 0x01F0, 0x03F8, 0x0248, 0x0248, 0x0278, 0x0170, - /* f */ 0x0008, 0x03FE, 0x03FF, 0x0009, 0x0001, - /* g */ 0x01F0, 0x0BF8, 0x0A08, 0x0A08, 0x0908, 0x0FF8, 0x07F8, - /* h */ 0x03FF, 0x03FF, 0x0010, 0x0008, 0x0008, 0x03F8, 0x03F0, - /* i */ 0x03FA, 0x03FA, - /* j */ 0x0808, 0x0FFA, 0x07FA, - /* k */ 0x03FF, 0x03FF, 0x00E0, 0x01B0, 0x0318, 0x0208, - /* l */ 0x03FF, 0x03FF, - /* m */ 0x03F8, 0x03F8, 0x0008, 0x0008, 0x03F8, 0x03F0, 0x0008, 0x0008, 0x03F8, 0x03F0, - /* n */ 0x03F8, 0x03F8, 0x0010, 0x0008, 0x0008, 0x03F8, 0x03F0, - /* o */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0208, 0x03F8, 0x01F0, - /* p */ 0x0FF8, 0x0FF8, 0x0210, 0x0208, 0x0208, 0x03F8, 0x01F0, - /* q */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0108, 0x0FF8, 0x0FF8, - /* r */ 0x03F8, 0x03F8, 0x0010, 0x0018, - /* s */ 0x0130, 0x0278, 0x0248, 0x03C8, 0x0190, - /* t */ 0x0008, 0x01FE, 0x03FE, 0x0208, 0x0208, - /* u */ 0x01F8, 0x03F8, 0x0200, 0x0200, 0x0100, 0x03F8, 0x03F8, - /* v */ 0x0038, 0x00F8, 0x03C0, 0x03C0, 0x00F8, 0x0038, - /* w */ 0x0018, 0x00F8, 0x03E0, 0x0380, 0x00F8, 0x00F8, 0x0380, 0x03E0, 0x00F8, 0x0018, - /* x */ 0x0318, 0x03B8, 0x00E0, 0x00E0, 0x03B8, 0x0318, - /* y */ 0x0038, 0x0CF8, 0x0FC0, 0x03C0, 0x00F8, 0x0038, - /* z */ 0x0388, 0x03C8, 0x0268, 0x0238, 0x0218, - /* { */ 0x0020, 0x0020, 0x07FE, 0x0FDF, 0x0801, 0x0801, - /* | */ 0x0000, 0x0000, 0x0FFF, 0x0FFF, - /* } */ 0x0801, 0x0801, 0x0FDF, 0x07FE, 0x0020, 0x0020, - /* ~ */ 0x00E0, 0x0030, 0x0030, 0x0030, 0x0060, 0x00C0, 0x00C0, 0x00C0, 0x0070 - }; -#endif - -/* fontUI1 - UI Font 1 Medium Bold */ -#if 1 - /* Forward Declarations of internal arrays */ - static const uint8_t fontUI1_Widths[]; - static const uint16_t fontUI1_Offsets[]; - static const fontcolumn_t fontUI1_Data[]; - - const struct font fontUI1 = { 13, 0, 15, 2, 3, 13, ' ', '~', 1, 1, - fontUI1_Widths, - fontUI1_Offsets, - fontUI1_Data}; - const struct font fontUI1Double = { 13, 0, 15, 2, 3, 13, ' ', '~', 2, 2, - fontUI1_Widths, - fontUI1_Offsets, - fontUI1_Data}; - const struct font fontUI1Narrow = { 13, 0, 15, 2, 3, 13, ' ', '~', 1, 2, - fontUI1_Widths, - fontUI1_Offsets, - fontUI1_Data}; - - static const uint8_t fontUI1_Widths[] = { - 3, 3, 6, 8, 7, 13, 9, 3, 5, 5, 6, 8, 3, 5, 3, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 8, 8, 8, 6, - 10, 8, 7, 7, 8, 7, 7, 8, 8, 5, 5, 7, 7, 9, 8, 8, - 7, 8, 8, 7, 8, 8, 7, 11, 7, 7, 7, 5, 7, 5, 9, 8, - 5, 7, 7, 6, 7, 7, 5, 7, 7, 3, 4, 7, 3, 11, 7, 7, - 7, 7, 6, 6, 5, 7, 7, 9, 7, 7, 6, 7, 4, 7, 8, 0 - }; - static const uint16_t fontUI1_Offsets[] = { - 0, 3, 6, 12, 20, 27, 40, 49, - 52, 57, 62, 68, 76, 79, 84, 87, - 94, 101, 108, 115, 122, 129, 136, 143, - 150, 157, 164, 167, 170, 178, 186, 194, - 200, 210, 218, 225, 232, 240, 247, 254, - 262, 270, 275, 280, 287, 294, 303, 311, - 319, 326, 334, 342, 349, 357, 365, 372, - 383, 390, 397, 404, 409, 416, 421, 430, - 438, 443, 450, 457, 463, 470, 477, 482, - 489, 496, 499, 503, 510, 513, 524, 531, - 538, 545, 552, 558, 564, 569, 576, 583, - 592, 599, 606, 612, 619, 623, 630, 0 - }; - static const fontcolumn_t fontUI1_Data[] = { - /* */ 0x0000, 0x0000, 0x0000, - /* ! */ 0x0000, 0x02FC, 0x02FC, - /* " */ 0x0000, 0x000E, 0x000E, 0x0000, 0x000E, 0x000E, - /* # */ 0x0000, 0x0080, 0x0390, 0x00F0, 0x039C, 0x00F0, 0x009C, 0x0010, - /* $ */ 0x0000, 0x0130, 0x0278, 0x0FC8, 0x027E, 0x03C8, 0x0190, - /* % */ 0x0000, 0x0038, 0x007C, 0x0044, 0x007C, 0x0338, 0x00C0, 0x0030, 0x01CC, 0x03E0, 0x0220, 0x03E0, - 0x01C0, - /* & */ 0x0000, 0x01D8, 0x03FC, 0x0224, 0x027C, 0x02D8, 0x0180, 0x0360, 0x0220, - /* ' */ 0x0000, 0x000E, 0x000E, - /* ( */ 0x0000, 0x01F0, 0x07FC, 0x0E0E, 0x0802, - /* ) */ 0x0000, 0x0802, 0x0E0E, 0x07FC, 0x01F0, - /* * */ 0x0000, 0x0014, 0x0008, 0x003E, 0x0008, 0x0014, - /* + */ 0x0000, 0x0040, 0x0040, 0x0040, 0x03F8, 0x0040, 0x0040, 0x0040, - /* , */ 0x0000, 0x0F00, 0x0700, - /* - */ 0x0000, 0x0040, 0x0040, 0x0040, 0x0040, - /* . */ 0x0000, 0x0300, 0x0300, - /* / */ 0x0000, 0x0C00, 0x0F00, 0x03E0, 0x00F8, 0x001E, 0x0006, - /* 0 */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x03FC, 0x01F8, - /* 1 */ 0x0000, 0x0000, 0x0208, 0x03FC, 0x03FC, 0x0200, 0x0000, - /* 2 */ 0x0000, 0x0308, 0x038C, 0x02C4, 0x0264, 0x023C, 0x0218, - /* 3 */ 0x0000, 0x0108, 0x030C, 0x0224, 0x0224, 0x03FC, 0x01D8, - /* 4 */ 0x0000, 0x00C0, 0x00A0, 0x0090, 0x03F8, 0x03FC, 0x0080, - /* 5 */ 0x0000, 0x0100, 0x033C, 0x023C, 0x0224, 0x03E4, 0x01C4, - /* 6 */ 0x0000, 0x01F0, 0x03F8, 0x022C, 0x0224, 0x03E4, 0x01C0, - /* 7 */ 0x0000, 0x0004, 0x0304, 0x03C4, 0x00F4, 0x003C, 0x000C, - /* 8 */ 0x0000, 0x01D8, 0x03FC, 0x0224, 0x0224, 0x03FC, 0x01D8, - /* 9 */ 0x0000, 0x0038, 0x027C, 0x0244, 0x0344, 0x01FC, 0x00F8, - /* : */ 0x0000, 0x0330, 0x0330, - /* ; */ 0x0000, 0x0F30, 0x0730, - /* < */ 0x0000, 0x0040, 0x00A0, 0x00A0, 0x0110, 0x0110, 0x0208, 0x0208, - /* = */ 0x0000, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, - /* > */ 0x0000, 0x0208, 0x0208, 0x0110, 0x0110, 0x00A0, 0x00A0, 0x0040, - /* ? */ 0x0000, 0x0008, 0x02C4, 0x02E4, 0x003C, 0x0018, - /* @ */ 0x0000, 0x01F0, 0x0208, 0x04E4, 0x05F4, 0x0514, 0x05F4, 0x05F4, 0x0104, 0x00F8, - /* A */ 0x0000, 0x0380, 0x03F0, 0x00FC, 0x008C, 0x00FC, 0x03F0, 0x0380, - /* B */ 0x0000, 0x03FC, 0x03FC, 0x0224, 0x0224, 0x03FC, 0x01D8, - /* C */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0204, 0x0108, - /* D */ 0x0000, 0x03FC, 0x03FC, 0x0204, 0x0204, 0x030C, 0x01F8, 0x00F0, - /* E */ 0x0000, 0x03FC, 0x03FC, 0x0224, 0x0224, 0x0224, 0x0224, - /* F */ 0x0000, 0x03FC, 0x03FC, 0x0024, 0x0024, 0x0024, 0x0024, - /* G */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0244, 0x03C4, 0x03C8, - /* H */ 0x0000, 0x03FC, 0x03FC, 0x0020, 0x0020, 0x0020, 0x03FC, 0x03FC, - /* I */ 0x0000, 0x0204, 0x03FC, 0x03FC, 0x0204, - /* J */ 0x0200, 0x0204, 0x0204, 0x03FC, 0x01FC, - /* K */ 0x0000, 0x03FC, 0x03FC, 0x00F0, 0x0198, 0x030C, 0x0204, - /* L */ 0x0000, 0x03FC, 0x03FC, 0x0200, 0x0200, 0x0200, 0x0200, - /* M */ 0x0000, 0x03FC, 0x001C, 0x0038, 0x0070, 0x0020, 0x0010, 0x03F8, 0x03FC, - /* N */ 0x0000, 0x03FC, 0x0018, 0x0030, 0x0060, 0x00C0, 0x0180, 0x03FC, - /* O */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0204, 0x03FC, 0x01F8, - /* P */ 0x0000, 0x03FC, 0x03FC, 0x0044, 0x0044, 0x007C, 0x0038, - /* Q */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0604, 0x0E04, 0x0BFC, 0x09F8, - /* R */ 0x0000, 0x03FC, 0x03FC, 0x0044, 0x00C4, 0x01FC, 0x0338, 0x0200, - /* S */ 0x0000, 0x0138, 0x027C, 0x0264, 0x0264, 0x03E4, 0x01C8, - /* T */ 0x0004, 0x0004, 0x0004, 0x03FC, 0x03FC, 0x0004, 0x0004, 0x0004, - /* U */ 0x0000, 0x01FC, 0x03FC, 0x0200, 0x0200, 0x0200, 0x03FC, 0x01FC, - /* V */ 0x0000, 0x001C, 0x00FC, 0x03E0, 0x03E0, 0x00FC, 0x001C, - /* W */ 0x0000, 0x001C, 0x00FC, 0x03E0, 0x03C0, 0x007C, 0x007C, 0x03C0, 0x03E0, 0x00FC, 0x001C, - /* X */ 0x0000, 0x030C, 0x039C, 0x00F0, 0x00F0, 0x039C, 0x030C, - /* Y */ 0x0000, 0x000C, 0x003C, 0x03F0, 0x03F0, 0x003C, 0x000C, - /* Z */ 0x0000, 0x0384, 0x03C4, 0x02E4, 0x0274, 0x023C, 0x021C, - /* [ */ 0x0000, 0x0FFE, 0x0FFE, 0x0802, 0x0802, - /* \ */ 0x0000, 0x0006, 0x001E, 0x00F8, 0x03E0, 0x0F00, 0x0C00, - /* ] */ 0x0000, 0x0802, 0x0802, 0x0FFE, 0x0FFE, - /* ^ */ 0x0000, 0x0020, 0x0030, 0x0018, 0x000C, 0x000C, 0x0018, 0x0030, 0x0020, - /* _ */ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, - /* ` */ 0x0000, 0x0000, 0x0002, 0x0006, 0x0004, - /* a */ 0x0000, 0x0180, 0x03D0, 0x0250, 0x0250, 0x03F0, 0x03E0, - /* b */ 0x0000, 0x03FE, 0x03FE, 0x0210, 0x0210, 0x03F0, 0x01E0, - /* c */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x0210, - /* d */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x03FE, 0x03FE, - /* e */ 0x0000, 0x01E0, 0x03F0, 0x0250, 0x0250, 0x0270, 0x0160, - /* f */ 0x0010, 0x03FC, 0x03FE, 0x0012, 0x0012, - /* g */ 0x0000, 0x01E0, 0x0BF0, 0x0A10, 0x0A10, 0x0FF0, 0x07F0, - /* h */ 0x0000, 0x03FE, 0x03FE, 0x0010, 0x0010, 0x03F0, 0x03E0, - /* i */ 0x0000, 0x03F4, 0x03F4, - /* j */ 0x0800, 0x0810, 0x0FF4, 0x07F4, - /* k */ 0x0000, 0x03FE, 0x03FE, 0x00C0, 0x01E0, 0x0330, 0x0210, - /* l */ 0x0000, 0x03FE, 0x03FE, - /* m */ 0x0000, 0x03F0, 0x03F0, 0x0010, 0x0010, 0x03F0, 0x03E0, 0x0010, 0x0010, 0x03F0, 0x03E0, - /* n */ 0x0000, 0x03F0, 0x03F0, 0x0010, 0x0010, 0x03F0, 0x03E0, - /* o */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x03F0, 0x01E0, - /* p */ 0x0000, 0x0FF0, 0x0FF0, 0x0210, 0x0210, 0x03F0, 0x01E0, - /* q */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x0FF0, 0x0FF0, - /* r */ 0x0000, 0x03F0, 0x03F0, 0x0020, 0x0030, 0x0030, - /* s */ 0x0000, 0x0260, 0x02F0, 0x02D0, 0x03D0, 0x0190, - /* t */ 0x0010, 0x01FC, 0x03FC, 0x0210, 0x0210, - /* u */ 0x0000, 0x01F0, 0x03F0, 0x0200, 0x0200, 0x03F0, 0x03F0, - /* v */ 0x0000, 0x0070, 0x01F0, 0x0380, 0x0380, 0x01F0, 0x0070, - /* w */ 0x0000, 0x00F0, 0x03F0, 0x0300, 0x00F0, 0x00F0, 0x0300, 0x03F0, 0x00F0, - /* x */ 0x0000, 0x0330, 0x03F0, 0x00C0, 0x00C0, 0x03F0, 0x0330, - /* y */ 0x0000, 0x0030, 0x0CF0, 0x0FC0, 0x03C0, 0x00F0, 0x0030, - /* z */ 0x0000, 0x0310, 0x0390, 0x02D0, 0x0270, 0x0230, - /* { */ 0x0000, 0x0040, 0x0040, 0x07FC, 0x0FBE, 0x0802, 0x0802, - /* | */ 0x0000, 0x0000, 0x0FFE, 0x0FFE, - /* } */ 0x0000, 0x0802, 0x0802, 0x0FBE, 0x07FC, 0x0040, 0x0040, - /* ~ */ 0x0000, 0x01C0, 0x0020, 0x0020, 0x00C0, 0x0100, 0x0100, 0x00E0 - }; -#endif - -/* fontUI1 - UI Font 2 Medium Bold */ -#if 1 - /* Forward Declarations of internal arrays */ - static const uint8_t fontUI2_Widths[]; - static const uint16_t fontUI2_Offsets[]; - static const fontcolumn_t fontUI2_Data[]; - - const struct font fontUI2 = { 11, 1, 13, 2, 2, 12, ' ', '~', 1, 1, - fontUI2_Widths, - fontUI2_Offsets, - fontUI2_Data}; - const struct font fontUI2Double = { 11, 1, 13, 2, 2, 12, ' ', '~', 2, 2, - fontUI2_Widths, - fontUI2_Offsets, - fontUI2_Data}; - const struct font fontUI2Narrow = { 11, 1, 13, 2, 2, 12, ' ', '~', 1, 2, - fontUI2_Widths, - fontUI2_Offsets, - fontUI2_Data}; - - static const uint8_t fontUI2_Widths[] = { - 2, 2, 5, 8, 6, 12, 8, 2, 4, 4, 6, 8, 2, 4, 2, 5, - 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 8, 8, 8, 5, - 9, 7, 6, 6, 7, 5, 5, 7, 7, 4, 5, 6, 5, 9, 6, 7, - 6, 7, 7, 6, 6, 7, 6, 10, 6, 6, 6, 4, 5, 4, 7, 7, - 4, 6, 6, 5, 6, 6, 4, 6, 6, 2, 3, 6, 2, 10, 6, 6, - 6, 6, 4, 5, 4, 6, 6, 8, 6, 6, 5, 6, 4, 6, 8, 0 - }; - static const uint16_t fontUI2_Offsets[] = { - 0, 2, 4, 9, 17, 23, 35, 43, - 45, 49, 53, 59, 67, 69, 73, 75, - 80, 86, 92, 98, 104, 110, 116, 122, - 128, 134, 140, 142, 144, 152, 160, 168, - 173, 182, 189, 195, 201, 208, 213, 218, - 225, 232, 236, 241, 247, 252, 261, 267, - 274, 280, 287, 294, 300, 306, 313, 319, - 329, 335, 341, 347, 351, 356, 360, 367, - 374, 378, 384, 390, 395, 401, 407, 411, - 417, 423, 425, 428, 434, 436, 446, 452, - 458, 464, 470, 474, 479, 483, 489, 495, - 503, 509, 515, 520, 526, 530, 536, 0 - }; - static const fontcolumn_t fontUI2_Data[] = { - /* */ 0x0000, 0x0000, - /* ! */ 0x017E, 0x017E, - /* " */ 0x0007, 0x0007, 0x0000, 0x0007, 0x0007, - /* # */ 0x00C0, 0x03D8, 0x00F8, 0x00DE, 0x03D8, 0x00F8, 0x00DE, 0x0018, - /* $ */ 0x0098, 0x013C, 0x07E4, 0x013F, 0x01E4, 0x00C8, - /* % */ 0x001C, 0x003E, 0x0022, 0x003E, 0x019C, 0x0060, 0x0018, 0x00E6, 0x01F0, 0x0110, 0x01F0, 0x00E0, - /* & */ 0x00EC, 0x01FE, 0x0112, 0x013E, 0x016C, 0x00C0, 0x01B0, 0x0110, - /* ' */ 0x0007, 0x0007, - /* ( */ 0x00F8, 0x03FE, 0x0707, 0x0401, - /* ) */ 0x0401, 0x0707, 0x03FE, 0x00F8, - /* * */ 0x000A, 0x0004, 0x001F, 0x001F, 0x0004, 0x000A, - /* + */ 0x0000, 0x0020, 0x0020, 0x0020, 0x01FC, 0x0020, 0x0020, 0x0020, - /* , */ 0x0780, 0x0380, - /* - */ 0x0020, 0x0020, 0x0020, 0x0020, - /* . */ 0x0180, 0x0180, - /* / */ 0x0600, 0x0180, 0x0070, 0x000C, 0x0003, - /* 0 */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x01FE, 0x00FC, - /* 1 */ 0x0000, 0x0104, 0x01FE, 0x01FE, 0x0100, 0x0000, - /* 2 */ 0x0184, 0x01C6, 0x0162, 0x0132, 0x011E, 0x010C, - /* 3 */ 0x0084, 0x0186, 0x0112, 0x0112, 0x01FE, 0x00EC, - /* 4 */ 0x0060, 0x0050, 0x0048, 0x01FC, 0x01FE, 0x0040, - /* 5 */ 0x0080, 0x019E, 0x011E, 0x0112, 0x01F2, 0x00E2, - /* 6 */ 0x00FC, 0x01FE, 0x0112, 0x0112, 0x01F2, 0x00E0, - /* 7 */ 0x0002, 0x0002, 0x01C2, 0x01FA, 0x003E, 0x0006, - /* 8 */ 0x00EC, 0x01FE, 0x0112, 0x0112, 0x01FE, 0x00EC, - /* 9 */ 0x001C, 0x013E, 0x0122, 0x0122, 0x01FE, 0x00FC, - /* : */ 0x0198, 0x0198, - /* ; */ 0x0798, 0x0398, - /* < */ 0x0000, 0x0020, 0x0050, 0x0050, 0x0088, 0x0088, 0x0104, 0x0104, - /* = */ 0x0000, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, - /* > */ 0x0000, 0x0104, 0x0104, 0x0088, 0x0088, 0x0050, 0x0050, 0x0020, - /* ? */ 0x0004, 0x0162, 0x0172, 0x001E, 0x000C, - /* @ */ 0x00F8, 0x0104, 0x0272, 0x02FA, 0x028A, 0x027A, 0x02FA, 0x0084, 0x0078, - /* A */ 0x01C0, 0x01F8, 0x007E, 0x0046, 0x007E, 0x01F8, 0x01C0, - /* B */ 0x01FE, 0x01FE, 0x0112, 0x0112, 0x01FE, 0x00EC, - /* C */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0102, 0x0102, - /* D */ 0x01FE, 0x01FE, 0x0102, 0x0102, 0x0186, 0x00FC, 0x0078, - /* E */ 0x01FE, 0x01FE, 0x0112, 0x0112, 0x0112, - /* F */ 0x01FE, 0x01FE, 0x0012, 0x0012, 0x0012, - /* G */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0122, 0x01E2, 0x01E2, - /* H */ 0x01FE, 0x01FE, 0x0010, 0x0010, 0x0010, 0x01FE, 0x01FE, - /* I */ 0x0102, 0x01FE, 0x01FE, 0x0102, - /* J */ 0x0100, 0x0102, 0x0102, 0x01FE, 0x00FE, - /* K */ 0x01FE, 0x01FE, 0x0078, 0x00CC, 0x0186, 0x0102, - /* L */ 0x01FE, 0x01FE, 0x0100, 0x0100, 0x0100, - /* M */ 0x01FE, 0x000E, 0x001C, 0x0038, 0x0030, 0x0018, 0x000C, 0x01FE, 0x01FE, - /* N */ 0x01FE, 0x000E, 0x001C, 0x0038, 0x0070, 0x01FE, - /* O */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0102, 0x01FE, 0x00FC, - /* P */ 0x01FE, 0x01FE, 0x0022, 0x0022, 0x003E, 0x001C, - /* Q */ 0x00FC, 0x01FE, 0x0102, 0x0302, 0x0702, 0x05FE, 0x04FC, - /* R */ 0x01FE, 0x01FE, 0x0022, 0x0062, 0x00FE, 0x019C, 0x0100, - /* S */ 0x011C, 0x013E, 0x0132, 0x0132, 0x01F2, 0x00E2, - /* T */ 0x0002, 0x0002, 0x01FE, 0x01FE, 0x0002, 0x0002, - /* U */ 0x00FE, 0x01FE, 0x0100, 0x0100, 0x0100, 0x01FE, 0x00FE, - /* V */ 0x000E, 0x007E, 0x01F0, 0x01F0, 0x007E, 0x000E, - /* W */ 0x000E, 0x007E, 0x01F0, 0x01E0, 0x003E, 0x003E, 0x01E0, 0x01F0, 0x007E, 0x000E, - /* X */ 0x0186, 0x01CE, 0x0078, 0x0078, 0x01CE, 0x0186, - /* Y */ 0x0006, 0x001E, 0x01F8, 0x01F8, 0x001E, 0x0006, - /* Z */ 0x01C2, 0x01E2, 0x0172, 0x013A, 0x011E, 0x010E, - /* [ */ 0x07FF, 0x07FF, 0x0401, 0x0401, - /* \ */ 0x0003, 0x000C, 0x0070, 0x0180, 0x0600, - /* ] */ 0x0401, 0x0401, 0x07FF, 0x07FF, - /* ^ */ 0x0010, 0x0008, 0x0004, 0x0002, 0x0004, 0x0008, 0x0010, - /* _ */ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, - /* ` */ 0x0000, 0x0001, 0x0003, 0x0002, - /* a */ 0x00C0, 0x01E8, 0x0128, 0x0128, 0x01F8, 0x01F0, - /* b */ 0x01FF, 0x01FF, 0x0108, 0x0108, 0x01F8, 0x00F0, - /* c */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x0108, - /* d */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01FF, 0x01FF, - /* e */ 0x00F0, 0x01F8, 0x0128, 0x0128, 0x0138, 0x0130, - /* f */ 0x01FE, 0x01FF, 0x0009, 0x0001, - /* g */ 0x00F0, 0x05F8, 0x0508, 0x0508, 0x07F8, 0x03F8, - /* h */ 0x01FF, 0x01FF, 0x0008, 0x0008, 0x01F8, 0x01F0, - /* i */ 0x01FA, 0x01FA, - /* j */ 0x0408, 0x07FA, 0x03FA, - /* k */ 0x01FF, 0x01FF, 0x0060, 0x00F0, 0x0198, 0x0108, - /* l */ 0x01FF, 0x01FF, - /* m */ 0x01F8, 0x01F8, 0x0008, 0x0008, 0x01F8, 0x01F0, 0x0008, 0x0008, 0x01F8, 0x01F0, - /* n */ 0x01F8, 0x01F8, 0x0008, 0x0008, 0x01F8, 0x01F0, - /* o */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01F8, 0x00F0, - /* p */ 0x07F8, 0x07F8, 0x0108, 0x0108, 0x01F8, 0x00F0, - /* q */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x07F8, 0x07F8, - /* r */ 0x01F8, 0x01F8, 0x0010, 0x0018, - /* s */ 0x0130, 0x0178, 0x0168, 0x01E8, 0x00C8, - /* t */ 0x00FE, 0x01FE, 0x0108, 0x0108, - /* u */ 0x00F8, 0x01F8, 0x0100, 0x0100, 0x01F8, 0x01F8, - /* v */ 0x0018, 0x0078, 0x01E0, 0x01E0, 0x0078, 0x0018, - /* w */ 0x0078, 0x01F8, 0x01C0, 0x0078, 0x0078, 0x01C0, 0x01F8, 0x0078, - /* x */ 0x0198, 0x01F8, 0x0060, 0x0060, 0x01F8, 0x0198, - /* y */ 0x0018, 0x0678, 0x07E0, 0x01E0, 0x0078, 0x0018, - /* z */ 0x0188, 0x01C8, 0x0168, 0x0138, 0x0118, - /* { */ 0x0020, 0x0020, 0x03FE, 0x07DF, 0x0401, 0x0401, - /* | */ 0x0000, 0x0000, 0x07FF, 0x07FF, - /* } */ 0x0401, 0x0401, 0x07DF, 0x03FE, 0x0020, 0x0020, - /* ~ */ 0x0060, 0x0010, 0x0010, 0x0030, 0x0060, 0x0040, 0x0040, 0x0030 - }; -#endif - -/* - fontLargeNumbers: - Large numbers font, height = 16 (including the decenders) - Characters include: 0 - 9, -, +, ., %, :, Space, Comma -*/ -#if 1 - /* Forward Declarations of internal arrays */ - static const uint8_t fontLargeNumbers_Widths[]; - static const uint16_t fontLargeNumbers_Offsets[]; - static const fontcolumn_t fontLargeNumbers_Data[]; - - const struct font fontLargeNumbers = { 16, 2, 21, 1, 3, 15, '%', ':', 1, 1, - fontLargeNumbers_Widths, - fontLargeNumbers_Offsets, - fontLargeNumbers_Data}; - const struct font fontLargeNumbersDouble = { 16, 2, 21, 1, 3, 15, '%', ':', 2, 2, - fontLargeNumbers_Widths, - fontLargeNumbers_Offsets, - fontLargeNumbers_Data}; - const struct font fontLargeNumbersNarrow = { 16, 2, 21, 1, 3, 15, '%', ':', 1, 2, - fontLargeNumbers_Widths, - fontLargeNumbers_Offsets, - fontLargeNumbers_Data}; - - static const uint8_t fontLargeNumbers_Widths[] = { - 15, 0, 0, 0, 0, 0, 11, 3, 6, 3, 0, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 4, 0, 0 - }; - static const uint16_t fontLargeNumbers_Offsets[] = { - 0, 0, 0, 0, 0, 0, 15, 26, - 29, 35, 0, 38, 48, 58, 68, 78, - 88, 98, 108, 118, 128, 138, 0, 0 - }; - static const fontcolumn_t fontLargeNumbers_Data[] = { - /* % */ 0x007E, 0x00FF, 0x00C3, 0x80C3, 0xE0FF, 0x7C7E, 0x1F00, 0x07C0, 0x00F0, 0x7E3E, 0xFF0F, 0xC303, - 0xC300, 0xFF00, 0x7E00, - /* + */ 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x1FFC, 0x1FFC, 0x1FFC, 0x01C0, 0x01C0, 0x01C0, 0x01C0, - /* , */ 0x7000, 0x7000, 0xF000, - /* - */ 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, - /* . */ 0x7000, 0x7000, 0x7000, - /* 0 */ 0x0FF8, 0x3FFE, 0x3FFE, 0x7007, 0x6003, 0x6003, 0x7007, 0x3FFE, 0x3FFE, 0x0FF8, - /* 1 */ 0x0000, 0x0070, 0x0038, 0x0038, 0x001C, 0x7FFF, 0x7FFF, 0x7FFF, 0x0000, 0x0000, - /* 2 */ 0x600C, 0x700E, 0x7C0F, 0x7E07, 0x6F03, 0x6783, 0x63C7, 0x61FF, 0x60FE, 0x603C, - /* 3 */ 0x180C, 0x380E, 0x780F, 0x70C3, 0x60C3, 0x60E3, 0x71FF, 0x3FFE, 0x3F3C, 0x0E00, - /* 4 */ 0x0F00, 0x0DC0, 0x0CE0, 0x0C38, 0x0C1E, 0x7FFF, 0x7FFF, 0x7FFF, 0x0C00, 0x0C00, - /* 5 */ 0x18C0, 0x38FC, 0x78FF, 0x707F, 0x6063, 0x6063, 0x70E3, 0x3FE3, 0x3FC3, 0x0F80, - /* 6 */ 0x0FF8, 0x3FFE, 0x3FFE, 0x70C7, 0x6063, 0x6063, 0x70E7, 0x3FEF, 0x3FC6, 0x0F04, - /* 7 */ 0x0003, 0x0003, 0x7803, 0x7F03, 0x7FC3, 0x07F3, 0x00FB, 0x003F, 0x000F, 0x0007, - /* 8 */ 0x1E1C, 0x3F3E, 0x7FFF, 0x71E7, 0x60C3, 0x60C3, 0x71E7, 0x7FFF, 0x3F3E, 0x1E1C, - /* 9 */ 0x1078, 0x39FE, 0x7BFE, 0x7387, 0x6303, 0x6303, 0x7187, 0x3FFE, 0x3FFE, 0x0FF8, - /* : */ 0x0000, 0x0E38, 0x0E38, 0x0E38 - }; -#endif - -#endif /* GDISP_NEED_TEXT */ - -#endif /* HAL_USE_GDISP */ diff --git a/halext/src/touchpad.c b/halext/src/touchpad.c deleted file mode 100644 index 977bb31c..00000000 --- a/halext/src/touchpad.c +++ /dev/null @@ -1,261 +0,0 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpad.c - * @brief Touchpad Driver code. - * - * @addgroup TOUCHPAD - * @{ - */ -#include "ch.h" -#include "hal.h" -#include "gdisp.h" -#include "touchpad.h" - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ -volatile static struct cal cal = { - 1, 1, 0, 0 -}; - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/** - * @brief returns the uncalibrated readout of the X direction from the controller - * - * @noapi - */ -static uint16_t _tpReadRealX(void) { - uint32_t results = 0; - uint16_t i, x; - - for(i = 0; i < CONVERSIONS; i++) { - tp_lld_read_x(); /* dummy, reduce noise on SPI */ - results += tp_lld_read_x(); - } - - // 12-bit - x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048); - - return x; -} - -/** - * @brief return the uncalibrated readout of the Y-direction from the controller - * - * @noapi - */ -static uint16_t _tpReadRealY(void) { - uint32_t results = 0; - uint16_t i, y; - - for(i = 0; i < CONVERSIONS; i++) { - tp_lld_read_y(); /* dummy, reduce noise on SPI */ - results += tp_lld_read_y(); - } - - // 12-bit - y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048); - - return y; -} - -/** - * @brief draws a cross. Used for calibration. - * - * @noapi - */ -static void _tpDrawCross(uint16_t x, uint16_t y) { - gdispDrawLine(x-15, y, x-2, y, 0xffff); - gdispDrawLine(x+2, y, x+15, y, 0xffff); - gdispDrawLine(x, y-15, x, y-2, 0xffff); - gdispDrawLine(x, y+2, x, y+15, 0xffff); - - gdispDrawLine(x-15, y+15, x-7, y+15, RGB565CONVERT(184,158,131)); - gdispDrawLine(x-15, y+7, x-15, y+15, RGB565CONVERT(184,158,131)); - - gdispDrawLine(x-15, y-15, x-7, y-15, RGB565CONVERT(184,158,131)); - gdispDrawLine(x-15, y-7, x-15, y-15, RGB565CONVERT(184,158,131)); - - gdispDrawLine(x+7, y+15, x+15, y+15, RGB565CONVERT(184,158,131)); - gdispDrawLine(x+15, y+7, x+15, y+15, RGB565CONVERT(184,158,131)); - - gdispDrawLine(x+7, y-15, x+15, y-15, RGB565CONVERT(184,158,131)); - gdispDrawLine(x+15, y-15, x+15, y-7, RGB565CONVERT(184,158,131)); -} - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/** - * @brief Touchpad Driver initialization. - * @note This function is NOT currently implicitly invoked by @p halInit(). - * It must be called manually. - * - * @api - */ -void tpInit(TOUCHPADDriver *tp) { - /* Initialise Mutex */ - //MUTEX_INIT - - /* Initialise driver */ - //MUTEX_ENTER - tp_lld_init(tp); - //MUTEX_EXIT -} - -/** - * @brief Get the X-Coordinate, relative to screen zero point. - * - * @return The X position in pixels. - * - * @api - */ -uint16_t tpReadX(void) { - uint16_t x, y; - - x = cal.xm * _tpReadRealX() + cal.xn; - y = cal.ym * _tpReadRealY() + cal.yn; - - /* - switch(gdispGetOrientation()) { // implement gdispGetOrientation() - case portrait: - return x; - case landscape: - return SCREEN_HEIGHT - y; - case portraitInv: - return SCREEN_WIDTH - x; - case landscapeInv: - return y; - } - */ - - return x; -} - -/** - * @brief Get the X-Coordinate, relative to screen zero point. - * - * @return The Y position in pixels. - * - * @api - */ -uint16_t tpReadY(void) { - uint16_t x, y; - - x = cal.xm * _tpReadRealX() + cal.xn; - y = cal.ym * _tpReadRealY() + cal.yn; - - /* - switch(gdispGetOrientation()) { // implement gdispGetOrientation() - case portrait: - return y; - case landscape: - return x; - case portraitInv: - return SCREEN_HEIGHT - y; - case landscapeInv: - return SCREEN_WIDTH - x; - } - */ - - return y; -} - -void tpCalibrate(void) { - uint16_t cross[2][2] = {{40,50}, {200, 280}}; - uint16_t points[2][2]; - uint8_t i; - - //gdispSetOrientation(portrait); - gdispClear(Red); - gdispFillStringBox(0, 10, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Red, justifyCenter); - - for(i = 0; i < 2; i++) { - _tpDrawCross(cross[i][0], cross[i][1]); - while(!tpIRQ()); - points[i][0] = _tpReadRealX(); - points[i][1] = _tpReadRealY(); - chThdSleepMilliseconds(100); - while(tpIRQ()); - gdispFillArea(cross[i][0]-15, cross[i][1]-15, 42, 42, Red); - } - - cal.xm = ((float)cross[1][0] - (float)cross[0][0]) / ((float)points[1][0] - (float)points[0][0]); - cal.ym = ((float)cross[1][1] - (float)cross[0][1]) / ((float)points[1][1] - (float)points[0][1]); - - cal.xn = (float)cross[0][0] - cal.xm * (float)points[0][0]; - cal.yn = (float)cross[0][1] - cal.ym * (float)points[0][1]; -} - -#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) - /** - * @brief returns if touchpad is pressed or not - * - * @return 1 if pressed, 0 otherwise - * - * @api - */ - uint8_t tpIRQ(void) { - return tp_lld_irq(); - } -#endif - -#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) - /** - * @brief Get the pressure. - * - * @return The pressure. - * - * @api - */ - uint16_t tpReadZ(void) { - /* ToDo */ - return (tp_lld_read_z()); - } -#endif - -#endif /* HAL_USE_TOUCHPAD */ -/** @} */ - diff --git a/halext/templates/gdispXXXXX/gdisp_lld.c b/halext/templates/gdispXXXXX/gdisp_lld.c deleted file mode 100644 index 81e96894..00000000 --- a/halext/templates/gdispXXXXX/gdisp_lld.c +++ /dev/null @@ -1,490 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file templates/gdisp_lld.c - * @brief GDISP Graphics Driver subsystem low level driver source template. - * - * @addtogroup GDISP - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "gdisp.h" - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/* Include the emulation code for things we don't support */ -#include "gdisp_emulation.c" - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -#if GDISP_NEED_TEXT - #include "gdisp_fonts.h" -#endif - -/* All the board specific code should go in these include file so the driver - * can be ported to another board just by creating a suitable file. - */ -#if defined(BOARD_YOURBOARDNAME) - #include "gdisp_lld_board_yourboardname.h" -#else - /* Include the user supplied board definitions */ - #include "gdisp_lld_board.h" -#endif - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ -/* - The following 2 routines are required. - All other routines are optional. -*/ - -/** - * @brief Low level GDISP driver initialisation. - * @return TRUE if successful, FALSE on error. - * - * @notapi - */ -bool_t GDISP_LLD(init)(void) { - /* Initialise your display */ - - /* Initialise the GDISP structure to match */ - GDISP.Width = SCREEN_WIDTH; - GDISP.Height = SCREEN_HEIGHT; - GDISP.Orientation = portrait; - GDISP.Powermode = powerOn; - GDISP.Backlight = 100; - GDISP.Contrast = 50; - return TRUE; -} - -/** - * @brief Draws a pixel on the display. - * - * @param[in] x X location of the pixel - * @param[in] y Y location of the pixel - * @param[in] color The color of the pixel - * - * @notapi - */ -void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return; - #endif - /* Code here */ -} - -/* ---- Optional Routines ---- */ -/* - All the below routines are optional. - Defining them will increase speed but everything - will work if they are not defined. - If you are not using a routine - turn it off using - the appropriate GDISP_HARDWARE_XXXX macro. - Don't bother coding for obvious similar routines if - there is no performance penalty as the emulation software - makes a good job of using similar routines. - eg. If fillarea() is defined there is little - point in defining clear() unless the - performance bonus is significant. - For good performance it is suggested to implement - fillarea() and blitarea(). -*/ - -#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) - /** - * @brief Clear the display. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] color The color of the pixel - * - * @notapi - */ - void GDISP_LLD(clear)(color_t color) { - /* Code here */ - } -#endif - -#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) - /** - * @brief Draw a line. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x0, y0 The start of the line - * @param[in] x1, y1 The end of the line - * @param[in] color The color of the line - * - * @notapi - */ - void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { - #if GDISP_NEED_VALIDATION - /* Need to clip to screen */ - #endif - /* Code here */ - } -#endif - -#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a color. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] color The color of the fill - * - * @notapi - */ - void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - /* Code here */ - } -#endif - -#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) - /** - * @brief Fill an area with a bitmap. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The start filled area - * @param[in] cx, cy The width and height to be filled - * @param[in] buffer The pixels to use to fill the area. - * - * @notapi - */ - void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) return; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - /* Code here */ - } -#endif - -/* Circular Drawing Functions */ -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) - /** - * @brief Draw a circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled circle. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the circle is over the edges of the screen. - * - * @param[in] x, y The centre of the circle - * @param[in] radius The radius of the circle - * @param[in] color The color of the circle - * - * @notapi - */ - void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) - /** - * @brief Draw an ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) - /** - * @brief Create a filled ellipse. - * @note Optional - The high level driver can emulate using software. - * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave - * correctly if the ellipse is over the edges of the screen. - * - * @param[in] x, y The centre of the ellipse - * @param[in] a, b The dimensions of the ellipse - * @param[in] color The color of the ellipse - * - * @notapi - */ - void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a transparent background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * - * @notapi - */ - void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) - /** - * @brief Draw a character using a filled background. - * @note Optional - The high level driver can emulate using software. - * - * @param[in] x, y The top-left corner of the text - * @param[in] c The character to print - * @param[in] color The color of the character - * @param[in] bgcolor The background color - * - * @notapi - */ - void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { - #if GDISP_NEED_VALIDATION - /* Code here */ - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) - /** - * @brief Get the color of a particular pixel. - * @note Optional. - * @note If x,y is off the screen, the result is undefined. - * @return The color of the specified pixel. - * - * @param[in] x, y The start of the text - * - * @notapi - */ - color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { - #if GDISP_NEED_VALIDATION - if (x >= GDISP.Width || y >= GDISP.Height) return 0; - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) - /** - * @brief Scroll vertically a section of the screen. - * @note Optional. - * @note If x,y + cx,cy is off the screen, the result is undefined. - * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. - * - * @param[in] x, y The start of the area to be scrolled - * @param[in] cx, cy The size of the area to be scrolled - * @param[in] lines The number of lines to scroll (Can be positive or negative) - * @param[in] bgcolor The color to fill the newly exposed area. - * - * @notapi - */ - void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { - #if GDISP_NEED_VALIDATION - if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; - if (x+cx > GDISP.Width) cx = GDISP.Width - x; - if (y+cy > GDISP.Height) cy = GDISP.Height - y; - #endif - /* Code here */ - } -#endif - -#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) - /** - * @brief Driver Control - * @detail Unsupported control codes are ignored. - * @note The value parameter should always be typecast to (void *). - * @note There are some predefined and some specific to the low level driver. - * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t - * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t - * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver - * that only supports off/on anything other - * than zero is on. - * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. - * GDISP_CONTROL_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to do. - * @param[in] value The value to use (always cast to a void *). - * - * @notapi - */ - void GDISP_LLD(control)(unsigned what, void *value) { - switch(what) { - case GDISP_CONTROL_POWER: - if (GDISP.Powermode == (gdisp_powermode_t)value) - return; - switch((gdisp_powermode_t)value) { - case powerOff: - /* Code here */ - break; - case powerOn: - /* Code here */ - /* You may need this --- - if (GDISP.Powermode != powerSleep) - GDISP_LLD(init)(); - */ - break; - case powerSleep: - /* Code here */ - break; - default: - return; - } - GDISP.Powermode = (gdisp_powermode_t)value; - return; - case GDISP_CONTROL_ORIENTATION: - if (GDISP.Orientation == (gdisp_orientation_t)value) - return; - switch((gdisp_orientation_t)value) { - case portrait: - /* Code here */ - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscape: - /* Code here */ - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - case portraitInv: - /* Code here */ - GDISP.Height = SCREEN_HEIGHT; - GDISP.Width = SCREEN_WIDTH; - break; - case landscapeInv: - /* Code here */ - GDISP.Height = SCREEN_WIDTH; - GDISP.Width = SCREEN_HEIGHT; - break; - default: - return; - } - GDISP.Orientation = (gdisp_orientation_t)value; - return; -/* - case GDISP_CONTROL_BACKLIGHT: - case GDISP_CONTROL_CONTRAST: -*/ - } - } -#endif - -#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) -/** - * @brief Query a driver value. - * @detail Typecase the result to the type you want. - * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen - * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen - * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode - * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation - * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) - * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). - * GDISP_QUERY_LLD - Low level driver control constants start at - * this value. - * - * @param[in] what What to Query - * - * @notapi - */ -void *GDISP_LLD(query)(unsigned what) { - switch(what) { - case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; - case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; - case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; - case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; - case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; - case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; - case GDISP_QUERY_LLD+0: - /* Code here */ - default: return (void *)-1; - } -} -#endif - -#endif /* HAL_USE_GDISP */ -/** @} */ diff --git a/halext/templates/gdispXXXXX/gdisp_lld.mk b/halext/templates/gdispXXXXX/gdisp_lld.mk deleted file mode 100644 index d0933492..00000000 --- a/halext/templates/gdispXXXXX/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE/gdisp_lld.c - -# Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE diff --git a/halext/templates/gdispXXXXX/gdisp_lld_config.h b/halext/templates/gdispXXXXX/gdisp_lld_config.h deleted file mode 100644 index 81a6826f..00000000 --- a/halext/templates/gdispXXXXX/gdisp_lld_config.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file templates/gdisp_lld_config.h - * @brief GDISP Graphic Driver subsystem low level driver header template. - * - * @addtogroup GDISP - * @{ - */ - -#ifndef _GDISP_LLD_CONFIG_H -#define _GDISP_LLD_CONFIG_H - -#if HAL_USE_GDISP || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver hardware support. */ -/*===========================================================================*/ - -#define GDISP_DRIVER_NAME "YourDriverName" -#define GDISP_LLD(x) gdisp_lld_##x##_YourDriverName - -#define GDISP_HARDWARE_LINES FALSE -#define GDISP_HARDWARE_CLEARS FALSE -#define GDISP_HARDWARE_FILLS FALSE -#define GDISP_HARDWARE_BITFILLS FALSE -#define GDISP_HARDWARE_CIRCLES FALSE -#define GDISP_HARDWARE_CIRCLEFILLS FALSE -#define GDISP_HARDWARE_ELLIPSES FALSE -#define GDISP_HARDWARE_ELLIPSEFILLS FALSE -#define GDISP_HARDWARE_TEXT FALSE -#define GDISP_HARDWARE_TEXTFILLS FALSE -#define GDISP_HARDWARE_SCROLL FALSE -#define GDISP_HARDWARE_PIXELREAD FALSE -#define GDISP_HARDWARE_CONTROL FALSE -#define GDISP_HARDWARE_QUERY FALSE - -#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE -#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE - -#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 -#define GDISP_PACKED_PIXELS FALSE -#define GDISP_PACKED_LINES FALSE - -#endif /* HAL_USE_GDISP */ - -#endif /* _GDISP_LLD_CONFIG_H */ -/** @} */ diff --git a/halext/templates/gdispXXXXX/readme.txt b/halext/templates/gdispXXXXX/readme.txt deleted file mode 100644 index bdb66006..00000000 --- a/halext/templates/gdispXXXXX/readme.txt +++ /dev/null @@ -1,35 +0,0 @@ -To use this driver template - 1. Copy this entire directory (including the directory itself) - into halext/drivers - 2. Rename the directory to match your hardware. - 3. Customise each file in the directory including the .mk file - and this file. An example for this file is below... - 4. Keep any board specific code in a file you create called - gdisp_lld_board_yourboardname.h and adjust gdisp.c to match. - This enables someone porting to a new board to add another - suitable boad definition without worrying about the rest of - the driver. See the gdispNokia6610 driver as an example. - ------------------------------------------------------------------- -To use this driver: - -1. Add in your halconf.h: - a) #define HAL_USE_GDISP TRUE - b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD - c) One (only) of: - #define LCD_USE_GPIO - #define LCD_USE_SPI - #define LCD_USE_FSMC - d) All of the following (with appropriate values): - #define SCREEN_WIDTH 128 - #define SCREEN_HEIGHT 128 - e) If you are not using a known board then create a gdisp_lld_board.h file - and ensure it is on your include path. - Use the gdisp_lld_board_example.h file as a basis. - Currently known boards are: - XXXXXXXXX - - -2. To your makefile add the following lines: - include $(CHIBIOS)/os/halext/halext.mk - include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk diff --git a/halext/templates/readme.txt b/halext/templates/readme.txt deleted file mode 100644 index a2c5b7ef..00000000 --- a/halext/templates/readme.txt +++ /dev/null @@ -1,4 +0,0 @@ -The following low level driver templates are available: - -GDISP: - gdispXXXXX - Generalised GDISP driver diff --git a/lcd.mk b/lcd.mk index 47120a13..802873b5 100644 --- a/lcd.mk +++ b/lcd.mk @@ -3,29 +3,8 @@ ifeq ($(LCDLIB),) LCDLIB = $(CHIBIOS)/ext/lcd endif +LCDSRC += $(LCDLIB)/src/gdisp.c \ + $(LCDLIB)/src/gdisp_fonts.c \ + $(LCDLIB)/src/touchpad.c -include $(LCDLIB)/halext/halext.mk - - - -# this is used for the old structure - will get removed soon - -#include $(LCDLIB)/drivers/drivers.mk -#include $(LCDLIB)/glcd/glcd.mk -#include $(LCDLIB)/touchpad/touchpad.mk -#include $(LCDLIB)/graph/graph.mk -#include $(LCDLIB)/gui/gui.mk - -#LCDSRC = $(LCD_DRIVERS_SRC) \ -# $(LCD_GLCD_SRC) \ -# $(LCD_TOUCHPAD_SRC) \ -# $(LCD_GRAPH_SRC) \ -# $(LCD_GUI_SRC) - -#LCDINC = $(LCDLIB) \ -# $(LCD_DRIVERS_INC) \ -# $(LCD_GLCD_INC) \ -# $(LCD_TOUCHPAD_INC) \ -# $(LCD_GRAPH_INC) \ -# $(LCD_GUI_INC) - +LCDINC += $(LCDLIB)/include diff --git a/readme b/readme deleted file mode 100644 index 0b67c9b0..00000000 --- a/readme +++ /dev/null @@ -1,19 +0,0 @@ -## Doxygen -run doxygen in the toplevel directory to generate the doxygen documentation in html - - - -## Wiki -please read the wiki pages to this project carefully, before you ask any questions: - -http://chibios.org/dokuwiki/doku.php?id=chibios:community - - - -## Maintainer & Contributors -please read the contributors.txt file which contains a full history of each contribution - -Maintainer: - - Joel Bodenmann aka Tectu - - diff --git a/touchpad/touchpad.c b/touchpad/touchpad.c deleted file mode 100644 index 1ef54190..00000000 --- a/touchpad/touchpad.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - ChibiOS/RT - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#include "touchpad.h" -#include "glcd.h" - -volatile static struct cal cal = { - 1, 1, 0, 0 -}; - -static const SPIConfig spicfg = { - NULL, - TP_CS_PORT, - TP_CS, - SPI_CR1_SPE | SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0, -}; - -void tpInit(SPIDriver *spip) { - spiStart(spip, &spicfg); -} - -uint8_t tpIRQ(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); -} - -static uint16_t tpReadRealX(void) { - uint32_t results = 0; - uint16_t i, x; - - for(i=0; i - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -#ifndef TOUCHPAD_H -#define TOUCHPAD_H - -#include "ch.h" -#include "hal.h" -#include "glcd.h" -#include "glcdconf.h" -#include "ads7843_lld.h" -#include "xpt2046_lld.h" - -#define CONVERSIONS 3 - -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - -struct cal { - float xm; - float ym; - float xn; - float yn; -}; - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * Description: initializes touchpad (SPI) - * - * param: SPI driver - * - * return: none - */ -void tpInit(SPIDriver *spip); - -/* - * Description: reads out PEN_IRQ from touchpad controller - * - * param: none - * - * return: 1 = touchpad pressed / 0 = touchpad not pressed - */ -uint8_t tpIRQ(void); - -/* - * Description: reads-out X coordinate, calibrated - * - * param: none - * - * return: X coordinate, relative to screen zero-point - */ -uint16_t tpReadX(void); - -/* - * Description: reads-out Y coordinate, calibrated - * - * param: none - * - * return: Y coordinate, relative to screen zero-point - */ -uint16_t tpReadY(void); - -/* - * Description: reads-out Z value / pressure - * only available when controller supports, returns - * zero otherwise. - * - * param: none - * - * return: pressure on the touchpad - */ -uint16_t tpReadZ(void); - -/* - * Description: calibration routine - * - * param: none - * - * return: none - */ -void tpCalibrate(void); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/touchpad/touchpad.mk b/touchpad/touchpad.mk deleted file mode 100644 index de27ae0d..00000000 --- a/touchpad/touchpad.mk +++ /dev/null @@ -1,3 +0,0 @@ -LCD_TOUCHPAD_SRC = $(LCDLIB)/touchpad/touchpad.c - -LCD_TOUCHPAD_INC = $(LCDLIB)/touchpad From e27d04d002a40f3b514eeeb60d374df6a8a1280c Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 04:12:42 +0200 Subject: [PATCH 15/47] restructure --- drivers/gdisp/gdispNokia6610/GE12.h | 81 ++ drivers/gdisp/gdispNokia6610/GE8.h | 67 ++ drivers/gdisp/gdispNokia6610/gdisp_lld.c | 688 ++++++++++++ drivers/gdisp/gdispNokia6610/gdisp_lld.mk | 5 + .../gdispNokia6610/gdisp_lld_board_example.h | 97 ++ .../gdisp_lld_board_olimexsam7ex256.h | 199 ++++ .../gdisp/gdispNokia6610/gdisp_lld_config.h | 66 ++ drivers/gdisp/gdispNokia6610/readme.txt | 17 + drivers/gdisp/gdispS6d1121/gdisp_lld.c | 688 ++++++++++++ drivers/gdisp/gdispS6d1121/gdisp_lld.mk | 5 + drivers/gdisp/gdispS6d1121/gdisp_lld_config.h | 66 ++ drivers/gdisp/gdispS6d1121/readme.txt | 16 + drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h | 244 +++++ drivers/gdisp/gdispSsd1289/gdisp_lld.c | 610 +++++++++++ drivers/gdisp/gdispSsd1289/gdisp_lld.mk | 5 + drivers/gdisp/gdispSsd1289/gdisp_lld_config.h | 66 ++ drivers/gdisp/gdispSsd1289/readme.txt | 16 + drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h | 322 ++++++ drivers/gdisp/gdispTestStub/gdisp_lld.c | 361 +++++++ drivers/gdisp/gdispTestStub/gdisp_lld.mk | 5 + .../gdisp/gdispTestStub/gdisp_lld_config.h | 66 ++ drivers/gdisp/gdispTestStub/readme.txt | 17 + drivers/gdisp/gdispVMT/gdisp_lld.c | 249 +++++ drivers/gdisp/gdispVMT/gdisp_lld.mk | 7 + drivers/gdisp/gdispVMT/gdisp_lld_config.h | 67 ++ drivers/gdisp/gdispVMT/gdisp_lld_driver1.c | 51 + drivers/gdisp/gdispVMT/gdisp_lld_driver2.c | 51 + drivers/gdisp/gdispVMT/readme.txt | 23 + drivers/touchpad/touchpadADS7843/readme.txt | 9 + .../touchpad/touchpadADS7843/touchpad_lld.c | 146 +++ .../touchpad/touchpadADS7843/touchpad_lld.mk | 6 + .../touchpadADS7843/touchpad_lld_config.h | 44 + drivers/touchpad/touchpadXPT2046/readme.txt | 9 + .../touchpad/touchpadXPT2046/touchpad_lld.c | 158 +++ .../touchpad/touchpadXPT2046/touchpad_lld.mk | 6 + .../touchpadXPT2046/touchpad_lld_config.h | 44 + include/gdisp.h | 266 +++++ include/gdisp_emulation.c | 549 ++++++++++ include/gdisp_fonts.h | 90 ++ include/gdisp_lld.h | 599 +++++++++++ include/gdisp_lld_msgs.h | 165 +++ include/glcd.h | 136 +++ include/touchpad.h | 93 ++ include/touchpad_lld.h | 106 ++ old/console.c | 171 +++ old/console.h | 84 ++ old/graph/graph.c | 75 ++ old/graph/graph.h | 72 ++ old/graph/graph.mk | 3 + old/gui/gui.c | 334 ++++++ old/gui/gui.h | 115 ++ old/gui/gui.mk | 3 + readme1.txt | 28 + readme2.txt | 19 + src/gdisp-readme.txt | 14 + src/gdisp.c | 997 ++++++++++++++++++ src/gdisp_fonts.c | 655 ++++++++++++ src/touchpad.c | 261 +++++ templates/gdispXXXXX/gdisp_lld.c | 490 +++++++++ templates/gdispXXXXX/gdisp_lld.mk | 5 + templates/gdispXXXXX/gdisp_lld_config.h | 66 ++ templates/gdispXXXXX/readme.txt | 35 + templates/readme.txt | 4 + 63 files changed, 10012 insertions(+) create mode 100644 drivers/gdisp/gdispNokia6610/GE12.h create mode 100644 drivers/gdisp/gdispNokia6610/GE8.h create mode 100644 drivers/gdisp/gdispNokia6610/gdisp_lld.c create mode 100644 drivers/gdisp/gdispNokia6610/gdisp_lld.mk create mode 100644 drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h create mode 100644 drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h create mode 100644 drivers/gdisp/gdispNokia6610/gdisp_lld_config.h create mode 100644 drivers/gdisp/gdispNokia6610/readme.txt create mode 100644 drivers/gdisp/gdispS6d1121/gdisp_lld.c create mode 100644 drivers/gdisp/gdispS6d1121/gdisp_lld.mk create mode 100644 drivers/gdisp/gdispS6d1121/gdisp_lld_config.h create mode 100644 drivers/gdisp/gdispS6d1121/readme.txt create mode 100644 drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h create mode 100644 drivers/gdisp/gdispSsd1289/gdisp_lld.c create mode 100644 drivers/gdisp/gdispSsd1289/gdisp_lld.mk create mode 100644 drivers/gdisp/gdispSsd1289/gdisp_lld_config.h create mode 100644 drivers/gdisp/gdispSsd1289/readme.txt create mode 100644 drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h create mode 100644 drivers/gdisp/gdispTestStub/gdisp_lld.c create mode 100644 drivers/gdisp/gdispTestStub/gdisp_lld.mk create mode 100644 drivers/gdisp/gdispTestStub/gdisp_lld_config.h create mode 100644 drivers/gdisp/gdispTestStub/readme.txt create mode 100644 drivers/gdisp/gdispVMT/gdisp_lld.c create mode 100644 drivers/gdisp/gdispVMT/gdisp_lld.mk create mode 100644 drivers/gdisp/gdispVMT/gdisp_lld_config.h create mode 100644 drivers/gdisp/gdispVMT/gdisp_lld_driver1.c create mode 100644 drivers/gdisp/gdispVMT/gdisp_lld_driver2.c create mode 100644 drivers/gdisp/gdispVMT/readme.txt create mode 100644 drivers/touchpad/touchpadADS7843/readme.txt create mode 100644 drivers/touchpad/touchpadADS7843/touchpad_lld.c create mode 100644 drivers/touchpad/touchpadADS7843/touchpad_lld.mk create mode 100644 drivers/touchpad/touchpadADS7843/touchpad_lld_config.h create mode 100644 drivers/touchpad/touchpadXPT2046/readme.txt create mode 100644 drivers/touchpad/touchpadXPT2046/touchpad_lld.c create mode 100644 drivers/touchpad/touchpadXPT2046/touchpad_lld.mk create mode 100644 drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h create mode 100644 include/gdisp.h create mode 100644 include/gdisp_emulation.c create mode 100644 include/gdisp_fonts.h create mode 100644 include/gdisp_lld.h create mode 100644 include/gdisp_lld_msgs.h create mode 100644 include/glcd.h create mode 100644 include/touchpad.h create mode 100644 include/touchpad_lld.h create mode 100644 old/console.c create mode 100644 old/console.h create mode 100644 old/graph/graph.c create mode 100644 old/graph/graph.h create mode 100644 old/graph/graph.mk create mode 100644 old/gui/gui.c create mode 100644 old/gui/gui.h create mode 100644 old/gui/gui.mk create mode 100644 readme1.txt create mode 100644 readme2.txt create mode 100644 src/gdisp-readme.txt create mode 100644 src/gdisp.c create mode 100644 src/gdisp_fonts.c create mode 100644 src/touchpad.c create mode 100644 templates/gdispXXXXX/gdisp_lld.c create mode 100644 templates/gdispXXXXX/gdisp_lld.mk create mode 100644 templates/gdispXXXXX/gdisp_lld_config.h create mode 100644 templates/gdispXXXXX/readme.txt create mode 100644 templates/readme.txt diff --git a/drivers/gdisp/gdispNokia6610/GE12.h b/drivers/gdisp/gdispNokia6610/GE12.h new file mode 100644 index 00000000..7f438d9a --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/GE12.h @@ -0,0 +1,81 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GE12_H +#define GE12_H + +// ************************************************************************************* +// LCD Include File for Philips PCF8833 STN RGB- 132x132x3 Driver (GE12) +// +// Taken from Philips data sheet Feb 14, 2003 +// ************************************************************************************* + +// Philips PCF8833 LCD controller command codes +#define NOP 0x00 // nop +#define SWRESET 0x01 // software reset +#define BSTROFF 0x02 // booster voltage OFF +#define BSTRON 0x03 // booster voltage ON +#define RDDIDIF 0x04 // read display identification +#define RDDST 0x09 // read display status +#define SLEEPIN 0x10 // sleep in +#define SLEEPOUT 0x11 // sleep out +#define PTLON 0x12 // partial display mode +#define NORON 0x13 // display normal mode +#define INVOFF 0x20 // inversion OFF +#define INVON 0x21 // inversion ON +#define DALO 0x22 // all pixel OFF +#define DAL 0x23 // all pixel ON +#define SETCON 0x25 // write contrast +#define DISPOFF 0x28 // display OFF +#define DISPON 0x29 // display ON +#define CASET 0x2A // column address set +#define PASET 0x2B // page address set +#define RAMWR 0x2C // memory write +#define RGBSET 0x2D // colour set +#define PTLAR 0x30 // partial area +#define VSCRDEF 0x33 // vertical scrolling definition +#define TEOFF 0x34 // test mode +#define TEON 0x35 // test mode +#define MADCTL 0x36 // memory access control +#define SEP 0x37 // vertical scrolling start address +#define IDMOFF 0x38 // idle mode OFF +#define IDMON 0x39 // idle mode ON +#define COLMOD 0x3A // interface pixel format +#define SETVOP 0xB0 // set Vop +#define BRS 0xB4 // bottom row swap +#define TRS 0xB6 // top row swap +#define DISCTR 0xB9 // display control +#define DOR 0xBA // data order +#define TCDFE 0xBD // enable/disable DF temperature compensation +#define TCVOPE 0xBF // enable/disable Vop temp comp +#define EC 0xC0 // internal or external oscillator +#define SETMUL 0xC2 // set multiplication factor +#define TCVOPAB 0xC3 // set TCVOP slopes A and B +#define TCVOPCD 0xC4 // set TCVOP slopes c and d +#define TCDF 0xC5 // set divider frequency +#define DF8COLOR 0xC6 // set divider frequency 8-color mode +#define SETBS 0xC7 // set bias system +#define RDTEMP 0xC8 // temperature read back +#define NLI 0xC9 // n-line inversion +#define RDID1 0xDA // read ID1 +#define RDID2 0xDB // read ID2 +#define RDID3 0xDC // read ID3 + +#endif /* GE12_H */ diff --git a/drivers/gdisp/gdispNokia6610/GE8.h b/drivers/gdisp/gdispNokia6610/GE8.h new file mode 100644 index 00000000..3ae0be77 --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/GE8.h @@ -0,0 +1,67 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GE8_H +#define GE8_H + +// ***************************************************************************** +// Include file for Epson S1D15G00 LCD Controller (GE8) +// +// Author: James P Lynch August 30, 2007 +// Modified for GDISP: Andrew Hannam August 2, 2012 +// +// ***************************************************************************** + +#define DISON 0xAF // Display on +#define DISOFF 0xAE // Display off +#define DISNOR 0xA6 // Normal display +#define DISINV 0xA7 // Inverse display +#define COMSCN 0xBB // Common scan direction +#define DISCTL 0xCA // Display control +#define SLPIN 0x95 // Sleep in +#define SLPOUT 0x94 // Sleep out +#define PASET 0x75 // Page address set +#define CASET 0x15 // Column address set +#define DATCTL 0xBC // Data scan direction, etc. +#define RGBSET8 0xCE // 256-color position set +#define RAMWR 0x5C // Writing to memory +#define RAMRD 0x5D // Reading from memory +#define PTLIN 0xA8 // Partial display in +#define PTLOUT 0xA9 // Partial display out +#define RMWIN 0xE0 // Read and modify write +#define RMWOUT 0xEE // End +#define ASCSET 0xAA // Area scroll set +#define SCSTART 0xAB // Scroll start set +#define OSCON 0xD1 // Internal oscillation on +#define OSCOFF 0xD2 // Internal oscillation off +#define PWRCTR 0x20 // Power control +#define VOLCTR 0x81 // Electronic volume control +#define VOLUP 0xD6 // Increment electronic control by 1 +#define VOLDOWN 0xD7 // Decrement electronic control by 1 +#define TMPGRD 0x82 // Temperature gradient set +#define EPCTIN 0xCD // Control EEPROM +#define EPCOUT 0xCC // Cancel EEPROM control +#define EPMWR 0xFC // Write into EEPROM +#define EPMRD 0xFD // Read from EEPROM +#define EPSRRD1 0x7C // Read register 1 +#define EPSRRD2 0x7D // Read register 2 +#define NOP 0x25 // NOP instruction + +#endif /* GE8_H */ diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld.c b/drivers/gdisp/gdispNokia6610/gdisp_lld.c new file mode 100644 index 00000000..5ebe2177 --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/gdisp_lld.c @@ -0,0 +1,688 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispNokia6610/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the Nokia6610 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/* Include the emulation code for things we don't support */ +#include "gdisp_emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/* Controller definitions */ +#if defined(LCD_USE_GE8) + #include "GE8.h" +#elif defined(LCD_USE_GE12) + #include "GE12.h" +#else + #error "gdispNokia6610: Either LCD_USE_GE8 or LCD_USE_GE12 must be defined depending on your controller" +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#include "gdisp_fonts.h" + +#if defined(BOARD_OLIMEX_SAM7_EX256) + #include "gdisp_lld_board_olimexsam7ex256.h" +#else + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#endif + +#define gdisp_lld_write_command(cmd) GDISP_LLD(write_spi)((cmd) & ~0x0100) +#define gdisp_lld_write_data(data) GDISP_LLD(write_spi)((data) | 0x0100) + +static __inline void gdisp_lld_setviewport(coord_t x, coord_t y, coord_t cx, coord_t cy) { + gdisp_lld_write_command(CASET); // Column address set + gdisp_lld_write_data(x); + gdisp_lld_write_data(x+cx-1); + gdisp_lld_write_command(PASET); // Page address set + gdisp_lld_write_data(y); + gdisp_lld_write_data(y+cy-1); +} + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t GDISP_LLD(init)(void) { + /* Initialise your display */ + GDISP_LLD(init_board)(); + + // Hardware reset + GDISP_LLD(setpin_reset)(TRUE); + chThdSleepMilliseconds(20); + GDISP_LLD(setpin_reset)(FALSE); + chThdSleepMilliseconds(20); + + #if defined(LCD_USE_GE8) + #if 1 + gdisp_lld_write_command(DISCTL); // Display control + gdisp_lld_write_data(0x00); // P1: 0x00 = 2 divisions, switching period=8 (default) + gdisp_lld_write_data(0x20); // P2: 0x20 = nlines/4 - 1 = 132/4 - 1 = 32) + gdisp_lld_write_data(0x00); // P3: 0x00 = no inversely highlighted lines + gdisp_lld_write_command(COMSCN); // COM scan + gdisp_lld_write_data(1); // P1: 0x01 = Scan 1->80, 160<-81 + gdisp_lld_write_command(OSCON); // Internal oscilator ON + gdisp_lld_write_command(SLPOUT); // Sleep out + gdisp_lld_write_command(PWRCTR); // Power control + gdisp_lld_write_data(0x0f); // reference voltage regulator on, circuit voltage follower on, BOOST ON + // Interesting - all the code seems to say this should be done. But my display doesn't want it! + //gdisp_lld_write_command(DISINV); // Inverse display + gdisp_lld_write_command(DATCTL); // Data control + gdisp_lld_write_data(0x01); // P1: 0x01 = page address inverted, column address normal, address scan in column direction + gdisp_lld_write_data(0x00); // P2: 0x00 = RGB sequence (default value) + gdisp_lld_write_data(0x02); // P3: 0x02 = Grayscale -> 16 (selects 12-bit color, type A) + gdisp_lld_write_command(VOLCTR); // Voltage control (contrast setting) + gdisp_lld_write_data(32); // P1 = 32 volume value (experiment with this value to get the best contrast) + gdisp_lld_write_data(3); // P2 = 3 resistance ratio (only value that works) + chThdSleepMilliseconds(100); // allow power supply to stabilize + gdisp_lld_write_command(DISON); // Turn on the display + #else + // Alternative + gdisp_lld_write_command(DISCTL); // Display control + gdisp_lld_write_data(0x00); // default + gdisp_lld_write_data(0x20); // (32 + 1) * 4 = 132 lines (of which 130 are visible) + gdisp_lld_write_data(0x0a); // default + gdisp_lld_write_command(COMSCN); // COM scan + gdisp_lld_write_data(0x00); // Scan 1-80 + gdisp_lld_write_command(OSCON); // Internal oscilator ON + chThdSleepMilliseconds(100); // wait aproximetly 100ms + gdisp_lld_write_command(SLPOUT); // Sleep out + gdisp_lld_write_command(VOLCTR); // Voltage control + gdisp_lld_write_data(0x1F); // middle value of V1 + gdisp_lld_write_data(0x03); // middle value of resistance value + gdisp_lld_write_command(TMPGRD); // Temperature gradient + gdisp_lld_write_data(0x00); // default + gdisp_lld_write_command(PWRCTR); // Power control + gdisp_lld_write_data(0x0f); // referance voltage regulator on, circuit voltage follower on, BOOST ON + gdisp_lld_write_command(DISNOR); // Normal display + gdisp_lld_write_command(DISINV); // Inverse display + gdisp_lld_write_command(PTLOUT); // Partial area off + // gdisp_lld_write_command(ASCSET); // Scroll area set + // gdisp_lld_write_data(0); + // gdisp_lld_write_data(0); + // gdisp_lld_write_data(40); + // gdisp_lld_write_data(3); + // gdisp_lld_write_command(SCSTART); // Vertical scrool address start + // gdisp_lld_write_data(0); + gdisp_lld_write_command(DATCTL); // Data control + gdisp_lld_write_data(0x00); // all inversions off, column direction + gdisp_lld_write_data(0x03); // RGB sequence + gdisp_lld_write_data(0x02); // Grayscale -> 16 + gdisp_lld_write_command(PASET); // Page Address set + gdisp_lld_write_data(0); + gdisp_lld_write_data(131); + gdisp_lld_write_command(CASET); // Page Column set + gdisp_lld_write_data(0); + gdisp_lld_write_data(131); + gdisp_lld_write_command(DISON); // Turn on the display + #endif + + #elif defined(LCD_USE_GE12) + #if 1 + gdisp_lld_write_command(SLEEPOUT); // Sleep out + gdisp_lld_write_command(INVON); // Inversion on: seems to be required for this controller + gdisp_lld_write_command(COLMOD); // Color Interface Pixel Format + gdisp_lld_write_data(0x03); // 0x03 = 12 bits-per-pixel + gdisp_lld_write_command(MADCTL); // Memory access controler + gdisp_lld_write_data(0xC8); // 0xC0 = mirror x and y, reverse rgb + gdisp_lld_write_command(SETCON); // Write contrast + gdisp_lld_write_data(0x30); // contrast - experiental value + chThdSleepMilliseconds(20); + gdisp_lld_write_command(DISPON); // Display On + #else + // Alternative + // Hardware reset commented out + gdisp_lld_write_command(SOFTRST); // Software Reset + chThdSleepMilliseconds(20); + gdisp_lld_write_command(INITESC); // Initial escape + chThdSleepMilliseconds(20); + gdisp_lld_write_command(REFSET); // Refresh set + gdisp_lld_write_data(0); + gdisp_lld_write_command(DISPCTRL); // Set Display control + gdisp_lld_write_data(128); // Set the lenght of one selection term + gdisp_lld_write_data(128); // Set N inversion -> no N inversion + gdisp_lld_write_data(134); // Set frame frequence and bias rate -> 2 devision of frequency and 1/8 bias, 1/67 duty, 96x67 size + gdisp_lld_write_data(84); // Set duty parameter + gdisp_lld_write_data(69); // Set duty parameter + gdisp_lld_write_data(82); // Set duty parameter + gdisp_lld_write_data(67); // Set duty parameter + gdisp_lld_write_command(GRAYSCALE0); // Grey scale 0 position set - 15 parameters + gdisp_lld_write_data(1); // GCP1 - gray lavel to be output when the RAM data is "0001" + gdisp_lld_write_data(2); // GCP2 - gray lavel to be output when the RAM data is "0010" + gdisp_lld_write_data(4); // GCP3 - gray lavel to be output when the RAM data is "0011" + gdisp_lld_write_data(8); // GCP4 - gray lavel to be output when the RAM data is "0100" + gdisp_lld_write_data(16); // GCP5 - gray lavel to be output when the RAM data is "0101" + gdisp_lld_write_data(30); // GCP6 - gray lavel to be output when the RAM data is "0110" + gdisp_lld_write_data(40); // GCP7 - gray lavel to be output when the RAM data is "0111" + gdisp_lld_write_data(50); // GCP8 - gray lavel to be output when the RAM data is "1000" + gdisp_lld_write_data(60); // GCP9 - gray lavel to be output when the RAM data is "1001" + gdisp_lld_write_data(70); // GCP10 - gray lavel to be output when the RAM data is "1010" + gdisp_lld_write_data(80); // GCP11 - gray lavel to be output when the RAM data is "1011" + gdisp_lld_write_data(90); // GCP12 - gray lavel to be output when the RAM data is "1100" + gdisp_lld_write_data(100); // GCP13 - gray lavel to be output when the RAM data is "1101" + gdisp_lld_write_data(110); // GCP14 - gray lavel to be output when the RAM data is "1110" + gdisp_lld_write_data(127); // GCP15 - gray lavel to be output when the RAM data is "1111" + gdisp_lld_write_command(GAMMA); // Gamma curve set - select gray scale - GRAYSCALE 0 or GREYSCALE 1 + gdisp_lld_write_data(1); // Select grey scale 0 + gdisp_lld_write_command(COMMONDRV); // Command driver output + gdisp_lld_write_data(0); // Set COM1-COM41 side come first, normal mod + gdisp_lld_write_command(NORMALMODE); // Set Normal mode (my) + // gdisp_lld_write_command(INVERSIONOFF); // Inversion off + gdisp_lld_write_command(COLADDRSET); // Column address set + gdisp_lld_write_data(0); + gdisp_lld_write_data(131); + gdisp_lld_write_command(PAGEADDRSET); // Page address set + gdisp_lld_write_data(0); + gdisp_lld_write_data(131); + gdisp_lld_write_command(ACCESSCTRL); // Memory access controler + gdisp_lld_write_data(0x40); // horizontal + //gdisp_lld_write_data(0x20); // vertical + gdisp_lld_write_command(PWRCTRL); // Power control + gdisp_lld_write_data(4); // Internal resistance, V1OUT -> high power mode, oscilator devision rate + gdisp_lld_write_command(SLEEPOUT); // Sleep out + gdisp_lld_write_command(VOLTCTRL); // Voltage control - voltage control and write contrast define LCD electronic volume + //gdisp_lld_write_data(0x7f); // full voltage control + //gdisp_lld_write_data(0x03); // must be "1" + gdisp_lld_write_command(CONTRAST); // Write contrast + gdisp_lld_write_data(0x3b); // contrast + chThdSleepMilliseconds(20); + gdisp_lld_write_command(TEMPGRADIENT); // Temperature gradient + for(i=0; i<14; i++) gdisp_lld_write_data(0); + gdisp_lld_write_command(BOOSTVON); // Booster voltage ON + gdisp_lld_write_command(DISPLAYON); // Finally - Display On + #endif + #endif + + /* Turn on the back-light */ + GDISP_LLD(setpin_backlight)(TRUE); + + /* Initialise the GDISP structure to match */ + GDISP.Width = 132; + GDISP.Height = 132; + GDISP.Orientation = portrait; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return; + #endif + gdisp_lld_setviewport(x, y, 1, 1); + gdisp_lld_write_command(RAMWR); + gdisp_lld_write_data((color >> 4) & 0xFF); + gdisp_lld_write_data((color << 4) & 0xF0); + gdisp_lld_write_command(NOP); +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If fillarea() is defined there is little + point in defining clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + fillarea() and blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void GDISP_LLD(clear(color_t color) { + /* NOT IMPLEMENTED */ + /* Nothing to be gained by implementing this + * as fillarea is just as fast. + */ + } +#endif + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + unsigned i, tuples; + + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + tuples = (cx*cy+1)/2; // With an odd sized area we over-print by one pixel. + // This extra pixel is ignored by the controller. + + gdisp_lld_setviewport(x, y, cx, cy); + gdisp_lld_write_command(RAMWR); + for(i=0; i < tuples; i++) { + gdisp_lld_write_data((color >> 4) & 0xFF); + gdisp_lld_write_data(((color << 4) & 0xF0)|((color >> 8) & 0x0F)); + gdisp_lld_write_data(color & 0xFF); + } + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + unsigned i, area, tuples; + #ifndef GDISP_PACKED_PIXELS + color_t c1, c2; + #endif + + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) return; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + area = cx*cy; + + gdisp_lld_setviewport(x, y, cx, cy); + gdisp_lld_write_command(RAMWR); + + #ifdef GDISP_PACKED_PIXELS + // 3 bytes per 2 pixels + an extra 2 bytes if the total size is odd. + // Note we can't just over-estimate this and let the controller handle the extra pixel + // as that might over-run our source buffer (very bad in some circumstances). + tuples = (area/2)*3+(area & 0x01)*2; + for(i=0; i < tuples; i++) + gdisp_lld_write_data(*buffer++); + if (area & 0x01) + gdisp_lld_write_command(NOP); + #else + // Although this controller uses packed pixels we support unpacked pixel + // formats in this blit by packing the data as we feed it to the controller. + tuples = area/2; + for(i=0; i < tuples; i++) { + c1 = *buffer++; + c2 = *buffer++; + gdisp_lld_write_data((c1 >> 4) & 0xFF); + gdisp_lld_write_data(((c1 << 4) & 0xF0)|((c2 >> 8) & 0x0F)); + gdisp_lld_write_data(c2 & 0xFF); + } + if (area & 0x01) { + c1 = *buffer++; + gdisp_lld_write_data((c1 >> 4) & 0xFF); + gdisp_lld_write_data((c1 << 4) & 0xF0); + gdisp_lld_write_command(NOP); + } + #endif + } +#endif + +/* Circular Drawing Functions */ +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + #include "gdisp_fonts.h" +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a transparent background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * + * @notapi + */ + void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a filled background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * @param[in] bgcolor The background color + * + * @notapi + */ + void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + /* NOT IMPLEMENTED */ + } +#endif + +#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void GDISP_LLD(control)(int what, void *value) { + /* NOT IMPLEMENTED YET */ + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + /* Code here */ + break; + case powerOn: + /* Code here */ + /* You may need this --- + if (GDISP.Powermode != powerSleep) + GDISP_LLD(init(); + */ + break; + case powerSleep: + /* Code here */ + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + // WriteSpiData(0x48); // no mirror Y (temporary to satisfy Olimex bmptoarray utility) + // WriteSpiData(0xC8); // restore to (mirror x and y, reverse rgb) + switch((gdisp_orientation_t)value) { + case portrait: + /* Code here */ + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscape: + /* Code here */ + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + case portraitInv: + /* Code here */ + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscapeInv: + /* Code here */ + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + default: + return; + } + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) +/** + * @brief Query a driver value. + * @detail Typecase the result to the type you want. + * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen + * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen + * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode + * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation + * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) + * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). + * GDISP_QUERY_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to Query + * + * @notapi + */ +void *GDISP_LLD(query)(unsigned what) { + switch(what) { + case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; + case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; + case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; + case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; + case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; + case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; + case GDISP_QUERY_LLD+0: + /* Code here */ + default: return (void *)-1; + } +} +#endif + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld.mk b/drivers/gdisp/gdispNokia6610/gdisp_lld.mk new file mode 100644 index 00000000..4c980c3c --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/gdispNokia6610/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/gdispNokia6610 diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h new file mode 100644 index 00000000..0e2b806e --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h @@ -0,0 +1,97 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispNokia6610/gdisp_lld_board_example.h + * @brief GDISP Graphic Driver subsystem board interface for the Nokia6610 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the spi port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void GDISP_LLD(init_board)(void) { + /* Code here */ +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void GDISP_LLD(setpin_reset)(bool_t state) { + /* Code here */ +} + +/** + * @brief Set or clear the lcd back-light pin. + * + * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off + * + * @notapi + */ +static __inline void GDISP_LLD(setpin_backlight)(bool_t state) { + /* Code here */ +} + +/** + * @brief Send a 9 bit command/data to the lcd. + * @note The chip select may need to be asserted/de-asserted + * around the actual spi write + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void GDISP_LLD(write_spi)(uint16_t data) { + /* Code here */ +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * @note The chip select may need to be asserted/de-asserted + * around the actual spi read + * + * @notapi + */ +static __inline uint16_t GDISP_LLD(read_spi)(void) { + /* Code here */ +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h new file mode 100644 index 00000000..b5b4b1d5 --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h @@ -0,0 +1,199 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h + * @brief GDISP Graphic Driver subsystem board interface for the Olimex SAM7-EX256 board. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_BOARD_H +#define _GDISP_LLD_BOARD_H + +// mask definitions +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 + +// ****************************************************** +// Pointers to AT91SAM7X256 peripheral data structures +// ****************************************************** +volatile AT91PS_PIO pPIOA = AT91C_BASE_PIOA; +volatile AT91PS_PIO pPIOB = AT91C_BASE_PIOB; +volatile AT91PS_SPI pSPI = AT91C_BASE_SPI0; +volatile AT91PS_PMC pPMC = AT91C_BASE_PMC; +volatile AT91PS_PDC pPDC = AT91C_BASE_PDC_SPI0; + +/** + * @brief Initialise the board for the display. + * @notes Performs the following functions: + * 1. initialise the spi port used by your display + * 2. initialise the reset pin (initial state not-in-reset) + * 3. initialise the chip select pin (initial state not-active) + * 4. initialise the backlight pin (initial state back-light off) + * + * @notapi + */ +static __inline void GDISP_LLD(init_board)(void) { + // ********************************************************************************************* + // InitSpi( ) + // + // Sets up SPI channel 0 for communications to Nokia 6610 LCD Display + // + // I/O ports used: PA2 = LCD Reset (set to low to reset) + // PA12 = LCD chip select (set to low to select the LCD chip) + // PA16 = SPI0_MISO Master In - Slave Out (not used in LCD interface) + // PA17 = SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) + // PA18 = SPI0_SPCK Serial Clock (to LCD slave) + // PB20 = backlight control (normally PWM control, 1 = full on) + // + // *********************************************************************************************} + + /* This code should really use the ChibiOS driver for these functions */ + + // Pin for backlight + pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; // Set PB20 to LOW + pPIOB->PIO_OER = PIOB_LCD_BL_MASK; // Configure PB20 as output + + // Reset pin + pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; // Set PA2 to HIGH + pPIOA->PIO_OER = PIOA_LCD_RESET_MASK; // Configure PA2 as output + + // CS pin - this seems to be ignored + // pPIOA->PIO_SODR = BIT12; // Set PA2 to HIGH + // pPIOA->PIO_OER = BIT12; // Configure PA2 as output + + // Init SPI0 + // Disable the following pins from PIO control (will be used instead by the SPI0 peripheral) + // BIT12 = PA12 -> SPI0_NPCS0 chip select + // BIT16 = PA16 -> SPI0_MISO Master In - Slave Out (not used in LCD interface) + // BIT17 = PA17 -> SPI0_MOSI Master Out - Slave In pin (Serial Data to LCD slave) + // BIT18 = PA18 -> SPI0_SPCK Serial Clock (to LCD slave) + pPIOA->PIO_PDR = BIT12 | BIT16 | BIT17 | BIT18; + pPIOA->PIO_ASR = BIT12 | BIT16 | BIT17 | BIT18; + pPIOA->PIO_BSR = 0; + + //enable the clock of SPI + pPMC->PMC_PCER = 1 << AT91C_ID_SPI0; + + // Fixed mode + pSPI->SPI_CR = 0x81; //SPI Enable, Sowtware reset + pSPI->SPI_CR = 0x01; //SPI Enable + + //pSPI->SPI_MR = 0xE0019; //Master mode, fixed select, disable decoder, FDIV=1 (MCK), PCS=1110 + pSPI->SPI_MR = 0xE0011; //Master mode, fixed select, disable decoder, FDIV=0 (MCK), PCS=1110 + + //pSPI->SPI_CSR[0] = 0x01010C11; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/32*12 = 125kHz + pSPI->SPI_CSR[0] = 0x01010311; //9bit, CPOL=1, ClockPhase=0, SCLK = 48Mhz/8 = 6MHz if using commented MR line above +} + +/** + * @brief Set or clear the lcd reset pin. + * + * @param[in] state TRUE = lcd in reset, FALSE = normal operation + * + * @notapi + */ +static __inline void GDISP_LLD(setpin_reset)(bool_t state) { + if (state) + palClearPad(IOPORT1, PIOA_LCD_RESET); +// pPIOA->PIO_CODR = PIOA_LCD_RESET_MASK; + else + palSetPad(IOPORT1, PIOA_LCD_RESET); +// pPIOA->PIO_SODR = PIOA_LCD_RESET_MASK; +} + +/** + * @brief Set or clear the lcd back-light pin. + * + * @param[in] state TRUE = lcd back-light on, FALSE = lcd back-light off + * + * @notapi + */ +static __inline void GDISP_LLD(setpin_backlight)(bool_t state) { + if (state) + palSetPad(IOPORT2, PIOB_LCD_BL); +// pPIOB->PIO_SODR = PIOB_LCD_BL_MASK; + else + palClearPad(IOPORT2, PIOB_LCD_BL); +// pPIOB->PIO_CODR = PIOB_LCD_BL_MASK; +} + +/** + * @brief Send a 9 bit command/data to the lcd. + * + * @param[in] data The data to send + * + * @notapi + */ +static __inline void GDISP_LLD(write_spi)(uint16_t data) { + // wait for the previous transfer to complete + while((pSPI->SPI_SR & AT91C_SPI_TXEMPTY) == 0); + // send the data + pSPI->SPI_TDR = data; +} + +#if GDISP_HARDWARE_READPIXEL || GDISP_HARDWARE_SCROLL || defined(__DOXYGEN__) +/** + * @brief Read data from the lcd. + * + * @return The data from the lcd + * + * @notapi + */ +static __inline uint16_t GDISP_LLD(read_spi)(void) { + #error "gdispNokia6610: GDISP_HARDWARE_READPIXEL and GDISP_HARDWARE_SCROLL are not supported on this board" + return 0; +} +#endif + +#endif /* _GDISP_LLD_BOARD_H */ +/** @} */ diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h b/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h new file mode 100644 index 00000000..9e2d1258 --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h @@ -0,0 +1,66 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispNokia6610/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the Nokia6610 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if HAL_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "Nokia6610" +#define GDISP_LLD(x) gdisp_lld_##x##_Nokia6610 + +#define GDISP_HARDWARE_LINES FALSE +#define GDISP_HARDWARE_CLEARS FALSE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CIRCLES FALSE +#define GDISP_HARDWARE_CIRCLEFILLS FALSE +#define GDISP_HARDWARE_ELLIPSES FALSE +#define GDISP_HARDWARE_ELLIPSEFILLS FALSE +#define GDISP_HARDWARE_TEXT FALSE +#define GDISP_HARDWARE_TEXTFILLS FALSE +#define GDISP_HARDWARE_SCROLL FALSE +#define GDISP_HARDWARE_PIXELREAD FALSE +#define GDISP_HARDWARE_CONTROL FALSE +#define GDISP_HARDWARE_QUERY FALSE + +#define GDISP_SOFTWARE_TEXTFILLDRAW TRUE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB444 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/gdispNokia6610/readme.txt b/drivers/gdisp/gdispNokia6610/readme.txt new file mode 100644 index 00000000..facb400f --- /dev/null +++ b/drivers/gdisp/gdispNokia6610/readme.txt @@ -0,0 +1,17 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) One (only) of: + #define LCD_USE_GE8 /* The Epson controller */ + #define LCD_USE_GE12 /* The Philips controller */ + d) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h file as a basis. + Currently known boards are: + Olimex SAM7-EX256 + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld.c b/drivers/gdisp/gdispS6d1121/gdisp_lld.c new file mode 100644 index 00000000..5811a6ed --- /dev/null +++ b/drivers/gdisp/gdispS6d1121/gdisp_lld.c @@ -0,0 +1,688 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispS6d1121/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the S6d1121 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/* Include the emulation code for things we don't support */ +#include "gdisp_emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#include "s6d1121_lld.c.h" + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t GDISP_LLD(init)(void) { + palSetPadMode(LCD_RST_GPIO, LCD_RST_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + // A Good idea to reset the module before using + LCD_RST_LOW; + s6d1121_delay(2); + LCD_RST_HIGH; // Hardware Reset + s6d1121_delay(2); + + #ifdef LCD_USE_GPIO + // IO Default Configurations + palSetPadMode(LCD_CS_GPIO, LCD_CS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + palSetPadMode(LCD_WR_GPIO, LCD_WR_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + palSetPadMode(LCD_RD_GPIO, LCD_RD_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + palSetPadMode(LCD_RS_GPIO, LCD_RS_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + palSetPadMode(LCD_BL_GPIO, LCD_BL_PIN, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + + palSetGroupMode(LCD_D0_GPIO, 0x0000000F, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + palSetGroupMode(LCD_D4_GPIO, 0x0000FFF0, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); + + LCD_CS_HIGH; + LCD_RD_HIGH; + LCD_WR_HIGH; + LCD_BL_LOW; + + #elif defined(LCD_USE_FSMC) + #if defined(STM32F1XX) + /* FSMC setup. TODO: this only works for STM32F1 */ + rccEnableAHB(RCC_AHBENR_FSMCEN, 0); + + /* TODO: pin setup */ + #elif defined(STM32F4XX) + /* STM32F4 FSMC init */ + rccEnableAHB3(RCC_AHB3ENR_FSMCEN, 0); + + /* set pins to FSMC mode */ + IOBus busD = {GPIOD, (1 << 0) | (1 << 1) | (1 << 4) | (1 << 5) | (1 << 7) | (1 << 8) | + (1 << 9) | (1 << 10) | (1 << 11) | (1 << 14) | (1 << 15), 0}; + + IOBus busE = {GPIOE, (1 << 7) | (1 << 8) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12) | + (1 << 13) | (1 << 14) | (1 << 15), 0}; + + palSetBusMode(&busD, PAL_MODE_ALTERNATE(12)); + palSetBusMode(&busE, PAL_MODE_ALTERNATE(12)); + #else + #error "FSMC not implemented for this device" + #endif + + int FSMC_Bank = 0; + /* FSMC timing */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = (10) | (10 << 8) | (10 << 16); + + /* Bank1 NOR/SRAM control register configuration */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + #endif + + lld_lcdWriteReg(0x11,0x2004); + lld_lcdWriteReg(0x13,0xCC00); + lld_lcdWriteReg(0x15,0x2600); + lld_lcdWriteReg(0x14,0x252A); + lld_lcdWriteReg(0x12,0x0033); + lld_lcdWriteReg(0x13,0xCC04); + + s6d1121_delay(1); + + lld_lcdWriteReg(0x13,0xCC06); + + s6d1121_delay(1); + + lld_lcdWriteReg(0x13,0xCC4F); + + s6d1121_delay(1); + + lld_lcdWriteReg(0x13,0x674F); + lld_lcdWriteReg(0x11,0x2003); + + s6d1121_delay(1); + + // Gamma Setting + lld_lcdWriteReg(0x30,0x2609); + lld_lcdWriteReg(0x31,0x242C); + lld_lcdWriteReg(0x32,0x1F23); + lld_lcdWriteReg(0x33,0x2425); + lld_lcdWriteReg(0x34,0x2226); + lld_lcdWriteReg(0x35,0x2523); + lld_lcdWriteReg(0x36,0x1C1A); + lld_lcdWriteReg(0x37,0x131D); + lld_lcdWriteReg(0x38,0x0B11); + lld_lcdWriteReg(0x39,0x1210); + lld_lcdWriteReg(0x3A,0x1315); + lld_lcdWriteReg(0x3B,0x3619); + lld_lcdWriteReg(0x3C,0x0D00); + lld_lcdWriteReg(0x3D,0x000D); + + lld_lcdWriteReg(0x16,0x0007); + lld_lcdWriteReg(0x02,0x0013); + lld_lcdWriteReg(0x03,0x0003); + lld_lcdWriteReg(0x01,0x0127); + + s6d1121_delay(1); + + lld_lcdWriteReg(0x08,0x0303); + lld_lcdWriteReg(0x0A,0x000B); + lld_lcdWriteReg(0x0B,0x0003); + lld_lcdWriteReg(0x0C,0x0000); + lld_lcdWriteReg(0x41,0x0000); + lld_lcdWriteReg(0x50,0x0000); + lld_lcdWriteReg(0x60,0x0005); + lld_lcdWriteReg(0x70,0x000B); + lld_lcdWriteReg(0x71,0x0000); + lld_lcdWriteReg(0x78,0x0000); + lld_lcdWriteReg(0x7A,0x0000); + lld_lcdWriteReg(0x79,0x0007); + lld_lcdWriteReg(0x07,0x0051); + + s6d1121_delay(1); + + lld_lcdWriteReg(0x07,0x0053); + lld_lcdWriteReg(0x79,0x0000); + + lld_lcdResetViewPort(); + + /* Now initialise the GDISP structure */ + GDISP.Width = SCREEN_WIDTH; + GDISP.Height = SCREEN_HEIGHT; + GDISP.Orientation = portrait; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return; + #endif + lld_lcdSetCursor(x, y); + lld_lcdWriteReg(0x0022, color); +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If fillarea() is defined there is little + point in defining clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + fillarea() and blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void GDISP_LLD(clear)(color_t color) { + unsigned i; + + lld_lcdSetCursor(0, 0); + lld_lcdWriteStreamStart(); + + for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++) + lld_lcdWriteData(color); + + lld_lcdWriteStreamStop(); + } +#endif + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + #if GDISP_NEED_VALIDATION + /* Need to clip to screen */ + #endif + /* Code here */ + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + unsigned i, area; + + area = cx*cy; + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + for(i = 0; i < area; i++) + lld_lcdWriteData(color); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + unsigned i, area; + + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) return; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + area = cx*cy; + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + for(i = 0; i < area; i++) + lld_lcdWriteData(*buffer++); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +/* Circular Drawing Functions */ +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + #include "gdisp_fonts.h" +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a transparent background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * + * @notapi + */ + void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a filled background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * @param[in] bgcolor The background color + * + * @notapi + */ + void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { + /* This routine is marked "DO NOT USE" in the original + * GLCD driver. We just keep our GDISP_HARDWARE_READPIXEL + * turned off for now. + */ + color_t color; + + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return 0; + #endif + + lld_lcdSetCursor(x, y); + lld_lcdWriteStreamStart(); + + color = lld_lcdReadData(); + color = lld_lcdReadData(); + + lld_lcdWriteStreamStop(); + + return color; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + /* This is marked as "TODO: Test this" in the original GLCD driver. + * For now we just leave the GDISP_HARDWARE_SCROLL off. + */ + static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)]; + coord_t row0, row1; + unsigned i, gap, abslines; + + abslines = lines < 0 ? -lines : lines; + + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + if (!abslines) return; + if (abslines >= cy) { + abslines = cy; + gap = 0; + } else { + gap = cy - abslines; + for(i = 0; i < gap; i++) { + if(lines > 0) { + row0 = y + i + lines; + row1 = y + i; + } else { + row0 = (y - i - 1) + lines; + row1 = (y - i - 1); + } + + /* read row0 into the buffer and then write at row1*/ + lld_lcdSetViewPort(x, row0, cx, 1); + lld_lcdReadStreamStart(); + lld_lcdReadStream(buf, cx); + lld_lcdReadStreamStop(); + + lld_lcdSetViewPort(x, row1, cx, 1); + lld_lcdWriteStreamStart(); + lld_lcdWriteStream(buf, cx); + lld_lcdWriteStreamStop(); + } + } + + /* fill the remaining gap */ + lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); + lld_lcdWriteStreamStart(); + gap = cx*abslines; + for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void GDISP_LLD(control)(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + /* Code here */ + /* break; */ + case powerOn: + /* Code here */ + /* You may need this --- + if (GDISP.Powermode != powerSleep) + GDISP_LLD(init(); + */ + /* break; */ + case powerSleep: + /* Code here */ + /* break; */ + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case portrait: + lld_lcdWriteReg(0x0001,0x0127); + lld_lcdWriteReg(0x03, 0b0011); + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscape: + lld_lcdWriteReg(0x0001,0x0027); + lld_lcdWriteReg(0x0003, 0b1011); + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + case portraitInv: + lld_lcdWriteReg(0x0001,0x0127); + lld_lcdWriteReg(0x0003, 0b0000); + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscapeInv: + lld_lcdWriteReg(0x0001,0x0027); + lld_lcdWriteReg(0x0003, 0b1000); + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + default: + return; + } + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) +/** + * @brief Query a driver value. + * @detail Typecase the result to the type you want. + * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen + * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen + * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode + * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation + * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) + * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). + * GDISP_QUERY_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to Query + * + * @notapi + */ +void *GDISP_LLD(query)(unsigned what) { + switch(what) { + case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; + case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; + case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; + case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; + case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; + case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; + case GDISP_QUERY_LLD+0: + /* Code here */ + default: return (void *)-1; + } +} +#endif + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld.mk b/drivers/gdisp/gdispS6d1121/gdisp_lld.mk new file mode 100644 index 00000000..1f9f093a --- /dev/null +++ b/drivers/gdisp/gdispS6d1121/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/gdispS6d1121/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/gdispS6d1121 diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h b/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h new file mode 100644 index 00000000..ee3fdeee --- /dev/null +++ b/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h @@ -0,0 +1,66 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispS6d1121/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the S6d1121 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if HAL_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "S6d1121" +#define GDISP_LLD(x) gdisp_lld_##x##_S6d1121 + +#define GDISP_HARDWARE_LINES FALSE +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CIRCLES FALSE +#define GDISP_HARDWARE_CIRCLEFILLS FALSE +#define GDISP_HARDWARE_ELLIPSES FALSE +#define GDISP_HARDWARE_ELLIPSEFILLS FALSE +#define GDISP_HARDWARE_TEXT FALSE +#define GDISP_HARDWARE_TEXTFILLS FALSE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD FALSE +#define GDISP_HARDWARE_CONTROL TRUE +#define GDISP_HARDWARE_QUERY FALSE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/gdispS6d1121/readme.txt b/drivers/gdisp/gdispS6d1121/readme.txt new file mode 100644 index 00000000..fc24d4a2 --- /dev/null +++ b/drivers/gdisp/gdispS6d1121/readme.txt @@ -0,0 +1,16 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) One (only) of: + #define LCD_USE_GPIO + #define LCD_USE_SPI + #define LCD_USE_FSMC + d) All of the following (with appropriate values): + #define SCREEN_WIDTH 320 + #define SCREEN_HEIGHT 240 + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispS6d1121/gdisp_lld.mk diff --git a/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h b/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h new file mode 100644 index 00000000..c1539fe7 --- /dev/null +++ b/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h @@ -0,0 +1,244 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef S6D1121_H +#define S6D1121_H + +// I/O assignments +#define LCD_BL_GPIO GPIOB +#define LCD_BL_PIN 8 + +#define LCD_CS_GPIO GPIOD +#define LCD_CS_PIN 7 + +#define LCD_RS_GPIO GPIOD +#define LCD_RS_PIN 11 + +#define LCD_RST_GPIO GPIOD +#define LCD_RST_PIN 10 + +#define LCD_RD_GPIO GPIOD +#define LCD_RD_PIN 9 + +#define LCD_WR_GPIO GPIOD +#define LCD_WR_PIN 8 + +#define LCD_D0_GPIO GPIOD +#define LCD_D4_GPIO GPIOE + +/* all interfaces use RST via GPIO */ +/* TODO: option to disable RST; assumes RST is tied high */ +#define LCD_RST_LOW palClearPad(LCD_RST_GPIO, LCD_RST_PIN) +#define LCD_RST_HIGH palSetPad(LCD_RST_GPIO, LCD_RST_PIN) + +#define s6d1121_delay(n) halPolledDelay(MS2RTT(n)); + +#if defined(LCD_USE_GPIO) + + #define LCD_CS_LOW palClearPad(LCD_CS_GPIO, LCD_CS_PIN) + #define LCD_CS_HIGH palSetPad(LCD_CS_GPIO, LCD_CS_PIN) + + #define LCD_RS_LOW palClearPad(LCD_RS_GPIO, LCD_RS_PIN) + #define LCD_RS_HIGH palSetPad(LCD_RS_GPIO, LCD_RS_PIN) + + #define LCD_RD_LOW palClearPad(LCD_RD_GPIO, LCD_RD_PIN) + #define LCD_RD_HIGH palSetPad(LCD_RD_GPIO, LCD_RD_PIN) + + #define LCD_WR_LOW palClearPad(LCD_WR_GPIO, LCD_WR_PIN) + #define LCD_WR_HIGH palSetPad(LCD_WR_GPIO, LCD_WR_PIN) + + #define LCD_BL_LOW palClearPad(LCD_BL_GPIO, LCD_BL_PIN) + #define LCD_BL_HIGH palSetPad(LCD_BL_GPIO, LCD_BL_PIN) + + + static inline void lld_lcddelay(void) { asm volatile ("nop"); asm volatile ("nop"); } + static inline void lld_lcdwrite(uint16_t db) { + LCD_D4_GPIO->BSRR.W=((~db&0xFFF0)<<16)|(db&0xFFF0); + LCD_D0_GPIO->BSRR.W=((~db&0x000F)<<16)|(db&0x000F); + LCD_WR_LOW; + lld_lcddelay(); + LCD_WR_HIGH; + } + static __inline uint16_t lld_lcdReadData(void) { + uint16_t value=0; + + LCD_RS_HIGH; LCD_WR_HIGH; LCD_RD_LOW; + #ifndef STM32F4XX + // change pin mode to digital input + LCD_DATA_PORT->CRH = 0x47444444; + LCD_DATA_PORT->CRL = 0x47444444; + #endif + #ifndef STM32F4XX + // change pin mode back to digital output + LCD_DATA_PORT->CRH = 0x33333333; + LCD_DATA_PORT->CRL = 0x33333333; + #endif + LCD_RD_HIGH; + return value; + } + static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { + uint16_t lcdRAM; + + LCD_CS_LOW; LCD_RS_LOW; + lld_lcdwrite(lcdReg); + LCD_RS_HIGH; + lcdRAM = lld_lcdReadData(); + LCD_CS_HIGH; + return lcdRAM; + } + static void lld_lcdWriteIndex(uint16_t lcdReg) { + LCD_RS_LOW; + lld_lcdwrite(lcdReg); + LCD_RS_HIGH; + } + static void lld_lcdWriteData(uint16_t lcdData) { + lld_lcdwrite(lcdData); + } + static void lld_lcdWriteReg(uint16_t lcdReg, uint16_t lcdRegValue) { + LCD_CS_LOW; + lld_lcdWriteIndex(lcdReg); + lld_lcdWriteData(lcdRegValue); + LCD_CS_HIGH; + } + static __inline void lld_lcdWriteStreamStart(void) { + LCD_CS_LOW; + lld_lcdWriteIndex(0x0022); + } + static __inline void lld_lcdWriteStreamStop(void) { + LCD_CS_HIGH; + } + static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { + uint16_t i; + + for(i = 0; i < size; i++) { lld_lcdwrite(buffer[i]); } + } + static __inline void lld_lcdReadStreamStart(void) { /* TODO */ } + static __inline void lld_lcdReadStreamStop(void) { /* TODO */ } + static __inline void lld_lcdReadStream(uint16_t *UNUSED(buffer), size_t UNUSED(size)) { /* TODO */ } + +#elif defined(LCD_USE_FSMC) + #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ + #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ + + static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; } + static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; } + static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { + LCD_REG = lcdReg; + LCD_RAM = lcdRegValue; + } + static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); } + static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { + LCD_REG = lcdReg; + return LCD_RAM; + } + static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; } + static __inline void lld_lcdWriteStreamStop(void) {} + static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { + uint16_t i; + for(i = 0; i < size; i++) LCD_RAM = buffer[i]; + } + static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; } + static __inline void lld_lcdReadStreamStop(void) {} + static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { + uint16_t i; + volatile uint16_t dummy; + + /* throw away first value read */ + dummy = LCD_RAM; + for(i = 0; i < size; i++) buffer[i] = LCD_RAM; + } + +#elif defined(LCD_USE_SPI) + #error "gdispS6d1121: LCD_USE_SPI not implemented yet" + +#else + #error "gdispS6d1121: No known LCD_USE_XXX has been defined" +#endif + +static void lld_lcdSetCursor(coord_t x, coord_t y) { + /* R20h - 8 bit + * R21h - 9 bit + */ + switch(GDISP.Orientation) { + case portraitInv: + lld_lcdWriteReg(0x0020, (SCREEN_WIDTH-1-x) & 0x00FF); + lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT-1-y) & 0x01FF); + break; + case portrait: + lld_lcdWriteReg(0x0020, x & 0x00FF); + lld_lcdWriteReg(0x0021, y & 0x01FF); + break; + case landscape: + lld_lcdWriteReg(0x0020, y & 0x00FF); + lld_lcdWriteReg(0x0021, x & 0x01FF); + break; + case landscapeInv: + lld_lcdWriteReg(0x0020, (SCREEN_WIDTH - y - 1) & 0x00FF); + lld_lcdWriteReg(0x0021, (SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } +} + +static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { + /* HSA / HEA are 8 bit + * VSA / VEA are 9 bit + * use masks 0x00FF and 0x01FF to enforce this + */ + + switch(GDISP.Orientation) { + case portrait: + lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); + lld_lcdWriteReg(0x48, y & 0x01FF); + lld_lcdWriteReg(0x47, (y+cy-1) & 0x01FF); + break; + case landscape: + lld_lcdWriteReg(0x46, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF)); + lld_lcdWriteReg(0x48, x & 0x01FF); + lld_lcdWriteReg(0x47, (x+cx-1) & 0x01FF); + break; + case portraitInv: + lld_lcdWriteReg(0x46, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF)); + lld_lcdWriteReg(0x48, (SCREEN_HEIGHT-(y+cy)) & 0x01FF); + lld_lcdWriteReg(0x47, (SCREEN_HEIGHT-y-1) & 0x01FF); + break; + case landscapeInv: + lld_lcdWriteReg(0x46, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF)); + lld_lcdWriteReg(0x48, (SCREEN_HEIGHT - (x+cx)) & 0x01FF); + lld_lcdWriteReg(0x47, (SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } + + lld_lcdSetCursor(x, y); +} + +static void lld_lcdResetViewPort(void) { + switch(GDISP.Orientation) { + case portrait: + case portraitInv: + lld_lcdSetViewPort(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); + break; + case landscape: + case landscapeInv: + lld_lcdSetViewPort(0, 0, SCREEN_HEIGHT, SCREEN_WIDTH); + break; + } +} + +#endif /* S6D1121_H */ diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.c b/drivers/gdisp/gdispSsd1289/gdisp_lld.c new file mode 100644 index 00000000..7dfb83a7 --- /dev/null +++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.c @@ -0,0 +1,610 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispSsd1289/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for the Ssd1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/* Include the emulation code for things we don't support */ +#include "gdisp_emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#include "ssd1289_lld.c.h" + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t GDISP_LLD(init)(void) { + uint16_t deviceCode; + + #ifdef LCD_USE_FSMC + /* FSMC setup. TODO: this only works for STM32F1 */ + rccEnableAHB(RCC_AHBENR_FSMCEN, 0); + int FSMC_Bank = 0; + /* timing structure */ + /* from datasheet: + address setup: 0ns + address hold: 0ns + Data setup: 5ns + Data hold: 5ns + Data access: 250ns + output hold: 100ns + */ + FSMC_Bank1->BTCR[FSMC_Bank+1] = FSMC_BTR1_ADDSET_1 | FSMC_BTR1_DATAST_1; + + /* Bank1 NOR/SRAM control register configuration */ + FSMC_Bank1->BTCR[FSMC_Bank] = FSMC_BCR1_MWID_0 | FSMC_BCR1_WREN | FSMC_BCR1_MBKEN; + #endif + + deviceCode = lld_lcdReadReg(0x0000); + + lld_lcdWriteReg(0x0000,0x0001); lld_lcdDelay(5); + lld_lcdWriteReg(0x0003,0xA8A4); lld_lcdDelay(5); + lld_lcdWriteReg(0x000C,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x000D,0x080C); lld_lcdDelay(5); + lld_lcdWriteReg(0x000E,0x2B00); lld_lcdDelay(5); + lld_lcdWriteReg(0x001E,0x00B0); lld_lcdDelay(5); + lld_lcdWriteReg(0x0001,0x2B3F); lld_lcdDelay(5); + lld_lcdWriteReg(0x0002,0x0600); lld_lcdDelay(5); + lld_lcdWriteReg(0x0010,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0011,0x6070); lld_lcdDelay(5); + lld_lcdWriteReg(0x0005,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0006,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0016,0xEF1C); lld_lcdDelay(5); + lld_lcdWriteReg(0x0017,0x0003); lld_lcdDelay(5); + lld_lcdWriteReg(0x0007,0x0133); lld_lcdDelay(5); + lld_lcdWriteReg(0x000B,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x000F,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0041,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0042,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0048,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0049,0x013F); lld_lcdDelay(5); + lld_lcdWriteReg(0x004A,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x004B,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0044,0xEF00); lld_lcdDelay(5); + lld_lcdWriteReg(0x0045,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0046,0x013F); lld_lcdDelay(5); + lld_lcdWriteReg(0x0030,0x0707); lld_lcdDelay(5); + lld_lcdWriteReg(0x0031,0x0204); lld_lcdDelay(5); + lld_lcdWriteReg(0x0032,0x0204); lld_lcdDelay(5); + lld_lcdWriteReg(0x0033,0x0502); lld_lcdDelay(5); + lld_lcdWriteReg(0x0034,0x0507); lld_lcdDelay(5); + lld_lcdWriteReg(0x0035,0x0204); lld_lcdDelay(5); + lld_lcdWriteReg(0x0036,0x0204); lld_lcdDelay(5); + lld_lcdWriteReg(0x0037,0x0502); lld_lcdDelay(5); + lld_lcdWriteReg(0x003A,0x0302); lld_lcdDelay(5); + lld_lcdWriteReg(0x003B,0x0302); lld_lcdDelay(5); + lld_lcdWriteReg(0x0023,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0024,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x0025,0x8000); lld_lcdDelay(5); + lld_lcdWriteReg(0x004f,0x0000); lld_lcdDelay(5); + lld_lcdWriteReg(0x004e,0x0000); lld_lcdDelay(5); + + /* Initialise the GDISP structure */ + GDISP.Width = SCREEN_WIDTH; + GDISP.Height = SCREEN_HEIGHT; + GDISP.Orientation = portrait; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return; + #endif + lld_lcdSetCursor(x, y); + lld_lcdWriteReg(0x0022, color); +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If gfillarea() is defined there is little + point in defining clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + fillarea() and blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void GDISP_LLD(clear)(color_t color) { + unsigned i; + + lld_lcdSetCursor(0, 0); + lld_lcdWriteStreamStart(); + + for(i = 0; i < SCREEN_WIDTH * SCREEN_HEIGHT; i++) + lld_lcdWriteData(color); + + lld_lcdWriteStreamStop(); + } +#endif + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + unsigned i, area; + + area = cx*cy; + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + for(i = 0; i < area; i++) + lld_lcdWriteData(color); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + unsigned i, area; + + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) return; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + area = cx*cy; + lld_lcdSetViewPort(x, y, cx, cy); + lld_lcdWriteStreamStart(); + for(i = 0; i < area; i++) + lld_lcdWriteData(*buffer++); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +/* Circular Drawing Functions */ +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + #include "gdisp_fonts.h" +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a transparent background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * + * @notapi + */ + void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a filled background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * @param[in] bgcolor The background color + * + * @notapi + */ + void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + /* NOT IMPLEMENTED */ + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { + color_t color; + + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return 0; + #endif + + lld_lcdSetCursor(x, y); + lld_lcdWriteStreamStart(); + + color = lld_lcdReadData(); + color = lld_lcdReadData(); + + lld_lcdWriteStreamStop(); + + return color; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + static color_t buf[((SCREEN_HEIGHT > SCREEN_WIDTH ) ? SCREEN_HEIGHT : SCREEN_WIDTH)]; + coord_t row0, row1; + unsigned i, gap, abslines; + + abslines = lines < 0 ? -lines : lines; + + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + + if (!abslines) return; + if (abslines >= cy) { + abslines = cy; + gap = 0; + } else { + gap = cy - abslines; + for(i = 0; i < gap; i++) { + if(lines > 0) { + row0 = y + i + lines; + row1 = y + i; + } else { + row0 = (y - i - 1) + lines; + row1 = (y - i - 1); + } + + /* read row0 into the buffer and then write at row1*/ + lld_lcdSetViewPort(x, row0, cx, 1); + lld_lcdReadStreamStart(); + lld_lcdReadStream(buf, cx); + lld_lcdReadStreamStop(); + + lld_lcdSetViewPort(x, row1, cx, 1); + lld_lcdWriteStreamStart(); + lld_lcdWriteStream(buf, cx); + lld_lcdWriteStreamStop(); + } + } + + /* fill the remaining gap */ + lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); + lld_lcdWriteStreamStart(); + gap = cx*abslines; + for(i = 0; i < gap; i++) lld_lcdWriteData(color); + lld_lcdWriteStreamStop(); + lld_lcdResetViewPort(); + } +#endif + +#if GDISP_HARDWARE_CONTROL || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void GDISP_LLD(control)(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode + lld_lcdWriteReg(0x0007, 0x0000); // halt operation + lld_lcdWriteReg(0x0000, 0x0000); // turn off oszillator + lld_lcdWriteReg(0x0010, 0x0001); // enter sleepmode + break; + case powerOn: + lld_lcdWriteReg(0x0010, 0x0000); // leave sleep mode + if (GDISP.Powermode != powerSleep) + GDISP_LLD(init)(); + break; + case powerSleep: + lld_lcdWriteReg(0x0010, 0x0001); // enter sleep mode + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case portrait: + lld_lcdWriteReg(0x0001, 0x2B3F); + /* ID = 11 AM = 0 */ + lld_lcdWriteReg(0x0011, 0x6070); + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscape: + lld_lcdWriteReg(0x0001, 0x293F); + /* ID = 11 AM = 1 */ + lld_lcdWriteReg(0x0011, 0x6078); + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + case portraitInv: + lld_lcdWriteReg(0x0001, 0x2B3F); + /* ID = 01 AM = 0 */ + lld_lcdWriteReg(0x0011, 0x6040); + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscapeInv: + lld_lcdWriteReg(0x0001, 0x293F); + /* ID = 01 AM = 1 */ + lld_lcdWriteReg(0x0011, 0x6048); + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + default: + return; + } + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) +/** + * @brief Query a driver value. + * @detail Typecase the result to the type you want. + * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen + * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen + * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode + * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation + * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) + * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). + * GDISP_QUERY_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to Query + * + * @notapi + */ +void *GDISP_LLD(query)(unsigned what) { + switch(what) { + case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; + case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; + case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; + case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; + case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; + case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; + case GDISP_QUERY_LLD+0: + /* Code here */ + default: return (void *)-1; + } +} +#endif + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.mk b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk new file mode 100644 index 00000000..8167cbfb --- /dev/null +++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/gdispSsd1289/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/gdispSsd1289 diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h b/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h new file mode 100644 index 00000000..123ce875 --- /dev/null +++ b/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h @@ -0,0 +1,66 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispSsd1289/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header for the Ssd1289 display. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if HAL_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "SSD1289" +#define GDISP_LLD(x) gdisp_lld_##x##_SSD1289 + +#define GDISP_HARDWARE_LINES FALSE +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CIRCLES FALSE +#define GDISP_HARDWARE_CIRCLEFILLS FALSE +#define GDISP_HARDWARE_ELLIPSES FALSE +#define GDISP_HARDWARE_ELLIPSEFILLS FALSE +#define GDISP_HARDWARE_TEXT FALSE +#define GDISP_HARDWARE_TEXTFILLS FALSE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE +#define GDISP_HARDWARE_QUERY FALSE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/gdispSsd1289/readme.txt b/drivers/gdisp/gdispSsd1289/readme.txt new file mode 100644 index 00000000..17d22223 --- /dev/null +++ b/drivers/gdisp/gdispSsd1289/readme.txt @@ -0,0 +1,16 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) One (only) of: + #define LCD_USE_GPIO + #define LCD_USE_SPI + #define LCD_USE_FSMC + d) All of the following (with appropriate values): + #define SCREEN_WIDTH 320 + #define SCREEN_HEIGHT 240 + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispSsd1289/gdisp_lld.mk diff --git a/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h b/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h new file mode 100644 index 00000000..7c0fade2 --- /dev/null +++ b/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h @@ -0,0 +1,322 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef SSD1289_H +#define SSD1289_H + +#if defined(LCD_USE_GPIO) + #define Set_CS palSetPad(LCD_CMD_PORT, LCD_CS); + #define Clr_CS palClearPad(LCD_CMD_PORT, LCD_CS); + #define Set_RS palSetPad(LCD_CMD_PORT, LCD_RS); + #define Clr_RS palClearPad(LCD_CMD_PORT, LCD_RS); + #define Set_WR palSetPad(LCD_CMD_PORT, LCD_WR); + #define Clr_WR palClearPad(LCD_CMD_PORT, LCD_WR); + #define Set_RD palSetPad(LCD_CMD_PORT, LCD_RD); + #define Clr_RD palClearPad(LCD_CMD_PORT, LCD_RD); + + static __inline void lld_lcdWriteIndex(uint16_t index) { + Clr_RS; Set_RD; + lld_lcdWriteGPIO(index); + Clr_WR; Set_WR; + } + static __inline void lld_lcdWriteData(uint16_t data) { + Set_RS; + lld_lcdWriteGPIO(data); + Clr_WR; Set_WR; + } + static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { + Clr_CS; + lld_lcdWriteIndex(lcdReg); + lld_lcdWriteData(lcdRegValue); + Set_CS; + } + static __inline uint16_t lld_lcdReadData(void) { + uint16_t value; + + Set_RS; Set_WR; Clr_RD; + value = lld_lcdReadGPIO(); + Set_RD; + return value; + } + static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { + uint16_t value; + + Clr_CS; + lld_lcdWriteIndex(lcdReg); + value = lld_lcdReadData(); + Set_CS; + return value; + } + + static __inline void lld_lcdWriteStreamStart(void) { + Clr_CS; + lld_lcdWriteIndex(0x0022); + } + + static __inline void lld_lcdWriteStreamStop(void) { + Set_CS; + } + + static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { + uint16_t i; + + Set_RS; + for(i = 0; i < size; i++) { lld_lcdWriteGPIO(buffer[i]); Clr_WR; Set_WR; } + } + + static __inline void lld_lcdReadStreamStart(void) { + Clr_CS + lld_lcdWriteIndex(0x0022); + } + + static __inline void lld_lcdReadStreamStop(void) { + Set_CS; + } + + static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { + uint16_t i; + volatile uint16_t dummy; + + dummy = lld_lcdReadData(); + for(i = 0; i < size; i++) buffer[i] = lld_lcdReadData(); + } + +#elif defined(LCD_USE_FSMC) + /* LCD Registers */ + #define R0 0x00 + #define R1 0x01 + #define R2 0x02 + #define R3 0x03 + #define R4 0x04 + #define R5 0x05 + #define R6 0x06 + #define R7 0x07 + #define R8 0x08 + #define R9 0x09 + #define R10 0x0A + #define R12 0x0C + #define R13 0x0D + #define R14 0x0E + #define R15 0x0F + #define R16 0x10 + #define R17 0x11 + #define R18 0x12 + #define R19 0x13 + #define R20 0x14 + #define R21 0x15 + #define R22 0x16 + #define R23 0x17 + #define R24 0x18 + #define R25 0x19 + #define R26 0x1A + #define R27 0x1B + #define R28 0x1C + #define R29 0x1D + #define R30 0x1E + #define R31 0x1F + #define R32 0x20 + #define R33 0x21 + #define R34 0x22 + #define R36 0x24 + #define R37 0x25 + #define R40 0x28 + #define R41 0x29 + #define R43 0x2B + #define R45 0x2D + #define R48 0x30 + #define R49 0x31 + #define R50 0x32 + #define R51 0x33 + #define R52 0x34 + #define R53 0x35 + #define R54 0x36 + #define R55 0x37 + #define R56 0x38 + #define R57 0x39 + #define R59 0x3B + #define R60 0x3C + #define R61 0x3D + #define R62 0x3E + #define R63 0x3F + #define R64 0x40 + #define R65 0x41 + #define R66 0x42 + #define R67 0x43 + #define R68 0x44 + #define R69 0x45 + #define R70 0x46 + #define R71 0x47 + #define R72 0x48 + #define R73 0x49 + #define R74 0x4A + #define R75 0x4B + #define R76 0x4C + #define R77 0x4D + #define R78 0x4E + #define R79 0x4F + #define R80 0x50 + #define R81 0x51 + #define R82 0x52 + #define R83 0x53 + #define R96 0x60 + #define R97 0x61 + #define R106 0x6A + #define R118 0x76 + #define R128 0x80 + #define R129 0x81 + #define R130 0x82 + #define R131 0x83 + #define R132 0x84 + #define R133 0x85 + #define R134 0x86 + #define R135 0x87 + #define R136 0x88 + #define R137 0x89 + #define R139 0x8B + #define R140 0x8C + #define R141 0x8D + #define R143 0x8F + #define R144 0x90 + #define R145 0x91 + #define R146 0x92 + #define R147 0x93 + #define R148 0x94 + #define R149 0x95 + #define R150 0x96 + #define R151 0x97 + #define R152 0x98 + #define R153 0x99 + #define R154 0x9A + #define R157 0x9D + #define R192 0xC0 + #define R193 0xC1 + #define R229 0xE5 + + #define LCD_REG (*((volatile uint16_t *) 0x60000000)) /* RS = 0 */ + #define LCD_RAM (*((volatile uint16_t *) 0x60020000)) /* RS = 1 */ + + static __inline void lld_lcdWriteIndex(uint16_t index) { LCD_REG = index; } + static __inline void lld_lcdWriteData(uint16_t data) { LCD_RAM = data; } + static __inline void lld_lcdWriteReg(uint16_t lcdReg,uint16_t lcdRegValue) { + LCD_REG = lcdReg; + LCD_RAM = lcdRegValue; + } + static __inline uint16_t lld_lcdReadData(void) { return (LCD_RAM); } + static __inline uint16_t lld_lcdReadReg(uint16_t lcdReg) { + volatile uint16_t dummy; + + LCD_REG = lcdReg; + dummy = LCD_RAM; + return (LCD_RAM); + } + static __inline void lld_lcdWriteStreamStart(void) { LCD_REG = 0x0022; } + static __inline void lld_lcdWriteStreamStop(void) {} + static __inline void lld_lcdWriteStream(uint16_t *buffer, uint16_t size) { + uint16_t i; + + for(i = 0; i < size; i++) LCD_RAM = buffer[i]; + } + static __inline void lld_lcdReadStreamStart(void) { LCD_REG = 0x0022; } + static __inline void lld_lcdReadStreamStop(void) {} + static __inline void lld_lcdReadStream(uint16_t *buffer, size_t size) { + uint16_t i; + volatile uint16_t dummy; + + dummy = LCD_RAM; /* throw away first value read */ + for(i = 0; i < size; i++) buffer[i] = LCD_RAM; + } + +#elif defined(LCD_USE_SPI) + #error "gdispSsd1289: LCD_USE_SPI not implemented yet" + +#else + #error "gdispSsd1289: No known LCD_USE_XXX has been defined" +#endif + +static __inline void lld_lcdDelay(uint16_t us) { + chThdSleepMicroseconds(us); +} + +static void lld_lcdSetCursor(uint16_t x, uint16_t y) { + /* Reg 0x004E is an 8 bit value + * Reg 0x004F is 9 bit + * Use a bit mask to make sure they are not set too high + */ + switch(GDISP.Orientation) { + case portraitInv: + lld_lcdWriteReg(0x004e, (SCREEN_WIDTH-1-x) & 0x00FF); + lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT-1-y) & 0x01FF); + break; + case portrait: + lld_lcdWriteReg(0x004e, x & 0x00FF); + lld_lcdWriteReg(0x004f, y & 0x01FF); + break; + case landscape: + lld_lcdWriteReg(0x004e, y & 0x00FF); + lld_lcdWriteReg(0x004f, x & 0x01FF); + break; + case landscapeInv: + lld_lcdWriteReg(0x004e, (SCREEN_WIDTH - y - 1) & 0x00FF); + lld_lcdWriteReg(0x004f, (SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } +} + +static void lld_lcdSetViewPort(uint16_t x, uint16_t y, uint16_t cx, uint16_t cy) { + lld_lcdSetCursor(x, y); + + /* Reg 0x44 - Horizontal RAM address position + * Upper Byte - HEA + * Lower Byte - HSA + * 0 <= HSA <= HEA <= 0xEF + * Reg 0x45,0x46 - Vertical RAM address position + * Lower 9 bits gives 0-511 range in each value + * 0 <= Reg(0x45) <= Reg(0x46) <= 0x13F + */ + + switch(GDISP.Orientation) { + case portrait: + lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00 ) | (x & 0x00FF)); + lld_lcdWriteReg(0x45, y & 0x01FF); + lld_lcdWriteReg(0x46, (y+cy-1) & 0x01FF); + break; + case landscape: + lld_lcdWriteReg(0x44, (((x+cx-1) << 8) & 0xFF00) | ((y+cy) & 0x00FF)); + lld_lcdWriteReg(0x45, x & 0x01FF); + lld_lcdWriteReg(0x46, (x+cx-1) & 0x01FF); + break; + case portraitInv: + lld_lcdWriteReg(0x44, (((SCREEN_WIDTH-x-1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (x+cx)) & 0x00FF)); + lld_lcdWriteReg(0x45, (SCREEN_HEIGHT-(y+cy)) & 0x01FF); + lld_lcdWriteReg(0x46, (SCREEN_HEIGHT-y-1) & 0x01FF); + break; + case landscapeInv: + lld_lcdWriteReg(0x44, (((SCREEN_WIDTH - y - 1) & 0x00FF) << 8) | ((SCREEN_WIDTH - (y+cy)) & 0x00FF)); + lld_lcdWriteReg(0x45, (SCREEN_HEIGHT - (x+cx)) & 0x01FF); + lld_lcdWriteReg(0x46, (SCREEN_HEIGHT - x - 1) & 0x01FF); + break; + } + + lld_lcdSetCursor(x, y); +} + +static __inline void lld_lcdResetViewPort(void) {} + +#endif /* SSD1289_H */ diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld.c b/drivers/gdisp/gdispTestStub/gdisp_lld.c new file mode 100644 index 00000000..fd8410fb --- /dev/null +++ b/drivers/gdisp/gdispTestStub/gdisp_lld.c @@ -0,0 +1,361 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispTestStub/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source (stub). + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/* Include the emulation code for things we don't support */ +#include "gdisp_emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialization. + * + * @notapi + */ +bool_t GDISP_LLD(init)(void) { + /* Initialise the GDISP structure */ + GDISP.Width = 128; + GDISP.Height = 128; + GDISP.Orientation = portrait; + GDISP.Powermode = powerOff; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void GDISP_LLD(drawpixel)(coord_t UNUSED(x), coord_t UNUSED(y), color_t UNUSED(color)) { +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If fillarea() is defined there is little + point in defining clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + fillarea() and blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void GDISP_LLD(clear)(color_t UNUSED(color)) { + } +#endif + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void GDISP_LLD(drawline)(coord_t UNUSED(x0), coord_t UNUSED(y0), coord_t UNUSED(x1), coord_t UNUSED(y1), color_t UNUSED(color)) { + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void GDISP_LLD(fillarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), color_t UNUSED(color)) { + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void GDISP_LLD(blitarea)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), const pixel_t *UNUSED(buffer)) { + } +#endif + +/* Circular Drawing Functions */ +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(drawcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(fillcircle)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(radius), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(drawellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(fillellipse)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(a), coord_t UNUSED(b), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a transparent background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * + * @notapi + */ + void GDISP_LLD(drawchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color)) { + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a filled background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * @param[in] bgcolor The background color + * + * @notapi + */ + void GDISP_LLD(fillchar)(coord_t UNUSED(x), coord_t UNUSED(y), char UNUSED(c), font_t UNUSED(font), color_t UNUSED(color), color_t UNUSED(bgcolor)) { + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t GDISP_LLD(getpixelcolor)(coord_t UNUSED(x), coord_t UNUSED(y)) { + return 0; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void GDISP_LLD(verticalscroll)(coord_t UNUSED(x), coord_t UNUSED(y), coord_t UNUSED(cx), coord_t UNUSED(cy), int UNUSED(lines), color_t UNUSED(bgcolor)) { + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) { + } +#endif + +#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) +/** + * @brief Query a driver value. + * @detail Typecase the result to the type you want. + * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen + * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen + * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode + * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation + * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) + * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). + * GDISP_QUERY_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to Query + * + * @notapi + */ +void *GDISP_LLD(query)(unsigned what) { + switch(what) { + case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; + case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; + case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; + case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; + case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; + case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; + case GDISP_QUERY_LLD+0: + /* Code here */ + default: return (void *)-1; + } +} +#endif + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld.mk b/drivers/gdisp/gdispTestStub/gdisp_lld.mk new file mode 100644 index 00000000..9c5d02ea --- /dev/null +++ b/drivers/gdisp/gdispTestStub/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/gdispTestStub/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/gdispTestStub diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld_config.h b/drivers/gdisp/gdispTestStub/gdisp_lld_config.h new file mode 100644 index 00000000..d66e050f --- /dev/null +++ b/drivers/gdisp/gdispTestStub/gdisp_lld_config.h @@ -0,0 +1,66 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispTestStub/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header (stub). + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if HAL_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "TestStub" +#define GDISP_LLD(x) gdisp_lld_##x##_TestStub + +#define GDISP_HARDWARE_LINES FALSE +#define GDISP_HARDWARE_CLEARS FALSE +#define GDISP_HARDWARE_FILLS FALSE +#define GDISP_HARDWARE_BITFILLS FALSE +#define GDISP_HARDWARE_CIRCLES FALSE +#define GDISP_HARDWARE_CIRCLEFILLS FALSE +#define GDISP_HARDWARE_ELLIPSES FALSE +#define GDISP_HARDWARE_ELLIPSEFILLS FALSE +#define GDISP_HARDWARE_TEXT FALSE +#define GDISP_HARDWARE_TEXTFILLS FALSE +#define GDISP_HARDWARE_SCROLL GDISP_NEED_SCROLL +#define GDISP_HARDWARE_PIXELREAD GDISP_NEED_PIXELREAD +#define GDISP_HARDWARE_CONTROL FALSE +#define GDISP_HARDWARE_QUERY FALSE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/gdispTestStub/readme.txt b/drivers/gdisp/gdispTestStub/readme.txt new file mode 100644 index 00000000..83611acf --- /dev/null +++ b/drivers/gdisp/gdispTestStub/readme.txt @@ -0,0 +1,17 @@ +This low level driver is a test stub that doesn't talk to any +real hardware. It is included to allow testing of the compilation +process. + +Do not use this driver as a template for new drivers. Use the + templates/gdispXXXXX directory for that. + +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) + you want to compile test eg: GDISP_NEED_MULTITHREAD + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispTestStub/gdisp_lld.mk diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.c b/drivers/gdisp/gdispVMT/gdisp_lld.c new file mode 100644 index 00000000..1528f470 --- /dev/null +++ b/drivers/gdisp/gdispVMT/gdisp_lld.c @@ -0,0 +1,249 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispVMT/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for VMT. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +#define GDISP_LLD_NO_STRUCT + +/* Include the emulation code for things we don't support */ +#include "gdisp_emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define GDISP_LLD1(x) GDISP_VMT_NAME1(gdisp_lld_##x##_) +#define GDISP_LLD2(x) GDISP_VMT_NAME2(gdisp_lld_##x##_) + +/* Prototypes for lld driver functions */ +bool_t GDISP_LLD1(init)(void); +void GDISP_LLD1(clear)(color_t color); +void GDISP_LLD1(drawpixel)(coord_t x, coord_t y, color_t color); +void GDISP_LLD1(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); +void GDISP_LLD1(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); +void GDISP_LLD1(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); +#if GDISP_NEED_CIRCLE + void GDISP_LLD1(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); + void GDISP_LLD1(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +#endif +#if GDISP_NEED_ELLIPSE + void GDISP_LLD1(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + void GDISP_LLD1(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +#endif +#if GDISP_NEED_TEXT + void GDISP_LLD1(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); + void GDISP_LLD1(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); +#endif +#if GDISP_NEED_PIXELREAD + color_t GDISP_LLD1(getpixelcolor)(coord_t x, coord_t y); +#endif +#if GDISP_NEED_SCROLL + void GDISP_LLD1(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); +#endif +#if GDISP_NEED_CONTROL + void GDISP_LLD1(control)(unsigned what, void *value); +#endif +#if GDISP_NEED_QUERY + void *GDISP_LLD1(query)(unsigned what); +#endif + +bool_t GDISP_LLD2(init)(void); +void GDISP_LLD2(clear)(color_t color); +void GDISP_LLD2(drawpixel)(coord_t x, coord_t y, color_t color); +void GDISP_LLD2(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); +void GDISP_LLD2(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); +void GDISP_LLD2(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); +#if GDISP_NEED_CIRCLE + void GDISP_LLD2(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); + void GDISP_LLD2(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +#endif +#if GDISP_NEED_ELLIPSE + void GDISP_LLD2(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + void GDISP_LLD2(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +#endif +#if GDISP_NEED_TEXT + void GDISP_LLD2(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); + void GDISP_LLD2(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); +#endif +#if GDISP_NEED_PIXELREAD + color_t GDISP_LLD2(getpixelcolor)(coord_t x, coord_t y); +#endif +#if GDISP_NEED_SCROLL + void GDISP_LLD2(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); +#endif +#if GDISP_NEED_CONTROL + void GDISP_LLD2(control)(unsigned what, void *value); +#endif +#if GDISP_NEED_QUERY + void *GDISP_LLD2(query)(unsigned what); +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/* Our VMT table variables */ +void GDISP_LLD_VMT(clear)(color_t color); +void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); +void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); +void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); +void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); + +#if GDISP_NEED_CIRCLE +void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); +#endif + +#if GDISP_NEED_ELLIPSE +void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); +#endif + +/* Text Rendering Functions */ +#if GDISP_NEED_TEXT +void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); +void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); +#endif + +/* Pixel readback */ +#if GDISP_NEED_PIXELREAD +color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); +#endif + +/* Scrolling Function - clears the area scrolled out */ +#if GDISP_NEED_SCROLL +void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); +#endif + +/* Set driver specific control */ +#if GDISP_NEED_CONTROL +void GDISP_LLD_VMT(control)(unsigned what, void *value); +#endif +/* Set driver specific control */ +#if GDISP_NEED_QUERY +void *GDISP_LLD_VMT(query)(unsigned what); +#endif + + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +bool_t gdisp_lld_init_VMT(void) { + if (GDISP_VMT_NAME1(gdisp_lld_init_)()) { + gdisp_lld_clear_VMT = GDISP_VMT_NAME1(gdisp_lld_clear_); + gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME1(gdisp_lld_drawpixel_); + gdisp_lld_fillarea_VMT = GDISP_VMT_NAME1(gdisp_lld_fillarea_); + gdisp_lld_blitarea_VMT = GDISP_VMT_NAME1(gdisp_lld_blitarea_); + gdisp_lld_drawline_VMT = GDISP_VMT_NAME1(gdisp_lld_drawline_); + #if GDISP_NEED_CIRCLE + gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_drawcircle_); + gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME1(gdisp_lld_fillcircle_); + #endif + #if GDISP_NEED_ELLIPSE + gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_drawellipse_); + gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME1(gdisp_lld_fillellipse_); + #endif + #if GDISP_NEED_TEXT + gdisp_lld_drawchar_VMT = GDISP_VMT_NAME1(gdisp_lld_drawchar_); + gdisp_lld_fillchar_VMT = GDISP_VMT_NAME1(gdisp_lld_fillchar_); + #endif + #if GDISP_NEED_PIXELREAD + gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME1(gdisp_lld_pixelread_); + #endif + #if GDISP_NEED_SCROLL + gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME1(gdisp_lld_scroll_); + #endif + #if GDISP_NEED_CONTROL + gdisp_lld_control_VMT = GDISP_VMT_NAME1(gdisp_lld_control_); + #endif + #if GDISP_NEED_QUERY + gdisp_lld_query_VMT = GDISP_VMT_NAME1(gdisp_lld_query_); + #endif + + return TRUE; + } + + if (GDISP_VMT_NAME2(gdisp_lld_init_)()) { + gdisp_lld_clear_VMT = GDISP_VMT_NAME2(gdisp_lld_clear_); + gdisp_lld_drawpixel_VMT = GDISP_VMT_NAME2(gdisp_lld_drawpixel_); + gdisp_lld_fillarea_VMT = GDISP_VMT_NAME2(gdisp_lld_fillarea_); + gdisp_lld_blitarea_VMT = GDISP_VMT_NAME2(gdisp_lld_blitarea_); + gdisp_lld_drawline_VMT = GDISP_VMT_NAME2(gdisp_lld_drawline_); + #if GDISP_NEED_CIRCLE + gdisp_lld_drawcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_drawcircle_); + gdisp_lld_fillcircle_VMT = GDISP_VMT_NAME2(gdisp_lld_fillcircle_); + #endif + #if GDISP_NEED_ELLIPSE + gdisp_lld_drawellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_drawellipse_); + gdisp_lld_fillellipse_VMT = GDISP_VMT_NAME2(gdisp_lld_fillellipse_); + #endif + #if GDISP_NEED_TEXT + gdisp_lld_drawchar_VMT = GDISP_VMT_NAME2(gdisp_lld_drawchar_); + gdisp_lld_fillchar_VMT = GDISP_VMT_NAME2(gdisp_lld_fillchar_); + #endif + #if GDISP_NEED_PIXELREAD + gdisp_lld_getpixelcolor_VMT = GDISP_VMT_NAME2(gdisp_lld_pixelread_); + #endif + #if GDISP_NEED_SCROLL + gdisp_lld_verticalscroll_VMT = GDISP_VMT_NAME2(gdisp_lld_scroll_); + #endif + #if GDISP_NEED_CONTROL + gdisp_lld_control_VMT = GDISP_VMT_NAME2(gdisp_lld_control_); + #endif + #if GDISP_NEED_QUERY + gdisp_lld_query_VMT = GDISP_VMT_NAME2(gdisp_lld_query_); + #endif + + return TRUE; + } + return FALSE; +} + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.mk b/drivers/gdisp/gdispVMT/gdisp_lld.mk new file mode 100644 index 00000000..f89470a6 --- /dev/null +++ b/drivers/gdisp/gdispVMT/gdisp_lld.mk @@ -0,0 +1,7 @@ +# List the required driver. +LCDSRC += ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld.c \ + ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver1.c \ + ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver2.c + +# Required include directories +LCDINC += ${CHIBIOS}/os/halext/drivers/gdispVMT diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_config.h b/drivers/gdisp/gdispVMT/gdisp_lld_config.h new file mode 100644 index 00000000..6c6f7c80 --- /dev/null +++ b/drivers/gdisp/gdispVMT/gdisp_lld_config.h @@ -0,0 +1,67 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispVMT/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header template. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if HAL_USE_GDISP + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "VMT" +#define GDISP_LLD(x) gdisp_lld_##x##_VMT +#define GDISP_LLD_VMT(x) (*GDISP_LLD(x)) + +#define GDISP_HARDWARE_LINES TRUE +#define GDISP_HARDWARE_CLEARS TRUE +#define GDISP_HARDWARE_FILLS TRUE +#define GDISP_HARDWARE_BITFILLS TRUE +#define GDISP_HARDWARE_CIRCLES TRUE +#define GDISP_HARDWARE_CIRCLEFILLS TRUE +#define GDISP_HARDWARE_ELLIPSES TRUE +#define GDISP_HARDWARE_ELLIPSEFILLS TRUE +#define GDISP_HARDWARE_TEXT TRUE +#define GDISP_HARDWARE_TEXTFILLS TRUE +#define GDISP_HARDWARE_SCROLL TRUE +#define GDISP_HARDWARE_PIXELREAD TRUE +#define GDISP_HARDWARE_CONTROL TRUE +#define GDISP_HARDWARE_QUERY TRUE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c b/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c new file mode 100644 index 00000000..f088623e --- /dev/null +++ b/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c @@ -0,0 +1,51 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispVMT/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for VMT. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +#define CONFIGFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld_config.h> +#define DRIVERFILE() <../GDISP_VMT_NAME1(gdisp)/gdisp_lld.c> + +/* We don't need these in our VMT referenced driver */ +#undef GDISP_NEED_MSGAPI +#define GDISP_NEED_MSGAPI FALSE + +/* Include the specific config file we want */ +#include CONFIGFILE() + +/* Bring in our API */ +#include "gdisp.h" + +/* Add the low level driver */ +#include DRIVERFILE() + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c b/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c new file mode 100644 index 00000000..325a53e6 --- /dev/null +++ b/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c @@ -0,0 +1,51 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdispVMT/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source for VMT. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +#define CONFIGFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld_config.h> +#define DRIVERFILE() <../GDISP_VMT_NAME2(gdisp)/gdisp_lld.c> + +/* We don't need these in our VMT referenced driver */ +#undef GDISP_NEED_MSGAPI +#define GDISP_NEED_MSGAPI FALSE + +/* Include the specific config file we want */ +#include CONFIGFILE() + +/* Bring in our API */ +#include "gdisp.h" + +/* Add the low level driver */ +#include DRIVERFILE() + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/drivers/gdisp/gdispVMT/readme.txt b/drivers/gdisp/gdispVMT/readme.txt new file mode 100644 index 00000000..91d3f58c --- /dev/null +++ b/drivers/gdisp/gdispVMT/readme.txt @@ -0,0 +1,23 @@ +This driver enables you to have two underlying drivers handling different hardware. +A choice is made at run-time of which driver to call based on which driver succeeds +to initialise first (init returns TRUE). + +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) Define these: + #define GDISP_VMT_NAME1(x) x##YourDriver1 + #define GDISP_VMT_NAME2(x) x##YourDriver2 + Note YourDriver1 & 2 are the basenames of the directories containing the driver. + Note that both drivers must be the same pixel format which is + GDISP_PIXELFORMAT_RGB565 by default. Alter gdispVMT/gdisp_lld_config.h if your + pixel format is different on both drivers. + d) Any driver specific defines. If both drivers use the same defines then they must + accept the same values for the define. + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispVMT/gdisp_lld.mk + \ No newline at end of file diff --git a/drivers/touchpad/touchpadADS7843/readme.txt b/drivers/touchpad/touchpadADS7843/readme.txt new file mode 100644 index 00000000..34a57bc0 --- /dev/null +++ b/drivers/touchpad/touchpadADS7843/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_TOUCHPAD TRUE + +2. To your makefile add the following lines: + include $(LCDLIB)/lcd.mk + include $(LCDLIB)/halext/drivers/touchpad/touchpadADS7843/touchpad_lld.mk + diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/drivers/touchpad/touchpadADS7843/touchpad_lld.c new file mode 100644 index 00000000..a5265995 --- /dev/null +++ b/drivers/touchpad/touchpadADS7843/touchpad_lld.c @@ -0,0 +1,146 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadADS7843/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + TOUCHPADDriver Touchpad; +#endif + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ + +/** + * @brief Low level Touchpad driver initialization. + * + * @notapi + */ +void tp_lld_init(TOUCHPADDriver *tp) { + spiStart(tp->spid, tp->spicfg); +} + +/** + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t tp_lld_read_x(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0xd0; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; +} + +/* + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t tp_lld_read_y(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; +} + +/* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @noapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.mk b/drivers/touchpad/touchpadADS7843/touchpad_lld.mk new file mode 100644 index 00000000..f70f0dd1 --- /dev/null +++ b/drivers/touchpad/touchpadADS7843/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadADS7843/touchpad_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/touchpad/touchpadADS7843 + diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h b/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h new file mode 100644 index 00000000..1e878795 --- /dev/null +++ b/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h @@ -0,0 +1,44 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadADS7843/touchpad_lld_config.h + * @brief Touchpad Driver subsystem low level driver. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_CONFIG_H +#define _TOUCHPAD_LLD_CONFIG_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define TOUCHPAD_HAS_IRQ TRUE +#define TOUCHPAD_HAS_PRESSURE FALSE + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_CONFIG_H */ +/** @} */ diff --git a/drivers/touchpad/touchpadXPT2046/readme.txt b/drivers/touchpad/touchpadXPT2046/readme.txt new file mode 100644 index 00000000..992d346d --- /dev/null +++ b/drivers/touchpad/touchpadXPT2046/readme.txt @@ -0,0 +1,9 @@ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_TOUCHPAD TRUE + +2. To your makefile add the following lines: + include $(LCDLIB)/lcd.mk + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk + diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/drivers/touchpad/touchpadXPT2046/touchpad_lld.c new file mode 100644 index 00000000..195c8aa6 --- /dev/null +++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -0,0 +1,158 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadXPT2046/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + TOUCHPADDriver Touchpad; +#endif + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ + +/** + * @brief Low level Touchpad driver initialization. + * + * @notapi + */ +void tp_lld_init(TOUCHPADDriver *tp) { + spiStart(tp->spid, tp->spicfg); +} + +/** + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t tp_lld_read_x(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0xd0; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; +} + +/* + * @brief Reads out the Y direction. + * + * @notapi + */ +uint16_t tp_lld_read_y(void) { + uint8_t txbuf[1]; + uint8_t rxbuf[2]; + uint16_t y; + + txbuf[0] = 0x90; + TP_CS_LOW; + spiSend(&SPID1, 1, txbuf); + spiReceive(&SPID1, 2, rxbuf); + TP_CS_HIGH; + + y = rxbuf[0] << 4; + y |= rxbuf[1] >> 4; + + return y; +} + +/* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @notapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + } +#endif + +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) + /* + * @brief Reads out the Z direction / pressure. + * + * @notapi + */ + uint16_t tp_lld_read_z(void) { + /* ToDo */ + return 42; + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk new file mode 100644 index 00000000..26e27c1c --- /dev/null +++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadXPT2046/touchpad_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/touchpad/touchpadXPT2046 + diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h new file mode 100644 index 00000000..4ddd8da0 --- /dev/null +++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h @@ -0,0 +1,44 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadXPT2046/touchpad_lld_config.h + * @brief Touchppad Driver subsystem low level driver. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_CONFIG_H +#define _TOUCHPAD_LLD_CONFIG_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define TOUCHPAD_HAS_IRQ TRUE +#define TOUCHPAD_HAS_PRESSURE TRUE + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_CONFIG_H */ +/** @} */ diff --git a/include/gdisp.h b/include/gdisp.h new file mode 100644 index 00000000..b5a59cf9 --- /dev/null +++ b/include/gdisp.h @@ -0,0 +1,266 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file gdisp.h + * @brief GDISP Graphic Driver subsystem header file. + * + * @addtogroup GDISP + * @{ + */ +#ifndef _GDISP_H +#define _GDISP_H + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/** + * @brief Some basic colors + */ +#define White HTML2COLOR(0xFFFFFF) +#define Black HTML2COLOR(0x000000) +#define Gray HTML2COLOR(0x808080) +#define Grey Gray +#define Blue HTML2COLOR(0x0000FF) +#define Red HTML2COLOR(0xFF0000) +#define Fuchsia HTML2COLOR(0xFF00FF) +#define Magenta Fuchsia +#define Green HTML2COLOR(0x008000) +#define Yellow HTML2COLOR(0xFFFF00) +#define Aqua HTML2COLOR(0x00FFFF) +#define Cyan Aqua +#define Lime HTML2COLOR(0x00FF00) +#define Maroon HTML2COLOR(0x800000) +#define Navy HTML2COLOR(0x000080) +#define Olive HTML2COLOR(0x808000) +#define Purple HTML2COLOR(0x800080) +#define Silver HTML2COLOR(0xC0C0C0) +#define Teal HTML2COLOR(0x008080) +#define Orange HTML2COLOR(0xFFA500) +#define Pink HTML2COLOR(0xFFC0CB) +#define SkyBlue HTML2COLOR(0x87CEEB) + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ + +/** + * @name GDISP more complex functionality to be compiled + * @{ + */ + /** + * @brief Do the drawing functions need to be thread-safe. + * @details Defaults to FALSE + * @note Both GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC make + * the gdisp API thread-safe. + * @note This is more efficient than GDISP_NEED_ASYNC as it only + * requires a context switch if something else is already + * drawing. + */ + #ifndef GDISP_NEED_MULTITHREAD + #define GDISP_NEED_MULTITHREAD FALSE + #endif + + /** + * @brief Use asynchronous calls (multi-thread safe). + * @details Defaults to FALSE + * @note Both GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC make + * the gdisp API thread-safe. + * @note Turning this on adds two context switches per transaction + * so it can significantly slow graphics drawing. + */ + #ifndef GDISP_NEED_ASYNC + #define GDISP_NEED_ASYNC FALSE + #endif +/** @} */ + +#if GDISP_NEED_MULTITHREAD && GDISP_NEED_ASYNC + #error "GDISP: Only one of GDISP_NEED_MULTITHREAD and GDISP_NEED_ASYNC should be defined." +#endif + +#if GDISP_NEED_ASYNC + /* Messaging API is required for Async Multi-Thread */ + #undef GDISP_NEED_MSGAPI + #define GDISP_NEED_MSGAPI TRUE +#endif + +/*===========================================================================*/ +/* Low Level Driver details and error checks. */ +/*===========================================================================*/ + +/* Include the low level driver information */ +#include "gdisp_lld.h" + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +/** + * @brief Type for the text justification. + */ +typedef enum justify {justifyLeft, justifyCenter, justifyRight} justify_t; +/** + * @brief Type for the font metric. + */ +typedef enum fontmetric {fontHeight, fontDescendersHeight, fontLineSpacing, fontCharPadding, fontMinWidth, fontMaxWidth} fontmetric_t; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) +/** + * @brief Predefined fonts. + */ +extern const struct font fontSmall; +extern const struct font fontSmallDouble; +extern const struct font fontSmallNarrow; +extern const struct font fontLarger; +extern const struct font fontLargerDouble; +extern const struct font fontLargerNarrow; +extern const struct font fontUI1; +extern const struct font fontUI1Double; +extern const struct font fontUI1Narrow; +extern const struct font fontUI2; +extern const struct font fontUI2Double; +extern const struct font fontUI2Narrow; +extern const struct font fontLargeNumbers; +extern const struct font fontLargeNumbersDouble; +extern const struct font fontLargeNumbersNarrow; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC + + /* Base Functions */ + bool_t gdispInit(void); + bool_t gdispIsBusy(void); + + /* Drawing Functions */ + void gdispClear(color_t color); + void gdispDrawPixel(coord_t x, coord_t y, color_t color); + void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); + void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); + void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); + + /* Circle Functions */ + #if GDISP_NEED_CIRCLE + void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color); + void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color); + #endif + + /* Ellipse Functions */ + #if GDISP_NEED_ELLIPSE + void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + #endif + + /* Basic Text Rendering Functions */ + #if GDISP_NEED_TEXT + void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color); + void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); + #endif + + /* Read a pixel Function */ + #if GDISP_NEED_PIXELREAD + color_t gdispGetPixelColor(coord_t x, coord_t y); + #endif + + /* Scrolling Function - clears the area scrolled out */ + #if GDISP_NEED_SCROLL + void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); + #endif + + /* Set driver specific control */ + #if GDISP_NEED_CONTROL + void gdispControl(unsigned what, void *value); + #endif + + /* Query driver specific data */ + #if GDISP_NEED_CONTROL + void *gdispQuery(unsigned what); + #endif + +#else + + /* The same as above but use the low level driver directly if no multi-thread support is needed */ + #define gdispInit(gdisp) GDISP_LLD(init)() + #define gdispIsBusy() FALSE + #define gdispClear(color) GDISP_LLD(clear)(color) + #define gdispDrawPixel(x, y, color) GDISP_LLD(drawpixel)(x, y, color) + #define gdispDrawLine(x0, y0, x1, y1, color) GDISP_LLD(drawline)(x0, y0, x1, y1, color) + #define gdispFillArea(x, y, cx, cy, color) GDISP_LLD(fillarea)(x, y, cx, cy, color) + #define gdispBlitArea(x, y, cx, cy, buffer) GDISP_LLD(blitarea)(x, y, cx, cy, buffer) + #define gdispDrawCircle(x, y, radius, color) GDISP_LLD(drawcircle)(x, y, radius, color) + #define gdispFillCircle(x, y, radius, color) GDISP_LLD(fillcircle)(x, y, radius, color) + #define gdispDrawEllipse(x, y, a, b, color) GDISP_LLD(drawellipse)(x, y, a, b, color) + #define gdispFillEllipse(x, y, a, b, color) GDISP_LLD(fillellipse)(x, y, a, b, color) + #define gdispDrawChar(x, y, c, font, color) GDISP_LLD(drawchar)(x, y, c, font, color) + #define gdispFillChar(x, y, c, font, color, bgcolor) GDISP_LLD(fillchar)(x, y, c, font, color, bgcolor) + #define gdispGetPixelColor(x, y) GDISP_LLD(getpixelcolor)(x, y) + #define gdispVerticalScroll(x, y, cx, cy, lines, bgcolor) GDISP_LLD(verticalscroll)(x, y, cx, cy, lines, bgcolor) + #define gdispControl(what, value) GDISP_LLD(control)(what, value) + #define gdispQuery(what) GDISP_LLD(query)(what) + +#endif + +void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); + +/* Extra Text Functions */ +#if GDISP_NEED_TEXT + void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color); + void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor); + void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgColor, justify_t justify); + coord_t gdispGetFontMetric(font_t font, fontmetric_t metric); + coord_t gdispGetCharWidth(char c, font_t font); + coord_t gdispGetStringWidth(const char* str, font_t font); +#endif + +/* Support routine for packed pixel formats */ +#ifndef gdispPackPixels + void gdispPackPixels(const pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color); +#endif + +/* Macro definitions for common gets and sets */ +#define gdispSetPowerMode(powerMode) gdispControl(GDISP_CONTROL_POWER, (void *)(unsigned)(powerMode)) +#define gdispSetOrientation(newOrientation) gdispControl(GDISP_CONTROL_ORITENTATION, (void *)(unsigned)(newOrientation)) +#define gdispSetBacklight(percent) gdispControl(GDISP_CONTROL_BACKLIGHT, (void *)(unsigned)(percent)) +#define gdispSetContrast(percent) gdispControl(GDISP_CONTROL_CONTRAST, (void *)(unsigned)(percent)) + +#define gdispGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH)) +#define gdispGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT)) +#define gdispGetPowerMode() ((gdisp_powermode_t)(unsigned)gdispQuery(GDISP_QUERY_POWER)) +#define gdispGetOrientation() ((gdisp_orientation_t)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) +#define gdispGetBacklight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_BACKLIGHT)) +#define gdispGetContrast() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_CONTRAST)) + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_H */ +/** @} */ diff --git a/include/gdisp_emulation.c b/include/gdisp_emulation.c new file mode 100644 index 00000000..cb3773a7 --- /dev/null +++ b/include/gdisp_emulation.c @@ -0,0 +1,549 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + Emulation routines included into gdisp_lld.c +*/ + +/* + Even though this is a software emulation of a low level driver + most validation doesn't need to happen here as eventually + we call a real low level driver routine and if validation is + required - it will do it. +*/ +#ifndef GDISP_EMULATION_C +#define GDISP_EMULATION_C + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +#ifndef GDISP_LLD_NO_STRUCT + static struct GDISPDriver { + coord_t Width; + coord_t Height; + gdisp_orientation_t Orientation; + gdisp_powermode_t Powermode; + coord_t Backlight; + coord_t Contrast; + } GDISP; +#endif + +#if !GDISP_HARDWARE_CLEARS + void GDISP_LLD(clear)(color_t color) { + GDISP_LLD(fillarea)(0, 0, GDISP.Width, GDISP.Height, color); + } +#endif + +#if !GDISP_HARDWARE_LINES + void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + int16_t dy, dx; + int16_t addx, addy; + int16_t P, diff, i; + + #if GDISP_HARDWARE_FILLS || GDISP_HARDWARE_SCROLL + // speed improvement if vertical or horizontal + if (x0 == x1) { + if (y1 > y0) + GDISP_LLD(fillarea)(x0, y0, 1, y1-y0+1, color); + else + GDISP_LLD(fillarea)(x0, y1, 1, y0-y1+1, color); + return; + } + if (y0 == y1) { + if (x1 > x0) + GDISP_LLD(fillarea)(x0, y0, x1-x0+1, 1, color); + else + GDISP_LLD(fillarea)(x0, y1, x0-x1+1, 1, color); + return; + } + #endif + + if (x1 >= x0) { + dx = x1 - x0; + addx = 1; + } else { + dx = x0 - x1; + addx = -1; + } + if (y1 >= y0) { + dy = y1 - y0; + addy = 1; + } else { + dy = y0 - y1; + addy = -1; + } + + if (dx >= dy) { + dy *= 2; + P = dy - dx; + diff = P - dx; + + for(i=0; i<=dx; ++i) { + GDISP_LLD(drawpixel)(x0, y0, color); + if (P < 0) { + P += dy; + x0 += addx; + } else { + P += diff; + x0 += addx; + y0 += addy; + } + } + } else { + dx *= 2; + P = dx - dy; + diff = P - dy; + + for(i=0; i<=dy; ++i) { + GDISP_LLD(drawpixel)(x0, y0, color); + if (P < 0) { + P += dx; + y0 += addy; + } else { + P += diff; + x0 += addx; + y0 += addy; + } + } + } + } +#endif + +#if !GDISP_HARDWARE_FILLS + void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + #if GDISP_HARDWARE_SCROLL + GDISP_LLD(verticalscroll)(x, y, cx, cy, cy, color); + #elif GDISP_HARDWARE_LINES + coord_t x1, y1; + + x1 = x + cx - 1; + y1 = y + cy; + for(; y < y1; y++) + GDISP_LLD(drawline)(x, y, x1, y, color); + #else + coord_t x0, x1, y1; + + x0 = x; + x1 = x + cx; + y1 = y + cy; + for(; y < y1; y++) + for(x = x0; x < x1; x++) + GDISP_LLD(drawpixel)(x, y, color); + #endif + } +#endif + +#if !GDISP_HARDWARE_BITFILLS + void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + coord_t x0, x1, y1; + + x0 = x; + x1 = x + cx; + y1 = y + cy; + for(; y < y1; y++) + for(x = x0; x < x1; x++) + GDISP_LLD(drawpixel)(x, y, *buffer++); + } +#endif + +#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLES + void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + int16_t a, b, P; + + a = 0; + b = radius; + P = 1 - radius; + + do { + GDISP_LLD(drawpixel)(a+x, b+y, color); + GDISP_LLD(drawpixel)(b+x, a+y, color); + GDISP_LLD(drawpixel)(x-a, b+y, color); + GDISP_LLD(drawpixel)(x-b, a+y, color); + GDISP_LLD(drawpixel)(b+x, y-a, color); + GDISP_LLD(drawpixel)(a+x, y-b, color); + GDISP_LLD(drawpixel)(x-a, y-b, color); + GDISP_LLD(drawpixel)(x-b, y-a, color); + if (P < 0) + P += 3 + 2*a++; + else + P += 5 + 2*(a++ - b--); + } while(a <= b); + } +#endif + +#if GDISP_NEED_CIRCLE && !GDISP_HARDWARE_CIRCLEFILLS + void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + int16_t a, b, P; + + a = 0; + b = radius; + P = 1 - radius; + + do { + GDISP_LLD(drawline)(x-a, y+b, x+a, y+b, color); + GDISP_LLD(drawline)(x-a, y-b, x+a, y-b, color); + GDISP_LLD(drawline)(x-b, y+a, x+b, y+a, color); + GDISP_LLD(drawline)(x-b, y-a, x+b, y-a, color); + if (P < 0) + P += 3 + 2*a++; + else + P += 5 + 2*(a++ - b--); + } while(a <= b); + } +#endif + +#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSES + void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */ + long a2 = a*a, b2 = b*b; + long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */ + + do { + GDISP_LLD(drawpixel)(x+dx, y+dy, color); /* I. Quadrant */ + GDISP_LLD(drawpixel)(x-dx, y+dy, color); /* II. Quadrant */ + GDISP_LLD(drawpixel)(x-dx, y-dy, color); /* III. Quadrant */ + GDISP_LLD(drawpixel)(x+dx, y-dy, color); /* IV. Quadrant */ + + e2 = 2*err; + if(e2 < (2*dx+1)*b2) { + dx++; + err += (2*dx+1)*b2; + } + if(e2 > -(2*dy-1)*a2) { + dy--; + err -= (2*dy-1)*a2; + } + } while(dy >= 0); + + while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */ + GDISP_LLD(drawpixel)(x+dx, y, color); /* -> Spitze der Ellipse vollenden */ + GDISP_LLD(drawpixel)(x-dx, y, color); + } + } +#endif + +#if GDISP_NEED_ELLIPSE && !GDISP_HARDWARE_ELLIPSEFILLS + void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + int dx = 0, dy = b; /* im I. Quadranten von links oben nach rechts unten */ + long a2 = a*a, b2 = b*b; + long err = b2-(2*b-1)*a2, e2; /* Fehler im 1. Schritt */ + + do { + GDISP_LLD(drawline)(x-dx,y+dy,x+dx,y+dy, color); + GDISP_LLD(drawline)(x-dx,y-dy,x+dx,y-dy, color); + + e2 = 2*err; + if(e2 < (2*dx+1)*b2) { + dx++; + err += (2*dx+1)*b2; + } + if(e2 > -(2*dy-1)*a2) { + dy--; + err -= (2*dy-1)*a2; + } + } while(dy >= 0); + + while(dx++ < a) { /* fehlerhafter Abbruch bei flachen Ellipsen (b=1) */ + GDISP_LLD(drawpixel)(x+dx, y, color); /* -> Spitze der Ellipse vollenden */ + GDISP_LLD(drawpixel)(x-dx, y, color); + } + } +#endif + +#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT + #include "gdisp_fonts.h" +#endif + +#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXT + void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { + const fontcolumn_t *ptr; + fontcolumn_t column; + coord_t width, height, xscale, yscale; + coord_t i, j, xs, ys; + + /* Check we actually have something to print */ + width = _getCharWidth(font, c); + if (!width) return; + + xscale = font->xscale; + yscale = font->yscale; + height = font->height * yscale; + width *= xscale; + + ptr = _getCharData(font, c); + + /* Loop through the data and display. The font data is LSBit first, down the column */ + for(i=0; i < width; i+=xscale) { + /* Get the font bitmap data for the column */ + column = *ptr++; + + /* Draw each pixel */ + for(j=0; j < height; j+=yscale, column >>= 1) { + if (column & 0x01) { + for(xs=0; xs < xscale; xs++) + for(ys=0; ys < yscale; ys++) + GDISP_LLD(drawpixel)(x+i+xs, y+j+ys, color); + } + } + } + } +#endif + +#if GDISP_NEED_TEXT && !GDISP_HARDWARE_TEXTFILLS + void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + coord_t width, height; + coord_t xscale, yscale; + + /* Check we actually have something to print */ + width = _getCharWidth(font, c); + if (!width) return; + + xscale = font->xscale; + yscale = font->yscale; + height = font->height * yscale; + width *= xscale; + + /* Method 1: Use background fill and then draw the text */ + #if GDISP_HARDWARE_TEXT || GDISP_SOFTWARE_TEXTFILLDRAW + + /* Fill the area */ + GDISP_LLD(fillarea)(x, y, width, height, bgcolor); + + /* Draw the text */ + GDISP_LLD(drawchar)(x, y, c, font, color); + + /* Method 2: Create a single column bitmap and then blit it */ + #elif GDISP_HARDWARE_BITFILLS && GDISP_SOFTWARE_TEXTBLITCOLUMN + { + const fontcolumn_t *ptr; + fontcolumn_t column; + coord_t i, j, xs, ys; + + /* Working buffer for fast non-transparent text rendering [patch by Badger] + This needs to be larger than the largest character we can print. + Assume the max is double sized by one column. + */ + static pixel_t buf[sizeof(fontcolumn_t)*8*2]; + + #if GDISP_NEED_VALIDATION + /* Check our buffer is big enough */ + if (height > sizeof(buf)/sizeof(buf[0])) return; + #endif + + ptr = _getCharData(font, c); + + /* Loop through the data and display. The font data is LSBit first, down the column */ + for(i = 0; i < width; i+=xscale) { + /* Get the font bitmap data for the column */ + column = *ptr++; + + /* Draw each pixel */ + for(j = 0; j < height; j+=yscale, column >>= 1) { + if (column & 0x01) { + for(ys=0; ys < yscale; ys++) + gdispPackPixels(buf, 1, j+ys, 0, color); + } else { + for(ys=0; ys < yscale; ys++) + gdispPackPixels(buf, 1, j+ys, 0, bgcolor); + } + } + + for(xs=0; xs < xscale; xs++) + GDISP_LLD(blitarea)(x+i+xs, y, 1, height, buf); + } + } + + /* Method 3: Create a character bitmap and then blit it */ + #elif GDISP_HARDWARE_BITFILLS + { + const fontcolumn_t *ptr; + fontcolumn_t column; + coord_t i, j, xs, ys; + + /* Working buffer for fast non-transparent text rendering [patch by Badger] + This needs to be larger than the largest character we can print. + Assume the max is double sized. + */ + static pixel_t buf[20*(sizeof(fontcolumn_t)*8)*2]; + + #if GDISP_NEED_VALIDATION + /* Check our buffer is big enough */ + if ((unsigned)(width * height) > sizeof(buf)/sizeof(buf[0])) return; + #endif + + ptr = _getCharData(font, c); + + /* Loop through the data and display. The font data is LSBit first, down the column */ + for(i = 0; i < width; i+=xscale) { + /* Get the font bitmap data for the column */ + column = *ptr++; + + /* Draw each pixel */ + for(j = 0; j < height; j+=yscale, column >>= 1) { + if (column & 0x01) { + for(xs=0; xs < xscale; xs++) + for(ys=0; ys < yscale; ys++) + gdispPackPixels(buf, width, i+xs, j+ys, color); + } else { + for(xs=0; xs < xscale; xs++) + for(ys=0; ys < yscale; ys++) + gdispPackPixels(buf, width, i+xs, j+ys, bgcolor); + } + } + } + + /* [Patch by Badger] Write all in one stroke */ + GDISP_LLD(blitarea)(x, y, width, height, buf); + } + + /* Method 4: Draw pixel by pixel */ + #else + { + const fontcolumn_t *ptr; + fontcolumn_t column; + coord_t i, j, xs, ys; + + ptr = _getCharData(font, c); + + /* Loop through the data and display. The font data is LSBit first, down the column */ + for(i = 0; i < width; i+=xscale) { + /* Get the font bitmap data for the column */ + column = *ptr++; + + /* Draw each pixel */ + for(j = 0; j < height; j+=yscale, column >>= 1) { + if (column & 0x01) { + for(xs=0; xs < xscale; xs++) + for(ys=0; ys < yscale; ys++) + GDISP_LLD(drawpixel)(x+i, y+j, color); + } else { + for(xs=0; xs < xscale; xs++) + for(ys=0; ys < yscale; ys++) + GDISP_LLD(drawpixel)(x+i, y+j, bgcolor); + } + } + } + } + #endif + } +#endif + + +#if GDISP_NEED_CONTROL && !GDISP_HARDWARE_CONTROL + void GDISP_LLD(control)(unsigned UNUSED(what), void *UNUSED(value)) { + /* Ignore everything */ + } +#endif + +#if GDISP_NEED_QUERY && !GDISP_HARDWARE_QUERY +void *GDISP_LLD(query)(unsigned what) { + switch(what) { + case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; + case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; + case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; + case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; + case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; + case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; + default: return (void *)-1; + } +} +#endif + +#if GDISP_NEED_MSGAPI + void GDISP_LLD(msgdispatch)(gdisp_lld_msg_t *msg) { + switch(msg->action) { + case GDISP_LLD_MSG_NOP: + break; + case GDISP_LLD_MSG_INIT: + GDISP_LLD(init)(); + break; + case GDISP_LLD_MSG_CLEAR: + GDISP_LLD(clear)(msg->clear.color); + break; + case GDISP_LLD_MSG_DRAWPIXEL: + GDISP_LLD(drawpixel)(msg->drawpixel.x, msg->drawpixel.y, msg->drawpixel.color); + break; + case GDISP_LLD_MSG_FILLAREA: + GDISP_LLD(fillarea)(msg->fillarea.x, msg->fillarea.y, msg->fillarea.cx, msg->fillarea.cy, msg->fillarea.color); + break; + case GDISP_LLD_MSG_BLITAREA: + GDISP_LLD(blitarea)(msg->blitarea.x, msg->blitarea.y, msg->blitarea.cx, msg->blitarea.cy, msg->blitarea.buffer); + break; + case GDISP_LLD_MSG_DRAWLINE: + GDISP_LLD(drawline)(msg->drawline.x0, msg->drawline.y0, msg->drawline.x1, msg->drawline.y1, msg->drawline.color); + break; + #if GDISP_NEED_CIRCLE + case GDISP_LLD_MSG_DRAWCIRCLE: + GDISP_LLD(drawcircle)(msg->drawcircle.x, msg->drawcircle.y, msg->drawcircle.radius, msg->drawcircle.color); + break; + case GDISP_LLD_MSG_FILLCIRCLE: + GDISP_LLD(fillcircle)(msg->fillcircle.x, msg->fillcircle.y, msg->fillcircle.radius, msg->fillcircle.color); + break; + #endif + #if GDISP_NEED_ELLIPSE + case GDISP_LLD_MSG_DRAWELLIPSE: + GDISP_LLD(drawellipse)(msg->drawellipse.x, msg->drawellipse.y, msg->drawellipse.a, msg->drawellipse.b, msg->drawellipse.color); + break; + case GDISP_LLD_MSG_FILLELLIPSE: + GDISP_LLD(fillellipse)(msg->fillellipse.x, msg->fillellipse.y, msg->fillellipse.a, msg->fillellipse.b, msg->fillellipse.color); + break; + #endif + #if GDISP_NEED_TEXT + case GDISP_LLD_MSG_DRAWCHAR: + GDISP_LLD(drawchar)(msg->drawchar.x, msg->drawchar.y, msg->drawchar.c, msg->drawchar.font, msg->drawchar.color); + break; + case GDISP_LLD_MSG_FILLCHAR: + GDISP_LLD(fillchar)(msg->fillchar.x, msg->fillchar.y, msg->fillchar.c, msg->fillchar.font, msg->fillchar.color, msg->fillchar.bgcolor); + break; + #endif + #if GDISP_NEED_PIXELREAD + case GDISP_LLD_MSG_GETPIXELCOLOR: + msg->getpixelcolor.result = GDISP_LLD(getpixelcolor)(msg->getpixelcolor.x, msg->getpixelcolor.y); + break; + #endif + #if GDISP_NEED_SCROLL + case GDISP_LLD_MSG_VERTICALSCROLL: + GDISP_LLD(verticalscroll)(msg->verticalscroll.x, msg->verticalscroll.y, msg->verticalscroll.cx, msg->verticalscroll.cy, msg->verticalscroll.lines, msg->verticalscroll.bgcolor); + break; + #endif + #if GDISP_NEED_CONTROL + case GDISP_LLD_MSG_CONTROL: + GDISP_LLD(control)(msg->control.what, msg->control.value); + break; + #endif + #if GDISP_NEED_QUERY + case GDISP_LLD_MSG_QUERY: + msg->query.result = GDISP_LLD(query)(msg->query.what); + break; + #endif + } + } +#endif + +#endif /* HAL_USE_GDISP */ +#endif /* GDISP_EMULATION_C */ diff --git a/include/gdisp_fonts.h b/include/gdisp_fonts.h new file mode 100644 index 00000000..a1a4c3cb --- /dev/null +++ b/include/gdisp_fonts.h @@ -0,0 +1,90 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file gdisp_fonts.h + * @brief GDISP internal font definitions. + * @details This is not generally needed by an application. It is used + * by the low level drivers that need to understand a font. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_FONTS_H +#define _GDISP_FONTS_H + +/* Don't test against HAL_USE_GDISP as we may want to use this in other non-GDISP utilities. */ + +/** + * @brief The maximum height of a font. + * @details Either 16 or 32. Defaults to 16 + * @note Setting this to 32 causes the font tables to take + * twice the internal program memory. + */ +#ifndef GDISP_MAX_FONT_HEIGHT + #define GDISP_MAX_FONT_HEIGHT 16 +#endif + +/** + * @brief The type of a font column. + * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately. + */ +#if GDISP_MAX_FONT_HEIGHT == 16 + typedef uint16_t fontcolumn_t; +#elif GDISP_MAX_FONT_HEIGHT == 32 + typedef uint32_t fontcolumn_t; +#else + #error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32" +#endif + +/** + * @brief Internal font structure. + * @note This structure is followed by: + * 1. An array of character widths (uint8_t) + * 2. An array of column data offsets (relative to the font structure) + * 3. Each characters array of column data (fontcolumn_t) + * Each sub-structure must be padded to a multiple of 8 bytes + * to allow the tables to work across many different compilers. + */ +struct font { + uint8_t height; + uint8_t charPadding; + uint8_t lineSpacing; + uint8_t descenderHeight; + uint8_t minWidth; + uint8_t maxWidth; + char minChar; + char maxChar; + uint8_t xscale; + uint8_t yscale; + const uint8_t *widthTable; + const uint16_t *offsetTable; + const fontcolumn_t *dataTable; + }; + +/** + * @brief Macros to get to the complex parts of the font structure. + */ +#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar]) +#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar]) +#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)]) + +#endif /* _GDISP_FONTS_H */ +/** @} */ diff --git a/include/gdisp_lld.h b/include/gdisp_lld.h new file mode 100644 index 00000000..99865a9f --- /dev/null +++ b/include/gdisp_lld.h @@ -0,0 +1,599 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file gdisp_lld.h + * @brief GDISP Graphic Driver subsystem low level driver header. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_H +#define _GDISP_LLD_H + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Low level driver configuration needs */ +/*===========================================================================*/ + +/** + * @name GDISP low level driver more complex functionality to be compiled + * @{ + */ + /** + * @brief Should all operations be clipped to the screen and colors validated. + * @details Defaults to TRUE. + * @note If this is FALSE, any operations that extend beyond the + * edge of the screen will have undefined results. Any + * out-of-range colors will produce undefined results. + * @note If defined then all low level and high level driver routines + * must check the validity of inputs and do something sensible + * if they are out of range. It doesn't have to be efficient, + * just valid. + */ + #ifndef GDISP_NEED_VALIDATION + #define GDISP_NEED_VALIDATION TRUE + #endif + + /** + * @brief Are circle functions needed. + * @details Defaults to TRUE + */ + #ifndef GDISP_NEED_CIRCLE + #define GDISP_NEED_CIRCLE TRUE + #endif + + /** + * @brief Are ellipse functions needed. + * @details Defaults to TRUE + */ + #ifndef GDISP_NEED_ELLIPSE + #define GDISP_NEED_ELLIPSE TRUE + #endif + + /** + * @brief Are text functions needed. + * @details Defaults to TRUE + */ + #ifndef GDISP_NEED_TEXT + #define GDISP_NEED_TEXT TRUE + #endif + + /** + * @brief Is scrolling needed. + * @details Defaults to FALSE + */ + #ifndef GDISP_NEED_SCROLL + #define GDISP_NEED_SCROLL FALSE + #endif + + /** + * @brief Is the capability to read pixels back needed. + * @details Defaults to FALSE + */ + #ifndef GDISP_NEED_PIXELREAD + #define GDISP_NEED_PIXELREAD FALSE + #endif + + /** + * @brief Control some aspect of the drivers operation. + * @details Defaults to FALSE + */ + #ifndef GDISP_NEED_CONTROL + #define GDISP_NEED_CONTROL FALSE + #endif + + /** + * @brief Query some aspect of the drivers operation. + * @details Defaults to TRUE + */ + #ifndef GDISP_NEED_QUERY + #define GDISP_NEED_QUERY TRUE + #endif + + /** + * @brief Is the messaging api interface required. + * @details Defaults to FALSE + */ + #ifndef GDISP_NEED_MSGAPI + #define GDISP_NEED_MSGAPI FALSE + #endif +/** @} */ + +/*===========================================================================*/ +/* Include the low level driver configuration information */ +/*===========================================================================*/ + +#include "gdisp_lld_config.h" + +/*===========================================================================*/ +/* Constants. */ +/*===========================================================================*/ + +/** + * @brief Driver Control Constants + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + */ +#define GDISP_CONTROL_POWER 0 +#define GDISP_CONTROL_ORIENTATION 1 +#define GDISP_CONTROL_BACKLIGHT 2 +#define GDISP_CONTROL_CONTRAST 3 +#define GDISP_CONTROL_LLD 1000 + +/** + * @brief Driver Query Constants + * @detail Unsupported query codes return (void *)-1. + * @note There are some predefined and some specific to the low level driver. + * @note The result should be typecast the required type. + * @note GDISP_QUERY_WIDTH - Gets the width of the screen + * GDISP_QUERY_HEIGHT - Gets the height of the screen + * GDISP_QUERY_POWER - Get the current powermode + * GDISP_QUERY_ORIENTATION - Get the current orientation + * GDISP_QUERY_BACKLIGHT - Get the backlight state (0 to 100) + * GDISP_QUERY_CONTRAST - Get the contrast. + * GDISP_QUERY_LLD - Low level driver control constants start at + * this value. + */ +#define GDISP_QUERY_WIDTH 0 +#define GDISP_QUERY_HEIGHT 1 +#define GDISP_QUERY_POWER 2 +#define GDISP_QUERY_ORIENTATION 3 +#define GDISP_QUERY_BACKLIGHT 4 +#define GDISP_QUERY_CONTRAST 5 +#define GDISP_QUERY_LLD 1000 + +/** + * @brief Driver Pixel Format Constants + */ +#define GDISP_PIXELFORMAT_RGB565 565 +#define GDISP_PIXELFORMAT_RGB888 888 +#define GDISP_PIXELFORMAT_RGB444 444 +#define GDISP_PIXELFORMAT_RGB332 332 +#define GDISP_PIXELFORMAT_RGB666 666 +#define GDISP_PIXELFORMAT_CUSTOM 99999 +#define GDISP_PIXELFORMAT_ERROR 88888 + +/*===========================================================================*/ +/* Error checks. */ +/*===========================================================================*/ + +/** + * @name GDISP hardware accelerated support + * @{ + */ + /** + * @brief Hardware accelerated line drawing. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_LINES + #define GDISP_HARDWARE_LINES FALSE + #endif + + /** + * @brief Hardware accelerated screen clears. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_CLEARS + #define GDISP_HARDWARE_CLEARS FALSE + #endif + + /** + * @brief Hardware accelerated rectangular fills. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_FILLS + #define GDISP_HARDWARE_FILLS FALSE + #endif + + /** + * @brief Hardware accelerated fills from an image. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_BITFILLS + #define GDISP_HARDWARE_BITFILLS FALSE + #endif + + /** + * @brief Hardware accelerated circles. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_CIRCLES + #define GDISP_HARDWARE_CIRCLES FALSE + #endif + + /** + * @brief Hardware accelerated filled circles. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_CIRCLEFILLS + #define GDISP_HARDWARE_CIRCLEFILLS FALSE + #endif + + /** + * @brief Hardware accelerated ellipses. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_ELLIPSES + #define GDISP_HARDWARE_ELLIPSES FALSE + #endif + + /** + * @brief Hardware accelerated filled ellipses. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_ELLIPSEFILLS + #define GDISP_HARDWARE_ELLIPSEFILLS FALSE + #endif + + /** + * @brief Hardware accelerated text drawing. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_TEXT + #define GDISP_HARDWARE_TEXT FALSE + #endif + + /** + * @brief Hardware accelerated text drawing with a filled background. + * @details If set to @p FALSE software emulation is used. + */ + #ifndef GDISP_HARDWARE_TEXTFILLS + #define GDISP_HARDWARE_TEXTFILLS FALSE + #endif + + /** + * @brief Hardware accelerated scrolling. + * @details If set to @p FALSE there is no support for scrolling. + */ + #ifndef GDISP_HARDWARE_SCROLL + #define GDISP_HARDWARE_SCROLL FALSE + #endif + + /** + * @brief Reading back of pixel values. + * @details If set to @p FALSE there is no support for pixel read-back. + */ + #ifndef GDISP_HARDWARE_PIXELREAD + #define GDISP_HARDWARE_PIXELREAD FALSE + #endif + + /** + * @brief The driver supports one or more control commands. + * @details If set to @p FALSE there is no support for control commands. + */ + #ifndef GDISP_HARDWARE_CONTROL + #define GDISP_HARDWARE_CONTROL FALSE + #endif + + /** + * @brief The driver supports a non-standard query. + * @details If set to @p FALSE there is no support for non-standard queries. + */ + #ifndef GDISP_HARDWARE_QUERY + #define GDISP_HARDWARE_QUERY FALSE + #endif +/** @} */ + +/** + * @name GDISP software algorithm choices + * @{ + */ + /** + * @brief For filled text drawing, use a background fill and then draw + * the text instead of using a blit or direct pixel drawing. + * @details If set to @p TRUE background fill and then text draw is used. + * @note This is ignored if hardware accelerated text is supported. + */ + #ifndef GDISP_SOFTWARE_TEXTFILLDRAW + #define GDISP_SOFTWARE_TEXTFILLDRAW FALSE + #endif + + /** + * @brief For filled text drawing, when using a bitmap blit + * use a column by column buffer rather than a full character + * buffer to save memory at a small performance cost. + * @details If set to @p TRUE background fill one character column at a time. + * @note This is ignored if software text using blit is not being used. + */ + #ifndef GDISP_SOFTWARE_TEXTBLITCOLUMN + #define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + #endif +/** @} */ + +/** + * @name GDISP pixel format choices + * @{ + */ + /** + * @brief The native pixel format for this device + * @note Should be set to one of the following: + * GDISP_PIXELFORMAT_RGB565 + * GDISP_PIXELFORMAT_RGB888 + * GDISP_PIXELFORMAT_RGB444 + * GDISP_PIXELFORMAT_RGB332 + * GDISP_PIXELFORMAT_RGB666 + * GDISP_PIXELFORMAT_CUSTOM + * @note If you set GDISP_PIXELFORMAT_CUSTOM you need to also define + * color_t, RGB2COLOR(r,g,b), HTML2COLOR(h), + * RED_OF(c), GREEN_OF(c), BLUE_OF(c), + * COLOR(c) and MASKCOLOR. + */ + #ifndef GDISP_PIXELFORMAT + #define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_ERROR + #endif + + /** + * @brief Do pixels require packing for a blit + * @note Is only valid for a pixel format that doesn't fill it's datatype. ie formats: + * GDISP_PIXELFORMAT_RGB888 + * GDISP_PIXELFORMAT_RGB444 + * GDISP_PIXELFORMAT_RGB666 + * GDISP_PIXELFORMAT_CUSTOM + * @note If you use GDISP_PIXELFORMAT_CUSTOM and packed bit fills + * you need to also define @P gdispPackPixels(buf,cx,x,y,c) + * @note If you are using GDISP_HARDWARE_BITFILLS = FALSE then the pixel + * format must not be a packed format as the software blit does + * not support packed pixels + * @note Very few cases should actually require packed pixels as the low + * level driver can also pack on the fly as it is sending it + * to the graphics device. + */ + #ifndef GDISP_PACKED_PIXELS + #define GDISP_PACKED_PIXELS FALSE + #endif + + /** + * @brief Do lines of pixels require packing for a blit + * @note Ignored if GDISP_PACKED_PIXELS is FALSE + */ + #ifndef GDISP_PACKED_LINES + #define GDISP_PACKED_LINES FALSE + #endif +/** @} */ + +/*===========================================================================*/ +/* Define the macro's for the various pixel formats */ +/*===========================================================================*/ + +#if defined(__DOXYGEN__) + /** + * @brief The color of a pixel. + */ + typedef uint16_t color_t; + /** + * @brief Convert a number (of any type) to a color_t. + * @details Masks any invalid bits in the color + */ + #define COLOR(c) ((color_t)(c)) + /** + * @brief Does the color_t type contain invalid bits that need masking. + */ + #define MASKCOLOR FALSE + /** + * @brief Convert red, green, blue (each 0 to 255) into a color value. + */ + #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3))) + /** + * @brief Convert a 6 digit HTML code (hex) into a color value. + */ + #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3))) + /** + * @brief Extract the red component (0 to 255) of a color value. + */ + #define RED_OF(c) (((c) & 0xF800)>>8) + /** + * @brief Extract the green component (0 to 255) of a color value. + */ + #define GREEN_OF(c) (((c)&0x007E)>>3) + /** + * @brief Extract the blue component (0 to 255) of a color value. + */ + #define BLUE_OF(c) (((c)&0x001F)<<3) + +#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB565 + typedef uint16_t color_t; + #define COLOR(c) ((color_t)(c)) + #define MASKCOLOR FALSE + #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF8)<<8) | (((g) & 0xFC)<<3) | (((b) & 0xF8)>>3))) + #define HTML2COLOR(h) ((color_t)((((h) & 0xF80000)>>8) | (((h) & 0x00FC00)>>5) | (((h) & 0x0000F8)>>3))) + #define RED_OF(c) (((c) & 0xF800)>>8) + #define GREEN_OF(c) (((c)&0x007E)>>3) + #define BLUE_OF(c) (((c)&0x001F)<<3) + #define RGB565CONVERT(red, green, blue) (uint16_t)( (( red >> 3 ) << 11 ) | (( green >> 2 ) << 5 ) | ( blue >> 3 )) + + +#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB888 + typedef uint32_t color_t; + #define COLOR(c) ((color_t)(((c) & 0xFFFFFF))) + #define MASKCOLOR TRUE + #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xFF)<<16) | (((g) & 0xFF) << 8) | ((b) & 0xFF))) + #define HTML2COLOR(h) ((color_t)(h)) + #define RED_OF(c) (((c) & 0xFF0000)>>16) + #define GREEN_OF(c) (((c)&0x00FF00)>>8) + #define BLUE_OF(c) ((c)&0x0000FF) + +#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB444 + typedef uint16_t color_t; + #define COLOR(c) ((color_t)(((c) & 0x0FFF))) + #define MASKCOLOR TRUE + #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xF0)<<4) | ((g) & 0xF0) | (((b) & 0xF0)>>4))) + #define HTML2COLOR(h) ((color_t)((((h) & 0xF00000)>>12) | (((h) & 0x00F000)>>8) | (((h) & 0x0000F0)>>4))) + #define RED_OF(c) (((c) & 0x0F00)>>4) + #define GREEN_OF(c) ((c)&0x00F0) + #define BLUE_OF(c) (((c)&0x000F)<<4) + +#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB332 + typedef uint8_t color_t; + #define COLOR(c) ((color_t)(c)) + #define MASKCOLOR FALSE + #define RGB2COLOR(r,g,b) ((color_t)(((r) & 0xE0) | (((g) & 0xE0)>>3) | (((b) & 0xC0)>>6))) + #define HTML2COLOR(h) ((color_t)((((h) & 0xE00000)>>16) | (((h) & 0x00E000)>>11) | (((h) & 0x0000C0)>>6))) + #define RED_OF(c) ((c) & 0xE0) + #define GREEN_OF(c) (((c)&0x1C)<<3) + #define BLUE_OF(c) (((c)&0x03)<<6) + +#elif GDISP_PIXELFORMAT == GDISP_PIXELFORMAT_RGB666 + typedef uint32_t color_t; + #define COLOR(c) ((color_t)(((c) & 0x03FFFF))) + #define MASKCOLOR TRUE + #define RGB2COLOR(r,g,b) ((color_t)((((r) & 0xFC)<<10) | (((g) & 0xFC)<<4) | (((b) & 0xFC)>>2))) + #define HTML2COLOR(h) ((color_t)((((h) & 0xFC0000)>>6) | (((h) & 0x00FC00)>>4) | (((h) & 0x0000FC)>>2))) + #define RED_OF(c) (((c) & 0x03F000)>>12) + #define GREEN_OF(c) (((c)&0x00FC00)>>8) + #define BLUE_OF(c) (((c)&0x00003F)<<2) + +#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM + #error "GDISP: No supported pixel format has been specified." +#endif + +/* Verify information for packed pixels and define a non-packed pixel macro */ +#if !GDISP_PACKED_PIXELS + #define gdispPackPixels(buf,cx,x,y,c) { ((color_t *)(buf))[(y)*(cx)+(x)] = (c); } +#elif !GDISP_HARDWARE_BITFILLS + #error "GDISP: packed pixel formats are only supported for hardware accelerated drivers." +#elif GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB888 \ + && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB444 \ + && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_RGB666 \ + && GDISP_PIXELFORMAT != GDISP_PIXELFORMAT_CUSTOM + #error "GDISP: A packed pixel format has been specified for an unsupported pixel format." +#endif + +#if GDISP_NEED_SCROLL && !GDISP_HARDWARE_SCROLL + #error "GDISP: Hardware scrolling is wanted but not supported." +#endif + +#if GDISP_NEED_PIXELREAD && !GDISP_HARDWARE_PIXELREAD + #error "GDISP: Pixel read-back is wanted but not supported." +#endif + +/*===========================================================================*/ +/* Driver types. */ +/*===========================================================================*/ + +/** + * @brief The type for a coordinate or length on the screen. + */ +typedef uint16_t coord_t; +/** + * @brief The type of a pixel. + */ +typedef color_t pixel_t; +/** + * @brief The type of a font. + */ +typedef const struct font *font_t; +/** + * @brief Type for the screen orientation. + */ +typedef enum orientation {portrait, landscape, portraitInv, landscapeInv} gdisp_orientation_t; +/** + * @brief Type for the available power modes for the screen. + */ +typedef enum powermode {powerOff, powerSleep, powerOn} gdisp_powermode_t; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifndef GDISP_LLD_VMT + /* Special magic stuff for the VMT driver */ + #define GDISP_LLD_VMT(x) GDISP_LLD(x) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* Core functions */ + extern bool_t GDISP_LLD(init)(void); + + /* Some of these functions will be implemented in software by the high level driver + depending on the GDISP_HARDWARE_XXX macros defined in gdisp_lld_config.h. + */ + + /* Drawing functions */ + extern void GDISP_LLD_VMT(clear)(color_t color); + extern void GDISP_LLD_VMT(drawpixel)(coord_t x, coord_t y, color_t color); + extern void GDISP_LLD_VMT(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); + extern void GDISP_LLD_VMT(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer); + extern void GDISP_LLD_VMT(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color); + + /* Circular Drawing Functions */ + #if GDISP_NEED_CIRCLE + extern void GDISP_LLD_VMT(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color); + extern void GDISP_LLD_VMT(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color); + #endif + + #if GDISP_NEED_ELLIPSE + extern void GDISP_LLD_VMT(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + extern void GDISP_LLD_VMT(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color); + #endif + + /* Text Rendering Functions */ + #if GDISP_NEED_TEXT + extern void GDISP_LLD_VMT(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color); + extern void GDISP_LLD_VMT(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor); + #endif + + /* Pixel readback */ + #if GDISP_NEED_PIXELREAD + extern color_t GDISP_LLD_VMT(getpixelcolor)(coord_t x, coord_t y); + #endif + + /* Scrolling Function - clears the area scrolled out */ + #if GDISP_NEED_SCROLL + extern void GDISP_LLD_VMT(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor); + #endif + + /* Set driver specific control */ + #if GDISP_NEED_CONTROL + extern void GDISP_LLD_VMT(control)(unsigned what, void *value); + #endif + + /* Query driver specific data */ + #if GDISP_NEED_QUERY + extern void *GDISP_LLD_VMT(query)(unsigned what); + #endif + + /* Messaging API */ + #if GDISP_NEED_MSGAPI + #include "gdisp_lld_msgs.h" + extern void GDISP_LLD(msgdispatch)(gdisp_lld_msg_t *msg); + #endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_H */ +/** @} */ diff --git a/include/gdisp_lld_msgs.h b/include/gdisp_lld_msgs.h new file mode 100644 index 00000000..28a6707e --- /dev/null +++ b/include/gdisp_lld_msgs.h @@ -0,0 +1,165 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/** + * @file gdisp_lld_msgs.h + * @brief GDISP Graphic Driver subsystem low level driver message structures. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_MSGS_H +#define _GDISP_LLD_MSGS_H + +/* This file describes the message API for gdisp_lld */ +#if HAL_USE_GDISP && GDISP_NEED_MSGAPI + +typedef enum gdisp_msgaction { + GDISP_LLD_MSG_NOP, + GDISP_LLD_MSG_INIT, + GDISP_LLD_MSG_CLEAR, + GDISP_LLD_MSG_DRAWPIXEL, + GDISP_LLD_MSG_FILLAREA, + GDISP_LLD_MSG_BLITAREA, + GDISP_LLD_MSG_DRAWLINE, + #if GDISP_NEED_CIRCLE + GDISP_LLD_MSG_DRAWCIRCLE, + GDISP_LLD_MSG_FILLCIRCLE, + #endif + #if GDISP_NEED_ELLIPSE + GDISP_LLD_MSG_DRAWELLIPSE, + GDISP_LLD_MSG_FILLELLIPSE, + #endif + #if GDISP_NEED_TEXT + GDISP_LLD_MSG_DRAWCHAR, + GDISP_LLD_MSG_FILLCHAR, + #endif + #if GDISP_NEED_PIXELREAD + GDISP_LLD_MSG_GETPIXELCOLOR, + #endif + #if GDISP_NEED_SCROLL + GDISP_LLD_MSG_VERTICALSCROLL, + #endif + #if GDISP_NEED_CONTROL + GDISP_LLD_MSG_CONTROL, + #endif + #if GDISP_NEED_QUERY + GDISP_LLD_MSG_QUERY, + #endif +} gdisp_msgaction_t; + +typedef union gdisp_lld_msg { + gdisp_msgaction_t action; + struct gdisp_lld_msg_init { + gdisp_msgaction_t action; // GDISP_LLD_MSG_INIT + } init; + struct gdisp_lld_msg_clear { + gdisp_msgaction_t action; // GDISP_LLD_MSG_CLEAR + color_t color; + } clear; + struct gdisp_lld_msg_drawpixel { + gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWPIXEL + coord_t x, y; + color_t color; + } drawpixel; + struct gdisp_lld_msg_fillarea { + gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLAREA + coord_t x, y; + coord_t cx, cy; + color_t color; + } fillarea; + struct gdisp_lld_msg_blitarea { + gdisp_msgaction_t action; // GDISP_LLD_MSG_BLITAREA + coord_t x, y; + coord_t cx, cy; + const pixel_t *buffer; + } blitarea; + struct gdisp_lld_msg_drawline { + gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWLINE + coord_t x0, y0; + coord_t x1, y1; + color_t color; + } drawline; + struct gdisp_lld_msg_drawcircle { + gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCIRCLE + coord_t x, y; + coord_t radius; + color_t color; + } drawcircle; + struct gdisp_lld_msg_fillcircle { + gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCIRCLE + coord_t x, y; + coord_t radius; + color_t color; + } fillcircle; + struct gdisp_lld_msg_drawellipse { + gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWELLIPSE + coord_t x, y; + coord_t a, b; + color_t color; + } drawellipse; + struct gdisp_lld_msg_fillellipse { + gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLELLIPSE + coord_t x, y; + coord_t a, b; + color_t color; + } fillellipse; + struct gdisp_lld_msg_drawchar { + gdisp_msgaction_t action; // GDISP_LLD_MSG_DRAWCHAR + coord_t x, y; + char c; + font_t font; + color_t color; + } drawchar; + struct gdisp_lld_msg_fillchar { + gdisp_msgaction_t action; // GDISP_LLD_MSG_FILLCHAR + coord_t x, y; + char c; + font_t font; + color_t color; + color_t bgcolor; + } fillchar; + struct gdisp_lld_msg_getpixelcolor { + gdisp_msgaction_t action; // GDISP_LLD_MSG_GETPIXELCOLOR + coord_t x, y; + color_t result; + } getpixelcolor; + struct gdisp_lld_msg_verticalscroll { + gdisp_msgaction_t action; // GDISP_LLD_MSG_VERTICALSCROLL + coord_t x, y; + coord_t cx, cy; + int lines; + color_t bgcolor; + } verticalscroll; + struct gdisp_lld_msg_control { + gdisp_msgaction_t action; // GDISP_LLD_MSG_CONTROL + int what; + void * value; + } control; + struct gdisp_lld_msg_query { + gdisp_msgaction_t action; // GDISP_LLD_MSG_QUERY + int what; + void * result; + } query; +} gdisp_lld_msg_t; + +#endif /* HAL_USE_GDISP */ +#endif /* _GDISP_LLD_MSGS_H */ +/** @} */ diff --git a/include/glcd.h b/include/glcd.h new file mode 100644 index 00000000..ab2f6be2 --- /dev/null +++ b/include/glcd.h @@ -0,0 +1,136 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/* + This file is an emulation of the GLCD interface using the + new GDISP interface. It is probably not a perfect replica, + some code changes may be necessary. + Note it does not replicate the GLCD low level driver, just + the high level interface. + You may also need to define the various GDISP_NEED_XXX in your + halconf.h in order to turn on the functionality you need. +*/ + +#ifndef GLCD_H +#define GLCD_H + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#define PORTRAIT (lcdGetOrientation() == portrait || lcdGetOrientation() == portraitInv) +#define LANDSCAPE (lcdGetOrientation() == landscape || lcdGetOrientation() == landscapeInv) + +#define RGB565CONVERT(r, g, b) RGB2COLOR(r,g,b) + +enum filled {frame, filled}; +enum transparency {solid, transparent}; +#define sleepOn powerSleep +#define sleepOff powerOn + +#define font_Small (&fontSmall) +#define font_SmallDouble (&fontSmallDouble) +#define font_SmallNarrow (&fontSmall) +#define font_Larger (&fontLarger) +#define font_LargerDouble (&fontLargerDouble) +#define font_LargerNarrow (&fontLargerNarrow) +#define font_MediumBold (&fontUI1) +#define font_MediumBoldDouble (&fontUI1Double) +#define font_MediumBoldNarrow (&fontUI1Narrow) +#define font_LargeNumbers (&fontLargeNumbers) +#define font_LargeNumbersDouble (&fontLargeNumbersDouble) +#define font_LargeNumbersNarrow (&fontLargeNumbersNarrow) + +enum glcd_result { GLCD_DONE, + GLCD_FAILED, + GLCD_PROGRESS, + }; + +typedef enum glcd_result glcd_result_t; + +/* Core functions */ +#define lcdInit(dvr) gdispInit(dvr) +static __inline glcd_result_t lcdClear(color_t color) { + gdispClear(color); + return GLCD_DONE; +} +static __inline glcd_result_t lcdSetOrientation(enum orientation newO) { + gdispControl(GDISP_CONTROL_ORIENTATION, (void *)(int)newO); + return ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) == (newO) ? GLCD_DONE : GLCD_FAILED; +} +static __inline glcd_result_t lcdFillArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1,color_t c) { + gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); + return GLCD_DONE; +} +static __inline glcd_result_t lcdWriteArea(coord_t x0, coord_t y0, coord_t x1, coord_t y1, const pixel_t *b, coord_t n) { + (void)n; + gdispBlitArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(b)); + return GLCD_DONE; +} +static __inline glcd_result_t lcdSetPowerMode(enum powermode pm) { + gdispControl(GDISP_CONTROL_POWER, (void *)(int)pm); + return ((enum powermode)(unsigned)gdispQuery(GDISP_QUERY_POWER)) == (pm) ? GLCD_DONE : GLCD_FAILED; +} + +/* Drawing functions */ +static __inline glcd_result_t lcdDrawPixel(coord_t x, coord_t y, color_t c) { + gdispDrawPixel((x),(y),(c)); + return GLCD_DONE; +} +#define lcdDrawLine(x0,y0,x1,y1,c) gdispDrawLine((x0),(y0),(x1),(y1),(c)) +#define lcdDrawRect(x0,y0,x1,y1,f,c) {if(f) gdispFillArea((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c)); else gdispDrawBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(c));} +#define lcdDrawRectString(x0,y0,x1,y1,s,f,c,b) gdispFillStringBox((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,(s),(f),(c),(b),justifyLeft) +#define lcdDrawCircle(x,y,r,f,c) {if(f) gdispFillCircle((x),(y),(r),(c)); else gdispDrawCircle((x),(y),(r),(c));} +#define lcdDrawEllipse(x,y,a,b,f,c) {if(f) gdispFillEllipse((x),(y),(a),(b),(c)); else gdispDrawEllipse((x),(y),(a),(b),(c));} + +/* Text Rendering Functions */ +static __inline coord_t lcdDrawChar(coord_t x, coord_t y, char h, font_t f, color_t c, color_t b, bool_t t) { + if (t) + gdispDrawChar((x),(y),(h),(f),(c)); + else + gdispFillChar((x),(y),(h),(f),(c),(b)); + return gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding); +} +static __inline coord_t lcdDrawString(coord_t x, coord_t y, const char *s, font_t f, color_t c, color_t b, bool_t t) { + if (t) + gdispDrawString((x),(y),(s),(f),(c)); + else + gdispFillString((x),(y),(s),(f),(c),(b)); + return gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding); +} + +/* Character measuring functions */ +#define lcdMeasureChar(h,f) (gdispGetCharWidth((h),(f))+gdispGetFontMetric((f), fontCharPadding)) +#define lcdMeasureString(s,f) (gdispGetStringWidth((s),(f))+gdispGetFontMetric((f), fontCharPadding)) +#define lcdGetFontHeight(f) gdispGetFontMetric((f), fontHeight) + +/* Size and orientation related */ +#define lcdGetHeight() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_HEIGHT)) +#define lcdGetWidth() ((coord_t)(unsigned)gdispQuery(GDISP_QUERY_WIDTH)) +#define lcdGetOrientation() ((enum orientation)(unsigned)gdispQuery(GDISP_QUERY_ORIENTATION)) + +/* BGR->RGB and pixel readback */ +#define lcdBGR2RGB(c) RGB2COLOR(BLUE_OF(c),GREEN_OF(c),RED_OF(c)) +#define lcdGetPixelColor(x,y) gdispGetPixelColor((x),(y)) + +/* Scrolling function */ +#define lcdVerticalScroll(x0,y0,x1,y1,l) gdispVerticalScroll((x0),(y0),(x1)-(x0)+1,(y1)-(y0)+1,l,Black) + +#endif diff --git a/include/touchpad.h b/include/touchpad.h new file mode 100644 index 00000000..445d3202 --- /dev/null +++ b/include/touchpad.h @@ -0,0 +1,93 @@ +/* + ChibiOS-LCD-Driver/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpad.h + * @brief TOUCHPAD Touchpad Driver subsystem header file. + * + * @addgroup TOUCHPAD + * @{ + */ +#ifndef _TOUCHPAD_H +#define _TOUCHPAD_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/** + * @brief specifies how many conversions are made for a readout. + * + * @note higher is more accurate, but takes more time + */ +#define CONVERSIONS 3 + +/*===========================================================================*/ +/* Driver constants. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Low Level Driver details and error checks. */ +/*===========================================================================*/ + +/* Include the low level driver information */ +#include "touchpad_lld.h" + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +/** + * @brief Struct used for calibration + */ +struct cal { + float xm; + float ym; + float xn; + float yn; +}; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#ifdef __cplusplus +extern "C" { +#endif + +void tpInit(TOUCHPADDriver *tp); +uint16_t tpReadX(void); +uint16_t tpReadY(void); + +#if TOUCHPAD_HAS_IRQ + uint8_t tpIRQ(void); +#endif + +#if TOUCHPAD_HAS_PRESSURE + uint16_t tpReadZ(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_H */ +/** @} */ + diff --git a/include/touchpad_lld.h b/include/touchpad_lld.h new file mode 100644 index 00000000..45a561d3 --- /dev/null +++ b/include/touchpad_lld.h @@ -0,0 +1,106 @@ +/* + ChibiOS-LCD-Driver/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpad_lld.h + * @brief TOUCHPAD Driver subsystem low level driver header. + * + * @addgroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_H +#define _TOUCHPAD_LLD_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Include the low level driver configuration information */ +/*===========================================================================*/ + +#include "touchpad_lld_config.h" + +/*===========================================================================*/ +/* Error checks. */ +/*===========================================================================*/ + +#ifndef TOUCHPAD_HAS_IRQ + #define TOUCHPAD_HAS_IRQ FALSE +#endif + +#ifndef TOUCHPAD_HAS_PRESSURE + #define TOUCHPAD_HAS_PRESSURE FALSE +#endif + +/*===========================================================================*/ +/* Driver types. */ +/*===========================================================================*/ + +typedef struct TOUCHPADDriver TOUCHPADDriver; + +/** + * @brief Structure representing a Touchpad driver. + */ +struct TOUCHPADDriver { + /* + * @brief Pointer to SPI driver. + */ + SPIDriver *spid; + + /* + * @brief SPI configuration. + */ + SPIConfig *spicfg; +}; + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + extern TOUCHPADDriver Touchpad; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + + /* Core functions */ + void tp_lld_init(TOUCHPADDriver *tp); + uint16_t tp_lld_read_x(void); + uint16_t tp_lld_read_y(void); + + #if TOUCHPAD_HAS_IRQ + uint8_t tp_lld_irq(void); + #endif + + #if TOUCHPAD_HAS_PRESSURE + uint16_t tp_lld_read_z(void); + #endif + +#ifdef __cplusplus +} +#endif + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_H */ +/** @} */ + diff --git a/old/console.c b/old/console.c new file mode 100644 index 00000000..caddfce2 --- /dev/null +++ b/old/console.c @@ -0,0 +1,171 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "ch.h" + +#include "glcd.h" +#include "console.h" + +/* + * Interface implementation. The interface is write only + */ + +static size_t writes(void *ip, const uint8_t *bp, size_t n) { + return lcdConsoleWrite((GLCDConsole *)ip, bp, n); +} + +static size_t reads(void *ip, uint8_t *bp, size_t n) { + (void)ip; + (void)bp; + (void)n; + + return 0; +} + +static msg_t put(void *ip, uint8_t b) { + return lcdConsolePut((GLCDConsole *)ip, (char)b); +} + +static msg_t get(void *ip) { + (void)ip; + + return RDY_OK; +} + +static msg_t putt(void *ip, uint8_t b, systime_t timeout) { + (void)timeout; + + /* TODO: handle timeout */ + + return lcdConsolePut((GLCDConsole *)ip, (char)b); +} + +static msg_t gett(void *ip, systime_t timeout) { + (void)ip; + (void)timeout; + + return RDY_OK; +} + +static size_t writet(void *ip, const uint8_t *bp, size_t n, systime_t time) { + (void)time; + + return lcdConsoleWrite((GLCDConsole *)ip, bp, n); +} + +static size_t readt(void *ip, uint8_t *bp, size_t n, systime_t time) { + (void)ip; + (void)bp; + (void)n; + (void)time; + + return 0; +} + +static uint16_t getflags(void *ip) { + _chn_get_and_clear_flags_impl(ip); +} + +static const struct GLCDConsoleVMT vmt = { + writes, reads, put, get, + putt, gett, writet, readt, + getflags +}; + + +msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color) { + const uint8_t* ptr; + uint16_t chi; + uint16_t x,y; + + console->vmt = &vmt; + /* read font, get height */ + console->fy = lcdGetFontHeight(font); + + /* calculate the size of the console as an integer multiple of characters height*/ + console->sx = width; + console->sy = (((int16_t)(height/console->fy))-1)*console->fy; + + console->cx = 0; + console->cy = 0; + console->x0 = x0; + console->y0 = y0; + + console->bkcolor = bkcolor; + console->color = color; + + console->font = font; + + lcdFillArea(x0, y0, x0+width, y0+height, console->bkcolor); + return RDY_OK; +} + +msg_t lcdConsolePut(GLCDConsole *console, char c) { + uint8_t width; + + if(c == '\n') { + /* clear the text at the end of the line */ + if(console->cx < console->sx) + lcdFillArea(console->x0 + console->cx, console->y0 + console->cy, + console->x0 + console->sx, console->y0 + console->cy + console->fy, + console->bkcolor); + console->cx = 0; + console->cy += console->fy; + } else if(c == '\r') { + /* TODO: work backwards through the buffer to the start of the current line */ + //console->cx = 0; + } else { + width = lcdMeasureChar(c, console->font); + if((console->cx + width) >= console->sx) { + /* clear the text at the end of the line */ + lcdFillArea(console->x0 + console->cx, console->y0 + console->cy, + console->x0 + console->cx + width, console->y0 + console->cy + console->fy, + console->bkcolor); + console->cx = 0; + console->cy += console->fy; + } + + if((console->cy > console->sy)) { + + lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx, + console->y0 + console->sy + console->fy, console->fy); + /* reset the cursor */ + console->cx = 0; + console->cy = console->sy; + } + + lcdDrawChar(console->x0 + console->cx, console->y0 + console->cy, c, + console->font, console->color, console->bkcolor, solid); + + /* update cursor */ + console->cx += width; + } + return RDY_OK; +} + +msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n) { + size_t i; + for(i = 0; i < n; i++) + lcdConsolePut(console, bp[i]); + + return RDY_OK; +} + + diff --git a/old/console.h b/old/console.h new file mode 100644 index 00000000..f76c5adf --- /dev/null +++ b/old/console.h @@ -0,0 +1,84 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef CONSOLE_H +#define CONSOLE_H + +#include "glcd.h" + +/** + * @brief Structure representing a GLCD driver. + */ +typedef struct GLCDConsole GLCDConsole; + +/** + * @brief @p GLCDConsole specific methods. + */ +#define _glcd_driver_methods \ + _base_asynchronous_channel_methods + +/** + * @extends BaseAsynchronousChannelVMT + * + * @brief @p GLCDConsole virtual methods table. + */ +struct GLCDConsoleVMT { + _glcd_driver_methods +}; + +/** + * @extends BaseAsynchronousChannel + * + * @brief GLCD Console class. + * @details This class extends @p BaseAsynchronousChannel by adding physical + * I/O queues. + */ +struct GLCDConsole { + /** @brief Virtual Methods Table.*/ + const struct GLCDConsoleVMT *vmt; + _base_asynchronous_channel_data + /* WARNING: Do not add any data to this struct above this comment, only below */ + /* font */ + font_t font; + /* lcd area to use */ + uint16_t x0,y0; + /* current cursor position, in pixels */ + uint16_t cx,cy; + /* console size in pixels */ + uint16_t sx,sy; + /* foreground and background colour */ + uint16_t bkcolor, color; + /* font size in pixels */ + uint8_t fy; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color); +msg_t lcdConsolePut(GLCDConsole *console, char c); +msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n); + +#ifdef __cplusplus +} +#endif + +#endif /* CONSOLE_H */ diff --git a/old/graph/graph.c b/old/graph/graph.c new file mode 100644 index 00000000..853ab738 --- /dev/null +++ b/old/graph/graph.c @@ -0,0 +1,75 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "glcd.h" + +#define MARKSIZE 5 // half + +static uint16_t x, y; // origins in graph +static uint16_t grid_X, grid_Y; //grids + +void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color) { + uint16_t i, length; + volatile uint16_t off; + + x = x0; + y = y0; + grid_X = gridX; + grid_Y = gridY; + + // X-Axis + length = x1 - x0; + lcdDrawLine(x0, y0, x1, y0, color); + lcdDrawLine(x1, y0, x1-5, y0+5, color); + lcdDrawLine(x1, y0, x1-5, y0-5, color); + for(i=1; i<(length / grid_X); i++) { + off = x0 + i * grid_X; + lcdDrawLine(off, y0-MARKSIZE, off, y0+MARKSIZE, color); + } + + // Y-Axis + length = y0 - y1; + lcdDrawLine(x0, y0, x0, y1, color); + lcdDrawLine(x0, y1, x0-5, y1+5, color); + lcdDrawLine(x0, y1, x0+5, y1+5, color); + for(i=1; i<(length / grid_Y); i++) { + off = y0 + i * grid_Y; + lcdDrawLine(x0-MARKSIZE, off, x0+MARKSIZE, off, color); + } +} + +void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color) { + uint16_t i; + + for(i = 0; i < entries; i++) + lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, color); +} + +void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor) { + uint16_t i; + + for(i = 0; i < entries; ++i) + lcdDrawLine(coord[i-1][0]+x, y-coord[i-1][1], coord[i][0]+x, y-coord[i][1], lineColor); + for(i = 0; i < entries; ++i) + if(radius != 0) + lcdDrawCircle(coord[i][0]+x, y-coord[i][1], radius, 1, dotColor); +} + + diff --git a/old/graph/graph.h b/old/graph/graph.h new file mode 100644 index 00000000..f4286fc2 --- /dev/null +++ b/old/graph/graph.h @@ -0,0 +1,72 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GRAPH_H +#define GRAPH_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * Description: does draw axis arrows and grid + * + * param: + * - x0, y0, x1, y1: location of arrows + * - gridX, gridY: grid size in X and Y direction + * - color: color of arrows + * + * return: none + */ +void graphDrawSystem(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t gridX, uint16_t gridY, uint16_t color); + +/* + * Description: does draw coordinates into graph as dots + * + * param: + * - coord: two dimensionl array containing X and Y coordinates + * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0]) + * - radius: size of the dots + * - color: color of the dots + * + * return: none + */ +void graphDrawDots(int coord[][2], uint16_t entries, uint16_t radius, uint16_t color); + +/* + * Description: does draw coordinates into graph connected by lines + * + * param: + * - coord: two dimensional array containing X and Y coordinates + * - entries: amount of coordinates passed (sizeof(coord)/sizeof(coord[0]) + * - radius: if not 0, graphDrawDots() gets invoked + * - lineColor: color of the lines + * - dotColor: color of dots, if radius != 0 + * + * return: none + */ +void graphDrawNet(int coord[][2], uint16_t entries, uint16_t radius, uint16_t lineColor, uint16_t dotColor); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/old/graph/graph.mk b/old/graph/graph.mk new file mode 100644 index 00000000..706a9412 --- /dev/null +++ b/old/graph/graph.mk @@ -0,0 +1,3 @@ +LCD_GRAPH_SRC = $(LCDLIB)/graph/graph.c + +LCD_GRAPH_INC = $(LCDLIB)/graph diff --git a/old/gui/gui.c b/old/gui/gui.c new file mode 100644 index 00000000..40553d86 --- /dev/null +++ b/old/gui/gui.c @@ -0,0 +1,334 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "gui.h" + +static struct guiNode_t *firstGUI = NULL; +uint16_t x, y; // global touchpad coordinates + +static uint8_t addElement(struct guiNode_t *newNode) { + struct guiNode_t *new; + + if(firstGUI == NULL) { + firstGUI = chHeapAlloc(NULL, sizeof(struct guiNode_t)); + if(firstGUI == NULL) + return 0; + + *firstGUI = *newNode; + firstGUI->next = NULL; + } else { + new = firstGUI; + while(new->next != NULL) + new = new->next; + + new->next = chHeapAlloc(NULL, sizeof(struct guiNode_t)); + if(new->next == NULL) + return 0; + + new = new->next; + *new = *newNode; + new->next = NULL; + } + + return 1; +} + +static uint8_t deleteElement(char *label) { + struct guiNode_t *pointer, *pointer1; + + if(firstGUI != NULL) { + if(strcmp(firstGUI->label, label) == 0) { + pointer = firstGUI->next; + chHeapFree(firstGUI); + firstGUI = pointer; + } else { + pointer = firstGUI; + + while(pointer->next != NULL) { + pointer1 = pointer->next; + + if(strcmp(firstGUI->label, label) == 0) { + pointer->next = pointer1->next; + chHeapFree(pointer1); + break; + } + + pointer = pointer1; + + } + } + + return 1; // successful + } + + return 0; // not successful +} + +void guiPrintElements(BaseSequentialStream *chp) { + struct guiNode_t *pointer = firstGUI; + + chprintf(chp, "\r\n\nguiNodes:\r\n\n"); + + while(pointer != NULL) { + chprintf(chp, "x0: %d\r\n", pointer->x0); + chprintf(chp, "y0: %d\r\n", pointer->y0); + chprintf(chp, "x1: %d\r\n", pointer->x1); + chprintf(chp, "y1: %d\r\n", pointer->y1); + chprintf(chp, "label: %s\r\n", pointer->label); + chprintf(chp, "active: %d\r\n", *(pointer->active)); + chprintf(chp, "state: %d\r\n", *(pointer->state)); + chprintf(chp, "*next: 0x%x\r\n", pointer->next); + chprintf(chp, "\r\n\n"); + pointer = pointer->next; + } +} + +static inline void buttonUpdate(struct guiNode_t *node) { + if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) { + *(node->state) = 1; + } else { + *(node->state) = 0; + } +} + +static inline void sliderUpdate(struct guiNode_t *node) { + uint16_t length = 1; + + if(node->orientation == horizontal) + length = node->x1 - node->x0; + else if(node->orientation == vertical) + length = node->y1 - node->y0; + + if(node->mode == modePassive) { + node->percentage = *(node->state); + } else if(node->mode == modeActive) { + if(x >= node->x0 && x <= node->x1 && y >= node->y0 && y <= node->y1) { + if(node->orientation == horizontal) { + node->percentage = (((x - node->x0) * 100) / length); + } else if(node->orientation == vertical) { + node->percentage = (((y - node->y0) * 100) / length); + } + } + + *(node->state) = node->percentage; + } + + // a bit of safety here + if(node->percentage > 100) + node->percentage = 100; + + if(node->orientation == horizontal) { + node->value = ((((node->x1)-(node->x0)) * node->percentage) / 100); + if(node->oldValue > node->value || node->value == 0) + lcdFillArea(node->x0+1, node->y0+1, node->x1, node->y1, node->bkColor); + else + lcdDrawRect(node->x0+1, node->y0+1, node->x0+node->value, node->y1, filled, node->valueColor); + } else if(node->orientation == vertical) { + node->value = ((((node->y1)-(node->y0)) * node->percentage) / 100); + if(node->oldValue > node->value || node->value == 0) + lcdFillArea(node->x0+1, node->y0+1, node->x1, node->y1, node->bkColor); + else + lcdDrawRect(node->x0+1, node->y0+1, node->x1, node->y0+node->value, filled, node->valueColor); + } + + node->oldValue = node->value; +} + +static inline void wheelUpdate(struct guiNode_t *node) { + (void)node; +} + +static inline void keymatrixUpdate(struct guiNode_t *node) { + (void)node; +} + +static void guiThread(const uint16_t interval) { + struct guiNode_t *node; + + chRegSetThreadName("GUI"); + + while(TRUE) { + for(node = firstGUI; node; node = node->next) { + // check if GUI element is set active + if(*(node->active) == active) { + x = tpReadX(); + y = tpReadY(); + + switch(node->type) { + case button: + buttonUpdate(node); + break; + case slider: + sliderUpdate(node); + break; + case wheel: + wheelUpdate(node); + break; + case keymatrix: + keymatrixUpdate(node); + break; + } + } + } + + chThdSleepMilliseconds(interval); + } +} + +Thread *guiInit(uint16_t interval, tprio_t priority) { + Thread *tp = NULL; + + tp = chThdCreateFromHeap(NULL, THD_WA_SIZE(512), priority, guiThread, interval); + + return tp; +} + +uint8_t guiDeleteElement(char *label) { + return deleteElement(label); +} + +uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state) { + struct guiNode_t *newNode; + uint16_t i; + + newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); + if(newNode == NULL) + return 0; + + newNode->type = button; + newNode->label = label; + newNode->x0 = x0; + newNode->y0 = y0; + newNode->x1 = x1; + newNode->y1 = y1; + newNode->shadow = shadow; + newNode->active = active; + newNode->state = state; + + if(addElement(newNode) != 1) + return 0; + + lcdDrawRectString(x0, y0, x1, y1, str, font, fontColor, buttonColor); + + if(shadow != 0) { + for(i = 0; i < shadow; i++) { + lcdDrawLine(x0+shadow, y1+i, x1+shadow-1, y1+i, Black); + lcdDrawLine(x1+i, y0+shadow, x1+i, y1+shadow-1, Black); + } + } + + chHeapFree(newNode); + + return 1; +} + +uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value) { + struct guiNode_t *newNode; + + newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); + if(newNode == NULL) + return 0; + + newNode->type = slider; + newNode->label = label; + newNode->x0 = x0; + newNode->y0 = y0; + newNode->x1 = x1; + newNode->y1 = y1; + newNode->mode = mode; + newNode->bkColor = bkColor; + newNode->valueColor = valueColor; + newNode->state = value; + newNode->active = active; + newNode->orientation = orientation; + newNode->percentage = 0; + + if(addElement(newNode) != 1) + return 0; + + (void)bkColor; + (void)valueColor; + + // lcdDraw functions + lcdDrawRect(x0, y0, x1, y1, frame, frameColor); + + chHeapFree(newNode); + + return 1; +} + +uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value) { + struct guiNode_t *newNode; + + newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); + if(newNode == NULL) + return 0; + + newNode->type = wheel; + newNode->label = label; + newNode->x0 = x0; + newNode->y0 = y0; + newNode->r1 = radius1; + newNode->r2 = radius2; + newNode->active = active; + newNode->state = value; + + if(addElement(newNode) != 1) + return 0; + + (void)bkColor; + (void)valueColor; + // lcdDraw functions + + chHeapFree(newNode); + + return 1; +} + +uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t size, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value) { + struct guiNode_t *newNode; + + newNode = chHeapAlloc(NULL, sizeof(struct guiNode_t)); + if(newNode == NULL) + return 0; + + newNode->type = keymatrix; + newNode->label = label; + newNode->x0 = x0; + newNode->y0 = y0; + newNode->shadow = shadow; + newNode->active = active; + newNode->state = value; + + if(addElement(newNode) != 1) + return 0; + + // lcdDraw functions + (void)size; + (void)space; + (void)buttonColor; + (void)fontColor; + (void)font; + + chHeapFree(newNode); + + return 1; +} + diff --git a/old/gui/gui.h b/old/gui/gui.h new file mode 100644 index 00000000..04d9a8b1 --- /dev/null +++ b/old/gui/gui.h @@ -0,0 +1,115 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef GUI_H +#define GUI_H + +#include "ch.h" +#include "hal.h" +#include "glcd.h" +#include "chprintf.h" +#include "touchpad.h" +#include + +struct guiNode_t { + uint8_t type; + uint16_t x0; + uint16_t y0; + uint16_t x1; + uint16_t y1; + uint16_t r1; + uint16_t r2; + uint16_t shadow; + uint16_t bkColor; + uint16_t valueColor; + uint16_t value; + uint16_t oldValue; + uint16_t percentage; + uint8_t orientation; + uint8_t mode; + uint8_t *active; + uint8_t *state; + char *label; + struct guiNode_t *next; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +enum {button, slider, wheel, keymatrix}; +enum {horizontal, vertical}; +enum {inactive, active}; +enum {modePassive, modeActive}; + +/* + * Description: creates the GUI thread + * + * param: - interval: thread sleep in milliseconds after each GUI element update + * - priority: priority of the thread + * + * return: pointer to created thread + */ +Thread *guiInit(uint16_t interval, tprio_t priority); + +/* + * Description: prints all GUI elements structs (linked list) + * + * param: - chp: pointer to output stream + * + * return: none + */ +void guiPrintElements(BaseSequentialStream *chp); + +/* + * Description: deletes a GUI element from the linked list + * + * param: - label: label of the element (parameter of each guiDrawXXX function) + * + * return: 1 if successful, 0 otherwise + */ +uint8_t guiDeleteElement(char *label); + +/* + * Description: draws a button on the screen and keeps it's state up to date + * + * param: - x0, y0, x1, y1: start and end coordinates of the button's rectangle + * - str: string that gets drawn into the rectangle - button's lable + * - fontColor: color of the lable + * - buttonColor: color of the rectangle + * - shadow: draws a black shadow with N pixels size if != 0 + * - active: pass pointer to variable which holds the state 'active' or 'inactive' + * - state: pass pointer to variable whcih will keep the state of the button (pressed / unpressed)' + * + * return: 1 if button successfully created + */ +uint8_t guiDrawButton(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, char *str, font_t font, uint16_t fontColor, uint16_t buttonColor, uint16_t shadow, char *label, uint8_t *active, uint8_t *state); + +uint8_t guiDrawSlider(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint8_t orientation, uint8_t mode, uint16_t frameColor, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value); + +uint8_t guiDrawWheel(uint16_t x0, uint16_t y0, uint16_t radius1, uint16_t radius2, uint16_t bkColor, uint16_t valueColor, char *label, uint8_t *active, uint8_t *value); + +uint8_t guiDrawKeymatrix(uint16_t x0, uint16_t y0, uint16_t buttonSize, uint16_t space, uint16_t shadow, uint16_t buttonColor, uint16_t fontColor, font_t font, char *label, uint8_t *active, uint8_t *value); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/old/gui/gui.mk b/old/gui/gui.mk new file mode 100644 index 00000000..e25cbd73 --- /dev/null +++ b/old/gui/gui.mk @@ -0,0 +1,3 @@ +LCD_GUI_SRC = $(LCDLIB)/gui/gui.c + +LCD_GUI_INC = $(LCDLIB)/gui diff --git a/readme1.txt b/readme1.txt new file mode 100644 index 00000000..907c7eb4 --- /dev/null +++ b/readme1.txt @@ -0,0 +1,28 @@ +To include any of these functions/drivers in your project... + + 1/ Specify the path to the LCDLIB. If none defined, default is $(CHIBIOS)/ext/lcd + + 2/ In your project Makefile (amongst similiar lines but after the hal line) add the line... + include $(LCDLIB)/lcd.mk + + 3/ In your project Makefile add the makefiles for any specific drivers you want e.g + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk + include $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.mk + + 4/ In your project halconf.h turn on the support you want eg. + /** + * @brief Enables the Touchpad subsystem. + */ + #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) + #define HAL_USE_TOUCHPAD TRUE + #endif + /** + * @brief Enables the GDISP subsystem. + */ + #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__) + #define HAL_USE_GDISP TRUE + /* Any driver specific defines required go here. The below line is an example. */ + #define GDISP_NEED_MULTITHREAD TRUE + #endif + 5/ Do a make clean. + diff --git a/readme2.txt b/readme2.txt new file mode 100644 index 00000000..0b67c9b0 --- /dev/null +++ b/readme2.txt @@ -0,0 +1,19 @@ +## Doxygen +run doxygen in the toplevel directory to generate the doxygen documentation in html + + + +## Wiki +please read the wiki pages to this project carefully, before you ask any questions: + +http://chibios.org/dokuwiki/doku.php?id=chibios:community + + + +## Maintainer & Contributors +please read the contributors.txt file which contains a full history of each contribution + +Maintainer: + - Joel Bodenmann aka Tectu + + diff --git a/src/gdisp-readme.txt b/src/gdisp-readme.txt new file mode 100644 index 00000000..12b00e2c --- /dev/null +++ b/src/gdisp-readme.txt @@ -0,0 +1,14 @@ +The new GDISP driver is an architecture independant rewrite of the GLCD interface. +This new architecture independance should allow many new low level drivers to be easily added. + +GDISP allows low-level driver hardware accelerated drawing routines while providing a software emulation +if the low level driver can not provide it. A basic low level driver now only requires 2 routines to be written. + +A glcd.h compatability file has been included that allow applications written to use the existing GLCD driver to +use the GDISP driver with little or no change. + +It is written in the ChibiOS style with ChibiOS style includes and documentation. + +It is encapsulated into a "halext" structure with appropriate readme's that allow for easy inclusion in any +ChibiOS project. This structure can be seamlessly added to as new driver types are added and it supports +low level drivers that are neither platform or board specific (although they can be). diff --git a/src/gdisp.c b/src/gdisp.c new file mode 100644 index 00000000..ee2b98e4 --- /dev/null +++ b/src/gdisp.c @@ -0,0 +1,997 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file gdisp.c + * @brief GDISP Driver code. + * + * @addtogroup GDISP + * @{ + */ +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#ifndef _GDISP_C +#define _GDISP_C + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +#ifdef GDISP_NEED_TEXT + #include "gdisp_fonts.h" +#endif + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +#if GDISP_NEED_MULTITHREAD + #if !CH_USE_MUTEXES + #error "GDISP: CH_USE_MUTEXES must be defined in chconf.h because GDISP_NEED_MULTITHREAD is defined" + #endif +#endif + +#if GDISP_NEED_ASYNC + #if !CH_USE_MAILBOXES || !CH_USE_MUTEXES || !CH_USE_SEMAPHORES + #error "GDISP: CH_USE_MAILBOXES, CH_USE_SEMAPHORES and CH_USE_MUTEXES must be defined in chconf.h because GDISP_NEED_ASYNC is defined" + #endif +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +#if GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC + static Mutex gdispMutex; +#endif + +#if GDISP_NEED_ASYNC + #define GDISP_THREAD_STACK_SIZE 512 /* Just a number - not yet a reflection of actual use */ + #define GDISP_QUEUE_SIZE 8 /* We only allow a short queue */ + + static Thread * lldThread; + static Mailbox gdispMailbox; + static msg_t gdispMailboxQueue[GDISP_QUEUE_SIZE]; + static Semaphore gdispMsgsSem; + static Mutex gdispMsgsMutex; + static gdisp_lld_msg_t gdispMsgs[GDISP_QUEUE_SIZE]; + static WORKING_AREA(waGDISPThread, GDISP_THREAD_STACK_SIZE); +#endif + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#if GDISP_NEED_ASYNC + static msg_t GDISPThreadHandler(void *UNUSED(arg)) { + gdisp_lld_msg_t *pmsg; + + #if CH_USE_REGISTRY + chRegSetThreadName("GDISPAsyncAPI"); + #endif + + while(1) { + /* Wait for msg with work to do. */ + chMBFetch(&gdispMailbox, (msg_t *)&pmsg, TIME_INFINITE); + + /* OK - we need to obtain the mutex in case a synchronous operation is occurring */ + chMtxLock(&gdispMutex); + GDISP_LLD(msgdispatch)(pmsg); + chMtxUnlock(); + + /* Mark the message as free */ + pmsg->action = GDISP_LLD_MSG_NOP; + chSemSignal(&gdispMsgsSem); + } + return 0; + } + + static gdisp_lld_msg_t *gdispAllocMsg(gdisp_msgaction_t action) { + gdisp_lld_msg_t *p; + + while(1) { /* To be sure, to be sure */ + + /* Wait for a slot */ + chSemWait(&gdispMsgsSem); + + /* Find the slot */ + chMtxLock(&gdispMsgsMutex); + for(p=gdispMsgs; p < &gdispMsgs[GDISP_QUEUE_SIZE]; p++) { + if (p->action == GDISP_LLD_MSG_NOP) { + /* Allocate it */ + p->action = action; + chMtxUnlock(); + return p; + } + } + chMtxUnlock(); + + /* Oops - none found, try again */ + chSemSignal(&gdispMsgsSem); + } + } +#endif + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief GDISP Driver initialization. + * @note This function is NOT currently implicitly invoked by @p halInit(). + * It must be called manually. + * + * @init + */ + bool_t gdispInit(void) { + bool_t res; + + /* Initialise Mutex */ + chMtxInit(&gdispMutex); + + /* Initialise driver */ + chMtxLock(&gdispMutex); + res = GDISP_LLD(init)(); + chMtxUnlock(); + + return res; + } +#elif GDISP_NEED_ASYNC + bool_t gdispInit(void) { + bool_t res; + unsigned i; + + /* Mark all the Messages as free */ + for(i=0; i < GDISP_QUEUE_SIZE; i++) + gdispMsgs[i].action = GDISP_LLD_MSG_NOP; + + /* Initialise our Mailbox, Mutex's and Counting Semaphore. + * A Mutex is required as well as the Mailbox and Thread because some calls have to be synchronous. + * Synchronous calls get handled by the calling thread, asynchronous by our worker thread. + */ + chMBInit(&gdispMailbox, gdispMailboxQueue, sizeof(gdispMailboxQueue)/sizeof(gdispMailboxQueue[0])); + chMtxInit(&gdispMutex); + chMtxInit(&gdispMsgsMutex); + chSemInit(&gdispMsgsSem, GDISP_QUEUE_SIZE); + + lldThread = chThdCreateStatic(waGDISPThread, sizeof(waGDISPThread), NORMALPRIO, GDISPThreadHandler, NULL); + + /* Initialise driver - synchronous */ + chMtxLock(&gdispMutex); + res = GDISP_LLD(init)(); + chMtxUnlock(); + + return res; + } +#endif + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Test if the GDISP engine is currently drawing. + * @note This function will always return FALSE if + * GDISP_NEED_ASYNC is not defined. + * + * @init + */ + bool_t gdispIsBusy(void) { + return FALSE; + } +#elif GDISP_NEED_ASYNC + bool_t gdispIsBusy(void) { + return chMBGetUsedCountI(&gdispMailbox) != FALSE; + } +#endif + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Clear the display to the specified color. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] color The color to use when clearing the screen + * + * @api + */ + void gdispClear(color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(clear)(color); + chMtxUnlock(); + } +#elif GDISP_NEED_ASYNC + void gdispClear(color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_CLEAR); + p->clear.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Set a pixel in the specified color. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x,y The position to set the pixel. + * @param[in] color The color to use + * + * @api + */ + void gdispDrawPixel(coord_t x, coord_t y, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(drawpixel)(x, y, color); + chMtxUnlock(); + } +#elif GDISP_NEED_ASYNC + void gdispDrawPixel(coord_t x, coord_t y, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWPIXEL); + p->drawpixel.x = x; + p->drawpixel.y = y; + p->drawpixel.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The start position + * @param[in] x1,y1 The end position + * @param[in] color The color to use + * + * @api + */ + void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(drawline)(x0, y0, x1, y1, color); + chMtxUnlock(); + } +#elif GDISP_NEED_ASYNC + void gdispDrawLine(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWLINE); + p->drawline.x0 = x0; + p->drawline.y0 = y0; + p->drawline.x1 = x1; + p->drawline.y1 = y1; + p->drawline.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The start position + * @param[in] cx,cy The size of the box (outside dimensions) + * @param[in] color The color to use + * + * @api + */ + void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(fillarea)(x, y, cx, cy, color); + chMtxUnlock(); + } +#elif GDISP_NEED_ASYNC + void gdispFillArea(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLAREA); + p->fillarea.x = x; + p->fillarea.y = y; + p->fillarea.cx = cx; + p->fillarea.cy = cy; + p->fillarea.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if GDISP_NEED_MULTITHREAD || defined(__DOXYGEN__) + /** + * @brief Fill an area using the supplied bitmap. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * @details The bitmap is in the pixel format specified by the low level driver + * @note If a packed pixel format is used and the width doesn't + * match a whole number of bytes, the next line will start on a + * non-byte boundary (no end-of-line padding). + * @note If GDISP_NEED_ASYNC is defined then the buffer must be static + * or at least retained until this call has finished the blit. You can + * tell when all graphics drawing is finished by @p gdispIsBusy() going FALSE. + * + * @param[in] x0,y0 The start position + * @param[in] cx,cy The size of the filled area + * @param[in] buffer The bitmap in the driver's pixel format. + * + * @api + */ + void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + chMtxLock(&gdispMutex); + GDISP_LLD(blitarea)(x, y, cx, cy, buffer); + chMtxUnlock(); + } +#elif GDISP_NEED_ASYNC + void gdispBlitArea(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_BLITAREA); + p->blitarea.x = x; + p->blitarea.y = y; + p->blitarea.cx = cx; + p->blitarea.cy = cy; + p->blitarea.buffer = buffer; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The center of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color to use + * + * @api + */ + void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(drawcircle)(x, y, radius, color); + chMtxUnlock(); + } +#elif GDISP_NEED_CIRCLE && GDISP_NEED_ASYNC + void gdispDrawCircle(coord_t x, coord_t y, coord_t radius, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWCIRCLE); + p->drawcircle.x = x; + p->drawcircle.y = y; + p->drawcircle.radius = radius; + p->drawcircle.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Draw a filled circle. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The center of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color to use + * + * @api + */ + void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(fillcircle)(x, y, radius, color); + chMtxUnlock(); + } +#elif GDISP_NEED_CIRCLE && GDISP_NEED_ASYNC + void gdispFillCircle(coord_t x, coord_t y, coord_t radius, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLCIRCLE); + p->fillcircle.x = x; + p->fillcircle.y = y; + p->fillcircle.radius = radius; + p->fillcircle.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The center of the ellipse + * @param[in] a,b The dimensions of the ellipse + * @param[in] color The color to use + * + * @api + */ + void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(drawellipse)(x, y, a, b, color); + chMtxUnlock(); + } +#elif GDISP_NEED_ELLIPSE && GDISP_NEED_ASYNC + void gdispDrawEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWELLIPSE); + p->drawellipse.x = x; + p->drawellipse.y = y; + p->drawellipse.a = a; + p->drawellipse.b = b; + p->drawellipse.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Draw a filled ellipse. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The center of the ellipse + * @param[in] a,b The dimensions of the ellipse + * @param[in] color The color to use + * + * @api + */ + void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(fillellipse)(x, y, a, b, color); + chMtxUnlock(); + } +#elif GDISP_NEED_ELLIPSE && GDISP_NEED_ASYNC + void gdispFillEllipse(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLELLIPSE); + p->fillellipse.x = x; + p->fillellipse.y = y; + p->fillellipse.a = a; + p->fillellipse.b = b; + p->fillellipse.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Draw a text character. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x,y The position for the text + * @param[in] c The character to draw + * @param[in] color The color to use + * + * @api + */ + void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color) { + chMtxLock(&gdispMutex); + GDISP_LLD(drawchar)(x, y, c, font, color); + chMtxUnlock(); + } +#elif GDISP_NEED_TEXT && GDISP_NEED_ASYNC + void gdispDrawChar(coord_t x, coord_t y, char c, font_t font, color_t color) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_DRAWCHAR); + p->drawchar.x = x; + p->drawchar.y = y; + p->drawchar.c = c; + p->drawchar.font = font; + p->drawchar.color = color; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Draw a text character with a filled background. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x,y The position for the text + * @param[in] c The character to draw + * @param[in] color The color to use + * @param[in] bgcolor The background color to use + * + * @api + */ + void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + chMtxLock(&gdispMutex); + GDISP_LLD(fillchar)(x, y, c, font, color, bgcolor); + chMtxUnlock(); + } +#elif GDISP_NEED_TEXT && GDISP_NEED_ASYNC + void gdispFillChar(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_FILLCHAR); + p->fillchar.x = x; + p->fillchar.y = y; + p->fillchar.c = c; + p->fillchar.font = font; + p->fillchar.color = color; + p->fillchar.bgcolor = bgcolor; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_PIXELREAD && (GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC)) || defined(__DOXYGEN__) + /** + * @brief Get the color of a pixel. + * @return The color of the pixel. + * + * @param[in] x,y The position of the pixel + * + * @api + */ + color_t gdispGetPixelColor(coord_t x, coord_t y) { + color_t c; + + /* Always synchronous as it must return a value */ + chMtxLock(&gdispMutex); + c = GDISP_LLD(getpixelcolor)(x, y); + chMtxUnlock(); + + return c; + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @api + */ + void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + chMtxLock(&gdispMutex); + GDISP_LLD(verticalscroll)(x, y, cx, cy, lines, bgcolor); + chMtxUnlock(); + } +#elif GDISP_NEED_SCROLL && GDISP_NEED_ASYNC + void gdispVerticalScroll(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_VERTICALSCROLL); + p->verticalscroll.x = x; + p->verticalscroll.y = y; + p->verticalscroll.cx = cx; + p->verticalscroll.cy = cy; + p->verticalscroll.lines = lines; + p->verticalscroll.bgcolor = bgcolor; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_NEED_MULTITHREAD) || defined(__DOXYGEN__) + /** + * @brief Set the power mode for the display. + * @pre The GDISP unit must have been initialised using @p gdispInit(). + * @note Depending on the hardware implementation this function may not + * support some codes. They will be ignored. + * + * @param[in] powerMode The power mode to use + * + * @api + */ + void gdispControl(unsigned what, void *value) { + chMtxLock(&gdispMutex); + GDISP_LLD(control)(what, value); + chMtxUnlock(); + } +#elif GDISP_NEED_CONTROL && GDISP_NEED_ASYNC + void gdispControl(unsigned what, void *value) { + gdisp_lld_msg_t *p = gdispAllocMsg(GDISP_LLD_MSG_CONTROL); + p->control.what = what; + p->control.value = value; + chMBPost(&gdispMailbox, (msg_t)p, TIME_INFINITE); + } +#endif + +#if (GDISP_NEED_QUERY && (GDISP_NEED_MULTITHREAD || GDISP_NEED_ASYNC)) || defined(__DOXYGEN__) + /** + * @brief Query a property of the display. + * @pre The GDISP unit must have been initialised using @p gdispInit(). + * @note The result must be typecast to the correct type. + * @note An uunsupported query will return (void *)-1. + * + * @param[in] what What to query + * + * @api + */ + void *gdispQuery(unsigned what) { + void *res; + + chMtxLock(&gdispMutex); + res = GDISP_LLD(query)(what); + chMtxUnlock(); + return res; + } +#endif + +/*===========================================================================*/ +/* High Level Driver Routines. */ +/*===========================================================================*/ + +/** + * @brief Draw a rectangular box. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x0,y0 The start position + * @param[in] cx,cy The size of the box (outside dimensions) + * @param[in] color The color to use + * @param[in] filled Should the box should be filled + * + * @api + */ +void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + /* No mutex required as we only call high level functions which have their own mutex */ + coord_t x1, y1; + + x1 = x+cx-1; + y1 = y+cy-1; + + if (cx > 2) { + if (cy >= 1) { + gdispDrawLine(x, y, x1, y, color); + if (cy >= 2) { + gdispDrawLine(x, y1, x1, y1, color); + if (cy > 2) { + gdispDrawLine(x, y+1, x, y1-1, color); + gdispDrawLine(x1, y+1, x1, y1-1, color); + } + } + } + } else if (cx == 2) { + gdispDrawLine(x, y, x, y1, color); + gdispDrawLine(x1, y, x1, y1, color); + } else if (cx == 1) { + gdispDrawLine(x, y, x, y1, color); + } +} + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) + /** + * @brief Draw a text string. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x,y The position for the text + * @param[in] str The string to draw + * @param[in] color The color to use + * + * @api + */ + void gdispDrawString(coord_t x, coord_t y, const char *str, font_t font, color_t color) { + /* No mutex required as we only call high level functions which have their own mutex */ + coord_t w, p; + char c; + int first; + + first = 1; + p = font->charPadding * font->xscale; + while(*str) { + /* Get the next printable character */ + c = *str++; + w = _getCharWidth(font, c) * font->xscale; + if (!w) continue; + + /* Handle inter-character padding */ + if (p) { + if (!first) + x += p; + else + first = 0; + } + + /* Print the character */ + gdispDrawChar(x, y, c, font, color); + x += w; + } + } +#endif + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) + /** + * @brief Draw a text string. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * + * @param[in] x,y The position for the text + * @param[in] str The string to draw + * @param[in] color The color to use + * @param[in] bgcolor The background color to use + * + * @api + */ + void gdispFillString(coord_t x, coord_t y, const char *str, font_t font, color_t color, color_t bgcolor) { + /* No mutex required as we only call high level functions which have their own mutex */ + coord_t w, h, p; + char c; + int first; + + first = 1; + h = font->height * font->yscale; + p = font->charPadding * font->xscale; + while(*str) { + /* Get the next printable character */ + c = *str++; + w = _getCharWidth(font, c) * font->xscale; + if (!w) continue; + + /* Handle inter-character padding */ + if (p) { + if (!first) { + gdispFillArea(x, y, p, h, bgcolor); + x += p; + } else + first = 0; + } + + /* Print the character */ + gdispFillChar(x, y, c, font, color, bgcolor); + x += w; + } + } +#endif + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) + /** + * @brief Draw a text string verticly centered within the specified box. + * @pre The GDISP unit must be in powerOn or powerSleep mode. + * @note The entire box is filled + * + * @param[in] x,y The position for the text (need to define top-right or base-line - check code) + * @param[in] str The string to draw + * @param[in] color The color to use + * @param[in] bgcolor The background color to use + * @param[in] justify Justify the text left, center or right within the box + * + * @api + */ + void gdispFillStringBox(coord_t x, coord_t y, coord_t cx, coord_t cy, const char* str, font_t font, color_t color, color_t bgcolor, justify_t justify) { + /* No mutex required as we only call high level functions which have their own mutex */ + coord_t w, h, p, ypos, xpos; + char c; + int first; + const char *rstr; + + h = font->height * font->yscale; + p = font->charPadding * font->xscale; + + /* Oops - font too large for the area */ + if (h > cy) return; + + /* See if we need to fill above the font */ + ypos = (cy - h + 1)/2; + if (ypos > 0) { + gdispFillArea(x, y, cx, ypos, bgcolor); + y += ypos; + cy -= ypos; + } + + /* See if we need to fill below the font */ + ypos = cy - h; + if (ypos > 0) { + gdispFillArea(x, y+cy-ypos, cx, ypos, bgcolor); + cy -= ypos; + } + + /* get the start of the printable string and the xpos */ + switch(justify) { + case justifyCenter: + /* Get the length of the entire string */ + w = gdispGetStringWidth(str, font); + if (w <= cx) + xpos = x + (cx - w)/2; + else { + /* Calculate how much of the string we need to get rid of */ + ypos = (w - cx)/2; + xpos = 0; + first = 1; + while(*str) { + /* Get the next printable character */ + c = *str++; + w = _getCharWidth(font, c) * font->xscale; + if (!w) continue; + + /* Handle inter-character padding */ + if (p) { + if (!first) { + xpos += p; + if (xpos > ypos) break; + } else + first = 0; + } + + /* Print the character */ + xpos += w; + if (xpos > ypos) break; + } + xpos = ypos - xpos + x; + } + break; + case justifyRight: + /* Find the end of the string */ + for(rstr = str; *str; str++); + xpos = x+cx - 2; + first = 1; + for(str--; str >= rstr; str--) { + /* Get the next printable character */ + c = *str; + w = _getCharWidth(font, c) * font->xscale; + if (!w) continue; + + /* Handle inter-character padding */ + if (p) { + if (!first) { + if (xpos - p < x) break; + xpos -= p; + } else + first = 0; + } + + /* Print the character */ + if (xpos - w < x) break; + xpos -= w; + } + str++; + break; + case justifyLeft: + /* Fall through */ + default: + xpos = x+1; + break; + } + + /* Fill any space to the left */ + if (x < xpos) + gdispFillArea(x, y, xpos-x, cy, bgcolor); + + /* Print characters until we run out of room */ + first = 1; + while(*str) { + /* Get the next printable character */ + c = *str++; + w = _getCharWidth(font, c) * font->xscale; + if (!w) continue; + + /* Handle inter-character padding */ + if (p) { + if (!first) { + if (xpos + p > x+cx) break; + gdispFillArea(xpos, y, p, cy, bgcolor); + xpos += p; + } else + first = 0; + } + + /* Print the character */ + if (xpos + w > x+cx) break; + gdispFillChar(xpos, y, c, font, color, bgcolor); + xpos += w; + } + + /* Fill any space to the right */ + if (xpos < x+cx) + gdispFillArea(xpos, y, x+cx-xpos, cy, bgcolor); + } +#endif + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) + /** + * @brief Get a metric of a font. + * @return The metric requested in pixels. + * + * @param[in] font The font to test + * @param[in] metric The metric to measure + * + * @api + */ + coord_t gdispGetFontMetric(font_t font, fontmetric_t metric) { + /* No mutex required as we only read static data */ + switch(metric) { + case fontHeight: return font->height * font->yscale; + case fontDescendersHeight: return font->descenderHeight * font->yscale; + case fontLineSpacing: return font->lineSpacing * font->yscale; + case fontCharPadding: return font->charPadding * font->xscale; + case fontMinWidth: return font->minWidth * font->xscale; + case fontMaxWidth: return font->maxWidth * font->xscale; + } + return 0; + } +#endif + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) + /** + * @brief Get the pixel width of a character. + * @return The width of the character in pixels. Does not include any between character padding. + * + * @param[in] c The character to draw + * @param[in] font The font to use + * + * @api + */ + coord_t gdispGetCharWidth(char c, font_t font) { + /* No mutex required as we only read static data */ + return _getCharWidth(font, c) * font->xscale; + } +#endif + +#if GDISP_NEED_TEXT || defined(__DOXYGEN__) + /** + * @brief Get the pixel width of a string. + * @return The width of the string in pixels. + * + * @param[in] str The string to measure + * @param[in] font The font to use + * + * @api + */ + coord_t gdispGetStringWidth(const char* str, font_t font) { + /* No mutex required as we only read static data */ + coord_t w, p, x; + char c; + int first; + + first = 1; + x = 0; + p = font->charPadding * font->xscale; + while(*str) { + /* Get the next printable character */ + c = *str++; + w = _getCharWidth(font, c) * font->xscale; + if (!w) continue; + + /* Handle inter-character padding */ + if (p) { + if (!first) + x += p; + else + first = 0; + } + + /* Add the character width */ + x += w; + } + return x; + } +#endif + +#if (!defined(gdispPackPixels) && !defined(GDISP_PIXELFORMAT_CUSTOM)) || defined(__DOXYGEN__) + /** + * @brief Pack a pixel into a pixel buffer. + * @note This function performs no buffer boundary checking + * regardless of whether GDISP_NEED_CLIPPING has been specified. + * + * @param[in] buf The buffer to put the pixel in + * @param[in] cx The width of a pixel line + * @param[in] x, y The location of the pixel to place + * @param[in] color The color to put into the buffer + * + * @api + */ + void gdispPackPixels(pixel_t *buf, coord_t cx, coord_t x, coord_t y, color_t color) { + /* No mutex required as we only read static data */ + #if defined(GDISP_PIXELFORMAT_RGB888) + #error "GDISP: Packed pixels not supported yet" + #elif defined(GDISP_PIXELFORMAT_RGB444) + #error "GDISP: Packed pixels not supported yet" + #elif defined(GDISP_PIXELFORMAT_RGB666) + #error "GDISP: Packed pixels not supported yet" + #elif + #error "GDISP: Unsupported packed pixel format" + #endif + } +#endif + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_C */ +/** @} */ diff --git a/src/gdisp_fonts.c b/src/gdisp_fonts.c new file mode 100644 index 00000000..25a56526 --- /dev/null +++ b/src/gdisp_fonts.c @@ -0,0 +1,655 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +/* + Font tables included into gdisp.c +*/ +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +#if GDISP_NEED_TEXT + +#include "gdisp_fonts.h" + + +/* fontSmall - for side buttons */ +#if 1 + /* Forward Declarations of internal arrays */ + static const uint8_t fontSmall_Widths[]; + static const uint16_t fontSmall_Offsets[]; + static const fontcolumn_t fontSmall_Data[]; + + const struct font fontSmall = { 11, 0, 14, 2, 2, 12, ' ', '~', 1, 1, + fontSmall_Widths, + fontSmall_Offsets, + fontSmall_Data}; + const struct font fontSmallDouble = { 11, 0, 14, 2, 2, 12, ' ', '~', 2, 2, + fontSmall_Widths, + fontSmall_Offsets, + fontSmall_Data}; + const struct font fontSmallNarrow = { 11, 0, 14, 2, 2, 12, ' ', '~', 1, 2, + fontSmall_Widths, + fontSmall_Offsets, + fontSmall_Data}; + + static const uint8_t fontSmall_Widths[] = { + 2, 3, 6, 8, 7, 9, 7, 3, 4, 4, 5, 7, 4, 4, 3, 6, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 4, 6, 7, 6, 7, + 12, 8, 7, 8, 8, 7, 7, 8, 8, 3, 5, 8, 7, 9, 8, 8, + 8, 8, 8, 7, 7, 8, 8, 12, 8, 8, 8, 4, 6, 4, 7, 7, + 4, 7, 7, 7, 7, 7, 4, 7, 7, 3, 3, 7, 3, 9, 7, 7, + 7, 7, 4, 6, 4, 7, 7, 9, 6, 6, 6, 5, 3, 5, 8, 0 + }; + static const uint16_t fontSmall_Offsets[] = { + 0, 2, 5, 11, 19, 26, 35, 42, + 45, 49, 53, 58, 65, 69, 73, 76, + 82, 89, 96, 103, 110, 117, 124, 131, + 138, 145, 152, 155, 159, 165, 172, 178, + 185, 197, 205, 212, 220, 228, 235, 242, + 250, 258, 261, 266, 274, 281, 290, 298, + 306, 314, 322, 330, 337, 344, 352, 360, + 372, 380, 388, 396, 400, 406, 410, 417, + 424, 428, 435, 442, 449, 456, 463, 467, + 474, 481, 484, 487, 494, 497, 506, 513, + 520, 527, 534, 538, 544, 548, 555, 562, + 571, 577, 583, 589, 594, 597, 602, 0 + }; + static const fontcolumn_t fontSmall_Data[] = { + /* */ 0x0000, 0x0000, + /* ! */ 0x0000, 0x017F, 0x017F, + /* " */ 0x0000, 0x0007, 0x0007, 0x0000, 0x0007, 0x0007, + /* # */ 0x0000, 0x0044, 0x01FF, 0x01FF, 0x0044, 0x01FF, 0x01FF, 0x0044, + /* $ */ 0x0000, 0x008C, 0x019E, 0x03FF, 0x03FF, 0x01E6, 0x00C4, + /* % */ 0x0000, 0x0082, 0x00C7, 0x0065, 0x00B7, 0x01DA, 0x014C, 0x01C6, 0x0082, + /* & */ 0x0000, 0x00E6, 0x01FF, 0x013F, 0x01E6, 0x01E0, 0x0120, + /* ' */ 0x0000, 0x0007, 0x0007, + /* ( */ 0x0000, 0x03FE, 0x07FF, 0x0401, + /* ) */ 0x0000, 0x0401, 0x07FF, 0x03FE, + /* * */ 0x0000, 0x000A, 0x000E, 0x000E, 0x000A, + /* + */ 0x0000, 0x0020, 0x0020, 0x00F8, 0x00F8, 0x0020, 0x0020, + /* , */ 0x0000, 0x0200, 0x0300, 0x0100, + /* - */ 0x0000, 0x0020, 0x0020, 0x0020, + /* . */ 0x0000, 0x0100, 0x0100, + /* / */ 0x0000, 0x0180, 0x01E0, 0x0078, 0x001F, 0x0007, + /* 0 */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x01FF, 0x00FE, + /* 1 */ 0x0000, 0x0002, 0x0002, 0x01FF, 0x01FF, 0x0000, 0x0000, + /* 2 */ 0x0000, 0x0182, 0x01C3, 0x0161, 0x0131, 0x011F, 0x010E, + /* 3 */ 0x0000, 0x0082, 0x0183, 0x0111, 0x0111, 0x01FF, 0x00EE, + /* 4 */ 0x0000, 0x0060, 0x0078, 0x005E, 0x01FF, 0x01FF, 0x0040, + /* 5 */ 0x0000, 0x009F, 0x019F, 0x0109, 0x0109, 0x01F9, 0x00F1, + /* 6 */ 0x0000, 0x00FE, 0x01FF, 0x0111, 0x0111, 0x01F3, 0x00E2, + /* 7 */ 0x0000, 0x0001, 0x01C1, 0x01F1, 0x003D, 0x000F, 0x0003, + /* 8 */ 0x0000, 0x00EE, 0x01FF, 0x0111, 0x0111, 0x01FF, 0x00EE, + /* 9 */ 0x0000, 0x008E, 0x019F, 0x0111, 0x0111, 0x01FF, 0x00FE, + /* : */ 0x0000, 0x0108, 0x0108, + /* ; */ 0x0000, 0x0200, 0x0308, 0x0108, + /* < */ 0x0000, 0x0020, 0x0070, 0x00D8, 0x018C, 0x0104, + /* = */ 0x0000, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, 0x0050, + /* > */ 0x0000, 0x0104, 0x018C, 0x00D8, 0x0070, 0x0020, + /* ? */ 0x0000, 0x0002, 0x0003, 0x0161, 0x0171, 0x001F, 0x000E, + /* @ */ 0x0000, 0x0078, 0x01FE, 0x0186, 0x0333, 0x0279, 0x0249, 0x0279, 0x027B, 0x0246, 0x007E, 0x0078, + /* A */ 0x0180, 0x01F0, 0x007C, 0x004F, 0x004F, 0x007C, 0x01F0, 0x0180, + /* B */ 0x0000, 0x01FF, 0x01FF, 0x0111, 0x0111, 0x01FF, 0x00EE, + /* C */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x0101, 0x0183, 0x0082, + /* D */ 0x0000, 0x01FF, 0x01FF, 0x0101, 0x0101, 0x0183, 0x00FE, 0x007C, + /* E */ 0x0000, 0x01FF, 0x01FF, 0x0111, 0x0111, 0x0111, 0x0101, + /* F */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x0001, + /* G */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0111, 0x0191, 0x01F3, 0x01F2, + /* H */ 0x0000, 0x01FF, 0x01FF, 0x0010, 0x0010, 0x0010, 0x01FF, 0x01FF, + /* I */ 0x0000, 0x01FF, 0x01FF, + /* J */ 0x00C0, 0x01C0, 0x0100, 0x01FF, 0x00FF, + /* K */ 0x0000, 0x01FF, 0x01FF, 0x003C, 0x0066, 0x00C3, 0x0181, 0x0100, + /* L */ 0x0000, 0x01FF, 0x01FF, 0x0100, 0x0100, 0x0100, 0x0100, + /* M */ 0x0000, 0x01FF, 0x01FF, 0x003C, 0x00F0, 0x00F0, 0x003C, 0x01FF, 0x01FF, + /* N */ 0x0000, 0x01FF, 0x01FF, 0x001E, 0x0038, 0x00E0, 0x01FF, 0x01FF, + /* O */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0101, 0x0101, 0x01FF, 0x00FE, + /* P */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x001F, 0x000E, + /* Q */ 0x0000, 0x00FE, 0x01FF, 0x0101, 0x0141, 0x01C1, 0x03FF, 0x02FE, + /* R */ 0x0000, 0x01FF, 0x01FF, 0x0011, 0x0011, 0x0011, 0x01FF, 0x01EE, + /* S */ 0x0000, 0x008E, 0x019F, 0x0111, 0x0111, 0x01F3, 0x00E2, + /* T */ 0x0000, 0x0001, 0x0001, 0x01FF, 0x01FF, 0x0001, 0x0001, + /* U */ 0x0000, 0x00FF, 0x01FF, 0x0100, 0x0100, 0x0100, 0x01FF, 0x00FF, + /* V */ 0x0003, 0x001F, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x001F, 0x0003, + /* W */ 0x0003, 0x001F, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x007C, 0x01E0, 0x01E0, 0x007C, 0x001F, 0x0003, + /* X */ 0x0183, 0x01C7, 0x006C, 0x0038, 0x0038, 0x006C, 0x01C7, 0x0183, + /* Y */ 0x0003, 0x0007, 0x000C, 0x01F8, 0x01F8, 0x000C, 0x0007, 0x0003, + /* Z */ 0x0181, 0x01C1, 0x0161, 0x0131, 0x0119, 0x010D, 0x0107, 0x0103, + /* [ */ 0x0000, 0x07FF, 0x07FF, 0x0401, + /* \ */ 0x0000, 0x0007, 0x001F, 0x0078, 0x01E0, 0x0180, + /* ] */ 0x0000, 0x0401, 0x07FF, 0x07FF, + /* ^ */ 0x0000, 0x0002, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002, + /* _ */ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, + /* ` */ 0x0000, 0x0001, 0x0003, 0x0002, + /* a */ 0x0000, 0x00C0, 0x01E8, 0x0128, 0x0128, 0x01F8, 0x01F0, + /* b */ 0x0000, 0x01FF, 0x01FF, 0x0108, 0x0108, 0x01F8, 0x00F0, + /* c */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x0198, 0x0090, + /* d */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01FF, 0x01FF, + /* e */ 0x0000, 0x00F0, 0x01F8, 0x0128, 0x0128, 0x01B8, 0x00B0, + /* f */ 0x0000, 0x01FE, 0x01FF, 0x0009, + /* g */ 0x0000, 0x04F0, 0x05F8, 0x0508, 0x0508, 0x07F8, 0x03F8, + /* h */ 0x0000, 0x01FF, 0x01FF, 0x0018, 0x0008, 0x01F8, 0x01F0, + /* i */ 0x0000, 0x01F9, 0x01F9, + /* j */ 0x0000, 0x07F9, 0x07F9, + /* k */ 0x0000, 0x01FF, 0x01FF, 0x0070, 0x00D8, 0x0188, 0x0100, + /* l */ 0x0000, 0x01FF, 0x01FF, + /* m */ 0x0000, 0x01F8, 0x01F8, 0x0008, 0x01F8, 0x01F8, 0x0008, 0x01F8, 0x01F0, + /* n */ 0x0000, 0x01F8, 0x01F8, 0x0018, 0x0008, 0x01F8, 0x01F0, + /* o */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01F8, 0x00F0, + /* p */ 0x0000, 0x07F8, 0x07F8, 0x0108, 0x0108, 0x01F8, 0x00F0, + /* q */ 0x0000, 0x00F0, 0x01F8, 0x0108, 0x0108, 0x07F8, 0x07F8, + /* r */ 0x0000, 0x01F8, 0x01F8, 0x0008, + /* s */ 0x0000, 0x0090, 0x01B8, 0x0168, 0x01D8, 0x0090, + /* t */ 0x0000, 0x00FE, 0x01FE, 0x0108, + /* u */ 0x0000, 0x00F8, 0x01F8, 0x0100, 0x0180, 0x01F8, 0x01F8, + /* v */ 0x0000, 0x0018, 0x0078, 0x01E0, 0x01E0, 0x0078, 0x0018, + /* w */ 0x0000, 0x0078, 0x01F8, 0x01E0, 0x0078, 0x0078, 0x01E0, 0x01F8, 0x0078, + /* x */ 0x0000, 0x0198, 0x01F8, 0x0060, 0x01F8, 0x0198, + /* y */ 0x0400, 0x0478, 0x07F8, 0x0380, 0x00F8, 0x0078, + /* z */ 0x0000, 0x0188, 0x01C8, 0x0168, 0x0138, 0x0118, + /* { */ 0x0000, 0x0010, 0x01FF, 0x03EF, 0x0200, + /* | */ 0x0000, 0x03FF, 0x03FF, + /* } */ 0x0000, 0x0200, 0x03EF, 0x01FF, 0x0010, + /* ~ */ 0x0000, 0x0004, 0x0006, 0x0002, 0x0006, 0x0004, 0x0006, 0x0002 + }; +#endif + +/* fontLarger - Tahoma, 11, Bold */ +#if 1 + /* Forward Declarations of internal arrays */ + static const uint8_t fontLarger_Widths[]; + static const uint16_t fontLarger_Offsets[]; + static const fontcolumn_t fontLarger_Data[]; + + const struct font fontLarger = { 12, 1, 13, 2, 2, 13, ' ', '~', 1, 1, + fontLarger_Widths, + fontLarger_Offsets, + fontLarger_Data}; + const struct font fontLargerDouble = { 12, 1, 13, 2, 2, 13, ' ', '~', 2, 2, + fontLarger_Widths, + fontLarger_Offsets, + fontLarger_Data}; + const struct font fontLargerNarrow = { 12, 1, 13, 2, 2, 13, ' ', '~', 1, 2, + fontLarger_Widths, + fontLarger_Offsets, + fontLarger_Data}; + static const uint8_t fontLarger_Widths[] = { + 2, 3, 5, 8, 7, 13, 8, 2, 4, 4, 7, 8, 3, 4, 3, 5, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 9, 8, 9, 6, + 9, 8, 7, 7, 8, 6, 5, 7, 8, 4, 5, 7, 6, 10, 7, 8, + 7, 8, 8, 7, 6, 7, 7, 11, 7, 6, 6, 4, 5, 4, 9, 8, + 5, 6, 7, 5, 7, 6, 5, 7, 7, 2, 3, 6, 2, 10, 7, 7, + 7, 7, 4, 5, 5, 7, 6, 10, 6, 6, 5, 6, 4, 6, 9, 0 + }; + static const uint16_t fontLarger_Offsets[] = { + 0, 2, 5, 10, 18, 25, 38, 46, + 48, 52, 56, 63, 71, 74, 78, 81, + 86, 93, 100, 107, 114, 121, 128, 135, + 142, 149, 156, 159, 162, 171, 179, 188, + 194, 203, 211, 218, 225, 233, 239, 244, + 251, 259, 263, 268, 275, 281, 291, 298, + 306, 313, 321, 329, 336, 342, 349, 356, + 367, 374, 380, 386, 390, 395, 399, 408, + 416, 421, 427, 434, 439, 446, 452, 457, + 464, 471, 473, 476, 482, 484, 494, 501, + 508, 515, 522, 526, 531, 536, 543, 549, + 559, 565, 571, 576, 582, 586, 592, 0 + }; + static const fontcolumn_t fontLarger_Data[] = { + /* */ 0x0000, 0x0000, + /* ! */ 0x0000, 0x037E, 0x037E, + /* " */ 0x0007, 0x0007, 0x0000, 0x0007, 0x0007, + /* # */ 0x00C0, 0x03D8, 0x00F8, 0x00DE, 0x03D8, 0x00F8, 0x00DE, 0x0018, + /* $ */ 0x0118, 0x023C, 0x0264, 0x0FFF, 0x0264, 0x03C4, 0x0188, + /* % */ 0x001C, 0x003E, 0x0022, 0x023E, 0x011C, 0x00C0, 0x0020, 0x0018, 0x01C4, 0x03E2, 0x0220, 0x03E0, + 0x01C0, + /* & */ 0x01CC, 0x03FE, 0x0232, 0x0272, 0x03DE, 0x018C, 0x03E0, 0x0260, + /* ' */ 0x0007, 0x0007, + /* ( */ 0x01F8, 0x07FE, 0x0E07, 0x0801, + /* ) */ 0x0801, 0x0E07, 0x07FE, 0x01F8, + /* * */ 0x0000, 0x000A, 0x0004, 0x001F, 0x001F, 0x0004, 0x000A, + /* + */ 0x0000, 0x0020, 0x0020, 0x0020, 0x01FC, 0x0020, 0x0020, 0x0020, + /* , */ 0x0000, 0x0F00, 0x0700, + /* - */ 0x0020, 0x0020, 0x0020, 0x0020, + /* . */ 0x0000, 0x0300, 0x0300, + /* / */ 0x0C00, 0x0380, 0x0060, 0x001C, 0x0003, + /* 0 */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x03FE, 0x01FC, + /* 1 */ 0x0000, 0x0204, 0x0204, 0x03FE, 0x03FE, 0x0200, 0x0200, + /* 2 */ 0x0204, 0x0302, 0x0382, 0x02C2, 0x0262, 0x023E, 0x021C, + /* 3 */ 0x0104, 0x0202, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC, + /* 4 */ 0x0060, 0x0050, 0x0048, 0x0044, 0x03FE, 0x03FE, 0x0040, + /* 5 */ 0x0100, 0x021E, 0x021E, 0x0212, 0x0212, 0x03F2, 0x01E2, + /* 6 */ 0x01F8, 0x03FC, 0x0216, 0x0212, 0x0212, 0x03F2, 0x01E0, + /* 7 */ 0x0002, 0x0002, 0x0382, 0x03E2, 0x007A, 0x001E, 0x0006, + /* 8 */ 0x01DC, 0x03FE, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC, + /* 9 */ 0x003C, 0x027E, 0x0242, 0x0242, 0x0342, 0x01FE, 0x00FC, + /* : */ 0x0000, 0x0318, 0x0318, + /* ; */ 0x0000, 0x0F18, 0x0718, + /* < */ 0x0000, 0x0060, 0x0060, 0x0090, 0x0090, 0x0108, 0x0108, 0x0204, 0x0204, + /* = */ 0x0000, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, + /* > */ 0x0000, 0x0204, 0x0204, 0x0108, 0x0108, 0x0090, 0x0090, 0x0060, 0x0060, + /* ? */ 0x0004, 0x0002, 0x0362, 0x0372, 0x001E, 0x000C, + /* @ */ 0x01F8, 0x0204, 0x04F2, 0x05FA, 0x050A, 0x04FA, 0x05FA, 0x0104, 0x00F8, + /* A */ 0x0380, 0x03F0, 0x00FC, 0x008E, 0x008E, 0x00FC, 0x03F0, 0x0380, + /* B */ 0x03FE, 0x03FE, 0x0222, 0x0222, 0x0222, 0x03FE, 0x01DC, + /* C */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0202, 0x018C, + /* D */ 0x03FE, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0306, 0x01FC, 0x00F8, + /* E */ 0x03FE, 0x03FE, 0x0222, 0x0222, 0x0222, 0x0222, + /* F */ 0x03FE, 0x03FE, 0x0022, 0x0022, 0x0022, + /* G */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0222, 0x03E2, 0x03EC, + /* H */ 0x03FE, 0x03FE, 0x0020, 0x0020, 0x0020, 0x0020, 0x03FE, 0x03FE, + /* I */ 0x0202, 0x03FE, 0x03FE, 0x0202, + /* J */ 0x0200, 0x0202, 0x0202, 0x03FE, 0x01FE, + /* K */ 0x03FE, 0x03FE, 0x0070, 0x00D8, 0x018C, 0x0306, 0x0202, + /* L */ 0x03FE, 0x03FE, 0x0200, 0x0200, 0x0200, 0x0200, + /* M */ 0x03FE, 0x000E, 0x001C, 0x0038, 0x0070, 0x0030, 0x0018, 0x000C, 0x03FE, 0x03FE, + /* N */ 0x03FE, 0x000E, 0x001C, 0x0070, 0x01E0, 0x0380, 0x03FE, + /* O */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0202, 0x0202, 0x03FE, 0x01FC, + /* P */ 0x03FE, 0x03FE, 0x0042, 0x0042, 0x0042, 0x007E, 0x003C, + /* Q */ 0x01FC, 0x03FE, 0x0202, 0x0202, 0x0602, 0x0E02, 0x0BFE, 0x09FC, + /* R */ 0x03FE, 0x03FE, 0x0022, 0x0062, 0x00E2, 0x01BE, 0x031C, 0x0200, + /* S */ 0x019C, 0x023E, 0x0222, 0x0222, 0x0222, 0x03E2, 0x01CC, + /* T */ 0x0002, 0x0002, 0x03FE, 0x03FE, 0x0002, 0x0002, + /* U */ 0x01FE, 0x03FE, 0x0200, 0x0200, 0x0200, 0x03FE, 0x01FE, + /* V */ 0x000E, 0x007E, 0x03F0, 0x0380, 0x03F0, 0x007E, 0x000E, + /* W */ 0x001E, 0x00FE, 0x03E0, 0x03E0, 0x00FC, 0x000E, 0x00FC, 0x03E0, 0x03E0, 0x00FE, 0x001E, + /* X */ 0x0306, 0x038E, 0x00F8, 0x0070, 0x00F8, 0x038E, 0x0306, + /* Y */ 0x000E, 0x003E, 0x03F0, 0x03F0, 0x003E, 0x000E, + /* Z */ 0x0382, 0x03C2, 0x0262, 0x0232, 0x021E, 0x020E, + /* [ */ 0x0FFF, 0x0FFF, 0x0801, 0x0801, + /* \ */ 0x0003, 0x001C, 0x0060, 0x0380, 0x0C00, + /* ] */ 0x0801, 0x0801, 0x0FFF, 0x0FFF, + /* ^ */ 0x0000, 0x0010, 0x0008, 0x0004, 0x0002, 0x0002, 0x0004, 0x0008, 0x0010, + /* _ */ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, + /* ` */ 0x0000, 0x0000, 0x0001, 0x0003, 0x0002, + /* a */ 0x0180, 0x03D0, 0x0248, 0x0248, 0x03F8, 0x03F0, + /* b */ 0x03FF, 0x03FF, 0x0210, 0x0208, 0x0208, 0x03F8, 0x01F0, + /* c */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0208, + /* d */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0108, 0x03FF, 0x03FF, + /* e */ 0x01F0, 0x03F8, 0x0248, 0x0248, 0x0278, 0x0170, + /* f */ 0x0008, 0x03FE, 0x03FF, 0x0009, 0x0001, + /* g */ 0x01F0, 0x0BF8, 0x0A08, 0x0A08, 0x0908, 0x0FF8, 0x07F8, + /* h */ 0x03FF, 0x03FF, 0x0010, 0x0008, 0x0008, 0x03F8, 0x03F0, + /* i */ 0x03FA, 0x03FA, + /* j */ 0x0808, 0x0FFA, 0x07FA, + /* k */ 0x03FF, 0x03FF, 0x00E0, 0x01B0, 0x0318, 0x0208, + /* l */ 0x03FF, 0x03FF, + /* m */ 0x03F8, 0x03F8, 0x0008, 0x0008, 0x03F8, 0x03F0, 0x0008, 0x0008, 0x03F8, 0x03F0, + /* n */ 0x03F8, 0x03F8, 0x0010, 0x0008, 0x0008, 0x03F8, 0x03F0, + /* o */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0208, 0x03F8, 0x01F0, + /* p */ 0x0FF8, 0x0FF8, 0x0210, 0x0208, 0x0208, 0x03F8, 0x01F0, + /* q */ 0x01F0, 0x03F8, 0x0208, 0x0208, 0x0108, 0x0FF8, 0x0FF8, + /* r */ 0x03F8, 0x03F8, 0x0010, 0x0018, + /* s */ 0x0130, 0x0278, 0x0248, 0x03C8, 0x0190, + /* t */ 0x0008, 0x01FE, 0x03FE, 0x0208, 0x0208, + /* u */ 0x01F8, 0x03F8, 0x0200, 0x0200, 0x0100, 0x03F8, 0x03F8, + /* v */ 0x0038, 0x00F8, 0x03C0, 0x03C0, 0x00F8, 0x0038, + /* w */ 0x0018, 0x00F8, 0x03E0, 0x0380, 0x00F8, 0x00F8, 0x0380, 0x03E0, 0x00F8, 0x0018, + /* x */ 0x0318, 0x03B8, 0x00E0, 0x00E0, 0x03B8, 0x0318, + /* y */ 0x0038, 0x0CF8, 0x0FC0, 0x03C0, 0x00F8, 0x0038, + /* z */ 0x0388, 0x03C8, 0x0268, 0x0238, 0x0218, + /* { */ 0x0020, 0x0020, 0x07FE, 0x0FDF, 0x0801, 0x0801, + /* | */ 0x0000, 0x0000, 0x0FFF, 0x0FFF, + /* } */ 0x0801, 0x0801, 0x0FDF, 0x07FE, 0x0020, 0x0020, + /* ~ */ 0x00E0, 0x0030, 0x0030, 0x0030, 0x0060, 0x00C0, 0x00C0, 0x00C0, 0x0070 + }; +#endif + +/* fontUI1 - UI Font 1 Medium Bold */ +#if 1 + /* Forward Declarations of internal arrays */ + static const uint8_t fontUI1_Widths[]; + static const uint16_t fontUI1_Offsets[]; + static const fontcolumn_t fontUI1_Data[]; + + const struct font fontUI1 = { 13, 0, 15, 2, 3, 13, ' ', '~', 1, 1, + fontUI1_Widths, + fontUI1_Offsets, + fontUI1_Data}; + const struct font fontUI1Double = { 13, 0, 15, 2, 3, 13, ' ', '~', 2, 2, + fontUI1_Widths, + fontUI1_Offsets, + fontUI1_Data}; + const struct font fontUI1Narrow = { 13, 0, 15, 2, 3, 13, ' ', '~', 1, 2, + fontUI1_Widths, + fontUI1_Offsets, + fontUI1_Data}; + + static const uint8_t fontUI1_Widths[] = { + 3, 3, 6, 8, 7, 13, 9, 3, 5, 5, 6, 8, 3, 5, 3, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 3, 8, 8, 8, 6, + 10, 8, 7, 7, 8, 7, 7, 8, 8, 5, 5, 7, 7, 9, 8, 8, + 7, 8, 8, 7, 8, 8, 7, 11, 7, 7, 7, 5, 7, 5, 9, 8, + 5, 7, 7, 6, 7, 7, 5, 7, 7, 3, 4, 7, 3, 11, 7, 7, + 7, 7, 6, 6, 5, 7, 7, 9, 7, 7, 6, 7, 4, 7, 8, 0 + }; + static const uint16_t fontUI1_Offsets[] = { + 0, 3, 6, 12, 20, 27, 40, 49, + 52, 57, 62, 68, 76, 79, 84, 87, + 94, 101, 108, 115, 122, 129, 136, 143, + 150, 157, 164, 167, 170, 178, 186, 194, + 200, 210, 218, 225, 232, 240, 247, 254, + 262, 270, 275, 280, 287, 294, 303, 311, + 319, 326, 334, 342, 349, 357, 365, 372, + 383, 390, 397, 404, 409, 416, 421, 430, + 438, 443, 450, 457, 463, 470, 477, 482, + 489, 496, 499, 503, 510, 513, 524, 531, + 538, 545, 552, 558, 564, 569, 576, 583, + 592, 599, 606, 612, 619, 623, 630, 0 + }; + static const fontcolumn_t fontUI1_Data[] = { + /* */ 0x0000, 0x0000, 0x0000, + /* ! */ 0x0000, 0x02FC, 0x02FC, + /* " */ 0x0000, 0x000E, 0x000E, 0x0000, 0x000E, 0x000E, + /* # */ 0x0000, 0x0080, 0x0390, 0x00F0, 0x039C, 0x00F0, 0x009C, 0x0010, + /* $ */ 0x0000, 0x0130, 0x0278, 0x0FC8, 0x027E, 0x03C8, 0x0190, + /* % */ 0x0000, 0x0038, 0x007C, 0x0044, 0x007C, 0x0338, 0x00C0, 0x0030, 0x01CC, 0x03E0, 0x0220, 0x03E0, + 0x01C0, + /* & */ 0x0000, 0x01D8, 0x03FC, 0x0224, 0x027C, 0x02D8, 0x0180, 0x0360, 0x0220, + /* ' */ 0x0000, 0x000E, 0x000E, + /* ( */ 0x0000, 0x01F0, 0x07FC, 0x0E0E, 0x0802, + /* ) */ 0x0000, 0x0802, 0x0E0E, 0x07FC, 0x01F0, + /* * */ 0x0000, 0x0014, 0x0008, 0x003E, 0x0008, 0x0014, + /* + */ 0x0000, 0x0040, 0x0040, 0x0040, 0x03F8, 0x0040, 0x0040, 0x0040, + /* , */ 0x0000, 0x0F00, 0x0700, + /* - */ 0x0000, 0x0040, 0x0040, 0x0040, 0x0040, + /* . */ 0x0000, 0x0300, 0x0300, + /* / */ 0x0000, 0x0C00, 0x0F00, 0x03E0, 0x00F8, 0x001E, 0x0006, + /* 0 */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x03FC, 0x01F8, + /* 1 */ 0x0000, 0x0000, 0x0208, 0x03FC, 0x03FC, 0x0200, 0x0000, + /* 2 */ 0x0000, 0x0308, 0x038C, 0x02C4, 0x0264, 0x023C, 0x0218, + /* 3 */ 0x0000, 0x0108, 0x030C, 0x0224, 0x0224, 0x03FC, 0x01D8, + /* 4 */ 0x0000, 0x00C0, 0x00A0, 0x0090, 0x03F8, 0x03FC, 0x0080, + /* 5 */ 0x0000, 0x0100, 0x033C, 0x023C, 0x0224, 0x03E4, 0x01C4, + /* 6 */ 0x0000, 0x01F0, 0x03F8, 0x022C, 0x0224, 0x03E4, 0x01C0, + /* 7 */ 0x0000, 0x0004, 0x0304, 0x03C4, 0x00F4, 0x003C, 0x000C, + /* 8 */ 0x0000, 0x01D8, 0x03FC, 0x0224, 0x0224, 0x03FC, 0x01D8, + /* 9 */ 0x0000, 0x0038, 0x027C, 0x0244, 0x0344, 0x01FC, 0x00F8, + /* : */ 0x0000, 0x0330, 0x0330, + /* ; */ 0x0000, 0x0F30, 0x0730, + /* < */ 0x0000, 0x0040, 0x00A0, 0x00A0, 0x0110, 0x0110, 0x0208, 0x0208, + /* = */ 0x0000, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, 0x0090, + /* > */ 0x0000, 0x0208, 0x0208, 0x0110, 0x0110, 0x00A0, 0x00A0, 0x0040, + /* ? */ 0x0000, 0x0008, 0x02C4, 0x02E4, 0x003C, 0x0018, + /* @ */ 0x0000, 0x01F0, 0x0208, 0x04E4, 0x05F4, 0x0514, 0x05F4, 0x05F4, 0x0104, 0x00F8, + /* A */ 0x0000, 0x0380, 0x03F0, 0x00FC, 0x008C, 0x00FC, 0x03F0, 0x0380, + /* B */ 0x0000, 0x03FC, 0x03FC, 0x0224, 0x0224, 0x03FC, 0x01D8, + /* C */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0204, 0x0108, + /* D */ 0x0000, 0x03FC, 0x03FC, 0x0204, 0x0204, 0x030C, 0x01F8, 0x00F0, + /* E */ 0x0000, 0x03FC, 0x03FC, 0x0224, 0x0224, 0x0224, 0x0224, + /* F */ 0x0000, 0x03FC, 0x03FC, 0x0024, 0x0024, 0x0024, 0x0024, + /* G */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0244, 0x03C4, 0x03C8, + /* H */ 0x0000, 0x03FC, 0x03FC, 0x0020, 0x0020, 0x0020, 0x03FC, 0x03FC, + /* I */ 0x0000, 0x0204, 0x03FC, 0x03FC, 0x0204, + /* J */ 0x0200, 0x0204, 0x0204, 0x03FC, 0x01FC, + /* K */ 0x0000, 0x03FC, 0x03FC, 0x00F0, 0x0198, 0x030C, 0x0204, + /* L */ 0x0000, 0x03FC, 0x03FC, 0x0200, 0x0200, 0x0200, 0x0200, + /* M */ 0x0000, 0x03FC, 0x001C, 0x0038, 0x0070, 0x0020, 0x0010, 0x03F8, 0x03FC, + /* N */ 0x0000, 0x03FC, 0x0018, 0x0030, 0x0060, 0x00C0, 0x0180, 0x03FC, + /* O */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0204, 0x0204, 0x03FC, 0x01F8, + /* P */ 0x0000, 0x03FC, 0x03FC, 0x0044, 0x0044, 0x007C, 0x0038, + /* Q */ 0x0000, 0x01F8, 0x03FC, 0x0204, 0x0604, 0x0E04, 0x0BFC, 0x09F8, + /* R */ 0x0000, 0x03FC, 0x03FC, 0x0044, 0x00C4, 0x01FC, 0x0338, 0x0200, + /* S */ 0x0000, 0x0138, 0x027C, 0x0264, 0x0264, 0x03E4, 0x01C8, + /* T */ 0x0004, 0x0004, 0x0004, 0x03FC, 0x03FC, 0x0004, 0x0004, 0x0004, + /* U */ 0x0000, 0x01FC, 0x03FC, 0x0200, 0x0200, 0x0200, 0x03FC, 0x01FC, + /* V */ 0x0000, 0x001C, 0x00FC, 0x03E0, 0x03E0, 0x00FC, 0x001C, + /* W */ 0x0000, 0x001C, 0x00FC, 0x03E0, 0x03C0, 0x007C, 0x007C, 0x03C0, 0x03E0, 0x00FC, 0x001C, + /* X */ 0x0000, 0x030C, 0x039C, 0x00F0, 0x00F0, 0x039C, 0x030C, + /* Y */ 0x0000, 0x000C, 0x003C, 0x03F0, 0x03F0, 0x003C, 0x000C, + /* Z */ 0x0000, 0x0384, 0x03C4, 0x02E4, 0x0274, 0x023C, 0x021C, + /* [ */ 0x0000, 0x0FFE, 0x0FFE, 0x0802, 0x0802, + /* \ */ 0x0000, 0x0006, 0x001E, 0x00F8, 0x03E0, 0x0F00, 0x0C00, + /* ] */ 0x0000, 0x0802, 0x0802, 0x0FFE, 0x0FFE, + /* ^ */ 0x0000, 0x0020, 0x0030, 0x0018, 0x000C, 0x000C, 0x0018, 0x0030, 0x0020, + /* _ */ 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, 0x0800, + /* ` */ 0x0000, 0x0000, 0x0002, 0x0006, 0x0004, + /* a */ 0x0000, 0x0180, 0x03D0, 0x0250, 0x0250, 0x03F0, 0x03E0, + /* b */ 0x0000, 0x03FE, 0x03FE, 0x0210, 0x0210, 0x03F0, 0x01E0, + /* c */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x0210, + /* d */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x03FE, 0x03FE, + /* e */ 0x0000, 0x01E0, 0x03F0, 0x0250, 0x0250, 0x0270, 0x0160, + /* f */ 0x0010, 0x03FC, 0x03FE, 0x0012, 0x0012, + /* g */ 0x0000, 0x01E0, 0x0BF0, 0x0A10, 0x0A10, 0x0FF0, 0x07F0, + /* h */ 0x0000, 0x03FE, 0x03FE, 0x0010, 0x0010, 0x03F0, 0x03E0, + /* i */ 0x0000, 0x03F4, 0x03F4, + /* j */ 0x0800, 0x0810, 0x0FF4, 0x07F4, + /* k */ 0x0000, 0x03FE, 0x03FE, 0x00C0, 0x01E0, 0x0330, 0x0210, + /* l */ 0x0000, 0x03FE, 0x03FE, + /* m */ 0x0000, 0x03F0, 0x03F0, 0x0010, 0x0010, 0x03F0, 0x03E0, 0x0010, 0x0010, 0x03F0, 0x03E0, + /* n */ 0x0000, 0x03F0, 0x03F0, 0x0010, 0x0010, 0x03F0, 0x03E0, + /* o */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x03F0, 0x01E0, + /* p */ 0x0000, 0x0FF0, 0x0FF0, 0x0210, 0x0210, 0x03F0, 0x01E0, + /* q */ 0x0000, 0x01E0, 0x03F0, 0x0210, 0x0210, 0x0FF0, 0x0FF0, + /* r */ 0x0000, 0x03F0, 0x03F0, 0x0020, 0x0030, 0x0030, + /* s */ 0x0000, 0x0260, 0x02F0, 0x02D0, 0x03D0, 0x0190, + /* t */ 0x0010, 0x01FC, 0x03FC, 0x0210, 0x0210, + /* u */ 0x0000, 0x01F0, 0x03F0, 0x0200, 0x0200, 0x03F0, 0x03F0, + /* v */ 0x0000, 0x0070, 0x01F0, 0x0380, 0x0380, 0x01F0, 0x0070, + /* w */ 0x0000, 0x00F0, 0x03F0, 0x0300, 0x00F0, 0x00F0, 0x0300, 0x03F0, 0x00F0, + /* x */ 0x0000, 0x0330, 0x03F0, 0x00C0, 0x00C0, 0x03F0, 0x0330, + /* y */ 0x0000, 0x0030, 0x0CF0, 0x0FC0, 0x03C0, 0x00F0, 0x0030, + /* z */ 0x0000, 0x0310, 0x0390, 0x02D0, 0x0270, 0x0230, + /* { */ 0x0000, 0x0040, 0x0040, 0x07FC, 0x0FBE, 0x0802, 0x0802, + /* | */ 0x0000, 0x0000, 0x0FFE, 0x0FFE, + /* } */ 0x0000, 0x0802, 0x0802, 0x0FBE, 0x07FC, 0x0040, 0x0040, + /* ~ */ 0x0000, 0x01C0, 0x0020, 0x0020, 0x00C0, 0x0100, 0x0100, 0x00E0 + }; +#endif + +/* fontUI1 - UI Font 2 Medium Bold */ +#if 1 + /* Forward Declarations of internal arrays */ + static const uint8_t fontUI2_Widths[]; + static const uint16_t fontUI2_Offsets[]; + static const fontcolumn_t fontUI2_Data[]; + + const struct font fontUI2 = { 11, 1, 13, 2, 2, 12, ' ', '~', 1, 1, + fontUI2_Widths, + fontUI2_Offsets, + fontUI2_Data}; + const struct font fontUI2Double = { 11, 1, 13, 2, 2, 12, ' ', '~', 2, 2, + fontUI2_Widths, + fontUI2_Offsets, + fontUI2_Data}; + const struct font fontUI2Narrow = { 11, 1, 13, 2, 2, 12, ' ', '~', 1, 2, + fontUI2_Widths, + fontUI2_Offsets, + fontUI2_Data}; + + static const uint8_t fontUI2_Widths[] = { + 2, 2, 5, 8, 6, 12, 8, 2, 4, 4, 6, 8, 2, 4, 2, 5, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 2, 2, 8, 8, 8, 5, + 9, 7, 6, 6, 7, 5, 5, 7, 7, 4, 5, 6, 5, 9, 6, 7, + 6, 7, 7, 6, 6, 7, 6, 10, 6, 6, 6, 4, 5, 4, 7, 7, + 4, 6, 6, 5, 6, 6, 4, 6, 6, 2, 3, 6, 2, 10, 6, 6, + 6, 6, 4, 5, 4, 6, 6, 8, 6, 6, 5, 6, 4, 6, 8, 0 + }; + static const uint16_t fontUI2_Offsets[] = { + 0, 2, 4, 9, 17, 23, 35, 43, + 45, 49, 53, 59, 67, 69, 73, 75, + 80, 86, 92, 98, 104, 110, 116, 122, + 128, 134, 140, 142, 144, 152, 160, 168, + 173, 182, 189, 195, 201, 208, 213, 218, + 225, 232, 236, 241, 247, 252, 261, 267, + 274, 280, 287, 294, 300, 306, 313, 319, + 329, 335, 341, 347, 351, 356, 360, 367, + 374, 378, 384, 390, 395, 401, 407, 411, + 417, 423, 425, 428, 434, 436, 446, 452, + 458, 464, 470, 474, 479, 483, 489, 495, + 503, 509, 515, 520, 526, 530, 536, 0 + }; + static const fontcolumn_t fontUI2_Data[] = { + /* */ 0x0000, 0x0000, + /* ! */ 0x017E, 0x017E, + /* " */ 0x0007, 0x0007, 0x0000, 0x0007, 0x0007, + /* # */ 0x00C0, 0x03D8, 0x00F8, 0x00DE, 0x03D8, 0x00F8, 0x00DE, 0x0018, + /* $ */ 0x0098, 0x013C, 0x07E4, 0x013F, 0x01E4, 0x00C8, + /* % */ 0x001C, 0x003E, 0x0022, 0x003E, 0x019C, 0x0060, 0x0018, 0x00E6, 0x01F0, 0x0110, 0x01F0, 0x00E0, + /* & */ 0x00EC, 0x01FE, 0x0112, 0x013E, 0x016C, 0x00C0, 0x01B0, 0x0110, + /* ' */ 0x0007, 0x0007, + /* ( */ 0x00F8, 0x03FE, 0x0707, 0x0401, + /* ) */ 0x0401, 0x0707, 0x03FE, 0x00F8, + /* * */ 0x000A, 0x0004, 0x001F, 0x001F, 0x0004, 0x000A, + /* + */ 0x0000, 0x0020, 0x0020, 0x0020, 0x01FC, 0x0020, 0x0020, 0x0020, + /* , */ 0x0780, 0x0380, + /* - */ 0x0020, 0x0020, 0x0020, 0x0020, + /* . */ 0x0180, 0x0180, + /* / */ 0x0600, 0x0180, 0x0070, 0x000C, 0x0003, + /* 0 */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x01FE, 0x00FC, + /* 1 */ 0x0000, 0x0104, 0x01FE, 0x01FE, 0x0100, 0x0000, + /* 2 */ 0x0184, 0x01C6, 0x0162, 0x0132, 0x011E, 0x010C, + /* 3 */ 0x0084, 0x0186, 0x0112, 0x0112, 0x01FE, 0x00EC, + /* 4 */ 0x0060, 0x0050, 0x0048, 0x01FC, 0x01FE, 0x0040, + /* 5 */ 0x0080, 0x019E, 0x011E, 0x0112, 0x01F2, 0x00E2, + /* 6 */ 0x00FC, 0x01FE, 0x0112, 0x0112, 0x01F2, 0x00E0, + /* 7 */ 0x0002, 0x0002, 0x01C2, 0x01FA, 0x003E, 0x0006, + /* 8 */ 0x00EC, 0x01FE, 0x0112, 0x0112, 0x01FE, 0x00EC, + /* 9 */ 0x001C, 0x013E, 0x0122, 0x0122, 0x01FE, 0x00FC, + /* : */ 0x0198, 0x0198, + /* ; */ 0x0798, 0x0398, + /* < */ 0x0000, 0x0020, 0x0050, 0x0050, 0x0088, 0x0088, 0x0104, 0x0104, + /* = */ 0x0000, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, 0x0048, + /* > */ 0x0000, 0x0104, 0x0104, 0x0088, 0x0088, 0x0050, 0x0050, 0x0020, + /* ? */ 0x0004, 0x0162, 0x0172, 0x001E, 0x000C, + /* @ */ 0x00F8, 0x0104, 0x0272, 0x02FA, 0x028A, 0x027A, 0x02FA, 0x0084, 0x0078, + /* A */ 0x01C0, 0x01F8, 0x007E, 0x0046, 0x007E, 0x01F8, 0x01C0, + /* B */ 0x01FE, 0x01FE, 0x0112, 0x0112, 0x01FE, 0x00EC, + /* C */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0102, 0x0102, + /* D */ 0x01FE, 0x01FE, 0x0102, 0x0102, 0x0186, 0x00FC, 0x0078, + /* E */ 0x01FE, 0x01FE, 0x0112, 0x0112, 0x0112, + /* F */ 0x01FE, 0x01FE, 0x0012, 0x0012, 0x0012, + /* G */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0122, 0x01E2, 0x01E2, + /* H */ 0x01FE, 0x01FE, 0x0010, 0x0010, 0x0010, 0x01FE, 0x01FE, + /* I */ 0x0102, 0x01FE, 0x01FE, 0x0102, + /* J */ 0x0100, 0x0102, 0x0102, 0x01FE, 0x00FE, + /* K */ 0x01FE, 0x01FE, 0x0078, 0x00CC, 0x0186, 0x0102, + /* L */ 0x01FE, 0x01FE, 0x0100, 0x0100, 0x0100, + /* M */ 0x01FE, 0x000E, 0x001C, 0x0038, 0x0030, 0x0018, 0x000C, 0x01FE, 0x01FE, + /* N */ 0x01FE, 0x000E, 0x001C, 0x0038, 0x0070, 0x01FE, + /* O */ 0x00FC, 0x01FE, 0x0102, 0x0102, 0x0102, 0x01FE, 0x00FC, + /* P */ 0x01FE, 0x01FE, 0x0022, 0x0022, 0x003E, 0x001C, + /* Q */ 0x00FC, 0x01FE, 0x0102, 0x0302, 0x0702, 0x05FE, 0x04FC, + /* R */ 0x01FE, 0x01FE, 0x0022, 0x0062, 0x00FE, 0x019C, 0x0100, + /* S */ 0x011C, 0x013E, 0x0132, 0x0132, 0x01F2, 0x00E2, + /* T */ 0x0002, 0x0002, 0x01FE, 0x01FE, 0x0002, 0x0002, + /* U */ 0x00FE, 0x01FE, 0x0100, 0x0100, 0x0100, 0x01FE, 0x00FE, + /* V */ 0x000E, 0x007E, 0x01F0, 0x01F0, 0x007E, 0x000E, + /* W */ 0x000E, 0x007E, 0x01F0, 0x01E0, 0x003E, 0x003E, 0x01E0, 0x01F0, 0x007E, 0x000E, + /* X */ 0x0186, 0x01CE, 0x0078, 0x0078, 0x01CE, 0x0186, + /* Y */ 0x0006, 0x001E, 0x01F8, 0x01F8, 0x001E, 0x0006, + /* Z */ 0x01C2, 0x01E2, 0x0172, 0x013A, 0x011E, 0x010E, + /* [ */ 0x07FF, 0x07FF, 0x0401, 0x0401, + /* \ */ 0x0003, 0x000C, 0x0070, 0x0180, 0x0600, + /* ] */ 0x0401, 0x0401, 0x07FF, 0x07FF, + /* ^ */ 0x0010, 0x0008, 0x0004, 0x0002, 0x0004, 0x0008, 0x0010, + /* _ */ 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, 0x0400, + /* ` */ 0x0000, 0x0001, 0x0003, 0x0002, + /* a */ 0x00C0, 0x01E8, 0x0128, 0x0128, 0x01F8, 0x01F0, + /* b */ 0x01FF, 0x01FF, 0x0108, 0x0108, 0x01F8, 0x00F0, + /* c */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x0108, + /* d */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01FF, 0x01FF, + /* e */ 0x00F0, 0x01F8, 0x0128, 0x0128, 0x0138, 0x0130, + /* f */ 0x01FE, 0x01FF, 0x0009, 0x0001, + /* g */ 0x00F0, 0x05F8, 0x0508, 0x0508, 0x07F8, 0x03F8, + /* h */ 0x01FF, 0x01FF, 0x0008, 0x0008, 0x01F8, 0x01F0, + /* i */ 0x01FA, 0x01FA, + /* j */ 0x0408, 0x07FA, 0x03FA, + /* k */ 0x01FF, 0x01FF, 0x0060, 0x00F0, 0x0198, 0x0108, + /* l */ 0x01FF, 0x01FF, + /* m */ 0x01F8, 0x01F8, 0x0008, 0x0008, 0x01F8, 0x01F0, 0x0008, 0x0008, 0x01F8, 0x01F0, + /* n */ 0x01F8, 0x01F8, 0x0008, 0x0008, 0x01F8, 0x01F0, + /* o */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x01F8, 0x00F0, + /* p */ 0x07F8, 0x07F8, 0x0108, 0x0108, 0x01F8, 0x00F0, + /* q */ 0x00F0, 0x01F8, 0x0108, 0x0108, 0x07F8, 0x07F8, + /* r */ 0x01F8, 0x01F8, 0x0010, 0x0018, + /* s */ 0x0130, 0x0178, 0x0168, 0x01E8, 0x00C8, + /* t */ 0x00FE, 0x01FE, 0x0108, 0x0108, + /* u */ 0x00F8, 0x01F8, 0x0100, 0x0100, 0x01F8, 0x01F8, + /* v */ 0x0018, 0x0078, 0x01E0, 0x01E0, 0x0078, 0x0018, + /* w */ 0x0078, 0x01F8, 0x01C0, 0x0078, 0x0078, 0x01C0, 0x01F8, 0x0078, + /* x */ 0x0198, 0x01F8, 0x0060, 0x0060, 0x01F8, 0x0198, + /* y */ 0x0018, 0x0678, 0x07E0, 0x01E0, 0x0078, 0x0018, + /* z */ 0x0188, 0x01C8, 0x0168, 0x0138, 0x0118, + /* { */ 0x0020, 0x0020, 0x03FE, 0x07DF, 0x0401, 0x0401, + /* | */ 0x0000, 0x0000, 0x07FF, 0x07FF, + /* } */ 0x0401, 0x0401, 0x07DF, 0x03FE, 0x0020, 0x0020, + /* ~ */ 0x0060, 0x0010, 0x0010, 0x0030, 0x0060, 0x0040, 0x0040, 0x0030 + }; +#endif + +/* + fontLargeNumbers: + Large numbers font, height = 16 (including the decenders) + Characters include: 0 - 9, -, +, ., %, :, Space, Comma +*/ +#if 1 + /* Forward Declarations of internal arrays */ + static const uint8_t fontLargeNumbers_Widths[]; + static const uint16_t fontLargeNumbers_Offsets[]; + static const fontcolumn_t fontLargeNumbers_Data[]; + + const struct font fontLargeNumbers = { 16, 2, 21, 1, 3, 15, '%', ':', 1, 1, + fontLargeNumbers_Widths, + fontLargeNumbers_Offsets, + fontLargeNumbers_Data}; + const struct font fontLargeNumbersDouble = { 16, 2, 21, 1, 3, 15, '%', ':', 2, 2, + fontLargeNumbers_Widths, + fontLargeNumbers_Offsets, + fontLargeNumbers_Data}; + const struct font fontLargeNumbersNarrow = { 16, 2, 21, 1, 3, 15, '%', ':', 1, 2, + fontLargeNumbers_Widths, + fontLargeNumbers_Offsets, + fontLargeNumbers_Data}; + + static const uint8_t fontLargeNumbers_Widths[] = { + 15, 0, 0, 0, 0, 0, 11, 3, 6, 3, 0, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 4, 0, 0 + }; + static const uint16_t fontLargeNumbers_Offsets[] = { + 0, 0, 0, 0, 0, 0, 15, 26, + 29, 35, 0, 38, 48, 58, 68, 78, + 88, 98, 108, 118, 128, 138, 0, 0 + }; + static const fontcolumn_t fontLargeNumbers_Data[] = { + /* % */ 0x007E, 0x00FF, 0x00C3, 0x80C3, 0xE0FF, 0x7C7E, 0x1F00, 0x07C0, 0x00F0, 0x7E3E, 0xFF0F, 0xC303, + 0xC300, 0xFF00, 0x7E00, + /* + */ 0x01C0, 0x01C0, 0x01C0, 0x01C0, 0x1FFC, 0x1FFC, 0x1FFC, 0x01C0, 0x01C0, 0x01C0, 0x01C0, + /* , */ 0x7000, 0x7000, 0xF000, + /* - */ 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, 0x0700, + /* . */ 0x7000, 0x7000, 0x7000, + /* 0 */ 0x0FF8, 0x3FFE, 0x3FFE, 0x7007, 0x6003, 0x6003, 0x7007, 0x3FFE, 0x3FFE, 0x0FF8, + /* 1 */ 0x0000, 0x0070, 0x0038, 0x0038, 0x001C, 0x7FFF, 0x7FFF, 0x7FFF, 0x0000, 0x0000, + /* 2 */ 0x600C, 0x700E, 0x7C0F, 0x7E07, 0x6F03, 0x6783, 0x63C7, 0x61FF, 0x60FE, 0x603C, + /* 3 */ 0x180C, 0x380E, 0x780F, 0x70C3, 0x60C3, 0x60E3, 0x71FF, 0x3FFE, 0x3F3C, 0x0E00, + /* 4 */ 0x0F00, 0x0DC0, 0x0CE0, 0x0C38, 0x0C1E, 0x7FFF, 0x7FFF, 0x7FFF, 0x0C00, 0x0C00, + /* 5 */ 0x18C0, 0x38FC, 0x78FF, 0x707F, 0x6063, 0x6063, 0x70E3, 0x3FE3, 0x3FC3, 0x0F80, + /* 6 */ 0x0FF8, 0x3FFE, 0x3FFE, 0x70C7, 0x6063, 0x6063, 0x70E7, 0x3FEF, 0x3FC6, 0x0F04, + /* 7 */ 0x0003, 0x0003, 0x7803, 0x7F03, 0x7FC3, 0x07F3, 0x00FB, 0x003F, 0x000F, 0x0007, + /* 8 */ 0x1E1C, 0x3F3E, 0x7FFF, 0x71E7, 0x60C3, 0x60C3, 0x71E7, 0x7FFF, 0x3F3E, 0x1E1C, + /* 9 */ 0x1078, 0x39FE, 0x7BFE, 0x7387, 0x6303, 0x6303, 0x7187, 0x3FFE, 0x3FFE, 0x0FF8, + /* : */ 0x0000, 0x0E38, 0x0E38, 0x0E38 + }; +#endif + +#endif /* GDISP_NEED_TEXT */ + +#endif /* HAL_USE_GDISP */ diff --git a/src/touchpad.c b/src/touchpad.c new file mode 100644 index 00000000..977bb31c --- /dev/null +++ b/src/touchpad.c @@ -0,0 +1,261 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpad.c + * @brief Touchpad Driver code. + * + * @addgroup TOUCHPAD + * @{ + */ +#include "ch.h" +#include "hal.h" +#include "gdisp.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ +volatile static struct cal cal = { + 1, 1, 0, 0 +}; + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/** + * @brief returns the uncalibrated readout of the X direction from the controller + * + * @noapi + */ +static uint16_t _tpReadRealX(void) { + uint32_t results = 0; + uint16_t i, x; + + for(i = 0; i < CONVERSIONS; i++) { + tp_lld_read_x(); /* dummy, reduce noise on SPI */ + results += tp_lld_read_x(); + } + + // 12-bit + x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048); + + return x; +} + +/** + * @brief return the uncalibrated readout of the Y-direction from the controller + * + * @noapi + */ +static uint16_t _tpReadRealY(void) { + uint32_t results = 0; + uint16_t i, y; + + for(i = 0; i < CONVERSIONS; i++) { + tp_lld_read_y(); /* dummy, reduce noise on SPI */ + results += tp_lld_read_y(); + } + + // 12-bit + y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048); + + return y; +} + +/** + * @brief draws a cross. Used for calibration. + * + * @noapi + */ +static void _tpDrawCross(uint16_t x, uint16_t y) { + gdispDrawLine(x-15, y, x-2, y, 0xffff); + gdispDrawLine(x+2, y, x+15, y, 0xffff); + gdispDrawLine(x, y-15, x, y-2, 0xffff); + gdispDrawLine(x, y+2, x, y+15, 0xffff); + + gdispDrawLine(x-15, y+15, x-7, y+15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x-15, y+7, x-15, y+15, RGB565CONVERT(184,158,131)); + + gdispDrawLine(x-15, y-15, x-7, y-15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x-15, y-7, x-15, y-15, RGB565CONVERT(184,158,131)); + + gdispDrawLine(x+7, y+15, x+15, y+15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x+15, y+7, x+15, y+15, RGB565CONVERT(184,158,131)); + + gdispDrawLine(x+7, y-15, x+15, y-15, RGB565CONVERT(184,158,131)); + gdispDrawLine(x+15, y-15, x+15, y-7, RGB565CONVERT(184,158,131)); +} + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** + * @brief Touchpad Driver initialization. + * @note This function is NOT currently implicitly invoked by @p halInit(). + * It must be called manually. + * + * @api + */ +void tpInit(TOUCHPADDriver *tp) { + /* Initialise Mutex */ + //MUTEX_INIT + + /* Initialise driver */ + //MUTEX_ENTER + tp_lld_init(tp); + //MUTEX_EXIT +} + +/** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The X position in pixels. + * + * @api + */ +uint16_t tpReadX(void) { + uint16_t x, y; + + x = cal.xm * _tpReadRealX() + cal.xn; + y = cal.ym * _tpReadRealY() + cal.yn; + + /* + switch(gdispGetOrientation()) { // implement gdispGetOrientation() + case portrait: + return x; + case landscape: + return SCREEN_HEIGHT - y; + case portraitInv: + return SCREEN_WIDTH - x; + case landscapeInv: + return y; + } + */ + + return x; +} + +/** + * @brief Get the X-Coordinate, relative to screen zero point. + * + * @return The Y position in pixels. + * + * @api + */ +uint16_t tpReadY(void) { + uint16_t x, y; + + x = cal.xm * _tpReadRealX() + cal.xn; + y = cal.ym * _tpReadRealY() + cal.yn; + + /* + switch(gdispGetOrientation()) { // implement gdispGetOrientation() + case portrait: + return y; + case landscape: + return x; + case portraitInv: + return SCREEN_HEIGHT - y; + case landscapeInv: + return SCREEN_WIDTH - x; + } + */ + + return y; +} + +void tpCalibrate(void) { + uint16_t cross[2][2] = {{40,50}, {200, 280}}; + uint16_t points[2][2]; + uint8_t i; + + //gdispSetOrientation(portrait); + gdispClear(Red); + gdispFillStringBox(0, 10, gdispGetWidth(), 30, "Calibration", &fontUI2Double, White, Red, justifyCenter); + + for(i = 0; i < 2; i++) { + _tpDrawCross(cross[i][0], cross[i][1]); + while(!tpIRQ()); + points[i][0] = _tpReadRealX(); + points[i][1] = _tpReadRealY(); + chThdSleepMilliseconds(100); + while(tpIRQ()); + gdispFillArea(cross[i][0]-15, cross[i][1]-15, 42, 42, Red); + } + + cal.xm = ((float)cross[1][0] - (float)cross[0][0]) / ((float)points[1][0] - (float)points[0][0]); + cal.ym = ((float)cross[1][1] - (float)cross[0][1]) / ((float)points[1][1] - (float)points[0][1]); + + cal.xn = (float)cross[0][0] - cal.xm * (float)points[0][0]; + cal.yn = (float)cross[0][1] - cal.ym * (float)points[0][1]; +} + +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /** + * @brief returns if touchpad is pressed or not + * + * @return 1 if pressed, 0 otherwise + * + * @api + */ + uint8_t tpIRQ(void) { + return tp_lld_irq(); + } +#endif + +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) + /** + * @brief Get the pressure. + * + * @return The pressure. + * + * @api + */ + uint16_t tpReadZ(void) { + /* ToDo */ + return (tp_lld_read_z()); + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + diff --git a/templates/gdispXXXXX/gdisp_lld.c b/templates/gdispXXXXX/gdisp_lld.c new file mode 100644 index 00000000..81e96894 --- /dev/null +++ b/templates/gdispXXXXX/gdisp_lld.c @@ -0,0 +1,490 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file templates/gdisp_lld.c + * @brief GDISP Graphics Driver subsystem low level driver source template. + * + * @addtogroup GDISP + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/* Include the emulation code for things we don't support */ +#include "gdisp_emulation.c" + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +#if GDISP_NEED_TEXT + #include "gdisp_fonts.h" +#endif + +/* All the board specific code should go in these include file so the driver + * can be ported to another board just by creating a suitable file. + */ +#if defined(BOARD_YOURBOARDNAME) + #include "gdisp_lld_board_yourboardname.h" +#else + /* Include the user supplied board definitions */ + #include "gdisp_lld_board.h" +#endif + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ +/* + The following 2 routines are required. + All other routines are optional. +*/ + +/** + * @brief Low level GDISP driver initialisation. + * @return TRUE if successful, FALSE on error. + * + * @notapi + */ +bool_t GDISP_LLD(init)(void) { + /* Initialise your display */ + + /* Initialise the GDISP structure to match */ + GDISP.Width = SCREEN_WIDTH; + GDISP.Height = SCREEN_HEIGHT; + GDISP.Orientation = portrait; + GDISP.Powermode = powerOn; + GDISP.Backlight = 100; + GDISP.Contrast = 50; + return TRUE; +} + +/** + * @brief Draws a pixel on the display. + * + * @param[in] x X location of the pixel + * @param[in] y Y location of the pixel + * @param[in] color The color of the pixel + * + * @notapi + */ +void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return; + #endif + /* Code here */ +} + +/* ---- Optional Routines ---- */ +/* + All the below routines are optional. + Defining them will increase speed but everything + will work if they are not defined. + If you are not using a routine - turn it off using + the appropriate GDISP_HARDWARE_XXXX macro. + Don't bother coding for obvious similar routines if + there is no performance penalty as the emulation software + makes a good job of using similar routines. + eg. If fillarea() is defined there is little + point in defining clear() unless the + performance bonus is significant. + For good performance it is suggested to implement + fillarea() and blitarea(). +*/ + +#if GDISP_HARDWARE_CLEARS || defined(__DOXYGEN__) + /** + * @brief Clear the display. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] color The color of the pixel + * + * @notapi + */ + void GDISP_LLD(clear)(color_t color) { + /* Code here */ + } +#endif + +#if GDISP_HARDWARE_LINES || defined(__DOXYGEN__) + /** + * @brief Draw a line. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x0, y0 The start of the line + * @param[in] x1, y1 The end of the line + * @param[in] color The color of the line + * + * @notapi + */ + void GDISP_LLD(drawline)(coord_t x0, coord_t y0, coord_t x1, coord_t y1, color_t color) { + #if GDISP_NEED_VALIDATION + /* Need to clip to screen */ + #endif + /* Code here */ + } +#endif + +#if GDISP_HARDWARE_FILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a color. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] color The color of the fill + * + * @notapi + */ + void GDISP_LLD(fillarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) { + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + /* Code here */ + } +#endif + +#if GDISP_HARDWARE_BITFILLS || defined(__DOXYGEN__) + /** + * @brief Fill an area with a bitmap. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The start filled area + * @param[in] cx, cy The width and height to be filled + * @param[in] buffer The pixels to use to fill the area. + * + * @notapi + */ + void GDISP_LLD(blitarea)(coord_t x, coord_t y, coord_t cx, coord_t cy, const pixel_t *buffer) { + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) return; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + /* Code here */ + } +#endif + +/* Circular Drawing Functions */ +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLES) || defined(__DOXYGEN__) + /** + * @brief Draw a circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(drawcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_CIRCLE && GDISP_HARDWARE_CIRCLEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled circle. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the circle is over the edges of the screen. + * + * @param[in] x, y The centre of the circle + * @param[in] radius The radius of the circle + * @param[in] color The color of the circle + * + * @notapi + */ + void GDISP_LLD(fillcircle)(coord_t x, coord_t y, coord_t radius, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSES) || defined(__DOXYGEN__) + /** + * @brief Draw an ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(drawellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_ELLIPSE && GDISP_HARDWARE_ELLIPSEFILLS) || defined(__DOXYGEN__) + /** + * @brief Create a filled ellipse. + * @note Optional - The high level driver can emulate using software. + * @note If GDISP_NEED_CLIPPING is defined this routine MUST behave + * correctly if the ellipse is over the edges of the screen. + * + * @param[in] x, y The centre of the ellipse + * @param[in] a, b The dimensions of the ellipse + * @param[in] color The color of the ellipse + * + * @notapi + */ + void GDISP_LLD(fillellipse)(coord_t x, coord_t y, coord_t a, coord_t b, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXT) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a transparent background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * + * @notapi + */ + void GDISP_LLD(drawchar)(coord_t x, coord_t y, char c, font_t font, color_t color) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_TEXT && GDISP_HARDWARE_TEXTFILLS) || defined(__DOXYGEN__) + /** + * @brief Draw a character using a filled background. + * @note Optional - The high level driver can emulate using software. + * + * @param[in] x, y The top-left corner of the text + * @param[in] c The character to print + * @param[in] color The color of the character + * @param[in] bgcolor The background color + * + * @notapi + */ + void GDISP_LLD(fillchar)(coord_t x, coord_t y, char c, font_t font, color_t color, color_t bgcolor) { + #if GDISP_NEED_VALIDATION + /* Code here */ + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_PIXELREAD && GDISP_HARDWARE_PIXELREAD) || defined(__DOXYGEN__) + /** + * @brief Get the color of a particular pixel. + * @note Optional. + * @note If x,y is off the screen, the result is undefined. + * @return The color of the specified pixel. + * + * @param[in] x, y The start of the text + * + * @notapi + */ + color_t GDISP_LLD(getpixelcolor)(coord_t x, coord_t y) { + #if GDISP_NEED_VALIDATION + if (x >= GDISP.Width || y >= GDISP.Height) return 0; + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_SCROLL && GDISP_HARDWARE_SCROLL) || defined(__DOXYGEN__) + /** + * @brief Scroll vertically a section of the screen. + * @note Optional. + * @note If x,y + cx,cy is off the screen, the result is undefined. + * @note If lines is >= cy, it is equivelent to a area fill with bgcolor. + * + * @param[in] x, y The start of the area to be scrolled + * @param[in] cx, cy The size of the area to be scrolled + * @param[in] lines The number of lines to scroll (Can be positive or negative) + * @param[in] bgcolor The color to fill the newly exposed area. + * + * @notapi + */ + void GDISP_LLD(verticalscroll)(coord_t x, coord_t y, coord_t cx, coord_t cy, int lines, color_t bgcolor) { + #if GDISP_NEED_VALIDATION + if (cx < 1 || cy < 1 || x >= GDISP.Width || y >= GDISP.Height) return; + if (x+cx > GDISP.Width) cx = GDISP.Width - x; + if (y+cy > GDISP.Height) cy = GDISP.Height - y; + #endif + /* Code here */ + } +#endif + +#if (GDISP_NEED_CONTROL && GDISP_HARDWARE_CONTROL) || defined(__DOXYGEN__) + /** + * @brief Driver Control + * @detail Unsupported control codes are ignored. + * @note The value parameter should always be typecast to (void *). + * @note There are some predefined and some specific to the low level driver. + * @note GDISP_CONTROL_POWER - Takes a gdisp_powermode_t + * GDISP_CONTROL_ORIENTATION - Takes a gdisp_orientation_t + * GDISP_CONTROL_BACKLIGHT - Takes an int from 0 to 100. For a driver + * that only supports off/on anything other + * than zero is on. + * GDISP_CONTROL_CONTRAST - Takes an int from 0 to 100. + * GDISP_CONTROL_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to do. + * @param[in] value The value to use (always cast to a void *). + * + * @notapi + */ + void GDISP_LLD(control)(unsigned what, void *value) { + switch(what) { + case GDISP_CONTROL_POWER: + if (GDISP.Powermode == (gdisp_powermode_t)value) + return; + switch((gdisp_powermode_t)value) { + case powerOff: + /* Code here */ + break; + case powerOn: + /* Code here */ + /* You may need this --- + if (GDISP.Powermode != powerSleep) + GDISP_LLD(init)(); + */ + break; + case powerSleep: + /* Code here */ + break; + default: + return; + } + GDISP.Powermode = (gdisp_powermode_t)value; + return; + case GDISP_CONTROL_ORIENTATION: + if (GDISP.Orientation == (gdisp_orientation_t)value) + return; + switch((gdisp_orientation_t)value) { + case portrait: + /* Code here */ + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscape: + /* Code here */ + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + case portraitInv: + /* Code here */ + GDISP.Height = SCREEN_HEIGHT; + GDISP.Width = SCREEN_WIDTH; + break; + case landscapeInv: + /* Code here */ + GDISP.Height = SCREEN_WIDTH; + GDISP.Width = SCREEN_HEIGHT; + break; + default: + return; + } + GDISP.Orientation = (gdisp_orientation_t)value; + return; +/* + case GDISP_CONTROL_BACKLIGHT: + case GDISP_CONTROL_CONTRAST: +*/ + } + } +#endif + +#if (GDISP_NEED_QUERY && GDISP_HARDWARE_QUERY) || defined(__DOXYGEN__) +/** + * @brief Query a driver value. + * @detail Typecase the result to the type you want. + * @note GDISP_QUERY_WIDTH - (coord_t) Gets the width of the screen + * GDISP_QUERY_HEIGHT - (coord_t) Gets the height of the screen + * GDISP_QUERY_POWER - (gdisp_powermode_t) Get the current powermode + * GDISP_QUERY_ORIENTATION - (gdisp_orientation_t) Get the current screen orientation + * GDISP_QUERY_BACKLIGHT - (coord_t) Get the backlight state (0 to 100) + * GDISP_QUERY_CONTRAST - (coord_t) Get the contrast (0 to 100). + * GDISP_QUERY_LLD - Low level driver control constants start at + * this value. + * + * @param[in] what What to Query + * + * @notapi + */ +void *GDISP_LLD(query)(unsigned what) { + switch(what) { + case GDISP_QUERY_WIDTH: return (void *)(unsigned)GDISP.Width; + case GDISP_QUERY_HEIGHT: return (void *)(unsigned)GDISP.Height; + case GDISP_QUERY_POWER: return (void *)(unsigned)GDISP.Powermode; + case GDISP_QUERY_ORIENTATION: return (void *)(unsigned)GDISP.Orientation; + case GDISP_QUERY_BACKLIGHT: return (void *)(unsigned)GDISP.Backlight; + case GDISP_QUERY_CONTRAST: return (void *)(unsigned)GDISP.Contrast; + case GDISP_QUERY_LLD+0: + /* Code here */ + default: return (void *)-1; + } +} +#endif + +#endif /* HAL_USE_GDISP */ +/** @} */ diff --git a/templates/gdispXXXXX/gdisp_lld.mk b/templates/gdispXXXXX/gdisp_lld.mk new file mode 100644 index 00000000..d0933492 --- /dev/null +++ b/templates/gdispXXXXX/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +HALSRC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE/gdisp_lld.c + +# Required include directories +HALINC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE diff --git a/templates/gdispXXXXX/gdisp_lld_config.h b/templates/gdispXXXXX/gdisp_lld_config.h new file mode 100644 index 00000000..81a6826f --- /dev/null +++ b/templates/gdispXXXXX/gdisp_lld_config.h @@ -0,0 +1,66 @@ +/* + ChibiOS/RT - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file templates/gdisp_lld_config.h + * @brief GDISP Graphic Driver subsystem low level driver header template. + * + * @addtogroup GDISP + * @{ + */ + +#ifndef _GDISP_LLD_CONFIG_H +#define _GDISP_LLD_CONFIG_H + +#if HAL_USE_GDISP || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define GDISP_DRIVER_NAME "YourDriverName" +#define GDISP_LLD(x) gdisp_lld_##x##_YourDriverName + +#define GDISP_HARDWARE_LINES FALSE +#define GDISP_HARDWARE_CLEARS FALSE +#define GDISP_HARDWARE_FILLS FALSE +#define GDISP_HARDWARE_BITFILLS FALSE +#define GDISP_HARDWARE_CIRCLES FALSE +#define GDISP_HARDWARE_CIRCLEFILLS FALSE +#define GDISP_HARDWARE_ELLIPSES FALSE +#define GDISP_HARDWARE_ELLIPSEFILLS FALSE +#define GDISP_HARDWARE_TEXT FALSE +#define GDISP_HARDWARE_TEXTFILLS FALSE +#define GDISP_HARDWARE_SCROLL FALSE +#define GDISP_HARDWARE_PIXELREAD FALSE +#define GDISP_HARDWARE_CONTROL FALSE +#define GDISP_HARDWARE_QUERY FALSE + +#define GDISP_SOFTWARE_TEXTFILLDRAW FALSE +#define GDISP_SOFTWARE_TEXTBLITCOLUMN FALSE + +#define GDISP_PIXELFORMAT GDISP_PIXELFORMAT_RGB565 +#define GDISP_PACKED_PIXELS FALSE +#define GDISP_PACKED_LINES FALSE + +#endif /* HAL_USE_GDISP */ + +#endif /* _GDISP_LLD_CONFIG_H */ +/** @} */ diff --git a/templates/gdispXXXXX/readme.txt b/templates/gdispXXXXX/readme.txt new file mode 100644 index 00000000..bdb66006 --- /dev/null +++ b/templates/gdispXXXXX/readme.txt @@ -0,0 +1,35 @@ +To use this driver template + 1. Copy this entire directory (including the directory itself) + into halext/drivers + 2. Rename the directory to match your hardware. + 3. Customise each file in the directory including the .mk file + and this file. An example for this file is below... + 4. Keep any board specific code in a file you create called + gdisp_lld_board_yourboardname.h and adjust gdisp.c to match. + This enables someone porting to a new board to add another + suitable boad definition without worrying about the rest of + the driver. See the gdispNokia6610 driver as an example. + +------------------------------------------------------------------ +To use this driver: + +1. Add in your halconf.h: + a) #define HAL_USE_GDISP TRUE + b) Any optional high level driver defines (see gdisp.h) eg: GDISP_NEED_MULTITHREAD + c) One (only) of: + #define LCD_USE_GPIO + #define LCD_USE_SPI + #define LCD_USE_FSMC + d) All of the following (with appropriate values): + #define SCREEN_WIDTH 128 + #define SCREEN_HEIGHT 128 + e) If you are not using a known board then create a gdisp_lld_board.h file + and ensure it is on your include path. + Use the gdisp_lld_board_example.h file as a basis. + Currently known boards are: + XXXXXXXXX + + +2. To your makefile add the following lines: + include $(CHIBIOS)/os/halext/halext.mk + include $(CHIBIOS)/os/halext/drivers/gdispXXXXX/gdisp_lld.mk diff --git a/templates/readme.txt b/templates/readme.txt new file mode 100644 index 00000000..a2c5b7ef --- /dev/null +++ b/templates/readme.txt @@ -0,0 +1,4 @@ +The following low level driver templates are available: + +GDISP: + gdispXXXXX - Generalised GDISP driver From eb4d5be986c4fa3f08c3325174067ebbc348f59f Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 04:49:55 +0200 Subject: [PATCH 16/47] readme update --- readme1.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/readme1.txt b/readme1.txt index 907c7eb4..e2d33c18 100644 --- a/readme1.txt +++ b/readme1.txt @@ -5,17 +5,20 @@ To include any of these functions/drivers in your project... 2/ In your project Makefile (amongst similiar lines but after the hal line) add the line... include $(LCDLIB)/lcd.mk - 3/ In your project Makefile add the makefiles for any specific drivers you want e.g - include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk - include $(LCDLIB)/halext/drivers/gdispNokia6610/gdisp_lld.mk + 3/ Add $(LCDSRC) and $(LCDINC) to your SRCS and INCDIR of your projects Makefile - 4/ In your project halconf.h turn on the support you want eg. + 4/ In your project Makefile add the makefiles for any specific drivers you want e.g + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk + include $(LCDLIB)/halext/drivers/gdisp/gdispNokia6610/gdisp_lld.mk + + 5/ In your project halconf.h turn on the support you want eg. /** * @brief Enables the Touchpad subsystem. */ #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) #define HAL_USE_TOUCHPAD TRUE #endif + /** * @brief Enables the GDISP subsystem. */ @@ -24,5 +27,6 @@ To include any of these functions/drivers in your project... /* Any driver specific defines required go here. The below line is an example. */ #define GDISP_NEED_MULTITHREAD TRUE #endif - 5/ Do a make clean. + + 6/ Do a make clean. From 9df4ebe4263ed3acdee27fd1f2eb800b2843aaab Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 07:56:25 +0200 Subject: [PATCH 17/47] added tools folder --- tools/readme.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tools/readme.txt diff --git a/tools/readme.txt b/tools/readme.txt new file mode 100644 index 00000000..a43636f3 --- /dev/null +++ b/tools/readme.txt @@ -0,0 +1,7 @@ +This directory contains serval different tools, which might be helpful +for developing and using this GLCD library. + +Tools: + - foo + - bar + From 570ca30f58bc4adaea3d1aacbf1e425f567a2ebc Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 07:57:04 +0200 Subject: [PATCH 18/47] added docs folder --- docs/readme.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 docs/readme.txt diff --git a/docs/readme.txt b/docs/readme.txt new file mode 100644 index 00000000..3a76a92f --- /dev/null +++ b/docs/readme.txt @@ -0,0 +1,2 @@ +This folder contains documentation about this GLCD library. + From 4e854d1646b3222e7f8687383e2b5230909e5a97 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 07:57:42 +0200 Subject: [PATCH 19/47] moved contributors file to docs --- contributors.txt => docs/contributors.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename contributors.txt => docs/contributors.txt (100%) diff --git a/contributors.txt b/docs/contributors.txt similarity index 100% rename from contributors.txt rename to docs/contributors.txt From d8a0e7fe7879504b4a92b7aaa9f088df284442da Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 08:05:52 +0200 Subject: [PATCH 20/47] added touchpadXXXXX driver template --- templates/readme.txt | 5 + templates/touchpadXXXXX/touchpad_lld.c | 154 ++++++++++++++++++ templates/touchpadXXXXX/touchpad_lld.mk | 6 + templates/touchpadXXXXX/touchpad_lld_config.h | 45 +++++ 4 files changed, 210 insertions(+) create mode 100644 templates/touchpadXXXXX/touchpad_lld.c create mode 100644 templates/touchpadXXXXX/touchpad_lld.mk create mode 100644 templates/touchpadXXXXX/touchpad_lld_config.h diff --git a/templates/readme.txt b/templates/readme.txt index a2c5b7ef..398cca3d 100644 --- a/templates/readme.txt +++ b/templates/readme.txt @@ -2,3 +2,8 @@ The following low level driver templates are available: GDISP: gdispXXXXX - Generalised GDISP driver + +TOUCHPAD: + touchpadXXXXX - Generalised TOUCHPAD driver + + diff --git a/templates/touchpadXXXXX/touchpad_lld.c b/templates/touchpadXXXXX/touchpad_lld.c new file mode 100644 index 00000000..8c6c21d7 --- /dev/null +++ b/templates/touchpadXXXXX/touchpad_lld.c @@ -0,0 +1,154 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadXPT2046/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/* put needed macros for your interface/driver here. + * when using SPI, macros for setting and clearing CS line + */ +#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) +#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +#if !defined(__DOXYGEN__) + TOUCHPADDriver Touchpad; +#endif + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ + +/** + * @brief Low level Touchpad driver initialization. + * + * @notapi + */ +void tp_lld_init(TOUCHPADDriver *tp) { + /* do communicate with the touchpad controller + * to do any inizialisation (mostly spiStart()) + */ +} + +/** + * @brief Reads out the X direction. + * + * @notapi + */ +uint16_t tp_lld_read_x(void) { + uint16_t x; + + /* do communicate with the touchpad controller + * to receive the X-Coordinate + */ + x = 0; + + return x; +} + +/* + * @brief Reads out the Y direction. + * + * @notapi + */ +uint16_t tp_lld_read_y(void) { + uint16_t y; + + /* do communicate with the touchpad controller + * to receive the Y-Coordinate + */ + y = 0; + + return y; +} + +/* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @notapi + */ + uint8_t tp_lld_irq(void) { + /* do return PEN IRQ state if your + * touchpad controller does have any + */ + return 0; + } +#endif + +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) + /* + * @brief Reads out the Z direction / pressure. + * + * @notapi + */ + uint16_t tp_lld_read_z(void) { + /* return the pressure */ + return 0; + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + diff --git a/templates/touchpadXXXXX/touchpad_lld.mk b/templates/touchpadXXXXX/touchpad_lld.mk new file mode 100644 index 00000000..bbc7b527 --- /dev/null +++ b/templates/touchpadXXXXX/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadYOURDEVICE/touchpad_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/touchpad/touchpadYOURDEVICE + diff --git a/templates/touchpadXXXXX/touchpad_lld_config.h b/templates/touchpadXXXXX/touchpad_lld_config.h new file mode 100644 index 00000000..95db9ec8 --- /dev/null +++ b/templates/touchpadXXXXX/touchpad_lld_config.h @@ -0,0 +1,45 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadXPT2046/touchpad_lld_config.h + * @brief Touchppad Driver subsystem low level driver. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#ifndef _TOUCHPAD_LLD_CONFIG_H +#define _TOUCHPAD_LLD_CONFIG_H + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver hardware support. */ +/*===========================================================================*/ + +#define TOUCHPAD_HAS_IRQ TRUE +#define TOUCHPAD_HAS_PRESSURE TRUE + +#endif /* HAL_USE_TOUCHPAD */ + +#endif /* _TOUCHPAD_LLD_CONFIG_H */ +/** @} */ + From e78626a8bb1743e1b7c826984b07c117f5898076 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 08:07:15 +0200 Subject: [PATCH 21/47] gdispXXXXX driver template fix --- templates/gdispXXXXX/gdisp_lld.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/gdispXXXXX/gdisp_lld.mk b/templates/gdispXXXXX/gdisp_lld.mk index d0933492..0d243099 100644 --- a/templates/gdispXXXXX/gdisp_lld.mk +++ b/templates/gdispXXXXX/gdisp_lld.mk @@ -1,5 +1,5 @@ # List the required driver. -HALSRC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE/gdisp_lld.c +LCDSRC += $(LCDLIB)/drivers/gdisp/gdispYOURDEVICE/gdisp_lld.c # Required include directories -HALINC += ${CHIBIOS}/os/halext/drivers/gdispYOURDEVICE +LCDINC += $(LCDLIB)/drivers/gdisp/gdispYOURDEVICE From 46e67f657d1ac142853f3d933eb6b63239e564f8 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 08:08:38 +0200 Subject: [PATCH 22/47] touchpad driver fixes --- drivers/touchpad/touchpadADS7843/touchpad_lld.c | 10 +++++----- drivers/touchpad/touchpadXPT2046/touchpad_lld.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/drivers/touchpad/touchpadADS7843/touchpad_lld.c index a5265995..8fc334b2 100644 --- a/drivers/touchpad/touchpadADS7843/touchpad_lld.c +++ b/drivers/touchpad/touchpadADS7843/touchpad_lld.c @@ -91,7 +91,7 @@ void tp_lld_init(TOUCHPADDriver *tp) { uint16_t tp_lld_read_x(void) { uint8_t txbuf[1]; uint8_t rxbuf[2]; - uint16_t y; + uint16_t x; txbuf[0] = 0xd0; TP_CS_LOW; @@ -99,14 +99,14 @@ uint16_t tp_lld_read_x(void) { spiReceive(&SPID1, 2, rxbuf); TP_CS_HIGH; - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; + x = rxbuf[0] << 4; + x |= rxbuf[1] >> 4; - return y; + return x; } /* - * @brief Reads out the X direction. + * @brief Reads out the Y direction. * * @notapi */ diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/drivers/touchpad/touchpadXPT2046/touchpad_lld.c index 195c8aa6..24afcab4 100644 --- a/drivers/touchpad/touchpadXPT2046/touchpad_lld.c +++ b/drivers/touchpad/touchpadXPT2046/touchpad_lld.c @@ -91,7 +91,7 @@ void tp_lld_init(TOUCHPADDriver *tp) { uint16_t tp_lld_read_x(void) { uint8_t txbuf[1]; uint8_t rxbuf[2]; - uint16_t y; + uint16_t x; txbuf[0] = 0xd0; TP_CS_LOW; @@ -99,10 +99,10 @@ uint16_t tp_lld_read_x(void) { spiReceive(&SPID1, 2, rxbuf); TP_CS_HIGH; - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; + x = rxbuf[0] << 4; + x |= rxbuf[1] >> 4; - return y; + return x; } /* From 8142d6c931b0fdd010ab8607d39e652626e06471 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 08:11:19 +0200 Subject: [PATCH 23/47] gdispVMT makefile update --- drivers/gdisp/gdispVMT/gdisp_lld.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.mk b/drivers/gdisp/gdispVMT/gdisp_lld.mk index f89470a6..71d75f14 100644 --- a/drivers/gdisp/gdispVMT/gdisp_lld.mk +++ b/drivers/gdisp/gdispVMT/gdisp_lld.mk @@ -1,7 +1,7 @@ # List the required driver. -LCDSRC += ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld.c \ - ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver1.c \ - ${CHIBIOS}/os/halext/drivers/gdispVMT/gdisp_lld_driver2.c +LCDSRC += $(LCDLIB)/drivers/gdisp/gdispVMT/gdisp_lld.c \ + $(LCDLIB)/os/halext/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c \ + $(LCDLIB)/os/halext/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c # Required include directories -LCDINC += ${CHIBIOS}/os/halext/drivers/gdispVMT +LCDINC += $(LCDLIB)/drivers/gdisp/gdispVMT From 9d886f2451c7a277257bd5b779581527238e12aa Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 08:45:02 +0200 Subject: [PATCH 24/47] readme fix --- readme1.txt | 32 -------------------------------- readme2.txt | 19 ------------------- 2 files changed, 51 deletions(-) delete mode 100644 readme1.txt delete mode 100644 readme2.txt diff --git a/readme1.txt b/readme1.txt deleted file mode 100644 index e2d33c18..00000000 --- a/readme1.txt +++ /dev/null @@ -1,32 +0,0 @@ -To include any of these functions/drivers in your project... - - 1/ Specify the path to the LCDLIB. If none defined, default is $(CHIBIOS)/ext/lcd - - 2/ In your project Makefile (amongst similiar lines but after the hal line) add the line... - include $(LCDLIB)/lcd.mk - - 3/ Add $(LCDSRC) and $(LCDINC) to your SRCS and INCDIR of your projects Makefile - - 4/ In your project Makefile add the makefiles for any specific drivers you want e.g - include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk - include $(LCDLIB)/halext/drivers/gdisp/gdispNokia6610/gdisp_lld.mk - - 5/ In your project halconf.h turn on the support you want eg. - /** - * @brief Enables the Touchpad subsystem. - */ - #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) - #define HAL_USE_TOUCHPAD TRUE - #endif - - /** - * @brief Enables the GDISP subsystem. - */ - #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__) - #define HAL_USE_GDISP TRUE - /* Any driver specific defines required go here. The below line is an example. */ - #define GDISP_NEED_MULTITHREAD TRUE - #endif - - 6/ Do a make clean. - diff --git a/readme2.txt b/readme2.txt deleted file mode 100644 index 0b67c9b0..00000000 --- a/readme2.txt +++ /dev/null @@ -1,19 +0,0 @@ -## Doxygen -run doxygen in the toplevel directory to generate the doxygen documentation in html - - - -## Wiki -please read the wiki pages to this project carefully, before you ask any questions: - -http://chibios.org/dokuwiki/doku.php?id=chibios:community - - - -## Maintainer & Contributors -please read the contributors.txt file which contains a full history of each contribution - -Maintainer: - - Joel Bodenmann aka Tectu - - From bcccde53e6af28dcc13756516ed2806b64c60da3 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 08:47:27 +0200 Subject: [PATCH 25/47] doc updates --- docs/usage.txt | 32 ++++++++++++++++++++++++++++++++ readme.txt | 19 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 docs/usage.txt create mode 100644 readme.txt diff --git a/docs/usage.txt b/docs/usage.txt new file mode 100644 index 00000000..e2d33c18 --- /dev/null +++ b/docs/usage.txt @@ -0,0 +1,32 @@ +To include any of these functions/drivers in your project... + + 1/ Specify the path to the LCDLIB. If none defined, default is $(CHIBIOS)/ext/lcd + + 2/ In your project Makefile (amongst similiar lines but after the hal line) add the line... + include $(LCDLIB)/lcd.mk + + 3/ Add $(LCDSRC) and $(LCDINC) to your SRCS and INCDIR of your projects Makefile + + 4/ In your project Makefile add the makefiles for any specific drivers you want e.g + include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk + include $(LCDLIB)/halext/drivers/gdisp/gdispNokia6610/gdisp_lld.mk + + 5/ In your project halconf.h turn on the support you want eg. + /** + * @brief Enables the Touchpad subsystem. + */ + #if !defined(HAL_USE_TOUCHPAD) || defined(__DOXYGEN__) + #define HAL_USE_TOUCHPAD TRUE + #endif + + /** + * @brief Enables the GDISP subsystem. + */ + #if !defined(HAL_USE_GDISP) || defined(__DOXYGEN__) + #define HAL_USE_GDISP TRUE + /* Any driver specific defines required go here. The below line is an example. */ + #define GDISP_NEED_MULTITHREAD TRUE + #endif + + 6/ Do a make clean. + diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..0b67c9b0 --- /dev/null +++ b/readme.txt @@ -0,0 +1,19 @@ +## Doxygen +run doxygen in the toplevel directory to generate the doxygen documentation in html + + + +## Wiki +please read the wiki pages to this project carefully, before you ask any questions: + +http://chibios.org/dokuwiki/doku.php?id=chibios:community + + + +## Maintainer & Contributors +please read the contributors.txt file which contains a full history of each contribution + +Maintainer: + - Joel Bodenmann aka Tectu + + From 3830d082b303da81cb75f911c57b9d19c6c99487 Mon Sep 17 00:00:00 2001 From: Thomas Saunders Date: Thu, 9 Aug 2012 09:09:45 +0100 Subject: [PATCH 26/47] use gdisp code in console needs moving into halext structure --- old/console.c | 31 +++++++++++++++---------------- old/console.h | 17 ++++++++++------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/old/console.c b/old/console.c index caddfce2..55bc3312 100644 --- a/old/console.c +++ b/old/console.c @@ -19,14 +19,15 @@ */ #include "ch.h" +#include "hal.h" -#include "glcd.h" +#include "gdisp.h" +#include "gdisp_fonts.h" #include "console.h" /* * Interface implementation. The interface is write only */ - static size_t writes(void *ip, const uint8_t *bp, size_t n) { return lcdConsoleWrite((GLCDConsole *)ip, bp, n); } @@ -90,14 +91,14 @@ static const struct GLCDConsoleVMT vmt = { }; -msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color) { +msg_t lcdConsoleInit(GLCDConsole *console, coord_t x0, coord_t y0, coord_t width, coord_t height, font_t font, pixel_t bkcolor, pixel_t color) { const uint8_t* ptr; uint16_t chi; uint16_t x,y; console->vmt = &vmt; /* read font, get height */ - console->fy = lcdGetFontHeight(font); + console->fy = font->height; /* calculate the size of the console as an integer multiple of characters height*/ console->sx = width; @@ -113,7 +114,7 @@ msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t wi console->font = font; - lcdFillArea(x0, y0, x0+width, y0+height, console->bkcolor); + gdispFillArea(x0, y0, x0 + width, y0 + height, console->bkcolor); return RDY_OK; } @@ -123,7 +124,7 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) { if(c == '\n') { /* clear the text at the end of the line */ if(console->cx < console->sx) - lcdFillArea(console->x0 + console->cx, console->y0 + console->cy, + gdispFillArea(console->x0 + console->cx, console->y0 + console->cy, console->x0 + console->sx, console->y0 + console->cy + console->fy, console->bkcolor); console->cx = 0; @@ -132,10 +133,10 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) { /* TODO: work backwards through the buffer to the start of the current line */ //console->cx = 0; } else { - width = lcdMeasureChar(c, console->font); + width = _getCharWidth(console->font, c); if((console->cx + width) >= console->sx) { /* clear the text at the end of the line */ - lcdFillArea(console->x0 + console->cx, console->y0 + console->cy, + gdispFillArea(console->x0 + console->cx, console->y0 + console->cy, console->x0 + console->cx + width, console->y0 + console->cy + console->fy, console->bkcolor); console->cx = 0; @@ -143,16 +144,16 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) { } if((console->cy > console->sy)) { - - lcdVerticalScroll(console->x0, console->y0, console->x0 + console->sx, - console->y0 + console->sy + console->fy, console->fy); + /* scroll the screen */ + gdispVerticalScroll(console->x0, console->y0, console->x0 + console->sx, + console->y0 + console->sy + console->fy, console->fy, console->bkcolor); /* reset the cursor */ console->cx = 0; console->cy = console->sy; } - lcdDrawChar(console->x0 + console->cx, console->y0 + console->cy, c, - console->font, console->color, console->bkcolor, solid); + gdispDrawChar(console->x0 + console->cx, console->y0 + console->cy, c, + console->font, console->color); /* update cursor */ console->cx += width; @@ -160,12 +161,10 @@ msg_t lcdConsolePut(GLCDConsole *console, char c) { return RDY_OK; } -msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n) { +msg_t lcdConsoleWrite(GLCDConsole *console, char *bp, size_t n) { size_t i; for(i = 0; i < n; i++) lcdConsolePut(console, bp[i]); return RDY_OK; } - - diff --git a/old/console.h b/old/console.h index f76c5adf..edd8498e 100644 --- a/old/console.h +++ b/old/console.h @@ -21,7 +21,10 @@ #ifndef CONSOLE_H #define CONSOLE_H -#include "glcd.h" +#include "ch.h" +#include "hal.h" + +#include "gdisp.h" /** * @brief Structure representing a GLCD driver. @@ -58,13 +61,13 @@ struct GLCDConsole { /* font */ font_t font; /* lcd area to use */ - uint16_t x0,y0; + coord_t x0,y0; /* current cursor position, in pixels */ - uint16_t cx,cy; + coord_t cx,cy; /* console size in pixels */ - uint16_t sx,sy; + coord_t sx,sy; /* foreground and background colour */ - uint16_t bkcolor, color; + pixel_t bkcolor, color; /* font size in pixels */ uint8_t fy; }; @@ -73,9 +76,9 @@ struct GLCDConsole { extern "C" { #endif -msg_t lcdConsoleInit(GLCDConsole *console, uint16_t x0, uint16_t y0, uint16_t width, uint16_t height, font_t font, uint16_t bkcolor, uint16_t color); +msg_t lcdConsoleInit(GLCDConsole *console, coord_t x0, coord_t y0, coord_t width, coord_t height, font_t font, pixel_t bkcolor, pixel_t color); msg_t lcdConsolePut(GLCDConsole *console, char c); -msg_t lcdConsoleWrite(GLCDConsole *console, uint8_t *bp, size_t n); +msg_t lcdConsoleWrite(GLCDConsole *console, char *bp, size_t n); #ifdef __cplusplus } From c14a813c6ee78b7f55bfaf40ae4012a87d6348cf Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 13:40:48 +0200 Subject: [PATCH 27/47] ported console (thanks to badger) --- {old => console}/console.c | 0 {old => console}/console.h | 0 console/console.mk | 4 ++++ console/readme.txt | 3 +++ lcd.mk | 4 +++- 5 files changed, 10 insertions(+), 1 deletion(-) rename {old => console}/console.c (100%) rename {old => console}/console.h (100%) create mode 100644 console/console.mk create mode 100644 console/readme.txt diff --git a/old/console.c b/console/console.c similarity index 100% rename from old/console.c rename to console/console.c diff --git a/old/console.h b/console/console.h similarity index 100% rename from old/console.h rename to console/console.h diff --git a/console/console.mk b/console/console.mk new file mode 100644 index 00000000..58c1b8f1 --- /dev/null +++ b/console/console.mk @@ -0,0 +1,4 @@ +LCDSRC += $(LCDLIB)/console/console.c + +LCDINC += $(LCDLIB)/console + diff --git a/console/readme.txt b/console/readme.txt new file mode 100644 index 00000000..806fdf98 --- /dev/null +++ b/console/readme.txt @@ -0,0 +1,3 @@ +This directory contains any files which are needed by the +console implementation. + diff --git a/lcd.mk b/lcd.mk index 802873b5..c49ddc61 100644 --- a/lcd.mk +++ b/lcd.mk @@ -3,8 +3,10 @@ ifeq ($(LCDLIB),) LCDLIB = $(CHIBIOS)/ext/lcd endif +include $(LCDLIB)/console/console.mk + LCDSRC += $(LCDLIB)/src/gdisp.c \ $(LCDLIB)/src/gdisp_fonts.c \ - $(LCDLIB)/src/touchpad.c + $(LCDLIB)/src/touchpad.c LCDINC += $(LCDLIB)/include From 6982d7d076ac480fa46bb1c69ef49963c7bebb18 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 13:44:43 +0200 Subject: [PATCH 28/47] moved console to src/ and include/ --- console/console.mk | 4 ---- console/readme.txt | 3 --- {console => include}/console.h | 0 lcd.mk | 5 ++--- {console => src}/console.c | 0 5 files changed, 2 insertions(+), 10 deletions(-) delete mode 100644 console/console.mk delete mode 100644 console/readme.txt rename {console => include}/console.h (100%) rename {console => src}/console.c (100%) diff --git a/console/console.mk b/console/console.mk deleted file mode 100644 index 58c1b8f1..00000000 --- a/console/console.mk +++ /dev/null @@ -1,4 +0,0 @@ -LCDSRC += $(LCDLIB)/console/console.c - -LCDINC += $(LCDLIB)/console - diff --git a/console/readme.txt b/console/readme.txt deleted file mode 100644 index 806fdf98..00000000 --- a/console/readme.txt +++ /dev/null @@ -1,3 +0,0 @@ -This directory contains any files which are needed by the -console implementation. - diff --git a/console/console.h b/include/console.h similarity index 100% rename from console/console.h rename to include/console.h diff --git a/lcd.mk b/lcd.mk index c49ddc61..b2e7d784 100644 --- a/lcd.mk +++ b/lcd.mk @@ -3,10 +3,9 @@ ifeq ($(LCDLIB),) LCDLIB = $(CHIBIOS)/ext/lcd endif -include $(LCDLIB)/console/console.mk - LCDSRC += $(LCDLIB)/src/gdisp.c \ $(LCDLIB)/src/gdisp_fonts.c \ - $(LCDLIB)/src/touchpad.c + $(LCDLIB)/src/touchpad.c \ + $(LCDLIB)/src/console.c LCDINC += $(LCDLIB)/include diff --git a/console/console.c b/src/console.c similarity index 100% rename from console/console.c rename to src/console.c From 504049e969f407485eb2c75dc72f8645013239be Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 20:48:20 +0200 Subject: [PATCH 29/47] added filestructure like chibios --- docs/files.txt | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 docs/files.txt diff --git a/docs/files.txt b/docs/files.txt new file mode 100644 index 00000000..4bed0f2d --- /dev/null +++ b/docs/files.txt @@ -0,0 +1,104 @@ +This is a tree of the toplevel directory of the GLCD library. +The maintainer is supposed to keep it up to date at any time. + + +├── console +│   ├── console.c +│   └── console.h +├── demos +│   ├── lcd +│   │   └── main.c +│   └── readme.txt +├── docs +│   ├── contributors.txt +│   ├── readme.txt +│   └── usage.txt +├── Doxygenfile +├── drivers +│   ├── gdisp +│   │   ├── gdispNokia6610 +│   │   │   ├── gdisp_lld_board_example.h +│   │   │   ├── gdisp_lld_board_olimexsam7ex256.h +│   │   │   ├── gdisp_lld.c +│   │   │   ├── gdisp_lld_config.h +│   │   │   ├── gdisp_lld.mk +│   │   │   ├── GE12.h +│   │   │   ├── GE8.h +│   │   │   └── readme.txt +│   │   ├── gdispS6d1121 +│   │   │   ├── gdisp_lld.c +│   │   │   ├── gdisp_lld_config.h +│   │   │   ├── gdisp_lld.mk +│   │   │   ├── readme.txt +│   │   │   └── s6d1121_lld.c.h +│   │   ├── gdispSsd1289 +│   │   │   ├── gdisp_lld.c +│   │   │   ├── gdisp_lld_config.h +│   │   │   ├── gdisp_lld.mk +│   │   │   ├── readme.txt +│   │   │   └── ssd1289_lld.c.h +│   │   ├── gdispTestStub +│   │   │   ├── gdisp_lld.c +│   │   │   ├── gdisp_lld_config.h +│   │   │   ├── gdisp_lld.mk +│   │   │   └── readme.txt +│   │   └── gdispVMT +│   │   ├── gdisp_lld.c +│   │   ├── gdisp_lld_config.h +│   │   ├── gdisp_lld_driver1.c +│   │   ├── gdisp_lld_driver2.c +│   │   ├── gdisp_lld.mk +│   │   └── readme.txt +│   └── touchpad +│   ├── touchpadADS7843 +│   │   ├── readme.txt +│   │   ├── touchpad_lld.c +│   │   ├── touchpad_lld_config.h +│   │   └── touchpad_lld.mk +│   └── touchpadXPT2046 +│   ├── readme.txt +│   ├── touchpad_lld.c +│   ├── touchpad_lld_config.h +│   └── touchpad_lld.mk +├── include +│   ├── console.h +│   ├── gdisp_emulation.c +│   ├── gdisp_fonts.h +│   ├── gdisp.h +│   ├── gdisp_lld.h +│   ├── gdisp_lld_msgs.h +│   ├── glcd.h +│   ├── touchpad.h +│   └── touchpad_lld.h +├── lcd.mk +├── license.txt +├── old +│   ├── graph +│   │   ├── graph.c +│   │   ├── graph.h +│   │   └── graph.mk +│   └── gui +│   ├── gui.c +│   ├── gui.h +│   └── gui.mk +├── readme.txt +├── src +│   ├── console.c +│   ├── gdisp.c +│   ├── gdisp_fonts.c +│   ├── gdisp-readme.txt +│   └── touchpad.c +├── templates +│   ├── gdispXXXXX +│   │   ├── gdisp_lld.c +│   │   ├── gdisp_lld_config.h +│   │   ├── gdisp_lld.mk +│   │   └── readme.txt +│   ├── readme.txt +│   └── touchpadXXXXX +│   ├── touchpad_lld.c +│   ├── touchpad_lld_config.h +│   └── touchpad_lld.mk +└── tools + └── readme.txt + From 72d1bef6c3e020106cffad04799f7fd7737a2ebf Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 20:53:01 +0200 Subject: [PATCH 30/47] added docs/releases.txt --- docs/releases.txt | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/releases.txt diff --git a/docs/releases.txt b/docs/releases.txt new file mode 100644 index 00000000..8ff13228 --- /dev/null +++ b/docs/releases.txt @@ -0,0 +1,6 @@ +***************************************************************************** +*** Releases *** +***************************************************************************** + +*** 0.1.0 *** + From 1a6eed0c07806b5d5129024eb3645907e25a4139 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 20:59:29 +0200 Subject: [PATCH 31/47] added touchpad demo --- demos/touchpad/main.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 demos/touchpad/main.c diff --git a/demos/touchpad/main.c b/demos/touchpad/main.c new file mode 100644 index 00000000..8a1d3275 --- /dev/null +++ b/demos/touchpad/main.c @@ -0,0 +1,26 @@ +#include "ch.h" +#include "hal.h" +#include "gdisp.h" +#include "touchpad.h" + +TOUCHPADDriver TOUCHPADD1 = { + &SPID1, +}; + +int main(void) { + halInit(); + chSysInit(); + + gdispInit(); + gdispClear(Lime); + + tpInit(&TOUCHPADD1); + tpCalibrate(); + + gdispClear(Lime); + + while (TRUE) { + gdispDrawFillCircle(tpReadX(), tpReadY(), 3, Black); + } +} + From f833dc27c0ebcf92ef34c0f842088c5efb09a277 Mon Sep 17 00:00:00 2001 From: Tectu Date: Mon, 13 Aug 2012 21:00:53 +0200 Subject: [PATCH 32/47] docs update --- docs/files.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/files.txt b/docs/files.txt index 4bed0f2d..244a4c66 100644 --- a/docs/files.txt +++ b/docs/files.txt @@ -1,17 +1,17 @@ This is a tree of the toplevel directory of the GLCD library. -The maintainer is supposed to keep it up to date at any time. +The maintainer is supposed to keep it up to date at any new release. - -├── console -│   ├── console.c -│   └── console.h ├── demos │   ├── lcd │   │   └── main.c -│   └── readme.txt +│   ├── readme.txt +│   └── touchpad +│   └── main.c ├── docs │   ├── contributors.txt +│   ├── files.txt │   ├── readme.txt +│   ├── releases.txt │   └── usage.txt ├── Doxygenfile ├── drivers @@ -102,3 +102,5 @@ The maintainer is supposed to keep it up to date at any time. └── tools └── readme.txt +23 directories, 77 files + From 53704f7b368f18753f82f7004ddc90f8da40903b Mon Sep 17 00:00:00 2001 From: trsaunders Date: Mon, 13 Aug 2012 21:42:24 +0100 Subject: [PATCH 33/47] add basic console docs elaborate on contributions --- docs/console.txt | 20 ++++++++++++++++++++ docs/contributors.txt | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 docs/console.txt diff --git a/docs/console.txt b/docs/console.txt new file mode 100644 index 00000000..09e7ae86 --- /dev/null +++ b/docs/console.txt @@ -0,0 +1,20 @@ +The console module acts as a BaseSequentialStream at a user defined area of the LCD. + +Requirements: +The console code requires a lld that has vertical scroll implemented. +It is also necessary to enable the scroll code: + + #define GDISP_NEED_SCROLL TRUE + +Usage: + + #include "console.h" + + /* Define a console object */ + GLCDConsole CON1; + + /* initialise the console to take up the entire screen */ + lcdConsoleInit(&CON1, 0, 0, 320, 240, &fontLarger, Black, White); + + /* print something */ + chprintf((BaseSequentialStream *)&CON1, "Hello the time is %d\nGoodbye.", chTimeNow()); diff --git a/docs/contributors.txt b/docs/contributors.txt index 289aa98f..70c7e660 100644 --- a/docs/contributors.txt +++ b/docs/contributors.txt @@ -10,6 +10,8 @@ Date NickName RealName Contribution 30.07.2012 inmarket Andrew Hannam halext implementation - dxli Dongxu Li lcdDrawEllipse() filled option - benwilliam - fastMath & lcdDrawEllipse() -- Badger Thomas Saunders console implementation, FSMC +- Badger Thomas Saunders console implementation + FSMC for STM32F1 and F4 + lld orientation fixes for S6D1121 and SSD1189 - Abhishek Abhishek Kakkar font rendering, S6D1121 GPIO From 61f527498f6c6705792c39f0b38d6c8794d7b39e Mon Sep 17 00:00:00 2001 From: trsaunders Date: Mon, 13 Aug 2012 21:46:58 +0100 Subject: [PATCH 34/47] only enable console code if driver support is available --- src/console.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/console.c b/src/console.c index 55bc3312..e5f2371c 100644 --- a/src/console.c +++ b/src/console.c @@ -25,6 +25,8 @@ #include "gdisp_fonts.h" #include "console.h" +#if defined(GDISP_NEED_SCROLL) + /* * Interface implementation. The interface is write only */ @@ -168,3 +170,6 @@ msg_t lcdConsoleWrite(GLCDConsole *console, char *bp, size_t n) { return RDY_OK; } + + +#endif /* GDISP_NEED_SCROLL */ From ee99456a9eeeacce0ea574b980e34ad72620fccb Mon Sep 17 00:00:00 2001 From: trsaunders Date: Mon, 13 Aug 2012 21:53:52 +0100 Subject: [PATCH 35/47] fix spelling --- src/gdisp-readme.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gdisp-readme.txt b/src/gdisp-readme.txt index 12b00e2c..28b86077 100644 --- a/src/gdisp-readme.txt +++ b/src/gdisp-readme.txt @@ -1,10 +1,10 @@ -The new GDISP driver is an architecture independant rewrite of the GLCD interface. -This new architecture independance should allow many new low level drivers to be easily added. +The new GDISP driver is an architecture independent rewrite of the GLCD interface. +This new architecture independence should allow many new low level drivers to be easily added. GDISP allows low-level driver hardware accelerated drawing routines while providing a software emulation if the low level driver can not provide it. A basic low level driver now only requires 2 routines to be written. -A glcd.h compatability file has been included that allow applications written to use the existing GLCD driver to +A glcd.h compatibility file has been included that allow applications written to use the existing GLCD driver to use the GDISP driver with little or no change. It is written in the ChibiOS style with ChibiOS style includes and documentation. From 7d336b5e01df076035853fb9199f15c41a633b2c Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 14 Aug 2012 01:54:46 +0200 Subject: [PATCH 36/47] SSD1289 fix --- drivers/gdisp/gdispSsd1289/gdisp_lld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.c b/drivers/gdisp/gdispSsd1289/gdisp_lld.c index 7dfb83a7..39c7334c 100644 --- a/drivers/gdisp/gdispSsd1289/gdisp_lld.c +++ b/drivers/gdisp/gdispSsd1289/gdisp_lld.c @@ -478,7 +478,7 @@ void GDISP_LLD(drawpixel)(coord_t x, coord_t y, color_t color) { lld_lcdSetViewPort(x, lines > 0 ? (y+gap) : y, cx, abslines); lld_lcdWriteStreamStart(); gap = cx*abslines; - for(i = 0; i < gap; i++) lld_lcdWriteData(color); + for(i = 0; i < gap; i++) lld_lcdWriteData(bgcolor); lld_lcdWriteStreamStop(); lld_lcdResetViewPort(); } From f8a0e45cbffb9884e6980f3e636053c11a47a1ba Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 14 Aug 2012 01:57:43 +0200 Subject: [PATCH 37/47] added console demo --- demos/console/main.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 demos/console/main.c diff --git a/demos/console/main.c b/demos/console/main.c new file mode 100755 index 00000000..78e24a9c --- /dev/null +++ b/demos/console/main.c @@ -0,0 +1,47 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "ch.h" +#include "hal.h" +#include "gdisp.h" +#include "chprintf.h" +#include "console.h" + +static GLCDConsole CON1; + +int main(void) { + halInit(); + chSysInit(); + + gdispInit(); + gdispClear(Lime); + + lcdConsoleInit(&CON1, 0, 0, gdispGetWidth(), gdispGetHeight(), &fontLarger, Black, White); + + + chprintf((BaseSequentialStream *)&CON1, "Hello the time is %d\nGoodbye.", chTimeNow()); + + + while (TRUE) { + + chThdSleepMilliseconds(100); + } +} + From 975faaab679c7a872e0390ac533abf79b08dedbf Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 14 Aug 2012 01:58:24 +0200 Subject: [PATCH 38/47] demos license header --- demos/lcd/main.c | 20 ++++++++++++++++++++ demos/touchpad/main.c | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/demos/lcd/main.c b/demos/lcd/main.c index 99b87948..aec1b9ab 100644 --- a/demos/lcd/main.c +++ b/demos/lcd/main.c @@ -1,3 +1,23 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + #include "ch.h" #include "hal.h" #include "gdisp.h" diff --git a/demos/touchpad/main.c b/demos/touchpad/main.c index 8a1d3275..52f52e83 100644 --- a/demos/touchpad/main.c +++ b/demos/touchpad/main.c @@ -1,3 +1,23 @@ +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + #include "ch.h" #include "hal.h" #include "gdisp.h" From e6373df68bbfc508493aabaec2b56335f8a8d6b0 Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 14 Aug 2012 02:10:57 +0200 Subject: [PATCH 39/47] removed gdisp prefix on gdisp drivers --- docs/usage.txt | 2 +- drivers/gdisp/{gdispNokia6610 => Nokia6610}/GE12.h | 0 drivers/gdisp/{gdispNokia6610 => Nokia6610}/GE8.h | 0 drivers/gdisp/{gdispNokia6610 => Nokia6610}/gdisp_lld.c | 0 drivers/gdisp/Nokia6610/gdisp_lld.mk | 5 +++++ .../gdisp_lld_board_example.h | 0 .../gdisp_lld_board_olimexsam7ex256.h | 0 .../gdisp/{gdispNokia6610 => Nokia6610}/gdisp_lld_config.h | 0 drivers/gdisp/{gdispNokia6610 => Nokia6610}/readme.txt | 0 drivers/gdisp/{gdispS6d1121 => S6D1121}/gdisp_lld.c | 0 drivers/gdisp/S6D1121/gdisp_lld.mk | 5 +++++ drivers/gdisp/{gdispS6d1121 => S6D1121}/gdisp_lld_config.h | 0 drivers/gdisp/{gdispS6d1121 => S6D1121}/readme.txt | 0 drivers/gdisp/{gdispS6d1121 => S6D1121}/s6d1121_lld.c.h | 0 drivers/gdisp/{gdispSsd1289 => SSD1289}/gdisp_lld.c | 0 drivers/gdisp/SSD1289/gdisp_lld.mk | 5 +++++ drivers/gdisp/{gdispSsd1289 => SSD1289}/gdisp_lld_config.h | 0 drivers/gdisp/{gdispSsd1289 => SSD1289}/readme.txt | 0 drivers/gdisp/{gdispSsd1289 => SSD1289}/ssd1289_lld.c.h | 0 drivers/gdisp/{gdispTestStub => TestStub}/gdisp_lld.c | 0 drivers/gdisp/TestStub/gdisp_lld.mk | 5 +++++ .../gdisp/{gdispTestStub => TestStub}/gdisp_lld_config.h | 0 drivers/gdisp/{gdispTestStub => TestStub}/readme.txt | 0 drivers/gdisp/{gdispVMT => VMT}/gdisp_lld.c | 0 drivers/gdisp/VMT/gdisp_lld.mk | 7 +++++++ drivers/gdisp/{gdispVMT => VMT}/gdisp_lld_config.h | 0 drivers/gdisp/{gdispVMT => VMT}/gdisp_lld_driver1.c | 0 drivers/gdisp/{gdispVMT => VMT}/gdisp_lld_driver2.c | 0 drivers/gdisp/{gdispVMT => VMT}/readme.txt | 0 drivers/gdisp/gdispNokia6610/gdisp_lld.mk | 5 ----- drivers/gdisp/gdispS6d1121/gdisp_lld.mk | 5 ----- drivers/gdisp/gdispSsd1289/gdisp_lld.mk | 5 ----- drivers/gdisp/gdispTestStub/gdisp_lld.mk | 5 ----- drivers/gdisp/gdispVMT/gdisp_lld.mk | 7 ------- 34 files changed, 28 insertions(+), 28 deletions(-) rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/GE12.h (100%) rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/GE8.h (100%) rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/gdisp_lld.c (100%) create mode 100644 drivers/gdisp/Nokia6610/gdisp_lld.mk rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/gdisp_lld_board_example.h (100%) rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/gdisp_lld_board_olimexsam7ex256.h (100%) rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/gdisp_lld_config.h (100%) rename drivers/gdisp/{gdispNokia6610 => Nokia6610}/readme.txt (100%) rename drivers/gdisp/{gdispS6d1121 => S6D1121}/gdisp_lld.c (100%) create mode 100644 drivers/gdisp/S6D1121/gdisp_lld.mk rename drivers/gdisp/{gdispS6d1121 => S6D1121}/gdisp_lld_config.h (100%) rename drivers/gdisp/{gdispS6d1121 => S6D1121}/readme.txt (100%) rename drivers/gdisp/{gdispS6d1121 => S6D1121}/s6d1121_lld.c.h (100%) rename drivers/gdisp/{gdispSsd1289 => SSD1289}/gdisp_lld.c (100%) create mode 100644 drivers/gdisp/SSD1289/gdisp_lld.mk rename drivers/gdisp/{gdispSsd1289 => SSD1289}/gdisp_lld_config.h (100%) rename drivers/gdisp/{gdispSsd1289 => SSD1289}/readme.txt (100%) rename drivers/gdisp/{gdispSsd1289 => SSD1289}/ssd1289_lld.c.h (100%) rename drivers/gdisp/{gdispTestStub => TestStub}/gdisp_lld.c (100%) create mode 100644 drivers/gdisp/TestStub/gdisp_lld.mk rename drivers/gdisp/{gdispTestStub => TestStub}/gdisp_lld_config.h (100%) rename drivers/gdisp/{gdispTestStub => TestStub}/readme.txt (100%) rename drivers/gdisp/{gdispVMT => VMT}/gdisp_lld.c (100%) create mode 100644 drivers/gdisp/VMT/gdisp_lld.mk rename drivers/gdisp/{gdispVMT => VMT}/gdisp_lld_config.h (100%) rename drivers/gdisp/{gdispVMT => VMT}/gdisp_lld_driver1.c (100%) rename drivers/gdisp/{gdispVMT => VMT}/gdisp_lld_driver2.c (100%) rename drivers/gdisp/{gdispVMT => VMT}/readme.txt (100%) delete mode 100644 drivers/gdisp/gdispNokia6610/gdisp_lld.mk delete mode 100644 drivers/gdisp/gdispS6d1121/gdisp_lld.mk delete mode 100644 drivers/gdisp/gdispSsd1289/gdisp_lld.mk delete mode 100644 drivers/gdisp/gdispTestStub/gdisp_lld.mk delete mode 100644 drivers/gdisp/gdispVMT/gdisp_lld.mk diff --git a/docs/usage.txt b/docs/usage.txt index e2d33c18..52222ddc 100644 --- a/docs/usage.txt +++ b/docs/usage.txt @@ -9,7 +9,7 @@ To include any of these functions/drivers in your project... 4/ In your project Makefile add the makefiles for any specific drivers you want e.g include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk - include $(LCDLIB)/halext/drivers/gdisp/gdispNokia6610/gdisp_lld.mk + include $(LCDLIB)/halext/drivers/gdisp/Nokia6610/gdisp_lld.mk 5/ In your project halconf.h turn on the support you want eg. /** diff --git a/drivers/gdisp/gdispNokia6610/GE12.h b/drivers/gdisp/Nokia6610/GE12.h similarity index 100% rename from drivers/gdisp/gdispNokia6610/GE12.h rename to drivers/gdisp/Nokia6610/GE12.h diff --git a/drivers/gdisp/gdispNokia6610/GE8.h b/drivers/gdisp/Nokia6610/GE8.h similarity index 100% rename from drivers/gdisp/gdispNokia6610/GE8.h rename to drivers/gdisp/Nokia6610/GE8.h diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld.c b/drivers/gdisp/Nokia6610/gdisp_lld.c similarity index 100% rename from drivers/gdisp/gdispNokia6610/gdisp_lld.c rename to drivers/gdisp/Nokia6610/gdisp_lld.c diff --git a/drivers/gdisp/Nokia6610/gdisp_lld.mk b/drivers/gdisp/Nokia6610/gdisp_lld.mk new file mode 100644 index 00000000..0f09ec0f --- /dev/null +++ b/drivers/gdisp/Nokia6610/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/Nokia6610/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/Nokia6610 diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h b/drivers/gdisp/Nokia6610/gdisp_lld_board_example.h similarity index 100% rename from drivers/gdisp/gdispNokia6610/gdisp_lld_board_example.h rename to drivers/gdisp/Nokia6610/gdisp_lld_board_example.h diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h b/drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h similarity index 100% rename from drivers/gdisp/gdispNokia6610/gdisp_lld_board_olimexsam7ex256.h rename to drivers/gdisp/Nokia6610/gdisp_lld_board_olimexsam7ex256.h diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld_config.h b/drivers/gdisp/Nokia6610/gdisp_lld_config.h similarity index 100% rename from drivers/gdisp/gdispNokia6610/gdisp_lld_config.h rename to drivers/gdisp/Nokia6610/gdisp_lld_config.h diff --git a/drivers/gdisp/gdispNokia6610/readme.txt b/drivers/gdisp/Nokia6610/readme.txt similarity index 100% rename from drivers/gdisp/gdispNokia6610/readme.txt rename to drivers/gdisp/Nokia6610/readme.txt diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld.c b/drivers/gdisp/S6D1121/gdisp_lld.c similarity index 100% rename from drivers/gdisp/gdispS6d1121/gdisp_lld.c rename to drivers/gdisp/S6D1121/gdisp_lld.c diff --git a/drivers/gdisp/S6D1121/gdisp_lld.mk b/drivers/gdisp/S6D1121/gdisp_lld.mk new file mode 100644 index 00000000..79f5c2a9 --- /dev/null +++ b/drivers/gdisp/S6D1121/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/S6D1121/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/S6D1121 diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld_config.h b/drivers/gdisp/S6D1121/gdisp_lld_config.h similarity index 100% rename from drivers/gdisp/gdispS6d1121/gdisp_lld_config.h rename to drivers/gdisp/S6D1121/gdisp_lld_config.h diff --git a/drivers/gdisp/gdispS6d1121/readme.txt b/drivers/gdisp/S6D1121/readme.txt similarity index 100% rename from drivers/gdisp/gdispS6d1121/readme.txt rename to drivers/gdisp/S6D1121/readme.txt diff --git a/drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h b/drivers/gdisp/S6D1121/s6d1121_lld.c.h similarity index 100% rename from drivers/gdisp/gdispS6d1121/s6d1121_lld.c.h rename to drivers/gdisp/S6D1121/s6d1121_lld.c.h diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.c b/drivers/gdisp/SSD1289/gdisp_lld.c similarity index 100% rename from drivers/gdisp/gdispSsd1289/gdisp_lld.c rename to drivers/gdisp/SSD1289/gdisp_lld.c diff --git a/drivers/gdisp/SSD1289/gdisp_lld.mk b/drivers/gdisp/SSD1289/gdisp_lld.mk new file mode 100644 index 00000000..247f3ef7 --- /dev/null +++ b/drivers/gdisp/SSD1289/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/SSD1289/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/SSD1289 diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld_config.h b/drivers/gdisp/SSD1289/gdisp_lld_config.h similarity index 100% rename from drivers/gdisp/gdispSsd1289/gdisp_lld_config.h rename to drivers/gdisp/SSD1289/gdisp_lld_config.h diff --git a/drivers/gdisp/gdispSsd1289/readme.txt b/drivers/gdisp/SSD1289/readme.txt similarity index 100% rename from drivers/gdisp/gdispSsd1289/readme.txt rename to drivers/gdisp/SSD1289/readme.txt diff --git a/drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h b/drivers/gdisp/SSD1289/ssd1289_lld.c.h similarity index 100% rename from drivers/gdisp/gdispSsd1289/ssd1289_lld.c.h rename to drivers/gdisp/SSD1289/ssd1289_lld.c.h diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld.c b/drivers/gdisp/TestStub/gdisp_lld.c similarity index 100% rename from drivers/gdisp/gdispTestStub/gdisp_lld.c rename to drivers/gdisp/TestStub/gdisp_lld.c diff --git a/drivers/gdisp/TestStub/gdisp_lld.mk b/drivers/gdisp/TestStub/gdisp_lld.mk new file mode 100644 index 00000000..84c8ba7d --- /dev/null +++ b/drivers/gdisp/TestStub/gdisp_lld.mk @@ -0,0 +1,5 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/TestStub/gdisp_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/TestStub diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld_config.h b/drivers/gdisp/TestStub/gdisp_lld_config.h similarity index 100% rename from drivers/gdisp/gdispTestStub/gdisp_lld_config.h rename to drivers/gdisp/TestStub/gdisp_lld_config.h diff --git a/drivers/gdisp/gdispTestStub/readme.txt b/drivers/gdisp/TestStub/readme.txt similarity index 100% rename from drivers/gdisp/gdispTestStub/readme.txt rename to drivers/gdisp/TestStub/readme.txt diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.c b/drivers/gdisp/VMT/gdisp_lld.c similarity index 100% rename from drivers/gdisp/gdispVMT/gdisp_lld.c rename to drivers/gdisp/VMT/gdisp_lld.c diff --git a/drivers/gdisp/VMT/gdisp_lld.mk b/drivers/gdisp/VMT/gdisp_lld.mk new file mode 100644 index 00000000..d4cf90be --- /dev/null +++ b/drivers/gdisp/VMT/gdisp_lld.mk @@ -0,0 +1,7 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/gdisp/VMT/gdisp_lld.c \ + $(LCDLIB)/drivers/gdisp/VMT/gdisp_lld_driver1.c \ + $(LCDLIB)//drivers/gdisp/VMT/gdisp_lld_driver2.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/gdisp/VMT diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_config.h b/drivers/gdisp/VMT/gdisp_lld_config.h similarity index 100% rename from drivers/gdisp/gdispVMT/gdisp_lld_config.h rename to drivers/gdisp/VMT/gdisp_lld_config.h diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c b/drivers/gdisp/VMT/gdisp_lld_driver1.c similarity index 100% rename from drivers/gdisp/gdispVMT/gdisp_lld_driver1.c rename to drivers/gdisp/VMT/gdisp_lld_driver1.c diff --git a/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c b/drivers/gdisp/VMT/gdisp_lld_driver2.c similarity index 100% rename from drivers/gdisp/gdispVMT/gdisp_lld_driver2.c rename to drivers/gdisp/VMT/gdisp_lld_driver2.c diff --git a/drivers/gdisp/gdispVMT/readme.txt b/drivers/gdisp/VMT/readme.txt similarity index 100% rename from drivers/gdisp/gdispVMT/readme.txt rename to drivers/gdisp/VMT/readme.txt diff --git a/drivers/gdisp/gdispNokia6610/gdisp_lld.mk b/drivers/gdisp/gdispNokia6610/gdisp_lld.mk deleted file mode 100644 index 4c980c3c..00000000 --- a/drivers/gdisp/gdispNokia6610/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/gdisp/gdispNokia6610/gdisp_lld.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/gdisp/gdispNokia6610 diff --git a/drivers/gdisp/gdispS6d1121/gdisp_lld.mk b/drivers/gdisp/gdispS6d1121/gdisp_lld.mk deleted file mode 100644 index 1f9f093a..00000000 --- a/drivers/gdisp/gdispS6d1121/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/gdisp/gdispS6d1121/gdisp_lld.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/gdisp/gdispS6d1121 diff --git a/drivers/gdisp/gdispSsd1289/gdisp_lld.mk b/drivers/gdisp/gdispSsd1289/gdisp_lld.mk deleted file mode 100644 index 8167cbfb..00000000 --- a/drivers/gdisp/gdispSsd1289/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/gdisp/gdispSsd1289/gdisp_lld.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/gdisp/gdispSsd1289 diff --git a/drivers/gdisp/gdispTestStub/gdisp_lld.mk b/drivers/gdisp/gdispTestStub/gdisp_lld.mk deleted file mode 100644 index 9c5d02ea..00000000 --- a/drivers/gdisp/gdispTestStub/gdisp_lld.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/gdisp/gdispTestStub/gdisp_lld.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/gdisp/gdispTestStub diff --git a/drivers/gdisp/gdispVMT/gdisp_lld.mk b/drivers/gdisp/gdispVMT/gdisp_lld.mk deleted file mode 100644 index 71d75f14..00000000 --- a/drivers/gdisp/gdispVMT/gdisp_lld.mk +++ /dev/null @@ -1,7 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/gdisp/gdispVMT/gdisp_lld.c \ - $(LCDLIB)/os/halext/drivers/gdisp/gdispVMT/gdisp_lld_driver1.c \ - $(LCDLIB)/os/halext/drivers/gdisp/gdispVMT/gdisp_lld_driver2.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/gdisp/gdispVMT From 72d994626f750a86a7a92b2c7ef87a3cceededb3 Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 14 Aug 2012 02:12:59 +0200 Subject: [PATCH 40/47] removed touchpad prefix on touchpad drivers --- docs/usage.txt | 2 +- drivers/touchpad/{touchpadADS7843 => ADS7843}/readme.txt | 0 .../touchpad/{touchpadADS7843 => ADS7843}/touchpad_lld.c | 0 drivers/touchpad/ADS7843/touchpad_lld.mk | 6 ++++++ .../{touchpadADS7843 => ADS7843}/touchpad_lld_config.h | 0 drivers/touchpad/{touchpadXPT2046 => XPT2046}/readme.txt | 0 .../touchpad/{touchpadXPT2046 => XPT2046}/touchpad_lld.c | 0 drivers/touchpad/XPT2046/touchpad_lld.mk | 6 ++++++ .../{touchpadXPT2046 => XPT2046}/touchpad_lld_config.h | 0 drivers/touchpad/touchpadADS7843/touchpad_lld.mk | 6 ------ drivers/touchpad/touchpadXPT2046/touchpad_lld.mk | 6 ------ 11 files changed, 13 insertions(+), 13 deletions(-) rename drivers/touchpad/{touchpadADS7843 => ADS7843}/readme.txt (100%) rename drivers/touchpad/{touchpadADS7843 => ADS7843}/touchpad_lld.c (100%) create mode 100644 drivers/touchpad/ADS7843/touchpad_lld.mk rename drivers/touchpad/{touchpadADS7843 => ADS7843}/touchpad_lld_config.h (100%) rename drivers/touchpad/{touchpadXPT2046 => XPT2046}/readme.txt (100%) rename drivers/touchpad/{touchpadXPT2046 => XPT2046}/touchpad_lld.c (100%) create mode 100644 drivers/touchpad/XPT2046/touchpad_lld.mk rename drivers/touchpad/{touchpadXPT2046 => XPT2046}/touchpad_lld_config.h (100%) delete mode 100644 drivers/touchpad/touchpadADS7843/touchpad_lld.mk delete mode 100644 drivers/touchpad/touchpadXPT2046/touchpad_lld.mk diff --git a/docs/usage.txt b/docs/usage.txt index 52222ddc..961fa2c6 100644 --- a/docs/usage.txt +++ b/docs/usage.txt @@ -8,7 +8,7 @@ To include any of these functions/drivers in your project... 3/ Add $(LCDSRC) and $(LCDINC) to your SRCS and INCDIR of your projects Makefile 4/ In your project Makefile add the makefiles for any specific drivers you want e.g - include $(LCDLIB)/halext/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk + include $(LCDLIB)/halext/drivers/touchpad/XPT2046/touchpad_lld.mk include $(LCDLIB)/halext/drivers/gdisp/Nokia6610/gdisp_lld.mk 5/ In your project halconf.h turn on the support you want eg. diff --git a/drivers/touchpad/touchpadADS7843/readme.txt b/drivers/touchpad/ADS7843/readme.txt similarity index 100% rename from drivers/touchpad/touchpadADS7843/readme.txt rename to drivers/touchpad/ADS7843/readme.txt diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.c b/drivers/touchpad/ADS7843/touchpad_lld.c similarity index 100% rename from drivers/touchpad/touchpadADS7843/touchpad_lld.c rename to drivers/touchpad/ADS7843/touchpad_lld.c diff --git a/drivers/touchpad/ADS7843/touchpad_lld.mk b/drivers/touchpad/ADS7843/touchpad_lld.mk new file mode 100644 index 00000000..b17b1726 --- /dev/null +++ b/drivers/touchpad/ADS7843/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/touchpad/ADS7843/touchpad_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/touchpad/ADS7843 + diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld_config.h b/drivers/touchpad/ADS7843/touchpad_lld_config.h similarity index 100% rename from drivers/touchpad/touchpadADS7843/touchpad_lld_config.h rename to drivers/touchpad/ADS7843/touchpad_lld_config.h diff --git a/drivers/touchpad/touchpadXPT2046/readme.txt b/drivers/touchpad/XPT2046/readme.txt similarity index 100% rename from drivers/touchpad/touchpadXPT2046/readme.txt rename to drivers/touchpad/XPT2046/readme.txt diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.c b/drivers/touchpad/XPT2046/touchpad_lld.c similarity index 100% rename from drivers/touchpad/touchpadXPT2046/touchpad_lld.c rename to drivers/touchpad/XPT2046/touchpad_lld.c diff --git a/drivers/touchpad/XPT2046/touchpad_lld.mk b/drivers/touchpad/XPT2046/touchpad_lld.mk new file mode 100644 index 00000000..362fb452 --- /dev/null +++ b/drivers/touchpad/XPT2046/touchpad_lld.mk @@ -0,0 +1,6 @@ +# List the required driver. +LCDSRC += $(LCDLIB)/drivers/touchpad/XPT2046/touchpad_lld.c + +# Required include directories +LCDINC += $(LCDLIB)/drivers/touchpad/XPT2046 + diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h b/drivers/touchpad/XPT2046/touchpad_lld_config.h similarity index 100% rename from drivers/touchpad/touchpadXPT2046/touchpad_lld_config.h rename to drivers/touchpad/XPT2046/touchpad_lld_config.h diff --git a/drivers/touchpad/touchpadADS7843/touchpad_lld.mk b/drivers/touchpad/touchpadADS7843/touchpad_lld.mk deleted file mode 100644 index f70f0dd1..00000000 --- a/drivers/touchpad/touchpadADS7843/touchpad_lld.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadADS7843/touchpad_lld.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/touchpad/touchpadADS7843 - diff --git a/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk b/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk deleted file mode 100644 index 26e27c1c..00000000 --- a/drivers/touchpad/touchpadXPT2046/touchpad_lld.mk +++ /dev/null @@ -1,6 +0,0 @@ -# List the required driver. -LCDSRC += $(LCDLIB)/drivers/touchpad/touchpadXPT2046/touchpad_lld.c - -# Required include directories -LCDINC += $(LCDLIB)/drivers/touchpad/touchpadXPT2046 - From 2d8c4a825de421f1d045433478e65da31d551d06 Mon Sep 17 00:00:00 2001 From: Tectu Date: Tue, 14 Aug 2012 02:16:13 +0200 Subject: [PATCH 41/47] docs update --- docs/releases.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/releases.txt b/docs/releases.txt index 8ff13228..f895106e 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -3,4 +3,5 @@ ***************************************************************************** *** 0.1.0 *** +FIX: removed gdisp and touchpad prefix of driver directories From a9beec902da2348e858dcd54550d99a40c1fbe87 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 16 Aug 2012 15:14:16 +0530 Subject: [PATCH 42/47] XPT2046 LLD Major Update Added 7 point median filtering to reduce noise TOUCHPADDriver structure now encapsulates the IRQ pin, so removed the TP_CS_ and TP_IRQ_ macros Added generic tp_lld_read_value method to read any ADC channel from the XPT2046, this includes on-chip temperature sensor and VBAT input Improved SPI bus sharing, with the optional TOUCHPAD_SPI_PROLOGUE and TOUCHPAD_SPI_EPILOGUE macros --- drivers/touchpad/XPT2046/touchpad_lld.c | 155 +++++++++++++++++++----- include/touchpad_lld.h | 63 +++++++--- 2 files changed, 172 insertions(+), 46 deletions(-) diff --git a/drivers/touchpad/XPT2046/touchpad_lld.c b/drivers/touchpad/XPT2046/touchpad_lld.c index 24afcab4..16e4db79 100644 --- a/drivers/touchpad/XPT2046/touchpad_lld.c +++ b/drivers/touchpad/XPT2046/touchpad_lld.c @@ -36,9 +36,6 @@ /* Driver local definitions. */ /*===========================================================================*/ -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) @@ -52,13 +49,15 @@ /* Driver exported variables. */ /*===========================================================================*/ -#if !defined(__DOXYGEN__) - TOUCHPADDriver Touchpad; -#endif - /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ +#if !defined(__DOXYGEN__) + /* Local copy of the current touchpad driver */ + static const TOUCHPADDriver *tpDriver; + + static uint16_t sampleBuf[7]; +#endif /*===========================================================================*/ /* Driver local functions. */ @@ -79,30 +78,104 @@ * * @notapi */ -void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, tp->spicfg); +void tp_lld_init(const TOUCHPADDriver *tp) { + tpDriver=tp; + + if (tpDriver->direct_init) + spiStart(tpDriver->spip, tpDriver->spicfg); +} + + +/** + * @brief Reads a conversion from the touchpad + * + * @param[in] cmd The command bits to send to the touchpad + * + * @return The read value 12-bit right-justified + * + * @note This function only reads data, it is assumed that the pins are + * configured properly and the bus has been acquired beforehand + * + * @notapi + */ +uint16_t tp_lld_read_value(uint8_t cmd) { + static uint8_t txbuf[3]={0}; + static uint8_t rxbuf[3]={0}; + uint16_t ret; + + txbuf[0]=cmd; + + spiExchange(tpDriver->spip, 3, txbuf, rxbuf); + + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + + return ret; +} + +/** + * @brief 7-point median filtering code for touchpad samples + * + * @note This is an internally used routine only. + * + * @notapi + */ +static void tp_lld_filter(void) { + uint16_t temp; + int i,j; + + for (i=0; i<4; i++) { + for (j=i; j<7; j++) { + if (sampleBuf[i] > sampleBuf[j]) { + /* Swap the values */ + temp=sampleBuf[i]; + sampleBuf[i]=sampleBuf[j]; + sampleBuf[j]=temp; + } + } + } + } /** * @brief Reads out the X direction. * + * @note The samples are median filtered for greater noise reduction + * * @notapi */ uint16_t tp_lld_read_x(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t x; + int i; - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiAcquireBus(tpDriver->spip); +#endif - x = rxbuf[0] << 4; - x |= rxbuf[1] >> 4; + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - return x; + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0xD1); + + for (i=0;i<7;i++) { + sampleBuf[i]=tp_lld_read_value(0xD1); + } + + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0xD0); + + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiReleaseBus(tpDriver->spip); +#endif + + /* Find the median - use selection sort */ + tp_lld_filter(); + + return sampleBuf[3]; } /* @@ -111,20 +184,38 @@ uint16_t tp_lld_read_x(void) { * @notapi */ uint16_t tp_lld_read_y(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; + int i; - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiAcquireBus(tpDriver->spip); +#endif - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - return y; + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0x91); + + for (i=0;i<7;i++) { + sampleBuf[i]=tp_lld_read_value(0x91); + } + + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0x90); + + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); + +#ifdef SPI_USE_MUTUAL_EXCLUSION + spiReleaseBus(tpDriver->spip); +#endif + + /* Find the median - use selection sort */ + tp_lld_filter(); + + return sampleBuf[3]; } /* ---- Optional Routines ---- */ @@ -137,7 +228,7 @@ uint16_t tp_lld_read_y(void) { * @notapi */ uint8_t tp_lld_irq(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); + return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); } #endif diff --git a/include/touchpad_lld.h b/include/touchpad_lld.h index 45a561d3..a3a7489c 100644 --- a/include/touchpad_lld.h +++ b/include/touchpad_lld.h @@ -49,41 +49,76 @@ #define TOUCHPAD_HAS_PRESSURE FALSE #endif +#ifndef TOUCHPAD_SPI_PROLOGUE + #define TOUCHPAD_SPI_PROLOGUE() +#endif + +#ifndef TOUCHPAD_SPI_EPILOGUE + #define TOUCHPAD_SPI_EPILOGUE() +#endif + /*===========================================================================*/ /* Driver types. */ /*===========================================================================*/ -typedef struct TOUCHPADDriver TOUCHPADDriver; +typedef struct _TOUCHPADDriver TOUCHPADDriver; /** * @brief Structure representing a Touchpad driver. */ -struct TOUCHPADDriver { - /* - * @brief Pointer to SPI driver. - */ - SPIDriver *spid; +struct _TOUCHPADDriver { + /* + * @brief Pointer to SPI driver. + * @note SPI driver must be enabled in mcuconf.h and halconf.h + */ + SPIDriver *spip; - /* - * @brief SPI configuration. - */ - SPIConfig *spicfg; + /* + * @brief Pointer to the SPI configuration structure. + * @note The lowest possible speed ~ 1-2MHz is to be used, otherwise + * will result in a lot of noise + */ + const SPIConfig *spicfg; + + /* + * @brief Touchscreen controller TPIRQ pin GPIO port + */ + ioportid_t tpIRQPort; + + /* + * @brief Touchscreen controller TPIRQ GPIO pin + * @note The interface is polled as of now, interrupt support is + * to be implemented in the future. + */ + ioportmask_t tpIRQPin; + + /* + * @brief Initialize the SPI with the configuration struct given or not + * If TRUE, spiStart is called by the init, otherwise not + * @note This is provided in such a case when SPI port is being shared + * across multiple peripherals, so not to disturb the SPI bus. + * You can use TOUCHPAD_SPI_PROLOGUE() and TOUCHPAD_SPI_EPILOGUE() + * macros to change the SPI configuration or speed before and + * after using the touchpad. An example case would be sharing the + * bus with a fast flash memory chip. + */ + bool_t direct_init; }; + /*===========================================================================*/ /* External declarations. */ /*===========================================================================*/ -#if !defined(__DOXYGEN__) - extern TOUCHPADDriver Touchpad; -#endif #ifdef __cplusplus extern "C" { #endif /* Core functions */ - void tp_lld_init(TOUCHPADDriver *tp); + void tp_lld_init(const TOUCHPADDriver *tp); + + uint16_t tp_lld_read_value(uint8_t cmd); uint16_t tp_lld_read_x(void); uint16_t tp_lld_read_y(void); From a41a5911e54a2b9683d88d35c01c58d0349cd804 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 16 Aug 2012 15:26:03 +0530 Subject: [PATCH 43/47] Fix compiler warnings Removed redundant dummy read from high level functions --- include/touchpad.h | 2 +- src/touchpad.c | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/touchpad.h b/include/touchpad.h index 445d3202..55a83a9d 100644 --- a/include/touchpad.h +++ b/include/touchpad.h @@ -70,7 +70,7 @@ struct cal { extern "C" { #endif -void tpInit(TOUCHPADDriver *tp); +void tpInit(const TOUCHPADDriver *tp); uint16_t tpReadX(void); uint16_t tpReadY(void); diff --git a/src/touchpad.c b/src/touchpad.c index 977bb31c..a18930da 100644 --- a/src/touchpad.c +++ b/src/touchpad.c @@ -69,13 +69,13 @@ static uint16_t _tpReadRealX(void) { uint32_t results = 0; uint16_t i, x; + /* Median filtering is already done in LLD */ for(i = 0; i < CONVERSIONS; i++) { - tp_lld_read_x(); /* dummy, reduce noise on SPI */ results += tp_lld_read_x(); - } + } - // 12-bit - x = (((SCREEN_WIDTH-1) * (results/CONVERSIONS)) / 2048); + /* Take the average of the readings */ + x = results / CONVERSIONS; return x; } @@ -89,13 +89,13 @@ static uint16_t _tpReadRealY(void) { uint32_t results = 0; uint16_t i, y; + /* Median filtering is already done in LLD */ for(i = 0; i < CONVERSIONS; i++) { - tp_lld_read_y(); /* dummy, reduce noise on SPI */ results += tp_lld_read_y(); - } + } - // 12-bit - y = (((SCREEN_HEIGHT-1) * (results/CONVERSIONS)) / 2048); + /* Take the average of the readings */ + y = results / CONVERSIONS; return y; } @@ -135,7 +135,7 @@ static void _tpDrawCross(uint16_t x, uint16_t y) { * * @api */ -void tpInit(TOUCHPADDriver *tp) { +void tpInit(const TOUCHPADDriver *tp) { /* Initialise Mutex */ //MUTEX_INIT From 0b8c95ab207a474e9b1c28c89c8848e6d0992974 Mon Sep 17 00:00:00 2001 From: Kumar Abhishek Date: Thu, 16 Aug 2012 15:40:48 +0530 Subject: [PATCH 44/47] ADS7843 update Same changes as the XPT2046 --- drivers/touchpad/ADS7843/touchpad_lld.c | 383 +++++++++++++++--------- 1 file changed, 237 insertions(+), 146 deletions(-) diff --git a/drivers/touchpad/ADS7843/touchpad_lld.c b/drivers/touchpad/ADS7843/touchpad_lld.c index 8fc334b2..77e42133 100644 --- a/drivers/touchpad/ADS7843/touchpad_lld.c +++ b/drivers/touchpad/ADS7843/touchpad_lld.c @@ -1,146 +1,237 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpadADS7843/touchpad_lld.c - * @brief Touchpad Driver subsystem low level driver source. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "touchpad.h" - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#define TP_CS_HIGH palSetPad(TP_CS_PORT, TP_CS) -#define TP_CS_LOW palClearPad(TP_CS_PORT, TP_CS) - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -#if !defined(__DOXYGEN__) - TOUCHPADDriver Touchpad; -#endif - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ - -/** - * @brief Low level Touchpad driver initialization. - * - * @notapi - */ -void tp_lld_init(TOUCHPADDriver *tp) { - spiStart(tp->spid, tp->spicfg); -} - -/** - * @brief Reads out the X direction. - * - * @notapi - */ -uint16_t tp_lld_read_x(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t x; - - txbuf[0] = 0xd0; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - x = rxbuf[0] << 4; - x |= rxbuf[1] >> 4; - - return x; -} - -/* - * @brief Reads out the Y direction. - * - * @notapi - */ -uint16_t tp_lld_read_y(void) { - uint8_t txbuf[1]; - uint8_t rxbuf[2]; - uint16_t y; - - txbuf[0] = 0x90; - TP_CS_LOW; - spiSend(&SPID1, 1, txbuf); - spiReceive(&SPID1, 2, rxbuf); - TP_CS_HIGH; - - y = rxbuf[0] << 4; - y |= rxbuf[1] >> 4; - - return y; -} - -/* ---- Optional Routines ---- */ -#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) - /* - * @brief for checking if touchpad is pressed or not. - * - * @return 1 if pressed / 0 if not pressed - * - * @noapi - */ - uint8_t tp_lld_irq(void) { - return (!palReadPad(TP_IRQ_PORT, TP_IRQ)); - } -#endif - -#endif /* HAL_USE_TOUCHPAD */ -/** @} */ - +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadADS7843/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ +#if !defined(__DOXYGEN__) + /* Local copy of the current touchpad driver */ + static const TOUCHPADDriver *tpDriver; + + static uint16_t sampleBuf[7]; +#endif + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ + +/** + * @brief Low level Touchpad driver initialization. + * + * @notapi + */ +void tp_lld_init(const TOUCHPADDriver *tp) { + tpDriver=tp; + + if (tpDriver->direct_init) + spiStart(tpDriver->spip, tpDriver->spicfg); +} + + +/** + * @brief Reads a conversion from the touchpad + * + * @param[in] cmd The command bits to send to the touchpad + * + * @return The read value 12-bit right-justified + * + * @note This function only reads data, it is assumed that the pins are + * configured properly and the bus has been acquired beforehand + * + * @notapi + */ +uint16_t tp_lld_read_value(uint8_t cmd) { + static uint8_t txbuf[3]={0}; + static uint8_t rxbuf[3]={0}; + uint16_t ret; + + txbuf[0]=cmd; + + spiExchange(tpDriver->spip, 3, txbuf, rxbuf); + + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + + return ret; +} + +/** + * @brief 7-point median filtering code for touchpad samples + * + * @note This is an internally used routine only. + * + * @notapi + */ +static void tp_lld_filter(void) { + uint16_t temp; + int i,j; + + for (i=0; i<4; i++) { + for (j=i; j<7; j++) { + if (sampleBuf[i] > sampleBuf[j]) { + /* Swap the values */ + temp=sampleBuf[i]; + sampleBuf[i]=sampleBuf[j]; + sampleBuf[j]=temp; + } + } + } + +} + +/** + * @brief Reads out the X direction. + * + * @note The samples are median filtered for greater noise reduction + * + * @notapi + */ +uint16_t tp_lld_read_x(void) { + int i; + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiAcquireBus(tpDriver->spip); +#endif + + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0xD1); + + for (i=0;i<7;i++) { + sampleBuf[i]=tp_lld_read_value(0xD1); + } + + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0xD0); + + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiReleaseBus(tpDriver->spip); +#endif + + /* Find the median - use selection sort */ + tp_lld_filter(); + + return sampleBuf[3]; +} + +/* + * @brief Reads out the Y direction. + * + * @notapi + */ +uint16_t tp_lld_read_y(void) { + int i; + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiAcquireBus(tpDriver->spip); +#endif + + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0x91); + + for (i=0;i<7;i++) { + sampleBuf[i]=tp_lld_read_value(0x91); + } + + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0x90); + + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); + +#ifdef SPI_USE_MUTUAL_EXCLUSION + spiReleaseBus(tpDriver->spip); +#endif + + /* Find the median - use selection sort */ + tp_lld_filter(); + + return sampleBuf[3]; +} + +/* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @notapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + From b40222826505f7c1e5d087a2014f7f2ea7e426ba Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 16 Aug 2012 12:52:34 +0200 Subject: [PATCH 45/47] XPT2046 cleanup --- drivers/touchpad/XPT2046/touchpad_lld.c | 123 ++++++++++++------------ 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/drivers/touchpad/XPT2046/touchpad_lld.c b/drivers/touchpad/XPT2046/touchpad_lld.c index 16e4db79..62a1f747 100644 --- a/drivers/touchpad/XPT2046/touchpad_lld.c +++ b/drivers/touchpad/XPT2046/touchpad_lld.c @@ -79,10 +79,10 @@ * @notapi */ void tp_lld_init(const TOUCHPADDriver *tp) { - tpDriver=tp; + tpDriver = tp; - if (tpDriver->direct_init) - spiStart(tpDriver->spip, tpDriver->spicfg); + if(tpDriver->direct_init) + spiStart(tpDriver->spip, tpDriver->spicfg); } @@ -99,17 +99,17 @@ void tp_lld_init(const TOUCHPADDriver *tp) { * @notapi */ uint16_t tp_lld_read_value(uint8_t cmd) { - static uint8_t txbuf[3]={0}; - static uint8_t rxbuf[3]={0}; - uint16_t ret; + static uint8_t txbuf[3] = {0}; + static uint8_t rxbuf[3] = {0}; + uint16_t ret; - txbuf[0]=cmd; + txbuf[0] = cmd; - spiExchange(tpDriver->spip, 3, txbuf, rxbuf); + spiExchange(tpDriver->spip, 3, txbuf, rxbuf); - ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - return ret; + return ret; } /** @@ -120,20 +120,19 @@ uint16_t tp_lld_read_value(uint8_t cmd) { * @notapi */ static void tp_lld_filter(void) { - uint16_t temp; - int i,j; - - for (i=0; i<4; i++) { - for (j=i; j<7; j++) { - if (sampleBuf[i] > sampleBuf[j]) { - /* Swap the values */ - temp=sampleBuf[i]; - sampleBuf[i]=sampleBuf[j]; - sampleBuf[j]=temp; - } - } - } + uint16_t temp; + int i,j; + for(i = 0; i < 4; i++) { + for(j=i; j < 7; j++) { + if(sampleBuf[i] > sampleBuf[j]) { + /* Swap the values */ + temp = sampleBuf[i]; + sampleBuf[i] = sampleBuf[j]; + sampleBuf[j] = temp; + } + } + } } /** @@ -144,38 +143,38 @@ static void tp_lld_filter(void) { * @notapi */ uint16_t tp_lld_read_x(void) { - int i; + int i; #if defined(SPI_USE_MUTUAL_EXCLUSION) - spiAcquireBus(tpDriver->spip); + spiAcquireBus(tpDriver->spip); #endif - TOUCHPAD_SPI_PROLOGUE(); - palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - /* Discard the first conversion - very noisy and keep the ADC on hereafter - * till we are done with the sampling. Note that PENIRQ is disabled. - */ - tp_lld_read_value(0xD1); + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0xD1); - for (i=0;i<7;i++) { - sampleBuf[i]=tp_lld_read_value(0xD1); - } + for(i = 0; i < 7; i++) { + sampleBuf[i]=tp_lld_read_value(0xD1); + } - /* Switch on PENIRQ once again - perform a dummy read */ - tp_lld_read_value(0xD0); + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0xD0); - palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - TOUCHPAD_SPI_EPILOGUE(); + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); #if defined(SPI_USE_MUTUAL_EXCLUSION) - spiReleaseBus(tpDriver->spip); + spiReleaseBus(tpDriver->spip); #endif - /* Find the median - use selection sort */ - tp_lld_filter(); + /* Find the median - use selection sort */ + tp_lld_filter(); - return sampleBuf[3]; + return sampleBuf[3]; } /* @@ -184,38 +183,38 @@ uint16_t tp_lld_read_x(void) { * @notapi */ uint16_t tp_lld_read_y(void) { - int i; + int i; #if defined(SPI_USE_MUTUAL_EXCLUSION) - spiAcquireBus(tpDriver->spip); + spiAcquireBus(tpDriver->spip); #endif - TOUCHPAD_SPI_PROLOGUE(); - palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - /* Discard the first conversion - very noisy and keep the ADC on hereafter - * till we are done with the sampling. Note that PENIRQ is disabled. - */ - tp_lld_read_value(0x91); + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0x91); - for (i=0;i<7;i++) { - sampleBuf[i]=tp_lld_read_value(0x91); - } + for(i = 0; i < 7; i++) { + sampleBuf[i] = tp_lld_read_value(0x91); + } - /* Switch on PENIRQ once again - perform a dummy read */ - tp_lld_read_value(0x90); + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0x90); - palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - TOUCHPAD_SPI_EPILOGUE(); + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); #ifdef SPI_USE_MUTUAL_EXCLUSION - spiReleaseBus(tpDriver->spip); + spiReleaseBus(tpDriver->spip); #endif - /* Find the median - use selection sort */ - tp_lld_filter(); + /* Find the median - use selection sort */ + tp_lld_filter(); - return sampleBuf[3]; + return sampleBuf[3]; } /* ---- Optional Routines ---- */ @@ -227,7 +226,7 @@ uint16_t tp_lld_read_y(void) { * * @notapi */ - uint8_t tp_lld_irq(void) { + uint8_t tp_lld_irq(void) { return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); } #endif From 53000e3c199fb106f3f8dee57b417512a488a3ff Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 16 Aug 2012 12:55:18 +0200 Subject: [PATCH 46/47] ADS7843 cleanup --- drivers/touchpad/ADS7843/touchpad_lld.c | 485 ++++++++++++------------ 1 file changed, 248 insertions(+), 237 deletions(-) diff --git a/drivers/touchpad/ADS7843/touchpad_lld.c b/drivers/touchpad/ADS7843/touchpad_lld.c index 77e42133..62a1f747 100644 --- a/drivers/touchpad/ADS7843/touchpad_lld.c +++ b/drivers/touchpad/ADS7843/touchpad_lld.c @@ -1,237 +1,248 @@ -/* - ChibiOS-LCD-Driver - Copyright (C) 2012 - Joel Bodenmann aka Tectu - - This file is part of ChibiOS-LCD-Driver. - - ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - ChibiOS-LCD-Driver is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . -*/ - -/** - * @file touchpadADS7843/touchpad_lld.c - * @brief Touchpad Driver subsystem low level driver source. - * - * @addtogroup TOUCHPAD - * @{ - */ - -#include "ch.h" -#include "hal.h" -#include "touchpad.h" - -#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) - -/*===========================================================================*/ -/* Driver local definitions. */ -/*===========================================================================*/ - -#ifdef UNUSED -#elif defined(__GNUC__) -# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) -#elif defined(__LCLINT__) -# define UNUSED(x) /*@unused@*/ x -#else -# define UNUSED(x) x -#endif - -/*===========================================================================*/ -/* Driver exported variables. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver local variables. */ -/*===========================================================================*/ -#if !defined(__DOXYGEN__) - /* Local copy of the current touchpad driver */ - static const TOUCHPADDriver *tpDriver; - - static uint16_t sampleBuf[7]; -#endif - -/*===========================================================================*/ -/* Driver local functions. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver interrupt handlers. */ -/*===========================================================================*/ - -/*===========================================================================*/ -/* Driver exported functions. */ -/*===========================================================================*/ - -/* ---- Required Routines ---- */ - -/** - * @brief Low level Touchpad driver initialization. - * - * @notapi - */ -void tp_lld_init(const TOUCHPADDriver *tp) { - tpDriver=tp; - - if (tpDriver->direct_init) - spiStart(tpDriver->spip, tpDriver->spicfg); -} - - -/** - * @brief Reads a conversion from the touchpad - * - * @param[in] cmd The command bits to send to the touchpad - * - * @return The read value 12-bit right-justified - * - * @note This function only reads data, it is assumed that the pins are - * configured properly and the bus has been acquired beforehand - * - * @notapi - */ -uint16_t tp_lld_read_value(uint8_t cmd) { - static uint8_t txbuf[3]={0}; - static uint8_t rxbuf[3]={0}; - uint16_t ret; - - txbuf[0]=cmd; - - spiExchange(tpDriver->spip, 3, txbuf, rxbuf); - - ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); - - return ret; -} - -/** - * @brief 7-point median filtering code for touchpad samples - * - * @note This is an internally used routine only. - * - * @notapi - */ -static void tp_lld_filter(void) { - uint16_t temp; - int i,j; - - for (i=0; i<4; i++) { - for (j=i; j<7; j++) { - if (sampleBuf[i] > sampleBuf[j]) { - /* Swap the values */ - temp=sampleBuf[i]; - sampleBuf[i]=sampleBuf[j]; - sampleBuf[j]=temp; - } - } - } - -} - -/** - * @brief Reads out the X direction. - * - * @note The samples are median filtered for greater noise reduction - * - * @notapi - */ -uint16_t tp_lld_read_x(void) { - int i; - -#if defined(SPI_USE_MUTUAL_EXCLUSION) - spiAcquireBus(tpDriver->spip); -#endif - - TOUCHPAD_SPI_PROLOGUE(); - palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - - /* Discard the first conversion - very noisy and keep the ADC on hereafter - * till we are done with the sampling. Note that PENIRQ is disabled. - */ - tp_lld_read_value(0xD1); - - for (i=0;i<7;i++) { - sampleBuf[i]=tp_lld_read_value(0xD1); - } - - /* Switch on PENIRQ once again - perform a dummy read */ - tp_lld_read_value(0xD0); - - palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - TOUCHPAD_SPI_EPILOGUE(); - -#if defined(SPI_USE_MUTUAL_EXCLUSION) - spiReleaseBus(tpDriver->spip); -#endif - - /* Find the median - use selection sort */ - tp_lld_filter(); - - return sampleBuf[3]; -} - -/* - * @brief Reads out the Y direction. - * - * @notapi - */ -uint16_t tp_lld_read_y(void) { - int i; - -#if defined(SPI_USE_MUTUAL_EXCLUSION) - spiAcquireBus(tpDriver->spip); -#endif - - TOUCHPAD_SPI_PROLOGUE(); - palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - - /* Discard the first conversion - very noisy and keep the ADC on hereafter - * till we are done with the sampling. Note that PENIRQ is disabled. - */ - tp_lld_read_value(0x91); - - for (i=0;i<7;i++) { - sampleBuf[i]=tp_lld_read_value(0x91); - } - - /* Switch on PENIRQ once again - perform a dummy read */ - tp_lld_read_value(0x90); - - palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); - TOUCHPAD_SPI_EPILOGUE(); - -#ifdef SPI_USE_MUTUAL_EXCLUSION - spiReleaseBus(tpDriver->spip); -#endif - - /* Find the median - use selection sort */ - tp_lld_filter(); - - return sampleBuf[3]; -} - -/* ---- Optional Routines ---- */ -#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) - /* - * @brief for checking if touchpad is pressed or not. - * - * @return 1 if pressed / 0 if not pressed - * - * @notapi - */ - uint8_t tp_lld_irq(void) { - return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); - } -#endif - -#endif /* HAL_USE_TOUCHPAD */ -/** @} */ - +/* + ChibiOS-LCD-Driver - Copyright (C) 2012 + Joel Bodenmann aka Tectu + + This file is part of ChibiOS-LCD-Driver. + + ChibiOS-LCD-Driver is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS-LCD-Driver is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file touchpadXPT2046/touchpad_lld.c + * @brief Touchpad Driver subsystem low level driver source. + * + * @addtogroup TOUCHPAD + * @{ + */ + +#include "ch.h" +#include "hal.h" +#include "touchpad.h" + +#if HAL_USE_TOUCHPAD || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +#ifdef UNUSED +#elif defined(__GNUC__) +# define UNUSED(x) UNUSED_ ## x __attribute__((unused)) +#elif defined(__LCLINT__) +# define UNUSED(x) /*@unused@*/ x +#else +# define UNUSED(x) x +#endif + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables. */ +/*===========================================================================*/ +#if !defined(__DOXYGEN__) + /* Local copy of the current touchpad driver */ + static const TOUCHPADDriver *tpDriver; + + static uint16_t sampleBuf[7]; +#endif + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/* ---- Required Routines ---- */ + +/** + * @brief Low level Touchpad driver initialization. + * + * @notapi + */ +void tp_lld_init(const TOUCHPADDriver *tp) { + tpDriver = tp; + + if(tpDriver->direct_init) + spiStart(tpDriver->spip, tpDriver->spicfg); +} + + +/** + * @brief Reads a conversion from the touchpad + * + * @param[in] cmd The command bits to send to the touchpad + * + * @return The read value 12-bit right-justified + * + * @note This function only reads data, it is assumed that the pins are + * configured properly and the bus has been acquired beforehand + * + * @notapi + */ +uint16_t tp_lld_read_value(uint8_t cmd) { + static uint8_t txbuf[3] = {0}; + static uint8_t rxbuf[3] = {0}; + uint16_t ret; + + txbuf[0] = cmd; + + spiExchange(tpDriver->spip, 3, txbuf, rxbuf); + + ret = (rxbuf[1] << 5) | (rxbuf[2] >> 3); + + return ret; +} + +/** + * @brief 7-point median filtering code for touchpad samples + * + * @note This is an internally used routine only. + * + * @notapi + */ +static void tp_lld_filter(void) { + uint16_t temp; + int i,j; + + for(i = 0; i < 4; i++) { + for(j=i; j < 7; j++) { + if(sampleBuf[i] > sampleBuf[j]) { + /* Swap the values */ + temp = sampleBuf[i]; + sampleBuf[i] = sampleBuf[j]; + sampleBuf[j] = temp; + } + } + } +} + +/** + * @brief Reads out the X direction. + * + * @note The samples are median filtered for greater noise reduction + * + * @notapi + */ +uint16_t tp_lld_read_x(void) { + int i; + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiAcquireBus(tpDriver->spip); +#endif + + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0xD1); + + for(i = 0; i < 7; i++) { + sampleBuf[i]=tp_lld_read_value(0xD1); + } + + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0xD0); + + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiReleaseBus(tpDriver->spip); +#endif + + /* Find the median - use selection sort */ + tp_lld_filter(); + + return sampleBuf[3]; +} + +/* + * @brief Reads out the Y direction. + * + * @notapi + */ +uint16_t tp_lld_read_y(void) { + int i; + +#if defined(SPI_USE_MUTUAL_EXCLUSION) + spiAcquireBus(tpDriver->spip); +#endif + + TOUCHPAD_SPI_PROLOGUE(); + palClearPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + + /* Discard the first conversion - very noisy and keep the ADC on hereafter + * till we are done with the sampling. Note that PENIRQ is disabled. + */ + tp_lld_read_value(0x91); + + for(i = 0; i < 7; i++) { + sampleBuf[i] = tp_lld_read_value(0x91); + } + + /* Switch on PENIRQ once again - perform a dummy read */ + tp_lld_read_value(0x90); + + palSetPad(tpDriver->spicfg->ssport, tpDriver->spicfg->sspad); + TOUCHPAD_SPI_EPILOGUE(); + +#ifdef SPI_USE_MUTUAL_EXCLUSION + spiReleaseBus(tpDriver->spip); +#endif + + /* Find the median - use selection sort */ + tp_lld_filter(); + + return sampleBuf[3]; +} + +/* ---- Optional Routines ---- */ +#if TOUCHPAD_HAS_IRQ || defined(__DOXYGEN__) + /* + * @brief for checking if touchpad is pressed or not. + * + * @return 1 if pressed / 0 if not pressed + * + * @notapi + */ + uint8_t tp_lld_irq(void) { + return (!palReadPad(tpDriver->tpIRQPort, tpDriver->tpIRQPin)); + } +#endif + +#if TOUCHPAD_HAS_PRESSURE || defined(__DOXYGEN__) + /* + * @brief Reads out the Z direction / pressure. + * + * @notapi + */ + uint16_t tp_lld_read_z(void) { + /* ToDo */ + return 42; + } +#endif + +#endif /* HAL_USE_TOUCHPAD */ +/** @} */ + From f0a7643598a221a91f8ec1c79eb3646617d099bd Mon Sep 17 00:00:00 2001 From: Tectu Date: Thu, 16 Aug 2012 13:11:35 +0200 Subject: [PATCH 47/47] contributors.txt update --- docs/contributors.txt | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/docs/contributors.txt b/docs/contributors.txt index 70c7e660..2586ed61 100644 --- a/docs/contributors.txt +++ b/docs/contributors.txt @@ -3,15 +3,23 @@ This file is a complete history of persons who contributed to the GLCD Library. At this point we want to thank all of these people for their work. -Date NickName RealName Contribution -==== ======== ======== ============ +NickName RealName Contribution +======== ======== ============ -09.08.2012 inmarket Andrew Hannam GDISP VMT, ASYNC and MULTITHREAD implementation -30.07.2012 inmarket Andrew Hannam halext implementation -- dxli Dongxu Li lcdDrawEllipse() filled option -- benwilliam - fastMath & lcdDrawEllipse() -- Badger Thomas Saunders console implementation - FSMC for STM32F1 and F4 - lld orientation fixes for S6D1121 and SSD1189 -- Abhishek Abhishek Kakkar font rendering, S6D1121 GPIO +inmarket Andrew Hannam GDISP (restructorizing the entire library) + VMT + ASYNC and MULTITHREAD implementation + +Badger Thomas Saunders console implementation + FSMC for STM32F1 and F4 + lld orientation fixed for S6F1121 and SSD1289 + +Abhishek Abhishek Kumar S6D1121 GPIO + font rendering + touchpad noise filtering & optimizations + +benwilliam - lcdDrawEllipse() + fastMath + +dxli Dongxu Li lcdDrawEllipse() filled option