add logo, do more aggressive batching
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 442 B After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 3.7 KiB |
|
@ -45,6 +45,7 @@ class MyHomePage extends StatefulWidget {
|
|||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
final _barcodeScanner = BarcodeScanner(formats: [BarcodeFormat.qrCode]);
|
||||
// late final AnalysisController _scannerController;
|
||||
final _rxTextController = BehaviorSubject<String>();
|
||||
late final Stream<String> _rxTextStream = _rxTextController.stream;
|
||||
|
||||
|
@ -53,6 +54,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
final HashSet<RaptorPacket> _rxData = HashSet();
|
||||
String _rxText = '';
|
||||
int _rxCount = 1;
|
||||
int _bSize = 0;
|
||||
|
||||
final _formatter = NumberFormat('###,###,###');
|
||||
|
||||
|
@ -66,18 +68,19 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CameraAwesomeBuilder.previewOnly(
|
||||
zoom: 1.5,
|
||||
onImageForAnalysis: (img) => _processImageBarcode(img),
|
||||
imageAnalysisConfig: AnalysisConfig(
|
||||
androidOptions: const AndroidAnalysisOptions.nv21(
|
||||
width: 600,
|
||||
),
|
||||
maxFramesPerSecond: 20,
|
||||
autoStart: false,
|
||||
autoStart: true,
|
||||
),
|
||||
builder: (cameraModeState, previewSize, previewRect) {
|
||||
//_scannerController = cameraModeState.analysisController!;
|
||||
return _RxTextDisplayWidget(
|
||||
rxTextStream: _rxTextStream,
|
||||
analysisController: cameraModeState.analysisController!,
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -124,16 +127,28 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
|
||||
case CuttleState.receiving:
|
||||
{
|
||||
if (_bSize > 0 && dbytes.length < _bSize) {
|
||||
continue;
|
||||
}
|
||||
if (_bSize == 0) {
|
||||
var txconf = await api.getTxConfig(bytes: dbytes);
|
||||
if (txconf != null) {
|
||||
await api.dropTxConfig(txc: txconf);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_bSize = dbytes.length;
|
||||
final packet = RaptorPacket(field0: dbytes);
|
||||
_rxData.add(packet);
|
||||
_rxCount += 1;
|
||||
final bytesTotal = _rxData.length * dbytes.length;
|
||||
if (_rxCount % 40 == 0) {
|
||||
_rxCount = 1;
|
||||
|
||||
// if we've not received at least as many bytes as txconf.len,
|
||||
// we cannot have enough bytes to reconstruct, so only try to
|
||||
// decode if we've gotten at least that many
|
||||
if (bytesTotal > _txConfig!.len) {
|
||||
final content = await api.decodePackets(
|
||||
packets: _rxData.toList(), txconf: _txConfig!);
|
||||
if (content != null) {
|
||||
|
@ -147,7 +162,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
final bytesTotal = _rxData.length * dbytes.length;
|
||||
}
|
||||
final pct = (100.0 * bytesTotal / _txConfig!.len).floor();
|
||||
_rxTextController.add(
|
||||
"$_rxText -- $pct% received (${_formatter.format(bytesTotal)} bytes)");
|
||||
|
@ -176,13 +191,10 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||
class _RxTextDisplayWidget extends StatefulWidget {
|
||||
final Stream<String> rxTextStream;
|
||||
|
||||
final AnalysisController analysisController;
|
||||
|
||||
const _RxTextDisplayWidget({
|
||||
// ignore: unused_element
|
||||
super.key,
|
||||
required this.rxTextStream,
|
||||
required this.analysisController,
|
||||
});
|
||||
|
||||
@override
|
||||
|
@ -199,24 +211,6 @@ class _RxTextDisplayWidgetState extends State<_RxTextDisplayWidget> {
|
|||
color: Colors.white,
|
||||
),
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
Material(
|
||||
color: Colors.transparent,
|
||||
child: CheckboxListTile(
|
||||
value: widget.analysisController.enabled,
|
||||
onChanged: (newValue) async {
|
||||
if (widget.analysisController.enabled == true) {
|
||||
await widget.analysisController.stop();
|
||||
} else {
|
||||
await widget.analysisController.start();
|
||||
}
|
||||
setState(() {});
|
||||
},
|
||||
title: const Text(
|
||||
"Enable barcode scan",
|
||||
style: TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
height: 120,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
|
|