From 9d912c35a139c17f8b184b43ce82fc4dc1778f4a Mon Sep 17 00:00:00 2001 From: Murat Aka Date: Thu, 12 Apr 2018 17:11:31 +0300 Subject: [PATCH] more stable... --- watchX/src/menu.cpp | 16 ++++---- watchX/src/menu.h | 1 + watchX/src/watchX.cpp | 87 ++++++++++++++++++++++------------------ watchX/src/watchX.h | 7 +++- watchX/src/watchface.cpp | 51 +++++++++++++++++------ 5 files changed, 101 insertions(+), 61 deletions(-) diff --git a/watchX/src/menu.cpp b/watchX/src/menu.cpp index 8a08e3f..1939b13 100644 --- a/watchX/src/menu.cpp +++ b/watchX/src/menu.cpp @@ -12,7 +12,7 @@ int _x=0; int menuspeed=0; int scrollto=0; - +uint8_t menuapp=0; int menuindex=0; int targetmenuindex=0; @@ -90,14 +90,14 @@ targetmenuindex=MENUCOUNT-1; /* When memory is dynamically allocated, the atmega chip cannot allocate memory ... */ -const char title[] PROGMEM= "< MAIN MENU >"; -const char menuCap[][15] PROGMEM ={"Exit","Stopwatch","Gyrocube","Diagnostic","Bluetooth","Settings","About","Help"}; +const char title[][15] PROGMEM= {"< MAIN MENU >","< SETTINGS >"}; +const char menuCap[][15] PROGMEM ={"Exit","Stopwatch","Gyrocube","Diagnostic","Messages","Settings","About","Help","Bluetooth","Screen","Settings3","Settings4","Settings5","Settings6","Settings7","Settings8"}; void drawMenus(){ ///char menuCap[][15]={"Exit","Stopwatch","Gyrocube","Diagnostic","Bluetooth","Settings"}; //const char* title PROGMEM= "< MAIN MENU >"; - drawString_P(26,0,title,smallFont); - drawString_P(0,56,menuCap[menuindex%MENUCOUNT],smallFont); + drawString_P(26,0,title[menuapp],smallFont); + drawString_P(0,56,menuCap[(menuindex%MENUCOUNT)+(menuapp*MENUCOUNT)],smallFont); drawLine(48,12,80,12); @@ -114,12 +114,12 @@ for( char a=-1;a<4;a++) if(menuindex+a-1>=0&&menuindex+a-1=160){ - - - -//} -if(!animating) lastcolon=0; - animating=!animating; -curtm[0]+=animating; -if(animating){ - if(curtm[0]==59){ - - curtm[0]=0; - - curtm[1]++; - if(curtm[1]==59){ - curtm[1]=0; - curtm[2]++; - - } - - } -} - -//lastcolon=0; -///secondsofday+=animating; - - -} @@ -168,6 +139,44 @@ if(batterylevel<530){ //} } +void nextSecond( ){ + +//if(lastcolon>=160){ + + + +//} +switch(watchMode){ + case 0: + case 1: +if(!animating) lastcolon=0; + animating=!animating; +curtm[0]+=animating; +if(animating){ + if(curtm[0]==59){ + + curtm[0]=0; + + curtm[1]++; + if(curtm[1]==59){ + curtm[1]=0; + curtm[2]++; + + } + + } +} +break; +default : + +break; +} +//lastcolon=0; +///secondsofday+=animating; + + +} + void gotoWatchFace(){ stopSqw(); @@ -186,7 +195,7 @@ watchMode=0; void gotoMenu( ){ stopSqw(); menuspeed=0; - +menuapp=0; nextUIFunc=drawMenus; functions[sw1Func]=menusw1; @@ -203,11 +212,13 @@ menuspeed=0; void gotoSettings( ){ stopSqw(); - if( (~SW1_WASPUSHED)&SW1_PUSHED){ +menuapp=1; +menuindex=0; // ssd1306_clearScreen(); // usbFunc= drawUsb; /// nextUIFunc=functions[ uiFunc]; - nextUIFunc=drawSettings; + // nextUIFunc=drawSettings; + nextUIFunc=drawMenus; functions[sw1Func]=gotoMenu; functions[sw2Func]=menusw2; functions[sw3Func]=menusw3; @@ -218,7 +229,7 @@ stopSqw(); // Old_DEVICESTATE=DEVICESTATE; /// TODO DEFINE ACTIONCOMPLETE - } + } @@ -244,8 +255,8 @@ void gotoStopWatch(){ watchMode = 1; nextUIFunc=drawWatchFace; functions[sw1Func]=gotoMenu; - functions[sw2Func]=NULL; - functions[sw3Func]=NULL; + functions[sw2Func]=watchsw1; + functions[sw3Func]=watchsw2; } void gotoBlueTooth(){ @@ -349,9 +360,9 @@ ble_connect(); - - gotoWatchFace(); - +//gotoSettings(); + gotoWatchFace(); +///gotoStopWatch(); startMpu6050(); updateThings(); diff --git a/watchX/src/watchX.h b/watchX/src/watchX.h index 321f660..3dda5e6 100644 --- a/watchX/src/watchX.h +++ b/watchX/src/watchX.h @@ -92,11 +92,12 @@ extern unsigned char Old_DEVICESTATE; //extern char *activekeyframe; extern char strtmpbuf[15]; - +void nextSecond(); extern func_type nextUIFunc; //extern func_type usbFunc ,sw1Func,sw2Func,sw3Func,uiFunc,batteryFunc,bleFunc; extern func_type functions[]; + void handleFunction(func_type f); void gotoMenu( ); @@ -108,7 +109,9 @@ void gotoDiagnostic(); void gotoStopWatch( ); void gotoBlueTooth( ); void gotoSettings( ); - +void watchsw1( ); +void watchsw2( ); +void watchsw3( ); diff --git a/watchX/src/watchface.cpp b/watchX/src/watchface.cpp index 3212f2b..61dcb49 100644 --- a/watchX/src/watchface.cpp +++ b/watchX/src/watchface.cpp @@ -43,6 +43,18 @@ "SAT", "SUN" }; + + void watchsw1( ){ + + watchMode=1; + + } + void watchsw2( ){ +if(watchMode==2) + watchMode=1; + if(watchMode==1) +watchMode=2; + } void drawWatchFace( ){ if(watchMode==0){ @@ -142,28 +154,41 @@ if(animating&&seconds==0&&minutes%10==9){ if(lastcolon==160) speed=2; if(lastcolon==210) speed=1; +if(watchMode==1){ +// speed=10; +// animating=1; +} if(lastcolon<256){ //curtm[0]++; - +if(watchMode==1){ + lastcolon+=speed*2; + if((lastcolon/10)%4==0){ + nextSecond(); +// animating=1; + } +} +if(watchMode==0) lastcolon+=speed; } //else lastcolon=0; -////usbFunc -if(DEVICESTATE&128){ -// draw_bitmap(40, 0, watchXui,8,8,false,0); -if(digitalRead(CHARGE_PIN)==LOW) -draw_bitmap( 36, 56, watchXui+64, 8, 8, false, 0); - -draw_bitmap(18, 56, watchXui+80,16,8,false,0); + if(watchMode==0){ + ////usbFunc -// + if(DEVICESTATE&128){ + // draw_bitmap(40, 0, watchXui,8,8,false,0); + if(digitalRead(CHARGE_PIN)==LOW){ + draw_bitmap( 36, 56, watchXui+64, 8, 8, false, 0); + } + draw_bitmap(18, 56, watchXui+80,16,8,false,0); -} + // -/// battery -// -draw_bitmap( 0, 56, watchXui+(unsigned)(((batterylevel-500)/40)*16), 16, 8, false, 0); + } + /// battery + // + draw_bitmap( 0, 56, watchXui+(unsigned)(((batterylevel-500)/40)*16), 16, 8, false, 0); + } }