/Transportables_Koptertool/trunk/CHANGE.LOG |
---|
0,0 → 1,194 |
/**************************************************************************** |
* Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje * |
* admiralcascade@gmail.com * |
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
****************************************************************************/ |
20090612-2100 |
*spi transfer now struct driven (needs C-Strom 20090612-2100 now!!!) |
*lesser spi update rate (caused problems on some strom-slaves) |
*voltage gets transfered via spi as well |
*menu to switch display of 2nd voltage measured by C-Strom on and off |
20090604-1350 |
*bugfix for stats |
20090604-1330 |
*possible to choose between different osd-layouts (via menu) |
20090604-0700 |
+(shaddi)osd_ncmode_minimal for less symbols during FPV |
20090601-2233 |
*(woggle) changed timer init an interupt to be more precise |
*(woggle) remove all warning during compile |
*(woggle) simplify draw_big_variometer |
*(woggle) put compass rose to PROGMEM |
*(woggle) put directions array to PROGMEM |
20090525-2305 |
+HUD on/off via RC (connect to PPM, according to manual) testing stuff |
20090523-1150 |
+pal/ntsc changable in menu (applied immedeately!) |
20090519-2245 |
*mah corrected |
+config gets saved now (menu item!) |
*source moved a bit |
20090519-0115 |
+mah currently wasted |
*some small changes |
20090517-2345 |
*modded the real alpha stuff i have been talking about below |
20090516-2345 |
+some really testing stuff 'bout current measurement, more to come |
20090513-2350 |
*cellnumber autoconfig modified, offset set to 1,5V |
*copy paste nick/roll error fixed |
*clean after build in dist.sh |
+a little shellscript to auto-build the files (testing) |
*osd-layouts in seperate files so including own layouts should get easier |
+build date is displayed during init to know which version you are runing |
20090513-1040 |
*some code movement |
+artificial horizon for FC-ONLY mode |
20090512-2100 |
+some FCONLY basics (set FCONLY to 1 in main.h to use it) |
20090511-2345 |
*battery voltages now calculated according to CELL_VOLT_MIN CELL_VOLT_MAX and CELL_NUM |
*CELL_NUM -1 causes a rough auto detection of cell number |
-UBAT_WRN and UBAT_MAX are now deprecated |
20090427-2315 |
+write_gps_pos(...) (needs to be tested) |
+gps position is shown in stats screen for testing purpose |
20090427-2131 |
*stats are only collected while engines running (shaddi) |
20090427-2102 |
*fixed maximum distance in stats (shaddi) |
20090427-2050 |
*clear() now faster |
*fixed calculation of max speed in stats (shaddi) |
*littel typo in artificial horizon (thx joko) |
*stats are only shown AFTER flight (more specific, after motors had been on at least once) |
+indication icon for serial link (requires new character 198) |
+indication icon for manual controll (stick > stick threshold) |
(Character set 192 needs to be reflashed since new icon is in it) |
20090420-0205 |
*reset-bug fixed |
*moved code a bit |
20090419-2145 |
*reset-bug workaround in usart1.c: usart1_DisableTXD and usart1_EnableTXD |
20090419-1900 |
*fixed bug in heading-fine conv for bearing to home |
20090419-1245 |
*compass characters bigger |
*battery position |
+voltage-symbol to battery-voltage |
(Character Set 208 needs to be reflashed since compass chars are in it) |
20090418-2015 |
*fixed bug in Character Set 128 (reflash it if you already flashed it!) |
+another set of vario chars |
*changed vario to use new characters |
*moved vario/home-bearing positions |
*big vario now enabled via menu or BIGVARIO |
(Character Set 112 needs to be flashed) |
20090418-1235 |
+big vario for testing purpose |
(Character Set 192 needs to be flashed) |
20090418-0100 |
*variometer uses more steps (9 instead of 5) |
*home-arrow is now home-clock using more steps (22,5° resolution) |
+visual battery-gauge according to difference between UBAT_WRN and UBAT_MAX |
20090417-1115 |
*changed calculation of km/h (thx wowie) |
*added JochenK_(joko)'s characters |
(Character-Sets 128, 136, 144, 152, 160, 168, 176 and 184 need to be flashed!) |
20090408-1245 (shaddi) |
*fixed distance towards home |
20090408-0035 |
*rewrote number->display functions |
*fixed height bug (uint vs int) |
20090407-2100 |
+added request of OSD data, disrequest of debug data and uptime reset to menu |
-removed the uptime-reset binding from S2 |
+pgm space for some strings to save _normal_ data space |
*some code movement |
20090406-0130 |
*MK-Datastruct updated to work with NaviCtrl 0.15c firmware |
*changed flags from NO* to invers versions |
*enhanced the menu a bit |
-artificial horizon at bootup, the menu is cooler imho |
20090405-0207 |
+NOOSD as requested |
*height now corrected (thx lephisto) and displayed as .x up to 10m |
20090402-0106 |
+ disabling the txd pin while not using it so it won't interfere with KopterTool usage (thx joko) |
+ if no data has been received for over 2sec we re-request it |
* tried source organisation a bit |
20090401-1741 (shaddi) |
+ More precise Veriometer. Uses more more characters to show the speed of the movement |
(Character-Set 232 needs to be flashed!) |
20090331-1549 |
+ simple config menu during runtime, press S1 to jump in, S2 to cyle and S1 to accept choice |
- S1 no longer requests the NC data |
20090331-1305 |
+ added more statistics |
* corrected S1/S2 mapping (d'oh) |
+ started simple mode controll, press S2 during bootup toggles artificial horizon |
20090329-1452 |
* fixed bearing to home |
+ added flight stats (shown while engines off) |
+ sat icon should indicate PH/CH/Free now |
+ you need to flash characters 224-231 if you were using previous versions |
20090327-2140 |
* fixed km/h (was cm/s) |
* fixed height m (was dm) |
* modified incoming data speed to 100ms (was 200ms) |
20090326-2031 |
+ first binary release |
/Transportables_Koptertool/trunk/LICENSE.TXT |
---|
0,0 → 1,340 |
GNU GENERAL PUBLIC LICENSE |
Version 2, June 1991 |
Copyright (C) 1989, 1991 Free Software Foundation, Inc. |
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Everyone is permitted to copy and distribute verbatim copies |
of this license document, but changing it is not allowed. |
Preamble |
The licenses for most software are designed to take away your |
freedom to share and change it. By contrast, the GNU General Public |
License is intended to guarantee your freedom to share and change free |
software--to make sure the software is free for all its users. This |
General Public License applies to most of the Free Software |
Foundation's software and to any other program whose authors commit to |
using it. (Some other Free Software Foundation software is covered by |
the GNU Library General Public License instead.) You can apply it to |
your programs, too. |
When we speak of free software, we are referring to freedom, not |
price. Our General Public Licenses are designed to make sure that you |
have the freedom to distribute copies of free software (and charge for |
this service if you wish), that you receive source code or can get it |
if you want it, that you can change the software or use pieces of it |
in new free programs; and that you know you can do these things. |
To protect your rights, we need to make restrictions that forbid |
anyone to deny you these rights or to ask you to surrender the rights. |
These restrictions translate to certain responsibilities for you if you |
distribute copies of the software, or if you modify it. |
For example, if you distribute copies of such a program, whether |
gratis or for a fee, you must give the recipients all the rights that |
you have. You must make sure that they, too, receive or can get the |
source code. And you must show them these terms so they know their |
rights. |
We protect your rights with two steps: (1) copyright the software, and |
(2) offer you this license which gives you legal permission to copy, |
distribute and/or modify the software. |
Also, for each author's protection and ours, we want to make certain |
that everyone understands that there is no warranty for this free |
software. If the software is modified by someone else and passed on, we |
want its recipients to know that what they have is not the original, so |
that any problems introduced by others will not reflect on the original |
authors' reputations. |
Finally, any free program is threatened constantly by software |
patents. We wish to avoid the danger that redistributors of a free |
program will individually obtain patent licenses, in effect making the |
program proprietary. To prevent this, we have made it clear that any |
patent must be licensed for everyone's free use or not licensed at all. |
The precise terms and conditions for copying, distribution and |
modification follow. |
GNU GENERAL PUBLIC LICENSE |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION |
0. This License applies to any program or other work which contains |
a notice placed by the copyright holder saying it may be distributed |
under the terms of this General Public License. The "Program", below, |
refers to any such program or work, and a "work based on the Program" |
means either the Program or any derivative work under copyright law: |
that is to say, a work containing the Program or a portion of it, |
either verbatim or with modifications and/or translated into another |
language. (Hereinafter, translation is included without limitation in |
the term "modification".) Each licensee is addressed as "you". |
Activities other than copying, distribution and modification are not |
covered by this License; they are outside its scope. The act of |
running the Program is not restricted, and the output from the Program |
is covered only if its contents constitute a work based on the |
Program (independent of having been made by running the Program). |
Whether that is true depends on what the Program does. |
1. You may copy and distribute verbatim copies of the Program's |
source code as you receive it, in any medium, provided that you |
conspicuously and appropriately publish on each copy an appropriate |
copyright notice and disclaimer of warranty; keep intact all the |
notices that refer to this License and to the absence of any warranty; |
and give any other recipients of the Program a copy of this License |
along with the Program. |
You may charge a fee for the physical act of transferring a copy, and |
you may at your option offer warranty protection in exchange for a fee. |
2. You may modify your copy or copies of the Program or any portion |
of it, thus forming a work based on the Program, and copy and |
distribute such modifications or work under the terms of Section 1 |
above, provided that you also meet all of these conditions: |
a) You must cause the modified files to carry prominent notices |
stating that you changed the files and the date of any change. |
b) You must cause any work that you distribute or publish, that in |
whole or in part contains or is derived from the Program or any |
part thereof, to be licensed as a whole at no charge to all third |
parties under the terms of this License. |
c) If the modified program normally reads commands interactively |
when run, you must cause it, when started running for such |
interactive use in the most ordinary way, to print or display an |
announcement including an appropriate copyright notice and a |
notice that there is no warranty (or else, saying that you provide |
a warranty) and that users may redistribute the program under |
these conditions, and telling the user how to view a copy of this |
License. (Exception: if the Program itself is interactive but |
does not normally print such an announcement, your work based on |
the Program is not required to print an announcement.) |
These requirements apply to the modified work as a whole. If |
identifiable sections of that work are not derived from the Program, |
and can be reasonably considered independent and separate works in |
themselves, then this License, and its terms, do not apply to those |
sections when you distribute them as separate works. But when you |
distribute the same sections as part of a whole which is a work based |
on the Program, the distribution of the whole must be on the terms of |
this License, whose permissions for other licensees extend to the |
entire whole, and thus to each and every part regardless of who wrote it. |
Thus, it is not the intent of this section to claim rights or contest |
your rights to work written entirely by you; rather, the intent is to |
exercise the right to control the distribution of derivative or |
collective works based on the Program. |
In addition, mere aggregation of another work not based on the Program |
with the Program (or with a work based on the Program) on a volume of |
a storage or distribution medium does not bring the other work under |
the scope of this License. |
3. You may copy and distribute the Program (or a work based on it, |
under Section 2) in object code or executable form under the terms of |
Sections 1 and 2 above provided that you also do one of the following: |
a) Accompany it with the complete corresponding machine-readable |
source code, which must be distributed under the terms of Sections |
1 and 2 above on a medium customarily used for software interchange; or, |
b) Accompany it with a written offer, valid for at least three |
years, to give any third party, for a charge no more than your |
cost of physically performing source distribution, a complete |
machine-readable copy of the corresponding source code, to be |
distributed under the terms of Sections 1 and 2 above on a medium |
customarily used for software interchange; or, |
c) Accompany it with the information you received as to the offer |
to distribute corresponding source code. (This alternative is |
allowed only for noncommercial distribution and only if you |
received the program in object code or executable form with such |
an offer, in accord with Subsection b above.) |
The source code for a work means the preferred form of the work for |
making modifications to it. For an executable work, complete source |
code means all the source code for all modules it contains, plus any |
associated interface definition files, plus the scripts used to |
control compilation and installation of the executable. However, as a |
special exception, the source code distributed need not include |
anything that is normally distributed (in either source or binary |
form) with the major components (compiler, kernel, and so on) of the |
operating system on which the executable runs, unless that component |
itself accompanies the executable. |
If distribution of executable or object code is made by offering |
access to copy from a designated place, then offering equivalent |
access to copy the source code from the same place counts as |
distribution of the source code, even though third parties are not |
compelled to copy the source along with the object code. |
4. You may not copy, modify, sublicense, or distribute the Program |
except as expressly provided under this License. Any attempt |
otherwise to copy, modify, sublicense or distribute the Program is |
void, and will automatically terminate your rights under this License. |
However, parties who have received copies, or rights, from you under |
this License will not have their licenses terminated so long as such |
parties remain in full compliance. |
5. You are not required to accept this License, since you have not |
signed it. However, nothing else grants you permission to modify or |
distribute the Program or its derivative works. These actions are |
prohibited by law if you do not accept this License. Therefore, by |
modifying or distributing the Program (or any work based on the |
Program), you indicate your acceptance of this License to do so, and |
all its terms and conditions for copying, distributing or modifying |
the Program or works based on it. |
6. Each time you redistribute the Program (or any work based on the |
Program), the recipient automatically receives a license from the |
original licensor to copy, distribute or modify the Program subject to |
these terms and conditions. You may not impose any further |
restrictions on the recipients' exercise of the rights granted herein. |
You are not responsible for enforcing compliance by third parties to |
this License. |
7. If, as a consequence of a court judgment or allegation of patent |
infringement or for any other reason (not limited to patent issues), |
conditions are imposed on you (whether by court order, agreement or |
otherwise) that contradict the conditions of this License, they do not |
excuse you from the conditions of this License. If you cannot |
distribute so as to satisfy simultaneously your obligations under this |
License and any other pertinent obligations, then as a consequence you |
may not distribute the Program at all. For example, if a patent |
license would not permit royalty-free redistribution of the Program by |
all those who receive copies directly or indirectly through you, then |
the only way you could satisfy both it and this License would be to |
refrain entirely from distribution of the Program. |
If any portion of this section is held invalid or unenforceable under |
any particular circumstance, the balance of the section is intended to |
apply and the section as a whole is intended to apply in other |
circumstances. |
It is not the purpose of this section to induce you to infringe any |
patents or other property right claims or to contest validity of any |
such claims; this section has the sole purpose of protecting the |
integrity of the free software distribution system, which is |
implemented by public license practices. Many people have made |
generous contributions to the wide range of software distributed |
through that system in reliance on consistent application of that |
system; it is up to the author/donor to decide if he or she is willing |
to distribute software through any other system and a licensee cannot |
impose that choice. |
This section is intended to make thoroughly clear what is believed to |
be a consequence of the rest of this License. |
8. If the distribution and/or use of the Program is restricted in |
certain countries either by patents or by copyrighted interfaces, the |
original copyright holder who places the Program under this License |
may add an explicit geographical distribution limitation excluding |
those countries, so that distribution is permitted only in or among |
countries not thus excluded. In such case, this License incorporates |
the limitation as if written in the body of this License. |
9. The Free Software Foundation may publish revised and/or new versions |
of the General Public License from time to time. Such new versions will |
be similar in spirit to the present version, but may differ in detail to |
address new problems or concerns. |
Each version is given a distinguishing version number. If the Program |
specifies a version number of this License which applies to it and "any |
later version", you have the option of following the terms and conditions |
either of that version or of any later version published by the Free |
Software Foundation. If the Program does not specify a version number of |
this License, you may choose any version ever published by the Free Software |
Foundation. |
10. If you wish to incorporate parts of the Program into other free |
programs whose distribution conditions are different, write to the author |
to ask for permission. For software which is copyrighted by the Free |
Software Foundation, write to the Free Software Foundation; we sometimes |
make exceptions for this. Our decision will be guided by the two goals |
of preserving the free status of all derivatives of our free software and |
of promoting the sharing and reuse of software generally. |
NO WARRANTY |
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED |
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS |
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE |
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, |
REPAIR OR CORRECTION. |
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, |
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING |
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED |
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY |
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER |
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE |
POSSIBILITY OF SUCH DAMAGES. |
END OF TERMS AND CONDITIONS |
How to Apply These Terms to Your New Programs |
If you develop a new program, and you want it to be of the greatest |
possible use to the public, the best way to achieve this is to make it |
free software which everyone can redistribute and change under these terms. |
To do so, attach the following notices to the program. It is safest |
to attach them to the start of each source file to most effectively |
convey the exclusion of warranty; and each file should have at least |
the "copyright" line and a pointer to where the full notice is found. |
<one line to give the program's name and a brief idea of what it does.> |
Copyright (C) <year> <name of author> |
This program 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 2 of the License, or |
(at your option) any later version. |
This program 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, write to the Free Software |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Also add information on how to contact you by electronic and paper mail. |
If the program is interactive, make it output a short notice like this |
when it starts in an interactive mode: |
Gnomovision version 69, Copyright (C) year name of author |
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. |
This is free software, and you are welcome to redistribute it |
under certain conditions; type `show c' for details. |
The hypothetical commands `show w' and `show c' should show the appropriate |
parts of the General Public License. Of course, the commands you use may |
be called something other than `show w' and `show c'; they could even be |
mouse-clicks or menu items--whatever suits your program. |
You should also get your employer (if you work as a programmer) or your |
school, if any, to sign a "copyright disclaimer" for the program, if |
necessary. Here is a sample; alter the names: |
Yoyodyne, Inc., hereby disclaims all copyright interest in the program |
`Gnomovision' (which makes passes at compilers) written by James Hacker. |
<signature of Ty Coon>, 1 April 1989 |
Ty Coon, President of Vice |
This General Public License does not permit incorporating your program into |
proprietary programs. If your program is a subroutine library, you may |
consider it more useful to permit linking proprietary applications with the |
library. If this is what you want to do, use the GNU Library General |
Public License instead of this License. |
/Transportables_Koptertool/trunk/MMB 1.pdf |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Transportables_Koptertool/trunk/MMB 1.sch |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/Transportables_Koptertool/trunk/Makefile |
---|
0,0 → 1,505 |
#------------------------------------------------------------------- |
# Use only one! |
# _M_obiles _M_ikrokopter _T_ool http://forum.mikrokopter.de/topic-4061-1.html |
# MK Multi Box |
BOARD = MMT |
# |
#BOARD = xxx |
#------------------------------------------------------------------- |
VERSION_MAJOR = 0 |
VERSION_MINOR = 2 |
VERSION_PATCH = 1 |
VERSION_SERIAL_MAJOR = 10 # Serial Protocol Major Version |
VERSION_SERIAL_MINOR = 0 # Serial Protocol Minor Version |
#------------------------------------------------------------------- |
# get SVN revision |
REV := $(shell sh -c "cat .svn/entries | sed -n '4p'") |
ifeq ($(BOARD), MMT) |
# The original with ATmega32 and 7.3 MHz |
MCU = atmega32 |
F_CPU = 7372800 |
QUARZ = 7MHZ |
FUSE_SETTINGS = -u -U lfuse:w:0x3f:m -U hfuse:w:0xcf:m |
HEX_NAME = $(BOARD)_MEGA32 |
endif |
ifeq ($(BOARD), MMB) |
# MK Multi Box with ATmega644p and 20 MHz |
MCU = atmega644p |
F_CPU = 20000000 |
QUARZ = 20MHZ |
FUSE_SETTINGS = -u -U lfuse:w:0xd7:m -U hfuse:w:0xdf:m -U efuse:w:0xfc:m |
HEX_NAME = $(BOARD)_MEGA644p |
endif |
ifeq ($(BOARD), MMB1) |
# original board. ATmega32 replaced with ATmega644p |
MCU = atmega644p |
F_CPU = 7372800 |
QUARZ = 7MHZ |
FUSE_SETTINGS = -u -U lfuse:w:0xd7:m -U hfuse:w:0xdf:m -U efuse:w:0xfc:m |
HEX_NAME = $(BOARD)_MEGA644p |
endif |
# Output format. (can be srec, ihex, binary) |
FORMAT = ihex |
# Target file name (without extension). |
ifeq ($(VERSION_PATCH), 0) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)a_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 1) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)b_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 2) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)c_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 3) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)d_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 4) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)e_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 5) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)f_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 6) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)g_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 7) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)h_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 8) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)i_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 9) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)j_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 10) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)k_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 11) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)l_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 12) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)m_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 13) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)n_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 14) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)o_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 15) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)p_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 16) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)q_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 17) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)r_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 18) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)s_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 19) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)t_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 20) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)u_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 21) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)v_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 22) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)w_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 23) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)x_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 24) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)y_SVN$(REV) |
endif |
ifeq ($(VERSION_PATCH), 25) |
TARGET = $(HEX_NAME)_V$(VERSION_MAJOR)_$(VERSION_MINOR)z_SVN$(REV) |
endif |
# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. |
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.) |
OPT = s |
########################################################################################################## |
# List C source files here. (C dependencies are automatically generated.) |
ifeq ($(BOARD), MMT) |
SRC = main.c menu.c timer.c lcd.c font8X6.c usart.c settings.c motortest.c display.c osd.c debug.c parameter.c status.c eeprom.c |
else |
SRC = main.c menu.c timer.c lcd.c font8X6.c font8x8.c usart.c settings.c motortest.c display.c osd.c debug.c jeti.c servo.c lipo.c parameter.c status.c eeprom.c |
endif |
########################################################################################################## |
# List Assembler source files here. |
# Make them always end in a capital .S. Files ending in a lowercase .s |
# will not be considered source files but generated files (assembler |
# output from the compiler), and will be deleted upon "make clean"! |
# Even though the DOS/Win* filesystem matches both .s and .S the same, |
# it will preserve the spelling of the filenames, and gcc itself does |
# care about how the name is spelled on its command-line. |
ASRC = |
# List any extra directories to look for include files here. |
# Each directory must be seperated by a space. |
EXTRAINCDIRS = |
# Optional compiler flags. |
# -g: generate debugging information (for GDB, or for COFF conversion) |
# -O*: optimization level |
# -f...: tuning, see gcc manual and avr-libc documentation |
# -Wall...: warning level |
# -Wa,...: tell GCC to pass this to the assembler. |
# -ahlms: create assembler listing |
CFLAGS = -O$(OPT) |
CFLAGS += -funsigned-char |
CFLAGS += -funsigned-bitfields |
CFLAGS += -fpack-struct |
CFLAGS += -fshort-enums |
CFLAGS += -Wall |
CFLAGS += -Wstrict-prototypes |
CFLAGS += -Wa,-adhlns=$(<:.c=.lst) |
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) |
# Compiler flag to set the C Standard level. |
# Unremark just one line below to set the language standard to use. |
# c89 = "ANSI" C |
# gnu89 = c89 plus GCC extensions |
# c99 = ISO C99 standard (not yet fully implemented) |
# gnu99 = c99 plus GCC extensions |
#CFLAGS += -std=c89 |
#CFLAGS += -std=gnu89 |
#CFLAGS += -std=c99 |
CFLAGS += -std=gnu99 |
CFLAGS += -DF_CPU=$(F_CPU) |
CFLAGS += -DQUARZ=$(QUARZ) |
CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) |
CFLAGS += -DVERSION_MINOR=$(VERSION_MINOR) |
CFLAGS += -DVERSION_PATCH=$(VERSION_PATCH) |
CFLAGS += -DVERSION_SERIAL_MAJOR=$(VERSION_SERIAL_MAJOR) |
CFLAGS += -DVERSION_SERIAL_MINOR=$(VERSION_SERIAL_MINOR) |
ifeq ($(BOARD), MMT) |
CFLAGS += -DUSE_MMT |
endif |
ifeq ($(BOARD), MMB) |
CFLAGS += -DUSE_MMB |
endif |
ifeq ($(BOARD), MMB1) |
CFLAGS += -DUSE_MMB1 |
endif |
# Optional assembler flags. |
# -Wa,...: tell GCC to pass this to the assembler. |
# -ahlms: create listing |
# -gstabs: have the assembler create line number information; note that |
# for use in COFF files, additional information about filenames |
# and function names needs to be present in the assembler source |
# files -- see avr-libc docs [FIXME: not yet described there] |
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs |
# Optional linker flags. |
# -Wl,...: tell GCC to pass this to linker. |
# -Map: create map file |
# --cref: add cross reference to map file |
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref |
# Additional libraries |
# Minimalistic printf version |
#LDFLAGS += -Wl,-u,vfprintf -lprintf_min |
# Floating point printf version (requires -lm below) |
#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt |
# -lm = math library |
LDFLAGS += -lm |
##LDFLAGS += -T./linkerfile/avr5.x |
# Programming support using avrdude. Settings and variables. |
# Programming hardware: |
# |
# Type: avrdude -c ? |
# to get a full listing. |
# |
AVRDUDE_PROGRAMMER = usbasp |
#falls Ponyser ausgewählt wird, muss sich unsere avrdude-Configdatei im Bin-Verzeichnis des Compilers befinden |
#AVRDUDE_PORT = com1 # programmer connected to serial device |
#AVRDUDE_PORT = lpt1 # programmer connected to parallel port |
#AVRDUDE_PORT = usb # programmer connected to USB |
AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex |
AVRDUDE_WRITE_FUSE = $(FUSE_SETTINGS) |
AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep |
#avrdude -c avrispv2 -P usb -p m32 -U flash:w:blink.hex |
#AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) |
AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) |
# Uncomment the following if you want avrdude's erase cycle counter. |
# Note that this counter needs to be initialized first using -Yn, |
# see avrdude manual. |
#AVRDUDE_ERASE += -y |
# Uncomment the following if you do /not/ wish a verification to be |
# performed after programming the device. |
AVRDUDE_FLAGS += -V |
# Increase verbosity level. Please use this when submitting bug |
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> |
# to submit bug reports. |
#AVRDUDE_FLAGS += -v -v |
# --------------------------------------------------------------------------- |
# Define directories, if needed. |
#DIRAVR = c:/winavr |
#DIRAVRBIN = $(DIRAVR)/bin |
#DIRAVRUTILS = $(DIRAVR)/utils/bin |
#DIRINC = . |
#DIRLIB = $(DIRAVR)/avr/lib |
# Define programs and commands. |
SHELL = sh |
CC = avr-gcc |
OBJCOPY = avr-objcopy |
OBJDUMP = avr-objdump |
SIZE = avr-size |
# Programming support using avrdude. |
AVRDUDE = avrdude |
REMOVE = rm -f |
COPY = cp |
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex |
##ELFSIZE = $(SIZE) -A $(TARGET).elf |
ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf |
# Define Messages |
# English |
MSG_ERRORS_NONE = Errors: none |
MSG_BEGIN = -------- begin -------- |
MSG_END = -------- end -------- |
MSG_SIZE_BEFORE = Size before: |
MSG_SIZE_AFTER = Size after: |
MSG_COFF = Converting to AVR COFF: |
MSG_EXTENDED_COFF = Converting to AVR Extended COFF: |
MSG_FLASH = Creating load file for Flash: |
MSG_EEPROM = Creating load file for EEPROM: |
MSG_EXTENDED_LISTING = Creating Extended Listing: |
MSG_SYMBOL_TABLE = Creating Symbol Table: |
MSG_LINKING = Linking: |
MSG_COMPILING = Compiling: |
MSG_ASSEMBLING = Assembling: |
MSG_CLEANING = Cleaning project: |
# Define all object files. |
OBJ = $(SRC:.c=.o) $(ASRC:.S=.o) |
# Define all listing files. |
LST = $(SRC:.c=.lst) $(ASRC:.S=.lst) |
# Combine all necessary flags and optional flags. |
# Add target processor to flags. |
#ALL_CFLAGS = -mmcu=$(MCU) -DF_CPU=$(F_CPU) -I. $(CFLAGS) |
ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) |
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) |
# Default target. |
all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ |
$(TARGET).lss $(TARGET).sym sizeafter finished end |
# Eye candy. |
# AVR Studio 3.x does not check make's exit code but relies on |
# the following magic strings to be generated by the compile job. |
begin: |
@echo |
@echo $(MSG_BEGIN) |
finished: |
@echo $(MSG_ERRORS_NONE) |
end: |
@echo $(MSG_END) |
@echo |
# Display size of file. |
sizebefore: |
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi |
sizeafter: |
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi |
# Display compiler version information. |
gccversion : |
@$(CC) --version |
# Convert ELF to COFF for use in debugging / simulating in |
# AVR Studio or VMLAB. |
COFFCONVERT=$(OBJCOPY) --debugging \ |
--change-section-address .data-0x800000 \ |
--change-section-address .bss-0x800000 \ |
--change-section-address .noinit-0x800000 \ |
--change-section-address .eeprom-0x810000 |
coff: $(TARGET).elf |
@echo |
@echo $(MSG_COFF) $(TARGET).cof |
$(COFFCONVERT) -O coff-avr $< $(TARGET).cof |
extcoff: $(TARGET).elf |
@echo |
@echo $(MSG_EXTENDED_COFF) $(TARGET).cof |
$(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof |
# Program the device. |
flash: $(TARGET).hex |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) |
eeprom: $(TARGET).eep |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_EEPROM) |
fuse: |
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FUSE) |
reset: |
$(AVRDUDE) $(AVRDUDE_FLAGS) |
# Create final output files (.hex, .eep) from ELF output file. |
%.hex: %.elf |
@echo |
@echo $(MSG_FLASH) $@ |
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ |
%.eep: %.elf |
@echo |
@echo $(MSG_EEPROM) $@ |
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ |
--change-section-lma .eeprom=0 -O $(FORMAT) $< $@ |
# Create extended listing file from ELF output file. |
%.lss: %.elf |
@echo |
@echo $(MSG_EXTENDED_LISTING) $@ |
$(OBJDUMP) -h -S $< > $@ |
# Create a symbol table from ELF output file. |
%.sym: %.elf |
@echo |
@echo $(MSG_SYMBOL_TABLE) $@ |
avr-nm -n $< > $@ |
# Link: create ELF output file from object files. |
.SECONDARY : $(TARGET).elf |
.PRECIOUS : $(OBJ) |
%.elf: $(OBJ) |
@echo |
@echo $(MSG_LINKING) $@ |
$(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) |
# Compile: create object files from C source files. |
%.o : %.c |
@echo |
@echo $(MSG_COMPILING) $< |
$(CC) -c $(ALL_CFLAGS) $< -o $@ |
# Compile: create assembler files from C source files. |
%.s : %.c |
$(CC) -S $(ALL_CFLAGS) $< -o $@ |
# Assemble: create object files from assembler source files. |
%.o : %.S |
@echo |
@echo $(MSG_ASSEMBLING) $< |
$(CC) -c $(ALL_ASFLAGS) $< -o $@ |
# Target: clean project. |
clean: begin clean_list finished end |
clean_list : |
@echo |
@echo $(MSG_CLEANING) |
# $(REMOVE) $(TARGET).hex |
$(REMOVE) $(TARGET).eep |
$(REMOVE) $(TARGET).obj |
$(REMOVE) $(TARGET).cof |
$(REMOVE) $(TARGET).elf |
$(REMOVE) $(TARGET).map |
$(REMOVE) $(TARGET).obj |
$(REMOVE) $(TARGET).a90 |
$(REMOVE) $(TARGET).sym |
$(REMOVE) $(TARGET).lnk |
$(REMOVE) $(TARGET).lss |
$(REMOVE) $(OBJ) |
$(REMOVE) $(LST) |
$(REMOVE) $(SRC:.c=.s) |
$(REMOVE) $(SRC:.c=.d) |
@echo |
# Automatically generate C source code dependencies. |
# (Code originally taken from the GNU make user manual and modified |
# (See README.txt Credits).) |
# |
# Note that this will work with sh (bash) and sed that is shipped with WinAVR |
# (see the SHELL variable defined above). |
# This may not work with other shells or other seds. |
# |
%.d: %.c |
@set -e; $(CC) -MM $(ALL_CFLAGS) $< \ |
| sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ |
[ -s $@ ] || rm -f $@ |
# Remove the '-' if you want to see the dependency files generated. |
-include $(SRC:.c=.d) |
# Listing of phony targets. |
.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff clean clean_list flash eeprom fuse reset |
/Transportables_Koptertool/trunk/README.txt |
---|
0,0 → 1,189 |
MK Multi Box: |
============= |
Stand: 12.02.2010 |
Was kann die MMB: |
- Anzeige der OSD-Daten |
- MK Display |
- MK Motor Test |
- MK Debug-Daten |
- Jeti Box |
- Servo Tester |
Das muß noch geschrieben/überarbeitet/getestet werde: |
- MK Parameter |
- LiPo Überwachung |
- I2C-Tester für BL-Ctrl |
Die MMB entstand aus dem Projekt "Transportables Kopter Tool" von thkais: |
http://www.ft-fanpage.de/mikrokopter/ |
und |
http://forum.mikrokopter.de/topic-4061-1.html |
Das Projekt hatte ich mal auf Lochraster nachgebaut. |
Leider war es kurz nach dem Bau ziemlich nutzlos. |
Die FC bekam ein Firmware-Update und niemand hat sich um die Software-Anpassung des Tools gekümmert. :-( |
So lag es denn einige Monate und staubte vor sich hin... |
Mitte 2009 wollte ich mich mit den AVRs beschäftigen und |
mir etwas basteln um die OSD-Daten vom MK zu visualisieren. |
Und zufällig schweift mein Blick über die verstaubte Kopter-Tool Hardware. ;-) |
Herausgekommen ist die MMB. |
Die Hardware basiert weitestgehend auf dem Entwurf von thkais. |
Ich habe nur etwas "modernisiert", d.h. den ATmega32 durch einen ATmega644p mit 20 MHz ersetzt. |
Die genauen Hardware-Details finden sich im Schaltplan, der auch im Eagle-Format vorliegt. |
Die "tausend" LEDs habe ich mir nur als "Debug-Hilfe" dazugebastelt |
und können auch weggelassen werden. |
Entwickelt habe ich auf dem Mac (Mac OS X 10.6) mit Crosspack. Als Editor mußte XCode herhalten. |
Der Source sollte sich aber auch unter Linux oder (zur Not) auch Windows mit den entsprechenden AVR-Tools compilieren lassen. |
Die Tasten |
^ v ⎋ ⏎ |
^ - Up |
v - Down |
⎋ - Escape/Back/Top |
⏎ - Enter |
Wenn genug Platz im Display vorhanden ist, wird in der untersten Zeile die aktuelle |
Tastenbelegung eingeblendet. Das ist aber leider nicht immer möglich. |
Hauptmenü: |
========== |
- Navi Data |
- Display |
- Parameters |
- Debug Data |
- Jeti |
- Utilities... |
1) Navi Data |
Anzeige des OSD Datensatzes der NC. |
Tasten: |
---- ---- Exit Status |
Beim Stoppen der Motoren wird einen Statusseite angezeigt. |
Die Statusseite kann auch gezielt mit der Status-taste ausgerufen werden. |
Tasten (Statusseite): |
---- ---- Exit ---- |
2) Display |
Anzeigen des MK-Displays. |
Tasten: |
page- page+ Exit NC/FC |
3) Parameters |
-- noch nicht funktionsfähig --- |
Auslesen und Ändern der FC Parameter. |
4) Debug Data |
Anzeige der MK Debug Daten. |
Tasten: |
page- page+ Exit NC/FC |
5) Jeti |
Die MK Multi Box arbeitet als "Jeti Box". |
Die Belegung der Tasten hat sich wie folgt geändert: |
^ v < > |
^ - Up |
v - Down |
< - Left |
> - Right |
Die "Jeti Box"-Funktion wird über längeres Drückern der <-Taste (Left) verlassen. |
6) Utilities... |
Weiter zum Sub-Menü "Utilities". |
Utilities: |
========== |
- Motor Test |
- Servo Tester |
- LiPo Status |
- Status |
- Settings... |
1) Motor Test |
MK Motortest |
2) Servo Tester |
Generiert einen Servo Puls mit variabler Länge von 1.0 ms bis 2.0 ms |
mit einer Wiederholrate vom 20 ms. |
Tasten: |
-10 +10 Exit >|< |
-10 - -10 Steps |
+10 - +10 Steps |
Exit - Servo-Test verlassen |
>|< - Servo in Mittenposition (1,5 ms) |
Langes Drücken auf >|< schaltet die Schrittweite auf +1/-1 um. |
Schrittweite ist 0,32 µs. |
3) LiPo Status |
Anzeige der Zellenspannungen eines LiPos bis max 4S. |
4) Status |
Einige Statusinformationen... |
5) Settings... |
Weiter zum Sub-Menü "Settings". |
Settings: |
========= |
- Orientation |
- LiPo Warn |
- View Font |
- Line |
- Rectangle |
1) Orientation |
Anzeige um 128 Grad drehen. |
Einstellung wird im EEPROM gespeichert. |
2) LiPo Warn |
Einstellen der Warnschwelle |
3) View Font |
Anzeige des 6x8 Fonts. |
4) Line |
***TEST |
5) Rectangle |
***TEST |
Source: |
======= |
Das Makefile unterstützt im Moment drei Hardware-Typen: |
- das originale "Transportable Kopter Tool": ATmega32 mit 7 MHz |
- originale Hardware aber mit ATmega644P (7 MHz) |
- MK Multi Box (siehe Eagle Schaltbild): ATmega644P mit 20 MHz |
Der Hardware-Typ wird im Makefile eingestellt. |
Ziele fürs make: |
- make clean |
ordentlich aufräumen ;-) |
- make |
HEX-File erzeugen |
- make flash |
Zielsystem flashen |
- make fuse |
FUSE-Bits programmieren |
- make reset |
Zielsystem via Programmer resetten |
/Transportables_Koptertool/trunk/TODO.txt |
---|
0,0 → 1,8 |
- MK Parameter |
- LiPo Überwachung |
Warnung ausgeben! |
- I2C BL-Ctrl Tester |
entweder zusammen mit dem Motor-Test (einfach alle Motoren bzw. alle I2C BL-Ctrl Adressen) oder |
als extra Menü und Reglernummer wählbar |
/Transportables_Koptertool/trunk/VERSION.txt |
---|
0,0 → 1,13 |
20100208: |
- erste offizielle Version |
- für Firmware FC 0.76 / NC 0. |
20100213: |
- Anpassung an die neue Firmware FC 0.78 / NC 0.18 |
abo_timeout: bei Funktionen mit Abonnement muß das Abonnement regelmäßig erneuert werden! Es läuft sonst nach 4 s aus. |
OSD: Flugzeit und RC-Quality um eine Zeile nach oben verschoben. |
In die unterste Zeile stehen nun aktuelle Spannung, aktueller Strom und verbrauchte Kapazität direkt nebeneinander. |
In der Statusseite des OSD mußten die kryptischen Lat./Long.-Angaben dem max. Strom und der verbrauchten Kapazität weichen. |
Display: Umbau auf die neue Konvention |
- Kompatibilität zur Original-Hardware (hoffentlich) wieder hergestellt |
/Transportables_Koptertool/trunk/debug.c |
---|
0,0 → 1,332 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
// @TODO: maybe choose a smaler font for the debug data. 6x6 or 6x7 would be nice and gives some additional space for status lines |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <string.h> |
#include "main.h" |
#include "menu.h" |
#include "lcd.h" |
#include "usart.h" |
#include "debug.h" |
#include "timer.h" |
#include "mk-data-structs.h" |
#define TIMEOUT 200 // 2 sec |
#define ANALOGTIME 20 // 200 ms |
// WARNING: this work for NC & FC only |
// if current_hardware == MK3MAG or MKGPS the access is outside of the array... |
#if defined (__AVR_ATmega32__) |
uint8_t AnalogNames[32][16 + 1]; // 32 names, 16 characters + 1 0x00 |
uint8_t AnalogNamesRead = 0; |
// um noch mehr Speicherplatz zu sparen, könnte man auch nur die jeweils benötigten Labels anfordern... |
#else |
uint8_t AnalogNames[2][32][16 + 1]; // 32 names, 16 characters + 1 0x00 |
uint8_t AnalogNamesRead[2] = {0,0}; |
#endif |
//***************************************************************************** |
// |
void GetAnalogNames (void) |
{ |
#if defined (__AVR_ATmega32__) |
uint8_t i = AnalogNamesRead; |
#else |
uint8_t i = AnalogNamesRead[current_hardware - 1]; |
#endif |
uint8_t t = 0; |
lcd_cls (); |
lcd_printp_at (0, 3, PSTR("Reading"), 0); |
lcd_printp_at (0, 4, PSTR("Analog Names: "), 0); |
mode = 'A'; // read Names |
_delay_ms(200); |
rxd_buffer_locked = FALSE; |
timer = ANALOGTIME; |
while (i < 32) |
{ |
SendOutData ('a', ADDRESS_ANY, 1, &i, 1); |
while (!rxd_buffer_locked && timer); |
if (timer) |
{ |
Decode64 (); |
if (i == *pRxData) |
{ |
write_ndigit_number_u(14, 4, i, 2, 0); |
#if defined (__AVR_ATmega32__) |
memcpy (AnalogNames[*pRxData], (uint8_t *) pRxData + 1, 16); |
AnalogNames[*pRxData][16] = 0; |
#else |
memcpy (AnalogNames[current_hardware - 1][*pRxData], (uint8_t *) pRxData + 1, 16); |
AnalogNames[current_hardware - 1][*pRxData][16] = 0; |
#endif |
i++; |
t = 0; |
} |
else |
{ |
_delay_ms (100); |
} |
timer = ANALOGTIME; |
rxd_buffer_locked = FALSE; |
} |
else |
{ // timeout occured |
t++; |
timer = ANALOGTIME; |
if (t >= 50) |
{ |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
break; |
} |
} |
} |
#if defined (__AVR_ATmega32__) |
AnalogNamesRead = i; |
#else |
AnalogNamesRead[current_hardware - 1] = i; |
#endif |
#if 0 |
if (timer) |
{ |
for (page = 0; page < 4; page++) |
{ |
for (i = 0; i < 7; i++) |
{ |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 8], 0); |
} |
while (!get_key_press (1 << KEY_ESC)); // ESC |
} |
} |
//return; |
#endif |
} |
//***************************************************************************** |
// |
void display_debug (void) |
{ |
uint8_t i = 0; |
uint8_t tmp_dat; |
uint8_t page = 0; |
DebugData_t *DebugData; |
lcd_cls (); |
timer = TIMEOUT; |
#if defined (__AVR_ATmega32__) |
if (AnalogNamesRead < 32) { |
#else |
if (AnalogNamesRead[current_hardware - 1] < 32) { |
#endif |
GetAnalogNames (); |
} |
if (!timer) |
{ |
return; |
} |
mode = 'D'; // Debug Data |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
for (i = 0; i < 8; i++) |
{ |
#if defined (__AVR_ATmega32__) |
lcd_print_at (0, i, AnalogNames[i + page * 8], 0); |
#else |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 8], 0); |
#endif |
} |
do |
{ |
if (rxd_buffer_locked) |
{ |
Decode64 (); |
DebugData = (DebugData_t *) pRxData; |
//lcd_printp_at (0,6,PSTR("Page"),0); |
lcd_write_number_u_at (20, 0, page); |
switch (current_hardware) |
{ |
case FC: |
lcd_printp_at (20, 1, PSTR("F"), 0); |
break; |
case NC: |
lcd_printp_at (20, 1, PSTR("N"), 0); |
break; |
default: |
lcd_printp_at (20, 1, PSTR("?"), 0); |
break; |
} |
for (i = 0; i < 8; i++) |
{ |
//lcd_print_at (0, i, AnalogNames[i + page * 8], 0); |
if (current_hardware == NC) |
{ |
write_ndigit_number_u (14, i, DebugData->Analog[i + page * 8], 5, 0); |
} |
else |
{ |
write_ndigit_number_s (14, i, DebugData->Analog[i + page * 8], 5, 0); |
} |
} |
timer = TIMEOUT; |
rxd_buffer_locked = FALSE; |
} |
if (!abo_timer) |
{ // renew abo every 3 sec |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
} |
if (get_key_press (1 << KEY_MINUS)) |
{ |
page--; |
page &= 0x03; |
lcd_cls (); |
for (i = 0; i < 8; i++) |
{ |
#if defined (__AVR_ATmega32__) |
lcd_print_at (0, i, AnalogNames[i + page * 8], 0); |
#else |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 8], 0); |
#endif |
} |
} |
else if (get_key_press (1 << KEY_PLUS)) |
{ |
page++; |
page &= 0x03; |
lcd_cls (); |
for (i = 0; i < 8; i++) |
{ |
#if defined (__AVR_ATmega32__) |
lcd_print_at (0, i, AnalogNames[i + page * 8], 0); |
#else |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 8], 0); |
#endif |
} |
} |
if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
{ |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
_delay_ms (200); |
if (current_hardware == NC) |
{ |
SwitchToFC(); |
timer = TIMEOUT; |
//lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
} |
else |
{ |
SwitchToNC(); |
timer = TIMEOUT; |
//lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
} |
_delay_ms (200); |
#if defined (__AVR_ATmega32__) |
AnalogNamesRead = 0; |
GetAnalogNames (); |
#else |
if (AnalogNamesRead[current_hardware - 1] < 32) { |
GetAnalogNames (); |
} |
#endif |
mode = 'D'; // Debug Data |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
tmp_dat = 10; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
lcd_cls (); |
page = 0; |
for (i = 0; i < 8; i++) |
{ |
#if defined (__AVR_ATmega32__) |
lcd_print_at (0, i, AnalogNames[i + page * 8], 0); |
#else |
lcd_print_at (0, i, AnalogNames[current_hardware - 1][i + page * 8], 0); |
#endif |
} |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); // ESC |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
mode = 0; |
rxd_buffer_locked = FALSE; |
if (!timer) |
{ // timeout occured |
lcd_cls (); |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
} |
} |
/Transportables_Koptertool/trunk/debug.h |
---|
0,0 → 1,36 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _DEBUG_H |
#define _DEBUG_H |
//***************************************************************************** |
// |
#if defined (__AVR_ATmega32__) |
extern uint8_t AnalogNamesRead; |
#else |
extern uint8_t AnalogNamesRead[2]; |
#endif |
//***************************************************************************** |
// |
void display_debug(void); |
#endif |
/Transportables_Koptertool/trunk/displ_val.c |
---|
0,0 → 1,88 |
#include <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include "main.h" |
#include "lcd.h" |
#include "usart.h" |
// Insgesamt 32 Werte können angezeigt werden |
// jeweils 8 Stück werden gleichzeitg angezeigt |
// Auswahl über Tasten |
uint8_t displ_page; |
void displ_get_text (uint8_t number) |
{ |
#if 0 |
uint8_t text[17]; |
uint8_t i; |
buffer[0] = '#'; |
buffer[1] = 'a'; |
buffer[2] = 'a'; |
buffer[3] = number; |
buffer[4] = 0; |
buffer[5] = 0; |
// base64_send(6); |
do |
{ |
// get_message (); |
} |
while (buffer[1] != 'A'); |
for (i = 0; i < 16; i++) |
text[i] = buffer[i]; |
text[16] = 0x00; |
lcd_print_at (0, (number & 0x07), text, 0); |
#endif |
} |
void displ_values (void) |
{ |
#if 0 |
uint8_t displ_page, i; |
int16_t value; |
uint8_t text[17]; |
displ_page = 0; // Page 0..3 (4 Pages zu je 8 Werte) |
lcd_cls (); // LCD löschen |
do |
{ |
for (i = 0; i < 8; i++) // Texte lesen und anzeigen |
displ_get_text (i + displ_page * 8); |
do |
{ |
// get_message (); |
if (buffer[1] == 'D') |
{ |
for (i = 0; i < 8; i++) |
{ |
value = buffer[i * 2 + displ_page * 16 + 2] + 256 * buffer[i * 2 + displ_page * 16 + 3]; |
itoa (value, text, 10); |
lcd_printp_at (14, i, PSTR(" "), 0); |
lcd_print_at (14, i, text, 0); |
} |
} |
} |
while (key == key_nokey); |
if (key == key_minus) |
displ_page++; |
if (key == key_plus) |
displ_page--; |
displ_page &= 0x03; |
} |
while (key != key_enter); |
#endif |
} |
/Transportables_Koptertool/trunk/displ_val.h |
---|
0,0 → 1,9 |
#ifndef _DISPL_VAL_H |
#define _DISPL_VAL_H |
//***************************************************************************** |
// |
void displ_values(void); |
#endif |
/Transportables_Koptertool/trunk/display.c |
---|
0,0 → 1,159 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include "main.h" |
#include "lcd.h" |
#include "usart.h" |
#include "timer.h" |
#include "mk-data-structs.h" |
#define TIMEOUT 500 // 5 sec |
void display_data (void) |
{ |
uint8_t cmd; |
uint8_t flag = 0;; |
mode = 'H'; |
lcd_cls (); |
if (current_hardware == NC) |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
} |
else |
{ |
if (hardware == FC) |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit"), 0); |
} |
else |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
} |
} |
lcd_printp_at (0, 0, PSTR("Display"), 0); |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
cmd = 0xfc; // Home = first page |
do |
{ |
SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
cmd = 0xff; |
//LED6_TOGGLE; |
_delay_ms (250); |
if (rxd_buffer_locked) |
{ |
Decode64 (); |
flag = 1; |
if (!hardware) |
{ // hardware was not detected at startup |
hardware = rxd_buffer[1] - 'a'; |
if (hardware == NC) |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
current_hardware = NC; |
} |
else |
{ |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit"), 0); |
current_hardware = FC; |
} |
} |
#if 0 |
rxd_buffer[24] = 0; |
lcd_print_at (0, rxd_buffer[3] + 1, (uint8_t *) &rxd_buffer[4], 0); |
#else |
rxd_buffer[83] = 0; |
print_display_at (0, 2, (uint8_t *) &rxd_buffer[3]); |
#endif |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
} |
if (get_key_press (1 << KEY_MINUS)) |
{ |
cmd = 0xfe; // next page |
LED1_TOGGLE; |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if (get_key_press (1 << KEY_PLUS)) |
{ |
cmd = 0xfd; // previous page |
LED2_TOGGLE; |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
else if ((hardware == NC) && get_key_press (1 << KEY_ENTER)) |
{ |
if (current_hardware == NC) |
{ |
SwitchToFC(); |
//timer = TIMEOUT; |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit NC"), 0); |
LED3_TOGGLE; |
} |
else |
{ |
SwitchToNC(); |
//timer = TIMEOUT; |
lcd_printpns_at (0, 7, PSTR(" \x1c \x1d Exit FC"), 0); |
LED4_TOGGLE; |
} |
cmd = 0xfc; // Home = first page |
//SendOutData('h', ADDRESS_ANY, 1, &cmd, 1); |
//cmd = 0; |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); |
get_key_press(KEY_ALL); |
mode = 0; |
rxd_buffer_locked = FALSE; |
if (!timer) |
{ // timeout occured |
if (flag) |
{ |
lcd_cls (); |
} |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
} |
LED_ALL_OFF; |
} |
/Transportables_Koptertool/trunk/display.h |
---|
0,0 → 1,27 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _DISPLAY_H |
#define _DISPLAY_H |
//***************************************************************************** |
// |
void display_data (void); |
#endif |
/Transportables_Koptertool/trunk/eeprom.c |
---|
0,0 → 1,68 |
/***************************************************************************** |
* Copyright (C) 2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/eeprom.h> |
#include <avr/pgmspace.h> |
#include "eeprom.h" |
#include "lcd.h" |
#ifndef USE_MMT |
#include "lipo.h" |
#endif |
#include "timer.h" |
//***************************************************************************** |
// |
unsigned char EEPromArray[E2END+1] EEMEM; |
//***************************************************************************** |
// |
void WriteParameterDefaults (void) |
{ |
eeprom_write_byte(&EEPromArray[EEPROM_ADDR_VALID], EEPROM_REV); |
eeprom_write_byte(&EEPromArray[EEPROM_ADDR_ORIENTATION], 0); |
#ifndef USE_MMT |
eeprom_write_byte(&EEPromArray[EEPROM_ADDR_LIPO], 33); |
#endif |
} |
//***************************************************************************** |
// |
void ReadParameter (void) |
{ |
if ((eeprom_read_byte(&EEPromArray[EEPROM_ADDR_VALID])) != EEPROM_REV) |
{ |
WriteParameterDefaults(); |
} |
LCD_ORIENTATION = eeprom_read_byte (&EEPromArray[EEPROM_ADDR_ORIENTATION]); |
#ifndef USE_MMT |
AD_WarnLevel = eeprom_read_byte (&EEPromArray[EEPROM_ADDR_LIPO]); |
#endif |
} |
//***************************************************************************** |
// |
void WriteParameter (void) |
{ |
eeprom_write_byte(&EEPromArray[EEPROM_ADDR_ORIENTATION], LCD_ORIENTATION); |
#ifndef USE_MMT |
eeprom_write_byte(&EEPromArray[EEPROM_ADDR_LIPO], AD_WarnLevel); |
#endif |
} |
/Transportables_Koptertool/trunk/eeprom.h |
---|
0,0 → 1,34 |
/***************************************************************************** |
* Copyright (C) 2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _EEPROM_H |
#define _EEPROM_H |
#define EEPROM_REV 1 // please increment when adding or changing parameters! |
#define EEPROM_ADDR_VALID 1 |
#define EEPROM_ADDR_ORIENTATION 2 |
#define EEPROM_ADDR_LIPO 3 |
//***************************************************************************** |
// |
void ReadParameter (void); |
void WriteParameter (void); |
#endif |
/Transportables_Koptertool/trunk/font8X6.c |
---|
0,0 → 1,158 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/pgmspace.h> |
// one byte is a column |
// bit 7 is the bottom |
prog_uint8_t font8x6[128][6] = |
{ |
{ 0x78,0x15,0x14,0x15,0x78,0x00 }, // ASCII - 0 'Ä' |
{ 0x20,0x55,0x54,0x55,0x78,0x00 }, // ASCII - 1 'ä' |
{ 0x38,0x45,0x44,0x45,0x38,0x00 }, // ASCII - 2 'Ö' |
{ 0x30,0x49,0x48,0x49,0x30,0x00 }, // ASCII - 3 'ö' |
{ 0x3c,0x41,0x40,0x41,0x3c,0x00 }, // ASCII - 4 'Ü' |
{ 0x38,0x41,0x40,0x21,0x78,0x00 }, // ASCII - 5 'ü' |
{ 0x7e,0x15,0x15,0x15,0x0a,0x00 }, // ASCII - 6 'ß' |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 7 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 8 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 9 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 10 A (not useable) |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 11 B |
{ 0x10,0x38,0x54,0x10,0x10,0x1e }, // ASCII - 12 C Enter Symbol |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 13 D (not useable) |
{ 0x10,0x10,0x10,0x10,0x10,0x10 }, // ASCII - 14 E hor. line |
{ 0x10,0x10,0x10,0x7c,0x10,0x10 }, // ASCII - 15 F hor. line with tick mark |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 16 10 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 17 11 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 18 12 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 19 13 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 20 14 |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 21 15 |
{ 0x04,0x02,0x7f,0x02,0x04,0x00 }, // ASCII - 22 16 Arrow up |
{ 0x10,0x20,0x7f,0x20,0x10,0x00 }, // ASCII - 23 17 Arrow down |
{ 0x10,0x38,0x54,0x10,0x10,0x10 }, // ASCII - 24 18 <- |
{ 0x10,0x10,0x10,0x54,0x38,0x10 }, // ASCII - 25 19 -> |
{ 0x10,0x18,0x1c,0x1c,0x18,0x10 }, // ASCII - 26 1A ^ |
{ 0x08,0x18,0x38,0x38,0x18,0x08 }, // ASCII - 27 1B v |
{ 0x00,0x08,0x1c,0x3e,0x7f,0x00 }, // ASCII - 28 1C < |
{ 0x00,0x7f,0x3e,0x1c,0x08,0x00 }, // ASCII - 29 1D > |
{ 0x06,0x09,0x09,0x09,0x06,0x00 }, // ASCII - 30 1E '°' |
{ 0x06,0x49,0x7d,0x49,0x06,0x00 }, // ASCII - 31 1F RC-Tx |
{ 0x00,0x00,0x00,0x00,0x00,0x00 }, // ASCII - 32 20 ' ' |
{ 0x00,0x00,0x2f,0x00,0x00,0x00 }, // ASCII - 33 21 '!' |
{ 0x00,0x07,0x00,0x07,0x00,0x00 }, // ASCII - 34 22 '"' |
{ 0x14,0x7f,0x14,0x7f,0x14,0x00 }, // ASCII - 35 23 '#' |
{ 0x24,0x2a,0x6b,0x2a,0x12,0x00 }, // ASCII - 36 24 '$' |
{ 0x23,0x13,0x08,0x64,0x62,0x00 }, // ASCII - 37 25 '%' |
{ 0x36,0x49,0x55,0x22,0x50,0x00 }, // ASCII - 38 26 '&' |
{ 0x00,0x05,0x03,0x00,0x00,0x00 }, // ASCII - 39 27 ''' |
{ 0x00,0x1c,0x22,0x41,0x00,0x00 }, // ASCII - 40 28 '(' |
{ 0x00,0x41,0x22,0x1c,0x00,0x00 }, // ASCII - 41 29 ')' |
{ 0x14,0x08,0x3e,0x08,0x14,0x00 }, // ASCII - 42 2a '*' |
{ 0x08,0x08,0x3e,0x08,0x08,0x00 }, // ASCII - 43 2b '+' |
{ 0x00,0x50,0x30,0x00,0x00,0x00 }, // ASCII - 44 2c ',' |
{ 0x08,0x08,0x08,0x08,0x08,0x00 }, // ASCII - 45 2d '-' |
{ 0x00,0x60,0x60,0x00,0x00,0x00 }, // ASCII - 46 2e '.' |
{ 0x20,0x10,0x08,0x04,0x02,0x00 }, // ASCII - 47 2f '/' |
{ 0x3e,0x51,0x49,0x45,0x3e,0x00 }, // ASCII - 48 30 '0' |
{ 0x00,0x42,0x7f,0x40,0x00,0x00 }, // ASCII - 49 31 '1' |
{ 0x42,0x61,0x51,0x49,0x46,0x00 }, // ASCII - 50 32 '2' |
{ 0x21,0x41,0x45,0x4b,0x31,0x00 }, // ASCII - 51 33 '3' |
{ 0x18,0x14,0x12,0x7f,0x10,0x00 }, // ASCII - 52 34 '4' |
{ 0x27,0x45,0x45,0x45,0x39,0x00 }, // ASCII - 53 35 '5' |
{ 0x3c,0x4a,0x49,0x49,0x30,0x00 }, // ASCII - 54 36 '6' |
{ 0x03,0x01,0x71,0x09,0x07,0x00 }, // ASCII - 55 37 '7' |
{ 0x36,0x49,0x49,0x49,0x36,0x00 }, // ASCII - 56 38 '8' |
{ 0x06,0x49,0x49,0x29,0x1e,0x00 }, // ASCII - 57 39 '9' |
{ 0x00,0x36,0x36,0x00,0x00,0x00 }, // ASCII - 58 3a ':' |
{ 0x00,0x56,0x36,0x00,0x00,0x00 }, // ASCII - 59 3b ';' |
{ 0x08,0x14,0x22,0x41,0x00,0x00 }, // ASCII - 60 3c '<' |
{ 0x14,0x14,0x14,0x14,0x14,0x00 }, // ASCII - 61 3d '=' |
{ 0x00,0x41,0x22,0x14,0x08,0x00 }, // ASCII - 62 3e '>' |
{ 0x02,0x01,0x51,0x09,0x06,0x00 }, // ASCII - 63 3f '?' |
{ 0x32,0x49,0x79,0x41,0x3e,0x00 }, // ASCII - 64 40 '@' |
{ 0x7e,0x11,0x11,0x11,0x7e,0x00 }, // ASCII - 65 41 'A' |
{ 0x7f,0x49,0x49,0x49,0x36,0x00 }, // ASCII - 66 42 'B' |
{ 0x3e,0x41,0x41,0x41,0x22,0x00 }, // ASCII - 67 43 'C' |
{ 0x7f,0x41,0x41,0x22,0x1c,0x00 }, // ASCII - 68 44 'D' |
{ 0x7f,0x49,0x49,0x49,0x41,0x00 }, // ASCII - 69 45 'E' |
{ 0x7f,0x09,0x09,0x09,0x01,0x00 }, // ASCII - 70 46 'F' |
{ 0x3e,0x41,0x49,0x49,0x7a,0x00 }, // ASCII - 71 47 'G' |
{ 0x7f,0x08,0x08,0x08,0x7f,0x00 }, // ASCII - 72 48 'H' |
{ 0x00,0x41,0x7f,0x41,0x00,0x00 }, // ASCII - 73 49 'I' |
{ 0x20,0x40,0x41,0x3f,0x01,0x00 }, // ASCII - 74 4a 'J' |
{ 0x7f,0x08,0x14,0x22,0x41,0x00 }, // ASCII - 75 4b 'K' |
{ 0x7f,0x40,0x40,0x40,0x40,0x00 }, // ASCII - 76 4c 'L' |
{ 0x7f,0x02,0x0c,0x02,0x7f,0x00 }, // ASCII - 77 4d 'M' |
{ 0x7f,0x04,0x08,0x10,0x7f,0x00 }, // ASCII - 78 4e 'N' |
{ 0x3e,0x41,0x41,0x41,0x3e,0x00 }, // ASCII - 79 4f 'O' |
{ 0x7f,0x09,0x09,0x09,0x06,0x00 }, // ASCII - 80 50 'P' |
{ 0x3e,0x41,0x51,0x21,0x5e,0x00 }, // ASCII - 81 51 'Q' |
{ 0x7f,0x09,0x19,0x29,0x46,0x00 }, // ASCII - 82 52 'R' |
{ 0x46,0x49,0x49,0x49,0x31,0x00 }, // ASCII - 83 53 'S' |
{ 0x01,0x01,0x7f,0x01,0x01,0x00 }, // ASCII - 84 54 'T' |
{ 0x3f,0x40,0x40,0x40,0x3f,0x00 }, // ASCII - 85 55 'U' |
{ 0x1f,0x20,0x40,0x20,0x1f,0x00 }, // ASCII - 86 56 'V' |
{ 0x3f,0x40,0x38,0x40,0x3f,0x00 }, // ASCII - 87 57 'W' |
{ 0x63,0x14,0x08,0x14,0x63,0x00 }, // ASCII - 88 58 'X' |
{ 0x07,0x08,0x70,0x08,0x07,0x00 }, // ASCII - 89 59 'Y' |
{ 0x61,0x51,0x49,0x45,0x43,0x00 }, // ASCII - 90 5a 'Z' |
{ 0x7f,0x41,0x41,0x00,0x00,0x00 }, // ASCII - 91 5b '[' |
{ 0x02,0x04,0x08,0x10,0x20,0x00 }, // ASCII - 92 5c '\' |
{ 0x00,0x41,0x41,0x7f,0x00,0x00 }, // ASCII - 93 5d ']' |
{ 0x04,0x02,0x01,0x02,0x04,0x00 }, // ASCII - 94 5e '^' |
{ 0x40,0x40,0x40,0x40,0x40,0x00 }, // ASCII - 95 5f '_' |
{ 0x00,0x01,0x02,0x04,0x00,0x00 }, // ASCII - 96 60 '`' |
{ 0x20,0x54,0x54,0x54,0x78,0x00 }, // ASCII - 97 61 'a' |
{ 0x7f,0x48,0x44,0x44,0x38,0x00 }, // ASCII - 98 62 'b' |
{ 0x38,0x44,0x44,0x44,0x20,0x00 }, // ASCII - 99 63 'c' |
{ 0x38,0x44,0x44,0x48,0x7f,0x00 }, // ASCII - 100 64 'd' |
{ 0x38,0x54,0x54,0x54,0x18,0x00 }, // ASCII - 101 65 'e' |
{ 0x08,0x7e,0x09,0x01,0x02,0x00 }, // ASCII - 102 66 'f' |
{ 0x0c,0x52,0x52,0x52,0x3e,0x00 }, // ASCII - 103 67 'g' |
{ 0x7f,0x08,0x04,0x04,0x78,0x00 }, // ASCII - 104 68 'h' |
{ 0x00,0x44,0x7d,0x40,0x00,0x00 }, // ASCII - 105 69 'i' |
{ 0x20,0x40,0x44,0x3d,0x00,0x00 }, // ASCII - 106 6a 'j' |
{ 0x7f,0x10,0x28,0x44,0x00,0x00 }, // ASCII - 107 6b 'k' |
{ 0x00,0x41,0x7f,0x40,0x00,0x00 }, // ASCII - 108 6c 'l' |
{ 0x7c,0x04,0x18,0x04,0x78,0x00 }, // ASCII - 109 6d 'm' |
{ 0x7c,0x08,0x04,0x04,0x78,0x00 }, // ASCII - 110 6e 'n' |
{ 0x38,0x44,0x44,0x44,0x38,0x00 }, // ASCII - 111 6f 'o' |
{ 0x7c,0x14,0x14,0x14,0x08,0x00 }, // ASCII - 112 70 'p' |
{ 0x08,0x14,0x14,0x18,0x7c,0x00 }, // ASCII - 113 71 'q' |
{ 0x7c,0x08,0x04,0x04,0x08,0x00 }, // ASCII - 114 72 'r' |
{ 0x48,0x54,0x54,0x54,0x20,0x00 }, // ASCII - 115 73 's' |
{ 0x04,0x3f,0x44,0x40,0x20,0x00 }, // ASCII - 116 74 't' |
{ 0x3c,0x40,0x40,0x20,0x7c,0x00 }, // ASCII - 117 75 'u' |
{ 0x1c,0x20,0x40,0x20,0x1c,0x00 }, // ASCII - 118 76 'v' |
{ 0x3c,0x40,0x38,0x40,0x3c,0x00 }, // ASCII - 119 77 'w' |
{ 0x44,0x28,0x10,0x28,0x44,0x00 }, // ASCII - 120 78 'x' |
{ 0x0c,0x50,0x50,0x50,0x3c,0x00 }, // ASCII - 121 79 'y' |
{ 0x44,0x64,0x54,0x4c,0x44,0x00 }, // ASCII - 122 7a 'z' |
{ 0x00,0x08,0x36,0x41,0x00,0x00 }, // ASCII - 123 7b '{' |
{ 0x00,0x00,0x7f,0x00,0x00,0x00 }, // ASCII - 124 7c '|' |
{ 0x00,0x41,0x36,0x08,0x00,0x00 }, // ASCII - 125 7d '}' |
{ 0x08,0x08,0x2a,0x1c,0x08,0x00 }, // ASCII - 126 7e -> |
{ 0x08,0x1c,0x2a,0x08,0x08,0x00 }, // ASCII - 127 7f <- |
}; |
/Transportables_Koptertool/trunk/font8x6.h |
---|
0,0 → 1,31 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - font provided by Claas Anders "CaScAdE" Rathje * |
* - umlauts and special characters by Peter "woggle" Mack * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _FONT8X6_H |
#define _FONT8X6_H |
#include <avr/pgmspace.h> |
//***************************************************************************** |
// |
extern prog_uint8_t font8x6[128][6]; |
#endif |
/Transportables_Koptertool/trunk/font8x8.c |
---|
0,0 → 1,271 |
/* |
* font8x8.c |
* LCD-OSD |
* |
* Created by Peter Mack on 26.12.09. |
* Copyright 2009 SCS GmbH & Co. KG. All rights reserved. |
* |
*/ |
#include <avr/pgmspace.h> |
prog_uint8_t font8x8[256][8]={ |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x00 |
{0x7E,0x81,0x95,0xB1,0xB1,0x95,0x81,0x7E}, // 0x01 |
{0x7E,0xFF,0xEB,0xCF,0xCF,0xEB,0xFF,0x7E}, // 0x02 |
{0x0E,0x1F,0x3F,0x7E,0x3F,0x1F,0x0E,0x00}, // 0x03 |
{0x08,0x1C,0x3E,0x7F,0x3E,0x1C,0x08,0x00}, // 0x04 |
{0x38,0x3A,0x9F,0xFF,0x9F,0x3A,0x38,0x00}, // 0x05 |
{0x10,0x38,0xBC,0xFF,0xBC,0x38,0x10,0x00}, // 0x06 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x07 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x08 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x09 |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0A |
{0x70,0xF8,0x88,0x88,0xFD,0x7F,0x07,0x0F}, // 0x0B |
{0x00,0x4E,0x5F,0xF1,0xF1,0x5F,0x4E,0x00}, // 0x0C |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x0D |
{0xC0,0xFF,0x7F,0x05,0x05,0x65,0x7F,0x3F}, // 0x0E |
{0x99,0x5A,0x3C,0xE7,0xE7,0x3C,0x5A,0x99}, // 0x0F |
{0x7F,0x3E,0x3E,0x1C,0x1C,0x08,0x08,0x00}, // 0x10 |
{0x08,0x08,0x1C,0x1C,0x3E,0x3E,0x7F,0x00}, // 0x11 |
{0x00,0x24,0x66,0xFF,0xFF,0x66,0x24,0x00}, // 0x12 |
{0x00,0x5F,0x5F,0x00,0x00,0x5F,0x5F,0x00}, // 0x13 |
{0x06,0x0F,0x09,0x7F,0x7F,0x01,0x7F,0x7F}, // 0x14 |
{0xDA,0xBF,0xA5,0xA5,0xFD,0x59,0x03,0x02}, // 0x15 |
{0x00,0x70,0x70,0x70,0x70,0x70,0x70,0x00}, // 0x16 |
{0x80,0x94,0xB6,0xFF,0xFF,0xB6,0x94,0x80}, // 0x17 |
{0x00,0x04,0x06,0x7F,0x7F,0x06,0x04,0x00}, // 0x18 |
{0x00,0x10,0x30,0x7F,0x7F,0x30,0x10,0x00}, // 0x19 |
{0x08,0x08,0x08,0x2A,0x3E,0x1C,0x08,0x00}, // 0x1A |
{0x08,0x1C,0x3E,0x2A,0x08,0x08,0x08,0x00}, // 0x1B |
{0x3C,0x3C,0x20,0x20,0x20,0x20,0x20,0x00}, // 0x1C |
{0x08,0x1C,0x3E,0x08,0x08,0x3E,0x1C,0x08}, // 0x1D |
{0x30,0x38,0x3C,0x3E,0x3E,0x3C,0x38,0x30}, // 0x1E |
{0x06,0x0E,0x1E,0x3E,0x3E,0x1E,0x0E,0x06}, // 0x1F |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // 0x20 |
{0x00,0x06,0x5F,0x5F,0x06,0x00,0x00,0x00}, // 0x21 |
{0x00,0x07,0x07,0x00,0x07,0x07,0x00,0x00}, // 0x22 |
{0x14,0x7F,0x7F,0x14,0x7F,0x7F,0x14,0x00}, // 0x23 |
{0x24,0x2E,0x6B,0x6B,0x3A,0x12,0x00,0x00}, // 0x24 |
{0x46,0x66,0x30,0x18,0x0C,0x66,0x62,0x00}, // 0x25 |
{0x30,0x7A,0x4F,0x5D,0x37,0x7A,0x48,0x00}, // 0x26 |
{0x04,0x07,0x03,0x00,0x00,0x00,0x00,0x00}, // 0x27 |
{0x00,0x1C,0x3E,0x63,0x41,0x00,0x00,0x00}, // 0x28 |
{0x00,0x41,0x63,0x3E,0x1C,0x00,0x00,0x00}, // 0x29 |
{0x08,0x2A,0x3E,0x1C,0x1C,0x3E,0x2A,0x08}, // 0x2A |
{0x08,0x08,0x3E,0x3E,0x08,0x08,0x00,0x00}, // 0x2B |
{0x00,0xA0,0xE0,0x60,0x00,0x00,0x00,0x00}, // 0x2C |
{0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00}, // 0x2D |
{0x00,0x00,0x60,0x60,0x00,0x00,0x00,0x00}, // 0x2E |
{0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00}, // 0x2F |
{0x3E,0x7F,0x59,0x4D,0x7F,0x3E,0x00,0x00}, // 0x30 |
{0x42,0x42,0x7F,0x7F,0x40,0x40,0x00,0x00}, // 0x31 |
{0x62,0x73,0x59,0x49,0x6F,0x66,0x00,0x00}, // 0x32 |
{0x22,0x63,0x49,0x49,0x7F,0x36,0x00,0x00}, // 0x33 |
{0x18,0x1C,0x16,0x13,0x7F,0x7F,0x10,0x00}, // 0x34 |
{0x27,0x67,0x45,0x45,0x7D,0x39,0x00,0x00}, // 0x35 |
{0x3C,0x7E,0x4B,0x49,0x79,0x30,0x00,0x00}, // 0x36 |
{0x03,0x63,0x71,0x19,0x0F,0x07,0x00,0x00}, // 0x37 |
{0x36,0x7F,0x49,0x49,0x7F,0x36,0x00,0x00}, // 0x38 |
{0x06,0x4F,0x49,0x69,0x3F,0x1E,0x00,0x00}, // 0x39 |
{0x00,0x00,0x6C,0x6C,0x00,0x00,0x00,0x00}, // 0x3A |
{0x00,0xA0,0xEC,0x6C,0x00,0x00,0x00,0x00}, // 0x3B |
{0x08,0x1C,0x36,0x63,0x41,0x00,0x00,0x00}, // 0x3C |
{0x14,0x14,0x14,0x14,0x14,0x14,0x00,0x00}, // 0x3D |
{0x00,0x41,0x63,0x36,0x1C,0x08,0x00,0x00}, // 0x3E |
{0x02,0x03,0x51,0x59,0x0F,0x06,0x00,0x00}, // 0x3F |
{0x3E,0x7F,0x41,0x5D,0x5D,0x1F,0x1E,0x00}, // 0x40 |
{0x7C,0x7E,0x13,0x13,0x7E,0x7C,0x00,0x00}, // 0x41 |
{0x41,0x7F,0x7F,0x49,0x49,0x7F,0x36,0x00}, // 0x42 |
{0x1C,0x3E,0x63,0x41,0x41,0x63,0x22,0x00}, // 0x43 |
{0x41,0x7F,0x7F,0x41,0x63,0x7F,0x1C,0x00}, // 0x44 |
{0x41,0x7F,0x7F,0x49,0x5D,0x41,0x63,0x00}, // 0x45 |
{0x41,0x7F,0x7F,0x49,0x1D,0x01,0x03,0x00}, // 0x46 |
{0x1C,0x3E,0x63,0x41,0x51,0x73,0x72,0x00}, // 0x47 |
{0x7F,0x7F,0x08,0x08,0x7F,0x7F,0x00,0x00}, // 0x48 |
{0x00,0x41,0x7F,0x7F,0x41,0x00,0x00,0x00}, // 0x49 |
{0x30,0x70,0x40,0x41,0x7F,0x3F,0x01,0x00}, // 0x4A |
{0x41,0x7F,0x7F,0x08,0x1C,0x77,0x63,0x00}, // 0x4B |
{0x41,0x7F,0x7F,0x41,0x40,0x60,0x70,0x00}, // 0x4C |
{0x7F,0x7F,0x06,0x0C,0x06,0x7F,0x7F,0x00}, // 0x4D |
{0x7F,0x7F,0x06,0x0C,0x18,0x7F,0x7F,0x00}, // 0x4E |
{0x1C,0x3E,0x63,0x41,0x63,0x3E,0x1C,0x00}, // 0x4F |
{0x41,0x7F,0x7F,0x49,0x09,0x0F,0x06,0x00}, // 0x50 |
{0x1E,0x3F,0x21,0x71,0x7F,0x5E,0x00,0x00}, // 0x51 |
{0x41,0x7F,0x7F,0x19,0x39,0x6F,0x46,0x00}, // 0x52 |
{0x26,0x67,0x4D,0x59,0x7B,0x32,0x00,0x00}, // 0x53 |
{0x03,0x41,0x7F,0x7F,0x41,0x03,0x00,0x00}, // 0x54 |
{0x7F,0x7F,0x40,0x40,0x7F,0x7F,0x00,0x00}, // 0x55 |
{0x1F,0x3F,0x60,0x60,0x3F,0x1F,0x00,0x00}, // 0x56 |
{0x7F,0x7F,0x30,0x18,0x30,0x7F,0x7F,0x00}, // 0x57 |
{0x63,0x77,0x1C,0x08,0x1C,0x77,0x63,0x00}, // 0x58 |
{0x07,0x4F,0x78,0x78,0x4F,0x07,0x00,0x00}, // 0x59 |
{0x67,0x73,0x59,0x4D,0x47,0x63,0x71,0x00}, // 0x5A |
{0x00,0x7F,0x7F,0x41,0x41,0x00,0x00,0x00}, // 0x5B |
{0x01,0x03,0x06,0x0C,0x18,0x30,0x60,0x00}, // 0x5C |
{0x00,0x41,0x41,0x7F,0x7F,0x00,0x00,0x00}, // 0x5D |
{0x08,0x0C,0x06,0x03,0x06,0x0C,0x08,0x00}, // 0x5E |
{0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, // 0x5F |
{0x00,0x00,0x03,0x07,0x04,0x00,0x00,0x00}, // 0x60 |
{0x20,0x74,0x54,0x54,0x3C,0x78,0x40,0x00}, // 0x61 |
{0x41,0x3F,0x7F,0x44,0x44,0x7C,0x38,0x00}, // 0x62 |
{0x38,0x7C,0x44,0x44,0x6C,0x28,0x00,0x00}, // 0x63 |
{0x30,0x78,0x48,0x49,0x3F,0x7F,0x40,0x00}, // 0x64 |
{0x38,0x7C,0x54,0x54,0x5C,0x18,0x00,0x00}, // 0x65 |
{0x48,0x7E,0x7F,0x49,0x03,0x02,0x00,0x00}, // 0x66 |
{0x98,0xBC,0xA4,0xA4,0xF8,0x7C,0x04,0x00}, // 0x67 |
{0x41,0x7F,0x7F,0x08,0x04,0x7C,0x78,0x00}, // 0x68 |
{0x00,0x44,0x7D,0x7D,0x40,0x00,0x00,0x00}, // 0x69 |
{0x40,0xC4,0x84,0xFD,0x7D,0x00,0x00,0x00}, // 0x6A |
{0x41,0x7F,0x7F,0x10,0x38,0x6C,0x44,0x00}, // 0x6B |
{0x00,0x41,0x7F,0x7F,0x40,0x00,0x00,0x00}, // 0x6C |
{0x7C,0x7C,0x0C,0x18,0x0C,0x7C,0x78,0x00}, // 0x6D |
{0x7C,0x7C,0x04,0x04,0x7C,0x78,0x00,0x00}, // 0x6E |
{0x38,0x7C,0x44,0x44,0x7C,0x38,0x00,0x00}, // 0x6F |
{0x84,0xFC,0xF8,0xA4,0x24,0x3C,0x18,0x00}, // 0x70 |
{0x18,0x3C,0x24,0xA4,0xF8,0xFC,0x84,0x00}, // 0x71 |
{0x44,0x7C,0x78,0x44,0x1C,0x18,0x00,0x00}, // 0x72 |
{0x48,0x5C,0x54,0x54,0x74,0x24,0x00,0x00}, // 0x73 |
{0x00,0x04,0x3E,0x7F,0x44,0x24,0x00,0x00}, // 0x74 |
{0x3C,0x7C,0x40,0x40,0x3C,0x7C,0x40,0x00}, // 0x75 |
{0x1C,0x3C,0x60,0x60,0x3C,0x1C,0x00,0x00}, // 0x76 |
{0x3C,0x7C,0x60,0x30,0x60,0x7C,0x3C,0x00}, // 0x77 |
{0x44,0x6C,0x38,0x10,0x38,0x6C,0x44,0x00}, // 0x78 |
{0x9C,0xBC,0xA0,0xA0,0xFC,0x7C,0x00,0x00}, // 0x79 |
{0x4C,0x64,0x74,0x5C,0x4C,0x64,0x00,0x00}, // 0x7A |
{0x08,0x08,0x3E,0x77,0x41,0x41,0x00,0x00}, // 0x7B |
{0x00,0x00,0x00,0x77,0x77,0x00,0x00,0x00}, // 0x7C |
{0x41,0x41,0x77,0x3E,0x08,0x08,0x00,0x00}, // 0x7D |
{0x02,0x03,0x01,0x03,0x02,0x03,0x01,0x00}, // 0x7E |
{0x78,0x7C,0x46,0x43,0x46,0x7C,0x78,0x00}, // 0x7F |
{0x1E,0xBF,0xE1,0x61,0x33,0x12,0x00,0x00}, // 0x80 |
{0x3A,0x7A,0x40,0x40,0x7A,0x7A,0x40,0x00}, // 0x81 |
{0x38,0x7C,0x56,0x57,0x5D,0x18,0x00,0x00}, // 0x82 |
{0x02,0x23,0x75,0x55,0x55,0x7D,0x7B,0x42}, // 0x83 |
{0x21,0x75,0x54,0x54,0x7D,0x79,0x40,0x00}, // 0x84 |
{0x20,0x75,0x57,0x56,0x7C,0x78,0x40,0x00}, // 0x85 |
{0x00,0x22,0x77,0x55,0x55,0x7F,0x7A,0x40}, // 0x86 |
{0x1C,0xBE,0xE2,0x62,0x36,0x14,0x00,0x00}, // 0x87 |
{0x02,0x3B,0x7D,0x55,0x55,0x5D,0x1B,0x02}, // 0x88 |
{0x39,0x7D,0x54,0x54,0x5D,0x19,0x00,0x00}, // 0x89 |
{0x38,0x7D,0x57,0x56,0x5C,0x18,0x00,0x00}, // 0x8A |
{0x01,0x45,0x7C,0x7C,0x41,0x01,0x00,0x00}, // 0x8B |
{0x02,0x03,0x45,0x7D,0x7D,0x43,0x02,0x00}, // 0x8C |
{0x00,0x45,0x7F,0x7E,0x40,0x00,0x00,0x00}, // 0x8D |
{0x79,0x7D,0x26,0x26,0x7D,0x79,0x00,0x00}, // 0x8E |
{0x70,0x7A,0x2D,0x2D,0x7A,0x70,0x00,0x00}, // 0x8F |
{0x44,0x7C,0x7E,0x57,0x55,0x44,0x00,0x00}, // 0x90 |
{0x20,0x74,0x54,0x54,0x7C,0x7C,0x54,0x54}, // 0x91 |
{0x7C,0x7E,0x0B,0x09,0x7F,0x7F,0x49,0x00}, // 0x92 |
{0x32,0x7B,0x49,0x49,0x7B,0x32,0x00,0x00}, // 0x93 |
{0x32,0x7A,0x48,0x48,0x7A,0x32,0x00,0x00}, // 0x94 |
{0x30,0x79,0x4B,0x4A,0x78,0x30,0x00,0x00}, // 0x95 |
{0x3A,0x7B,0x41,0x41,0x7B,0x7A,0x40,0x00}, // 0x96 |
{0x38,0x79,0x43,0x42,0x78,0x78,0x40,0x00}, // 0x97 |
{0xBA,0xBA,0xA0,0xA0,0xFA,0x7A,0x00,0x00}, // 0x98 |
{0x39,0x7D,0x44,0x44,0x44,0x7D,0x39,0x00}, // 0x99 |
{0x3D,0x7D,0x40,0x40,0x7D,0x3D,0x00,0x00}, // 0x9A |
{0x38,0x7C,0x64,0x54,0x4C,0x7C,0x38,0x00}, // 0x9B |
{0x68,0x7E,0x7F,0x49,0x43,0x66,0x20,0x00}, // 0x9C |
{0x5C,0x3E,0x73,0x49,0x67,0x3E,0x1D,0x00}, // 0x9D |
{0x44,0x6C,0x38,0x38,0x6C,0x44,0x00,0x00}, // 0x9E |
{0x40,0xC8,0x88,0xFE,0x7F,0x09,0x0B,0x02}, // 0x9F |
{0x20,0x74,0x56,0x57,0x7D,0x78,0x40,0x00}, // 0xA0 |
{0x00,0x44,0x7E,0x7F,0x41,0x00,0x00,0x00}, // 0xA1 |
{0x30,0x78,0x48,0x4A,0x7B,0x31,0x00,0x00}, // 0xA2 |
{0x38,0x78,0x40,0x42,0x7B,0x79,0x40,0x00}, // 0xA3 |
{0x7A,0x7B,0x09,0x0B,0x7A,0x73,0x01,0x00}, // 0xA4 |
{0x7A,0x7B,0x19,0x33,0x7A,0x7B,0x01,0x00}, // 0xA5 |
{0x00,0x26,0x2F,0x29,0x2F,0x2F,0x28,0x00}, // 0xA6 |
{0x00,0x26,0x2F,0x29,0x29,0x2F,0x26,0x00}, // 0xA7 |
{0x30,0x78,0x4D,0x45,0x60,0x20,0x00,0x00}, // 0xA8 |
{0x1C,0x22,0x7D,0x4B,0x5B,0x65,0x22,0x1C}, // 0xA9 |
{0x08,0x08,0x08,0x08,0x38,0x38,0x00,0x00}, // 0xAA |
{0x61,0x3F,0x1F,0xCC,0xEE,0xAB,0xB9,0x90}, // 0xAB |
{0x61,0x3F,0x1F,0x4C,0x66,0x73,0xD9,0xF8}, // 0xAC |
{0x00,0x00,0x60,0xFA,0xFA,0x60,0x00,0x00}, // 0xAD |
{0x08,0x1C,0x36,0x22,0x08,0x1C,0x36,0x22}, // 0xAE |
{0x22,0x36,0x1C,0x08,0x22,0x36,0x1C,0x08}, // 0xAF |
{0xAA,0x00,0x55,0x00,0xAA,0x00,0x55,0x00}, // 0xB0 |
{0xAA,0x55,0xAA,0x55,0xAA,0x55,0xAA,0x55}, // 0xB1 |
{0x55,0xFF,0xAA,0xFF,0x55,0xFF,0xAA,0xFF}, // 0xB2 |
{0x00,0x00,0x00,0xFF,0xFF,0x00,0x00,0x00}, // 0xB3 |
{0x10,0x10,0x10,0xFF,0xFF,0x00,0x00,0x00}, // 0xB4 |
{0x70,0x78,0x2C,0x2E,0x7B,0x71,0x00,0x00}, // 0xB5 |
{0x72,0x79,0x2D,0x2D,0x79,0x72,0x00,0x00}, // 0xB6 |
{0x71,0x7B,0x2E,0x2C,0x78,0x70,0x00,0x00}, // 0xB7 |
{0x1C,0x22,0x5D,0x55,0x55,0x41,0x22,0x1C}, // 0xB8 |
{0x14,0x14,0xF7,0xF7,0x00,0xFF,0xFF,0x00}, // 0xB9 |
{0x00,0x00,0xFF,0xFF,0x00,0xFF,0xFF,0x00}, // 0xBA |
{0x14,0x14,0xF4,0xF4,0x04,0xFC,0xFC,0x00}, // 0xBB |
{0x14,0x14,0x17,0x17,0x10,0x1F,0x1F,0x00}, // 0xBC |
{0x18,0x3C,0x24,0xE7,0xE7,0x24,0x24,0x00}, // 0xBD |
{0x2B,0x2F,0xFC,0xFC,0x2F,0x2B,0x00,0x00}, // 0xBE |
{0x10,0x10,0x10,0xF0,0xF0,0x00,0x00,0x00}, // 0xBF |
{0x00,0x00,0x00,0x1F,0x1F,0x10,0x10,0x10}, // 0xC0 |
{0x10,0x10,0x10,0x1F,0x1F,0x10,0x10,0x10}, // 0xC1 |
{0x10,0x10,0x10,0xF0,0xF0,0x10,0x10,0x10}, // 0xC2 |
{0x00,0x00,0x00,0xFF,0xFF,0x10,0x10,0x10}, // 0xC3 |
{0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10}, // 0xC4 |
{0x10,0x10,0x10,0xFF,0xFF,0x10,0x10,0x10}, // 0xC5 |
{0x22,0x77,0x55,0x57,0x7E,0x7B,0x41,0x00}, // 0xC6 |
{0x72,0x7B,0x2D,0x2F,0x7A,0x73,0x01,0x00}, // 0xC7 |
{0x00,0x00,0x1F,0x1F,0x10,0x17,0x17,0x14}, // 0xC8 |
{0x00,0x00,0xFC,0xFC,0x04,0xF4,0xF4,0x14}, // 0xC9 |
{0x14,0x14,0x17,0x17,0x10,0x17,0x17,0x14}, // 0xCA |
{0x14,0x14,0xF4,0xF4,0x04,0xF4,0xF4,0x14}, // 0xCB |
{0x00,0x00,0xFF,0xFF,0x00,0xF7,0xF7,0x14}, // 0xCC |
{0x14,0x14,0x14,0x14,0x14,0x14,0x14,0x14}, // 0xCD |
{0x14,0x14,0xF7,0xF7,0x00,0xF7,0xF7,0x14}, // 0xCE |
{0x66,0x3C,0x3C,0x24,0x3C,0x3C,0x66,0x00}, // 0xCF |
{0x05,0x27,0x72,0x57,0x7D,0x38,0x00,0x00}, // 0xD0 |
{0x49,0x7F,0x7F,0x49,0x63,0x7F,0x1C,0x00}, // 0xD1 |
{0x46,0x7D,0x7D,0x55,0x55,0x46,0x00,0x00}, // 0xD2 |
{0x45,0x7D,0x7C,0x54,0x55,0x45,0x00,0x00}, // 0xD3 |
{0x44,0x7D,0x7F,0x56,0x54,0x44,0x00,0x00}, // 0xD4 |
{0x0A,0x0E,0x08,0x00,0x00,0x00,0x00,0x00}, // 0xD5 |
{0x00,0x44,0x7E,0x7F,0x45,0x00,0x00,0x00}, // 0xD6 |
{0x02,0x45,0x7D,0x7D,0x45,0x02,0x00,0x00}, // 0xD7 |
{0x01,0x45,0x7C,0x7C,0x45,0x01,0x00,0x00}, // 0xD8 |
{0x10,0x10,0x10,0x1F,0x1F,0x00,0x00,0x00}, // 0xD9 |
{0x00,0x00,0x00,0xF0,0xF0,0x10,0x10,0x10}, // 0xDA |
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}, // 0xDB |
{0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0}, // 0xDC |
{0x00,0x00,0x00,0x77,0x77,0x00,0x00,0x00}, // 0xDD |
{0x00,0x45,0x7F,0x7E,0x44,0x00,0x00,0x00}, // 0xDE |
{0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F,0x0F}, // 0xDF |
{0x38,0x7C,0x46,0x47,0x45,0x7C,0x38,0x00}, // 0xE0 |
{0xFC,0xFE,0x2A,0x2A,0x3E,0x14,0x00,0x00}, // 0xE1 |
{0x3A,0x7D,0x45,0x45,0x45,0x7D,0x3A,0x00}, // 0xE2 |
{0x38,0x7C,0x45,0x47,0x46,0x7C,0x38,0x00}, // 0xE3 |
{0x32,0x7B,0x49,0x4B,0x7A,0x33,0x01,0x00}, // 0xE4 |
{0x3A,0x7F,0x45,0x47,0x46,0x7F,0x39,0x00}, // 0xE5 |
{0x80,0xFE,0x7E,0x20,0x20,0x3E,0x1E,0x00}, // 0xE6 |
{0x42,0x7E,0x7E,0x54,0x1C,0x08,0x00,0x00}, // 0xE7 |
{0x41,0x7F,0x7F,0x55,0x14,0x1C,0x08,0x00}, // 0xE8 |
{0x3C,0x7C,0x42,0x43,0x7D,0x3C,0x00,0x00}, // 0xE9 |
{0x3A,0x79,0x41,0x41,0x79,0x3A,0x00,0x00}, // 0xEA |
{0x3C,0x7D,0x43,0x42,0x7C,0x3C,0x00,0x00}, // 0xEB |
{0xB8,0xB8,0xA2,0xA3,0xF9,0x78,0x00,0x00}, // 0xEC |
{0x0C,0x5C,0x72,0x73,0x5D,0x0C,0x00,0x00}, // 0xED |
{0x02,0x02,0x02,0x02,0x02,0x02,0x00,0x00}, // 0xEE |
{0x00,0x00,0x02,0x03,0x01,0x00,0x00,0x00}, // 0xEF |
{0x10,0x10,0x10,0x10,0x10,0x10,0x00,0x00}, // 0xF0 |
{0x44,0x44,0x5F,0x5F,0x44,0x44,0x00,0x00}, // 0xF1 |
{0x28,0x28,0x28,0x28,0x28,0x28,0x00,0x00}, // 0xF2 |
{0x71,0x35,0x1F,0x4C,0x66,0x73,0xD9,0xF8}, // 0xF3 |
{0x06,0x0F,0x09,0x7F,0x7F,0x01,0x7F,0x7F}, // 0xF4 |
{0xDA,0xBF,0xA5,0xA5,0xFD,0x59,0x03,0x02}, // 0xF5 |
{0x08,0x08,0x6B,0x6B,0x08,0x08,0x00,0x00}, // 0xF6 |
{0x00,0x80,0xC0,0x40,0x00,0x00,0x00,0x00}, // 0xF7 |
{0x00,0x06,0x0F,0x09,0x0F,0x06,0x00,0x00}, // 0xF8 |
{0x02,0x02,0x00,0x00,0x02,0x02,0x00,0x00}, // 0xF9 |
{0x00,0x00,0x00,0x10,0x10,0x00,0x00,0x00}, // 0xFA |
{0x00,0x12,0x13,0x1F,0x1F,0x10,0x10,0x00}, // 0xFB |
{0x00,0x11,0x15,0x15,0x1F,0x1F,0x0A,0x00}, // 0xFC |
{0x00,0x19,0x1D,0x15,0x17,0x12,0x00,0x00}, // 0xFD |
{0x00,0x00,0x3C,0x3C,0x3C,0x3C,0x00,0x00}, // 0xFE |
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00} // 0xFF |
}; |
/Transportables_Koptertool/trunk/font8x8.h |
---|
0,0 → 1,19 |
/* |
* font8x8.h |
* LCD-OSD |
* |
* Created by Peter Mack on 26.12.09. |
* Copyright 2009 SCS GmbH & Co. KG. All rights reserved. |
* |
*/ |
#ifndef _FONT8X8_H |
#define _FONT8X8_H |
#include <avr/pgmspace.h> |
//***************************************************************************** |
// |
extern prog_uint8_t font8x8[256][8]; |
#endif |
/Transportables_Koptertool/trunk/jeti.c |
---|
0,0 → 1,260 |
/***************************************************************************** |
* Copyright (C) 2009-2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* see this fine thread on RCLine: * |
* http://www.rclineforum.de/forum/thread.php?threadid=226786 * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include "main.h" // LEDs |
#include "timer.h" // Keys |
#include "lcd.h" |
#include "jeti.h" |
#define font8x8 |
uint8_t JetiBuffer[32]; // 32 characters |
volatile uint8_t JetiBufferReady; |
//***************************************************************************** |
// |
ISR (USART1_RX_vect) |
{ |
uint8_t stat; |
uint8_t rh; |
uint8_t rl; |
static uint8_t jbp; |
stat = UCSR1A; |
rh = UCSR1B; |
rl = UDR1; |
if (stat & ((1 << FE1) | (1 << DOR1) | (1 << UPE1))) |
{ // discard buffer and start new on any error |
JetiBufferReady = 0; |
jbp = 0; |
//1234567890123456 |
lcd_printpj_at (0, 3, PSTR(" Communication "), 0); |
lcd_printpj_at (0, 4, PSTR(" Error "), 0); |
LED6_TOGGLE; |
} |
else if ((rh & (1 << RXB81)) == 0) |
{ // control |
if (rl == 0xfe) |
{ // start condition |
JetiBufferReady = 0; |
jbp = 0; |
LED1_ON; |
} |
else if (rl == 0xff) |
{ // stop condition |
JetiBufferReady = 1; |
LED1_OFF; |
} |
} |
else |
{ // data |
if (jbp < 32) |
{ |
JetiBuffer[jbp++] = rl; |
} |
} |
} |
//***************************************************************************** |
// |
void JETI_Init (void) |
{ |
DDRD &= ~(1 << DDD3); // set TXD1 pin as input |
PORTD &= ~(1 << PORTD3); // disable pullup on TXD1 pin |
// set clock divider |
#undef BAUD |
#define BAUD 9600 |
#include <util/setbaud.h> |
UBRR1H = UBRRH_VALUE; |
UBRR1L = UBRRL_VALUE; |
#if USE_2X |
UCSR1A |= (1 << U2X1); // enable double speed operation |
#else |
UCSR1A &= ~(1 << U2X1); // disable double speed operation |
#endif |
// set 9O1 |
UCSR1C = (1 << UPM11) | (1 << UPM10) | (1 << UCSZ11) | (1 << UCSZ10); |
UCSR1B = (1 << UCSZ12); |
// flush receive buffer |
while ( UCSR1A & (1 << RXC1) ) UDR1; |
} |
//***************************************************************************** |
// disable the txd pin of usart |
void JETI_DisableTXD (void) |
{ |
UCSR1B &= ~(1 << TXEN1); // disable TX} |
} |
//***************************************************************************** |
// enable the txd pin of usart |
void JETI_EnableTXD (void) |
{ |
UCSR1B |= (1 << TXEN1); // enable TX |
} |
//***************************************************************************** |
// |
void JETI_putw (uint16_t c) |
{ |
loop_until_bit_is_set(UCSR1A, UDRE1); |
UCSR1B &= ~(1 << TXB81); |
if (c & 0x0100) |
{ |
UCSR1B |= (1 << TXB81); |
} |
UDR1 = c; |
} |
//***************************************************************************** |
// |
void JETI_putc (uint8_t c) |
{ |
loop_until_bit_is_set(UCSR1A, UDRE1); |
// UCSRB &= ~(1 << TXB8); |
UCSR1B |= (1 << TXB81); |
UDR1 = c; |
} |
//***************************************************************************** |
// |
void JETI_puts (char *s) |
{ |
while (*s) |
{ |
JETI_putc (*s); |
s++; |
} |
} |
//***************************************************************************** |
// |
void JETI_puts_p (const char *s) |
{ |
while (pgm_read_byte(s)) |
{ |
JETI_putc (pgm_read_byte(s)); |
s++; |
} |
} |
//***************************************************************************** |
// |
void JETI_put_start (void) |
{ |
loop_until_bit_is_set(UCSR1A, UDRE1); |
UCSR1B &= ~(1 << TXB81); |
UDR1 = 0xFE; |
} |
//***************************************************************************** |
// |
void JETI_put_stop (void) |
{ |
loop_until_bit_is_set(UCSR1A, UDRE1); |
UCSR1B &= ~(1 << TXB81); |
UDR1 = 0xFF; |
} |
//***************************************************************************** |
// |
void jeti (void) |
{ |
uint8_t key; |
uint8_t i; |
// enable Rx |
UCSR1B |= (1 << RXEN1); |
UCSR1B |= (1 << RXCIE1); |
lcd_cls (); |
lcd_printp_at (0, 0, PSTR("Jeti Box Display"), 0); |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b \x1c \x1d"), 0); |
#ifdef font8x8 |
lcd_line(0, 21, 127, 21, 1); |
lcd_line(0, 22, 127, 22, 1); |
lcd_line(0, 40, 127, 40, 1); |
lcd_line(0, 41, 127, 41, 1); |
#else |
lcd_rect(10, 22, 98, 18, 1); |
#endif |
do |
{ |
if (JetiBufferReady) |
{ |
JETI_EnableTXD(); |
LED2_ON; |
for (i = 0; i < 16; i++) |
{ |
#ifdef font8x8 |
lcd_putc_jeti(i, 3, JetiBuffer[i], 0); |
#else |
lcd_putc (2 + i, 3, JetiBuffer[i], 0); |
#endif |
} |
for (i = 0; i < 16; i++) |
{ |
#ifdef font8x8 |
lcd_putc_jeti(i, 4, JetiBuffer[i + 16], 0); |
#else |
lcd_putc (2 + i, 4, JetiBuffer[i + 16], 0); |
#endif |
} |
JetiBufferReady = 0; // invalidate buffer |
LED2_OFF; |
_delay_ms (1); // |
// Writing to the display takes aprox. 5.8 ms @ 7 MHz and 3.2 ms @ 20 MHz. |
// With the additional 4 ms we had a 10 ms delay. |
// 10 ms works perfect with the MUI30 and the MT125 |
// But not with the TU transceiver module. |
key = get_key_short ((1 << KEY_MINUS) | (1 << KEY_PLUS) | (1 << KEY_ESC) | (1 << KEY_ENTER)); |
key = (key << 1) | (key >> 3); |
key = (~key) & 0xf0; |
JETI_putw((uint16_t) key); |
_delay_ms (1); |
JETI_DisableTXD(); |
} |
} |
while (!get_key_long (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
// disable Rx |
UCSR1B &= ~(1 << RXCIE1); |
UCSR1B &= ~(1 << RXEN1); |
} |
/Transportables_Koptertool/trunk/jeti.h |
---|
0,0 → 1,40 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* see this fine thread on RCLine: * |
* http://www.rclineforum.de/forum/thread.php?threadid=226786 * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _JETI_H |
#define _JETI_H |
//***************************************************************************** |
// |
void JETI_Init (void); |
void JETI_DisableTXD (void); |
void JETI_EnableTXD (void); |
void JETI_putw (uint16_t c); |
void JETI_putc (uint8_t c); |
void JETI_puts (char *s); |
void JETI_puts_p (const char *s); |
void JETI_put_start (void); |
void JETI_put_stop (void); |
void jeti (void); |
#endif |
/Transportables_Koptertool/trunk/lcd.c |
---|
0,0 → 1,1158 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <stdlib.h> |
#include <string.h> |
#include <math.h> |
#include "font8x6.h" |
#ifndef USE_MMT |
#include "font8x8.h" |
#endif |
#include "main.h" |
#include "lcd.h" |
#define DISP_W 128 |
#define DISP_H 64 |
#define DISP_BUFFER ((DISP_H * DISP_W) / 8) |
volatile uint8_t display_buffer[DISP_BUFFER]; // Display-Puffer, weil nicht zurückgelesen werden kann |
volatile uint16_t display_buffer_pointer; // Pointer auf das aktuell übertragene Byte |
volatile uint8_t display_buffer_counter; // Hilfszähler zur Selektierung der Page |
volatile uint8_t display_page_counter; // aktuelle Page-Nummer |
volatile uint8_t display_mode; // Modus für State-Machine |
volatile uint8_t LCD_ORIENTATION; |
// DOG: 128 x 64 with 6x8 Font => 21 x 8 |
// MAX7456: 30 x 16 |
uint8_t lcd_xpos; |
uint8_t lcd_ypos; |
void send_byte (uint8_t data) |
{ |
clr_cs (); |
SPDR = data; |
while (!(SPSR & (1<<SPIF))); |
//SPSR = SPSR; |
set_cs (); |
} |
void lcd_cls (void) |
{ |
uint16_t i, j; |
// memset (display_buffer, 0, 1024); |
for (i = 0; i < DISP_BUFFER; i++) |
display_buffer[i] = 0x00; |
for (i = 0; i < 8; i++) |
{ |
clr_A0 (); |
send_byte (0xB0 + i); //1011xxxx |
send_byte (0x10); //00010000 |
// send_byte(0x04); //00000100 gedreht plus 4 Byte |
// send_byte(0x00); //00000000 |
send_byte (LCD_ORIENTATION); //00000000 |
set_A0 (); |
for (j = 0; j < 128; j++) |
send_byte (0x00); |
} |
lcd_xpos = 0; |
lcd_ypos = 0; |
} |
void wait_1ms (void) |
{ |
_delay_ms (1.0); |
} |
void wait_ms (uint16_t time) |
{ |
uint16_t i; |
for (i = 0; i < time; i++) |
wait_1ms (); |
} |
void LCD_Init (void) |
{ |
lcd_xpos = 0; |
lcd_ypos = 0; |
DDRB = 0xFF; |
// SPI max. speed |
// the DOGM128 lcd controller can work at 20 MHz |
SPCR = (1 << SPE) | (1 << MSTR) | (1 << CPHA) | (1 << CPOL); |
SPSR = (1 << SPI2X); |
set_cs (); |
clr_reset (); |
wait_ms (10); |
set_reset (); |
clr_cs (); |
clr_A0 (); |
send_byte (0x40); |
if (LCD_ORIENTATION == 0) |
{ |
send_byte (0xA1); // A1 normal A0 reverse(original) |
send_byte (0xC0); // C0 normal C8 reverse(original) |
} |
else |
{ |
send_byte (0xA0); // A1 normal A0 reverse(original) |
send_byte (0xC8); // C0 normal C8 reverse(original) |
} |
send_byte (0xA6); |
send_byte (0xA2); |
send_byte (0x2F); |
send_byte (0xF8); |
send_byte (0x00); |
send_byte (0x27); |
send_byte (0x81); |
send_byte (0x16); |
send_byte (0xAC); |
send_byte (0x00); |
send_byte (0xAF); |
lcd_cls (); |
} |
void set_adress (uint16_t adress, uint8_t data) |
{ |
uint8_t page; |
uint8_t column; |
page = adress >> 7; |
clr_A0 (); |
send_byte (0xB0 + page); |
// column = (adress & 0x7F) + 4; Wenn gedreht |
// column = (adress & 0x7F); |
column = (adress & 0x7F) + LCD_ORIENTATION; |
send_byte (0x10 + (column >> 4)); |
send_byte (column & 0x0F); |
set_A0 (); |
send_byte (data); |
} |
void scroll (void) |
{ |
uint16_t adress; |
for (adress = 0; adress < 896; adress++) |
{ |
display_buffer[adress] = display_buffer[adress + 128]; |
set_adress (adress, display_buffer[adress]); |
} |
for (adress = 896; adress < 1024; adress++) |
{ |
display_buffer[adress] = 0; |
set_adress (adress, 0); |
} |
} |
// |
// x,y = character-Pos. ! |
// |
// mode: 0=Overwrite, 1 = OR, 2 = XOR, 3 = AND, 4 = Delete |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
switch (c) |
{ // ISO 8859-1 |
case 0xc4: // Ä |
c = 0x00; |
break; |
case 0xe4: // ä |
c = 0x01; |
break; |
case 0xd6: // Ö |
c = 0x02; |
break; |
case 0xf6: // ö |
c = 0x03; |
break; |
case 0xdc: // Ü |
c = 0x04; |
break; |
case 0xfc: // ü |
c = 0x05; |
break; |
case 0xdf: // ß |
//c = 0x06; |
c = 0x1e; // ° (used by Jeti) |
break; |
} |
c &= 0x7f; |
adress = y * 128 + x * 6; |
adress &= 0x3FF; |
for (i = 0; i < 6; i++) |
{ |
ch = pgm_read_byte (&font8x6[0][0] + i + c * 6); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
#ifndef USE_MMT |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode) |
{ |
uint8_t ch; |
uint8_t i; |
uint16_t adress; |
switch (c) |
{ |
case 0x7e: |
c = 0x1a; // -> |
break; |
case 0x7f: |
c = 0x1b; // <- |
break; |
case 0xdf: |
c = 0xf8; // ° |
break; |
} |
adress = y * 128 + x * 8; |
adress &= 0x3FF; |
for (i = 0; i < 8; i++) |
{ |
ch = pgm_read_byte (&font8x8[0][0] + i + c * 8); |
switch (mode) |
{ |
case 0: |
display_buffer[adress+i] = ch; |
break; |
case 1: |
display_buffer[adress+i] |= ch; |
break; |
case 2: |
display_buffer[adress+i] ^= ch; |
break; |
case 3: |
display_buffer[adress+i] &= ch; |
break; |
case 4: |
display_buffer[adress+i] &= ~ch; |
break; |
} |
set_adress (adress + i, display_buffer[adress + i]); |
} |
} |
#endif |
void new_line (void) |
{ |
lcd_ypos++; |
if (lcd_ypos > 7) |
{ |
scroll (); |
lcd_ypos = 7; |
} |
} |
#ifndef USE_MMT |
void lcd_printpj (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc_jeti (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpj (text, mode); |
} |
#endif |
void lcd_printpns (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
// new_line (); |
} |
break; |
} |
text++; |
} |
} |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printpns (text, mode); |
} |
void lcd_printp (const char *text, uint8_t mode) |
{ |
while (pgm_read_byte(text)) |
{ |
switch (pgm_read_byte(text)) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, pgm_read_byte(text), mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_printp (text, mode); |
} |
void lcd_print (uint8_t *text, uint8_t mode) |
{ |
while (*text) |
{ |
switch (*text) |
{ |
case 0x0D: |
lcd_xpos = 0; |
break; |
case 0x0A: |
new_line(); |
break; |
default: |
lcd_putc (lcd_xpos, lcd_ypos, *text, mode); |
lcd_xpos++; |
if (lcd_xpos > 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
break; |
} |
text++; |
} |
} |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_print (text, mode); |
} |
void print_display (uint8_t *text) |
{ |
while (*text) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, *text, 0); |
lcd_xpos++; |
if (lcd_xpos >= 20) |
{ |
lcd_xpos = 0; |
new_line (); |
} |
text++; |
} |
} |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
print_display (text); |
} |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Plot (set one Pixel) |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// mode: |
// 0=Clear, 1=Set, 2=XOR |
void lcd_plot (uint8_t xpos, uint8_t ypos, uint8_t mode) |
{ |
uint16_t adress; |
uint8_t mask; |
if ((xpos < DISP_W) && (ypos < DISP_H)) |
{ |
adress = (ypos / 8) * DISP_W + xpos; // adress = 0/8 * 128 + 0 = 0 |
mask = 1 << (ypos & 0x07); // mask = 1<<0 = 1 |
adress &= DISP_BUFFER - 1; |
switch (mode) |
{ |
case 0: |
display_buffer[adress] &= ~mask; |
break; |
case 1: |
display_buffer[adress] |= mask; |
break; |
case 2: |
display_buffer[adress] ^= mask; |
break; |
} |
set_adress (adress, display_buffer[adress]); |
} |
} |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Line (draws a line from x1,y1 to x2,y2 |
// + Based on Bresenham line-Algorithm |
// + found in the internet, modified by thkais 2007 |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode) |
{ |
int x, y, count, xs, ys, xm, ym; |
x = (int) x1; |
y = (int) y1; |
xs = (int) x2 - (int) x1; |
ys = (int) y2 - (int) y1; |
if (xs < 0) |
xm = -1; |
else |
if (xs > 0) |
xm = 1; |
else |
xm = 0; |
if (ys < 0) |
ym = -1; |
else |
if (ys > 0) |
ym = 1; |
else |
ym = 0; |
if (xs < 0) |
xs = -xs; |
if (ys < 0) |
ys = -ys; |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
if (xs > ys) // Flat Line <45 degrees |
{ |
count = -(xs / 2); |
while (x != x2) |
{ |
count = count + ys; |
x = x + xm; |
if (count > 0) |
{ |
y = y + ym; |
count = count - xs; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
else // Line >=45 degrees |
{ |
count =- (ys / 2); |
while (y != y2) |
{ |
count = count + xs; |
y = y + ym; |
if (count > 0) |
{ |
x = x + xm; |
count = count - ys; |
} |
lcd_plot ((unsigned char) x, (unsigned char) y, mode); |
} |
} |
} |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Filled rectangle |
// + x1, y1 = upper left corner |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
uint16_t i; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
for (i = y1; i <= y2; i++) |
{ |
lcd_line (x1, i, x2, i, mode); |
} |
} |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + outline of rectangle |
// + x1, y1 = upper left corner |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode) |
{ |
uint16_t x2, y2; |
if (x1 >= DISP_W) |
x1 = DISP_W - 1; |
if (y1 >= DISP_H) |
y1 = DISP_H - 1; |
x2 = x1 + widthx; |
y2 = y1 + widthy; |
if (x2 > DISP_W) |
x2 = DISP_W; |
if (y2 > DISP_H) |
y2 = DISP_H; |
lcd_line (x1, y1, x2, y1, mode); |
lcd_line (x2, y1, x2, y2, mode); |
lcd_line (x2, y2, x1, y2, mode); |
lcd_line (x1, y2, x1, y1, mode); |
} |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + outline of a circle |
// + Based on Bresenham-algorithm found in wikipedia |
// + modified by thkais (2007) |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_plot (x0, y0 + radius, mode); |
lcd_plot (x0, y0 - radius, mode); |
lcd_plot (x0 + radius, y0, mode); |
lcd_plot (x0 - radius, y0, mode); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y --; |
ddF_y += 2; |
f += ddF_y; |
} |
x ++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
lcd_plot (x0 + y, y0 + x, mode); |
lcd_plot (x0 - y, y0 + x, mode); |
lcd_plot (x0 + y, y0 - x, mode); |
lcd_plot (x0 - y, y0 - x, mode); |
} |
} |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + filled Circle |
// + modified circle-algorithm thkais (2007) |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius) |
{ |
int16_t f = 1 - radius; |
int16_t ddF_x = 0; |
int16_t ddF_y = -2 * radius; |
int16_t x = 0; |
int16_t y = radius; |
lcd_line (x0, y0 + radius, x0, y0 - radius, 1); |
lcd_line (x0 + radius, y0, x0 - radius, y0, 1); |
while (x < y) |
{ |
if (f >= 0) |
{ |
y--; |
ddF_y += 2; |
f += ddF_y; |
} |
x++; |
ddF_x += 2; |
f += ddF_x + 1; |
lcd_line (x0 + x, y0 + y, x0 - x, y0 + y, 1); |
lcd_line (x0 + x, y0 - y, x0 - x, y0 - y, 1); |
lcd_line (x0 + y, y0 + x, x0 - y, y0 + x, 1); |
lcd_line (x0 + y, y0 - x, x0 - y, y0 - x, 1); |
} |
} |
//***************************************************************************** |
// |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) r); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) r); |
lcd_line (x, y, xc, yc, mode); |
} |
//***************************************************************************** |
// |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode) |
{ |
uint8_t xc, yc; |
double deg_rad; |
deg_rad = (deg * M_PI) / 180.0; |
yc = y - (uint8_t) round (cos (deg_rad) * (double) ry); |
xc = x + (uint8_t) round (sin (deg_rad) * (double) rx); |
lcd_line (x, y, xc, yc, mode); |
} |
//***************************************************************************** |
// |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode) |
{ |
const int16_t rx2 = rx * rx; |
const int16_t ry2 = ry * ry; |
int16_t F = round (ry2 - rx2 * ry + 0.25 * rx2); |
int16_t ddF_x = 0; |
int16_t ddF_y = 2 * rx2 * ry; |
int16_t x = 0; |
int16_t y = ry; |
lcd_plot (x0, y0 + ry, mode); |
lcd_plot (x0, y0 - ry, mode); |
lcd_plot (x0 + rx, y0, mode); |
lcd_plot (x0 - rx, y0, mode); |
// while ( 2*ry2*x < 2*rx2*y ) { we can use ddF_x and ddF_y |
while (ddF_x < ddF_y) |
{ |
if(F >= 0) |
{ |
y -= 1; // south |
ddF_y -= 2 * rx2; |
F -= ddF_y; |
} |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x + ry2; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
F = round (ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2); |
while(y > 0) |
{ |
if(F <= 0) |
{ |
x += 1; // east |
ddF_x += 2 * ry2; |
F += ddF_x; |
} |
y -=1; // south |
ddF_y -= 2 * rx2; |
F += rx2 - ddF_y; |
lcd_plot (x0 + x, y0 + y, mode); |
lcd_plot (x0 + x, y0 - y, mode); |
lcd_plot (x0 - x, y0 + y, mode); |
lcd_plot (x0 - x, y0 - y, mode); |
} |
} |
//***************************************************************************** |
// |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode) |
{ |
lcd_ellipse (x0, y0, radius + 3, radius, mode); |
} |
//***************************************************************************** |
// |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode) |
{ |
lcd_ellipse_line(x, y, r + 3, r, deg, mode); |
} |
//***************************************************************************** |
// |
void lcd_view_font (uint8_t page) |
{ |
int x; |
int y; |
lcd_cls (); |
lcd_printp (PSTR(" 0123456789ABCDEF\r\n"), 0); |
// lcd_printpns_at (0, 7, PSTR(" \x16 \x17 Exit"), 0); |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Exit"), 0); |
lcd_ypos = 2; |
for (y = page * 4 ; y < (page * 4 + 4); y++) |
{ |
if (y < 10) |
{ |
lcd_putc (0, lcd_ypos, '0' + y, 0); |
} |
else |
{ |
lcd_putc (0, lcd_ypos, 'A' + y - 10, 0); |
} |
lcd_xpos = 2; |
for (x = 0; x < 16; x++) |
{ |
lcd_putc (lcd_xpos, lcd_ypos, y * 16 + x, 0); |
lcd_xpos++; |
} |
lcd_ypos++; |
} |
} |
uint8_t hdigit (uint8_t d) |
{ |
if (d < 10) |
{ |
return '0' + d; |
} |
else |
{ |
return 'A' + d - 10; |
} |
} |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_putc (lcd_xpos++, lcd_ypos, hdigit (h >> 4), mode); |
lcd_putc (lcd_xpos, lcd_ypos, hdigit (h & 0x0f), mode); |
} |
void lcd_write_number_u (uint8_t number) |
{ |
uint8_t num = 100; |
uint8_t started = 0; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if (b > 0 || started || num == 1) |
{ |
lcd_putc (lcd_xpos++, lcd_ypos, '0' + b, 0); |
started = 1; |
} |
number -= b * num; |
num /= 10; |
} |
} |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number) |
{ |
lcd_xpos = x; |
lcd_ypos = y; |
lcd_write_number_u (number); |
} |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
utoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
lcd_print_at(x, y, s, 0); |
} |
/** |
* Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
lcd_print_at(x, y, s, 0); |
} |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> to MAX7456 display memory |
* as /10th of the value |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
itoa(number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', 0); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', 0); |
lcd_putc (x, y, '0', 0); |
} |
else |
{ |
lcd_print_at(x, y, s, 0); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', 0); |
lcd_putc (x++, y, rest, 0); |
} |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad) |
{ |
uint8_t num = 100; |
while (num > 0) |
{ |
uint8_t b = number / num; |
if ((num / 10) == 1) |
{ |
lcd_putc (x++, y, '.', 0); |
} |
lcd_putc (x++, y, '0' + b, 0); |
number -= b * num; |
num /= 10; |
} |
} |
/** |
* Write only some digits of a signed <number> at <x>/<y> to MAX7456 display memory |
* as /10th of the value |
* <num> represents the largest multiple of 10 that will still be displayable as |
* the first digit, so num = 10 will be 0-99 and so on |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad) |
{ |
char s[7]; |
itoa (number, s, 10 ); |
uint8_t len = strlen(s); |
if (length < len) |
{ |
for (uint8_t i = 0; i < length; i++) |
{ |
lcd_putc (x++, y, '*', 0); |
} |
return; |
} |
for (uint8_t i = 0; i < length - len; i++) |
{ |
if (pad) |
{ |
lcd_putc (x++, y, '0', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
} |
char rest = s[len - 1]; |
s[len - 1] = 0; |
if (len == 1) |
{ |
lcd_putc (x-1, y, '0', 0); |
} |
else if (len == 2 && s[0] == '-') |
{ |
lcd_putc (x-1, y, '-', 0); |
lcd_putc (x, y, '0', 0); |
} |
else |
{ |
lcd_print_at(x, y, s, 0); |
} |
x += len - 1; |
lcd_putc (x++, y, '.', 0); |
lcd_putc (x++, y, rest, 0); |
} |
/** |
* write <seconds> as human readable time at <x>/<y> to MAX7456 display mem |
*/ |
void write_time (uint8_t x, uint8_t y, uint16_t seconds) |
{ |
uint16_t min = seconds / 60; |
seconds -= min * 60; |
write_ndigit_number_u (x, y, min, 2, 0); |
lcd_putc (x + 2, y, ':', 0); |
write_ndigit_number_u (x + 3, y, seconds, 2, 1); |
} |
/** |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position) |
{ |
if (position < 0) |
{ |
position ^= ~0; |
position++; |
lcd_putc (x++, y, '-', 0); |
} |
else |
{ |
lcd_putc (x++, y, ' ', 0); |
} |
write_ndigit_number_u (x, y, (uint16_t) (position / (int32_t) 10000000), 3, 1); |
lcd_putc (x + 3, y, '.', 0); |
position = position - ((position / (int32_t) 10000000) * (int32_t) 10000000); |
write_ndigit_number_u (x + 4, y, (uint16_t) (position / (int32_t) 1000), 4, 1); |
position = position - ((uint16_t) (position / (int32_t) 1000) * (int32_t) 1000); |
write_ndigit_number_u (x + 8, y, (uint16_t) position, 3, 1); |
lcd_putc (x + 11, y, 0x1e, 0); // degree symbol |
} |
/Transportables_Koptertool/trunk/lcd.h |
---|
0,0 → 1,122 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* - original LCD control by Thomas "thkais" Kaiser * |
* - special number formating routines taken from C-OSD * |
* from Claas Anders "CaScAdE" Rathje * |
* - some extension, ellipse and circ_line by Peter "woggle" Mack * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _LCD_H |
#define _LCD_H |
//***************************************************************************** |
// |
extern volatile uint8_t LCD_ORIENTATION; |
extern uint8_t lcd_xpos; |
extern uint8_t lcd_ypos; |
//***************************************************************************** |
// |
void LCD_Init (void); |
void lcd_putc (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
//void send_byte (uint8_t data); |
void lcd_print (uint8_t *text, uint8_t mode); |
void lcd_print_at (uint8_t x, uint8_t y, uint8_t *text, uint8_t mode); |
void lcd_printp (const char *text, uint8_t mode); |
void lcd_printp_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_printpns (const char *text, uint8_t mode); |
void lcd_printpns_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_cls (void); |
void print_display (uint8_t *text); |
void print_display_at (uint8_t x, uint8_t y, uint8_t *text); |
// Jeti |
void lcd_putc_jeti (uint8_t x, uint8_t y, uint8_t c, uint8_t mode); |
void lcd_printpj (const char *text, uint8_t mode); |
void lcd_printpj_at (uint8_t x, uint8_t y, const char *text, uint8_t mode); |
void lcd_plot (uint8_t x, uint8_t y, uint8_t mode); |
void lcd_line (unsigned char x1, unsigned char y1, unsigned char x2, unsigned char y2, uint8_t mode); |
void lcd_rect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_frect (uint8_t x1, uint8_t y1, uint8_t widthx, uint8_t widthy, uint8_t mode); |
void lcd_circle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_fcircle (int16_t x0, int16_t y0, int16_t radius); |
void lcd_circ_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_ellipse (int16_t x0, int16_t y0, int16_t rx, int16_t ry, uint8_t mode); |
void lcd_ellipse_line (uint8_t x, uint8_t y, uint8_t rx, uint8_t ry, uint16_t deg, uint8_t mode); |
void lcd_ecircle (int16_t x0, int16_t y0, int16_t radius, uint8_t mode); |
void lcd_ecirc_line (uint8_t x, uint8_t y, uint8_t r, uint16_t deg, uint8_t mode); |
void lcd_view_font (uint8_t page); |
void lcd_print_hex_at (uint8_t x, uint8_t y, uint8_t h, uint8_t mode); |
void lcd_write_number_u (uint8_t number); |
void lcd_write_number_u_at (uint8_t x, uint8_t y, uint8_t number); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_u (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 007 instead of 7 |
*/ |
void write_ndigit_number_s (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_10th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a unsigned <number> at <x>/<y> as /100th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_u_100th (uint8_t x, uint8_t y, uint16_t number, int16_t length, uint8_t pad); |
/** |
* Write only some digits of a signed <number> at <x>/<y> as /10th of the value |
* <length> represents the length to rightbound the number |
* <pad> = 1 will cause blank spaced to be filled up with zeros e.g. 00.7 instead of .7 |
*/ |
void write_ndigit_number_s_10th (uint8_t x, uint8_t y, int16_t number, int16_t length, uint8_t pad); |
/** |
* write <seconds> as human readable time at <x>/<y> |
*/ |
void write_time (uint8_t x, uint8_t y, uint16_t seconds); |
/** |
* wirte a <position> at <x>/<y> assuming it is a gps position for long-/latitude |
*/ |
void write_gps_pos (uint8_t x, uint8_t y, int32_t position); |
#endif |
/Transportables_Koptertool/trunk/lipo.c |
---|
0,0 → 1,105 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include "main.h" // LEDs |
#include "timer.h" // Keys |
#include "lcd.h" |
#include "lipo.h" |
volatile uint8_t AD_Ready = 0; |
volatile uint8_t AD_Channel = 0; |
volatile uint16_t AD_Val[4]; |
volatile uint8_t AD_WarnLevel; |
volatile uint8_t AD_Warn = 0; |
//***************************************************************************** |
// |
ISR(ADC_vect) |
{ |
// LED1_TOGGLE; |
AD_Val[AD_Channel] = ADC; |
if (AD_Val[AD_Channel] <= (AD_WarnLevel * 20)) |
{ |
AD_Warn |= (1 << AD_Channel); |
} |
AD_Channel++; |
AD_Channel &= 0x03; |
ADMUX = (ADMUX & 0xe0) | AD_Channel; |
if (AD_Channel) |
{ |
ADCSRA |= (1 << ADSC); |
} |
else |
{ |
AD_Ready = 1; |
} |
} |
//***************************************************************************** |
// |
void ADC_Init(void) |
{ |
DIDR0 = 0x0f; // disable digital inputs on PA0-3 |
ADMUX = (1 << REFS1) | (1 << REFS0); // internal 2.56 V ref. |
ADCSRB = 0; // free running mode |
// enable ADC, start conversion, auto trigger, enable interrupt, prescaler = 128 |
ADCSRA = (1 << ADEN) | (1 << ADSC) | (0 << ADATE) | (1 << ADIE) | (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); |
} |
//***************************************************************************** |
// |
void lipo (void) |
{ |
uint8_t i; |
lcd_cls (); |
lcd_printp_at (0, 0, PSTR("LiPo Display"), 0); |
lcd_printpns_at (0, 7, PSTR(" Exit"), 0); |
lcd_printp_at (0, 2, PSTR("Cell 1:"), 0); |
lcd_printp_at (0, 3, PSTR("Cell 2:"), 0); |
lcd_printp_at (0, 4, PSTR("Cell 3:"), 0); |
lcd_printp_at (0, 5, PSTR("Cell 4:"), 0); |
do |
{ |
if (AD_Ready) |
{ |
for (i = 0; i < 4; i++) |
{ |
//write_ndigit_number_u (0, 2 + i, AD_Val[i], 4, 0); |
//write_ndigit_number_u_10th (6, 2 + i, AD_Val[i] >> 1, 3, 0); |
write_ndigit_number_u_100th (10, 2 + i, AD_Val[i] >> 1, 10, 0); |
} |
AD_Ready = 0; |
ADCSRA |= (1 << ADSC); |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
/Transportables_Koptertool/trunk/lipo.h |
---|
0,0 → 1,34 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _LIPO_H |
#define _LIPO_H |
//***************************************************************************** |
// |
extern volatile uint16_t AD_Val[4]; |
extern volatile uint8_t AD_WarnLevel; |
extern volatile uint8_t AD_Warn; |
//***************************************************************************** |
// |
void ADC_Init(void); |
void lipo (void); |
#endif |
/Transportables_Koptertool/trunk/main.c |
---|
0,0 → 1,172 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009-2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
*****************************************************************************/ |
#include <inttypes.h> |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/eeprom.h> |
#include <util/delay.h> |
#include "main.h" |
#include "lcd.h" |
#include "usart.h" |
#include "parameter.h" |
#include "menu.h" |
#include "display.h" |
#include "timer.h" |
#include "jeti.h" |
#include "lipo.h" |
#include "eeprom.h" |
#include "mk-data-structs.h" |
#ifndef USE_MMT |
#define LEDS // my development board has some status LEDs |
#endif |
//#define MTEST // Menu Test (skip FC/NC detection) |
Version_t *version; |
volatile uint8_t mode = 0; |
uint8_t hardware = 0; |
uint8_t current_hardware = 0; |
int main (void) |
{ |
uint8_t timeout; |
PORTA = 0xF0; |
PORTB = 0x43; |
#if defined (__AVR_ATmega32__) |
PORTC = 0xFC; |
#else |
PORTC = 0xFF; |
#endif |
PORTD = 0x70; |
#ifdef LEDS |
DDRC = 0x1C; |
DDRD = 0xF0; |
#else |
#if defined (__AVR_ATmega32__) |
DDRC = 0x03; |
#endif |
DDRD = 0x80; |
#endif |
ReadParameter (); |
LCD_Init (); |
USART_Init (); |
TIMER0_Init (); |
#ifndef USE_MMT |
JETI_Init(); |
ADC_Init(); |
#endif |
sei (); |
#ifndef MTEST |
lcd_cls (); |
#ifdef USE_MMT |
lcd_printp (PSTR("Portable Kopter Tool\r\n"), 0); |
#else |
lcd_printp (PSTR("MK Multi Box\r\n"), 0); |
#endif |
lcd_printp (PSTR("checking hardware..."), 0); |
// switch to NC |
USART_putc (0x1b); |
USART_putc (0x1b); |
USART_putc (0x55); |
USART_putc (0xaa); |
USART_putc (0x00); |
mode = 'V'; |
timeout = 50; |
while (!rxd_buffer_locked && timeout) |
{ |
SendOutData('v', ADDRESS_ANY, 0); |
timer = 20; |
while (timer > 0); |
timeout--; |
} |
if (timeout != 0) |
{ |
Decode64 (); |
version = (Version_t *) pRxData; |
lcd_cls (); |
#ifdef USE_MMT |
lcd_printp (PSTR("Portable Kopter Tool\r\n"), 0); |
#else |
lcd_printp (PSTR("MK Multi Box\r\n"), 0); |
#endif |
lcd_printp (PSTR("found:\r\n\n"), 0); |
if ((rxd_buffer[1] - 'a') == ADDRESS_FC) |
{ |
lcd_printp (PSTR("Flight-Ctrl\r\n"), 0); |
hardware = FC; |
current_hardware = hardware; |
} |
else if ((rxd_buffer[1] - 'a') == ADDRESS_NC) |
{ |
lcd_printp (PSTR("Navi-Ctrl\r\n"), 0); |
hardware = NC; |
current_hardware = hardware; |
} |
lcd_printp (PSTR("Version: "), 0); |
lcd_write_number_u (version->SWMajor); |
lcd_printp (PSTR("."), 0); |
lcd_write_number_u (version->SWMinor); |
lcd_putc (lcd_xpos, lcd_ypos, version->SWPatch + 'a', 0); |
} |
else |
{ // timeout occured |
lcd_printp (PSTR("\r\n\nERROR: no data"), 0); |
} |
mode = 0; |
rxd_buffer_locked = FALSE; |
timer = 200; |
while (timer > 0); |
#endif |
for (;;) |
{ |
main_menu (); |
} |
} |
/Transportables_Koptertool/trunk/main.h |
---|
0,0 → 1,84 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
* * |
* Credits to: * |
* Holger Buss & Ingo Busker from mikrokopter.de for the MK project + SVN * |
* http://www.mikrokopter.de * |
* Gregor "killagreg" Stobrawa for his version of the MK code * |
* Thomas Kaiser "thkais" for the original project. See * |
* http://www.ft-fanpage.de/mikrokopter/ * |
* http://forum.mikrokopter.de/topic-4061-1.html * |
* Claas Anders "CaScAdE" Rathje for providing the font and his C-OSD code * |
* http://www.mylifesucks.de/oss/c-osd/ * |
*****************************************************************************/ |
#ifndef _MAIN_H |
#define _MAIN_H |
//***************************************************************************** |
// |
#define set_cs() (PORTB |= (1 << PB4)) |
#define clr_cs() (PORTB &= ~(1 << PB4)) |
#define set_reset() (PORTB |= (1 << PB2)) |
#define clr_reset() (PORTB &= ~(1 << PB2)) |
#define set_A0() (PORTB |= (1 << PB3)) // Data |
#define clr_A0() (PORTB &= ~(1 << PB3)) // Command |
#define set_scl() (PORTB |= (1 << PB7)) |
#define clr_scl() (PORTB &= ~(1 << PB7)) |
#define set_si() (PORTB |= (1 << PB5)) |
#define clr_si() (PORTB &= ~(1 << PB5)) |
#define LED1_OFF PORTC |= (1 << PC3) |
#define LED1_ON PORTC &= ~(1 << PC3) |
#define LED1_TOGGLE PORTC ^= (1 << PC3) |
#define LED2_OFF PORTD |= (1 << PD4) |
#define LED2_ON PORTD &= ~(1 << PD4) |
#define LED2_TOGGLE PORTD ^= (1 << PD4) |
#define LED3_OFF PORTD |= (1 << PD5) |
#define LED3_ON PORTD &= ~(1 << PD5) |
#define LED3_TOGGLE PORTD ^= (1 << PD5) |
#define LED4_OFF PORTD |= (1 << PD6) |
#define LED4_ON PORTD &= ~(1 << PD6) |
#define LED4_TOGGLE PORTD ^= (1 << PD6) |
#define LED5_OFF PORTC |= (1 << PC4) |
#define LED5_ON PORTC &= ~(1 << PC4) |
#define LED5_TOGGLE PORTC ^= (1 << PC4) |
#define LED6_OFF PORTC |= (1 << PC2) |
#define LED6_ON PORTC &= ~(1 << PC2) |
#define LED6_TOGGLE PORTC ^= (1 << PC2) |
#define LED_ALL_OFF {LED1_OFF; LED2_OFF; LED3_OFF; LED4_OFF; LED5_OFF; LED6_OFF;} |
#define NC 1 |
#define FC 2 |
#define MK3MAG 3 |
#define MKGPS 4 |
//***************************************************************************** |
// |
extern volatile uint8_t mode; |
extern uint8_t hardware; |
extern uint8_t current_hardware; |
#endif |
/Transportables_Koptertool/trunk/menu.c |
---|
0,0 → 1,265 |
/***************************************************************************** |
* Copyright (C) 2009-2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include "main.h" |
#include "lcd.h" |
#include "parameter.h" |
#include "menu.h" |
#include "display.h" |
#include "motortest.h" |
#include "debug.h" |
#include "settings.h" |
#include "timer.h" |
#include "osd.h" |
#include "jeti.h" |
#include "servo.h" |
#include "lipo.h" |
#include "status.h" |
void utils (void); |
void sett (void); |
//***************************************************************************** |
// Main Menu |
const char mm_item_0[] PROGMEM = "Navi Data"; |
const char mm_item_1[] PROGMEM = "Display"; |
const char mm_item_2[] PROGMEM = "Parameters"; |
const char mm_item_3[] PROGMEM = "Debug Data"; |
#ifndef USE_MMT |
const char mm_item_4[] PROGMEM = "Jeti"; |
#endif |
const char mm_item_5[] PROGMEM = "Utilities..."; |
const struct menu menu_main[] PROGMEM = { |
{mm_item_0, osd}, |
{mm_item_1, display_data}, |
{mm_item_2, edit_parameter}, |
{mm_item_3, display_debug}, |
#ifndef USE_MMT |
{mm_item_4, jeti}, |
#endif |
{mm_item_5, utils}, // sub menu |
}; |
#define N_MAIN (sizeof menu_main / sizeof menu_main[0]) |
//***************************************************************************** |
// Utilities Menu |
const char mu_item_0[] PROGMEM = "Motor Test"; |
const char mu_item_1[] PROGMEM = "I2C Motor Test"; |
#ifndef USE_MMT |
const char mu_item_2[] PROGMEM = "Servo Tester"; |
const char mu_item_3[] PROGMEM = "LiPo Status"; |
#endif |
const char mu_item_4[] PROGMEM = "Status"; |
const char mu_item_5[] PROGMEM = "Settings..."; |
const struct menu menu_util[] PROGMEM = { |
{mu_item_0, motor_test}, |
{mu_item_1, motor_i2c}, |
#ifndef USE_MMT |
{mu_item_2, servo_test}, |
{mu_item_3, lipo}, |
#endif |
{mu_item_4, status}, |
{mu_item_5, sett}, // sub menu |
}; |
#define N_UTIL (sizeof menu_util / sizeof menu_util[0]) |
//***************************************************************************** |
// Settings Menu |
const char ms_item_0[] PROGMEM = "Orientation"; |
#ifndef USE_MMT |
const char ms_item_1[] PROGMEM = "LiPo Warn"; |
#endif |
const char ms_item_2[] PROGMEM = "View Font"; |
const char ms_item_3[] PROGMEM = "Line"; |
const char ms_item_4[] PROGMEM = "Rectangle"; |
const struct menu menu_set[] PROGMEM = { |
{ms_item_0, set_toggledisplay}, |
#ifndef USE_MMT |
{ms_item_1, set_lipo}, |
#endif |
{ms_item_2, set_viewfont}, |
{ms_item_3, set_line}, |
{ms_item_4, set_rect}, |
}; |
#define N_SET (sizeof menu_set / sizeof menu_set[0]) |
#if 0 |
const struct menus PROGMEM = { |
{menu_main, N_MAIN, title_main}, |
{menu_util, N_UTIL, title_util}, |
{menu_set, N_SET, title_set}, |
}; |
#endif |
//***************************************************************************** |
// |
void menu_print (const struct menu m[], uint8_t size) |
{ |
uint8_t i; |
for (i = MENU_LINE; i < MENU_LINE + size; i++) |
{ |
lcd_printp_at (MENU_COL, i, (const char *) pgm_read_word(&(m[i - MENU_LINE].str)), 0); |
} |
lcd_printpns_at (0, 7, PSTR(" \x1a \x1b Back \x0c"), 0); |
} |
//***************************************************************************** |
// |
void utils (void) |
{ |
static uint8_t f = MENU_LINE; |
do |
{ |
lcd_cls (); |
lcd_printp (PSTR("Utilities:"), 0); |
menu_print(menu_util, N_UTIL); |
f = menu_choose (MENU_LINE, N_UTIL, CURSOR_COL, f); |
if (f != 255) |
{ |
((pfunc)(pgm_read_word (&(menu_util[f - MENU_LINE].func))))(); |
} |
} |
while (f != 255); |
f = MENU_LINE; |
} |
//***************************************************************************** |
// |
void sett (void) |
{ |
static uint8_t f = MENU_LINE; |
do |
{ |
lcd_cls (); |
lcd_printp (PSTR("Settings:"), 0); |
menu_print(menu_set, N_SET); |
f = menu_choose (MENU_LINE, N_SET, CURSOR_COL, f); |
if (f != 255) |
{ |
((pfunc)(pgm_read_word (&(menu_set[f - MENU_LINE].func))))(); |
} |
} |
while (f != 255); |
f = MENU_LINE; |
} |
//***************************************************************************** |
// print cursor |
void menu_set_cursor (uint8_t before, uint8_t line, uint8_t pos) |
{ |
lcd_printp_at (pos, before, PSTR(" "), 0); |
lcd_printp_at (pos, line, PSTR("\x1D"), 0); |
} |
//***************************************************************************** |
// |
uint8_t menu_choose (uint8_t min, uint8_t max, uint8_t pos, uint8_t start) |
{ |
uint8_t line = start; |
uint8_t before = start; |
uint8_t k; |
menu_set_cursor (line, line, pos); |
do |
{ |
if (get_key_press (1 << KEY_PLUS)) |
{ |
if (line < max) |
{ |
line ++; |
} |
else |
{ |
line = min; |
} |
} |
if (get_key_press (1 << KEY_MINUS)) |
{ |
if (line > min) |
{ |
line --; |
} |
else |
{ |
line = max; |
} |
} |
if (line != before) |
{ |
menu_set_cursor (before, line, pos); |
before = line; |
} |
} |
while (!(k = get_key_press ((1 << KEY_ENTER) | (1 << KEY_ESC)))); |
if (k & (1 << KEY_ESC)) |
{ |
line = 255; |
} |
return line; |
} |
//***************************************************************************** |
// |
void main_menu (void) |
{ |
static uint8_t f = MENU_LINE; |
lcd_cls (); |
//lcd_printp (PSTR("Portable Kopter Tool"), 0); |
lcd_printp (PSTR("MK Multi Box"), 0); |
menu_print(menu_main, N_MAIN); |
f = menu_choose (MENU_LINE, N_MAIN, CURSOR_COL, f); |
if (f != 255) |
{ |
((pfunc)(pgm_read_word (&(menu_main[f - MENU_LINE].func))))(); |
} |
else |
{ |
f = MENU_LINE; |
} |
} |
/Transportables_Koptertool/trunk/menu.h |
---|
0,0 → 1,43 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _MENU_H |
#define _MENU_H |
//***************************************************************************** |
// |
#define CURSOR_COL 1 // column where the menu cursor is displayed |
#define MENU_LINE 1 // starting line of menu |
#define MENU_COL 3 // column where the menu starts |
//***************************************************************************** |
// |
typedef void(*pfunc)(void); |
struct menu { |
const char *str; |
pfunc func; |
}; |
//***************************************************************************** |
// |
void main_menu (void); |
uint8_t menu_choose (uint8_t min, uint8_t max, uint8_t pos, uint8_t start); |
#endif |
/Transportables_Koptertool/trunk/mk-data-structs.h |
---|
0,0 → 1,390 |
/**************************************************************************** |
* Copyright (C) 2009 by Claas Anders "CaScAdE" Rathje * |
* admiralcascade@gmail.com * |
* Project-URL: http://www.mylifesucks.de/oss/c-osd/ * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
****************************************************************************/ |
/* ########################################################################## |
* gain some fake arm compat :) |
* ##########################################################################*/ |
#define u8 uint8_t |
#define s8 int8_t |
#define u16 uint16_t |
#define s16 int16_t |
#define u32 uint32_t |
#define s32 int32_t |
//***************************************************************************** |
// |
#define NUMBER_OF_DEBUG_DATAS 32 |
#define ANALOG_NAME_LENGTH 16 |
// Version of supported serial protocol |
#define MIN_VERSION 7 |
#define MAX_VERSION 10 |
// Setting index |
#define SETTING_1 1 |
#define SETTING_2 2 |
#define SETTING_3 3 |
#define SETTING_4 4 |
#define SETTING_5 5 |
#define SETTING_CURRENT 0xff |
typedef struct |
{ |
unsigned char SWMajor; |
unsigned char SWMinor; |
unsigned char ProtoMajor; |
unsigned char ProtoMinor; |
unsigned char SWPatch; |
unsigned char Reserved[5]; |
} __attribute__((packed)) Version_t; |
/* |
* FC Debug Struct |
* portions taken and adapted from |
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.h |
*/ |
typedef struct { |
uint8_t Digital[2]; |
// NC: unsigned; FC: signed !!!! |
int16_t Analog[32]; // Debugvalues |
} __attribute__((packed)) DebugData_t; |
typedef struct { |
uint8_t line; |
uint8_t text[20]; |
} __attribute__((packed)) Display_t; |
typedef struct |
{ |
char Revision; |
char Name[12]; |
signed char Motor[16][4]; |
} __attribute__((packed)) Mixer_t; |
/* |
* NaviCtrl OSD Structs |
* portions taken and adapted from |
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h |
*/ |
typedef struct |
{ |
s16 AngleNick; // in 0.1 deg |
s16 AngleRoll; // in 0.1 deg |
s16 Heading; // in 0.1 deg |
u8 reserve[8]; |
} __attribute__((packed)) Data3D_t; |
typedef struct { |
s32 Longitude; // in 1E-7 deg |
s32 Latitude; // in 1E-7 deg |
s32 Altitude; // in mm |
u8 Status; // validity of data |
} __attribute__((packed)) GPS_Pos_t; |
typedef struct { |
s16 Distance; // distance to target in cm |
s16 Bearing; // course to target in deg |
} __attribute__((packed)) GPS_PosDev_t; |
#if 0 |
typedef struct { |
u8 Version; // version of the data structure |
GPS_Pos_t CurrentPosition; // see ubx.h for details |
GPS_Pos_t TargetPosition; |
GPS_PosDev_t TargetPositionDeviation; |
GPS_Pos_t HomePosition; |
GPS_PosDev_t HomePositionDeviation; |
u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
u8 WaypointNumber; // number of stored waypoints |
u8 SatsInUse; // number of satellites used for position solution |
s16 Altimeter; // hight according to air pressure |
s16 Variometer; // climb(+) and sink(-) rate |
u16 FlyingTime; // in seconds |
u8 UBat; // Battery Voltage in 0.1 Volts |
u16 GroundSpeed; // speed over ground in cm/s (2D) |
s16 Heading; // current flight direction in ∞ as angle to north |
s16 CompassHeading; // current compass value in ∞ |
s8 AngleNick; // current Nick angle in 1∞ |
s8 AngleRoll; // current Rick angle in 1∞ |
u8 RC_Quality; // RC_Quality |
u8 MKFlags; // Flags from FC |
u8 NCFlags; // Flags from NC |
u8 Errorcode; // 0 --> okay |
u8 OperatingRadius; // current operation radius around the Home Position in m |
s16 TopSpeed; // velocity in vertical direction in cm/s |
u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
u8 Reserve[4]; // for future use |
} __attribute__((packed)) NaviData_t; |
#endif |
typedef struct |
{ |
u8 Version; // version of the data structure |
GPS_Pos_t CurrentPosition; // see ubx.h for details |
GPS_Pos_t TargetPosition; |
GPS_PosDev_t TargetPositionDeviation; |
GPS_Pos_t HomePosition; |
GPS_PosDev_t HomePositionDeviation; |
u8 WaypointIndex; // index of current waypoints running from 0 to WaypointNumber-1 |
u8 WaypointNumber; // number of stored waypoints |
u8 SatsInUse; // number of satellites used for position solution |
s16 Altimeter; // hight according to air pressure |
s16 Variometer; // climb(+) and sink(-) rate |
u16 FlyingTime; // in seconds |
u8 UBat; // Battery Voltage in 0.1 Volts |
u16 GroundSpeed; // speed over ground in cm/s (2D) |
s16 Heading; // current flight direction in ° as angle to north |
s16 CompassHeading; // current compass value in ° |
s8 AngleNick; // current Nick angle in 1° |
s8 AngleRoll; // current Rick angle in 1° |
u8 RC_Quality; // RC_Quality |
u8 FCFlags; // Flags from FC |
u8 NCFlags; // Flags from NC |
u8 Errorcode; // 0 --> okay |
u8 OperatingRadius; // current operation radius around the Home Position in m |
s16 TopSpeed; // velocity in vertical direction in cm/s |
u8 TargetHoldTime; // time in s to stay at the given target, counts down to 0 if target has been reached |
u8 RC_RSSI; // Receiver signal strength (since version 2 added) |
s16 SetpointAltitude; // setpoint for altitude |
u8 Gas; // for future use |
u16 Current; // actual current in 0.1A steps |
u16 UsedCapacity; // used capacity in mAh |
} __attribute__((packed)) NaviData_t; |
/* |
* MikroKopter Flags |
* taken from |
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.73d%2Ffc.h |
*/ |
#define FCFLAG_MOTOR_RUN 0x01 |
#define FCFLAG_FLY 0x02 |
#define FCFLAG_CALIBRATE 0x04 |
#define FCFLAG_START 0x08 |
#define FCFLAG_NOTLANDUNG 0x10 |
#define FCFLAG_LOWBAT 0x20 |
#define FCFLAG_SPI_RX_ERR 0x40 |
#define FCFLAG_I2CERR 0x80 |
/* |
* NaviCtrl Flags |
* taken from |
* http://mikrocontroller.cco-ev.de/mikrowebsvn/filedetails.php?repname=NaviCtrl&path=%2Ftags%2FV0.15c%2Fuart1.h |
*/ |
#define NC_FLAG_FREE 0x01 |
#define NC_FLAG_PH 0x02 |
#define NC_FLAG_CH 0x04 |
#define NC_FLAG_RANGE_LIMIT 0x08 |
#define NC_FLAG_NOSERIALLINK 0x10 |
#define NC_FLAG_TARGET_REACHED 0x20 |
#define NC_FLAG_MANUAL_CONTROL 0x40 |
#define NC_FLAG_8 0x80 |
#if 0 |
typedef struct |
{ |
unsigned char Kanalbelegung[8]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
unsigned char Hoehe_MinGas; // Wert : 0-100 |
unsigned char Luftdruck_D; // Wert : 0-250 |
unsigned char MaxHoehe; // Wert : 0-32 |
unsigned char Hoehe_P; // Wert : 0-32 |
unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
unsigned char Hoehe_HoverBand; // Wert : 0-250 |
unsigned char Hoehe_GPS_Z; // Wert : 0-250 |
unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250 |
unsigned char Stick_P; // Wert : 1-6 |
unsigned char Stick_D; // Wert : 0-64 |
unsigned char Gier_P; // Wert : 1-20 |
unsigned char Gas_Min; // Wert : 0-32 |
unsigned char Gas_Max; // Wert : 33-250 |
unsigned char GyroAccFaktor; // Wert : 1-64 |
unsigned char KompassWirkung; // Wert : 0-32 |
unsigned char Gyro_P; // Wert : 10-250 |
unsigned char Gyro_I; // Wert : 0-250 |
unsigned char Gyro_D; // Wert : 0-250 |
unsigned char Gyro_Gier_P; // Wert : 10-250 |
unsigned char Gyro_Gier_I; // Wert : 0-250 |
unsigned char UnterspannungsWarnung; // Wert : 0-250 |
unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
unsigned char UfoAusrichtung; // X oder + Formation |
unsigned char I_Faktor; // Wert : 0-250 |
unsigned char UserParam1; // Wert : 0-250 |
unsigned char UserParam2; // Wert : 0-250 |
unsigned char UserParam3; // Wert : 0-250 |
unsigned char UserParam4; // Wert : 0-250 |
unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
//--- Seit V0.75 |
unsigned char ServoRollControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoRollComp; // Wert : 0-250 |
unsigned char ServoRollMin; // Wert : 0-250 |
unsigned char ServoRollMax; // Wert : 0-250 |
//--- |
unsigned char ServoNickRefresh; // |
unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
unsigned char Driftkomp; |
unsigned char DynamicStability; |
unsigned char UserParam5; // Wert : 0-250 |
unsigned char UserParam6; // Wert : 0-250 |
unsigned char UserParam7; // Wert : 0-250 |
unsigned char UserParam8; // Wert : 0-250 |
//---Output --------------------------------------------- |
unsigned char J16Bitmask; // for the J16 Output |
unsigned char J16Timing; // for the J16 Output |
unsigned char J17Bitmask; // for the J17 Output |
unsigned char J17Timing; // for the J17 Output |
// seit version V0.75c |
unsigned char WARN_J16_Bitmask; // for the J16 Output |
unsigned char WARN_J17_Bitmask; // for the J17 Output |
//---NaviCtrl--------------------------------------------- |
unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
unsigned char NaviGpsGain; |
unsigned char NaviGpsP; |
unsigned char NaviGpsI; |
unsigned char NaviGpsD; |
unsigned char NaviGpsPLimit; |
unsigned char NaviGpsILimit; |
unsigned char NaviGpsDLimit; |
unsigned char NaviGpsACC; |
unsigned char NaviGpsMinSat; |
unsigned char NaviStickThreshold; |
unsigned char NaviWindCorrection; |
unsigned char NaviSpeedCompensation; |
unsigned char NaviOperatingRadius; |
unsigned char NaviAngleLimitation; |
unsigned char NaviPH_LoginTime; |
//---Ext.Ctrl--------------------------------------------- |
unsigned char ExternalControl; // for serial Control |
//------------------------------------------------ |
unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen |
unsigned char ExtraConfig; // bitcodiert |
char Name[12]; |
} __attribute__((packed)) mk_param_struct_t; |
#endif |
typedef struct |
{ |
unsigned char Kanalbelegung[12]; // GAS[0], GIER[1],NICK[2], ROLL[3], POTI1, POTI2, POTI3 |
unsigned char GlobalConfig; // 0x01=Höhenregler aktiv,0x02=Kompass aktiv, 0x04=GPS aktiv, 0x08=Heading Hold aktiv |
unsigned char Hoehe_MinGas; // Wert : 0-100 |
unsigned char Luftdruck_D; // Wert : 0-250 |
unsigned char MaxHoehe; // Wert : 0-32 |
unsigned char Hoehe_P; // Wert : 0-32 |
unsigned char Hoehe_Verstaerkung; // Wert : 0-50 |
unsigned char Hoehe_ACC_Wirkung; // Wert : 0-250 |
unsigned char Hoehe_HoverBand; // Wert : 0-250 |
unsigned char Hoehe_GPS_Z; // Wert : 0-250 |
unsigned char Hoehe_StickNeutralPoint;// Wert : 0-250 |
unsigned char Stick_P; // Wert : 1-6 |
unsigned char Stick_D; // Wert : 0-64 |
unsigned char Gier_P; // Wert : 1-20 |
unsigned char Gas_Min; // Wert : 0-32 |
unsigned char Gas_Max; // Wert : 33-250 |
unsigned char GyroAccFaktor; // Wert : 1-64 |
unsigned char KompassWirkung; // Wert : 0-32 |
unsigned char Gyro_P; // Wert : 10-250 |
unsigned char Gyro_I; // Wert : 0-250 |
unsigned char Gyro_D; // Wert : 0-250 |
unsigned char Gyro_Gier_P; // Wert : 10-250 |
unsigned char Gyro_Gier_I; // Wert : 0-250 |
unsigned char UnterspannungsWarnung; // Wert : 0-250 |
unsigned char NotGas; // Wert : 0-250 //Gaswert bei Empängsverlust |
unsigned char NotGasZeit; // Wert : 0-250 // Zeitbis auf NotGas geschaltet wird, wg. Rx-Problemen |
unsigned char Receiver; // 0= Summensignal, 1= Spektrum, 2 =Jeti, 3=ACT DSL, 4=ACT S3D |
unsigned char I_Faktor; // Wert : 0-250 |
unsigned char UserParam1; // Wert : 0-250 |
unsigned char UserParam2; // Wert : 0-250 |
unsigned char UserParam3; // Wert : 0-250 |
unsigned char UserParam4; // Wert : 0-250 |
unsigned char ServoNickControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoNickComp; // Wert : 0-250 // Einfluss Gyro/Servo |
unsigned char ServoNickMin; // Wert : 0-250 // Anschlag |
unsigned char ServoNickMax; // Wert : 0-250 // Anschlag |
//--- Seit V0.75 |
unsigned char ServoRollControl; // Wert : 0-250 // Stellung des Servos |
unsigned char ServoRollComp; // Wert : 0-250 |
unsigned char ServoRollMin; // Wert : 0-250 |
unsigned char ServoRollMax; // Wert : 0-250 |
//--- |
unsigned char ServoNickRefresh; // Speed of the Servo |
unsigned char Servo3; // Value or mapping of the Servo Output |
unsigned char Servo4; // Value or mapping of the Servo Output |
unsigned char Servo5; // Value or mapping of the Servo Output |
unsigned char LoopGasLimit; // Wert: 0-250 max. Gas während Looping |
unsigned char LoopThreshold; // Wert: 0-250 Schwelle für Stickausschlag |
unsigned char LoopHysterese; // Wert: 0-250 Hysterese für Stickausschlag |
unsigned char AchsKopplung1; // Wert: 0-250 Faktor, mit dem Gier die Achsen Roll und Nick koppelt (NickRollMitkopplung) |
unsigned char AchsKopplung2; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
unsigned char CouplingYawCorrection; // Wert: 0-250 Faktor, mit dem Nick und Roll verkoppelt werden |
unsigned char WinkelUmschlagNick; // Wert: 0-250 180°-Punkt |
unsigned char WinkelUmschlagRoll; // Wert: 0-250 180°-Punkt |
unsigned char GyroAccAbgleich; // 1/k (Koppel_ACC_Wirkung) |
unsigned char Driftkomp; |
unsigned char DynamicStability; |
unsigned char UserParam5; // Wert : 0-250 |
unsigned char UserParam6; // Wert : 0-250 |
unsigned char UserParam7; // Wert : 0-250 |
unsigned char UserParam8; // Wert : 0-250 |
//---Output --------------------------------------------- |
unsigned char J16Bitmask; // for the J16 Output |
unsigned char J16Timing; // for the J16 Output |
unsigned char J17Bitmask; // for the J17 Output |
unsigned char J17Timing; // for the J17 Output |
// seit version V0.75c |
unsigned char WARN_J16_Bitmask; // for the J16 Output |
unsigned char WARN_J17_Bitmask; // for the J17 Output |
//---NaviCtrl--------------------------------------------- |
unsigned char NaviGpsModeControl; // Parameters for the Naviboard |
unsigned char NaviGpsGain; |
unsigned char NaviGpsP; |
unsigned char NaviGpsI; |
unsigned char NaviGpsD; |
unsigned char NaviGpsPLimit; |
unsigned char NaviGpsILimit; |
unsigned char NaviGpsDLimit; |
unsigned char NaviGpsACC; |
unsigned char NaviGpsMinSat; |
unsigned char NaviStickThreshold; |
unsigned char NaviWindCorrection; |
unsigned char NaviSpeedCompensation; |
unsigned char NaviOperatingRadius; |
unsigned char NaviAngleLimitation; |
unsigned char NaviPH_LoginTime; |
//---Ext.Ctrl--------------------------------------------- |
unsigned char ExternalControl; // for serial Control |
//------------------------------------------------ |
unsigned char BitConfig; // (war Loop-Cfg) Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
unsigned char ServoCompInvert; // // 0x01 = Nick, 0x02 = Roll 0 oder 1 // WICHTIG!!! am Ende lassen |
unsigned char ExtraConfig; // bitcodiert |
char Name[12]; |
} __attribute__((packed)) mk_param_struct_t; |
#define STRUCT_PARAM_LAENGE sizeof(mk_param_struct_t) |
/Transportables_Koptertool/trunk/motortest.c |
---|
0,0 → 1,281 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <string.h> |
#include <util/twi.h> |
#include "main.h" |
#include "motortest.h" |
#include "lcd.h" |
#include "usart.h" |
#include "timer.h" |
uint8_t m; |
#define SCL_FREQ 200000L |
#define I2C_STATE_TX_ADDRESS 0 |
#define I2C_STATE_TX_DATA 1 |
#define I2C_STATE_TX_STOP 2 |
#define I2C_STATE_RX_ADDRESS 3 |
#define I2C_STATE_RX_1BYTE 4 |
#define I2C_STATE_RX_2BYTE 5 |
volatile uint8_t i2c_state; |
volatile uint8_t motor_addr = 0; |
//***************************************************************************** |
// |
void I2C_Init(void) |
{ |
uint8_t sreg = SREG; |
cli(); |
DDRC &= ~(1<<DDC1); // SDA is input |
DDRC |= (1<<DDC0); // SCL is output |
PORTC |= (1<<PORTC0)|(1<<PORTC1); // pull up SDA and SCL |
// prescaler 1 (TWPS1 = 0, TWPS0 = 0) |
TWSR &= ~((1<<TWPS1)|(1<<TWPS0)); |
TWBR = ((F_CPU/SCL_FREQ)-16)/2; |
i2c_state = I2C_STATE_TX_ADDRESS; |
SREG = sreg; |
} |
//***************************************************************************** |
// |
void I2C_Start(uint8_t start_state) |
{ |
i2c_state = start_state; |
// generate start condition and enable interrupts |
TWCR = (1<<TWINT) | (1<<TWSTA) | (1<<TWEN) | (1<<TWIE); |
} |
//***************************************************************************** |
// |
void I2C_Stop(uint8_t start_state) |
{ |
i2c_state = start_state; |
// generate stop condition and disable interrupt |
TWCR = (1<<TWINT) | (1<<TWSTO) | (1<<TWEN); |
} |
//***************************************************************************** |
// |
void I2C_WriteByte(int8_t b) |
{ |
TWDR = b; |
// clear interrupt flag (TWINT = 1) |
// enable i2c bus (TWEN = 1) |
// enable interrupt (TWIE = 1) |
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE); |
} |
//***************************************************************************** |
// |
void I2C_ReceiveByte(void) |
{ |
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE) | (1<<TWEA); |
} |
//***************************************************************************** |
// |
void I2C_ReceiveLastByte(void) |
{ |
TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWIE); |
} |
//***************************************************************************** |
// |
ISR (TWI_vect) |
{ |
int8_t mrCurrent; |
int8_t mrMaxpwm; |
switch (i2c_state++) |
{ |
// TWI Master Transmit |
case I2C_STATE_TX_ADDRESS: |
I2C_WriteByte(0x52 + (motor_addr * 2) ); // select slave adress in tx mode |
break; |
case I2C_STATE_TX_DATA: |
I2C_WriteByte(m); |
break; |
case I2C_STATE_TX_STOP: |
if(TWSR == TW_MT_DATA_NACK) // Data transmitted, NACK received |
{ |
// error occured |
} |
I2C_Stop(I2C_STATE_TX_ADDRESS); |
I2C_Start(I2C_STATE_RX_ADDRESS); // Repeated start -> switch slave or switch Master Transmit -> Master Receive |
break; |
// Master Receive Data |
case I2C_STATE_RX_ADDRESS: |
I2C_WriteByte(0x53 + (motor_addr * 2) ); // select slave adress in rx mode |
if(TWSR != TW_MR_SLA_ACK) // SLA+R transmitted, if not ACK received |
{ // no response from the addressed slave received |
I2C_Stop(I2C_STATE_TX_ADDRESS); |
} |
else |
{ |
I2C_ReceiveByte(); //Transmit 1st byte |
} |
break; |
case I2C_STATE_RX_1BYTE: //Read 1st byte and transmit 2nd Byte |
mrCurrent = TWDR; |
I2C_ReceiveLastByte(); // nack |
break; |
case I2C_STATE_RX_2BYTE: |
//Read 2nd byte |
mrMaxpwm = TWDR;; |
I2C_Stop(I2C_STATE_TX_ADDRESS); |
break; |
default: |
I2C_Stop(I2C_STATE_TX_ADDRESS); |
break; |
} |
} |
//***************************************************************************** |
// |
void motor_i2c (void) |
{ |
uint8_t blc = 0; |
lcd_cls (); |
m = 0; |
lcd_printp (PSTR("I2C Motor Test"), 0); |
lcd_printpns_at (0, 7, PSTR("dec inc Exit Off"), 0); |
lcd_printp (PSTR("BLC #"), 0); |
do |
{ |
if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (m < 254)) |
{ |
m++; |
} |
if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (m > 0)) |
{ |
lcd_frect (GX, GY, (m * 108) / 255, 10, 0); |
m--; |
} |
if (get_key_press (1 << KEY_ENTER)) |
{ |
lcd_frect (GX, GY, (m * 108) / 255, 10, 0); |
m = 0; |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
// switch all engines off at exit ! |
} |
//***************************************************************************** |
// |
void motor (uint8_t m) |
{ |
memset (buffer, m, 16); |
#if 0 |
buffer[0] = m; // 0 |
buffer[1] = m; // 1 |
buffer[2] = m; // 2 |
buffer[3] = m; // 3 |
buffer[4] = m; // 4 |
buffer[5] = m; // 5 |
buffer[6] = m; // 6 |
buffer[7] = m; // 7 |
buffer[8] = m; // 8 |
buffer[9] = m; // 9 |
buffer[10] = m; // 10 |
buffer[11] = m; // 11 |
buffer[12] = m; // 12 |
buffer[13] = m; // 13 |
buffer[14] = m; // 14 |
buffer[15] = m; // 15 |
#endif |
SendOutData('t', ADDRESS_FC, 1, buffer, 16); |
// hier könnte man noch eine I2C-Ausgabe einbauen... |
lcd_frect (GX, GY, (m * 108) / 255, 10, 1); |
write_ndigit_number_u (MX, MY, m, 3, 0); |
} |
//***************************************************************************** |
// |
void motor_test (void) |
{ |
//uint8_t m; |
lcd_cls (); |
m = 0; |
lcd_printp (PSTR("Motor Test"), 0); |
lcd_printpns_at (0, 7, PSTR("dec inc Exit Off"), 0); |
if (hardware == NC && current_hardware == NC) |
{ |
SwitchToFC(); |
} |
motor (m); |
do |
{ |
if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (m < 254)) |
{ |
m++; |
} |
if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (m > 0)) |
{ |
lcd_frect (GX, GY, (m * 108) / 255, 10, 0); |
m--; |
} |
if (get_key_press (1 << KEY_ENTER)) |
{ |
lcd_frect (GX, GY, (m * 108) / 255, 10, 0); |
m = 0; |
} |
motor (m); |
} |
while (!get_key_press (1 << KEY_ESC)); |
// switch all engines off at exit ! |
motor (0); |
} |
/Transportables_Koptertool/trunk/motortest.h |
---|
0,0 → 1,36 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _MOTORTEST_H |
#define _MOTORTEST_H |
//***************************************************************************** |
// |
#define MX 0 |
#define MY 3 |
#define GX (MX + 3) * 6 + 1 // 3 for 3 digits |
#define GY MY * 8 - 2 |
#define MAXGX 128 - GX |
//***************************************************************************** |
// |
void motor_test (void); |
void motor_i2c (void); |
#endif |
/Transportables_Koptertool/trunk/osd.c |
---|
0,0 → 1,501 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the C-OSD code from CaScAdE * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <inttypes.h> |
#include <stdlib.h> |
#include <avr/pgmspace.h> |
#include "main.h" |
#include "osd.h" |
#include "lcd.h" |
#include "timer.h" |
#include "usart.h" |
#include "mk-data-structs.h" |
#define COSD_WASFLYING 4 |
/* ########################################################################## |
* global definitions and global vars |
* ##########################################################################*/ |
NaviData_t *naviData; |
// stats for after flight |
int16_t max_Altimeter = 0; |
uint16_t max_GroundSpeed = 0; |
int16_t max_Distance = 0; |
uint8_t min_UBat = 255; |
uint16_t max_FlyingTime = 0; |
uint16_t max_Current = 0; |
uint16_t max_Capacity = 0; |
// cache old vars for blinking attribute, checkup is faster than full |
// attribute write each time |
volatile uint8_t last_UBat = 255; |
volatile uint8_t last_RC_Quality = 255; |
volatile uint16_t ftimer = 0; |
// store stats description in progmem to save space |
const char stats_item_0[] PROGMEM = "max Altitude:"; |
const char stats_item_1[] PROGMEM = "max Speed :"; |
const char stats_item_2[] PROGMEM = "max Distance:"; |
const char stats_item_3[] PROGMEM = "min Voltage :"; |
const char stats_item_4[] PROGMEM = "max Time :"; |
#if 1 |
const char stats_item_5[] PROGMEM = "max Current :"; |
const char stats_item_6[] PROGMEM = "UsedCapacity:"; |
#else |
const char stats_item_5[] PROGMEM = "Long. :"; |
const char stats_item_6[] PROGMEM = "Lat. :"; |
#endif |
const char *stats_item_pointers[] PROGMEM = { |
stats_item_0, |
stats_item_1, |
stats_item_2, |
stats_item_3, |
stats_item_4, |
stats_item_5, |
stats_item_6 |
}; |
//char* rose = "-+-N-+-O-+-S-+-W-+-N-+-O-+-S-+-W-+-N-+-O-+-S-+-W"; |
const char rose[48] PROGMEM = { |
0x0e, 0x0f, 0x0e, 'N', 0x0e, 0x0f, 0x0e, 'O', 0x0e, 0x0f, 0x0e, 'S', |
0x0e, 0x0f, 0x0e, 'W', 0x0e, 0x0f, 0x0e, 'N', 0x0e, 0x0f, 0x0e, 'O', |
0x0e, 0x0f, 0x0e, 'S', 0x0e, 0x0f, 0x0e, 'W', 0x0e, 0x0f, 0x0e, 'N', |
0x0e, 0x0f, 0x0e, 'O', 0x0e, 0x0f, 0x0e, 'S', 0x0e, 0x0f, 0x0e, 'W'}; |
// the center is char 19 (north), we add the current heading in 8th |
// which would be 22.5 degrees, but float would bloat up the code |
// and *10 / 225 would take ages... so we take the uncorrect way |
const char str_NE[] PROGMEM = "NE"; |
const char str_E[] PROGMEM = "E "; |
const char str_SE[] PROGMEM = "SE"; |
const char str_S[] PROGMEM = "S "; |
const char str_SW[] PROGMEM = "SW"; |
const char str_W[] PROGMEM = "W "; |
const char str_NW[] PROGMEM = "NW"; |
const char str_N[] PROGMEM = "N "; |
const char *directions_p[8] PROGMEM = { |
str_NE, |
str_E, |
str_SE, |
str_S, |
str_SW, |
str_W, |
str_NW, |
str_N |
}; |
// Flags |
uint8_t COSD_FLAGS2 = 0; |
/** |
* convert the <heading> gotton from NC into an index |
*/ |
uint8_t heading_conv (uint16_t heading) |
{ |
if (heading > 23 && heading < 68) |
{ |
return 0; //direction = "NE"; |
} |
else if (heading > 67 && heading < 113) |
{ |
return 1; //direction = "E "; |
} |
else if (heading > 112 && heading < 158) |
{ |
return 2; //direction = "SE"; |
} |
else if (heading > 157 && heading < 203) |
{ |
return 3; //direction = "S "; |
} |
else if (heading > 202 && heading < 248) |
{ |
return 4; //direction = "SW"; |
} |
else if (heading > 247 && heading < 293) |
{ |
return 5; //direction = "W "; |
} |
else if (heading > 292 && heading < 338) |
{ |
return 6; //direction = "NW"; |
} |
return 7; //direction = "N "; |
} |
/** |
* draw a compass rose at <x>/<y> for <heading> |
*/ |
void draw_compass (uint8_t x, uint8_t y, uint16_t heading) |
{ |
uint8_t front = 19 + (heading / 22); |
for (uint8_t i = 0; i < 9; i++) |
{ |
lcd_putc (x++, y, pgm_read_byte(&rose[front - 4 + i]), 0); |
} |
} |
/* ########################################################################## |
* variometer |
* ##########################################################################*/ |
/** |
* draw variometer arrows at <x>/<y> according to <variometer> |
*/ |
void draw_variometer (uint8_t x, uint8_t y, uint8_t width_x, uint8_t width_y, int16_t variometer) |
{ |
lcd_rect (x, y - ((width_y - 1) / 2), width_x, width_y, 1); |
lcd_frect (x + 1, y - ((width_y - 1) / 2) + 1, width_x - 2, width_y - 2, 0); |
lcd_line (x, y, x + width_x, y, 1); |
if (variometer > 0) |
{ // gain height |
switch (variometer / 5) |
{ |
case 0: |
lcd_frect (x + 3, y - 1, 3, 1, 1); |
break; |
case 1: |
lcd_frect (x + 2, y - 3, 5, 3, 1); |
break; |
case 2: |
lcd_frect (x + 2, y - 4, 5, 4, 1); |
break; |
default: |
lcd_frect (x + 1, y - 5, 7, 5, 1); |
break; |
} |
} |
else |
{ // sink |
switch (variometer / -5) |
{ |
case 0: |
lcd_frect (x + 3, y, 3, 1, 1); |
break; |
case 1: |
lcd_frect (x + 2, y, 5, 3, 1); |
break; |
case 2: |
lcd_frect (x + 2, y, 5, 4, 1); |
break; |
default: |
lcd_frect (x + 1, y, 7, 5, 1); |
break; |
} |
} |
} |
#define TIMEOUT 200 // 2 sec |
void print_statistics (void) |
{ |
uint8_t line = 0; |
lcd_cls (); |
// max Altitude |
lcd_printpns_at (0, line, stats_item_pointers[0], 0); |
write_ndigit_number_s (13, line, max_Altimeter / 30, 4, 0); |
lcd_putc (17, line, 'm', 0); |
// max Speed |
lcd_printpns_at (0, ++line, stats_item_pointers[1], 0); |
write_ndigit_number_u (14, line, (uint16_t) (((uint32_t) max_GroundSpeed * (uint32_t) 9) / (uint32_t) 250), 3, 0); |
lcd_printpns_at(17, line, PSTR("km/h"), 0); |
// max Distance |
lcd_printpns_at (0, ++line, stats_item_pointers[2], 0); |
write_ndigit_number_u (14, line, max_Distance / 10, 3, 0); |
lcd_putc (17, line, 'm', 0); |
// max time |
lcd_printpns_at (0, ++line, stats_item_pointers[4], 0); |
write_time (13, line, max_FlyingTime); |
// min voltage |
lcd_printpns_at (0, ++line, stats_item_pointers[3], 0); |
write_ndigit_number_u_10th (13, line, min_UBat, 3, 0); |
lcd_putc (17, line, 'V', 0); |
#if 1 |
// max Current |
lcd_printpns_at (0, ++line, stats_item_pointers[5], 0); |
write_ndigit_number_u_10th (13, line, max_Current, 3, 0); |
lcd_putc (17, line, 'A', 0); |
// Used Capacity |
lcd_printpns_at (0, ++line, stats_item_pointers[6], 0); |
write_ndigit_number_u (13, line, max_Capacity, 4, 0); |
lcd_printpns_at(17, line, PSTR("mAh"), 0); |
#else |
// longitude |
lcd_printpns_at (0, ++line, stats_item_pointers[5], 0); |
write_gps_pos (8, line, naviData->CurrentPosition.Longitude); |
// latitude |
lcd_printpns_at (0, ++line, stats_item_pointers[6], 0); |
write_gps_pos (8, line, naviData->CurrentPosition.Latitude); |
#endif |
while (!get_key_press (1 << KEY_ESC)) |
timer = TIMEOUT; |
COSD_FLAGS2 &= ~COSD_WASFLYING; |
get_key_press(KEY_ALL); |
lcd_cls(); |
} |
void osd (void) |
{ |
uint8_t flag; |
uint8_t tmp_dat; |
// Clear statistics |
max_Altimeter = 0; |
max_GroundSpeed = 0; |
max_Distance = 0; |
min_UBat = 255; |
max_FlyingTime = 0; |
// flags from last round to check for changes |
uint8_t old_FCFlags = 0; |
uint16_t old_hh = 0; |
lcd_cls(); |
if (hardware == FC) |
{ |
lcd_printp_at(0, 3, PSTR("Only with NC !"), 0); |
timer = 100; |
while (timer > 0); |
} |
SwitchToNC(); |
mode = 'O'; |
// disable debug... |
// RS232_request_mk_data (0, 'd', 0); |
tmp_dat = 0; |
SendOutData ('d', ADDRESS_ANY, 1, &tmp_dat, 1); |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
flag = 0; |
timer = TIMEOUT; |
abo_timer = ABO_TIMEOUT; |
do |
{ |
if (rxd_buffer_locked) |
{ |
timer = TIMEOUT; |
Decode64 (); |
naviData = (NaviData_t *) pRxData; |
flag = 1; |
if (naviData->FCFlags & FCFLAG_MOTOR_RUN) |
{ // should be engines running |
// motors are on, assume we were/are flying |
COSD_FLAGS2 |= COSD_WASFLYING; |
} |
else |
{ // stats |
if ((COSD_FLAGS2 & COSD_WASFLYING) || (get_key_press (1 << KEY_ENTER))) |
{ |
print_statistics (); |
} |
} |
// lcd_printpns_at (0, 3, PSTR("012345678901234567890"), 0); |
lcd_ecircle(22, 35, 16, 1); |
// Ground Speed |
write_ndigit_number_u (1, 0, (uint16_t) (((uint32_t) naviData->GroundSpeed * (uint32_t) 9) / (uint32_t) 250), 3, 0); |
lcd_printpns_at(4, 0, PSTR("km/h"), 0); |
// Compass |
write_ndigit_number_u (14, 0, naviData->CompassHeading, 3, 0); |
lcd_putc (17, 0, 0x1E, 0); // degree symbol |
lcd_printpns_at (18, 0, (const char *) (pgm_read_word ( &(directions_p[heading_conv(naviData->CompassHeading)]))), 0); |
draw_compass (12, 1, naviData->CompassHeading); |
// Altitude |
//note:lephisto:according to several sources it's /30 |
if (naviData->Altimeter > 300 || naviData->Altimeter < -300) |
{ |
// above 10m only write full meters |
write_ndigit_number_s (0, 1, naviData->Altimeter / 30, 4, 0); |
} |
else |
{ |
// up to 10m write meters.dm |
write_ndigit_number_s_10th (0, 1, naviData->Altimeter / 3, 3, 0); |
} |
lcd_putc (4, 1, 'm', 0); |
draw_variometer (55, 7, 9, 13, naviData->Variometer); |
// TODO: verify correctness |
uint16_t heading_home = (naviData->HomePositionDeviation.Bearing + 360 - naviData->CompassHeading) % 360; |
lcd_ecirc_line (22, 35, 15, old_hh, 0); |
old_hh = heading_home; |
lcd_ecirc_line (22, 35, 15, heading_home, 1); |
write_ndigit_number_u (7, 3, heading_home, 3, 0); |
lcd_putc (10, 3, 0x1e, 0); // degree symbol |
write_ndigit_number_u (7, 2, naviData->HomePositionDeviation.Distance / 10, 3, 0); |
lcd_putc (10, 2, 'm', 0); |
// Sats in use |
lcd_printp_at(10, 4, PSTR("Sats"), 0); |
write_ndigit_number_u (8, 4, naviData->SatsInUse, 2, 0); |
if (naviData->NCFlags & NC_FLAG_MANUAL_CONTROL) |
{ |
lcd_putc (19, 4, 'M', 0); // rc transmitter |
} |
else |
{ |
lcd_putc (19, 4, ' ', 0); // clear |
} |
#if 0 |
lcd_printp_at(11, 5, PSTR("Mode:"), 0); |
if (naviData->NCFlags & NC_FLAG_CH) |
{ |
lcd_printpns_at (17, 5, PSTR("CH "), 0); |
} |
else if (naviData->NCFlags & NC_FLAG_PH) |
{ |
lcd_printpns_at (17, 5, PSTR("PH "), 0); |
} |
else |
{ // (naviData->NCFlags & NC_FLAG_FREE) |
lcd_printpns_at (17, 5, PSTR("Free"), 0); // sat2 (free) |
} |
#endif |
if (naviData->NCFlags & NC_FLAG_CH) |
{ |
lcd_printpns_at (10, 5, PSTR("Coming Home"), 0); |
} |
else if (naviData->NCFlags & NC_FLAG_PH) |
{ |
lcd_printpns_at (10, 5, PSTR("Pos. Hold "), 0); |
} |
else |
{ // (naviData->NCFlags & NC_FLAG_FREE) |
lcd_printpns_at (10, 5, PSTR("Free "), 0); |
} |
// Flying time |
write_time (7, 6, naviData->FlyingTime); |
// lcd_printp_at (7, 6, PSTR("Fly"), 0); |
// RC |
write_ndigit_number_u (15, 6, naviData->RC_Quality, 3, 0); |
lcd_putc (18, 6, 0x1F, 0); // RC-transmitter |
if (naviData->NCFlags & NC_FLAG_NOSERIALLINK) |
{ |
lcd_printpns_at(19, 6, PSTR(" "), 0); // clear |
} |
else |
{ |
lcd_printpns_at(19, 6, PSTR("PC"), 0); |
} |
// Battery level |
write_ndigit_number_u_10th (0, 7, naviData->UBat, 3, 0); |
lcd_putc (4, 7, 'V', 0); |
// Current |
write_ndigit_number_u_10th (7, 7, naviData->Current, 3, 0); |
lcd_putc (11, 7, 'A', 0); |
// Capacity |
write_ndigit_number_u (14, 7, naviData->UsedCapacity, 4, 0); |
lcd_printpns_at(18, 7, PSTR("mAh"), 0); |
// remember statistics (only when engines running) |
if (naviData->FCFlags & FCFLAG_MOTOR_RUN) |
{ |
if (naviData->Altimeter > max_Altimeter) max_Altimeter = naviData->Altimeter; |
if (naviData->GroundSpeed > max_GroundSpeed) max_GroundSpeed = naviData->GroundSpeed; |
if (naviData->HomePositionDeviation.Distance > max_Distance) max_Distance = naviData->HomePositionDeviation.Distance; |
if (naviData->UBat < min_UBat) min_UBat = naviData->UBat; |
if (naviData->FlyingTime > max_FlyingTime) max_FlyingTime = naviData->FlyingTime; |
if (naviData->Current > max_Current) max_Current = naviData->Current; |
if (naviData->UsedCapacity > max_Capacity) max_Capacity = naviData->UsedCapacity; |
} |
// remember last values |
last_RC_Quality = naviData->RC_Quality; |
last_UBat = naviData->UBat; |
old_FCFlags = naviData->FCFlags; |
rxd_buffer_locked = FALSE; |
} |
if (!abo_timer) |
{ // renew abo every 3 sec |
// request OSD Data from NC every 100ms |
// RS232_request_mk_data (1, 'o', 100); |
tmp_dat = 10; |
SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
abo_timer = ABO_TIMEOUT; |
} |
} |
while (!get_key_press (1 << KEY_ESC) && timer); |
get_key_press(KEY_ALL); |
// disable OSD Data from NC |
// RS232_request_mk_data (1, 'o', 0); |
tmp_dat = 0; |
SendOutData ('o', ADDRESS_NC, 1, &tmp_dat, 1); |
mode = 0; |
rxd_buffer_locked = FALSE; |
if (!timer) |
{ // timeout occured |
if (flag) |
{ |
lcd_cls (); |
} |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
print_statistics (); |
} |
} |
/Transportables_Koptertool/trunk/osd.h |
---|
0,0 → 1,29 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the C-OSD code from CaScAdE * |
* http://www.mylifesucks.de/oss/c-osd/ * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _OSD_H |
#define _OSD_H |
//***************************************************************************** |
// |
void osd (void); |
#endif |
/Transportables_Koptertool/trunk/parameter.c |
---|
0,0 → 1,687 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <util/delay.h> |
#include <string.h> |
#include <stdlib.h> |
#include "main.h" |
#include "lcd.h" |
#include "timer.h" |
#include "usart.h" |
#include "parameter.h" |
#include "menu.h" |
#include "mk-data-structs.h" |
#define TIMEOUT 500 // 5 sec |
mk_param_struct_t *mk_param_struct; |
uint8_t array[8]; |
prog_uchar p_menus[12][11]= |
{ |
"Config ", |
"Channels ", |
"Stick ", |
"Hight ", |
"Gyro ", |
"Looping ", |
"Camera ", |
"Misc. ", |
"User ", |
"Coupling ", |
"Config(2) ", |
"Loopingset" |
}; |
// Diese Tabelle ordnet die eingelesenen Parameter den Menü-Seiten zu |
prog_uchar p_menu_number[67]= |
{ |
2, 2, 2, 2, 2, 2, 2, 2, // Die ersten 8 Parameter werden auf Menüseite 2 angezeigt (=Kanalzuordnungen) |
0, 4, 4, 4, 4, 4, 4, 3, |
3, 3, 8, 8, 8, 8, 5, 5, |
8,8,8,0,5,9,9,9, |
9,7,7,7,7,7,7,6, |
6,6,10,10,6,6,5,5, |
5,9,9,9,9,0,7,11, |
11,11,11,12,12, 12, |
12,12,12,12,12 |
}; |
prog_uchar p_limits[199]= // Limits f¸r die Parameter |
{ |
1,8,2, // 2:Nick (3) |
1,8,2, // 2:Roll (4) |
1,8,2, // 2:Gas (2) |
1,8,2, // 2:Gier (1) |
1,8,2, // 2:Poti1 (6) |
1,8,2, // 2:Poti2 (6) |
1,8,2, // 2:Poti3 (7) |
1,8,2, // 2:Poti4 (5) |
0,0,0, // 1:Config |
0,255,4, // 4:Höhe MinGas (30) |
0,255,4, // 4:Luftdruck_D (30) |
0,255,4, // 4:MaxHöhe (Setpoint?) (Poti4) |
0,255,4, // 4:Höhe_P (10) |
0,50,4, // 4:Höhe Verst‰rkung (3) |
0,255,4, // 4:Höhe Z-acc (30) |
0,6,3, // 3:Nick/Roll P (3) |
0,64,3, // 3:Nick/Roll D (4) |
0,20,3, // 3:Gier_P (6) |
0,32,8, // 8:Min.Gas (15) |
33,250,8, // 8:Max.Gas (250) |
0,50,8, // 5:Gyro-Acc Faktor (30) |
0,255,8, // 8:Kompass-Wirkung (128) |
0,0,5, // 5:Gyro-P (80) |
0,0,5, // 5:Gyro-I (120) |
0,250,8, // 8:Unterspannung (94) |
0,250,8, // 8:Not-Gas Zeit (20) |
0,250,8, // 8:Not-Gas (35) |
0,1,0, // Ufo-Ausrichtung (X +) |
0,255,5, // I-Faktor (32) |
0,255,9, // 9:User1 (80) |
0,255,9, // 9:User2 (0) |
0,255,9, // 9:User3 |
0,255,9, // 9:User4 |
0,255,7, // 7:Servo Nick Control (100) |
0,250,7, // 7:Servo Nick Compensation (40) |
0,250,7, // 7:Servo Nick min (50) |
0,250,7, // 7:Servo Nick max (150) |
0,25,7, // 7:Servo Nick refrsh (5) |
0,255,6, // 6:Loop Gas Limit (50) |
0,250,6, // 6:Loop Ansprechschwelle (90) |
0,250,6, // 6:Loop Hysterese (50) |
0,255,10, // 10:Achskopplung (90) |
0,255,10, // 10:Achsgegenkopplung (5) |
0,250,6, // 6:Turnover Nick (100) |
0,250,6, // 6:Turnover Roll (100) |
0,250,5, // 5: Gyro-Abgleich (Comp.) (32) |
0,250,5, // 5: Drift (4) |
0,255,5, // 5: Dynamic stability (75) |
0,255,9, // 9:User5 |
0,255,9, // 9:User6 |
0,255,9, // 9:User7 |
0,255,9, // 9:User8 (0) |
0,0,1, // 6:Loop Config (0) |
0,1,7 // 7:Servo Nick Compensation Invert (0) |
}; |
prog_char bin_parameter[12][16] = // Die bin‰r kodierten Parametern werden getrennt behandelt. |
{ |
"Loop up ", |
"Loop down ", |
"Loop left ", |
"Loop right ", |
"Höhenregler ", // 8 |
"Höhenschalter ", |
"Headhold ", |
"Kompass ", |
"KompassFix ", |
"GPS ", |
"Achsenkopplung ", |
"Drehrate " |
}; |
prog_char parameter[54][16]= |
{ |
"Nick ", // 0 (3) |
"Roll ", // 1 (4) |
"Gas ", // (2) |
"Gier ", // (1) |
"Poti1 ", // (6) |
"Poti2 ", // (6) |
"Poti3 ", // (7) |
"Poti4 ", // 7 (5) |
"Config ", // 8 |
"Höhe_MinGas ", // 9 (30) |
"Luftdruck_D ", // 10 Wert : 0-250 (30) |
"MaxHöhe ", // 11 Wert : 0-250 251 -> Poti1 (Poti4) |
"Höhe_P ", // 12 Wert : 0-32 (10) |
"Höhe_Verstaerk", // 13 Wert : 0-50 |
"Höhe_ACC_Wirk.", // 14 Wert : 0-250 (30) |
"Stick_P ", // 15 Wert : 1-6 |
"Stick_D ", // 16 Wert : 0-64 |
"Gier_P ", // 17 Wert : 1-20 POTI(?) |
"Gas_Min ", // 17 Wert : 0-32 |
"Gas_Max ", // 18 Wert : 33-250 |
"GyroAccFaktor ", // 19 Wert : 1-64 |
"KompassWirkung ", // 20 Wert : 0-250 |
"Gyro_P ", // 21 Wert : 0-250 |
"Gyro_I ", // 22 Wert : 0-250 |
"Unterspannung ", // 23 Wert : 0-250 |
"NotGas ", // 24 Wert : 0-250 // Gaswert bei Empangsverlust |
"NotGasZeit ", // 25 Wert : 0-250 // Zeit bis auf NotGas geschaltet wird, wg. Rx-Problemen |
"UfoAusrichtung ", // 26 X oder + Formation |
"I_Faktor ", // 27 = 32; |
"UserParam1 ", // 28 = 32 * 4; //zur freien Verwendung |
"UserParam2 ", // 29 zur freien Verwendung |
"UserParam3 ", // 30 zur freien Verwendung |
"UserParam4 ", // 31 zur freien Verwendung |
"ServoNickCtrl ", // 32 Wert : 0-250 // Stellung des Servos |
"ServoNickComp ", // 33 Wert : 0-250 // Einfluss Gyro/Servo |
"ServoNickMin ", // 34 Wert : 0-250 // Anschlag |
"ServoNickMax ", // 35 Wert : 0-250 // Anschlag |
"ServoNickRefrsh", // 36 |
"LoopGasLimit ", // 37 |
"LoopThreshold ", // 38 Wert: 0-250 Schwelle f¸r Stickausschlag |
"LoopHysterese ", // 39 |
"AchsKopplung ", // 40 |
"AchsGegenKoppl.", // 41 |
"WinklUmschlNick", // 42 |
"WinklUmschlRoll", // 43 |
"GyroAccAbgleich", // 44 1/k |
"Driftkomp ", // 45 |
"DynamicStabilit", // 47 |
"UserParam5 ", // 48 zur freien Verwendung |
"UserParam6 ", // 49 zur freien Verwendung |
"UserParam7 ", // 50 zur freien Verwendung |
"UserParam8 ", // 51 zur freien Verwendung |
"LoopConfig ", // 52 Bitcodiert: 0x01=oben, 0x02=unten, 0x04=links, 0x08=rechts / wird getrennt behandelt |
"ServoNickCompIn" // 53 Wert : 0-250 // Richtung Einfluss Gyro/Servo |
// "Name " // 54 |
}; |
void binary (uint8_t data, uint8_t *feld) // Wandelt eine 8-Bit Zahl in eine Bin‰rzahl um (Array mit 8 Elementen) |
{ // Wird f¸r die Flags (Loop + Grundkonfiguration) benˆtigt |
uint8_t i; |
i=0; |
for (i = 0; i < 8; i++) |
{ |
if ((1 << i) & data) |
feld[i] = 1; |
else |
feld[i] = 0; |
} |
} |
uint8_t bindec (uint8_t *feld) // wandelt eine Bin‰rzahl (im Array) in eine 8-Bit Zahl |
{ // Wird f¸r die Flags (Loop + Grundkonfiguration) benˆtigt |
uint8_t i; |
uint8_t result; |
result = 0; |
for (i = 0; i < 8; i++) |
{ |
if (feld[i] == 1) |
result += 1 << i; |
} |
return result; |
} |
void decimal (uint8_t data, uint8_t *text) // wandelt Wert in rechtsbündigen Text um |
{ // (schneller/kleiner als printf()) |
text[0] = data/100; |
data -= (text[0] * 100); |
text[1] = data/10; |
data -= (text[1] *10); |
text[2] = data + 0x30; |
text[0] += 0x30; |
text[1] += 0x30; |
if (text[0] == 0x30) |
{ |
text[0] = 0x20; |
if (text[1] == 0x30) |
text[1] = 0x20; |
} |
text[3] = 0x00; |
} |
uint8_t show_parameter (uint8_t number) // Zeigt eine Parameter-Seite an und gibt die ausgew‰hlte Zeile zur¸ck |
{ |
#if 0 |
uint8_t i; |
uint8_t line; |
uint8_t text[25]; |
uint8_t bin[8]; |
line = 0; |
if (number > 1) |
{ |
for (i = 0; i<66; i++) |
{ |
if (pgm_read_byte(p_limits+i*3+2) == number) |
{ |
array[line] = i; |
decimal(buffer[i],text); |
lcd_print_at(0,line,text,0); |
lcd_printp_at (5,line,parameter[i],0); |
if (line <= 7) |
line++; |
} |
} |
} |
else |
{ // Sonderf‰lle: Bin‰re Eingabe |
if (number == 1) |
{ |
binary(buffer[52],bin); // Loop-Config |
text[1] = 0x00; |
for (i = 0; i < 4; i++) |
{ |
text[0] = bin[i] + 0x30; |
lcd_print_at (0, i, text, 0); |
lcd_printp_at (5, i, bin_parameter[i], 0); |
} |
} |
if (number == 0) |
{ |
binary (buffer[8], bin); // Config |
text[1] = 0x00; |
for (i = 0; i < 8; i++) |
{ |
text[0] = bin[i] + 0x30; |
lcd_print_at (0, i, text, 0); |
lcd_printp_at (5, i, bin_parameter[i + 4], 0); |
} |
} |
} |
return line; |
#endif |
} |
void edit_parameter2 (uint8_t page, uint8_t lines) // ƒndern der Parameter einer Seite |
{ |
#if 0 |
uint8_t line; |
uint8_t par; |
uint8_t min; |
uint8_t max; |
uint8_t text[10]; |
uint8_t bin[8]; |
if (page > 1) // "normale" Parameter-Seiten |
{ |
line = menu_choose(0,lines-1,4); |
if (line != 255) // Wenn line == 255, wurde Escape gedr¸ckt |
{ |
par = buffer[array[line]]; |
min = pgm_read_byte(p_limits + par * 3); |
max = pgm_read_byte(p_limits + par * 3 + 1); |
lcd_printp_at(4,line,PSTR("-"),0); |
while (key != key_nokey); |
do |
{ |
if (key == key_minus) |
{ |
//if (par > min) // ‹berpr¸fung der Parameter auf Bereichs¸berschreitung derzeit deaktiviert |
par --; |
} |
if (key == key_plus) |
{ |
//if (par < max) |
par ++; |
} |
decimal(par,text); |
lcd_print_at(0,line,text,0); |
timer = 20; |
while (timer > 0); |
} |
while ((key != 0x04) && (key != 0x08)); |
if (key == 0x08) |
buffer[array[line]] = par; |
} |
} |
if (page == 1) // Spezialfall: Loop-Config (einzelne Bits setzen / lˆschen) |
{ |
binary(buffer[52],bin); |
text[1] = 0x00; |
line = menu_choose(0,3,4); |
if (line != 255) // Wenn line == 255, wurde Escape gedr¸ckt |
{ |
par = bin[line]; |
lcd_printp_at(4,line,PSTR("-"),0); |
do |
{ |
if (key == key_minus) |
{ |
par = 0x00; |
} |
if (key == key_plus) |
{ |
par = 0x01; |
} |
text[0] = par+0x30; |
lcd_print_at(0,line,text,0); |
timer = 20; |
while (timer > 0); |
} |
while ((key != key_enter) && (key != key_esc)); |
if (key == key_enter) |
{ |
bin[line] = par; |
buffer[52] = bindec(bin); |
} |
lcd_cls(); |
decimal(buffer[52],text); |
lcd_print(text,0); |
timer = 200; |
while(timer > 0); |
} |
} |
if (page == 0) // Spezialfall: Allgemeine Konfiguration (einzelne Bits setzen/lˆschen) |
{ |
binary(buffer[8],bin); |
text[1] = 0x00; |
line = menu_choose(0,7,4); |
if (line != 255) // Wenn line == 255, wurde Escape gedr¸ckt |
{ |
par = bin[line]; |
lcd_printp_at(4,line,PSTR("-"),0); |
do |
{ |
if (key == key_minus) |
{ |
par = 0x00; |
} |
if (key == key_plus) |
{ |
par = 0x01; |
} |
text[0] = par+0x30; |
lcd_print_at(0,line,text,0); |
timer = 20; |
while (timer > 0); |
} |
while ((key != key_enter) && (key != key_esc)); |
if (key == key_enter) |
{ |
bin[line] = par; |
buffer[8] = bindec(bin); |
} |
lcd_cls(); |
decimal(buffer[8],text); |
lcd_print(text,0); |
timer = 200; |
while(timer > 0); |
} |
} |
#endif |
} |
void edit_parameter1 (void) |
{ |
uint8_t cmd; |
uint8_t setting = 0xff; |
mode = 'P'; // Settings |
lcd_cls (); |
//mode = 'Q'; // Settings |
_delay_ms (50); |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
LED2_ON; |
//SendOutData ('q', ADDRESS_FC, 1, &setting, 1); |
SendOutData ('p', ADDRESS_FC, 1); |
while (!rxd_buffer_locked && timer); |
if (timer) |
{ |
LED3_ON; |
Decode64 (); |
#if 0 |
mk_param_struct = (mk_param_struct_t *) pRxData + 2; |
lcd_printp (PSTR("Current Setting: "), 0); |
lcd_write_number_u (*pRxData); |
lcd_printp (PSTR("Setting Version: "), 0); |
lcd_write_number_u (*pRxData+1); |
#endif |
LED3_OFF; |
} |
else |
{ // timeout occured |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
return; |
} |
LED2_OFF; |
// after all work is done... |
rxd_buffer_locked = FALSE; |
#if 0 |
uint8_t page; // 12 Pages |
uint8_t text[15]; |
uint8_t lines; |
uint8_t parameter; |
lcd_cls (); |
lcd_printp (PSTR("Load Setting\r\n"), 0); |
lcd_printp (PSTR(" 1:\r\n"), 0); |
lcd_printp (PSTR(" 2:\r\n"), 0); |
lcd_printp (PSTR(" 3:\r\n"), 0); |
lcd_printp (PSTR(" 4:\r\n"), 0); |
lcd_printp (PSTR(" 5:\r\n"), 0); |
parameter = menu_choose (1, 5, 0); |
page = 2; |
if (read_parameter (parameter) == 1) |
{ |
lcd_printp_at (0, 6, PSTR("Timeout"), 0); |
} |
else |
{ |
do |
{ |
lcd_cls (); |
utoa (page, text, 10); |
lcd_print (text, 0); |
timer = 50; |
while (timer > 0); |
lcd_cls (); |
lines = show_parameter (page); |
while (key == key_nokey); |
if (key == key_plus) |
page++; |
if (key == key_minus) |
page--; |
if (page == 255) |
page = 12; |
if (page > 12) |
page = 0; |
if (key == key_enter) |
edit_parameter2 (page, lines); |
} |
while (key != key_esc); |
lcd_cls (); |
lcd_printp (PSTR("Parameter speichern?\r\n ja\r\n nein"), 0); |
lines = menu_choose (1, 2, 0); |
if (lines == 1 ) |
{ |
lcd_printp (PSTR("\r\n--->"), 0); |
write_parameter (5); // Sicherheitshalber wird derzeit ausschliefllich auf Parametersatz 5 gesichert. |
lcd_printp (PSTR("\r\nParameter gespeichert"), 0); |
} |
else |
{ |
lcd_printp (PSTR("\r\nNicht gespeichert"), 0); |
} |
} |
timer = 100; |
while (timer > 0); |
#endif |
} |
void display_page (uint8_t page) |
{ |
lcd_cls (); |
switch (page) |
{ |
case 0: |
lcd_printp (PSTR("Current Setting: "), 0); |
lcd_write_number_u (*pRxData); |
lcd_printp (PSTR("\r\nSetting Version: "), 0); |
lcd_write_number_u (*(pRxData + 1)); |
#if 0 |
lcd_printp (PSTR("\r\nRxDataLen: "), 0); |
lcd_write_number_u (RxDataLen); |
lcd_printp (PSTR("\r\nRxBytes: "), 0); |
lcd_write_number_u (ReceivedBytes); |
#endif |
break; |
case 1: |
lcd_printp (PSTR("Pitch: "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[0]); |
lcd_printp (PSTR("Yaw : "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[1]); |
lcd_printp (PSTR("Nick : "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[2]); |
lcd_printp (PSTR("Roll : "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[3]); |
lcd_printp (PSTR("Poti1: "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[4]); |
lcd_printp (PSTR("Poti2: "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[5]); |
lcd_printp (PSTR("Poti3: "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[6]); |
lcd_printp (PSTR("Poti4: "), 0); |
lcd_write_number_u (mk_param_struct->Kanalbelegung[7]); |
break; |
} |
} |
void edit_parameter (void) |
{ |
uint8_t cmd; |
uint8_t sett = 0xff; // current active parameter set |
uint8_t page = 0; |
SwitchToFC(); |
mode = 'Q'; // Settings |
lcd_cls (); |
_delay_ms (50); |
rxd_buffer_locked = FALSE; |
timer = TIMEOUT; |
SendOutData ('q', ADDRESS_FC, 1, &sett, 1); |
while (!rxd_buffer_locked && timer); |
if (timer) |
{ |
Decode64 (); |
mk_param_struct = (mk_param_struct_t *) pRxData + 2; |
display_page (page); |
if (get_key_press (1 << KEY_MINUS)) |
{ |
page--; |
} |
else if (get_key_press (1 << KEY_PLUS)) |
{ |
page++; |
} |
} |
else |
{ // timeout occured |
lcd_printp_at (0, 2, PSTR("ERROR: no data"), 0); |
timer = 100; |
while (timer > 0); |
return; |
} |
// after all work is done... |
//rxd_buffer_locked = FALSE; |
while (!get_key_press (1 << KEY_ESC)); // ESC |
mode = 0; |
rxd_buffer_locked = FALSE; |
} |
/Transportables_Koptertool/trunk/parameter.h |
---|
0,0 → 1,29 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _PARAMETER_H |
#define _PARAMETER_H |
//***************************************************************************** |
// |
void edit_parameter (void); |
void decimal (uint8_t data, uint8_t *text); |
#endif |
/Transportables_Koptertool/trunk/servo.c |
---|
0,0 → 1,128 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include "lcd.h" |
#include "timer.h" // Keys |
#include "servo.h" |
#define SERVO_MIN 313 // 1.0 ms (Servo min) |
#define SERVO_MAX 625 // 2.0 ms (Servo max) |
#define SERVO_CENTER 469 // 1.5 ms |
#define SERVO_PULSE 6250 // 20 ms |
//***************************************************************************** |
// |
ISR(TIMER1_COMPA_vect) |
{ |
PORTD |= (1 << PD7); |
} |
//***************************************************************************** |
// |
ISR(TIMER1_COMPB_vect) |
{ |
PORTD &= ~(1 << PD7); |
} |
//***************************************************************************** |
// |
void servo_test (void) |
{ |
uint8_t chg = 0; |
uint8_t step = 10; |
DDRD |= (1 << DDD7); // PD7 output |
TCCR1B = (1 << WGM12) | (1 << CS11) | (1 << CS10); // Prescaler 1/64, CTC mode |
// 1 step = 3,2 µs (@ 20 MHz) |
OCR1A = SERVO_PULSE; |
OCR1B = SERVO_CENTER; |
TIMSK1 = (1 << OCIE1A) | (1 << OCIE1B); |
lcd_cls (); |
lcd_printp (PSTR("Servo Tester"), 0); |
//lcd_printpns_at (0, 7, PSTR("-1 +1 Exit \x1d\x7c\x1c"), 0); |
lcd_printpns_at (0, 7, PSTR("-10 +10 Exit \x1d\x7c\x1c"), 0); |
lcd_frect (SGX, SGY, ((OCR1B - SERVO_MIN) * SMAXGX) / (SERVO_MAX - SERVO_MIN), 10, 1); |
//write_ndigit_number_u (SMX, SMY, ((OCR1B - SERVO_MIN) * 100) / (SERVO_MAX - SERVO_MIN), 3, 0); // Pulse width in % |
write_ndigit_number_u_100th(SMX, SMY, (OCR1B * 64) / 200 , 3, 0); // Pulse width in ms |
do |
{ |
if ((get_key_press (1 << KEY_PLUS) || get_key_rpt (1 << KEY_PLUS)) && (OCR1B < SERVO_MAX)) |
{ |
OCR1B += step; |
if (OCR1B > SERVO_MAX) |
{ |
OCR1B = SERVO_MAX; |
} |
chg++; |
} |
else if ((get_key_press (1 << KEY_MINUS) || get_key_rpt (1 << KEY_MINUS)) && (OCR1B > SERVO_MIN)) |
{ |
lcd_frect (SGX, SGY, ((OCR1B - SERVO_MIN) * SMAXGX) / (SERVO_MAX - SERVO_MIN), 10, 0); |
OCR1B -= step; |
if (OCR1B < SERVO_MIN) |
{ |
OCR1B = SERVO_MIN; |
} |
chg++; |
} |
else if (get_key_short (1 << KEY_ENTER)) |
{ |
lcd_frect (SGX, SGY, ((OCR1B - SERVO_MIN) * SMAXGX) / (SERVO_MAX - SERVO_MIN), 10, 0); |
OCR1B = SERVO_CENTER; |
chg++; |
} |
else if (get_key_long (1 << KEY_ENTER)) |
{ |
if (step == 1) |
{ |
step = 10; |
lcd_printpns_at (0, 7, PSTR("-10 +10 Exit \x1d\x7c\x1c"), 0); |
} |
else |
{ |
step = 1; |
lcd_printpns_at (0, 7, PSTR("-1 +1 Exit \x1d\x7c\x1c"), 0); |
} |
} |
if (chg) |
{ |
chg = 0; |
lcd_frect (SGX, SGY, ((OCR1B - SERVO_MIN) * SMAXGX) / (SERVO_MAX - SERVO_MIN), 10, 1); |
//write_ndigit_number_u (SMX, SMY, ((OCR1B - SERVO_MIN) * 100) / (SERVO_MAX - SERVO_MIN), 3, 0); // Pulse width in % |
write_ndigit_number_u_100th(SMX, SMY, (OCR1B * 64) / 200 , 3, 0); // Pulse width in ms |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
TIMSK1 = 0; |
} |
/Transportables_Koptertool/trunk/servo.h |
---|
0,0 → 1,41 |
/***************************************************************************** |
* Copyright (C) 2009-2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _SERVO_H |
#define _SERVO_H |
//***************************************************************************** |
// |
// text position |
#define SMX 0 |
#define SMY 3 |
// graphics position |
//#define SGX ((SMX + 3) * 6 + 1) // 3 for 3 digits |
#define SGX ((SMX + 4) * 6 + 1) // 4 for 4 digits |
#define SGY (SMY * 8 - 2) |
#define SMAXGX (128 - SGX) |
//***************************************************************************** |
// |
void servo_test (void); |
#endif |
/Transportables_Koptertool/trunk/settings.c |
---|
0,0 → 1,145 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009-2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/pgmspace.h> |
#include <avr/interrupt.h> |
#include "main.h" |
#include "menu.h" |
#include "lcd.h" |
#include "settings.h" |
#include "timer.h" |
#ifndef USE_MMT |
#include "lipo.h" |
#endif |
#include "eeprom.h" |
//***************************************************************************** |
// |
void set_toggledisplay(void) |
{ |
cli(); |
if (LCD_ORIENTATION == 0) |
LCD_ORIENTATION = 4; |
else |
LCD_ORIENTATION = 0; |
WriteParameter (); |
LCD_Init(); |
sei(); |
} |
//***************************************************************************** |
// |
void set_viewfont(void) |
{ |
uint8_t page; |
page = 0; |
lcd_view_font (page); |
do |
{ |
if (get_key_press (1 << KEY_PLUS) && (page < 1)) |
{ |
page++; |
lcd_view_font (page); |
} |
if (get_key_press (1 << KEY_MINUS) && (page > 0)) |
{ |
page--; |
lcd_view_font (page); |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
} |
//***************************************************************************** |
// |
#ifndef USE_MMT |
void set_lipo(void) |
{ |
lcd_cls(); |
lcd_printp_at(0, 0, PSTR("LiPo Under Voltage:"), 0); |
lcd_printp_at(0, 2, PSTR("Warn Voltage: "), 0); |
lcd_printpns_at (0, 7, PSTR(" - + Ok"), 0); |
do |
{ |
write_ndigit_number_u_10th(14, 2, AD_WarnLevel, 3, 0); |
if (get_key_press (1 << KEY_PLUS) && (AD_WarnLevel < 40)) |
{ |
AD_WarnLevel++; |
} |
else if (get_key_press (1 << KEY_MINUS) && (AD_WarnLevel > 20)) |
{ |
AD_WarnLevel--; |
} |
} |
while (!get_key_press (1 << KEY_ESC)); |
get_key_press(KEY_ALL); |
WriteParameter (); |
} |
#endif |
// Not really usefull :-) |
// testing.... |
//***************************************************************************** |
// |
void set_line(void) |
{ |
lcd_cls (); |
#if 1 |
lcd_line (10, 20, 100, 50, 1); // draw a line |
#else |
lcd_ecircle(22, 35, 18, 1); |
uint16_t old_d = 0; |
for (uint16_t i = 0; i < 360; i += 10) |
{ |
lcd_ecirc_line (22, 35, 17, old_d, 0); |
old_d = i; |
lcd_ecirc_line (22, 35, 17, i, 1); |
while (!get_key_press (1 << KEY_ENTER)); |
} |
#endif |
while (!get_key_press (1 << KEY_ESC)); |
} |
//***************************************************************************** |
// |
void set_rect(void) |
{ |
lcd_cls (); |
//lcd_rect (10, 20, 100, 40, 1); // draw a rect |
//lcd_ellipse(60, 30, 23, 20, 1); |
lcd_frect(10, 10, 20, -5, 1); |
write_ndigit_number_s (10, 1, -10, 2, 0); |
write_ndigit_number_s (10, 2, -10, 3, 0); |
write_ndigit_number_s (10, 3, -10, 4, 0); |
write_ndigit_number_s (10, 4, -10, 5, 0); |
while (!get_key_press (1 << KEY_ESC)); |
} |
/Transportables_Koptertool/trunk/settings.h |
---|
0,0 → 1,36 |
/***************************************************************************** |
* Copyright (C) 2008 Thomas Kaiser, thomas@ft-fanpage.de * |
* Copyright (C) 2009-2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _SETTINGS_H |
#define _SETTINGS_H |
//***************************************************************************** |
// |
void set_toggledisplay(void); |
void set_viewfont(void); |
void set_line(void); |
void set_rect(void); |
#ifndef USE_MMT |
void set_lipo(void); |
#endif |
#endif |
/Transportables_Koptertool/trunk/status.c |
---|
0,0 → 1,71 |
/***************************************************************************** |
* Copyright (C) 2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include "lcd.h" |
#include "timer.h" // Keys |
#include "usart.h" |
#include "status.h" |
#include "debug.h" |
//***************************************************************************** |
// |
void status (void) |
{ |
uint8_t line = 1; |
lcd_cls (); |
lcd_printp (PSTR("Status:"), 0); |
lcd_printpns_at (0, 7, PSTR(" Back "), 0); |
lcd_printp_at(0, line, PSTR("MMB Version: "), 0); |
lcd_write_number_u (VERSION_MAJOR); |
lcd_printp(PSTR("."), 0); |
lcd_write_number_u (VERSION_MINOR); |
line++; |
lcd_printp_at(0, line, PSTR("UART CRC ERR: "), 0); |
write_ndigit_number_u(15, line, stat_crc_error, 5, 0); |
line++; |
lcd_printp_at(0, line, PSTR("UART OVEFLOW: "), 0); |
write_ndigit_number_u(15, line, stat_overflow_error, 5, 0); |
line++; |
#if defined (__AVR_ATmega32__) |
lcd_printp_at(0, line, PSTR("Names: "), 0); |
write_ndigit_number_u(15, line, AnalogNamesRead, 5, 0); |
line++; |
#else |
lcd_printp_at(0, line, PSTR("Names NC: "), 0); |
write_ndigit_number_u(15, line, AnalogNamesRead[0], 5, 0); |
line++; |
lcd_printp_at(0, line, PSTR("AN FC: "), 0); |
write_ndigit_number_u(15, line, AnalogNamesRead[1], 5, 0); |
line++; |
#endif |
while (!get_key_press (1 << KEY_ESC)); |
} |
/Transportables_Koptertool/trunk/status.h |
---|
0,0 → 1,30 |
/***************************************************************************** |
* Copyright (C) 2010 Peter "woggle" Mack, mac@denich.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _STATUS_H |
#define _STATUS_H |
//***************************************************************************** |
// |
//***************************************************************************** |
// |
void status (void); |
#endif |
/Transportables_Koptertool/trunk/timer.c |
---|
0,0 → 1,177 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the key handling by Peter Dannegger * |
* see www.mikrocontroller.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include "main.h" |
#include "timer.h" |
volatile uint16_t timer; |
volatile uint16_t abo_timer; |
uint8_t key_state = 0; // debounced and inverted key state: |
// bit = 1: key pressed |
uint8_t key_press = 0; // key press detect |
uint8_t key_rpt; // key long press and repeat |
//***************************************************************************** |
// |
#if defined (__AVR_ATmega32__) |
ISR(TIMER0_COMP_vect) // Timer-Interrupt (100 Hz) |
#else |
ISR(TIMER0_COMPA_vect) // Timer-Interrupt (100 Hz) |
#endif |
{ |
static uint8_t ct0 = 0; |
static uint8_t ct1 = 0; |
static uint8_t rpt = 0; |
uint8_t i; |
// Key handling by Peter Dannegger |
// see www.mikrocontroller.net |
i = key_state ^ ~KEY_PIN; // key changed ? |
ct0 = ~(ct0 & i); // reset or count ct0 |
ct1 = ct0 ^ (ct1 & i); // reset or count ct1 |
i &= (ct0 & ct1); // count until roll over ? |
key_state ^= i; // then toggle debounced state |
key_press |= (key_state & i); // 0->1: key press detect |
if ((key_state & REPEAT_MASK) == 0) // check repeat function |
{ |
rpt = REPEAT_START; // start delay |
} |
if (--rpt == 0) |
{ |
rpt = REPEAT_NEXT; // repeat delay |
key_rpt |= (key_state & REPEAT_MASK); |
} |
if (timer > 0) |
{ |
timer --; |
} |
if (abo_timer > 0) |
{ |
abo_timer --; |
} |
} |
//***************************************************************************** |
// |
void TIMER0_Init (void) |
{ |
timer = 0; |
#if defined (__AVR_ATmega32__) |
TCCR0 = (1 << CS02) | (1 << CS00) | (1 << WGM01); // Prescaler 1024 |
OCR0 = (F_CPU / (100L * 1024L)) ; |
TIMSK |= (1 << OCIE0); // enable interrupt for OCR |
#else |
TCCR0A = (1 << WGM01); |
TCCR0B = (1 << CS02) | (1 << CS00); |
OCR0A = (F_CPU / (100L * 1024L)) ; |
TIMSK0 |= (1 << OCIE0A); // enable interrupt for OCR |
#endif |
} |
//***************************************************************************** |
// |
uint8_t get_key_press (uint8_t key_mask) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_press; // read key(s) |
key_press ^= key_mask; // clear key(s) |
SREG = sreg; // restore status register |
return key_mask; |
} |
//***************************************************************************** |
// |
uint8_t get_key_rpt (uint8_t key_mask) |
{ |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
key_mask &= key_rpt; // read key(s) |
key_rpt ^= key_mask; // clear key(s) |
SREG = sreg; // restore status register |
return key_mask; |
} |
//***************************************************************************** |
// |
uint8_t get_key_short (uint8_t key_mask) |
{ |
uint8_t ret; |
uint8_t sreg = SREG; |
// disable all interrupts |
cli(); |
ret = get_key_press (~key_state & key_mask); |
SREG = sreg; // restore status register |
return ret; |
} |
//***************************************************************************** |
// |
uint8_t get_key_long (uint8_t key_mask) |
{ |
return get_key_press (get_key_rpt (key_mask)); |
} |
//***************************************************************************** |
// |
uint8_t get_key_long2 (uint8_t key_mask) |
{ |
return get_key_press (get_key_rpt (key_press^key_mask)); |
} |
//***************************************************************************** |
// |
uint8_t get_key_long_rpt (uint8_t key_mask) |
{ |
return get_key_rpt (~key_press^key_mask); |
} |
/Transportables_Koptertool/trunk/timer.h |
---|
0,0 → 1,50 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* based on the key handling by Peter Dannegger * |
* see www.mikrocontroller.net * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _TIMER_H |
#define _TIMER_H |
#define KEY_PIN PINA |
#define KEY_ENTER PA7 |
#define KEY_ESC PA6 |
#define KEY_PLUS PA5 |
#define KEY_MINUS PA4 |
#define KEY_ALL ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) |
#define REPEAT_MASK ((1 << KEY_PLUS) | (1 << KEY_MINUS) | (1 << KEY_ENTER) | (1 << KEY_ESC)) // repeat: MODE |
#define REPEAT_START 50 // after 500ms |
#define REPEAT_NEXT 10 // every 100ms |
#define ABO_TIMEOUT 300 // 3 sec |
extern volatile uint16_t timer; |
extern volatile uint16_t abo_timer; |
void TIMER0_Init (void); |
uint8_t get_key_press (uint8_t key_mask); |
uint8_t get_key_rpt (uint8_t key_mask); |
uint8_t get_key_short (uint8_t key_mask); |
uint8_t get_key_long (uint8_t key_mask); |
uint8_t get_key_long2 (uint8_t key_mask); |
uint8_t get_key_long_rpt (uint8_t key_mask); |
#endif |
/Transportables_Koptertool/trunk/usart.c |
---|
0,0 → 1,515 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* taken some ideas from the C-OSD code from CaScAdE * |
* the MK communication routines are taken from the MK source * |
* (killagreg version) * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#include <avr/io.h> |
#include <avr/interrupt.h> |
#include <avr/pgmspace.h> |
#include <avr/wdt.h> |
#include <util/delay.h> |
#include <stdarg.h> |
#include "main.h" |
#include "usart.h" |
#include "lcd.h" |
uint8_t buffer[30]; |
volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
volatile uint8_t txd_complete = TRUE; |
volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
volatile uint8_t rxd_buffer_locked = FALSE; |
volatile uint8_t ReceivedBytes = 0; |
volatile uint8_t *pRxData = 0; |
volatile uint8_t RxDataLen = 0; |
volatile uint16_t stat_crc_error = 0; |
volatile uint16_t stat_overflow_error = 0; |
#ifdef DEBUG_UART |
//***************************************************************************** |
// USART1 transmitter ISR |
ISR (USART1_TXC_vect) |
{ |
static uint16_t ptr_txd_buffer = 0; |
uint8_t tmp_tx; |
if(!txd_complete) // transmission not completed |
{ |
ptr_txd_buffer++; // [0] was already sent |
tmp_tx = txd_buffer[ptr_txd_buffer]; |
// if terminating character or end of txd buffer was reached |
if((tmp_tx == '\r') || (ptr_txd_buffer == TXD_BUFFER_LEN)) |
{ |
ptr_txd_buffer = 0; // reset txd pointer |
txd_complete = TRUE; // stop transmission |
} |
UDR1 = tmp_tx; // send current byte will trigger this ISR again |
} |
// transmission completed |
else ptr_txd_buffer = 0; |
} |
//***************************************************************************** |
// |
void USART1_Init (void) |
{ |
// set clock divider |
#undef BAUD |
#define BAUD USART_BAUD |
#include <util/setbaud.h> |
UBRR1H = UBRRH_VALUE; |
UBRR1L = UBRRL_VALUE; |
#if USE_2X |
UCSR1A |= (1 << U2X1); // enable double speed operation |
#else |
UCSR1A &= ~(1 << U2X1); // disable double speed operation |
#endif |
// set 8N1 |
UCSR1C = (1 << UCSZ11) | (1 << UCSZ10); |
UCSR1B &= ~(1 << UCSZ12); |
// flush receive buffer |
while ( UCSR1A & (1 << RXC1) ) UDR1; |
// UCSR1B |= (1 << RXEN1) | (1 << TXEN1); |
// UCSR1B |= (1 << RXCIE1) | (1 << TXCIE1); |
UCSR1B |= (1 << RXEN1) | (1 << TXEN1); |
UCSR1B |= (1 << TXCIE1); |
} |
void debug () |
{ |
sprintf (txd_buffer, "test\r"); |
txd_complete = FALSE; |
UDR1 = txd_buffer[0]; |
} |
#endif |
#ifdef USART_INT |
//***************************************************************************** |
// USART0 transmitter ISR |
ISR (USART_TXC_vect) |
{ |
static uint16_t ptr_txd_buffer = 0; |
uint8_t tmp_tx; |
if(!txd_complete) // transmission not completed |
{ |
ptr_txd_buffer++; // [0] was already sent |
tmp_tx = txd_buffer[ptr_txd_buffer]; |
// if terminating character or end of txd buffer was reached |
if((tmp_tx == '\r') || (ptr_txd_buffer == TXD_BUFFER_LEN)) |
{ |
ptr_txd_buffer = 0; // reset txd pointer |
txd_complete = TRUE; // stop transmission |
} |
UDR = tmp_tx; // send current byte will trigger this ISR again |
} |
// transmission completed |
else ptr_txd_buffer = 0; |
} |
#endif |
//***************************************************************************** |
// |
ISR (USART_RXC_vect) |
{ |
static uint16_t crc; |
static uint8_t ptr_rxd_buffer = 0; |
uint8_t crc1, crc2; |
uint8_t c; |
c = UDR; // catch the received byte |
if (rxd_buffer_locked) |
{ |
return; // if rxd buffer is locked immediately return |
} |
// the rxd buffer is unlocked |
if ((ptr_rxd_buffer == 0) && (c == '#')) // if rxd buffer is empty and syncronisation character is received |
{ |
LED6_OFF; |
rxd_buffer[ptr_rxd_buffer++] = c; // copy 1st byte to buffer |
crc = c; // init crc |
} |
else if (ptr_rxd_buffer < RXD_BUFFER_LEN) // collect incomming bytes |
{ |
if(c != '\r') // no termination character |
{ |
rxd_buffer[ptr_rxd_buffer++] = c; // copy byte to rxd buffer |
crc += c; // update crc |
} |
else // termination character was received |
{ |
// the last 2 bytes are no subject for checksum calculation |
// they are the checksum itself |
crc -= rxd_buffer[ptr_rxd_buffer-2]; |
crc -= rxd_buffer[ptr_rxd_buffer-1]; |
// calculate checksum from transmitted data |
crc %= 4096; |
crc1 = '=' + crc / 64; |
crc2 = '=' + crc % 64; |
// compare checksum to transmitted checksum bytes |
if((crc1 == rxd_buffer[ptr_rxd_buffer-2]) && (crc2 == rxd_buffer[ptr_rxd_buffer-1])) |
{ // checksum valid |
rxd_buffer[ptr_rxd_buffer] = '\r'; // set termination character |
ReceivedBytes = ptr_rxd_buffer + 1;// store number of received bytes |
if (mode == rxd_buffer[2]) |
{ |
rxd_buffer_locked = TRUE; // lock the rxd buffer |
LED6_ON; |
// if 2nd byte is an 'R' enable watchdog that will result in an reset |
if(rxd_buffer[2] == 'R') {wdt_enable(WDTO_250MS);} // Reset-Commando |
} |
} |
else |
{ // checksum invalid |
stat_crc_error++; |
rxd_buffer_locked = FALSE; // unlock rxd buffer |
//LED5_TOGGLE; |
//lcd_putc(0, 6, rxd_buffer[2], 0); |
} |
ptr_rxd_buffer = 0; // reset rxd buffer pointer |
} |
} |
else // rxd buffer overrun |
{ |
//LED4_TOGGLE; |
stat_overflow_error++; |
ptr_rxd_buffer = 0; // reset rxd buffer |
rxd_buffer_locked = FALSE; // unlock rxd buffer |
} |
} |
//***************************************************************************** |
// |
void USART_Init (void) |
{ |
// set clock divider |
#undef BAUD |
#define BAUD USART_BAUD |
#include <util/setbaud.h> |
UBRRH = UBRRH_VALUE; |
UBRRL = UBRRL_VALUE; |
#if USE_2X |
UCSRA |= (1 << U2X); // enable double speed operation |
#else |
UCSRA &= ~(1 << U2X); // disable double speed operation |
#endif |
// set 8N1 |
#if defined (__AVR_ATmega8__) || defined (__AVR_ATmega32__) |
UCSRC = (1 << URSEL) | (1 << UCSZ1) | (1 << UCSZ0); |
#else |
UCSRC = (1 << UCSZ1) | (1 << UCSZ0); |
#endif |
UCSRB &= ~(1 << UCSZ2); |
// flush receive buffer |
while ( UCSRA & (1 << RXC) ) UDR; |
UCSRB |= (1 << RXEN) | (1 << TXEN); |
#ifdef USART_INT |
UCSRB |= (1 << RXCIE) | (1 << TXCIE); |
#else |
UCSRB |= (1 << RXCIE); |
#endif |
} |
//***************************************************************************** |
// disable the txd pin of usart |
void USART_DisableTXD (void) |
{ |
#ifdef USART_INT |
UCSRB &= ~(1 << TXCIE); // disable TX-Interrupt |
#endif |
UCSRB &= ~(1 << TXEN); // disable TX in USART |
DDRB &= ~(1 << DDB3); // set TXD pin as input |
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin |
} |
//***************************************************************************** |
// enable the txd pin of usart |
void USART_EnableTXD (void) |
{ |
DDRB |= (1 << DDB3); // set TXD pin as output |
PORTB &= ~(1 << PORTB3); // disable pullup on TXD pin |
UCSRB |= (1 << TXEN); // enable TX in USART |
#ifdef USART_INT |
UCSRB |= (1 << TXCIE); // enable TX-Interrupt |
#endif |
} |
//***************************************************************************** |
// short script to directly send a request thorugh usart including en- and disabling it |
// where <address> is the address of the receipient, <label> is which data set to request |
// and <ms> represents the milliseconds delay between data |
void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms) |
{ |
USART_EnableTXD (); // re-enable TXD pin |
unsigned char mstenth = ms/10; |
SendOutData(cmd, addr, 1, &mstenth, 1); |
// wait until command transmitted |
while (txd_complete == FALSE); |
USART_DisableTXD (); // disable TXD pin again |
} |
//***************************************************************************** |
// |
void USART_putc (char c) |
{ |
#ifdef USART_INT |
#else |
loop_until_bit_is_set(UCSRA, UDRE); |
UDR = c; |
#endif |
} |
//***************************************************************************** |
// |
void USART_puts (char *s) |
{ |
#ifdef USART_INT |
#else |
while (*s) |
{ |
USART_putc (*s); |
s++; |
} |
#endif |
} |
//***************************************************************************** |
// |
void USART_puts_p (const char *s) |
{ |
#ifdef USART_INT |
#else |
while (pgm_read_byte(s)) |
{ |
USART_putc (pgm_read_byte(s)); |
s++; |
} |
#endif |
} |
//***************************************************************************** |
// |
void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...) // uint8_t *pdata, uint8_t len, ... |
{ |
va_list ap; |
uint16_t pt = 0; |
uint8_t a,b,c; |
uint8_t ptr = 0; |
uint16_t tmpCRC = 0; |
uint8_t *pdata = 0; |
int len = 0; |
txd_buffer[pt++] = '#'; // Start character |
txd_buffer[pt++] = 'a' + addr; // Address (a=0; b=1,...) |
txd_buffer[pt++] = cmd; // Command |
va_start(ap, numofbuffers); |
if(numofbuffers) |
{ |
pdata = va_arg (ap, uint8_t*); |
len = va_arg (ap, int); |
ptr = 0; |
numofbuffers--; |
} |
while(len) |
{ |
if(len) |
{ |
a = pdata[ptr++]; |
len--; |
if((!len) && numofbuffers) |
{ |
pdata = va_arg(ap, uint8_t*); |
len = va_arg(ap, int); |
ptr = 0; |
numofbuffers--; |
} |
} |
else a = 0; |
if(len) |
{ |
b = pdata[ptr++]; |
len--; |
if((!len) && numofbuffers) |
{ |
pdata = va_arg(ap, uint8_t*); |
len = va_arg(ap, int); |
ptr = 0; |
numofbuffers--; |
} |
} |
else b = 0; |
if(len) |
{ |
c = pdata[ptr++]; |
len--; |
if((!len) && numofbuffers) |
{ |
pdata = va_arg(ap, uint8_t*); |
len = va_arg(ap, int); |
ptr = 0; |
numofbuffers--; |
} |
} |
else c = 0; |
txd_buffer[pt++] = '=' + (a >> 2); |
txd_buffer[pt++] = '=' + (((a & 0x03) << 4) | ((b & 0xf0) >> 4)); |
txd_buffer[pt++] = '=' + (((b & 0x0f) << 2) | ((c & 0xc0) >> 6)); |
txd_buffer[pt++] = '=' + ( c & 0x3f); |
} |
va_end(ap); |
for(a = 0; a < pt; a++) |
{ |
tmpCRC += txd_buffer[a]; |
} |
tmpCRC %= 4096; |
txd_buffer[pt++] = '=' + tmpCRC / 64; |
txd_buffer[pt++] = '=' + tmpCRC % 64; |
txd_buffer[pt++] = '\r'; |
txd_complete = FALSE; |
#ifdef USART_INT |
UDR = txd_buffer[0]; // initiates the transmittion (continued in the TXD ISR) |
#else |
for(a = 0; a < pt; a++) |
{ |
loop_until_bit_is_set(UCSRA, UDRE); |
UDR = txd_buffer[a]; |
} |
txd_complete = TRUE; |
#endif |
} |
//***************************************************************************** |
// |
void Decode64 (void) |
{ |
uint8_t a,b,c,d; |
uint8_t ptrIn = 3; |
uint8_t ptrOut = 3; |
uint8_t len = ReceivedBytes - 6; |
while (len) |
{ |
a = rxd_buffer[ptrIn++] - '='; |
b = rxd_buffer[ptrIn++] - '='; |
c = rxd_buffer[ptrIn++] - '='; |
d = rxd_buffer[ptrIn++] - '='; |
//if(ptrIn > ReceivedBytes - 3) break; |
if (len--) |
rxd_buffer[ptrOut++] = (a << 2) | (b >> 4); |
else |
break; |
if (len--) |
rxd_buffer[ptrOut++] = ((b & 0x0f) << 4) | (c >> 2); |
else |
break; |
if (len--) |
rxd_buffer[ptrOut++] = ((c & 0x03) << 6) | d; |
else |
break; |
} |
pRxData = &rxd_buffer[3]; |
RxDataLen = ptrOut - 3; |
} |
//***************************************************************************** |
// |
void SwitchToNC (void) |
{ |
// switch to NC |
USART_putc (0x1b); |
USART_putc (0x1b); |
USART_putc (0x55); |
USART_putc (0xaa); |
USART_putc (0x00); |
current_hardware = NC; |
_delay_ms (50); |
} |
//***************************************************************************** |
// |
void SwitchToFC (void) |
{ |
uint8_t cmd; |
if (current_hardware == NC) |
{ |
// switch to FC |
cmd = 0x00; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = FC; |
_delay_ms (50); |
} |
} |
//***************************************************************************** |
// |
void SwitchToMAG (void) |
{ |
uint8_t cmd; |
if (current_hardware == NC) |
{ |
// switch to MK3MAG |
cmd = 0x01; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = MK3MAG; |
_delay_ms (50); |
} |
} |
//***************************************************************************** |
// |
void SwitchToGPS (void) |
{ |
uint8_t cmd; |
if (current_hardware == NC) |
{ |
// switch to MKGPS |
cmd = 0x02; // 0 = FC, 1 = MK3MAG, 2 = MKGPS |
SendOutData('u', ADDRESS_NC, 1, &cmd, 1); |
current_hardware = MKGPS; |
_delay_ms (50); |
} |
} |
/Transportables_Koptertool/trunk/usart.h |
---|
0,0 → 1,127 |
/***************************************************************************** |
* Copyright (C) 2009 Peter "woggle" Mack, mac@denich.net * |
* taken some ideas from the C-OSD code from CaScAdE * |
* the MK communication routines are taken from the MK source * |
* (killagreg version) * |
* * |
* This program 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 2 of the License. * |
* * |
* This program 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, write to the * |
* Free Software Foundation, Inc., * |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
* * |
*****************************************************************************/ |
#ifndef _USART_H |
#define _USART_H |
//***************************************************************************** |
// |
#ifndef FALSE |
#define FALSE 0 |
#endif |
#ifndef TRUE |
#define TRUE 1 |
#endif |
// addresses |
#define ADDRESS_ANY 0 |
#define ADDRESS_FC 1 |
#define ADDRESS_NC 2 |
#define ADDRESS_MAG 3 |
// must be at least 4('#'+Addr+'CmdID'+'\r')+ (80 * 4)/3 = 111 bytes |
#define TXD_BUFFER_LEN 60 |
#define RXD_BUFFER_LEN 180 |
// Baud rate of the USART |
#define USART_BAUD 57600 |
//***************************************************************************** |
// |
extern uint8_t buffer[30]; |
extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN]; |
extern volatile uint8_t txd_complete; |
extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN]; |
extern volatile uint8_t rxd_buffer_locked; |
extern volatile uint8_t ReceivedBytes; |
extern volatile uint8_t *pRxData; |
extern volatile uint8_t RxDataLen; |
extern volatile uint16_t stat_crc_error; |
extern volatile uint16_t stat_overflow_error; |
//***************************************************************************** |
// |
void USART_Init (void); |
void USART_DisableTXD (void); |
void USART_EnableTXD (void); |
void USART_request_mk_data (uint8_t cmd, uint8_t addr, uint8_t ms); |
void USART_putc (char c); |
void USART_puts (char *s); |
void USART_puts_p (const char *s); |
void SendOutData (uint8_t cmd, uint8_t addr, uint8_t numofbuffers, ...); // uint8_t *pdata, uint8_t len, ... |
//void SendOutData(uint8_t cmd, uint8_t addr, uint8_t numofbuffers, uint8_t *pdata, uint8_t len); // uint8_t *pdata, uint8_t len, ... |
void Decode64 (void); |
void SwitchToNC (void); |
void SwitchToFC (void); |
void SwitchToMAG (void); |
void SwitchToGPS (void); |
//***************************************************************************** |
//Anpassen der seriellen Schnittstellen Register |
#if defined (__AVR_ATmega644__) || defined (__AVR_ATmega644P__) || defined (__AVR_ATmega168__) |
#define USART_RXC_vect USART0_RX_vect |
//----------------------- |
#define UCSRA UCSR0A |
#define UCSRB UCSR0B |
#define UCSRC UCSR0C |
#define UDR UDR0 |
#define UBRRL UBRR0L |
#define UBRRH UBRR0H |
// UCSRA |
#define RXC RXC0 |
#define TXC TXC0 |
#define UDRE UDRE0 |
#define FE FE0 |
#define UPE UPE0 |
#define U2X U2X0 |
#define MPCM MPCM0 |
// UCSRB |
#define RXCIE RXCIE0 |
#define TXCIE TXCIE0 |
#define UDRIE UDRIE0 |
#define TXEN TXEN0 |
#define RXEN RXEN0 |
#define UCSZ2 UCSZ02 |
#define RXB8 RXB80 |
#define TXB8 TXB80 |
// UCSRC |
#define UMSEL1 UMSEL01 |
#define UMSEL0 UMSEL00 |
#define UPM1 UPM01 |
#define UPM0 UPM00 |
#define USBS USBS0 |
#define UCSZ1 UCSZ01 |
#define UCSZ0 UCSZ00 |
#define UCPOL UCPOL0 |
//----------------------- |
#endif |
#endif |