34 #include <sys/types.h>
40 #include "dsserverlogger.h"
48 #include "hostPersistence.hpp"
52 #define direct_list_top(list) ((list))
53 #define IARM_BUS_Lock(lock) pthread_mutex_lock(&fpLock)
54 #define IARM_BUS_Unlock(lock) pthread_mutex_unlock(&fpLock)
58 #ifndef dsFPD_BRIGHTNESS_DEFAULT
59 #define dsFPD_BRIGHTNESS_DEFAULT dsFPD_BRIGHTNESS_MAX
62 static int m_isInitialized = 0;
63 static int m_isPlatInitialized=0;
64 static pthread_mutex_t fpLock = PTHREAD_MUTEX_INITIALIZER;
66 IARM_Result_t dsFPDMgr_init();
67 IARM_Result_t dsFPDMgr_term();
68 IARM_Result_t _dsFPInit(
void *arg);
69 IARM_Result_t _dsFPTerm(
void *arg);
70 IARM_Result_t _dsSetFPText(
void *arg);
71 IARM_Result_t _dsSetFPTime(
void *arg);
72 IARM_Result_t _dsSetFPScroll(
void *arg);
73 IARM_Result_t _dsSetFPBlink(
void *arg);
74 IARM_Result_t _dsGetFPBrightness(
void *arg);
75 IARM_Result_t _dsSetFPBrightness(
void *arg);
76 IARM_Result_t _dsSetFPState(
void *arg);
77 IARM_Result_t _dsGetFPState(
void *arg);
78 IARM_Result_t _dsSetFPColor(
void *arg);
79 IARM_Result_t _dsGetFPColor(
void *arg);
80 IARM_Result_t _dsSetFPTextBrightness(
void *arg);
81 IARM_Result_t _dsGetFPTextBrightness(
void *arg);
82 IARM_Result_t _dsFPEnableCLockDisplay(
void *arg);
83 IARM_Result_t _dsGetTimeFormat(
void *arg);
84 IARM_Result_t _dsSetTimeFormat(
void *arg);
85 IARM_Result_t _dsSetFPDMode(
void *arg);
114 std::string numberToString (
int number);
115 int stringToNumber (std::string text);
116 std::string enumToColor (dsFPDColor_t enumColor);
118 std::string numberToString (
int number)
120 stringstream convert;
122 return convert.str();
126 int stringToNumber (std::string text)
129 stringstream convert (text);
131 if (!(convert >> number) )
137 std::string enumToColor (dsFPDColor_t enumColor)
140 stringstream convert;
166 convert << enumColor;
167 return convert.str();
173 IARM_Result_t dsFPDMgr_init()
183 int maxBrightness = dsFPD_BRIGHTNESS_DEFAULT;
186 _dsPowerBrightness = stringToNumber(value);
189 _dsTextBrightness = stringToNumber(value);
191 #if(dsFPD_BRIGHTNESS_DEFAULT != dsFPD_BRIGHTNESS_MAX)
197 INT_INFO(
"Applying new default brightness to power indicator. Changing from %d to %d.\n", _dsPowerBrightness, dsFPD_BRIGHTNESS_DEFAULT);
198 _dsPowerBrightness = dsFPD_BRIGHTNESS_DEFAULT;
202 INT_INFO(
"Applying new default brightness to text indicator. Changing from %d to %d.\n", _dsTextBrightness, dsFPD_BRIGHTNESS_DEFAULT);
203 _dsTextBrightness = dsFPD_BRIGHTNESS_DEFAULT;
207 INT_INFO(
"Power Brightness Read from Persistent is %d \r\n",_dsPowerBrightness);
208 INT_INFO(
"Text Brightness Read from Persistent is %d \r\n",_dsTextBrightness);
210 #ifdef HAS_CLOCK_DISPLAY
211 string _TimeFormat(
"12_HOUR");
214 if (_TimeFormat.compare(
"12_HOUR") == 0)
219 else if (_TimeFormat.compare(
"24_HOUR") == 0)
224 INT_INFO(
"Clock Time Format Read from Persistent is %s \r\n",_TimeFormat.c_str());
230 INT_ERROR(
"Error in Reading Brightness Value On Startup.. Use Default value \r\n");
233 return IARM_RESULT_SUCCESS;
236 IARM_Result_t dsFPDMgr_term()
238 return IARM_RESULT_SUCCESS;
241 IARM_Result_t _dsFPInit(
void *arg)
246 if (!m_isInitialized) {
248 INT_INFO(
"<<<<< called _dsFPInit >>>>>>>>\r\n");
281 if (!m_isPlatInitialized) {
283 m_isPlatInitialized = 1;
286 IARM_BUS_Unlock(lock);
288 return IARM_RESULT_SUCCESS;
290 IARM_Result_t _dsFPTerm(
void *arg)
298 if (m_isPlatInitialized) {
300 m_isPlatInitialized = 0;
303 IARM_BUS_Unlock(lock);
305 return IARM_RESULT_SUCCESS;
308 IARM_Result_t _dsSetFPText(
void *arg)
312 IARM_Result_t ret = IARM_RESULT_SUCCESS;
313 #ifdef HAS_CLOCK_DISPLAY
320 ret = IARM_RESULT_INVALID_PARAM;
324 INT_INFO(
"_dsSetFPText: Not setting Text, Clock mode enabled \r\n");
327 IARM_BUS_Unlock(lock);
333 IARM_Result_t _dsSetFPTime(
void *arg)
337 IARM_Result_t ret = IARM_RESULT_SUCCESS;
338 #ifdef HAS_CLOCK_DISPLAY
346 ret = IARM_RESULT_INVALID_PARAM;
350 INT_INFO(
"_dsSetFPTime: Not setting Clock, Text mode enabled \r\n");
353 IARM_BUS_Unlock(lock);
359 IARM_Result_t _dsSetFPScroll(
void *arg)
363 IARM_Result_t ret = IARM_RESULT_SUCCESS;
364 #ifdef HAS_CLOCK_DISPLAY
368 dsError_t dsStatus =
dsSetFPScroll(param->nScrollHoldOnDur, param->nHorzScrollIterations, param->nVertScrollIterations);
371 ret = IARM_RESULT_INVALID_PARAM;
374 IARM_BUS_Unlock(lock);
380 IARM_Result_t _dsSetFPBlink(
void *arg)
383 IARM_Result_t ret = IARM_RESULT_SUCCESS;
387 dsError_t dsStatus =
dsSetFPBlink(param->eIndicator, param->nBlinkDuration, param->nBlinkIterations);
390 ret = IARM_RESULT_INVALID_PARAM;
393 IARM_BUS_Unlock(lock);
397 IARM_Result_t _dsGetFPBrightness(
void *arg)
410 param->eBrightness = _dsPowerBrightness;
412 INT_INFO(
"_dsGetFPBrightness Power Brightness is %d \r\n",param->eBrightness);
414 IARM_BUS_Unlock(lock);
415 return IARM_RESULT_SUCCESS;
421 IARM_Result_t _dsSetFPBrightness(
void *arg)
424 IARM_Result_t ret = IARM_RESULT_SUCCESS;
435 srvFPDSettings[param->eIndicator].brightness = param->eBrightness;
438 switch (param->eIndicator)
442 INT_INFO(
"_dsSetFPBrightness Power Brightness From App is %d \r\n",param->eBrightness);
446 _dsPowerBrightness = param->eBrightness;
464 INT_ERROR(
"Error in Persisting the Power Brightness Value \r\n");
469 ret = IARM_RESULT_INVALID_PARAM;
475 ret = IARM_RESULT_INVALID_PARAM;
480 IARM_BUS_Unlock(lock);
485 IARM_Result_t _dsGetFPTextBrightness(
void *arg)
489 #ifdef HAS_CLOCK_DISPLAY
496 param->eBrightness = _dsTextBrightness;
497 INT_INFO(
"_dsGetFPTextBrightness Brightness is %d \r\n",param->eBrightness);
499 IARM_BUS_Unlock(lock);
501 return IARM_RESULT_SUCCESS;
504 IARM_Result_t _dsSetFPTextBrightness(
void *arg)
507 IARM_Result_t ret = IARM_RESULT_SUCCESS;
508 #ifdef HAS_CLOCK_DISPLAY
521 switch (param->eIndicator)
525 INT_INFO(
"_dsSetFPTextBrightness Brightness frm App is %d \r\n",param->eBrightness);
526 _dsTextBrightness = param->eBrightness;
538 INT_ERROR(
"Error in Persisting the Text Brightness Value \r\n");
543 ret = IARM_RESULT_INVALID_PARAM;
549 ret = IARM_RESULT_INVALID_PARAM;
552 IARM_BUS_Unlock(lock);
559 IARM_Result_t _dsGetFPColor(
void *arg)
566 IARM_BUS_Unlock(lock);
567 return IARM_RESULT_SUCCESS;
571 IARM_Result_t _dsSetFPColor(
void *arg)
574 IARM_Result_t ret = IARM_RESULT_SUCCESS;
581 param->eColor &= 0x00FFFFFF;
583 INT_INFO(
"_dsSetFPColor Value From App is %d for Indicator %d \r\n",param->eColor,param->eIndicator);
585 switch (param->eIndicator)
591 _dsPowerLedColor = param->eColor;
608 INT_ERROR(
"Error in Persisting the Color Value \r\n");
613 INT_ERROR(
"Error in dsSetFPColor dsStatus:%d \r\n",dsStatus);
614 ret = IARM_RESULT_INVALID_PARAM;
616 IARM_BUS_Unlock(lock);
622 IARM_Result_t _dsFPEnableCLockDisplay(
void *arg)
625 IARM_Result_t ret = IARM_RESULT_SUCCESS;
626 #ifdef HAS_CLOCK_DISPLAY
628 int *enable = (
int *)arg;
629 int lenable = *enable;
633 ret = IARM_RESULT_INVALID_PARAM;
635 IARM_BUS_Unlock(lock);
641 IARM_Result_t _dsSetFPState(
void *arg)
644 IARM_Result_t ret = IARM_RESULT_SUCCESS;
660 INT_INFO(
"_dsSetFPState Setting Power LED to ON with Brightness %d \r\n",_dsPowerBrightness);
666 ret = IARM_RESULT_INVALID_PARAM;
675 INT_INFO(
"_dsSetFPState Setting Power LED to OFF with Brightness 0 \r\n");
681 ret = IARM_RESULT_INVALID_PARAM;
685 IARM_BUS_Unlock(lock);
692 IARM_Result_t _dsGetTimeFormat(
void *arg)
696 #ifdef HAS_CLOCK_DISPLAY
703 INT_INFO(
"Error:_dsGetTimeFormat : NULL Param ... \r\n");
704 IARM_BUS_Unlock(lock);
705 return IARM_RESULT_INVALID_PARAM;
708 param->eTime = _dsTextTimeFormat;
710 IARM_BUS_Unlock(lock);
712 return IARM_RESULT_SUCCESS;
715 IARM_Result_t _dsSetTimeFormat(
void *arg)
719 #ifdef HAS_CLOCK_DISPLAY
727 INT_INFO(
"Error:_dsSetTimeFormat : NULL Param ... \r\n");
728 IARM_BUS_Unlock(lock);
729 return IARM_RESULT_INVALID_PARAM;
732 if (param->eTime != _dsTextTimeFormat)
734 _dsTextTimeFormat = param->eTime;
739 INT_INFO(
"Clock Time Format Updated to 12_HOUR ... \r\n");
744 INT_INFO(
"Clock Time Format Updated to 24_HOUR ... \r\n");
751 _eventData.data.FPDTimeFormat.eTimeFormat = _dsTextTimeFormat;
756 INT_INFO(
"Sent Clock IARM_BUS_DSMGR_EVENT_TIME_FORMAT_CHANGE event ... \r\n");
759 IARM_BUS_Unlock(lock);
763 return IARM_RESULT_SUCCESS;
767 IARM_Result_t _dsGetFPState(
void *arg)
774 if(param->eIndicator < dsFPD_INDICATOR_MAX)
779 IARM_BUS_Unlock(lock);
780 return IARM_RESULT_SUCCESS;
784 IARM_Result_t _dsSetFPDMode(
void *arg)
792 _dsFPDMode = param->eMode;
793 INT_INFO(
"_dsSetFPDMode: Mode set to %d \r\n",param->eMode);
796 INT_INFO(
"Error:_dsSetFPDMode : Invalid Param ... \r\n");
797 IARM_BUS_Unlock(lock);
798 return IARM_RESULT_INVALID_PARAM;
801 IARM_BUS_Unlock(lock);
802 return IARM_RESULT_SUCCESS;