In Arduino IDE zit ergens een optie die de code netjes maakt als ik me goed herinner.
Netbeans
Code: [Selecteer]if(x < 5) { if(y > 6) { doeIets(); if(z == 7) { doeIetsAnders(); } helloWorld(); } }Zal prima compilen maar doet wat anders dan de indentatie doet vermoeden.
if(x < 5) { if(y > 6) { doeIets(); if(z == 7) { doeIetsAnders(); } helloWorld(); } }
Om te "forceren" (lees: makkelijk kunnen controleren) dat ik genoeg sluit-accolades plaats om niet per ongeluk de boel verkeerd te groeperen.
startAfter(&foo, 500, 200, 0);
#define trigger(func,interval) startAfter(func,interval,1)#define start(func,interval) startAfter(func,interval,0)
Kun je Netbeans of Eclipse ook gebruiken bij Arduino schrijfsels, dan?(ben er zelf kennelijk al weer een tijdje uit)
of Eclipse ook gebruiken bij Arduino schrijfsels,
Ik heb dus ondervonden dat methode 1 (die van mij dus) niet onderdoet aan de "standaards".
of nog "erger":
Voor mij persoonlijk visuele puinhoop
Ik denk dat het tijd wordt om deze discussie te stoppen.
ik ga het zeker eens goed bestuderen.
#include <SPI.h>#include <mcp2515.h>#define CANBUS_DEBUG 0#define CANBUS_DEBUG1 0//// Id's of the different types of controllers on the CanBus// Maximum nr of ID's is 127!!!//enum systemId { BEZETMELDER_CONTROLLER_ID = 1, // 16 Bezetmelder controllers supported WISSEL_CONTROLLER_ID = 17, // 16 Wissel controllers supported SEIN_CONTROLLER_ID = 33, // 16 Sein controllers supported DCC_INTERFACE_ID = 126, // 1 DCC Interface system supported S88_INTERFACE_ID = 127 // 1 S88 Interface system supported};//// Error codes//enum cbError { CB_OK = 0, CB_FAIL = 1};//// There are several types of messages, each is identified by an unique number// the lowest id's have the highest priority//// DCC_ACC defines a DCC Accesory command// OCC_DT defines an Occupance detector that triggered// DCC_LOC defines a DCC locomotive command//enum messageId { OCC_DT = 1, DCC_ACC = 2, DCC_LOC = 3};//// Struct used for the Occupance Detector message//typedef struct{ unsigned short address; byte state;} OCC_DT_MSG;//// Struct used for the DCC Accessory command//typedef struct{ unsigned short address; byte direction;} DCC_ACC_MSG;//// A request for sending a message is handled by putting it on// the send queue. The heartbeat method is the responsible for // the actual sending.//#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)#define NROFSENDBUFFERS 32 // Buffers on the MEGA#endif#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)#define NROFSENDBUFFERS 4 // Buffers on the UNO#endif//// Type definition for the call back routine which will handle a received// message.//typedef void (*msgReceiver_t)(unsigned char aMsgLen, void *msgData);
//// The Interface which has to be implemented by all classes that seperate the// CanBus class from the used hardware and supporting library.//class CBusInterface {protected: friend class CanBus; // Give CanBus access to the internals virtual void begin(byte aSystemId) = 0; virtual cbError sendMsg(messageId anId, unsigned int aMsgLen, void *msgData) = 0; virtual void heartBeat() = 0; virtual void setMsgReceiver(messageId aMsgId, msgReceiver_t aMsgReceiver) = 0; virtual void prepareForSend() = 0;};
//// This class implents the CBusInterface and supports the MCP2515 chip in// combination with the "arduino-mcp2515-master" library.//class Mcp2515 : public CBusInterface {private: //// Stuff for the send buffers//#define MAXRETRIES 10 int sendRetryCount = 0; int nrOfSendBuffers = 0; volatile long lastTimeSend = 0; volatile int firstEmptySB = 0; volatile int firstUsedSB = -1; volatile can_frame *sendBuffers = nullptr; #define MESSAGE_WAIT_TIME 10 // Max 100 messages per second int sendWaitTime = MESSAGE_WAIT_TIME; // Minimum time between successive // sends, this to throttle the // the rate of messages produced // by this sender. byte systemId; MCP2515 *can_bus; msgReceiver_t msgReceiver[16]; int activeFilter = 0; void setMaskAndFilter(const unsigned long aFilter); void acceptMsgId(messageId aMsgId); cbError sendMsg(); void receiveMsg(); init(int aCsPin, int aSendWaitTime, int aNrOfSendBuffers); protected: friend class CanBus; // Give CanBus access to the internals void begin(byte aSystemId); cbError sendMsg(messageId anId, unsigned int aMsgLen, void *msgData); void heartBeat(); void setMsgReceiver(messageId aMsgId, msgReceiver_t aMsgReceiver); void prepareForSend(); public: Mcp2515(int aCsPin); Mcp2515(int aCsPin, int aSendWaitTime, int aNrOfSendBuffers); int getSendWaitTime(); void setSendWaitTime(int aSendWaitTime);};
//// The CanBus class that provides the sketch all the facilities to send and// receive CBus messages for the defined systems and message types.//class CanBus {private: byte systemId; CBusInterface *sender; CBusInterface *receiver;public: CanBus(byte aSystemId, CBusInterface *aSender, CBusInterface *aReceiver); void begin(); void setMsgReceiver(messageId aMsgId, msgReceiver_t aMsgReceiver); cbError sendMsg(messageId anId, unsigned int aMsgLen, void *msgData); void heartBeat();};
In tegendeel. De identatie laat precies zien waar wat bijhoort.
Ik gebruik hiervoor: de bracket highlighting [...]
dus pak er een biertje bij
OpenLCB en LCC, ik heb weer genoeg te lezen