Skip to content
Open
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
35 changes: 35 additions & 0 deletions lvgl/_demo/example/demo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main

import (
"time"

"github.com/goplus/lib/c"
"github.com/goplus/llpkg/lvgl"
)

func main() {
// Initialize LVGL
lvgl.Init()
disp := lvgl.SdlWindowCreate(480, 320)
lvgl.SdlMouseCreate()
lvgl.SdlKeyboardCreate()

disp.SdlWindowSetZoom(1.0)
disp.SdlWindowSetTitle(c.Str("Profile Page"))

//lv_example_style_1() // 背景
//lv_example_style_2() // 渐变 -- 有问题
//lv_example_style_3() // 边框
//lv_example_style_4() // 轮廓
//lv_example_style_5() // 阴影
//lv_example_style_6() // 图片
lv_example_get_started_2() // 按钮
//lv_example_get_started_3() // 滑块
//lv_example_get_started_4() // 标签
//lv_example_anim_1() // 动画
// Main event loop
for {
lvgl.TimerHandler()
time.Sleep(time.Millisecond * 5)
}
}
39 changes: 39 additions & 0 deletions lvgl/_demo/example/lv_example_get_started_2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package main

import (
"github.com/goplus/lib/c"
"github.com/goplus/llpkg/lvgl"
)

//var cnt uint8 = 0

func btn_event_cb(e *lvgl.EventT) {
code := e.EventGetCode()
btn := e.EventGetTarget()
//fmt.Println("code", code)
if code == lvgl.EVENT_CLICKED {

//cnt++
/*Get the first child of the button which is the label and change its text*/
label := (*lvgl.ObjT)(btn).ObjGetChild(0)

// c.Str(btnstr)

label.LabelSetTextFmt(c.Str("test"))
}
}

/**
* Create a button with a label and react on click event.
*/
func lv_example_get_started_2() {
objT := lvgl.ScreenActive()
btn := objT.ButtonCreate() /*Add a button the current screen*/
btn.ObjSetPos(10, 10) /*Set its position*/
btn.ObjSetSize(120, 50) /*Set its size*/
btn.ObjAddEventCb(btn_event_cb, lvgl.EVENT_ALL, nil) /*Assign a callback to the button*/

label := btn.LabelCreate() /*Add a label to the button*/
label.LabelSetText(c.Str("Button")) /*Set the labels text*/
label.ObjCenter()
}
5 changes: 5 additions & 0 deletions lvgl/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/goplus/llpkg/lvgl

go 1.20

require github.com/goplus/lib v0.2.0
2 changes: 2 additions & 0 deletions lvgl/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/goplus/lib v0.2.0 h1:AjqkN1XK5H23wZMMlpaUYAMCDAdSBQ2NMFrLtSh7W4g=
github.com/goplus/lib v0.2.0/go.mod h1:SgJv3oPqLLHCu0gcL46ejOP3x7/2ry2Jtxu7ta32kp0=
13 changes: 13 additions & 0 deletions lvgl/llcppg.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "lvgl",
"cflags": "$(pkg-config --cflags lvgl)",
"libs": "$(pkg-config --libs lvgl sdl2)",
"include": [
"lvgl_private.h",
"lvgl.h",
"lv_conf.h",
"lv_version.h"
],
"trimPrefixes": ["lv_", "LV_"],
"staticLib": true
}
Loading
Loading