/* * Author - Mike Blandford * * Based on er9x by Erez Raviv * * Based on 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 #include #include "../src/opentx.h" void per10ms(void) { register uint32_t i ; uint8_t enuk = KEY_MENU; uint8_t in = ~readKeys() ; // Bits 3-6 are down, up, right and left // Try to only allow one at a #ifdef REVX static uint8_t current ; uint8_t dir_keys ; uint8_t lcurrent ; dir_keys = in & 0x78 ; // Mask to direction keys if ( ( lcurrent = current ) ) { // Something already pressed if ( ( lcurrent & dir_keys ) == 0 ) { lcurrent = 0 ; // No longer pressed } else { in &= lcurrent | 0x06 ; // current or MENU or EXIT allowed } } if ( lcurrent == 0 ) { // look for a key if ( dir_keys & 0x20 ) // right { lcurrent = 0x60 ; // Allow L and R for 9X } else if ( dir_keys & 0x40 ) // left { lcurrent = 0x60 ; // Allow L and R for 9X } else if ( dir_keys & 0x08 ) // down { lcurrent = 0x08 ; } else if ( dir_keys & 0x10 ) // up { lcurrent = 0x10 ; } in &= lcurrent | 0x06 ; // current or MENU or EXIT allowed } current = lcurrent ; #endif for( i=1; i<7; i++) { uint8_t value = in & (1<