Open csBlueChip opened 9 years ago
#include <stdio.h> //---------------------------------------------------------------------------------------------------------------------- // Enable(/disable) [1/0] debug support // This will enable extra output for developers // This should be disabled in RELEASE code #define DEBUG 1 //---------------------------------------------------------------------------------------------------------------------- // Declare all supported protocols // This will need a rethink if we support more than 32 protocols #define IR_JVC (0x00000001) #define IR_RC5 (0x00000002) #define IR_RC6 (0x00000004) #define IR_SONY (0x00000008) #define IR_NEC (0x00000010) #define IR_NONE (0x00000000) // No supported protocols #define IR_ALL (0xFFFFFFFF) // All supported protocols //---------------------------------------------------------------------------------------------------------------------- // Select supported protocols // Adding ENCODE (send) features will make the code a bit bigger // Adding DECODE (recv) features will make the code a lot bigger and slower // So only add support for the protocols you need #define IR_ENCODE (IR_JVC | IR_RC5) #define IR_DECODE (IR_RC5 | IR_RC6 | IR_SONY) //---------------------------------------------------------------------------------------------------------------------- // Compose support options #define IR_SUPPORT (IR_ENCODE | IR_DECODE) //+===================================================================================================================== // This creates tight code but isn't very readable // #if DEBUG void showSupport1 (void) { printf("JVC : "); # if (IR_SUPPORT & IR_JVC) # if (IR_ENCODE & IR_JVC) printf("ENCODE "); # endif // (IR_ENCODE & IR_JVC) # if (IR_DECODE & IR_JVC) printf("DECODE"); # endif // (IR_DECODE & IR_JVC) # else printf("disabled"); # endif // (IR_SUPPORT & IR_JVC) printf("\n"); printf("RC5 : "); # if (IR_SUPPORT & IR_RC5) # if (IR_ENCODE & IR_RC5) printf("ENCODE "); # endif // (IR_ENCODE & IR_RC5) # if (IR_DECODE & IR_RC5) printf("DECODE"); # endif // (IR_DECODE & IR_RC5) # else printf("disabled"); # endif // (IR_SUPPORT & IR_RC5) printf("\n"); printf("RC6 : "); # if (IR_SUPPORT & IR_RC6) # if (IR_ENCODE & IR_RC6) printf("ENCODE "); # endif // (IR_ENCODE & IR_RC6) # if (IR_DECODE & IR_RC6) printf("DECODE"); # endif // (IR_DECODE & IR_RC6) # else printf("disabled"); # endif // (IR_SUPPORT & IR_RC6) printf("\n"); printf("SONY : "); # if (IR_SUPPORT & IR_SONY) # if (IR_ENCODE & IR_SONY) printf("ENCODE "); # endif // (IR_ENCODE & IR_SONY) # if (IR_DECODE & IR_SONY) printf("DECODE"); # endif // (IR_DECODE & IR_SONY) # else printf("disabled"); # endif // (IR_SUPPORT & IR_SONY) printf("\n"); printf("NEC : "); # if (IR_SUPPORT & IR_NEC) # if (IR_ENCODE & IR_NEC) printf("ENCODE "); # endif // (IR_ENCODE & IR_NEC) # if (IR_DECODE & IR_NEC) printf("DECODE"); # endif // (IR_DECODE & IR_NEC) # else printf("disabled"); # endif // (IR_SUPPORT & IR_NEC) printf("\n"); } #endif // DEBUG //+===================================================================================================================== // This creates bloaty code but is very readable // #if DEBUG void showSupport2 (void) { #define PRINTF(s) printf("%s", s) PRINTF("JVC : "); PRINTF((IR_SUPPORT & IR_JVC) ? "" : "disabled"); PRINTF((IR_ENCODE & IR_JVC) ? "ENCODE " : ""); PRINTF((IR_DECODE & IR_JVC) ? "DECODE" : ""); PRINTF("\n"); PRINTF("RC5 : "); PRINTF((IR_SUPPORT & IR_RC5) ? "" : "disabled"); PRINTF((IR_ENCODE & IR_RC5) ? "ENCODE " : ""); PRINTF((IR_DECODE & IR_RC5) ? "DECODE" : ""); PRINTF("\n"); PRINTF("RC6 : "); PRINTF((IR_SUPPORT & IR_RC6) ? "" : "disabled"); PRINTF((IR_ENCODE & IR_RC6) ? "ENCODE " : ""); PRINTF((IR_DECODE & IR_RC6) ? "DECODE" : ""); PRINTF("\n"); PRINTF("SONY : "); PRINTF((IR_SUPPORT & IR_SONY) ? "" : "disabled"); PRINTF((IR_ENCODE & IR_SONY) ? "ENCODE " : ""); PRINTF((IR_DECODE & IR_SONY) ? "DECODE" : ""); PRINTF("\n"); PRINTF("NEC : "); PRINTF((IR_SUPPORT & IR_NEC) ? "" : "disabled"); PRINTF((IR_ENCODE & IR_NEC) ? "ENCODE " : ""); PRINTF((IR_DECODE & IR_NEC) ? "DECODE" : ""); PRINTF("\n"); #undef PRINTF } #endif // DEBUG //+===================================================================================================================== int main (void) { showSupport1(); showSupport2(); }
As this limited me to 32 protocols, i rejected it ...shame