Skip to content

Commit c13afaf

Browse files
committed
Start adapting to new screen messages
1 parent 8918551 commit c13afaf

22 files changed

+509
-181
lines changed

examples/geofence.toit

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mainLoop:
110110
throw "📟❌ Failed to turn on RTK"
111111

112112
// Subscribe to location data
113-
if not ( io.send (messages.Position.subscribe-msg --ms=500) --now=true
113+
if not ( io.send (messages.Position.subscribe-msg --interval=500) --now=true
114114
--preSend=(:: logger.info "📟💬 Sending location subscribe")
115115
--onAck=(:: logger.info "📟✅ Location subscribe")
116116
--onNack=(:: if it.msg-status != null: logger.warn "Location not yet subscribed, state: $(it.msg-status)" else: logger.warn "Location not yet subscribed" )
@@ -227,8 +227,9 @@ mainLoop:
227227
throw "Main loop exited unexpectedly"
228228

229229
drawPresetNow:
230-
presetPageMsg := messages.PresetPage.msg
231-
presetPageMsg.data.add-data-uint8 3 1 // page-id -> home page
230+
data := protocol.Data
231+
data.add-data-uint8 3 1 // page-id -> home page
232+
presetPageMsg := messages.BasePage.msg --data=data
232233
if not ( io.send presetPageMsg --now=true
233234
--preSend=(:: logger.info "📟💬 Requesting preset page")
234235
--onAck=(:: logger.info "📟✅ Preset page")

examples/modules/comms/heartbeat-handler.toit

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ import lightbug.modules.strobe.strobe show Strobe
55
import lightbug.protocol as protocol
66
import log
77

8+
main:
9+
device := devices.RtkHandheld2
10+
11+
heartbeat-handler := HeartbeatHandler --strobe=device.strobe
12+
device.comms.register-handler heartbeat-handler
13+
14+
print "Heartbeat handler registered - will show 💓 for each heartbeat"
15+
print "Device will send heartbeats automatically..."
16+
17+
while true:
18+
sleep --ms=11000
19+
print "Still listening for heartbeats... (💓 count: $(heartbeat-handler.heartbeat-count))"
20+
821
/**
922
* Example message handler that prints a heart emoji when heartbeat messages are received.
1023
* Demonstrates how to create and register a custom message handler.
@@ -19,13 +32,12 @@ class HeartbeatHandler implements MessageHandler:
1932
strobe_ = strobe
2033

2134
/**
22-
* Handle incoming messages - look for heartbeats (message type 13).
35+
* Handle incoming messages - look for heartbeats
2336
*/
2437
handle-message msg/protocol.Message -> bool:
25-
if msg.type == 13: // Heartbeat message type
38+
if msg.type == messages.Heartbeat.MT:
2639
heartbeat-count_++
2740
print "💓 Heartbeat #$heartbeat-count_ received!"
28-
logger_.debug "Heartbeat message handled"
2941
strobe_.red
3042
sleep --ms=50
3143
strobe_.off
@@ -38,15 +50,4 @@ class HeartbeatHandler implements MessageHandler:
3850
heartbeat-count -> int:
3951
return heartbeat-count_
4052

41-
main:
42-
device := devices.RtkHandheld2
43-
44-
heartbeat-handler := HeartbeatHandler --strobe=device.strobe
45-
device.comms.register-handler heartbeat-handler
46-
47-
print "Heartbeat handler registered - will show 💓 for each heartbeat"
48-
print "Device will send heartbeats automatically..."
49-
50-
while true:
51-
sleep --ms=11000
52-
print "Still listening for heartbeats... (💓 count: $(heartbeat-handler.heartbeat-count))"
53+
lineMsg:

examples/modules/eink/bitmap.toit renamed to examples/modules/eink/element-bitmap.toit

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ main:
1313

1414
print "💬 Sending bitmap logo to device screen"
1515
print "📷 Drawing 40x40 logo at (0,0)"
16-
device.comms.send (messages.DrawBitmap.msg
17-
--data=(messages.DrawBitmap.data
18-
--redraw-type=messages.DrawBitmap.REDRAW-TYPE_FULLREDRAW
16+
device.comms.send (messages.DrawElement.msg
17+
--data=(messages.DrawElement.data
18+
--page-id=(random 10 255)
19+
--status-bar-enable=false
20+
--type=messages.DrawElement.TYPE_BITMAP
1921
--x=0
2022
--y=0
2123
--width=40
2224
--height=40
2325
--bitmap=lightbug-40-40))
24-
--now=true
26+
27+
// Continue running to keep the app alive
28+
while true:
29+
sleep --ms=10000

examples/modules/eink/bitmaps.toit renamed to examples/modules/eink/element-bitmaps.toit

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,34 @@ main:
1212
device := devices.RtkHandheld2
1313

1414
print "💬 Sending bitmap logo to device screen"
15+
page := (random 10 255)
1516

1617
print "📷 Drawing 40x40 logo at (0,0) top left"
17-
device.comms.send (messages.DrawBitmap.msg
18-
--data=(messages.DrawBitmap.data
19-
--page-id=1234
20-
--redraw-type=messages.DrawBitmap.REDRAW-TYPE_FULLREDRAW
18+
device.comms.send (messages.DrawElement.msg
19+
--data=(messages.DrawElement.data
20+
--page-id=page
21+
--status-bar-enable=false
22+
--redraw-type=messages.DrawElement.REDRAW-TYPE_CLEARDONTDRAW
2123
--x=0
2224
--y=0
2325
--width=40
2426
--height=40
27+
--type=messages.DrawElement.TYPE_BITMAP
2528
--bitmap=lightbug-40-40))
26-
--now=true
2729

2830
print "📷 Drawing a second 40x40 logo at (210,0) top right"
29-
device.comms.send (messages.DrawBitmap.msg
30-
--data=(messages.DrawBitmap.data
31-
--page-id=1234
32-
--redraw-type=messages.DrawBitmap.REDRAW-TYPE_PARTIALREDRAW
31+
device.comms.send (messages.DrawElement.msg
32+
--data=(messages.DrawElement.data
33+
--page-id=page
34+
--status-bar-enable=false
35+
--redraw-type=messages.DrawElement.REDRAW-TYPE_FULLREDRAW
3336
--x=209
3437
--y=0
3538
--width=40
3639
--height=40
40+
--type=messages.DrawElement.TYPE_BITMAP
3741
--bitmap=lightbug-40-40))
38-
--now=true
42+
43+
// Continue running to keep the app alive
44+
while true:
45+
sleep --ms=10000
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import lightbug.devices as devices
2+
import lightbug.services as services
3+
import lightbug.messages.messages_gen as messages
4+
5+
// A simple application that draws a simple bit of text on the E-ink display
6+
main:
7+
// This example is setup to work with the RH2 device
8+
device := devices.RtkHandheld2
9+
10+
print "💬 Sending text to device"
11+
device.comms.send (messages.DrawElement.msg
12+
--data=(messages.DrawElement.data
13+
--page-id=(random 10 255)
14+
--status-bar-enable=false
15+
--type=messages.DrawElement.TYPE_BOX
16+
--x=0
17+
--y=0
18+
--text="Lightbug"))
19+
20+
while true:
21+
sleep --ms=10000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import lightbug.devices as devices
2+
import lightbug.services as services
3+
import lightbug.messages.messages_gen as messages
4+
5+
// A simple application that draws a simple bit of text on the E-ink display
6+
main:
7+
// This example is setup to work with the RH2 device
8+
device := devices.RtkHandheld2
9+
10+
print "💬 Sending circle to device"
11+
device.comms.send (messages.DrawElement.msg
12+
--data=(messages.DrawElement.data
13+
--page-id=(random 10 255)
14+
--status-bar-enable=false
15+
--type=messages.DrawElement.TYPE_CIRCLE
16+
--x=(250/2) - 10
17+
--y=(122/2) - 10
18+
--width=20
19+
--height=20
20+
))
21+
22+
while true:
23+
sleep --ms=10000
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import lightbug.devices as devices
2+
import lightbug.services as services
3+
import lightbug.messages.messages_gen as messages
4+
5+
// A simple application that draws a simple bit of text on the E-ink display
6+
main:
7+
// This example is setup to work with the RH2 device
8+
device := devices.RtkHandheld2
9+
10+
print "💬 Sending line to device"
11+
device.comms.send (messages.DrawElement.msg
12+
--data=(messages.DrawElement.data
13+
--page-id=(random 10 255)
14+
--status-bar-enable=false
15+
--type=messages.DrawElement.TYPE_LINE
16+
--x=0
17+
--y=(122/2)
18+
--width=250
19+
--height=0
20+
))
21+
22+
while true:
23+
sleep --ms=10000

examples/modules/eink/menu.toit

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ main:
1010
print "💬 Sending a menu to the device"
1111
device.comms.send (messages.MenuPage.msg
1212
--data=(messages.MenuPage.data
13-
// --redraw-type=messages.MenuPage.REDRAW-TYPE_FULLREDRAW
14-
--item-count=3
15-
--initial-item-selection=3
13+
--page-id=(random 10 255)
14+
--item-count=4
15+
--selected-item=3
1616
--item-1="Option 1"
1717
--item-2="Option 2"
18-
--item-3="Option 3"))
19-
--now=true
18+
--item-3="Option 3"
19+
--item-4="Option 4"))
20+
21+
while true:
22+
sleep --ms=10000

examples/modules/eink/preset.toit

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ main:
88
device := devices.RtkHandheld2
99

1010
print "💬 Sending request for home page to device"
11-
device.comms.send (messages.PresetPage.msg)
12-
--now=true
11+
device.comms.send (messages.BasePage.msg
12+
--data=(messages.BasePage.data
13+
--page-id=1
14+
--status-bar-enable=true))

examples/modules/eink/text.toit

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)