本文整理汇总了C++中SoftwareSerial::write方法的典型用法代码示例。如果您正苦于以下问题:C++ SoftwareSerial::write方法的具体用法?C++ SoftwareSerial::write怎么用?C++ SoftwareSerial::write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoftwareSerial
的用法示例。
在下文中一共展示了SoftwareSerial::write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setX
//-------------------------------------------------------------------------------------------
void LCD::setX(byte posX) //0-127 or 0-159 pixels
{
//Set the X position
serial.write(0x7C);
serial.write(0x18);//CTRL x
serial.write(posX);
//characters are 8 pixels tall x 6 pixels wide
//The top left corner of a char is where the x/y value will start its print
//For example, if you print a char at position 1,1, the bottom right of your char will be at position 7,9.
//Therefore, to print a character in the very bottom right corner, you would need to print at the coordinates
//x = 154 , y = 120. You should never exceed these values.
// Here we have an example using an upper case 'B'. The star is where the character starts, given a set
//of x,y coordinates. # represents the blocks that make up the character, and _ represnets the remaining
//unused bits in the char space.
// *###__
// # #_
// # #_
// ####__
// # #_
// # #_
// ####__
// ______
}
示例2: setName
/* This function sets the name of an RN-42 module
name should be an up to 20-character value. It MUST BE TERMINATED by a
\r character */
uint8_t makeyMateClass::setName(char * name)
{
if (bluetooth.available())
bluetooth.flush(); // Get rid of any characters in the buffer, we'll need to check it fresh
bluetooth.print("SN,");
for (int i=0; i<20; i++)
{
if (name[i] != '\r')
bluetooth.write(name[i]);
else
break;
}
bluetooth.write('\r');
delay(BLUETOOTH_RESPONSE_DELAY);
bluetoothReceive(rxBuffer);
/* Double check the setting, output results in Serial monitor */
bluetooth.flush();
bluetooth.print("GN");
bluetooth.write('\r');
delay(BLUETOOTH_RESPONSE_DELAY);
Serial.print("Name set to: ");
while (bluetooth.available())
Serial.write(bluetooth.read());
return bluetoothCheckReceive(rxBuffer, "AOK", 3);
}
示例3: lcd_setBrightness
void lcd_setBrightness(int brightness){
// set the brightness - we'll max it (255 is max brightness)
lcd.write(0xFE);
lcd.write(0x99);
lcd.write(255);
delay(10);
}
示例4: lcd_setCursor
void lcd_setCursor(int column, int row){
lcd.write(0xFE);
lcd.write(0x47);
lcd.write((uint8_t)column);
lcd.write((uint8_t)row);
delay(10);
}
示例5: setBacklight
//-------------------------------------------------------------------------------------------
void LCD::setBacklight(byte duty)
{
//changes the back light intensity, range is 0-100.
serial.write(0x7C);
serial.write(0x02); //CTRL b
serial.write(duty); //send a value of 0 - 100
}
示例6: lcd_setContrast
void lcd_setContrast(int contrast){
// set the contrast, 200 is a good place to start, adjust as desired
lcd.write(0xFE);
lcd.write(0x50);
lcd.write(200);
delay(10);
}
示例7: setup
void setup() {
// Init display
mySerial.begin(9600); // set up serial port for 9600 baud
delay(500); // wait for display to boot up
// Setup DS1820 temp sensor
sensors.begin();
sensors.setResolution(Sensor1, 11);
sensors.setResolution(Sensor2, 11);
sensors.setWaitForConversion(false);
sensors.requestTemperatures();
delayInMillis = 750 / (1 << (12 - 11)); //750 for 12bit, 400 for 11bit, 220 for 10bit, 100 for 9bit
// calc by delayInMillis = 750 / (1 << (12 - resolution));
lastTempRequest = millis();
// Set next state i FSM
menu_FSM = M_PAGE1;
menu_last_state = M_PAGE1;
system_FSM = S_IDLE;
// **************** Set up display *******************
DisplayClear();
MenuShowTime = millis();
// **************** Set up RTC ***********************
Wire.begin();
rtc.begin();
//TimeDate(rtc.now(),dateTimeString,1);
//DateTime now = rtc.now();
// write on display
DisplayGoto(2,0);
mySerial.print("Version 0.9B");
// **************** Set up SD card *******************
pinMode(10, OUTPUT);
DisplayGoto(1,0);
mySerial.write("Init SD -> "); // clear display + legends
DisplayGoto(1,11);
// see if the card is present and can be initialized:
if (!SD.begin())
mySerial.write("Fail");
else
mySerial.write("OK");
delay(2000);
// ***************** Clear display ********************
DisplayClear();
}
示例8: clearScreen
//-------------------------------------------------------------------------------------------
void LCD::clearScreen()
{
//clears the screen, you will use this a lot!
serial.write(0x7C);
serial.write((byte)0); //CTRL @
//can't send LCD.write(0) or LCD.write(0x00) because it's interprestted as a NULL
}
示例9: lcd_setColor
void lcd_setColor(int red, int green, int blue){
lcd.write(0xFE);
lcd.write(0xD0);
lcd.write((uint8_t)red);
lcd.write((uint8_t)green);
lcd.write((uint8_t)blue);
delay(1000);
}
示例10: DisplayGoto
void DisplayGoto(int line ,int pos)
{
mySerial.write(0xFE); //command flag
if(line==1)
mySerial.write(128+pos);
if(line==2)
mySerial.write(128+64+pos);
}
示例11: setY
//-------------------------------------------------------------------------------------------
void LCD::setY(byte posY)//0-63 or 0-127 pixels
{
//Set the y position
serial.write(0x7C);
serial.write(0x19);//CTRL y
serial.write(posY);
}
示例12: keyPress
/* This function sends a key press down. An array of pressed keys is
generated and the RN-42 module is commanded to send a keyboard report.
The k parameter should either be an HID usage value, or one of the key
codes provided for in settings.h
Does not release the key! */
uint8_t makeyMateClass::keyPress(uint8_t k)
{
uint8_t i;
if (k >= 136) // Non printing key, these are listed in settings.h
{
k = k - 136;
}
else if (k >= 128) // !!! Modifiers, NOT YET IMPLEMENTED
{
}
else
{
k = asciiToScanCode[k];
if (!k)
{
return 0;
}
if (k & 0x80)
{
modifiers |= 0x02; // Adds the shift key to modifiers variable
k &= 0x7F; // k can only be a 7-bit value.
}
}
/* generate the key report into the keyCodes array
we can send up to 6 key presses, first make sure k isn't already in there */
if (keyCodes[0] != k && keyCodes[1] != k &&
keyCodes[2] != k && keyCodes[3] != k &&
keyCodes[4] != k && keyCodes[5] != k)
{
for (i=0; i<6; i++) // Add k to the next available array index
{
if (keyCodes[i] == 0x00)
{
keyCodes[i] = k;
break;
}
}
if (i == 6) // Too many characters to send
{
return 0;
}
}
bluetooth.write(0xFE); // Keyboard Shorthand Mode
bluetooth.write(0x07); // Length
bluetooth.write(modifiers); // Modifiers
for (int j=0; j<6; j++)
{
bluetooth.write(keyCodes[j]); // up to six key codes, 0 is nothing
}
return 1;
}
示例13: setPixel
//-------------------------------------------------------------------------------------------
void LCD::setPixel(byte x, byte y, byte set)
{
serial.write(0x7C);
serial.write(0x10);//CTRL p
serial.write(x);
serial.write(y);
serial.write(0x01);
delay(10);
}
示例14: setHome
//-------------------------------------------------------------------------------------------
void LCD::setHome()
{
serial.write(0x7C);
serial.write(0x18);
serial.write((byte)0);//set x back to 0
serial.write(0x7C);
serial.write(0x19);
serial.write((byte)0);//set y back to 0
}
示例15: lcd_begin
void lcd_begin(){
//lcd = SoftwareSerial(0,2);
lcd.begin(9600); // set the size of the display if it isn't 16x2 (you only have to do this once)
lcd.write(0xFE);
lcd.write(0xD1);
lcd.write(16); // 16 columns
lcd.write(2); // 2 rows
delay(10);
}