PIC24 Support Libraries
esos_f14ui.c
1 /*******************************************************************
2  *
3  * C code framework for ESOS user-interface (UI) service
4  *
5  * requires the EMBEDDED SYSTEMS target rev. F14
6  *
7  * ****************************************************************/
8 # include esos_f14ui.h;
9 
10 // PRIVATE FUNCTIONS
11 inline void _esos_uiF14_setRPGCounter (uint16_t newValue) {
12  _st_esos_uiF14Data.u16_RPGCounter = newValue;
13  return;
14 }
15 
16 inline void _esos_uiF14_setLastRPGCounter (uint16_t newValue) {
17  _st_esos_uiF14Data.u16_lastRPGCounter = newValue;
18  return;
19 }
20 
21 // PUBLIC SWITCH FUNCTIONS
22 inline BOOL esos_uiF14_getSW1Pressed (void) {
23  return (_st_esos_uiF14Data.b_SW1Pressed==TRUE);
24 }
25 
26 inline BOOL esos_uiF14_getSW1Released (void) {
27  return (_st_esos_uiF14Data.b_SW1Pressed==FALSE);
28 }
29 
30 inline BOOL esos_uiF14_getSW1DoublePressed (void) {
31  return (_st_esos_uiF14Data.b_SW1DoublePressed==TRUE);
32 }
33 
34 /***** SW2 and SW3 need need similar *****/
35 
36 // PUBLIC LED FUNCTIONS
37 
38 inline BOOL esos_uiF14_isLED1On (void) {
39  return (_st_esos_uiF14Data.b_LED1On==TRUE);
40 }
41 
42 inline BOOL esos_uiF14_isLED1Off (void) {
43  return (_st_esos_uiF14Data.b_LED1On==FALSE);
44 }
45 
46 inline void esos_uiF14_turnLED1On (void) {
47  _st_esos_uiF14Data.b_LED1On = TRUE;
48  return;
49 }
50 
51 inline void esos_uiF14_turnLED1Off (void) {
52  _st_esos_uiF14Data.b_LED1On = FALSE;
53  return;
54 }
55 
56 inline void esos_uiF14_toggleLED1 (void) {
57  _st_esos_uiF14Data.b_LED1On ^= 1;
58  return;
59 }
60 
61 inline void esos_uiF14_flashLED1( uint16_t u16_period) {
62  _st_esos_uiF14Data.u16_LED1FlashPeriod = u16_period;
63  return
64 }
65 
66 /****** LED2 and LED3 will need similar. ********/
67 /****** RED, GREEN, and YELLOW functions need to be created *******/
68 
69 // PUBLIC RPG FUNCTIONS
70 
71 inline uint16_t esos_uiF14_getRpgValue_u16 ( void ) {
72  return _st_esos_uiF14Data.u16_RPGCounter;
73 }
74 
75 inline BOOL esos_uiF14_isRpgTurning ( void ) {
76  return (esos_uiF14_getRpgVelocity_i16() != 0);
77 }
78 
79 inline BOOL esos_uiF14_isRpgTurningSlow( void ) {
80  // not yet implemented
81 }
82 
83 inline BOOL esos_uiF14_isRpgTurningMedium( void ) {
84  // not yet implemented
85 }
86 
87 inline BOOL esos_uiF14_isRpgTurningFast( void ) {
88  // not yet implemented
89 }
90 
91 inline BOOL esos_uiF14_isRpgTurningCW( void ) {
92  // not yet implemented
93 }
94 
95 inline BOOL esos_uiF14_isRpgTurningCCW( void ) {
96  // not yet implemented
97 }
98 
99 int16_t esos_uiF14_getRpgVelocity_i16( void ) {
100  // not yet implemented
101 }
102 
103 // UIF14 INITIALIZATION FUNCTION
104 
105 void config_esos_uiF14() {
106  // setup your UI implementation
107  esos_RegisterTask( __uiF14_task );
108 }
109 
110 
111 // UIF14 task to manage user-interface
112 ESOS_USER_TASK( __esos_uiF14_task ){
113 
114  ESOS_TASK_BEGIN();
115  while(TRUE) {
116  // do your UI stuff here
117  ESOS_TASK_WAIT_TICKS( __ESOS_UIF14_UI_PERIOD );
118  }
119  ESOS_TASK_END();
120 }
ESOS_TASK_HANDLE esos_RegisterTask(uint8_t(*taskname)(ESOS_TASK_HANDLE pstTask))
Definition: esos.c:86
BOOL
Definition: all_generic.h:402
#define ESOS_TASK_WAIT_TICKS(u32_duration)
Definition: esos_task.h:376
#define ESOS_TASK_END()
Definition: esos_task.h:272
#define ESOS_TASK_BEGIN()
Definition: esos_task.h:260
ESOS_USER_TASK(CANFactory)
Definition: esos_ecan.c:70