Skip to content

Commit

Permalink
Merge pull request #24 from kvazimoda24/main
Browse files Browse the repository at this point in the history
Fixed black screen bug on Inmotion V5/8/10 dashboard
  • Loading branch information
enaon authored Apr 10, 2024
2 parents fe9cd66 + 631b971 commit f5d4d79
Show file tree
Hide file tree
Showing 50 changed files with 3,316 additions and 1,883 deletions.
2 changes: 1 addition & 1 deletion P8-testing/apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
{ "id": "Dashboard Digital",
"name": "EUC digital Dashboard",
"icon": "../dash/icon.png",
"version":"1.92.1",
"version":"1.92.2",
"description": "EUC simple digital",
"tags": "euc",
"readme": "README.md",
Expand Down
111 changes: 53 additions & 58 deletions P8-testing/dash/dashAlerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,22 @@ face[0] = {
//if (!face.appPrev.startsWith("dash")) this.g.clear();
this.g.setColor(0,0);
this.g.fillRect(0,98,239,99);

this.g.flip();
this.g.flip();
this.g.fillRect(120,0,121,195);
this.g.flip();
this.g.flip();
this.g.fillRect(0,196,239,197);
this.g.flip();
this.g.flip();
if (this.page){
this.btn(euc.dash.alrt.pwm.hapt.en,euc.dash.alrt.pwm.hapt.en?"PWM: "+euc.dash.alrt.pwm.hapt.hi+" %":"PWM DISABLED",25,120,37,4,1,0,0,239,97);
this.btn(0,"",25,120,37,4,0,0,100,239,195);
}else{
}else{
this.btn(euc.dash.alrt.spd.hapt.en,"SPEED",25,60,37,4,1,0,0,119,97);
this.btn(euc.dash.alrt.amp.hapt.en,"AMP",25,180,37,4,1,122,0,239,97);
this.btn(euc.dash.alrt.tmp.hapt.en,"TEMP",25,60,136,4,1,0,100,119,195);
this.btn(euc.dash.alrt.bat.hapt.en,"BATT",25,180,136,4,1,122,100,239,195);
this.btn(euc.dash.alrt.bat.hapt.en,"BATT",25,180,136,4,1,122,100,239,195);
}
//if ( euc.dash.info.get.makr=="Kingsong" ||euc.dash.info.get.makr=="Begode" || euc.dash.info.get.makr=="Veteran" ) {
if ( euc.dash.info.get.makr=="Kingsong" ) {
if ( euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran") {
this.g.setColor(0,0);
this.g.fillRect(0,196,239,204);
this.g.setColor(1,3);
Expand All @@ -34,7 +33,7 @@ face[0] = {
this.g.setColor(1,15);
if (this.page) this.g.fillRect(120,200,165,204);
else this.g.fillRect(75,200,120,204);
this.g.flip();
this.g.flip();
this.g.setColor(0,0);
this.g.fillRect(0,205,239,239);
}else {
Expand All @@ -43,13 +42,13 @@ face[0] = {
}
this.g.setColor(1,15);
this.g.setFont("Vector",20);
this.g.drawString("WATCH ALERTS",120-(this.g.stringWidth("WATCH ALERTS")/2),217);
this.g.drawString("WATCH ALERTS",120-(this.g.stringWidth("WATCH ALERTS")/2),217);
this.g.flip();
this.run=true;
},
show : function(){
if (euc.state!=="READY"&&face.appPrev!=="dashGarage") {face.go(ew.is.dash[ew.def.dash.face],0);return;}
if (!this.run) return;
if (!this.run) return;
this.tid=setTimeout(function(t,o){
t.tid=-1;
t.show();
Expand All @@ -59,8 +58,8 @@ face[0] = {
this.g.setColor(0,(bt)?clr1:clr0);
this.g.fillRect(rx1,ry1,rx2,ry2);
this.g.setColor(1,15);
this.g.setFont("Vector",size1);
this.g.drawString(txt1,x1+6-(this.g.stringWidth(txt1)/2),y1);
this.g.setFont("Vector",size1);
this.g.drawString(txt1,x1+6-(this.g.stringWidth(txt1)/2),y1);
if (txt2){
this.g.setFont("Vector",size2);this.g.drawString(txt2,x2-(this.g.stringWidth(txt2)/2),y2);
if (sele) {this.g.drawString("<",10,y2); this.g.drawString(">",207,y2); }
Expand All @@ -72,7 +71,7 @@ face[0] = {
this.g.fillRect(0,198,239,239);
this.g.setColor(1,15);
this.g.setFont("Vector",size);
this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214);
this.g.drawString((bt)?txt1:txt0,120-(this.g.stringWidth((bt)?txt1:txt0)/2),214);
this.g.flip();
if (this.ntid) clearTimeout(this.ntid);
this.ntid=setTimeout(function(t){
Expand Down Expand Up @@ -106,25 +105,24 @@ face[1] = {
euc.updateDash(require("Storage").readJSON("dash.json",1).slot);
face.go("dashGarage",0);
}else face.go(ew.is.dash[ew.def.dash.face],0);
return;
return;
},
clear: function(){
return true;
},
};
};
//touch
touchHandler[0]=function(e,x,y){
touchHandler[0]=function(e,x,y){
this.timeout();
switch (e) {
case 5: //tap event

if (face[0].set) {
if (face[0].set) {
if (face[0].set=="spd") {//spd
buzzer.nav([30,50,30]);
if (y<=120){
if (x<=120){
if (y<=120){
if (x<=120){
if (1<euc.dash.alrt.spd.hapt.hi) euc.dash.alrt.spd.hapt.hi--;
}else if (euc.dash.alrt.spd.hapt.hi<99)
}else if (euc.dash.alrt.spd.hapt.hi<99)
euc.dash.alrt.spd.hapt.hi++;

if (!face[0].spds) { face[0].spds=1;face[0].spdr=0;
Expand All @@ -135,7 +133,7 @@ touchHandler[0]=function(e,x,y){
face[0].ntfy("ALERT IF OVER "+((ew.def.dash.mph)?(euc.dash.alrt.spd.hapt.hi*0.625).toFixed(1):euc.dash.alrt.spd.hapt.hi) +((ew.def.dash.mph)?" MPH":" Km/h"),"",18,12,1);
},0);
}else if (y<=195) { //RESOLUTION
if (x<=120){
if (x<=120){
if (1<euc.dash.alrt.spd.hapt.step) euc.dash.alrt.spd.hapt.step--;
}else if (euc.dash.alrt.spd.hapt.step<5)
euc.dash.alrt.spd.hapt.step++;
Expand All @@ -155,17 +153,15 @@ touchHandler[0]=function(e,x,y){
if (y<=140){ //pwm
if (x<=120) {
if (50<euc.dash.alrt.pwm.hapt.hi) euc.dash.alrt.pwm.hapt.hi--;
}else if (euc.dash.alrt.pwm.hapt.hi<90)
}else if (euc.dash.alrt.pwm.hapt.hi<90)
euc.dash.alrt.pwm.hapt.hi++;
face[0].btn(1,euc.dash.alrt.pwm.hapt.hi,50,120,70,1,0,80,60,150,130);
face[0].ntfy("ALERT IF OVER "+euc.dash.alrt.pwm.hapt.hi+" %","",18,12,1);
}else if (y<=195) {

}else if (y<=195) {
} else { //haptic
euc.dash.alrt.pwm.hapt.en=1-euc.dash.alrt.pwm.hapt.en;
face[0].btn(euc.dash.alrt.pwm.hapt.en,euc.dash.alrt.pwm.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}

}else if (face[0].set=="amp") { //amp
buzzer.nav([30,50,30]);
if (y<=65){ //uphill
Expand All @@ -174,11 +170,11 @@ touchHandler[0]=function(e,x,y){
if (!face[0].ampa) { face[0].ampa=1;face[0].ampd=0;face[0].ampr=0;
face[0].btn(1,"BRAKING:",20,65,90,1,0,0,66,239,132,euc.dash.alrt.amp.hapt.low+ " A",35,182,84);
face[0].btn(1,"RESOLUTION:",17,70,157,2,0,0,135,239,195,euc.dash.alrt.amp.hapt.step+ " A",35,190,150);
face[0].ntfy("ALERT IF OVER "+euc.dash.alrt.amp.hapt.hi+" A","",18,1,1);
face[0].ntfy("ALERT IF OVER "+euc.dash.alrt.amp.hapt.hi+" A","",18,1,1);
}
return setTimeout(function() {
face[0].btn(1,"UPHILL:",20,65,23,12,0,0,0,239,63,euc.dash.alrt.amp.hapt.hi+" A",35,180,16);
face[0].ntfy("ALERT IF OVER "+euc.dash.alrt.amp.hapt.hi+" A","",18,12,1);
face[0].ntfy("ALERT IF OVER "+euc.dash.alrt.amp.hapt.hi+" A","",18,12,1);
},0);
}else if (65<=y&&y<=133){//braking
if (x<=120&&euc.dash.alrt.amp.hapt.low<-5) euc.dash.alrt.amp.hapt.low++;
Expand All @@ -189,7 +185,7 @@ touchHandler[0]=function(e,x,y){
}
return setTimeout(function() {
face[0].btn(1,"BRAKING:",20,65,90,12,0,0,66,239,132,euc.dash.alrt.amp.hapt.low+ " A",35,182,84);
face[0].ntfy("ALERT IF UNDER "+euc.dash.alrt.amp.hapt.low+" A","",18,12,1);
face[0].ntfy("ALERT IF UNDER "+euc.dash.alrt.amp.hapt.low+" A","",18,12,1);
},0);
}else if (y<=195) {//RESOLUTION
if (120<=x&&euc.dash.alrt.amp.hapt.step<3) euc.dash.alrt.amp.hapt.step++;
Expand Down Expand Up @@ -226,7 +222,7 @@ touchHandler[0]=function(e,x,y){
face[0].set="batt";
face[0].btn(1,"SET LOW-BATT (in %)",18,120,8,12,0,0,0,239,97,euc.dash.alrt.bat.hapt.low,50,125,40,1);
face[0].btn(euc.dash.alrt.bat.hapt.en,euc.dash.alrt.bat.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.bat.hapt.en,euc.dash.alrt.bat.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else{ //back
Expand All @@ -245,13 +241,13 @@ touchHandler[0]=function(e,x,y){
buzzer.nav([30,50,30]);
euc.dash.alrt.bat.hapt.en=1-euc.dash.alrt.bat.hapt.en;
face[0].btn(euc.dash.alrt.bat.hapt.en,euc.dash.alrt.bat.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].btn(euc.dash.alrt.bat.hapt.en,"BATT",25,180,136,4,1,122,100,239,195);
face[0].btn(euc.dash.alrt.bat.hapt.en,"BATT",25,180,136,4,1,122,100,239,195);
}else if (x<=120) {
buzzer.nav([30,50,30]);
face[0].set="temp";
face[0].btn(1,"SET HI-TEMP (in "+((ew.def.dash.farn)?"F)":"C)"),18,120,8,12,0,0,0,239,97,(ew.def.dash.farn)?(euc.dash.alrt.tmp.hapt.hi*1.8+32).toFixed(1):euc.dash.alrt.tmp.hapt.hi,50,125,40,1);
face[0].btn(euc.dash.alrt.tmp.hapt.en,euc.dash.alrt.tmp.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.tmp.hapt.en,euc.dash.alrt.tmp.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else{
Expand All @@ -265,21 +261,21 @@ touchHandler[0]=function(e,x,y){
face[0].btn(1,"PWM LIMIT (IN %)",18,120,20,1,0,0,0,239,145,euc.dash.alrt.pwm.hapt.hi,50,125,70,1);
if ( euc.dash.info.get.makr=="Begode")
face[0].btn(1,"CALIBRATE PWM",19,120,160,2,0,0,148,239,195);
else
else
face[0].btn(0,"",19,120,160,0,0,0,148,239,195);
face[0].btn(euc.dash.alrt.pwm.hapt.en,euc.dash.alrt.pwm.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.pwm.hapt.en,euc.dash.alrt.pwm.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else buzzer.nav(40);
}else buzzer.nav(40);
}else {
if (x<=120&&y<100) { //spd
face[0].set="spd";
buzzer.nav([30,50,30]);
face[0].btn(1,"SPEED (in "+((ew.def.dash.mph)?"MPH)":"Km/h)"),18,120,8,1,0,0,0,239,97,(ew.def.dash.mph)?(euc.dash.alrt.spd.hapt.hi*0.625).toFixed(1):euc.dash.alrt.spd.hapt.hi,50,125,40);
face[0].btn(1,"RESOLUTION:",18,120,110,2,0,0,100,239,195,euc.dash.alrt.spd.hapt.step,50,125,140);
face[0].btn(euc.dash.alrt.spd.hapt.en,euc.dash.alrt.spd.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.spd.hapt.en,euc.dash.alrt.spd.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else if (120<=x&&y<=100) { //amp
Expand All @@ -292,7 +288,7 @@ touchHandler[0]=function(e,x,y){
face[0].btn(1,"BRAKING:",20,65,90,1,0,0,66,239,132,euc.dash.alrt.amp.hapt.low+ " A",35,182,84);
face[0].btn(1,"RESOLUTION:",17,70,157,2,0,0,135,239,195,euc.dash.alrt.amp.hapt.step+ " A",35,190,150);
face[0].btn(euc.dash.alrt.amp.hapt.en,euc.dash.alrt.amp.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.amp.hapt.en,euc.dash.alrt.amp.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else if (x<=120&&100<=y&&y<=195) { //temp
Expand All @@ -301,23 +297,23 @@ touchHandler[0]=function(e,x,y){
//face[0].btn(1,"TEMP",25,60,136,12,0,0,100,119,195);
face[0].btn(1,"SET HI-TEMP (in "+((ew.def.dash.farn)?"F)":"C)"),18,120,8,12,0,0,0,239,97,(ew.def.dash.farn)?(euc.dash.alrt.tmp.hapt.hi*1.8+32).toFixed(1):euc.dash.alrt.tmp.hapt.hi,50,125,40,1);
face[0].btn(euc.dash.alrt.tmp.hapt.en,euc.dash.alrt.tmp.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.tmp.hapt.en,euc.dash.alrt.tmp.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else if (120<=x&&100<=y&&y<=195) { //batt
face[0].set="batt";
buzzer.nav([30,50,30]);
//face[0].btn(1,"BATT",25,180,136,12,0,122,100,239,195);
//face[0].btn(1,"BATT",25,180,136,12,0,122,100,239,195);
face[0].btn(1,"SET LOW-BATT (in %)",18,120,8,12,0,0,0,239,97,euc.dash.alrt.bat.hapt.low,50,125,40,1);
face[0].btn(euc.dash.alrt.bat.hapt.en,euc.dash.alrt.bat.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
face[0].hapSw=function(){
face[0].hapSw=function(){
face[0].btn(euc.dash.alrt.bat.hapt.en,euc.dash.alrt.bat.hapt.en?"HAPTIC ENABLED":"HAPTIC DISABLED",18,120,215,4,1,0,198,239,239);
}
}else buzzer.nav(40);
}else buzzer.nav(40);
}
break;
case 1: //slide down event
if (face[0].set) {
if (face[0].set) {
face[0].set=0;
w.gfx.setColor(0,0);
w.gfx.drawLine (0,98,239,98);
Expand All @@ -326,50 +322,49 @@ touchHandler[0]=function(e,x,y){
w.gfx.drawLine (120,0,120,195);
w.gfx.drawLine (121,0,121,195);
w.gfx.flip();
face[0].init();return;
face[0].init();return;
}
if (face.appPrev=="dashGarage") {
euc.updateDash(require("Storage").readJSON("dash.json",1).slot);
face.go("dashGarage",0);
return;
}else face.go(ew.is.dash[ew.def.dash.face],0);
return;
return;
case 2: //slide up event
if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up.
if (y>200&&x<50) { //toggles full/current brightness on a left down corner swipe up.
if (w.gfx.bri.lv!==7) {this.bri=w.gfx.bri.lv;w.gfx.bri.set(7);}
else w.gfx.bri.set(this.bri);
buzzer.nav([30,50,30]);
}else //if (y>100) {
face[0].set=0;
if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;}
if (Boolean(require("Storage").read("settings"))) {face.go("settings",0);return;}
//} else {buzzer.nav(40);}

break;
case 3: //slide left event
//if ( !face[0].set &&!face[0].page&& (euc.dash.info.get.makr=="Kingsong" ||euc.dash.info.get.makr=="Begode" || euc.dash.info.get.makr=="Veteran" )) {
if ( !face[0].set &&!face[0].page&& euc.dash.info.get.makr=="Kingsong" ) {
if ( !face[0].set &&!face[0].page&& (euc.dash.info.get.makr=="Kingsong" || euc.dash.info.get.makr=="Veteran")) {
face[0].page=1
face[0].init();return;
face[0].init();return;
//face.go("dashAlertsPwm",0);
//return;
}else
buzzer.nav(40);
break;
case 4: //slide right event (back action)
if (face[0].set) {
if (face[0].set) {
face[0].set=0;
w.gfx.setColor(0,0);
w.gfx.drawLine (0,98,239,98);
w.gfx.drawLine (0,99,239,99);
w.gfx.flip();
w.gfx.drawLine (120,0,120,195);
w.gfx.drawLine (121,0,121,195);
w.gfx.flip();
face[0].init();return;
w.gfx.flip();
face[0].init();return;
}
if (face[0].page) {
face[0].page=0;
face[0].init();return;
face[0].init();return;
}
if (face.appPrev=="dashGarage") {
euc.updateDash(require("Storage").readJSON("dash.json",1).slot);
Expand All @@ -379,9 +374,9 @@ touchHandler[0]=function(e,x,y){
face.go(face.last,0);
return;
}else face.go(face.appPrev,0);
return;
return;
case 12: //hold event
if (face[0].set) {
if (face[0].set) {
w.gfx.setColor(0,0);
w.gfx.drawLine (0,98,239,98);
w.gfx.drawLine (0,99,239,99);
Expand All @@ -390,9 +385,9 @@ touchHandler[0]=function(e,x,y){
w.gfx.drawLine (121,0,121,195);
w.gfx.flip();
face[0].set=0;face[0].init();
buzzer.nav([30,50,30]);
}else
buzzer.nav(40);
buzzer.nav([30,50,30]);
}else
buzzer.nav(40);
break;
}
};
Loading

0 comments on commit f5d4d79

Please sign in to comment.