|
200 | 200 | import display_driver |
201 | 201 | import lvgl as lv |
202 | 202 |
|
203 | | -import lvgl |
204 | 203 |
|
205 | | -button = lvgl.button( lvgl.screen_active() ) |
| 204 | + |
| 205 | +button = lv.button( lv.screen_active() ) |
206 | 206 | button.set_size( 50, 20 ) |
207 | 207 | button.center() |
208 | 208 |
|
209 | | -anim1 = lvgl.anim_t() |
| 209 | +anim1 = lv.anim_t() |
210 | 210 | anim1.init() |
211 | 211 | anim1.set_var( button ) |
212 | 212 | anim1.set_time( 1000 ) |
213 | 213 | anim1.set_values( -100, 100 ) |
214 | 214 | anim1.set_custom_exec_cb( lambda not_used, value : button.set_x( value )) |
215 | 215 |
|
216 | | -anim2 = lvgl.anim_t() |
| 216 | +anim2 = lv.anim_t() |
217 | 217 | anim2.init() |
218 | 218 | anim2.set_var( button ) |
219 | 219 | anim2.set_time( 150 ) |
220 | 220 | anim2.set_values( 100, 30 ) |
221 | 221 | anim2.set_custom_exec_cb( lambda not_used, value : button.set_x( value )) |
222 | 222 |
|
223 | | -anim3 = lvgl.anim_t() |
| 223 | +anim3 = lv.anim_t() |
224 | 224 | anim3.init() |
225 | 225 | anim3.set_var( button ) |
226 | 226 | anim3.set_time( 2000 ) |
227 | 227 | anim3.set_values( 30, -100 ) |
228 | 228 | anim3.set_custom_exec_cb( lambda not_used, value : button.set_x( value )) |
229 | 229 |
|
230 | | -time = lvgl.anim_timeline_create() |
| 230 | +timeline = lv.anim_timeline_create() |
| 231 | + |
| 232 | + |
| 233 | +# this works: |
| 234 | +lv.anim_timeline_t.add(timeline,0,anim1) |
| 235 | +lv.anim_timeline_t.add(timeline,2000,anim2) |
| 236 | +lv.anim_timeline_t.add(timeline,3150,anim3) |
231 | 237 |
|
232 | | -# somehow this doesn't work: |
233 | | -#lvgl.anim_timeline_add( time, 0, anim1 ) |
234 | | -#lvgl.anim_timeline_add( time, 1000, anim2 ) |
235 | | -#lvgl.anim_timeline_add( time, 1150, anim3 ) |
| 238 | +lv.anim_timeline_t.start(timeline) |
236 | 239 |
|
237 | | -#lvgl.anim_timeline_start( time ) |
| 240 | +# to restart it: |
| 241 | +#lv.anim_timeline_t.set_progress(timeline, 0) |
| 242 | +#lv.anim_timeline_t.start(timeline) |
238 | 243 |
|
| 244 | +# or to reverse it: |
| 245 | +#lv.anim_timeline_t.set_reverse(timeline,True) |
| 246 | +#lv.anim_timeline_t.start(timeline) |
| 247 | +#lv.anim_timeline_t.set_reverse(timeline,False) |
| 248 | +#lv.anim_timeline_t.start(timeline) |
| 249 | +# progress max is 65535, not 32k |
| 250 | +#lv.anim_timeline_t.set_progress(timeline,65535) |
| 251 | +#lv.anim_timeline_t.start(timeline) |
239 | 252 |
|
240 | 253 |
|
241 | 254 |
|
|
0 commit comments