/* * Authors (alphabetical order) * - Andre Bernet * - Andreas Weitl * - Bertrand Songis * - Bryan J. Rentoul (Gruvin) * - Cameron Weeks * - Erez Raviv * - Gabriel Birkus * - Jean-Pierre Parisy * - Karl Szmutny * - Michael Blandford * - Michal Hlavinka * - Pat Mackenzie * - Philip Moss * - Rob Thomson * - Romolo Manfredini * - Thomas Husterer * * opentx is based on code named * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, * er9x by Erez Raviv: http://code.google.com/p/er9x/, * and the original (and ongoing) project by * Thomas Husterer, th9x: http://code.google.com/p/th9x/ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * 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. * */ #include "../opentx.h" #if defined(ROTARY_ENCODER_NAVIGATION) #if defined(TELEMETREZ) uint8_t TrotCount ; // TeZ version uint8_t LastTrotCount ; // TeZ version uint8_t RotEncoder ; #define ROTENC_DOWN() (RotEncoder != 0) #else uint8_t RotPosition ; int8_t LastRotaryValue ; int8_t Rotary_diff ; int8_t RotaryControl ; uint8_t RotEncoder ; #define ROTENC_DOWN() (RotEncoder & 0x20) #endif void rotencPoll() { #if defined(TELEMETREZ) if (TrotCount != LastTrotCount) { g_rotenc[0] = LastTrotCount = TrotCount ; } #else // Rotary Encoder polling PORTA = 0 ; // No pullups DDRA = 0x1F ; // Top 3 bits input asm(" rjmp 1f") ; asm("1:") ; uint8_t rotary ; rotary = PINA ; DDRA = 0xFF ; // Back to all outputs rotary &= 0xE0 ; RotEncoder = rotary ; // just read the lcd pin rotary &= 0xDF ; if ( rotary != RotPosition ) { uint8_t x ; x = RotPosition & 0x40 ; x <<= 1 ; x ^= rotary & 0x80 ; if ( x ) { g_rotenc[0] -= 1 ; } else { g_rotenc[0] += 1 ; } RotPosition = rotary ; } #endif // TELEMETREZ } #else #define ROTENC_DOWN() (0) #endif // ROTARY_ENCODER_NAVIGATION #ifndef SIMU inline void boardInit() { // Set up I/O port data directions and initial states DDRA = 0xff; PORTA = 0x00; // LCD data DDRB = 0x81; PORTB = 0x7e; //pullups keys+nc DDRC = 0x3e; PORTC = 0xc1; //pullups nc DDRD = 0x00; PORTD = 0xff; //pullups keys DDRE = (1< 0); break; #endif case SW_GEA: result = PINE & (1< only phone jack = slave mode static bool lastSlaveMode = false; static uint8_t checkDelay = 0; if (IS_AUDIO_BUSY()) { checkDelay = 20; } else if (checkDelay) { --checkDelay; } else { lastSlaveMode = (PING & (1< bl_current) OCR2 = pgm_read_byte(&pwmtable[++bl_current]); else OCR2 = pgm_read_byte(&pwmtable[--bl_current]); } } #endif