コード例 #1
0
ファイル: IR.c プロジェクト: dagoodma/24_hour_bot_2013
char IsLeftTriggered() {
    unsigned int val = ReadADPin(IR_LEFT);
    char result = OFF;
    //dbprintf("\nMain=%d", val);
    if (val > irThreshold[IR_LEFT_I]) {
        #ifndef USE_SAMPLING
        irThreshold[IR_LEFT_I] = LEFT_LOW_THRESHOLD;
#endif
        result =  ON;
    }
    if (val < irThreshold[IR_LEFT_I]) {
        #ifndef USE_SAMPLING
        irThreshold[IR_LEFT_I] = LEFT_HIGH_THRESHOLD;
        #endif
        result = OFF;
    }

    #ifdef USE_LEDS
    if (result)
        LED_OnBank(LED_BANK3, 0x8);
    else
        LED_OffBank(LED_BANK3, 0x8);
    #endif

    return result;
}
コード例 #2
0
ファイル: LED.c プロジェクト: JustinEwing/R2BJT2
int main(void)
{
    int i, j, k, count;
    unsigned char pat;
    BOARD_Init();
    AD1PCFG = 0xFF;


    printf("\n\nLED Module Unit Test\n");
    printf("\nInitializing LED module");
    dbprintf("\nVerbose Debugging is ON");
    LED_Init();
    LED_AddBanks(LED_BANK1 | LED_BANK2 | LED_BANK3);
    //LED_RemoveBanks(LED_BANK1);

    for (count = 0; count < 10; count++) {
        printf("\npass %u", count);
        printf("\nTesting LED_OnBank");
        for (j = 0; j < NUMLEDBANKS; j++) {
            LED_OnBank((1 << j), 0x0F);
        }
        DELAY();
        printf("\nTesting LED OffBank");
        for (j = 0; j < NUMLEDBANKS; j++) {
            LED_OffBank((1 << j), 0x0F);
        }
        DELAY();
        LED_OnBank(LED_BANK1, 0x0F);
        DELAY();
        LED_OffBank(LED_BANK1, 0x0F);
        LED_OnBank(LED_BANK2, 0x0F);
        DELAY();
        LED_OffBank(LED_BANK2, 0x0F);
        LED_OnBank(LED_BANK3, 0x0F);
        DELAY();
        LED_OffBank(LED_BANK3, 0x0F);
        LED_OnBank(LED_BANK2, 0x0F);
        DELAY();
        LED_OffBank(LED_BANK2, 0x0F);
        LED_OnBank(LED_BANK1, 0x0F);
        DELAY();
        LED_OffBank(LED_BANK1, 0x0F);
        DELAY();
        LED_OnBank(LED_BANK1, 0x01);
        LED_OnBank(LED_BANK2, 0x01);
        LED_OnBank(LED_BANK3, 0x01);
        DELAY();
        printf("\nTesting LED_InvertBank");
        for (k = 0; k < 3; k++) {
            for (j = 0; j < NUMLEDBANKS; j++) {
                LED_InvertBank((1 << j), (0x03 << k));

            }
            DELAY();
        }
        for (k = 0; k < 3; k++) {
            for (j = 0; j < NUMLEDBANKS; j++) {
                LED_InvertBank((1 << j), (0x0C >> k));
            }
            DELAY();
        }

        printf("\nTesting LED_SetBank");
        pat = 0x05;
        for (k = 0; k < 4; k++) {
            for (j = 0; j < NUMLEDBANKS; j++) {
                LED_SetBank((1 << j), pat);
                printf("Input was %X and Get was %X\r\n", (pat), LED_GetBank((1 << j)));
                pat ^= 0x0F;
            }
            DELAY();
        }
    }

    LED_End();
    printf("\nLED module unit test ended");
    return 0;
}
コード例 #3
0
ファイル: LED.c プロジェクト: BananaSlug/24_hour_bot_2013
int main(void) {
    int i, j, k, count;
    unsigned char pat;
    SERIAL_Init();
    AD1PCFG = 0xFF;
    INTEnableSystemMultiVectoredInt();


    dbprintf("\nLED Module Unit Test\n\n");
    LED_Init(LED_BANK1 | LED_BANK2 | LED_BANK3);

    for(count=0; count<10; count++) {
        dbprintf("\nTesting LED_OnBank");
        for(j=0;j<NUMLEDBANKS;j++) {
            LED_OnBank((1<<j),0x0F);
        }
        DELAY();
        dbprintf("\nTesting LED OffBank");
        for(j=0;j<NUMLEDBANKS;j++) {
            LED_OffBank((1<<j),0x0F);
        }
        DELAY();
        LED_OnBank(LED_BANK1,0x0F);
        DELAY();
        LED_OffBank(LED_BANK1,0x0F);
        LED_OnBank(LED_BANK2,0x0F);
        DELAY();
        LED_OffBank(LED_BANK2,0x0F);
        LED_OnBank(LED_BANK3,0x0F);
        DELAY();
        LED_OffBank(LED_BANK3,0x0F);
        LED_OnBank(LED_BANK2,0x0F);
        DELAY();
        LED_OffBank(LED_BANK2,0x0F);
        LED_OnBank(LED_BANK1,0x0F);
        DELAY();
        LED_OffBank(LED_BANK1,0x0F);
        DELAY();
        LED_OnBank(LED_BANK1,0x01);
        LED_OnBank(LED_BANK2,0x01);
        LED_OnBank(LED_BANK3,0x01);
        DELAY();
        dbprintf("\nTesting LED_InvertBank");
        for(k=0;k<3;k++) {
            for(j=0;j<NUMLEDBANKS;j++) {
                LED_InvertBank((1<<j),(0x03<<k));
            }
            DELAY();
        }
        for(k=0;k<3;k++) {
            for(j=0;j<NUMLEDBANKS;j++) {
                LED_InvertBank((1<<j),(0x0C>>k));
            }
            DELAY();
        }
        dbprintf("\nTesting LED_SetFullState");
        LED_SetFullState(0x00);
        DELAY();
        for(j=0;j<12;j++) {
            LED_SetFullState(1<<j);
            DELAY();
        }
        for (j=0;j<12;j++) {
            LED_SetFullState(0x800 >> j);
            DELAY();
        }
        dbprintf("\nTesting LED_SetBank");
        pat = 0x05;
        for(k=0;k<4;k++) {
            for(j=0;j<NUMLEDBANKS;j++) {
                LED_SetBank((1<<j),pat);
                pat ^= 0x0F;
            }
            DELAY();
        }
    }

    LED_End();
    return 0;
}