void promptSDcard(struct Env* p, alt_up_sd_card_dev* device_reference) { /* * Loading Screen if SD card is not presented */ int frame = 25; struct animation* b = initAnimation((int*)pacman01, 1); addImage(b, initAnimation((int*)pacman02, 0)); addImage(b, initAnimation((int*)pacman03, 0)); addImage(b, initAnimation((int*)pacman04, 0)); struct Object *face; face= initObject(80, 120, 10, b, NULL); addToEnv(p, face); alt_alarm_start (&alarm,alt_ticks_per_second(),my_alarm_callback,(void*)p); while(!loadSDCard(device_reference)) { displayString("Please insert the SD card to start", frame, 30); frame++; setXY(face, face->x+4, face->y); if(face->x >245) face->x = 0; if(frame > 61) frame = 0; usleep(300000); }alt_up_char_buffer_clear(char_buffer); killAnimation(b); removeFromEnv(p, face); alt_alarm_stop(&alarm); alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 0); }
void alt_tick (void) { alt_alarm* next; alt_alarm* alarm = (alt_alarm*) alt_alarm_list.next; alt_u32 next_callback; /* update the tick counter */ _alt_nticks++; /* process the registered callbacks */ while (alarm != (alt_alarm*) &alt_alarm_list) { next = (alt_alarm*) alarm->llist.next; /* * Upon the tick-counter rolling over it is safe to clear the * roll-over flag; once the flag is cleared this (or subsequnt) * tick events are enabled to generate an alarm event. */ if ((alarm->rollover) && (_alt_nticks == 0)) { alarm->rollover = 0; } /* if the alarm period has expired, make the callback */ if ((alarm->time <= _alt_nticks) && (alarm->rollover == 0)) { next_callback = alarm->callback (alarm->context); /* deactivate the alarm if the return value is zero */ if (next_callback == 0) { alt_alarm_stop (alarm); } else { alarm->time += next_callback; /* * If the desired alarm time causes a roll-over, set the rollover * flag. This will prevent the subsequent tick event from causing * an alarm too early. */ if(alarm->time < _alt_nticks) { alarm->rollover = 1; } } } alarm = next; } /* * Update the operating system specific timer facilities. */ ALT_OS_TIME_TICK(); }