Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: prototype: add static image transferring #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kienvo
Copy link
Member

@kienvo kienvo commented Jan 8, 2025

This is a prototype for testing the firmware so still messy.

Summary by Sourcery

Add initial support for static image transfer to the e-paper display.

New Features:

  • Implement static image transfer functionality to update the e-paper display.

Tests:

  • Add basic unit tests.

Copy link

sourcery-ai bot commented Jan 8, 2025

Reviewer's Guide by Sourcery

This pull request introduces a prototype for static image transfer to an e-paper display. It includes platform-specific code for Windows, Linux, and mobile, as well as core Dart logic for image processing and NFC communication.

Sequence diagram for static image transfer process

sequenceDiagram
    participant User
    participant App
    participant ImageUtils
    participant NFC
    participant EPaper

    User->>App: Select image
    App->>ImageUtils: Process image
    ImageUtils->>ImageUtils: Convert to EPD format
    Note over ImageUtils: Convert to black/red pixels
    ImageUtils->>ImageUtils: Divide into chunks
    App->>NFC: Write chunks
    loop For each chunk
        NFC->>EPaper: Transfer chunk
        EPaper-->>NFC: Acknowledge
    end
    NFC->>EPaper: Refresh display
    EPaper-->>User: Display image
Loading

Class diagram for image handling components

classDiagram
    class ImageUtils {
        +originalHeight: double
        +originalWidth: double
        +picture: Picture
        +convert2DListToUint8List(List<List<int>>)
        +generateByteData(String)
        +convertBitmapToByteData(String)
        +convertBitmapToByteDataBiColor(String)
        +divideUint8List(Uint8List, int)
        -_loadSVG(String)
        -_scaleSVG(Image, double, double)
        -_convertImageToByteArray(Image)
        -_convertUint8ListTo2DList(Uint8List, int, int)
        -_convertPixelsToEpdBytes(List<List<int>>)
        -_convertImageArrayToEpdBytes(Uint8List)
    }

    class MagicEpd {
        +default_req_flags: int
        +write_msg_cmd: int
        +read_msg_cmd: int
        +read_dyncfg_cmd: int
        +write_dyncfg_cmd: int
        +ic_mfg_code: int
        +epd_cmd: int
        +epd_send: int
        +writeChunk(List<Uint8List>, List<Uint8List>)
        -_transceive(int, Uint8List, Uint8List)
        -_writeMsg(Uint8List, Uint8List)
        -_readMsg(Uint8List)
        -_readDynCfg(Uint8List, int)
        -_writeDynCfg(Uint8List, int, int)
    }
Loading

File-Level Changes

Change Details Files
Add initial support for image transfer on Windows.
  • Implement Win32 window creation and management.
  • Handle window messages and DPI scaling.
  • Integrate Flutter view controller.
  • Set up console and command-line arguments.
  • Add resource file and manifest.
windows/runner/win32_window.cpp
windows/runner/win32_window.h
windows/runner/flutter_window.cpp
windows/runner/main.cpp
windows/runner/utils.cpp
windows/runner/utils.h
windows/CMakeLists.txt
windows/runner/CMakeLists.txt
windows/runner/resource.h
windows/runner/runner.exe.manifest
Add initial support for image transfer on Linux.
  • Set up CMake project and dependencies.
  • Implement GTK application and window.
  • Register Flutter plugins.
  • Handle command-line arguments.
linux/CMakeLists.txt
linux/my_application.cc
linux/my_application.h
linux/main.cc
linux/flutter/CMakeLists.txt
linux/flutter/generated_plugins.cmake
linux/flutter/generated_plugin_registrant.h
linux/flutter/generated_plugin_registrant.cc
Implement core image processing and NFC communication logic in Dart.
  • Add functions for loading, scaling, and converting SVG and bitmap images.
  • Implement functions for converting image data to byte arrays and 2D pixel lists.
  • Implement NFC communication functions for writing image data to an e-paper display.
  • Integrate image processing and NFC functionality into the main application.
lib/imagehandler.dart
lib/epdutils.dart
lib/main.dart
Add basic project setup for iOS, Android, macOS, and web platforms.
  • Add configuration files and assets.
  • Set up project structure and dependencies.
  • Configure build settings.
ios/Runner/Info.plist
android/app/src/main/AndroidManifest.xml
android/app/build.gradle
macos/Runner/Info.plist
web/index.html
web/manifest.json
ios/Flutter/AppFrameworkInfo.plist
macos/Runner/MainFlutterWindow.swift
android/settings.gradle
windows/flutter/CMakeLists.txt
pubspec.yaml
pubspec.lock
README.md
analysis_options.yaml
l10n.yaml
ios/Runner/Runner-Bridging-Header.h
.gitignore
android/.gitignore
ios/.gitignore
linux/.gitignore
macos/.gitignore
windows/.gitignore
android/build/.last_build_id
ios/Flutter/Debug.xcconfig
ios/Flutter/Release.xcconfig
ios/Runner.xcodeproj/project.pbxproj
ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata
ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
ios/Runner.xcworkspace/contents.xcworkspacedata
ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json
ios/Runner/Base.lproj/LaunchScreen.storyboard
ios/Runner/Base.lproj/Main.storyboard
lib/src/localization/app_en.arb
macos/Flutter/Flutter-Debug.xcconfig
macos/Flutter/Flutter-Release.xcconfig
macos/Runner.xcodeproj/project.pbxproj
macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
macos/Runner.xcworkspace/contents.xcworkspacedata
macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json
macos/Runner/Base.lproj/MainMenu.xib
macos/Runner/Configs/AppInfo.xcconfig
macos/Runner/Configs/Debug.xcconfig
macos/Runner/Configs/Release.xcconfig
macos/Runner/Configs/Warnings.xcconfig
macos/Runner/DebugProfile.entitlements
macos/Runner/Release.entitlements
android/gradle/wrapper/gradle-wrapper.properties
ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md
android/gradle.properties
ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
android/app/src/debug/AndroidManifest.xml
android/app/src/profile/AndroidManifest.xml
android/app/src/main/kotlin/org/fossasia/magic_epaper_app/MainActivity.kt
android/app/src/main/res/values-night/styles.xml
android/app/src/main/res/values/styles.xml
android/build.gradle
android/app/src/main/res/drawable-v21/launch_background.xml
android/app/src/main/res/drawable/launch_background.xml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant