Skip to content

Commit c5770e0

Browse files
committed
Fix lint/formatting in stm32-lvgl
1 parent f011d04 commit c5770e0

File tree

4 files changed

+33
-26
lines changed

4 files changed

+33
-26
lines changed

stm32-lvgl/Package.swift

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ let package = Package(
4747
//
4848
// HOST TARGETS
4949
//
50-
51-
.executableTarget(name: "HostSDLApp", dependencies: [
50+
51+
.executableTarget(
52+
name: "HostSDLApp",
53+
dependencies: [
5254
.product(name: "SDL", package: "SwiftSDL2"),
53-
"CLVGL"
54-
],
55-
swiftSettings: [.enableExperimentalFeature("Extern")],
56-
linkerSettings: [.unsafeFlags(["-L.build/lvgl-host/lib", "-llvgl", "-llvgl_demos"])]),
55+
"CLVGL",
56+
],
57+
swiftSettings: [.enableExperimentalFeature("Extern")],
58+
linkerSettings: [.unsafeFlags(["-L.build/lvgl-host/lib", "-llvgl", "-llvgl_demos"])]),
5759
])

stm32-lvgl/Sources/Application/Main.swift

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ struct Main {
5555
log("initSysTick")
5656
initSysTick()
5757

58+
log("TouchPanel.initialize()")
59+
TouchPanel.initialize()
60+
5861
// Everything is initialized now. Run application logic.
5962

6063
//log("dramTest()")
6164
//dramTest()
6265

63-
log("TouchPanel.initialize()")
64-
TouchPanel.initialize()
65-
6666
log("lvglDemo()")
6767
lvglDemo()
6868
}
@@ -103,13 +103,11 @@ struct Main {
103103

104104
let bufSize: UInt32 = UInt32(Lcd.LCD_WIDTH * Lcd.LCD_HEIGHT * 4)
105105
let buf1 = UnsafeMutableRawPointer(bitPattern: 0xC000_0000 as UInt)!
106-
let buf2 = UnsafeMutableRawPointer(
107-
bitPattern: (0xC000_0000 as UInt) + UInt(bufSize))!
106+
let buf2 = UnsafeMutableRawPointer(bitPattern: (0xC000_0000 as UInt) + UInt(bufSize))!
108107

109108
let disp = lv_display_create(Int32(Lcd.LCD_WIDTH), Int32(Lcd.LCD_HEIGHT))!
110109
lv_display_set_color_format(disp, LV_COLOR_FORMAT_ARGB8888)
111-
lv_display_set_buffers(
112-
disp, buf1, buf2, bufSize, LV_DISPLAY_RENDER_MODE_FULL)
110+
lv_display_set_buffers(disp, buf1, buf2, bufSize, LV_DISPLAY_RENDER_MODE_FULL)
113111
lv_display_set_flush_cb(
114112
disp,
115113
{ disp, _, bufferToShow in
@@ -140,10 +138,10 @@ struct Main {
140138
data!.pointee.point.x = Int32(touchData.x)
141139
data!.pointee.point.y = Int32(touchData.y)
142140
data!.pointee.state = LV_INDEV_STATE_PRESSED
143-
print("pressed: \(touchData.x) \(touchData.y)")
141+
//print("pressed: \(touchData.x) \(touchData.y)")
144142
} else {
145143
data!.pointee.state = LV_INDEV_STATE_RELEASED
146-
print("released")
144+
//print("released")
147145
}
148146
})
149147

@@ -152,13 +150,12 @@ struct Main {
152150

153151
log("LVGL setup done, starting render loop")
154152

155-
var frameCounter = 0
156153
while true {
157154
// If we're pending a render, wait.
158155
while lcdInterruptVerticalSyncHandler != nil { /* busy wait */ nop() }
159156

160157
lv_timer_handler()
161-
158+
162159
// Update UI of application logic
163160
UIAppLogic.updateFrame()
164161
}

stm32-lvgl/Sources/Application/UIAppLogic.swift

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ enum UIAppLogic {
2626
static var style = lv_style_t()
2727
static var labelStyle = lv_style_t()
2828
static var gradient = lv_grad_dsc_t()
29-
29+
3030
static var widgetDemoScreen: OpaquePointer! = nil
3131

32-
static func createUI() {
32+
static func createUI() {
3333
// Get the active screen
3434
let screen = lv_screen_active()
3535

@@ -60,21 +60,25 @@ enum UIAppLogic {
6060
buttonLabel = lv_label_create(button)
6161
lv_label_set_text(buttonLabel, "Click me")
6262
lv_obj_center(buttonLabel)
63-
lv_obj_add_event_cb(button, { event in
63+
lv_obj_add_event_cb(
64+
button,
65+
{ event in
6466
Self.clickCount += 1
6567
lv_label_set_text(Self.buttonLabel, "Clicked \(Self.clickCount)")
6668
}, LV_EVENT_CLICKED, nil)
67-
69+
6870
// Create a 'Demo' button in the bottom right
6971
let demoButton = lv_button_create(screen)
7072
lv_obj_set_size(demoButton, 120, 50)
7173
lv_obj_align(demoButton, LV_ALIGN_BOTTOM_RIGHT, -10, -10)
7274
let demoButtonLabel = lv_label_create(demoButton)
7375
lv_label_set_text(demoButtonLabel, "Widget Demo")
7476
lv_obj_center(demoButtonLabel)
75-
lv_obj_add_event_cb(demoButton, { event in
77+
lv_obj_add_event_cb(
78+
demoButton,
79+
{ event in
7680
lv_screen_load(Self.widgetDemoScreen)
77-
}, LV_EVENT_CLICKED, nil)
81+
}, LV_EVENT_CLICKED, nil)
7882

7983
// Create a label
8084
let label = lv_label_create(screen)
@@ -118,7 +122,7 @@ enum UIAppLogic {
118122
lv_label_set_text(spinnerLabel, "Loading...")
119123
lv_obj_align(spinnerLabel, LV_ALIGN_BOTTOM_LEFT, 20, -20)
120124
lv_obj_add_style(spinnerLabel, &labelStyle, 0)
121-
125+
122126
// Create a 2nd screen with the widgets demo app from LVGL, then switch back
123127
// to the original screen.
124128
widgetDemoScreen = lv_obj_create(nil)

stm32-lvgl/Sources/HostSDLApp/Main.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,18 @@ struct Main {
3838
let disp = lv_display_create(Int32(drawSize.width), Int32(drawSize.height))!
3939
lv_display_set_color_format(disp, LV_COLOR_FORMAT_ARGB8888)
4040
lv_display_set_buffers(disp, buf1, buf2, bufSize, LV_DISPLAY_RENDER_MODE_FULL)
41-
lv_display_set_flush_cb(disp, { disp, _, bufferToShow in
41+
lv_display_set_flush_cb(
42+
disp,
43+
{ disp, _, bufferToShow in
4244
_ = SDL_UpdateTexture(texture, nil, bufferToShow, Int32(drawSize.width * 4))
4345
lv_display_flush_ready(disp)
4446
})
4547

4648
let touch = lv_indev_create()
4749
lv_indev_set_type(touch, LV_INDEV_TYPE_POINTER)
48-
lv_indev_set_read_cb(touch, { indev, data in
50+
lv_indev_set_read_cb(
51+
touch,
52+
{ indev, data in
4953
if mouseEvent.type == SDL_MOUSEBUTTONDOWN.rawValue {
5054
data!.pointee.point.x = Int32(mouseEvent.button.x) / windowScale
5155
data!.pointee.point.y = Int32(mouseEvent.button.y) / windowScale

0 commit comments

Comments
 (0)