/** * Get time stored in DS1307. * * Return the current time, * and also return the time this clock was last updated. * * @param now current time * @param last time clock was updated * @return true if ok, false if clock is not running. */ bool RTC_DS1307::getTime(DateTime* now, DateTime* last) { if(!isrunning()) return false; Wire.beginTransmission(DS1307_ADDRESS); Wire.write(0); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, 7); now->sec = Wire.read(); now->min = Wire.read(); now->hour = Wire.read(); now->dow = Wire.read(); now->day = Wire.read(); now->month = Wire.read(); now->year = Wire.read(); Wire.beginTransmission(DS1307_ADDRESS); Wire.write(0x10); Wire.endTransmission(); Wire.requestFrom(DS1307_ADDRESS, 7); last->sec = Wire.read(); last->min = Wire.read(); last->hour = Wire.read(); last->dow = Wire.read(); last->day = Wire.read(); last->month = Wire.read(); last->year = Wire.read(); return true; }
void buttons_process() { running = isrunning(); if(!running1 && running) { adc_timer_play(); } if(running1 && !running) { adc_timer_pause(); } if(menu_state == MENU_NONE) { if(right_pressed()) { decr_step(adc_period, ADC_PERIOD_MIN, ADC_PERIOD_MAX, (adc_period >> ADC_PERIOD_SCALE)); osd(); osd_delay(); } else if(left_pressed()) { incr_step(adc_period, ADC_PERIOD_MIN, ADC_PERIOD_MAX, (adc_period >> ADC_PERIOD_SCALE)); osd(); osd_delay(); } else if(up_pressed())
/* * enable internal oscilator if this is disable (start the clock) */ uint8_t Hotboards_rtcc::begin( void ) { if( isrunning( ) == 0 ) { writeReg( RTC_STARTADDR, 0x80 ); } }
static void check_prior_instance_running(char *progname) { char *prlist[2] = { progname, NULL }; int res = isrunning(prlist); if (res > 1) { exit(EXIT_SUCCESS); } } // check_prior_instance_running()
fstast(int lhnum,int appnum,int *node,int *stat,char *remtestscript,int *remnode,char *testscript,int *result,int *crit,char *name, int *timeo,int sleeptime,int pause) { FILE *f; char msg2[128]=""; int lhstat; sleep(pause); while (1) { if (isrunning("fsthbm") != YES) { exit(0); } if (isrunning("fstsvr") != YES) { exit(0); } if (*node != shm->nodeN && (*remnode == shm->nodeN || *remnode == 8)) { if (*stat != NOCHECK) { time(&now); sprintf(msg2,"lh%dapp%dremtesttimeo %d",lhnum,appnum,now); fsthahere(msg2); sprintf(msg,"/tmp/lh%dapp%dremtest%d",lhnum,appnum,now); f=fopen(msg,"w"); if (f == NULL) { sprintf(msg2,"Unable to open %s",msg); logit(msg2); } fprintf(f,"%s",remtestscript); fclose(f); sprintf(msg2,". %s",msg); if (system(msg2) != 0 ) { sprintf(msg2,"lh%dapp%dremtestres %d",lhnum,appnum,(*result+1)); fsthahere(msg2); sprintf(msg,"Application %s Failed Remote Test",name); logit(msg); sprintf(msg2,"/opt/FSTha/bin/notify REMOTE Application Test Failed: %s",msg); system(msg2); } unlink(msg); } } else if (*node == shm->nodeN) { if (*stat == NOCHECK) { sprintf(msg2,"lh%dapp%dtestres 0",lhnum,appnum); fsthahere(msg2); } else { time(&now); sprintf(msg2,"lh%dapp%dtesttimeo %d",lhnum,appnum,now); fsthahere(msg2); sprintf(msg,"/tmp/lh%dapp%dtest%d",lhnum,appnum,now); f=fopen(msg,"w"); if (f == NULL) { sprintf(msg2,"Unable to open %s",msg); logit(msg2); } fprintf(f,"%s",testscript); fclose(f); sprintf(msg2,". %s",msg); if (system(msg2) != 0 ) { sprintf(msg2,"lh%dapp%dtestres %d",lhnum,appnum,(*result+1)); fsthahere(msg2); if ( *crit == 0 ) { sprintf(msg,"Application %s Failed Test",name); logit(msg); } else if (*result <= *crit || *crit == 0 ) { sprintf(msg,"Application %s Failed Test %d out of %d times", name,*result,*crit); logit(msg); } } else { if (*result != 0) { sprintf(msg,"Application %s Test Passed Again", name); logit(msg); } sprintf(msg2,"lh%dapp%dtestres 0",lhnum,appnum); fsthahere(msg2); } sprintf(msg2,"lh%dapp%dtesttimeo 0",lhnum,appnum); fsthahere(msg2); sprintf(msg,"/tmp/lh%dapp%dtest%d",lhnum,appnum,now); unlink(msg); } sleep(sleeptime); } } }
/* * stop the internal rtcc clock */ void Hotboards_rtcc::stop( void ) { writeReg( RTC_STARTADDR, 0x00 ); while( isrunning( ) == 1 ); }