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 | led_driver_stop_timer | static void led_driver_stop_timer() {
LL_TIM_DisableCounter(TIM2);
LL_TIM_DisableUpdateEvent(TIM2);
LL_TIM_DisableDMAReq_UPDATE(TIM2);
furi_hal_bus_disable(FuriHalBusTIM2);
} | /**
* @brief Stops the timer for led transitions.
* @param led_driver The led driver to initialize.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/led_driver.c#L185-L190 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_spin_lock | static void led_driver_spin_lock(LedDriver* led_driver) {
const uint32_t prev_timer = DWT->CYCCNT;
const uint32_t wait_time = LED_DRIVER_SETINEL_WAIT_MS * SystemCoreClock / 1000;
do {
/* Make sure it's started (allow 100 ticks), but then check for sentinel value. */
if(TIM2->ARR == LED_DRIV... | /**
* @brief Waits for the DMA to complete.
* @param led_driver The led driver to use.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/led_driver.c#L196-L218 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_transmit | void led_driver_transmit(LedDriver* led_driver) {
furi_assert(led_driver);
furi_assert(!led_driver->read_pos);
furi_assert(!led_driver->write_pos);
furi_hal_gpio_init(led_driver->gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
furi_hal_gpio_write(led_driver->gpio, false);
const ... | /**
* @brief Send the LED data to the LEDs.
* @param led_driver The led driver to use.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/led_driver.c#L259-L299 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_free | void rgbleds_free(RgbLeds* leds) {
if(leds->led_driver) {
led_driver_free(leds->led_driver);
}
free(leds->color);
free(leds);
} | /**
* @brief Frees a RgbLeds struct.
* @param leds The RgbLeds struct to free.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L38-L44 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_reset | void rgbleds_reset(RgbLeds* leds) {
for(int i = 0; i < leds->num_leds; i++) {
leds->color[i] = 0x000000;
}
} | /**
* @brief Resets the LEDs to their default color pattern (off).
* @details This method resets the LEDs data to their default color pattern (off).
* You must still call rgbleds_update to update the LEDs.
* @param leds The RgbLeds struct to reset.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L52-L56 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_set | bool rgbleds_set(RgbLeds* leds, uint16_t led, uint32_t color) {
if(led > leds->num_leds) {
return false;
}
leds->color[led] = color;
return true;
} | /**
* @brief Sets the color of the LEDs.
* @details This method sets the color of the LEDs.
* @param leds The RgbLeds struct to set the color of.
* @param led The LED index to set the color of.
* @param color The color to set the LED to (Hex value: RRGGBB).
* @return True if the LED was set, false if the LED was ... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L66-L73 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_get | uint32_t rgbleds_get(RgbLeds* leds, uint16_t led) {
if(led > leds->num_leds) {
return 0;
}
return leds->color[led];
} | /**
* @brief Gets the color of the LEDs.
* @details This method gets the color of the LEDs.
* @param leds The RgbLeds struct to get the color of.
* @param led The LED index to get the color of.
* @return The color of the LED (Hex value: RRGGBB).
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L82-L88 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_set_brightness | void rgbleds_set_brightness(RgbLeds* leds, uint8_t brightness) {
leds->brightness = brightness;
} | /**
* @brief Sets the brightness of the LEDs.
* @details This method sets the brightness of the LEDs.
* @param leds The RgbLeds struct to set the brightness of.
* @param brightness The brightness to set the LEDs to (0-255).
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L96-L98 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | adjust_color_brightness | static uint32_t adjust_color_brightness(uint32_t color, uint8_t brightness) {
uint32_t red = (color & 0xFF0000) >> 16;
uint32_t green = (color & 0x00FF00) >> 8;
uint32_t blue = (color & 0x0000FF);
red = (red * brightness) / 255;
green = (green * brightness) / 255;
blue = (blue * brightness) / 2... | /**
* @brief Adjusts the brightness of a color.
* @details This method adjusts the brightness of a color.
* @param color The color to adjust.
* @param brightness The brightness to adjust the color to (0-255).
* @return The adjusted color.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L107-L117 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_update | void rgbleds_update(RgbLeds* leds) {
for(int i = 0; i < leds->num_leds; i++) {
uint32_t color = adjust_color_brightness(leds->color[i], leds->brightness);
led_driver_set_led(leds->led_driver, i, color);
}
led_driver_transmit(leds->led_driver);
} | /**
* @brief Updates the LEDs.
* @details This method changes the LEDs to the colors set by rgbleds_set.
* @param leds The RgbLeds struct to update.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js-old/flipboard/modules/js_rgbleds/rgbleds.c#L124-L131 | 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/js-old/vgm_sensor/js_vgm/imu.c#L126-L166 | 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/js-old/vgm_sensor/js_vgm/imu.c#L201-L273 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_init_dma_gpio_update | static void led_driver_init_dma_gpio_update(LedDriver* led_driver, const GpioPin* gpio) {
led_driver->gpio = gpio;
// Memory to Peripheral
led_driver->dma_gpio_update.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
// Peripheral (GPIO - We populate GPIO port's BSRR register)
led_driver->dma_gpio_upd... | /**
* @brief Initializes the DMA for GPIO pin toggle via BSRR.
* @param led_driver The led driver to initialize.
* @param gpio The GPIO pin to toggle.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L25-L44 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_init_dma_led_transition_timer | static void led_driver_init_dma_led_transition_timer(LedDriver* led_driver) {
// Timer that triggers based on user data.
led_driver->dma_led_transition_timer.Direction = LL_DMA_DIRECTION_MEMORY_TO_PERIPH;
// Peripheral (Timer - We populate TIM2's ARR register)
led_driver->dma_led_transition_timer.Periph... | /**
* @brief Initializes the DMA for the LED timings via ARR.
* @param led_driver The led driver to initialize.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L50-L68 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_free | void led_driver_free(LedDriver* led_driver) {
furi_assert(led_driver);
furi_hal_gpio_init_simple(led_driver->gpio, GpioModeAnalog);
free(led_driver->led_data);
free(led_driver);
} | /**
* @brief Frees a led driver.
* @details Frees a led driver.
* @param led_driver The led driver to free.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L94-L100 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_set_led | uint32_t led_driver_set_led(LedDriver* led_driver, uint32_t index, uint32_t rrggbb) {
furi_assert(led_driver);
if(index >= led_driver->count_leds) {
return 0xFFFFFFFF;
}
uint32_t previous = led_driver->led_data[index];
led_driver->led_data[index] = rrggbb;
return previous;
} | /**
* @brief Sets the LED at the given index to the given color.
* @note You must still call led_driver_transmit to actually update the LEDs.
* @param led_driver The led driver to use.
* @param index The index of the LED to set.
* @param rrggbb The color to set the LED to (0xrrggbb format).
* @return The previous... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L110-L119 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_get_led | uint32_t led_driver_get_led(LedDriver* led_driver, uint32_t index) {
furi_assert(led_driver);
if(index >= led_driver->count_leds) {
return 0xFFFFFFFF;
}
return led_driver->led_data[index];
} | /**
* @brief Gets the LED at the given index.
* @param led_driver The led driver to use.
* @param index The index of the LED to get.
* @return The color of the LED (0xrrggbb format).
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L127-L134 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_start_dma | static void led_driver_start_dma(LedDriver* led_driver) {
furi_assert(led_driver);
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_1, &led_driver->dma_gpio_update);
LL_DMA_Init(DMA1, LL_DMA_CHANNEL_2, &led_driver->dma_led_transition_timer);
LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_DMA_EnableChannel(DMA1,... | /**
* @brief Initializes the DMA for GPIO pin toggle and led transititions.
* @param led_driver The led driver to initialize.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L140-L148 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_stop_dma | static void led_driver_stop_dma() {
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1);
LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2);
LL_DMA_ClearFlag_TC1(DMA1);
LL_DMA_ClearFlag_TC2(DMA1);
} | /**
* @brief Stops the DMA for GPIO pin toggle and led transititions.
* @param led_driver The led driver to initialize.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L154-L159 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_start_timer | static void led_driver_start_timer() {
furi_hal_bus_enable(FuriHalBusTIM2);
LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP);
LL_TIM_SetClockDivision(TIM2, LL_TIM_CLOCKDIVISION_DIV1);
LL_TIM_SetPrescaler(TIM2, 0);
// Updated by led_driver->dma_led_transition_timer.PeriphOrM2MSrcAddress
LL_TIM... | /**
* @brief Starts the timer for led transitions.
* @param led_driver The led driver to initialize.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L165-L179 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_stop_timer | static void led_driver_stop_timer() {
LL_TIM_DisableCounter(TIM2);
LL_TIM_DisableUpdateEvent(TIM2);
LL_TIM_DisableDMAReq_UPDATE(TIM2);
furi_hal_bus_disable(FuriHalBusTIM2);
} | /**
* @brief Stops the timer for led transitions.
* @param led_driver The led driver to initialize.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L185-L190 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_spin_lock | static void led_driver_spin_lock(LedDriver* led_driver) {
const uint32_t prev_timer = DWT->CYCCNT;
const uint32_t wait_time = LED_DRIVER_SETINEL_WAIT_MS * SystemCoreClock / 1000;
do {
/* Make sure it's started (allow 100 ticks), but then check for sentinel value. */
if(TIM2->ARR == LED_DRIV... | /**
* @brief Waits for the DMA to complete.
* @param led_driver The led driver to use.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L196-L218 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | led_driver_transmit | void led_driver_transmit(LedDriver* led_driver) {
furi_assert(led_driver);
furi_assert(!led_driver->read_pos);
furi_assert(!led_driver->write_pos);
furi_hal_gpio_init(led_driver->gpio, GpioModeOutputPushPull, GpioPullNo, GpioSpeedVeryHigh);
furi_hal_gpio_write(led_driver->gpio, false);
const ... | /**
* @brief Send the LED data to the LEDs.
* @param led_driver The led driver to use.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/led_driver.c#L259-L299 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_free | void rgbleds_free(RgbLeds* leds) {
if(leds->led_driver) {
led_driver_free(leds->led_driver);
}
free(leds->color);
free(leds);
} | /**
* @brief Frees a RgbLeds struct.
* @param leds The RgbLeds struct to free.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L38-L44 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_reset | void rgbleds_reset(RgbLeds* leds) {
for(int i = 0; i < leds->num_leds; i++) {
leds->color[i] = 0x000000;
}
} | /**
* @brief Resets the LEDs to their default color pattern (off).
* @details This method resets the LEDs data to their default color pattern (off).
* You must still call rgbleds_update to update the LEDs.
* @param leds The RgbLeds struct to reset.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L52-L56 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_set | bool rgbleds_set(RgbLeds* leds, uint16_t led, uint32_t color) {
if(led > leds->num_leds) {
return false;
}
leds->color[led] = color;
return true;
} | /**
* @brief Sets the color of the LEDs.
* @details This method sets the color of the LEDs.
* @param leds The RgbLeds struct to set the color of.
* @param led The LED index to set the color of.
* @param color The color to set the LED to (Hex value: RRGGBB).
* @return True if the LED was set, false if the LED was ... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L66-L73 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_get | uint32_t rgbleds_get(RgbLeds* leds, uint16_t led) {
if(led > leds->num_leds) {
return 0;
}
return leds->color[led];
} | /**
* @brief Gets the color of the LEDs.
* @details This method gets the color of the LEDs.
* @param leds The RgbLeds struct to get the color of.
* @param led The LED index to get the color of.
* @return The color of the LED (Hex value: RRGGBB).
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L82-L88 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_set_brightness | void rgbleds_set_brightness(RgbLeds* leds, uint8_t brightness) {
leds->brightness = brightness;
} | /**
* @brief Sets the brightness of the LEDs.
* @details This method sets the brightness of the LEDs.
* @param leds The RgbLeds struct to set the brightness of.
* @param brightness The brightness to set the LEDs to (0-255).
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L96-L98 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | adjust_color_brightness | static uint32_t adjust_color_brightness(uint32_t color, uint8_t brightness) {
uint32_t red = (color & 0xFF0000) >> 16;
uint32_t green = (color & 0x00FF00) >> 8;
uint32_t blue = (color & 0x0000FF);
red = (red * brightness) / 255;
green = (green * brightness) / 255;
blue = (blue * brightness) / 2... | /**
* @brief Adjusts the brightness of a color.
* @details This method adjusts the brightness of a color.
* @param color The color to adjust.
* @param brightness The brightness to adjust the color to (0-255).
* @return The adjusted color.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L107-L117 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rgbleds_update | void rgbleds_update(RgbLeds* leds) {
for(int i = 0; i < leds->num_leds; i++) {
uint32_t color = adjust_color_brightness(leds->color[i], leds->brightness);
led_driver_set_led(leds->led_driver, i, color);
}
led_driver_transmit(leds->led_driver);
} | /**
* @brief Updates the LEDs.
* @details This method changes the LEDs to the colors set by rgbleds_set.
* @param leds The RgbLeds struct to update.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/js/flipboard/modules/js_rgbleds/rgbleds.c#L124-L131 | 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/js/vgm_sensor/js_vgm/imu.c#L126-L166 | 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/js/vgm_sensor/js_vgm/imu.c#L201-L273 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | basic_demo_input_callback | static void basic_demo_input_callback(InputEvent* input_event, FuriMessageQueue* queue) {
furi_assert(queue);
DemoEvent event = {.type = DemoEventTypeKey, .input = *input_event};
furi_message_queue_put(queue, &event, FuriWaitForever);
} | // Invoked when input (button press) is detected. We queue a message and then return to the caller. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/basic/basic_view_port_demo_app.c#L45-L49 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | basic_demo_render_callback | static void basic_demo_render_callback(Canvas* canvas, void* ctx) {
// Attempt to aquire context, so we can read the data.
DemoContext* demo_context = ctx;
if(furi_mutex_acquire(demo_context->mutex, 200) != FuriStatusOk) {
return;
}
DemoData* data = demo_context->data;
furi_string_print... | // Invoked by the draw callback to render the screen. We render our UI on the callback thread. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/basic/basic_view_port_demo_app.c#L52-L74 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | message | void message(char* message) {
FURI_LOG_I(TAG, message);
furi_delay_ms(10);
} | /////////////////////////////////////////////////////////////////
// Routine for logging messages with a delay.
///////////////////////////////////////////////////////////////// | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L29-L32 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_set_callback | static void knob_set_callback(Knob* knob, KnobCallback callback, void* callback_context) {
with_view_model(
knob->view,
KnobModel * model,
{
model->callback_context = callback_context;
model->callback = callback;
},
true);
} | // Set a callback to invoke when knob has an event.
// @knob is a pointer to our Knob instance.
// @callback is a function to invoke when we have custom events. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L59-L68 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_input_callback | static bool knob_input_callback(InputEvent* input_event, void* ctx) {
message("knob_input_callback");
Knob* knob = (Knob*)ctx;
bool handled = false;
if(input_event->type == InputTypePress && input_event->key == InputKeyUp) {
bool updated = false;
with_view_model(
knob->view... | // Invoked when input (button press) is detected.
// @input_even is the event the occured.
// @ctx is a pointer to our Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L73-L116 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_render_callback | static void knob_render_callback(Canvas* canvas, void* ctx) {
message("knob_render_callback");
KnobModel* model = ctx;
furi_string_printf(model->buffer, "Knob demo %d", model->counter);
canvas_set_font(canvas, FontPrimary);
if(model->heading) {
canvas_draw_str_aligned(canvas, 64, 5, Align... | // Invoked by the draw callback to render the knob.
// @canvas is the canvas to draw on.
// @ctx is our model. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L121-L135 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_free | void knob_free(Knob* knob) {
message("knob_free");
furi_assert(knob);
with_view_model(
knob->view, KnobModel * model, { furi_string_free(model->buffer); }, true);
view_free(knob->view);
free(knob);
} | // Free a Knob instance.
// @knob pointer to a Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L165-L172 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_get_counter | uint32_t knob_get_counter(Knob* knob) {
message("knob_get_counter");
furi_assert(knob);
uint32_t value = 0;
with_view_model(
knob->view, KnobModel * model, { value = model->counter; }, false);
return value;
} | // Gets the current counter value for a given Knob instance.
// @knob pointer to a Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L184-L193 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_set_counter | void knob_set_counter(Knob* knob, uint32_t count) {
with_view_model(
knob->view, KnobModel * model, { model->counter = count; }, true);
} | // Set the counter value for a given Knob instance.
// @knob pointer to a Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L197-L200 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_set_heading | void knob_set_heading(Knob* knob, char* heading) {
with_view_model(
knob->view, KnobModel * model, { model->heading = heading; }, true);
} | // Sets the heading for displaying our knob.
// @knob pointer to a Knob instance.
// @heading the kind of knob. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/knob_component/knob_demo_app.c#L205-L208 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | minimal_viewport_demo_app | int32_t minimal_viewport_demo_app(void* p) {
UNUSED(p);
FuriMessageQueue* queue = furi_message_queue_alloc(8, sizeof(AppEvent));
ViewPort* view_port = view_port_alloc();
view_port_input_callback_set(view_port, input_callback, queue);
view_port_draw_callback_set(view_port, render_callback, NULL);
... | //static ViewPort* view_port = view_port_alloc(); | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/minimal_viewport/minimal_viewport_app.c#L21-L44 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | message | void message(char* message) {
FURI_LOG_I(TAG, message);
furi_delay_ms(10);
} | /////////////////////////////////////////////////////////////////
// Routine for logging messages with a delay.
///////////////////////////////////////////////////////////////// | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L30-L33 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_set_callback | static void knob_set_callback(Knob* knob, KnobCallback callback, void* callback_context) {
with_view_model(
knob->view,
KnobModel * model,
{
model->callback_context = callback_context;
model->callback = callback;
},
true);
} | // Set a callback to invoke when knob has an event.
// @knob is a pointer to our Knob instance.
// @callback is a function to invoke when we have custom events. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L60-L69 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_input_callback | static bool knob_input_callback(InputEvent* input_event, void* ctx) {
message("knob_input_callback");
Knob* knob = (Knob*)ctx;
bool handled = false;
if(input_event->type == InputTypePress && input_event->key == InputKeyUp) {
bool updated = false;
with_view_model(
knob->view... | // Invoked when input (button press) is detected.
// @input_even is the event the occured.
// @ctx is a pointer to our Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L74-L117 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_render_callback | static void knob_render_callback(Canvas* canvas, void* ctx) {
message("knob_render_callback");
KnobModel* model = ctx;
furi_string_printf(model->buffer, "Knob demo %d", model->counter);
canvas_set_font(canvas, FontPrimary);
if(model->heading) {
canvas_draw_str_aligned(canvas, 64, 5, Align... | // Invoked by the draw callback to render the knob.
// @canvas is the canvas to draw on.
// @ctx is our model. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L122-L136 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_free | void knob_free(Knob* knob) {
message("knob_free");
furi_assert(knob);
with_view_model(
knob->view, KnobModel * model, { furi_string_free(model->buffer); }, true);
view_free(knob->view);
free(knob);
} | // Free a Knob instance.
// @knob pointer to a Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L166-L173 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_get_counter | uint32_t knob_get_counter(Knob* knob) {
message("knob_get_counter");
furi_assert(knob);
uint32_t value = 0;
with_view_model(
knob->view, KnobModel * model, { value = model->counter; }, false);
return value;
} | // Gets the current counter value for a given Knob instance.
// @knob pointer to a Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L185-L194 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_set_counter | void knob_set_counter(Knob* knob, uint32_t count) {
with_view_model(
knob->view, KnobModel * model, { model->counter = count; }, true);
} | // Set the counter value for a given Knob instance.
// @knob pointer to a Knob instance. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L198-L201 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | knob_set_heading | void knob_set_heading(Knob* knob, char* heading) {
with_view_model(
knob->view, KnobModel * model, { model->heading = heading; }, true);
} | // Sets the heading for displaying our knob.
// @knob pointer to a Knob instance.
// @heading the kind of knob. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/plugins/scenes/scenes_demo_app.c#L206-L209 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | genie_navigation_submenu_callback | uint32_t genie_navigation_submenu_callback(void* context) {
UNUSED(context);
return GenieViewSubmenu;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/genie_submenu.c#L36-L39 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | genie_navigation_exit_callback | static uint32_t genie_navigation_exit_callback(void* context) {
UNUSED(context);
return VIEW_NONE;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/genie_submenu.c#L48-L51 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_set_sn_and_btn | static void subghz_protocol_genie_set_sn_and_btn(SubGhzBlockGeneric* instance) {
uint64_t key = subghz_protocol_blocks_reverse_key(instance->data, instance->data_count_bit);
uint32_t key_fix = key >> 32;
instance->serial = key_fix & 0x0FFFFFFF;
instance->btn = key_fix >> 28;
} | /**
* Set serial number and button number from data
* @param instance Pointer to a SubGhzBlockGeneric* instance
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L128-L133 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_storage_file_read16 | static uint16_t subghz_protocol_genie_storage_file_read16(File* file) {
uint16_t read = 0;
char buffer[2] = {0};
storage_file_read(file, buffer, 2);
read |= (buffer[0] << 8);
read |= buffer[1];
return read;
} | /**
* Read 16-bits from file
* @param file Pointer to a File instance
* @return 16-bit unsigned integer
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L140-L147 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_storage_file_read32 | static uint32_t subghz_protocol_genie_storage_file_read32(File* file) {
uint32_t read = 0;
char buffer[4] = {0};
storage_file_read(file, buffer, 4);
read = (buffer[0] << 24);
read |= (buffer[1] << 16);
read |= (buffer[2] << 8);
read |= buffer[3];
return read;
} | /**
* Read 32-bits from file
* @param file Pointer to a File instance
* @return 32-bit unsigned integer
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L154-L163 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_storage_file_write16 | static bool subghz_protocol_genie_storage_file_write16(File* file, uint16_t data) {
char buffer[2] = {0};
buffer[0] = (data >> 8) & 0xFF;
buffer[1] = data & 0xFF;
return storage_file_write(file, buffer, 2) == 2;
} | /**
* Write 16-bits to file
* @param file Pointer to a File instance
* @param data 16-bit unsigned integer
* @return true On success
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L171-L176 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_next_code_from_file | static uint64_t subghz_protocol_genie_next_code_from_file(
uint32_t code_low,
uint32_t code_high,
bool update_index) {
Storage* storage = furi_record_open(RECORD_STORAGE);
char buffer[256] = {0};
snprintf(buffer, 128, "%s/%08lX%s", GENIE_SAVE_FOLDER, code_low, GENIE_FILE_EXT);
uint64_t res... | /**
* Finds next code from the .gne file associated with the given code_low.
* @param code_low 32-bit unsigned integer (static part of code)
* @param code_high 32-bit unsigned integer (dynamic part of code)
* @param update_index If true, the index of the last sent code will be updated.
* @return 64-bit unsigned in... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L185-L307 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_find_next_code | static void
subghz_protocol_genie_find_next_code(SubGhzProtocolEncoderGenie* instance, bool counter_up) {
instance->generic.data_count_bit = 64;
instance->generic.cnt = 0x0000;
if(counter_up) {
uint32_t code_found_hi = instance->generic.data >> 32;
uint32_t code_found_lo = instance->gen... | /**
* Finds next code for this remote.
* @param instance Pointer to a SubGhzProtocolEncoderGenie* instance
* @param counter_up attempt to find next code if the value is true
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L314-L340 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_genie_gen_data | static bool subghz_protocol_genie_gen_data(
SubGhzProtocolEncoderGenie* instance,
uint8_t btn,
bool counter_up) {
uint32_t fix = (uint32_t)btn << 28 | instance->generic.serial;
uint32_t hop = 0;
uint64_t code_found_reverse;
subghz_protocol_genie_find_next_code(instance, counter_up);
co... | /**
* Key generation from simple data
* @param instance Pointer to a SubGhzProtocolEncoderGenie* instance
* @param btn Button number, 4 bit
* @param counter_up increasing the counter if the value is true
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L348-L369 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_encoder_genie_get_upload | static bool subghz_protocol_encoder_genie_get_upload(
SubGhzProtocolEncoderGenie* instance,
uint8_t btn,
bool counter_up) {
furi_assert(instance);
// Generate next key
if(!subghz_protocol_genie_gen_data(instance, btn, counter_up)) {
return false;
}
size_t index = 0;
size_t ... | /**
* Generating an upload from data.
* @param instance Pointer to a SubGhzProtocolEncoderGenie instance
* @return true On success
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/genie.c#L376-L436 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_encrypt | inline uint32_t subghz_protocol_keeloq_common_encrypt(const uint32_t data, const uint64_t key) {
uint32_t x = data, r;
for(r = 0; r < 528; r++)
x = (x >> 1) ^ ((bit(x, 0) ^ bit(x, 16) ^ (uint32_t)bit(key, r & 63) ^
bit(KEELOQ_NLF, g5(x, 1, 9, 20, 26, 31)))
... | /** Simple Learning Encrypt
* @param data - 0xBSSSCCCC, B(4bit) key, S(10bit) serial&0x3FF, C(16bit) counter
* @param key - manufacture (64bit)
* @return keeloq encrypt data
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L15-L22 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_decrypt | inline uint32_t subghz_protocol_keeloq_common_decrypt(const uint32_t data, const uint64_t key) {
uint32_t x = data, r;
for(r = 0; r < 528; r++)
x = (x << 1) ^ bit(x, 31) ^ bit(x, 15) ^ (uint32_t)bit(key, (15 - r) & 63) ^
bit(KEELOQ_NLF, g5(x, 0, 8, 19, 25, 30));
return x;
} | /** Simple Learning Decrypt
* @param data - keeloq encrypt data
* @param key - manufacture (64bit)
* @return 0xBSSSCCCC, B(4bit) key, S(10bit) serial&0x3FF, C(16bit) counter
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L29-L35 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_normal_learning | inline uint64_t subghz_protocol_keeloq_common_normal_learning(uint32_t data, const uint64_t key) {
uint32_t k1, k2;
data &= 0x0FFFFFFF;
data |= 0x20000000;
k1 = subghz_protocol_keeloq_common_decrypt(data, key);
data &= 0x0FFFFFFF;
data |= 0x60000000;
k2 = subghz_protocol_keeloq_common_decr... | /** Normal Learning
* @param data - serial number (28bit)
* @param key - manufacture (64bit)
* @return manufacture for this serial number (64bit)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L42-L54 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_secure_learning | inline uint64_t subghz_protocol_keeloq_common_secure_learning(
uint32_t data,
uint32_t seed,
const uint64_t key) {
uint32_t k1, k2;
data &= 0x0FFFFFFF;
k1 = subghz_protocol_keeloq_common_decrypt(data, key);
k2 = subghz_protocol_keeloq_common_decrypt(seed, key);
return ((uint64_t)k1 << ... | /** Secure Learning
* @param data - serial number (28bit)
* @param seed - seed number (32bit)
* @param key - manufacture (64bit)
* @return manufacture for this serial number (64bit)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L63-L74 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_magic_xor_type1_learning | inline uint64_t
subghz_protocol_keeloq_common_magic_xor_type1_learning(uint32_t data, uint64_t xor) {
data &= 0x0FFFFFFF;
return (((uint64_t)data << 32) | data) ^ xor;
} | /** Magic_xor_type1 Learning
* @param data - serial number (28bit)
* @param xor - magic xor (64bit)
* @return manufacture for this serial number (64bit)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L82-L86 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_magic_serial_type1_learning | inline uint64_t
subghz_protocol_keeloq_common_magic_serial_type1_learning(uint32_t data, uint64_t man) {
return (man & 0xFFFFFFFF) | ((uint64_t)data << 40) |
((uint64_t)(((data & 0xff) + ((data >> 8) & 0xFF)) & 0xFF) << 32);
} | /** Magic_serial_type1 Learning
* @param data - serial number (28bit)
* @param man - magic man (64bit)
* @return manufacture for this serial number (64bit)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L94-L98 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_magic_serial_type2_learning | inline uint64_t
subghz_protocol_keeloq_common_magic_serial_type2_learning(uint32_t data, uint64_t man) {
uint8_t* p = (uint8_t*)&data;
uint8_t* m = (uint8_t*)&man;
m[7] = p[0];
m[6] = p[1];
m[5] = p[2];
m[4] = p[3];
return man;
} | /** Magic_serial_type2 Learning
* @param data - btn+serial number (32bit)
* @param man - magic man (64bit)
* @return manufacture for this serial number (64bit)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L106-L115 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | subghz_protocol_keeloq_common_magic_serial_type3_learning | inline uint64_t
subghz_protocol_keeloq_common_magic_serial_type3_learning(uint32_t data, uint64_t man) {
return (man & 0xFFFFFFFFFF000000) | (data & 0xFFFFFF);
} | /** Magic_serial_type3 Learning
* @param data - serial number (24bit)
* @param man - magic man (64bit)
* @return manufacture for this serial number (64bit)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/genie-recorder/protocols/keeloq_common.c#L123-L126 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rolling_flaws_navigation_exit_callback | uint32_t rolling_flaws_navigation_exit_callback(void* context) {
UNUSED(context);
return VIEW_NONE;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/rolling-flaws/rolling_flaws.c#L110-L113 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rolling_flaws_navigation_submenu_callback | uint32_t rolling_flaws_navigation_submenu_callback(void* context) {
UNUSED(context);
return RollingFlawsViewSubmenu;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/rolling-flaws/rolling_flaws.c#L122-L126 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rolling_flaws_navigation_submenu_stop_receiving_callback | uint32_t rolling_flaws_navigation_submenu_stop_receiving_callback(void* context) {
RollingFlaws* app = (RollingFlaws*)context;
stop_listening(app->subghz);
return RollingFlawsViewSubmenu;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/rolling-flaws/rolling_flaws.c#L135-L140 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | my_app_navigation_exit_callback | static uint32_t my_app_navigation_exit_callback(void* context) {
UNUSED(context);
return VIEW_NONE;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/signal_send_demo/app.c#L61-L64 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | my_app_navigation_submenu_callback | static uint32_t my_app_navigation_submenu_callback(void* context) {
UNUSED(context);
return MyAppViewSubmenu;
} | /**
* @brief Callback for navigation events
* @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
* @return next view id
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/signal_send_demo/app.c#L73-L76 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | my_app_submenu_callback | static void my_app_submenu_callback(void* context, uint32_t index) {
MyApp* app = (MyApp*)context;
switch(index) {
case MyAppSubmenuIndexConfigure:
view_dispatcher_switch_to_view(app->view_dispatcher, MyAppViewConfigure);
break;
case MyAppSubmenuIndexFlipTheWorld: {
// Copy our... | /**
* @brief Callback for most of the submenu events (About, Configure, etc.)
* @details This function is called when user press a submenu item. We switch to the
* appropriate view.
* @param context The context
* @param[in] index The index of the menu item.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/signal_send_demo/app.c#L85-L107 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | my_app_submenu_send_signal_callback | static void my_app_submenu_send_signal_callback(void* context, uint32_t index) {
MyApp* app = (MyApp*)context;
uint32_t freq = setting_1_values[app->model->setting_1_index];
// Show a "sending signal" screen while we send the signal.
view_dispatcher_switch_to_view(app->view_dispatcher, MyAppViewSendSig... | /**
* @brief Callback for submenu events that send a signal
* @details This function is called when user press a submenu item. We send the signal,
* show a "sending signal" screen, and then switch back to the submenu.
* @param context The context
* @param[in] index The index of the men... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/apps/signal_send_demo/app.c#L116-L140 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_navigation_exit_callback | static uint32_t fmf2sub_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 (VIEW_NONE)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L92-L95 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_navigation_submenu_callback | static uint32_t fmf2sub_navigation_submenu_callback(void* _context) {
UNUSED(_context);
return Fmf2SubViewSubmenu;
} | /**
* @brief Callback for returning to submenu.
* @details This function is called when user press back button. We return ViewSubmenu to
* indicate that we want to navigate to the submenu.
* @param _context The context - unused
* @return next view id (ViewSubmenu)
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L104-L107 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_submenu_callback | static void fmf2sub_submenu_callback(void* context, uint32_t index) {
Fmf2SubApp* app = (Fmf2SubApp*)context;
switch(index) {
case Fmf2SubSubmenuIndexConfigure:
view_dispatcher_switch_to_view(app->view_dispatcher, Fmf2SubViewConfigure);
break;
case Fmf2SubSubmenuIndexConvert:
vie... | /**
* @brief Handle submenu item selection.
* @details This function is called when user selects an item from the submenu.
* @param context The context - Fmf2SubApp object.
* @param index The Fmf2SubSubmenuIndex item that was clicked.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L115-L130 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_view_convert_draw_callback | static void fmf2sub_view_convert_draw_callback(Canvas* canvas, void* model) {
Fmf2SubConvertModel* my_model = (Fmf2SubConvertModel*)model;
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 1, 10, "Press OK to select Flipper");
canvas_draw_str(canvas, 1, 20, "Music File (.FMF) to convert");... | /**
* @brief Callback for drawing the convert 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/subghz/fmf_to_sub/app.c#L229-L257 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_view_convert_enter_callback | static void fmf2sub_view_convert_enter_callback(void* context) {
UNUSED(context);
} | /**
* @brief Callback when the user starts the convert screen.
* @details This function is called when the user enters the convert screen.
* @param context The context - Fmf2SubApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L264-L266 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_view_convert_exit_callback | static void fmf2sub_view_convert_exit_callback(void* context) {
Fmf2SubApp* app = (Fmf2SubApp*)context;
with_view_model(
app->view_convert,
Fmf2SubConvertModel * model,
{
model->state = Fmf2SubStateIdle;
if(model->data.notes) {
furi_string_free(mod... | /**
* @brief Callback when the user exits the convert screen.
* @details This function is called when the user exits the convert screen.
* @param context The context - Fmf2SubApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L273-L286 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_view_convert_custom_event_callback | static bool fmf2sub_view_convert_custom_event_callback(uint32_t event, void* context) {
Fmf2SubApp* app = (Fmf2SubApp*)context;
switch(event) {
case Fmf2SubEventIdRedrawScreen:
// 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 - Fmf2SubEventId value.
* @param context The context - Fmf2SubApp object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L630-L690 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_view_convert_input_callback | static bool fmf2sub_view_convert_input_callback(InputEvent* event, void* context) {
Fmf2SubApp* app = (Fmf2SubApp*)context;
UNUSED(app);
if(event->type == InputTypeShort) {
if(event->key == InputKeyLeft) {
bool redraw = true;
with_view_model(
app->view_conver... | /**
* @brief Callback for convert screen input.
* @details This function is called when the user presses a button while on the convert screen.
* @param event The event - InputEvent object.
* @param context The context - Fmf2SubApp object.
* @return true if the event was handled, false oth... | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L699-L746 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf2sub_app_free | static void fmf2sub_app_free(Fmf2SubApp* app) {
view_dispatcher_remove_view(app->view_dispatcher, Fmf2SubViewTextInput);
text_input_free(app->text_input);
free(app->temp_buffer);
view_dispatcher_remove_view(app->view_dispatcher, Fmf2SubViewAbout);
widget_free(app->widget_about);
view_dispatcher_... | /**
* @brief Free the fmf2sub application.
* @details This function frees the fmf2sub application resources.
* @param app The fmf2sub application object.
*/ | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/fmf_to_sub/app.c#L876-L895 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | fmf_to_sub_app | int32_t fmf_to_sub_app(void* _p) {
UNUSED(_p);
Fmf2SubApp* app = fmf2sub_app_alloc();
view_dispatcher_run(app->view_dispatcher);
fmf2sub_app_free(app);
return 0;
} | /**
* @brief Main function for fmf2sub application.
* @details This function is the entry point for the fmf2sub 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/subghz/fmf_to_sub/app.c#L904-L912 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | isWin | static bool isWin(GameState state) {
return (StateWonPaper == state) || (StateWonRock == state) || (StateWonScissors == state);
} | // Checks if game state is winner.
// @param state GameState to check.
// @returns true if game state is a winner. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L22-L24 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | isLoss | static bool isLoss(GameState state) {
return (StateLostPaper == state) || (StateLostRock == state) || (StateLostScissors == state);
} | // Checks if game state is lost.
// @param state GameState to check.
// @returns true if game state is a loss. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L29-L31 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | isTie | static bool isTie(GameState state) {
return (StateTiePaper == state) || (StateTieRock == state) || (StateTieScissors == state);
} | // Checks if game state is tie.
// @param state GameState to check.
// @returns true if game state is a tie. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L36-L38 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | isResult | static bool isResult(GameState state) {
return isWin(state) || isLoss(state) || isTie(state);
} | // Checks if game state is result (win/loss/tie).
// @param state GameState to check.
// @returns true if game state is a win, loss or tie. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L43-L45 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | isFinalMove | static bool isFinalMove(GameState state) {
return (StateRock == state) || (StatePaper == state) || (StateScissors == state);
} | // Checks if game state is final move (rock/paper/scissors).
// @param state GameState to check.
// @returns true if game state is a rock, paper, scissors. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L50-L52 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | single_vibro | static void single_vibro() {
NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION);
notification_message(notification, &sequence_single_vibro);
furi_record_close(RECORD_NOTIFICATION);
} | // When user makes a move, we briefly pulse the vibro motor. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L55-L59 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | play_note | static void
play_note(float frequency, float volume, uint32_t durationPlay, uint32_t durationPause) {
furi_hal_speaker_start(frequency, volume);
uint32_t n = furi_get_tick();
while(furi_get_tick() < n + durationPlay) {
furi_thread_yield();
}
furi_hal_speaker_stop();
n = furi_get_tick... | // Plays a note. You must acquire the speaker before invoking.
// @frequency the frequency of the note in Hz.
// @volume the volume of the note from 0.0 to 1.0
// @durationPlay the duration of the note in ms.
// @durationPause the duration after the note to be silent. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L66-L78 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | play_song | static void play_song(GameContext* game_context) {
if(furi_hal_speaker_acquire(1000)) {
GameState state = game_context->data->local_player;
const float volume = 1.0f;
const uint32_t playQtr = 500;
const uint32_t delayQtr = 100;
if(isWin(state)) {
play_note(523.25... | // Play a song | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L81-L107 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_worker_update_rx_event_callback | static void rps_worker_update_rx_event_callback(void* ctx) {
furi_assert(ctx);
GameContext* game_context = ctx;
GameEvent event = {.type = GameEventDataDetected, .tick = furi_get_tick()};
furi_message_queue_put(game_context->queue, &event, FuriWaitForever);
} | // We register this callback to get invoked whenever new subghz data is received.
// Queue a GameEventDataDetected message.
// @param ctx pointer to a GameContext | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L112-L117 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_timer_callback | static void rps_timer_callback(void* ctx) {
furi_assert(ctx);
GameContext* game_context = ctx;
GameEvent event = {.type = GameEventTypeTimer};
furi_message_queue_put(game_context->queue, &event, FuriWaitForever);
} | // We register this callback to get invoked whenever the timer triggers.
// Queue a GameEventTypeTimer message.
// @param ctx pointer to a GameContext | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L122-L127 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_receive_data | static void rps_receive_data(GameContext* game_context, uint32_t tick) {
char sender_name[MESSAGE_MAX_LEN] = {0};
GameRfPurpose purpose;
uint8_t version;
unsigned int game_number;
Move move = MoveUnknown;
char* sender_contact;
int index = 0;
uint8_t message[MESSAGE_MAX_LEN] = {0};
... | // This gets invoked when we process a GameEventDataDetected event.
// Read the message using subghz_tx_rx_worker_read & determine if valid format.
// If valid, we queue a message for further processing.
// @param game_context pointer to a GameContext
// @param time (furi_get_tick) when event was initially made | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L134-L364 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_input_callback | static void rps_input_callback(InputEvent* input_event, void* ctx_q) {
furi_assert(ctx_q);
FuriMessageQueue* queue = ctx_q;
GameEvent event = {.type = GameEventTypeKey, .tick = furi_get_tick(), .input = *input_event};
furi_message_queue_put(queue, &event, FuriWaitForever);
} | // This gets invoked when input (button press) is detected.
// We queue a GameEventTypeKey message with the input event data.
// @param input_event event information, such as key that was pressed.
// @param ctx_q message queue. | https://github.com/jamisonderek/flipper-zero-tutorials/blob/89716a9b00eacce7055a75fddb5a3adde93f265f/subghz/plugins/rock_paper_scissors/rock_paper_scissors.c#L370-L375 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_host_game | static void rps_render_host_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 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#L380-L435 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
flipper-zero-tutorials | github_2023 | jamisonderek | c | rps_render_join_game | static void rps_render_join_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 joining a 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#L440-L503 | 89716a9b00eacce7055a75fddb5a3adde93f265f |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.