Skip to content

Commit 0a675d0

Browse files
committed
adding timeouts
1 parent 91e9a21 commit 0a675d0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

screen.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ namespace user_interface_base {
8181
}
8282
}
8383

84+
public static tryToSend(buf: Buffer) {
85+
let received = false;
86+
radio.onReceivedString((_: String) => {
87+
received = true;
88+
})
89+
90+
let timePassed = 0;
91+
while (!received) {
92+
if (timePassed % 99 == 0)
93+
radio.sendBuffer(buf);
94+
timePassed += 3;
95+
basic.pause(3)
96+
}
97+
}
98+
8499

85100
public static getBuffer(bitmap: Bitmap, chunkIndex: number, chunkSize: number): Buffer {
86101
const width = bitmap.width
@@ -129,9 +144,8 @@ namespace user_interface_base {
129144
// Send a chunk of the bitmap and wait for ACK, RX will rebuild the bitmap:
130145
for (let j = 0; j < numberOfChunks; j++) {
131146
const rowBuffer = this.getBuffer(bitmap, j, maxPacketBufferSize);
132-
radio.sendBuffer(rowBuffer);
133-
134-
this.waitForAck();
147+
// radio.sendBuffer(rowBuffer);
148+
this.tryToSend(rowBuffer);
135149
}
136150
this.bitmapCache.push(bitmap);
137151
}

0 commit comments

Comments
 (0)