Skip to content

Commit

Permalink
update ublox, game15, uart terminal, intervalometer, seader
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Sep 5, 2023
1 parent dc2bacc commit 1f7082f
Show file tree
Hide file tree
Showing 24 changed files with 297 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
App(
appid="sony_intervalometer",
name="[Sony] Intervalometer",
appid="ir_intervalometer",
name="[IR] Intervalometer",
apptype=FlipperAppType.EXTERNAL,
entry_point="flipvalo_app",
requires=["gui"],
Expand All @@ -12,5 +12,5 @@ App(
fap_author="@Nitepone",
fap_weburl="https://github.com/Nitepone/flipper-intervalometer",
fap_version="1.1",
fap_description="This is a simple configurable valometer app for Sony cameras. Works via Infrared port.",
fap_description="This is a simple configurable valometer app for DSLR cameras. Works via Infrared port.",
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,28 @@
#include <notification/notification.h>
#include <notification/notification_messages.h>

#include <sony_intervalometer_icons.h>
#include <ir_intervalometer_icons.h>

// app ui scenes
enum flipvalo_ui_scene {
FVSceneMain,
FVSceneConfig,
};

// defines a flipvalo camera trigger
struct flipvalo_trigger {
const char* display_name;
int (*send)(void* output_config);
};

enum flipvalo_trigger_variants {
FvTrigMin = 0,
FvTrigSony = 0,
FvTrigCanon = 1,
FvTrigNikon = 2,
FvTrigMax = 2,
};

// run config for intervalometer
struct flipvalo_config {
int init_delay_msec; // initial delay to start capture
Expand All @@ -34,11 +48,8 @@ struct flipvalo_config {
int burst_count; // number of triggers in a shot
int burst_delay_msec; // time between triggers in a shot
int tickrate; // tick rate in "ticks per second"
enum flipvalo_trigger_variants trigger; // current trigger

// camera control functions.
// a bit overkill atm, but this will allow us to drop in support
// for other cameras, bluetooth, and more adv. functions later.
int (*send_trigger_fn)(void* output_config);
void* output_config;
};

Expand Down Expand Up @@ -67,7 +78,8 @@ enum flipvalo_config_edit_lines {
FvConfigEditShotDelay,
FvConfigEditBurstCount,
FvConfigEditBurstDelay,
FvConfigEditMAX = FvConfigEditBurstDelay,
FvConfigEditTrigger,
FvConfigEditMAX = FvConfigEditTrigger,
};

struct flipvalo_config_edit_view {
Expand Down Expand Up @@ -107,11 +119,10 @@ struct plugin_event {
InputEvent input;
};

// XXX(luna) settings experimental ui kludge

enum flipvalo_config_edit_line_type {
FvConfigEditTypeTimer,
FvConfigEditTypeCount,
FvConfigEditTypeEnum,
};

static void flipvalo_config_edit_view_init(struct flipvalo_config_edit_view* view) {
Expand All @@ -122,13 +133,62 @@ static void flipvalo_config_edit_view_init(struct flipvalo_config_edit_view* vie
view->edit_mode = false;
}

static int sony_ir_trigger_send(void* ctx) {
UNUSED(ctx);
InfraredMessage message = {
.address = 0x1E3A,
.command = 0x2D,
.protocol = InfraredProtocolSIRC20,
};
infrared_send(&message, 1);
return 0;
}

uint32_t canon_ir_timings[] = {594, 7182, 593};
static int canon_ir_trigger_send(void* ctx) {
UNUSED(ctx);
infrared_send_raw_ext(canon_ir_timings, 3, true, 38000, 0.33);
return 0;
}

uint32_t nikon_ir_timings[] =
{1945, 28253, 404, 1513, 410, 3611, 460, 70144, 1974, 28213, 455, 1493, 461, 3591, 409};
static int nikon_ir_trigger_send(void* ctx) {
UNUSED(ctx);
infrared_send_raw_ext(nikon_ir_timings, 15, true, 38000, 0.33);
return 0;
}

struct flipvalo_trigger sony_ir_trigger = {.send = sony_ir_trigger_send, .display_name = "Sony IR"};

struct flipvalo_trigger canon_ir_trigger = {
.send = canon_ir_trigger_send,
.display_name = "Canon IR"};

struct flipvalo_trigger nikon_ir_trigger = {
.send = nikon_ir_trigger_send,
.display_name = "Nikon IR"};

static struct flipvalo_trigger* flipvalo_get_trigger(enum flipvalo_trigger_variants variant) {
switch(variant) {
case FvTrigSony:
return &sony_ir_trigger;
case FvTrigCanon:
return &canon_ir_trigger;
case FvTrigNikon:
return &nikon_ir_trigger;
}
return NULL;
}

#define ITEM_H 64 / 3
#define ITEM_W 128
#define VALUE_X 100
#define VALUE_W 45
static void flipvalo_config_edit_draw(Canvas* canvas, struct flipvalo_config_edit_view* view) {
int* line_value;
char* line_label = NULL;
const char* line_disp_str = "";
FuriString* temp_str = furi_string_alloc();
enum flipvalo_config_edit_line_type line_type;
enum flipvalo_config_edit_lines selected_line;
Expand Down Expand Up @@ -161,6 +221,12 @@ static void flipvalo_config_edit_draw(Canvas* canvas, struct flipvalo_config_edi
line_type = FvConfigEditTypeCount;
line_label = "Brst Count";
break;
case FvConfigEditTrigger:
line_value = NULL;
line_type = FvConfigEditTypeEnum;
line_label = "Trig Type";
line_disp_str = flipvalo_get_trigger(view->config->trigger)->display_name;
break;
default:
continue;
};
Expand Down Expand Up @@ -232,6 +298,15 @@ static void flipvalo_config_edit_draw(Canvas* canvas, struct flipvalo_config_edi
canvas_draw_str_aligned(
canvas, VALUE_X + VALUE_W / 2, text_y, AlignCenter, AlignCenter, ">");
break;
case FvConfigEditTypeEnum:
furi_string_printf(temp_str, "%s", line_disp_str);
canvas_draw_str_aligned(
canvas, VALUE_X, text_y, AlignCenter, AlignCenter, furi_string_get_cstr(temp_str));
canvas_draw_str_aligned(
canvas, VALUE_X - VALUE_W / 2, text_y, AlignCenter, AlignCenter, "<");
canvas_draw_str_aligned(
canvas, VALUE_X + VALUE_W / 2, text_y, AlignCenter, AlignCenter, ">");
break;
}
}

Expand All @@ -242,8 +317,11 @@ static void
flipvalo_config_edit_input_move_cursor(struct flipvalo_config_edit_view* view, int dx, int dy) {
enum flipvalo_config_edit_lines new_line = 0;

int* line_value;
int* line_value = NULL;
enum flipvalo_config_edit_line_type line_type;
// only used for enum type
int max_value;
int min_value;

switch(view->cur_line) {
case FvConfigEditInitDelay:
Expand All @@ -266,6 +344,12 @@ static void
line_value = &view->config->burst_count;
line_type = FvConfigEditTypeCount;
break;
case FvConfigEditTrigger:
line_value = (int*)(&view->config->trigger);
line_type = FvConfigEditTypeEnum;
min_value = FvTrigMin;
max_value = FvTrigMax;
break;
default:
return;
};
Expand All @@ -288,18 +372,23 @@ static void

// Do `dx` behavior
switch(line_type) {
case FvConfigEditTypeTimer:
// no-op unless edit mode
break;
case FvConfigEditTypeCount:
if(*line_value + dx >= 0) {
min_value = 0;
max_value = INT_MAX;
// fall through.
case FvConfigEditTypeEnum:
if((*line_value + dx) >= min_value && (*line_value + dx) <= max_value) {
*line_value += dx;
}
break;
case FvConfigEditTypeTimer:
// no-op unless edit mode
break;
}
} else /* edit mode */ {
switch(line_type) {
case FvConfigEditTypeCount:
case FvConfigEditTypeEnum:
// If current line does not edit mode.. why are we in edit mode?
// Reaching this would be a bug, so lets go back to normal mode.
view->edit_mode = false;
Expand Down Expand Up @@ -386,17 +475,6 @@ static void flipvalo_run_state_init(struct flipvalo_run_state* fv_run_state) {
fv_run_state->tick_cur = 0;
}

static int sony_ir_trigger(void* ctx) {
UNUSED(ctx);
InfraredMessage message = {
.address = 0x1E3A,
.command = 0x2D,
.protocol = InfraredProtocolSIRC20,
};
infrared_send(&message, 1);
return 0;
}

static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) {
furi_assert(event_queue);
struct plugin_event event = {.type = EventTypeKey, .input = *input_event};
Expand All @@ -413,7 +491,7 @@ static void flipvalo_intv_tick(struct flipvalo_priv* fv_priv) {
// check if action required
if(run->tick_cur++ >= run->tick_next) {
// call trigger function
conf->send_trigger_fn(conf->output_config);
flipvalo_get_trigger(conf->trigger)->send(conf->output_config);
fv_priv->gui_shutter_blink = 3;
// end of burst, prepare next shot
if(run->burst_cur >= conf->burst_count) {
Expand Down Expand Up @@ -523,7 +601,7 @@ static void flipvalo_config_init(struct flipvalo_config* fv_conf) {
fv_conf->burst_count = 1;
fv_conf->burst_delay_msec = 0;
fv_conf->tickrate = 125;
fv_conf->send_trigger_fn = sony_ir_trigger;
fv_conf->trigger = FvTrigSony;
fv_conf->output_config = NULL;
}

Expand Down Expand Up @@ -592,7 +670,7 @@ int32_t flipvalo_app() {
case FVSceneMain:
// TODO(luna) Maybe give this a function.. look howl clean FVSceneConfig is...
if(event.type == EventTypeKey) {
if(event.input.type == InputTypeShort) {
if(event.input.type == InputTypeShort || event.input.type == InputTypeLong) {
switch(event.input.key) {
case InputKeyUp:
break;
Expand All @@ -605,7 +683,8 @@ int32_t flipvalo_app() {
break;
case InputKeyRight:
fv_priv->gui_shutter_blink = 3;
fv_priv->config.send_trigger_fn(fv_priv->config.output_config);
flipvalo_get_trigger(fv_priv->config.trigger)
->send(fv_priv->config.output_config);
break;
case InputKeyOk:
if(flipvalo_intv_running(fv_priv)) {
Expand Down
8 changes: 5 additions & 3 deletions base_pack/game15/game15.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,10 @@ static bool is_board_solved() {
static void game_tick() {
switch(game_state.scene) {
case ScenePlay:
game_state.tick_count++;
if(loaded_saving_ticks) loaded_saving_ticks--;
if (game_state.move_count >= 1)
game_state.tick_count++;
if (loaded_saving_ticks)
loaded_saving_ticks--;
if(moving_cell.move_direction == DirectionNone && !key_stack_is_empty()) {
set_moving_cell_by_direction(key_stack_pop());
if(moving_cell.move_direction == DirectionNone) {
Expand Down Expand Up @@ -363,7 +365,7 @@ static void render_callback(Canvas* const canvas) {
canvas_draw_rbox(canvas, 20, 24, 88, 16, 4);
canvas_set_color(canvas, ColorBlack);
canvas_draw_rframe(canvas, 20, 24, 88, 16, 4);
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "Restore game ...");
canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "Restoring game ...");
}
}

Expand Down
Loading

0 comments on commit 1f7082f

Please sign in to comment.