V0.0.2 Published client
parent
f22d90d735
commit
a7694c06db
|
@ -1 +1,2 @@
|
|||
org.gradle.jvmargs=-Xmx1536M
|
||||
android.enableR8=true
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
//
|
||||
// NMMCSEND dart project (main.dart)
|
||||
//
|
||||
// History:
|
||||
// --------
|
||||
// 24.06.19/KQ Initial version
|
||||
//
|
||||
|
||||
import 'dart:io';
|
||||
//import 'dart:ui' as prefix0;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'color_picker.dart';
|
||||
|
||||
|
@ -35,45 +42,21 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
blue = currentColor & 0xFF;
|
||||
green = (currentColor >> 8) & 0xFF;
|
||||
red = (currentColor >> 16) & 0xFF;
|
||||
//alpha = (currentColor >> 24) & 0xFF;
|
||||
print("ARGB($alpha,$red,$green,$blue)");
|
||||
print("ARGB($alpha,$red,$green,$blue)");
|
||||
}
|
||||
|
||||
/*
|
||||
Uint8List convert(String string, [int start = 0, int end]) {
|
||||
var stringLength = string.length;
|
||||
end = RangeError.checkValidRange(start, end, stringLength);
|
||||
var length = end - start;
|
||||
var result = Uint8List(length);
|
||||
for (var i = 0; i < length; i++) {
|
||||
var codeUnit = string.codeUnitAt(start + i);
|
||||
if ((codeUnit & ~_subsetMask) != 0) {
|
||||
throw ArgumentError.value(
|
||||
string, "string", "Contains invalid characters.");
|
||||
}
|
||||
result[i] = codeUnit;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
*/
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
String sEntry = myController.text;
|
||||
if(sEntry.length > 0) {
|
||||
hex2rgb(currentColor.value);
|
||||
_counter = _counter + rcMC; //_counter++;
|
||||
_counter = _counter + rcMC;
|
||||
if(_counter >= sEntry.length)
|
||||
_counter = 0;
|
||||
if(iCodeValue == 2) // Send alternating lines ...
|
||||
iCodeValue = 1; // Top line
|
||||
else
|
||||
iCodeValue = 2; // Bottom line
|
||||
//iCodeValue = sEntry.codeUnitAt(_counter);
|
||||
String s = (_counter).toString().padLeft(3,'0')
|
||||
+ ":"
|
||||
+ iCodeValue.toString().padLeft(3,'0')
|
||||
|
@ -121,15 +104,6 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
return MaterialApp(
|
||||
title: "NodeSwarm Master Controller",
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// Try running your application with "flutter run". You'll see the
|
||||
// application has a blue toolbar. Then, without quitting the app, try
|
||||
// changing the primarySwatch below to Colors.green and then invoke
|
||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// is not restarted.
|
||||
primarySwatch: Colors.grey,
|
||||
),
|
||||
home: Scaffold(
|
||||
|
@ -137,10 +111,10 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
body: Align(
|
||||
alignment: Alignment.topCenter,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center, // center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 20),
|
||||
Text('Enter text to send: ', textScaleFactor: 2), // Test
|
||||
Text('Enter text to send: ', textScaleFactor: 2),
|
||||
TextField(
|
||||
controller: myController,
|
||||
onChanged: (text) {
|
||||
|
@ -149,7 +123,7 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
style: new TextStyle(
|
||||
fontSize: 40.0,
|
||||
height: 1.5,
|
||||
color: currentColor, //Colors.green
|
||||
color: currentColor,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
|
@ -163,7 +137,7 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
textScaleFactor: 0.3,
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
Text('Select color to use: ', textScaleFactor: 2), // Test
|
||||
Text('Select color to use: ', textScaleFactor: 2),
|
||||
SizedBox(height: 10),
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
|
@ -179,15 +153,6 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
});
|
||||
},
|
||||
),
|
||||
/*SizedBox(width: 20),
|
||||
Container(
|
||||
width: 150,
|
||||
height: 50,
|
||||
color: currentColor,
|
||||
alignment: Alignment.center,
|
||||
child: Text(currentColor.value.toRadixString(16).toUpperCase()),
|
||||
),
|
||||
*/
|
||||
SizedBox(width: 60),
|
||||
BarColorPicker(
|
||||
cornerRadius: 10,
|
||||
|
@ -216,7 +181,7 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
});
|
||||
}),
|
||||
SizedBox(height: 20),
|
||||
Text('Brightness: ', textScaleFactor: 2), // Test
|
||||
Text('Brightness: ', textScaleFactor: 2),
|
||||
Slider(
|
||||
min: 0,
|
||||
max: 64,
|
||||
|
@ -230,8 +195,7 @@ class _ColorPickerAppState extends State<ColorPickerApp> {
|
|||
_incrementCounter();
|
||||
});
|
||||
},
|
||||
),
|
||||
//SizedBox(height: 50),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
@ -1,172 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'dart:io';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
int rcMC = 0;
|
||||
RawDatagramSocket sG;
|
||||
InternetAddress multicastAddress; //= new InternetAddress('238.255.255.250');
|
||||
int multicastPort = 1337;
|
||||
int iCodeValue = 0;
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
multicastAddress = new InternetAddress('238.255.255.250');
|
||||
RawDatagramSocket.bind(InternetAddress.ANY_IP_V4, 0).then((RawDatagramSocket s) {
|
||||
s.multicastLoopback = false;
|
||||
s.multicastHops = 4;
|
||||
try {
|
||||
s.joinMulticast(multicastAddress); // Join multicast group
|
||||
print("Multicast group joined.");
|
||||
}
|
||||
catch (e) {
|
||||
print("***** Multicast join failed: ${e.toString()}");
|
||||
}
|
||||
rcMC = 1;
|
||||
sG = s;
|
||||
int nBytes = s.send("000:000".codeUnits, multicastAddress, multicastPort);
|
||||
print("Sent: $nBytes bytes, display reset.");
|
||||
});
|
||||
return MaterialApp(
|
||||
title: 'NodeSwarm Master Controller',
|
||||
//debugShowCheckedModeBanner: false, // May be disabled, even in debug mode!
|
||||
theme: ThemeData(
|
||||
// This is the theme of your application.
|
||||
//
|
||||
// Try running your application with "flutter run". You'll see the
|
||||
// application has a blue toolbar. Then, without quitting the app, try
|
||||
// changing the primarySwatch below to Colors.green and then invoke
|
||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
||||
// Notice that the counter didn't reset back to zero; the application
|
||||
// is not restarted.
|
||||
primarySwatch: Colors.grey,
|
||||
),
|
||||
home: MyHomePage(title: 'NodeSwarm Master Control'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
MyHomePage({Key key, this.title}) : super(key: key);
|
||||
|
||||
// This widget is the home page of your application. It is stateful, meaning
|
||||
// that it has a State object (defined below) that contains fields that affect
|
||||
// how it looks.
|
||||
|
||||
// This class is the configuration for the state. It holds the values (in this
|
||||
// case the title) provided by the parent (in this case the App widget) and
|
||||
// used by the build method of the State. Fields in a Widget subclass are
|
||||
// always marked "final".
|
||||
|
||||
final String title;
|
||||
|
||||
@override
|
||||
_MyHomePageState createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
int _counter = 0;
|
||||
final myController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Clean up the controller when the widget is disposed.
|
||||
myController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _incrementCounter() {
|
||||
setState(() {
|
||||
// This call to setState tells the Flutter framework that something has
|
||||
// changed in this State, which causes it to rerun the build method below
|
||||
// so that the display can reflect the updated values. If we changed
|
||||
// _counter without calling setState(), then the build method would not be
|
||||
// called again, and so nothing would appear to happen.
|
||||
String sEntry = myController.text;
|
||||
if(sEntry.length > 0) {
|
||||
_counter = _counter + rcMC; //_counter++;
|
||||
if(_counter >= sEntry.length)
|
||||
_counter = 0;
|
||||
iCodeValue = sEntry.codeUnitAt(_counter);
|
||||
String s = (_counter).toString().padLeft(3,'0') + ":" + iCodeValue.toString().padLeft(3,'0');
|
||||
int nBytes = sG.send(s.codeUnits, multicastAddress, multicastPort);
|
||||
print("Bytes sent: $nBytes ($s)");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _onTextChanged(String t) {
|
||||
print("onTextChanged: $t");
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// This method is rerun every time setState is called, for instance as done
|
||||
// by the _incrementCounter method above.
|
||||
//
|
||||
// The Flutter framework has been optimized to make rerunning build methods
|
||||
// fast, so that you can just rebuild anything that needs updating rather
|
||||
// than having to individually change instances of widgets.
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: Text(widget.title),
|
||||
),
|
||||
body: Center(
|
||||
// Center is a layout widget. It takes a single child and positions it
|
||||
// in the middle of the parent.
|
||||
child: Column(
|
||||
// Column is also layout widget. It takes a list of children and
|
||||
// arranges them vertically. By default, it sizes itself to fit its
|
||||
// children horizontally, and tries to be as tall as its parent.
|
||||
//
|
||||
// Invoke "debug painting" (press "p" in the console, choose the
|
||||
// "Toggle Debug Paint" action from the Flutter Inspector in Android
|
||||
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
|
||||
// to see the wireframe for each widget.
|
||||
//
|
||||
// Column has various properties to control how it sizes itself and
|
||||
// how it positions its children. Here we use mainAxisAlignment to
|
||||
// center the children vertically; the main axis here is the vertical
|
||||
// axis because Columns are vertical (the cross axis would be
|
||||
// horizontal).
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,// .center,
|
||||
children: <Widget>[
|
||||
Text('Enter chars. to send:', textScaleFactor: 3), // Test
|
||||
TextField(
|
||||
controller: myController,
|
||||
onChanged: (text) {
|
||||
_onTextChanged(text);
|
||||
},
|
||||
style: new TextStyle(
|
||||
fontSize: 40.0,
|
||||
height: 1.5,
|
||||
color: Colors.green
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
border: InputBorder.none,
|
||||
hintText: 'enter here!',
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 50.0)
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'($_counter): $iCodeValue',
|
||||
style: Theme.of(context).textTheme.display1,
|
||||
textScaleFactor: 1,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: _incrementCounter,
|
||||
tooltip: 'Increment',
|
||||
child: Icon(Icons.input),
|
||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
||||
);
|
||||
}
|
||||
}
|
59
pubspec.lock
59
pubspec.lock
|
@ -1,13 +1,27 @@
|
|||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
archive:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: archive
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.11"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.5.2"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
version: "2.4.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -29,6 +43,20 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.11"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
@ -46,20 +74,27 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.5"
|
||||
version: "0.12.6"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.7"
|
||||
version: "1.1.8"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -74,6 +109,13 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0+1"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: petitparser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -127,7 +169,7 @@ packages:
|
|||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.5"
|
||||
version: "0.2.11"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -142,5 +184,12 @@ packages:
|
|||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
xml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.5.0"
|
||||
sdks:
|
||||
dart: ">=2.2.2 <3.0.0"
|
||||
dart: ">=2.4.0 <3.0.0"
|
||||
|
|
Loading…
Reference in New Issue