2016-12-05 11:56:41 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string>
|
2017-08-16 09:02:57 +00:00
|
|
|
#include <vector>
|
2016-12-05 11:56:41 +00:00
|
|
|
#include "ch.h"
|
|
|
|
|
|
|
|
#ifndef __RDS_H__
|
|
|
|
#define __RDS_H__
|
|
|
|
|
|
|
|
namespace rds {
|
|
|
|
|
|
|
|
#define RDS_OFFSET_A 0b0011111100
|
|
|
|
#define RDS_OFFSET_B 0b0110011000
|
|
|
|
#define RDS_OFFSET_C 0b0101101000
|
|
|
|
#define RDS_OFFSET_Cp 0b1101010000
|
|
|
|
#define RDS_OFFSET_D 0b0110110100
|
|
|
|
|
2016-12-08 20:08:53 +00:00
|
|
|
struct RDS_flags {
|
|
|
|
uint16_t PI_code;
|
2016-12-09 17:21:47 +00:00
|
|
|
uint8_t PTY;
|
|
|
|
uint8_t DI;
|
|
|
|
bool TP;
|
|
|
|
bool TA;
|
|
|
|
bool MS;
|
2016-12-08 20:08:53 +00:00
|
|
|
};
|
|
|
|
|
2017-08-16 09:02:57 +00:00
|
|
|
struct RDSGroup {
|
2017-04-18 17:12:32 +00:00
|
|
|
uint32_t block[4];
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t make_block(uint32_t blockdata, uint16_t offset);
|
2016-12-05 11:56:41 +00:00
|
|
|
uint8_t b2b(const bool in);
|
2017-04-18 17:12:32 +00:00
|
|
|
|
2017-08-16 09:02:57 +00:00
|
|
|
RDSGroup make_0B_group(const uint16_t PI_code, const bool TP, const uint8_t PTY, const bool TA,
|
2017-04-18 17:12:32 +00:00
|
|
|
const bool MS, const bool DI, const uint8_t C, const std::string chars);
|
2017-08-16 09:02:57 +00:00
|
|
|
RDSGroup make_2A_group(const uint16_t PI_code, const bool TP, const uint8_t PTY, const bool AB,
|
2017-04-18 17:12:32 +00:00
|
|
|
const uint8_t segment, const std::string chars);
|
2017-08-16 09:02:57 +00:00
|
|
|
RDSGroup make_4A_group(const uint16_t PI_code, const bool TP, const uint8_t PTY,
|
2016-12-08 20:08:53 +00:00
|
|
|
const uint16_t year, const uint8_t month, const uint8_t day,
|
|
|
|
const uint8_t hour, const uint8_t minute, const int8_t local_offset);
|
|
|
|
|
2017-08-16 09:02:57 +00:00
|
|
|
void gen_PSN(std::vector<RDSGroup>& frame, const std::string& psname, const RDS_flags * rds_flags);
|
|
|
|
void gen_RadioText(std::vector<RDSGroup>& frame, const std::string& text, const bool AB, const RDS_flags * rds_flags);
|
|
|
|
void gen_ClockTime(std::vector<RDSGroup>& frame, const RDS_flags * rds_flags,
|
2016-12-08 20:08:53 +00:00
|
|
|
const uint16_t year, const uint8_t month, const uint8_t day,
|
|
|
|
const uint8_t hour, const uint8_t minute, const int8_t local_offset);
|
2016-12-05 11:56:41 +00:00
|
|
|
|
|
|
|
} /* namespace rds */
|
|
|
|
|
|
|
|
#endif/*__RDS_H__*/
|