1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 15:46:14 +01:00

Add files via upload

This commit is contained in:
Barry Daniel 2024-10-07 15:55:52 +10:00 committed by GitHub
parent 623e105805
commit 431db07c80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 55 deletions

View File

@ -1,5 +1,5 @@
//sensorCAM parser.cpp version 3.01 Aug 2024
//sensorCAM parser.cpp version 3.03 Sep 2024
#include "CamParser.h"
#include "FSH.h"
#include "IO_EXSensorCAM.h"
@ -48,17 +48,18 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
}
if (EXSensorCAM::CAMBaseVpin==0) return false; // no cam defined
if((p[0] == ve) || (p[0] == ver) || (p[0] == 'V')) camop='^';
// send UPPER case to sensorCAM to flag binary data from a DCCEX-CS parser
switch(paramCount) {
case 1: //<N ver> produces '^'
case 1: //<N ver> produces '^'
if((p[0] == ve) || (p[0] == ver) || (p[0] == 'V')) camop='^';
if (STRCHR_P((const char *)F("EFGMQRVW^"),camop) == nullptr) return false;
if (camop=='F') camop=']'; //<NF> for Reset/Finish webCAM.
if (camop=='Q') param3=10; //<NQ> for activation state of all 10 banks of sensors
break; // Coded as ']' else conflicts with <Nf %%>
if (camop=='F') camop=']'; //<NF> for Reset/Finish webCAM.
break; // F Coded as ']' else conflicts with <Nf %%>
case 2: //<N camop p1>
if (STRCHR_P((const char *)F("ABFILMNOPQRSTUV^"),camop)==nullptr) return false;
if (STRCHR_P((const char *)F("ABFILMNOPQRSTUV"),camop)==nullptr) return false;
param1=p[1];
break;
@ -74,7 +75,7 @@ bool CamParser::parseN(Print * stream, byte paramCount, int16_t p[]) {
param3 = p[2];
break;
case 4: //<N a id row col>
case 4: //<N a id row col>
if (camop!='A') return false; //must start with 'a'
if (p[3]>316 || p[3]<0) return false;
if (p[2]>236 || p[2]<0) return false;

View File

@ -16,10 +16,11 @@
* You should have received a copy of the GNU General Public License
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
*/
#define driverVer 304
#define driverVer 305
// v305 less debug & alpha ordered switch
// v304 static oldb0; t(##[,%%];
// v303 zipped with CS 5.2.76 and uploaded to repo (with debug)
// v302 SEND=StringFormatter::send; remove Sp(); + 'q'; memcpy( .8) -> .7);
// v302 SEND=StringFormatter::send, remove Sp(), add 'q', memcpy( .8) -> .7);
// v301 improved 'f','p'&'q' code and driver version calc. Correct bsNo calc. for 'a'
// v300 stripped & revised without expander functionality. Needs sensorCAM.h v300 AND CamParser.cpp
// v222 uses '@'for EXIORDD read. handles <NB $> and <NN $ ##>
@ -222,7 +223,7 @@ int ioESP32(uint8_t i2cAddr,uint8_t *rBuf,int inbytes,uint8_t *outBuff,int outby
//rBuf contains packet of up to 32 bytes usually with (ascii) cmd header in rBuf[0]
//sensorCmd command header byte from CAM (in rBuf[0]?)
int processIncomingPkt(uint8_t *rBuf,uint8_t sensorCmd) {
static uint8_t oldb0; //for debug only
//static uint8_t oldb0; //for debug only
int k;
int b;
char str[] = "11111111";
@ -230,9 +231,10 @@ static uint8_t oldb0; //for debug only
switch (sensorCmd){
case '`': //response to request for digitalInputStates[] table '@'=>'`'
memcpy(_digitalInputStates, rBuf+1, digitalBytesNeeded);
if ( _digitalInputStates[0]!=oldb0) { oldb0=_digitalInputStates[0]; //debug
// if ( _digitalInputStates[0]!=oldb0) { oldb0=_digitalInputStates[0]; //debug
// for (k=0;k<5;k++) {Serial.print(" ");Serial.print(_digitalInputStates[k],HEX);}
}break;
// }
break;
case EXIORDY: //some commands give back acknowledgement only
break;
@ -241,33 +243,12 @@ static uint8_t oldb0; //for debug only
DIAG(F("CAM cmd error 0xFE 0x%x"),rBuf[1]);
break;
case '~': //information from '^' version request <N ve[r]>
case '~': //information from '^' version request <N v[er]>
DIAG(F("EX-SensorCAM device found, I2C:%s,CAM Version v%d.%d.%d vpins %u-%u"),
_I2CAddress.toString(), rBuf[1]/10, rBuf[1]%10, rBuf[2],(int) _firstVpin, (int) _firstVpin +_nPins-1);
DIAG(F("IO_EXSensorCAM driver v0.%d.%d vpin: %d "), driverVer/100,driverVer%100,_firstVpin);
break;
case 'i': //information from i%%
k=256*rBuf[5]+rBuf[4];
DIAG(F("(i%%%%[,$$]) Info: Sensor 0%o(%d) enabled:%d status:%d row=%d x=%d Twin=0%o pvtThreshold=%d A~%d")
,rBuf[1],rBuf[1],rBuf[3],rBuf[2],rBuf[6],k,rBuf[7],rBuf[9],int(rBuf[8])*16);
break;
case 'm':
DIAG(F("(m$[,##]) Min/max: $ frames min2flip (trip) %d, maxSensors 0%o, minSensors 0%o, nLED %d,"
" threshold %d, TWOIMAGE_MAXBS 0%o"),rBuf[1],rBuf[3],rBuf[2],rBuf[4],rBuf[5],rBuf[6]);
break;
case 'n':
DIAG(F("(n$[,##]) Nominate: $ nLED %d, ## minSensors 0%o (maxSensors 0%o threshold %d)")
,rBuf[4],rBuf[2],rBuf[3],rBuf[5]);
break;
case 'q':
for (int i =0; i<8; i++) str[i] = ((rBuf[2] << i) & 0x80 ? '1' : '0');
DIAG(F("(q $) Query bank %c ENABLED sensors(S%c7-%c0): %s "), rBuf[1], rBuf[1], rBuf[1], str);
break;
case 'f':
DIAG(F("(f %%%%) frame header 'f' for bsNo %d/%d - showing Quarter sample (1 row) only"), rBuf[1]/8,rBuf[1]%8);
SEND(&USB_SERIAL,F("<n row: %d Ref bytes: "),rBuf[2]);
@ -279,6 +260,22 @@ static uint8_t oldb0; //for debug only
Serial.print(" n>\n");
break;
case 'i': //information from i%%
k=256*rBuf[5]+rBuf[4];
DIAG(F("(i%%%%[,$$]) Info: Sensor 0%o(%d) enabled:%d status:%d row=%d x=%d Twin=0%o pvtThreshold=%d A~%d")
,rBuf[1],rBuf[1],rBuf[3],rBuf[2],rBuf[6],k,rBuf[7],rBuf[9],int(rBuf[8])*16);
break;
case 'm':
DIAG(F("(m$[,##]) Min/max: $ frames min2flip (trip) %d, maxSensors 0%o, minSensors 0%o, nLED %d,"
" threshold %d, TWOIMAGE_MAXBS 0%o"),rBuf[1],rBuf[3],rBuf[2],rBuf[4],rBuf[5],rBuf[6]);
break;
case 'n':
DIAG(F("(n$[,##]) Nominate: $ nLED %d, ## minSensors 0%o (maxSensors 0%o threshold %d)")
,rBuf[4],rBuf[2],rBuf[3],rBuf[5]);
break;
case 'p':
b=rBuf[1]-2;
if(b<4) { Serial.print("<n (p%%) Bank empty n>\n"); break; }
@ -288,6 +285,11 @@ static uint8_t oldb0; //for debug only
Serial.print(" n>\n");
break;
case 'q':
for (int i =0; i<8; i++) str[i] = ((rBuf[2] << i) & 0x80 ? '1' : '0');
DIAG(F("(q $) Query bank %c ENABLED sensors(S%c7-%c0): %s "), rBuf[1], rBuf[1], rBuf[1], str);
break;
case 't': //threshold etc. from t## //bad pkt if 't' FF's
if(rBuf[1]==0xFF) {Serial.println("<n bad CAM 't' packet: 74 FF n>");_savedCmd[2] +=1; return 0;}
SEND(&USB_SERIAL,F("<n (t[##[,%%%%]]) Threshold:%d sensor S00:-%d"),rBuf[1],min(rBuf[2]&0x7F,99));

View File

@ -18,12 +18,12 @@
// Include devices you need.
#include "IODevice.h"
//#include "IO_HALDisplay.h" // Auxiliary display devices (LCD/OLED)
//#include "IO_HCSR04.h" // Ultrasonic range sensor
//#include "IO_VL53L0X.h" // Laser time-of-flight sensor
//#include "IO_DFPlayer.h" // MP3 sound player
//#include "IO_HCSR04.h" // Ultrasonic range sensor
//#include "IO_VL53L0X.h" // Laser time-of-flight sensor
//#include "IO_DFPlayer.h" // MP3 sound player
//#include "IO_TouchKeypad.h // Touch keypad with 16 keys
//#include "IO_EXTurntable.h" // Turntable-EX turntable controller
//#include "IO_EXFastClock.h" // FastClock driver
//#include "IO_EXTurntable.h" // Turntable-EX turntable controller
//#include "IO_EXFastClock.h" // FastClock driver
//#include "IO_PCA9555.h" // 16-bit I/O expander (NXP & Texas Instruments).
//#include "IO_I2CDFPlayer.h" // DFPlayer over I2C
#include "IO_EXSensorCAM.h" // sensorCAM driver
@ -36,7 +36,7 @@
void halSetup() {
I2CManager.setClock(100000);
// I2CManager.setClock(100000); //to set i2c bus clock rate
//=======================================================================
// The following directives define auxiliary display devices.
@ -306,14 +306,7 @@ void halSetup() {
// Note that the I2C address is defined in the EX-IOExpander code, and 0x65 is the default.
// The example is for an Arduino Nano.
//EXIOExpander::create(800, 18, 0x65);
//=======================================================================
@ -342,7 +335,7 @@ void halSetup() {
// EXFastClock::create(0x55);
//=======================================================================
// The following directive defines an ESP32-CAM instance.
//=======================================================================
@ -353,12 +346,11 @@ void halSetup() {
// #define SENSORCAM_VPIN0 #00 in config.h if not using 700.
// Number of VPINs=pin count (must not exceed 80)
// I2C address=an available I2C address (default 0x11)
// #define ESP32CAP 0x13 in config.h to raise allowable ESP32 range of addresses
// Note that the I2C address (0x11) is the default in the sensorCAM code
//
// EXSensorCAM::create(700, 80, 0x11);
EXSensorCAM::create(700, 80, 0x11); //preference is now to use HAL(700 80 0x11) in myAutomation.h
//EXSensorCAM::create(600, 80, 0x12); //alternate or second CAM device address creation
}
// EXSensorCAM::create(700, 80, 0x11); //preference is now to use HAL(700 80 0x11) in myAutomation.h
//EXSensorCAM::create(600, 80, 0x12); //alternate or second CAM device address creation
//preference is now to use HAL(EXSensorCAM 700 80 0x11) in myAutomation.h rather than :create
}
#endif