コード例 #1
0
ファイル: ws2812.cpp プロジェクト: 415DomSmith/node-pixel
void process_command(byte argc, byte *argv){
    // this takes a pixel command that has been determined and then
    // processes it appropriately.

    switch (argv[0]) {
        case PIXEL_SHOW: {
            show();
            break;
        }
        case PIXEL_SET_STRIP: {
            // sets the entirety of the strip to one colour
            uint32_t strip_colour = (uint32_t)argv[1] + ((uint32_t)argv[2]<<7) + ((uint32_t)argv[3]<<14) + ((uint32_t)argv[4] << 21);
            for (uint16_t i = 0; i<STRIP_LENGTH; i++) {
                strip.setPixelColor(i, strip_colour);
            }
            break;
        }
        case PIXEL_SET_PIXEL: {
            // sets the pixel given by the index to the given colour
            uint16_t index = (uint16_t)argv[1] + ((uint16_t)argv[2]<<7);
            uint32_t colour = (uint32_t)argv[3] + ((uint32_t)argv[4]<<7) + ((uint32_t)argv[5]<<14) + ((uint32_t)argv[6] << 21);
            strip.setPixelColor(index, colour);
            break;
        }
        case PIXEL_CONFIG: {
            // Sets the pin that the neopixel strip is on.
            strip.setPin((uint8_t)argv[1]);

            // TODO: Sort out the strand length stuff here.

            break;

        }
    }
}
コード例 #2
0
void InternetButton::begin(int i){
    if(i == 1 || i == 0){
        pin = 17;
        b1 = 1;
        b2 = 2;
        b3 = 3;
        b4 = 4;
    }

    ring.begin();
    ring.setPin(pin);
    ring.show();

    accelerometer.begin();                   // Setup SPI protocol, issue device soft reset
    accelerometer.beginMeasure();            // Switch ADXL362 to measure mode
    accelerometer.checkAllControlRegs();     // Burst Read all Control Registers, to check for proper setup

    pinMode(b1, INPUT_PULLUP);
    pinMode(b2, INPUT_PULLUP);
    pinMode(b3, INPUT_PULLUP);
    pinMode(b4, INPUT_PULLUP);
}