diff --git a/src/displayapp/icons/music/disc.c b/src/displayapp/icons/music/disc.c
deleted file mode 100644
index 0957873f87..0000000000
--- a/src/displayapp/icons/music/disc.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* Copyright (C) 2020 Avamander
-
- This file is part of InfiniTime.
-
- InfiniTime is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- InfiniTime is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#pragma once
-
-#include "lvgl/lvgl.h"
-
-#ifndef LV_ATTRIBUTE_MEM_ALIGN
-#define LV_ATTRIBUTE_MEM_ALIGN
-#endif
-
-#ifndef LV_ATTRIBUTE_IMG_DISC
-#define LV_ATTRIBUTE_IMG_DISC
-#endif
-
-const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_DISC uint8_t disc_map[] = {
- 0xbd, 0xc1, 0xbe, 0xff, /* Color of index 0: foreground */
- 0x00, 0x00, 0x00, 0x00, /* Color of index 1: background */
-
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xfc, 0x00, 0x00, 0x1f, 0xff, 0xff,
- 0xff, 0xff, 0xf0, 0x0f, 0xf8, 0x07, 0xff, 0xff,
- 0xff, 0xff, 0xc0, 0xff, 0xff, 0x81, 0xff, 0xff,
- 0xff, 0xff, 0x07, 0xff, 0xff, 0xf0, 0x7f, 0xff,
- 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc, 0x1f, 0xff,
- 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0x0f, 0xff,
- 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff,
- 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff,
- 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
- 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff,
- 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f,
- 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f,
- 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f,
- 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf,
- 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7,
- 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7,
- 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3,
- 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
- 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
- 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
- 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
- 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
- 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
- 0x8f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
- 0x9f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe3, 0xe3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe7, 0xf3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xe3, 0xe3, 0xff, 0xff, 0xfc,
- 0x9f, 0xff, 0xff, 0xf0, 0x07, 0xff, 0xff, 0xfc,
- 0x8f, 0xff, 0xff, 0xf8, 0x0f, 0xff, 0xff, 0xf8,
- 0x8f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf8,
- 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
- 0xcf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf9,
- 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
- 0xc7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf1,
- 0xe7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3,
- 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe3,
- 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe7,
- 0xf1, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc7,
- 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xcf,
- 0xf8, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x8f,
- 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0xfc, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f,
- 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0x3f,
- 0xff, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x7f,
- 0xff, 0x8f, 0xff, 0xff, 0xff, 0xff, 0xf8, 0xff,
- 0xff, 0xc7, 0xff, 0xff, 0xff, 0xff, 0xf1, 0xff,
- 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xe3, 0xff,
- 0xff, 0xf0, 0xff, 0xff, 0xff, 0xff, 0x87, 0xff,
- 0xff, 0xf8, 0x7f, 0xff, 0xff, 0xff, 0x0f, 0xff,
- 0xff, 0xfc, 0x1f, 0xff, 0xff, 0xfc, 0x1f, 0xff,
- 0xff, 0xff, 0x07, 0xff, 0xff, 0xf0, 0x7f, 0xff,
- 0xff, 0xff, 0xc0, 0xff, 0xff, 0x81, 0xff, 0xff,
- 0xff, 0xff, 0xf0, 0x0f, 0xf8, 0x07, 0xff, 0xff,
- 0xff, 0xff, 0xfc, 0x00, 0x00, 0x1f, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff,
-};
-
-const lv_img_dsc_t disc = {
- {
- LV_IMG_CF_INDEXED_1BIT,
- 0,
- 0,
- 64,
- 64
- },
- 520,
- disc_map
-};
\ No newline at end of file
diff --git a/src/displayapp/icons/music/disc.png b/src/displayapp/icons/music/disc.png
deleted file mode 100644
index 699734fb9c..0000000000
Binary files a/src/displayapp/icons/music/disc.png and /dev/null differ
diff --git a/src/displayapp/icons/music/disc_f_1.c b/src/displayapp/icons/music/disc_f_1.c
deleted file mode 100644
index 9b6b74177f..0000000000
--- a/src/displayapp/icons/music/disc_f_1.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright (C) 2020 Avamander
-
- This file is part of InfiniTime.
-
- InfiniTime is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- InfiniTime is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#pragma once
-
-#include "lvgl/lvgl.h"
-
-#ifndef LV_ATTRIBUTE_MEM_ALIGN
-#define LV_ATTRIBUTE_MEM_ALIGN
-#endif
-
-#ifndef LV_ATTRIBUTE_IMG_DISC_F_1
-#define LV_ATTRIBUTE_IMG_DISC_F_1
-#endif
-
-const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_DISC_F_1 uint8_t disc_f_1_map[] = {
- 0xbd, 0xc1, 0xbe, 0xff, /* Color of index 0: foreground */
- 0x00, 0x00, 0x00, 0x00, /* Color of index 1: background */
-
- 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xc0,
- 0xff, 0xff, 0xfc, 0x00,
- 0xff, 0xff, 0xf0, 0x0f,
- 0xff, 0xff, 0xc0, 0xff,
- 0xff, 0xff, 0x07, 0xff,
- 0xff, 0xfc, 0x1f, 0xff,
- 0xff, 0xf8, 0x7f, 0xff,
- 0xff, 0xf0, 0xff, 0xff,
- 0xff, 0xe3, 0xff, 0xff,
- 0xff, 0xc7, 0xf3, 0xff,
- 0xff, 0x8f, 0xc3, 0xff,
- 0xff, 0x1f, 0x87, 0xff,
- 0xfe, 0x3f, 0x0f, 0xff,
- 0xfc, 0x7e, 0x1f, 0xff,
- 0xfc, 0x7c, 0x3f, 0xff,
- 0xf8, 0xfc, 0x7f, 0xff,
- 0xf9, 0xfc, 0xff, 0xff,
- 0xf1, 0xff, 0xff, 0xff,
- 0xf3, 0xff, 0xff, 0xff,
- 0xe3, 0xff, 0xff, 0xff,
- 0xe7, 0xff, 0xff, 0xff,
- 0xc7, 0xff, 0xff, 0xff,
- 0xc7, 0xff, 0xff, 0xff,
- 0xcf, 0xff, 0xff, 0xff,
- 0xcf, 0xff, 0xff, 0xff,
- 0x8f, 0xff, 0xff, 0xff,
- 0x8f, 0xff, 0xff, 0xf8,
- 0x9f, 0xff, 0xff, 0xf0,
- 0x9f, 0xff, 0xff, 0xe3,
- 0x9f, 0xff, 0xff, 0xe7,
- 0x9f, 0xff, 0xff, 0xe7,
-};
-
-const lv_img_dsc_t disc_f_1 = {
- {
- LV_IMG_CF_INDEXED_1BIT,
- 0,
- 0,
- 32,
- 32
- },
- 136,
- disc_f_1_map
-};
-
diff --git a/src/displayapp/icons/music/disc_f_1.png b/src/displayapp/icons/music/disc_f_1.png
deleted file mode 100644
index 946577344a..0000000000
Binary files a/src/displayapp/icons/music/disc_f_1.png and /dev/null differ
diff --git a/src/displayapp/icons/music/disc_f_2.c b/src/displayapp/icons/music/disc_f_2.c
deleted file mode 100644
index 3d2331d171..0000000000
--- a/src/displayapp/icons/music/disc_f_2.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* Copyright (C) 2020 Avamander
-
- This file is part of InfiniTime.
-
- InfiniTime is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- InfiniTime is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see .
-*/
-#pragma once
-
-#include "lvgl/lvgl.h"
-
-#ifndef LV_ATTRIBUTE_MEM_ALIGN
-#define LV_ATTRIBUTE_MEM_ALIGN
-#endif
-
-#ifndef LV_ATTRIBUTE_IMG_DISC_F_2
-#define LV_ATTRIBUTE_IMG_DISC_F_2
-#endif
-
-const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_IMG_DISC_F_2 uint8_t disc_f_2_map[] = {
- 0xbd, 0xc1, 0xbe, 0xff, /* Color of index 0: foreground */
- 0x00, 0x00, 0x00, 0x00, /* Color of index 1: background */
-
- 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xc0,
- 0xff, 0xff, 0xfc, 0x00,
- 0xff, 0xff, 0xf0, 0x0f,
- 0xff, 0xff, 0xc0, 0xff,
- 0xff, 0xff, 0x07, 0xff,
- 0xff, 0xfc, 0x1f, 0xff,
- 0xff, 0xf8, 0x7f, 0xf1,
- 0xff, 0xf0, 0xff, 0x00,
- 0xff, 0xe3, 0xfc, 0x03,
- 0xff, 0xc7, 0xf0, 0x3f,
- 0xff, 0x8f, 0xf0, 0xff,
- 0xff, 0x1f, 0xf3, 0xff,
- 0xfe, 0x3f, 0xff, 0xff,
- 0xfc, 0x7f, 0xff, 0xff,
- 0xfc, 0x7f, 0xff, 0xff,
- 0xf8, 0xff, 0xff, 0xff,
- 0xf9, 0xff, 0xff, 0xff,
- 0xf1, 0xff, 0xff, 0xff,
- 0xf3, 0xff, 0xff, 0xff,
- 0xe3, 0xff, 0xff, 0xff,
- 0xe7, 0xff, 0xff, 0xff,
- 0xc7, 0xff, 0xff, 0xff,
- 0xc7, 0xff, 0xff, 0xff,
- 0xcf, 0xff, 0xff, 0xff,
- 0xcf, 0xff, 0xff, 0xff,
- 0x8f, 0xff, 0xff, 0xff,
- 0x8f, 0xff, 0xff, 0xf8,
- 0x9f, 0xff, 0xff, 0xf0,
- 0x9f, 0xff, 0xff, 0xe3,
- 0x9f, 0xff, 0xff, 0xe7,
- 0x9f, 0xff, 0xff, 0xe7,
-};
-
-const lv_img_dsc_t disc_f_2 = {
- {
- LV_IMG_CF_INDEXED_1BIT,
- 0,
- 0,
- 32,
- 32
- },
- 136,
- disc_f_2_map
-};
-
diff --git a/src/displayapp/icons/music/disc_f_2.png b/src/displayapp/icons/music/disc_f_2.png
deleted file mode 100644
index 4d9a4a388a..0000000000
Binary files a/src/displayapp/icons/music/disc_f_2.png and /dev/null differ
diff --git a/src/displayapp/screens/Music.cpp b/src/displayapp/screens/Music.cpp
index e1441460f7..3d7e896eb3 100644
--- a/src/displayapp/screens/Music.cpp
+++ b/src/displayapp/screens/Music.cpp
@@ -20,10 +20,8 @@
#include
#include "displayapp/DisplayApp.h"
#include "components/ble/MusicService.h"
-#include "displayapp/icons/music/disc.c"
-#include "displayapp/icons/music/disc_f_1.c"
-#include "displayapp/icons/music/disc_f_2.c"
#include "displayapp/InfiniTimeTheme.h"
+#include "components/ble/BleController.h"
using namespace Pinetime::Applications::Screens;
@@ -48,8 +46,8 @@ inline void lv_img_set_src_arr(lv_obj_t* img, const lv_img_dsc_t* src_img) {
*
* TODO: Investigate Apple Media Service and AVRCPv1.6 support for seamless integration
*/
-Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
- lv_obj_t* label;
+Music::Music(Pinetime::Controllers::MusicService& music, const Controllers::Ble& bleController)
+ : musicService(music), bleController {bleController} {
lv_style_init(&btn_style);
lv_style_set_radius(&btn_style, LV_STATE_DEFAULT, 20);
@@ -58,22 +56,20 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
btnVolDown = lv_btn_create(lv_scr_act(), nullptr);
btnVolDown->user_data = this;
lv_obj_set_event_cb(btnVolDown, event_handler);
- lv_obj_set_size(btnVolDown, 76, 76);
- lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 3, 0);
+ lv_obj_set_size(btnVolDown, 117, 60);
+ lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0);
lv_obj_add_style(btnVolDown, LV_STATE_DEFAULT, &btn_style);
- label = lv_label_create(btnVolDown, nullptr);
- lv_label_set_text_static(label, Symbols::volumDown);
- lv_obj_set_hidden(btnVolDown, true);
+ txtVolDown = lv_label_create(btnVolDown, nullptr);
+ lv_label_set_text_static(txtVolDown, Symbols::volumDown);
btnVolUp = lv_btn_create(lv_scr_act(), nullptr);
btnVolUp->user_data = this;
lv_obj_set_event_cb(btnVolUp, event_handler);
- lv_obj_set_size(btnVolUp, 76, 76);
- lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
+ lv_obj_set_size(btnVolUp, 117, 60);
+ lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_TOP_RIGHT, 0, 0);
lv_obj_add_style(btnVolUp, LV_STATE_DEFAULT, &btn_style);
- label = lv_label_create(btnVolUp, nullptr);
- lv_label_set_text_static(label, Symbols::volumUp);
- lv_obj_set_hidden(btnVolUp, true);
+ txtVolUp = lv_label_create(btnVolUp, nullptr);
+ lv_label_set_text_static(txtVolUp, Symbols::volumUp);
btnPrev = lv_btn_create(lv_scr_act(), nullptr);
btnPrev->user_data = this;
@@ -81,8 +77,8 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
lv_obj_set_size(btnPrev, 76, 76);
lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 3, 0);
lv_obj_add_style(btnPrev, LV_STATE_DEFAULT, &btn_style);
- label = lv_label_create(btnPrev, nullptr);
- lv_label_set_text_static(label, Symbols::stepBackward);
+ txtBtnPrev = lv_label_create(btnPrev, nullptr);
+ lv_label_set_text_static(txtBtnPrev, Symbols::stepBackward);
btnNext = lv_btn_create(lv_scr_act(), nullptr);
btnNext->user_data = this;
@@ -90,8 +86,8 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
lv_obj_set_size(btnNext, 76, 76);
lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, -3, 0);
lv_obj_add_style(btnNext, LV_STATE_DEFAULT, &btn_style);
- label = lv_label_create(btnNext, nullptr);
- lv_label_set_text_static(label, Symbols::stepForward);
+ txtBtnNext = lv_label_create(btnNext, nullptr);
+ lv_label_set_text_static(txtBtnNext, Symbols::stepForward);
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
btnPlayPause->user_data = this;
@@ -102,45 +98,63 @@ Music::Music(Pinetime::Controllers::MusicService& music) : musicService(music) {
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
lv_label_set_text_static(txtPlayPause, Symbols::play);
- txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
- lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
- lv_label_set_text_static(txtTrackDuration, "--:--/--:--");
- lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
- lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
+ buttons[0] = btnPrev;
+ buttons[1] = btnPlayPause;
+ buttons[2] = btnNext;
+ buttons[3] = btnVolDown;
+ buttons[4] = btnVolUp;
- constexpr uint8_t FONT_HEIGHT = 12;
- constexpr uint8_t LINE_PAD = 15;
- constexpr int8_t MIDDLE_OFFSET = -25;
- txtArtist = lv_label_create(lv_scr_act(), nullptr);
- lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL_CIRC);
- lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 2 * FONT_HEIGHT + LINE_PAD);
- lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
- lv_obj_set_width(txtArtist, LV_HOR_RES - 12);
- lv_label_set_text_static(txtArtist, "");
- lv_obj_set_style_local_text_color(txtArtist, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
+ controlLabels[0] = txtBtnPrev;
+ controlLabels[1] = txtPlayPause;
+ controlLabels[2] = txtBtnNext;
+ controlLabels[3] = txtVolDown;
+ controlLabels[4] = txtVolUp;
+
+ // I'm using the txtTrack label as the top anchor for the whole lot
+ // of song, artist, progress bar and duration text (0:00 and -0:00) so
+ // its much easier to move that around and mess with the buttons separately
+ constexpr int16_t BASE_Y = -40; // -45 for buttons at the top
txtTrack = lv_label_create(lv_scr_act(), nullptr);
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL_CIRC);
- lv_obj_align(txtTrack, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
+ lv_obj_align(txtTrack, nullptr, LV_ALIGN_IN_LEFT_MID, 0, BASE_Y);
lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
- lv_obj_set_width(txtTrack, LV_HOR_RES - 12);
+ lv_obj_set_width(txtTrack, LV_HOR_RES);
lv_label_set_text_static(txtTrack, "");
- pageIndicator.Create();
-
- /** Init animation */
- imgDisc = lv_img_create(lv_scr_act(), nullptr);
- lv_img_set_src_arr(imgDisc, &disc);
- lv_obj_align(imgDisc, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15, 15);
-
- imgDiscAnim = lv_img_create(lv_scr_act(), nullptr);
- lv_img_set_src_arr(imgDiscAnim, &disc_f_1);
- lv_obj_align(imgDiscAnim, nullptr, LV_ALIGN_IN_TOP_RIGHT, -15 - 32, 15);
+ txtArtist = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL_CIRC);
+ lv_obj_align(txtArtist, txtTrack, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
+ lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
+ lv_obj_set_width(txtArtist, LV_HOR_RES);
+ lv_label_set_text_static(txtArtist, "");
+ lv_obj_set_style_local_text_color(txtArtist, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
- frameB = false;
+ barTrackDuration = lv_bar_create(lv_scr_act(), nullptr);
+ lv_obj_set_style_local_bg_color(barTrackDuration, LV_BAR_PART_BG, LV_STATE_DEFAULT, Colors::bgAlt);
+ lv_obj_set_style_local_bg_color(barTrackDuration, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, Colors::lightGray);
+ lv_obj_set_style_local_bg_opa(barTrackDuration, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_OPA_100);
+ lv_obj_set_style_local_radius(barTrackDuration, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_RADIUS_CIRCLE);
+ lv_obj_set_size(barTrackDuration, 240, 10);
+ lv_obj_align(barTrackDuration, txtArtist, LV_ALIGN_OUT_BOTTOM_MID, 0, 10);
+ lv_bar_set_range(barTrackDuration, 0, 1000);
+ lv_bar_set_value(barTrackDuration, 0, LV_ANIM_OFF);
+
+ txtCurrentPosition = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(txtCurrentPosition, LV_LABEL_LONG_SROLL);
+ lv_obj_align(txtCurrentPosition, barTrackDuration, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
+ lv_label_set_text_static(txtCurrentPosition, "--:--");
+ lv_label_set_align(txtCurrentPosition, LV_ALIGN_IN_LEFT_MID);
+ lv_obj_set_width(txtCurrentPosition, LV_HOR_RES);
+ lv_obj_set_style_local_text_color(txtCurrentPosition, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
- musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
+ txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
+ lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
+ lv_obj_align(txtTrackDuration, barTrackDuration, LV_ALIGN_OUT_BOTTOM_RIGHT, -13, 0);
+ lv_label_set_text_static(txtTrackDuration, "--:--");
+ lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_RIGHT_MID);
+ lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
+ lv_obj_set_style_local_text_color(txtTrackDuration, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this);
}
@@ -152,22 +166,72 @@ Music::~Music() {
}
void Music::Refresh() {
- if (artist != musicService.getArtist()) {
- artist = musicService.getArtist();
- lv_label_set_text(txtArtist, artist.data());
+ bleState = bleController.IsConnected();
+
+ if (bleState.IsUpdated()) {
+ const bool connected = bleState.Get();
+
+ if (!connected) {
+ SetDisconnectedUI();
+ return;
+ } else {
+ musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
+ SetConnectedUI();
+ RefreshTrackInfo();
+ return;
+ }
}
- if (track != musicService.getTrack()) {
- track = musicService.getTrack();
- lv_label_set_text(txtTrack, track.data());
+ if (bleState.Get()) {
+ RefreshTrackInfo();
}
+}
- if (album != musicService.getAlbum()) {
- album = musicService.getAlbum();
+void Music::SetDisconnectedUI() {
+ lv_label_set_text_static(txtArtist, "Disconnected");
+ lv_label_set_text_static(txtTrack, "");
+
+ for (auto btn : buttons) {
+ lv_obj_set_style_local_bg_color(btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgDark);
+ }
+
+ for (auto lbl : controlLabels) {
+ lv_obj_set_style_local_text_color(lbl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
}
+ lv_label_set_text_static(txtCurrentPosition, "--:--");
+ lv_label_set_text_static(txtTrackDuration, "--:--");
+ lv_bar_set_range(barTrackDuration, 0, 1000);
+ lv_bar_set_value(barTrackDuration, 0, LV_ANIM_OFF);
+
+ artist = "";
+ track = "";
+}
+
+void Music::SetConnectedUI() {
+ for (auto btn : buttons) {
+ lv_obj_set_style_local_bg_color(btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, Colors::bgAlt);
+ }
+
+ for (auto lbl : controlLabels) {
+ lv_obj_set_style_local_text_color(lbl, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
+ }
+}
+
+void Music::RefreshTrackInfo() {
if (playing != musicService.isPlaying()) {
playing = musicService.isPlaying();
+ lv_label_set_text_static(txtPlayPause, playing ? Symbols::pause : Symbols::play);
+ }
+
+ artist = musicService.getArtist();
+ if (artist.IsUpdated()) {
+ lv_label_set_text(txtArtist, artist.Get().data());
+ }
+
+ track = musicService.getTrack();
+ if (track.IsUpdated()) {
+ lv_label_set_text(txtTrack, track.Get().data());
}
if (currentPosition != musicService.getProgress()) {
@@ -179,47 +243,27 @@ void Music::Refresh() {
totalLength = musicService.getTrackLength();
UpdateLength();
}
-
- if (playing) {
- lv_label_set_text_static(txtPlayPause, Symbols::pause);
- if (xTaskGetTickCount() - 1024 >= lastIncrement) {
-
- if (frameB) {
- lv_img_set_src(imgDiscAnim, &disc_f_1);
- } else {
- lv_img_set_src(imgDiscAnim, &disc_f_2);
- }
- frameB = !frameB;
-
- if (currentPosition >= totalLength) {
- // Let's assume the getTrack finished, paused when the timer ends
- // and there's no new getTrack being sent to us
- playing = false;
- }
- lastIncrement = xTaskGetTickCount();
- }
- } else {
- lv_label_set_text_static(txtPlayPause, Symbols::play);
- }
}
void Music::UpdateLength() {
+ int remaining = totalLength - currentPosition;
+ if (remaining < 0) {
+ remaining = 0;
+ }
+
if (totalLength > (99 * 60 * 60)) {
- lv_label_set_text_static(txtTrackDuration, "Inf/Inf");
+ lv_label_set_text_static(txtCurrentPosition, "Inf");
+ lv_label_set_text_static(txtTrackDuration, "Inf");
} else if (totalLength > (99 * 60)) {
- lv_label_set_text_fmt(txtTrackDuration,
- "%02d:%02d/%02d:%02d",
- (currentPosition / (60 * 60)) % 100,
- ((currentPosition % (60 * 60)) / 60) % 100,
- (totalLength / (60 * 60)) % 100,
- ((totalLength % (60 * 60)) / 60) % 100);
+ lv_label_set_text_fmt(txtCurrentPosition, "%d:%02d", (currentPosition / (60 * 60)) % 100, ((currentPosition % (60 * 60)) / 60) % 100);
+ lv_label_set_text_fmt(txtTrackDuration, "-%d:%02d", (remaining / (60 * 60)) % 100, ((remaining % (60 * 60)) / 60) % 100);
+ lv_bar_set_range(barTrackDuration, 0, totalLength > 0 ? totalLength : 1);
+ lv_bar_set_value(barTrackDuration, currentPosition, LV_ANIM_OFF);
} else {
- lv_label_set_text_fmt(txtTrackDuration,
- "%02d:%02d/%02d:%02d",
- (currentPosition / 60) % 100,
- (currentPosition % 60) % 100,
- (totalLength / 60) % 100,
- (totalLength % 60) % 100);
+ lv_label_set_text_fmt(txtCurrentPosition, "%d:%02d", (currentPosition / 60) % 100, (currentPosition % 60) % 100);
+ lv_label_set_text_fmt(txtTrackDuration, "-%d:%02d", (remaining / 60) % 100, (remaining % 60) % 100);
+ lv_bar_set_range(barTrackDuration, 0, totalLength > 0 ? totalLength : 1);
+ lv_bar_set_value(barTrackDuration, currentPosition, LV_ANIM_OFF);
}
}
@@ -252,25 +296,6 @@ void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event) {
bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
switch (event) {
- case TouchEvents::SwipeUp: {
- lv_obj_set_hidden(btnVolDown, false);
- lv_obj_set_hidden(btnVolUp, false);
- lv_obj_set_hidden(btnNext, true);
- lv_obj_set_hidden(btnPrev, true);
- pageIndicator.SetPageIndicatorPosition(1);
- return true;
- }
- case TouchEvents::SwipeDown: {
- if (lv_obj_get_hidden(btnNext)) {
- lv_obj_set_hidden(btnNext, false);
- lv_obj_set_hidden(btnPrev, false);
- lv_obj_set_hidden(btnVolDown, true);
- lv_obj_set_hidden(btnVolUp, true);
- pageIndicator.SetPageIndicatorPosition(0);
- return true;
- }
- return false;
- }
case TouchEvents::SwipeLeft: {
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
return true;
diff --git a/src/displayapp/screens/Music.h b/src/displayapp/screens/Music.h
index 3c371b85eb..e143bf493d 100644
--- a/src/displayapp/screens/Music.h
+++ b/src/displayapp/screens/Music.h
@@ -25,6 +25,8 @@
#include "displayapp/apps/Apps.h"
#include "displayapp/Controllers.h"
#include "Symbols.h"
+#include "components/ble/BleController.h"
+#include "utility/DirtyValue.h"
namespace Pinetime {
namespace Controllers {
@@ -35,7 +37,7 @@ namespace Pinetime {
namespace Screens {
class Music : public Screen {
public:
- Music(Pinetime::Controllers::MusicService& music);
+ Music(Pinetime::Controllers::MusicService& music, const Controllers::Ble& bleController);
~Music() override;
@@ -48,42 +50,53 @@ namespace Pinetime {
void UpdateLength();
+ void RefreshTrackInfo();
+
+ void SetDisconnectedUI();
+
+ void SetConnectedUI();
+
lv_obj_t* btnPrev;
lv_obj_t* btnPlayPause;
lv_obj_t* btnNext;
lv_obj_t* btnVolDown;
lv_obj_t* btnVolUp;
+
+ lv_obj_t* buttons[5];
+
+ lv_obj_t* txtBtnPrev;
+ lv_obj_t* txtPlayPause;
+ lv_obj_t* txtBtnNext;
+ lv_obj_t* txtVolDown;
+ lv_obj_t* txtVolUp;
+
+ lv_obj_t* controlLabels[5];
+
lv_obj_t* txtArtist;
lv_obj_t* txtTrack;
- lv_obj_t* txtPlayPause;
- lv_obj_t* imgDisc;
- lv_obj_t* imgDiscAnim;
lv_obj_t* txtTrackDuration;
+ lv_obj_t* txtCurrentPosition;
+ lv_obj_t* barTrackDuration;
lv_style_t btn_style;
- /** For the spinning disc animation */
- bool frameB;
-
Pinetime::Controllers::MusicService& musicService;
+ const Controllers::Ble& bleController;
- std::string artist;
- std::string album;
- std::string track;
+ Utility::DirtyValue artist;
+ Utility::DirtyValue track;
/** Total length in seconds */
int totalLength = 0;
/** Current position in seconds */
int currentPosition;
- /** Last time an animation update or timer was incremented */
- TickType_t lastIncrement = 0;
bool playing;
lv_task_t* taskRefresh;
- Widgets::PageIndicator pageIndicator = Widgets::PageIndicator(0, 2);
+ Utility::DirtyValue bleState {};
/** Watchapp */
};
@@ -95,7 +108,7 @@ namespace Pinetime {
static constexpr const char* icon = Screens::Symbols::music;
static Screens::Screen* Create(AppControllers& controllers) {
- return new Screens::Music(*controllers.musicService);
+ return new Screens::Music(*controllers.musicService, controllers.bleController);
};
static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {