-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a demo demonstrating the use of the OSAL. Resolves: lvgl#6049
- Loading branch information
Showing
10 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# OSAL demo | ||
|
||
## Overview | ||
|
||
A OSAL test for LVGL. | ||
|
||
|
||
## Run the demo | ||
- In `lv_conf.h` or equivalent places set `LV_USE_DEMO_OSAL 1` | ||
- In `lv_conf.h` enable all the widgets (`LV_USE_BUTTON 1`) and the label (`LV_USE_LABEL 1`) | ||
- After `lv_init()` and initializing the drivers call `lv_demo_osal()` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* @file lv_demo_osal.c | ||
* | ||
*/ | ||
|
||
/********************* | ||
* INCLUDES | ||
*********************/ | ||
#include "lv_demo_osal.h" | ||
|
||
#if LV_USE_DEMO_OSAL | ||
|
||
/********************* | ||
* DEFINES | ||
*********************/ | ||
|
||
/********************** | ||
* TYPEDEFS | ||
**********************/ | ||
|
||
/********************** | ||
* STATIC PROTOTYPES | ||
**********************/ | ||
static void counter_button_event_cb(lv_event_t * e); | ||
static void increment_thread_entry(void * user_data); | ||
|
||
/********************** | ||
* STATIC VARIABLES | ||
**********************/ | ||
static lv_thread_sync_t press_sync; | ||
static lv_thread_t increment_thread; | ||
|
||
/********************** | ||
* MACROS | ||
**********************/ | ||
|
||
/********************** | ||
* GLOBAL FUNCTIONS | ||
**********************/ | ||
|
||
void lv_demo_osal(void) | ||
{ | ||
lv_obj_t * counter_button; | ||
|
||
counter_button = lv_button_create(lv_screen_active()); | ||
lv_obj_align(counter_button, LV_ALIGN_CENTER, 0, -15); | ||
lv_obj_add_event_cb(counter_button, counter_button_event_cb, LV_EVENT_CLICKED, NULL); | ||
|
||
if(lv_thread_sync_init(&press_sync) != LV_RESULT_OK) { | ||
LV_LOG_ERROR("Error initializing thread sync"); | ||
} | ||
|
||
if(lv_thread_init(&increment_thread, LV_THREAD_PRIO_MID, increment_thread_entry, 2048, NULL) != LV_RESULT_OK) { | ||
LV_LOG_ERROR("Error initializing thread"); | ||
} | ||
} | ||
|
||
/********************** | ||
* STATIC FUNCTIONS | ||
**********************/ | ||
|
||
void counter_button_event_cb(lv_event_t * e) | ||
{ | ||
if(lv_thread_sync_signal(&press_sync) != LV_RESULT_OK) { | ||
LV_LOG_ERROR("Error signaling thread sync"); | ||
} | ||
} | ||
|
||
void increment_thread_entry(void * user_data) | ||
{ | ||
lv_obj_t * counter_label; | ||
uint32_t press_count = 0; | ||
|
||
counter_label = lv_label_create(lv_scr_act()); | ||
lv_obj_align(counter_label, LV_ALIGN_CENTER, 0, 0); | ||
lv_label_set_text_fmt("Pressed %u times", press_count); | ||
|
||
while(true) { | ||
if(lv_thread_sync_wait(&press_sync) != LV_RESULT_OK) { | ||
LV_LOG_ERROR("Error awaiting thread sync"); | ||
} | ||
press_count += 1; | ||
lv_label_set_text_fmt("Pressed %u times", press_count); | ||
} | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* @file lv_demo_osal.h | ||
* | ||
*/ | ||
|
||
#ifndef LV_DEMO_OSAL_H | ||
#define LV_DEMO_OSAL_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/********************* | ||
* INCLUDES | ||
*********************/ | ||
#include "../lv_demos.h" | ||
|
||
/********************* | ||
* DEFINES | ||
*********************/ | ||
|
||
/********************** | ||
* TYPEDEFS | ||
**********************/ | ||
|
||
/********************** | ||
* GLOBAL PROTOTYPES | ||
**********************/ | ||
void lv_demo_osal(void); | ||
|
||
/********************** | ||
* MACROS | ||
**********************/ | ||
|
||
#ifdef __cplusplus | ||
} /* extern "C" */ | ||
#endif | ||
|
||
#endif /*LV_DEMO_OSAL_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters