Skip to content

Commit

Permalink
add scroll test and crontab daemon to avoid unkonw bug
Browse files Browse the repository at this point in the history
  • Loading branch information
NateLol committed Jun 27, 2020
1 parent 4038873 commit 921778a
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#

include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-oled
LUCI_Title:=LuCI support for ssd1306 0.91\' 138x32 display
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+i2c-tools +coreutils-nohup
LUCI_DEPENDS:=+i2c-tools +coreutils-nohup +libuci
PKG_VERSION:=1.0
PKG_RELEASE:=1.0

Expand Down
12 changes: 10 additions & 2 deletions luasrc/model/cbi/oled/setting.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,20 @@ o = s:taboption("info", Flag, "cpufreq", translate("CPU frequency"))
o.default=0
o = s:taboption("info", Flag, "netspeed", translate("Network speed"))
o.default=0
o = s:taboption("info", ListValue, "netsource", translate("which eth to monitor"))
o:value("eth0","eth0")
o:value("eth1","eth1")
o:depends("netspeed",'1')
o.default='eth0'
o = s:taboption("info", Value, "time", translate("Display interval(s)"), translate('Screensaver will activate in set seconds'))
o.default=0

--screensaver options--
o = s:taboption("screensaver", Flag, "scroll", translate("Scroll Text"))
o.default=1
o = s:taboption("screensaver", Value, "text", translate("Text you want to scroll"))
o:depends("scroll",'1')
o.default='OPENWRT'
o = s:taboption("screensaver", Flag, "drawline", translate("Draw Many Lines"))
o.default=0
o = s:taboption("screensaver", Flag, "drawrect", translate("Draw Rectangles"))
Expand All @@ -49,8 +59,6 @@ o = s:taboption("screensaver", Flag, "displaybitmap", translate("Display miniatu
o.default=0
o = s:taboption("screensaver", Flag, "displayinvertnormal", translate("Invert Display Normalize it"))
o.default=0
o = s:taboption("screensaver", Flag, "drawbitmap", translate("Draw a bitmap and animate movement"))
o.default=0
o = s:taboption("screensaver", Flag, "drawbitmapeg", translate("Draw a bitmap and animate"))
o.default=0

Expand Down
9 changes: 9 additions & 0 deletions po/zh_Hans/oled.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ msgstr "CPU频率"
msgid "CPU temperature"
msgstr "CPU温度"

msgid "Scroll Text"
msgstr "文字滚动"

msgid "Text you want to scroll"
msgstr "你想要显示的文字"

msgid "which eth to monitor"
msgstr "选择监控哪个网口"

#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:20
msgid "Collecting data..."
msgstr ""
Expand Down
9 changes: 9 additions & 0 deletions po/zh_Hant/oled.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ msgstr "CPU頻率"
msgid "CPU temperature"
msgstr "CPU溫度"

msgid "Scroll Text"
msgstr "文字滾動"

msgid "Text you want to scroll"
msgstr "妳想要顯示的文字"

msgid "which eth to monitor"
msgstr "選擇監控哪個網口"

#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:20
msgid "Collecting data..."
msgstr ""
Expand Down
23 changes: 11 additions & 12 deletions root/etc/config/oled
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
config oled
option drawline '1'
option drawrect '1'
option fillrect '1'
option drawcircle '1'
option drawroundrect '1'
option fillroundrect '1'
option drawtriangle '1'
option filltriangle '1'
option displaybitmap '1'
option displayinvertnormal '1'
option drawbitmap '1'
option drawbitmapeg '1'
option drawline '0'
option drawrect '0'
option fillrect '0'
option drawcircle '0'
option drawroundrect '0'
option fillroundrect '0'
option drawtriangle '0'
option filltriangle '0'
option displaybitmap '0'
option displayinvertnormal '0'
option drawbitmapeg '0'
option date '1'
option netspeed '0'
option lanip '1'
Expand Down
12 changes: 10 additions & 2 deletions root/etc/init.d/oled
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ start() {
if [ $enabled -eq 0 ]; then
exit 0
fi
#crontab daemon
cat /etc/crontabs/root | grep oled > /dev/null
if [ $? -eq 1 ]; then
echo "*/15 * * * * /etc/init.d/oled restart" >> /etc/crontabs/root
fi

date=$(uci get oled.@oled[0].date)
lanip=$(uci get oled.@oled[0].lanip)
cputemp=$(uci get oled.@oled[0].cputemp)
Expand All @@ -24,9 +30,11 @@ start() {
filltriangle=$(uci get oled.@oled[0].filltriangle)
displaybitmap=$(uci get oled.@oled[0].displaybitmap)
displayinvertnormal=$(uci get oled.@oled[0].displayinvertnormal)
drawbitmap=$(uci get oled.@oled[0].drawbitmap)
drawbitmapeg=$(uci get oled.@oled[0].drawbitmapeg)
nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmap} ${drawbitmapeg} >/dev/null 2>&1 &
scroll=$(uci get oled.@oled[0].scroll)
text=$(uci get oled.@oled[0].text)
netsource=$(uci get oled.@oled[0].netsource)
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 &
}


Expand Down
44 changes: 16 additions & 28 deletions src/Example_Code/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,6 @@
#include <string.h>
#include <unistd.h>
#include <signal.h>
#include <getopt.h>

const char* program_name;


void print_usage(FILE* stream, int exit_code)
{
fprintf(stream, "Usage: %s options [...]\n", program_name);
fprintf(stream,
"-h --help Display this usage information\n"
"-o \n"
"-v \n");
exit(exit_code);
}

int getopt(int argc, char * const argv[], const char *optstring);

extern char * optarg;
extern int optind, opteer, optopt;


/* Header Files */
#include "I2C.h"
Expand All @@ -58,11 +38,9 @@ void BreakDeal(int sig)
}




int main(int argc, char* argv[])
{
int display_offset=5;
int display_offset=7;
int date=atoi(argv[1]);
int lanip=atoi(argv[2]);
int cputemp=atoi(argv[3]);
Expand All @@ -79,9 +57,11 @@ int main(int argc, char* argv[])
int filltriangle=atoi(argv[14]);
int displaybitmap=atoi(argv[15]);
int displayinvertnormal=atoi(argv[16]);
int drawbitmap=atoi(argv[17]);
int drawbitmapeg=atoi(argv[18]);

int drawbitmapeg=atoi(argv[17]);
int scroll=atoi(argv[18]);
char *text=argv[19];
char *eth = argv[20];



/* Initialize I2C bus and connect to the I2C Device */
Expand Down Expand Up @@ -114,6 +94,12 @@ int main(int argc, char* argv[])
// draw many lines
while(1){

if(scroll){
testscrolltext(text);
usleep(1000000);
clearDisplay();
}

if(drawline){
testdrawline();
usleep(1000000);
Expand Down Expand Up @@ -176,20 +162,22 @@ int main(int argc, char* argv[])
display_bitmap();
Display();
usleep(1000000);
}
};
// Display Inverted image and normalize it back
if(displayinvertnormal){
display_invert_normal();
clearDisplay();
usleep(1000000);
Display();

}

// Generate Signal after 20 Seconds
alarm(20);

// draw a bitmap icon and 'animate' movement
if(drawbitmapeg){
alarm(10);
flag=0;
testdrawbitmap_eg();
clearDisplay();
usleep(1000000);
Expand Down
18 changes: 9 additions & 9 deletions src/Example_Code/example_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SOFTWARE.
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>
#include "SSD1306_OLED.h"
Expand Down Expand Up @@ -275,27 +275,27 @@ void testdrawchar()
}

/* Display "scroll" and scroll around */
void testscrolltext()
void testscrolltext(char* str)
{
setTextSize(2);
setTextColor(WHITE);
setCursor(10,0);
print_str("scroll");
println();
setCursor(10,8);
sprintf(buf,"%s",str);
print_strln(buf);
Display();
usleep(1000);
startscrollright(0x00, 0x0F);
usleep(2000000);
usleep(5000000);
stopscroll();
usleep(1000000);
startscrollleft(0x00, 0x0F);
usleep(2000000);
usleep(5000000);
stopscroll();
usleep(1000000);
startscrolldiagright(0x00, 0x07);
usleep(2000000);
usleep(5000000);
startscrolldiagleft(0x00, 0x07);
usleep(2000000);
usleep(5000000);
stopscroll();
}

Expand Down
3 changes: 1 addition & 2 deletions src/Example_Code/example_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ void testfillroundrect();
void testdrawtriangle();
void testfilltriangle();
void testdrawchar();
void testscrolltext();
void display_texts();
void testscrolltext(char *str);
void display_texts();
void display_bitmap();
void display_invert_normal();
Expand Down

0 comments on commit 921778a

Please sign in to comment.