Skip to content

Commit 27f4a27

Browse files
committed
formatting
1 parent 0caf5dc commit 27f4a27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1557
-967
lines changed

.swift-format

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"fileScopedDeclarationPrivacy" : {
3+
"accessLevel" : "private"
4+
},
5+
"indentation" : {
6+
"spaces" : 2
7+
},
8+
"indentConditionalCompilationBlocks" : false,
9+
"indentSwitchCaseLabels" : false,
10+
"lineBreakAroundMultilineExpressionChainComponents" : false,
11+
"lineBreakBeforeControlFlowKeywords" : false,
12+
"lineBreakBeforeEachArgument" : false,
13+
"lineBreakBeforeEachGenericRequirement" : false,
14+
"lineLength" : 80,
15+
"maximumBlankLines" : 1,
16+
"multiElementCollectionTrailingCommas" : true,
17+
"noAssignmentInExpressions" : {
18+
"allowedFunctions" : [
19+
"XCTAssertNoThrow"
20+
]
21+
},
22+
"prioritizeKeepingFunctionOutputTogether" : false,
23+
"respectsExistingLineBreaks" : true,
24+
"rules" : {
25+
"AllPublicDeclarationsHaveDocumentation" : false,
26+
"AlwaysUseLowerCamelCase" : true,
27+
"AmbiguousTrailingClosureOverload" : false,
28+
"BeginDocumentationCommentWithOneLineSummary" : false,
29+
"DoNotUseSemicolons" : true,
30+
"DontRepeatTypeInStaticProperties" : true,
31+
"FileScopedDeclarationPrivacy" : true,
32+
"FullyIndirectEnum" : true,
33+
"GroupNumericLiterals" : true,
34+
"IdentifiersMustBeASCII" : true,
35+
"NeverForceUnwrap" : true,
36+
"NeverUseForceTry" : true,
37+
"NeverUseImplicitlyUnwrappedOptionals" : true,
38+
"NoAccessLevelOnExtensionDeclaration" : true,
39+
"NoAssignmentInExpressions" : true,
40+
"NoBlockComments" : false,
41+
"NoCasesWithOnlyFallthrough" : true,
42+
"NoEmptyTrailingClosureParentheses" : true,
43+
"NoLabelsInCasePatterns" : true,
44+
"NoLeadingUnderscores" : false,
45+
"NoParensAroundConditions" : true,
46+
"NoPlaygroundLiterals" : true,
47+
"NoVoidReturnOnFunctionSignature" : true,
48+
"OmitExplicitReturns" : true,
49+
"OneCasePerLine" : true,
50+
"OneVariableDeclarationPerLine" : true,
51+
"OnlyOneTrailingClosureArgument" : true,
52+
"OrderedImports" : true,
53+
"ReplaceForEachWithForLoop" : true,
54+
"ReturnVoidInsteadOfEmptyTuple" : true,
55+
"TypeNamesShouldBeCapitalized" : true,
56+
"UseEarlyExits" : true,
57+
"UseLetInEveryBoundCaseVariable" : true,
58+
"UseShorthandTypeNames" : true,
59+
"UseSingleLinePropertyGetter" : true,
60+
"UseSynthesizedInitializer" : true,
61+
"UseTripleSlashForDocumentationComments" : true,
62+
"UseWhereClausesInForLoops" : false,
63+
"ValidateDocumentationComments" : true
64+
},
65+
"spacesAroundRangeFormationOperators" : false,
66+
"tabWidth" : 2,
67+
"version" : 1
68+
}

esp32-led-strip-sdk/main/LedStrip.swift

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// A simple "overlay" to provide nicer APIs in Swift
1313
struct LedStrip {
1414
private let handle: led_strip_handle_t
15+
1516
init(gpioPin: Int, maxLeds: Int) {
1617
var handle = led_strip_handle_t(bitPattern: 0)
1718
var stripConfig = led_strip_config_t(
@@ -26,24 +27,27 @@ struct LedStrip {
2627
spi_bus: SPI2_HOST,
2728
flags: .init(with_dma: 1)
2829
)
29-
guard led_strip_new_spi_device(&stripConfig, &spiConfig, &handle) == ESP_OK else {
30-
fatalError("cannot configure spi device")
31-
}
32-
self.handle = handle!
30+
guard led_strip_new_spi_device(&stripConfig, &spiConfig, &handle) == ESP_OK,
31+
let handle = handle
32+
else { fatalError("cannot configure spi device") }
33+
self.handle = handle
3334
}
3435

35-
struct Color {
36-
var r, g, b: UInt8
36+
struct Color {
3737
static var white = Color(r: 255, g: 255, b: 255)
3838
static var lightWhite = Color(r: 16, g: 16, b: 16)
39-
static var lightRandom: Color {
40-
Color(r: .random(in: 0...16), g: .random(in: 0...16), b: .random(in: 0...16))
39+
static var lightRandom: Color {
40+
Color(
41+
r: .random(in: 0...16), g: .random(in: 0...16), b: .random(in: 0...16))
4142
}
4243
static var off = Color(r: 0, g: 0, b: 0)
44+
45+
var r, g, b: UInt8
4346
}
4447

4548
func setPixel(index: Int, color: Color) {
46-
led_strip_set_pixel(handle, UInt32(index), UInt32(color.r), UInt32(color.g), UInt32(color.b))
49+
led_strip_set_pixel(
50+
handle, UInt32(index), UInt32(color.r), UInt32(color.g), UInt32(color.b))
4751
}
4852

4953
func refresh() { led_strip_refresh(handle) }

esp32-led-strip-sdk/main/Main.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//===----------------------------------------------------------------------===//
1111

1212
@_cdecl("app_main")
13-
func app_main() {
13+
func main() {
1414
print("Hello from Swift on ESP32-C6!")
1515

1616
let n = 8
@@ -22,11 +22,11 @@ func app_main() {
2222
colors.removeLast()
2323
colors.insert(.lightRandom, at: 0)
2424

25-
for index in 0 ..< n {
25+
for index in 0..<n {
2626
ledStrip.setPixel(index: index, color: colors[index])
2727
}
2828
ledStrip.refresh()
29-
29+
3030
let blinkDelayMs: UInt32 = 500
3131
vTaskDelay(blinkDelayMs / (1000 / UInt32(configTICK_RATE_HZ)))
3232
}

nrfx-blink-sdk/Main.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ struct Main {
1414
static func main() {
1515
// Note: & in Swift is not the "address of" operator, but on a global variable declared in C
1616
// it will give the correct address of the global.
17-
gpio_pin_configure_dt(&led0, GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH | GPIO_OUTPUT_INIT_LOGICAL)
17+
gpio_pin_configure_dt(
18+
&led0, GPIO_OUTPUT | GPIO_OUTPUT_INIT_HIGH | GPIO_OUTPUT_INIT_LOGICAL)
1819
while true {
1920
gpio_pin_toggle_dt(&led0)
2021
k_msleep(100)

pico-blink-sdk/Main.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct Main {
1414
static func main() {
1515
let led = UInt32(PICO_DEFAULT_LED_PIN)
1616
gpio_init(led)
17-
gpio_set_dir(led, /*out*/true)
17+
gpio_set_dir(led, /*out*/ true)
1818
while true {
1919
gpio_put(led, true)
2020
sleep_ms(250)

pico-blink/Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import PackageDescription
55
let package = Package(
66
name: "RP2040",
77
products: [
8-
.library(name: "Blinky", type: .static, targets: ["Blinky"]),
8+
.library(name: "Blinky", type: .static, targets: ["Blinky"])
99
],
1010
targets: [
1111
.target(name: "Blinky", dependencies: ["RP2040"]),
1212
.target(name: "Support"),
13-
.target(name: "RP2040", dependencies: ["Support"])
13+
.target(name: "RP2040", dependencies: ["Support"]),
1414
]
1515
)

0 commit comments

Comments
 (0)