Subversion Repositories Projects

Compare Revisions

Ignore whitespace Rev 1198 → Rev 1199

/C-OSD/C-Epilepsy/C-Epilepsy.aps
0,0 → 1,0
<AVRStudio><MANAGEMENT><ProjectName>C-Epilepsy</ProjectName><Created>10-Jul-2011 16:20:44</Created><LastEdit>17-Jul-2011 16:29:13</LastEdit><ICON>241</ICON><ProjectType>0</ProjectType><Created>10-Jul-2011 16:20:44</Created><Version>4</Version><Build>4, 17, 0, 655</Build><ProjectTypeName>AVR GCC</ProjectTypeName></MANAGEMENT><CODE_CREATION><ObjectFile>default\C-Epilepsy.elf</ObjectFile><EntryFile></EntryFile><SaveFolder>G:\Eigene Dateien\C-Projects\C-Epilepsy\</SaveFolder></CODE_CREATION><DEBUG_TARGET><CURRENT_TARGET>AVR Simulator</CURRENT_TARGET><CURRENT_PART>ATmega644P.xml</CURRENT_PART><BREAKPOINTS></BREAKPOINTS><IO_EXPAND><HIDE>false</HIDE></IO_EXPAND><REGISTERNAMES><Register>R00</Register><Register>R01</Register><Register>R02</Register><Register>R03</Register><Register>R04</Register><Register>R05</Register><Register>R06</Register><Register>R07</Register><Register>R08</Register><Register>R09</Register><Register>R10</Register><Register>R11</Register><Register>R12</Register><Register>R13</Register><Register>R14</Register><Register>R15</Register><Register>R16</Register><Register>R17</Register><Register>R18</Register><Register>R19</Register><Register>R20</Register><Register>R21</Register><Register>R22</Register><Register>R23</Register><Register>R24</Register><Register>R25</Register><Register>R26</Register><Register>R27</Register><Register>R28</Register><Register>R29</Register><Register>R30</Register><Register>R31</Register></REGISTERNAMES><COM>Auto</COM><COMType>0</COMType><WATCHNUM>0</WATCHNUM><WATCHNAMES><Pane0></Pane0><Pane1></Pane1><Pane2></Pane2><Pane3></Pane3></WATCHNAMES><BreakOnTrcaeFull>0</BreakOnTrcaeFull></DEBUG_TARGET><Debugger><modules><module></module></modules><Triggers></Triggers></Debugger><AVRGCCPLUGIN><FILES><SOURCEFILE>main.c</SOURCEFILE><SOURCEFILE>usart0.c</SOURCEFILE><SOURCEFILE>usart1.c</SOURCEFILE><SOURCEFILE>timer1.c</SOURCEFILE><SOURCEFILE>led_out.c</SOURCEFILE><SOURCEFILE>player.c</SOURCEFILE><SOURCEFILE>epi_helpers.c</SOURCEFILE><SOURCEFILE>nc_handler.c</SOURCEFILE><SOURCEFILE>buttons.c</SOURCEFILE><SOURCEFILE>eeprom.c</SOURCEFILE><SOURCEFILE>timer0.c</SOURCEFILE><SOURCEFILE>integer_math.c</SOURCEFILE><HEADERFILE>usart0.h</HEADERFILE><HEADERFILE>usart1.h</HEADERFILE><HEADERFILE>main.h</HEADERFILE><HEADERFILE>timer1.h</HEADERFILE><HEADERFILE>led_out.h</HEADERFILE><HEADERFILE>player.h</HEADERFILE><HEADERFILE>mk-data-structs.h</HEADERFILE><HEADERFILE>epi_helpers.h</HEADERFILE><HEADERFILE>nc_handler.h</HEADERFILE><HEADERFILE>buttons.h</HEADERFILE><HEADERFILE>eeprom.h</HEADERFILE><HEADERFILE>timer0.h</HEADERFILE><HEADERFILE>integer_math.h</HEADERFILE><OTHERFILE>default\C-Epilepsy.lss</OTHERFILE><OTHERFILE>default\C-Epilepsy.map</OTHERFILE></FILES><CONFIGS><CONFIG><NAME>default</NAME><USESEXTERNALMAKEFILE>YES</USESEXTERNALMAKEFILE><EXTERNALMAKEFILE>default\Makefile</EXTERNALMAKEFILE><PART>atmega644</PART><HEX>1</HEX><LIST>1</LIST><MAP>1</MAP><OUTPUTFILENAME>C-Epilepsy.elf</OUTPUTFILENAME><OUTPUTDIR>default\</OUTPUTDIR><ISDIRTY>1</ISDIRTY><OPTIONS/><INCDIRS/><LIBDIRS/><LIBS/><LINKOBJECTS/><OPTIONSFORALL>-Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums</OPTIONSFORALL><LINKEROPTIONS></LINKEROPTIONS><SEGMENTS/></CONFIG></CONFIGS><LASTCONFIG>default</LASTCONFIG><USES_WINAVR>1</USES_WINAVR><GCC_LOC>C:\WinAVR\bin\avr-gcc.exe</GCC_LOC><MAKE_LOC>C:\WinAVR\utils\bin\make.exe</MAKE_LOC></AVRGCCPLUGIN><IOView><usergroups/><sort sorted="0" column="0" ordername="0" orderaddress="0" ordergroup="0"/></IOView><Files><File00000><FileId>00000</FileId><FileName>usart1.c</FileName><Status>257</Status></File00000><File00001><FileId>00001</FileId><FileName>timer1.c</FileName><Status>257</Status></File00001><File00002><FileId>00002</FileId><FileName>timer1.h</FileName><Status>1</Status></File00002><File00003><FileId>00003</FileId><FileName>main.c</FileName><Status>259</Status></File00003><File00004><FileId>00004</FileId><FileName>main.h</FileName><Status>257</Status></File00004><File00005><FileId>00005</FileId><FileName>usart0.h</FileName><Status>257</Status></File00005><File00006><FileId>00006</FileId><FileName>usart0.c</FileName><Status>257</Status></File00006><File00007><FileId>00007</FileId><FileName>usart1.h</FileName><Status>1</Status></File00007><File00008><FileId>00008</FileId><FileName>led_out.h</FileName><Status>257</Status></File00008><File00009><FileId>00009</FileId><FileName>led_out.c</FileName><Status>257</Status></File00009><File00010><FileId>00010</FileId><FileName>player.c</FileName><Status>257</Status></File00010><File00011><FileId>00011</FileId><FileName>player.h</FileName><Status>257</Status></File00011><File00012><FileId>00012</FileId><FileName>epi_helpers.c</FileName><Status>257</Status></File00012><File00013><FileId>00013</FileId><FileName>epi_helpers.h</FileName><Status>1</Status></File00013><File00014><FileId>00014</FileId><FileName>mk-data-structs.h</FileName><Status>257</Status></File00014><File00015><FileId>00015</FileId><FileName>nc_handler.c</FileName><Status>257</Status></File00015><File00016><FileId>00016</FileId><FileName>nc_handler.h</FileName><Status>257</Status></File00016><File00017><FileId>00017</FileId><FileName>buttons.h</FileName><Status>1</Status></File00017><File00018><FileId>00018</FileId><FileName>buttons.c</FileName><Status>257</Status></File00018><File00019><FileId>00019</FileId><FileName>eeprom.c</FileName><Status>257</Status></File00019><File00020><FileId>00020</FileId><FileName>eeprom.h</FileName><Status>1</Status></File00020><File00021><FileId>00021</FileId><FileName>timer0.c</FileName><Status>257</Status></File00021><File00022><FileId>00022</FileId><FileName>timer0.h</FileName><Status>1</Status></File00022><File00023><FileId>00023</FileId><FileName>integer_math.c</FileName><Status>257</Status></File00023><File00024><FileId>00024</FileId><FileName>integer_math.h</FileName><Status>1</Status></File00024><File00025><FileId>00025</FileId><FileName>default\Makefile</FileName><Status>1</Status></File00025></Files><Events><Bookmarks></Bookmarks></Events><Trace><Filters></Filters></Trace></AVRStudio>
/C-OSD/C-Epilepsy/CHANGE.LOG
0,0 → 1,22
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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. *
****************************************************************************/
 
20110830-1050
+ first public release
/C-OSD/C-Epilepsy/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.
/C-OSD/C-Epilepsy/README.TXT
0,0 → 1,72
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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. *
****************************************************************************/
 
Look at
http://www.mylifesucks.de/oss/c-epilepsy/
to see what this is all about.
 
The hex-files are named in a pattern like:
C-Epilepsy-%BUILDDATE%-%CPU%-%HWVERSION%.hex
where:
%BUILDDATE% representing the date of the build, like a version number
for lazy people :)
%CPU% representing the type of AVR that is running your board
%HWVERSION% representing the different hardware versions (see below)
You have to pick the right hex-file for your hardware!
There are three different hardware revisions out there that I know about:
EPI10AQ41
The grey board hand made by akku65 himself.
You will need to build yourself a little converter to connect the board
to a NC/FC.
EPI-Side <--> FC/NC-Side
3 (TXD) 1 (TXD)
8 (RXD) 9 (RXD)
10 (GND) 7 (GND)
EPI10
The first black board available for sale, it has no connection from TXD to
pin1 of the FC-Connector, so you have to solder a little wire from
SV2(STK 500)'s pin3 to SV1(FC Connection)'s pin1.
The solder jumper SJ3 should be soldered to bridge 1-2 so we have RXD on pin9.
If you are going to connect the board directly to the NC/FC please cut the wire
for +5V (pin2 of the FC-port)!
EPI11
The _current_ board available.
The solder jumpers should be soldered to bridge 1-2 so we have RXD on pin9 and
TXD on pin1.
Leave SJ5 open in case you are going to use the board directly on the NC/FC.
C-Epilepsy supports several modes of animation and fancy stuff.
When pressing the "MODE"-Button you can toggle the basic modes like playing the
programmed animations or responding to the NC/FC stuff. After pressing the
button the board will blink with as many LEDs as the number of the mode you are
now running is (1-base, so Modes are 1 to a maximum of 48), this should be pretty
convenient to use.
With the "SET"-Button you can toggle the sub-modes of the mode you are in. For the
animation-playback mode this means the number of the animation you want to see. For
the others modes you should look in the sourcecode to see what is going on when...
 
A handy tool to make own animations without the need to compile and flash the firmware
each tim is the Epilepsy Animation Simulator (E.A.S.) which can be found here:
http://www.mylifesucks.de/oss/c-epilepsy/EAS.jar
It is a small Java-tool which can play the animations like they are entered in the
source here.
#EOF
/C-OSD/C-Epilepsy/buttons.c
0,0 → 1,64
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "buttons.h"
 
volatile uint8_t BUTTONS;
 
void buttons_init() {
DDRD &= ~((1 << PD4) | (1 << PD5)); // switches are input
PORTD |= ((1 << PD4) | (1 << PD5)); // pullups for switches
 
// unmask pin change interrupts 28 and 29
PCMSK3 |= ((1 << PCINT28) | (1 << PCINT29));
 
// enable PCINT31..24
PCICR |= (1 << PCIE3);
}
 
ISR(PCINT3_vect) {
uint8_t raw = PIND; // for different buttons
// mode
if (!(raw & (1 << MODE))) {
BUTTONS |= (1 << MODE);
}
// set
if (!(raw & (1 << SET))) {
BUTTONS |= (1 << SET);
}
}
 
uint8_t mode_pressed() {
if (BUTTONS & (1 << MODE)) {
BUTTONS &= ~(1 << MODE);
CEPILEPSYFLAGS |= CEPI_DIRTYEEPROM;
return 1;
}
return 0;
}
 
uint8_t set_pressed() {
if (BUTTONS & (1 << SET)) {
BUTTONS &= ~(1 << SET);
CEPILEPSYFLAGS |= CEPI_DIRTYEEPROM;
return 1;
}
return 0;
}
/C-OSD/C-Epilepsy/buttons.h
0,0 → 1,41
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
#ifndef _BUTTONS_H
#define _BUTTONS_H
 
#define MODE PD5
#define SET PD4
 
//#define MODE_PRESSED !(PIND & (1<<MODE))
//#define SET_PRESSED !(PIND & (1<<PD4))
 
#define BUTTON_MASKED_TIME 25
 
extern volatile uint8_t BUTTONS;
 
uint8_t mode_pressed(void);
uint8_t set_pressed(void);
 
void buttons_init(void);
 
#endif
/C-OSD/C-Epilepsy/c-epilepsy.aws
0,0 → 1,0
<AVRWorkspace><IOSettings><CurrentRegisters/></IOSettings><part name="ATMEGA644P"/><Files><File00000 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\usart1.c" Position="325 182 1115 579" LineCol="32 0" State="Maximized"/><File00001 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\timer1.c" Position="347 204 1151 593" LineCol="0 0" State="Maximized"/><File00002 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\timer1.h" Position="369 226 1173 615" LineCol="0 0" State="Maximized"/><File00003 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\main.c" Position="391 248 1195 637" LineCol="35 0" State="Maximized"/><File00004 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\main.h" Position="413 270 1217 659" LineCol="50 0" State="Maximized"/><File00005 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\usart0.h" Position="435 292 1239 681" LineCol="0 0" State="Maximized"/><File00006 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\usart0.c" Position="457 314 1261 703" LineCol="60 0" State="Maximized"/><File00007 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\usart1.h" Position="479 336 1283 725" LineCol="0 0" State="Maximized"/><File00008 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\led_out.h" Position="501 358 1305 747" LineCol="0 0" State="Maximized"/><File00009 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\led_out.c" Position="325 182 1129 571" LineCol="24 0" State="Maximized"/><File00010 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\player.c" Position="321 159 1313 755" LineCol="33 0" State="Maximized"/><File00011 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\player.h" Position="369 226 1173 615" LineCol="0 0" State="Maximized"/><File00012 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\epi_helpers.c" Position="391 248 1195 637" LineCol="60 0" State="Maximized"/><File00013 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\epi_helpers.h" Position="413 270 1217 659" LineCol="0 0" State="Maximized"/><File00014 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\mk-data-structs.h" Position="435 292 1239 681" LineCol="0 0" State="Maximized"/><File00015 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\nc_handler.c" Position="457 314 1261 703" LineCol="73 0" State="Maximized"/><File00016 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\nc_handler.h" Position="479 336 1283 725" LineCol="0 0" State="Maximized"/><File00017 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\buttons.h" Position="501 358 1305 747" LineCol="9 0" State="Maximized"/><File00018 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\buttons.c" Position="325 182 1129 571" LineCol="19 0" State="Maximized"/><File00019 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\eeprom.c" Position="347 204 1151 593" LineCol="32 0" State="Maximized"/><File00020 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\eeprom.h" Position="369 226 1173 615" LineCol="0 0" State="Maximized"/><File00021 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\timer0.c" Position="391 248 1195 637" LineCol="0 0" State="Maximized"/><File00022 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\timer0.h" Position="413 270 1217 659" LineCol="0 0" State="Maximized"/><File00023 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\integer_math.c" Position="435 292 1239 681" LineCol="0 0" State="Maximized"/><File00024 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\integer_math.h" Position="457 314 1261 703" LineCol="0 0" State="Maximized"/><File00025 Name="G:\Eigene Dateien\C-Projects\C-Epilepsy\default\Makefile" Position="479 336 1283 725" LineCol="0 0" State="Maximized"/></Files></AVRWorkspace>
/C-OSD/C-Epilepsy/default/Makefile
0,0 → 1,114
###############################################################################
# Makefile for the project C-Epilepsy
###############################################################################
 
## General Flags
PROJECT = C-Epilepsy
ifndef MCU
MCU = atmega644p
endif
 
TARGET = C-Epilepsy.elf
CC = avr-gcc
 
CPP = avr-g++
 
## Options common to compile, link and assembly rules
COMMON = -mmcu=$(MCU) -DMCU=$(MCU)
#COMMON =
 
## Compile options common for all C compilation units.
CFLAGS += $(COMMON)
CFLAGS += -Wall -gdwarf-2 -std=gnu99 -DF_CPU=20000000UL -O2 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d
 
## Assembly specific flags
ASMFLAGS = $(COMMON)
ASMFLAGS += $(CFLAGS)
ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2
 
## Linker flags
LDFLAGS = $(COMMON)
LDFLAGS += -Wl,-Map=C-Epilepsy.map
 
 
## Intel Hex file production flags
HEX_FLASH_FLAGS = -R .eeprom -R .fuse -R .lock -R .signature
 
HEX_EEPROM_FLAGS = -j .eeprom
HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load"
HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 --no-change-warnings
 
 
## Objects that must be built in order to link
OBJECTS = main.o usart0.o usart1.o timer0.o timer1.o led_out.o player.o epi_helpers.o nc_handler.o buttons.o eeprom.o integer_math.o
 
## Objects explicitly added by the user
LINKONLYOBJECTS =
 
## Build
all: $(TARGET) C-Epilepsy.hex C-Epilepsy.eep C-Epilepsy.lss size
 
## Compile
main.o: ../main.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
usart0.o: ../usart0.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
usart1.o: ../usart1.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
timer0.o: ../timer0.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
timer1.o: ../timer1.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
led_out.o: ../led_out.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
player.o: ../player.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
epi_helpers.o: ../epi_helpers.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
nc_handler.o: ../nc_handler.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
buttons.o: ../buttons.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
eeprom.o: ../eeprom.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
 
integer_math.o: ../integer_math.c
$(CC) $(INCLUDES) $(CFLAGS) -c $<
##Link
$(TARGET): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET)
 
%.hex: $(TARGET)
avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@
 
%.eep: $(TARGET)
-avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ || exit 0
 
%.lss: $(TARGET)
avr-objdump -h -S $< > $@
 
size: ${TARGET}
@echo
@avr-size -C --mcu=${MCU} ${TARGET}
 
## Clean target
.PHONY: clean
clean:
-rm -rf $(OBJECTS) C-Epilepsy.elf dep/* C-Epilepsy.hex C-Epilepsy.eep C-Epilepsy.lss C-Epilepsy.map
 
 
## Other dependencies
-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*)
 
/C-OSD/C-Epilepsy/default/dist.bat
0,0 → 1,62
@echo off
:: /****************************************************************************
:: * Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
:: * admiralcascade@gmail.com *
:: * Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
:: * *
:: * 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. *
:: ****************************************************************************/
 
set DATE=20110830-1050
::set DATE=DEVEL
 
:: date /T
 
:: clean up first
del *.hex
 
FOR %%C IN (atmega644 atmega644p) DO (
FOR %%H IN (EPI10AQ41 EPI10 EPI11) DO (
echo Building Hex file for: %%C on %%H
set CFLAGS=-DBUILDDATE=\"%DATE%\" -DHWVERSION=%%H
set MCU=%%C
make clean
make
move C-Epilepsy.hex C-Epilepsy-%DATE%-%%C-%%H.hex
)
)
 
:: clean up
make clean
 
:: show stats f.e. http://etree.org/cgi-bin/counter.cgi/software/md5sum.exe
md5sum *.hex
::dir /A *.hex
 
:: pack all stuff
mkdir C-Epilepsy-%DATE%
move *.hex C-Epilepsy-%DATE%
copy ..\CHANGE.LOG C-Epilepsy-%DATE%
copy ..\LICENSE.TXT C-Epilepsy-%DATE%
copy ..\README.TXT C-Epilepsy-%DATE%
:: 7zip command line version from http://www.7-zip.org
7za a -tzip C-Epilepsy-%DATE%.zip C-Epilepsy-%DATE%
 
rmdir /S /Q C-Epilepsy-%DATE%
 
dir /A C-Epilepsy-%DATE%.zip
 
::echo "building based on revision $REVISION is now DONE..."
 
/C-OSD/C-Epilepsy/eeprom.c
0,0 → 1,57
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "eeprom.h"
 
uint8_t EEMEM ee_checkbyte1 = CHECKBYTE1;
uint8_t EEMEM ee_checkbyte2 = CHECKBYTE2;
uint8_t EEMEM ee_main_mode = 0;
uint8_t EEMEM ee_nc_handler_state = 0;
uint8_t EEMEM ee_player_current_animation = 0;
 
void load_eeprom(void) {
if (eeprom_read_byte(&ee_checkbyte1) == CHECKBYTE1 && eeprom_read_byte(&ee_checkbyte2) == CHECKBYTE2) {
main_mode = eeprom_read_byte(&ee_main_mode);
nc_handler_state = eeprom_read_byte(&ee_nc_handler_state);
player_current_animation = eeprom_read_byte(&ee_player_current_animation);
player_changeanim(0);
}
}
 
void save_eeprom(void) {
eeprom_write_byte(&ee_checkbyte1, CHECKBYTE1);
eeprom_write_byte(&ee_checkbyte2, CHECKBYTE2);
eeprom_write_byte(&ee_main_mode, main_mode);
eeprom_write_byte(&ee_nc_handler_state, nc_handler_state);
eeprom_write_byte(&ee_player_current_animation, player_current_animation);
}
 
uint8_t eeprom_delay = 0;
 
void eeprom_timer_callback(void) {
eeprom_delay++;
if (eeprom_delay > 10) { // every 10sec check for dirty (mode change)
if (CEPILEPSYFLAGS & CEPI_DIRTYEEPROM) {
CEPILEPSYFLAGS &= ~(CEPI_DIRTYEEPROM);
save_eeprom();
}
eeprom_delay = 0;
}
}
/C-OSD/C-Epilepsy/eeprom.h
0,0 → 1,36
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
#ifndef _EEPROM_H
#define _EEPROM_H
 
#define CHECKBYTE1 23
#define CHECKBYTE2 1
 
 
void load_eeprom(void);
 
void save_eeprom(void);
 
void eeprom_timer_callback(void);
 
#endif
/C-OSD/C-Epilepsy/epi_helpers.c
0,0 → 1,94
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "epi_helpers.h"
 
// clear anomation
 
void clear(void) {
for (uint8_t i = 0; i < 7; i++) {
animation[i] = 0;
}
}
 
/**
* Display degree on the EPI
* @param animation the animation array to set the LEDs in
* @param degree 0-360 degree to set
*/
void degree2epi(uint8_t *animation, uint16_t degree) {
setLed(animation, (degree * 10) / 75, 1);
}
 
void setSingleLed(uint8_t *animation, uint8_t led) {
uint8_t segment = led / 8;
uint8_t ledleft = (led - segment * 8);
animation[segment] |= (128 >> (7 - ledleft));
}
 
void unsetSingleLed(uint8_t *animation, uint8_t led) {
uint8_t segment = led / 8;
uint8_t ledleft = (led - segment * 8);
animation[segment] &= ~(128 >> (7 - ledleft));
}
 
void setLed(uint8_t *animation, uint8_t led, uint8_t bool_clear) {
if (bool_clear) {
clear();
}
setSingleLed(animation, led);
}
 
void setLedsAround(uint8_t *animation, uint8_t center, uint8_t border, uint8_t bool_clear) {
animation_locked = 1;
if (bool_clear) {
clear();
}
setSingleLed(animation, center);
for (uint8_t b = 1; b <= border; b++) {
setSingleLed(animation, (center + b) % 48);
setSingleLed(animation, (center + (48 - b)) % 48);
}
animation_locked = 0;
}
 
void setLeds(uint8_t *animation, uint8_t leds) {
uint8_t segment = leds / 8;
for (uint8_t i = 0; i < 6; i++) {
if (i < segment) {
animation[i] = 255;
} else if (i == segment) {
uint8_t ledsleft = (leds - segment * 8);
//animation[i] = ~((uint8_t) (255 >> ledsleft));
animation[i] = ~((uint8_t)(255 << ledsleft));
} else {
animation[i] = 0;
}
}
}
 
void blinkNumer(uint8_t *animation, uint8_t num, uint8_t times) {
for (uint8_t i = 0; i < times; i++) {
setLeds(animation, num);
_delay_ms(150);
setLeds(animation, 0);
_delay_ms(100);
}
}
/C-OSD/C-Epilepsy/epi_helpers.h
0,0 → 1,32
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
#ifndef _EPI_HELPERS_H
#define _EPI_HELPERS_H
 
void clear(void);
void degree2epi(uint8_t *animation, uint16_t degree);
void setLed(uint8_t *animation, uint8_t led, uint8_t clear);
void setLedsAround(uint8_t *animation, uint8_t center, uint8_t border, uint8_t bool_clear);
void setLeds(uint8_t *animation, uint8_t leds);
void blinkNumer(uint8_t *animation, uint8_t num, uint8_t times);
 
#endif
/C-OSD/C-Epilepsy/integer_math.c
0,0 → 1,74
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "integer_math.h"
 
/*
CORDIC atan2 generated by http://vivara.net/cgi-bin/cordic.cgi?range=3600&n=10&size=int16_t
 
send bugs to Mark Rages <markrages@gmail.com>
 
result is one revolution per 3600 counts.
 
Performance test (error as percent of revolution):
Maximum: +0.088%
Mean: 0.006%
Minimum: -0.085%
mean(abs): 0.029%
rms: 0.001%
*/
 
int16_t atan2_fp(int16_t y, int16_t x) {
 
const int16_t cordic[] = {450, 266, 140, 71, 36, 18, 9, 4, 2, 1};
int16_t theta;
int16_t i;
 
if (x < 0) {
theta = 1800;
x = -x;
y = -y;
} else {
theta = 0;
}
 
for (i = 0; i < 10; i++) {
int16_t last_x;
 
last_x = x;
 
if (y < 0) { // sign=1
x -= y >> i;
y += last_x >> i;
theta -= cordic[i];
} else {
x += y >> i;
y -= last_x >> i;
theta += cordic[i];
}
}
 
#ifdef CORDIC_DEBUG
printf("%d", theta);
printf(" %lld\n", ((long long int)x) * 155L / 256);
#endif
 
return theta % 3600;
}
/C-OSD/C-Epilepsy/integer_math.h
0,0 → 1,28
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
#ifndef _INTEGER_MATH_H
#define _INTEGER_MATH_H
 
int16_t atan2_fp(int16_t y, int16_t x);
 
#endif
/C-OSD/C-Epilepsy/led_out.c
0,0 → 1,86
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "led_out.h"
 
#define ROWPORT PORTA
#define COLPORT PORTC
#define COLBASE (1 << PC2)
 
 
 
uint8_t col = 0;
uint8_t delay = 0;
 
uint8_t on = 0; // on-round or off-round
 
uint8_t animation[7];
volatile uint8_t animation_locked = 0;
 
#define TIMESON 7 // time slices to stay on
#define TIMESOFF 3 // time slices to stay off
 
void led_out_init() {
DDRA |= 0xFF; // Z0-Z7 output
DDRC |= ((1 << PC2) | (1 << PC3) | (1 << PC4) | (1 << PC5) | (1 << PC6) | (1 << PC7)); // S0-S5 output
}
 
void inline led_timer_callback() {
if (!animation_locked) {
// the Epilepsy was not build for powering the LEDs constantly, so we force a dim
delay--;
 
// only after
if (!delay) {
if (on) {
// time is up, go dark
ROWPORT = 0;
COLPORT &= ~(COLBASE << col);
 
// controll next col in next round
col = (col + 1) % 6;
 
delay = TIMESOFF;
} else {
COLPORT |= (COLBASE << col);
 
// hardware EPI10AQ41 has the rows reversed
// to convert old animations use
// http://www.mylifesucks.de/tools/epireverse/
#if HWVERSION == EPI10AQ41
uint8_t reverse = 0;
for (uint8_t mask = 128; mask; mask >>= 1) {
reverse >>= 1;
if (animation[col] & mask) {
reverse |= 128;
}
}
ROWPORT = reverse;
#else
ROWPORT = animation[col];
#endif
delay = TIMESON;
}
 
on = !on;
}
}
}
 
/C-OSD/C-Epilepsy/led_out.h
0,0 → 1,35
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
#include <avr/io.h>
#include <avr/interrupt.h>
 
 
#ifndef _LED_OUT_H
#define _LED_OUT_H
 
extern uint8_t animation[7];
extern volatile uint8_t animation_locked;
void led_out_init(void);
void led_timer_callback(void);
 
 
#endif
/C-OSD/C-Epilepsy/main.c
0,0 → 1,133
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
uint8_t main_mode = 0;
volatile uint8_t CEPILEPSYFLAGS = 0;
 
const uint8_t COLORS [][6] = {
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010}, // color one
{ 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101}, // color one
{ 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111, 0b11111111} // both colors
};
 
void pin_init(void) {
#if HWVERSION == EPI10AQ41
DDRB |= (1 << PB1) | (1 << PB2); // LEDs output
DDRD |= ((1 << PD6)); // S6 output, unused for now
#elif HWVERSION == EPI10
DDRD |= (1 << PD7) | (1 << PD3); // LEDs output
#else
// hardware 1.1
DDRD |= (1 << PD7); // dual led port output
#endif
}
 
 
// random init
 
unsigned short get_seed(void) {
unsigned short seed = 0;
unsigned short *p = (unsigned short*)(RAMEND + 1);
extern unsigned short __heap_start;
 
while (p >= &__heap_start + 1)
seed ^= *(--p);
 
return seed;
}
 
/* ##########################################################################
* MAIN
* ##########################################################################*/
int main(void) {
 
LEDRED_ON // boot
 
clear();
 
 
 
pin_init();
led_out_init();
timer0_init();
timer1_init();
usart0_init();
#ifdef __AVR_ATmega644P__
//usart1_init();
#endif
buttons_init();
load_eeprom();
 
 
// enable interrupts
sei();
 
 
unsigned short seed = get_seed();
srand(seed);
 
 
// selftest
//while (1) {
/*for (uint8_t times = 0; times < 5; times++) {
for (uint8_t i = 0; i < 48; i++) {
setLed(animation, i, 1);
_delay_ms(100);
animation[i] = 0;
}
}*/
//}
 
LEDRED_OFF // finished boot
LEDGREEN_ON
 
 
// clear serial screen
//usart0_puts("\x1B[2J\x1B[H");
/*usart0_puts_pgm(PSTR("C-Epilepsy came to say hello...\r\n"));
usart0_puts_pgm(PSTR("\tVersion: "));
usart0_puts_pgm(PSTR(BUILDDATE));
#ifdef __AVR_ATmega644P__
usart0_puts_pgm(PSTR(" atmega644p"));
#endif
usart0_puts_pgm(PSTR("\r\n"));*/
 
 
while (1) {
switch (main_mode) {
case 0:
player();
break;
case 1:
nc_handler();
break;
}
 
if (mode_pressed()) {
main_mode = (main_mode + 1) % 2; // % number of modes available
blinkNumer(animation, main_mode + 1, 5);
}
 
}
 
return 0;
}
/C-OSD/C-Epilepsy/main.h
0,0 → 1,112
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 _MAIN_H
#define _MAIN_H
 
 
#ifndef MCU
#define MCU atmega644p
//#ifndef __AVR_ATmega644P__
//#define __AVR_ATmega644P__
//#endif
#endif
 
#define EPI10AQ41 01 /* the grey one done by akku by hand */
#define EPI10 10
#define EPI11 11
 
//#define HWVERSION HW_10AQ41
 
#ifndef HWVERSION
#define HWVERSION EPI11
#endif
 
#if HWVERSION == EPI10AQ41
 
#define LEDGREEN_ON PORTB |= (1 << PB1);
#define LEDGREEN_OFF PORTB &= ~(1 << PB1);
#define LEDGREEN_TOGGLE PORTB ^= (1 << PB1);
#define LEDRED_ON PORTB |= (1 << PB2);
#define LEDRED_OFF PORTB &= ~(1 << PB2);
#define LEDRED_TOGGLE PORTB ^= (1 << PB2);
 
#elif HWVERSION == EPI10
 
#define LEDGREEN_ON PORTD |= (1 << PD7);
#define LEDGREEN_OFF PORTD &= ~(1 << PD7);
#define LEDGREEN_TOGGLE PORTD ^= (1 << PD7);
#define LEDRED_ON PORTD |= (1 << PD3);
#define LEDRED_OFF PORTD &= ~(1 << PD3);
#define LEDRED_TOGGLE PORTD ^= (1 << PD3);
 
#else
 
#define LEDGREEN_ON PORTD |= (1 << PD7);
#define LEDGREEN_OFF PORTD &= ~(1 << PD7);
#define LEDGREEN_TOGGLE PORTD ^= (1 << PD7);
#define LEDRED_ON PORTD &= ~(1 << PD7);
#define LEDRED_OFF PORTD |= (1 << PD7);
#define LEDRED_TOGGLE PORTD ^= (1 << PD7);
 
#endif
 
 
#include <avr/eeprom.h>
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include <avr/wdt.h>
#include <inttypes.h>
//#include <math.h>
#include <stdint.h>
#include <stdlib.h>
#include <util/delay.h>
#include <string.h>
#include "timer0.h"
#include "timer1.h"
#include "led_out.h"
#include "player.h"
#include "usart0.h"
#include "usart1.h"
#include "mk-data-structs.h"
#include "epi_helpers.h"
#include "integer_math.h"
#include "nc_handler.h"
#include "buttons.h"
#include "eeprom.h"
 
#ifndef BUILDDATE
#define BUILDDATE "DEVEL-BUILD" // build date, this is testing...
#endif
 
#ifndef FCONLY
#define FCONLY 0 // set to 1 if you do NOT have a NaviCtrl and the Epilepsy is
#endif // connected to the FC directly
 
 
extern const uint8_t COLORS [][6];
extern uint8_t main_mode;
extern volatile uint8_t CEPILEPSYFLAGS;
 
#define CEPI_DIRTYEEPROM 1
 
 
#endif
/C-OSD/C-Epilepsy/mk-data-structs.h
0,0 → 1,281
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 _MK_DATA_STRUCTS_H
#define _MK_DATA_STRUCTS_H
 
/* ##########################################################################
* 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
 
/**
* MikroKopter Slave-Addresses
* portions taken and adapted from
* http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.22a/mkprotocol.h
*/
#define ANY_ADDRESS 0
#define FC_ADDRESS 1
#define NC_ADDRESS 2
#define MK3MAG_ADDRESS 3
#define MKOSD_ADDRESS 4
#define BL_ADDRESS 5
 
/*
* FC Debug Struct
* portions taken and adapted from
* http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/uart.h
*/
typedef struct {
unsigned char Status[2];
signed int Analog[32]; // Debugwerte
} __attribute__((packed)) str_DebugOut;
 
typedef struct {
unsigned char SWMajor;
unsigned char SWMinor;
unsigned char ProtoMajor;
unsigned char ProtoMinor;
unsigned char SWPatch;
unsigned char HardwareError[5];
} __attribute__((packed)) str_VersionInfo;
 
/*
* NaviCtrl GPS Structs
* portions taken and adapted from
* http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.20c/ubx.h
*/
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;
 
#define INVALID 0x00
#define NEWDATA 0x01
#define PROCESSED 0x02
 
/*
* NaviCtrl OSD Structs
* portions taken and adapted from
* http://svn.mikrokopter.de/filedetails.php?repname=NaviCtrl&path=/tags/V0.24b/uart1.h
*/
typedef struct {
u16 Distance; // distance to target in dm
s16 Bearing; // course to target in deg
} __attribute__((packed)) GPS_PosDev_t;
 
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 FCStatusFlags2; // StatusFlags2 (since version 5 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;
 
#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_GPS_OK 0x80
 
/*
* MikroKopter Flags
* portions taken and adapted from
* http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/fc.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_VARIO_TRIM_UP 0x40
#define FCFLAG_VARIO_TRIM_DOWN 0x80
 
// FC STATUS FLAGS2
#define FC_STATUS2_CAREFREE 0x01
#define FC_STATUS2_ALTITUDE_CONTROL 0x02
 
#define DEFEKT_G_NICK 0x01
#define DEFEKT_G_ROLL 0x02
#define DEFEKT_G_GIER 0x04
#define DEFEKT_A_NICK 0x08
#define DEFEKT_A_ROLL 0x10
#define DEFEKT_A_Z 0x20
#define DEFEKT_PRESSURE 0x40
#define DEFEKT_CAREFREE_ERR 0x80
 
#define DEFEKT_I2C 0x01
#define DEFEKT_BL_MISSING 0x02
#define DEFEKT_SPI_RX_ERR 0x04
#define DEFEKT_PPM_ERR 0x08
#define DEFEKT_MIXER_ERR 0x10
 
/*
* MikroKopter config struct
* portions taken and adapted from
* http://svn.mikrokopter.de/filedetails.php?repname=FlightCtrl&path=/tags/V0.80d/eeprom.h
*/
typedef struct {
unsigned char Revision;
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 Gyro_Stability; // Wert : 0-16
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 ServoManualControlSpeed; //
unsigned char CamOrientation; //
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
//---CareFree---------------------------------------------
unsigned char OrientationAngle; // Where is the front-direction?
unsigned char OrientationModeControl; // switch for CareFree
unsigned char MotorSafetySwitch;
//------------------------------------------------
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];
unsigned char crc; // must be the last byte!
} __attribute__((packed)) paramset_t;
 
typedef struct {
u8 SettingsIndex;
paramset_t param;
} __attribute__((packed)) paramset_serial;
 
#endif
/C-OSD/C-Epilepsy/nc_handler.c
0,0 → 1,106
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "nc_handler.h"
 
volatile uint16_t nc_handler_time = 2; // request on first call
uint8_t nc_handler_state = 0;
 
 
NaviData_t naviData; // = malloc(sizeof(NaviData_t));
 
void inline nc_handler_timer_callback(void) {
nc_handler_time++;
}
 
void show_heading_home(void) {
uint16_t heading_home = (naviData.HomePositionDeviation.Bearing + 360) % 360;
degree2epi(animation, heading_home);
}
 
uint8_t vario_state = 0;
 
void show_vario(void) {
uint8_t index = naviData.Variometer > 0 ? 0 : 1;
if (naviData.Variometer == 0) index = 2;
for (uint8_t i = 0; i <= 6; i++) {
if (vario_state < 129) {
animation[i] = COLORS[index][i];
} else {
animation[i] = 0;
}
}
vario_state += 64;
}
 
void spirit_level(void) {
/*
basic principle is:
take degree nick as y coordinate of a point
take degree roll as x coordinate of a point
use atan2 to get the degree between the x-axis and that point
substract 90 degree since the y-axis is heding front
*/
int degree = atan2_fp(naviData.AngleNick, naviData.AngleRoll) / 10;
degree = (degree + 360 - 90) % 360;
//degree2epi(animation, degree);
setLedsAround(animation, (degree * 10) / 75, 2, 1);
}
 
void nc_handler_change_state(void) {
nc_handler_state = (nc_handler_state + 1) % 3;
blinkNumer(animation, nc_handler_state + 1, 3);
}
 
void inline nc_handler(void) {
if (nc_handler_time >= 2) {
usart0_request_mk_data(NC_ADDRESS, 'o', 100);
nc_handler_time = 0;
LEDGREEN_TOGGLE
}
if (rxd_buffer_locked) {
if (rxd_buffer[2] == 'O') { // NC OSD Data
Decode64();
LEDRED_TOGGLE
//naviData = *((NaviData_t*)pRxData);
memcpy((unsigned char *) & naviData, (unsigned char *)pRxData, sizeof (NaviData_t));
rxd_buffer_locked = 0;
}
}
 
switch (nc_handler_state) {
case 0:
show_heading_home();
break;
case 1:
show_vario();
break;
case 2:
spirit_level();
break;
}
if (set_pressed()) {
nc_handler_change_state();
}
}
 
 
 
/C-OSD/C-Epilepsy/nc_handler.h
0,0 → 1,35
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
#ifndef _NC_HANDLER_H
#define _NC_HANDLER_H
 
extern uint8_t nc_handler_state;
 
 
 
void nc_handler_timer_callback(void);
 
void nc_handler(void);
 
 
 
#endif
/C-OSD/C-Epilepsy/player.c
0,0 → 1,192
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "player.h"
 
const uint8_t SIMPLSESCAN [][8] PROGMEM = {
{ 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b10000000, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b10100000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b00001010, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10100000, 0b00000010, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00010101, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b00000001, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b00000101, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b01010100, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b01010000, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b01000000, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10}
};
 
 
const uint8_t TRIPLEROUND [][8] PROGMEM = {
{ 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b10000000, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b10100000, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b10101000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b10000000, 0b00001010, 0b00000000, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10100000, 0b00000010, 0b00000000, 10},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b10101000, 0b00000000, 10}
};
 
const uint8_t SOMETHING [][8] PROGMEM = {
{ 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b10101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00101010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00001010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00000010, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 5},
{ 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 5},
{ 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 5},
{ 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 5},
{ 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 5},
{ 0b01010101, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b01010101, 5},
{ 0b01010101, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b01010101, 5},
{ 0b01010101, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00000001, 0b00000000, 0b01000000, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00000101, 0b00000000, 0b01010000, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00010101, 0b00000000, 0b01010100, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b01010101, 0b00000000, 0b01010101, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b01010101, 0b01000001, 0b01010101, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b01010101, 0b01000001, 0b01010101, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b01010101, 0b00000000, 0b01010101, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00010101, 0b00000000, 0b01010100, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00000101, 0b00000000, 0b01010000, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00000001, 0b00000000, 0b01000000, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 0b01010101, 5},
{ 0b01010101, 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 0b01010101, 5},
{ 0b01010101, 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 0b01010101, 5},
{ 0b01010101, 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 0b01010101, 5},
{ 0b01010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010101, 5},
{ 0b00010101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010100, 5},
{ 0b00000101, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01010000, 5},
{ 0b00000001, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b01000000, 5}
};
 
 
 
volatile uint8_t runtime;
 
void inline player_timer_callback() {
if (runtime > 0) {
runtime--;
}
}
 
 
 
volatile uint8_t *animbase = (uint8_t*)SIMPLSESCAN;
volatile uint16_t animlength = sizeof (SIMPLSESCAN) / 8;
volatile uint16_t animindex = 0;
 
void inline player(void) {
if (runtime == 0) {
for (uint8_t i = 0; i <= 6; i++) {
animation[i] = pgm_read_byte(animbase + animindex * 8 + i);
}
runtime = pgm_read_byte(animbase + animindex * 8 + 7);
animindex++;
animindex %= animlength;
}
if (set_pressed()) {
player_changeanim(1);
}
}
 
typedef struct {
uint8_t* base;
uint16_t length;
} animation_t;
 
animation_t animations[] = {
{(uint8_t*)SIMPLSESCAN, sizeof (SIMPLSESCAN) / 8},
{(uint8_t*)TRIPLEROUND, sizeof (TRIPLEROUND) / 8},
{(uint8_t*)SOMETHING, sizeof (SOMETHING) / 8}
};
 
uint8_t player_current_animation = 0;
 
void player_changeanim(uint8_t increment) {
if (increment) {
player_current_animation = (player_current_animation + 1) % (sizeof (animations) / sizeof (animation_t));
blinkNumer(animation, player_current_animation + 1, 3);
}
animbase = animations[player_current_animation].base;
animlength = animations[player_current_animation].length;
animindex = 0;
}
/C-OSD/C-Epilepsy/player.h
0,0 → 1,33
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
#ifndef _PLAYER_H
#define _PLAYER_H
extern uint8_t player_current_animation;
 
void player(void);
 
void player_timer_callback(void);
 
void player_changeanim(uint8_t increment);
 
#endif
/C-OSD/C-Epilepsy/timer0.c
0,0 → 1,55
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "timer0.h"
 
// 8 bit timer
// unccritical stuff
// periodic critical stuff should go to the blocking timer1
 
volatile uint16_t uptime = 0;
 
void timer0_init() {
TCCR0B |= ((1 << CS02) | (1 << CS00)); // Prescale 1024
 
TIMSK0 |= (1 << TOIE0); // overflow enable
}
 
// every ~ 10ms = 10000us (9984us)
uint8_t timer0_scale_helper = 0;
 
ISR(TIMER0_OVF_vect, ISR_NOBLOCK) {
TCNT0 = 61;
 
player_timer_callback();
 
static uint16_t ticks = 0;
ticks++;
 
// ~1s
if (timer0_scale_helper++ >= 100) {
timer0_scale_helper = 0;
nc_handler_timer_callback();
eeprom_timer_callback();
uptime++;
//LEDRED_TOGGLE
}
 
}
/C-OSD/C-Epilepsy/timer0.h
0,0 → 1,35
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
 
#ifndef _TIMER0_H
#define _TIMER0_H
 
void timer0_init();
// 8 bit timer
 
extern volatile uint16_t uptime;
 
ISR(TIMER0_OVF_vect, ISR_NOBLOCK);
 
 
#endif
/C-OSD/C-Epilepsy/timer1.c
0,0 → 1,49
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "timer1.h"
 
// 16 bit timer
// critical for pwm and stuff
// periodic uncritical stuff should go to the non-blocking timer0
 
void timer1_init() {
// CTC Mode
TCCR1B = (1 << WGM12);
 
// Prescale 8
TCCR1B &= ~(1 << CS10);
TCCR1B |= (1 << CS11);
TCCR1B &= ~(1 << CS12);
 
// Compare every 100us at 20MHz
OCR1A = 250;
 
// Compare Interrupt enable
TIMSK1 |= (1 << OCIE1A);
}
 
// every 100us
 
ISR(TIMER1_COMPA_vect, ISR_BLOCK) {
 
// every 100us
led_timer_callback();
}
/C-OSD/C-Epilepsy/timer1.h
0,0 → 1,33
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
 
#ifndef _TIMER1_H
#define _TIMER1_H
 
void timer1_init();
// 16 bit timer
 
ISR(TIMER1_COMPA_vect, ISR_BLOCK);
 
 
#endif
/C-OSD/C-Epilepsy/usart0.c
0,0 → 1,293
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "usart0.h"
 
volatile uint8_t rxd_buffer_locked = 0;
volatile uint8_t rxd_buffer[RXD_BUFFER_LEN];
volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
volatile uint8_t ReceivedBytes = 0;
volatile uint8_t *pRxData = 0;
volatile uint8_t RxDataLen = 0;
 
/**
* init usart0
*/
void usart0_init() {
 
UBRR0H = ((F_CPU / (16UL * USART0_BAUD)) - 1) >> 8;
UBRR0L = (F_CPU / (16UL * USART0_BAUD)) - 1;
 
// Enable receiver and transmitter; enable RX interrupt
UCSR0B = (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0);
 
// set asynchronous mode
UCSR0C &= ~(1 << UMSEL01);
UCSR0C &= ~(1 << UMSEL00);
// no parity
UCSR0C &= ~(1 << UPM01);
UCSR0C &= ~(1 << UPM00);
// 1 stop bit
UCSR0C &= ~(1 << USBS0);
// 8-bit
UCSR0B &= ~(1 << UCSZ02);
UCSR0C |= (1 << UCSZ01);
UCSR0C |= (1 << UCSZ00);
 
// set direction of RXD0 and TXD0 pins
// set RXD0 (PD0) as an input pin
PORTD &= ~(1 << PORTD0);
DDRD &= ~(1 << DDD0);
// set TXD0 (PD1) as an output pin
//PORTD |= (1 << PORTD1);
//DDRD &= ~(1 << DDD1);
 
}
 
/**
* disable the txd pin of usart0
*/
void usart0_DisableTXD(void) {
UCSR0B &= ~(1 << TXCIE0); // disable TX-Interrupt
UCSR0B &= ~(1 << TXEN0); // disable TX in USART
DDRD &= ~(1 << DDD1); // set TXD pin as input
PORTD &= ~(1 << PORTD1); // disable pullup on TXD pin
}
 
/**
* enable the txd pin of usart0
*/
void usart0_EnableTXD(void) {
DDRD |= (1 << DDD1); // set TXD pin as output
PORTD &= ~(1 << PORTD1); // disable pullup on TXD pin
UCSR0B |= (1 << TXEN0); // enable TX in USART
UCSR0B |= (1 << TXCIE0); // enable TX-Interrupt
}
 
/**
* send a single <character> through usart0
*/
void usart0_putc(unsigned char character) {
// wait until UDR ready
while (!(UCSR0A & (1 << UDRE0)));
UDR0 = character;
}
 
/**
* send a <string> throught usart0
*/
void usart0_puts(char *s) {
while (*s) {
usart0_putc(*s);
s++;
}
}
 
/**
* send a PGM<string> throught usart0
*/
void usart0_puts_pgm(const char* string) {
while (pgm_read_byte(string) != 0x00)
usart0_putc(pgm_read_byte(string++));
}
 
/**
* transmit interrupt handler
* unused
*/
ISR(USART0_TX_vect, ISR_BLOCK) {
}
 
/*
* receive data through usart0
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Fbranches%2FV0.72p+Code+Redesign+killagreg%2Fuart0.c
*/
ISR(USART0_RX_vect, ISR_BLOCK) {
uint8_t c;
// catch the received byte
c = UDR0;
if (rxd_buffer_locked) return; // if rxd buffer is locked immediately return
static uint16_t crc;
static uint8_t ptr_rxd_buffer = 0;
static uint8_t c1 = 0;
static uint8_t c2 = 0;
static uint8_t usart_rx_ok = 0;
uint8_t crc1, crc2;
// the rxd buffer is unlocked
if (usart_rx_ok == 0) {
// if ((c2 == '#') && (c1 == 'b' || c1 == 'c') && (c == 'D' || c == 'V' || c == 'O')) {
 
if ((c2 == '#') && (c1 == 'b' || c1 == 'c') &&
#if FCONLY
(c == 'V' || c == 'D' || c == 'Q' || c == 'L')) { // version, debug, settings, LCD
#else
(c == 'V' || c == 'O' || c == 'Q')) { // version, OSD, settings
#endif
usart_rx_ok = 1;
rxd_buffer[ptr_rxd_buffer++] = c2;
crc = c2;
rxd_buffer[ptr_rxd_buffer++] = c1;
crc += c1;
rxd_buffer[ptr_rxd_buffer++] = c;
crc += c;
c2 = 0;
c1 = 0;
} else {
c2 = c1;
c1 = c;
}
} 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
rxd_buffer_locked = 1; // lock the rxd buffer
 
 
if (rxd_buffer[2] == 'R') {
wdt_enable(WDTO_250MS); // Reset-Commando
}
} else { // checksum invalid
rxd_buffer_locked = 0; // unlock rxd buffer
 
}
ptr_rxd_buffer = 0; // reset rxd buffer pointer
usart_rx_ok = 0;
}
} else { // rxd buffer overrun
ptr_rxd_buffer = 0; // reset rxd buffer
rxd_buffer_locked = 0; // unlock rxd buffer
usart_rx_ok = 0;
 
}
}
 
/**
* Decode the recevied Buffer
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void Decode64(void) {
uint8_t a, b, c, d;
uint8_t x, y, z;
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++] - '=';
 
x = (a << 2) | (b >> 4);
y = ((b & 0x0f) << 4) | (c >> 2);
z = ((c & 0x03) << 6) | d;
 
if (len--) rxd_buffer[ptrOut++] = x;
else break;
if (len--) rxd_buffer[ptrOut++] = y;
else break;
if (len--) rxd_buffer[ptrOut++] = z;
else break;
}
pRxData = &rxd_buffer[3];
RxDataLen = ptrOut - 3;
}
 
/**
* request Data through USART in special MK format by adding checksum and
* encode data in modified Base64
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void sendMKData(unsigned char cmd, unsigned char addr, unsigned char *snd, unsigned char len) {
unsigned int pt = 0;
unsigned char a, b, c;
unsigned char ptr = 0;
 
txd_buffer[pt++] = '#'; // Start-Byte
txd_buffer[pt++] = 'a' + addr; // Adress
txd_buffer[pt++] = cmd; // Command
while (len) {
if (len) {
a = snd[ptr++];
len--;
} else a = 0;
if (len) {
b = snd[ptr++];
len--;
} else b = 0;
if (len) {
c = snd[ptr++];
len--;
} 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);
}
 
// add crc
unsigned int tmpCRC = 0, i;
for (i = 0; i < pt; i++) {
tmpCRC += txd_buffer[i];
}
tmpCRC %= 4096;
txd_buffer[i++] = '=' + tmpCRC / 64;
txd_buffer[i++] = '=' + tmpCRC % 64;
txd_buffer[i++] = '\r';
 
usart0_puts((char*)txd_buffer);
}
 
/**
* 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 usart0_request_mk_data(uint8_t address, char label, uint8_t ms) {
// re-enable TXD pin
usart0_EnableTXD();
 
unsigned char mstenth = ms / 10;
sendMKData(label, address, &mstenth, 1);
// wait until UDR ready
while (!(UCSR0A & (1 << UDRE0)));
// disable TXD pin again
usart0_DisableTXD();
}
 
 
 
/C-OSD/C-Epilepsy/usart0.h
0,0 → 1,87
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
#ifndef _USART0_H
#define _USART0_H
 
#ifndef USART0_BAUD
#define USART0_BAUD 57600
#endif
 
 
#define RXD_BUFFER_LEN 180
#define TXD_BUFFER_LEN 20 // not so much needed since only requesting stuff
 
extern volatile uint8_t rxd_buffer_locked;
extern volatile uint8_t rxd_buffer[RXD_BUFFER_LEN];
extern volatile uint8_t txd_buffer[TXD_BUFFER_LEN];
extern volatile uint8_t ReceivedBytes;
extern volatile uint8_t *pRxData;
extern volatile uint8_t RxDataLen;
 
/**
* init usart0
*/
void usart0_init();
 
 
/**
* send a single <character> through usart0
*/
void usart0_putc(unsigned char character);
 
/**
* send a <string> throught usart0
*/
void usart0_puts(char *s);
 
/**
* send a PGM<string> throught usart0
*/
void usart0_puts_pgm(const char* string);
 
 
/**
* Decode the recevied Buffer
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void Decode64(void);
 
 
/**
* request Data through USART in special MK format by adding checksum and
* encode data in modified Base64
* portions taken and adapted from
* http://svn.mikrokopter.de/mikrowebsvn/filedetails.php?repname=FlightCtrl&path=%2Ftags%2FV0.72p%2Fuart.c
*/
void sendMKData(unsigned char, unsigned char, unsigned char*, unsigned char);
 
/**
* 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 usart0_request_mk_data(uint8_t, char, uint8_t);
 
 
#endif
/C-OSD/C-Epilepsy/usart1.c
0,0 → 1,66
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "usart1.h"
 
#ifdef __AVR_ATmega644P__
 
/**
* init usart1
*/
void usart1_init() {
UBRR1H = ((F_CPU / (16UL * USART1_BAUD)) - 1) >> 8;
UBRR1L = (F_CPU / (16UL * USART1_BAUD)) - 1;
 
// Enable receiver and transmitter; enable RX interrupt
UCSR1B = (1 << RXEN1) | (1 << TXEN1) | (1 << RXCIE1);
 
// set asynchronous mode
UCSR1C &= ~(1 << UMSEL11);
UCSR1C &= ~(1 << UMSEL10);
// no parity
UCSR1C &= ~(1 << UPM11);
UCSR1C &= ~(1 << UPM10);
// 1 stop bit
UCSR1C &= ~(1 << USBS1);
// 8-bit
UCSR1B &= ~(1 << UCSZ12);
UCSR1C |= (1 << UCSZ11);
UCSR1C |= (1 << UCSZ10);
 
// set direction of RXD1 and TXD1 pins
// set RXD1 (PD2) as an input pin
PORTD &= ~(1 << PORTD2);
DDRD &= ~(1 << DDD2);
// set TXD1 (PD3) as an output pin
//PORTD |= (1 << PORTD3);
//DDRD &= ~(1 << DDD3);
 
}
 
ISR(USART1_TX_vect, ISR_BLOCK) {
}
 
ISR(USART1_RX_vect, ISR_BLOCK) {
}
 
 
 
#endif // __AVR_ATmega644P__
/C-OSD/C-Epilepsy/usart1.h
0,0 → 1,42
/****************************************************************************
* Copyright (C) 2011 by Claas Anders "CaScAdE" Rathje *
* admiralcascade@gmail.com *
* Project-URL: http://www.mylifesucks.de/oss/c-epilepsy/ *
* *
* 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 "main.h"
 
#ifndef _USART1_H
#define _USART1_H
 
#ifdef __AVR_ATmega644P__
 
#ifndef USART1_BAUD
#define USART1_BAUD 57600
#endif
 
 
 
/**
* init usart1
*/
void usart1_init();
 
#endif // __AVR_ATmega644P__
 
 
#endif // ndef _USART1_H