Skip to content

Commit

Permalink
Arduino 1.6.x compatibiliy.
Browse files Browse the repository at this point in the history
change of using datatype boolean to bool8
  • Loading branch information
mathertel committed Apr 12, 2015
1 parent 426db21 commit 47285c0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 21 deletions.
5 changes: 3 additions & 2 deletions examples/RDMSerialRecv/RDMSerialRecv.ino
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
// If you have to save pgm space you can delete the inner lines of this "#if" blocks
// 24.01.2014 Peter Newman/Sean Sill: Get device specific PIDs returning properly in supportedParameters
// 24.01.2014 Peter Newman: Make the device specific PIDs compliant with the OLA RDM Tests. Add device model ID option
// 12.04.2015 change of using datatype boolean to bool8.
// - - - - -

#include <EEPROM.h>
Expand Down Expand Up @@ -154,11 +155,11 @@ void loop() {

// This function was registered to the DMXSerial2 library in the initRDM call.
// Here device specific RDM Commands are implemented.
boolean processCommand(struct RDMDATA *rdm, uint16_t *nackReason)
bool8 processCommand(struct RDMDATA *rdm, uint16_t *nackReason)
{
byte CmdClass = rdm->CmdClass; // command class
uint16_t Parameter = rdm->Parameter; // parameter ID
boolean handled = false;
bool8 handled = false;

// This is a sample of how to return some device specific data
if (Parameter == SWAPINT(E120_DEVICE_HOURS)) { // 0x0400
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=DMXSerial2
version=1.1.0
version=1.2.0
author=Matthias Hertel
maintainer=Matthias Hertel, http://www.mathertel.de
sentence=Enables building DMX/RDM devices using the built-in serial port for Arduino boards UNO, Leonardo, Mega.
Expand Down
25 changes: 13 additions & 12 deletions DMXSerial2.cpp → src/DMXSerial2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
// 21.11.2013 response to E120_DISC_MUTE and E120_DISC_UN_MUTE messages as required by the spec.
// 03.12.2013 Code merged from raumzeitlabor
// 04.12.2013 Allow manufacturer broadcasts
// 05.12.2013 FIX: respond only to direct commands as required by the spec.
// 05.12.2013 FIX: response only to direct commands as required by the spec.

This comment has been minimized.

Copy link
@peternewman

peternewman Dec 9, 2016

Contributor

This was spelled correctly before. Perhaps better English would be "only respond to direct commands".

// 13.12.2013 ADD: getDeviceID() function added
// 15.12.2013 introducing the type DEVICEID and copy by using memcpy to save pgm space.
// 12.01.2014 Peter Newman: make the responder more compliant with the OLA RDM Tests
// 24.01.2014 Peter Newman: More compliance with the OLA RDM Tests around sub devices and mute messages
// 24.01.2014 Peter Newman/Sean Sill: Get device specific PIDs returning properly in supportedParameters
// 24.01.2014 Peter Newman: Make the device specific PIDs compliant with the OLA RDM Tests. Add device model ID option

// 12.04.2015 making library Arduino 1.6.x compatible
// 12.04.2015 change of using datatype boolean to bool8.
// - - - - -

#include "Arduino.h"
Expand Down Expand Up @@ -285,13 +286,13 @@ union RDMMEM {


// This flag will be set when a full RDM packet was received.
boolean _rdmAvailable;
bool8 _rdmAvailable;

// This is the current 16 bit checksum for RDM commands, used by the interrupt routines.
uint16_t _rdmCheckSum;

// static data that is not needed externally so it is not put into the class definition.
boolean _isMute; // is set to true when RDM discovery command muted this device.
bool8 _isMute; // is set to true when RDM discovery command muted this device.

uint8_t _dmxModePin = 2;
uint8_t _dmxModeOut = HIGH;
Expand Down Expand Up @@ -334,7 +335,7 @@ DMXSerialClass2 DMXSerial2;
void _DMXSerialBaud(uint16_t baud_setting, uint8_t format);
void _DMXSerialWriteByte(uint8_t data);

void respondMessage(boolean isHandled, uint16_t nackReason = E120_NR_UNKNOWN_PID);
void respondMessage(bool8 isHandled, uint16_t nackReason = E120_NR_UNKNOWN_PID);
int random255();

// ----- Class implementation -----
Expand Down Expand Up @@ -453,7 +454,7 @@ void DMXSerialClass2::attachRDMCallback(RDMCallbackFunction newFunction)
// some functions to hide the internal variables from beeing changed

unsigned long DMXSerialClass2::noDataSince() { return(millis() - _gotLastPacket);}
boolean DMXSerialClass2::isIdentifyMode() { return(_identifyMode); }
bool8 DMXSerialClass2::isIdentifyMode() { return(_identifyMode); }
uint16_t DMXSerialClass2::getStartAddress() { return(_startAddress); }
uint16_t DMXSerialClass2::getFootprint() { return(_initData->footprint); }

Expand All @@ -468,10 +469,10 @@ void DMXSerialClass2::tick(void)
_rdmAvailable = false;

// respond to RDM commands now.
boolean packetIsForMe = false;
boolean packetIsForGroup = false;
boolean packetIsForAll = false;
boolean isHandled = false;
bool8 packetIsForMe = false;
bool8 packetIsForGroup = false;
bool8 packetIsForAll = false;
bool8 isHandled = false;

struct RDMDATA *rdm = &_rdm.packet;

Expand Down Expand Up @@ -600,7 +601,7 @@ void DMXSerialClass2::term(void)
// manufacturer label, DMX Start address.
// When parameters are chenged by a SET command they are persisted into EEPROM.
// When doRespond is true, send an answer back to the controller node.
void DMXSerialClass2::_processRDMMessage(byte CmdClass, uint16_t Parameter, boolean handled, boolean doRespond)
void DMXSerialClass2::_processRDMMessage(byte CmdClass, uint16_t Parameter, bool8 handled, bool8 doRespond)
{
uint16_t nackReason = E120_NR_UNKNOWN_PID;

Expand Down Expand Up @@ -983,7 +984,7 @@ ISR(USARTn_TX_vect)


// send back original Message including changed data in some cases
void respondMessage(boolean isHandled, uint16_t nackReason)
void respondMessage(bool8 isHandled, uint16_t nackReason)
{
int bufferLen;
uint16_t checkSum = 0;
Expand Down
14 changes: 8 additions & 6 deletions DMXSerial2.h → src/DMXSerial2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// 22.01.2013 first published version to support RDM
// 01.03.2013 finished some "TIMING" topics
// 08.03.2013 finished as a library
// 12.04.2015 making library Arduino 1.6.x compatible
// 12.04.2015 change of using datatype boolean to bool8.
// - - - - -

#ifndef DmxSerial_h
Expand All @@ -33,7 +35,7 @@

// ----- Types -----

typedef uint8_t boolean;
typedef uint8_t bool8;
typedef uint8_t byte;


Expand Down Expand Up @@ -83,7 +85,7 @@ struct RDMDATA {
// ----- Callback function types -----

extern "C" {
typedef boolean (*RDMCallbackFunction)(struct RDMDATA *buffer, uint16_t *nackReason);
typedef bool8 (*RDMCallbackFunction)(struct RDMDATA *buffer, uint16_t *nackReason);
}

// ----- Library Class -----
Expand Down Expand Up @@ -131,7 +133,7 @@ class DMXSerialClass2
// ----- RDM specific members -----

// Return true when identify mode was set on by controller.
boolean isIdentifyMode();
bool8 isIdentifyMode();

// Returns the Device ID. Copies the UID to the buffer passed through the uid argument.
void getDeviceID(DEVICEID id);
Expand All @@ -155,13 +157,13 @@ class DMXSerialClass2
char deviceLabel[DMXSERIAL_MAX_RDM_STRING_LENGTH];

// don't use that method from extern.
void _processRDMMessage(byte CmdClass, uint16_t Parameter, boolean isHandled);
void _processRDMMessage(byte CmdClass, uint16_t Parameter, bool8 isHandled);

// save all data to EEPROM
void _saveEEPRom();
private:
// process a relevant message
void _processRDMMessage(byte CmdClass, uint16_t Parameter, boolean isHandled, boolean doRespond);
void _processRDMMessage(byte CmdClass, uint16_t Parameter, bool8 isHandled, bool8 doRespond);

// common internal initialization function.
void _baseInit();
Expand All @@ -174,7 +176,7 @@ class DMXSerialClass2

// intern parameter settings
const char *_softwareLabel;
boolean _identifyMode;
bool8 _identifyMode;
uint16_t _startAddress;
}; // class DMXSerialClass2

Expand Down
File renamed without changes.

0 comments on commit 47285c0

Please sign in to comment.