From d1f21d076820c7efa979a9dcbde51a5fcbab2156 Mon Sep 17 00:00:00 2001 From: Andy Liu Date: Thu, 5 Dec 2024 20:38:47 +0700 Subject: [PATCH] Update MadGraphics related examples Signed-off-by: Andy Liu --- .../13MoreProjects/Fireworks/Package.mmp | 31 +++++++++++++------ .../13MoreProjects/Fireworks/Package.swift | 4 +-- .../Fireworks/Sources/Fireworks.swift | 12 +++---- .../Fireworks/Sources/SoundThread.swift | 11 ++----- .../13MoreProjects/HilbertCurve/Package.mmp | 31 +++++++++++++------ .../13MoreProjects/HilbertCurve/Package.swift | 4 +-- .../13MoreProjects/MazeGame/Package.mmp | 31 +++++++++++++------ .../13MoreProjects/MazeGame/Package.swift | 4 +-- .../13MoreProjects/SandSimulation/Package.mmp | 31 +++++++++++++------ .../SandSimulation/Package.swift | 4 +-- .../13MoreProjects/SpinningCube/Package.mmp | 31 +++++++++++++------ .../13MoreProjects/SpinningCube/Package.swift | 4 +-- .../13MoreProjects/WordClock/Package.mmp | 31 +++++++++++++------ .../13MoreProjects/WordClock/Package.swift | 4 +-- 14 files changed, 146 insertions(+), 87 deletions(-) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.mmp b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.mmp index 102d0e2..8af5322 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.mmp +++ b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.mmp @@ -1,17 +1,28 @@ # This is a MadMachine project file in TOML format -# This file holds those parameters that could not be managed by SwiftPM -# Edit this file would change the behavior of the building/downloading procedure -# Those project files in the dependent libraries would be IGNORED +# This file contains parameters that cannot be managed by SwiftPM +# Editing this file will alter the behavior of the build/download process +# Project files within dependent libraries will be IGNORED # Specify the board name below -# There are "SwiftIOBoard" and "SwiftIOMicro" now +# Supported boards are listed as follows +# "SwiftIOBoard" +# "SwiftIOMicro" board = "SwiftIOMicro" -# Specifiy the target triple below -# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now -# If your code use significant floating-point calculation, -# plz set it to "thumbv7em-unknown-none-eabihf" -triple = "thumbv7em-unknown-none-eabi" +# Specify the target triple below +# Supported architectures are listed as follows +# "thumbv7em-unknown-none-eabi" +# "thumbv7em-unknown-none-eabihf" +# "armv7em-none-none-eabi" +triple = "armv7em-none-none-eabi" + +# Enable or disable hardware floating-point support below +# If your code involves significant floating-point calculations, please set it to 'true' +hard-float = true + +# Enable or disable float register below +# If your code involves significant floating-point calculations, please set it to 'true' +float-abi = false # Reserved for future use -version = 1 +version = 1 \ No newline at end of file diff --git a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.swift b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.swift index 244eb6a..8d25e0c 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.swift @@ -10,7 +10,7 @@ let package = Package( .package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadBoards.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "develop"), - .package(path: "/Users/andy/Documents/MadGraphics"), + .package(url: "https://github.com/madmachineio/CFreeType", from: "2.13.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -22,7 +22,7 @@ let package = Package( "MadBoards", // Use specific library name rather than "MadDrivers" would speed up the build procedure. .product(name: "ST7789", package: "MadDrivers"), - "MadGraphics" + "CFreeType" ]), ] ) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/Fireworks.swift b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/Fireworks.swift index 84f98fa..2724192 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/Fireworks.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/Fireworks.swift @@ -42,12 +42,12 @@ public struct Fireworks { var fireworks: [Firework] = [] var exploded = false - // createThread( - // name: "play_sound", - // priority: 3, - // stackSize: 1024 * 64, - // soundThread - // ) + createThread( + name: "play_sound", + priority: 3, + stackSize: 1024 * 64, + soundThread + ) sleep(ms: 10) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/SoundThread.swift b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/SoundThread.swift index d343837..69ff853 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/SoundThread.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Sources/SoundThread.swift @@ -31,22 +31,15 @@ func soundThread(_ a: UnsafeMutableRawPointer?, _ b: UnsafeMutableRawPointer?, _ func readSoundData(from path: String) -> [UInt8] { let headerSize = 0x2C - - guard let file = try? FileDescriptor.open(path) else { - print("Read sound data \(path) failed!") - return [] - } - var buffer = [UInt8]() do { + let file = try FileDescriptor.open(path) try file.seek(offset: 0, from: FileDescriptor.SeekOrigin.end) let size = try file.tell() - headerSize buffer = [UInt8](repeating: 0, count: size) - try buffer.withUnsafeMutableBytes { rawBuffer in - _ = try file.read(fromAbsoluteOffest: headerSize, into: rawBuffer, count: size) - } + try file.read(fromAbsoluteOffest: headerSize, into: &buffer, count: size) try file.close() } catch { print("File \(path) handle error: \(error)") diff --git a/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.mmp b/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.mmp index 102d0e2..8af5322 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.mmp +++ b/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.mmp @@ -1,17 +1,28 @@ # This is a MadMachine project file in TOML format -# This file holds those parameters that could not be managed by SwiftPM -# Edit this file would change the behavior of the building/downloading procedure -# Those project files in the dependent libraries would be IGNORED +# This file contains parameters that cannot be managed by SwiftPM +# Editing this file will alter the behavior of the build/download process +# Project files within dependent libraries will be IGNORED # Specify the board name below -# There are "SwiftIOBoard" and "SwiftIOMicro" now +# Supported boards are listed as follows +# "SwiftIOBoard" +# "SwiftIOMicro" board = "SwiftIOMicro" -# Specifiy the target triple below -# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now -# If your code use significant floating-point calculation, -# plz set it to "thumbv7em-unknown-none-eabihf" -triple = "thumbv7em-unknown-none-eabi" +# Specify the target triple below +# Supported architectures are listed as follows +# "thumbv7em-unknown-none-eabi" +# "thumbv7em-unknown-none-eabihf" +# "armv7em-none-none-eabi" +triple = "armv7em-none-none-eabi" + +# Enable or disable hardware floating-point support below +# If your code involves significant floating-point calculations, please set it to 'true' +hard-float = true + +# Enable or disable float register below +# If your code involves significant floating-point calculations, please set it to 'true' +float-abi = false # Reserved for future use -version = 1 +version = 1 \ No newline at end of file diff --git a/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.swift b/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.swift index acc9b7c..6d7f734 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.swift @@ -10,7 +10,7 @@ let package = Package( .package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadBoards.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "develop"), - .package(path: "/Users/andy/Documents/MadGraphics"), + .package(url: "https://github.com/madmachineio/CFreeType", from: "2.13.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -22,7 +22,7 @@ let package = Package( "MadBoards", // Use specific library name rather than "MadDrivers" would speed up the build procedure. .product(name: "ST7789", package: "MadDrivers"), - "MadGraphics", + "CFreeType", ]), ] ) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.mmp b/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.mmp index 102d0e2..8af5322 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.mmp +++ b/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.mmp @@ -1,17 +1,28 @@ # This is a MadMachine project file in TOML format -# This file holds those parameters that could not be managed by SwiftPM -# Edit this file would change the behavior of the building/downloading procedure -# Those project files in the dependent libraries would be IGNORED +# This file contains parameters that cannot be managed by SwiftPM +# Editing this file will alter the behavior of the build/download process +# Project files within dependent libraries will be IGNORED # Specify the board name below -# There are "SwiftIOBoard" and "SwiftIOMicro" now +# Supported boards are listed as follows +# "SwiftIOBoard" +# "SwiftIOMicro" board = "SwiftIOMicro" -# Specifiy the target triple below -# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now -# If your code use significant floating-point calculation, -# plz set it to "thumbv7em-unknown-none-eabihf" -triple = "thumbv7em-unknown-none-eabi" +# Specify the target triple below +# Supported architectures are listed as follows +# "thumbv7em-unknown-none-eabi" +# "thumbv7em-unknown-none-eabihf" +# "armv7em-none-none-eabi" +triple = "armv7em-none-none-eabi" + +# Enable or disable hardware floating-point support below +# If your code involves significant floating-point calculations, please set it to 'true' +hard-float = true + +# Enable or disable float register below +# If your code involves significant floating-point calculations, please set it to 'true' +float-abi = false # Reserved for future use -version = 1 +version = 1 \ No newline at end of file diff --git a/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.swift b/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.swift index e399495..acf4109 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.swift @@ -10,7 +10,7 @@ let package = Package( .package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadBoards.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "develop"), - .package(path: "/Users/andy/Documents/MadGraphics") + .package(url: "https://github.com/madmachineio/CFreeType", from: "2.13.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -23,7 +23,7 @@ let package = Package( // Use specific library name rather than "MadDrivers" would speed up the build procedure. .product(name: "ST7789", package: "MadDrivers"), .product(name: "LIS3DH", package: "MadDrivers"), - "MadGraphics" + "CFreeType", ]), ] ) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.mmp b/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.mmp index 102d0e2..8af5322 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.mmp +++ b/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.mmp @@ -1,17 +1,28 @@ # This is a MadMachine project file in TOML format -# This file holds those parameters that could not be managed by SwiftPM -# Edit this file would change the behavior of the building/downloading procedure -# Those project files in the dependent libraries would be IGNORED +# This file contains parameters that cannot be managed by SwiftPM +# Editing this file will alter the behavior of the build/download process +# Project files within dependent libraries will be IGNORED # Specify the board name below -# There are "SwiftIOBoard" and "SwiftIOMicro" now +# Supported boards are listed as follows +# "SwiftIOBoard" +# "SwiftIOMicro" board = "SwiftIOMicro" -# Specifiy the target triple below -# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now -# If your code use significant floating-point calculation, -# plz set it to "thumbv7em-unknown-none-eabihf" -triple = "thumbv7em-unknown-none-eabi" +# Specify the target triple below +# Supported architectures are listed as follows +# "thumbv7em-unknown-none-eabi" +# "thumbv7em-unknown-none-eabihf" +# "armv7em-none-none-eabi" +triple = "armv7em-none-none-eabi" + +# Enable or disable hardware floating-point support below +# If your code involves significant floating-point calculations, please set it to 'true' +hard-float = true + +# Enable or disable float register below +# If your code involves significant floating-point calculations, please set it to 'true' +float-abi = false # Reserved for future use -version = 1 +version = 1 \ No newline at end of file diff --git a/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.swift b/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.swift index 6b268db..619d9c7 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/SandSimulation/Package.swift @@ -10,7 +10,7 @@ let package = Package( .package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadBoards.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "develop"), - .package(path: "/Users/andy/Documents/MadGraphics"), + .package(url: "https://github.com/madmachineio/CFreeType", from: "2.13.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -23,7 +23,7 @@ let package = Package( // Use specific library name rather than "MadDrivers" would speed up the build procedure. .product(name: "ST7789", package: "MadDrivers"), .product(name: "LIS3DH", package: "MadDrivers"), - "MadGraphics" + "CFreeType", ]), ] ) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.mmp b/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.mmp index 102d0e2..8af5322 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.mmp +++ b/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.mmp @@ -1,17 +1,28 @@ # This is a MadMachine project file in TOML format -# This file holds those parameters that could not be managed by SwiftPM -# Edit this file would change the behavior of the building/downloading procedure -# Those project files in the dependent libraries would be IGNORED +# This file contains parameters that cannot be managed by SwiftPM +# Editing this file will alter the behavior of the build/download process +# Project files within dependent libraries will be IGNORED # Specify the board name below -# There are "SwiftIOBoard" and "SwiftIOMicro" now +# Supported boards are listed as follows +# "SwiftIOBoard" +# "SwiftIOMicro" board = "SwiftIOMicro" -# Specifiy the target triple below -# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now -# If your code use significant floating-point calculation, -# plz set it to "thumbv7em-unknown-none-eabihf" -triple = "thumbv7em-unknown-none-eabi" +# Specify the target triple below +# Supported architectures are listed as follows +# "thumbv7em-unknown-none-eabi" +# "thumbv7em-unknown-none-eabihf" +# "armv7em-none-none-eabi" +triple = "armv7em-none-none-eabi" + +# Enable or disable hardware floating-point support below +# If your code involves significant floating-point calculations, please set it to 'true' +hard-float = true + +# Enable or disable float register below +# If your code involves significant floating-point calculations, please set it to 'true' +float-abi = false # Reserved for future use -version = 1 +version = 1 \ No newline at end of file diff --git a/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.swift b/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.swift index 8f16731..4be7625 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.swift @@ -10,7 +10,7 @@ let package = Package( .package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadBoards.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "develop"), - .package(path: "/Users/andy/Documents/MadGraphics"), + .package(url: "https://github.com/madmachineio/CFreeType", from: "2.13.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -22,7 +22,7 @@ let package = Package( "MadBoards", // Use specific library name rather than "MadDrivers" would speed up the build procedure. .product(name: "ST7789", package: "MadDrivers"), - "MadGraphics", + "CFreeType", ]), ] ) diff --git a/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.mmp b/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.mmp index 102d0e2..8af5322 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.mmp +++ b/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.mmp @@ -1,17 +1,28 @@ # This is a MadMachine project file in TOML format -# This file holds those parameters that could not be managed by SwiftPM -# Edit this file would change the behavior of the building/downloading procedure -# Those project files in the dependent libraries would be IGNORED +# This file contains parameters that cannot be managed by SwiftPM +# Editing this file will alter the behavior of the build/download process +# Project files within dependent libraries will be IGNORED # Specify the board name below -# There are "SwiftIOBoard" and "SwiftIOMicro" now +# Supported boards are listed as follows +# "SwiftIOBoard" +# "SwiftIOMicro" board = "SwiftIOMicro" -# Specifiy the target triple below -# There are "thumbv7em-unknown-none-eabi" and "thumbv7em-unknown-none-eabihf" now -# If your code use significant floating-point calculation, -# plz set it to "thumbv7em-unknown-none-eabihf" -triple = "thumbv7em-unknown-none-eabi" +# Specify the target triple below +# Supported architectures are listed as follows +# "thumbv7em-unknown-none-eabi" +# "thumbv7em-unknown-none-eabihf" +# "armv7em-none-none-eabi" +triple = "armv7em-none-none-eabi" + +# Enable or disable hardware floating-point support below +# If your code involves significant floating-point calculations, please set it to 'true' +hard-float = true + +# Enable or disable float register below +# If your code involves significant floating-point calculations, please set it to 'true' +float-abi = false # Reserved for future use -version = 1 +version = 1 \ No newline at end of file diff --git a/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.swift b/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.swift index 110e613..f7d8e42 100644 --- a/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.swift +++ b/Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.swift @@ -10,7 +10,7 @@ let package = Package( .package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadBoards.git", branch: "develop"), .package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "develop"), - .package(path: "/Users/andy/Documents/MadGraphics") + .package(url: "https://github.com/madmachineio/CFreeType", from: "2.13.0"), ], targets: [ // Targets are the basic building blocks of a package, defining a module or a test suite. @@ -23,7 +23,7 @@ let package = Package( // Use specific library name rather than "MadDrivers" would speed up the build procedure. .product(name: "ST7789", package: "MadDrivers"), .product(name: "PCF8563", package: "MadDrivers"), - "MadGraphics" + "CFreeType", ]), ] )