Skip to content

Commit

Permalink
Style: convert tabs to 4 spaces alignment
Browse files Browse the repository at this point in the history
Then run Clang Format 16 again
  • Loading branch information
gfgit committed Aug 22, 2023
1 parent 2436eeb commit 09b2045
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 49 deletions.
90 changes: 48 additions & 42 deletions z21.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
*****************************************************************************
* z21.cpp - library for Roco Z21 LAN protocoll
* Copyright (c) 2013-2022 Philipp Gahtow All right reserved.
* z21.cpp - library for Roco Z21 LAN protocoll
* Copyright (c) 2013-2022 Philipp Gahtow All right reserved.
*
*
*****************************************************************************
* IMPORTANT:
*
* Please contact ROCO Inc. for more details.
* Please contact ROCO Inc. for more details.
*****************************************************************************
*/

Expand Down Expand Up @@ -165,7 +165,7 @@ void z21Class::receive(uint8_t client, uint8_t *packet)
break; // ENDE DB0
case LAN_X_DCC_READ_REGISTER:
if (packet[5] == 0x15)
{ // DB0 - SPECIAL: WLANMaus CV Read!
{ // DB0 - SPECIAL: WLANMaus CV Read!
if (notifyz21CVREAD)
notifyz21CVREAD(0, packet[6] - 1); // CV_MSB, CV_LSB
}
Expand All @@ -180,7 +180,7 @@ void z21Class::receive(uint8_t client, uint8_t *packet)
notifyz21CVREAD(packet[6], packet[7]); // CV_MSB, CV_LSB
}
if (packet[5] == 0x16)
{ // DB0 - SPECIAL: WLANMaus CV Write!
{ // DB0 - SPECIAL: WLANMaus CV Write!
if (notifyz21CVWRITE)
notifyz21CVWRITE(0, packet[6] - 1, packet[7]); // CV_MSB, CV_LSB, value
}
Expand Down Expand Up @@ -270,9 +270,10 @@ void z21Class::receive(uint8_t client, uint8_t *packet)
// bool TurnOnOff = bitRead(packet[7],3); //Spule EIN/AUS
if (notifyz21Accessory)
{
// Addresse Links/Rechts
notifyz21Accessory((packet[5] << 8) + packet[6], bitRead(packet[7], 0),
bitRead(packet[7], 3));
} // Addresse Links/Rechts Spule EIN/AUS
bitRead(packet[7], 3)); // Spule EIN/AUS
}
// Check if Broadcast Flag is correct set up?
bool BCset = true;
for (byte i = 0; i < z21clientMAX; i++)
Expand Down Expand Up @@ -449,7 +450,7 @@ void z21Class::receive(uint8_t client, uint8_t *packet)
case 0x73:
// LAN_X_??? WLANmaus periodische Abfrage:
// 0x09 0x00 0x40 0x00 0x73 0x00 0xFF 0xFF 0x00
// length X-Header XNet-Msg speed?
// length X-Header XNet-Msg speed?
#if defined(SERIALDEBUG)
ZDebug.println("LAN-X_WLANmaus");
#endif
Expand All @@ -460,9 +461,10 @@ void z21Class::receive(uint8_t client, uint8_t *packet)
default:
#if defined(SERIALDEBUG)
ZDebug.print("UNKNOWN_LAN-X_COMMAND");
// for (byte i = 0; i < packet[0]; i++) {
// ZDebug.print(" 0x");
// ZDebug.print(packet[i], HEX);
// for (byte i = 0; i < packet[0]; i++)
// {
// ZDebug.print(" 0x");
// ZDebug.print(packet[i], HEX);
// }
ZDebug.println();
#endif
Expand Down Expand Up @@ -580,9 +582,9 @@ void z21Class::receive(uint8_t client, uint8_t *packet)
data[8] = 0x00;
data[9] = 0x00;
/*
data[10] = 0x00; //UINT8 Reserved1 experimentell, siehe Anmerkung
data[11] = 0x00; //UINT8 Reserved2 experimentell, siehe Anmerkung
data[12] = 0x00; //UINT8 Reserved3 experimentell, siehe Anmerkung
data[10] = 0x00; // UINT8 Reserved1 experimentell, siehe Anmerkung
data[11] = 0x00; // UINT8 Reserved2 experimentell, siehe Anmerkung
data[12] = 0x00; // UINT8 Reserved3 experimentell, siehe Anmerkung
*/
EthSend(client, 0x0E, LAN_RAILCOM_DATACHANGED, data, false, Z21bcNone);
break;
Expand Down Expand Up @@ -832,10 +834,11 @@ FSTORAGE.commit();
default:
#if defined(SERIALDEBUG)
ZDebug.print("UNKNOWN_COMMAND");
// for (byte i = 0; i < packet[0]; i++) {
// ZDebug.print(" 0x");
// ZDebug.print(packet[i], HEX);
// }
// for (byte i = 0; i < packet[0]; i++)
// {
// ZDebug.print(" 0x");
// ZDebug.print(packet[i], HEX);
// }
ZDebug.println();
#endif
data[0] = 0x61;
Expand Down Expand Up @@ -919,31 +922,34 @@ void z21Class::setCVPOMBYTE(uint16_t CVAdr, uint8_t value)
// Zustand Rückmeldung non - Z21 device - Busy!
void z21Class::setLocoStateExt(int Adr)
{
/* uint8_t ldata[6];
if (notifyz21LocoState)
notifyz21LocoState(Adr, ldata); //uint8_t Steps[0], uint8_t Speed[1], uint8_t F0[2],
uint8_t F1[3], uint8_t F2[4], uint8_t F3[5]
byte data[10];
data[0] = LAN_X_LOCO_INFO; //0xEF X-HEADER
data[1] = (Adr >> 8) & 0x3F;
data[2] = Adr & 0xFF;
// Fahrstufeninformation: 0=14, 2=28, 4=128
if ((ldata[0] & 0x03) == DCCSTEP14)
data[3] = 0; // 14 steps
if ((ldata[0] & 0x03) == DCCSTEP28)
data[3] = 2; // 28 steps
if ((ldata[0] & 0x03) == DCCSTEP128)
data[3] = 4; // 128 steps
data[3] = data[3] | 0x08; //BUSY!
data[4] = (char) ldata[1]; //DSSS SSSS
data[5] = (char) ldata[2] & 0x1F; //F0, F4, F3, F2, F1
data[6] = (char) ldata[3]; //F5 - F12; Funktion F5 ist bit0 (LSB)
data[7] = (char) ldata[4]; //F13-F20
data[8] = (char) ldata[5]; //F21-F28
data[9] = (char) ldata[8] >> 7; //F31-F29 only
/*
uint8_t ldata[6];
if (notifyz21LocoState)
notifyz21LocoState(Adr, ldata); // uint8_t Steps[0], uint8_t Speed[1], uint8_t F0[2],
// uint8_t F1[3], uint8_t F2[4], uint8_t F3[5]
byte data[10];
data[0] = LAN_X_LOCO_INFO; // 0xEF X-HEADER
data[1] = (Adr >> 8) & 0x3F;
data[2] = Adr & 0xFF;
// Fahrstufeninformation: 0=14, 2=28, 4=128
if ((ldata[0] & 0x03) == DCCSTEP14)
data[3] = 0; // 14 steps
if ((ldata[0] & 0x03) == DCCSTEP28)
data[3] = 2; // 28 steps
if ((ldata[0] & 0x03) == DCCSTEP128)
data[3] = 4; // 128 steps
data[3] = data[3] | 0x08; // BUSY!
data[4] = (char)ldata[1]; // DSSS SSSS
data[5] = (char)ldata[2] & 0x1F; // F0, F4, F3, F2, F1
data[6] = (char)ldata[3]; // F5 - F12; Funktion F5 ist bit0 (LSB)
data[7] = (char)ldata[4]; // F13-F20
data[8] = (char)ldata[5]; // F21-F28
data[9] = (char)ldata[8] >> 7; // F31-F29 only
*/

reqLocoBusy(Adr);

returnLocoStateFull(0, Adr, true);
Expand Down
6 changes: 3 additions & 3 deletions z21.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#define z21Port 21105 // local port to listen on

//**************************************************************
// #define SERIALDEBUG //Serial Debug
// #define SERIALDEBUG //Serial Debug

#if defined(SERIALDEBUG)
# define ZDebug Serial // Port for the Debugging
Expand Down Expand Up @@ -97,8 +97,8 @@
#define CONFz21SnLSB 1 // 0xE8
//**************************************************************
// Store Z21 configuration inside EEPROM:
#define CONF1STORE 50 //(10x Byte) - Prog, RailCom, etc.
#define CONF2STORE 60 //(15x Byte) - Voltage: Prog, Rail, etc.
#define CONF1STORE 50 //(10x Byte) - Prog, RailCom, etc.
#define CONF2STORE 60 //(15x Byte) - Voltage: Prog, Rail, etc.
#define CLIENTHASHSTORE 0x200 // 512 Start where Client-Hash is stored

//--------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion z21header.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Created on: 16.04.2016
* Author: Philipp Gahtow
*
* 19.07.16 Add X-Bus (XpressNet)
* 19.07.16 Add X-Bus (XpressNet)
* 19.06.17 Add CAN and new BC-Flags
*
*/
Expand Down
6 changes: 3 additions & 3 deletions z21nvs.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
*****************************************************************************
* z21nvs.cpp - library for emulate EEPROM on Non-Volatile Storage
* Copyright (c) 2021 Philipp Gahtow All right reserved.
* z21nvs.cpp - library for emulate EEPROM on Non-Volatile Storage
* Copyright (c) 2021 Philipp Gahtow All right reserved.
*
*
*****************************************************************************
* IMPORTANT:
*
* Please contact ROCO Inc. for more details.
* Please contact ROCO Inc. for more details.
*****************************************************************************
*/

Expand Down

0 comments on commit 09b2045

Please sign in to comment.