mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +02:00
Printer: Implement flow control
Also make the print activity scrollable for dealing with long images.
This commit is contained in:
committed by
daniele
parent
0af011c929
commit
c03b229563
+15
-1
@@ -182,7 +182,7 @@ public class GenericThermalPrinterSupport extends AbstractBTLESingleDeviceSuppor
|
||||
final int cmdId = data.get();
|
||||
PrinterCommand command = PrinterCommand.fromId(cmdId);
|
||||
if (command == null) {
|
||||
LOG.error("Unkwnown incoming command{} in message: {}", cmdId, GB.hexdump(data.array()));
|
||||
LOG.error("Unknown incoming command{} in message: {}", cmdId, GB.hexdump(data.array()));
|
||||
return true;
|
||||
}
|
||||
int response = data.get();
|
||||
@@ -211,6 +211,19 @@ public class GenericThermalPrinterSupport extends AbstractBTLESingleDeviceSuppor
|
||||
LOG.debug("Incoming message: {}", GB.hexdump(data.array()));
|
||||
final ByteBuffer payloadBB = ByteBuffer.wrap(payload);
|
||||
switch (command) {
|
||||
case flowControl:
|
||||
//5178AE010100 10 70FF -> buffer full
|
||||
//5178AE010100 00 00FF -> buffer empty
|
||||
final int code = payloadBB.get();
|
||||
if (code == 0x10) {
|
||||
LOG.info("Printer buffer is full, will stop the queue");
|
||||
getQueue().setPaused(true);
|
||||
} else if (code == 0x00) {
|
||||
LOG.info("Printer buffer is empty, will resume the queue");
|
||||
getQueue().setPaused(false);
|
||||
}
|
||||
|
||||
break;
|
||||
case getDevInfo:
|
||||
if (payloadBB.get() != 0) {
|
||||
LOG.info("Setting the device supports Run Length Encoding");
|
||||
@@ -358,6 +371,7 @@ public class GenericThermalPrinterSupport extends AbstractBTLESingleDeviceSuppor
|
||||
quality(0xa4),
|
||||
printHeadSetup(0xa6), //possibly
|
||||
getDevInfo(0xa8),
|
||||
flowControl(0xae),
|
||||
intensity(0xaf),
|
||||
printSpeed(0xbd),
|
||||
printType(0xbe),
|
||||
|
||||
@@ -4,7 +4,19 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<!-- Wrap the content with a ScrollView -->
|
||||
<ScrollView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<Button
|
||||
android:id="@+id/sendToPrinterButton"
|
||||
android:layout_width="0dp"
|
||||
@@ -63,4 +75,8 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/incomingImage" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</ScrollView>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user