You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/samples/SerialStreamer.cpp
+6-117Lines changed: 6 additions & 117 deletions
Original file line number
Diff line number
Diff line change
@@ -21,126 +21,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
22
DEALINGS IN THE SOFTWARE.
23
23
*/
24
-
24
+
#include"MicroBit.h"
25
25
#include"SerialStreamer.h"
26
26
#include"Tests.h"
27
27
28
-
/**
29
-
* Creates a simple component that logs a stream of signed 16 bit data as signed 8-bit data over serial.
30
-
* @param source a DataSource to measure the level of.
31
-
* @param mode the format of the serialised data. Valid options are SERIAL_STREAM_MODE_BINARY (default), SERIAL_STREAM_MODE_DECIMAL, SERIAL_STREAM_MODE_HEX.
32
-
*/
33
-
SerialStreamer::SerialStreamer(DataSource &source, int mode) : upstream(source)
34
-
{
35
-
this->mode = mode;
36
-
37
-
// Register with our upstream component
38
-
source.connect(*this);
39
-
}
40
-
41
-
/**
42
-
* Callback provided when data is ready.
43
-
*/
44
-
intSerialStreamer::pullRequest()
45
-
{
46
-
staticvolatileint pr = 0;
47
-
48
-
if(!pr)
49
-
{
50
-
pr++;
51
-
while(pr)
52
-
{
53
-
lastBuffer = upstream.pull();
54
-
streamBuffer(lastBuffer);
55
-
pr--;
56
-
}
57
-
}
58
-
else
59
-
{
60
-
pr++;
61
-
}
62
-
63
-
return DEVICE_OK;
64
-
}
65
-
66
-
/**
67
-
* returns the last buffer processed by this component
0 commit comments