7 Commits

Author SHA1 Message Date
6c8ff18de0 cmd 2024-09-09 10:51:55 +03:00
3f29b8f596 delay TX 2024-09-04 13:49:04 +03:00
b6e181f7b6 CarCMD 2024-09-04 10:27:33 +03:00
6375c4eed5 for debug test 2024-09-04 10:12:39 +03:00
c4000d6b75 test 2024-08-14 17:43:12 +03:00
fc02c79135 upd 2024-04-22 14:56:12 +03:00
d068a576f7 Merge pull request #3 from Show-maket/dev
v2.0
2024-03-18 16:24:38 +03:00
2 changed files with 47 additions and 16 deletions

4
.gitignore vendored
View File

@ -1 +1,3 @@
.vscode/*
.vscode/*
bin/*
log/*

View File

@ -2,10 +2,11 @@
#include "IR_Encoder.h"
#include "TimerStatic.h"
#include "MemoryCheck.h"
#include "CarCmdList.h"
/////////////// Pinout ///////////////
#define encForward_PIN 5
#define encBackward_PIN 6
#define encForward_PIN 0
#define encBackward_PIN 5
#define LoopOut 12
#define ISR_Out 10
@ -17,6 +18,8 @@
#define INFO "IR_FOX TEST"
#define SERIAL_SPEED 115200
constexpr uint8_t cmd_for_car = CarCmd::stop_Tmp_H_S; // <<<<<<<<< CMD FOR CAR
//////////////// Var /////////////////
IR_Decoder decForward(2, 555);
@ -32,9 +35,9 @@ void decForwardISR() {
decForward.isr();
}
// void decBackwardISR() {
// decBackward.isr();
// }
void decBackwardISR() {
decBackward.isr();
}
static uint8_t* portOut;
ISR(TIMER2_COMPA_vect) {
@ -42,9 +45,9 @@ ISR(TIMER2_COMPA_vect) {
// encBackward.isr();
// encTree.isr();
//TODO: Сделать выбор порта
*portOut = (*portOut & 0b11001111) |
*portOut = (*portOut & 0b11111110) |
(
encForward.ir_out_virtual << 5U
encForward.ir_out_virtual << 0U
// | encBackward.ir_out_virtual << 6U
// | encTree.ir_out_virtual << 2U
);
@ -57,10 +60,10 @@ uint8_t data3 [] = { 42 , 127, 137 };
uint8_t data4 [] = { 42 , 127, 137, 255 };
uint32_t loopTimer;
uint8_t sig = 0;
uint8_t sig = 255;
uint16_t targetAddr = IR_Broadcast;
Timer t1(500, millis, []() {
Timer t1(750, millis, []() {
// Serial.println(sig);
@ -151,7 +154,7 @@ Timer t2(500, millis, []() {
/////////////////////////////////////////////////////////////////////
void setup() {
IR_Encoder::timerSetup();
portOut = &PORTD;
portOut = &PORTB;
Serial.begin(SERIAL_SPEED);
Serial.println(F(INFO));
@ -174,6 +177,7 @@ void setup() {
pinMode(encForward_PIN, OUTPUT);
pinMode(encBackward_PIN, OUTPUT);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
@ -182,18 +186,25 @@ void setup() {
attachInterrupt(0, decForwardISR, CHANGE); // D2
// attachInterrupt(1, decBackwardISR, CHANGE); // D3
attachInterrupt(1, decBackwardISR, CHANGE); // D3
}
bool testLed = false;
uint32_t testLed_timer;
bool responsponse_f = false;
uint32_t responsponse_tim;;
void loop() {
digitalToggle(LoopOut);
// digitalToggle(LoopOut);
Timer::tick();
decForward.tick();
decBackward.tick();
status(decForward);
// status(decBackward);
status(decBackward);
// Serial.println(micros() - loopTimer);
@ -218,8 +229,18 @@ void loop() {
break;
}
}
}
if(testLed && millis() - testLed_timer > 100){
testLed=false;
digitalWrite(12, LOW);
}
if(responsponse_f && millis() - responsponse_tim > 100) {
responsponse_f=false;
encForward.sendData(IR_Broadcast, cmd_for_car);
}
}
@ -227,7 +248,15 @@ void loop() {
//test
void status(IR_Decoder& dec) {
if (dec.gotData.available()) {
if (dec.gotData.available() && dec.gotData.getAddrFrom() != 42) {
digitalWrite(12, HIGH);
testLed = true;
testLed_timer = millis();
responsponse_f = true;
responsponse_tim = testLed_timer;
String str;
if (/* dec.gotData.getDataPrt()[1] */1) {
str += ("Data on pin "); str += (dec.isrPin); str += "\n";