int show_sys_info (int fd) { FILE *fp; char temp_char[15]; //树莓派温度 char Total[20]; //总内存量 char Free[20]; //空闲内存量 lcdPosition (fd, 0, 0); lcdPuts (fd, "System Info:"); fp=fopen("/sys/class/thermal/thermal_zone0/temp","r"); //读取树莓派温度 fgets(temp_char,9,fp); float Temp; Temp=atof(temp_char)/1000; lcdPosition (fd, 0, 1);lcdPrintf (fd, "%3.1fC", Temp) ; fclose(fp); fp=fopen("/proc/meminfo","r"); //读取内存信息 fgets(Total,19,fp); fgets(Total,4,fp); fgets(Free,9,fp); fgets(Free,19,fp); fgets(Free,4,fp); lcdPosition (fd, 7, 1); lcdPrintf (fd, "%3d/%3dMB", atoi(Free),atoi(Total)) ; fclose(fp); }
static long write_lcdout(lcdoutRecord *pstrout) { struct Pin_Info *pin_info = pstrout->dpvt; int handle = pin_info->handle; int bits = pin_info->bits; lcdHome(handle); lcdClear(handle); int dirs = pstrout->dirs; if(dirs == 1) { char *val = pstrout->val; lcdPuts(handle, val); // lcdPrintf(handle, "%s", val); } else { double inpa = 0.0; double inpb = 0.0; double inpc = 0.0; double inpd = 0.0; long status; status = dbGetLink(&(pstrout->inpa), DBF_DOUBLE, &inpa, 0, 0); status = dbGetLink(&(pstrout->inpb), DBF_DOUBLE, &inpb, 0, 0); status = dbGetLink(&(pstrout->inpc), DBF_DOUBLE, &inpc, 0, 0); status = dbGetLink(&(pstrout->inpd), DBF_DOUBLE, &inpd, 0, 0); char *stra = pstrout->stra; char *strb = pstrout->strb; char *strc = pstrout->strc; char *strd = pstrout->strd; char *unia = pstrout->unia; char *unib = pstrout->unib; char *unic = pstrout->unic; char *unid = pstrout->unid; lcdPosition(handle, 0,0); lcdPrintf(handle, "%s%.2f%s", stra, inpa, unia); lcdPosition(handle, 0,1); lcdPrintf(handle, "%s%.2f%s", strb, inpb, unib); if(bits > 2) { lcdPosition(handle, 0,2); lcdPrintf(handle, "%s%.2f%s", strc, inpc, unic); lcdPosition(handle, 0,3); lcdPrintf(handle, "%s%.2f%s", strd, inpd, unid); } } return 0; }
int show_net_info (int fd) { struct ifaddrs * ifAddrStruct=NULL; void * tmpAddrPtr=NULL; char * s1="eth0"; char buf[60]; lcdPosition (fd, 0, 0); lcdPuts (fd, "Network Info:"); getifaddrs(&ifAddrStruct); while (ifAddrStruct != NULL) { if (ifAddrStruct->ifa_addr->sa_family==AF_INET) { // check it is IP4 sprintf(buf, "%s", ifAddrStruct->ifa_name); if(strcmp(buf, s1) == 0){ // is a valid IP4 Address tmpAddrPtr=&((struct sockaddr_in *)ifAddrStruct->ifa_addr)->sin_addr; char addressBuffer[INET_ADDRSTRLEN]; inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN); lcdPosition (fd, 0, 1);lcdPrintf (fd, "%s", addressBuffer) ; } } ifAddrStruct=ifAddrStruct->ifa_next; } return 0; }
int main(){ if (wiringPiSetup() < 0) { fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ; return 1 ; } int lcdFD; lcdFD = lcdInit(2, 16, 4, RS, EN, D0, D1, D2, D3, D0, D1, D2, D3); lcdPosition(lcdFD, 0,0); lcdPrintf(lcdFD,"Waveshare"); lcdPosition(lcdFD, 0,1); lcdPrintf(lcdFD, "Pi"); }
void lcdup() { pthread_mutex_lock(&m_lcd); stdoutup(); delay(2); lcdClear(lcd); delay(4); lcdPrintf(lcd, "v: %i, b: %i", enc_val, btn_val); pthread_mutex_unlock(&m_lcd); }
int show_temp(fd){ lcdPosition (fd, 0, 0); lcdPuts (fd, "Temperature:"); int fdata = -1, ret; char *tmp1, tmp2[10], ch='t'; char dev_name[100] = "/sys/devices/w1_bus_master1/28-000005e38995/w1_slave"; long value; int integer, decimal; char buffer[100]; int i,j; float temp; if ((fdata = open(dev_name, O_RDONLY)) < 0) { //perror("open error"); lcdPosition (fd, 0, 1); lcdPrintf (fd, "open error"); return 0; } ret = read(fdata, buffer, sizeof(buffer)); if (ret < 0) { //perror("read error"); lcdPosition (fd, 0, 1); lcdPrintf (fd, "read error"); exit(1); } tmp1 = strchr(buffer, ch); sscanf(tmp1, "t=%s", tmp2); value = atoi(tmp2); integer = value / 1000; decimal = value % 1000; //printf("temperature is %d.%d\n", integer, decimal); sprintf(buffer, "%d.%d", integer, decimal); temp = atof(buffer); lcdPosition (fd, 0, 1); lcdPrintf (fd, "%.1fC", temp); close(fdata); return 0; }
///// scan keypad for key press void keyCol(void) { delay ( 1000 ); lcdPrintf ( "%c%c%c%c%c%c", ((RdPortI(PBDR)&0x20)?'.':'*'), ((RdPortI(PBDR)&0x10)?'.':'*'), ((RdPortI(PBDR)&0x08)?'.':'*'), ((RdPortI(PBDR)&0x04)?'.':'*'), ((RdPortI(PCDR)&0x02)?'.':'*'), ((RdPortI(PBDR)&0x01)?'.':'*') ); }
int show_date (int fd) { struct tm *newtime; char tmpbuf[128]; time_t timestamp; int start,now; time(×tamp); newtime=localtime(×tamp); start = timestamp; strftime(tmpbuf, 128, "%Y-%m-%d %a", newtime); lcdPosition (fd, 0, 0);lcdPrintf (fd, tmpbuf); while(now - start < 5){ time(×tamp); newtime=localtime(×tamp); now = timestamp; strftime(tmpbuf, 128, "%H:%M:%S", newtime); lcdPosition (fd, 0, 1);lcdPrintf (fd, tmpbuf); sleep(1); } }
int show_client_info(int fd) { FILE *fp; fp = fopen("/var/lib/misc/dnsmasq.leases","r"); char buf[200]; int i = 0; char * buf2; while(fgets(buf,sizeof(buf),fp) != NULL){ //printf("%s\n", buf); cls(fd); buf2 = strtok(buf, " "); while(buf2 != NULL) { //printf("%s\n", buf2); i++; if(i == 4) { lcdPosition (fd, 0, 0);lcdPrintf (fd, "%.16s", buf2); //printf("%s\n", s); } if(i == 3) { lcdPosition (fd, 0, 1);lcdPrintf (fd, "%.16s", buf2); //printf("%s\n", s); } buf2 = strtok(NULL, " "); //sleep(1); } i = 0; sleep(3); } fclose(fp); return 0; }
int main(void) { char buf[1024]; int i; int sck = socket(AF_INET, SOCK_DGRAM, 0); if(sck < 0) { perror("socket"); return 1; } struct ifconf ifc; ifc.ifc_len = sizeof(buf); ifc.ifc_buf = buf; if(ioctl(sck, SIOCGIFCONF, &ifc) < 0) { perror("ioctl(SIOCGIFCONF)"); return 1; } if (wiringPiSetup() == -1) { printf("wiringPiSetup failed!\nexiting.\n"); return 1; } int lcd = lcdInit(2, 16, 4, 15, 16, 7, 0, 2, 3, 0, 0, 0, 0); delay(5); if (lcd == -1) { printf("lcdinit failed!\nexiting.\n"); return 2; } lcdClear(lcd); delay(2); struct ifreq *ifr = ifc.ifc_req; int nInterfaces = ifc.ifc_len / sizeof(struct ifreq), y = 0; for(i = 0; i < nInterfaces; i++) { struct ifreq *item = &ifr[i]; if (strcmp(item->ifr_name, "lo") == 0) continue; lcdPosition(lcd, 0, y++); delay(2); lcdPrintf(lcd, "%s: %s", item->ifr_name, inet_ntoa(((struct sockaddr_in *)&item->ifr_addr)->sin_addr)); delay(5); } return 0; }
int show_client_count(int fd) { FILE *fp; fp = popen("hostapd_cli all_sta", "r"); char mid; int i = 0; lcdPosition (fd, 0, 0); lcdPuts (fd, "Client Info:"); while(!feof(fp)) { mid = fgetc(fp);//从txt文本中读取一个字符赋值给mid if(mid == '\n') //如果这个字符为换行符 i++; } //printf("\n行數:\n",i); lcdPosition (fd, 0, 1);lcdPrintf (fd, "Count: %d", (i-1)/8) ; fclose(fp); return 0; }
int show_run_time (int fd) { lcdPosition (fd, 0, 0); lcdPuts (fd, "Already Run:"); FILE *fp; char buf[50]; char *buf2; int timestamp; fp=fopen("/proc/uptime","r"); //读取内存信息 fgets(buf,sizeof(buf)-1,fp); buf2 = strtok(buf, " "); timestamp = atoi(buf2); int day = timestamp / 86400; int hour = (timestamp % 86400) / 3600; int minute = (timestamp % 3600) / 60; int second = timestamp % 60; lcdPosition (fd, 0, 1); lcdPrintf (fd, "%dD %dh %dm %ds", day, hour, minute, second); fclose(fp); return timestamp; }
int main() { int n; int c=0; int lcd; char ch[128]; int fd_port; int p; int spo2; char read_buf[20]; fd_port = open_serial(); // 장치 초기화 및 열기 if(wiringPiSetup()==-1) return 1; pinMode(LED1, OUTPUT); pinMode(LED2, OUTPUT); pinMode(LED3, OUTPUT); lcd= lcdInit(2,16,4,6,5,4,0,2,3,0,0,0,0); sleep(1); lcdPosition(lcd,0,0); lcdPrintf(lcd,"WElCOME!!"); delay(1000); lcdPosition(lcd,0,1); lcdPrintf(lcd,"Your Finger Test"); delay(1500); lcdClear(lcd); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading. "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading.. "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading... "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading. "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading.. "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading... "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading. "); delay(900); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Loading.. "); delay(900); lcdPosition(lcd,0,1); lcdPrintf(lcd,"S"); delay(700); lcdPosition(lcd,0,1); lcdPrintf(lcd,"ST"); delay(700); lcdPosition(lcd,0,1); lcdPrintf(lcd,"STA"); delay(700); lcdPosition(lcd,0,1); lcdPrintf(lcd,"STAR"); delay(700); lcdPosition(lcd,0,1); lcdPrintf(lcd,"START"); delay(1200); while (1) { n=read(fd_port,ch, sizeof(ch)); p=atoi(ch); printf("문자->%s 변환->%d", ch,p); lcdClear(lcd); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Handle Test!"); lcdPosition(lcd,0,1); lcdPrintf(lcd,"Pitch>%d",p); if(p<70) { digitalWrite(LED3,1); digitalWrite(LED2,0); digitalWrite(LED1,0); } else if(p<88){ digitalWrite(LED3,0); digitalWrite(LED2,1); digitalWrite(LED1,0); } else { c++; digitalWrite(LED3,0); digitalWrite(LED2,0); digitalWrite(LED1,1); if(c>5){ lcdClear(lcd); lcdPosition(lcd,0,0); lcdPrintf(lcd,"Congratulation"); lcdPosition(lcd,0,1); lcdPrintf(lcd,"Pitch>%d Cure!!",p); break; } } // delay(1); } close(fd_port); // 장치 닫기 return 0; }
int lcdProcess( void ) { int i,n; if( pattern != 1 ) { if( cnt_lcd >= 250 ) { cnt_lcd = 0; lcdPosition( 0, 0 ); /* 0123456789abcbef 1行16文字 */ lcdPrintf( "pattern = %3d ", pattern ); /* 01234567..89abcde.f 1行16文字 */ lcdPrintf( "sensor=%02x bar=%d ", sensor8, startbar_get() ); } return; } /* スイッチ4 設定値保存 */ if( getSwFlag(SW_4) ) { // パラメータ保存 writeDataFlashParameter(); } /* スイッチ3 メニュー+1 */ if( getSwFlag(SW_3) ) { lcd_pattern++; lcdPosition( 0, 0 ); lcdPrintf( " ", i ); lcdPrintf( " ", i ); if( lcd_pattern == 16 ) lcd_pattern = 1; } /* スイッチ2 メニュー−1 */ if( getSwFlag(SW_2) ) { lcd_pattern--; lcdPosition( 0, 0 ); lcdPrintf( " ", i ); lcdPrintf( " ", i ); if( lcd_pattern == 0 ) lcd_pattern = 11; } /* LCD、スイッチ処理 */ switch( lcd_pattern ) { case 1: /* サーボセンタ値調整 */ if( getSwFlag(SW_1) ) { servo_center++; if( servo_center > 10000 ) servo_center = 10000; } if( getSwFlag(SW_0) ) { servo_center--; if( servo_center < 1000 ) servo_center = 1000; } data_buff[DF_SERVO1] = servo_center >> 8; data_buff[DF_SERVO2] = servo_center & 0xff; handle( 0 ); /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789ab..f 1行16文字 */ lcdPrintf( "01 servo = %05d", servo_center ); /* 01234567..89abcde.f 1行16文字 */ lcdPrintf( "sensor=%02x bar=%d ", sensor8, startbar_get() ); break; case 2: /* PWM値調整 */ i = data_buff[DF_PWM]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_PWM] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789..bcdef0123456789..bcdef 1行16文字 */ lcdPrintf( "02 Max SPEED %03d ", i ); /* 01234567..89abcde.f 1行16文字 */ break; case 3: /* 比例値 Kp */ i = data_buff[DF_KP]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < -100 ) i = -100; } data_buff[DF_KP] = i; if(i > 0 ){ n = i % 10; i /= 10; }else{ n = -(i % 10); i /= 10; } /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789..bcdef0123456789..bcdef 1行16文字 */ lcdPrintf( "03 Kp %d.%d ", i,n ); /* 01234567..89abcde.f 1行16文字 */ break; case 4: /* 比例値 Kp */ i = data_buff[DF_KI]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < -100 ) i = -100; } data_buff[DF_KI] = i; if(i > 0 ){ n = i % 10; i /= 10; }else{ n = -(i % 10); i /= 10; } /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789..bcdef0123456789..bcdef 1行16文字 */ lcdPrintf( "04 Ki %d.%d ", i,n ); /* 01234567..89abcde.f 1行16文字 */ break; case 5: /* 比例値 Kp */ i = data_buff[DF_KD]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < -100 ) i = -100; } data_buff[DF_KD] = i; if(i > 0 ){ n = i % 10; i /= 10; }else{ n = -(i % 10); i /= 10; } /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789..bcdef0123456789..bcdef 1行16文字 */ lcdPrintf( "05 Kd %d.%d ", i,n ); /* 01234567..89abcde.f 1行16文字 */ break; case 6: /* タイマー値調整 */ i = ((unsigned char)data_buff[DF_STOP1]*0x100)|(unsigned char)data_buff[DF_STOP2]; if( getSwFlag(SW_1) ) { i+=100; if( i > 9000 ) i = 9000; } if( getSwFlag(SW_0) ) { i-=100; if( i < 0 ) i = 0; } data_buff[DF_STOP1] = i >> 8; data_buff[DF_STOP2] = i & 0xff; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "06 stop time %04d mS", i ); break; case 7://クランク時モーター速度 i = data_buff[DF_crank_motorS]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_crank_motorS] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "07 Crank Speed %03d", i ); break; case 8: i = data_buff[DF_crank_handlepwm]; if( getSwFlag(SW_1) ) { i++; if( i > 40 ) i = 40; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_crank_handlepwm] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "08 Crank handle %03d", i ); break; case 9://クランク時モーター OUT i = data_buff[DF_crank_motor1]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_crank_motor1] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "09 Crank motor OUT %03d", i ); break; case 10://クランク時モーター IN i = data_buff[DF_crank_motor2]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < -100 ) i = -100; } data_buff[DF_crank_motor2] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "10 Crank motor IN %03d", i ); break; case 11: i = data_buff[DF_lane_motorS]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_lane_motorS] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "11 LaneChange Speed %3d", i ); break; case 12: i = data_buff[DF_laneL_PWM]; if( getSwFlag(SW_1) ) { i++; if( i > 30 ) i = 30; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_laneL_PWM] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "12 LaneChange L handle %03d", i ); break; case 13: i = data_buff[DF_laneR_PWM]; if( getSwFlag(SW_1) ) { i++; if( i > 30 ) i = 30; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_laneR_PWM] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "13 LaneChange R handle %03d", i ); break; case 14: i = data_buff[DF_lane_motorL]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_lane_motorL] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "14 LaneChange Motor OUT %03d", i ); break; case 15: i = data_buff[DF_lane_motorR]; if( getSwFlag(SW_1) ) { i++; if( i > 100 ) i = 100; } if( getSwFlag(SW_0) ) { i--; if( i < 0 ) i = 0; } data_buff[DF_lane_motorR] = i; /* LCD処理 */ lcdPosition( 0, 0 ); /* 0123456789abcdef0123456789abcdef 1行16文字 */ lcdPrintf( "15 LaneChange Motor IN %03d", i ); break; } }
/** * Open main editor interface windows */ void openEditor(struct options_values *options, struct editor *e) { char title[100]; int i; struct panelw *p0, *p1, *p2; FIELD *f[2]; openI2LCD2(&e->lcd, options->bus, options->address, options->columns, options->rows); lcdPower(&e->lcd, POWERON); lcdSetBacklight(&e->lcd, 0x3f); lcdSetContrast(&e->lcd, 0x17); lcdBlink(&e->lcd, 1); lcdCursor(&e->lcd, 1); lcdClear(&e->lcd); lcdPrintf(&e->lcd, "LCDEd v1.0\x01"); e->brght = 0x3f; e->contr = 0x17; snprintf(title, 100, "LCD %dx%d:", e->lcd.cols, e->lcd.rows); p0 = openWindow(1, 1, e->lcd.cols, e->lcd.rows, COLOR_PAIR(1), title, "LCD Content editor\n" "\tCursor keys to move cursor around\n" "\t'PgUp'\tmoves cursor to the top row\n" "\t'PgDown'\tmoves cursor to the bottom row\n" "\t'Home'\tmoves cursor to the first column in row\n" "\t'End'\tmoves cursor to the last column in row\n\n" "\t'F1'\tto clear LCD screen\n" "\t'F3'/'F4'\tto decrease/increase contrast\n" "\t'F5'/'F6'\tto decrease/increase brightness\n", lcdWindowHandler, lcdActivateHandler); lcdSetCursor(&e->lcd, p0->col, p0->row); p0->lcd = &e->lcd; p1 = openWindow((p0->x + (p0->width < 20 ? 20 : p0->width)) + 1, 1, 5, 8, COLOR_PAIR(1), "C-1:", "Graphic character editor\n" "\tCursor keys to move cursor around\n" "\t'Space' to toggle pixel under the cursor\n" "\t'PgUp'\tPrevious character\n" "\t'PgDown'\tNext character\n" "\t'F1'\tto wipe character\n" "\t'F2'\tto reverse colors\n" "\t'S'\tTo save GC to header file\n", gcWindowHandler, gcActivateHandler); p1->lcd = &e->lcd; p1->gcn = 0; p2 = openWindow((p1->x + p1->width), 1, 2, 8, COLOR_PAIR(3), "Hex", "Hex editor for graphic character\n" "\tCursor keys to move cursor around\n" "\tSet value 0-f for value under cursor\n" "\t'PgUp'\tPrevious character\n" "\t'PgDown'\tNext character\n" "\t's'\tTo save GC to header file\n", gchWindowHandler, NULL); p2->lcd = &e->lcd; e->_actw = p0; joinWindows(p0, p1); joinWindows(p1, p2); joinWindows(p2, p0); e->potss = openWindow(p0->x, p0->y + p0->height + 1, 20, 3, COLOR_PAIR(3), "Potentiometers:", "", NULL, NULL); mvwprintw(e->potss->win, 1, 1, "Brightness:\t0x%02X", e->brght); mvwprintw(e->potss->win, 2, 1, "Contrast:\t0x%02X", e->contr); refresh(); }
static void showLine(lcd_line_e line, int screenY) { static char buffer[10]; switch (line) { case LL_VERSION: lcdPrintf("version %s", VCS_VERSION); return; case LL_CONFIG: lcdPrintf("config %s", getConfigurationName(engineConfiguration->engineType)); return; case LL_RPM: lcdPrintf("RPM %d", getRpmE(engine)); { char sdState; if (boardConfiguration->isSdCardEnabled) { sdState = isSdCardAlive() ? 'L' : 'n'; } else { sdState = 'D'; } int seconds = getTimeNowSeconds(); if (seconds < 10000) { lcdPrintf(" %d%c", seconds, sdState); } } return; case LL_CLT_TEMPERATURE: lcdPrintf("Coolant %f", getCoolantTemperature(PASS_ENGINE_PARAMETER_F)); return; case LL_IAT_TEMPERATURE: lcdPrintf("Intake Air %f", getIntakeAirTemperature(PASS_ENGINE_PARAMETER_F)); return; case LL_ALGORITHM: lcdPrintf(getEngine_load_mode_e(engineConfiguration->algorithm)); return; case LL_INJECTION: lcdPrintf(getInjection_mode_e(engineConfiguration->injectionMode)); return; case LL_ING_FLOW: lcdPrintf("Inj %fcc", engineConfiguration->injector.flow); return; case LL_IGNITION: lcdPrintf(getIgnition_mode_e(engineConfiguration->ignitionMode)); return; case LL_TPS: getPinNameByAdcChannel(engineConfiguration->tpsAdcChannel, buffer); lcdPrintf("Throttle %s %f%%", buffer, getTPS()); return; case LL_VBATT: lcdPrintf("Battery %fv", getVBatt(PASS_ENGINE_PARAMETER_F)); return; case LL_KNOCK: getPinNameByAdcChannel(engineConfiguration->hipOutputChannel, buffer); lcdPrintf("Knock %s %fv", buffer, engine->knockVolts); return; #if EFI_ANALOG_SENSORS || defined(__DOXYGEN__) case LL_BARO: if (hasBaroSensor()) { lcdPrintf("Baro: %f", getBaroPressure()); } else { lcdPrintf("Baro: none"); } return; #endif case LL_AFR: if (engineConfiguration->hasAfrSensor) { lcdPrintf("AFR: %f", getAfr()); } else { lcdPrintf("AFR: none"); } return; case LL_MAP: if (engineConfiguration->hasMapSensor) { lcdPrintf("MAP %f", getMap()); } else { lcdPrintf("MAP: none"); } return; case LL_MAF_V: if (hasMafSensor()) { lcdPrintf("MAF: %fv", getMaf()); } else { lcdPrintf("MAF: none"); } return; case LL_MAF_KG_HR: if (hasMafSensor()) { lcdPrintf("MAF: %f kg/hr", getRealMaf()); } else { lcdPrintf("MAF: none"); } return; case LL_TRIGGER_ERRORS: lcdPrintf("Errors"); return; case LL_TRIGGER_DUTY: lcdPrintf("Duty"); return; default: lcdPrintf("()"); } }
extern int8_t writeLCD(const int fd_lcd, const double value, const char mode, const struct tm *time) { const char *FNAME = "writeLCD()"; char *shour = NULL; char *smin = NULL; char *ssec = NULL; char *svalue = NULL; shour = (char *) alloca(sizeof(char)*3 + 1); smin = (char *) alloca(sizeof(char)*3 + 1); ssec = (char *) alloca(sizeof(char)*3 + 1); svalue = (char *) alloca(sizeof(char)*7 + 1); snprintf(shour, 3, "%02d", time->tm_hour); snprintf(smin, 3, "%02d", time->tm_min); snprintf(ssec, 3, "%02d", time->tm_sec); snprintf(svalue, 7, "%4.1f", value); fprintf(stdout, "DEBUG: %s: hour=%s min=%s sec=%s mode=%c value=%s\n", FNAME, shour, smin, ssec, mode, svalue); /* switch off backlight */ lcdDisplay(fd_lcd, 1); /* set the cursor position: column 0-15, row 0-1*/ /* set cursor top row, position 0 */ lcdPosition(fd_lcd, 0, 0); /* clear the screen (fill with blanks) */ lcdPuts(fd_lcd, " "); /* set cursor bottom row, position 0 */ lcdPosition(fd_lcd, 0, 1); /* clear the screen (fill with blanks) */ lcdPuts(fd_lcd, " "); lcdPosition(fd_lcd, 0, 0); lcdPuts(fd_lcd, shour); lcdPutchar(fd_lcd, ':'); lcdPuts(fd_lcd, smin); lcdPutchar(fd_lcd, ':'); lcdPuts(fd_lcd, ssec); lcdPosition(fd_lcd, 0, 1); switch (mode) { case 't': lcdPuts(fd_lcd, "Temperatur "); lcdPosition(fd_lcd, 11, 1); snprintf(svalue, 5, "%2.1f", value); lcdPrintf(fd_lcd, svalue); break; case 'h': lcdPuts(fd_lcd, "Feuchte "); lcdPosition(fd_lcd, 8, 1); snprintf(svalue, 3, "%2.0f", value); lcdPrintf(fd_lcd, svalue); lcdPutchar(fd_lcd, '%'); break; case 'p': lcdPuts(fd_lcd, "Druck "); lcdPosition(fd_lcd, 6, 1); snprintf(svalue, 5, "%4.0f", value); lcdPrintf(fd_lcd, svalue); lcdPuts(fd_lcd, " HPa"); break; } return 0; }
// Use vcgencmd commands to show status int main() { // Wiring pi status if (wiringPiSetup() < 0) { fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ; return 1 ; } //getStat(); //system("sudo /opt/vc/bin/vcgencmd measure_temp > sysTemp.txt"); // Create files with status //system("sudo /opt/vc/bin/vcgencmd get_config int > Config.txt"); printf(" ==== Raspberry Pi A Status====\n"); int lcdFD; lcdFD = lcdInit(2, 16, 4, RS, EN, D0, D1, D2, D3, D0, D1, D2, D3); lcdPosition(lcdFD, 0,0); lcdPrintf(lcdFD,"===RPI STATUS:=="); while(1) { system(" /opt/vc/bin/vcgencmd measure_temp > sysTemp.txt"); // Create files with status //system(" /opt/vc/bin/vcgencmd get_config int > Config.txt"); sleep(3); FILE * ftemp = fopen("sysTemp.txt","r"); char tempBuf[16]; fscanf(ftemp,"%s",tempBuf); // Read temp from text file printf("%s\n",tempBuf); sleep(2); lcdPosition(lcdFD, 0,1); lcdPrintf(lcdFD, tempBuf); // getStat(); //system("sudo /opt/vc/bin/vcgencmd measure_temp > sysTemp.txt"); // Create files with s // fscanf(ftemp,"%s",tempBuf); // Read temp from text file // printf("%s\n",tempBuf); // lcdPosition(lcdFD, 0,1); // lcdPrintf(lcdFD, tempBuf); fclose(ftemp); } //printf("Core frequency: "); //system("vcgencmd measure_clock core"); //system("vcgencmd measure_volts"); //system("vcgencmd measure_temp"); /* FILE* ftemp = fopen("/opt/vc/bin/vcgencmd measure_temp","-rb"); // Temp file if(!ftemp) // If not temp file printf("Can't open temp file to read!"); /* char buf[BUFSIZE]; // Buffer fread(buf, BUFSIZE, 1, ftemp); //while (fscanf(ftemp,"%s",sizeof(buf) )==1) // Copy from temp file to buffer // {} int i; for(i = 0; i < BUFSIZE; i++) { printf("%s",buf[i]); } // printf("%s\n", buf); FILE* tTemp = fopen("CPUtemp.txt","w"); if(!tTemp) printf("Can't create txt file!"); //while(buf != null) //fprintf(tTemp,"",sizeof(buf),buf); /* while(ftemp != NULL) { temp[i] = fscanf(ftemp,"%s"); } */ //fclose(tTemp); //printf(" Hz \n"); return 0; }