Solved: LG air conditioning codes

adis:
Hi,

Below is the test program and a library I wrote in january.
I did my best to make it as clear as possible.

Regards,
Adi

#include <LG.h>

#include <IRremote.h>

// the LG code generator object

// the IR emitter object
IRsend irsend;

void setup()
{
Serial.begin(9600);
Serial.println("Start");

// wait 5 seconds
//delay(5000);
//LG LG(mode_heating,fan_4,30,state_on);
//LG LG(mode_heating,fan_4,30,state_off);
LG LG(mode_cooling,fan_1,18 ,state_on);

LG.debug();
// change the state
//LG.setState(STATE_off);
// send the code

irsend.sendRaw(LG.codes,LG_buffer_size,38);
//
Serial.println("End");

// wait 10 seconds
//delay(10000);

// change the state
//LG.setState(STATE_on);
// send the code
//irsend.sendRaw(LG.codes,LG_buffer_size,38);
}

void loop() {}




LG.h


#ifndef LG_h
#define LG_h
#include <WProgram.h>

#define first_byte 136 //b10001000

#define state_on 0
#define state_off 24 //b11000
#define state_change_mode 1

#define mode_heating 4 //b100
#define mode_auto 3 //b011
#define mode_dehuidification 1 //b001
#define mode_cooling 0
#define mode_none 0

#define temperature_offset 15

#define fan_1 1
#define fan_2 0
#define fan_3 2
#define fan_4 4 //b100
#define fan_none 5 //b101

#define first_high 8271
#define first_low 4298
#define zero_and_one_high 439
#define zero_low 647
#define one_low 1709

#define LG_buffer_size 59

class LG
{
public:
// fields
unsigned int codes[LG_buffer_size];
// methods
// setter
LG(int _mode,
int _fan,
int _temperature,
int _state);
// getter
// debugging
void debug();
private:
// fields
byte crc;
// methods
void FillBuffer(byte _pos, byte _bit, byte _value);
};

#endif;



LG.cpp


#include "LG.h"
LG::LG(int _mode,
int _fan,
int _temperature,
int _state)
{
// set sync
codes[0] = first_high;
codes[1] = first_low;
crc = 0;
FillBuffer(0,8,first_byte);
FillBuffer(8,5,_state);
if(_state==state_off)
FillBuffer(13,3,mode_none);
else
FillBuffer(13,3,_mode);
if(_state==state_off)
FillBuffer(16,4,0);
else
FillBuffer(16,4,(byte)_temperature-temperature_offset);
FillBuffer(20,1,0); //jet
if(_state==state_off)
FillBuffer(21,3,fan_none);
else
FillBuffer(21,3,_fan);
FillBuffer(24,4,crc);
codes[LG_buffer_size-1] = zero_and_one_high;
}

void LG::FillBuffer(byte _pos, byte _bits, byte _value){
for (int i=_bits;i>0;i--){
codes[2+2*(_pos+_bits-i)] = zero_and_one_high;
codes[2+2*(_pos+_bits-i)+1] = (bitRead(_value,i-1)==1?one_low:zero_low);
if(bitRead(_value,i-1)==1){
byte bitset = 0;
bitSet(bitset,(128+i-_pos-_bits-1)%4);
crc = crc + bitset;
}
}
}
void LG::debug()
{
for(byte i=0;i<LG_buffer_size;i++){
Serial.print(codes[i],DEC);
Serial.print(",");
}
}

It is something wrong with the code above?

Arduino: 1.5.7 (Mac OS X), Board: "Arduino Uno"

Build options changed, rebuilding all
Using library LG in folder: /Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/libraries/LG (legacy)
Using library IRremote in folder: /Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/libraries/IRremote (legacy)

/Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=157 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/libraries/LG -I/Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/libraries/IRremote /var/folders/10/07l7h8mx39n1bs7klbmdzvv00000gn/T/build7630953899009137011.tmp/sketch_sep08a.cpp -o /var/folders/10/07l7h8mx39n1bs7klbmdzvv00000gn/T/build7630953899009137011.tmp/sketch_sep08a.cpp.o
In file included from sketch_sep08a.ino:2:0:
sketch_sep08a.ino: In function 'void setup()':
/Users/adrian/Documents/Programming X/Arduino.app/Contents/Java/libraries/IRremote/IRremote.h:50:12: error: expected ';' before numeric constant
#define LG 12
^
sketch_sep08a.ino:19:4: note: in expansion of macro 'LG'
sketch_sep08a.ino:22:4: error: request for member 'debug' in '12', which is of non-class type 'int'
sketch_sep08a.ino:27:19: error: request for member 'codes' in '12', which is of non-class type 'int'