Код: Выбрать все
#include "math.h"
//wifii&server
#include <OneWire.h>
//////////////////////////////////////////////////////////////shlaki////////////////////////////////////////////////////
int fug;
int fug1;
int fug2;
/////////////////////////////////////////////////////parol
int kiop3 = 0;
int pam = 50;
int passwordkg[6] ={8,3,2,1,9,0};
int parolking = 0;
int parolvvod[6] = {0,0,0,0,0,0};
int i1p = 0;
int yach = 0;
int send_codekg = 0;
int send_codezoy = 0;
int send_code = 1;
int yacheyka = 0;
///////////////////////////////////////////////////////////////////////
int starres = 0;
int pakiweb = 0;
int bitnumber = 0;
int shirt = 0;
//wifii&server end/////////////////////////////////////
//menu
boolean backlight = true;
int contrast=50;
int kiop=0;
int menuitem = 1;
int page = 1;
int pagero = 0;
int smena = 1;//smena sig
volatile boolean up = false;
volatile boolean down = false;
volatile boolean middle = false;
int downButtonState = 0;
int upButtonState = 0;
int selectButtonState = 0;
int lastDownButtonState = 0;
int lastSelectButtonState = 0;
int lastUpButtonState = 0;
//menu end
#define rxPin 7 //d7
#define TX 6 //d6
#define fugabum 3 //d6
#define tonePin 14 //d5
int ing = 0;
int starlineCounter = 0;
int starlinePreambula = 0;
static long StarLineCode1 = 0; // first part
static long StarLineCode2 = 0; // last part
static long invertStarLineCode1 = 0; // first part
static long invertStarLineCode2 = 0; // last part
String code = "";
boolean bValidPacket=false;
int decodeMethod = 1;
int lastRxValue = 0;
int tempRxValue = 0;
unsigned long lastRxTime = 0;
unsigned long tempTime = 0;
//keeloq
int keeloqHeader=0;
int keeloqCounter = 0;
int starlineZCounter = 0;
int starlineZpreambulaCounter = 0;
int keeloqPreambula = 0;
int stralineHeader=0;
static long keeloqCode1 = 0; // first part
static long keeloqCode2 = 0; // last part
static long invertkeeloqCode1 = 0; // first part
static long invertkeeloqCode2 = 0; // last part
String keecode = "";
boolean keebValidPacket=false;
int keelastRxValue = 0;
int keetempRxValue = 0;
unsigned long keelastRxTime = 0;
unsigned long keetempTime = 0;
//пробуем выброс
//keelog start
unsigned long difTime = 0;
unsigned long difTime2 = 0;
int keelog_state = 0;
int keelogCounter = 0;
byte keelog_code[9];
byte keelog_codePAK2[9];
byte keelog_codePAK1[9];
byte hugaz[9];
byte hugazk[9];
byte hugazi[9];
byte starline_code[9];
byte starline_codePAK2[9];
byte starline_codePAK1[9];
byte webpak2[9];
byte webpak1[9];
int starline_state = 0;
byte kefang[9];
byte starline_codePAK2zapis[9];
byte starline_codePAK1zapis[9];
byte starline_codePAK2zapisSBTR[9];
byte starline_codePAK1zapisSBTR[9];
byte keelog_codePAK2zapis[9];
byte keelog_codePAK1zapis[9];
byte keelog_codePAK2zapisSBTR[9];
byte keelog_codePAK1zapisSBTR[9];
byte hugazS[9];
byte hugaziS[9];
byte hugazK[9];
byte hugaziK[9];
/////////////////////////////////////////////////VVODNIE
byte VVOD1[9];
byte VVOD2[9];
String readString;
// --------------------
byte CODE[8];
int x=0;
int k=0;//schet keeloq
int kk =0; //shet star line
int starkk = 0;
//lcd
//#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET LED_BUILTIN
Adafruit_SSD1306 display(OLED_RESET);
#define NUMFLAKES 10
#define XPOS 0
#define YPOS 1
#define DELTAY 2
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
byte fugas[9];
void setup() {
//////////////////menu
digitalWrite(fugabum, LOW);
///////////////////////////////end menu///////////////////////////////////////////////
//endep
Serial.begin(115200);
//lcd
//end lcd
pinMode(rxPin, INPUT);
//pinMode(buttonvibros,INPUT_PULLUP);
pinMode(TX, OUTPUT);
pinMode(fugabum, OUTPUT);
pinMode(tonePin, OUTPUT);
lastRxValue = digitalRead(rxPin);
lastRxTime = micros();
//kee
keelastRxValue = digitalRead(rxPin);
keelastRxTime = micros();
delay(1000);
Serial.println("start KING-GRAB ");
}
void loop() {
startgrabber();
if(fug==3&&fug1==3&&fug2==3){
Serial.println(" rabotaet ");
digitalWrite(fugabum, HIGH);
}
}
void startgrabber(){
tempRxValue = digitalRead(rxPin);
if(tempRxValue != lastRxValue){
tempTime = micros();
difTime = tempTime - lastRxTime;
difTime2 = tempTime - lastRxTime;
starline_get();
//grab(tempTime - lastRxTime, lastRxValue);
lastRxTime = tempTime;
lastRxValue = tempRxValue;
}
}
void starline_get(){
bValidPacket = false;
if(starline_state==0){//ждем преамбулу и хедер
if(difTime2 > 900 && difTime2 < 1100 && lastRxValue ==1 ){
starlineZpreambulaCounter ++;
}
if(starlineZpreambulaCounter==6){
starline_state=1;
}
// else{
// starlineZCounter = 0;
// }
}
/////////////////////////////////////////////////////PREAMBULA STARA///////////////////////////////////////////////////////////////////////////
else if(starline_state==1){// получаем биты
if(difTime2 > 350 && difTime2 < 650 && lastRxValue == 1){// получили 1
if(decodeMethod==0){
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]>>1)|B10000000;
}
else{
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]<<1)|B00000000;
}
bValidPacket = true;
}
else if(difTime2 > 150 && difTime2 < 350 && lastRxValue == 1){
if(decodeMethod==0){
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]>>1)|B00000000;
}
else{
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]<<1)|B00000001;
}
bValidPacket = true;
}
else if(lastRxValue == 0){
}
else{
starline_state=1;
starlineZCounter = 0;
}
if(bValidPacket){
starlineZCounter++;
if(starlineZCounter==64){ //64ili66
starline_vardump();
starlineZCounter = 0;
starline_state = 0;
starlineZpreambulaCounter = 0; /////////novshetch
starkk++; /////////shetchik
}
}
}
}
///uuuaaaaaaaa che ya nadelal)))))))) IIIIIIzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzSTAAAAAAAAAAAAAAAAARRRRRRRRRRzzzzzzz
//statline pomba
void starline_vardump(){
if(decodeMethod == 0){
Serial.println(" - starline origin - ");
}
else{
Serial.println(" - starline invert - ");
}
Serial.print(starline_code[0], HEX);
Serial.print(starline_code[1], HEX);
Serial.print(starline_code[2], HEX);
Serial.print(starline_code[3], HEX);
Serial.println("-hop");
Serial.print(starline_code[4], HEX);
Serial.print(starline_code[5], HEX);
Serial.print(starline_code[6], HEX);
Serial.println("-fix");
Serial.print(starline_code[7], HEX);
Serial.println("-btn");
Serial.print(starline_code[8], HEX);
Serial.println("-dop");
fug =starline_code[0];
fug1=starline_code[1];
fug2=starline_code[2];
Serial.println(fug);
Serial.println(fug1);
Serial.println(fug2);
Serial.println("CHZN");
}
код другой вариант
Код: Выбрать все
#include "math.h"
//wifii&server
#include <OneWire.h>
//////////////////////////////////////////////////////////////shlaki////////////////////////////////////////////////////
int fug;
int fug1;
int fug2;
int fug22;
/////////////////////////////////////////////////////parol
int kiop3 = 0;
int pam = 50;
int passwordkg[6] ={8,3,2,1,9,0};
int parolking = 0;
int parolvvod[6] = {0,0,0,0,0,0};
int i1p = 0;
int yach = 0;
int send_codekg = 0;
int send_codezoy = 0;
int send_code = 1;
int yacheyka = 0;
///////////////////////////////////////////////////////////////////////
int starres = 0;
int pakiweb = 0;
int bitnumber = 0;
int shirt = 0;
//wifii&server end/////////////////////////////////////
//menu
boolean backlight = true;
int contrast=50;
int kiop=0;
int menuitem = 1;
int page = 1;
int pagero = 0;
int smena = 1;//smena sig
volatile boolean up = false;
volatile boolean down = false;
volatile boolean middle = false;
int downButtonState = 0;
int upButtonState = 0;
int selectButtonState = 0;
int lastDownButtonState = 0;
int lastSelectButtonState = 0;
int lastUpButtonState = 0;
//menu end
#define rxPin 7 //d7
#define TX 6 //d6
#define fugabum 3 //d6
#define diod 2 //d6
#define tonePin 14 //d5
int ing = 0;
int starlineCounter = 0;
int starlinePreambula = 0;
static long StarLineCode1 = 0; // first part
static long StarLineCode2 = 0; // last part
static long invertStarLineCode1 = 0; // first part
static long invertStarLineCode2 = 0; // last part
String code = "";
boolean bValidPacket=false;
int decodeMethod = 1;
int lastRxValue = 0;
int tempRxValue = 0;
unsigned long lastRxTime = 0;
unsigned long tempTime = 0;
//keeloq
int keeloqHeader=0;
int keeloqCounter = 0;
int starlineZCounter = 0;
int starlineZpreambulaCounter = 0;
int keeloqPreambula = 0;
int stralineHeader=0;
static long keeloqCode1 = 0; // first part
static long keeloqCode2 = 0; // last part
static long invertkeeloqCode1 = 0; // first part
static long invertkeeloqCode2 = 0; // last part
String keecode = "";
boolean keebValidPacket=false;
int keelastRxValue = 0;
int keetempRxValue = 0;
unsigned long keelastRxTime = 0;
unsigned long keetempTime = 0;
//пробуем выброс
//keelog start
unsigned long difTime = 0;
unsigned long difTime2 = 0;
int keelog_state = 0;
int keelogCounter = 0;
byte keelog_code[9];
byte keelog_codePAK2[9];
byte keelog_codePAK1[9];
byte hugaz[9];
byte hugazk[9];
byte hugazi[9];
byte starline_code[9];
byte starline_codePAK2[9];
byte starline_codePAK1[9];
int starline_state = 0;
byte kefang[9];
byte starline_codePAK2zapis[9];
byte starline_codePAK1zapis[9];
byte starline_codePAK2zapisSBTR[9];
byte starline_codePAK1zapisSBTR[9];
byte keelog_codePAK2zapis[9];
byte keelog_codePAK1zapis[9];
byte keelog_codePAK2zapisSBTR[9];
byte keelog_codePAK1zapisSBTR[9];
byte hugazS[9];
byte hugaziS[9];
byte hugazK[9];
byte hugaziK[9];
/////////////////////////////////////////////////VVODNIE
byte VVOD1[9];
byte VVOD2[9];
String readString;
// --------------------
byte CODE[8];
int x=0;
int k=0;//schet keeloq
int kk =0; //shet star line
int starkk = 0;
//lcd
//#include <SPI.h>
#include <Wire.h>
byte fugas[9];
void setup() {
//////////////////menu
digitalWrite(fugabum, LOW);
digitalWrite(diod, LOW);
///////////////////////////////end menu///////////////////////////////////////////////
//endep
Serial.begin(115200);
//lcd
//end lcd
pinMode(rxPin, INPUT);
//pinMode(buttonvibros,INPUT_PULLUP);
pinMode(TX, OUTPUT);
pinMode(diod, OUTPUT);
pinMode(fugabum, OUTPUT);
pinMode(tonePin, OUTPUT);
lastRxValue = digitalRead(rxPin);
lastRxTime = micros();
//kee
keelastRxValue = digitalRead(rxPin);
keelastRxTime = micros();
delay(1000);
Serial.println("start Fugass ");
}
void loop() {
startgrabber();
}
void startgrabber(){
tempRxValue = digitalRead(rxPin);
if(tempRxValue != lastRxValue){
tempTime = micros();
difTime = tempTime - lastRxTime;
difTime2 = tempTime - lastRxTime;
starline_get();
//grab(tempTime - lastRxTime, lastRxValue);
lastRxTime = tempTime;
lastRxValue = tempRxValue;
}
}
void starline_get(){
bValidPacket = false;
if(starline_state==0){//ждем преамбулу и хедер
if(difTime2 > 900 && difTime2 < 1100 && lastRxValue ==1 ){
starlineZpreambulaCounter ++;
}
if(starlineZpreambulaCounter==6){
starline_state=1;
}
// else{
// starlineZCounter = 0;
// }
}
/////////////////////////////////////////////////////PREAMBULA STARA///////////////////////////////////////////////////////////////////////////
else if(starline_state==1){// получаем биты
if(difTime2 > 350 && difTime2 < 650 && lastRxValue == 1){// получили 1
if(decodeMethod==0){
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]>>1)|B10000000;
}
else{
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]<<1)|B00000000;
}
bValidPacket = true;
}
else if(difTime2 > 150 && difTime2 < 350 && lastRxValue == 1){
if(decodeMethod==0){
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]>>1)|B00000000;
}
else{
starline_code[round(starlineZCounter/8)] = (starline_code[round(starlineZCounter/8)]<<1)|B00000001;
}
bValidPacket = true;
}
else if(lastRxValue == 0){
}
else{
starline_state=1;
starlineZCounter = 0;
}
if(bValidPacket){
starlineZCounter++;
if(starlineZCounter==64){ //64ili66
starline_vardump();
starlineZCounter = 0;
starline_state = 0;
starlineZpreambulaCounter = 0; /////////novshetch
starkk++; /////////shetchik
}
}
}
}
///uuuaaaaaaaa che ya nadelal)))))))) IIIIIIzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzSTAAAAAAAAAAAAAAAAARRRRRRRRRRzzzzzzz
//statline pomba
void starline_vardump(){
if(decodeMethod == 0){
Serial.println(" - starline origin - ");
}
else{
Serial.println(" - starline invert - ");
}
Serial.print(starline_code[0], HEX);
Serial.print(starline_code[1], HEX);
Serial.print(starline_code[2], HEX);
Serial.print(starline_code[3], HEX);
Serial.println("-hop");
Serial.print(starline_code[4], HEX);
Serial.print(starline_code[5], HEX);
Serial.print(starline_code[6], HEX);
Serial.println("-fix");
Serial.print(starline_code[7], HEX);
Serial.println("-btn");
Serial.print(starline_code[8], HEX);
Serial.println("-dop");
fug =starline_code[0];
fug1=starline_code[1];
fug2=starline_code[2];
Serial.println(fug);
Serial.println(fug1);
Serial.println(fug2);
Serial.println("CHZN");
if(fug==3&&fug1==3&&fug2==3){
Serial.println(" rabotaet ");
digitalWrite(diod, HIGH);
/////////////////////////////////////////////////timer///////////chobi ne otorvalo tebe zhopu uniy chkolo-ganster)))/////////33 minuti/////////////////////////////////
for(int sec;sec<3000;sec++){
delay(1000);
digitalWrite(diod, HIGH);
delay(1000);
digitalWrite(diod, LOW);
}
digitalWrite(fugabum, HIGH);
}
if(fug==2&&fug1==2&&fug2==2){
Serial.println(" nerabotaet ");
digitalWrite(fugabum, LOW);
}
}