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

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