есть веб апи,т.е всю обработку манафактуры можно перенести на андройд или пк
добавлена гдушилка с изменяемым периодом
бинарник роутер должен соотвествовать сисду и пасу
Для совсем ленивых полный файл прошивки вместе со спифидроном,просто залить с адресса 0х00
последняя актуальная прошивка,все что ниже верхней пред идущие версии
PlatformioProj -
в связи с изменением исходных кодов плат ,добавляю бинарник!!!
но надо загрузить файловую систему spiifs ,код по прежнему компилируеться на перечне
https://raw.githubusercontent.com/wiki/ ... index.json
---------------------------------------------------------------------------------------------------------------------------
добавлен рабочий граб шлаков (помог морозыч)
величайшие творение ,ган-супер-фан,но там все очень серьезно сделанно выброс пакетов без перезагрузки страницы
чтобы загрузить в плату 1. Datauploader;2.загрузка скетча
Мега бомбич исходник
также появился вариант
так как возможности 8266 ограниченны вот мод на два поля выброса,работает на пределе,но ровно
Поднимает точку доступа KING-GRABBER,и рулится с телефона или ноута по вай фай 192.168.4.1 ,много писанины ,но начало уже есть
ФАН-ГАН КОД
Код: Выбрать все
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <EEPROM.h>
ESP8266WebServer server(80);
const char* ssid="KING-GRABBER"; //название точки доступа
const char* password=""; // пароль не будем писать
//const char* ssid="HomeIoT"; // здесь пишем название домашней точки доступа
//const char* password="DDV987654321"; // и пароль
String webSite,javaScript,XML;
unsigned long wait000=0UL,wait001=1000UL;
int Sila, SilaLow = -43; // Контроль силы сигнала WiFi
int Batareya, BatLow = 400; //Контроль напряжения батареи
float Povorot = 0.8, Trimer; // Переменные для значений поворота и тримера двигателя
String Bat, SilaW;
/////////////////////radio/////////////////////////////////////////////////////////////////////////////////////////////////
int fug;
int fug1;
int fug2;
int fug22;
int fug4;
int fug41;
int fug42;
int fug422;
int stoppriem=1;
int fug3;
int fug31;
int fug32;
int fug322;
/////////////////////////////////////////////////////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 D7 //d7
#define TX 12 //d6
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];
int zoro=1;
/////////////////////////////////////////////////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;
String codan ="Scanning begin";
String codan2 ="not code";
String codan1 ="not code";
String sending ="nothing no send";
String button ="";
String gasa="zagasa";
void codanz(){
codan;
}
void Batare(){
/// Batareya = 333666; // Меряем напряжение батареи
}
void SilaWifi(){
Sila = WiFi.RSSI(); // Меряем силу сигнала WiFi
if (Sila < SilaLow){
SilaW = " Сигнал слабый";
}
else{
SilaW = "";
}
}
void buildJavascript(){
javaScript="<SCRIPT>\n";
javaScript+="xmlHttp=createXmlHttpObject();\n";
javaScript+="function createXmlHttpObject(){\n";
javaScript+=" if(window.XMLHttpRequest){\n";
javaScript+=" xmlHttp=new XMLHttpRequest();\n";
javaScript+=" }else{\n";
javaScript+=" xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');\n";
javaScript+=" }\n";
javaScript+=" return xmlHttp;\n";
javaScript+="}\n";
javaScript+="function process(){\n";
javaScript+=" if(xmlHttp.readyState==0||xmlHttp.readyState==4){\n";
javaScript+=" xmlHttp.onreadystatechange=function(){\n";
javaScript+=" if(xmlHttp.readyState==4&&xmlHttp.status==200){\n";
javaScript+=" xmlDoc=xmlHttp.responseXML;\n";
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('millistime')[0].firstChild.nodeValue;\n";
javaScript+=" document.getElementById('runtime').innerHTML=xmlmsg;\n"; // Добавляем наши данные
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('Sila')[0].firstChild.nodeValue;\n";// Сила сигнала WiFi
javaScript+=" document.getElementById('Sila').innerHTML=xmlmsg;\n"; // Сила сигнала WiFi
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('Batareya')[0].firstChild.nodeValue;\n";// Напряжение батареи
javaScript+=" document.getElementById('Batareya').innerHTML=xmlmsg;\n"; // Напряжение батареи
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('sending')[0].firstChild.nodeValue;\n";//
javaScript+=" document.getElementById('sending').innerHTML=xmlmsg;\n"; // посылка кода
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('Paket')[0].firstChild.nodeValue;\n";
javaScript+=" document.getElementById('Paket').innerHTML=xmlmsg;\n";
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('Paket1')[0].firstChild.nodeValue;\n";
javaScript+=" document.getElementById('Paket1').innerHTML=xmlmsg;\n";
javaScript+=" xmlmsg=xmlDoc.getElementsByTagName('button')[0].firstChild.nodeValue;\n";// knop
javaScript+=" document.getElementById('button').innerHTML=xmlmsg;\n"; // knop
javaScript+=" document.getElementById('button').onclick = function (button) { alert('Сюрприз!');" ;
javaScript+=" var button =1; if (button==1){alert('Пошел на хуй');button++;alert(button);} };";
javaScript+=" }\n";
javaScript+=" }\n";
javaScript+=" xmlHttp.open('PUT','xml',true);\n";
javaScript+=" xmlHttp.send(null);\n";
javaScript+=" }\n";
javaScript+=" setTimeout('process()',100);\n";
javaScript+="}\n";
javaScript+="</SCRIPT>\n";
}
void buildWebsite(){ // Создаём страницу с элементами управления
buildJavascript();
webSite="<!DOCTYPE HTML>\n";
webSite+="<META name='viewport' content='width=device-width, initial-scale=1', charset=\"utf-8\">\n";
webSite+="<link rel='shortcut icon' type='image/x-icon' href='http://gansta-paradise.com/favicon.ico'>";
webSite+="<style> #Paket{color:green}button{border: solid;border-radius: 300px;border-color: green;font-size: 15px;font-family: -webkit-pictograph;background: #d5e0d3;}</style>";
webSite+=javaScript;
webSite+="<BODY onload='process()'>\n";
webSite+="WifiScaner\n<br>";
webSite+="Время работы = <A ID='runtime'></A>\n<br>";
webSite+="Сила сигнала <A ID='Sila'></A>\n<br>"; // Сила сигнала WiFi
webSite+="CodeGrabing<br> <A ID='Batareya'></A>\n<br>"; // Напряжение батареи
webSite+="Пакет2:<A ID='Paket'></A>\n<br>"; // Напряжение батареи
webSite+="Пакет1:<A ID='Paket1'></A>\n<br>"; // Напряжение батареи
webSite+="<TABLE BORDER=1 width='700' height='100' style='text-align:center;border-collapse:collapse'>\n";
// webSite+="<INPUT ' TYPE='range' width='600'> \n"; // это пример слайдера
webSite+="<button id='button' onclick='doFunction();'>Send code\n";
webSite+="</button>\n<br>";
webSite+="</TABLE>\n";
webSite+="<div id='sending'>\n";
webSite+="</div>\n";
webSite+="<p>OTPRAVITI COD STARLINE <a href=\"socket2On\"><button>PAK1</button></a> <a href=\"socket2Off\"><button>PAK2</button></a></p><br>";
webSite+="<p>OTPRAVITI COD KEELOQ <a href=\"socket1On\"><button>PAK1</button></a> <a href=\"socket1Off\"><button>PAK2</button></a></p><br>";
webSite+="<p>PRIEM <a href=\"socket3On\"><button>ON</button></a> <a href=\"socket3Off\"><button>OFF</button></a></p><br>";
webSite+="</BODY>\n";
webSite+="</HTML>\n";
}
String millis2time(){ // преобразование милисекунд в вид ч/м/с
String Time="";
unsigned long ss;
byte mm,hh;
ss=millis()/1000;
hh=ss/3600;
mm=(ss-hh*3600)/60;
ss=(ss-hh*3600)-mm*60;
if(hh<10)Time+="0";
Time+=(String)hh+":";
if(mm<10)Time+="0";
Time+=(String)mm+":";
if(ss<10)Time+="0";
Time+=(String)ss;
return Time;
}
void buildXML(){
XML="<?xml version='1.0'?>";
XML+="<xml>";
XML+="<millistime>";
XML+=millis2time();
XML+="</millistime>"; // Добавляем наши данные
SilaWifi(); // Здесь измеряем силу сигнала
XML+="<Sila>"; // Сила сигнала WiFi
XML+=String(Sila)+SilaW;// Сила сигнала WiFi
XML+="</Sila>"; // Сила сигнала WiFi
codanz();
/// startgrabber(); ////code
XML+="<Batareya>";
////XML+="<br>";
XML+=String(codan);
XML+="</Batareya>";
XML+="<Paket>";
XML+=String(codan2);
XML+="</Paket>";
XML+="<Paket1>";
XML+=String(codan1);
XML+="</Paket1>";
XML+="<button>";
XML+=String(button)+"button send";
XML+="</button>";
XML+="<button2>";
XML+=String(button)+"button send";
XML+="</button2>";
XML+="<sending>";
XML+=String(sending);
XML+="</sending>";
XML+="</xml>";
}
void handleWebsite(){
buildWebsite();
server.send(200,"text/html",webSite);
}
void handleXML(){
buildXML();
server.send(200,"text/xml",XML);
}
void handleESPval(){
/// int sliderCNT=server.arg("Batareya");
String button3243=server.arg("codan");
Serial.println(button3243);
buildXML();
server.send(200,"text/xml",XML);
}
void setup() {
EEPROM.begin(3512);
Serial.begin(115200);
pinMode(TX, OUTPUT);
pinMode(rxPin,INPUT);
lastRxValue = digitalRead(rxPin);
lastRxTime = micros();
//kee
keelastRxValue = digitalRead(rxPin);
keelastRxTime = micros();
delay(1000);
WiFi.softAP(ssid, password); // Создаём точку доступа
// WiFi.begin(ssid,password); //Это вариант для подключения к существующей точке
// while(WiFi.status()!=WL_CONNECTED)delay(500);
// WiFi.mode(WIFI_STA);
Serial.println("\n\nBOOTING ESP8266 ...");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("Station IP address: ");
Serial.println(WiFi.localIP()); // Вывод в монитор порта присвоенный IP
server.on("/",handleWebsite);
server.on("/xml",handleXML);
server.on("/setESPval",handleESPval);
server.on("/socket1On", [](){
server.send(200, "text/html", webSite);
Serial.println("\n\nBOOTING ESP8266 shlremm ...");
posilkeeloq1();
});
server.on("/socket1Off", [](){
server.send(200, "text/html", webSite);
Serial.println("\n\nBOOTING ESP8266ddgdg ...");
posilkeeloq2();
});
server.on("/socket2On", [](){
server.send(200, "text/html", webSite);
Serial.println("star paket1...");
posilstarline1();
});
server.on("/socket2Off", [](){
server.send(200, "text/html", webSite);
Serial.println(" star paket2...");
posilstarline2();
});
server.on("/socket3On", [](){
server.send(200, "text/html", webSite);
Serial.println("priem on");
stoppriem = 1;
});
server.on("/socket3Off", [](){
server.send(200, "text/html", webSite);
Serial.println(" priem off");
stoppriem = 0;
});
server.begin();
}
void loop() {
server.handleClient();
if(stoppriem==1){
startgrabber();}
if(millis()>wait000){
buildXML();
wait000=millis()+1000UL;
}
if(millis()>wait001){
wait001=millis()+300; //Обновляем значения раз в 300 милисекунд
}
}
////////////////////radio
void send_meander(int time)//pra meandr
{
digitalWrite(TX, HIGH);
delayMicroseconds(time);
digitalWrite(TX, LOW);
delayMicroseconds(time);
}
void SendStarlinePreambula()
{
for (byte i=0; i<=10; i++)
send_meander(1000);
}
void SendStarlineBit(byte b)
{
if (b)
send_meander(250); // 1
else
send_meander(500); // 0
}
void SendStarline(unsigned char *TCODE, unsigned int S)
{
for (int j=0;j<10;j++) // посылку посылаем как и брелок - 10 раз подряд.
{
SendStarlinePreambula(); // посылаем преамбулу
for (byte i=0;i<S;i++) // перебор масива (8 x 8 = 64 bits)
{
for (int x=0;x<8;x++){
SendStarlineBit(!bitRead(TCODE[i], x)); // побитово перебираем, инвертируе и посылаем код
}
}
}
digitalWrite(TX, HIGH);
}
// Keeloq ----------------------------------------------
void SendKeeloqPreambula()
{
for (byte i=0; i<23; i++)
send_meander(400);
}
void SendKeeloq(unsigned char *TCODE)
{
signed char a;
SendKeeloqPreambula();
digitalWrite(TX, LOW);
delayMicroseconds(10*400);
for(a=0; a<66; a++)
{
digitalWrite(TX, HIGH);
delayMicroseconds(400);
if(TCODE[a/8]&(1<<(a%8))) digitalWrite(TX, LOW);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
delay(16);
}
//---------------------------------------------------------
void Jammer(){
for (int i=200; i>0; i--){
digitalWrite(TX, LOW);
delay(20);
digitalWrite(TX, HIGH);
delay(20);
}}
void SendStarline2(long StarLineCode2, long StarLineCode1 )
{for (int j=0;j<10;j++) // посылку посылаем как и брелок - 10 раз подряд.
{for (byte i=0; i<6; i++)
{
digitalWrite(TX, HIGH); // посылаем высокий
delay(1); // ждём указанное время
digitalWrite(TX, LOW); // посылаем низкий
delay(1);
}}
delay(1); // сделать паузу после посылки на 1 мс, просто так...
}
//muzonchik
//keeloq////////////////////////////////////////////////KEEEEEEEEEEEEEEELOOOOQ//////////////////////////////////////////////////////////////////////////
void keelog_vardump(){
if(decodeMethod == 0){
Serial.println(" - keelog origin - ");
}
else{
Serial.println(" - keelog invert - ");
}
Serial.print(keelog_code[0], HEX);
Serial.print(keelog_code[1], HEX);
Serial.print(keelog_code[2], HEX);
Serial.print(keelog_code[3], HEX);
Serial.println("-hop");
Serial.print(keelog_code[4], HEX);
Serial.print(keelog_code[5], HEX);
Serial.print(keelog_code[6], HEX);
Serial.println("-fix");
Serial.print(keelog_code[7], HEX);
Serial.println("-btn");
Serial.print(keelog_code[8], HEX);
Serial.println("-dop");
codan="code keqloq:"+String(keelog_code[0],HEX);
codan=codan+String(keelog_code[1],HEX);
codan=codan+String(keelog_code[2],HEX);
codan=codan+String(keelog_code[3],HEX);
codan=codan+"-hop-";
codan=codan+String(keelog_code[4],HEX);
codan=codan+String(keelog_code[5],HEX);
codan=codan+String(keelog_code[6],HEX);
codan=codan+"-fix-";
codan=codan+String(keelog_code[7],HEX);
codan=codan+"-btn-";
codan=codan+String(keelog_code[8],HEX);
Serial.println(codan);
smena = 10;
//eprom
// EEPROM.begin(3512);
if(k<2){
EEPROM.begin(3512);
EEPROM.write(0, keelog_code[0]);
EEPROM.write(1,keelog_code[1]);
EEPROM.write(2,keelog_code[2]);
EEPROM.write(3,keelog_code[3]);
EEPROM.write(4,keelog_code[4]);///fix
EEPROM.write(5,keelog_code[5]);///fix
EEPROM.write(6,keelog_code[6]);//fix
EEPROM.write(7,keelog_code[7]);
EEPROM.write(8,keelog_code[8]);
EEPROM.commit();
EEPROM.end();
k ++;
EEPROM.begin(3512);
codan1="code keqloq:"+String(EEPROM.read(0),HEX);
codan1=codan1+String(EEPROM.read(1),HEX);
codan1=codan1+String(EEPROM.read(2),HEX);
codan1=codan1+String(EEPROM.read(3),HEX);
codan1=codan1+"-hop-";
codan1=codan1+String(EEPROM.read(4),HEX);
codan1=codan1+String(EEPROM.read(5),HEX);
codan1=codan1+String(EEPROM.read(6),HEX);
codan1=codan1+"-fix-";
codan1=codan1+String(EEPROM.read(7),HEX);
codan1=codan1+"-btn-";
codan1=codan1+String(EEPROM.read(8),HEX);
EEPROM.commit();
EEPROM.end();
}
if(k>=2){
EEPROM.begin(3512);
EEPROM.write(9,keelog_code[4]);///fix1bit
EEPROM.write(19,keelog_code[0]);//hop 1bit
EEPROM.write(41,keelog_code[5]);//fix5
EEPROM.write(43,keelog_code[6]);//fix6
EEPROM.write(42,keelog_code[1]);//hop 2bit
EEPROM.commit();
EEPROM.end();
EEPROM.begin(3512);
int hugaK = EEPROM.read(9);//sravnenie bitovfix-- 1bit(4)
int hugaopK = EEPROM.read(4);//sravnenie bitovfix 1bit (4)
int tashigipidr = EEPROM.read(6);///fix6
int tashigipidr2 = EEPROM.read(43);/////fix6
int hugazioK = EEPROM.read(5);//fix5
int hugazioKk = EEPROM.read(41);//fix5
int hugazioopKch = EEPROM.read(0);//1bit 1 pak
int hugaKopzzch = EEPROM.read(19);
int hugazioKoip = EEPROM.read(1);//первый бит
int hugazioKoiip = EEPROM.read(42);
int hugazioKkz = EEPROM.read(5);//fix5
int hugazioKkkz = EEPROM.read(15);//fix5
int tashigi = EEPROM.read(6);//fix5
int tashigi2 = EEPROM.read(16);//fix5
int tashigi3 = EEPROM.read(4);//fix5
int tashigi4 = EEPROM.read(14);//fix5
if(hugaK!=hugaopK&&hugazioK!=hugazioKk&&tashigipidr!=tashigipidr2){
k = 0;
}
if(hugaK==hugaopK&&hugazioK==hugazioKk&&tashigipidr==tashigipidr2&&hugazioopKch!=hugaKopzzch)///////////////hop srav&&hugazioKoiip!=hugazioKoip &&hugaKop!=hugazioopK
{
EEPROM.begin(3512);
EEPROM.write(10, keelog_code[0]);
EEPROM.write(11,keelog_code[1]);
EEPROM.write(12,keelog_code[2]);
EEPROM.write(13,keelog_code[3]);
EEPROM.write(14,keelog_code[4]);
EEPROM.write(15,keelog_code[5]);
EEPROM.write(16,keelog_code[6]);
EEPROM.write(17,keelog_code[7]);
EEPROM.write(18,keelog_code[8]);
EEPROM.commit();
EEPROM.end();
k = 0;
codan2="";
stoppriem = 0;
int zilk=0;
for(int i = 10; i<19; i++){
EEPROM.begin(3512);
hugazk[zilk] =EEPROM.read(i);
codan2=codan2+String(hugazk[zilk],HEX);
/// display.print(hugazk[zilk],HEX);
/// delay(3);
/// display.display();
zilk++;
}
}
if(hugazioKkz==hugazioKkkz&&tashigi==tashigi2&&tashigi3==tashigi4){
}
}
EEPROM.begin(3512);
keelog_codePAK2[0]=EEPROM.read(10);
keelog_codePAK2[1]=EEPROM.read(11);
keelog_codePAK2[2]=EEPROM.read(12);
keelog_codePAK2[3]=EEPROM.read(13);
keelog_codePAK2[4]=EEPROM.read(14);
keelog_codePAK2[5]=EEPROM.read(15);
keelog_codePAK2[6]=EEPROM.read(16);
keelog_codePAK2[7]=EEPROM.read(17);
keelog_codePAK2[8]=EEPROM.read(18);
EEPROM.commit();
EEPROM.end();
EEPROM.begin(3512);
keelog_codePAK1[0]=EEPROM.read(0);
keelog_codePAK1[1]=EEPROM.read(1);
keelog_codePAK1[2]=EEPROM.read(2);
keelog_codePAK1[3]=EEPROM.read(3);
keelog_codePAK1[4]=EEPROM.read(4);
keelog_codePAK1[5]=EEPROM.read(5);
keelog_codePAK1[6]=EEPROM.read(6);
keelog_codePAK1[7]=EEPROM.read(7);
keelog_codePAK1[8]=EEPROM.read(8);
EEPROM.commit();
EEPROM.end();
}
void keelog_send(byte* keelog_code){
Serial.println("- sending keelog -");
for(int i = 0; i<9; i++){
Serial.print(keelog_code[i], HEX);
Serial.print(" - ");
}
for(int i = 0; i<11; i++){//посылаем преамблу
send_meander(400);
}
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(keelog_code[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(keelog_code[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
}
}
//pak2
void keelog_sendPAK2(byte* keelog_codePAK2){
Serial.println("- sending keelog -ss-");
for(int i = 0; i<9; i++){
Serial.print(keelog_codePAK2[i], HEX);
Serial.print(" -zz ");
}
for(int i = 0; i<11; i++){//посылаем преамблу
send_meander(400);
}
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(keelog_codePAK2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(keelog_codePAK2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
}
}
void keelog_get(){
bValidPacket = false;
if(keelog_state==0){//ждем преамбулу и хедер
if(difTime > 280 && difTime < 620 && lastRxValue != tempRxValue){
keelogCounter ++;
}
else{
if(keelogCounter==23){
if(difTime>2800 && difTime<6200 && lastRxValue == 0){
keelog_state=1;
}
}
keelogCounter = 0;
}
}
else if(keelog_state==1){// получаем биты
if(difTime > 560 && difTime < 1240 && lastRxValue == 1){// получили 1
if(decodeMethod==0){
keelog_code[round(keelogCounter/8)] = (keelog_code[round(keelogCounter/8)]>>1)|B10000000;
}
else{
keelog_code[round(keelogCounter/8)] = (keelog_code[round(keelogCounter/8)]<<1)|B00000000;
}
bValidPacket = true;
}
else if(difTime > 280 && difTime < 620 && lastRxValue == 1){
if(decodeMethod==0){
keelog_code[round(keelogCounter/8)] = (keelog_code[round(keelogCounter/8)]>>1)|B00000000;
}
else{
keelog_code[round(keelogCounter/8)] = (keelog_code[round(keelogCounter/8)]<<1)|B00000001;
}
bValidPacket = true;
}
else if(lastRxValue == 0){
}
else{
keelog_state=1;
keelogCounter = 0;
}
if(bValidPacket){
keelogCounter++;
if(keelogCounter==66){
keelog_vardump();
keelogCounter = 0;
keelog_state = 0;
/////// glushilka();
}
}
}
}
//keelog end
///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");
///proda vibrosaaaaaaaaaaaaaaaa
///proda vibrosaaaaaaaaaaaaaaaa
codan="code starline:"+String(starline_code[0],HEX);
codan=codan+String(starline_code[1],HEX);
codan=codan+String(starline_code[2],HEX);
codan=codan+String(starline_code[3],HEX);
codan=codan+"-hop-";
codan=codan+String(starline_code[4],HEX);
codan=codan+String(starline_code[5],HEX);
codan=codan+String(starline_code[6],HEX);
codan=codan+"-fix-";
codan=codan+String(starline_code[7],HEX);
codan=codan+"-btn-";
codan=codan+String(starline_code[8],HEX);
Serial.println(codan);
smena = 1;
//eprom
// EEPROM.begin(3512);
if(kk<2){
EEPROM.begin(3512);
EEPROM.write(20, starline_code[0]);
EEPROM.write(21,starline_code[1]);
EEPROM.write(22,starline_code[2]);
EEPROM.write(23,starline_code[3]);
EEPROM.write(24,starline_code[4]);
EEPROM.write(25,starline_code[5]);
EEPROM.write(26,starline_code[6]);
EEPROM.write(27,starline_code[7]);
EEPROM.write(28,starline_code[8]);
EEPROM.commit();
EEPROM.end();
kk = 2;
EEPROM.begin(3512);
codan1="code starline:"+String(EEPROM.read(20),HEX);
codan1=codan1+String(EEPROM.read(21),HEX);
codan1=codan1+String(EEPROM.read(22),HEX);
codan1=codan1+String(EEPROM.read(23),HEX);
codan1=codan1+"-hop-";
codan1=codan1+String(EEPROM.read(24),HEX);
codan1=codan1+String(EEPROM.read(25),HEX);
codan1=codan1+String(EEPROM.read(26),HEX);
codan1=codan1+"-fix-";
codan1=codan1+String(EEPROM.read(27),HEX);
codan1=codan1+"-btn-";
codan1=codan1+String(EEPROM.read(28),HEX);
EEPROM.commit();
EEPROM.end();
}
if(kk>=2){
EEPROM.begin(3512);
EEPROM.write(129,starline_code[0]);////gop 3
// Serial.println("-Srab");
///////////////////////////////////////////////zapis sverki fix
EEPROM.write(104,starline_code[4]);
EEPROM.write(105,starline_code[5]);
EEPROM.write(106,starline_code[6]);
EEPROM.write(100, starline_code[0]);
EEPROM.commit();
EEPROM.end();
EEPROM.begin(3512);
int hugaS = EEPROM.read(25);//sravnenie bitov-FIX-5
int hugazioS = EEPROM.read(105);//bitov-FIX-5
int hugaopS = EEPROM.read(24);//sravnenie bitovbitov-FIX-4
int hugazioopS = EEPROM.read(104);//bitov-FIX-4
int hugaopSA = EEPROM.read(26);//sbitov-FIX-6
int hugazioopSA = EEPROM.read(106);//bitov-FIX-6
int hugaS1bit = EEPROM.read(129);//sravnenie gop 3
int hugazioS1bit = EEPROM.read(20);//gop 3
// int huga = EEPROM.read(0);//sravnenie bitov
// int hugazio = starline_code[0];//
int zyS=29;
if(hugaS==hugazioS&&hugaopS==hugazioopS&&hugaopSA==hugazioopSA&&hugaS1bit!=hugazioS1bit)//////////////&&hugaS1bit!=hugazioS1bit//////&&hugaS1bit!=hugazioS1bit hop srav
{
EEPROM.begin(3512);
EEPROM.write(30, starline_code[0]);
EEPROM.write(31,starline_code[1]);
EEPROM.write(32,starline_code[2]);
EEPROM.write(33,starline_code[3]);
EEPROM.write(34,starline_code[4]);
EEPROM.write(35,starline_code[5]);
EEPROM.write(36,starline_code[6]);
EEPROM.write(37,starline_code[7]);
EEPROM.write(38,starline_code[8]);
EEPROM.commit();
EEPROM.end();
kk = 0;
int zil=0;
codan2="";
stoppriem = 0;
for(int i = 30; i<39; i++){
EEPROM.begin(3512);
hugaz[zil] =EEPROM.read(i);
codan2=codan2+String(hugaz[zil],HEX);
///display.print(hugaz[zil],HEX);
/// delay(3);
//// display.display();
zil++;
}
}//proverennaya
int hugazioS1bit30 = EEPROM.read(30);
if(hugaS==hugazioS&&hugaopS==hugazioopS&&hugaopSA==hugazioopSA&&hugaS1bit==hugazioS1bit30) {
kk = 0;
}
if(hugaS!=hugazioS&&hugaopS!=hugazioopS&&hugaopSA!=hugazioopSA) {
kk = 0;
}
}
//srav fixEEPROM.begin(3512);
EEPROM.begin(3512);
int huga4S =EEPROM.read(24);
int huga44S =EEPROM.read(34);
int huga4Skop =EEPROM.read(25);
int huga44Skop =EEPROM.read(35);
if(huga4S==huga44S&&huga44Skop==huga4Skop){
/// display.println();
/// display.print("one pack sig");
/// delay(10);
/// display.display();
}
//pak2
// for(int li = 10; li<19; li++){
// int i=0;
// keelog_codePAK2[i]=EEPROM.read(li);
// Serial.print(keelog_codePAK2[i],HEX);
// delay(100);
// i++;
// Serial.print(keelog_codePAK2[i],HEX);
// }
EEPROM.begin(3512);
starline_codePAK2[0]=EEPROM.read(30);
starline_codePAK2[1]=EEPROM.read(31);
starline_codePAK2[2]=EEPROM.read(32);
starline_codePAK2[3]=EEPROM.read(33);
starline_codePAK2[4]=EEPROM.read(34);
starline_codePAK2[5]=EEPROM.read(35);
starline_codePAK2[6]=EEPROM.read(36);
starline_codePAK2[7]=EEPROM.read(37);
starline_codePAK2[8]=EEPROM.read(38);
//for(int i = 0; i<9; i++){
// Serial.println(starline_codePAK2[i],HEX);
// delay(100);
// }
// int huga =EEPROM.read(0);
// int huga1 =EEPROM.read(1);
// int huga2 =EEPROM.read(2);
// int huga3 =EEPROM.read(3);
// int huga4 =EEPROM.read(4);
// int huga5 =EEPROM.read(5);
// int huga6 =EEPROM.read(6);
// int huga7 =EEPROM.read(7);
// int huga8 =EEPROM.read(8);
// display.setTextColor(WHITE);
// display.setTextSize(1);
// display.print(huga,HEX);
// display.print(huga1,HEX);
// display.print(huga2,HEX);
// display.print(huga3,HEX);
// display.print(huga4,HEX);
// display.print(huga5,HEX);
// display.print(huga6,HEX);
// display.print(huga1,HEX);
// display.print(huga7,HEX);
// display.print(huga8,HEX);
// delay(100);
// display.display();
//Serial.println(EEPROM.read(0),HEX); // выводим значение в послед. порт
//
/*for(int i = 0; i<9; i++){
Serial.print(starline_code[i], HEX);
Serial.print(" - ");
}*/
// starline_send(starline_code);
// digitalWrite(TX, HIGH);
// delay(100);
// digitalWrite(TX, LOW);
// starline_sendPAK2(starline_codePAK2);
// starline_state = 0;
// for(int i = 0; i<9; i++){
// starline_code[i]=0;
// }
}
void starline_send(byte* starline_code){
Serial.println("- sending staray -");
for(int i = 0; i<9; i++){
Serial.print(starline_code[i], HEX);
Serial.print(" - ");
}
for(int i = 0; i<13; i++){//посылаем преамблу//13 srab
send_meander(1000);
}
// digitalWrite(TX, HIGH);
// delayMicroseconds(1000);
// digitalWrite(TX, LOW);
// delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(starline_code[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(starline_code[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
}
}
//pak2
void starline_sendPAK2(byte* starline_codePAK2){
Serial.println("- sending staraylayn -ss-");
for(int i = 0; i<9; i++){
Serial.print(starline_codePAK2[i], HEX);
Serial.print(" -zz ");
}
for(int i = 0; i<13; i++){//посылаем преамблу
send_meander(1000);
}
// digitalWrite(TX, HIGH);
// delayMicroseconds(400);
// digitalWrite(TX, LOW);
// delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(starline_codePAK2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(starline_codePAK2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
}
}
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
}
}
}
}
//stara end zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzSSSSTTTTTARRRRRRRRRRRRZZZZZZZZZZZZZZZZzzzzzzzzzzzz
void startgrabber(){
tempRxValue = digitalRead(rxPin);
if(tempRxValue != lastRxValue){
tempTime = micros();
difTime = tempTime - lastRxTime;
difTime2 = tempTime - lastRxTime;
keelog_get();
starline_get();
//grab(tempTime - lastRxTime, lastRxValue);
lastRxTime = tempTime;
lastRxValue = tempRxValue;
}
}
//menu UUUUUUUUUUUUUUUUUUUMENUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU
void posilkeeloq1(){
EEPROM.begin(3512);
keelog_codePAK1[0]=EEPROM.read(0);
keelog_codePAK1[1]=EEPROM.read(1);
keelog_codePAK1[2]=EEPROM.read(2);
keelog_codePAK1[3]=EEPROM.read(3);
keelog_codePAK1[4]=EEPROM.read(4);
keelog_codePAK1[5]=EEPROM.read(5);
keelog_codePAK1[6]=EEPROM.read(6);
keelog_codePAK1[7]=EEPROM.read(7);
keelog_codePAK1[8]=EEPROM.read(8);
keelog_send(keelog_codePAK1);
digitalWrite(TX, HIGH);
delay(100);
digitalWrite(TX, LOW);
sending="code keqloq:"+String( keelog_codePAK1[0],HEX);
sending=sending+String( keelog_codePAK1[1],HEX);
sending=sending+String( keelog_codePAK1[2],HEX);
sending=sending+String( keelog_codePAK1[3],HEX);
sending=sending+String( keelog_codePAK1[4],HEX);
sending=sending+String( keelog_codePAK1[5],HEX);
sending=sending+String( keelog_codePAK1[6],HEX);
sending=sending+String( keelog_codePAK1[7],HEX);
sending=sending+String( keelog_codePAK1[8],HEX);
keelog_state = 0;
/// for(int i = 0; i<9; i++){
/// keelog_code[i]=0;}
//Serial.println("srabotalo-keeloq");
}
void posilkeeloq2(){
EEPROM.begin(3512);
keelog_codePAK2[0]=EEPROM.read(10);
keelog_codePAK2[1]=EEPROM.read(11);
keelog_codePAK2[2]=EEPROM.read(12);
keelog_codePAK2[3]=EEPROM.read(13);
keelog_codePAK2[4]=EEPROM.read(14);
keelog_codePAK2[5]=EEPROM.read(15);
keelog_codePAK2[6]=EEPROM.read(16);
keelog_codePAK2[7]=EEPROM.read(17);
keelog_codePAK2[8]=EEPROM.read(18);
sending="code keqloq:"+String( keelog_codePAK2[0],HEX);
sending=sending+String(keelog_codePAK2[1],HEX);
sending=sending+String(keelog_codePAK2[2],HEX);
sending=sending+String(keelog_codePAK2[3],HEX);
sending=sending+String(keelog_codePAK2[4],HEX);
sending=sending+String(keelog_codePAK2[5],HEX);
sending=sending+String(keelog_codePAK2[6],HEX);
sending=sending+String(keelog_codePAK2[7],HEX);
sending=sending+String(keelog_codePAK2[8],HEX);
////codan=codan+String(starline_code[8],HEX);
keelog_sendPAK2(keelog_codePAK2);
digitalWrite(TX, HIGH);
delay(100);
digitalWrite(TX, LOW);
keelog_state = 0;
/// for(int i = 0; i<9; i++){
/// keelog_codePAK2[i]=0;}
}
void posilstarline1(){
EEPROM.begin(3512);
starline_codePAK1[0]=EEPROM.read(20);
starline_codePAK1[1]=EEPROM.read(21);
starline_codePAK1[2]=EEPROM.read(22);
starline_codePAK1[3]=EEPROM.read(23);
starline_codePAK1[4]=EEPROM.read(24);
starline_codePAK1[5]=EEPROM.read(25);
starline_codePAK1[6]=EEPROM.read(26);
starline_codePAK1[7]=EEPROM.read(27);
starline_codePAK1[8]=EEPROM.read(28);
sending="code star_line:"+String( starline_codePAK1[0],HEX);
sending=sending+String( starline_codePAK1[1],HEX);
sending=sending+String( starline_codePAK1[2],HEX);
sending=sending+String( starline_codePAK1[3],HEX);
sending=sending+String( starline_codePAK1[4],HEX);
sending=sending+String( starline_codePAK1[5],HEX);
sending=sending+String( starline_codePAK1[6],HEX);
sending=sending+String( starline_codePAK1[7],HEX);
sending=sending+String( starline_codePAK1[8],HEX);
starline_send(starline_codePAK1);
digitalWrite(TX, HIGH);
delay(100);
digitalWrite(TX, LOW);
starline_state = 0;
// for(int i = 0; i<9; i++){
// starline_code[i]=0;
// }
/// Serial.println("srabotalo");
}
void posilstarline2(){
EEPROM.begin(3512);
starline_codePAK2[0]=EEPROM.read(30);
starline_codePAK2[1]=EEPROM.read(31);
starline_codePAK2[2]=EEPROM.read(32);
starline_codePAK2[3]=EEPROM.read(33);
starline_codePAK2[4]=EEPROM.read(34);
starline_codePAK2[5]=EEPROM.read(35);
starline_codePAK2[6]=EEPROM.read(36);
starline_codePAK2[7]=EEPROM.read(37);
starline_codePAK2[8]=EEPROM.read(38);
sending="code star_line:"+String( starline_codePAK2[0],HEX);
sending=sending+String( starline_codePAK2[1],HEX);
sending=sending+String( starline_codePAK2[2],HEX);
sending=sending+String( starline_codePAK2[3],HEX);
sending=sending+String( starline_codePAK2[4],HEX);
sending=sending+String( starline_codePAK2[5],HEX);
sending=sending+String( starline_codePAK2[6],HEX);
sending=sending+String( starline_codePAK2[7],HEX);
sending=sending+String( starline_codePAK2[8],HEX);
starline_sendPAK2(starline_codePAK2);
digitalWrite(TX, HIGH);
delay(100);
digitalWrite(TX, LOW);
starline_state = 0;
// for(int i = 0; i<9; i++){
// starline_code[i]=0;
// }
}
void posilkeeloq1zapis(){
////////////////////schet paketov
k = 0;
kk = 0;
EEPROM.begin(3512);
keelog_codePAK1zapis[0]=EEPROM.read(50);
keelog_codePAK1zapis[1]=EEPROM.read(51);
keelog_codePAK1zapis[2]=EEPROM.read(52);
keelog_codePAK1zapis[3]=EEPROM.read(53);
keelog_codePAK1zapis[4]=EEPROM.read(54);
keelog_codePAK1zapis[5]=EEPROM.read(55);
keelog_codePAK1zapis[6]=EEPROM.read(56);
keelog_codePAK1zapis[7]=EEPROM.read(57);
keelog_codePAK1zapis[8]=EEPROM.read(58);
keelog_send(keelog_codePAK1zapis);
digitalWrite(TX, HIGH);
delay(100);
digitalWrite(TX, LOW);
keelog_state = 0;
// for(int i = 0; i<9; i++){
// keelog_code[i]=0;}
//Serial.println("srabotalo-keeloq");
}
void posilkeeloq2zapis(){
////////////////////schet paketov
k = 0;
kk = 0;
EEPROM.begin(3512);
keelog_codePAK2zapis[0]=EEPROM.read(60);
keelog_codePAK2zapis[1]=EEPROM.read(61);
keelog_codePAK2zapis[2]=EEPROM.read(62);
keelog_codePAK2zapis[3]=EEPROM.read(63);
keelog_codePAK2zapis[4]=EEPROM.read(64);
keelog_codePAK2zapis[5]=EEPROM.read(65);
keelog_codePAK2zapis[6]=EEPROM.read(66);
keelog_codePAK2zapis[7]=EEPROM.read(67);
keelog_codePAK2zapis[8]=EEPROM.read(68);
keelog_send(keelog_codePAK2zapis);
digitalWrite(TX, HIGH);
delay(100);
digitalWrite(TX, LOW);
keelog_state = 0;
// for(int i = 0; i<9; i++){
// keelog_code[i]=0;}
Serial.println("srabotalo-keeloq");
}
void posilstarline1zapis(){
////////////////////schet paketov
k = 0;
kk = 0;
EEPROM.begin(3512);
starline_codePAK1zapis[0]=EEPROM.read(80);
starline_codePAK1zapis[1]=EEPROM.read(81);
starline_codePAK1zapis[2]=EEPROM.read(82);
starline_codePAK1zapis[3]=EEPROM.read(83);
starline_codePAK1zapis[4]=EEPROM.read(84);
starline_codePAK1zapis[5]=EEPROM.read(85);
starline_codePAK1zapis[6]=EEPROM.read(86);
starline_codePAK1zapis[7]=EEPROM.read(87);
starline_codePAK1zapis[8]=EEPROM.read(88);
starline_sendPAK2(starline_codePAK1zapis);
// digitalWrite(TX, HIGH);
// delay(100);
// digitalWrite(TX, LOW);
starline_state = 0;
//for(int i = 0; i<9; i++){
// starline_code[i]=0;
// }
}
void posilstarline2zapis(){
////////////////////schet paketov
k = 0;
kk = 0;
EEPROM.begin(3512);
starline_codePAK2zapis[0]=EEPROM.read(70);
starline_codePAK2zapis[1]=EEPROM.read(71);
starline_codePAK2zapis[2]=EEPROM.read(72);
starline_codePAK2zapis[3]=EEPROM.read(73);
starline_codePAK2zapis[4]=EEPROM.read(74);
starline_codePAK2zapis[5]=EEPROM.read(75);
starline_codePAK2zapis[6]=EEPROM.read(76);
starline_codePAK2zapis[7]=EEPROM.read(77);
starline_codePAK2zapis[8]=EEPROM.read(78);
starline_sendPAK2(starline_codePAK2zapis);
starline_state = 0;
}
////////////////////////////////////WIIIIIIIIIIIFIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII///////////////////////////
void starline_sendPAK2zub1(byte* starline_codePAK1zapisSBTR){
Serial.println("- sending staraylayn -ss-");
for(int i = 0; i<9; i++){
Serial.print(starline_codePAK1zapisSBTR[i], HEX);
Serial.print(" -zz ");
}
for(int i = 0; i<13; i++){//посылаем преамблу
send_meander(1000);
}
// digitalWrite(TX, HIGH);
// delayMicroseconds(400);
// digitalWrite(TX, LOW);
// delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(starline_codePAK1zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(starline_codePAK1zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
}
}
void starline_sendPAK2zub2(byte* starline_codePAK2zapisSBTR){
Serial.println("- sending staraylayn -ss-");
for(int i = 0; i<9; i++){
Serial.print(starline_codePAK2zapisSBTR[i], HEX);
Serial.print(" -zz ");
}
for(int i = 0; i<13; i++){//посылаем преамблу
send_meander(1000);
}
// digitalWrite(TX, HIGH);
// delayMicroseconds(400);
// digitalWrite(TX, LOW);
// delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(starline_codePAK2zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(starline_codePAK2zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
}
}
void keelog_sendzibaruy(byte* keelog_codePAK1zapisSBTR){
Serial.println("- sending keelog -");
for(int i = 0; i<9; i++){
Serial.print(keelog_codePAK1zapisSBTR[i], HEX);
Serial.print(" - ");
}
for(int i = 0; i<11; i++){//посылаем преамблу
send_meander(400);
}
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(keelog_codePAK1zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(keelog_codePAK1zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
}
}
void keelog_sendzibaruy2(byte* keelog_codePAK2zapisSBTR){
Serial.println("- sending keelog -");
for(int i = 0; i<9; i++){
Serial.print(keelog_codePAK2zapisSBTR[i], HEX);
Serial.print(" - ");
}
for(int i = 0; i<11; i++){//посылаем преамблу
send_meander(400);
}
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(keelog_codePAK2zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(keelog_codePAK2zapisSBTR[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
}
}
////////////////////////////////////////////////////////////////bit vvod send//////////////////////////////////////
void starline_sendVVOD1(byte* VVOD1){
Serial.println("- sending staraylayn -ss-");
for(int i = 0; i<9; i++){
Serial.print(VVOD1[i], HEX);
Serial.print(" -zz ");
}
for(int i = 0; i<13; i++){//посылаем преамблу
send_meander(1000);
}
// digitalWrite(TX, HIGH);
// delayMicroseconds(400);
// digitalWrite(TX, LOW);
// delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(VVOD1[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(VVOD1[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
}
}
void starline_sendVVOD2(byte* VVOD1){
Serial.println("- sending staraylayn -ss-");
for(int i = 0; i<9; i++){
Serial.print(VVOD2[i], HEX);
Serial.print(" -zz ");
}
for(int i = 0; i<13; i++){//посылаем преамблу
send_meander(1000);
}
// digitalWrite(TX, HIGH);
// delayMicroseconds(400);
// digitalWrite(TX, LOW);
// delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(VVOD2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(VVOD2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(250);
digitalWrite(TX, LOW);
delayMicroseconds(250);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(500);
digitalWrite(TX, LOW);
delayMicroseconds(500);
}
}
}
}
}
/////////////////////////////keevvod///////////////////////////////////
void keelog_sendVVOD1(byte* VVOD1){
Serial.println("- sending keelog -");
for(int i = 0; i<9; i++){
Serial.print(VVOD1[i], HEX);
Serial.print(" - ");
}
for(int i = 0; i<11; i++){//посылаем преамблу
send_meander(400);
}
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(VVOD1[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(VVOD1[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
}
}
//////////////////////////////////////22222222222222222222222222//////////////////////////////////////
void keelog_sendVVOD2(byte* VVOD2){
Serial.println("- sending keelog -");
for(int i = 0; i<9; i++){
Serial.print(VVOD2[i], HEX);
Serial.print(" - ");
}
for(int i = 0; i<11; i++){//посылаем преамблу
send_meander(400);
}
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(4000);//посылаем хедер
for( int i = 0; i<9; i++){
if(decodeMethod==1){
for(int i2 = 7;i2>=0;i2--){
if(bitRead(VVOD2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
else{
for(int i2 = 0;i2<8;i2++){
if(!bitRead(VVOD2[i], i2)){
digitalWrite(TX, HIGH);
delayMicroseconds(400);
digitalWrite(TX, LOW);
delayMicroseconds(2*400);
}
else{
digitalWrite(TX, HIGH);
delayMicroseconds(2*400);
digitalWrite(TX, LOW);
delayMicroseconds(400);
}
}
}
}
}