示例#1
0
int main() {
  
  /* struct sched_param sp; */
  /* memset( &sp, 0, sizeof(sp) ); */
  /* sp.sched_priority = 99; */
  /* sched_setscheduler( 0, SCHED_FIFO, &sp ); */
 

  uint16_t pwm_counter = 0;
  time_t rawtime;
  struct tm * timeinfo;
  initialise_io();
  
  initialise_digit(digit1);
  /* initialise_digit(digit2); */
  /* initialise_digit(digit3); */
  /* initialise_digit(digit4); */

  #ifdef gperf
  uint32_t loop_counter = 0;
  #endif
  char cursecond = 0;
  char oldsecond = 11; //out of usual bounds
  bool displayed = false;
  while (1) {
    
    // get current time
    time ( &rawtime );
    timeinfo = localtime ( &rawtime );
    cursecond = (timeinfo->tm_sec) % 10;
    if (pwm_counter < PWMTable[10]) {
      // display last digit of seconds of current time
      if (!displayed) {
        display_number (digit1,(cursecond));
        displayed = true;
      }
      oldsecond = cursecond;
    } else {
      if (displayed) {
        initialise_digit (digit1);
        displayed = false;
      }
    };
    
    // reset counter to 0
    if (pwm_counter++ > PWMTable[max_brightness]) {
      pwm_counter = 0;
      //printf("reset pwm_counter from %u to 0\n",pwm_counter-1);
    };
    #ifdef gperf
    if (loop_counter++ > 6000000) { 
      exit(0); };
    #endif
  }
}
示例#2
0
文件: 9p-client.c 项目: kyuba/duat
void multiplex_add_d9c_stdio
        (void (*attach) (struct d9r_io *, void *),
         void (*error)  (struct d9r_io *, const char *, void *),
         void (*close)  (struct d9r_io *, void *),
         void *aux)
{
    struct d9r_io *io = d9r_open_stdio();

    if (io == (struct d9r_io *)0) return;

    initialise_io (io, attach, error, close, aux);
}