[FL-1906] Documentation: add Doxyfile, prepare sources for doxygen. (#741)

* Documentation: add Doxyfile, prepare sources for doxygen.

* Update ReadMe and remove obsolete CLA

* Add contribution guide

* Contributing: update text

* Correct spelling
This commit is contained in:
あく 2021-10-03 13:36:05 +03:00 committed by GitHub
parent 1208a5077f
commit 89a6c09a7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
66 changed files with 4846 additions and 1224 deletions

71
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,71 @@
# Welcome to FlipperZero contributing guide <!-- omit in toc -->
Thank you for investing your time in contributing to our project!
Read our [Code of Coduct](CODE_OF_CONDUCT.md) to keep our community approachable and respectable.
In this guide you will get an overview of the contribution workflow from opening an issue, creating a PR, reviewing, and merging the PR.
## New contributor guide
See the [ReadMe](ReadMe.md) to get an overview of the project. Here are some helpful resources to get you comfortable with open source contribution:
- [Finding ways to contribute to open source on GitHub](https://docs.github.com/en/get-started/exploring-projects-on-github/finding-ways-to-contribute-to-open-source-on-github)
- [Set up Git](https://docs.github.com/en/get-started/quickstart/set-up-git)
- [GitHub flow](https://docs.github.com/en/get-started/quickstart/github-flow)
- [Collaborating with pull requests](https://docs.github.com/en/github/collaborating-with-pull-requests)
## Getting started
Before writing code and creating PR make sure that it aligns with our mission and guidlines:
- All our devices are intended for research and education.
- PR that contains code intended to commit crimes is not going to be accepted.
- Your PR must contain code compatiable with project [LICENSE](LICENSE).
- PR will only be merged if it pass CI/CD.
- PR will only be merged if it pass review by code owner.
Feel free to ask questions in issues if you're not sure.
### Issues
#### Create a new issue
If you found a problem, [search if an issue already exists](https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-issues-and-pull-requests#search-by-the-title-body-or-comments). If a related issue doesn't exist, you can open a new issue using a relevant [issue form](https://github.com/flipperdevices/flipperzero-firmware/issues/new/choose).
#### Solve an issue
Scan through our [existing issues](https://github.com/flipperdevices/flipperzero-firmware/issues) to find one that interests you.
### Make Changes
1. Fork the repository.
- Using GitHub Desktop:
- [Getting started with GitHub Desktop](https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/getting-started-with-github-desktop) will guide you through setting up Desktop.
- Once Desktop is set up, you can use it to [fork the repo](https://docs.github.com/en/desktop/contributing-and-collaborating-using-github-desktop/cloning-and-forking-repositories-from-github-desktop)!
- Using the command line:
- [Fork the repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo#fork-an-example-repository) so that you can make your changes without affecting the original project until you're ready to merge them.
2. Install build requirements
3. Create a working branch and start with your changes!
### Commit your update
Commit the changes once you are happy with them. Make sure that code compilation is not broken and passes tests. Check syntax and formatting.
### Pull Request
When you're done making the changes, open a pull request, often referred to as a PR.
- Fill out the "Ready for review" template so we can review your PR. This template helps reviewers understand your changes and the purpose of your pull request.
- Don't forget to [link PR to issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) if you are solving one.
- Enable the checkbox to [allow maintainer edits](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork) so the branch can be updated for a merge.
Once you submit your PR, a Docs team member will review your proposal. We may ask questions or request for additional information.
- We may ask for changes to be made before a PR can be merged, either using [suggested changes](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request) or pull request comments. You can apply suggested changes directly through the UI. You can make any other changes in your fork, then commit them to your branch.
- As you update your PR and apply changes, mark each conversation as [resolved](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/commenting-on-a-pull-request#resolving-conversations).
- If you run into any merge issues, checkout this [git tutorial](https://lab.github.com/githubtraining/managing-merge-conflicts) to help you resolve merge conflicts and other issues.
### Your PR is merged!
Congratulations :tada::tada: The FlipperDevices team thanks you :sparkles:.

View File

@ -162,6 +162,7 @@ Finally, you will have **`firmware/.obj/f6/full.dfu`** file that can be distribu
- core - core libraries: home for furi
- debug - debug helpers, plugins and tools
- docker - docker image sources (used for automated firmware build)
- documentation - documentation generation system configs and input files
- firmware - firmware for flipper
* targets - targets' hal and implementation
- lib - different libraries and drivers that apps and firmware uses

View File

@ -1,11 +1,16 @@
/**
* @file cli.h
* Cli API
*/
#pragma once
#include <m-string.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <m-string.h>
typedef enum {
CliSymbolAsciiSOH = 0x01,
CliSymbolAsciiETX = 0x03,
@ -21,30 +26,29 @@ typedef enum {
} CliSymbols;
typedef enum {
CliCommandFlagDefault = 0, /** Default, loader lock is used */
CliCommandFlagDefault = 0, /**< Default, loader lock is used */
CliCommandFlagParallelSafe =
(1 << 0), /** Safe to run in parallel with other apps, loader lock is not used */
CliCommandFlagInsomniaSafe = (1 << 1), /** Safe to run with insomnia mode on */
(1 << 0), /**< Safe to run in parallel with other apps, loader lock is not used */
CliCommandFlagInsomniaSafe = (1 << 1), /**< Safe to run with insomnia mode on */
} CliCommandFlag;
/* Cli type
* Anonymous structure. Use cli_i.h if you need to go deeper.
*/
/** Cli type anonymous structure */
typedef struct Cli Cli;
/* Cli callback function pointer.
* Implement this interface and use add_cli_command
* @param args - string with what was passed after command
* @param context - pointer to whatever you gave us on cli_add_command
/** Cli callback function pointer. Implement this interface and use
* add_cli_command
* @param args string with what was passed after command
* @param context pointer to whatever you gave us on cli_add_command
*/
typedef void (*CliCallback)(Cli* cli, string_t args, void* context);
/* Add cli command
* Registers you command callback
* @param cli - pointer to cli instance
* @param name - command name
* @param callback - callback function
* @param context - pointer to whatever we need to pass to callback
/** Add cli command Registers you command callback
*
* @param cli pointer to cli instance
* @param name command name
* @param flags CliCommandFlag
* @param callback callback function
* @param context pointer to whatever we need to pass to callback
*/
void cli_add_command(
Cli* cli,
@ -53,51 +57,56 @@ void cli_add_command(
CliCallback callback,
void* context);
/* Print unified cmd usage tip
* @param cmd - cmd name
* @param usage - usage tip
* @param arg - arg passed by user
/** Print unified cmd usage tip
*
* @param cmd cmd name
* @param usage usage tip
* @param arg arg passed by user
*/
void cli_print_usage(const char* cmd, const char* usage, const char* arg);
/* Delete cli command
* @param cli - pointer to cli instance
* @param name - command name
/** Delete cli command
*
* @param cli pointer to cli instance
* @param name command name
*/
void cli_delete_command(Cli* cli, const char* name);
/* Read from terminal
* Do it only from inside of cli call.
* @param cli - Cli instance
* @param buffer - pointer to buffer
* @param size - size of buffer in bytes
* @return bytes written
/** Read from terminal Do it only from inside of cli call.
*
* @param cli Cli instance
* @param buffer pointer to buffer
* @param size size of buffer in bytes
*
* @return bytes written
*/
size_t cli_read(Cli* cli, uint8_t* buffer, size_t size);
/* Not blocking check for interrupt command received
* @param cli - Cli instance
/** Not blocking check for interrupt command received
*
* @param cli Cli instance
*
* @return true if received
*/
bool cli_cmd_interrupt_received(Cli* cli);
/* Write to terminal
* Do it only from inside of cli call.
* @param cli - Cli instance
* @param buffer - pointer to buffer
* @param size - size of buffer in bytes
* @return bytes written
/** Write to terminal Do it only from inside of cli call.
*
* @param cli Cli instance
* @param buffer pointer to buffer
* @param size size of buffer in bytes
*/
void cli_write(Cli* cli, const uint8_t* buffer, size_t size);
/* Read character
* @param cli - Cli instance
* @return char
/** Read character
*
* @param cli Cli instance
*
* @return char
*/
char cli_getc(Cli* cli);
/* New line
* Send new ine sequence
/** New line Send new ine sequence
*/
void cli_nl();

View File

@ -1,3 +1,8 @@
/**
* @file canvas.h
* GUI: Canvas API
*/
#pragma once
#include <stdint.h>
@ -8,13 +13,16 @@
extern "C" {
#endif
/** Color enumeration */
typedef enum {
ColorWhite = 0x00,
ColorBlack = 0x01,
} Color;
/** Fonts enumeration */
typedef enum { FontPrimary, FontSecondary, FontKeyboard } Font;
/** Alignment enumeration */
typedef enum {
AlignLeft,
AlignRight,
@ -23,59 +31,85 @@ typedef enum {
AlignCenter,
} Align;
/** Canvas Orientation */
typedef enum {
CanvasOrientationHorizontal,
CanvasOrientationVertical,
} CanvasOrientation;
/** Canvas anonymouse structure */
typedef struct Canvas Canvas;
/*
* Canvas width
* @return width in pixels.
/** Get Canvas width
*
* @param canvas Canvas instance
*
* @return width in pixels.
*/
uint8_t canvas_width(Canvas* canvas);
/*
* Canvas height
* @return height in pixels.
/** Get Canvas height
*
* @param canvas Canvas instance
*
* @return height in pixels.
*/
uint8_t canvas_height(Canvas* canvas);
/*
* Get current font height
* @return height in pixels.
/** Get current font height
*
* @param canvas Canvas instance
*
* @return height in pixels.
*/
uint8_t canvas_current_font_height(Canvas* canvas);
/*
* Clear canvas, clear rendering buffer
/** Clear canvas
*
* @param canvas Canvas instance
*/
void canvas_clear(Canvas* canvas);
/*
* Set drawing color
/** Set drawing color
*
* @param canvas Canvas instance
* @param color Color
*/
void canvas_set_color(Canvas* canvas, Color color);
/*
* Invert drawing color
/** Invert drawing color
*
* @param canvas Canvas instance
*/
void canvas_invert_color(Canvas* canvas);
/*
* Set drawing font
/** Set drawing font
*
* @param canvas Canvas instance
* @param font Font
*/
void canvas_set_font(Canvas* canvas, Font font);
/*
* Draw string at position of baseline defined by x, y.
/** Draw string at position of baseline defined by x, y.
*
* @param canvas Canvas instance
* @param x anchor point x coordinate
* @param y anchor point y coordinate
* @param str C-string
*/
void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str);
/*
* Draw aligned string defined by x, y.
* Align calculated from position of baseline, string width and ascent (height of the glyphs above the baseline)
/** Draw aligned string defined by x, y.
*
* Align calculated from position of baseline, string width and ascent (height
* of the glyphs above the baseline)
*
* @param canvas Canvas instance
* @param x anchor point x coordinate
* @param y anchor point y coordinate
* @param horizontal horizontal alignment
* @param vertical vertical alignment
* @param str C-string
*/
void canvas_draw_str_aligned(
Canvas* canvas,
@ -85,22 +119,30 @@ void canvas_draw_str_aligned(
Align vertical,
const char* str);
/*
* Get string width
* @return width in pixels.
/** Get string width
*
* @param canvas Canvas instance
* @param str C-string
*
* @return width in pixels.
*/
uint16_t canvas_string_width(Canvas* canvas, const char* str);
/** Get glyph width
* @return width in pixels
*
* @param canvas Canvas instance
* @param[in] symbol character
*
* @return width in pixels
*/
uint8_t canvas_glyph_width(Canvas* canvas, char symbol);
/** Draw animation at position defined by x,y.
* @param canvas - canvas instance
* @param x - x coordinate
* @param y - y coordinate
* @param icon_animation - data pointer to IconAnimation
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param icon_animation IconAnimation instance
*/
void canvas_draw_icon_animation(
Canvas* canvas,
@ -109,15 +151,22 @@ void canvas_draw_icon_animation(
IconAnimation* icon_animation);
/** Draw icon at position defined by x,y.
* @param canvas - canvas instance
* @param x - x coordinate
* @param y - y coordinate
* @param icon - data pointer to Icon
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param icon Icon instance
*/
void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon);
/*
* Draw xbm icon of width, height at position defined by x,y.
/** Draw XBM bitmap
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param w bitmap width
* @param h bitmap height
* @param bitmap pointer to XBM bitmap data
*/
void canvas_draw_xbm(
Canvas* canvas,
@ -127,48 +176,86 @@ void canvas_draw_xbm(
uint8_t h,
const uint8_t* bitmap);
/*
* Draw dot at x,y
/** Draw dot at x,y
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
*/
void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y);
/*
* Draw box of width, height at x,y
/** Draw box of width, height at x,y
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param width box width
* @param height box height
*/
void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
/*
* Draw frame of width, height at x,y
/** Draw frame of width, height at x,y
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param width frame width
* @param height frame height
*/
void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
/*
* Draw line from x1,y1 to x2,y2
/** Draw line from x1,y1 to x2,y2
*
* @param canvas Canvas instance
* @param x1 x1 coordinate
* @param y1 y1 coordinate
* @param x2 x2 coordinate
* @param y2 y2 coordinate
*/
void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
/*
* Draw circle at x,y with radius r
/** Draw circle at x,y with radius r
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param r radius
*/
void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
/*
* Draw disc at x,y with radius r
/** Draw disc at x,y with radius r
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param r radius
*/
void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
/*
* Draw glyph
/** Draw glyph
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param ch character
*/
void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);
/*
* Set transparency mode
/** Set transparency mode
*
* @param canvas Canvas instance
* @param alpha transparency mode
*/
void canvas_set_bitmap_mode(Canvas* canvas, bool alpha);
/*
* Draw rounded-corner frame of width, height at x,y, with round value raduis
/** Draw rounded-corner frame of width, height at x,y, with round value raduis
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param width frame width
* @param height frame height
* @param radius frame corner radius
*/
void canvas_draw_rframe(
Canvas* canvas,
@ -178,8 +265,14 @@ void canvas_draw_rframe(
uint8_t height,
uint8_t radius);
/*
* Draw rounded-corner box of width, height at x,y, with round value raduis
/** Draw rounded-corner box of width, height at x,y, with round value raduis
*
* @param canvas Canvas instance
* @param x x coordinate
* @param y y coordinate
* @param width box width
* @param height box height
* @param radius box corner radius
*/
void canvas_draw_rbox(
Canvas* canvas,

View File

@ -1,8 +1,15 @@
/**
* @file canvas_i.h
* GUI: internal Canvas API
*/
#pragma once
#include "canvas.h"
#include <u8g2.h>
/** Canvas structure
*/
struct Canvas {
u8g2_t fb;
CanvasOrientation orientation;
@ -12,40 +19,53 @@ struct Canvas {
uint8_t height;
};
/*
* Allocate memory and initialize canvas
/** Allocate memory and initialize canvas
*
* @return Canvas instance
*/
Canvas* canvas_init();
/*
* Free canvas memory
/** Free canvas memory
*
* @param canvas Canvas instance
*/
void canvas_free(Canvas* canvas);
/*
* Reset canvas drawing tools configuration
/** Reset canvas drawing tools configuration
*
* @param canvas Canvas instance
*/
void canvas_reset(Canvas* canvas);
/*
* Commit canvas. Send buffer to display
/** Commit canvas. Send buffer to display
*
* @param canvas Canvas instance
*/
void canvas_commit(Canvas* canvas);
/*
* Get canvas buffer.
* @return pointer to buffer
/** Get canvas buffer.
*
* @param canvas Canvas instance
*
* @return pointer to buffer
*/
uint8_t* canvas_get_buffer(Canvas* canvas);
/*
* Get canvas buffer size.
* @return size of canvas in bytes
/** Get canvas buffer size.
*
* @param canvas Canvas instance
*
* @return size of canvas in bytes
*/
size_t canvas_get_buffer_size(Canvas* canvas);
/*
* Set drawing region relative to real screen buffer
/** Set drawing region relative to real screen buffer
*
* @param canvas Canvas instance
* @param offset_x x coordinate offset
* @param offset_y y coordinate offset
* @param width width
* @param height height
*/
void canvas_frame_set(
Canvas* canvas,
@ -54,12 +74,17 @@ void canvas_frame_set(
uint8_t width,
uint8_t height);
/*
* Set canvas orientation
/** Set canvas orientation
*
* @param canvas Canvas instance
* @param orientation CanvasOrientation
*/
void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation);
/*
* Get canvas orientation
/** Get canvas orientation
*
* @param canvas Canvas instance
*
* @return CanvasOrientation
*/
CanvasOrientation canvas_get_orientation(const Canvas* canvas);

View File

@ -1,3 +1,11 @@
/**
* @file elements.h
* GUI: Elements API
*
* Canvas helpers and UI building blocks.
*
*/
#pragma once
#include <stdint.h>

View File

@ -1,3 +1,8 @@
/**
* @file gui.h
* GUI: main API
*/
#pragma once
#include "view_port.h"
@ -7,60 +12,74 @@
extern "C" {
#endif
/* Gui layers */
/** Gui layers */
typedef enum {
GuiLayerNone, /* Special layer for internal use only */
GuiLayerNone, /**< Special layer for internal use only */
GuiLayerStatusBarLeft, /* Status bar left-side layer, auto-layout */
GuiLayerStatusBarRight, /* Status bar right-side layer, auto-layout */
GuiLayerMain, /* Main layer, status bar is shown */
GuiLayerFullscreen, /* Fullscreen layer */
GuiLayerStatusBarLeft, /**< Status bar left-side layer, auto-layout */
GuiLayerStatusBarRight, /**< Status bar right-side layer, auto-layout */
GuiLayerMain, /**< Main layer, status bar is shown */
GuiLayerFullscreen, /**< Fullscreen layer */
GuiLayerMAX /* Don't use or move, special value */
GuiLayerMAX /**< Don't use or move, special value */
} GuiLayer;
/* Gui frame buffer callback */
/** Gui Canvas Commit Callback */
typedef void (*GuiCanvasCommitCallback)(uint8_t* data, size_t size, void* context);
typedef struct Gui Gui;
/*
* Add view_port to view_port tree
* @remarks thread safe
/** Add view_port to view_port tree
*
* @remark thread safe
*
* @param gui Gui instance
* @param view_port ViewPort instance
* @param[in] layer GuiLayer where to place view_port
*/
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer);
/*
* Remove view_port from rendering tree
* @remarks thread safe
/** Remove view_port from rendering tree
*
* @remark thread safe
*
* @param gui Gui instance
* @param view_port ViewPort instance
*/
void gui_remove_view_port(Gui* gui, ViewPort* view_port);
/* Send ViewPort to the front
/** Send ViewPort to the front
*
* Places selected ViewPort to the top of the drawing stack
* @param gui - Gui instance
* @param view_port - ViewPort instance
*
* @param gui Gui instance
* @param view_port ViewPort instance
*/
void gui_send_view_port_front(Gui* gui, ViewPort* view_port);
/* Send ViewPort to the back
/** Send ViewPort to the back
*
* Places selected ViewPort to the bottom of the drawing stack
* @param gui - Gui instance
* @param view_port - ViewPort instance
*
* @param gui Gui instance
* @param view_port ViewPort instance
*/
void gui_send_view_port_back(Gui* gui, ViewPort* view_port);
/* Set gui canvas commit callback
* This callback will be called upon Canvas commit
* Callback dispatched from GUI thread and is time critical
* @param gui - Gui instance
* @param callback - GuiCanvasCommitCallback
/** Set gui canvas commit callback
*
* This callback will be called upon Canvas commit Callback dispatched from GUI
* thread and is time critical
*
* @param gui Gui instance
* @param callback GuiCanvasCommitCallback
*/
void gui_set_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback);
/* Set gui canvas commit callback context
* @param gui - Gui instance
* @param context - pointer to context
/** Set gui canvas commit callback context
*
* @param gui Gui instance
* @param context pointer to context
*/
void gui_set_framebuffer_callback_context(Gui* gui, void* context);

View File

@ -1,3 +1,8 @@
/**
* @file gui_i.h
* GUI: main API internals
*/
#pragma once
#include "gui.h"
@ -31,6 +36,7 @@
ARRAY_DEF(ViewPortArray, ViewPort*, M_PTR_OPLIST);
/** Gui structure */
struct Gui {
// Thread and lock
osThreadId_t thread;
@ -54,8 +60,9 @@ struct Gui {
ViewPort* gui_view_port_find_enabled(ViewPortArray_t array);
/* Update GUI, request redraw
* @param gui, Gui instance
/** Update GUI, request redraw
*
* @param gui Gui instance
*/
void gui_update(Gui* gui);
@ -67,4 +74,4 @@ void gui_unlock(Gui* gui);
void gui_cli_screen_stream_callback(uint8_t* data, size_t size, void* context);
void gui_cli_screen_stream(Cli* cli, string_t args, void* context);
void gui_cli_screen_stream(Cli* cli, string_t args, void* context);

View File

@ -1,3 +1,8 @@
/**
* @file icon.h
* GUI: Icon API
*/
#pragma once
#include <stdint.h>
@ -8,10 +13,28 @@ extern "C" {
typedef struct Icon Icon;
/** Get icon width
*
* @param[in] instance pointer to Icon data
*
* @return width in pixels
*/
uint8_t icon_get_width(const Icon* instance);
/** Get icon height
*
* @param[in] instance pointer to Icon data
*
* @return height in pixels
*/
uint8_t icon_get_height(const Icon* instance);
/** Get Icon XBM bitmap data
*
* @param[in] instance pointer to Icon data
*
* @return pointer to XBM bitmap data
*/
const uint8_t* icon_get_data(const Icon* instance);
#ifdef __cplusplus

View File

@ -1,28 +1,48 @@
/**
* @file icon_animation.h
* GUI: IconAnimation API
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <assets_icons.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <assets_icons.h>
/** Icon Animation */
typedef struct IconAnimation IconAnimation;
/** Icon Animation Callback. Used for update notification */
typedef void (*IconAnimationCallback)(IconAnimation* instance, void* context);
/** Allocate icon animation instance with const icon data.
*
* always returns Icon or stops system if not enough memory
*
* @param[in] icon pointer to Icon data
*
* @return IconAnimation instance
*/
IconAnimation* icon_animation_alloc(const Icon* icon);
/** Release icon animation instance
*
* @param instance IconAnimation instance
*/
void icon_animation_free(IconAnimation* instance);
/** Get icon animation width
/** Set IconAnimation update callback
*
* Normally you do not need to use this function, use view_tie_icon_animation
* instead.
*
* @param instance IconAnimation instance
* @param[in] callback IconAnimationCallback
* @param context callback context
*/
void icon_animation_set_update_callback(
IconAnimation* instance,
@ -30,22 +50,38 @@ void icon_animation_set_update_callback(
void* context);
/** Get icon animation width
*
* @param instance IconAnimation instance
*
* @return width in pixels
*/
uint8_t icon_animation_get_width(IconAnimation* instance);
/** Get icon animation height
*
* @param instance IconAnimation instance
*
* @return height in pixels
*/
uint8_t icon_animation_get_height(IconAnimation* instance);
/** Start icon animation
*
* @param instance IconAnimation instance
*/
void icon_animation_start(IconAnimation* instance);
/** Stop icon animation
*
* @param instance IconAnimation instance
*/
void icon_animation_stop(IconAnimation* instance);
/** Returns true if current frame is a last one
*
* @param instance IconAnimation instance
*
* @return true if last frame
*/
bool icon_animation_is_last_frame(IconAnimation* instance);

View File

@ -1,3 +1,8 @@
/**
* @file icon_animation_i.h
* GUI: internal IconAnimation API
*/
#pragma once
#include "icon_animation.h"
@ -13,11 +18,22 @@ struct IconAnimation {
void* callback_context;
};
/** Get pointer to current frame data */
/** Get pointer to current frame data
*
* @param instance IconAnimation instance
*
* @return pointer to current frame XBM bitmap data
*/
const uint8_t* icon_animation_get_data(IconAnimation* instance);
/** Advance to next frame */
/** Advance to next frame
*
* @param instance IconAnimation instance
*/
void icon_animation_next_frame(IconAnimation* instance);
/** IconAnimation timer callback */
/** IconAnimation timer callback
*
* @param context pointer to IconAnimation
*/
void icon_animation_timer_callback(void* context);

View File

@ -1,3 +1,8 @@
/**
* @file icon_i.h
* GUI: internal Icon API
*/
#include "icon.h"
struct Icon {

View File

@ -1,4 +1,10 @@
/**
* @file button_menu.h
* GUI: ButtonMenu view module API
*/
#pragma once
#include <stdint.h>
#include <gui/view.h>
@ -6,40 +12,48 @@
extern "C" {
#endif
/* ButtonMenu anonymous structure */
/** ButtonMenu anonymous structure */
typedef struct ButtonMenu ButtonMenu;
/** ButtonMenuItem anonymous structure */
typedef struct ButtonMenuItem ButtonMenuItem;
/* Callback for any button menu actions */
/** Callback for any button menu actions */
typedef void (*ButtonMenuItemCallback)(void* context, int32_t index, InputType type);
/* Type of button. Difference in drawing buttons. */
/** Type of button. Difference in drawing buttons. */
typedef enum {
ButtonMenuItemTypeCommon,
ButtonMenuItemTypeControl,
} ButtonMenuItemType;
/**
* @brief Get button menu view
* @param button_menu - ButtonMenu instance
* @return View instance that can be used for embedding
/** Get button menu view
*
* @param button_menu ButtonMenu instance
*
* @return View instance that can be used for embedding
*/
View* button_menu_get_view(ButtonMenu* button_menu);
/**
* @brief Clean button menu
* @param button_menu - ButtonMenu instance
/** Clean button menu
*
* @param button_menu ButtonMenu instance
*/
void button_menu_clean(ButtonMenu* button_menu);
/**
* @brief Add item to button menu instance
* @param button_menu - ButtonMenu instance
* @param label - text inside new button
* @param index - value to distinct between buttons inside ButtonMenuItemCallback
* @param type - type of button to create. Differ by button drawing.
* Control buttons have no frames, and have more squared borders.
* @return pointer to just-created item
/** Add item to button menu instance
*
* @param button_menu ButtonMenu instance
* @param label text inside new button
* @param index value to distinct between buttons inside
* ButtonMenuItemCallback
* @param callback The callback
* @param type type of button to create. Differ by button
* drawing. Control buttons have no frames, and
* have more squared borders.
* @param callback_context The callback context
*
* @return pointer to just-created item
*/
ButtonMenuItem* button_menu_add_item(
ButtonMenu* button_menu,
@ -49,29 +63,29 @@ ButtonMenuItem* button_menu_add_item(
ButtonMenuItemType type,
void* callback_context);
/**
* @brief Allocate and initialize new instance of ButtonMenu model
* @return just-created ButtonMenu model
/** Allocate and initialize new instance of ButtonMenu model
*
* @return just-created ButtonMenu model
*/
ButtonMenu* button_menu_alloc(void);
/**
* @brief Free ButtonMenu element
* @param button_menu - ButtonMenu instance
/** Free ButtonMenu element
*
* @param button_menu ButtonMenu instance
*/
void button_menu_free(ButtonMenu* button_menu);
/**
* @brief Set ButtonMenu header on top of canvas
* @param button_menu - ButtonMenu instance
* @param header - header on the top of button menu
/** Set ButtonMenu header on top of canvas
*
* @param button_menu ButtonMenu instance
* @param header header on the top of button menu
*/
void button_menu_set_header(ButtonMenu* button_menu, const char* header);
/**
* @brief Set selected item
* @param button_menu - ButtonMenu instance
* @param index - index of ButtonMenu to be selected
/** Set selected item
*
* @param button_menu ButtonMenu instance
* @param index index of ButtonMenu to be selected
*/
void button_menu_set_selected_item(ButtonMenu* button_menu, uint32_t index);

View File

@ -1,4 +1,10 @@
/**
* @file button_panel.h
* GUI: ButtonPanel view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
@ -10,37 +16,39 @@ typedef struct ButtonPanel ButtonPanel;
/** Callback type to call for handling selecting button_panel items */
typedef void (*ButtonItemCallback)(void* context, uint32_t index);
/** Callback type for additional drawings above main button_panel screen */
typedef void (*ButtonPanelDrawCallback)(Canvas* canvas, void* _model);
/** Callback type to intercept input events of button_panel */
typedef bool (*ButtonPanelInputCallback)(InputEvent* event, void* context);
/** Allocate new button_panel module.
*
* @return just-created module
* @return ButtonPanel instance
*/
ButtonPanel* button_panel_alloc(void);
/** Free button_panel module.
*
* @param button_panel - module to free
* @param button_panel ButtonPanel instance
*/
void button_panel_free(ButtonPanel* button_panel);
/** Free items from button_panel module. Preallocated matrix stays unchanged.
*
* @param button_panel - module to clean
* @param button_panel ButtonPanel instance
*/
void button_panel_clean(ButtonPanel* button_panel);
/** Reserve space for adding items.
*
* One does not simply use button_panel_add_item() without this function.
* It should be allocated space for it first.
* One does not simply use button_panel_add_item() without this function. It
* should be allocated space for it first.
*
* @param button_panel - module to modify
* @param reserve_x - number of columns in button_panel
* @param reserve_y - number of rows in button_panel
* @param button_panel ButtonPanel instance
* @param reserve_x number of columns in button_panel
* @param reserve_y number of rows in button_panel
*/
void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t reserve_y);
@ -48,20 +56,20 @@ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t re
*
* Have to set element in bounds of allocated size by X and by Y.
*
* @param button_panel - module
* @param index - value to pass to callback
* @param matrix_place_x - coordinates by x-axis on virtual grid, it
* is only used for naviagation
* @param matrix_place_y - coordinates by y-axis on virtual grid, it
* is only used for naviagation
* @param x - x-coordinate to draw icon on
* @param y - y-coordinate to draw icon on
* @param icon_name - name of the icon to draw
* @param icon_name_selected - name of the icon to draw when current
* element is selected
* @param callback - function to call when specific element is selected
* (pressed Ok on selected item)
* @param callback_context - context to pass to callback
* @param button_panel ButtonPanel instance
* @param index value to pass to callback
* @param matrix_place_x coordinates by x-axis on virtual grid, it
* is only used for naviagation
* @param matrix_place_y coordinates by y-axis on virtual grid, it
* is only used for naviagation
* @param x x-coordinate to draw icon on
* @param y y-coordinate to draw icon on
* @param icon_name name of the icon to draw
* @param icon_name_selected name of the icon to draw when current
* element is selected
* @param callback function to call when specific element is
* selected (pressed Ok on selected item)
* @param callback_context context to pass to callback
*/
void button_panel_add_item(
ButtonPanel* button_panel,
@ -77,17 +85,19 @@ void button_panel_add_item(
/** Get button_panel view.
*
* @param button_panel - module to get view from
* @return acquired view
* @param button_panel ButtonPanel instance
*
* @return acquired view
*/
View* button_panel_get_view(ButtonPanel* button_panel);
/** Add label to button_panel module.
*
* @param x - x-coordinate to place label
* @param y - y-coordinate to place label
* @param font - font to write label with
* @param label_str - string label to write
* @param button_panel ButtonPanel instance
* @param x x-coordinate to place label
* @param y y-coordinate to place label
* @param font font to write label with
* @param label_str string label to write
*/
void button_panel_add_label(
ButtonPanel* button_panel,
@ -101,9 +111,9 @@ void button_panel_add_label(
*
* Used to add popup drawings after main draw callback is done.
*
* @param button_panel - module to modify
* @param callback - callback function to set for draw event
* @param context - context to pass to callback
* @param button_panel ButtonPanel instance
* @param callback callback function to set for draw event
* @param context context to pass to callback
*/
void button_panel_set_popup_draw_callback(
ButtonPanel* button_panel,
@ -112,12 +122,12 @@ void button_panel_set_popup_draw_callback(
/** Set popup input callback for button_panel module.
*
* Used to add popup input callback. It will intercept all input
* events for current view.
* Used to add popup input callback. It will intercept all input events for
* current view.
*
* @param button_panel - module to modify
* @param callback - function to overwrite main input callbacks
* @param context - context to pass to callback
* @param button_panel ButtonPanel instance
* @param callback function to overwrite main input callbacks
* @param context context to pass to callback
*/
void button_panel_set_popup_input_callback(
ButtonPanel* button_panel,

View File

@ -1,59 +1,53 @@
/**
* @file byte_input.h
* GUI: ByteInput keyboard view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Byte input anonymous structure
*
*/
/** Byte input anonymous structure */
typedef struct ByteInput ByteInput;
/**
* @brief callback that is executed on save button press
*
*/
/** callback that is executed on save button press */
typedef void (*ByteInputCallback)(void* context);
/**
* @brief callback that is executed when byte buffer is changed
*
*/
/** callback that is executed when byte buffer is changed */
typedef void (*ByteChangedCallback)(void* context);
/**
* @brief Allocate and initialize byte input. This byte input is used to enter bytes.
*
* @return ByteInput instance pointer
/** Allocate and initialize byte input. This byte input is used to enter bytes.
*
* @return ByteInput instance pointer
*/
ByteInput* byte_input_alloc();
/**
* @brief Deinitialize and free byte input
*
* @param byte_input Byte input instance
/** Deinitialize and free byte input
*
* @param byte_input Byte input instance
*/
void byte_input_free(ByteInput* byte_input);
/**
* @brief Get byte input view
*
* @param byte_input byte input instance
* @return View instance that can be used for embedding
/** Get byte input view
*
* @param byte_input byte input instance
*
* @return View instance that can be used for embedding
*/
View* byte_input_get_view(ByteInput* byte_input);
/**
* @brief Set byte input result callback
*
* @param byte_input byte input instance
* @param input_callback input callback fn
* @param changed_callback changed callback fn
* @param callback_context callback context
* @param bytes buffer to use
* @param bytes_count buffer length
/** Set byte input result callback
*
* @param byte_input byte input instance
* @param input_callback input callback fn
* @param changed_callback changed callback fn
* @param callback_context callback context
* @param bytes buffer to use
* @param bytes_count buffer length
*/
void byte_input_set_result_callback(
ByteInput* byte_input,
@ -63,11 +57,10 @@ void byte_input_set_result_callback(
uint8_t* bytes,
uint8_t bytes_count);
/**
* @brief Set byte input header text
*
* @param byte_input byte input instance
* @param text text to be shown
/** Set byte input header text
*
* @param byte_input byte input instance
* @param text text to be shown
*/
void byte_input_set_header_text(ByteInput* byte_input, const char* text);

View File

@ -1,77 +1,95 @@
/**
* @file dialog.h
* GUI: Dialog view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Dialog anonymous structure */
/** Dialog anonymous structure */
typedef struct Dialog Dialog;
/* Dialog result */
/** Dialog result */
typedef enum {
DialogResultLeft,
DialogResultRight,
DialogResultBack,
} DialogResult;
/* Dialog result callback type
* @warning comes from GUI thread
/** Dialog result callback type
* @warning comes from GUI thread
*/
typedef void (*DialogResultCallback)(DialogResult result, void* context);
/* Allocate and initialize dialog
/** Allocate and initialize dialog
*
* This dialog used to ask simple questions like Yes/
*
* @return Dialog instance
*/
Dialog* dialog_alloc();
/* Deinitialize and free dialog
* @param dialog - Dialog instance
/** Deinitialize and free dialog
*
* @param dialog Dialog instance
*/
void dialog_free(Dialog* dialog);
/* Get dialog view
* @param dialog - Dialog instance
* @return View instance that can be used for embedding
/** Get dialog view
*
* @param dialog Dialog instance
*
* @return View instance that can be used for embedding
*/
View* dialog_get_view(Dialog* dialog);
/* Set dialog result callback
* @param dialog - Dialog instance
* @param callback - result callback function
/** Set dialog result callback
*
* @param dialog Dialog instance
* @param callback result callback function
*/
void dialog_set_result_callback(Dialog* dialog, DialogResultCallback callback);
/* Set dialog context
* @param dialog - Dialog instance
* @param context - context pointer, will be passed to result callback
/** Set dialog context
*
* @param dialog Dialog instance
* @param context context pointer, will be passed to result callback
*/
void dialog_set_context(Dialog* dialog, void* context);
/* Set dialog header text
* @param dialog - Dialog instance
* @param text - text to be shown
/** Set dialog header text
*
* @param dialog Dialog instance
* @param text text to be shown
*/
void dialog_set_header_text(Dialog* dialog, const char* text);
/* Set dialog text
* @param dialog - Dialog instance
* @param text - text to be shown
/** Set dialog text
*
* @param dialog Dialog instance
* @param text text to be shown
*/
void dialog_set_text(Dialog* dialog, const char* text);
/* Set left button text
* @param dialog - Dialog instance
* @param text - text to be shown
/** Set left button text
*
* @param dialog Dialog instance
* @param text text to be shown
*/
void dialog_set_left_button_text(Dialog* dialog, const char* text);
/* Set right button text
* @param dialog - Dialog instance
* @param text - text to be shown
/** Set right button text
*
* @param dialog Dialog instance
* @param text text to be shown
*/
void dialog_set_right_button_text(Dialog* dialog, const char* text);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,4 +1,10 @@
/**
* @file dialog_ex.h
* GUI: DialogEx view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
@ -21,40 +27,51 @@ typedef enum {
typedef void (*DialogExResultCallback)(DialogExResult result, void* context);
/** Allocate and initialize dialog
*
* This dialog used to ask simple questions
* @return DialogEx instance
*
* @return DialogEx instance
*/
DialogEx* dialog_ex_alloc();
/** Deinitialize and free dialog
* @param dialog - DialogEx instance
*
* @param dialog_ex DialogEx instance
*/
void dialog_ex_free(DialogEx* dialog_ex);
/** Get dialog view
* @param dialog - DialogEx instance
* @return View instance that can be used for embedding
*
* @param dialog_ex DialogEx instance
*
* @return View instance that can be used for embedding
*/
View* dialog_ex_get_view(DialogEx* dialog_ex);
/** Set dialog result callback
* @param dialog_ex - DialogEx instance
* @param callback - result callback function
*
* @param dialog_ex DialogEx instance
* @param callback result callback function
*/
void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback);
/** Set dialog context
* @param dialog_ex - DialogEx instance
* @param context - context pointer, will be passed to result callback
*
* @param dialog_ex DialogEx instance
* @param context context pointer, will be passed to result callback
*/
void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
/** Set dialog header text
*
* If text is null, dialog header will not be rendered
* @param dialog - DialogEx instance
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*
* @param dialog_ex DialogEx instance
* @param text text to be shown, can be multiline
* @param x x position
* @param y y position
* @param horizontal horizontal text aligment
* @param vertical vertical text aligment
*/
void dialog_ex_set_header(
DialogEx* dialog_ex,
@ -65,11 +82,15 @@ void dialog_ex_set_header(
Align vertical);
/** Set dialog text
*
* If text is null, dialog text will not be rendered
* @param dialog - DialogEx instance
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*
* @param dialog_ex DialogEx instance
* @param text text to be shown, can be multiline
* @param x x position
* @param y y position
* @param horizontal horizontal text aligment
* @param vertical vertical text aligment
*/
void dialog_ex_set_text(
DialogEx* dialog_ex,
@ -80,36 +101,47 @@ void dialog_ex_set_text(
Align vertical);
/** Set dialog icon
*
* If x or y is negative, dialog icon will not be rendered
* @param dialog - DialogEx instance
* @param x, y - icon position
* @param name - icon to be shown
*
* @param dialog_ex DialogEx instance
* @param x x position
* @param y y position
* @param icon The icon
* @param name icon to be shown
*/
void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon);
/** Set left button text
*
* If text is null, left button will not be rendered and processed
* @param dialog - DialogEx instance
* @param text - text to be shown
*
* @param dialog_ex DialogEx instance
* @param text text to be shown
*/
void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text);
/** Set center button text
*
* If text is null, center button will not be rendered and processed
* @param dialog - DialogEx instance
* @param text - text to be shown
*
* @param dialog_ex DialogEx instance
* @param text text to be shown
*/
void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text);
/** Set right button text
*
* If text is null, right button will not be rendered and processed
* @param dialog - DialogEx instance
* @param text - text to be shown
*
* @param dialog_ex DialogEx instance
* @param text text to be shown
*/
void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text);
/** Clean dialog
* @param dialog_ex DialogEx instance
*
* @param dialog_ex DialogEx instance
*/
void dialog_ex_clean(DialogEx* dialog_ex);

View File

@ -1,26 +1,38 @@
/**
* @file empty_screen.h
* GUI: EmptyScreen view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Empty screen anonymous structure */
/** Empty screen anonymous structure */
typedef struct EmptyScreen EmptyScreen;
/* Allocate and initialize empty screen
/** Allocate and initialize empty screen
*
* This empty screen used to ask simple questions like Yes/
*
* @return EmptyScreen instance
*/
EmptyScreen* empty_screen_alloc();
/* Deinitialize and free empty screen
* @param empty_screen - Empty screen instance
/** Deinitialize and free empty screen
*
* @param empty_screen Empty screen instance
*/
void empty_screen_free(EmptyScreen* empty_screen);
/* Get empty screen view
* @param empty_screen - Empty screen instance
* @return View instance that can be used for embedding
/** Get empty screen view
*
* @param empty_screen Empty screen instance
*
* @return View instance that can be used for embedding
*/
View* empty_screen_get_view(EmptyScreen* empty_screen);

View File

@ -1,4 +1,10 @@
/**
* @file file_select.h
* GUI: FileSelect view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus

View File

@ -1,4 +1,10 @@
/**
* @file menu.h
* GUI: Menu view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
@ -7,31 +13,38 @@ extern "C" {
/** Menu anonymous structure */
typedef struct Menu Menu;
/** Menu Item Callback */
typedef void (*MenuItemCallback)(void* context, uint32_t index);
/** Menu allocation and initialization
* @return Menu instance
*
* @return Menu instance
*/
Menu* menu_alloc();
/** Free menu
* @param menu - Menu instance
*
* @param menu Menu instance
*/
void menu_free(Menu* menu);
/** Get Menu view
* @param menu - Menu instance
* @return View instance
*
* @param menu Menu instance
*
* @return View instance
*/
View* menu_get_view(Menu* menu);
/** Add item to menu
* @param menu - Menu instance
* @param label - menu item string label
* @param icon - IconAnimation instance
* @param index - menu item index
* @param callback - MenuItemCallback instance
* @param context - pointer to context
*
* @param menu Menu instance
* @param label menu item string label
* @param icon IconAnimation instance
* @param index menu item index
* @param callback MenuItemCallback instance
* @param context pointer to context
*/
void menu_add_item(
Menu* menu,
@ -42,14 +55,16 @@ void menu_add_item(
void* context);
/** Clean menu
* Note: this function does not free menu instance
* @param menu - Menu instance
* @note this function does not free menu instance
*
* @param menu Menu instance
*/
void menu_clean(Menu* menu);
/** Set current menu item
* @param submenu
* @param index
*
* @param menu Menu instance
* @param index The index
*/
void menu_set_selected_item(Menu* menu, uint32_t index);

View File

@ -1,52 +1,70 @@
/**
* @file popup.h
* GUI: Popup view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Popup anonymous structure */
/** Popup anonymous structure */
typedef struct Popup Popup;
/* Popup result callback type
* @warning comes from GUI thread
/** Popup result callback type
* @warning comes from GUI thread
*/
typedef void (*PopupCallback)(void* context);
/* Allocate and initialize popup
/** Allocate and initialize popup
*
* This popup used to ask simple questions like Yes/
*
* @return Popup instance
*/
Popup* popup_alloc();
/* Deinitialize and free popup
* @param popup - Popup instance
/** Deinitialize and free popup
*
* @param popup Popup instance
*/
void popup_free(Popup* popup);
/* Get popup view
* @param popup - Popup instance
* @return View instance that can be used for embedding
/** Get popup view
*
* @param popup Popup instance
*
* @return View instance that can be used for embedding
*/
View* popup_get_view(Popup* popup);
/* Set popup header text
* @param popup - Popup instance
* @param text - text to be shown
/** Set popup header text
*
* @param popup Popup instance
* @param callback PopupCallback
*/
void popup_set_callback(Popup* popup, PopupCallback callback);
/* Set popup context
* @param popup - Popup instance
* @param context - context pointer, will be passed to result callback
/** Set popup context
*
* @param popup Popup instance
* @param context context pointer, will be passed to result callback
*/
void popup_set_context(Popup* popup, void* context);
/* Set popup header text
/** Set popup header text
*
* If text is null, popup header will not be rendered
* @param popup - Popup instance
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*
* @param popup Popup instance
* @param text text to be shown, can be multiline
* @param x x position
* @param y y position
* @param horizontal horizontal alignment
* @param vertical vertical aligment
*/
void popup_set_header(
Popup* popup,
@ -56,12 +74,16 @@ void popup_set_header(
Align horizontal,
Align vertical);
/* Set popup text
/** Set popup text
*
* If text is null, popup text will not be rendered
* @param popup - Popup instance
* @param text - text to be shown, can be multiline
* @param x, y - text position
* @param horizontal, vertical - text aligment
*
* @param popup Popup instance
* @param text text to be shown, can be multiline
* @param x x position
* @param y y position
* @param horizontal horizontal alignment
* @param vertical vertical aligment
*/
void popup_set_text(
Popup* popup,
@ -71,30 +93,36 @@ void popup_set_text(
Align horizontal,
Align vertical);
/* Set popup icon
/** Set popup icon
*
* If icon position is negative, popup icon will not be rendered
* @param popup - Popup instance
* @param x, y - icon position
* @param name - icon to be shown
*
* @param popup Popup instance
* @param x x position
* @param y y position
* @param icon pointer to Icon data
*/
void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon);
/* Set popup timeout
* @param popup - Popup instance
* @param timeout_in_ms - popup timeout value in milliseconds
/** Set popup timeout
*
* @param popup Popup instance
* @param timeout_in_ms popup timeout value in milliseconds
*/
void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms);
/* Enable popup timeout
* @param popup - Popup instance
/** Enable popup timeout
*
* @param popup Popup instance
*/
void popup_enable_timeout(Popup* popup);
/* Disable popup timeout
* @param popup - Popup instance
/** Disable popup timeout
*
* @param popup Popup instance
*/
void popup_disable_timeout(Popup* popup);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,40 +1,50 @@
/**
* @file submenu.h
* GUI: SubMenu view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Submenu anonymous structure */
/** Submenu anonymous structure */
typedef struct Submenu Submenu;
typedef void (*SubmenuItemCallback)(void* context, uint32_t index);
/**
* @brief Allocate and initialize submenu
/** Allocate and initialize submenu
*
* This submenu is used to select one option
*
* @return Submenu instance
*/
Submenu* submenu_alloc();
/**
* @brief Deinitialize and free submenu
* @param submenu - Submenu instance
/** Deinitialize and free submenu
*
* @param submenu Submenu instance
*/
void submenu_free(Submenu* submenu);
/**
* @brief Get submenu view
* @param submenu - Submenu instance
* @return View instance that can be used for embedding
/** Get submenu view
*
* @param submenu Submenu instance
*
* @return View instance that can be used for embedding
*/
View* submenu_get_view(Submenu* submenu);
/**
* @brief Add item to submenu
* @param submenu - Submenu instance
* @param label - menu item label
* @param index - menu item index, used for callback, may be the same with other items
* @param callback - menu item callback
* @param callback_context - menu item callback context
/** Add item to submenu
*
* @param submenu Submenu instance
* @param label menu item label
* @param index menu item index, used for callback, may be
* the same with other items
* @param callback menu item callback
* @param callback_context menu item callback context
*/
void submenu_add_item(
Submenu* submenu,
@ -43,23 +53,23 @@ void submenu_add_item(
SubmenuItemCallback callback,
void* callback_context);
/**
* @brief Remove all items from submenu
* @param submenu - Submenu instance
/** Remove all items from submenu
*
* @param submenu Submenu instance
*/
void submenu_clean(Submenu* submenu);
/**
* @brief Set submenu item selector
* @param submenu
* @param index
/** Set submenu item selector
*
* @param submenu Submenu instance
* @param index The index
*/
void submenu_set_selected_item(Submenu* submenu, uint32_t index);
/**
* @brief Set optional header for submenu
* @param submenu - submenu entity
* @param header - header to set
/** Set optional header for submenu
*
* @param submenu Submenu instance
* @param header header to set
*/
void submenu_set_header(Submenu* submenu, const char* header);

View File

@ -1,11 +1,17 @@
/**
* @file text_box.h
* GUI: TextBox view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* TextBox anonymous structure */
/** TextBox anonymous structure */
typedef struct TextBox TextBox;
typedef void (*TextBoxExitCallback)(void* context);
@ -15,46 +21,56 @@ typedef enum {
} TextBoxFont;
/** Allocate and initialize text_box
*
* @return TextBox instance
*/
TextBox* text_box_alloc();
/** Deinitialize and free text_box
* @param text_box text_box instance
*
* @param text_box text_box instance
*/
void text_box_free(TextBox* text_box);
/** Get text_box view
* @param text_box TextBox instance
* @return View instance that can be used for embedding
*
* @param text_box TextBox instance
*
* @return View instance that can be used for embedding
*/
View* text_box_get_view(TextBox* text_box);
/** Clean text_box
* @param text_box TextBox instance
*
* @param text_box TextBox instance
*/
void text_box_clean(TextBox* text_box);
/** Set text for text_box
* @param text_box TextBox instance
* @param text text to set
*
* @param text_box TextBox instance
* @param text text to set
*/
void text_box_set_text(TextBox* text_box, const char* text);
/** Set TextBox font
* @param text_box TextBox instance
* @param font TextBoxFont instance
*
* @param text_box TextBox instance
* @param font TextBoxFont instance
*/
void text_box_set_font(TextBox* text_box, TextBoxFont font);
/** Set text_box context
* @param text_box TextBox instance
* @param context context pointer
*
* @param text_box TextBox instance
* @param context context pointer
*/
void text_box_set_context(TextBox* text_box, void* context);
/** Set exit callback
* @param text_box TextBox instance
* @param callback TextBoxExitCallback callback pointer
*
* @param text_box TextBox instance
* @param callback TextBoxExitCallback callback pointer
*/
void text_box_set_exit_callback(TextBox* text_box, TextBoxExitCallback callback);

View File

@ -1,44 +1,59 @@
/**
* @file text_input.h
* GUI: TextInput keybord view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Text input anonymous structure */
/** Text input anonymous structure */
typedef struct TextInput TextInput;
typedef void (*TextInputCallback)(void* context);
/** Allocate and initialize text input
/** Allocate and initialize text input
*
* This text input is used to enter string
* @return TextInput instance
*
* @return TextInput instance
*/
TextInput* text_input_alloc();
/** Deinitialize and free text input
* @param text_input - TextInput instance
*
* @param text_input TextInput instance
*/
void text_input_free(TextInput* text_input);
/** Clean text input view
* Note: this function does not free memory
* @param text_input - Text input instance
/** Clean text input view Note: this function does not free memory
*
* @param text_input Text input instance
*/
void text_input_clean(TextInput* text_input);
/** Get text input view
* @param text_input - TextInput instance
* @return View instance that can be used for embedding
*
* @param text_input TextInput instance
*
* @return View instance that can be used for embedding
*/
View* text_input_get_view(TextInput* text_input);
/** Set text input result callback
* @param text_input - TextInput instance
* @param callback - callback fn
* @param callback_context - callback context
* @param text_buffer - pointer to YOUR text buffer, that we going to modify
* @param text_buffer_size - YOUR text buffer size in bytes. Max string length will be text_buffer_size - 1.
* @param clear_default_text - clear text from text_buffer on first OK event
*
* @param text_input TextInput instance
* @param callback callback fn
* @param callback_context callback context
* @param text_buffer pointer to YOUR text buffer, that we going
* to modify
* @param text_buffer_size YOUR text buffer size in bytes. Max string
* length will be text_buffer_size-1.
* @param clear_default_text clear text from text_buffer on first OK
* event
*/
void text_input_set_result_callback(
TextInput* text_input,
@ -49,8 +64,9 @@ void text_input_set_result_callback(
bool clear_default_text);
/** Set text input header text
* @param text_input - TextInput instance
* @param text - text to be shown
*
* @param text_input TextInput instance
* @param text text to be shown
*/
void text_input_set_header_text(TextInput* text_input, const char* text);

View File

@ -1,4 +1,10 @@
/**
* @file variable-item-list.h
* GUI: VariableItemList view module API
*/
#pragma once
#include <gui/view.h>
#ifdef __cplusplus
@ -11,29 +17,40 @@ typedef void (*VariableItemChangeCallback)(VariableItem* item);
typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index);
/** Allocate and initialize VariableItemList
* @return VariableItemList*
*
* @return VariableItemList*
*/
VariableItemList* variable_item_list_alloc();
/** Deinitialize and free VariableItemList
* @param variable_item_list VariableItemList instance
*
* @param variable_item_list VariableItemList instance
*/
void variable_item_list_free(VariableItemList* variable_item_list);
/** Clear all elements from list
* @param variable_item_list VariableItemList instance
*
* @param variable_item_list VariableItemList instance
*/
void variable_item_list_clean(VariableItemList* variable_item_list);
/** Get VariableItemList View instance
*
* @param variable_item_list VariableItemList instance
*
* @return View instance
*/
View* variable_item_list_get_view(VariableItemList* variable_item_list);
/** Add item to VariableItemList
* @param variable_item_list VariableItemList instance
* @param label item name
* @param values_count item values count
* @param change_callback called on value change in gui
* @param context item context
* @return VariableItem* item instance
*
* @param variable_item_list VariableItemList instance
* @param label item name
* @param values_count item values count
* @param change_callback called on value change in gui
* @param context item context
*
* @return VariableItem* item instance
*/
VariableItem* variable_item_list_add(
VariableItemList* variable_item_list,
@ -43,9 +60,10 @@ VariableItem* variable_item_list_add(
void* context);
/** Set enter callback
* @param variable_item_list VariableItemList instance
* @param calback VariableItemListEnterCallback instance
* @param context pointer to context
*
* @param variable_item_list VariableItemList instance
* @param callback VariableItemListEnterCallback instance
* @param context pointer to context
*/
void variable_item_list_set_enter_callback(
VariableItemList* variable_item_list,
@ -53,29 +71,35 @@ void variable_item_list_set_enter_callback(
void* context);
/** Set item current selected index
* @param item VariableItem* instance
* @param current_value_index
*
* @param item VariableItem* instance
* @param current_value_index The current value index
*/
void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index);
/** Set item current selected text
* @param item VariableItem* instance
* @param current_value_text
*
* @param item VariableItem* instance
* @param current_value_text The current value text
*/
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text);
/** Get item current selected index
* @param item VariableItem* instance
* @return uint8_t current selected index
*
* @param item VariableItem* instance
*
* @return uint8_t current selected index
*/
uint8_t variable_item_get_current_value_index(VariableItem* item);
/** Get item context
* @param item VariableItem* instance
* @return void* item context
*
* @param item VariableItem* instance
*
* @return void* item context
*/
void* variable_item_get_context(VariableItem* item);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,38 +1,51 @@
/**
* @file widget.h
* GUI: Widget view module API
*/
#pragma once
#include "widget_elements/widget_element_i.h"
typedef struct Widget Widget;
typedef struct WidgetElement WidgetElement;
/** Allocate Widget that holds Widget Elements
* @return Widget instance
*
* @return Widget instance
*/
Widget* widget_alloc();
/** Free Widget
* @note this function free allocated Widget Elements
* @param widget Widget instance
* @note this function free allocated Widget Elements
*
* @param widget Widget instance
*/
void widget_free(Widget* widget);
/** Clear Widget
* @param widget Widget instance
*
* @param widget Widget instance
*/
void widget_clear(Widget* widget);
/** Get Widget view
* @param widget Widget instance
* @return View instance
*
* @param widget Widget instance
*
* @return View instance
*/
View* widget_get_view(Widget* widget);
/** Add Multi String Element
* @param widget Widget instance
* @param x - x coordinate
* @param y - y coordinate
* @param horizontal - Align instance
* @param vertical - Align instance
* @param font Font instance
*
* @param widget Widget instance
* @param x x coordinate
* @param y y coordinate
* @param horizontal Align instance
* @param vertical Align instance
* @param font Font instance
* @param[in] text The text
*/
void widget_add_string_multiline_element(
Widget* widget,
@ -44,12 +57,14 @@ void widget_add_string_multiline_element(
const char* text);
/** Add String Element
* @param widget Widget instance
* @param x - x coordinate
* @param y - y coordinate
* @param horizontal - Align instance
* @param vertical - Align instance
* @param font Font instance
*
* @param widget Widget instance
* @param x x coordinate
* @param y y coordinate
* @param horizontal Align instance
* @param vertical Align instance
* @param font Font instance
* @param[in] text The text
*/
void widget_add_string_element(
Widget* widget,
@ -61,11 +76,12 @@ void widget_add_string_element(
const char* text);
/** Add Button Element
* @param widget Widget instance
* @param button_type GuiButtonType instance
* @param text text on allocated button
* @param callback ButtonCallback instance
* @param context pointer to context
*
* @param widget Widget instance
* @param button_type GuiButtonType instance
* @param text text on allocated button
* @param callback ButtonCallback instance
* @param context pointer to context
*/
void widget_add_button_element(
Widget* widget,
@ -75,20 +91,22 @@ void widget_add_button_element(
void* context);
/** Add Icon Element
* @param widget Widget instance
* @param x top left x coordinate
* @param y top left y coordinate
* @param icon Icon instance
*
* @param widget Widget instance
* @param x top left x coordinate
* @param y top left y coordinate
* @param icon Icon instance
*/
void widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon);
/** Add Frame Element
* @param widget Widget instance
* @param x top left x coordinate
* @param y top left y coordinate
* @param width frame width
* @param height frame height
* @param radius frame radius
*
* @param widget Widget instance
* @param x top left x coordinate
* @param y top left y coordinate
* @param width frame width
* @param height frame height
* @param radius frame radius
*/
void widget_add_frame_element(
Widget* widget,

View File

@ -1,3 +1,8 @@
/**
* @file widget_element_i.h
* GUI: internal Widget Element API
*/
#pragma once
#include <furi.h>
#include <gui/view.h>
@ -29,7 +34,7 @@ struct WidgetElement {
Widget* parent;
};
/* Create multi string element */
/** Create multi string element */
WidgetElement* widget_element_string_multiline_create(
uint8_t x,
uint8_t y,
@ -38,7 +43,7 @@ WidgetElement* widget_element_string_multiline_create(
Font font,
const char* text);
/* Create string element */
/** Create string element */
WidgetElement* widget_element_string_create(
uint8_t x,
uint8_t y,
@ -47,20 +52,20 @@ WidgetElement* widget_element_string_create(
Font font,
const char* text);
/* Create button element */
/** Create button element */
WidgetElement* widget_element_button_create(
GuiButtonType button_type,
const char* text,
ButtonCallback callback,
void* context);
/* Create icon element */
/** Create icon element */
WidgetElement* widget_element_icon_create(uint8_t x, uint8_t y, const Icon* icon);
/* Create frame element */
/** Create frame element */
WidgetElement* widget_element_frame_create(
uint8_t x,
uint8_t y,
uint8_t width,
uint8_t height,
uint8_t radius);
uint8_t radius);

View File

@ -1,14 +1,18 @@
/**
* @file scene_manager.h
* GUI: SceneManager API
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
/** Scene Manager events type
*/
/** Scene Manager events type */
typedef enum {
SceneManagerEventTypeCustom,
SceneManagerEventTypeBack,
@ -44,86 +48,110 @@ typedef struct {
typedef struct SceneManager SceneManager;
/** Set Scene state
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
* @param state Scene new state
*
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
* @param state Scene new state
*/
void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state);
/** Get Scene state
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
* @return Scene state
*
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
*
* @return Scene state
*/
uint32_t scene_manager_get_scene_state(SceneManager* scene_manager, uint32_t scene_id);
/** Scene Manager allocation and configuration
*
* Scene Manager allocates all scenes internally
* @param app_scene_handlers SceneManagerHandlers instance
* @param context context to be set on Scene handlers calls
* @return SceneManager instance
*
* @param app_scene_handlers SceneManagerHandlers instance
* @param context context to be set on Scene handlers calls
*
* @return SceneManager instance
*/
SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context);
/** Free Scene Manager with allocated Scenes
* @param scene_manager SceneManager instance
*
* @param scene_manager SceneManager instance
*/
void scene_manager_free(SceneManager* scene_manager);
/** Custom event handler
*
* Calls Scene event handler with Custom event parameter
* @param scene_manager SceneManager instance
* @param custom_event Custom event code
* @return true if event was consumed, false otherwise
*
* @param scene_manager SceneManager instance
* @param custom_event Custom event code
*
* @return true if event was consumed, false otherwise
*/
bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event);
/** Back event handler
*
* Calls Scene event handler with Back event parameter
* @param scene_manager SceneManager instance
* @return true if event was consumed, false otherwise
*
* @param scene_manager SceneManager instance
*
* @return true if event was consumed, false otherwise
*/
bool scene_manager_handle_back_event(SceneManager* scene_manager);
/** Tick event handler
*
* Calls Scene event handler with Tick event parameter
* @param scene_manager SceneManager instance
* @return true if event was consumed, false otherwise
*
* @param scene_manager SceneManager instance
* @return true if event was consumed, false otherwise
*/
void scene_manager_handle_tick_event(SceneManager* scene_manager);
/** Add and run next Scene
* @param scene_manager SceneManager instance
* @param next_scene_id next Scene ID
*
* @param scene_manager SceneManager instance
* @param next_scene_id next Scene ID
*/
void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id);
/** Run previous Scene
* @param scene_manager SceneManager instance
* @return true if previous scene was found, false otherwise
*
* @param scene_manager SceneManager instance
*
* @return true if previous scene was found, false otherwise
*/
bool scene_manager_previous_scene(SceneManager* scene_manager);
/** Search previous Scene
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
* @return true if previous scene was found, false otherwise
*
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
*
* @return true if previous scene was found, false otherwise
*/
bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scene_id);
/** Search and switch to previous Scene
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
* @return true if previous scene was found, false otherwise
*
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
*
* @return true if previous scene was found, false otherwise
*/
bool scene_manager_search_and_switch_to_previous_scene(
SceneManager* scene_manager,
uint32_t scene_id);
/** Clear Scene stack and switch to another Scene
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
* @return true if previous scene was found, false otherwise
*
* @param scene_manager SceneManager instance
* @param scene_id Scene ID
*
* @return true if previous scene was found, false otherwise
*/
bool scene_manager_search_and_switch_to_another_scene(
SceneManager* scene_manager,

View File

@ -1,3 +1,8 @@
/**
* @file scene_manager_i.h
* GUI: internal SceneManager API
*/
#pragma once
#include "scene_manager.h"

View File

@ -1,3 +1,8 @@
/**
* @file view.h
* GUI: View API
*/
#pragma once
#include <input/input.h>
@ -27,57 +32,57 @@ typedef enum {
typedef struct View View;
/** View Draw callback
* @param canvas, pointer to canvas
* @param view_model, pointer to context
* @warning called from GUI thread
* @param canvas, pointer to canvas
* @param view_model, pointer to context
* @warning called from GUI thread
*/
typedef void (*ViewDrawCallback)(Canvas* canvas, void* model);
/** View Input callback
* @param event, pointer to input event data
* @param context, pointer to context
* @return true if event handled, false if event ignored
* @warning called from GUI thread
* @param event, pointer to input event data
* @param context, pointer to context
* @return true if event handled, false if event ignored
* @warning called from GUI thread
*/
typedef bool (*ViewInputCallback)(InputEvent* event, void* context);
/** View Custom callback
* @param event, number of custom event
* @param context, pointer to context
* @return true if event handled, false if event ignored
* @param event, number of custom event
* @param context, pointer to context
* @return true if event handled, false if event ignored
*/
typedef bool (*ViewCustomCallback)(uint32_t event, void* context);
/** View navigation callback
* @param context, pointer to context
* @return next view id
* @warning called from GUI thread
* @param context, pointer to context
* @return next view id
* @warning called from GUI thread
*/
typedef uint32_t (*ViewNavigationCallback)(void* context);
/** View callback
* @param context, pointer to context
* @warning called from GUI thread
* @param context, pointer to context
* @warning called from GUI thread
*/
typedef void (*ViewCallback)(void* context);
/** View Update Callback
* Called upon model change, need to be propagated to GUI throw ViewPort update
* @param view, pointer to view
* @param context, pointer to context
* @warning called from GUI thread
/** View Update Callback Called upon model change, need to be propagated to GUI
* throw ViewPort update
* @param view, pointer to view
* @param context, pointer to context
* @warning called from GUI thread
*/
typedef void (*ViewUpdateCallback)(View* view, void* context);
/** View model types */
typedef enum {
/* Model is not allocated */
/** Model is not allocated */
ViewModelTypeNone,
/* Model consist of atomic types and/or partial update is not critical for rendering.
/** Model consist of atomic types and/or partial update is not critical for rendering.
* Lock free.
*/
ViewModelTypeLockFree,
/* Model access is guarded with mutex.
/** Model access is guarded with mutex.
* Locking gui thread.
*/
ViewModelTypeLocking,
@ -89,98 +94,115 @@ typedef enum {
View* view_alloc();
/** Free View
* @param View instance
*
* @param view instance
*/
void view_free(View* view);
/** Tie IconAnimation with View
* @param view, View instance
* @param icon_animation, IconAnimation instance
*
* @param view View instance
* @param icon_animation IconAnimation instance
*/
void view_tie_icon_animation(View* view, IconAnimation* icon_animation);
/** Set View Draw callback
* @param view, View instance
* @param callback, draw callback
*
* @param view View instance
* @param callback draw callback
*/
void view_set_draw_callback(View* view, ViewDrawCallback callback);
/** Set View Input callback
* @param view, View instance
* @param callback, input callback
*
* @param view View instance
* @param callback input callback
*/
void view_set_input_callback(View* view, ViewInputCallback callback);
/** Set View Custom callback
* @param view, View instance
* @param callback, input callback
*
* @param view View instance
* @param callback input callback
*/
void view_set_custom_callback(View* view, ViewCustomCallback callback);
/** Set Navigation Previous callback
* @param view, View instance
* @param callback, input callback
*
* @param view View instance
* @param callback input callback
*/
void view_set_previous_callback(View* view, ViewNavigationCallback callback);
/** Set Enter callback
* @param view, View instance
* @param callback, callback
*
* @param view View instance
* @param callback callback
*/
void view_set_enter_callback(View* view, ViewCallback callback);
/** Set Exit callback
* @param view, View instance
* @param callback, callback
*
* @param view View instance
* @param callback callback
*/
void view_set_exit_callback(View* view, ViewCallback callback);
/** Set Update callback
* @param view, View instance
* @param callback, callback
*
* @param view View instance
* @param callback callback
*/
void view_set_update_callback(View* view, ViewUpdateCallback callback);
/** Set View Draw callback
* @param view, View instance
* @param context, context for callbacks
*
* @param view View instance
* @param context context for callbacks
*/
void view_set_update_callback_context(View* view, void* context);
/** Set View Draw callback
* @param view, View instance
* @param context, context for callbacks
*
* @param view View instance
* @param context context for callbacks
*/
void view_set_context(View* view, void* context);
/** Set View Orientation
* @param view, View instance
* @param orientation, either vertical or horizontal
*
* @param view View instance
* @param orientation either vertical or horizontal
*/
void view_set_orientation(View* view, ViewOrientation orientation);
/** Allocate view model.
* @param view, View instance
* @param type, View Model Type
* @param size, size
*
* @param view View instance
* @param type View Model Type
* @param size size
*/
void view_allocate_model(View* view, ViewModelType type, size_t size);
/** Free view model data memory.
* @param view, View instance
*
* @param view View instance
*/
void view_free_model(View* view);
/** Get view model data
* @param view, View instance
* @return pointer to model data
* @warning Don't forget to commit model changes
*
* @param view View instance
*
* @return pointer to model data
* @warning Don't forget to commit model changes
*/
void* view_get_model(View* view);
/** Commit view model
* @param view, View instance
* @param update, true if you want to emit view update, false otherwise
*
* @param view View instance
* @param update true if you want to emit view update, false otherwise
*/
void view_commit_model(View* view, bool update);
@ -196,11 +218,13 @@ void view_commit_model(View* view, bool update);
view_commit_model(view, update); \
}
#else
/**
* With clause for view model
* @param view, View instance pointer
* @param function_body a (){} lambda declaration, executed within you parent function context
* @return true if you want to emit view update, false otherwise
/** With clause for view model
*
* @param view View instance pointer
* @param function_body a (){} lambda declaration, executed within you
* parent function context
*
* @return true if you want to emit view update, false otherwise
*/
#define with_view_model(view, function_body) \
{ \

View File

@ -1,3 +1,8 @@
/**
* @file view_dispatcher.h
* GUI: ViewDispatcher API
*/
#pragma once
#include "view.h"
@ -8,8 +13,7 @@
extern "C" {
#endif
/** ViewDispatcher view_port placement
*/
/** ViewDispatcher view_port placement */
typedef enum {
ViewDispatcherTypeNone, /**< Special layer for internal use only */
ViewDispatcherTypeWindow, /**< Main view_port layer, status bar is shown */
@ -18,61 +22,70 @@ typedef enum {
typedef struct ViewDispatcher ViewDispatcher;
/** Prototype for custom event callback
*/
/** Prototype for custom event callback */
typedef bool (*ViewDispatcherCustomEventCallback)(void* context, uint32_t event);
/** Prototype for navigation event callback
*/
/** Prototype for navigation event callback */
typedef bool (*ViewDispatcherNavigationEventCallback)(void* context);
/** Prototype for tick event callback
*/
/** Prototype for tick event callback */
typedef void (*ViewDispatcherTickEventCallback)(void* context);
/** Allocate ViewDispatcher instance
* @return pointer to ViewDispatcher instance
*
* @return pointer to ViewDispatcher instance
*/
ViewDispatcher* view_dispatcher_alloc();
/** Free ViewDispatcher instance
* @param view_dispatcher pointer to ViewDispatcher
*
* @param view_dispatcher pointer to ViewDispatcher
*/
void view_dispatcher_free(ViewDispatcher* view_dispatcher);
/** Enable queue support
* If queue enabled all input and custom events will be dispatched throw internal queue
* @param view_dispatcher ViewDispatcher instance
*
* If queue enabled all input and custom events will be dispatched throw
* internal queue
*
* @param view_dispatcher ViewDispatcher instance
*/
void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher);
/** Send custom event
* @param view_dispatcher ViewDispatcher instance
*
* @param view_dispatcher ViewDispatcher instance
* @param[in] event The event
*/
void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
/** Set custom event handler
*
* Called on Custom Event, if it is not consumed by view
* @param view_dispatcher ViewDispatcher instance
* @param callback ViewDispatcherCustomEventCallback instance
*
* @param view_dispatcher ViewDispatcher instance
* @param callback ViewDispatcherCustomEventCallback instance
*/
void view_dispatcher_set_custom_event_callback(
ViewDispatcher* view_dispatcher,
ViewDispatcherCustomEventCallback callback);
/** Set navigation event handler
*
* Called on Input Short Back Event, if it is not consumed by view
* @param view_dispatcher ViewDispatcher instance
* @param callback ViewDispatcherNavigationEventCallback instance
*
* @param view_dispatcher ViewDispatcher instance
* @param callback ViewDispatcherNavigationEventCallback instance
*/
void view_dispatcher_set_navigation_event_callback(
ViewDispatcher* view_dispatcher,
ViewDispatcherNavigationEventCallback callback);
/** Set tick event handler
* @param view_dispatcher ViewDispatcher instance
* @param callback ViewDispatcherTickEventCallback
* @param tick_period callback call period
*
* @param view_dispatcher ViewDispatcher instance
* @param callback ViewDispatcherTickEventCallback
* @param tick_period callback call period
*/
void view_dispatcher_set_tick_event_callback(
ViewDispatcher* view_dispatcher,
@ -80,46 +93,57 @@ void view_dispatcher_set_tick_event_callback(
uint32_t tick_period);
/** Set event callback context
* @param view_dispatcher ViewDispatcher instance
* @param context pointer to context
*
* @param view_dispatcher ViewDispatcher instance
* @param context pointer to context
*/
void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context);
/** Run ViewDispatcher
*
* Use only after queue enabled
* @param view_dispatcher ViewDispatcher instance
*
* @param view_dispatcher ViewDispatcher instance
*/
void view_dispatcher_run(ViewDispatcher* view_dispatcher);
/** Stop ViewDispatcher
*
* Use only after queue enabled
* @param view_dispatcher ViewDispatcher instance
*
* @param view_dispatcher ViewDispatcher instance
*/
void view_dispatcher_stop(ViewDispatcher* view_dispatcher);
/** Add view to ViewDispatcher
* @param view_dispatcher, ViewDispatcher instance
* @param view_id View id to register
* @param view View instance
*
* @param view_dispatcher ViewDispatcher instance
* @param view_id View id to register
* @param view View instance
*/
void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view);
/** Remove view from ViewDispatcher
* @param view_dispatcher ViewDispatcher instance
* @param view_id View id to remove
*
* @param view_dispatcher ViewDispatcher instance
* @param view_id View id to remove
*/
void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_id);
/** Switch to View
* @param view_dispatcher ViewDispatcher instance
* @param view_id View id to register
* @warning switching may be delayed till input events complementarity reached
*
* @param view_dispatcher ViewDispatcher instance
* @param view_id View id to register
* @warning switching may be delayed till input events complementarity
* reached
*/
void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t view_id);
/** Attach ViewDispatcher to GUI
* @param view_dispatcher ViewDispatcher instance
* @param gui GUI instance to attach to
*
* @param view_dispatcher ViewDispatcher instance
* @param gui GUI instance to attach to
* @param[in] type The type
*/
void view_dispatcher_attach_to_gui(
ViewDispatcher* view_dispatcher,

View File

@ -1,3 +1,8 @@
/**
* @file view_dispatcher_i.h
* GUI: ViewDispatcher API
*/
#pragma once
#include <furi.h>
@ -41,23 +46,23 @@ typedef struct {
};
} ViewDispatcherMessage;
/* ViewPort Draw Callback */
/** ViewPort Draw Callback */
void view_dispatcher_draw_callback(Canvas* canvas, void* context);
/* ViewPort Input Callback */
/** ViewPort Input Callback */
void view_dispatcher_input_callback(InputEvent* event, void* context);
/* Input handler */
/** Input handler */
void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* event);
/* Tick handler */
/** Tick handler */
void view_dispatcher_handle_tick_event(ViewDispatcher* view_dispatcher);
/* Custom event handler */
/** Custom event handler */
void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
/* Set current view, dispatches view enter and exit */
/** Set current view, dispatches view enter and exit */
void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view);
/* ViewDispatcher update event */
/** ViewDispatcher update event */
void view_dispatcher_update(View* view, void* context);

View File

@ -1,3 +1,8 @@
/**
* @file view_i.h
* GUI: internal View API
*/
#pragma once
#include "view.h"
@ -26,26 +31,26 @@ struct View {
void* context;
};
/* IconAnimation tie callback */
/** IconAnimation tie callback */
void view_icon_animation_callback(IconAnimation* instance, void* context);
/* Unlock model */
/** Unlock model */
void view_unlock_model(View* view);
/* Draw Callback for View dispatcher */
/** Draw Callback for View dispatcher */
void view_draw(View* view, Canvas* canvas);
/* Input Callback for View dispatcher */
/** Input Callback for View dispatcher */
bool view_input(View* view, InputEvent* event);
/* Custom Callback for View dispatcher */
/** Custom Callback for View dispatcher */
bool view_custom(View* view, uint32_t event);
/* Previous Callback for View dispatcher */
/** Previous Callback for View dispatcher */
uint32_t view_previous(View* view);
/* Enter Callback for View dispatcher */
/** Enter Callback for View dispatcher */
void view_enter(View* view);
/* Exit Callback for View dispatcher */
/** Exit Callback for View dispatcher */
void view_exit(View* view);

View File

@ -1,3 +1,8 @@
/**
* @file view_port.h
* GUI: ViewPort API
*/
#pragma once
#include <input/input.h>
@ -15,50 +20,65 @@ typedef enum {
} ViewPortOrientation;
/** ViewPort Draw callback
* @warning called from GUI thread
* @warning called from GUI thread
*/
typedef void (*ViewPortDrawCallback)(Canvas* canvas, void* context);
/** ViewPort Input callback
* @warning called from GUI thread
* @warning called from GUI thread
*/
typedef void (*ViewPortInputCallback)(InputEvent* event, void* context);
/** ViewPort allocator
*
* always returns view_port or stops system if not enough memory.
*
* @return ViewPort instance
*/
ViewPort* view_port_alloc();
/** ViewPort deallocator
*
* Ensure that view_port was unregistered in GUI system before use.
*
* @param view_port ViewPort instance
*/
void view_port_free(ViewPort* view_port);
/** Set view_port width.
*
* Will be used to limit canvas drawing area and autolayout feature.
* @param width - wanted width, 0 - auto.
*
* @param view_port ViewPort instance
* @param width wanted width, 0 - auto.
*/
void view_port_set_width(ViewPort* view_port, uint8_t width);
uint8_t view_port_get_width(ViewPort* view_port);
/** Set view_port height.
*
* Will be used to limit canvas drawing area and autolayout feature.
* @param height - wanted height, 0 - auto.
*
* @param view_port ViewPort instance
* @param height wanted height, 0 - auto.
*/
void view_port_set_height(ViewPort* view_port, uint8_t height);
uint8_t view_port_get_height(ViewPort* view_port);
/** Enable or disable view_port rendering.
* @param view_port - ViewPort instance
* @param enabled
* @warning automatically dispatches update event
*
* @param view_port ViewPort instance
* @param enabled Indicates if enabled
* @warning automatically dispatches update event
*/
void view_port_enabled_set(ViewPort* view_port, bool enabled);
bool view_port_is_enabled(ViewPort* view_port);
/** ViewPort event callbacks
* @param callback - appropriate callback function
* @param context - context to pass to callback
*
* @param view_port ViewPort instance
* @param callback appropriate callback function
* @param context context to pass to callback
*/
void view_port_draw_callback_set(ViewPort* view_port, ViewPortDrawCallback callback, void* context);
void view_port_input_callback_set(
@ -67,12 +87,17 @@ void view_port_input_callback_set(
void* context);
/** Emit update signal to GUI system.
*
* Rendering will happen later after GUI system process signal.
*
* @param view_port ViewPort instance
*/
void view_port_update(ViewPort* view_port);
/** Set ViewPort orientation.
* @param orientation, display orientation, horizontal or vertical.
*
* @param view_port ViewPort instance
* @param orientation display orientation, horizontal or vertical.
*/
void view_port_set_orientation(ViewPort* view_port, ViewPortOrientation orientation);
ViewPortOrientation view_port_get_orientation(const ViewPort* view_port);

View File

@ -1,3 +1,8 @@
/**
* @file view_port_i.h
* GUI: internal ViewPort API
*/
#pragma once
#include "gui_i.h"
@ -18,23 +23,29 @@ struct ViewPort {
void* input_callback_context;
};
/*
* Set GUI reference.
/** Set GUI reference.
*
* To be used by GUI, called upon view_port tree insert
* @param gui - gui instance pointer.
*
* @param view_port ViewPort instance
* @param gui gui instance pointer
*/
void view_port_gui_set(ViewPort* view_port, Gui* gui);
/*
* Process draw call. Calls draw callback.
/** Process draw call. Calls draw callback.
*
* To be used by GUI, called on tree redraw.
* @param canvas - canvas to draw at.
*
* @param view_port ViewPort instance
* @param canvas canvas to draw at
*/
void view_port_draw(ViewPort* view_port, Canvas* canvas);
/*
* Process input. Calls input callbac
/** Process input. Calls input callback.
*
* To be used by GUI, called on input dispatch.
* @param event - pointer to input event.
*
* @param view_port ViewPort instance
* @param event pointer to input event
*/
void view_port_input(ViewPort* view_port, InputEvent* event);

View File

@ -1,19 +1,24 @@
/**
* @file input.h
* Input: main API
*/
#pragma once
#include <furi-hal-resources.h>
/* Input Types
/** Input Types
* Some of them are physical events and some logical
*/
typedef enum {
InputTypePress, /* Press event, emitted after debounce */
InputTypeRelease, /* Release event, emitted after debounce */
InputTypeShort, /* Short event, emitted after InputTypeRelease done withing INPUT_LONG_PRESS interval */
InputTypeLong, /* Long event, emmited after INPUT_LONG_PRESS interval, asynchronouse to InputTypeRelease */
InputTypeRepeat, /* Repeat event, emmited with INPUT_REPEATE_PRESS period after InputTypeLong event */
InputTypePress, /**< Press event, emitted after debounce */
InputTypeRelease, /**< Release event, emitted after debounce */
InputTypeShort, /**< Short event, emitted after InputTypeRelease done withing INPUT_LONG_PRESS interval */
InputTypeLong, /**< Long event, emmited after INPUT_LONG_PRESS interval, asynchronouse to InputTypeRelease */
InputTypeRepeat, /**< Repeat event, emmited with INPUT_REPEATE_PRESS period after InputTypeLong event */
} InputType;
/* Input Event, dispatches with PubSub */
/** Input Event, dispatches with PubSub */
typedef struct {
uint32_t sequence;
InputKey key;

View File

@ -1,3 +1,8 @@
/**
* @file input_i.h
* Input: internal API
*/
#pragma once
#include "input.h"
@ -16,7 +21,7 @@
#define INPUT_LONG_PRESS_COUNTS 2
#define INPUT_THREAD_FLAG_ISR 0x00000001
/* Input pin state */
/** Input pin state */
typedef struct {
const InputPin* pin;
// State
@ -27,7 +32,7 @@ typedef struct {
volatile uint32_t counter;
} InputPinState;
/* Input state */
/** Input state */
typedef struct {
osThreadId_t thread;
PubSub event_pubsub;
@ -36,8 +41,8 @@ typedef struct {
volatile uint32_t counter;
} Input;
/* Input press timer callback */
/** Input press timer callback */
void input_press_timer_callback(void* arg);
/* Input interrupt handler */
/** Input interrupt handler */
void input_isr(void* _ctx);

View File

@ -1,3 +1,8 @@
/**
* @file api-interrupt-mgr.h
* Furi: interrupt API
*/
#pragma once
#include <stdbool.h>
@ -23,45 +28,45 @@ typedef struct {
bool ready;
} InterruptCallbackItem;
/**
* Init interrupt
* @return true on succsessful initialization, false otherwise
/** Init interrupt
*
* @return true on succsessful initialization, false otherwise
*/
bool api_interrupt_init();
/**
* Add interrupt
* @param callback InterruptCallback
* @param type InterruptType
* @param context context for callback
/** Add interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
* @param context context for callback
*/
void api_interrupt_add(InterruptCallback callback, InterruptType type, void* context);
/**
* Remove interrupt
* @param callback InterruptCallback
* @param type InterruptType
/** Remove interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
*/
void api_interrupt_remove(InterruptCallback callback, InterruptType type);
/**
* Enable interrupt
* @param callback InterruptCallback
* @param type InterruptType
/** Enable interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
*/
void api_interrupt_enable(InterruptCallback callback, InterruptType type);
/**
* Disable interrupt
* @param callback InterruptCallback
* @param type InterruptType
/** Disable interrupt
*
* @param callback InterruptCallback
* @param type InterruptType
*/
void api_interrupt_disable(InterruptCallback callback, InterruptType type);
/**
* Call interrupt
* @param type InterruptType
* @param hw pointer to hardware peripheral
/** Call interrupt
*
* @param type InterruptType
* @param hw pointer to hardware peripheral
*/
void api_interrupt_call(InterruptType type, void* hw);

View File

@ -68,6 +68,12 @@ size_t memmgr_get_minimum_free_heap(void) {
return xPortGetMinimumEverFreeHeapSize();
}
void* furi_alloc(size_t size) {
void* p = malloc(size);
furi_check(p);
return memset(p, 0, size);
}
void* __wrap__malloc_r(struct _reent* r, size_t size) {
void* pointer = malloc(size);
return pointer;

View File

@ -1,3 +1,8 @@
/**
* @file memmgr.h
* Furi: memory managment API and glue
*/
#pragma once
#include <stddef.h>
@ -12,14 +17,27 @@ extern "C" {
// define for test case "link against furi memmgr"
#define FURI_MEMMGR_GUARD 1
/** Get free heap size
*
* @return free heap size in bytes
*/
size_t memmgr_get_free_heap(void);
/** Get heap watermark
*
* @return minimum heap in bytes
*/
size_t memmgr_get_minimum_free_heap(void);
inline static void* furi_alloc(size_t size) {
void* p = malloc(size);
furi_check(p);
return memset(p, 0, size);
}
/** Allocate memory from heap
*
* @note performs memset with 0, will crash system if not enough memory
*
* @param[in] size bytes to allocate
*
* @return pointer to allocated memory
*/
void* furi_alloc(size_t size);
#ifdef __cplusplus
}

View File

@ -1,3 +1,8 @@
/**
* @file memmgr_heap.h
* Furi: heap memory managment API and allocator
*/
#pragma once
#include <stdint.h>
@ -10,28 +15,32 @@ extern "C" {
#define MEMMGR_HEAP_UNKNOWN 0xFFFFFFFF
/** Memmgr heap enable thread allocation tracking
* @param thread_id - thread id to track
*
* @param thread_id - thread id to track
*/
void memmgr_heap_enable_thread_trace(osThreadId_t thread_id);
/** Memmgr heap disable thread allocation tracking
* @param thread_id - thread id to track
*
* @param thread_id - thread id to track
*/
void memmgr_heap_disable_thread_trace(osThreadId_t thread_id);
/** Memmgr heap get allocatred thread memory
* @param thread_id - thread id to track
* @return bytes allocated right now
*
* @param thread_id - thread id to track
*
* @return bytes allocated right now
*/
size_t memmgr_heap_get_thread_memory(osThreadId_t thread_id);
/** Memmgr heap get the max contiguous block size on the heap
* @return size_t max contiguous block size
*
* @return size_t max contiguous block size
*/
size_t memmgr_heap_get_max_free_block();
/**
* Print the address and size of all free blocks to stdout
/** Print the address and size of all free blocks to stdout
*/
void memmgr_heap_printf_free_blocks();

View File

@ -1,3 +1,8 @@
/**
* @file record.h
* Furi: record API
*/
#pragma once
#include <stdbool.h>
@ -6,36 +11,45 @@
extern "C" {
#endif
/** Initialize record storage
* For internal use only.
/** Initialize record storage For internal use only.
*/
void furi_record_init();
/** Create record
* @param name - record name
* @param data - data pointer
* @note Thread safe. Create and destroy must be executed from the same thread.
*
* @param name record name
* @param data data pointer
* @note Thread safe. Create and destroy must be executed from the same
* thread.
*/
void furi_record_create(const char* name, void* data);
/** Destroy record
* @param name - record name
* @return true if successful, false if still have holders or thread is not owner.
* @note Thread safe. Create and destroy must be executed from the same thread.
*
* @param name record name
*
* @return true if successful, false if still have holders or thread is not
* owner.
* @note Thread safe. Create and destroy must be executed from the same
* thread.
*/
bool furi_record_destroy(const char* name);
/** Open record
* @param name - record name
* @return pointer to the record
* @note Thread safe. Open and close must be executed from the same thread.
* Suspends caller thread till record appear
*
* @param name record name
*
* @return pointer to the record
* @note Thread safe. Open and close must be executed from the same
* thread. Suspends caller thread till record appear
*/
void* furi_record_open(const char* name);
/** Close record
* @param name - record name
* @note Thread safe. Open and close must be executed from the same thread.
*
* @param name record name
* @note Thread safe. Open and close must be executed from the same
* thread.
*/
void furi_record_close(const char* name);

View File

@ -1,3 +1,8 @@
/**
* @file stdglue.h
* Furi: stdlibc glue
*/
#pragma once
#include <stdbool.h>
@ -7,31 +12,31 @@
extern "C" {
#endif
/**
* Write callback
* @param _cookie - pointer to cookie (see stdio gnu extension)
* @param data - pointer to data
* @param size - data size
* @warnign your handler must consume everything
/** Write callback
* @param _cookie pointer to cookie (see stdio gnu extension)
* @param data pointer to data
* @param size data size @warnign your handler must consume everything
*/
typedef void (*FuriStdglueWriteCallback)(void* _cookie, const char* data, size_t size);
/** Initialized std library glue code */
void furi_stdglue_init();
/**
* Set global STDOUT callback
* @param callback - callback or NULL to clear
* @return true on success, otherwise fail
* @warning function is thread aware, use this API from the same thread
/** Set global STDOUT callback
*
* @param callback callback or NULL to clear
*
* @return true on success, otherwise fail
* @warning function is thread aware, use this API from the same thread
*/
bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback);
/**
* Set STDOUT callback for your thread
* @param callback - callback or NULL to clear
* @return true on success, otherwise fail
* @warning function is thread aware, use this API from the same thread
/** Set STDOUT callback for your thread
*
* @param callback callback or NULL to clear
*
* @return true on success, otherwise fail
* @warning function is thread aware, use this API from the same thread
*/
bool furi_stdglue_set_thread_stdout_callback(FuriStdglueWriteCallback callback);

View File

@ -1,3 +1,8 @@
/**
* @file thread.h
* Furi: Furi Thread API
*/
#pragma once
#include <stdint.h>
@ -18,109 +23,130 @@ typedef enum {
/** FuriThread anonymous structure */
typedef struct FuriThread FuriThread;
/** FuriThreadCallback
* Your callback to run in new thread
* @warning don't use osThreadExit
/** FuriThreadCallback Your callback to run in new thread
* @warning never use osThreadExit in FuriThread
*/
typedef int32_t (*FuriThreadCallback)(void* context);
/** FuriThread state change calback
* called upon thread state change
* @param state - new thread state
* @param context - callback context
/** FuriThread state change calback called upon thread state change
* @param state new thread state
* @param context callback context
*/
typedef void (*FuriThreadStateCallback)(FuriThreadState state, void* context);
/** Allocate FuriThread
* @return FuriThread instance
*
* @return FuriThread instance
*/
FuriThread* furi_thread_alloc();
/** Release FuriThread
* @param thread - FuriThread instance
*
* @param thread FuriThread instance
*/
void furi_thread_free(FuriThread* thread);
/** Set FuriThread name
* @param thread - FuriThread instance
* @param name - string
*
* @param thread FuriThread instance
* @param name string
*/
void furi_thread_set_name(FuriThread* thread, const char* name);
/** Set FuriThread stack size
* @param thread - FuriThread instance
* @param stack_size - stack size in bytes
*
* @param thread FuriThread instance
* @param stack_size stack size in bytes
*/
void furi_thread_set_stack_size(FuriThread* thread, size_t stack_size);
/** Set FuriThread callback
* @param thread - FuriThread instance
* @param callback - FuriThreadCallback, called upon thread run
*
* @param thread FuriThread instance
* @param callback FuriThreadCallback, called upon thread run
*/
void furi_thread_set_callback(FuriThread* thread, FuriThreadCallback callback);
/** Set FuriThread context
* @param thread - FuriThread instance
* @param context - pointer to context for thread callback
*
* @param thread FuriThread instance
* @param context pointer to context for thread callback
*/
void furi_thread_set_context(FuriThread* thread, void* context);
/** Set FuriThread state change callback
* @param thread - FuriThread instance
* @param callack - state change callback
*
* @param thread FuriThread instance
* @param callback state change callback
*/
void furi_thread_set_state_callback(FuriThread* thread, FuriThreadStateCallback callback);
/** Set FuriThread state change context
* @param thread - FuriThread instance
* @param context - pointer to context
*
* @param thread FuriThread instance
* @param context pointer to context
*/
void furi_thread_set_state_context(FuriThread* thread, void* context);
/** Get FuriThread state
* @param thread - FuriThread instance
* @return thread state from FuriThreadState
*
* @param thread FuriThread instance
*
* @return thread state from FuriThreadState
*/
FuriThreadState furi_thread_get_state(FuriThread* thread);
/** Start FuriThread
* @param thread - FuriThread instance
* @return true on success
*
* @param thread FuriThread instance
*
* @return true on success
*/
bool furi_thread_start(FuriThread* thread);
/** Treminate FuriThread
* @param thread - FuriThread instance
* @return osStatus_t
* @warning terminating statefull thread is dangerous
* use only if you know what you doing
*
* @param thread FuriThread instance
*
* @return osStatus_t
* @warning terminating statefull thread is dangerous use only if you know
* what you doing
*/
osStatus_t furi_thread_terminate(FuriThread* thread);
/** Join FuriThread
* @param thread - FuriThread instance
* @return osStatus_t
*
* @param thread FuriThread instance
*
* @return osStatus_t
*/
osStatus_t furi_thread_join(FuriThread* thread);
/** Get CMSIS Thread ID
* @param thread - FuriThread instance
* @return osThreadId_t or NULL
*
* @param thread FuriThread instance
*
* @return osThreadId_t or NULL
*/
osThreadId_t furi_thread_get_thread_id(FuriThread* thread);
/** Enable heap tracing
* @param thread - FuriThread instance
*
* @param thread FuriThread instance
*/
void furi_thread_enable_heap_trace(FuriThread* thread);
/** Disable heap tracing
* @param thread - FuriThread instance
*
* @param thread FuriThread instance
*/
void furi_thread_disable_heap_trace(FuriThread* thread);
/** Get thread heap size
* @param thread - FuriThread instance
*
* @param thread FuriThread instance
*
* @return size in bytes
*/
size_t furi_thread_get_heap_size(FuriThread* thread);

2608
documentation/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,70 +5,88 @@
#include <stddef.h>
/** Get flash base address
* @return pointer to flash base
*
* @return pointer to flash base
*/
size_t furi_hal_flash_get_base();
/** Get flash read block size
* @return size in bytes
*
* @return size in bytes
*/
size_t furi_hal_flash_get_read_block_size();
/** Get flash write block size
* @return size in bytes
*
* @return size in bytes
*/
size_t furi_hal_flash_get_write_block_size();
/** Get flash page size
* @return size in bytes
*
* @return size in bytes
*/
size_t furi_hal_flash_get_page_size();
/** Get expected flash cycles count
* @return count of erase-write operations
*
* @return count of erase-write operations
*/
size_t furi_hal_flash_get_cycles_count();
/** Get free flash start address
* @return pointer to free region start
*
* @return pointer to free region start
*/
const void* furi_hal_flash_get_free_start_address();
/** Get free flash end address
* @return pointer to free region end
*
* @return pointer to free region end
*/
const void* furi_hal_flash_get_free_end_address();
/** Get first free page start address
* @return first free page memory address
*
* @return first free page memory address
*/
size_t furi_hal_flash_get_free_page_start_address();
/** Get free page count
* @return free page count
*
* @return free page count
*/
size_t furi_hal_flash_get_free_page_count();
/*
* Erase Flash
/** Erase Flash
*
* Locking operation, uses HSEM to manage shared access.
* @param page, page number
* @param count, page count to erase
*
* @param page page number
* @param count page count to erase
*
* @return true on success
*/
bool furi_hal_flash_erase(uint8_t page, uint8_t count);
/*
* Write double word (64 bits)
/** Write double word (64 bits)
*
* Locking operation, uses HSEM to manage shared access.
* @param address - destination address, must be double word aligned.
* @param data - data to write
*
* @param address destination address, must be double word aligned.
* @param data data to write
*
* @return true on success
*/
bool furi_hal_flash_write_dword(size_t address, uint64_t data);
/*
* Write double word (64 bits) from address
/** Write double word (64 bits) from address
*
* Locking operation, uses HSEM to manage shared access.
* @param address - destination address, must be block aligned
* @param source_address - source address
*
* @param address destination address, must be block aligned
* @param source_address source address
*
* @return true on success
*/
bool furi_hal_flash_write_dword_from(size_t address, size_t source_address);

View File

@ -290,14 +290,6 @@ void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset) {
}
}
uint8_t furi_hal_subghz_get_status() {
const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz);
CC1101StatusRaw st;
st.status = cc1101_get_status(device);
furi_hal_spi_device_return(device);
return st.status_raw;
}
void furi_hal_subghz_load_registers(const uint8_t data[][2]) {
const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz);
cc1101_reset(device);

View File

@ -290,14 +290,6 @@ void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset) {
}
}
uint8_t furi_hal_subghz_get_status() {
const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz);
CC1101StatusRaw st;
st.status = cc1101_get_status(device);
furi_hal_spi_device_return(device);
return st.status_raw;
}
void furi_hal_subghz_load_registers(const uint8_t data[][2]) {
const FuriHalSpiDevice* device = furi_hal_spi_device_get(FuriHalSpiDeviceIdSubGhz);
cc1101_reset(device);

View File

@ -1,4 +1,10 @@
/**
* @file furi-hal-boot.h
* Bootloader HAL API
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
@ -17,16 +23,26 @@ typedef enum {
FuriHalBootFlagFactoryReset=1,
} FuriHalBootFlag;
/** Initialize boot subsystem */
/** Initialize boot subsystem
*/
void furi_hal_boot_init();
/** Set boot mode */
/** Set boot mode
*
* @param[in] mode FuriHalBootMode
*/
void furi_hal_boot_set_mode(FuriHalBootMode mode);
/** Set boot flags */
/** Set boot flags
*
* @param[in] flags FuriHalBootFlag
*/
void furi_hal_boot_set_flags(FuriHalBootFlag flags);
/** Get boot flag */
/** Get boot flag
*
* @return FuriHalBootFlag
*/
FuriHalBootFlag furi_hal_boot_get_flags();
#ifdef __cplusplus

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-bt.h
* BT/BLE HAL API
*/
#pragma once
#include <m-string.h>
@ -7,64 +12,114 @@
extern "C" {
#endif
/** Initialize */
/** Initialize
*/
void furi_hal_bt_init();
/** Start BLE app */
/** Start BLE app
*
* @return true if app inited
*/
bool furi_hal_bt_init_app();
/** Start advertising */
/** Start advertising
*/
void furi_hal_bt_start_advertising();
/** Stop advertising */
/** Stop advertising
*/
void furi_hal_bt_stop_advertising();
/** Returns true if BLE is advertising */
/** Returns true if BLE is advertising
*
* @return true if BLE advertising
*/
bool furi_hal_bt_is_active();
/** Get BT/BLE system component state */
/** Get BT/BLE system component state
*
* @param[in] buffer string_t buffer to write to
*/
void furi_hal_bt_dump_state(string_t buffer);
/** Get BT/BLE system component state */
/** Get BT/BLE system component state
*
* @return true if core2 is alive
*/
bool furi_hal_bt_is_alive();
/** Wait for Core2 startup */
/** Wait for Core2 startup
*
* @return true if success, otherwise timeouted
*/
bool furi_hal_bt_wait_startup();
/**
* Lock shared access to flash controller
* @return true if lock was successful, false if not
/** Lock shared access to flash controller
*
* @param[in] erase_flag true if erase operation
*
* @return true if lock was successful, false if not
*/
bool furi_hal_bt_lock_flash(bool erase_flag);
/** Unlock shared access to flash controller */
/** Unlock shared access to flash controller
*
* @param[in] erase_flag true if erase operation
*/
void furi_hal_bt_unlock_flash(bool erase_flag);
/** Start ble tone tx at given channel and power */
/** Start ble tone tx at given channel and power
*
* @param[in] channel The channel
* @param[in] power The power
*/
void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power);
/** Stop ble tone tx */
/** Stop ble tone tx
*/
void furi_hal_bt_stop_tone_tx();
/** Start sending ble packets at a given frequency and datarate */
/** Start sending ble packets at a given frequency and datarate
*
* @param[in] channel The channel
* @param[in] pattern The pattern
* @param[in] datarate The datarate
*/
void furi_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datarate);
/** Stop sending ble packets */
/** Stop sending ble packets
*
* @return sent packet count
*/
uint16_t furi_hal_bt_stop_packet_test();
/** Start receiving packets */
/** Start receiving packets
*
* @param[in] channel RX channel
* @param[in] datarate Datarate
*/
void furi_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate);
/** Set up the RF to listen to a given RF channel */
/** Set up the RF to listen to a given RF channel
*
* @param[in] channel RX channel
*/
void furi_hal_bt_start_rx(uint8_t channel);
/** Stop RF listenning */
/** Stop RF listenning
*/
void furi_hal_bt_stop_rx();
/** Get RSSI */
/** Get RSSI
*
* @return RSSI in dBm
*/
float furi_hal_bt_get_rssi();
/** Get number of transmitted packets */
/** Get number of transmitted packets
*
* @return packet count
*/
uint32_t furi_hal_bt_get_transmitted_packets();
#ifdef __cplusplus

View File

@ -1,3 +1,7 @@
/**
* @file furi-hal-crypto.h
* Cryptography HAL API
*/
#pragma once
#include <stdbool.h>
@ -24,43 +28,54 @@ typedef struct {
uint8_t* data;
} FuriHalCryptoKey;
/** Initialize cryptography layer
* This includes AES engines, PKA and RNG
/** Initialize cryptography layer This includes AES engines, PKA and RNG
*/
void furi_hal_crypto_init();
/** Store key in crypto storage
* @param key - FuriHalCryptoKey to store. Only Master, Simple or Encrypted
* @param slot - pinter to int where store slot number will be saved
* @return true on success
*
* @param key FuriHalCryptoKey to store. Only Master, Simple or
* Encrypted
* @param slot pinter to int where store slot number will be saved
*
* @return true on success
*/
bool furi_hal_crypto_store_add_key(FuriHalCryptoKey* key, uint8_t* slot);
/** Init AES engine and load key from crypto store
* @param slot - store slot number
* @return true on success
*
* @param slot store slot number
* @param[in] iv pointer to 16 bytes Initialization Vector data
*
* @return true on success
*/
bool furi_hal_crypto_store_load_key(uint8_t slot, const uint8_t* iv);
/** Unload key engine and deinit AES engine
* @param slot - store slot number
* @return true on success
*
* @param slot store slot number
*
* @return true on success
*/
bool furi_hal_crypto_store_unload_key(uint8_t slot);
/** Encrypt data
* @param input - pointer to input data
* @param output - pointer to output data
* @param size - input/output buffer size in bytes
* @return true on success
*
* @param input pointer to input data
* @param output pointer to output data
* @param size input/output buffer size in bytes
*
* @return true on success
*/
bool furi_hal_crypto_encrypt(const uint8_t *input, uint8_t *output, size_t size);
/** Decrypt data
* @param input - pointer to input data
* @param output - pointer to output data
* @param size - input/output buffer size in bytes
* @return true on success
*
* @param input pointer to input data
* @param output pointer to output data
* @param size input/output buffer size in bytes
*
* @return true on success
*/
bool furi_hal_crypto_decrypt(const uint8_t *input, uint8_t *output, size_t size);

View File

@ -1,23 +1,39 @@
/**
* @file furi-hal-delay.h
* Delay HAL API
*/
#pragma once
#include "main.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Init DWT */
/** Init DWT
*/
void furi_hal_delay_init(void);
/**
* Delay in milliseconds
* @warning Cannot be used from ISR
/** Delay in milliseconds
* @warning Cannot be used from ISR
*
* @param[in] milliseconds milliseconds to wait
*/
void delay(float milliseconds);
/** Delay in microseconds */
/** Delay in microseconds
*
* @param[in] microseconds microseconds to wait
*/
void delay_us(float microseconds);
/** Get current millisecond */
/** Get current millisecond
*
* System uptime, pProvided by HAL, may overflow.
*
* @return Current milliseconds
*/
uint32_t millis(void);
#ifdef __cplusplus

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-i2c.h
* I2C HAL API
*/
#pragma once
#include <stdbool.h>
@ -8,17 +13,19 @@
extern "C" {
#endif
/** Init I2C */
/** Init I2C
*/
void furi_hal_i2c_init();
/**
* Perform I2C tx transfer
* @param instance I2C_TypeDef instance
* @param address I2C slave address
* @param data pointer to data buffer
* @param size size of data buffer
* @param timeout timeout in CPU ticks
* @return true on successful transfer, false otherwise
/** Perform I2C tx transfer
*
* @param instance I2C_TypeDef instance
* @param address I2C slave address
* @param data pointer to data buffer
* @param size size of data buffer
* @param timeout timeout in CPU ticks
*
* @return true on successful transfer, false otherwise
*/
bool furi_hal_i2c_tx(
I2C_TypeDef* instance,
@ -27,14 +34,15 @@ bool furi_hal_i2c_tx(
const uint8_t size,
uint32_t timeout);
/**
* Perform I2C rx transfer
* @param instance I2C_TypeDef instance
* @param address I2C slave address
* @param data pointer to data buffer
* @param size size of data buffer
* @param timeout timeout in CPU ticks
* @return true on successful transfer, false otherwise
/** Perform I2C rx transfer
*
* @param instance I2C_TypeDef instance
* @param address I2C slave address
* @param data pointer to data buffer
* @param size size of data buffer
* @param timeout timeout in CPU ticks
*
* @return true on successful transfer, false otherwise
*/
bool furi_hal_i2c_rx(
I2C_TypeDef* instance,
@ -43,16 +51,17 @@ bool furi_hal_i2c_rx(
const uint8_t size,
uint32_t timeout);
/**
* Perform I2C tx and rx transfers
* @param instance I2C_TypeDef instance
* @param address I2C slave address
* @param tx_data pointer to tx data buffer
* @param tx_size size of tx data buffer
* @param rx_data pointer to rx data buffer
* @param rx_size size of rx data buffer
* @param timeout timeout in CPU ticks
* @return true on successful transfer, false otherwise
/** Perform I2C tx and rx transfers
*
* @param instance I2C_TypeDef instance
* @param address I2C slave address
* @param tx_data pointer to tx data buffer
* @param tx_size size of tx data buffer
* @param rx_data pointer to rx data buffer
* @param rx_size size of rx data buffer
* @param timeout timeout in CPU ticks
*
* @return true on successful transfer, false otherwise
*/
bool furi_hal_i2c_trx(
I2C_TypeDef* instance,
@ -63,17 +72,22 @@ bool furi_hal_i2c_trx(
const uint8_t rx_size,
uint32_t timeout);
/** Acquire I2C mutex */
/** Acquire I2C mutex
*/
void furi_hal_i2c_lock();
/** Release I2C mutex */
/** Release I2C mutex
*/
void furi_hal_i2c_unlock();
/**
* With clause for I2C peripheral
* @param type type of function_body
* @param pointer pointer to return of function_body
* @param function_body a (){} lambda declaration, executed with I2C mutex acquired
/** With clause for I2C peripheral
*
* @param type type of function_body
* @param pointer pointer to return of function_body
* @param function_body a (){} lambda declaration, executed with I2C mutex
* acquired
*
* @return Nothing
*/
#define with_furi_hal_i2c(type, pointer, function_body) \
{ \

View File

@ -1,4 +1,10 @@
/**
* @file furi-hal-ibutton.h
* iButton HAL API
*/
#pragma once
#include <stdbool.h>
#ifdef __cplusplus

View File

@ -1,4 +1,10 @@
/**
* @file furi-hal-irda.h
* IRDA HAL API
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
@ -11,122 +17,120 @@ extern "C" {
#define IRDA_MIN_FREQUENCY 10000
typedef enum {
FuriHalIrdaTxGetDataStateOk, /* New data obtained */
FuriHalIrdaTxGetDataStateDone, /* New data obtained, and this is end of package */
FuriHalIrdaTxGetDataStateLastDone, /* New data obtained, and this is end of package and no more data available */
FuriHalIrdaTxGetDataStateOk, /**< New data obtained */
FuriHalIrdaTxGetDataStateDone, /**< New data obtained, and this is end of package */
FuriHalIrdaTxGetDataStateLastDone, /**< New data obtained, and this is end of package and no more data available */
} FuriHalIrdaTxGetDataState;
/* Callback type for providing data to IRDA DMA TX system. It is called every tim */
/** Callback type for providing data to IRDA DMA TX system. It is called every tim */
typedef FuriHalIrdaTxGetDataState (*FuriHalIrdaTxGetDataISRCallback) (void* context, uint32_t* duration, bool* level);
/* Callback type called every time signal is sent by DMA to Timer.
* Actually, it means there are 2 timings left to send for this signal, which is almost end.
* Don't use this callback to stop transmission, as far as there are next signal is
* charged for transmission by DMA.
/** Callback type called every time signal is sent by DMA to Timer.
*
* Actually, it means there are 2 timings left to send for this signal, which is
* almost end. Don't use this callback to stop transmission, as far as there are
* next signal is charged for transmission by DMA.
*/
typedef void (*FuriHalIrdaTxSignalSentISRCallback) (void* context);
/**
* Signature of callback function for receiving continuous IRDA rx signal.
/** Signature of callback function for receiving continuous IRDA rx signal.
*
* @param ctx[in] - context to pass to callback
* @param level[in] - level of input IRDA rx signal
* @param duration[in] - duration of continuous rx signal level in us
* @param ctx[in] context to pass to callback
* @param level[in] level of input IRDA rx signal
* @param duration[in] duration of continuous rx signal level in us
*/
typedef void (*FuriHalIrdaRxCaptureCallback)(void* ctx, bool level, uint32_t duration);
/**
* Signature of callback function for reaching silence timeout on IRDA port.
/** Signature of callback function for reaching silence timeout on IRDA port.
*
* @param ctx[in] - context to pass to callback
* @param ctx[in] context to pass to callback
*/
typedef void (*FuriHalIrdaRxTimeoutCallback)(void* ctx);
/**
* Initialize IRDA RX timer to receive interrupts.
* It provides interrupts for every RX-signal edge changing
* with its duration.
/** Initialize IRDA RX timer to receive interrupts.
*
* It provides interrupts for every RX-signal edge changing with its duration.
*/
void furi_hal_irda_async_rx_start(void);
/**
* Deinitialize IRDA RX interrupt.
/** Deinitialize IRDA RX interrupt.
*/
void furi_hal_irda_async_rx_stop(void);
/** Setup hal for receiving silence timeout.
*
* Should be used with 'furi_hal_irda_timeout_irq_set_callback()'.
*
* @param[in] timeout_us - time to wait for silence on IRDA port
* before generating IRQ.
* @param[in] timeout_us time to wait for silence on IRDA port before
* generating IRQ.
*/
void furi_hal_irda_async_rx_set_timeout(uint32_t timeout_us);
/** Setup callback for previously initialized IRDA RX interrupt.
*
* @param[in] callback - callback to call when RX signal edge changing occurs
* @param[in] ctx - context for callback
* @param[in] callback callback to call when RX signal edge changing occurs
* @param[in] ctx context for callback
*/
void furi_hal_irda_async_rx_set_capture_isr_callback(FuriHalIrdaRxCaptureCallback callback, void *ctx);
/**
* Setup callback for reaching silence timeout on IRDA port.
/** Setup callback for reaching silence timeout on IRDA port.
*
* Should setup hal with 'furi_hal_irda_setup_rx_timeout_irq()' first.
*
* @param[in] callback - callback for silence timeout
* @param[in] ctx - context to pass to callback
* @param[in] callback callback for silence timeout
* @param[in] ctx context to pass to callback
*/
void furi_hal_irda_async_rx_set_timeout_isr_callback(FuriHalIrdaRxTimeoutCallback callback, void *ctx);
/**
* Check if IRDA is in use now.
* @return true - IRDA is busy, false otherwise.
/** Check if IRDA is in use now.
*
* @return true if IRDA is busy, false otherwise.
*/
bool furi_hal_irda_is_busy(void);
/**
* Set callback providing new data. This function has to be called
* before furi_hal_irda_async_tx_start().
/** Set callback providing new data.
*
* @param[in] callback - function to provide new data
* @param[in] context - context for callback
* This function has to be called before furi_hal_irda_async_tx_start().
*
* @param[in] callback function to provide new data
* @param[in] context context for callback
*/
void furi_hal_irda_async_tx_set_data_isr_callback(FuriHalIrdaTxGetDataISRCallback callback, void* context);
/**
* Start IR asynchronous transmission. It can be stopped by 2 reasons:
* 1) implicit call for furi_hal_irda_async_tx_stop()
* 2) callback can provide FuriHalIrdaTxGetDataStateLastDone response
* which means no more data available for transmission.
/** Start IR asynchronous transmission.
*
* It can be stopped by 2 reasons:
* 1. implicit call for furi_hal_irda_async_tx_stop()
* 2. callback can provide FuriHalIrdaTxGetDataStateLastDone response which
* means no more data available for transmission.
*
* Any func (furi_hal_irda_async_tx_stop() or
* furi_hal_irda_async_tx_wait_termination()) has to be called to wait
* end of transmission and free resources.
* furi_hal_irda_async_tx_wait_termination()) has to be called to wait end of
* transmission and free resources.
*
* @param[in] freq - frequency for PWM
* @param[in] duty_cycle - duty cycle for PWM
* @param[in] freq frequency for PWM
* @param[in] duty_cycle duty cycle for PWM
*/
void furi_hal_irda_async_tx_start(uint32_t freq, float duty_cycle);
/**
* Stop IR asynchronous transmission and free resources.
* Transmission will stop as soon as transmission reaches end of
* package (FuriHalIrdaTxGetDataStateDone or FuriHalIrdaTxGetDataStateLastDone).
/** Stop IR asynchronous transmission and free resources.
*
* Transmission will stop as soon as transmission reaches end of package
* (FuriHalIrdaTxGetDataStateDone or FuriHalIrdaTxGetDataStateLastDone).
*/
void furi_hal_irda_async_tx_stop(void);
/**
* Wait for end of IR asynchronous transmission and free resources.
* Transmission will stop as soon as transmission reaches end of
* transmission (FuriHalIrdaTxGetDataStateLastDone).
/** Wait for end of IR asynchronous transmission and free resources.
*
* Transmission will stop as soon as transmission reaches end of transmission
* (FuriHalIrdaTxGetDataStateLastDone).
*/
void furi_hal_irda_async_tx_wait_termination(void);
/**
* Set callback for end of signal transmission
/** Set callback for end of signal transmission
*
* @param[in] callback - function to call when signal is sent
* @param[in] context - context for callback
* @param[in] callback function to call when signal is sent
* @param[in] context context for callback
*/
void furi_hal_irda_async_tx_set_signal_sent_isr_callback(FuriHalIrdaTxSignalSentISRCallback callback, void* context);

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-light.h
* Light control HAL API
*/
#pragma once
#include <stdbool.h>
@ -8,13 +13,14 @@
extern "C" {
#endif
/** Init light driver */
/** Init light driver
*/
void furi_hal_light_init();
/**
* Set light value
* @param light - Light
* @param value - light brightness [0-255]
/** Set light value
*
* @param light Light
* @param value light brightness [0-255]
*/
void furi_hal_light_set(Light light, uint8_t value);

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-nfc.h
* NFC HAL API
*/
#pragma once
#include <rfal_nfc.h>
@ -11,58 +16,78 @@ extern "C" {
#define FURI_HAL_NFC_UID_MAX_LEN 10
/**
* Init nfc
/** Init nfc
*/
void furi_hal_nfc_init();
/**
* Check if nfc worker is busy
/** Check if nfc worker is busy
*
* @return true if busy
*/
bool furi_hal_nfc_is_busy();
/**
* NFC field on
/** NFC field on
*/
void furi_hal_nfc_field_on();
/**
* NFC field off
/** NFC field off
*/
void furi_hal_nfc_field_off();
/**
* NFC start sleep
/** NFC start sleep
*/
void furi_hal_nfc_start_sleep();
/**
* NFC stop sleep
/** NFC stop sleep
*/
void furi_hal_nfc_exit_sleep();
/**
* NFC poll
/** NFC poll
*
* @param dev_list pointer to rfalNfcDevice buffer
* @param dev_cnt pointer device count
* @param timeout timeout in ms
* @param deactivate deactivate flag
*
* @return true on success
*/
bool furi_hal_nfc_detect(rfalNfcDevice** dev_list, uint8_t* dev_cnt, uint32_t timeout, bool deactivate);
/**
* NFC listen
/** NFC listen
*
* @param uid pointer to uid buffer
* @param uid_len uid length
* @param atqa pointer to atqa
* @param sak sak
* @param activate_after_sak activate after sak flag
* @param timeout timeout in ms
*
* @return true on success
*/
bool furi_hal_nfc_listen(uint8_t* uid, uint8_t uid_len, uint8_t* atqa, uint8_t sak, bool activate_after_sak, uint32_t timeout);
/**
* Get first command from reader after activation in emulation mode
/** Get first command from reader after activation in emulation mode
*
* @param rx_buff pointer to receive buffer
* @param rx_len receive buffer length
*
* @return true on success
*/
bool furi_hal_nfc_get_first_frame(uint8_t** rx_buff, uint16_t** rx_len);
/**
* NFC data exchange
/** NFC data exchange
*
* @param tx_buff transmit buffer
* @param tx_len transmit buffer length
* @param rx_buff receive buffer
* @param rx_len receive buffer length
* @param deactivate deactivate flag
*
* @return ST ReturnCode
*/
ReturnCode furi_hal_nfc_data_exchange(uint8_t* tx_buff, uint16_t tx_len, uint8_t** rx_buff, uint16_t** rx_len, bool deactivate);
/**
* NFC deactivate and start sleep
/** NFC deactivate and start sleep
*/
void furi_hal_nfc_deactivate();

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-power.h
* Power HAL API
*/
#pragma once
#include <stdint.h>
@ -14,92 +19,142 @@ typedef enum {
FuriHalPowerICFuelGauge,
} FuriHalPowerIC;
/** Initialize drivers */
/** Initialize drivers
*/
void furi_hal_power_init();
/**
* Get current insomnia level
* @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.
/** Get current insomnia level
*
* @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.
*/
uint16_t furi_hal_power_insomnia_level();
/**
* Enter insomnia mode
* Prevents device from going to sleep
* @warning Internally increases insomnia level
* Must be paired with furi_hal_power_insomnia_exit
/** Enter insomnia mode Prevents device from going to sleep
* @warning Internally increases insomnia level Must be paired with
* furi_hal_power_insomnia_exit
*/
void furi_hal_power_insomnia_enter();
/**
* Exit insomnia mode
* Allow device to go to sleep
* @warning Internally decreases insomnia level.
* Must be paired with furi_hal_power_insomnia_enter
/** Exit insomnia mode Allow device to go to sleep
* @warning Internally decreases insomnia level. Must be paired with
* furi_hal_power_insomnia_enter
*/
void furi_hal_power_insomnia_exit();
/** Check if sleep availble */
/** Check if sleep availble
*
* @return true if available
*/
bool furi_hal_power_sleep_available();
/** Check if deep sleep availble */
/** Check if deep sleep availble
*
* @return true if available
*/
bool furi_hal_power_deep_sleep_available();
/** Go to sleep */
/** Go to sleep
*/
void furi_hal_power_sleep();
/** Get predicted remaining battery capacity in percents */
/** Get predicted remaining battery capacity in percents
*
* @return remaining battery capacity in percents
*/
uint8_t furi_hal_power_get_pct();
/** Get battery health state in percents */
/** Get battery health state in percents
*
* @return health in percents
*/
uint8_t furi_hal_power_get_bat_health_pct();
/** Get charging status */
/** Get charging status
*
* @return true if charging
*/
bool furi_hal_power_is_charging();
/** Poweroff device */
/** Poweroff device
*/
void furi_hal_power_off();
/** Reset device */
/** Reset device
*/
void furi_hal_power_reset();
/** OTG enable */
/** OTG enable
*/
void furi_hal_power_enable_otg();
/** OTG disable */
/** OTG disable
*/
void furi_hal_power_disable_otg();
/** Get OTG status */
/** Get OTG status
*
* @return true if enabled
*/
bool furi_hal_power_is_otg_enabled();
/** Get remaining battery battery capacity in mAh */
/** Get remaining battery battery capacity in mAh
*
* @return capacity in mAh
*/
uint32_t furi_hal_power_get_battery_remaining_capacity();
/** Get full charge battery capacity in mAh */
/** Get full charge battery capacity in mAh
*
* @return capacity in mAh
*/
uint32_t furi_hal_power_get_battery_full_capacity();
/** Get battery voltage in V */
/** Get battery voltage in V
*
* @param ic FuriHalPowerIc to get measurment
*
* @return voltage in V
*/
float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic);
/** Get battery current in A */
/** Get battery current in A
*
* @param ic FuriHalPowerIc to get measurment
*
* @return current in A
*/
float furi_hal_power_get_battery_current(FuriHalPowerIC ic);
/** Get temperature in C */
/** Get temperature in C
*
* @param ic FuriHalPowerIc to get measurment
*
* @return temperature in C
*/
float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic);
/** Get System voltage in V */
/** Get System voltage in V
*
* @return voltage in V
*/
float furi_hal_power_get_system_voltage();
/** Get USB voltage in V */
/** Get USB voltage in V
*
* @return voltage in V
*/
float furi_hal_power_get_usb_voltage();
/** Get power system component state */
/** Get power system component state
*/
void furi_hal_power_dump_state();
/** Enable 3.3v on external gpio and sd card */
/** Enable 3.3v on external gpio and sd card
*/
void furi_hal_power_enable_external_3_3v();
/** Disable 3.3v on external gpio and sd card */
/** Disable 3.3v on external gpio and sd card
*/
void furi_hal_power_disable_external_3_3v();
#ifdef __cplusplus

View File

@ -1,4 +1,10 @@
/**
* @file furi-hal-rfid.h
* RFID HAL API
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <main.h>
@ -7,111 +13,91 @@
extern "C" {
#endif
/** Initialize RFID subsystem */
/** Initialize RFID subsystem
*/
void furi_hal_rfid_init();
/**
* @brief config rfid pins to reset state
*
/** Config rfid pins to reset state
*/
void furi_hal_rfid_pins_reset();
/**
* @brief config rfid pins to emulate state
*
/** Config rfid pins to emulate state
*/
void furi_hal_rfid_pins_emulate();
/**
* @brief config rfid pins to read state
*
/** Config rfid pins to read state
*/
void furi_hal_rfid_pins_read();
/**
* @brief config rfid timer to read state
*
* @param freq timer frequency
* @param duty_cycle timer duty cycle, 0.0-1.0
/** Config rfid timer to read state
*
* @param freq timer frequency
* @param duty_cycle timer duty cycle, 0.0-1.0
*/
void furi_hal_rfid_tim_read(float freq, float duty_cycle);
/**
* @brief start read timer
*
/** Start read timer
*/
void furi_hal_rfid_tim_read_start();
/**
* @brief stop read timer
*
/** Stop read timer
*/
void furi_hal_rfid_tim_read_stop();
/**
* @brief config rfid timer to emulate state
*
* @param freq timer frequency
/** Config rfid timer to emulate state
*
* @param freq timer frequency
*/
void furi_hal_rfid_tim_emulate(float freq);
/**
* @brief start emulation timer
*
/** Start emulation timer
*/
void furi_hal_rfid_tim_emulate_start();
/**
* @brief stop emulation timer
*
/** Stop emulation timer
*/
void furi_hal_rfid_tim_emulate_stop();
/**
* @brief config rfid timers to reset state
*
/** Config rfid timers to reset state
*/
void furi_hal_rfid_tim_reset();
/**
* @brief check that timer instance is emulation timer
*
* @param hw timer instance
/** Check that timer instance is emulation timer
*
* @param hw timer instance
*
* @return true if instance is emulation timer
*/
bool furi_hal_rfid_is_tim_emulate(TIM_HandleTypeDef* hw);
/**
* @brief set emulation timer period
*
* @param period overall duration
/** Set emulation timer period
*
* @param period overall duration
*/
void furi_hal_rfid_set_emulate_period(uint32_t period);
/**
* @brief set emulation timer pulse
*
* @param pulse duration of high level
/** Set emulation timer pulse
*
* @param pulse duration of high level
*/
void furi_hal_rfid_set_emulate_pulse(uint32_t pulse);
/**
* @brief set read timer period
*
* @param period overall duration
/** Set read timer period
*
* @param period overall duration
*/
void furi_hal_rfid_set_read_period(uint32_t period);
/**
* @brief set read timer pulse
*
* @param pulse duration of high level
/** Set read timer pulse
*
* @param pulse duration of high level
*/
void furi_hal_rfid_set_read_pulse(uint32_t pulse);
/**
* Сhanges the configuration of the RFID timer "on a fly"
* @param freq new frequency
* @param duty_cycle new duty cycle
/** Сhanges the configuration of the RFID timer "on a fly"
*
* @param freq new frequency
* @param duty_cycle new duty cycle
*/
void furi_hal_rfid_change_read_config(float freq, float duty_cycle);

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-sd.h
* SD Card HAL API
*/
#include <stdint.h>
#include <stdbool.h>
@ -5,19 +10,20 @@
extern "C" {
#endif
/** Init SD card detect */
/** Init SD card detect
*/
void hal_sd_detect_init(void);
/** Set SD card detect pin to low */
/** Set SD card detect pin to low
*/
void hal_sd_detect_set_low(void);
/**
* Get SD card status
* @return true if SD card present
* @return false if SD card not present
/** Get SD card status
*
* @return true if SD card present, false if SD card not present
*/
bool hal_sd_detect(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-subghz.h
* SubGhz HAL API
*/
#pragma once
#include <stdbool.h>
@ -11,130 +16,148 @@ extern "C" {
/** Radio Presets */
typedef enum {
FuriHalSubGhzPresetOok270Async, /** OOK, bandwidth 270kHz, asynchronous */
FuriHalSubGhzPresetOok650Async, /** OOK, bandwidth 650kHz, asynchronous */
FuriHalSubGhzPreset2FSKAsync, /** FM, asynchronous */
FuriHalSubGhzPresetOok270Async, /**< OOK, bandwidth 270kHz, asynchronous */
FuriHalSubGhzPresetOok650Async, /**< OOK, bandwidth 650kHz, asynchronous */
FuriHalSubGhzPreset2FSKAsync, /**< FM, asynchronous */
} FuriHalSubGhzPreset;
/** Switchable Radio Paths */
/** Switchable Radio Paths */
typedef enum {
FuriHalSubGhzPathIsolate, /** Isolate Radio from antenna */
FuriHalSubGhzPath433, /** Center Frquency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */
FuriHalSubGhzPath315, /** Center Frquency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */
FuriHalSubGhzPath868, /** Center Frquency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
FuriHalSubGhzPathIsolate, /**< Isolate Radio from antenna */
FuriHalSubGhzPath433, /**< Center Frquency: 433MHz. Path 1: SW1RF1-SW2RF2, LCLCL */
FuriHalSubGhzPath315, /**< Center Frquency: 315MHz. Path 2: SW1RF2-SW2RF1, LCLCLCL */
FuriHalSubGhzPath868, /**< Center Frquency: 868MHz. Path 3: SW1RF3-SW2RF3, LCLC */
} FuriHalSubGhzPath;
/** SubGhz state */
typedef enum {
SubGhzStateInit, /** Init pending */
SubGhzStateInit, /**< Init pending */
SubGhzStateIdle, /** Idle, energy save mode */
SubGhzStateIdle, /**< Idle, energy save mode */
SubGhzStateAsyncRx, /** Async RX started */
SubGhzStateAsyncRx, /**< Async RX started */
SubGhzStateAsyncTx, /** Async TX started, DMA and timer is on */
SubGhzStateAsyncTxLast, /** Async TX continue, DMA completed and timer got last value to go */
SubGhzStateAsyncTxEnd, /** Async TX complete, cleanup needed */
SubGhzStateAsyncTx, /**< Async TX started, DMA and timer is on */
SubGhzStateAsyncTxLast, /**< Async TX continue, DMA completed and timer got last value to go */
SubGhzStateAsyncTxEnd, /**< Async TX complete, cleanup needed */
} SubGhzState;
/** SubGhz regulation, receive transmission on the current frequency for the region */
/** SubGhz regulation, receive transmission on the current frequency for the
* region */
typedef enum {
SubGhzRegulationOnlyRx, /**only Rx*/
SubGhzRegulationTxRx, /**TxRx*/
} SubGhzRegulation;
/** Initialize and switch to power save mode
* Used by internal API-HAL initalization routine
* Can be used to reinitialize device to safe state and send it to sleep
/** Initialize and switch to power save mode Used by internal API-HAL
* initalization routine Can be used to reinitialize device to safe state and
* send it to sleep
*/
void furi_hal_subghz_init();
/** Send device to sleep mode */
/** Send device to sleep mode
*/
void furi_hal_subghz_sleep();
/** Dump info to stdout */
/** Dump info to stdout
*/
void furi_hal_subghz_dump_state();
/** Load registers from preset by preset name
* @param preset to load
/** Load registers from preset by preset name
*
* @param preset to load
*/
void furi_hal_subghz_load_preset(FuriHalSubGhzPreset preset);
/** Get status */
uint8_t furi_hal_subghz_get_status();
/** Load registers
* @param register-value pairs array, terminated with {0,0}
*
* @param data Registers data
*/
void furi_hal_subghz_load_registers(const uint8_t data[][2]);
/** Load PATABLE
* @param data, 8 uint8_t values
*
* @param data 8 uint8_t values
*/
void furi_hal_subghz_load_patable(const uint8_t data[8]);
/** Write packet to FIFO
* @param data, bytes array
* @param size, size
*
* @param data bytes array
* @param size size
*/
void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size);
/** Read packet from FIFO
* @param data, pointer
* @param size, size
*
* @param data pointer
* @param size size
*/
void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size);
/** Flush rx FIFO buffer */
/** Flush rx FIFO buffer
*/
void furi_hal_subghz_flush_rx();
/** Shutdown
* Issue spwd command
* @warning registers content will be lost
/** Shutdown Issue spwd command
* @warning registers content will be lost
*/
void furi_hal_subghz_shutdown();
/** Reset
* Issue reset command
* @warning registers content will be lost
/** Reset Issue reset command
* @warning registers content will be lost
*/
void furi_hal_subghz_reset();
/** Switch to Idle */
/** Switch to Idle
*/
void furi_hal_subghz_idle();
/** Switch to Recieve */
/** Switch to Recieve
*/
void furi_hal_subghz_rx();
/** Switch to Transmit
* @return true if the transfer is allowed by belonging to the region
*/
*
* @return true if the transfer is allowed by belonging to the region
*/
bool furi_hal_subghz_tx();
/** Get RSSI value in dBm */
/** Get RSSI value in dBm
*
* @return RSSI value
*/
float furi_hal_subghz_get_rssi();
/** Check if frequency is in valid range
* @return true if frequncy is valid, otherwise false
*
* @param value frequency in Hz
*
* @return true if frequncy is valid, otherwise false
*/
bool furi_hal_subghz_is_frequency_valid(uint32_t value);
/** Set frequency and path
* This function automatically selects antenna matching network
* @param frequency in herz
* @return real frequency in herz
/** Set frequency and path This function automatically selects antenna matching
* network
*
* @param value frequency in Hz
*
* @return real frequency in herz
*/
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
/** Set frequency
* @param frequency in herz
* @return real frequency in herz
*
* @param value frequency in Hz
*
* @return real frequency in herz
*/
uint32_t furi_hal_subghz_set_frequency(uint32_t value);
/** Set path
* @param radio path to use
*
* @param path path to use
*/
void furi_hal_subghz_set_path(FuriHalSubGhzPath path);
@ -143,33 +166,39 @@ void furi_hal_subghz_set_path(FuriHalSubGhzPath path);
/** Signal Timings Capture callback */
typedef void (*FuriHalSubGhzCaptureCallback)(bool level, uint32_t duration, void* context);
/** Enable signal timings capture
* Initializes GPIO and TIM2 for timings capture
/** Enable signal timings capture Initializes GPIO and TIM2 for timings capture
*
* @param callback FuriHalSubGhzCaptureCallback
* @param context callback context
*/
void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* context);
/** Disable signal timings capture
* Resets GPIO and TIM2
/** Disable signal timings capture Resets GPIO and TIM2
*/
void furi_hal_subghz_stop_async_rx();
/** Async TX callback type
* @param context - callback context
* @return LevelDuration
* @param context callback context
* @return LevelDuration
*/
typedef LevelDuration (*FuriHalSubGhzAsyncTxCallback)(void* context);
/** Start async TX
* Initializes GPIO, TIM2 and DMA1 for signal output
* @return true if the transfer is allowed by belonging to the region
/** Start async TX Initializes GPIO, TIM2 and DMA1 for signal output
*
* @param callback FuriHalSubGhzAsyncTxCallback
* @param context callback context
*
* @return true if the transfer is allowed by belonging to the region
*/
bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* context);
/** Wait for async transmission to complete */
/** Wait for async transmission to complete
*
* @return true if TX complete
*/
bool furi_hal_subghz_is_async_tx_complete();
/** Stop async transmission and cleanup resources
* Resets GPIO, TIM2, and DMA1
/** Stop async transmission and cleanup resources Resets GPIO, TIM2, and DMA1
*/
void furi_hal_subghz_stop_async_tx();

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-vcp.h
* VCP HAL API
*/
#pragma once
#include <stdbool.h>
@ -8,35 +13,34 @@
extern "C" {
#endif
/**
* Init VCP HAL
* Allocates ring buffer and initializes state
/** Init VCP HAL Allocates ring buffer and initializes state
*/
void furi_hal_vcp_init();
/**
* Recieve data from VCP
* Waits till some data arrives, never returns 0
* @param buffer - pointer to buffer
* @param size - buffer size
* @return items copied in buffer, 0 if channel closed
/** Recieve data from VCP Waits till some data arrives, never returns 0
*
* @param buffer pointer to buffer
* @param size buffer size
*
* @return items copied in buffer, 0 if channel closed
*/
size_t furi_hal_vcp_rx(uint8_t* buffer, size_t size);
/**
* Recieve data from VCP with timeout
* Waits till some data arrives during timeout
* @param buffer - pointer to buffer
* @param size - buffer size
* @param timeout - rx timeout in ms
* @return items copied in buffer, 0 if channel closed or timeout occurs
/** Recieve data from VCP with timeout Waits till some data arrives during
* timeout
*
* @param buffer pointer to buffer
* @param size buffer size
* @param timeout rx timeout in ms
*
* @return items copied in buffer, 0 if channel closed or timeout occurs
*/
size_t furi_hal_vcp_rx_with_timeout(uint8_t* buffer, size_t size, uint32_t timeout);
/**
* Transmit data to VCP
* @param buffer - pointer to buffer
* @param size - buffer size
/** Transmit data to VCP
*
* @param buffer pointer to buffer
* @param size buffer size
*/
void furi_hal_vcp_tx(const uint8_t* buffer, size_t size);

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-version.h
* Version HAL API
*/
#pragma once
#include <stdbool.h>
@ -24,65 +29,110 @@ typedef enum {
FuriHalVersionRegionJp=0x03,
} FuriHalVersionRegion;
/** Init flipper version */
/** Init flipper version
*/
void furi_hal_version_init();
/** Check target firmware version */
/** Check target firmware version
*
* @return true if target and real matches
*/
bool furi_hal_version_do_i_belong_here();
/** Get model name */
/** Get model name
*
* @return model name C-string
*/
const char* furi_hal_version_get_model_name();
/** Get hardware version */
/** Get hardware version
*
* @return Hardware Version
*/
const uint8_t furi_hal_version_get_hw_version();
/** Get hardware target */
/** Get hardware target
*
* @return Hardware Target
*/
const uint8_t furi_hal_version_get_hw_target();
/** Get hardware body */
/** Get hardware body
*
* @return Hardware Body
*/
const uint8_t furi_hal_version_get_hw_body();
/** Get hardware body color */
/** Get hardware body color
*
* @return Hardware Color
*/
const FuriHalVersionColor furi_hal_version_get_hw_color();
/** Get hardware connect */
/** Get hardware connect
*
* @return Hardware Interconnect
*/
const uint8_t furi_hal_version_get_hw_connect();
/** Get hardware region */
/** Get hardware region
*
* @return Hardware Region
*/
const FuriHalVersionRegion furi_hal_version_get_hw_region();
/** Get hardware timestamp */
/** Get hardware timestamp
*
* @return Hardware Manufacture timestamp
*/
const uint32_t furi_hal_version_get_hw_timestamp();
/** Get pointer to target name */
/** Get pointer to target name
*
* @return Hardware Name C-string
*/
const char* furi_hal_version_get_name_ptr();
/** Get pointer to target device name */
/** Get pointer to target device name
*
* @return Hardware Device Name C-string
*/
const char* furi_hal_version_get_device_name_ptr();
/** Get pointer to target ble local device name */
/** Get pointer to target ble local device name
*
* @return Ble Device Name C-string
*/
const char* furi_hal_version_get_ble_local_device_name_ptr();
/** Get BLE MAC address
*
* @return pointer to BLE MAC address
*/
const uint8_t* furi_hal_version_get_ble_mac();
/**
* Get address of version structure of bootloader, stored in chip flash.
/** Get address of version structure of bootloader, stored in chip flash.
*
* @return Address of boot version structure.
* @return Address of boot version structure.
*/
const struct Version* furi_hal_version_get_boot_version(void);
const struct Version* furi_hal_version_get_boot_version();
/**
* Get address of version structure of firmware.
/** Get address of version structure of firmware.
*
* @return Address of firmware version structure.
* @return Address of firmware version structure.
*/
const struct Version* furi_hal_version_get_firmware_version(void);
const struct Version* furi_hal_version_get_firmware_version();
/** Get platform UID size in bytes */
/** Get platform UID size in bytes
*
* @return UID size in bytes
*/
size_t furi_hal_version_uid_size();
/** Get const pointer to UID */
/** Get const pointer to UID
*
* @return pointer to UID
*/
const uint8_t* furi_hal_version_uid();
#ifdef __cplusplus

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal-vibro.h
* Vibro HAL API
*/
#pragma once
#include <stdbool.h>
@ -8,10 +13,14 @@
extern "C" {
#endif
/** Initialize vibro */
/** Initialize vibro
*/
void furi_hal_vibro_init();
/** Turn on/off vibro */
/** Turn on/off vibro
*
* @param[in] value new state
*/
void furi_hal_vibro_on(bool value);
#ifdef __cplusplus

View File

@ -1,3 +1,8 @@
/**
* @file furi-hal.h
* Furi HAL API
*/
#pragma once
#ifdef __cplusplus

View File

@ -1,39 +0,0 @@
# Flipper Zero Contributor License Agreement
## Definitions
* You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.
* This Flipper Zero Sources or Sources - all of the files within any archive file or any group of files released in conjunction by Flipper Devices Inc., Flipper Devices Inc., or a derived or modified work based on such files.
* Contribution - any type of work that is submitted to a Sources, including any modifications or additions to existing work.
* Submitted - conveyed to a Sources via a pull request, commit, issue, or any form of electronic, written, or verbal communication with Flipper Devices Inc., contributors or maintainers.
* A Modification, or a Mod - instructions, to be performed manually or in an automated manner, that alter any part of this Sources.
* A Modified Sources - this Sources or a derivative of it with one or more Modification applied to it.
* Distribution - allowing one or more other people to in any way download or receive
a copy of this Sources, a Modified Sources, or a derivative of this Sources.
* The Flipper Zero Website - https://flipperzero.one.
## Agreement
### 1. Grant of Copyright License.
Subject to the terms and conditions of this agreement, **You grant** to the Projects maintainers, contributors, users and to Flipper Devices Inc. a perpetual, worldwide, non-exclusive, no-charge, royalty-free, **irrevocable copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, sublicense, and distribute Your contributions and such derivative works**. Except for this license, **You reserve all rights, title, and interest in your contributions.**
### 2. Grant of Patent License.
Subject to the terms and conditions of this agreement, You grant to the Projects maintainers, contributors, users and to Flipper Devices Inc. a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer your contributions, where such license applies only to those patent claims licensable by you that are necessarily infringed by your contribution or by combination of your contribution with the project to which this contribution was submitted.
If any entity institutes patent litigation - including cross-claim or counterclaim in a lawsuit - against You alleging that your contribution or any project it was submitted to constitutes or is responsible for direct or contributory patent infringement, then any patent licenses granted to that entity under this agreement shall terminate as of the date such litigation is filed.
### 3. Grant of using, copying, modifying and distributing.
Permission is hereby granted to use, copy, modify and/or distribute this Sources, provided that:
* All copyright notices within source files and as generated by the Software as output are retained, unchanged.
* **Any Distribution of this Sources**, whether as a Modified Sources or not, **includes this license** and is released under the terms of this Agreement. This clause is not dependant upon any measure of changes made to this Sources.
* **Any Distribution of this Sources, whether as a Modified Sources or not, requires express written consent from Flipper Devices Inc..**
* You may make Modifications to this Sources or a derivative of it, and distribute your Modifications in a form that is separate from the Sources, such as patches. The following restrictions apply to Modifications:
* A Modification must not alter or remove any copyright notices in the Sources, generated or otherwise.
* When a Modification to the Sources is released, a non-exclusive royalty-free right is granted to Flipper Devices Inc. to distribute the Modification in future versions of the Sources provided such versions remain available under the terms of this Agreement in addition to any other license(s) of the initial developer.
* **Any Distribution of a Modified Sources or derivative requires express written consent from Flipper Devices Inc..**
* Permission is hereby also granted to distribute programs which depend on this Sources, provided that you do not distribute any Modified Sources without express written consent.
* **Flipper Devices Inc. reserves the right to change the terms of this Agreement at any time**, although those changes are not retroactive to past releases. Changes to this document will be announced via email using the Flipper Devices Inc. email notification list. Failure to receive notification of a change does not make those changes invalid. A current copy of this Agreement can be found in the Flipper Zero Source repository.
* This Agreement will terminate automatically if you fail to comply with the limitations described herein. Upon termination, you must destroy all copies of this Package, the Software, and any derivatives within 48 hours.