Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
build:
uses: madmachineio/actions/.github/workflows/build.yml@main
with:
runners: '["ubuntu-22.04", "ubuntu-24.04", "macos-13", "macos-14", "macos-15"]'
runners: '["ubuntu-24.04", "macos-15", "macos-15-intel"]'
7 changes: 7 additions & 0 deletions Examples/NV3007/DrawPixels/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
17 changes: 17 additions & 0 deletions Examples/NV3007/DrawPixels/Package.mmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

# Specify the board name below
# There are "SwiftIOBoard" and "SwiftIOMicro" now
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"

# Reserved for future use
version = 1
25 changes: 25 additions & 0 deletions Examples/NV3007/DrawPixels/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "DrawPixels",
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "main"),
.package(url: "https://github.com/madmachineio/MadBoards.git", branch: "main"),
//.package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "main"),
.package(path: "../../.."), // Use local path to MadDrivers
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "DrawPixels",
dependencies: [
"SwiftIO",
"MadBoards",
// use specific library would speed up the compile procedure
.product(name: "NV3007", package: "MadDrivers")
]),
]
)
16 changes: 16 additions & 0 deletions Examples/NV3007/DrawPixels/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# DrawPixels

Fill the LCD with white and draw a red square on the middle.

## Library reference

* [SwiftIO](https://github.com/madmachineio/SwiftIO)
* [MadBoard](https://github.com/madmachineio/MadBoards)
* [ST7789](https://github.com/madmachineio/MadDrivers/tree/main/Sources/ST7789/ST7789.swift)


## How to use

1. Download the MadDrivers folder.
2. Open and run one of the examples in Visual Studio Code. If you are not familiar with the operation, you could refer to [this tutorial](https://docs.madmachine.io/overview/advanced/run-example).

28 changes: 28 additions & 0 deletions Examples/NV3007/DrawPixels/Sources/DrawPixels/main.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Draw a red square on a white background on the screen.
import SwiftIO
import MadBoard
import NV3007

let spi = SPI(Id.SPI0, speed: 30_000_000)
let cs = DigitalOut(Id.D1)
let dc = DigitalOut(Id.D5)
let rst = DigitalOut(Id.D0)
let bl = DigitalOut(Id.D2)

let screen = NV3007(spi: spi, cs: cs, dc: dc, rst: rst, bl: bl)

let white: UInt16 = 0xFFFF
let red: UInt16 = 0x00F8

screen.clearScreen(white)
sleep(ms: 1000)

for y in 50..<100 {
for x in 100..<200 {
screen.writePixel(x: x, y: y, color: red)
}
}

while true {
sleep(ms: 1000)
}
7 changes: 7 additions & 0 deletions Examples/NV3007/DrawUsingMadGraphics/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
17 changes: 17 additions & 0 deletions Examples/NV3007/DrawUsingMadGraphics/Package.mmp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

# Specify the board name below
# There are "SwiftIOBoard" and "SwiftIOMicro" now
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"

# Reserved for future use
version = 1
27 changes: 27 additions & 0 deletions Examples/NV3007/DrawUsingMadGraphics/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "DrawUsingMadGraphics",
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/madmachineio/SwiftIO.git", branch: "main"),
.package(url: "https://github.com/madmachineio/MadBoards.git", branch: "main"),
//.package(url: "https://github.com/madmachineio/MadDrivers.git", branch: "main"),
.package(path: "../../.."),
.package(url: "https://github.com/madmachineio/CFreeType.git", from: "2.13.2"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.executableTarget(
name: "DrawUsingMadGraphics",
dependencies: [
"SwiftIO",
"MadBoards",
// use specific library would speed up the compile procedure
.product(name: "NV3007", package: "MadDrivers"),
"CFreeType",
]),
]
)
17 changes: 17 additions & 0 deletions Examples/NV3007/DrawUsingMadGraphics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# DrawUsingMadGraphics

Use another library `MadGraphics` to draw graphics on the LCD. You'll fill the screen with yellow, draw an orange square in the middle and display the text "Hello world!".

## Library reference

* [SwiftIO](https://github.com/madmachineio/SwiftIO)
* [MadBoard](https://github.com/madmachineio/MadBoards)
* [ST7789](https://github.com/madmachineio/MadDrivers/tree/main/Sources/ST7789/ST7789.swift)
* [MadGraphics](https://madmachineio.github.io/MadGraphicsDocs/documentation/madgraphics/)


## How to use

1. Download the MadDrivers folder.
2. Open and run one of the examples in Visual Studio Code. If you are not familiar with the operation, you could refer to [this tutorial](https://docs.madmachine.io/overview/advanced/run-example).

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Use MadGraphics library to draw shapes and text on the screen.
import SwiftIO
import MadBoard
import NV3007
import MadGraphics


let spi = SPI(Id.SPI0, speed: 30_000_000)
let cs = DigitalOut(Id.D1)
let dc = DigitalOut(Id.D5)
let rst = DigitalOut(Id.D0)
let bl = DigitalOut(Id.D2)

let screen = NV3007(spi: spi, cs: cs, dc: dc, rst: rst, bl: bl)
var screenBuffer = [UInt16](repeating: 0, count: screen.width * screen.height)
var frameBuffer = [UInt32](repeating: 0, count: screen.width * screen.height)

let robotoFont = Font(path: "/lfs/Resources/Fonts/Roboto-Regular.ttf" , pointSize: 12, dpi: 160)

let rootLayer = Layer(width: screen.width, height: screen.height, backgroundColor: Pixel.yellow)
rootLayer.render(into: &frameBuffer, output: &screenBuffer, transform: Pixel.toRGB565LE) { dirty, data in
screen.writeBitmap(x: dirty.x, y: dirty.y, width: dirty.width, height: dirty.height, data: data)
}
sleep(ms: 1000)

let rect = Layer(at: Point(x: 20, y: 20), width: 200, height: 100, backgroundColor: Pixel.orange)
rootLayer.append(rect)
rootLayer.render(into: &frameBuffer, output: &screenBuffer, transform: Pixel.toRGB565LE) { dirty, data in
screen.writeBitmap(x: dirty.x, y: dirty.y, width: dirty.width, height: dirty.height, data: data)
}
sleep(ms: 1000)

let label = TextLayer(at: Point(x: 120, y: 60), anchorPoint: UnitPoint.center, string: "Hello world!", font: robotoFont, foregroundColor: Pixel.red)
rootLayer.append(label)
rootLayer.render(into: &frameBuffer, output: &screenBuffer, transform: Pixel.toRGB565LE) { dirty, data in
screen.writeBitmap(x: dirty.x, y: dirty.y, width: dirty.width, height: dirty.height, data: data)
}
sleep(ms: 1000)


while true {
sleep(ms: 1000)
}
5 changes: 5 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ let package = Package(
"MPL3115A2",
"MPU6050",
"MS5611",
"NV3007",
"PCF8523",
"PCF8563",
"SGP30",
Expand Down Expand Up @@ -80,6 +81,7 @@ let package = Package(
.library(name: "MPR121", targets: ["MPR121"]),
.library(name: "MPU6050", targets: ["MPU6050"]),
.library(name: "MS5611", targets: ["MS5611"]),
.library(name: "NV3007", targets: ["NV3007"]),
.library(name: "PCF8523", targets: ["PCF8523"]),
.library(name: "PCF8563", targets: ["PCF8563"]),
.library(name: "SGP30", targets: ["SGP30"]),
Expand Down Expand Up @@ -194,6 +196,9 @@ let package = Package(
.target(
name: "MS5611",
dependencies: ["SwiftIO"]),
.target(
name: "NV3007",
dependencies: ["SwiftIO"]),
.target(
name: "PCF8523",
dependencies: ["SwiftIO"]),
Expand Down
Loading