int main (int args, char *argv[]) { if (wiringPiSetup () == -1) exit (1) ; int fd = lcdInit (2, 16, 4, RS, EN, D0,D1,D2,D3,D0,D1,D2,D3) ; if (fd == -1) { printf ("lcdInit 1 failed\n") ; return 1 ; } sleep (1) ; //显示屏初始化 lcdPosition (fd, 0, 0); lcdPuts (fd, " Raspberry Pi!"); //启动信息 sleep(1); if(argv[1]) { lcdPosition (fd, 0, 0) ; lcdPuts (fd, " ") ; //清空第一行 lcdPosition (fd, 0, 0) ; lcdPuts (fd, argv[1]) ; //命令行参数显示至第一行 } int start,now; while(1) { show_date(fd); cls(fd); show_sys_info(fd); sleep(5); cls(fd); start = show_run_time(fd); while(now - start < 5){ now = show_run_time(fd); sleep(1); } cls(fd); show_net_info(fd); sleep(5); cls(fd); show_client_count(fd); sleep(3); cls(fd); show_client_info(fd); cls(fd); show_temp(fd); sleep(5); cls(fd); } return 0; }
void main(void){ int count = 0; InitialChip(); delay_ms(200); SHTConReset(); set_tris_c(0b00011001); init(); //Pressure_init(); output_low(PIN_A0); //1 setup_adc_ports(NO_ANALOGS|VSS_VDD); //2 setup_adc(ADC_CLOCK_DIV_2); //setup_spi(SPI_SS_DISABLED); //3 setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1); //4 setup_timer_1(T1_DISABLED); //5 setup_timer_2(T2_DISABLED,0,1); //6 setup_ccp1(CCP_OFF); //7setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard enable_interrupts(INT_SSP); enable_interrupts(GLOBAL); if (gblTimeToUpdateScreen) { gblTimeToUpdateScreen = 0; updateScreen(); } while(true) { float temp, humid; //int16 sonic; float sonic; int error = oa_Temp_n_Humid(temp, humid); if (error) continue; //temp =3265; //humid =6532; show_temp(temp); show_humid(humid); //PC commented to change to Float //sonic = oa_Sonic(); //show_sonic(sonic); sonic = foa_Sonic(); //sonic = 6000/16-sonic; show_sonic(sonic); vTemp = temp; vHumid = humid; vSonic = sonic; } }
void read_rtc(bool show_extra_info) { static uint16_t counter = 0; if(g_show_temp && rtc_is_ds3231() && counter > 125) { int8_t t; uint8_t f; ds3231_get_temp_int(&t, &f); show_temp(t, f); } else { t = rtc_get_time(); if (t == NULL) return; show_time(t, g_24h_clock, show_extra_info); } counter++; if (counter == 250) counter = 0; }
void display_time(display_mode_t mode) // (wm) runs approx every 100 ms { static uint16_t counter = 0; #ifdef FEATURE_AUTO_DATE if (mode == MODE_DATE) { show_date(tm_, g_Region, (scroll_ctr++) * 10 / 38); // show date from last rtc_get_time() call } else #endif if (mode == MODE_ALARM_TEXT) { show_alarm_text(); } else if (mode == MODE_ALARM_TIME) { if (g_alarm_switch) { rtc_get_alarm_s(&alarm_hour, &alarm_min, &alarm_sec); show_alarm_time(alarm_hour, alarm_min, 0); } else { show_alarm_off(); } } // alternate temp and time every 2.5 seconds else if (g_show_temp && rtc_is_ds3231() && counter > 250) { int8_t t; uint8_t f; ds3231_get_temp_int(&t, &f); show_temp(t, f); } else { tm_ = rtc_get_time(); if (tm_ == NULL) return; #ifdef FEATURE_SET_DATE g_dateyear = tm_->Year; // save year for Menu g_datemonth = tm_->Month; // save month for Menu g_dateday = tm_->Day; // save day for Menu #endif #ifdef FEATURE_AUTO_DST if (tm_->Second%10 == 0) // check DST Offset every 10 seconds (60?) setDSToffset(g_DST_mode); if ((tm_->Hour == 0) && (tm_->Minute == 0) && (tm_->Second == 0)) { // MIDNIGHT! g_DST_updated = false; if (g_DST_mode) DSTinit(tm_, g_DST_Rules); // re-compute DST start, end } #endif #ifdef FEATURE_AUTO_DATE if (g_AutoDate && (tm_->Second == g_autotime) ) { save_mode = clock_mode; // save current mode clock_mode = MODE_DATE; // display date now g_show_special_cnt = g_autodisp; // show date for g_autodisp ms scroll_ctr = 0; // reset scroll position } else #endif #ifdef FEATURE_FLW if (mode == MODE_FLW) { if ((tm_->Second >= g_autotime - 3) && (tm_->Second < g_autotime)) show_time(tm_, g_24h_clock, 0); // show time briefly each minute else show_flw(tm_); // otherwise show FLW } else #endif show_time(tm_, g_24h_clock, mode); } counter++; if (counter == 500) counter = 0; }