Esempio n. 1
0
void initializeSnake(LLRoot * master) {
    /* Start Snake at 3 in length
     * x, y, z:layer
     */ 
      
    //if(master != NULL)      // Uh oh, non-empty snake?
    //    freeListLL(master); // No matter
    
    initializeLL(master);
    __disable_irq();
    addToHeadLL(master, 0, 0, 0);
    __enable_irq();
    // BEAMMEUPSCOTTY
    myCube.plotPoint(0, 0, 0);
    master->direction = XPOS;
    //master->length = 1;
   
    generateFruit(master);
    
    // Note: What if fruit is generated on snake?
    // The user will not be able to see it until all snake nodes have gone
    // over it
    
    tick.attach(&setSnakeFlag, SPEED);
}
Esempio n. 2
0
File: main.c Progetto: quano1/FS
int main()
{
    srand(time(NULL));

    unsigned char arrCharDevice[MAX_DEVICE][DEVICE_SIZE];
    unsigned char chDevice[] = {0xb,0x0,'F','S','o','f','\0',0x0,0x1,0x0,0x0};
    int i,j;
    device **ppd;
    device *tmp;

    linkedlist ll;
    initializeLL(&ll);  //initialize linkedlist
    initArrayDeviceData(arrCharDevice, MAX_DEVICE, DEVICE_SIZE);    //create data array of device
    ppd = initArrayDevice(arrCharDevice, MAX_DEVICE, DEVICE_SIZE);  //create array of device

    for(i=0; i<MAX_DEVICE; i++) {
        printDevice(*(ppd+i));
        addFirst(&ll, *(ppd+i));    //insert device into linkedlist
    }

    FL; printLL(&ll);

    tmp = (device*)chDevice;
    FL;printDevice(tmp);

    insertElement(&ll, tmp, 5);            //insert above device into linkedlist
    FL;printLL(&ll);

    rmElement(&ll,4);                       //remove element from linkedlist
    FL;printLL(&ll);

    free(tmp);
    freeLL(&ll);
    freeArrayDevice(&ppd, MAX_DEVICE);

    unsigned short asdf = 0xF0AA;
    unsigned char *asda = (char*)malloc(sizeof(asdf));

    FL; PRINT_HEX(asdf); EL;
    printf("%X", asdf&0xff); EL;

    convertToChar(asda, &asdf, 0, sizeof(short));

    FL; PRINT_HEX(*asda); SP; PRINT_HEX(*(asda+1)); EL;

    PRINT_UINT(sizeof(aaa)); EL;

    return 0;
}