Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions 2in1screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,24 @@ double accel_y = 0.0,
accel_g = 7.0;

int current_state = 0;

int dstate = 0;
int rotation_changed(){
int state = 0;

if(accel_y < -accel_g) state = 0;
else if(accel_y > accel_g) state = 1;
#if N_STATE == 4
else if(accel_x > accel_g) state = 2;
else if(accel_x < -accel_g) state = 3;
#endif
#if N_STATE == 4
else if(accel_x > accel_g) state = 2;
else if(accel_x < -accel_g) state = 3;
#endif
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... perhaps a little too quick and dirty, but you get the idea.


if(current_state!=state){
current_state = state;
return 1;
if(dstate ==state){
current_state = state;
return 1;
}
}
else return 0;
dstate = state;
return 0;
}

FILE* bdopen(char const *fname, char leave_open){
Expand Down Expand Up @@ -99,7 +101,7 @@ int main(int argc, char const *argv[]) {
#endif
if(rotation_changed())
rotate_screen();
sleep(2);
sleep(1);
}

return 0;
Expand Down