repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_playing_game | static void rps_render_playing_game(Canvas* canvas, void* ctx) {
furi_assert(ctx);
GameContext* game_context = ctx;
// Attempt to aquire context, so we can read the data.
if(furi_mutex_acquire(game_context->mutex, 200) != FuriStatusOk) {
return;
}
GameData* data = game_context->data;
... | // Render UI when we are playing the game.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L508-L666 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_error | static void rps_render_error(Canvas* canvas, void* ctx) {
furi_assert(ctx);
GameContext* game_context = ctx;
// Attempt to aquire context, so we can read the data.
if(furi_mutex_acquire(game_context->mutex, 200) != FuriStatusOk) {
return;
}
GameData* data = game_context->data;
Game... | // Render UI when we encounter an error in the game.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L671-L700 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_main_menu | static void rps_render_main_menu(Canvas* canvas, void* ctx) {
GameContext* game_context = ctx;
canvas_set_font(canvas, FontPrimary);
canvas_draw_str_aligned(canvas, 2, 0, AlignLeft, AlignTop, "ROCK PAPER SCISSORS");
canvas_draw_str_aligned(canvas, 30, 15, AlignLeft, AlignTop, "Edit contact info");
... | // Render UI when we are hosting the game.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L705-L724 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_past_games | static void rps_render_past_games(Canvas* canvas, void* ctx) {
GameContext* game_context = ctx;
canvas_set_font(canvas, FontPrimary);
PlayerStats* stats = game_context->data->viewing_player_stats;
if(!stats) {
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignTop, "NO GAMES PLAYED.");
... | // Render UI when we are showing previous games.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L729-L770 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_choose_social | static void rps_render_choose_social(Canvas* canvas, void* ctx) {
GameContext* game_context = ctx;
UNUSED(game_context);
int line = game_context->data->social_line;
int index = line - 2;
if(index < 0) {
index = 0;
}
canvas_clear(canvas);
canvas_set_font(canvas, FontPrimary);
... | // Render UI when we are choosing a social identity to share.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L775-L804 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | get_char | static char get_char(GameContext* game_context, bool long_press) {
int c_r = game_context->data->keyboard_row;
int c_c = game_context->data->keyboard_col;
char ch = keyboard[c_r][c_c];
if(!long_press && ch >= 'A' && ch <= 'Z') {
ch += 32;
}
return ch;
} | // Return the character at the current keyboard cursor position.
// @param game_context pointer to a GameContext.
// @param long_press true if the key was held down for a long time. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L809-L819 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | draw_arrow | static void draw_arrow(Canvas* canvas, int x, int y, bool tail) {
canvas_draw_line(canvas, x, y + 2, x + 4, y + 2);
canvas_draw_line(canvas, x, y + 2, x + 2, y);
canvas_draw_line(canvas, x, y + 2, x + 2, y + 4);
if(tail) {
canvas_draw_line(canvas, x + 4, y + 2, x + 4, y);
}
} | // Render an arrow, for enter and backspace.
// @param canvas rendering surface of the Flipper Zero.
// @param x x coordinate of the arrow.
// @param y y coordinate of the arrow.
// @param tail true for enter, false for backspace. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L826-L833 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_input_text | static void rps_render_input_text(Canvas* canvas, void* ctx) {
GameContext* game_context = ctx;
UNUSED(game_context);
canvas_clear(canvas);
canvas_set_font(canvas, FontKeyboard);
canvas_set_color(canvas, ColorBlack);
canvas_draw_str(canvas, 0, 8, furi_string_get_cstr(game_context->data->keyboar... | // Render UI when we are inputting text.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L838-L879 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_callback | static void rps_render_callback(Canvas* canvas, void* ctx) {
furi_assert(ctx);
GameContext* game_context = ctx;
if(game_context->data->screen_state == ScreenHostGame) {
rps_render_host_game(canvas, game_context);
} else if(game_context->data->screen_state == ScreenError) {
rps_render_er... | // We register this callback to get invoked whenever we need to render the screen.
// We render the UI on this callback thread.
// @param canvas rendering surface of the Flipper Zero.
// @param ctx pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L942-L965 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_broadcast | static void rps_broadcast(GameContext* game_context, FuriString* buffer) {
uint8_t* message = (uint8_t*)furi_string_get_cstr(buffer);
FURI_LOG_I(TAG, "Broadcast message >%s<", message);
// Make sure our message will fit into a packet; if not truncate it.
size_t length = strlen((char*)message);
if(l... | // This is a helper method that broadcasts a buffer.
// If the message is too large, the message will get truncated.
// @param game_context pointer to a GameContext.
// @param buffer string to broadcast. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L971-L1005 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_broadcast_move | static void rps_broadcast_move(GameContext* game_context, Move moveToSend) {
GameData* data = game_context->data;
FURI_LOG_I(TAG, "Sending move %c", moveToSend);
// The message for game 42 with a move with value Rock should look like... "YourFlip: RPS:MA042R\r\n"
furi_string_printf(
data->buff... | // Our GameEventSendCounter handler invokes this method.
// We broadcast - "YourFlip: " + "RPS:" + move"M" + version"A" + game"###" + move"R" + "\r\n"
// @param game_context pointer to a GameContext.
// @param moveToSend the move to send to the remote player. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1011-L1026 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_broadcast_beacon | static void rps_broadcast_beacon(GameContext* game_context) {
GameData* data = game_context->data;
FURI_LOG_I(TAG, "Sending beacon");
// The message for game 42 should look like... "YourFlip: RPS:BA042\r\n"
furi_string_printf(
data->buffer,
"%s: %s:%c%c%03u\r\n",
furi_hal_versi... | // Our GameEventTypeTimer handler invokes this method.
// We broadcast - "YourFlip: " + "RPS:" + beacon"B" + version"A" + game"###" + "\r\n"
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1031-L1045 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_broadcast_not_beacon | static void rps_broadcast_not_beacon(GameContext* game_context) {
GameData* data = game_context->data;
FURI_LOG_I(TAG, "Sending not beacon");
// The message for game 42 should look like... "YourFlip: RPS:NA042\r\n"
furi_string_printf(
data->buffer,
"%s: %s:%c%c%03u\r\n",
furi_h... | // Our GameEventTypeTimer handler invokes this method.
// We broadcast - "YourFlip: " + "RPS:" + notbeacon"N" + version"A" + game"###" + "\r\n"
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1050-L1064 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_broadcast_join | static void rps_broadcast_join(GameContext* game_context) {
GameData* data = game_context->data;
data->echo_duration = 42;
unsigned int gameNumber = data->game_number;
FURI_LOG_I(TAG, "Joining game %d.", gameNumber);
// The message for game 42 should look like... "YourFlip: RPS:JA042NYourNameHere\... | // Send message that indicates Flipper is joining a specific game.
// We broadcast - "YourFlip: " + "RPS:" + join"J" + version"A" + game"###" + "NYourNameHere" + "\r\n"
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1101-L1118 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_broadcast_join_acknowledge | static void rps_broadcast_join_acknowledge(GameContext* game_context) {
GameData* data = game_context->data;
data->echo_duration = 12;
unsigned int gameNumber = data->game_number;
FURI_LOG_I(TAG, "Acknowledge joining game %d.", gameNumber);
// The message for game 42 should look like... "YourFlip:... | // Send message that acknowledges Flipper joining a specific game.
// We broadcast - "YourFlip: " + "RPS:" + joinAck"A" + version"A" + game"###" + "NYourNameHere" + "\r\n"
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1123-L1140 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | duration | static uint32_t duration(uint32_t tick) {
uint32_t current = furi_get_tick();
// Every 55 days the tick could wrap.
if(current < tick) {
FURI_LOG_T(TAG, "tick count wrapped! current:%ld prev:%ld", current, tick);
return current + (UINT32_MAX - tick);
}
return current - tick;
} | // Calculates the elapsed duration (in ticks) since a previous tick.
// @param tick previous tick obtained from furi_get_tick(). | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1144-L1153 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_state_machine_update | static void rps_state_machine_update(GameContext* game_context) {
GameData* d = game_context->data;
if((d->screen_state != ScreenPlayingGame) && (d->screen_state != ScreenError)) {
FURI_LOG_T(TAG, "Not in playing game state. screenState:%d", d->screen_state);
return;
}
FURI_LOG_I(
... | // Updates the state machine, if needed.
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1157-L1227 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_state_machine_remote_joined | static bool rps_state_machine_remote_joined(GameContext* game_context) {
if(StateHostingLookingForPlayer == game_context->data->local_player) {
FURI_LOG_I(TAG, "Remote player joined our game!");
game_context->data->remote_player = StateReady;
game_context->data->remote_move_tick = furi_get_t... | // Update the state machine to reflect that a remote user joined the game.
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1231-L1245 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_state_machine_local_moved | static bool rps_state_machine_local_moved(GameContext* game_context, Move move) {
FURI_LOG_I(TAG, "Local move %c.", move);
Move localMove = MoveUnknown;
GameState localState = StateReady;
if(MoveCount == move && StateReady == game_context->data->local_player) {
localMove = MoveCount1;
... | // Update the state machine to reflect the local user's move.
// @param game_context pointer to a GameContext.
// @param move local user move. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1250-L1302 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_state_machine_remote_moved | static bool rps_state_machine_remote_moved(GameContext* game_context, Move move) {
GameState remoteState = StateReady;
FURI_LOG_I(TAG, "Remote move %c.", move);
if(MoveCount1 == move && StateReady == game_context->data->remote_player) {
remoteState = StateCount1;
} else if(MoveCount2 == move &&... | // Update the state machine to reflect the remote user's move.
// @param game_context pointer to a GameContext.
// @param move remote user move. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1307-L1336 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | ensure_dir_exists | static void ensure_dir_exists(Storage* storage) {
// If apps_data directory doesn't exist, create it.
if(!storage_dir_exists(storage, RPS_APPS_DATA_FOLDER)) {
FURI_LOG_I(TAG, "Creating directory: %s", RPS_APPS_DATA_FOLDER);
storage_simply_mkdir(storage, RPS_APPS_DATA_FOLDER);
} else {
... | // This is a helper method that creates the game directory if it does not exist.
// @param storage pointer to a Storage. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1530-L1546 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | save_local_contact | static void save_local_contact(GameContext* game_context) {
if(furi_mutex_acquire(game_context->mutex, FuriWaitForever) != FuriStatusOk) {
return;
}
Storage* storage = furi_record_open(RECORD_STORAGE);
ensure_dir_exists(storage);
FURI_LOG_I(TAG, "Saving social: %s", furi_string_get_cstr(gam... | // Saves a local contact to the file system.
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1550-L1600 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | load_social_data | static void load_social_data(int index, bool skip_first_char, FuriString* buffer) {
Storage* storage = furi_record_open(RECORD_STORAGE);
File* social_file = storage_file_alloc(storage);
if(storage_file_open(social_file, RPS_SOCIAL_PATH, FSAM_READ, FSOM_OPEN_EXISTING)) {
char ch;
FURI_LOG_T(... | // Loads a local contact from the file system.
// @param index index of the contact to load.
// @param skip_first_char true if the first character should be skipped.
// @param buffer pointer to a FuriString. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1606-L1637 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | load_keyboard_data | static void load_keyboard_data(GameContext* game_context) {
load_social_data(
contact_list[game_context->data->social_line][0], true, game_context->data->keyboard_data);
} | // Fills the keyboard data array with the previously saved social information.
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1641-L1644 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | load_local_contact | static void load_local_contact(GameContext* game_context) {
load_social_data(0, false, game_context->data->local_contact);
if(furi_string_size(game_context->data->local_contact) > 0) {
char ch = furi_string_get_char(game_context->data->local_contact, 0);
for(int i = 0; i < (int)COUNT_OF(contact_... | // Loads the initial local contact from the file system.
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1648-L1659 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | save_result | static void save_result(GameContext* game_context) {
if(furi_mutex_acquire(game_context->mutex, FuriWaitForever) != FuriStatusOk) {
return;
}
DateTime datetime;
furi_hal_rtc_get_datetime(&datetime);
furi_string_printf(
game_context->data->buffer,
"%c%c\t%04d-%02d-%02dT%02d:... | // Saves a game result to the file system.
// @param game_context pointer to a GameContext. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1663-L1731 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rock_paper_scissors_app | int32_t rock_paper_scissors_app(void* p) {
UNUSED(p);
// Configure our initial data.
GameContext* game_context = malloc(sizeof(GameContext));
game_context->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
game_context->data = malloc(sizeof(GameData));
game_context->data->buffer = furi_string_allo... | // This is the entry point for our application, which should match the application.fam file. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L1872-L2575 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_worker_update_rx_event_callback | static void subghz_demo_worker_update_rx_event_callback(void* ctx) {
furi_assert(ctx);
DemoContext* demo_context = ctx;
DemoEvent event = {.type = DemoEventDataDetected};
furi_message_queue_put(demo_context->queue, &event, FuriWaitForever);
} | // We register this callback to get invoked whenever new subghz data is received.
// We queue a DemoEventDataDetected message and then return to the caller. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L89-L94 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_receive_data | static void subghz_demo_receive_data(DemoContext* instance) {
uint8_t message[MESSAGE_MAX_LEN] = {0};
memset(message, 0x00, MESSAGE_MAX_LEN);
size_t len = subghz_tx_rx_worker_read(instance->subghz_txrx, message, MESSAGE_MAX_LEN);
size_t game_name_len = strlen(SUBGHZ_GAME_NAME);
if(len < (game_name_l... | // This gets invoked when we process a DemoEventDataDetected event.
// We read the message using subghz_tx_rx_worker_read.
// We determine if the message is in the valid format.
// If valid, we queue a DemoEventReceivedCounter/Tone message with the counter/frequency.
// IMPORTANT: The code processing our event needs to... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L101-L182 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_input_callback | static void subghz_demo_input_callback(InputEvent* input_event, void* ctx_q) {
furi_assert(ctx_q);
FuriMessageQueue* queue = ctx_q;
DemoEvent event = {.type = DemoEventTypeKey, .input = *input_event};
furi_message_queue_put(queue, &event, FuriWaitForever);
} | // This gets invoked when input (button press) is detected.
// We queue a DemoEventTypeKey message with the input event data. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L186-L191 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_tick_callback | static void subghz_demo_tick_callback(void* ctx_q) {
furi_assert(ctx_q);
FuriMessageQueue* queue = ctx_q;
DemoEvent event = {.type = DemoEventTypeTick};
// We don't pass a wait value for 3rd parameter -- this event is not critical (and will happen again soon).
furi_message_queue_put(queue, &event, 0... | // We register this callback to get invoked by the timer on every tick.
// We queue a DemoEventTypeTick message and then return to the caller. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L195-L201 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_send_count | static void subghz_demo_send_count(void* ctx) {
furi_assert(ctx);
DemoContext* demo_context = ctx;
FuriMessageQueue* queue = demo_context->queue;
DemoData* data = demo_context->data;
unsigned int counter = data->localCounter;
DemoEvent event = {.type = DemoEventSendCounter, .number = counter};
... | // Our DemoEventTypeKey handler invokes this method when user clicks OK button.
// We queue a DemoEventSendCounter message with the counter data. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L205-L213 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_send_tone | static void subghz_demo_send_tone(void* ctx, unsigned int frequency) {
furi_assert(ctx);
DemoContext* demo_context = ctx;
FuriMessageQueue* queue = demo_context->queue;
DemoEvent event = {.type = DemoEventSendTone, .number = frequency};
furi_message_queue_put(queue, &event, FuriWaitForever);
} | // Our DemoEventTypeKey handler invokes this method when user clicks UP button.
// We queue a DemoEventSendTone message with the frequency data. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L217-L223 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_render_callback | static void subghz_demo_render_callback(Canvas* canvas, void* ctx) {
furi_assert(ctx);
DemoContext* demo_context = ctx;
// Attempt to aquire context, so we can read the data.
if(furi_mutex_acquire(demo_context->mutex, 200) != FuriStatusOk) {
return;
}
DemoData* data = demo_context->dat... | // We register this callback to get invoked whenever we need to render the screen.
// We render the UI on this callback thread. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L227-L260 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_update_local_counter | static void subghz_demo_update_local_counter(DemoContext* demo_context) {
DemoData* data = demo_context->data;
// Increment the counter (which is supposed to be a 4 digit number for this app.)
data->localCounter++;
if(data->localCounter >= 10000U) {
data->localCounter = 0;
}
FURI_LOG_T... | // Our DemoEventTypeTick handler invokes this method.
// We increment our counter (wrapping back to 0 if it exceeds a 4 digit number.) | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L264-L274 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_update_remote_counter | static void subghz_demo_update_remote_counter(DemoContext* demo_context, DemoEvent* event) {
// The queueing code should have made sure the value was valid.
furi_assert(event->number < 10000U);
DemoData* data = demo_context->data;
data->remoteCounter = event->number;
FURI_LOG_I(TAG, "Remote counter... | // Our DemoEventReceivedCounter handler invokes this method.
// We update our remote counter. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L278-L285 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_play_tone | static void subghz_demo_play_tone(DemoContext* demo_context, DemoEvent* event) {
UNUSED(demo_context);
unsigned int frequency = event->number;
FURI_LOG_I(TAG, "Playing frequency %04u", frequency);
// Make tones if the speaker is available.
if(furi_hal_speaker_acquire(1000)) { // We wait up to a sec... | // Our DemoEventReceivedTone handler invokes this method.
// We play a quick (100ms) tone of the desired frequency. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L289-L303 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_broadcast | static void subghz_demo_broadcast(DemoContext* demo_context, FuriString* buffer) {
uint8_t* message = (uint8_t*)furi_string_get_cstr(buffer);
// Make sure our message will fit into a packet; if not truncate it.
size_t length = strlen((char*)message);
if(length > MESSAGE_MAX_LEN) {
FURI_LOG_E(
... | // This is a helper method that broadcasts a buffer.
// If the message is too large, the message will get truncated. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L307-L327 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_broadcast_counter | static void subghz_demo_broadcast_counter(DemoContext* demo_context, unsigned int counterToSend) {
// The counter is supposed to be a 4 digit number.
furi_assert(counterToSend < 10000U);
DemoData* data = demo_context->data;
FURI_LOG_I(TAG, "Sending counter %04u", counterToSend);
// The message for... | // Our DemoEventSendCounter handler invokes this method.
// We broadcast - "game name + purpose (Counter) + Version (A) + 4 digit counter value + : + Flipper name + \r\n" | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L331-L349 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_broadcast_tone | static void subghz_demo_broadcast_tone(DemoContext* demo_context, unsigned int frequency) {
DemoData* data = demo_context->data;
FURI_LOG_I(TAG, "Sending frequency %04u", frequency);
// The message for a frequency of 440 should look like... "SGDEMO:TA440:YourFlip\r\n"
furi_string_printf(
data... | // Our DemoEventSendTone handler invokes this method.
// We broadcast - "game name + purpose (Tone) + Version (A) + frequency + : + Flipper name + \r\n" | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L353-L369 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_demo_app | int32_t subghz_demo_app(void* p) {
UNUSED(p);
// For this demo we hardcode to 433.92MHz.
uint32_t frequency = 433920000;
// TODO: Have an ordered list of frequencies we try, instead of just 1 frequency.
// Configure our initial data.
DemoContext* demo_context = malloc(sizeof(DemoContext));
... | // This is the entry point for our application, which should match the application.fam file. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/subghz_demo/subghz_demo_app.c#L372-L543 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_x10_check_remote_controller | static void subghz_protocol_x10_check_remote_controller(SubGhzBlockGeneric* instance) {
instance->serial = (instance->data & 0xF0000000) >> (24+4);
instance->btn = (((instance->data & 0x07000000) >> 24) | ((instance->data & 0xF800) >> 8));
} | /**
* Set the serial and btn values based on the data and data_count_bit.
* @param instance Pointer to a SubGhzBlockGeneric* instance
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/protocols/x10/x10.c#L209-L212 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_navigation_exit_callback | static uint32_t skeleton_navigation_exit_callback(void* _context) {
UNUSED(_context);
return VIEW_NONE;
} | /**
* @brief Callback for exiting the application.
* @details This function is called when user press back button. We return VIEW_NONE to
* indicate that we want to exit the application.
* @param _context The context - unused
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L69-L72 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_navigation_submenu_callback | static uint32_t skeleton_navigation_submenu_callback(void* _context) {
UNUSED(_context);
return SkeletonViewSubmenu;
} | /**
* @brief Callback for returning to submenu.
* @details This function is called when user press back button. We return VIEW_NONE to
* indicate that we want to navigate to the submenu.
* @param _context The context - unused
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L81-L84 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_navigation_configure_callback | static uint32_t skeleton_navigation_configure_callback(void* _context) {
UNUSED(_context);
return SkeletonViewConfigure;
} | /**
* @brief Callback for returning to configure screen.
* @details This function is called when user press back button. We return VIEW_NONE to
* indicate that we want to navigate to the configure screen.
* @param _context The context - unused
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L93-L96 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_submenu_callback | static void skeleton_submenu_callback(void* context, uint32_t index) {
SkeletonApp* app = (SkeletonApp*)context;
switch(index) {
case SkeletonSubmenuIndexConfigure:
view_dispatcher_switch_to_view(app->view_dispatcher, SkeletonViewConfigure);
break;
case SkeletonSubmenuIndexGame:
... | /**
* @brief Handle submenu item selection.
* @details This function is called when user selects an item from the submenu.
* @param context The context - SkeletonApp object.
* @param index The SkeletonSubmenuIndex item that was clicked.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L104-L119 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_setting_item_clicked | static void skeleton_setting_item_clicked(void* context, uint32_t index) {
SkeletonApp* app = (SkeletonApp*)context;
index++; // The index starts at zero, but we want to start at 1.
// Our configuration UI has the 2nd item as a text field.
if(index == 2) {
// Header to display on the text input... | /**
* @brief Callback when item in configuration screen is clicked.
* @details This function is called when user clicks OK on an item in the configuration screen.
* If the item clicked is our text field then we switch to the text input screen.
* @param context The context - SkeletonApp obje... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L165-L204 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_view_game_draw_callback | static void skeleton_view_game_draw_callback(Canvas* canvas, void* model) {
SkeletonGameModel* my_model = (SkeletonGameModel*)model;
canvas_draw_icon(canvas, my_model->x, 20, &I_glyph_1_14x40);
canvas_draw_str(canvas, 1, 10, "LEFT/RIGHT to change x");
FuriString* xstr = furi_string_alloc();
furi_str... | /**
* @brief Callback for drawing the game screen.
* @details This function is called when the screen needs to be redrawn, like when the model gets updated.
* @param canvas The canvas to draw on.
* @param model The model - MyModel object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L212-L230 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_view_game_timer_callback | static void skeleton_view_game_timer_callback(void* context) {
SkeletonApp* app = (SkeletonApp*)context;
view_dispatcher_send_custom_event(app->view_dispatcher, SkeletonEventIdRedrawScreen);
} | /**
* @brief Callback for timer elapsed.
* @details This function is called when the timer is elapsed. We use this to queue a redraw event.
* @param context The context - SkeletonApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L237-L240 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_view_game_enter_callback | static void skeleton_view_game_enter_callback(void* context) {
uint32_t period = furi_ms_to_ticks(200);
SkeletonApp* app = (SkeletonApp*)context;
furi_assert(app->timer == NULL);
app->timer =
furi_timer_alloc(skeleton_view_game_timer_callback, FuriTimerTypePeriodic, context);
furi_timer_star... | /**
* @brief Callback when the user starts the game screen.
* @details This function is called when the user enters the game screen. We start a timer to
* redraw the screen periodically (so the random number is refreshed).
* @param context The context - SkeletonApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L248-L255 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_view_game_exit_callback | static void skeleton_view_game_exit_callback(void* context) {
SkeletonApp* app = (SkeletonApp*)context;
furi_timer_stop(app->timer);
furi_timer_free(app->timer);
app->timer = NULL;
} | /**
* @brief Callback when the user exits the game screen.
* @details This function is called when the user exits the game screen. We stop the timer.
* @param context The context - SkeletonApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L262-L267 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_view_game_custom_event_callback | static bool skeleton_view_game_custom_event_callback(uint32_t event, void* context) {
SkeletonApp* app = (SkeletonApp*)context;
switch(event) {
case SkeletonEventIdRedrawScreen:
// Redraw screen by passing true to last parameter of with_view_model.
{
bool redraw = true;
... | /**
* @brief Callback for custom events.
* @details This function is called when a custom event is sent to the view dispatcher.
* @param event The event id - SkeletonEventId value.
* @param context The context - SkeletonApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L275-L305 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_view_game_input_callback | static bool skeleton_view_game_input_callback(InputEvent* event, void* context) {
SkeletonApp* app = (SkeletonApp*)context;
if(event->type == InputTypeShort) {
if(event->key == InputKeyLeft) {
// Left button clicked, reduce x coordinate.
bool redraw = true;
with_view_... | /**
* @brief Callback for game screen input.
* @details This function is called when the user presses a button while on the game screen.
* @param event The event - InputEvent object.
* @param context The context - SkeletonApp object.
* @return true if the event was handled, false otherwis... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L314-L352 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | skeleton_app_free | static void skeleton_app_free(SkeletonApp* app) {
#ifdef BACKLIGHT_ON
notification_message(app->notifications, &sequence_display_backlight_enforce_auto);
#endif
furi_record_close(RECORD_NOTIFICATION);
view_dispatcher_remove_view(app->view_dispatcher, SkeletonViewTextInput);
text_input_free(app->text_in... | /**
* @brief Free the skeleton application.
* @details This function frees the skeleton application resources.
* @param app The skeleton application object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L457-L478 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | main_skeleton_app | int32_t main_skeleton_app(void* _p) {
UNUSED(_p);
SkeletonApp* app = skeleton_app_alloc();
view_dispatcher_run(app->view_dispatcher);
skeleton_app_free(app);
return 0;
} | /**
* @brief Main function for skeleton application.
* @details This function is the entry point for the skeleton application. It should be defined in
* application.fam as the entry_point setting.
* @param _p Input parameter - unused
* @return 0 - Success
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/ui/skeleton_app/app.c#L487-L495 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_thread | static int32_t imu_thread(void* context) {
furi_assert(context);
ImuThread* imu = context;
// float yaw_last = 0.f;
// float pitch_last = 0.f;
// float diff_x = 0.f;
// float diff_y = 0.f;
calibrate_gyro(imu);
icm42688p_accel_config(imu->icm42688p, AccelFullScale16G, ACCEL_GYRO_RATE);... | // static float imu_angle_diff(float a, float b) {
// float diff = a - b;
// if(diff > 180.f)
// diff -= 360.f;
// else if(diff < -180.f)
// diff += 360.f;
// return diff;
// } | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/air_level/engine/sensors/imu.c#L125-L165 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_madgwick_filter | static void imu_madgwick_filter(
ImuProcessedData* out,
ICM42688PScaledData* accel,
ICM42688PScaledData* gyro) {
float recipNorm;
float s0, s1, s2, s3;
float qDot1, qDot2, qDot3, qDot4;
float _2q0, _2q1, _2q2, _2q3, _4q0, _4q1, _4q2, _8q1, _8q2, q0q0, q1q1, q2q2, q3q3;
// Rate of change... | /* Simple madgwik filter, based on: https://github.com/arduino-libraries/MadgwickAHRS/ */ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/air_level/engine/sensors/imu.c#L200-L272 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | level_imu_alloc | static void level_imu_alloc(Level* level, GameManager* manager, void* ctx) {
UNUSED(ctx);
UNUSED(manager);
level_add_entity(level, &imu_debug_desc);
} | /**** Level ****/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/air_level/levels/level_imu.c#L130-L134 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | level_alloc | static void level_alloc(Level* level, GameManager* manager, void* context) {
UNUSED(manager);
UNUSED(context);
// Add player entity to the level
player_spawn(level, manager);
// Add wall entities to the level
wall_index = 0;
for(size_t i = 0; i < COUNT_OF(walls); i++) {
level_add_e... | /****** Level ******/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/apps/air_labyrinth/game.c#L296-L308 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | game_start | static void game_start(GameManager* game_manager, void* ctx) {
UNUSED(game_manager);
// Do some initialization here, for example you can load score from storage.
// For simplicity, we will just set it to 0.
GameContext* game_context = ctx;
game_context->score = 0;
game_context->imu = imu_alloc... | /****** Game ******/
/*
Write here the start code for your game, for example: creating a level and so on.
Game context is allocated (game.context_size) and passed to this function, you can use it to store your game data.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/apps/air_labyrinth/game.c#L331-L344 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | game_stop | static void game_stop(void* ctx) {
GameContext* game_context = ctx;
imu_free(game_context->imu);
game_context->imu = NULL;
// Do some deinitialization here, for example you can save score to storage.
// For simplicity, we will just print it.
FURI_LOG_I("Game", "Your score: %lu", game_context->s... | /*
Write here the stop code for your game, for example: freeing memory, if it was allocated.
You don't need to free level, sprites or entities, it will be done automatically.
Also, you don't need to free game_context, it will be done automatically, after this function.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/apps/air_labyrinth/game.c#L351-L359 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_release | static void imu_controller_release(ImuController* controller, InputKey key) {
// If the button was already released, ignore the request.
if(controller->button_state[key] == ButtonStateReleased) {
return;
}
if(controller->config->vibro_duration) {
furi_hal_vibro_on(true);
}
// I... | /**
* @brief Release a virtual button
* @param controller The controller
* @param key The key
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L49-L75 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_press | static void imu_controller_press(ImuController* controller, InputKey key) {
if(controller->button_press_tick[key]) {
// If the button was already pressed, check if we need to send a InputTypeLong or InputTypeRepeat event.
uint32_t duration = furi_get_tick() - controller->button_press_tick[key];
... | /**
* @brief Press a virtual button
* @param controller The controller
* @param key The key
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L82-L145 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_callback | static void imu_controller_callback(void* context) {
ImuController* imu_controller = (ImuController*)context;
// Acquire the mutex to access the IMU
furi_mutex_acquire(imu_controller->mutex, FuriWaitForever);
if(imu_present(imu_controller->imu)) {
// Get the roll (up/down)
float roll =... | /**
* @brief IMU controller callback
* @details This function is called periodically to check the IMU orientation and send virtual button events.
* @param context The context
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L152-L192 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_release_buttons | static void imu_controller_release_buttons(void* context) {
ImuController* imu_controller = (ImuController*)context;
imu_controller_release(imu_controller, InputKeyUp);
imu_controller_release(imu_controller, InputKeyDown);
imu_controller_release(imu_controller, InputKeyLeft);
imu_controller_release(... | /**
* @brief Release all virtual buttons
* @param context The context
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L198-L204 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_free | void imu_controller_free(ImuController* imu_controller) {
furi_timer_stop(imu_controller->timer);
furi_timer_free(imu_controller->timer);
imu_controller_release_buttons(imu_controller);
imu_free(imu_controller->imu);
furi_mutex_free(imu_controller->mutex);
free(imu_controller);
} | /**
* @brief Free the IMU controller
* @param imu_controller The IMU controller
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L233-L240 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_start | void imu_controller_start(ImuController* imu_controller) {
furi_timer_start(
imu_controller->timer, furi_kernel_get_tick_frequency() / BUTTON_READINGS_PER_SECOND);
} | /**
* @brief Start the IMU controller
* @details This function starts the IMU controller, which will periodically check the IMU orientation and send virtual button events.
* @param imu_controller The IMU controller
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L247-L250 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_stop | void imu_controller_stop(ImuController* imu_controller) {
furi_timer_stop(imu_controller->timer);
} | /**
* @brief Stop the IMU controller
* @details This function stops the IMU controller, which will stop checking the IMU orientation and sending virtual button events.
* @param imu_controller The IMU controller
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L257-L259 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | imu_controller_recalibrate | void imu_controller_recalibrate(ImuController* imu_controller) {
imu_controller_stop(imu_controller);
furi_mutex_acquire(imu_controller->mutex, FuriWaitForever);
imu_free(imu_controller->imu);
imu_controller->imu = imu_alloc();
furi_mutex_release(imu_controller->mutex);
imu_controller_start(imu_... | /**
* @brief Recalibrate the IMU controller
* @details This function stops the IMU controller, recalibrates the IMU and starts the IMU controller again.
* @param imu_controller The IMU controller
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/vgm/imu_controller/imu_controller.c#L266-L273 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
SBEMU | github_2023 | crazii | c | MAIN_InterruptPM | static void MAIN_InterruptPM()
{
const uint8_t irq = PIC_GetIRQ();
if(irq != aui.card_irq) //shared IRQ handled by other handlers(EOI sent) or new irq arrived after EOI but not for us
return;
//if(MAIN_InINT&MAIN_ININT_PM) return; //skip reentrance. go32 will do this so actually we don't need it
... | //with the modified fork of HDPMI, HDPMI will route PM interrupts to IVT.
//IRQ routing path:
//PM: IDT -> PM handlers after SBEMU -> SBEMU MAIN_InterruptPM(*) -> PM handlers befoe SBEMU -> IVT -> SBEMU MAIN_InterruptRM(*) -> DPMI entrance -> IVT handlers before DPMI installed
//RM: IVT -> RM handlers before SBEMU -> S... | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/main.c#L1084-L1125 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | setenv | int setenv(const char *name, const char *value, int rewrite)
{
int namelen;
int vallen;
if(name == NULL || value == NULL || (namelen=strlen(name)) == 0 || (vallen=strlen(value)) == 0)
return -1;
//find PSP of COMMAND.COM
uint32_t psp = 0;
uint32_t parent = 0;
{
DPMI_REG r = ... | // http://www.techhelpmanual.com/346-dos_environment.html | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/utility.c#L7-L91 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_als4000_configure2 | static void snd_als4000_configure2(struct snd_sb *chip)
{
u8 tmp;
int i;
/* do some more configuration */
spin_lock_irq(&chip->mixer_lock);
tmp = snd_als4_cr_read(chip, ALS4K_CR0_SB_CONFIG);
snd_als4_cr_write(chip, ALS4K_CR0_SB_CONFIG,
tmp|ALS4K_CR0_MX80_81_REG_WRITE_ENABLE);
/* always select DMA channel 0,... | // Need to call this after playback_trigger, or else PCM interrupts do not fire and FM sound volume is extremely low | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/als4000.c#L293-L332 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_als4000_interrupt | irqreturn_t snd_als4000_interrupt(int irq, void *dev_id)
{
struct snd_sb *chip = dev_id;
uint8_t pci_irqstatus;
uint8_t sb_irqstatus;
//snd_als4k_gcr_write(chip, ALS4K_GCR8C_MISC_CTRL, (3<<16) | 0); // Mask INTA# output
/* find out which bit of the ALS4000 PCI block produced the interrupt,
SPECS_PAGE: 38, 5 ... | /* FIXME: this IRQ routine doesn't really support IRQ sharing (we always
* return IRQ_HANDLED no matter whether we actually had an IRQ flag or not).
* ALS4000a.PDF writes that while ACKing IRQ in PCI block will *not* ACK
* the IRQ in the SB core, ACKing IRQ in SB block *will* ACK the PCI IRQ
* register (alt_port + ... | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/als4000.c#L400-L475 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_als4000_playback_open | int snd_als4000_playback_open(struct snd_pcm_substream *substream)
{
struct snd_sb *chip = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
chip->playback_substream = substream;
runtime->hw = snd_als4000_playback;
return 0;
} | /*****************************************************************/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/als4000.c#L531-L539 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_als4000_set_addr | static void snd_als4000_set_addr(unsigned long iobase,
unsigned int sb_io,
unsigned int mpu_io,
unsigned int opl_io,
unsigned int game_io)
{
u32 cfg1 = 0;
u32 cfg2 = 0;
if (mpu_io > 0)
cfg2 |= (mpu_io | 1) << 16;
if (sb_io > 0)
cfg2 |= (sb_io | 1);
if (game_io > 0)
cfg1 |= (game_io | 1) ... | /******************************************************************/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/als4000.c#L612-L631 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sbdsp_command | int snd_sbdsp_command(struct snd_sb *chip, unsigned char val)
{
int i;
#ifdef IO_DEBUG
snd_printk(KERN_DEBUG "command (%X) 0x%x\n", chip->port, val);
#endif
for (i = BUSY_LOOPS; i; i--)
if ((inb(SBP(chip, STATUS)) & 0x80) == 0) {
outb(val, SBP(chip, COMMAND));
return 1;
}
snd_printd("%s [0x%lx]: timeout (... | //#define IO_DEBUG 1 | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_common.c#L31-L44 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sbmixer_write | void snd_sbmixer_write(struct snd_sb *chip, unsigned char reg, unsigned char data)
{
outb(reg, SBP(chip, MIXER_ADDR));
udelay(10);
outb(data, SBP(chip, MIXER_DATA));
udelay(10);
#ifdef IO_DEBUG
snd_printk(KERN_DEBUG "mixer_write (%X) 0x%x 0x%x\n", chip->port, reg, data);
#endif
} | //#define IO_DEBUG 1 | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L17-L26 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sbmixer_info_single | static int snd_sbmixer_info_single(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
int mask = (kcontrol->private_value >> 24) & 0xff;
uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 1;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = ma... | /*
* Single channel mixer element
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L48-L57 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sbmixer_info_double | static int snd_sbmixer_info_double(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
int mask = (kcontrol->private_value >> 24) & 0xff;
uinfo->type = mask == 1 ? SNDRV_CTL_ELEM_TYPE_BOOLEAN : SNDRV_CTL_ELEM_TYPE_INTEGER;
uinfo->count = 2;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = ma... | /*
* Double channel mixer element
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L100-L109 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_dt019x_input_sw_info | static int snd_dt019x_input_sw_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static const char * const texts[5] = {
"CD", "Mic", "Line", "Synth", "Master"
};
return snd_ctl_enum_info(uinfo, 1, 5, texts);
} | /*
* DT-019x / ALS-007 capture/input switch
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L171-L178 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_als4k_mono_capture_route_info | static int snd_als4k_mono_capture_route_info(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_info *uinfo)
{
static const char * const texts[3] = {
"L chan only", "R chan only", "L ch/2 + R ch/2"
};
return snd_ctl_enum_info(uinfo, 1, 3, texts);
} | /*
* ALS4000 mono recording control switch
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L257-L265 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sb8mixer_info_mux | static int snd_sb8mixer_info_mux(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
static const char * const texts[3] = {
"Mic", "CD", "Line"
};
return snd_ctl_enum_info(uinfo, 1, 3, texts);
} | /*
* SBPRO input multiplexer
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L311-L318 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sb16mixer_info_input_sw | static int snd_sb16mixer_info_input_sw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
{
uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
uinfo->count = 4;
uinfo->value.integer.min = 0;
uinfo->value.integer.max = 1;
return 0;
} | /*
* SB16 input switch
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L378-L385 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | snd_sbmixer_add_ctl | int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int type, unsigned long value)
{
static const struct snd_kcontrol_new newctls[] = {
[SB_MIX_SINGLE] = {
.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
.info = snd_sbmixer_info_single,
.get = snd_sbmixer_get_single,
.put = snd_sbmixer_put_sin... | /*
*/
/*
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/als4000/sb_mixer.c#L442-L495 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | amixer_set_y | static int amixer_set_y(struct amixer *amixer, unsigned int y)
{
struct hw *hw;
hw = amixer->rsc.hw;
hw->amixer_set_y(amixer->rsc.ctrl_blk, y);
return 0;
} | /* y is a 14-bit immediate constant */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctamixer.c#L71-L79 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | sum_master | static void sum_master(struct rsc *rsc)
{
rsc->conj = 0;
rsc->idx = container_of(rsc, struct sum, rsc)->idx[0];
} | /* SUM resource management */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctamixer.c#L333-L337 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | ct_map_audio_buffer | static int ct_map_audio_buffer(struct ct_atc *atc, struct ct_atc_pcm *apcm)
{
struct snd_pcm_runtime *runtime;
struct ct_vm *vm;
if (!apcm->substream)
return 0;
runtime = apcm->substream->runtime;
vm = atc->vm;
apcm->vm_block = vm->map(vm, apcm->substream, runtime->dma_bytes);
if (!apcm->vm_block)
return... | /* *
* Only mono and interleaved modes are supported now.
* Always allocates a contiguous channel block.
* */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctatc.c#L140-L157 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | ct_atc_create | int ct_atc_create(struct snd_card *card, struct pci_dev *pci,
unsigned int rsr, unsigned int msr,
int chip_type, unsigned int ssid,
struct ct_atc **ratc)
{
struct ct_atc *atc;
static const struct snd_device_ops ops = {
.dev_free = atc_dev_free,
};
int err;
*ratc = NULL;
atc = kzalloc(sizeof(*atc), ... | /**
* ct_atc_create - create and initialize a hardware manager
* @card: corresponding alsa card object
* @pci: corresponding kernel pci device object
* @rsr: reference sampling rate
* @msr: master sampling rate
* @chip_type: CHIPTYP enum values
* @ssid: vendor ID (upper 16 bits) and device ID (lower 16 bi... | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctatc.c#L1698-L1780 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | create_hw_obj | int create_hw_obj(struct pci_dev *pci, enum CHIPTYP chip_type,
enum CTCARDS model, struct hw **rhw)
{
int err;
switch (chip_type) {
case ATC20K1:
err = create_20k1_hw_obj(rhw);
break;
case ATC20K2:
err = create_20k2_hw_obj(rhw);
break;
default:
err = -ENODEV;
break;
}
if (err)
return err;
(*... | //#include <linux/bug.h> | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthardware.c#L19-L43 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | src_get_rsc_ctrl_blk | static int src_get_rsc_ctrl_blk(void **rblk)
{
struct src_rsc_ctrl_blk *blk;
*rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (!blk)
return -ENOMEM;
*rblk = blk;
return 0;
} | /*
* Function implementation block.
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k1.c#L155-L167 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | set_timer_irq | static int set_timer_irq(struct hw *hw, int enable)
{
hw_write_20kx(hw, GIE, enable ? IT_INT : 0);
return 0;
} | /* Timer interrupt */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k1.c#L1165-L1169 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | hw_trn_init | static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
{
u32 trnctl;
u32 ptp_phys_low, ptp_phys_high;
/* Set up device page table */
if ((~0UL) == info->vm_pgt_phys) {
dev_err(hw->card->dev,
"Wrong device page table page address!\n");
return -1;
}
trnctl = 0x13; /* 32-bit, 4k-size page */
p... | /* TRANSPORT operations */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k1.c#L1254-L1282 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | hw_reset_dac | static int hw_reset_dac(struct hw *hw)
{
u32 i;
u16 gpioorg;
unsigned int ret;
if (i2c_unlock(hw))
return -1;
do {
ret = hw_read_pci(hw, 0xEC);
} while (!(ret & 0x800000));
hw_write_pci(hw, 0xEC, 0x05); /* write to i2c status control */
/* To be effective, need to reset the DAC twice. */
for (i = 0; i ... | /* DAC operations */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k1.c#L1390-L1421 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | is_adc_input_selected_SB055x | static int is_adc_input_selected_SB055x(struct hw *hw, enum ADCSRC type)
{
return 0;
} | /* ADC operations */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k1.c#L1485-L1488 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | src_get_rsc_ctrl_blk | static int src_get_rsc_ctrl_blk(void **rblk)
{
struct src_rsc_ctrl_blk *blk;
*rblk = NULL;
blk = kzalloc(sizeof(*blk), GFP_KERNEL);
if (!blk)
return -ENOMEM;
*rblk = blk;
return 0;
} | /*
* Function implementation block.
*/ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k2.c#L155-L167 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | set_timer_irq | static int set_timer_irq(struct hw *hw, int enable)
{
hw_write_20kx(hw, GIE, enable ? IT_INT : 0);
return 0;
} | /* Timer interrupt */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k2.c#L1108-L1112 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | hw_trn_init | static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
{
u32 vmctl, data;
u32 ptp_phys_low, ptp_phys_high;
int i;
/* Set up device page table */
if ((~0UL) == info->vm_pgt_phys) {
dev_alert(hw->card->dev,
"Wrong device page table page address!!!\n");
return -1;
}
vmctl = 0x80000C0F; /* 32... | /* TRANSPORT operations */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/cthw20k2.c#L1232-L1265 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | uint16_to_float14 | static unsigned int uint16_to_float14(unsigned int x)
{
unsigned int i;
if (x < 17)
return 0;
x *= 2031;
x /= 65535;
x += 16;
/* i <= 6 */
for (i = 0; !(x & 0x400); i++)
x <<= 1;
x = (((7 - i) & 0x7) << 10) | (x & 0x3ff);
return x;
} | /* Map integer value ranging from 0 to 65535 to 14-bit float value ranging
* from 2^-6 to (1+1023/1024) */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctmixer.c#L286-L304 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | ct_pcm_playback_open | int ct_pcm_playback_open(struct snd_pcm_substream *substream)
{
struct ct_atc *atc = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct ct_atc_pcm *apcm;
int err;
apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
if (!apcm)
return -ENOMEM;
apcm->substream = substream;
a... | /* pcm playback operations */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctpcm.c#L118-L166 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
SBEMU | github_2023 | crazii | c | ct_pcm_capture_open | static int ct_pcm_capture_open(struct snd_pcm_substream *substream)
{
struct ct_atc *atc = snd_pcm_substream_chip(substream);
struct snd_pcm_runtime *runtime = substream->runtime;
struct ct_atc_pcm *apcm;
int err;
apcm = kzalloc(sizeof(*apcm), GFP_KERNEL);
if (!apcm)
return -ENOMEM;
apcm->started = 0;
apcm-... | /* pcm capture operations */ | https://github.com/crazii/SBEMU/blob/f0cbde063396deb2c1246c9b3108a37755c68e9a/drivers/ctxfi/ctpcm.c#L268-L311 | f0cbde063396deb2c1246c9b3108a37755c68e9a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.