HSA_LCD_Shield.cpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // //
  3. // Programname: HSA_LCD_Shield - Code //
  4. // Date: 16.11.2018 //
  5. // Description: Code-File of the LCD-Shield, which was designed and built in //
  6. // the Modul "Elektronikdesign". In this file you can find the //
  7. // code of all functions mentioned in the Header-File of the //
  8. // class. //
  9. // //
  10. // Author: Tobias Müller, M. Eng. //
  11. // //
  12. ////////////////////////////////////////////////////////////////////////////////
  13. ////////////////////////////////////////////////////////////////////////////////
  14. //////////////////// Include Header-File ////////////////////
  15. ////////////////////////////////////////////////////////////////////////////////
  16. #include "HSA_LCD_Shield.h"
  17. ////////////////////////////////////////////////////////////////////////////////
  18. //////////////////// Protected Functions ////////////////////
  19. ////////////////////////////////////////////////////////////////////////////////
  20. //////////////////// GPIO Configuration ////////////////////
  21. bool HSA_LCD_Shield::__gpioConfig(void) {
  22. // Save Pin configuration, depending of LCD-Shield version
  23. if(this->__version == LCD_VERSION_5) {
  24. // Save Pin configuration for buttons
  25. this->__buttonUp = BUTTON_UP_V5;
  26. this->__buttonRight = BUTTON_RIGHT_V5;
  27. this->__buttonDown = BUTTON_DOWN_V5;
  28. this->__buttonLeft = BUTTON_LEFT_V5;
  29. // Save Pin configuration for LEDs
  30. this->__ledGreen = LED_GREEN_V5;
  31. this->__ledRed = LED_RED_V5;
  32. // Save Pin configuration for LCD-Backlight
  33. this->__lcdBacklight = LCD_BACKLIGHT_V5;
  34. }
  35. else if(this->__version == LCD_VERSION_6) {
  36. // Save Pin configuration for buttons
  37. this->__buttonUp = BUTTON_UP_V6;
  38. this->__buttonRight = BUTTON_RIGHT_V6;
  39. this->__buttonDown = BUTTON_DOWN_V6;
  40. this->__buttonLeft = BUTTON_LEFT_V6;
  41. // Save Pin configuration for LEDs
  42. this->__ledGreen = LED_GREEN_V6;
  43. this->__ledRed = LED_RED_V6;
  44. // Save Pin configuration for LCD-Backlight
  45. this->__lcdBacklight = LCD_BACKLIGHT_V6;
  46. }
  47. // If LCD-Shield version is unknown, exit function with error
  48. else return false;
  49. // Check config-value and setup the LEDs, depending of config-value
  50. if(strcmp(this->__config,CONFIG_L1B0) == false ||
  51. strcmp(this->__config,CONFIG_L1B1) == false) {
  52. // Setup LEDs
  53. pinMode(this->__ledGreen,OUTPUT);
  54. pinMode(this->__ledRed,OUTPUT);
  55. digitalWrite(this->__ledGreen,HIGH);
  56. digitalWrite(this->__ledRed,HIGH);
  57. // Store the value "true", if LEDs are configured
  58. this->__leds = true;
  59. }
  60. else {
  61. // Store the value "false", if LEDs are not configured
  62. this->__leds = false;
  63. }
  64. // Check config-value and setup the Buttons depending of config-value
  65. if(strcmp(this->__config,CONFIG_L0B1) == false ||
  66. strcmp(this->__config,CONFIG_L1B1) == false) {
  67. // Setup Buttons
  68. pinMode(this->__buttonUp,INPUT);
  69. pinMode(this->__buttonRight,INPUT);
  70. pinMode(this->__buttonDown,INPUT);
  71. pinMode(this->__buttonLeft,INPUT);
  72. // Store the value "true", if buttons are configured
  73. this->__buttons = true;
  74. }
  75. else {
  76. // Store the value "false", if buttons are not configured
  77. this->__buttons = false;
  78. }
  79. // If config-value is unknown, quit configuration, otherwise configure Display
  80. if(strcmp(this->__config,CONFIG_L1B1) != false &&
  81. strcmp(this->__config,CONFIG_L0B1) != false &&
  82. strcmp(this->__config,CONFIG_L1B0) != false &&
  83. strcmp(this->__config,CONFIG_L0B0) != false) return false;
  84. else {
  85. // Setup LCD-Backlight
  86. pinMode(this->__lcdBacklight,OUTPUT);
  87. // Initialize I²C as Master
  88. Wire.begin();
  89. // Define an array of Bytes for configure the Display
  90. byte buffer[] = {CONTROL_BYTE_CB,
  91. LCD_PARA_FUNC1,
  92. LCD_PARA_EXT_FUNC,
  93. LCD_PARA_ENTRY_MODE,
  94. LCD_PARA_BIAS_SET,
  95. LCD_PARA_FUNC2,
  96. LCD_PARA_INT_OSC,
  97. LCD_PARA_FOL_CON,
  98. LCD_PARA_POW_CON,
  99. LCD_PARA_CONTRAST,
  100. LCD_PARA_FUNC3,
  101. LCD_PARA_DIS_CON,
  102. LCD_PARA_CLR_DIS};
  103. // Send array of bytes
  104. _sendMessage(buffer, sizeof(buffer));
  105. // Exit function with positive feedback
  106. return true;
  107. }
  108. }
  109. ////////////////////////////////////////////////////////////////////////////////
  110. //////////////////// Privat Functions ////////////////////
  111. ////////////////////////////////////////////////////////////////////////////////
  112. //////////////////// Send Message ////////////////////
  113. void HSA_LCD_Shield::_sendMessage(byte* bytes, byte sizeBytes) {
  114. // Small timeout before access the I²C-Bus
  115. delayMicroseconds(DELAY_TRANS_US);
  116. // Start I²C transmission
  117. Wire.beginTransmission(this->__i2cAddress);
  118. // Send an array of Bytes over I²C, depending of its size
  119. for(byte i = 0x00; i < sizeBytes; i++) Wire.write(bytes[i]);
  120. // Stop I²C transmission
  121. Wire.endTransmission();
  122. // Small timeout after access the I²C-Bus
  123. delayMicroseconds(DELAY_TRANS_US);
  124. // Exit function
  125. return;
  126. }
  127. ////////////////////////////////////////////////////////////////////////////////
  128. //////////////////// Public Functions ////////////////////
  129. ////////////////////////////////////////////////////////////////////////////////
  130. //////////////////// Constructor ////////////////////
  131. HSA_LCD_Shield::HSA_LCD_Shield(byte version, const char config[CONFIG_SIZE]) {
  132. // Save LCD-Shield version
  133. this->__version = version;
  134. // Save standard I²C-Address for LC-Display
  135. this->__i2cAddress = I2C_ADDRESS;
  136. // Save the configuration of Buttons/LEDs
  137. strcpy(this->__config,config);
  138. // Exit Constructor
  139. return;
  140. }
  141. HSA_LCD_Shield::HSA_LCD_Shield(byte version) {
  142. // Save LCD-Shield version
  143. this->__version = version;
  144. // Save standard I²C-Address for LC-Display
  145. this->__i2cAddress = I2C_ADDRESS;
  146. // Save the configuration of Buttons/LEDs
  147. strcpy(this->__config,CONFIG_L1B1);
  148. // Exit Constructor
  149. return;
  150. }
  151. HSA_LCD_Shield::HSA_LCD_Shield(const char config[CONFIG_SIZE]){
  152. // Save LCD-Shield version
  153. this->__version = LCD_VERSION_6;
  154. // Save standard I²C-Address for LC-Display
  155. this->__i2cAddress = I2C_ADDRESS;
  156. // Save the configuration of Buttons/LEDs
  157. strcpy(this->__config,config);
  158. // Exit Constructor
  159. return;
  160. }
  161. HSA_LCD_Shield::HSA_LCD_Shield(void){
  162. // Save LCD-Shield version
  163. this->__version = LCD_VERSION_6;
  164. // Save standard I²C-Address for LC-Display
  165. this->__i2cAddress = I2C_ADDRESS;
  166. // Save the configuration of Buttons/LEDs
  167. strcpy(this->__config,CONFIG_L1B1);
  168. // Exit Constructor
  169. return;
  170. }
  171. //////////////////// Deconstructor ////////////////////
  172. HSA_LCD_Shield::~HSA_LCD_Shield(void) {
  173. // Exit function
  174. return;
  175. }
  176. //////////////////// Start Configuration ////////////////////
  177. bool HSA_LCD_Shield::begin(void) {
  178. // Configure GPIOs
  179. this->__lcd = __gpioConfig();
  180. // Exit function
  181. return this->__lcd;
  182. }
  183. bool HSA_LCD_Shield::begin(byte address) {
  184. // Save I²C-Address of LC-Display
  185. this->__i2cAddress = address;
  186. // Configure GPIOs
  187. this->__lcd = __gpioConfig();
  188. // Exit function
  189. return this->__lcd;
  190. }
  191. //////////////////// LCD-Backlight ////////////////////
  192. bool HSA_LCD_Shield::lcdBacklight(bool value) {
  193. // check, whether LCD is configured
  194. if(this->__lcd == false) return false;
  195. // Turning on/off LCD-Backlight
  196. digitalWrite(this->__lcdBacklight,value);
  197. // Exit function
  198. return true;
  199. }
  200. //////////////////// Clear Display ////////////////////
  201. bool HSA_LCD_Shield::clearDisplay(void) {
  202. // check, whether LCD is configured
  203. if(this->__lcd == false) return false;
  204. // Define an array of Bytes for clearing the Display
  205. byte buffer[] = {CONTROL_BYTE_CB,
  206. LCD_PARA_CLR_DIS};
  207. // Send array of bytes
  208. _sendMessage(buffer, sizeof(buffer));
  209. // Exit function
  210. return true;
  211. }
  212. /////////////////// Return Version ////////////////////
  213. byte HSA_LCD_Shield::returnVersion(void) {
  214. // Exit function and return the configured Version for the LCD-Shield
  215. return this->__version;
  216. }
  217. //////////////////// Return Config ////////////////////
  218. char* HSA_LCD_Shield::returnConfig(void) {
  219. // Exit function and return the configuration value
  220. return this->__config;
  221. }
  222. //////////////////// Return I²C-Address ////////////////////
  223. byte HSA_LCD_Shield::returnAddress(void){
  224. // Exit function and return the value of the I²C-Address
  225. return this->__i2cAddress;
  226. }
  227. //////////////////// Control LEDs ////////////////////
  228. bool HSA_LCD_Shield::controlLED(byte ledPin, bool state) {
  229. // Checks, whether LED-Pins are configured
  230. if(this->__leds) {
  231. // Checks, whether LED-Color is known and control LED
  232. if(ledPin == LED_GREEN) {
  233. digitalWrite(this->__ledGreen,!state);
  234. return true;
  235. }
  236. if(ledPin == LED_RED) {
  237. digitalWrite(this->__ledRed,!state);
  238. return true;
  239. }
  240. }
  241. // Exit function with error, if LED-Pins are not configured or LED-Color is
  242. // unknown
  243. return false;
  244. }
  245. //////////////////// Get LED state ////////////////////
  246. bool HSA_LCD_Shield::getLED(byte ledPin) {
  247. // Exit function and return the value of chosen LED
  248. if(ledPin == LED_GREEN && this->__leds)
  249. return !digitalRead(this->__ledGreen);
  250. else if(ledPin == LED_RED && this->__leds)
  251. return !digitalRead(this->__ledRed);
  252. else return false;
  253. }
  254. //////////////////// Get the pressed Button ////////////////////
  255. byte HSA_LCD_Shield::getButton() {
  256. // return 1, if only button "Up" is pressed and configured
  257. if(digitalRead(this->__buttonUp) &&
  258. !digitalRead(this->__buttonRight) &&
  259. !digitalRead(this->__buttonDown) &&
  260. !digitalRead(this->__buttonLeft) &&
  261. this->__buttons)
  262. return BUTTON_UP;
  263. // return 2, if only button "Right" is pressed and configured
  264. if(!digitalRead(this->__buttonUp) &&
  265. digitalRead(this->__buttonRight) &&
  266. !digitalRead(this->__buttonDown) &&
  267. !digitalRead(this->__buttonLeft) &&
  268. this->__buttons)
  269. return BUTTON_RIGHT;
  270. // return 3, if only button "Down" is pressed and configured
  271. if(!digitalRead(this->__buttonUp) &&
  272. !digitalRead(this->__buttonRight) &&
  273. digitalRead(this->__buttonDown) &&
  274. !digitalRead(this->__buttonLeft) &&
  275. this->__buttons)
  276. return BUTTON_DOWN;
  277. // return 4, if only button "Left" is pressed and configured
  278. if(!digitalRead(this->__buttonUp) &&
  279. !digitalRead(this->__buttonRight) &&
  280. !digitalRead(this->__buttonDown) &&
  281. digitalRead(this->__buttonLeft) &&
  282. this->__buttons)
  283. return BUTTON_LEFT;
  284. // return false, if no button or more than one button is pressed or
  285. // buttons are not configured
  286. return false;
  287. }
  288. //////////////////// Write Row ////////////////////
  289. bool HSA_LCD_Shield::writeRow(byte row, const char* text) {
  290. // check, whether LCD is configured
  291. if(this->__lcd == false) return false;
  292. // If chosen Row does not exist, exit function with error
  293. if(!(row >= 0x01 && row <= 0x04)) return false;
  294. // Define buffer for test Message
  295. byte buffer[ARRAY_SIZE_ROW] = "";
  296. // Define variable to store a boolean value, if a control-byte was found
  297. bool controlByte = false;
  298. // Create data-array with message and send the message at the end
  299. for(byte i = 0x00; i < ARRAY_SIZE_ROW; i++) {
  300. // Set control-byte for changing parameter in the first iteration
  301. if(i == 0x00) buffer[i] = CONTROL_BYTE_CB;
  302. // Change the cursor position to row in the second iteration.
  303. if(i == 0x01 && row == 0x01) buffer[i] = LCD_PARA_DIS_ROW1;
  304. if(i == 0x01 && row == 0x02) buffer[i] = LCD_PARA_DIS_ROW2;
  305. if(i == 0x01 && row == 0x03) buffer[i] = LCD_PARA_DIS_ROW3;
  306. if(i == 0x01 && row == 0x04) buffer[i] = LCD_PARA_DIS_ROW4;
  307. // Set control-byte for writing to the display in the third iteration
  308. if(i == 0x02) buffer[i] = CONTROL_BYTE_DCB;
  309. // Copy text into the buffer between iteration 2 to 13
  310. if(i > 0x02 && i < ARRAY_SIZE_ROW) {
  311. // If no control-byte was found, copy byte into buffer
  312. if(!controlByte) {
  313. // Check byte for control-byte
  314. if(isControl(text[i - 0x03])) controlByte = true;
  315. // if not, copy byte into buffer
  316. else buffer[i] = text[i - 0x03];
  317. }
  318. // If control-byte was found, fill message with free space
  319. if(controlByte) {
  320. // Fill Buffer with free space
  321. buffer[i] = FREE_SPACE;
  322. }
  323. }
  324. }
  325. // Send message
  326. _sendMessage(buffer,sizeof(buffer));
  327. // Exit function with success
  328. return true;
  329. }
  330. bool HSA_LCD_Shield::writeRow(const char* text) {
  331. // check, whether LCD is configured
  332. if(this->__lcd == false) return false;
  333. // Define buffer for test Message
  334. char buffer[ARRAY_SIZE_ROW] = "";
  335. // Define variable to store the actual row position
  336. byte rowPosition = LCD_PARA_DIS_ROW1;
  337. // Define variable, which count the copied bytes
  338. byte countBytes = 0x00;
  339. // Create data-array with messages for 4 rows and send the messages
  340. for(byte i = 0x00; i < 0x28; i++){
  341. // If the position of the row is not selected, skip following code
  342. if(rowPosition == false) continue;
  343. // If first row is selected
  344. if(rowPosition == LCD_PARA_DIS_ROW1) {
  345. // If counted bytes has not reach max value, copy byte into buffer
  346. if(countBytes < 0x0A) buffer[countBytes] = text[i];
  347. // Check, if copied byte was control-byte
  348. if(isControl(text[i])) {
  349. // Check if control-byte was \n or \r or end of string,
  350. // set counted bytes to max value
  351. if(text[i] == BACKSLASH_N ||
  352. text[i] == BACKSLASH_R ||
  353. text[i] == STRING_END)
  354. countBytes = 0x0A;
  355. // Check if control-byte was end of the string, deactivate row position
  356. if(text[i] == STRING_END) rowPosition = false;
  357. }
  358. // Otherwise increase counted bytes
  359. else countBytes++;
  360. // If count bytes is max value
  361. if(countBytes == 0x0A) {
  362. // Reset count bytes
  363. countBytes = 0x00;
  364. // write first row
  365. writeRow(0x01, buffer);
  366. // If row position is deactivated
  367. if(rowPosition == false) {
  368. // clear following rows
  369. writeRow(0x02, &text[i]);
  370. writeRow(0x03, &text[i]);
  371. writeRow(0x04, &text[i]);
  372. }
  373. // Otherwise set row position the row 2
  374. else rowPosition = LCD_PARA_DIS_ROW2;
  375. // skip the rest of the code in this iteration
  376. continue;
  377. }
  378. }
  379. // If second row is selected
  380. if(rowPosition == LCD_PARA_DIS_ROW2) {
  381. // If counted bytes has not reach max value, copy byte into buffer
  382. if(countBytes < 0x0A) buffer[countBytes] = text[i];
  383. // Check, if copied byte was control-byte
  384. if(isControl(text[i])) {
  385. // Check if control-byte was \n or \r or end of string,
  386. // set counted bytes to max value
  387. if(text[i] == BACKSLASH_N ||
  388. text[i] == BACKSLASH_R ||
  389. text[i] == STRING_END)
  390. countBytes = 0x0A;
  391. // Check if control-byte was end of the string, deactivate row position
  392. if(text[i] == STRING_END) rowPosition = false;
  393. }
  394. // Otherwise increase counted bytes
  395. else countBytes++;
  396. // If count bytes is max value
  397. if(countBytes == 0x0A) {
  398. // Reset count bytes
  399. countBytes = 0x00;
  400. // write second row
  401. writeRow(0x02, buffer);
  402. // If row position is deactivated
  403. if(rowPosition == false) {
  404. // clear following rows
  405. writeRow(0x03, &text[i]);
  406. writeRow(0x04, &text[i]);
  407. }
  408. // Otherwise set row position the row 3
  409. else rowPosition = LCD_PARA_DIS_ROW3;
  410. // skip the rest of the code in this iteration
  411. continue;
  412. }
  413. }
  414. // If third row is selected
  415. if(rowPosition == LCD_PARA_DIS_ROW3) {
  416. // If counted bytes has not reach max value, copy byte into buffer
  417. if(countBytes < 0x0A) buffer[countBytes] = text[i];
  418. // Check, if copied byte was control-byte
  419. if(isControl(text[i])) {
  420. // Check if control-byte was \n or \r or end of string,
  421. // set counted bytes to max value
  422. if(text[i] == BACKSLASH_N ||
  423. text[i] == BACKSLASH_R ||
  424. text[i] == STRING_END)
  425. countBytes = 0x0A;
  426. // Check if control-byte was end of the string, deactivate row position
  427. if(text[i] == STRING_END) rowPosition = false;
  428. }
  429. // Otherwise increase counted bytes
  430. else countBytes++;
  431. // If count bytes is max value
  432. if(countBytes == 0x0A) {
  433. // Reset count bytes
  434. countBytes = 0x00;
  435. // write third row
  436. writeRow(0x03, buffer);
  437. // If row position is deactivated, clear following row
  438. if(rowPosition == false) writeRow(0x04, &text[i]);
  439. // Otherwise set row position the row 4
  440. else rowPosition = LCD_PARA_DIS_ROW4;
  441. // skip the rest of the code in this iteration
  442. continue;
  443. }
  444. }
  445. // If fourth row is selected
  446. if(rowPosition == LCD_PARA_DIS_ROW4) {
  447. // If counted bytes has not reach max value, copy byte into buffer
  448. if(countBytes < 0x0A) buffer[countBytes] = text[i];
  449. // Check, if copied byte was control-byte
  450. if(isControl(text[i])) {
  451. // Check if control-byte was \n or \r or end of string,
  452. // set counted bytes to max value
  453. if(text[i] == BACKSLASH_N ||
  454. text[i] == BACKSLASH_R ||
  455. text[i] == STRING_END)
  456. countBytes = 0x0A;
  457. // Check if control-byte was end of the string, deactivate row position
  458. if(text[i] == STRING_END) rowPosition = false;
  459. }
  460. // Otherwise increase counted bytes
  461. else countBytes++;
  462. // If count bytes is max value
  463. if(countBytes == 0x0A) {
  464. // Reset count bytes
  465. countBytes = 0x00;
  466. // write fourth row
  467. writeRow(0x04, buffer);
  468. // If row position is not deactivated, deaktivate row position
  469. if(rowPosition != false) rowPosition = false;
  470. // skip the rest of the code in this iteration
  471. continue;
  472. }
  473. }
  474. }
  475. // Exit function
  476. return true;
  477. }
  478. //////////////////// Write Position XY ////////////////////
  479. bool HSA_LCD_Shield::writeXY(byte row, byte column, const char* text) {
  480. // check, whether LCD is configured
  481. if(this->__lcd == false) return false;
  482. // If chosen Row does not exist, exit function with error
  483. if(!(row >= 0x01 && row <= 0x04)) return false;
  484. // If chosen Column does not exist, exit function with error
  485. if(!(column >= 0x01 && column <= 0x0A)) return false;
  486. // create variable to store count of chars
  487. byte count = 0x00;
  488. // Count chars inside of text
  489. for(byte i = 0x00; i < 0x0A && !isControl(text[i]); i++) count++;
  490. // Define buffer for text Message
  491. byte buffer[ARRAY_SIZE_ROW - (0x0A - count)] = "";
  492. // Create data-array with message and send the message at the end
  493. for(byte i = 0x00; i < sizeof(buffer); i++) {
  494. // Set control-byte for changing parameter in the first iteration
  495. if(i == 0x00) buffer[i] = CONTROL_BYTE_CB;
  496. // Change the cursor position to row/column in the second iteration.
  497. if(i == 0x01 && row == 0x01) buffer[i] = LCD_PARA_DIS_ROW1 | (column - 0x01);
  498. if(i == 0x01 && row == 0x02) buffer[i] = LCD_PARA_DIS_ROW2 | (column - 0x01);
  499. if(i == 0x01 && row == 0x03) buffer[i] = LCD_PARA_DIS_ROW3 | (column - 0x01);
  500. if(i == 0x01 && row == 0x04) buffer[i] = LCD_PARA_DIS_ROW4 | (column - 0x01);
  501. // Set control-byte for writing to the display
  502. if(i == 0x02) buffer[i] = CONTROL_BYTE_DCB;
  503. // Copy text into the buffer between iteration 2 to 13
  504. if(i >= 0x03 && i < sizeof(buffer)) buffer[i] = text[i - 0x03];
  505. }
  506. // Send message
  507. _sendMessage(buffer,sizeof(buffer));
  508. // Exit function with success
  509. return true;
  510. }