Skip to content

Instantly share code, notes, and snippets.

@connected
Last active February 18, 2019 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save connected/d24083c49066b34cd0b35ea3bde81963 to your computer and use it in GitHub Desktop.
Save connected/d24083c49066b34cd0b35ea3bde81963 to your computer and use it in GitHub Desktop.
#define RF22_MAX_MESSAGE_LEN 255 //<<<<<<<<<<<<<<<<<<<<<<<
#include <Adafruit_GFX.h> // Core graphics library
#include "Adafruit_ILI9340.h" // Hardware-specific library
#include <SPI.h>
#include <SD.h>
#include <RF22.h> // http://www.airspayce.com/mikem/arduino/RF22/index.html
RF22 rf22(10); // СS, INT .. по умолчанию 10, (D2)
#if defined(__SAM3X8E__)
#undef __FlashStringHelper::F(string_literal)
#define F(string_literal) string_literal
#endif
#define TFT_RST 7
#define TFT_DC 8
#define TFT_CS 9
Adafruit_ILI9340 tft = Adafruit_ILI9340(TFT_CS, TFT_DC, TFT_RST);
#define BUFFPIXEL 2
#define NN 6
uint8_t sdbuffer[3 * BUFFPIXEL] = {255, 255, 255, 0, 0, 0}; // pixel buffer (R+G+B per pixel)*/
uint8_t data[NN];
uint8_t buf[RF22_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
uint8_t row = 0;
void setup() {
Serial.begin(9600);
tft.begin();
tft.fillScreen(ILI9340_BLACK);
if (!rf22.init()) {
Serial.println("RF22 init failed");
}
rf22.setTxPower(RF22_TXPOW_1DBM);
rf22.setFrequency(433.0);
rf22.setModemConfig(RF22::GFSK_Rb2Fd5);
}
void loop() {
uint8_t r, g, b;
Serial.println("LOOP START");
while (!rf22.available()) {
Serial.println("WAITING...");
}
if (rf22.recv(buf, &len)) {
digitalWrite(10, LOW);
Serial.print(row);
Serial.println("ROW");
Serial.print("Length:");
Serial.println(len);
// len == 48?
for (int jj = 0; jj < len; jj+=3) {
Serial.println(jj);
Serial.println("COL");
b = buf[jj];
g = buf[jj + 1];
r = buf[jj + 2];
Serial.print("R ");
Serial.print(r);
Serial.print(" G ");
Serial.print(g);
Serial.print(" B ");
Serial.println(b);
tft.drawPixel(jj, row, tft.Color565(r, g, b));
}
row++;
} else {
Serial.println("recv failed");
}
Serial.println("LOOP END");
}
// ================================================================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment