Skip to content

Commit e6a0abc

Browse files
committed
add timeline pin layout enum
1 parent 2e591e0 commit e6a0abc

File tree

1 file changed

+20
-3
lines changed
  • src/commonMain/kotlin/io/rebble/libpebblecommon/packets/blobdb

1 file changed

+20
-3
lines changed

src/commonMain/kotlin/io/rebble/libpebblecommon/packets/blobdb/Timeline.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TimelineItem(
1212
itemId: Uuid,
1313
parentId: Uuid, timestamp: UInt,
1414
duration: UShort, type: Type,
15-
flags: UShort, layout: UByte,
15+
flags: UShort, layout: Layout,
1616
attributes: List<Attribute>,
1717
actions: List<Action>
1818
) : StructMappable() {
@@ -23,12 +23,29 @@ class TimelineItem(
2323

2424
companion object {
2525
fun fromValue(value: UByte): Type {
26-
return values().firstOrNull { it.value == value }
26+
return entries.firstOrNull { it.value == value }
2727
?: error("Unknown timeline item type: $value")
2828
}
2929
}
3030
}
3131

32+
enum class Layout(val value: UByte) {
33+
GenericPin(1u),
34+
CalendarPin(2u),
35+
GenericReminder(3u),
36+
GenericNotification(4u),
37+
CommNotification(5u),
38+
WeatherPin(6u),
39+
SportsPin(7u);
40+
41+
companion object {
42+
fun fromValue(value: UByte): Layout {
43+
return entries.firstOrNull { it.value == value }
44+
?: error("Unknown timeline item layout: $value")
45+
}
46+
}
47+
}
48+
3249
val itemId = SUUID(m, itemId)
3350
val parentId = SUUID(m, parentId)
3451

@@ -52,7 +69,7 @@ class TimelineItem(
5269
*/
5370
val flags = SUShort(m, flags, endianness = '<')
5471

55-
val layout = SUByte(m, layout)
72+
val layout = SUByte(m, layout.value)
5673
val dataLength = SUShort(m, endianness = '<')
5774
val attrCount = SUByte(m, attributes.size.toUByte())
5875
val actionCount = SUByte(m, actions.size.toUByte())

0 commit comments

Comments
 (0)