last code cleanup

This commit is contained in:
baldeau 2024-03-22 01:37:13 +01:00
parent 965a9439c2
commit 27a045741e
14 changed files with 1411 additions and 242 deletions

Binary file not shown.

Binary file not shown.

2
assets/video/SOURCE.md Normal file
View File

@ -0,0 +1,2 @@
Video source: https://www.pexels.com/video/a-herd-of-deer-resting-on-a-ground-with-snowfall-3195315/
License: CC

View File

@ -2,7 +2,7 @@ import 'package:dart_periphery/dart_periphery.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
// linux_spidev was tried out here beforehand, // linux_spidev was tried out here beforehand,
// but it didn't work and was replaced by dart_periphery // but it didn't work well and was replaced by dart_periphery
// import 'package:linux_spidev/linux_spidev.dart'; // import 'package:linux_spidev/linux_spidev.dart';
class MatrixService { class MatrixService {
@ -10,7 +10,28 @@ class MatrixService {
// final spidev = Spidev.fromBusDevNrs(0, 0); // final spidev = Spidev.fromBusDevNrs(0, 0);
void setLedsOn(List<int> pixels) async { void setLedsOn(List<int> pixels) async {
// linux_spidev will error out with this console log:
// flutter: OS Error: Could not open spidev file at "/dev/spidev0.0"
// Failed to import fence to syncobj: -1
// Using linux_spidev:
// try {
// final handle = spidev.open(); // final handle = spidev.open();
// final typedData = Uint8List.fromList(pixels);
// await handle.transferSingleTypedData(txBuf: typedData, rxBuf: typedData);
// handle.close();
// } catch (e) {
// debugPrint(e.toString());
// }
// If a tuple error happens with StackTrace? has to be StackTrace:
// In the source code of spidev.dart line 395, change it to:
// before:
// sendPort.send(Tuple3<int, dynamic, StackTrace?>(transferId, null, null));
// after:
// sendPort.send(Tuple3<int, dynamic, StackTrace>(transferId, null, StackTrace.current));
// Using dart_periphery:
try { try {
int refresh = 1; int refresh = 1;
while (refresh != 0) { while (refresh != 0) {

View File

@ -35,7 +35,6 @@ class PixelPainter extends CustomPainter {
); );
} }
// Assuming 'width' represents the width of your matrix (in this case, 8)
const width = 8; const width = 8;
List<int> colorIntList = pixels.map((pixel) { List<int> colorIntList = pixels.map((pixel) {

View File

@ -13,24 +13,20 @@ class MorseService {
for (var char in chars) { for (var char in chars) {
final List<String> morseCode = _morseAlphabet[char]?.split('') ?? ['*']; final List<String> morseCode = _morseAlphabet[char]?.split('') ?? ['*'];
for (var code in morseCode) { for (var code in morseCode) {
print('CODE: $code from $morseCode');
if (code == '*') { if (code == '*') {
await Future.delayed(const Duration(milliseconds: pulseDuration * 7)); await Future.delayed(const Duration(milliseconds: pulseDuration * 7));
break; break;
} }
ledPin.setValue(true); ledPin.setValue(true);
print('ON');
if (code == '.') { if (code == '.') {
await Future.delayed(const Duration(milliseconds: pulseDuration)); await Future.delayed(const Duration(milliseconds: pulseDuration));
} else if (code == '-') { } else if (code == '-') {
await Future.delayed(const Duration(milliseconds: pulseDuration * 3)); await Future.delayed(const Duration(milliseconds: pulseDuration * 3));
} }
print('OFF');
ledPin.setValue(false); ledPin.setValue(false);
// pause between letters // pause between letters
await Future.delayed(const Duration(milliseconds: pulseDuration)); await Future.delayed(const Duration(milliseconds: pulseDuration));
} }
print("SPACE BETWEEN LETTERS");
// space between letters is 3*pulseDuration // space between letters is 3*pulseDuration
await Future.delayed(const Duration(milliseconds: pulseDuration * 3)); await Future.delayed(const Duration(milliseconds: pulseDuration * 3));
} }

View File

@ -1,62 +0,0 @@
import 'package:freezed_annotation/freezed_annotation.dart';
part 'teaser_image_url.freezed.dart';
part 'teaser_image_url.g.dart';
@freezed
class TeaserImageUrl with _$TeaserImageUrl {
const factory TeaserImageUrl({
String? imageurl,
}) = _TeaserImageUrl;
factory TeaserImageUrl.fromJson(Map<String, dynamic> json) =>
_$TeaserImageUrlFromJson(json);
}
// old manual implementation:
// class TeaserImageUrl {
// final String imageurl;
// TeaserImageUrl({
// required this.imageurl,
// });
// TeaserImageUrl copyWith({
// String? imageurl,
// }) {
// return TeaserImageUrl(
// imageurl: imageurl ?? this.imageurl,
// );
// }
// Map<String, dynamic> toMap() {
// return {
// 'imageurl': imageurl,
// };
// }
// factory TeaserImageUrl.fromMap(Map<String, dynamic> map) {
// return TeaserImageUrl(
// imageurl: map['imageurl'] ?? '',
// );
// }
// String toJson() => json.encode(toMap());
// factory TeaserImageUrl.fromJson(String source) =>
// TeaserImageUrl.fromMap(json.decode(source));
// @override
// String toString() => 'TeaserImageUrl(imageurl: $imageurl)';
// @override
// bool operator ==(Object other) {
// if (identical(this, other)) return true;
// return other is TeaserImageUrl && other.imageurl == imageurl;
// }
// @override
// int get hashCode => imageurl.hashCode;
// }

View File

@ -1,154 +0,0 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'teaser_image_url.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
TeaserImageUrl _$TeaserImageUrlFromJson(Map<String, dynamic> json) {
return _TeaserImageUrl.fromJson(json);
}
/// @nodoc
mixin _$TeaserImageUrl {
String? get imageurl => throw _privateConstructorUsedError;
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$TeaserImageUrlCopyWith<TeaserImageUrl> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $TeaserImageUrlCopyWith<$Res> {
factory $TeaserImageUrlCopyWith(
TeaserImageUrl value, $Res Function(TeaserImageUrl) then) =
_$TeaserImageUrlCopyWithImpl<$Res, TeaserImageUrl>;
@useResult
$Res call({String? imageurl});
}
/// @nodoc
class _$TeaserImageUrlCopyWithImpl<$Res, $Val extends TeaserImageUrl>
implements $TeaserImageUrlCopyWith<$Res> {
_$TeaserImageUrlCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? imageurl = freezed,
}) {
return _then(_value.copyWith(
imageurl: freezed == imageurl
? _value.imageurl
: imageurl // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
/// @nodoc
abstract class _$$TeaserImageUrlImplCopyWith<$Res>
implements $TeaserImageUrlCopyWith<$Res> {
factory _$$TeaserImageUrlImplCopyWith(_$TeaserImageUrlImpl value,
$Res Function(_$TeaserImageUrlImpl) then) =
__$$TeaserImageUrlImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String? imageurl});
}
/// @nodoc
class __$$TeaserImageUrlImplCopyWithImpl<$Res>
extends _$TeaserImageUrlCopyWithImpl<$Res, _$TeaserImageUrlImpl>
implements _$$TeaserImageUrlImplCopyWith<$Res> {
__$$TeaserImageUrlImplCopyWithImpl(
_$TeaserImageUrlImpl _value, $Res Function(_$TeaserImageUrlImpl) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? imageurl = freezed,
}) {
return _then(_$TeaserImageUrlImpl(
imageurl: freezed == imageurl
? _value.imageurl
: imageurl // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
@JsonSerializable()
class _$TeaserImageUrlImpl implements _TeaserImageUrl {
const _$TeaserImageUrlImpl({this.imageurl});
factory _$TeaserImageUrlImpl.fromJson(Map<String, dynamic> json) =>
_$$TeaserImageUrlImplFromJson(json);
@override
final String? imageurl;
@override
String toString() {
return 'TeaserImageUrl(imageurl: $imageurl)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$TeaserImageUrlImpl &&
(identical(other.imageurl, imageurl) ||
other.imageurl == imageurl));
}
@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, imageurl);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$TeaserImageUrlImplCopyWith<_$TeaserImageUrlImpl> get copyWith =>
__$$TeaserImageUrlImplCopyWithImpl<_$TeaserImageUrlImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$TeaserImageUrlImplToJson(
this,
);
}
}
abstract class _TeaserImageUrl implements TeaserImageUrl {
const factory _TeaserImageUrl({final String? imageurl}) =
_$TeaserImageUrlImpl;
factory _TeaserImageUrl.fromJson(Map<String, dynamic> json) =
_$TeaserImageUrlImpl.fromJson;
@override
String? get imageurl;
@override
@JsonKey(ignore: true)
_$$TeaserImageUrlImplCopyWith<_$TeaserImageUrlImpl> get copyWith =>
throw _privateConstructorUsedError;
}

View File

@ -1,18 +0,0 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'teaser_image_url.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$TeaserImageUrlImpl _$$TeaserImageUrlImplFromJson(Map<String, dynamic> json) =>
_$TeaserImageUrlImpl(
imageurl: json['imageurl'] as String?,
);
Map<String, dynamic> _$$TeaserImageUrlImplToJson(
_$TeaserImageUrlImpl instance) =>
<String, dynamic>{
'imageurl': instance.imageurl,
};

View File

@ -1,5 +1,7 @@
import 'dart:io'; import 'dart:io';
// needed import if debugRepaintRainbowEnabled is used in main():
// import 'package:flutter/rendering.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutterpi_gstreamer_video_player/flutterpi_gstreamer_video_player.dart'; import 'package:flutterpi_gstreamer_video_player/flutterpi_gstreamer_video_player.dart';
import 'package:scaled_app/scaled_app.dart'; import 'package:scaled_app/scaled_app.dart';
@ -9,6 +11,8 @@ import 'app.dart';
import 'common/settings/sharedPrefs.dart'; import 'common/settings/sharedPrefs.dart';
void main() async { void main() async {
// debugRepaintRainbowEnabled = true;
ScaledWidgetsFlutterBinding.ensureInitialized( ScaledWidgetsFlutterBinding.ensureInitialized(
scaleFactor: (deviceSize) { scaleFactor: (deviceSize) {
const double widthOfDesign = 960; const double widthOfDesign = 960;

View File

@ -552,6 +552,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
linux_spidev:
dependency: "direct main"
description:
name: linux_spidev
sha256: b9a7f37d43c2e95793ad8ccb1b3f6753713ad16de79feae1e10e5140f4706e7f
url: "https://pub.dev"
source: hosted
version: "0.2.1+5"
lists: lists:
dependency: transitive dependency: transitive
description: description:

View File

@ -53,6 +53,7 @@ dependencies:
simple_tiles_map: ^1.3.4 simple_tiles_map: ^1.3.4
flutter_map: ^5.0.0 flutter_map: ^5.0.0
video_player: ^2.8.2 video_player: ^2.8.2
linux_spidev: ^0.2.1+5
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@ -89,8 +90,6 @@ flutter:
- assets/images/flame_benchmark/sprite_benchmark/ - assets/images/flame_benchmark/sprite_benchmark/
- assets/img/ - assets/img/
- assets/video/ - assets/video/
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
shaders: shaders:
- shaders/aobench.frag - shaders/aobench.frag

1374
uml.txt Normal file

File diff suppressed because it is too large Load Diff