Skip to content

Commit

Permalink
slightly more stability
Browse files Browse the repository at this point in the history
  • Loading branch information
Round-Pi committed Feb 8, 2023
1 parent 13fb316 commit 9de12dc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 28 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Launching the app, directly from console to flipper:

Run the following to compile icons:
```
scripts/assets.py icons applications/tama_p1/icons applications/tama_p1/compiled
scripts/assets.py icons applications_user/TAMA-P1/icons applications_user/TAMA-P1/compiled
```

Note: you may also need to add `-Wno-unused-parameter` to `CCFLAGS` in
Expand All @@ -46,7 +46,7 @@ it is easy to add direct logging after running the application:
```
`python .\serial_logger.py`
`./fbt launch_app APPSRC=applications\plugins\tama_p1; python .\serial_logger.py`
`./fbt launch_app APPSRC=applications_user\TAMA-P1; python .\serial_logger.py`
```
Alternatively, follow the directions here: https://flipper.atmanos.com/docs/debugging/viewing/

Expand All @@ -55,7 +55,7 @@ Implemented
- Menu options:
- Switch between portrait and landscape
- A+C shortcut (mute/change in-game time)
- Double speed / fast-forward
- Double / quadruple speed

![Alt Text](Screenshot3.png)

Expand Down
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ App(
stack_size= 2 * 1024,
order = 215,
fap_icon="tamaIcon2.png",
fap_category="my_games",
fap_category="Games",
)
51 changes: 27 additions & 24 deletions tama_p1.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ static void tama_p1_init(TamaApp* const ctx) {
// Start stepping thread
ctx->thread = furi_thread_alloc();
furi_thread_set_name(ctx->thread, "TamaLIB");
furi_thread_set_stack_size(ctx->thread, 1024);
furi_thread_set_stack_size(ctx->thread, 2 * 1024);
furi_thread_set_callback(ctx->thread, tama_p1_worker);
furi_thread_set_context(ctx->thread, g_state_mutex);
furi_thread_start(ctx->thread);
Expand Down Expand Up @@ -830,14 +830,15 @@ int32_t tama_p1_app(void* p) {
btn_state_t tama_btn_state = 0; // BTN_STATE_RELEASED is 0

if(in_menu) {
if(menu_cursor == 2 &&
(event.input.key == InputKeyUp || event.input.key == InputKeyDown)) {
tama_btn_state = BTN_STATE_RELEASED;
}
// if(menu_cursor >= 2 &&
// (event.input.key == InputKeyUp || event.input.key == InputKeyDown)) {
// tama_btn_state = BTN_STATE_RELEASED;
// }
if(event.input.key == InputKeyBack) {
tama_btn_state = BTN_STATE_RELEASED;
in_menu = false;
} else if(event.input.key == InputKeyUp && event.input.type == InputTypePress) {
tama_btn_state = BTN_STATE_RELEASED;
if(menu_cursor > 0) {
menu_cursor -= 1;
} else {
Expand All @@ -851,6 +852,7 @@ int32_t tama_p1_app(void* p) {
sub_menu_last = 0;
}
} else if(event.input.key == InputKeyDown && event.input.type == InputTypePress) {
tama_btn_state = BTN_STATE_RELEASED;
if(menu_cursor < menu_items - 1) {
menu_cursor += 1;
} else {
Expand All @@ -859,7 +861,6 @@ int32_t tama_p1_app(void* p) {
if(menu_cursor >= menu_items - 2 && sub_menu_buttons > 0) {
sub_menu_buttons = 1;
sub_menu_last = 1;
// sub_menu_last = 2;
} else {
sub_menu_buttons = 0;
sub_menu_last = 0;
Expand Down Expand Up @@ -1082,6 +1083,8 @@ int32_t tama_p1_app(void* p) {
case 3: // C
tamalib_set_button(BTN_RIGHT, tama_btn_state);
break;
default:
break;
}
break;
case menu_items - 1:
Expand All @@ -1093,22 +1096,26 @@ int32_t tama_p1_app(void* p) {
break;
case 1: // Save
if(speed != 1) {
// uint8_t temp = speed;
// speed = 1;
tamalib_set_speed(1);
uint8_t temp = speed;
speed = 1;
tamalib_set_speed(speed);
furi_timer_stop(timer);
tama_p1_save_state();
// speed = temp;
furi_timer_start(
timer, furi_kernel_get_tick_frequency() / 30);
speed = temp;
tamalib_set_speed(speed);
} else {
furi_timer_stop(timer);
tama_p1_save_state();
furi_timer_start(
timer, furi_kernel_get_tick_frequency() / 30);
}
// in_menu = false;
break;
case 2: // Save & Exit
if(speed != 1) {
// speed = 1;
// tamalib_set_speed(speed);
tamalib_set_speed(1);
speed = 1;
tamalib_set_speed(speed);
}
furi_timer_stop(timer);
tama_p1_save_state();
Expand All @@ -1121,19 +1128,18 @@ int32_t tama_p1_app(void* p) {
break;
}
}
} else { // out of menu // TODO: clean up code -.-
} else { // out of menu
if(event.input.key == InputKeyBack && event.input.type == InputTypeLong) {
if(speed != 1) {
// speed = 1;
// tamalib_set_speed(speed);
tamalib_set_speed(1);
speed = 1;
tamalib_set_speed(speed);
}
furi_timer_stop(timer);
tama_p1_save_state();
running = false;
}
if(event.input.type == InputTypePress ||
event.input.type == InputTypeRelease) {
} else if(
event.input.type == InputTypePress ||
event.input.type == InputTypeRelease) {
if(event.input.key != InputKeyBack && event.input.key != m) {
if(event.input.type == InputTypePress)
tama_btn_state = BTN_STATE_PRESSED;
Expand All @@ -1144,9 +1150,6 @@ int32_t tama_p1_app(void* p) {
}
if(event.input.key == m && event.input.type == InputTypePress) {
in_menu = true;
// if(speed == 1) speed = 4;
// else speed = 1;
// tamalib_set_speed(speed);
} else if(event.input.key == a) {
tamalib_set_button(BTN_LEFT, tama_btn_state);
} else if(event.input.key == b) {
Expand Down

0 comments on commit 9de12dc

Please sign in to comment.