PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
charqueue.h
Go to the documentation of this file.
1 
26 #pragma once
27 
31 
32 #ifdef __PROPELLER_COG__
33 #define virtual
34 #endif
35 
36 namespace PropWare {
37 
46 class CharQueue : public Queue<char>,
47  public ScanCapable,
48  public PrintCapable {
49  public:
50  template<size_t N>
51  CharQueue (char (&array)[N], const int lockNumber = locknew())
52  : Queue(array, lockNumber) {
53  }
54 
55  CharQueue (char *array, const size_t length, const int lockNumber)
56  : Queue(array, length, lockNumber) {
57  }
58 
59  virtual char get_char () {
60  while (this->is_empty());
61  return this->dequeue();
62  }
63 
64  virtual void put_char (const char c) {
65  while (this->is_full());
66  this->enqueue(c);
67  }
68 
69  virtual void puts (const char *string) {
70  char *c = const_cast<char *>(string);
71  while (*c) {
72  this->put_char(*c);
73  c++;
74  }
75  }
76 };
77 
78 }
79 
80 #ifdef __PROPELLER_COG__
81 #undef virtual
82 #endif
PropWare::CharQueue::get_char
virtual char get_char()
Read and return a single character. Whether the method is blocking or not depends entirely on the imp...
Definition: charqueue.h:59
PropWare::Queue
A basic first-in, first-out queue implementation. The queue will overwrite itself when the maximum si...
Definition: queue.h:44
PropWare::Queue< char >::is_empty
bool is_empty() const
Determine if any elements exist.
Definition: queue.h:100
PropWare::Queue< char >::is_full
bool is_full() const
Determine if inserting another element would overwrite data.
Definition: queue.h:109
queue.h
PropWare::ScanCapable
Interface for all classes capable of printing.
Definition: scancapable.h:38
PropWare::PrintCapable
Interface for all classes capable of printing.
Definition: printcapable.h:38
PropWare::Queue< char >::Queue
Queue(char(&array)[N], const int lockNumber=locknew())
Construct a queue using the given statically-allocated array.
Definition: queue.h:52
string
void string(char *str)
Display a character string on the oLED display.
Definition: oled_string.c:7
PropWare::Queue< char >::dequeue
virtual char dequeue()
Return and remove the oldest value in the buffer.
Definition: queue.h:181
PropWare::CharQueue
Provide a communication buffer for character data between cogs.
Definition: charqueue.h:46
PropWare::Queue< char >::enqueue
virtual Queue & enqueue(const char &value)
Insert an element to the buffer.
Definition: queue.h:129
PropWare::CharQueue::put_char
virtual void put_char(const char c)
Print a single character.
Definition: charqueue.h:64
printcapable.h
locknew
#define locknew()
Get a new lock from the pool of Propeller hardware locks.
Definition: propeller.h:147
PropWare
Generic definitions and functions for the Parallax Propeller.
Definition: runnable.h:33
scancapable.h