MCPcopy Create free account
hub / github.com/cinder/Cinder / update

Method update

samples/SerialCommunication/src/SerialCommunicationApp.cpp:80–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78}
79
80void SerialCommunicationApp::update()
81{
82// console() << "Bytes available: " << mSerial->getNumBytesAvailable() << std::endl;
83
84 double now = getElapsedSeconds();
85 double deltaTime = now - mLastUpdate;
86 mLastUpdate = now;
87 mLastRead += deltaTime;
88
89 if( mLastRead > READ_INTERVAL ) {
90 mSendSerialMessage = true;
91 mLastRead = 0.0;
92 }
93
94 if( mSendSerialMessage ) {
95 // request next chunk
96 mSerial->writeByte( mCounter );
97
98 try{
99 // read until newline, to a maximum of BUFSIZE bytes
100 mLastString = mSerial->readStringUntil( '\n', BUFSIZE );
101
102 }
103 catch( SerialTimeoutExc &exc ) {
104 CI_LOG_EXCEPTION( "timeout", exc );
105 }
106
107 mSendSerialMessage = false;
108 mCounter += 8;
109
110 console() << "last string: " << mLastString << endl;
111
112 TextLayout simple;
113 simple.setFont( Font( "Arial Black", 24 ) );
114 simple.setColor( Color( .7, .7, .2 ) );
115 simple.addLine( mLastString );
116 simple.setLeadingOffset( 0 );
117 mTexture = gl::Texture::create( simple.render( true, false ) );
118
119 mSerial->flush();
120 }
121}
122
123void SerialCommunicationApp::draw()
124{

Callers

nothing calls this directly

Calls 12

writeByteMethod · 0.80
readStringUntilMethod · 0.80
addLineMethod · 0.80
setLeadingOffsetMethod · 0.80
getElapsedSecondsFunction · 0.50
FontFunction · 0.50
ColorFunction · 0.50
createFunction · 0.50
setFontMethod · 0.45
setColorMethod · 0.45
renderMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected