Skip to content

Commit

Permalink
Add inverted support
Browse files Browse the repository at this point in the history
  • Loading branch information
Astrrra committed Jul 1, 2022
1 parent d2d494c commit ce91582
Show file tree
Hide file tree
Showing 444 changed files with 1,714 additions and 4 deletions.
12 changes: 11 additions & 1 deletion applications/desktop/animations/animation_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
#include <assets_dolphin_internal.h>
#include <assets_dolphin_blocking.h>

#include <applications/desktop/desktop_settings/desktop_settings.h>

#define ANIMATION_META_FILE "meta.txt"
#define ANIMATION_DIR "/ext/dolphin"
#define ANIMATION_DIR_INVERTED "/ext/dolphin_inverted"
#define ANIMATION_MANIFEST_FILE ANIMATION_DIR "/manifest.txt"
#define TAG "AnimationStorage"

Expand Down Expand Up @@ -295,9 +298,16 @@ static bool animation_storage_load_frames(
string_init(filename);
size_t max_filesize = ROUND_UP_TO(width, 8) * height + 1;

DesktopSettings* desktop_settings = malloc(sizeof(DesktopSettings));
LOAD_DESKTOP_SETTINGS(desktop_settings);

for(int i = 0; i < icon->frame_count; ++i) {
frames_ok = false;
string_printf(filename, ANIMATION_DIR "/%s/frame_%d.bm", name, i);
if(!desktop_settings->is_inverted) {
string_printf(filename, ANIMATION_DIR "/%s/frame_%d.bm", name, i);
} else {
string_printf(filename, ANIMATION_DIR_INVERTED "/%s/frame_%d.bm", name, i);
}

if(storage_common_stat(storage, string_get_cstr(filename), &file_info) != FSE_OK) break;
if(file_info.size > max_filesize) {
Expand Down
1 change: 1 addition & 0 deletions applications/desktop/desktop_settings/desktop_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ typedef struct {
PinCode pin_code;
uint8_t is_locked;
uint32_t auto_lock_delay_ms;
bool is_inverted;
} DesktopSettings;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#define SCENE_EVENT_SELECT_PIN_SETUP 2
#define SCENE_EVENT_SELECT_AUTO_LOCK_DELAY 3

#define INVERTED 1
#define NOT_INVERTED 0

#define AUTO_LOCK_DELAY_COUNT 6
const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = {
"OFF",
Expand All @@ -22,6 +25,14 @@ const char* const auto_lock_delay_text[AUTO_LOCK_DELAY_COUNT] = {
const uint32_t auto_lock_delay_value[AUTO_LOCK_DELAY_COUNT] =
{0, 30000, 60000, 120000, 300000, 600000};

#define INVERTED_COUNT 2
const char* const inverted_text[INVERTED_COUNT] = {
"OFF",
"ON",
};

const uint32_t inverted_value[INVERTED_COUNT] = {NOT_INVERTED, INVERTED};

static void desktop_settings_scene_start_var_list_enter_callback(void* context, uint32_t index) {
DesktopSettingsApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, index);
Expand All @@ -35,6 +46,14 @@ static void desktop_settings_scene_start_auto_lock_delay_changed(VariableItem* i
app->settings.auto_lock_delay_ms = auto_lock_delay_value[index];
}

static void desktop_settings_scene_start_inverted_changed(VariableItem* item) {
DesktopSettingsApp* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

variable_item_set_current_value_text(item, inverted_text[index]);
app->settings.is_inverted = inverted_value[index];
}

void desktop_settings_scene_start_on_enter(void* context) {
DesktopSettingsApp* app = context;
VariableItemList* variable_item_list = app->variable_item_list;
Expand All @@ -55,13 +74,23 @@ void desktop_settings_scene_start_on_enter(void* context) {
desktop_settings_scene_start_auto_lock_delay_changed,
app);

variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
value_index = value_index_uint32(
app->settings.auto_lock_delay_ms, auto_lock_delay_value, AUTO_LOCK_DELAY_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, auto_lock_delay_text[value_index]);

item = variable_item_list_add(
variable_item_list,
"Invert screen",
INVERTED_COUNT,
desktop_settings_scene_start_inverted_changed,
app);

value_index = value_index_uint32(app->settings.is_inverted, inverted_value, INVERTED_COUNT);
variable_item_set_current_value_text(item, inverted_text[value_index]);

variable_item_list_set_enter_callback(
variable_item_list, desktop_settings_scene_start_var_list_enter_callback, app);
view_dispatcher_switch_to_view(app->view_dispatcher, DesktopSettingsAppViewVarItemList);
}

Expand Down
11 changes: 11 additions & 0 deletions assets/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,17 @@ if assetsenv["IS_BASE_FIRMWARE"]:
assetsenv.AlwaysBuild(dolphin_external)
assetsenv.Alias("dolphin_ext", dolphin_external)

# Inverted dolphin animations
dolphin_external_inv = assetsenv.DolphinExtBuilder(
assetsenv.Dir("#/assets/resources/dolphin_inverted"),
assetsenv.Dir("#/assets/dolphin_inverted"),
DOLPHIN_RES_TYPE="external",
)
assetsenv.NoClean(dolphin_external_inv)
if assetsenv["FORCE"]:
assetsenv.AlwaysBuild(dolphin_external_inv)
assetsenv.Alias("dolphin_ext_inv", dolphin_external_inv)

# Resources manifest

resources = assetsenv.Command(
Expand Down
81 changes: 81 additions & 0 deletions assets/dolphin_inverted/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Dolphin assets

Dolphin assets are split into 3 parts:

- essential - Essential animations that are used for blocking system notifications. They are packed to `assets_dolphin_essential.[h,c]`.
- internal - Internal animations that are used for idle dolphin animation. Converted to `assets_dolphin_internal.[h,c]`.
- external - External animations that are used for idle dolphin animation. Packed to resource folder and placed on SD card.

# Files

- `manifest.txt` - contains animations enumeration that is used for random animation selection. Starting point for Dolphin.
- `meta.txt` - contains data that describes how animation is drawn.
- `frame_X.bm` - Flipper Compressed Bitmap.

## File manifest.txt

Flipper Format File with ordered keys.

Header:

```
Filetype: Flipper Animation Manifest
Version: 1
```

- `Name` - name of animation. Must be exact animation directory name.
- `Min butthurt`, `Max butthurt` - range of dolphin's butthurt for this animation.
- `Min level`, `Max level` - range of dolphin's level for this animation. If 0, this animation doesn't participate in random idle animation selection and can only be selected by exact name.
- `Weight` - chance of this animation to be choosen at random animation selection.

Some animations can be excluded from participation in random animation selection, such as `L1_NoSd_128x49`.

## File meta.txt

Flipper Format File with ordered keys.

Header:

```
Filetype: Flipper Animation
Version: 1
```

- `Width` - animation width in px (<= 128)
- `Height` - animation height in px (<= 64)
- `Passive frames` - number of bitmap frames for passive animation state
- `Active frames` - number of bitmap frames for active animation state (can be 0)
- `Frames order` - order of bitmap frames where first N frames are passive and following M are active. Each X number in order refers to bitmap frame, with name frame\_X.bm. This file must exist. Any X number can be repeated to refer same frame in animation.
- `Active cycles` - cycles to repeat of N active frames for full active period. E.g. if frames for active cycles are 6 and 7, and active cycles is 3, so full active period plays 6 7 6 7 6 7. Full period of passive + active period are called *total period*.
- `Frame rate` - number of frames to play for 1 second.
- `Duration` - total amount of seconds to play 1 animation.
- `Active cooldown` - amount of seconds (after passive mode) to pass before entering next active mode.

- `Bubble slots` - amount of bubble sequences.
- Any bubble sequence plays whole sequence during active mode. There can be many bubble sequences and bubbles inside it. Bubbles in 1 bubble sequence have to reside in 1 slot. Bubbles order in 1 bubble sequence is determined by occurance in file. As soon as frame index goes out of EndFrame index of bubble - next animation bubble is choosen. There can also be free of bubbles frames between 2 bubbles.

- `Slot` - number to unite bubbles for same sequence.
- `X`, `Y` - are coordinates of left top corner of bubble.
- `Text` - text in bubble. New line is `\n`
- `AlignH` - horizontal place of bubble corner (Left, Center, Right)
- `AlignV` - vertical place of bubble corner (Top, Center, Bottom)
- `StartFrame`, `EndFrame` - frame index range inside whole period to show bubble.

### Understanding of frame indexes

For example we have

```
Passive frames: 6
Active frames: 2
Frames order: 0 1 2 3 4 5 6 7
Active cycles: 4
```

Then we have indexes

```
passive(6) active (2 * 4)
Real frames order: 0 1 2 3 4 5 6 7 6 7 6 7 6 7
Frames indexes: 0 1 2 3 4 5 6 7 8 9 10 11 12 13
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/dolphin_inverted/blocking/L0_NewMail_128x51/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 51
Passive frames: 6
Active frames: 0
Frames order: 0 1 2 3 2 1
Active cycles: 0
Frame rate: 2
Duration: 0
Active cooldown: 0

Bubble slots: 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/dolphin_inverted/blocking/L0_NoDb_128x51/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 51
Passive frames: 4
Active frames: 0
Frames order: 0 1 2 3
Active cycles: 0
Frame rate: 2
Duration: 0
Active cooldown: 0

Bubble slots: 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/dolphin_inverted/blocking/L0_SdBad_128x51/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 51
Passive frames: 2
Active frames: 0
Frames order: 0 1
Active cycles: 0
Frame rate: 2
Duration: 0
Active cooldown: 0

Bubble slots: 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/dolphin_inverted/blocking/L0_SdOk_128x51/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 51
Passive frames: 4
Active frames: 0
Frames order: 0 1 2 3
Active cycles: 0
Frame rate: 2
Duration: 0
Active cooldown: 0

Bubble slots: 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/dolphin_inverted/blocking/L0_Url_128x51/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 51
Passive frames: 4
Active frames: 0
Frames order: 0 1 2 3
Active cycles: 0
Frame rate: 2
Duration: 0
Active cooldown: 0

Bubble slots: 0
42 changes: 42 additions & 0 deletions assets/dolphin_inverted/blocking/manifest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Filetype: Flipper Animation Manifest
Version: 1

# Animation 1
Name: L0_NoDb_128x51
Min butthurt: 0
Max butthurt: 0
Min level: 0
Max level: 0
Weight: 0

# Animation 2
Name: L0_SdBad_128x51
Min butthurt: 0
Max butthurt: 0
Min level: 0
Max level: 0
Weight: 0

# Animation 3
Name: L0_SdOk_128x51
Min butthurt: 0
Max butthurt: 0
Min level: 0
Max level: 0
Weight: 0

# Animation 4
Name: L0_Url_128x51
Min butthurt: 0
Max butthurt: 0
Min level: 0
Max level: 0
Weight: 0

# Animation 5
Name: L0_NewMail_128x51
Min butthurt: 0
Max butthurt: 0
Min level: 0
Max level: 0
Weight: 0
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions assets/dolphin_inverted/external/L1_Boxing_128x64/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 64
Passive frames: 9
Active frames: 7
Frames order: 0 1 2 1 3 1 2 3 1 4 5 6 5 6 5 4
Active cycles: 1
Frame rate: 2
Duration: 3600
Active cooldown: 7

Bubble slots: 2

Slot: 0
X: 78
Y: 16
Text: F*&K!!!
AlignH: Left
AlignV: Bottom
StartFrame: 2
EndFrame: 4

Slot: 1
X: 78
Y: 16
Text: What ya\nlookin at?!
AlignH: Left
AlignV: Center
StartFrame: 10
EndFrame: 15
41 changes: 41 additions & 0 deletions assets/dolphin_inverted/external/L1_Cry_128x64/meta.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Filetype: Flipper Animation
Version: 1

Width: 128
Height: 64
Passive frames: 8
Active frames: 4
Frames order: 0 1 2 3 4 2 3 4 5 6 7 6
Active cycles: 2
Frame rate: 2
Duration: 3600
Active cooldown: 7

Bubble slots: 2

Slot: 0
X: 22
Y: 40
Text: I miss you
AlignH: Right
AlignV: Bottom
StartFrame: 9
EndFrame: 11

Slot: 0
X: 17
Y: 40
Text: my friend...
AlignH: Right
AlignV: Bottom
StartFrame: 12
EndFrame: 15

Slot: 1
X: 2
Y: 29
Text: Why are you\nalways away?
AlignH: Right
AlignV: Bottom
StartFrame: 9
EndFrame: 15
Loading

0 comments on commit ce91582

Please sign in to comment.