Skip to content

Commit 39047c7

Browse files
committed
Enlarge display when only one is selected.
1 parent 921778a commit 39047c7

File tree

3 files changed

+55
-25
lines changed

3 files changed

+55
-25
lines changed

src/Example_Code/Main.c

+23-9
Original file line numberDiff line numberDiff line change
@@ -184,21 +184,35 @@ int main(int argc, char* argv[])
184184
Display();
185185
}
186186

187-
setTextSize(1);
188-
setTextColor(WHITE);
187+
189188
//setCursor(0,0);
190189

191190
// info display
192-
for(int i = 1; i < time; i++){
193-
194-
if(date) {setCursor(display_offset, 8*(date-1)); testdate();}
195-
if(lanip) {setCursor(display_offset, 8*(date+lanip-1)); testlanip();}
196-
if(cpufreq) {setCursor(display_offset, 8*(date+lanip+cpufreq-1)); testcpufreq();}
197-
if(cputemp) {setCursor(display_offset, 8*(date+lanip+cpufreq+cputemp-1));testcputemp();}
198-
if(netspeed) {setCursor(display_offset, 8*(date+lanip+cpufreq+cputemp+netspeed-1));testnetspeed();}
191+
for(int i = 1; i < time; i++){
192+
if (date+lanip+cpufreq+cputemp+netspeed == 1){
193+
setTextSize(2);
194+
setTextColor(WHITE);
195+
if (date) testdate(date);
196+
if (lanip) testlanip(lanip);
197+
if (cpufreq) testcpufreq(cpufreq);
198+
if (cputemp) testcputemp(cputemp);
199+
if (netspeed) testnetspeed(netspeed);
200+
Display();
201+
usleep(1000000);
202+
clearDisplay();
203+
}
204+
else{
205+
setTextSize(1);
206+
setTextColor(WHITE);
207+
if(date) {setCursor(display_offset, 8*(date-1)); testdate(0);}
208+
if(lanip) {setCursor(display_offset, 8*(date+lanip-1)); testlanip(0);}
209+
if(cpufreq) {setCursor(display_offset, 8*(date+lanip+cpufreq-1)); testcpufreq(0);}
210+
if(cputemp) {setCursor(display_offset, 8*(date+lanip+cpufreq+cputemp-1));testcputemp(0);}
211+
if(netspeed) {setCursor(display_offset, 8*(date+lanip+cpufreq+cputemp+netspeed-1));testnetspeed(0);}
199212
Display();
200213
usleep(1000000);
201214
clearDisplay();
215+
}
202216
}
203217
}
204218

src/Example_Code/example_app.c

+27-11
Original file line numberDiff line numberDiff line change
@@ -407,60 +407,76 @@ void deeplyembedded_credits()
407407
}
408408

409409

410-
void testdate()
410+
void testdate(int standalone)
411411
{
412412
time_t rawtime;
413413
time_t curtime;
414414
uint8_t timebuff[TIMESIZE];
415415
curtime = time(NULL);
416416
time(&rawtime);
417-
strftime(timebuff,80,"%Y-%m-%d %H:%M:%S",localtime(&rawtime));
418-
sprintf(buf,"%s",timebuff);
419-
print_strln(buf);
417+
if(standalone)
418+
{
419+
strftime(timebuff,80,"%Y-%m-%d",localtime(&rawtime));
420+
sprintf(buf,"%s",timebuff);
421+
setCursor((127-strlen(buf)*11)/2-2,0);
422+
print_strln(buf);
423+
strftime(timebuff,80,"%H:%M:%S",localtime(&rawtime));
424+
sprintf(buf,"%s",timebuff);
425+
setCursor((127-strlen(buf)*11)/2,16);
426+
print_strln(buf);
427+
}
428+
else {
429+
strftime(timebuff,80,"%Y-%m-%d %H:%M:%S",localtime(&rawtime));
430+
sprintf(buf,"%s",timebuff);
431+
print_strln(buf);
432+
}
420433

421434
}
422435

423436

424-
void testlanip()
437+
void testlanip(int standalone)
425438
{
426439
if((fp=popen(IPPATH,"r"))!=NULL)
427440
{
428441
fscanf(fp,"%s",content_buff);
429442
fclose(fp);
430443
//ipbuff[strlen(ipbuff)-1]=32;
431-
sprintf(buf,"IP:%s",content_buff);
444+
if(standalone) {sprintf(buf,"%s",content_buff); setTextSize(1); setCursor((127-strlen(buf)*6)/2, 12);}
445+
else sprintf(buf,"IP:%s",content_buff);
432446
print_strln(buf);
433447
}
434448

435449
}
436450

437451

438-
void testcputemp()
452+
void testcputemp(int standalone)
439453
{
440454
if((fp=fopen(TEMPPATH,"r"))!=NULL)
441455
{
442456
fgets(content_buff,TEMPSIZE,fp);
443457
fclose(fp);
444-
sprintf(buf,"CPU TEMP:%.2f C",atoi(content_buff)/100.0);
458+
if(standalone) {sprintf(buf, "%.2f C",atoi(content_buff)/100.0); setCursor((127-strlen(buf)*11)/2, 8);}
459+
else sprintf(buf,"CPU TEMP:%.2f C",atoi(content_buff)/100.0);
445460
print_strln(buf);
446461
}
447462

448463
}
449464

450465

451-
void testcpufreq()
466+
void testcpufreq(int standalone)
452467
{
453468
if((fp=popen(FREQPATH,"r")) != NULL)
454469
{
455470
fgets(content_buff,FREQSIZE,fp);
456471
fclose(fp);
457-
sprintf(buf,"CPU FREQ:%d Mhz ",atoi(content_buff)/1000);
472+
if(standalone) {sprintf(buf,"%d Mhz",atoi(content_buff)/1000); setCursor((127-strlen(buf)*11)/2, 8);}
473+
else sprintf(buf,"CPU FREQ:%d Mhz",atoi(content_buff)/1000);
458474
print_strln(buf);
459475
}
460476

461477
}
462478

463-
void testnetspeed()
479+
void testnetspeed(int standalone)
464480
{
465481
if((fp=popen(NETPATH,"r")) != NULL)
466482
{

src/Example_Code/example_app.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ void testdrawbitmap(const unsigned char *bitmap, unsigned char w, unsigned char
1515
void testdrawbitmap_eg();
1616
void deeplyembedded_credits();
1717
void testprintinfo();
18-
void testdate();
19-
void testlanip();
20-
void testcpufreq();
21-
void testcputemp();
22-
void testnetspeed();
18+
void testdate(int standalone);
19+
void testlanip(int standalone);
20+
void testcpufreq(int standalone);
21+
void testcputemp(int standalone);
22+
void testnetspeed(int standalone);
2323

2424

0 commit comments

Comments
 (0)