acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

Hellschreiber.h (7686B)

      1 #if !defined(_RADIOLIB_HELLSCHREIBER_H)
      2 #define _RADIOLIB_HELLSCHREIBER_H
      3 
      4 #include "../../TypeDef.h"
      5 
      6 #if !defined(RADIOLIB_EXCLUDE_HELLSCHREIBER)
      7 
      8 #include "../PhysicalLayer/PhysicalLayer.h"
      9 #include "../AFSK/AFSK.h"
     10 
     11 #define RADIOLIB_HELL_FONT_WIDTH                                7
     12 #define RADIOLIB_HELL_FONT_HEIGHT                               7
     13 
     14 // font definition: characters are stored in rows,
     15 //                  least significant byte of each character is the first row
     16 //                  Hellschreiber use 7x7 characters, but this simplified font uses only 5x5 - the extra bytes aren't stored
     17 static const uint8_t HellFont[64][RADIOLIB_HELL_FONT_WIDTH - 2] RADIOLIB_NONVOLATILE = {
     18   { 0b0000000, 0b0000000, 0b0000000, 0b0000000, 0b0000000 },  // space
     19   { 0b0001000, 0b0001000, 0b0001000, 0b0000000, 0b0001000 },  // !
     20   { 0b0010100, 0b0010100, 0b0000000, 0b0000000, 0b0000000 },  // "
     21   { 0b0010100, 0b0111110, 0b0010100, 0b0111110, 0b0010100 },  // #
     22   { 0b0111110, 0b0101000, 0b0111110, 0b0001010, 0b0111110 },  // $
     23   { 0b0110010, 0b0110100, 0b0001000, 0b0010110, 0b0100110 },  // %
     24   { 0b0010000, 0b0101000, 0b0010000, 0b0101000, 0b0110100 },  // &
     25   { 0b0001000, 0b0001000, 0b0000000, 0b0000000, 0b0000000 },  // '
     26   { 0b0000100, 0b0001000, 0b0001000, 0b0001000, 0b0000100 },  // (
     27   { 0b0010000, 0b0001000, 0b0001000, 0b0001000, 0b0010000 },  // )
     28   { 0b0010100, 0b0001000, 0b0010100, 0b0000000, 0b0000000 },  // *
     29   { 0b0001000, 0b0001000, 0b0111110, 0b0001000, 0b0001000 },  // +
     30   { 0b0000000, 0b0000000, 0b0000000, 0b0001000, 0b0010000 },  // ,
     31   { 0b0000000, 0b0000000, 0b0111110, 0b0000000, 0b0000000 },  // -
     32   { 0b0000000, 0b0000000, 0b0000000, 0b0000000, 0b0001000 },  // .
     33   { 0b0000010, 0b0000100, 0b0001000, 0b0010000, 0b0100000 },  // /
     34   { 0b0011100, 0b0100110, 0b0101010, 0b0110010, 0b0011100 },  // 0
     35   { 0b0011000, 0b0001000, 0b0001000, 0b0001000, 0b0001000 },  // 1
     36   { 0b0011000, 0b0100100, 0b0001000, 0b0010000, 0b0111100 },  // 2
     37   { 0b0111100, 0b0000100, 0b0011100, 0b0000100, 0b0111100 },  // 3
     38   { 0b0100100, 0b0100100, 0b0111100, 0b0000100, 0b0000100 },  // 4
     39   { 0b0011100, 0b0100000, 0b0111100, 0b0000100, 0b0111100 },  // 5
     40   { 0b0111100, 0b0100000, 0b0111100, 0b0100100, 0b0111100 },  // 6
     41   { 0b0111100, 0b0000100, 0b0001000, 0b0010000, 0b0100000 },  // 7
     42   { 0b0111100, 0b0100100, 0b0011000, 0b0100100, 0b0111100 },  // 8
     43   { 0b0111100, 0b0100100, 0b0111100, 0b0000100, 0b0111100 },  // 9
     44   { 0b0000000, 0b0001000, 0b0000000, 0b0000000, 0b0001000 },  // :
     45   { 0b0000000, 0b0001000, 0b0000000, 0b0001000, 0b0001000 },  // ;
     46   { 0b0000100, 0b0001000, 0b0010000, 0b0001000, 0b0000100 },  // <
     47   { 0b0000000, 0b0111110, 0b0000000, 0b0111110, 0b0000000 },  // =
     48   { 0b0010000, 0b0001000, 0b0000100, 0b0001000, 0b0010000 },  // >
     49   { 0b0011100, 0b0000100, 0b0001000, 0b0000000, 0b0001000 },  // ?
     50   { 0b0011100, 0b0100010, 0b0101110, 0b0101010, 0b0001100 },  // @
     51   { 0b0111110, 0b0100010, 0b0111110, 0b0100010, 0b0100010 },  // A
     52   { 0b0111100, 0b0010010, 0b0011110, 0b0010010, 0b0111100 },  // B
     53   { 0b0011110, 0b0110000, 0b0100000, 0b0110000, 0b0011110 },  // C
     54   { 0b0111100, 0b0100010, 0b0100010, 0b0100010, 0b0111100 },  // D
     55   { 0b0111110, 0b0100000, 0b0111100, 0b0100000, 0b0111110 },  // E
     56   { 0b0111110, 0b0100000, 0b0111100, 0b0100000, 0b0100000 },  // F
     57   { 0b0111110, 0b0100000, 0b0101110, 0b0100010, 0b0111110 },  // G
     58   { 0b0100010, 0b0100010, 0b0111110, 0b0100010, 0b0100010 },  // H
     59   { 0b0011100, 0b0001000, 0b0001000, 0b0001000, 0b0011100 },  // I
     60   { 0b0111100, 0b0001000, 0b0001000, 0b0101000, 0b0111000 },  // J
     61   { 0b0100100, 0b0101000, 0b0110000, 0b0101000, 0b0100100 },  // K
     62   { 0b0100000, 0b0100000, 0b0100000, 0b0100000, 0b0111100 },  // L
     63   { 0b0100010, 0b0110110, 0b0101010, 0b0100010, 0b0100010 },  // M
     64   { 0b0100010, 0b0110010, 0b0101010, 0b0100110, 0b0100010 },  // N
     65   { 0b0011100, 0b0100010, 0b0100010, 0b0100010, 0b0011100 },  // O
     66   { 0b0111110, 0b0100010, 0b0111110, 0b0100000, 0b0100000 },  // P
     67   { 0b0111110, 0b0100010, 0b0100010, 0b0100110, 0b0111110 },  // Q
     68   { 0b0111110, 0b0100010, 0b0111110, 0b0100100, 0b0100010 },  // R
     69   { 0b0111110, 0b0100000, 0b0111110, 0b0000010, 0b0111110 },  // S
     70   { 0b0111110, 0b0001000, 0b0001000, 0b0001000, 0b0001000 },  // T
     71   { 0b0100010, 0b0100010, 0b0100010, 0b0100010, 0b0111110 },  // U
     72   { 0b0100010, 0b0100010, 0b0010100, 0b0010100, 0b0001000 },  // V
     73   { 0b0100010, 0b0100010, 0b0101010, 0b0110110, 0b0100010 },  // W
     74   { 0b0100010, 0b0010100, 0b0001000, 0b0010100, 0b0100010 },  // X
     75   { 0b0100010, 0b0010100, 0b0001000, 0b0001000, 0b0001000 },  // Y
     76   { 0b0111110, 0b0000100, 0b0001000, 0b0010000, 0b0111110 },  // Z
     77   { 0b0001100, 0b0001000, 0b0001000, 0b0001000, 0b0001100 },  // [
     78   { 0b0100000, 0b0010000, 0b0001000, 0b0000100, 0b0000010 },  // backslash
     79   { 0b0011000, 0b0001000, 0b0001000, 0b0001000, 0b0011000 },  // ]
     80   { 0b0001000, 0b0010100, 0b0000000, 0b0000000, 0b0000000 },  // ^
     81   { 0b0000000, 0b0000000, 0b0000000, 0b0000000, 0b0111110 }   // _
     82 };
     83 
     84 /*!
     85   \class HellClient
     86 
     87   \brief Client for Hellschreiber transmissions.
     88 */
     89 class HellClient {
     90   public:
     91     /*!
     92       \brief Constructor for 2-FSK mode.
     93 
     94       \param phy Pointer to the wireless module providing PhysicalLayer communication.
     95     */
     96     explicit HellClient(PhysicalLayer* phy);
     97 
     98     #if !defined(RADIOLIB_EXCLUDE_AFSK)
     99     /*!
    100       \brief Constructor for AFSK mode.
    101 
    102       \param audio Pointer to the AFSK instance providing audio.
    103     */
    104     explicit HellClient(AFSKClient* audio);
    105     #endif
    106 
    107     // basic methods
    108 
    109     /*!
    110       \brief Initialization method.
    111 
    112       \param base Base RF frequency to be used in MHz (in 2-FSK mode), or the tone frequency in Hz (in AFSK mode).
    113 
    114       \param rate Baud rate to be used during transmission. Defaults to 122.5 ("Feld Hell")
    115     */
    116     int16_t begin(float base, float rate = 122.5);
    117 
    118     /*!
    119       \brief Method to "print" a buffer of pixels, this is exposed to allow users to send custom characters.
    120 
    121       \param buff Buffer of pixels to send, in a 7x7 pixel array.
    122 
    123       \returns Always returns the number of printed glyphs (1).
    124     */
    125     size_t printGlyph(uint8_t* buff);
    126 
    127     /*!
    128       \brief Invert text color.
    129 
    130       \param invert Whether to enable color inversion (white text on black background), or not (black text on white background)
    131     */
    132     void setInversion(bool invert);
    133 
    134     size_t write(const char* str);
    135     size_t write(uint8_t* buff, size_t len);
    136     size_t write(uint8_t b);
    137 
    138     size_t print(__FlashStringHelper*);
    139     size_t print(const String &);
    140     size_t print(const char[]);
    141     size_t print(char);
    142     size_t print(unsigned char, int = DEC);
    143     size_t print(int, int = DEC);
    144     size_t print(unsigned int, int = DEC);
    145     size_t print(long, int = DEC);
    146     size_t print(unsigned long, int = DEC);
    147     size_t print(double, int = 2);
    148 
    149     size_t println(void);
    150     size_t println(__FlashStringHelper*);
    151     size_t println(const String &);
    152     size_t println(const char[]);
    153     size_t println(char);
    154     size_t println(unsigned char, int = DEC);
    155     size_t println(int, int = DEC);
    156     size_t println(unsigned int, int = DEC);
    157     size_t println(long, int = DEC);
    158     size_t println(unsigned long, int = DEC);
    159     size_t println(double, int = 2);
    160 
    161 #if !defined(RADIOLIB_GODMODE)
    162   private:
    163 #endif
    164     PhysicalLayer* _phy;
    165     #if !defined(RADIOLIB_EXCLUDE_AFSK)
    166     AFSKClient* _audio;
    167     #endif
    168 
    169     uint32_t _base = 0, _baseHz = 0;
    170     uint32_t _pixelDuration = 0;
    171     bool _inv = false;
    172 
    173     size_t printNumber(unsigned long, uint8_t);
    174     size_t printFloat(double, uint8_t);
    175 
    176     int16_t transmitDirect(uint32_t freq = 0, uint32_t freqHz = 0);
    177     int16_t standby();
    178 };
    179 
    180 #endif
    181 
    182 #endif