function lcd_output($string = '') { // Go into character mode if (!_lcd_set_mode(TRUE)) { return FALSE; } // Send string for ($i = 0; $i < strlen($string); $i++) { if ($string[$i] == "\n") { if (!lcd_command('new_line')) { return FALSE; } if (!_lcd_set_mode(TRUE)) { return FALSE; } // Go back into character mode } elseif ($string[$i] != "\r") { if (!_lcd_send(ord($string[$i]))) { return FALSE; } } } return TRUE; }
<?php /*------------------------------------------------------------------------------ BerryIO LCD Output String Command ------------------------------------------------------------------------------*/ $title = 'LCD Control'; // Load the LCD functions require_once FUNCTIONS . 'lcd.php'; // If we have a clear command do that first if (isset($_POST['clear'])) { if (lcd_command('clear') === FALSE) { $content .= message('ERROR: Cannot clear the LCD', 'lcd_status'); return FALSE; } } // If its a post, use that as the args if (isset($_POST['output'])) { $args[] = $_POST['output']; } // Check the args if (count($args) < 1) { $content .= usage('Please include the string you wish to send'); return FALSE; } // Execute the command if (lcd_output(implode(' ', $args)) === FALSE) { $content .= message('ERROR: Cannot send the string "' . implode(' ', $args) . '" to the LCD, is it initialised?', 'lcd_status'); return FALSE; } if ($GLOBALS['EXEC_MODE'] == 'html') { $content .= go_to('lcd_status');