From b00f59b1c5ce36b2421bdfbfddfd8851a23b345b Mon Sep 17 00:00:00 2001 From: CN_SZTL Date: Thu, 23 Jul 2020 17:27:56 +0800 Subject: [PATCH] luci-app-oled: sync with upstream source --- .../ctcgfw/luci-app-oled/root/etc/init.d/oled | 41 +++++++++++++++---- .../luci-app-oled/src/Example_Code/Main.c | 6 +-- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/package/ctcgfw/luci-app-oled/root/etc/init.d/oled b/package/ctcgfw/luci-app-oled/root/etc/init.d/oled index 9f3a2a6fff..499df12787 100755 --- a/package/ctcgfw/luci-app-oled/root/etc/init.d/oled +++ b/package/ctcgfw/luci-app-oled/root/etc/init.d/oled @@ -11,7 +11,7 @@ start() { #crontab daemon cat /etc/crontabs/root | grep oled > /dev/null if [ $? -eq 1 ]; then - echo "*/15 * * * * /etc/init.d/oled restart &>/dev/null 2>&1" >> /etc/crontabs/root + echo "*/5 * * * * /etc/init.d/oled restart &>/dev/null 2>&1" >> /etc/crontabs/root fi date=$(uci get oled.@oled[0].date) @@ -40,15 +40,13 @@ start() { ps|grep netspeed|grep -v grep|awk '{print $1}'|xargs kill -9 rm -f /tmp/netspeed fi - nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" > /dev/null 2>&1 & + nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" 1 > /dev/null 2>&1 & } stop() { - kill `pgrep /usr/bin/oled` - sleep 1 + kill -2 `pgrep /usr/bin/oled` ps|grep netspeed|grep -v grep|awk '{print $1}'|xargs kill -9 - sleep 1 echo "oled exit..." } @@ -57,9 +55,36 @@ restart(){ pgrep -f ${PROG} >/dev/null if [ $? -eq 0 ]; then if [ $enabled -eq 1 ]; then - stop - sleep 1 - start + kill `pgrep /usr/bin/oled` + ps|grep netspeed|grep -v grep|awk '{print $1}'|xargs kill -9 + + date=$(uci get oled.@oled[0].date) + lanip=$(uci get oled.@oled[0].lanip) + cputemp=$(uci get oled.@oled[0].cputemp) + cpufreq=$(uci get oled.@oled[0].cpufreq) + netspeed=$(uci get oled.@oled[0].netspeed) + time=$(uci get oled.@oled[0].time) + drawline=$(uci get oled.@oled[0].drawline) + drawrect=$(uci get oled.@oled[0].drawrect) + fillrect=$(uci get oled.@oled[0].fillrect) + drawcircle=$(uci get oled.@oled[0].drawcircle) + drawroundrect=$(uci get oled.@oled[0].drawroundrect) + fillroundrect=$(uci get oled.@oled[0].fillroundrect) + drawtriangle=$(uci get oled.@oled[0].drawtriangle) + filltriangle=$(uci get oled.@oled[0].filltriangle) + displaybitmap=$(uci get oled.@oled[0].displaybitmap) + displayinvertnormal=$(uci get oled.@oled[0].displayinvertnormal) + drawbitmapeg=$(uci get oled.@oled[0].drawbitmapeg) + scroll=$(uci get oled.@oled[0].scroll) + text=$(uci get oled.@oled[0].text) + netsource=$(uci get oled.@oled[0].netsource) + if [ ${netspeed} -eq 1 ]; then + nohup /usr/sbin/netspeed ${netsource} >/dev/null 2>&1 & + else + ps|grep netspeed|grep -v grep|awk '{print $1}'|xargs kill -9 + rm -f /tmp/netspeed + fi + nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" 0 > /dev/null 2>&1 & else stop fi diff --git a/package/ctcgfw/luci-app-oled/src/Example_Code/Main.c b/package/ctcgfw/luci-app-oled/src/Example_Code/Main.c index af33036fad..9bf87e697e 100644 --- a/package/ctcgfw/luci-app-oled/src/Example_Code/Main.c +++ b/package/ctcgfw/luci-app-oled/src/Example_Code/Main.c @@ -60,7 +60,7 @@ int main(int argc, char* argv[]) int scroll=atoi(argv[18]); char *text=argv[19]; char *eth = argv[20]; - + int needinit=atoi(argv[21]); /* Initialize I2C bus and connect to the I2C Device */ @@ -77,9 +77,9 @@ int main(int argc, char* argv[]) /* Register the Alarm Handler */ signal(SIGALRM, ALARMhandler); signal(SIGINT, BreakDeal); - signal(SIGTERM, BreakDeal); + //signal(SIGTERM, BreakDeal); /* Run SDD1306 Initialization Sequence */ - display_Init_seq(); + if (needinit==1) {display_Init_seq();} /* Clear display */ clearDisplay();