uEZ GUI Start Here Guide
UEZGUI-1788-56VI
Rev. 1.11 Aug 31, 2016
Page 23
All the tasks that will run in a project are called within main.c. In the following tasks we
will update main.c to create the new task.
1.
Open main.c
2.
Add the new #include shown below.
3.
Within the function MainTask(), find the existing UEZTaskCreate() function calls.
4.
Add a new UEZTaskCreate() function call for the temperature monitoring thread.
#include <uEZ.h>
#include <uEZTemperature.h>
#include <uEZGPIO.h>
#include <uEZProcessor.h>
#include "MyTask.h"
#include <stdio.h>
extern
void
UpdateTemp
(
char
*
myString
);
// Access to function in
SecondScreen.c
TUInt32 TemperatureLoopTask
(
T_uezTask aMyTask
,
void
*
aParams
) {
char
myString
[
10
]
=
""
;
// String to hold temperature
TInt32 i
,
f
;
// Variables for conversion
T_uezDevice temp
;
// uEZ device variable
TInt32 Temperature
;
// Variable to hold temperature reading
UEZTemperatureOpen
(
"Temp0"
,
&
temp
);
// Open the on board device
while
(
1
)
{
UEZTemperatureRead
(
temp
,
&
Temperature
);
// Read the temperature
// Convert to integer and decimal
i
=
Temperature
>>
16
;
f
=
((((
TUInt32
)
Temperature
)
&
0xFFFF
)
*
10
)
>>
16
;
sprintf
(
myString
,
"%02d.%01d *C"
,
i
,
f
);
// Print to text array
UpdateTemp
(
myString
);
// Update the temperature text on the screen
UEZTaskDelay
(
250
);
// Wait 1/4 seconds before reading again
}
}
#include "MyTask.h"
void
MainTask
(
void
) {
// Run the teperature reading task located in My.Task.c
UEZTaskCreate
(
TemperatureLoopTask
,
"Temperature"
,
1024
,
(
void
*)
0
,
UEZ_PRIORITY_NORMAL
,
0
);
//Start emWin
UEZTaskCreate
(
GUIInterfaceTask
,
"GUIInterface"
,
(
4
*
1024
),
(
void
*)
0
,
UEZ_PRIORITY_NORMAL
,
0
);
while
(
1
)
{
// Loop forever so that the main task never exits
UEZTaskDelay
(
1000
);
}
}