Refactored and improved the Music watchapp
This commit is contained in:
parent
da73938f4d
commit
2b9906184b
10 changed files with 932 additions and 292 deletions
|
@ -1,68 +1,143 @@
|
||||||
|
/* Copyright (C) 2020 JF, Adam Pigg, 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include <systemtask/SystemTask.h>
|
#include <systemtask/SystemTask.h>
|
||||||
#include "MusicService.h"
|
#include "MusicService.h"
|
||||||
|
|
||||||
int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
int MSCallback(uint16_t conn_handle, uint16_t attr_handle, struct ble_gatt_access_ctxt *ctxt, void *arg) {
|
||||||
auto musicService = static_cast<Pinetime::Controllers::MusicService*>(arg);
|
auto musicService = static_cast<Pinetime::Controllers::MusicService *>(arg);
|
||||||
return musicService->OnCommand(conn_handle, attr_handle, ctxt);
|
return musicService->OnCommand(conn_handle, attr_handle, ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask &system) : m_system(system)
|
Pinetime::Controllers::MusicService::MusicService(Pinetime::System::SystemTask &system) : m_system(system) {
|
||||||
{
|
msUuid.value[11] = msId[0];
|
||||||
msUuid.value[11] = msId[0];
|
msUuid.value[12] = msId[1];
|
||||||
msUuid.value[12] = msId[1];
|
msEventCharUuid.value[11] = msEventCharId[0];
|
||||||
msEventCharUuid.value[11] = msEventCharId[0];
|
msEventCharUuid.value[12] = msEventCharId[1];
|
||||||
msEventCharUuid.value[12] = msEventCharId[1];
|
msStatusCharUuid.value[11] = msStatusCharId[0];
|
||||||
msStatusCharUuid.value[11] = msStatusCharId[0];
|
msStatusCharUuid.value[12] = msStatusCharId[1];
|
||||||
msStatusCharUuid.value[12] = msStatusCharId[1];
|
msTrackCharUuid.value[11] = msTrackCharId[0];
|
||||||
msTrackCharUuid.value[11] = msTrackCharId[0];
|
msTrackCharUuid.value[12] = msTrackCharId[1];
|
||||||
msTrackCharUuid.value[12] = msTrackCharId[1];
|
msArtistCharUuid.value[11] = msArtistCharId[0];
|
||||||
msArtistCharUuid.value[11] = msArtistCharId[0];
|
msArtistCharUuid.value[12] = msArtistCharId[1];
|
||||||
msArtistCharUuid.value[12] = msArtistCharId[1];
|
msAlbumCharUuid.value[11] = msAlbumCharId[0];
|
||||||
msAlbumCharUuid.value[11] = msAlbumCharId[0];
|
msAlbumCharUuid.value[12] = msAlbumCharId[1];
|
||||||
msAlbumCharUuid.value[12] = msAlbumCharId[1];
|
msPositionCharUuid.value[11] = msPositionCharId[0];
|
||||||
|
msPositionCharUuid.value[12] = msPositionCharId[1];
|
||||||
|
msTotalLengthCharUuid.value[11] = msTotalLengthCharId[0];
|
||||||
|
msTotalLengthCharUuid.value[12] = msTotalLengthCharId[1];
|
||||||
|
msTrackNumberCharUuid.value[11] = msTrackNumberCharId[0];
|
||||||
|
msTrackNumberCharUuid.value[12] = msTrackNumberCharId[1];
|
||||||
|
msTrackTotalCharUuid.value[11] = msTrackTotalCharId[0];
|
||||||
|
msTrackTotalCharUuid.value[12] = msTrackTotalCharId[1];
|
||||||
|
msPlaybackSpeedCharUuid.value[11] = msPlaybackSpeedCharId[0];
|
||||||
|
msPlaybackSpeedCharUuid.value[12] = msPlaybackSpeedCharId[1];
|
||||||
|
msRepeatCharUuid.value[11] = msRepeatCharId[0];
|
||||||
|
msRepeatCharUuid.value[12] = msRepeatCharId[1];
|
||||||
|
msShuffleCharUuid.value[11] = msShuffleCharId[0];
|
||||||
|
msShuffleCharUuid.value[12] = msShuffleCharId[1];
|
||||||
|
|
||||||
characteristicDefinition[0] = { .uuid = (ble_uuid_t*)(&msEventCharUuid),
|
characteristicDefinition[0] = {.uuid = (ble_uuid_t *) (&msEventCharUuid),
|
||||||
.access_cb = MSCallback,
|
.access_cb = MSCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_NOTIFY,
|
.flags = BLE_GATT_CHR_F_NOTIFY,
|
||||||
.val_handle = &m_eventHandle
|
.val_handle = &eventHandle
|
||||||
};
|
};
|
||||||
characteristicDefinition[1] = { .uuid = (ble_uuid_t*)(&msStatusCharUuid),
|
characteristicDefinition[1] = {.uuid = (ble_uuid_t *) (&msStatusCharUuid),
|
||||||
.access_cb = MSCallback,
|
.access_cb = MSCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
};
|
};
|
||||||
characteristicDefinition[2] = { .uuid = (ble_uuid_t*)(&msTrackCharUuid),
|
characteristicDefinition[2] = {.uuid = (ble_uuid_t *) (&msTrackCharUuid),
|
||||||
.access_cb = MSCallback,
|
.access_cb = MSCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
};
|
};
|
||||||
characteristicDefinition[3] = { .uuid = (ble_uuid_t*)(&msArtistCharUuid),
|
characteristicDefinition[3] = {.uuid = (ble_uuid_t *) (&msArtistCharUuid),
|
||||||
.access_cb = MSCallback,
|
.access_cb = MSCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
};
|
};
|
||||||
characteristicDefinition[4] = { .uuid = (ble_uuid_t*)(&msAlbumCharUuid),
|
characteristicDefinition[4] = {.uuid = (ble_uuid_t *) (&msAlbumCharUuid),
|
||||||
.access_cb = MSCallback,
|
.access_cb = MSCallback,
|
||||||
.arg = this,
|
.arg = this,
|
||||||
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
};
|
};
|
||||||
characteristicDefinition[5] = {0};
|
characteristicDefinition[5] = {.uuid = (ble_uuid_t *) (&msPositionCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[6] = {.uuid = (ble_uuid_t *) (&msTotalLengthCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[7] = {.uuid = (ble_uuid_t *) (&msTotalLengthCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[8] = {.uuid = (ble_uuid_t *) (&msTrackNumberCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[9] = {.uuid = (ble_uuid_t *) (&msTrackTotalCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[10] = {.uuid = (ble_uuid_t *) (&msPlaybackSpeedCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[11] = {.uuid = (ble_uuid_t *) (&msRepeatCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[12] = {.uuid = (ble_uuid_t *) (&msShuffleCharUuid),
|
||||||
|
.access_cb = MSCallback,
|
||||||
|
.arg = this,
|
||||||
|
.flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_READ
|
||||||
|
};
|
||||||
|
characteristicDefinition[13] = {0};
|
||||||
|
|
||||||
serviceDefinition[0] = {
|
serviceDefinition[0] = {
|
||||||
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
.type = BLE_GATT_SVC_TYPE_PRIMARY,
|
||||||
.uuid = (ble_uuid_t *) &msUuid,
|
.uuid = (ble_uuid_t *) &msUuid,
|
||||||
.characteristics = characteristicDefinition
|
.characteristics = characteristicDefinition
|
||||||
};
|
};
|
||||||
serviceDefinition[1] = {0};
|
serviceDefinition[1] = {0};
|
||||||
|
|
||||||
m_artist = "Waiting for";
|
artistName = "Waiting for";
|
||||||
m_album = "";
|
albumName = "";
|
||||||
m_track = "track information...";
|
trackName = "track information...";
|
||||||
|
playing = false;
|
||||||
|
repeat = false;
|
||||||
|
shuffle = false;
|
||||||
|
playbackSpeed = 1.0f;
|
||||||
|
trackProgress = 0;
|
||||||
|
trackLength = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pinetime::Controllers::MusicService::Init()
|
void Pinetime::Controllers::MusicService::Init() {
|
||||||
{
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
res = ble_gatts_count_cfg(serviceDefinition);
|
res = ble_gatts_count_cfg(serviceDefinition);
|
||||||
ASSERT(res == 0);
|
ASSERT(res == 0);
|
||||||
|
@ -72,58 +147,79 @@ void Pinetime::Controllers::MusicService::Init()
|
||||||
}
|
}
|
||||||
|
|
||||||
int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle,
|
int Pinetime::Controllers::MusicService::OnCommand(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
struct ble_gatt_access_ctxt *ctxt) {
|
struct ble_gatt_access_ctxt *ctxt) {
|
||||||
|
|
||||||
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
|
||||||
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
|
size_t notifSize = OS_MBUF_PKTLEN(ctxt->om);
|
||||||
uint8_t data[notifSize + 1];
|
uint8_t data[notifSize + 1];
|
||||||
data[notifSize] = '\0';
|
data[notifSize] = '\0';
|
||||||
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
os_mbuf_copydata(ctxt->om, 0, notifSize, data);
|
||||||
char *s = (char *) &data[0];
|
char *s = (char *) &data[0];
|
||||||
NRF_LOG_INFO("DATA : %s", s);
|
NRF_LOG_INFO("DATA : %s", s);
|
||||||
if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msArtistCharUuid) == 0) {
|
if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msArtistCharUuid) == 0) {
|
||||||
m_artist = s;
|
artistName = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msTrackCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTrackCharUuid) == 0) {
|
||||||
m_track = s;
|
trackName = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msAlbumCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msAlbumCharUuid) == 0) {
|
||||||
m_album = s;
|
albumName = s;
|
||||||
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *)&msStatusCharUuid) == 0) {
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msStatusCharUuid) == 0) {
|
||||||
m_status = s[0];
|
playing = s[0];
|
||||||
}
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msRepeatCharUuid) == 0) {
|
||||||
|
repeat = s[0];
|
||||||
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msShuffleCharUuid) == 0) {
|
||||||
|
shuffle = s[0];
|
||||||
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msPositionCharUuid) == 0) {
|
||||||
|
trackProgress = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
|
||||||
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTotalLengthCharUuid) == 0) {
|
||||||
|
trackLength = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
|
||||||
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTrackNumberCharUuid) == 0) {
|
||||||
|
trackNumber = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
|
||||||
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msTrackTotalCharUuid) == 0) {
|
||||||
|
tracksTotal = (s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3];
|
||||||
|
} else if (ble_uuid_cmp(ctxt->chr->uuid, (ble_uuid_t *) &msPlaybackSpeedCharUuid) == 0) {
|
||||||
|
playbackSpeed = static_cast<float>(((s[0] << 24) | (s[1] << 16) | (s[2] << 8) | s[3])) / 100.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Pinetime::Controllers::MusicService::album()
|
std::string Pinetime::Controllers::MusicService::getAlbum() {
|
||||||
{
|
return albumName;
|
||||||
return m_album;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Pinetime::Controllers::MusicService::artist()
|
std::string Pinetime::Controllers::MusicService::getArtist() {
|
||||||
{
|
return artistName;
|
||||||
return m_artist;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Pinetime::Controllers::MusicService::track()
|
std::string Pinetime::Controllers::MusicService::getTrack() {
|
||||||
{
|
return trackName;
|
||||||
return m_track;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char Pinetime::Controllers::MusicService::status()
|
bool Pinetime::Controllers::MusicService::isPlaying() {
|
||||||
{
|
return playing;
|
||||||
return m_status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pinetime::Controllers::MusicService::event(char event)
|
float Pinetime::Controllers::MusicService::getPlaybackSpeed() {
|
||||||
{
|
return playbackSpeed;
|
||||||
auto *om = ble_hs_mbuf_from_flat(&event, 1);
|
}
|
||||||
|
|
||||||
uint16_t connectionHandle = m_system.nimble().connHandle();
|
void Pinetime::Controllers::MusicService::event(char event) {
|
||||||
|
auto *om = ble_hs_mbuf_from_flat(&event, 1);
|
||||||
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
|
||||||
return;
|
uint16_t connectionHandle = m_system.nimble().connHandle();
|
||||||
}
|
|
||||||
|
if (connectionHandle == 0 || connectionHandle == BLE_HS_CONN_HANDLE_NONE) {
|
||||||
ble_gattc_notify_custom(connectionHandle, m_eventHandle, om);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ble_gattc_notify_custom(connectionHandle, eventHandle, om);
|
||||||
|
}
|
||||||
|
|
||||||
|
int Pinetime::Controllers::MusicService::getProgress() {
|
||||||
|
return trackProgress;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Pinetime::Controllers::MusicService::getTrackLength() {
|
||||||
|
return trackLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,20 @@
|
||||||
|
/* Copyright (C) 2020 JF, Adam Pigg, 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -16,76 +33,133 @@ namespace Pinetime {
|
||||||
namespace Controllers {
|
namespace Controllers {
|
||||||
|
|
||||||
class MusicService {
|
class MusicService {
|
||||||
public:
|
public:
|
||||||
MusicService(Pinetime::System::SystemTask &system);
|
explicit MusicService(Pinetime::System::SystemTask &system);
|
||||||
void Init();
|
|
||||||
int OnCommand(uint16_t conn_handle, uint16_t attr_handle,
|
|
||||||
struct ble_gatt_access_ctxt *ctxt);
|
|
||||||
|
|
||||||
std::string artist();
|
void Init();
|
||||||
std::string track();
|
|
||||||
std::string album();
|
|
||||||
unsigned char status();
|
|
||||||
|
|
||||||
void event(char event);
|
int OnCommand(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
|
struct ble_gatt_access_ctxt *ctxt);
|
||||||
|
|
||||||
static const char EVENT_MUSIC_OPEN = 0xe0;
|
void event(char event);
|
||||||
static const char EVENT_MUSIC_PLAY = 0x00;
|
|
||||||
static const char EVENT_MUSIC_PAUSE = 0x01;
|
|
||||||
static const char EVENT_MUSIC_NEXT = 0x03;
|
|
||||||
static const char EVENT_MUSIC_PREV = 0x04;
|
|
||||||
static const char EVENT_MUSIC_VOLUP = 0x05;
|
|
||||||
static const char EVENT_MUSIC_VOLDOWN = 0x06;
|
|
||||||
static const char STATUS_MUSIC_PAUSED = 0x00;
|
|
||||||
static const char STATUS_MUSIC_PLAYING = 0x01;
|
|
||||||
|
|
||||||
private:
|
std::string getArtist();
|
||||||
static constexpr uint8_t msId[2] = {0x00, 0x01};
|
|
||||||
static constexpr uint8_t msEventCharId[2] = {0x00, 0x02};
|
|
||||||
static constexpr uint8_t msStatusCharId[2] = {0x00, 0x03};
|
|
||||||
static constexpr uint8_t msArtistCharId[2] = {0x00, 0x04};
|
|
||||||
static constexpr uint8_t msTrackCharId[2] = {0x00, 0x05};
|
|
||||||
static constexpr uint8_t msAlbumCharId[2] = {0x00, 0x06};
|
|
||||||
|
|
||||||
ble_uuid128_t msUuid {
|
std::string getTrack();
|
||||||
.u = { .type = BLE_UUID_TYPE_128 },
|
|
||||||
.value = MUSIC_SERVICE_UUID_BASE
|
|
||||||
};
|
|
||||||
|
|
||||||
ble_uuid128_t msEventCharUuid {
|
std::string getAlbum();
|
||||||
.u = { .type = BLE_UUID_TYPE_128 },
|
|
||||||
.value = MUSIC_SERVICE_UUID_BASE
|
|
||||||
};
|
|
||||||
ble_uuid128_t msStatusCharUuid {
|
|
||||||
.u = { .type = BLE_UUID_TYPE_128 },
|
|
||||||
.value = MUSIC_SERVICE_UUID_BASE
|
|
||||||
};
|
|
||||||
ble_uuid128_t msArtistCharUuid {
|
|
||||||
.u = { .type = BLE_UUID_TYPE_128 },
|
|
||||||
.value = MUSIC_SERVICE_UUID_BASE
|
|
||||||
};
|
|
||||||
ble_uuid128_t msTrackCharUuid {
|
|
||||||
.u = { .type = BLE_UUID_TYPE_128 },
|
|
||||||
.value = MUSIC_SERVICE_UUID_BASE
|
|
||||||
};
|
|
||||||
ble_uuid128_t msAlbumCharUuid {
|
|
||||||
.u = { .type = BLE_UUID_TYPE_128 },
|
|
||||||
.value = MUSIC_SERVICE_UUID_BASE
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ble_gatt_chr_def characteristicDefinition[6];
|
int getProgress();
|
||||||
struct ble_gatt_svc_def serviceDefinition[2];
|
|
||||||
|
|
||||||
uint16_t m_eventHandle;
|
int getTrackLength();
|
||||||
|
|
||||||
std::string m_artist;
|
float getPlaybackSpeed();
|
||||||
std::string m_album;
|
|
||||||
std::string m_track;
|
|
||||||
|
|
||||||
unsigned char m_status;
|
bool isPlaying();
|
||||||
|
|
||||||
Pinetime::System::SystemTask& m_system;
|
static const char EVENT_MUSIC_OPEN = 0xe0;
|
||||||
|
static const char EVENT_MUSIC_PLAY = 0x00;
|
||||||
|
static const char EVENT_MUSIC_PAUSE = 0x01;
|
||||||
|
static const char EVENT_MUSIC_NEXT = 0x03;
|
||||||
|
static const char EVENT_MUSIC_PREV = 0x04;
|
||||||
|
static const char EVENT_MUSIC_VOLUP = 0x05;
|
||||||
|
static const char EVENT_MUSIC_VOLDOWN = 0x06;
|
||||||
|
|
||||||
|
enum MusicStatus {
|
||||||
|
NOT_PLAYING = 0x00,
|
||||||
|
PLAYING = 0x01
|
||||||
|
};
|
||||||
|
private:
|
||||||
|
static constexpr uint8_t msId[2] = {0x00, 0x01};
|
||||||
|
static constexpr uint8_t msEventCharId[2] = {0x00, 0x02};
|
||||||
|
static constexpr uint8_t msStatusCharId[2] = {0x00, 0x03};
|
||||||
|
static constexpr uint8_t msArtistCharId[2] = {0x00, 0x04};
|
||||||
|
static constexpr uint8_t msTrackCharId[2] = {0x00, 0x05};
|
||||||
|
static constexpr uint8_t msAlbumCharId[2] = {0x00, 0x06};
|
||||||
|
static constexpr uint8_t msPositionCharId[2] = {0x00, 0x07};
|
||||||
|
static constexpr uint8_t msTotalLengthCharId[2] = {0x00, 0x08};
|
||||||
|
static constexpr uint8_t msTrackNumberCharId[2] = {0x00, 0x09};
|
||||||
|
static constexpr uint8_t msTrackTotalCharId[2] = {0x00, 0x0a};
|
||||||
|
static constexpr uint8_t msPlaybackSpeedCharId[2] = {0x00, 0x0b};
|
||||||
|
static constexpr uint8_t msRepeatCharId[2] = {0x00, 0x0c};
|
||||||
|
static constexpr uint8_t msShuffleCharId[2] = {0x00, 0x0d};
|
||||||
|
|
||||||
|
ble_uuid128_t msUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
|
||||||
|
ble_uuid128_t msEventCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msStatusCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msArtistCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msTrackCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msAlbumCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msPositionCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msTotalLengthCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msTrackNumberCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msTrackTotalCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msPlaybackSpeedCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msRepeatCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
ble_uuid128_t msShuffleCharUuid{
|
||||||
|
.u = {.type = BLE_UUID_TYPE_128},
|
||||||
|
.value = MUSIC_SERVICE_UUID_BASE
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ble_gatt_chr_def characteristicDefinition[14];
|
||||||
|
struct ble_gatt_svc_def serviceDefinition[2];
|
||||||
|
|
||||||
|
uint16_t eventHandle;
|
||||||
|
|
||||||
|
std::string artistName;
|
||||||
|
std::string albumName;
|
||||||
|
std::string trackName;
|
||||||
|
|
||||||
|
bool playing;
|
||||||
|
|
||||||
|
int trackProgress;
|
||||||
|
int trackLength;
|
||||||
|
int trackNumber;
|
||||||
|
int tracksTotal;
|
||||||
|
|
||||||
|
float playbackSpeed;
|
||||||
|
|
||||||
|
bool repeat;
|
||||||
|
bool shuffle;
|
||||||
|
|
||||||
|
Pinetime::System::SystemTask &m_system;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
110
src/displayapp/icons/music/disc.cpp
Normal file
110
src/displayapp/icons/music/disc.cpp
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#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
|
||||||
|
};
|
BIN
src/displayapp/icons/music/disc.png
Normal file
BIN
src/displayapp/icons/music/disc.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 516 B |
79
src/displayapp/icons/music/disc_f_1.cpp
Normal file
79
src/displayapp/icons/music/disc_f_1.cpp
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#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
|
||||||
|
};
|
||||||
|
|
BIN
src/displayapp/icons/music/disc_f_1.png
Normal file
BIN
src/displayapp/icons/music/disc_f_1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 200 B |
79
src/displayapp/icons/music/disc_f_2.cpp
Normal file
79
src/displayapp/icons/music/disc_f_2.cpp
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
/* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
#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
|
||||||
|
};
|
||||||
|
|
BIN
src/displayapp/icons/music/disc_f_2.png
Normal file
BIN
src/displayapp/icons/music/disc_f_2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 197 B |
|
@ -1,72 +1,120 @@
|
||||||
|
/* Copyright (C) 2020 JF, Adam Pigg, 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#include <libs/lvgl/lvgl.h>
|
#include <libs/lvgl/lvgl.h>
|
||||||
|
|
||||||
#include "Music.h"
|
#include "Music.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
extern lv_font_t jetbrains_mono_extrabold_compressed;
|
extern lv_font_t jetbrains_mono_extrabold_compressed;
|
||||||
extern lv_font_t jetbrains_mono_bold_20;
|
extern lv_font_t jetbrains_mono_bold_20;
|
||||||
|
|
||||||
static void event_handler(lv_obj_t * obj, lv_event_t event)
|
static void event_handler(lv_obj_t *obj, lv_event_t event) {
|
||||||
{
|
Music *screen = static_cast<Music *>(obj->user_data);
|
||||||
Music* screen = static_cast<Music *>(obj->user_data);
|
|
||||||
screen->OnObjectEvent(obj, event);
|
screen->OnObjectEvent(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Music control watchapp
|
||||||
|
*
|
||||||
|
* TODO: Investigate Apple Media Service and AVRCPv1.6 support for seamless integration
|
||||||
|
*/
|
||||||
Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::MusicService &music) : Screen(app), musicService(music) {
|
Music::Music(Pinetime::Applications::DisplayApp *app, Pinetime::Controllers::MusicService &music) : Screen(app), musicService(music) {
|
||||||
lv_obj_t * label;
|
lv_obj_t *label;
|
||||||
|
|
||||||
btnVolDown = lv_btn_create(lv_scr_act(), NULL);
|
btnVolDown = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnVolDown->user_data = this;
|
btnVolDown->user_data = this;
|
||||||
lv_obj_set_event_cb(btnVolDown, event_handler);
|
lv_obj_set_event_cb(btnVolDown, event_handler);
|
||||||
lv_obj_align(btnVolDown, NULL, LV_ALIGN_IN_TOP_LEFT, 10, 10);
|
lv_obj_set_size(btnVolDown, LV_HOR_RES / 3, 80);
|
||||||
label = lv_label_create(btnVolDown, NULL);
|
lv_obj_align(btnVolDown, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||||
lv_label_set_text(label, "v-");
|
label = lv_label_create(btnVolDown, nullptr);
|
||||||
|
lv_label_set_text(label, "V-");
|
||||||
|
lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
|
||||||
|
|
||||||
btnVolUp = lv_btn_create(lv_scr_act(), NULL);
|
btnVolUp = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnVolUp->user_data = this;
|
btnVolUp->user_data = this;
|
||||||
lv_obj_set_event_cb(btnVolUp, event_handler);
|
lv_obj_set_event_cb(btnVolUp, event_handler);
|
||||||
lv_obj_align(btnVolUp, NULL, LV_ALIGN_IN_TOP_RIGHT, -10, 10);
|
lv_obj_set_size(btnVolUp, LV_HOR_RES / 3, 80);
|
||||||
label = lv_label_create(btnVolUp, NULL);
|
lv_obj_align(btnVolUp, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||||
lv_label_set_text(label, "v+");
|
label = lv_label_create(btnVolUp, nullptr);
|
||||||
|
lv_label_set_text(label, "V+");
|
||||||
|
lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
|
||||||
|
|
||||||
btnPrev = lv_btn_create(lv_scr_act(), NULL);
|
btnPrev = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnPrev->user_data = this;
|
btnPrev->user_data = this;
|
||||||
lv_obj_set_event_cb(btnPrev, event_handler);
|
lv_obj_set_event_cb(btnPrev, event_handler);
|
||||||
lv_obj_set_size(btnPrev, LV_HOR_RES / 4, LV_VER_RES / 4);
|
lv_obj_set_size(btnPrev, LV_HOR_RES / 3, 80);
|
||||||
lv_obj_align(btnPrev, NULL, LV_ALIGN_IN_BOTTOM_LEFT, 10,-10);
|
lv_obj_align(btnPrev, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0);
|
||||||
label = lv_label_create(btnPrev, NULL);
|
label = lv_label_create(btnPrev, nullptr);
|
||||||
lv_label_set_text(label, "<<");
|
lv_label_set_text(label, "<<");
|
||||||
|
|
||||||
btnPlayPause = lv_btn_create(lv_scr_act(), NULL);
|
btnNext = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnPlayPause->user_data = this;
|
btnNext->user_data = this;
|
||||||
lv_obj_set_event_cb(btnPlayPause, event_handler);
|
lv_obj_set_event_cb(btnNext, event_handler);
|
||||||
lv_obj_set_size(btnPlayPause, LV_HOR_RES / 4, LV_VER_RES / 4);
|
lv_obj_set_size(btnNext, LV_HOR_RES / 3, 80);
|
||||||
lv_obj_align(btnPlayPause, NULL, LV_ALIGN_IN_BOTTOM_MID, 0,-10);
|
lv_obj_align(btnNext, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0);
|
||||||
txtPlayPause = lv_label_create(btnPlayPause, NULL);
|
label = lv_label_create(btnNext, nullptr);
|
||||||
lv_label_set_text(txtPlayPause, ">");
|
lv_label_set_text(label, ">>");
|
||||||
|
|
||||||
btnNext = lv_btn_create(lv_scr_act(), NULL);
|
btnPlayPause = lv_btn_create(lv_scr_act(), nullptr);
|
||||||
btnNext->user_data = this;
|
btnPlayPause->user_data = this;
|
||||||
lv_obj_set_event_cb(btnNext, event_handler);
|
lv_obj_set_event_cb(btnPlayPause, event_handler);
|
||||||
lv_obj_set_size(btnNext, LV_HOR_RES / 4, LV_VER_RES / 4);
|
lv_obj_set_size(btnPlayPause, LV_HOR_RES / 3, 80);
|
||||||
lv_obj_align(btnNext, NULL, LV_ALIGN_IN_BOTTOM_RIGHT, -10,-10);
|
lv_obj_align(btnPlayPause, nullptr, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
|
||||||
label = lv_label_create(btnNext, NULL);
|
txtPlayPause = lv_label_create(btnPlayPause, nullptr);
|
||||||
lv_label_set_text(label, ">>");
|
lv_label_set_text(txtPlayPause, ">");
|
||||||
|
|
||||||
txtArtist = lv_label_create(lv_scr_act(), NULL);
|
txtTrackDuration = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL);
|
lv_label_set_long_mode(txtTrackDuration, LV_LABEL_LONG_SROLL);
|
||||||
lv_obj_align(txtArtist, NULL, LV_ALIGN_IN_LEFT_MID, 0,-20);
|
lv_obj_align(txtTrackDuration, nullptr, LV_ALIGN_IN_TOP_LEFT, 12, 20);
|
||||||
lv_label_set_text(txtArtist, "Artist Name");
|
lv_label_set_text(txtTrackDuration, "--:--/--:--");
|
||||||
lv_label_set_align(txtArtist, LV_LABEL_ALIGN_CENTER);
|
lv_label_set_align(txtTrackDuration, LV_ALIGN_IN_LEFT_MID);
|
||||||
lv_obj_set_width(txtArtist, LV_HOR_RES);
|
lv_obj_set_width(txtTrackDuration, LV_HOR_RES);
|
||||||
|
|
||||||
txtTrack = lv_label_create(lv_scr_act(), NULL);
|
#define FONT_HEIGHT (12)
|
||||||
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_DOT);
|
#define MIDDLE_OFFSET (-25)
|
||||||
lv_obj_align(txtTrack, NULL, LV_ALIGN_IN_LEFT_MID, 0,20);
|
#define LINE_PAD (15)
|
||||||
lv_label_set_text(txtTrack, "This is a very long track name");
|
txtArtist = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_align(txtTrack, LV_LABEL_ALIGN_CENTER);
|
lv_label_set_long_mode(txtArtist, LV_LABEL_LONG_SROLL);
|
||||||
lv_obj_set_width(txtTrack, LV_HOR_RES);
|
lv_obj_align(txtArtist, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 1 * FONT_HEIGHT);
|
||||||
|
lv_label_set_text(txtArtist, "Artist Name");
|
||||||
|
lv_label_set_align(txtArtist, LV_ALIGN_IN_LEFT_MID);
|
||||||
|
lv_obj_set_width(txtArtist, LV_HOR_RES);
|
||||||
|
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
|
txtTrack = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
lv_label_set_long_mode(txtTrack, LV_LABEL_LONG_SROLL);
|
||||||
|
lv_obj_align(txtTrack, nullptr, LV_ALIGN_IN_LEFT_MID, 12, MIDDLE_OFFSET + 2 * FONT_HEIGHT + LINE_PAD);
|
||||||
|
lv_label_set_text(txtTrack, "This is a very long getTrack name");
|
||||||
|
lv_label_set_align(txtTrack, LV_ALIGN_IN_LEFT_MID);
|
||||||
|
lv_obj_set_width(txtTrack, LV_HOR_RES);
|
||||||
|
|
||||||
|
/** 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);
|
||||||
|
|
||||||
|
frameB = false;
|
||||||
|
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
Music::~Music() {
|
Music::~Music() {
|
||||||
|
@ -79,47 +127,155 @@ bool Music::OnButtonPushed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Music::Refresh() {
|
bool Music::Refresh() {
|
||||||
|
if (artist != musicService.getArtist()) {
|
||||||
|
artist = musicService.getArtist();
|
||||||
|
currentLength = 0;
|
||||||
|
lv_label_set_text(txtArtist, artist.data());
|
||||||
|
}
|
||||||
|
|
||||||
if (m_artist != musicService.artist()) {
|
if (track != musicService.getTrack()) {
|
||||||
m_artist = musicService.artist();
|
track = musicService.getTrack();
|
||||||
lv_label_set_text(txtArtist, m_artist.data());
|
currentLength = 0;
|
||||||
}
|
lv_label_set_text(txtTrack, track.data());
|
||||||
if (m_track != musicService.track()) {
|
}
|
||||||
m_track = musicService.track();
|
|
||||||
lv_label_set_text(txtTrack, m_track.data());
|
if (album != musicService.getAlbum()) {
|
||||||
}
|
album = musicService.getAlbum();
|
||||||
if (m_album != musicService.album()) {
|
currentLength = 0;
|
||||||
m_album = musicService.album();
|
}
|
||||||
}
|
|
||||||
if (m_status != musicService.status()) {
|
if (playing != musicService.isPlaying()) {
|
||||||
m_status = musicService.status();
|
playing = musicService.isPlaying();
|
||||||
}
|
}
|
||||||
if (m_status == Pinetime::Controllers::MusicService::STATUS_MUSIC_PLAYING) {
|
|
||||||
lv_label_set_text(txtPlayPause, "||");
|
// Because we increment this ourselves,
|
||||||
} else {
|
// we can't compare with the old data directly
|
||||||
lv_label_set_text(txtPlayPause, ">");
|
// have to update it when there's actually new data
|
||||||
|
// just to avoid unnecessary draws that make UI choppy
|
||||||
|
if (lastLength != musicService.getProgress()) {
|
||||||
|
currentLength = musicService.getProgress();
|
||||||
|
lastLength = currentLength;
|
||||||
|
UpdateLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalLength != musicService.getTrackLength()) {
|
||||||
|
totalLength = musicService.getTrackLength();
|
||||||
|
UpdateLength();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playing == Pinetime::Controllers::MusicService::MusicStatus::PLAYING) {
|
||||||
|
lv_label_set_text(txtPlayPause, "||");
|
||||||
|
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 (currentLength < totalLength) {
|
||||||
|
currentLength += static_cast<int>((static_cast<float>(xTaskGetTickCount() - lastIncrement) / 1024.0f) *
|
||||||
|
musicService.getPlaybackSpeed());
|
||||||
|
} else {
|
||||||
|
// Let's assume the getTrack finished, paused when the timer ends
|
||||||
|
// and there's no new getTrack being sent to us
|
||||||
|
// TODO: ideally this would be configurable
|
||||||
|
playing = false;
|
||||||
|
}
|
||||||
|
lastIncrement = xTaskGetTickCount();
|
||||||
|
|
||||||
|
UpdateLength();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
lv_label_set_text(txtPlayPause, ">");
|
||||||
|
}
|
||||||
|
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Music::OnObjectEvent(lv_obj_t* obj, lv_event_t event)
|
void Music::UpdateLength() {
|
||||||
{
|
if (totalLength > (99 * 60 * 60)) {
|
||||||
if (event == LV_EVENT_CLICKED) {
|
lv_label_set_text(txtTrackDuration, "Inf/Inf");
|
||||||
if (obj == btnVolDown) {
|
} else if (totalLength > (99 * 60)) {
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLDOWN);
|
char timer[12];
|
||||||
} else if (obj == btnVolUp) {
|
sprintf(timer, "%02d:%02d/%02d:%02d",
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLUP);
|
(currentLength / (60 * 60)) % 100,
|
||||||
} else if (obj == btnPrev) {
|
((currentLength % (60 * 60)) / 60) % 100,
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
|
(totalLength / (60 * 60)) % 100,
|
||||||
} else if (obj == btnPlayPause) {
|
((totalLength % (60 * 60)) / 60) % 100
|
||||||
if (m_status == Pinetime::Controllers::MusicService::STATUS_MUSIC_PLAYING) {
|
);
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_PAUSE);
|
lv_label_set_text(txtTrackDuration, timer);
|
||||||
} else {
|
} else {
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_PLAY);
|
char timer[12];
|
||||||
}
|
sprintf(timer, "%02d:%02d/%02d:%02d",
|
||||||
} else if (obj == btnNext) {
|
(currentLength / 60) % 100,
|
||||||
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
|
(currentLength % 60) % 100,
|
||||||
}
|
(totalLength / 60) % 100,
|
||||||
}
|
(totalLength % 60) % 100
|
||||||
|
);
|
||||||
|
lv_label_set_text(txtTrackDuration, timer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Music::OnObjectEvent(lv_obj_t *obj, lv_event_t event) {
|
||||||
|
if (event == LV_EVENT_CLICKED) {
|
||||||
|
if (obj == btnVolDown) {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLDOWN);
|
||||||
|
} else if (obj == btnVolUp) {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_VOLUP);
|
||||||
|
} else if (obj == btnPrev) {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
|
||||||
|
} else if (obj == btnPlayPause) {
|
||||||
|
if (playing == Pinetime::Controllers::MusicService::MusicStatus::PLAYING) {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_PAUSE);
|
||||||
|
|
||||||
|
// Let's assume it stops playing instantly
|
||||||
|
playing = Controllers::MusicService::NOT_PLAYING;
|
||||||
|
} else {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_PLAY);
|
||||||
|
|
||||||
|
// Let's assume it starts playing instantly
|
||||||
|
// TODO: In the future should check for BT connection for better UX
|
||||||
|
playing = Controllers::MusicService::PLAYING;
|
||||||
|
}
|
||||||
|
} else if (obj == btnNext) {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Music::OnTouchEvent(Pinetime::Applications::TouchEvents event) {
|
||||||
|
switch (event) {
|
||||||
|
case TouchEvents::SwipeUp: {
|
||||||
|
displayVolumeButtons = true;
|
||||||
|
lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
|
||||||
|
lv_obj_set_hidden(btnVolUp, !displayVolumeButtons);
|
||||||
|
|
||||||
|
lv_obj_set_hidden(btnNext, displayVolumeButtons);
|
||||||
|
lv_obj_set_hidden(btnPrev, displayVolumeButtons);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case TouchEvents::SwipeDown: {
|
||||||
|
displayVolumeButtons = false;
|
||||||
|
lv_obj_set_hidden(btnNext, displayVolumeButtons);
|
||||||
|
lv_obj_set_hidden(btnPrev, displayVolumeButtons);
|
||||||
|
|
||||||
|
lv_obj_set_hidden(btnVolDown, !displayVolumeButtons);
|
||||||
|
lv_obj_set_hidden(btnVolUp, !displayVolumeButtons);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case TouchEvents::SwipeLeft: {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_NEXT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case TouchEvents::SwipeRight: {
|
||||||
|
musicService.event(Controllers::MusicService::EVENT_MUSIC_PREV);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,20 @@
|
||||||
|
/* Copyright (C) 2020 JF, Adam Pigg, 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -13,37 +30,66 @@
|
||||||
#include <libs/lvgl/src/lv_core/lv_style.h>
|
#include <libs/lvgl/src/lv_core/lv_style.h>
|
||||||
#include <libs/lvgl/src/lv_core/lv_obj.h>
|
#include <libs/lvgl/src/lv_core/lv_obj.h>
|
||||||
#include "../../Version.h"
|
#include "../../Version.h"
|
||||||
|
#include "displayapp/icons/music/disc.cpp"
|
||||||
|
#include "displayapp/icons/music/disc_f_1.cpp"
|
||||||
|
#include "displayapp/icons/music/disc_f_2.cpp"
|
||||||
|
|
||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
|
class Music : public Screen {
|
||||||
|
public:
|
||||||
|
Music(DisplayApp *app, Pinetime::Controllers::MusicService &music);
|
||||||
|
|
||||||
class Music : public Screen{
|
~Music() override;
|
||||||
public:
|
|
||||||
Music(DisplayApp* app, Pinetime::Controllers::MusicService &music);
|
|
||||||
~Music() override;
|
|
||||||
|
|
||||||
bool Refresh() override;
|
bool Refresh() override;
|
||||||
bool OnButtonPushed() override;
|
|
||||||
|
|
||||||
void OnObjectEvent(lv_obj_t* obj, lv_event_t event);
|
bool OnButtonPushed() override;
|
||||||
|
|
||||||
private:
|
void OnObjectEvent(lv_obj_t *obj, lv_event_t event);
|
||||||
lv_obj_t * btnPrev;
|
|
||||||
lv_obj_t * btnPlayPause;
|
|
||||||
lv_obj_t * btnNext;
|
|
||||||
lv_obj_t * btnVolDown;
|
|
||||||
lv_obj_t * btnVolUp;
|
|
||||||
lv_obj_t * txtArtist;
|
|
||||||
lv_obj_t * txtTrack;
|
|
||||||
lv_obj_t * txtPlayPause;
|
|
||||||
|
|
||||||
bool running = true;
|
private:
|
||||||
Pinetime::Controllers::MusicService &musicService;
|
bool OnTouchEvent(TouchEvents event);
|
||||||
std::string m_artist;
|
|
||||||
std::string m_album;
|
void UpdateLength();
|
||||||
std::string m_track;
|
|
||||||
unsigned char m_status;
|
lv_obj_t *btnPrev;
|
||||||
|
lv_obj_t *btnPlayPause;
|
||||||
|
lv_obj_t *btnNext;
|
||||||
|
lv_obj_t *btnVolDown;
|
||||||
|
lv_obj_t *btnVolUp;
|
||||||
|
lv_obj_t *txtArtist;
|
||||||
|
lv_obj_t *txtTrack;
|
||||||
|
lv_obj_t *txtPlayPause;
|
||||||
|
|
||||||
|
lv_obj_t *imgDisc;
|
||||||
|
lv_obj_t *imgDiscAnim;
|
||||||
|
lv_obj_t *txtTrackDuration;
|
||||||
|
|
||||||
|
/** For the spinning disc animation */
|
||||||
|
bool frameB;
|
||||||
|
|
||||||
|
bool displayVolumeButtons = false;
|
||||||
|
Pinetime::Controllers::MusicService &musicService;
|
||||||
|
|
||||||
|
std::string artist;
|
||||||
|
std::string album;
|
||||||
|
std::string track;
|
||||||
|
|
||||||
|
/** Total length in seconds */
|
||||||
|
int totalLength;
|
||||||
|
/** Current length in seconds */
|
||||||
|
int currentLength;
|
||||||
|
/** Last length */
|
||||||
|
int lastLength;
|
||||||
|
/** Last time an animation update or timer was incremented */
|
||||||
|
TickType_t lastIncrement;
|
||||||
|
|
||||||
|
bool playing;
|
||||||
|
|
||||||
|
/** Watchapp */
|
||||||
|
bool running = true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue