mirror of
https://github.com/flipperdevices/flipperzero-firmware.git
synced 2025-12-12 04:41:26 +04:00
[FL-3949] Universal IR signal selection (#4085)
* feat: universal ir signal selection * fix: f18, format specifiers * update labels with suggestions from the ui team Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -8,6 +8,11 @@
|
||||
#include "flipper_format_stream.h"
|
||||
#include "flipper_format_stream_i.h"
|
||||
|
||||
// permits direct casting between `FlipperFormatOffset` and `StreamOffset`
|
||||
static_assert((size_t)FlipperFormatOffsetFromCurrent == (size_t)StreamOffsetFromCurrent);
|
||||
static_assert((size_t)FlipperFormatOffsetFromStart == (size_t)StreamOffsetFromStart);
|
||||
static_assert((size_t)FlipperFormatOffsetFromEnd == (size_t)StreamOffsetFromEnd);
|
||||
|
||||
/********************************** Private **********************************/
|
||||
struct FlipperFormat {
|
||||
Stream* stream;
|
||||
@@ -127,6 +132,17 @@ bool flipper_format_rewind(FlipperFormat* flipper_format) {
|
||||
return stream_rewind(flipper_format->stream);
|
||||
}
|
||||
|
||||
size_t flipper_format_tell(FlipperFormat* flipper_format) {
|
||||
furi_check(flipper_format);
|
||||
return stream_tell(flipper_format->stream);
|
||||
}
|
||||
|
||||
bool flipper_format_seek(FlipperFormat* flipper_format, int32_t offset, FlipperFormatOffset anchor) {
|
||||
furi_check(flipper_format);
|
||||
// direct usage of `anchor` made valid by `static_assert`s at the top of this file
|
||||
return stream_seek(flipper_format->stream, offset, (StreamOffset)anchor);
|
||||
}
|
||||
|
||||
bool flipper_format_seek_to_end(FlipperFormat* flipper_format) {
|
||||
furi_check(flipper_format);
|
||||
return stream_seek(flipper_format->stream, 0, StreamOffsetFromEnd);
|
||||
|
||||
@@ -94,6 +94,12 @@ extern "C" {
|
||||
|
||||
typedef struct FlipperFormat FlipperFormat;
|
||||
|
||||
typedef enum {
|
||||
FlipperFormatOffsetFromCurrent,
|
||||
FlipperFormatOffsetFromStart,
|
||||
FlipperFormatOffsetFromEnd,
|
||||
} FlipperFormatOffset;
|
||||
|
||||
/** Allocate FlipperFormat as string.
|
||||
*
|
||||
* @return FlipperFormat* pointer to a FlipperFormat instance
|
||||
@@ -216,6 +222,24 @@ void flipper_format_set_strict_mode(FlipperFormat* flipper_format, bool strict_m
|
||||
*/
|
||||
bool flipper_format_rewind(FlipperFormat* flipper_format);
|
||||
|
||||
/** Get the RW pointer position
|
||||
*
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
*
|
||||
* @return RW pointer position
|
||||
*/
|
||||
size_t flipper_format_tell(FlipperFormat* flipper_format);
|
||||
|
||||
/** Set the RW pointer position to an arbitrary value
|
||||
*
|
||||
* @param flipper_format Pointer to a FlipperFormat instance
|
||||
* @param offset Offset relative to the anchor point
|
||||
* @param anchor Anchor point (e.g. start of file)
|
||||
*
|
||||
* @return True on success
|
||||
*/
|
||||
bool flipper_format_seek(FlipperFormat* flipper_format, int32_t offset, FlipperFormatOffset anchor);
|
||||
|
||||
/** Move the RW pointer at the end. Can be useful if you want to add some data
|
||||
* after reading.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user