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 |
SSTV_Transmit_AFSK.ino (6544B)
1 /* 2 RadioLib SSTV Transmit AFSK Example 3 4 The following example sends SSTV picture using 5 SX1278's FSK modem. The data is modulated 6 as AFSK. 7 8 Other modules that can be used for SSTV: 9 with AFSK modulation: 10 - SX127x/RFM9x 11 - RF69 12 - SX1231 13 - CC1101 14 - Si443x/RFM2x 15 16 NOTE: Some platforms (such as Arduino Uno) 17 might not be fast enough to correctly 18 send pictures via high-speed modes 19 like Scottie2 or Martin2. For those, 20 lower speed modes such as Wrasse, 21 Scottie1 or Martin1 are recommended. 22 23 For default module settings, see the wiki page 24 https://github.com/jgromes/RadioLib/wiki/Default-configuration 25 26 For full API reference, see the GitHub Pages 27 https://jgromes.github.io/RadioLib/ 28 */ 29 30 // include the library 31 #include <RadioLib.h> 32 33 // SX1278 has the following connections: 34 // NSS pin: 10 35 // DIO0 pin: 2 36 // RESET pin: 9 37 // DIO1 pin: 3 38 SX1278 radio = new Module(10, 2, 9, 3); 39 40 // or using RadioShield 41 // https://github.com/jgromes/RadioShield 42 //SX1278 radio = RadioShield.ModuleA; 43 44 // create AFSK client instance using the FSK module 45 // pin 5 is connected to SX1278 DIO2 46 AFSKClient audio(&radio, 5); 47 48 // create SSTV client instance using the AFSK instance 49 SSTVClient sstv(&audio); 50 51 // test "image" - actually just a single 320px line 52 // will be sent over and over again, to create vertical color stripes at the receiver 53 uint32_t line[320] = { 54 // black 55 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 56 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 57 58 // blue 59 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 60 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 0x0000FF, 61 62 // green 63 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 64 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 0x00FF00, 65 66 // cyan 67 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 68 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 0x00FFFF, 69 70 // red 71 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 72 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 0xFF0000, 73 74 // magenta 75 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 76 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 0xFF00FF, 77 78 // yellow 79 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 80 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 0xFFFF00, 81 82 // white 83 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 84 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF, 0xFFFFFF 85 }; 86 87 void setup() { 88 Serial.begin(9600); 89 90 // initialize SX1278 with default settings 91 Serial.print(F("[SX1278] Initializing ... ")); 92 int state = radio.beginFSK(); 93 if (state == RADIOLIB_ERR_NONE) { 94 Serial.println(F("success!")); 95 } else { 96 Serial.print(F("failed, code ")); 97 Serial.println(state); 98 while (true); 99 } 100 101 // when using one of the non-LoRa modules for SSTV 102 // (RF69, SX1231 etc.), use the basic begin() method 103 // int state = radio.begin(); 104 105 // initialize SSTV client 106 Serial.print(F("[SSTV] Initializing ... ")); 107 // SSTV mode: Wrasse (SC2-180) 108 // correction factor: 0.95 109 // NOTE: Due to different speeds of various platforms 110 // supported by RadioLib (Arduino Uno, ESP32 etc), 111 // and because SSTV is analog protocol, incorrect 112 // timing of pulses can lead to distortions. 113 // To compensate, correction factor can be used 114 // to adjust the length of timing pulses 115 // (lower number = shorter pulses). 116 // The value is usually around 0.95 (95%). 117 state = sstv.begin(Wrasse, 0.95); 118 if(state == RADIOLIB_ERR_NONE) { 119 Serial.println(F("success!")); 120 } else { 121 Serial.print(F("failed, code ")); 122 Serial.println(state); 123 while(true); 124 } 125 126 // to help tune the receiver, SSTVClient can send 127 // continuous 1900 Hz beep 128 /* 129 sstv.idle(); 130 while(true); 131 */ 132 } 133 134 void loop() { 135 // send picture with 8 color stripes 136 Serial.print(F("[SSTV] Sending test picture ... ")); 137 138 // send synchronization header first 139 sstv.sendHeader(); 140 141 // send all picture lines 142 for(uint16_t i = 0; i < sstv.getPictureHeight(); i++) { 143 sstv.sendLine(line); 144 } 145 146 // turn off transmitter 147 radio.standby(); 148 149 Serial.println(F("done!")); 150 151 delay(30000); 152 }