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_Transmit_AFSK.ino (3166B)

      1 /*
      2    RadioLib Hellschreiber Transmit AFSK Example
      3 
      4    This example sends Hellschreiber message using
      5    SX1278's FSK modem. The data is modulated
      6    as AFSK.
      7 
      8    Other modules that can be used for Hellschreiber
      9    with AFSK modulation:
     10     - SX127x/RFM9x
     11     - RF69
     12     - SX1231
     13     - CC1101
     14     - Si443x/RFM2x
     15 
     16    For default module settings, see the wiki page
     17    https://github.com/jgromes/RadioLib/wiki/Default-configuration
     18 
     19    For full API reference, see the GitHub Pages
     20    https://jgromes.github.io/RadioLib/
     21 */
     22 
     23 // include the library
     24 #include <RadioLib.h>
     25 
     26 // SX1278 has the following connections:
     27 // NSS pin:   10
     28 // DIO0 pin:  2
     29 // RESET pin: 9
     30 // DIO1 pin:  3
     31 SX1278 radio = new Module(10, 2, 9, 3);
     32 
     33 // or using RadioShield
     34 // https://github.com/jgromes/RadioShield
     35 //SX1278 radio = RadioShield.ModuleA;
     36 
     37 // create AFSK client instance using the FSK module
     38 // pin 5 is connected to SX1278 DIO2
     39 AFSKClient audio(&radio, 5);
     40 
     41 // create Hellschreiber client instance using the AFSK instance
     42 HellClient hell(&audio);
     43 
     44 void setup() {
     45   Serial.begin(9600);
     46 
     47   // initialize SX1278 with default settings
     48   Serial.print(F("[SX1278] Initializing ... "));
     49   int state = radio.beginFSK();
     50 
     51   // when using one of the non-LoRa modules for Morse code
     52   // (RF69, CC1101, Si4432 etc.), use the basic begin() method
     53   // int state = radio.begin();
     54 
     55   if(state == RADIOLIB_ERR_NONE) {
     56     Serial.println(F("success!"));
     57   } else {
     58     Serial.print(F("failed, code "));
     59     Serial.println(state);
     60     while(true);
     61   }
     62 
     63   // initialize Hellschreiber client
     64   Serial.print(F("[Hell] Initializing ... "));
     65   // AFSK tone frequency:         400 Hz
     66   // speed:                       122.5 Baud ("Feld Hell")
     67   state = hell.begin(400);
     68   if(state == RADIOLIB_ERR_NONE) {
     69     Serial.println(F("success!"));
     70   } else {
     71     Serial.print(F("failed, code "));
     72     Serial.println(state);
     73     while(true);
     74   }
     75 }
     76 
     77 void loop() {
     78   Serial.print(F("[Hell] Sending Hellschreiber data ... "));
     79 
     80   // HellClient supports all methods of the Serial class
     81   // NOTE: Lower case letter will be capitalized.
     82 
     83   // Arduino String class
     84   String aStr = "Arduino String";
     85   hell.print(aStr);
     86 
     87   // character array (C-String)
     88   hell.print("C-String");
     89 
     90   // string saved in flash
     91   hell.print(F("Flash String"));
     92 
     93   // in AFSK mode, it is possible to invert the text colors
     94   // use white text on black background
     95   hell.setInversion(true);
     96   hell.print("Inverted String");
     97   hell.setInversion(false);
     98 
     99   // character
    100   hell.print('c');
    101 
    102   // byte
    103   // formatting DEC/HEX/OCT/BIN is supported for
    104   // any integer type (byte/int/long)
    105   hell.print(255, HEX);
    106 
    107   // integer number
    108   int i = 1000;
    109   hell.print(i);
    110 
    111   // floating point number
    112   // NOTE: println() has no effect on the transmission,
    113   //       and is only kept for compatibility reasons.
    114   float f = -3.1415;
    115   hell.println(f, 3);
    116 
    117   // custom glyph - must be a 7 byte array of rows 7 pixels long
    118   uint8_t customGlyph[] = { 0b0000000, 0b0010100, 0b0010100, 0b0000000, 0b0100010, 0b0011100, 0b0000000 };
    119   hell.printGlyph(customGlyph);
    120 
    121   Serial.println(F("done!"));
    122 
    123   // wait for a second before transmitting again
    124   delay(1000);
    125 }