Skip to content

Commit

Permalink
more stable...
Browse files Browse the repository at this point in the history
  • Loading branch information
murataka committed Apr 12, 2018
1 parent 54eb937 commit 9d912c3
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 61 deletions.
16 changes: 8 additions & 8 deletions watchX/src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
int _x=0;
int menuspeed=0;
int scrollto=0;

uint8_t menuapp=0;

int menuindex=0;
int targetmenuindex=0;
Expand Down Expand Up @@ -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);

Expand All @@ -114,12 +114,12 @@ for( char a=-1;a<4;a++)


if(menuindex+a-1>=0&&menuindex+a-1<MENUCOUNT){
if(menuindex==MENU_GYROCUBE&&menuspeed==0)
if(menuindex==MENU_GYROCUBE&&menuspeed==0&&menuapp==0)
gyroCube(8);

if(menuindex!=MENU_GYROCUBE|| menuindex+a-1!=MENU_GYROCUBE||menuspeed!=0)
if(menuindex!=MENU_GYROCUBE|| menuindex+a-1!=MENU_GYROCUBE||menuspeed!=0||menuapp==1)

draw_bitmap(_x+(a*48) , 16, menus_bits+((menuindex+a-1)*4*32), 32, 32, false, 0);
draw_bitmap(_x+(a*48) , 16, menus_bits+(((menuapp*8)+menuindex+a-1)*4*32), 32, 32, false, 0);
}

_x+=menuspeed;
Expand Down
1 change: 1 addition & 0 deletions watchX/src/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "resources.h"

//#define MENU_LENGTH 8
extern uint8_t menuapp;
extern int menuindex;
extern int menuspeed;
#define MENUCOUNT 0x08
Expand Down
87 changes: 49 additions & 38 deletions watchX/src/watchX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,7 @@ unsigned char Old_DEVICESTATE=DEVICESTATE;
//func_type usbFunc =NULL,sw1Func=NULL,sw2Func=NULL,sw3Func=NULL,uiFunc=NULL,batteryFunc=NULL,bleFunc=NULL;


void nextSecond(/* arguments */) {

//if(lastcolon>=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;


}



Expand Down Expand Up @@ -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();
Expand All @@ -186,7 +195,7 @@ watchMode=0;
void gotoMenu( ){
stopSqw();
menuspeed=0;

menuapp=0;
nextUIFunc=drawMenus;

functions[sw1Func]=menusw1;
Expand All @@ -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;
Expand All @@ -218,7 +229,7 @@ stopSqw();
// Old_DEVICESTATE=DEVICESTATE; /// TODO DEFINE ACTIONCOMPLETE


}

}


Expand All @@ -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(){
Expand Down Expand Up @@ -349,9 +360,9 @@ ble_connect();




gotoWatchFace();

//gotoSettings();
gotoWatchFace();
///gotoStopWatch();
startMpu6050();
updateThings();

Expand Down
7 changes: 5 additions & 2 deletions watchX/src/watchX.h
Original file line number Diff line number Diff line change
Expand Up @@ -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( );
Expand All @@ -108,7 +109,9 @@ void gotoDiagnostic();
void gotoStopWatch( );
void gotoBlueTooth( );
void gotoSettings( );

void watchsw1( );
void watchsw2( );
void watchsw3( );



Expand Down
51 changes: 38 additions & 13 deletions watchX/src/watchface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 9d912c3

Please sign in to comment.