本文整理汇总了C++中HardwareSerial::print方法的典型用法代码示例。如果您正苦于以下问题:C++ HardwareSerial::print方法的具体用法?C++ HardwareSerial::print怎么用?C++ HardwareSerial::print使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HardwareSerial
的用法示例。
在下文中一共展示了HardwareSerial::print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FifoTest
//! Test function to validate that the fifo works as expected.
//! It is always a good idea to validate your data structures. Languages like
//! Python or Perl have such validation built in, while C++ does not. This function
//! can be used in a special build to run through some test cases and make sure
//! that the fifo behaves as we exect, especially in the edge cases, such as when
//! it gets full, wraps around, etc.
void FifoTest(HardwareSerial& ds)
{
Fifo f1(20);
Fifo::FifoType x;
char buffer[128];
for (x=1;x<25;x++) {
f1.push(&x);
sprintf(buffer,"Fifo push %d count %d\n",x,f1.count());
ds.print(buffer);
}
f1.clear();
sprintf(buffer,"Fifo count %d\n",f1.count());
ds.print(buffer);
for (x=0;x<10;x++) {
f1.push(&x);
}
sprintf(buffer,"Fifo count %d. Expected 10\n",f1.count());
ds.print(buffer);
Fifo::FifoType y;
for (x=1;x<15;x++) {
f1.pop(&y);
sprintf(buffer,"Fifo pop %d count %d\n",y,f1.count());
ds.print(buffer);
}
}
示例2: cmdRead
/***
* Read [pin1] [pin2] ...
*
* Read pin values
* Pins are given in the following way: A0 A1 ... for analog pins
* D0 D1 ... for digital pins
* Answer is: val1 val2 ...
*/
void cmdRead(int argC, char **argV) {
char pinType[2];
int pin;
int value;
for (int i = 1; i <= argC; i++) {
pinType[0] = argV[i][0];
pinType[1] = NULL;
pin = strtol(&(argV[i][1]), NULL, 10);
if (strcasecmp(pinType, "D") == 0) {
value = digitalRead(pin);
} else if (strcasecmp(pinType, "A") == 0) {
value = analogRead(pin);
} else {
return;
}
// Add read values to answer string
Serial.print(value);
if (i < argC) {
Serial.print(' ');
}
}
}
示例3: setup
void setup()
{
// Set up serial port for debugging
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for Leonardo only
}
// Fullfil the data array
createDataArray();
// Read and set the key from the EEPROM
readKey(KEYLENGTH);
// Inicialization of the key
time = micros(); // time start
aes192_init(key, &key_init);
emit = micros(); // time start
Serial.print(F("Inicialisation total takes: "));
Serial.print(emit - time);
Serial.println(F(" [us]"));
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(ledPin, OUTPUT);
}
示例4: loop
void loop()
{
sendMsg = "";
recvMsg = "";
while (Serial.available()) {
sendMsg += (char)Serial.read();
delay(2);
}
if(sendMsg.length() > 0)
{
mySerial1.println(sendMsg);
Serial.print("I send: ");
Serial.println(sendMsg);
}
while (mySerial2.available()) {
recvMsg += (char)mySerial2.read();
delay(2);
}
if(recvMsg.length() > 0)
{
Serial.print("I recv: ");
Serial.println(recvMsg);
}
//delay(20);
}
示例5: create_gps_file
File create_gps_file() {
int year;
unsigned long age;
byte month, day, hour, minute, second, hundredth;
gps.crack_datetime(&year, &month, &day, &hour, &minute, &second, &hundredth, &age);
String filename;
filename.concat(GPS_DIR);
filename.concat('/');
filename.concat(year);
filename.concat('/');
filename.concat(month);
filename.concat('/');
filename.concat(day);
filename.concat('/');
filename.concat(hour);
filename.concat(minute);
filename.concat(second);
filename.concat(".GPS");
char buf[filename.length() + 1];
filename.toCharArray(buf, sizeof(buf));
Serial.print("Criando arquivo... ");
Serial.println(buf);
return create_file(buf);
}
示例6: loop2
void loop2()
{
vw_wait_rx();
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int port=parse();
switchState(port);
Serial.print(port);
Serial.println();
}
}
示例7: ajuste_pinos
void Node::ajuste_pinos(){
if (sizeof(this->comandos) > 0 ){
if(this->_debug) Serial.println("Ajustando pinagem: ");
for (int i = 0; i < sizeof(this->comandos)-1; i++){
pinMode(this->comandos[i].pino, OUTPUT);
if(this->_debug) Serial.print(this->comandos[i].pino+" ");
};
if(this->_debug) Serial.println("Fim de Ajuste.");
}
}
示例8: calcDeltaT
int calcDeltaT(){
lastLoopUsefulTime = millis()-loopStartTime;
if(lastLoopUsefulTime<STD_LOOP_TIME) {
delay(STD_LOOP_TIME-lastLoopUsefulTime);
if (debugSerial && debugLoopTime){
Serial.print(" Esperei: ");
Serial.println(STD_LOOP_TIME-lastLoopUsefulTime);
}
}
lastLoopTime = millis() - loopStartTime;
loopStartTime = millis();
return lastLoopTime;
}
示例9: debug
void debug(const char* format, ...) {
#ifdef __DEBUG__
va_list args;
va_start(args, format);
char buffer[MAX_LOG_LINE_LENGTH];
vsnprintf(buffer, MAX_LOG_LINE_LENGTH, format, args);
Serial2.print(buffer);
va_end(args);
#endif // __DEBUG__
}
示例10: loop
void loop()
{
if (Dennao.available() > 0) {
read_buf_len = Dennao.recv(read_buf, DENNAO_RX_SIZE, 0);
for(int i=0;i<read_buf_len;i++){
Uart.print((char)read_buf[i]);
}
}
if (Uart.available() > 0) {
uint8_t incomingByte = Uart.read();
if(incomingByte=='\r'){
Dennao.send(out_buf, out_buf_len, 0);
}else{
out_buf[out_buf_len++] = incomingByte;
}
}
}
示例11: loop
void loop(){
// update incoming values
g_ServoIn.update();
Serial.print(g_values[0]);
Serial.print(" - ");
Serial.print(g_values[1]);
Serial.print(" - ");
Serial.print(g_values[2]);
Serial.print(" - ");
Serial.println(g_values[3]);
// handle servo values here, stored in g_values
}
示例12: process_serial
void Comm::process_serial()
{
if (! Serial.available()) {
return;
}
byte addr = serial_get();
byte pkt = serial_get();
byte num = serial_get();
bool okay = false;
if (!addr) { // handle by master
if (m_handler) {
okay = m_handler(num);
serial_drain();
}
else {
okay = drain(num);
}
}
else { // send to slave
okay = transmit(addr,num);
serial_drain();
}
if (okay) {
Serial.print("OK");
}
else {
Serial.print("NO");
}
Serial.print(pkt);
Serial.print(addr);
Serial.print(num);
Serial.print('\0');
}
示例13: atualizaSensors
void atualizaSensors(int deltaT){
accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
/* Calcula os angulos (em graus) de X e Y */
accYangle = (atan2(ax,az)+PI)*RAD_TO_DEG;
accXangle = (atan2(ay,az)+PI)*RAD_TO_DEG;
double gyroXrate = (double)gx/131.0;
double gyroYrate = -((double)gy/131.0);
/* Calcula os angulos X e Y do Giroscopio*/
gyroXangle += gyroXrate*((double)deltaT/1000);
gyroYangle += gyroYrate*((double)deltaT/1000);
/* Aplica o Filtro Complementar*/
compAngleX = (0.93*(compAngleX+(gyroXrate*(double)deltaT/1000)))+(0.07*accXangle);
compAngleY = (0.93*(compAngleY+(gyroYrate*(double)deltaT/1000)))+(0.07*accYangle);
// DEBUG //
if (debugSerial && debugMPU6050){
Serial.print(accXangle);
Serial.print("\t");
Serial.print(accYangle);
Serial.print("\t");
Serial.print(gyroXangle);
Serial.print("\t");
Serial.print(gyroYangle);
Serial.print("\t");
Serial.print(compAngleX);
Serial.print("\t");
Serial.print(compAngleY);
Serial.print("\t");
}
delay(1);
}
示例14: debug
void Radio::debug(HardwareSerial& serial) {
serial.print((int)m_pressedButton);
serial.print("\t");
serial.print((int)m_bytesToSent);
}
示例15: debugHeader
void Radio::debugHeader(HardwareSerial& serial) {
serial.print(F("m_pressedButtonDebug\tm_bytesToSent"));
}