Skip to content

Commit

Permalink
Update MadGraphics related examples
Browse files Browse the repository at this point in the history
Signed-off-by: Andy Liu <andy@madmachine.io>
  • Loading branch information
andy0808 committed Dec 5, 2024
1 parent dd0205f commit d1f21d0
Show file tree
Hide file tree
Showing 14 changed files with 146 additions and 87 deletions.
31 changes: 21 additions & 10 deletions Examples/SwiftIOPlayground/13MoreProjects/Fireworks/Package.mmp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
]),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
31 changes: 21 additions & 10 deletions Examples/SwiftIOPlayground/13MoreProjects/HilbertCurve/Package.mmp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
]),
]
)
31 changes: 21 additions & 10 deletions Examples/SwiftIOPlayground/13MoreProjects/MazeGame/Package.mmp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
]),
]
)
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
]),
]
)
31 changes: 21 additions & 10 deletions Examples/SwiftIOPlayground/13MoreProjects/SpinningCube/Package.mmp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
]),
]
)
31 changes: 21 additions & 10 deletions Examples/SwiftIOPlayground/13MoreProjects/WordClock/Package.mmp
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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",
]),
]
)

0 comments on commit d1f21d0

Please sign in to comment.