Amazon Branded Mega 2560 Pro
Sketch uses 50008 bytes (19%) of program storage space. Maximum is 253952 bytes.
Global variables use 2178 bytes (26%) of dynamic memory, leaving 6014 bytes for local variables. Maximum is 8192 bytes.
Code (its big)
#define radioPower 30
#define gasPower 4
#define amp1Power 10
#define irPower 6
#define rgbPower 15
#define redPin 13
#define greenPin 11
#define bluePin 9
#define gyroPower 17
#define gyroGround 19
#define oledPower 25
#define oledGround 27
#define inputPower 36
#define inputGround 34
#define emitPin A0
#define joyClick 42
#define backBtn 40
#define fireBtn 38
#define gasApin A1//and ir in
#define irIN A2//and ir in
#define joyYpin A12
#define joyXpin A14
#define extPwm1 44
#define extPwm2 45
#define extPwm3 46
#define extAn1 A3
#define extAn2 A4
#define extAn3 A5
#define magFieldPin A15
#define SPK_PIN 33
#define SPK_GND 35
#define SD_CS 7
#define IR_USE_TIMER2
int counters[20];
float sharkTemperature=0;
float sharkAccel[3];
float sharkRotate[3];
const int n = 61;
float duration = 0;
float distance = 0;
bool debug = false;
bool warm = false;
//size,X,Y
byte textSet[3];
//exists,X,Y
byte mouse[3]{1,50,40};
byte Mode[25];
int joyStick[3];
byte btnState[2];
byte gas [3];
byte graphField[129];
byte buffer[61] = {0};
byte resolution[4]{30,128,90,128};
byte count = 0;
int pulse[2];
int magField[1024];
int gasTimer= 4000;
int Timer[20];
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <ELECHOUSE_CC1101_SRC_DRV.h>
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <NewTone.h>
Adafruit_MPU6050 mpu;
// include the SD library:
#include <SPI.h>
#include <SD.h>
// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
File root;
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// MKRZero SD: SDCARD_SS_PIN
const int chipSelect = 7;
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
// 'DTechlogo', 128x64px
const unsigned char bmp_DTechlogo [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x80, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x80, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf8, 0xf9, 0x80, 0x00, 0x01, 0x80, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf8, 0x44, 0x02, 0x00, 0x88, 0x00, 0x83, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf0, 0x42, 0xbf, 0x9c, 0xfe, 0x9c, 0xf1, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf0, 0x42, 0xe2, 0x22, 0x88, 0xa2, 0x91, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf0, 0x42, 0xb2, 0x22, 0x88, 0xa2, 0x91, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x44, 0x8a, 0x22, 0x88, 0xa2, 0x90, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x78, 0xf3, 0x3c, 0x8f, 0xbc, 0x98, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x3e, 0x00, 0x20, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x08, 0x00, 0x20, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x08, 0xe7, 0x3c, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x09, 0x24, 0xa4, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf0, 0x00, 0x09, 0xf4, 0x24, 0x00, 0x01, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01, 0xf8, 0x00, 0x09, 0x04, 0xa4, 0x00, 0x03, 0xf0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x09, 0xf7, 0xa4, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x07, 0xf0, 0x00, 0x00, 0x00, 0x01, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0xfe, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x7f, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xf8, 0x00, 0x03, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'DCARS', 128x64px
const unsigned char bmp_DCARS [] PROGMEM = {
0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0xb8, 0x00, 0x04, 0x00, 0xc1, 0xff, 0xff, 0xff, 0xff, 0xff,
0x80, 0x00, 0x00, 0x00, 0x01, 0x3e, 0xa8, 0x00, 0x7c, 0x0e, 0x5d, 0x00, 0x00, 0x00, 0x00, 0x01,
0xbf, 0xff, 0xff, 0xff, 0xff, 0x32, 0xae, 0x6f, 0x47, 0x33, 0x71, 0xff, 0xff, 0xff, 0xff, 0xfd,
0xbf, 0xff, 0xff, 0xff, 0xfe, 0x27, 0xab, 0x9d, 0x65, 0x53, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xfd,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x20, 0x6b, 0xed, 0x35, 0x32, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x33, 0x6b, 0x8d, 0xd5, 0x52, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x6e, 0xec, 0x75, 0xfa, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d,
0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d,
0xb0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d,
0xb0, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1d,
0x00, 0x07, 0xf2, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d,
0xb0, 0x38, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3d,
0x06, 0xc0, 0xf8, 0x68, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7d,
0x03, 0xc0, 0x10, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdd,
0x01, 0xf8, 0x27, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x25,
0xb3, 0x07, 0xc8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xad,
0x06, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0x25,
0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xdd,
0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfd,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
// 'mouse', 10x15px
const unsigned char bmp_mouse [] PROGMEM = {
0x80, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xb0, 0x00, 0xb8, 0x00, 0xdc, 0x00, 0xde, 0x00, 0xef, 0x00,
0xef, 0x80, 0xf7, 0xc0, 0xff, 0xc0, 0xf8, 0x00, 0xf0, 0x00, 0xc0, 0x00, 0x80, 0x00
};
// 'gasicon', 30x27px
const unsigned char bmp_gasicon [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
0x00, 0x03, 0x80, 0x00, 0x00, 0x06, 0x80, 0x00, 0x00, 0x04, 0xc0, 0x00, 0x00, 0x0c, 0x40, 0x00,
0x00, 0x08, 0x60, 0x00, 0x00, 0x10, 0x20, 0x00, 0x00, 0x30, 0x30, 0x00, 0x00, 0x20, 0x18, 0x00,
0x00, 0x64, 0x48, 0x00, 0x00, 0x48, 0x4c, 0x00, 0x00, 0xcb, 0xe4, 0x00, 0x01, 0x9c, 0xe6, 0x00,
0x01, 0x3f, 0xf2, 0x00, 0x03, 0x2a, 0x49, 0x00, 0x02, 0x4b, 0x49, 0x80, 0x06, 0x07, 0x80, 0x80,
0x0c, 0x03, 0x00, 0xc0, 0x08, 0x1e, 0xe0, 0x40, 0x18, 0x00, 0x00, 0x60, 0x1f, 0xff, 0xff, 0xe0,
0x0f, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'gasiconsmall', 15x15px
const unsigned char bmp_gasiconsmall [] PROGMEM = {
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x02, 0x80, 0x02, 0x80, 0x04, 0x40, 0x04, 0x40, 0x0a, 0xa0,
0x0a, 0xd0, 0x17, 0xd0, 0x33, 0x88, 0x21, 0x88, 0x62, 0x8c, 0x3f, 0xfc, 0x00, 0x00
};
// 'wifi', 30x30px
const unsigned char bmp_wifi [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xe0, 0x00,
0x01, 0xff, 0xfe, 0x00, 0x07, 0xff, 0xff, 0x80, 0x0f, 0xe0, 0x1f, 0xc0, 0x3f, 0x00, 0x03, 0xf0,
0x7c, 0x00, 0x00, 0xf8, 0xf8, 0x3f, 0xf0, 0x7c, 0xe0, 0xff, 0xfc, 0x1c, 0x43, 0xff, 0xff, 0x08,
0x07, 0xe0, 0x1f, 0x80, 0x0f, 0x80, 0x07, 0xc0, 0x0f, 0x03, 0x03, 0xc0, 0x0c, 0x1f, 0xe0, 0xc0,
0x00, 0x7f, 0xf8, 0x00, 0x00, 0xfd, 0xfc, 0x00, 0x01, 0xf0, 0x3e, 0x00, 0x01, 0xe0, 0x1e, 0x00,
0x00, 0x87, 0x84, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x0f, 0xc0, 0x00,
0x00, 0x0f, 0xc0, 0x00, 0x00, 0x0f, 0xc0, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'wifismall', 15x15px
const unsigned char bmp_wifismall [] PROGMEM = {
0x00, 0x00, 0x03, 0x80, 0x1f, 0xf0, 0x78, 0x3c, 0xe3, 0x8e, 0x8f, 0xe2, 0x38, 0x38, 0x33, 0x98,
0x0f, 0xe0, 0x0c, 0x60, 0x03, 0x80, 0x03, 0x80, 0x03, 0x80, 0x01, 0x00, 0x00, 0x00
};
// 'wave', 30x30px
const unsigned char bmp_wave [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0xff, 0xf0, 0x40, 0x03, 0xe0, 0x78,
0xe0, 0x07, 0x80, 0x1c, 0x70, 0x0f, 0x00, 0x08, 0x3f, 0xfe, 0x00, 0x00, 0x1f, 0xf8, 0x3f, 0xc0,
0x03, 0xe0, 0xff, 0xf0, 0x00, 0x01, 0xf0, 0xf8, 0xc0, 0x03, 0xc0, 0x3c, 0xf0, 0x0f, 0x00, 0x0c,
0x7c, 0x3e, 0x00, 0x00, 0x3f, 0xfc, 0x1f, 0x00, 0x0f, 0xf0, 0x7f, 0xe0, 0x00, 0x01, 0xff, 0xf0,
0x40, 0x03, 0xc0, 0x38, 0xe0, 0x07, 0x80, 0x1c, 0x78, 0x1f, 0x00, 0x08, 0x3f, 0xfc, 0x00, 0x00,
0x1f, 0xf8, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
// 'wavesmall', 15x15px
const unsigned char bmp_wavesmall [] PROGMEM = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0xfc, 0xc3, 0x02, 0x7e, 0x30, 0x00, 0xfc, 0xc1, 0x06,
0x7e, 0x00, 0x18, 0xfc, 0x81, 0x86, 0x7e, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00
};
#include <IrReceiverSampler.h>
#include <MultiDecoder.h>
static constexpr pin_t RECEIVE_PIN = A2;
static constexpr size_t BUFFERSIZE = 200U;
static constexpr uint32_t BAUD = 115200UL;
IrReceiver *receiver;
void setup() {
receiver = IrReceiverSampler::newIrReceiverSampler(BUFFERSIZE, RECEIVE_PIN);
pinMode (SPK_PIN,OUTPUT);
pinMode (SPK_GND,OUTPUT);
pinMode (rgbPower,OUTPUT);
pinMode (redPin,OUTPUT);
pinMode (bluePin,OUTPUT);
pinMode (greenPin,OUTPUT);
pinMode (irPower, OUTPUT);
pinMode (gyroPower, OUTPUT);
pinMode (gyroGround, OUTPUT);
pinMode (inputPower, OUTPUT);
pinMode (inputGround, OUTPUT);
pinMode (emitPin, OUTPUT);
pinMode (amp1Power, OUTPUT);
digitalWrite(amp1Power,HIGH);
pinMode (gasPower,OUTPUT);
pinMode (irIN, INPUT);
pinMode (magFieldPin, INPUT);
pinMode (joyYpin, INPUT);
pinMode (joyXpin, INPUT);
pinMode (gasApin, INPUT);
// pinMode (fanPowerpin, OUTPUT);
pinMode (backBtn ,INPUT);
pinMode (joyClick ,INPUT);
pinMode (radioPower ,OUTPUT);
digitalWrite (radioPower, HIGH);
digitalWrite (gyroPower, HIGH);
digitalWrite (gyroGround, LOW );
digitalWrite (inputPower, HIGH);
digitalWrite (inputGround, LOW );
digitalWrite (oledPower, HIGH);
digitalWrite (oledGround, LOW );
digitalWrite (SPK_GND, LOW );
digitalWrite (rgbPower, HIGH);
digitalWrite (greenPin, HIGH);
digitalWrite (redPin, HIGH);
digitalWrite (bluePin, HIGH);
digitalWrite (SD_CS, HIGH);
Serial.begin(9600);
Serial.println("Start");
bootGyros();
getVolume();
// SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
// Show initial display buffer contents on the screen --
// the library initializes this with an Adafruit splash screen.
// digitalWrite(ledPin, HIGH);
digitalWrite(redPin,LOW);
NewTone(SPK_PIN,440,200);
delay(200);
digitalWrite(redPin,HIGH);
digitalWrite(bluePin,LOW);
NewTone(SPK_PIN,659,200);
delay(200);
digitalWrite(bluePin,HIGH);
digitalWrite(greenPin,LOW);
NewTone(SPK_PIN,776,120);
delay(120);
digitalWrite(greenPin,HIGH);
noNewTone(SPK_PIN);
display.clearDisplay();
display.drawBitmap(0,0,bmp_DTechlogo,128,64,1);
display.display();
delay(2000); // Pause for 2 seconds
// Clear the buffer
display.clearDisplay();
// digitalWrite(ledPin, LOW);
}
void loop(void){
showsharkTemp();
sensors();
if (Mode[0] == 0){ analogWrite(bluePin,240),
digitalWrite(greenPin,HIGH),analogWrite(redPin,240);
mouseCur();
}
display.drawBitmap(0,0,bmp_DCARS,128,64,1);
if (debug == true){
textSet[0] = 1;
textSet[1] = 20;
textSet[2] = 45;
drawText();
display.print(Mode[0]);
textSet[0] = 1;
textSet[1] = 55;
textSet[2] = 45;
drawText();
display.print(Mode[7]);
textSet[0] = 1;
textSet[1] = 85;
textSet[2] = 45;
drawText();
display.print(Mode[3]);
}
mainMenu();
if (btnState[1] == HIGH or btnState[0] == HIGH){
// digitalWrite(ledPin,HIGH);
}
else
// digitalWrite(ledPin,LOW);
display.display();
display.clearDisplay();
}
void drawText (void){
display.setTextSize(textSet[0]);
display.setTextColor(SSD1306_WHITE);
display.setCursor(textSet[1], textSet[2]);
}
void mouseCur (void){
display.drawBitmap(mouse[1],mouse[2],bmp_mouse,10,15,1);
if (joyStick[1]<0 && mouse[1]>1){
mouse[1]=mouse[1]+joyStick[1];
}
if (joyStick[1]>0 && mouse[1]<115){
mouse[1]=mouse[1]+joyStick[1];
}
if (mouse[2]>0 && joyStick[2]<0){
mouse[2]=mouse[2]+joyStick[2];
}
if (mouse[2]<50 && joyStick[2]>0){
mouse[2]=mouse[2]+joyStick[2];
}
if (mouse[1]<0 or mouse[1]>120){mouse[1]=1;}
if (mouse[2]<0 or mouse[2]>55){mouse[2]=1;}
}
void sensors (void){
joyStick[1] = map (analogRead(joyXpin),0,1000,5,-5);
joyStick[2] = map (analogRead(joyYpin),0,1000,-5,5);
joyStick[0] = digitalRead(joyClick);
btnState[1] = digitalRead(joyClick);
btnState[0] = digitalRead(backBtn);
if (Mode[0] == 1){
gas[1] = analogRead (gasApin);
}
if (Mode[0] == 3){
magField[0] = analogRead(magFieldPin);
}
}
void mainMenu (void){
if (Mode[0]==0){
display.drawBitmap(10,15,bmp_gasicon,30,27,1);
if (mouse[1]>10 && mouse[1]<40){if (mouse[2]>15 && mouse[2]<42){
display.drawRect(10,15,30,30,SSD1306_WHITE);
Mode[1]=1;
Mode[6]=1;
}
else Mode[1]=0;
}
else Mode[1]=0;
display.drawBitmap(50,15,bmp_wifi,30,30,1);
if (mouse[1]>50 && mouse[1]<80){if (mouse[2]>15 && mouse[2]<42){
display.drawRect(50,15,30,30,SSD1306_WHITE);
Mode[2]=1;
Mode[6]=2;
}
else Mode[2]=0;
}
else Mode[2]=0;
display.drawBitmap(90,15,bmp_wave,30,30,1);
if (mouse[1]>90 && mouse[1]<120){if (mouse[2]>15 && mouse[2]<42){
display.drawRect(90,15,30,30,SSD1306_WHITE);
Mode[3]=1;
Mode[6]=3;
}
else Mode[3]=0;
}
else Mode[3]=0;
for (byte i = 1; i < 4; i++){
if (btnState[1] == HIGH && Mode[i]==1){
Mode[0] = Mode [6];
}
}
}
/////////////// MODE1////////////////////////
if (Mode[0] == 1){
digitalWrite(gasPower, LOW);
// digitalWrite(fanPowerpin, HIGH);
if (gasTimer>0){
gasTimer=gasTimer-1;
}
if (gasTimer==1){
warm = true;
NewTone(SPK_PIN,330,100);
delay(100);
NewTone(SPK_PIN,440,100);
delay(100);
NewTone(SPK_PIN,580,100);
delay(100);
NewTone(SPK_PIN,768,100);
delay(100);
noNewTone(SPK_PIN);}
if (Mode[9] == 0){
if (warm == false){
textSet[0] = 1;
textSet[1] = 30;
textSet[2] = 15;
drawText();
//display.print (gasTimer);
display.println ("Warming Up");
display.fillRect(10,30,map (gasTimer,4000,0,0,100),5, SSD1306_WHITE);
}
if (warm == true){
display.drawBitmap (105,40,bmp_gasiconsmall,15,15,1);
textSet[0] = 1;
textSet[1] = 5;
textSet[2] = 50;
drawText();
//display.print(resolution[2]);
display.drawRect(10,30,map (analogRead(gasApin),0,1023,5,100),5, SSD1306_WHITE);
display.drawLine(10,8,10,48,SSD1306_WHITE);
display.drawLine(31,8,31,58,SSD1306_WHITE);
display.drawLine(51,8,51,58,SSD1306_WHITE);
display.drawLine(72,8,72,58,SSD1306_WHITE);
display.drawLine(93,8,93,58,SSD1306_WHITE);
textSet[0] = 1;
textSet[1] = 33;
textSet[2] = 50;
drawText();
display.println ("Air");
textSet[0] = 1;
textSet[1] = 54;
textSet[2] = 50;
drawText();
display.println ("Gas");
if (gasTimer>0){
textSet[0] = 1;
textSet[1] = 75;
textSet[2] = 50;
drawText();
display.print (gasTimer);
}
if (analogRead(gasApin)>500){
// digitalWrite(ledPin, HIGH);
NewTone(SPK_PIN,analogRead(gasApin),20);}
else{
noNewTone(SPK_PIN);
// digitalWrite(ledPin, LOW);
}
delay(1);
if (joyStick[1]>0){
if (resolution[3]<250){ resolution[3]++;}
}
if (joyStick[1]<0){
if (resolution[3]>128){ resolution[3]--;}
}
if (joyStick[2]>0){
if (resolution[2]>5){ resolution[2]--;}
}
if (joyStick[2]<0){
if (resolution[2]<150){ resolution[2]++;}
}
if (joyStick[0] == HIGH){resolution[0]=30;resolution[1]=128;}
}
}
}
else {
digitalWrite(gasPower, HIGH );
//digitalWrite(fanPowerpin, LOW);
gasTimer=4000;
}
////////////// MODE2 //////////////////////////
if (Mode[0]==2){
digitalWrite(radioPower, LOW);
digitalWrite(greenPin,HIGH),
digitalWrite(redPin,HIGH),
analogWrite(bluePin,240);
if (Mode[15]==0){
display.clearDisplay();
if (ELECHOUSE_cc1101.getCC1101()){ // Check the CC1101 Spi connection.
Serial.println("Connection OK");
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 30;
drawText();
display.clearDisplay();
display.println(F("Radio OK"));
display.drawBitmap(0,0,bmp_DCARS,128,64,1);
display.display();
delay(650);
}else{
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 30;
drawText();
display.clearDisplay();
display.println(F("ERR"));
display.drawBitmap(0,0,bmp_DCARS,128,64,1);
display.display();
delay(1500);
Serial.println("ERR");
}
ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101!
ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission Mode.
ELECHOUSE_cc1101.setModulation(2); // set modulation Mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK.
ELECHOUSE_cc1101.setMHZ(315.00); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet.
ELECHOUSE_cc1101.setDeviation(380.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz.
ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0.
ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz.
ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz.
ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud!
ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max!
ELECHOUSE_cc1101.setSyncMode(4); // Combined sync-word qualifier Mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold.
ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low)
ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast.
ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF).
ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on.
ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal Mode, use FIFOs for RX and TX. 1 = Synchronous serial Mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX Mode; sends random data using PN9 generator. Used for test. Works as normal Mode, setting 0 (00), in RX. 3 = Asynchronous serial Mode, Data in on GDO0 and data out on either of the GDOx pins.
ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length Mode. 1 = Variable packet length Mode. 2 = Infinite packet length Mode. 3 = Reserved
ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length Mode is enabled. If variable packet length Mode is used, this value indicates the maximum packet length allowed.
ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX.
ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size.
ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity).
ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable.
ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length Mode. 0 = Disable. 1 = Enable.
ELECHOUSE_cc1101.setPRE(0); // Sets the minimum number of preamble bytes to be transmitted. Values: 0 : 2, 1 : 3, 2 : 4, 3 : 6, 4 : 8, 5 : 12, 6 : 16, 7 : 24
ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted.
ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK.
Serial.println("Rx Mode");
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 30;
drawText();
display.clearDisplay();
display.println(F("RX Mode"));
display.drawBitmap(0,0,bmp_DCARS,128,64,1);
display.display();
Mode[15]=1;
}
delay(650);
display.clearDisplay();
display.drawBitmap(0,0,bmp_DCARS,128,64,1);
Serial.println("Listening");
/* textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 30;
drawText();
display.println(F("Hunting"));
*/
//Checks whether something has been received.
//When something is received we give some time to receive the message in full.(time in millis)
if (ELECHOUSE_cc1101.CheckRxFifo(100)){
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 16;
drawText();
display.println("315 MHZ");
// / display.display();
delay(10);
//CRC Check. If "setCrc(false)" crc returns always OK!
if (ELECHOUSE_cc1101.CheckCRC()){
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 16;
drawText();
display.clearDisplay();
display.print(ELECHOUSE_cc1101.CheckCRC());
display.display();
delay(650);
//Rssi Level in dBm
Serial.print("Rssi: ");
Serial.println(ELECHOUSE_cc1101.getRssi());
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 16;
drawText();
display.clearDisplay();
display.println(F("Rssi"));
display.display();
delay(650);
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 16;
drawText();
display.print( ELECHOUSE_cc1101.getRssi());
delay(650);
display.clearDisplay();
//Link Quality Indicator
Serial.print("LQI: ");
Serial.println(ELECHOUSE_cc1101.getLqi());
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 40;
drawText();
display.println(F("LQI"));
display.display();
delay(650);
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 16;
drawText();
display.print( ELECHOUSE_cc1101.getLqi());
display.display();
delay(650);
display.clearDisplay();
//Get received Data and calculate length
int len = ELECHOUSE_cc1101.ReceiveData(buffer);
buffer[len] = '\0';
//Print received in char format.
Serial.println((char *) buffer);
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 40;
drawText();
display.println((char *) buffer);
display.display();
delay(650);
//Print received in bytes format.
for (int i = 0; i<len; i++){
Serial.print(buffer[i]);
Serial.print(",");
}
Serial.println();
}
}
textSet[0] = 1;
textSet[1] = 35;
textSet[2] = 50;
drawText();
display.println(F("CyberShark"));
display.drawBitmap(0,0,bmp_DCARS,128,64,1);
display.drawBitmap (100,20,bmp_wifismall,15,15,1);
display.drawBitmap (5,20,bmp_wifismall,15,15,1);
display.drawBitmap (105,40,bmp_wifismall,15,15,1);
}
else{
digitalWrite(radioPower, HIGH);}
/////////////////MODE3//////////////////////////
if (Mode[0] == 3){
if (Mode[7]==1){
if (Mode[16]==0){
digitalWrite(irPower, LOW);
digitalWrite(greenPin,HIGH),
digitalWrite(bluePin,HIGH),
analogWrite(redPin,240);
Mode[16]=1;
}
IRscan();
}
else
digitalWrite(irPower, HIGH),Mode[16]=0;
if (Mode[7] == 0){
if (Mode[0]==3){
digitalWrite(amp1Power, LOW),
analogWrite(greenPin,240),
digitalWrite(redPin,HIGH),
analogWrite(bluePin,240);
}
display.drawBitmap (105,40,bmp_wavesmall,15,15,1);
textSet[0] = 1;
textSet[1] = 5;
textSet[2] = 50;
drawText();
display.print(resolution[0]);
textSet[0] = 1;
textSet[1] = 30;
textSet[2] = 50;
drawText();
display.print(resolution[1]);
// loop over the graph array:
for (int graph = 0; graph < 128; graph++) {
display.drawPixel(graph,40 + map (analogRead(magFieldPin),0,1000,-15,15), SSD1306_WHITE);
// display.drawPixel(graph,map (resolution[0],0,100,30,-15 ) + map (analogRead(magFieldPin),-1023,1023,-resolution[0],resolution[0]), SSD1306_WHITE);
}
}
else {
digitalWrite(amp1Power, HIGH);
}
/////END OF MODE 7
if (joyStick[1]>0){
counters[0]++;
if (counters[0]>3){
Mode[7]++,counters[0]=0;
if (Mode[7]>1){
Mode[7]=0;
}
else
counters[0]=0;
}
}
}
else {
digitalWrite(amp1Power, HIGH);
}
if (btnState[0] == HIGH){
Mode[0]=0;
Mode[6]=0;
Mode[15]=0;
}
}
void bootGyros (void){
while (!Serial)
delay(10); // will pause Zero, Leonardo, etc until serial console opens
Serial.println("Adafruit MPU6050 test!");
// Try to initialize!
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
Serial.println("MPU6050 Found!");
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
Serial.print("Accelerometer range set to: ");
switch (mpu.getAccelerometerRange()) {
case MPU6050_RANGE_2_G:
Serial.println("+-2G");
break;
case MPU6050_RANGE_4_G:
Serial.println("+-4G");
break;
case MPU6050_RANGE_8_G:
Serial.println("+-8G");
break;
case MPU6050_RANGE_16_G:
Serial.println("+-16G");
break;
}
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
Serial.print("Gyro range set to: ");
switch (mpu.getGyroRange()) {
case MPU6050_RANGE_250_DEG:
Serial.println("+- 250 deg/s");
break;
case MPU6050_RANGE_500_DEG:
Serial.println("+- 500 deg/s");
break;
case MPU6050_RANGE_1000_DEG:
Serial.println("+- 1000 deg/s");
break;
case MPU6050_RANGE_2000_DEG:
Serial.println("+- 2000 deg/s");
break;
}
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
Serial.print("Filter bandwidth set to: ");
switch (mpu.getFilterBandwidth()) {
case MPU6050_BAND_260_HZ:
Serial.println("260 Hz");
break;
case MPU6050_BAND_184_HZ:
Serial.println("184 Hz");
break;
case MPU6050_BAND_94_HZ:
Serial.println("94 Hz");
break;
case MPU6050_BAND_44_HZ:
Serial.println("44 Hz");
break;
case MPU6050_BAND_21_HZ:
Serial.println("21 Hz");
break;
case MPU6050_BAND_10_HZ:
Serial.println("10 Hz");
break;
case MPU6050_BAND_5_HZ:
Serial.println("5 Hz");
break;
}
Serial.println("");
delay(100);
}
void showsharkTemp (void){
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
sharkTemperature=(temp.temperature*9/5)+32;
textSet[0] = 1;
textSet[1] =5;
textSet[2] = 8;
drawText();
display.print("T:");
textSet[0] = 1;
textSet[1] =15;
textSet[2] = 8;
drawText();
display.println( sharkTemperature);
}
void showbodGyro (void){
/* Get new sensor events with the readings */
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
/* Print out the values */
//Serial.print();
sharkAccel[0]=a.acceleration.x;
sharkAccel[1]=a.acceleration.y;
sharkAccel[2]=a.acceleration.z;
display.drawLine(64,32,(sharkAccel[0]*10)+64,16,SSD1306_WHITE);
sharkRotate[0]=g.gyro.x;
sharkRotate[1]=g.gyro.y;
sharkRotate[2]=g.gyro.z;
}
void reportGyros() {
/* Get new sensor events with the readings */
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
/* Print out the values */
Serial.print("Acceleration X: ");
Serial.print(a.acceleration.x);
Serial.print(", Y: ");
Serial.print(a.acceleration.y);
Serial.print(", Z: ");
Serial.print(a.acceleration.z);
Serial.println(" m/s^2");
Serial.print("Rotation X: ");
Serial.print(g.gyro.x);
Serial.print(", Y: ");
Serial.print(g.gyro.y);
Serial.print(", Z: ");
Serial.print(g.gyro.z);
Serial.println(" rad/s");
Serial.print("Temperature: ");
Serial.print(temp.temperature);
Serial.println(" degC");
Serial.println("");
delay(500);
}
void IRscan (void){
if (digitalRead (fireBtn)==HIGH){
receiver->receive();
if (receiver->isEmpty())
{
Serial.print("Stupid Shit");
delay(10);
}
else {
MultiDecoder decoder(*receiver);
if (decoder){
decoder.printDecode(Serial);
textSet[0] = 1;
textSet[1] = 5;
textSet[2] = 16;
drawText();
display.println(decoder.getDecode());
textSet[0] = 1;
textSet[1] = 25;
textSet[2] = 35;
drawText();
display.println("IR Detected");
}
}
delay(100);
}
}
void getVolume (void){
Serial.print("Initializing SD card...");
if (!SD.begin(7)) {
Serial.println("initialization failed!");
while (1);
}
Serial.println("initialization done.");
root = SD.open("/");
printDirectory(root, 0);
Serial.println("done!");
}
void printDirectory(File dir, int numTabs) {
while (true) {
File entry = dir.openNextFile();
if (! entry) {
// no more files
break;
}
for (uint8_t i = 0; i < numTabs; i++) {
Serial.print('\t');
}
Serial.print(entry.name());
if (entry.isDirectory()) {
Serial.println("/");
printDirectory(entry, numTabs + 1);
} else {
// files have sizes, directories do not
Serial.print("\t\t");
Serial.println(entry.size(), DEC);
}
entry.close();
}
}
This is a multi-signal handheld "Wonder tool"
That's not really important.
It has an SD Card. I have developed a way to keep that from interfering with other devices by silencing the lazy miso that the CS pin doesn't quiet. If you don't know what I'm talking about I envy you. This doesn't matter either, because that works. In several devices.
Here's the issue. The example works. I can run cardinfo and listfiles no problem.
If I add it to my code it won't initialize the card.
I've reverse engineered all the libraries included and it's not a conflict there.
I kept adding more of my code to the example until it broke.
I tracked it down to assigning pin 9 to the blue LED as output.
Commenting that function got it to work.
So I go try it in my code, it doesn't work.
I've removed the cc1101 and do not have rf24 installed (they use the same socket) so it's not a conflict on the spi line.
I do remember when developing my Atari console conversion I ran into an issue where despite available memory my numerous bitmaps stored as arrays resulted in fantastic system crashed which made no sense and took me forever to track down.
In that scenario the system broke down once I'd added more graphics.
Despite memory loads, this is still a pretty complicated gadget.
It has "applications" controlled by a mode array which set the states of and monitor numerous pins to create the different functionalities of the unit. It has a GUI with analog mouse cursor navigation.
The unit itself is a self designed and built shield block connecting dozens of modules together in a package smaller than an UNO by itself.
This is my first post, I'm sure I'll get yelled at for my formatting and I apologize in advanced for not researching the procedure.
I've solved a litany of problems on my own, and may very well know the problem now.
Before I gut out my graphics and try to get them loading off the sd card I'd love a second opinion hahaha.
The same hardware combination (though a standard Mega) is working fine in my Atari. But it has a TFT and loads it's bitmaps from the screen.
It's relative complexity leads me to believe I may again have obtuse bitmap arrays writing to unallocated memory. Which was okay until I started trying to allocate that rogue bit and it's getting crossed linked.
** Well that isn't the problem. I deleted all the bitmaps from the edited example and it still fails with all the pins assigned.
Well s**t. I just noticed that when I commented the bluepin assignment out of the example, when it reads the card, the blue LED blinks. It's on pin 9 what the hell. Nothing in the sketches or library that I can find mentions that pin. Unless it's 3 inclusions deep.