Added address filter in POCSAG RX

Changed POCSAG log format
Console widget knows red, green and blue now
This commit is contained in:
furrtek
2017-04-18 21:29:55 +01:00
parent 555201b780
commit 3a1e5b8772
8 changed files with 141 additions and 115 deletions

View File

@@ -33,9 +33,9 @@ namespace pocsag {
std::string bitrate_str(BitRate bitrate) {
switch (bitrate) {
case BitRate::FSK512: return "512 ";
case BitRate::FSK1200: return "1200";
case BitRate::FSK2400: return "2400";
case BitRate::FSK512: return "512bps ";
case BitRate::FSK1200: return "1200bps";
case BitRate::FSK2400: return "2400bps";
default: return "????";
}
}
@@ -43,7 +43,6 @@ std::string bitrate_str(BitRate bitrate) {
std::string flag_str(PacketFlag packetflag) {
switch (packetflag) {
case PacketFlag::NORMAL: return "OK";
case PacketFlag::IDLE: return "IDLE";
case PacketFlag::TIMED_OUT: return "TIMED OUT";
default: return "";
}
@@ -222,7 +221,7 @@ void pocsag_encode(
} while (char_idx < message_size);
}
bool pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state) {
void pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state) {
uint32_t codeword;
char ascii_char;
std::string output_text = "";
@@ -286,8 +285,6 @@ bool pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state) {
if (state->mode == STATE_HAVE_ADDRESS)
state->mode = STATE_CLEAR;
return true;
}
} /* namespace pocsag */

View File

@@ -24,7 +24,7 @@
#define __POCSAG_H__
#define POCSAG_PREAMBLE_LENGTH 576
#define POCSAG_TIMEOUT (576 * 2) // Preamble length * 2
#define POCSAG_TIMEOUT (576 * 2) // Preamble length * 2
#define POCSAG_SYNCWORD 0x7CD215D8
#define POCSAG_IDLEWORD 0x7A89C197
#define POCSAG_AUDIO_RATE 24000
@@ -78,7 +78,7 @@ void insert_BCH(BCHCode& BCH_code, uint32_t * codeword);
uint32_t get_digit_code(char code);
void pocsag_encode(const MessageType type, BCHCode& BCH_code, const std::string message,
const uint32_t address, std::vector<uint32_t>& codewords);
bool pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state);
void pocsag_decode_batch(const POCSAGPacket& batch, POCSAGState * const state);
} /* namespace pocsag */

View File

@@ -41,7 +41,6 @@ enum BitRate : uint32_t {
enum PacketFlag : uint32_t {
NORMAL,
IDLE,
TIMED_OUT,
TOO_LONG
};

View File

@@ -501,25 +501,41 @@ void Console::clear() {
}
void Console::write(std::string message) {
bool escape = false;
if (visible) {
const Style& s = style();
const Font& font = s.font;
const auto rect = screen_rect();
for(const auto c : message) {
if( c == '\n' ) {
crlf();
ui::Color pen_color = s.foreground;
for (const auto c : message) {
if (escape) {
if (c == '\x01')
pen_color = ui::Color::red();
else if (c == '\x02')
pen_color = ui::Color::green();
else if (c == '\x03')
pen_color = ui::Color::blue();
escape = false;
} else {
const auto glyph = font.glyph(c);
const auto advance = glyph.advance();
if( (pos.x() + advance.x()) > rect.width() ) {
if (c == '\n') {
crlf();
} else if (c == '\x1B') {
escape = true;
} else {
const auto glyph = font.glyph(c);
const auto advance = glyph.advance();
if( (pos.x() + advance.x()) > rect.width() ) {
crlf();
}
const Point pos_glyph {
rect.left() + pos.x(),
display.scroll_area_y(pos.y())
};
display.draw_glyph(pos_glyph, glyph, pen_color, s.background);
pos += { advance.x(), 0 };
}
const Point pos_glyph {
rect.left() + pos.x(),
display.scroll_area_y(pos.y())
};
display.draw_glyph(pos_glyph, glyph, s.foreground, s.background);
pos += { advance.x(), 0 };
}
}
buffer = message;
@@ -663,7 +679,7 @@ void Checkbox::paint(Painter& painter) {
painter.draw_string(
{
static_cast<Coord>(x + 16),
static_cast<Coord>(x + 16 + 2),
static_cast<Coord>(y + (16 - label_r.height()) / 2)
},
paint_style,