Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of g3_waterplay by
Printer.cpp
00001 /* 00002 * G3: WATERPLAY 00003 */ 00004 00005 #include "Printer.h" 00006 #include "TextLCD.h" 00007 #include "mbed.h" 00008 00009 Printer::Printer( 00010 mbed::Serial &serial, 00011 TextLCD &lcd 00012 ): 00013 _serial(serial), 00014 _lcd(lcd), 00015 _serial_message("G3: WATERPLAY\n\r"), 00016 _lcd_message("G3: WATERPLAY\n") 00017 { 00018 } 00019 void Printer::toSerial(char *message) 00020 { 00021 this->_serial_message = message; 00022 this->display(); 00023 } 00024 void Printer::toLCD(char *message) 00025 { 00026 this->_lcd_message = message; 00027 this->display(); 00028 } 00029 void Printer::toBoth(char *message) 00030 { 00031 this->_serial_message = message; 00032 this->_lcd_message = message; 00033 this->display(); 00034 } 00035 void Printer::toBothln(char *message) 00036 { 00037 char serial_buffer[32]; 00038 char lcd_buffer[32]; 00039 sprintf( 00040 serial_buffer, 00041 "%s\n\r", 00042 message 00043 ); 00044 00045 sprintf( 00046 lcd_buffer, 00047 "%s\n", 00048 message 00049 ); 00050 00051 this->_serial_message = serial_buffer; 00052 this->_lcd_message = lcd_buffer; 00053 this->display(); 00054 } 00055 void Printer::display() 00056 { 00057 this->_serial.printf( 00058 "%s", 00059 this->_serial_message 00060 ); 00061 00062 this->_lcd.cls(); 00063 this->_lcd.printf( 00064 "%s", 00065 this->_lcd_message 00066 ); 00067 } 00068 void Printer::display(double salinity, char* salinityStatus, double temperature, char* temperatureStatus) 00069 { 00070 this->_serial.printf( 00071 "salinity: %3.2F (%s) || temperature: %3.2F (%s)\n\r", 00072 salinity, 00073 salinityStatus, 00074 temperature, 00075 temperatureStatus 00076 00077 ); 00078 00079 this->_lcd.cls(); 00080 this->_lcd.printf( 00081 "sal: %3.2F %s\ntmp: %3.2F %s\n", 00082 salinity, 00083 salinityStatus, 00084 temperature, 00085 temperatureStatus 00086 ); 00087 }
Generated on Tue Jul 12 2022 21:07:58 by
1.7.2
